+ for (i = reg->idx_count; i < ARRAY_SIZE(reg->idx); ++i) + { + if (reg->idx[i].offset != ~0u || reg->idx[i].rel_addr != NULL) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, "Unused index %u has offset %#x and non-NULL relative address.", + i, reg->idx[i].offset); + }
I don't know about that one. There are probably still a few places left that depend on this property, but we should get rid of them and just use "idx_count".
+static void vsir_validate_dst_count(struct validation_context *ctx, + const struct vkd3d_shader_instruction *instruction, unsigned int count) +{ + if (instruction->dst_count != 0) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DEST_COUNT, + "Invalid destination count %u for an instruction of type %#x.", instruction->dst_count, instruction->handler_idx); +} + +static void vsir_validate_src_count(struct validation_context *ctx, + const struct vkd3d_shader_instruction *instruction, unsigned int count) +{ + if (instruction->src_count != 0) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_SOURCE_COUNT, + "Invalid source count %u for an instruction of type %#x.", instruction->src_count, instruction->handler_idx); +}
"count" is not used here.
+ /* There is not DCL_TEMPS in SM1-3. */ + if (vkd3d_shader_ver_ge(&ctx->parser->shader_version, 4, 0) && reg->idx_count >= 1 && reg->idx[0].offset >= ctx->temp_count) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, "TEMP register index %u exceeds the declared count %u.", + reg->idx[0].offset, ctx->temp_count); + break;
We do have "ctx->parser->shader_desc.temp_count" though, and that's what we should use here.
case VKD3DSIH_DCL_TEMPS: vsir_validate_dst_count(ctx, instruction, 0); vsir_validate_src_count(ctx, instruction, 0); + /* TODO Check that each phase in a hull shader has a at + * most one occurrence. */ + if (ctx->dcl_temps_found && ctx->parser->shader_version.type != VKD3D_SHADER_TYPE_HULL) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_DUPLICATE_DCL_TEMPS, "Duplicate DCL_TEMPS instruction."); + ctx->dcl_temps_found = true; + ctx->temp_count = instruction->declaration.count; break;
And we should probably just validate that DCL_TEMPS is consistent with "ctx->parser->shader_desc.temp_count" here.