mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
vkd3d-shader/ir: Validate the control point index when it is statically known.
This commit is contained in:
parent
a06e664730
commit
82963035e9
Notes:
Henri Verbeet
2024-12-04 14:44:22 +01:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1295
@ -7195,6 +7195,7 @@ static void vsir_validate_register_without_indices(struct validation_context *ct
|
|||||||
static void vsir_validate_io_register(struct validation_context *ctx,
|
static void vsir_validate_io_register(struct validation_context *ctx,
|
||||||
const struct vkd3d_shader_register *reg)
|
const struct vkd3d_shader_register *reg)
|
||||||
{
|
{
|
||||||
|
unsigned int control_point_count = 0, control_point_index;
|
||||||
const struct shader_signature *signature;
|
const struct shader_signature *signature;
|
||||||
bool has_control_point = false;
|
bool has_control_point = false;
|
||||||
|
|
||||||
@ -7209,6 +7210,7 @@ static void vsir_validate_io_register(struct validation_context *ctx,
|
|||||||
case VKD3D_SHADER_TYPE_HULL:
|
case VKD3D_SHADER_TYPE_HULL:
|
||||||
case VKD3D_SHADER_TYPE_DOMAIN:
|
case VKD3D_SHADER_TYPE_DOMAIN:
|
||||||
has_control_point = true;
|
has_control_point = true;
|
||||||
|
control_point_count = ctx->program->input_control_point_count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -7225,6 +7227,7 @@ static void vsir_validate_io_register(struct validation_context *ctx,
|
|||||||
{
|
{
|
||||||
signature = &ctx->program->output_signature;
|
signature = &ctx->program->output_signature;
|
||||||
has_control_point = ctx->program->normalisation_level >= VSIR_NORMALISED_HULL_CONTROL_POINT_IO;
|
has_control_point = ctx->program->normalisation_level >= VSIR_NORMALISED_HULL_CONTROL_POINT_IO;
|
||||||
|
control_point_count = ctx->program->output_control_point_count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -7241,11 +7244,13 @@ static void vsir_validate_io_register(struct validation_context *ctx,
|
|||||||
case VKD3DSPR_INCONTROLPOINT:
|
case VKD3DSPR_INCONTROLPOINT:
|
||||||
signature = &ctx->program->input_signature;
|
signature = &ctx->program->input_signature;
|
||||||
has_control_point = true;
|
has_control_point = true;
|
||||||
|
control_point_count = ctx->program->input_control_point_count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VKD3DSPR_OUTCONTROLPOINT:
|
case VKD3DSPR_OUTCONTROLPOINT:
|
||||||
signature = &ctx->program->output_signature;
|
signature = &ctx->program->output_signature;
|
||||||
has_control_point = true;
|
has_control_point = true;
|
||||||
|
control_point_count = ctx->program->output_control_point_count;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VKD3DSPR_PATCHCONST:
|
case VKD3DSPR_PATCHCONST:
|
||||||
@ -7262,6 +7267,8 @@ static void vsir_validate_io_register(struct validation_context *ctx,
|
|||||||
* allowed to have a relative address. */
|
* allowed to have a relative address. */
|
||||||
unsigned int expected_idx_count = 1 + !!has_control_point;
|
unsigned int expected_idx_count = 1 + !!has_control_point;
|
||||||
|
|
||||||
|
control_point_index = 0;
|
||||||
|
|
||||||
if (reg->idx_count != expected_idx_count)
|
if (reg->idx_count != expected_idx_count)
|
||||||
{
|
{
|
||||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
|
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX_COUNT,
|
||||||
@ -7280,7 +7287,7 @@ static void vsir_validate_io_register(struct validation_context *ctx,
|
|||||||
/* If the signature element is not an array, indices are
|
/* If the signature element is not an array, indices are
|
||||||
* [signature] or [control point, signature]. If the signature
|
* [signature] or [control point, signature]. If the signature
|
||||||
* element is an array, indices are [array, signature] or
|
* element is an array, indices are [array, signature] or
|
||||||
* [control point, array, signature]. In any case `signature' is
|
* [array, control point, signature]. In any case `signature' is
|
||||||
* not allowed to have a relative address, while the others are.
|
* not allowed to have a relative address, while the others are.
|
||||||
*/
|
*/
|
||||||
if (reg->idx_count < 1)
|
if (reg->idx_count < 1)
|
||||||
@ -7314,6 +7321,7 @@ static void vsir_validate_io_register(struct validation_context *ctx,
|
|||||||
is_array = true;
|
is_array = true;
|
||||||
|
|
||||||
expected_idx_count = 1 + !!has_control_point + !!is_array;
|
expected_idx_count = 1 + !!has_control_point + !!is_array;
|
||||||
|
control_point_index = !!is_array;
|
||||||
|
|
||||||
if (reg->idx_count != expected_idx_count)
|
if (reg->idx_count != expected_idx_count)
|
||||||
{
|
{
|
||||||
@ -7323,6 +7331,12 @@ static void vsir_validate_io_register(struct validation_context *ctx,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (has_control_point && !reg->idx[control_point_index].rel_addr
|
||||||
|
&& reg->idx[control_point_index].offset >= control_point_count)
|
||||||
|
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX,
|
||||||
|
"Control point index %u exceeds the control point count %u in a register of type %#x.",
|
||||||
|
reg->idx[control_point_index].offset, control_point_count, reg->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vsir_validate_temp_register(struct validation_context *ctx,
|
static void vsir_validate_temp_register(struct validation_context *ctx,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user