mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/ir: Store the global flags in struct vsir_program.
This commit is contained in:
parent
21e9029177
commit
1113d24a70
Notes:
Henri Verbeet
2024-10-22 20:55:52 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1207
@ -393,14 +393,13 @@ static unsigned int shader_get_float_offset(enum vkd3d_shader_register_type regi
|
||||
}
|
||||
}
|
||||
|
||||
static void shader_dump_global_flags(struct vkd3d_d3d_asm_compiler *compiler,
|
||||
enum vkd3d_shader_global_flags global_flags)
|
||||
static void shader_dump_global_flags(struct vkd3d_d3d_asm_compiler *compiler, enum vsir_global_flags global_flags)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
static const struct
|
||||
{
|
||||
enum vkd3d_shader_global_flags flag;
|
||||
enum vsir_global_flags flag;
|
||||
const char *name;
|
||||
}
|
||||
global_flag_info[] =
|
||||
|
@ -9564,7 +9564,7 @@ static enum vkd3d_result sm6_parser_signatures_init(struct sm6_parser *sm6, cons
|
||||
|
||||
static void sm6_parser_emit_global_flags(struct sm6_parser *sm6, const struct sm6_metadata_value *m)
|
||||
{
|
||||
enum vkd3d_shader_global_flags global_flags, mask, rotated_flags;
|
||||
enum vsir_global_flags global_flags, mask, rotated_flags;
|
||||
struct vkd3d_shader_instruction *ins;
|
||||
|
||||
if (!sm6_metadata_get_uint64_value(sm6, m, (uint64_t*)&global_flags))
|
||||
@ -9574,7 +9574,7 @@ static void sm6_parser_emit_global_flags(struct sm6_parser *sm6, const struct sm
|
||||
"Global flags metadata value is not an integer.");
|
||||
return;
|
||||
}
|
||||
/* Rotate SKIP_OPTIMIZATION from bit 0 to bit 4 to match vkd3d_shader_global_flags. */
|
||||
/* Rotate SKIP_OPTIMIZATION from bit 0 to bit 4 to match vsir_global_flags. */
|
||||
mask = (VKD3DSGF_SKIP_OPTIMIZATION << 1) - 1;
|
||||
rotated_flags = global_flags & mask;
|
||||
rotated_flags = (rotated_flags >> 1) | ((rotated_flags & 1) << 4);
|
||||
@ -9582,6 +9582,7 @@ static void sm6_parser_emit_global_flags(struct sm6_parser *sm6, const struct sm
|
||||
|
||||
ins = sm6_parser_add_instruction(sm6, VKD3DSIH_DCL_GLOBAL_FLAGS);
|
||||
ins->declaration.global_flags = global_flags;
|
||||
sm6->p.program->global_flags = global_flags;
|
||||
}
|
||||
|
||||
static enum vkd3d_result sm6_parser_emit_thread_group(struct sm6_parser *sm6, const struct sm6_metadata_value *m)
|
||||
|
@ -2210,6 +2210,10 @@ static void shader_glsl_generate_declarations(struct vkd3d_glsl_generator *gen)
|
||||
group_size->x, group_size->y, group_size->z);
|
||||
}
|
||||
|
||||
if (program->global_flags)
|
||||
vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled global flags %#"PRIx64".", (uint64_t)program->global_flags);
|
||||
|
||||
shader_glsl_generate_descriptor_declarations(gen);
|
||||
shader_glsl_generate_input_declarations(gen);
|
||||
shader_glsl_generate_output_declarations(gen);
|
||||
|
@ -699,6 +699,7 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr
|
||||
|
||||
case VKD3DSIH_DCL:
|
||||
case VKD3DSIH_DCL_CONSTANT_BUFFER:
|
||||
case VKD3DSIH_DCL_GLOBAL_FLAGS:
|
||||
case VKD3DSIH_DCL_SAMPLER:
|
||||
case VKD3DSIH_DCL_TEMPS:
|
||||
case VKD3DSIH_DCL_THREAD_GROUP:
|
||||
|
@ -785,6 +785,10 @@ static void msl_generator_generate(struct msl_generator *gen)
|
||||
|
||||
vkd3d_string_buffer_printf(gen->buffer, "/* Generated by %s. */\n\n", vkd3d_shader_get_version(NULL, NULL));
|
||||
|
||||
if (gen->program->global_flags)
|
||||
msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
||||
"Internal compiler error: Unhandled global flags %#"PRIx64".", (uint64_t)gen->program->global_flags);
|
||||
|
||||
vkd3d_string_buffer_printf(gen->buffer, "union vkd3d_vec4\n{\n");
|
||||
vkd3d_string_buffer_printf(gen->buffer, " uint4 u;\n");
|
||||
vkd3d_string_buffer_printf(gen->buffer, " int4 i;\n");
|
||||
|
@ -5912,11 +5912,8 @@ static size_t spirv_compiler_get_current_function_location(struct spirv_compiler
|
||||
return builder->main_function_location;
|
||||
}
|
||||
|
||||
static void spirv_compiler_emit_dcl_global_flags(struct spirv_compiler *compiler,
|
||||
const struct vkd3d_shader_instruction *instruction)
|
||||
static void spirv_compiler_emit_global_flags(struct spirv_compiler *compiler, enum vsir_global_flags flags)
|
||||
{
|
||||
enum vkd3d_shader_global_flags flags = instruction->declaration.global_flags;
|
||||
|
||||
if (flags & VKD3DSGF_FORCE_EARLY_DEPTH_STENCIL)
|
||||
{
|
||||
spirv_compiler_emit_execution_mode(compiler, SpvExecutionModeEarlyFragmentTests, NULL, 0);
|
||||
@ -10185,9 +10182,6 @@ static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler,
|
||||
|
||||
switch (instruction->opcode)
|
||||
{
|
||||
case VKD3DSIH_DCL_GLOBAL_FLAGS:
|
||||
spirv_compiler_emit_dcl_global_flags(compiler, instruction);
|
||||
break;
|
||||
case VKD3DSIH_DCL_INDEXABLE_TEMP:
|
||||
spirv_compiler_emit_dcl_indexable_temp(compiler, instruction);
|
||||
break;
|
||||
@ -10675,6 +10669,7 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, struct
|
||||
spirv_compiler_allocate_ssa_register_ids(compiler, program->ssa_count);
|
||||
if (compiler->shader_type == VKD3D_SHADER_TYPE_COMPUTE)
|
||||
spirv_compiler_emit_thread_group_size(compiler, &program->thread_group_size);
|
||||
spirv_compiler_emit_global_flags(compiler, program->global_flags);
|
||||
|
||||
spirv_compiler_emit_descriptor_declarations(compiler);
|
||||
|
||||
|
@ -1212,9 +1212,10 @@ static void shader_sm4_read_dcl_indexable_temp(struct vkd3d_shader_instruction *
|
||||
}
|
||||
|
||||
static void shader_sm4_read_dcl_global_flags(struct vkd3d_shader_instruction *ins, uint32_t opcode,
|
||||
uint32_t opcode_token, const uint32_t *tokens, unsigned int token_count, struct vkd3d_shader_sm4_parser *priv)
|
||||
uint32_t opcode_token, const uint32_t *tokens, unsigned int token_count, struct vkd3d_shader_sm4_parser *sm4)
|
||||
{
|
||||
ins->declaration.global_flags = (opcode_token & VKD3D_SM4_GLOBAL_FLAGS_MASK) >> VKD3D_SM4_GLOBAL_FLAGS_SHIFT;
|
||||
sm4->p.program->global_flags = ins->declaration.global_flags;
|
||||
}
|
||||
|
||||
static void shader_sm5_read_fcall(struct vkd3d_shader_instruction *ins, uint32_t opcode, uint32_t opcode_token,
|
||||
|
@ -774,7 +774,7 @@ enum vkd3d_shader_interpolation_mode
|
||||
VKD3DSIM_COUNT = 8,
|
||||
};
|
||||
|
||||
enum vkd3d_shader_global_flags
|
||||
enum vsir_global_flags
|
||||
{
|
||||
VKD3DSGF_REFACTORING_ALLOWED = 0x01,
|
||||
VKD3DSGF_ENABLE_DOUBLE_PRECISION_FLOAT_OPS = 0x02,
|
||||
@ -1247,7 +1247,7 @@ struct vkd3d_shader_instruction
|
||||
const struct vkd3d_shader_src_param *predicate;
|
||||
union
|
||||
{
|
||||
enum vkd3d_shader_global_flags global_flags;
|
||||
enum vsir_global_flags global_flags;
|
||||
struct vkd3d_shader_semantic semantic;
|
||||
struct vkd3d_shader_register_semantic register_semantic;
|
||||
struct vkd3d_shader_primitive_type primitive_type;
|
||||
@ -1420,6 +1420,7 @@ struct vsir_program
|
||||
unsigned int block_count;
|
||||
unsigned int temp_count;
|
||||
unsigned int ssa_count;
|
||||
enum vsir_global_flags global_flags;
|
||||
bool use_vocp;
|
||||
bool has_point_size;
|
||||
bool has_point_coord;
|
||||
|
Loading…
Reference in New Issue
Block a user