mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/ir: Store the temporary register count in struct vsir_program.
This commit is contained in:
parent
94ca46916a
commit
adc02eada8
Notes:
Alexandre Julliard
2024-01-22 22:53:09 +01:00
Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/585
@ -765,13 +765,13 @@ static void record_constant_register(struct vkd3d_shader_sm1_parser *sm1,
|
|||||||
static void shader_sm1_scan_register(struct vkd3d_shader_sm1_parser *sm1,
|
static void shader_sm1_scan_register(struct vkd3d_shader_sm1_parser *sm1,
|
||||||
const struct vkd3d_shader_register *reg, unsigned int mask, bool from_def)
|
const struct vkd3d_shader_register *reg, unsigned int mask, bool from_def)
|
||||||
{
|
{
|
||||||
struct vkd3d_shader_desc *desc = &sm1->p.shader_desc;
|
struct vsir_program *program = &sm1->p.program;
|
||||||
uint32_t register_index = reg->idx[0].offset;
|
uint32_t register_index = reg->idx[0].offset;
|
||||||
|
|
||||||
switch (reg->type)
|
switch (reg->type)
|
||||||
{
|
{
|
||||||
case VKD3DSPR_TEMP:
|
case VKD3DSPR_TEMP:
|
||||||
desc->temp_count = max(desc->temp_count, register_index + 1);
|
program->temp_count = max(program->temp_count, register_index + 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VKD3DSPR_CONST:
|
case VKD3DSPR_CONST:
|
||||||
|
@ -2369,7 +2369,7 @@ static void vsir_validate_register(struct validation_context *ctx,
|
|||||||
|
|
||||||
/* SM1-3 shaders do not include a DCL_TEMPS instruction. */
|
/* SM1-3 shaders do not include a DCL_TEMPS instruction. */
|
||||||
if (ctx->program->shader_version.major <= 3)
|
if (ctx->program->shader_version.major <= 3)
|
||||||
temp_count = ctx->parser->shader_desc.temp_count;
|
temp_count = ctx->program->temp_count;
|
||||||
|
|
||||||
if (reg->type >= VKD3DSPR_COUNT)
|
if (reg->type >= VKD3DSPR_COUNT)
|
||||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_REGISTER_TYPE, "Invalid register type %#x.",
|
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_REGISTER_TYPE, "Invalid register type %#x.",
|
||||||
@ -2421,10 +2421,10 @@ static void vsir_validate_register(struct validation_context *ctx,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parser->shader_desc.temp_count might be smaller then
|
/* program->temp_count might be smaller then temp_count if the
|
||||||
* temp_count if the parser made a mistake; we still don't
|
* parser made a mistake; we still don't want to overflow the
|
||||||
* want to overflow the array. */
|
* array. */
|
||||||
if (reg->idx[0].offset >= ctx->parser->shader_desc.temp_count)
|
if (reg->idx[0].offset >= ctx->program->temp_count)
|
||||||
break;
|
break;
|
||||||
data = &ctx->temps[reg->idx[0].offset];
|
data = &ctx->temps[reg->idx[0].offset];
|
||||||
|
|
||||||
@ -2788,9 +2788,10 @@ static void vsir_validate_instruction(struct validation_context *ctx)
|
|||||||
vsir_validate_src_count(ctx, instruction, 0);
|
vsir_validate_src_count(ctx, instruction, 0);
|
||||||
if (ctx->dcl_temps_found)
|
if (ctx->dcl_temps_found)
|
||||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_DUPLICATE_DCL_TEMPS, "Duplicate DCL_TEMPS instruction.");
|
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_DUPLICATE_DCL_TEMPS, "Duplicate DCL_TEMPS instruction.");
|
||||||
if (instruction->declaration.count > ctx->parser->shader_desc.temp_count)
|
if (instruction->declaration.count > ctx->program->temp_count)
|
||||||
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DCL_TEMPS, "Invalid DCL_TEMPS count %u, expected at most %u.",
|
validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DCL_TEMPS,
|
||||||
instruction->declaration.count, ctx->parser->shader_desc.temp_count);
|
"Invalid DCL_TEMPS count %u, expected at most %u.",
|
||||||
|
instruction->declaration.count, ctx->program->temp_count);
|
||||||
ctx->dcl_temps_found = true;
|
ctx->dcl_temps_found = true;
|
||||||
ctx->temp_count = instruction->declaration.count;
|
ctx->temp_count = instruction->declaration.count;
|
||||||
break;
|
break;
|
||||||
@ -3005,7 +3006,7 @@ enum vkd3d_result vsir_validate(struct vkd3d_shader_parser *parser)
|
|||||||
if (!(parser->config_flags & VKD3D_SHADER_CONFIG_FLAG_FORCE_VALIDATION))
|
if (!(parser->config_flags & VKD3D_SHADER_CONFIG_FLAG_FORCE_VALIDATION))
|
||||||
return VKD3D_OK;
|
return VKD3D_OK;
|
||||||
|
|
||||||
if (!(ctx.temps = vkd3d_calloc(parser->shader_desc.temp_count, sizeof(*ctx.temps))))
|
if (!(ctx.temps = vkd3d_calloc(ctx.program->temp_count, sizeof(*ctx.temps))))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(ctx.ssas = vkd3d_calloc(ctx.program->ssa_count, sizeof(*ctx.ssas))))
|
if (!(ctx.ssas = vkd3d_calloc(ctx.program->ssa_count, sizeof(*ctx.ssas))))
|
||||||
|
@ -9687,8 +9687,8 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
|
|||||||
if ((result = vkd3d_shader_normalise(parser, compile_info)) < 0)
|
if ((result = vkd3d_shader_normalise(parser, compile_info)) < 0)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
if (parser->shader_desc.temp_count)
|
if (program->temp_count)
|
||||||
spirv_compiler_emit_temps(compiler, parser->shader_desc.temp_count);
|
spirv_compiler_emit_temps(compiler, program->temp_count);
|
||||||
if (program->ssa_count)
|
if (program->ssa_count)
|
||||||
spirv_compiler_allocate_ssa_register_ids(compiler, program->ssa_count);
|
spirv_compiler_allocate_ssa_register_ids(compiler, program->ssa_count);
|
||||||
|
|
||||||
|
@ -1072,7 +1072,7 @@ static void shader_sm4_read_declaration_count(struct vkd3d_shader_instruction *i
|
|||||||
{
|
{
|
||||||
ins->declaration.count = *tokens;
|
ins->declaration.count = *tokens;
|
||||||
if (opcode == VKD3D_SM4_OP_DCL_TEMPS)
|
if (opcode == VKD3D_SM4_OP_DCL_TEMPS)
|
||||||
priv->p.shader_desc.temp_count = max(priv->p.shader_desc.temp_count, *tokens);
|
priv->p.program.temp_count = max(priv->p.program.temp_count, *tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void shader_sm4_read_declaration_dst(struct vkd3d_shader_instruction *ins, uint32_t opcode,
|
static void shader_sm4_read_declaration_dst(struct vkd3d_shader_instruction *ins, uint32_t opcode,
|
||||||
|
@ -1022,7 +1022,6 @@ struct vkd3d_shader_desc
|
|||||||
|
|
||||||
unsigned int input_control_point_count, output_control_point_count;
|
unsigned int input_control_point_count, output_control_point_count;
|
||||||
|
|
||||||
uint32_t temp_count;
|
|
||||||
unsigned int block_count;
|
unsigned int block_count;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
@ -1272,6 +1271,7 @@ struct vsir_program
|
|||||||
struct vkd3d_shader_version shader_version;
|
struct vkd3d_shader_version shader_version;
|
||||||
struct vkd3d_shader_instruction_array instructions;
|
struct vkd3d_shader_instruction_array instructions;
|
||||||
|
|
||||||
|
unsigned int temp_count;
|
||||||
unsigned int ssa_count;
|
unsigned int ssa_count;
|
||||||
bool use_vocp;
|
bool use_vocp;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user