mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-05 17:36:25 +00:00
gpu: rework alpha-to-coverage validation
This commit is contained in:

committed by
Sam Lantinga

parent
ceb9fecfc1
commit
3343cb2147
@@ -827,12 +827,6 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline(
|
||||
SDL_assert_release(!"Format is not supported for color targets on this device!");
|
||||
return NULL;
|
||||
}
|
||||
if (graphicsPipelineCreateInfo->multisample_state.enable_alpha_to_coverage &&
|
||||
(IsIntegerFormat(graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].format)
|
||||
|| IsCompressedFormat(graphicsPipelineCreateInfo->target_info.color_target_descriptions[i].format))) {
|
||||
SDL_assert_release(!"Format is not compatible with alpha-to-coverage!");
|
||||
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)
|
||||
@@ -841,6 +835,8 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline(
|
||||
CHECK_BLENDFACTOR_ENUM_INVALID(blend_state->src_alpha_blendfactor, NULL)
|
||||
CHECK_BLENDFACTOR_ENUM_INVALID(blend_state->dst_alpha_blendfactor, NULL)
|
||||
CHECK_BLENDOP_ENUM_INVALID(blend_state->alpha_blend_op, NULL)
|
||||
|
||||
// TODO: validate that format support blending?
|
||||
}
|
||||
}
|
||||
if (graphicsPipelineCreateInfo->target_info.has_depth_stencil_target) {
|
||||
@@ -854,6 +850,18 @@ SDL_GPUGraphicsPipeline *SDL_CreateGPUGraphicsPipeline(
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (graphicsPipelineCreateInfo->multisample_state.enable_alpha_to_coverage) {
|
||||
if (graphicsPipelineCreateInfo->target_info.num_color_targets < 1) {
|
||||
SDL_assert_release(!"Alpha-to-coverage enabled but no color targets present!");
|
||||
return NULL;
|
||||
}
|
||||
if (!FormatHasAlpha(graphicsPipelineCreateInfo->target_info.color_target_descriptions[0].format)) {
|
||||
SDL_assert_release(!"Format is not compatible with alpha-to-coverage!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// TODO: validate that format supports belnding? This is only required on Metal.
|
||||
}
|
||||
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!");
|
||||
return NULL;
|
||||
|
Reference in New Issue
Block a user