diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index 34905cea2c..b3148c27d7 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -801,6 +801,10 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline( SDL_assert_release(!"Color target formats cannot be a depth format!"); return NULL; } + if (!SDL_GPUTextureSupportsFormat(device, graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].format, SDL_GPU_TEXTURETYPE_2D, SDL_GPU_TEXTUREUSAGE_COLOR_TARGET)) { + SDL_assert_release(!"Format is not supported for color targets on this device!"); + return NULL; + } if (graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].blend_state.enable_blend) { const SDL_GPUColorTargetBlendState *blend_state = &graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].blend_state; CHECK_BLENDFACTOR_ENUM_INVALID(blend_state->src_color_blendfactor, NULL) @@ -817,6 +821,10 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline( SDL_assert_release(!"Depth-stencil target format must be a depth format!"); return NULL; } + if (!SDL_GPUTextureSupportsFormat(device, graphicsPipelineCreateInfo->target_info.depth_stencil_format, SDL_GPU_TEXTURETYPE_2D, SDL_GPU_TEXTUREUSAGE_DEPTH_STENCIL_TARGET)) { + SDL_assert_release(!"Format is not supported for depth targets on this device!"); + return NULL; + } } if (graphicsPipelineCreateInfo->vertex_input_state.num_vertex_buffers > 0 && graphicsPipelineCreateInfo->vertex_input_state.vertex_buffer_descriptions == NULL) { SDL_assert_release(!"Vertex buffer descriptions array pointer cannot be NULL!");