vkd3d-shader/ir: Store the block count in struct vsir_program.

This commit is contained in:
Henri Verbeet 2024-01-18 20:34:52 +01:00 committed by Alexandre Julliard
parent 98c6e85b33
commit f3c7d2d05c
Notes: Alexandre Julliard 2024-01-23 23:05:46 +01:00
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/594
4 changed files with 12 additions and 11 deletions

View File

@ -5527,7 +5527,7 @@ static enum vkd3d_result sm6_function_emit_blocks(const struct sm6_function *fun
{ {
unsigned int i; unsigned int i;
sm6->p.shader_desc.block_count = function->block_count; sm6->p.program.block_count = function->block_count;
for (i = 0; i < function->block_count; ++i) for (i = 0; i < function->block_count; ++i)
{ {

View File

@ -2213,6 +2213,7 @@ static enum vkd3d_result cf_flattener_iterate_instruction_array(struct cf_flatte
static enum vkd3d_result flatten_control_flow_constructs(struct vkd3d_shader_parser *parser) static enum vkd3d_result flatten_control_flow_constructs(struct vkd3d_shader_parser *parser)
{ {
struct vsir_program *program = &parser->program;
struct cf_flattener flattener = {0}; struct cf_flattener flattener = {0};
enum vkd3d_result result; enum vkd3d_result result;
@ -2222,10 +2223,10 @@ static enum vkd3d_result flatten_control_flow_constructs(struct vkd3d_shader_par
if (result >= 0) if (result >= 0)
{ {
vkd3d_free(parser->program.instructions.elements); vkd3d_free(parser->program.instructions.elements);
parser->program.instructions.elements = flattener.instructions; program->instructions.elements = flattener.instructions;
parser->program.instructions.capacity = flattener.instruction_capacity; program->instructions.capacity = flattener.instruction_capacity;
parser->program.instructions.count = flattener.instruction_count; program->instructions.count = flattener.instruction_count;
parser->shader_desc.block_count = flattener.block_id; program->block_count = flattener.block_id;
} }
else else
{ {
@ -2511,9 +2512,10 @@ static void vsir_validate_register(struct validation_context *ctx,
/* Index == 0 is invalid, but it is temporarily allowed /* Index == 0 is invalid, but it is temporarily allowed
* for intermediate stages. Once we support validation * for intermediate stages. Once we support validation
* dialects we can selectively check for that. */ * dialects we can selectively check for that. */
if (reg->idx[0].offset > ctx->parser->shader_desc.block_count) if (reg->idx[0].offset > ctx->program->block_count)
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX, "LABEL register index %u exceeds the maximum count %u.", validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_INDEX,
reg->idx[0].offset, ctx->parser->shader_desc.block_count); "LABEL register index %u exceeds the maximum count %u.",
reg->idx[0].offset, ctx->program->block_count);
break; break;
case VKD3DSPR_NULL: case VKD3DSPR_NULL:

View File

@ -9790,7 +9790,7 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
compiler->location.column = 0; compiler->location.column = 0;
compiler->location.line = 1; compiler->location.line = 1;
if (parser->shader_desc.block_count && !spirv_compiler_init_blocks(compiler, parser->shader_desc.block_count)) if (program->block_count && !spirv_compiler_init_blocks(compiler, program->block_count))
return VKD3D_ERROR_OUT_OF_MEMORY; return VKD3D_ERROR_OUT_OF_MEMORY;
instructions = program->instructions; instructions = program->instructions;

View File

@ -1020,8 +1020,6 @@ struct vkd3d_shader_desc
struct shader_signature output_signature; struct shader_signature output_signature;
struct shader_signature patch_constant_signature; struct shader_signature patch_constant_signature;
unsigned int block_count;
struct struct
{ {
uint32_t used, external; uint32_t used, external;
@ -1270,6 +1268,7 @@ struct vsir_program
struct vkd3d_shader_instruction_array instructions; struct vkd3d_shader_instruction_array instructions;
unsigned int input_control_point_count, output_control_point_count; unsigned int input_control_point_count, output_control_point_count;
unsigned int block_count;
unsigned int temp_count; unsigned int temp_count;
unsigned int ssa_count; unsigned int ssa_count;
bool use_vocp; bool use_vocp;