vkd3d-shader/ir: Validate tessellation declarations.

This commit is contained in:
Conor McCarthy 2024-04-05 13:54:25 +10:00 committed by Alexandre Julliard
parent e1abf1e48a
commit 0515482e82
Notes: Alexandre Julliard 2024-04-16 23:25:27 +02:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/767
2 changed files with 41 additions and 0 deletions

View File

@ -5433,6 +5433,46 @@ static void vsir_validate_instruction(struct validation_context *ctx)
ctx->dcl_temps_found = false;
return;
case VKD3DSIH_DCL_HS_MAX_TESSFACTOR:
/* Exclude non-finite values. */
if (!(instruction->declaration.max_tessellation_factor >= 1.0f
&& instruction->declaration.max_tessellation_factor <= 64.0f))
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_TESSELLATION, "Max tessellation factor %f is invalid.",
instruction->declaration.max_tessellation_factor);
return;
/* The DXIL parser can generate these outside phases, but this is not an issue. */
case VKD3DSIH_DCL_INPUT:
case VKD3DSIH_DCL_OUTPUT:
return;
case VKD3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT:
if (!instruction->declaration.count || instruction->declaration.count > 32)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_TESSELLATION, "Output control point count %u is invalid.",
instruction->declaration.count);
return;
case VKD3DSIH_DCL_TESSELLATOR_DOMAIN:
if (instruction->declaration.tessellator_domain == VKD3D_TESSELLATOR_DOMAIN_INVALID
|| instruction->declaration.tessellator_domain >= VKD3D_TESSELLATOR_DOMAIN_COUNT)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_TESSELLATION,
"Tessellator domain %#x is invalid.", instruction->declaration.tessellator_domain);
return;
case VKD3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE:
if (!instruction->declaration.tessellator_output_primitive
|| instruction->declaration.tessellator_output_primitive > VKD3D_SHADER_TESSELLATOR_OUTPUT_TRIANGLE_CCW)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_TESSELLATION,
"Tessellator output primitive %#x is invalid.", instruction->declaration.tessellator_output_primitive);
return;
case VKD3DSIH_DCL_TESSELLATOR_PARTITIONING:
if (!instruction->declaration.tessellator_partitioning
|| instruction->declaration.tessellator_partitioning > VKD3D_SHADER_TESSELLATOR_PARTITIONING_FRACTIONAL_EVEN)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_TESSELLATION,
"Tessellator partitioning %#x is invalid.", instruction->declaration.tessellator_partitioning);
return;
default:
break;
}

View File

@ -220,6 +220,7 @@ enum vkd3d_shader_error
VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX = 9015,
VKD3D_SHADER_ERROR_VSIR_INVALID_CONTROL_FLOW = 9016,
VKD3D_SHADER_ERROR_VSIR_INVALID_SSA_USAGE = 9017,
VKD3D_SHADER_ERROR_VSIR_INVALID_TESSELLATION = 9018,
VKD3D_SHADER_WARNING_VSIR_DYNAMIC_DESCRIPTOR_ARRAY = 9300,
};