Skip to content

Commit 4294c06

Browse files
committed
GPU: Check texture format support in pipeline creation
1 parent 31dd4fe commit 4294c06

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/gpu/SDL_gpu.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,10 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline(
801801
SDL_assert_release(!"Color target formats cannot be a depth format!");
802802
return NULL;
803803
}
804+
if (!SDL_GPUTextureSupportsFormat(device, graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].format, SDL_GPU_TEXTURETYPE_2D, SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) {
805+
SDL_assert_release(!"Format is not supported for color targets on this device!");
806+
return NULL;
807+
}
804808
if (graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].blend_state.enable_blend) {
805809
const SDL_GPUColorTargetBlendState *blend_state = &graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].blend_state;
806810
CHECK_BLENDFACTOR_ENUM_INVALID(blend_state->src_color_blendfactor, NULL)
@@ -817,6 +821,10 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline(
817821
SDL_assert_release(!"Depth-stencil target format must be a depth format!");
818822
return NULL;
819823
}
824+
if (!SDL_GPUTextureSupportsFormat(device, graphicsPipelineCreateInfo->target_info.depth_stencil_format, SDL_GPU_TEXTURETYPE_2D, SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) {
825+
SDL_assert_release(!"Format is not supported for depth targets on this device!");
826+
return NULL;
827+
}
820828
}
821829
if (graphicsPipelineCreateInfo->vertex_input_state.num_vertex_buffers > 0 && graphicsPipelineCreateInfo->vertex_input_state.vertex_buffer_descriptions == NULL) {
822830
SDL_assert_release(!"Vertex buffer descriptions array pointer cannot be NULL!");

0 commit comments

Comments
 (0)