From be94a37e23e038ecec3fef9caae308cb1c3bd3ba Mon Sep 17 00:00:00 2001 From: Giovanni Mascellani Date: Fri, 28 Mar 2025 10:51:57 +0100 Subject: [PATCH] vkd3d-shader/ir: Validate descriptor resource data types in vsir programs. --- libs/vkd3d-shader/ir.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 43af09a06..bead481a4 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -8878,6 +8878,15 @@ static void vsir_validate_descriptors(struct validation_context *ctx) validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_RESOURCE_TYPE, "Descriptor %u has invalid resource type %#x for descriptor type %#x.", i, descriptor->resource_type, descriptor->type); + + if (descriptor->resource_data_type >= VKD3D_DATA_COUNT) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Descriptor %u has invalid resource data type %#x.", i, descriptor->resource_data_type); + else if ((descriptor->resource_data_type == VKD3D_DATA_UNUSED) + != (descriptor->type == VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER)) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Descriptor %u has invalid resource data type %#x for descriptor type %#x.", + i, descriptor->resource_data_type, descriptor->type); } }