diff --git a/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d-shader/d3d_asm.c index c8993a1f..bc28aebe 100644 --- a/libs/vkd3d-shader/d3d_asm.c +++ b/libs/vkd3d-shader/d3d_asm.c @@ -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[] = diff --git a/libs/vkd3d-shader/dxil.c b/libs/vkd3d-shader/dxil.c index 234f74b2..570af5ec 100644 --- a/libs/vkd3d-shader/dxil.c +++ b/libs/vkd3d-shader/dxil.c @@ -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) diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index e775f108..a2a090e1 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -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); diff --git a/libs/vkd3d-shader/ir.c b/libs/vkd3d-shader/ir.c index 8cccc05f..19dc36d9 100644 --- a/libs/vkd3d-shader/ir.c +++ b/libs/vkd3d-shader/ir.c @@ -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: diff --git a/libs/vkd3d-shader/msl.c b/libs/vkd3d-shader/msl.c index 3c682432..a0dbb063 100644 --- a/libs/vkd3d-shader/msl.c +++ b/libs/vkd3d-shader/msl.c @@ -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"); diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c index 6bbac961..ca7ca0ae 100644 --- a/libs/vkd3d-shader/spirv.c +++ b/libs/vkd3d-shader/spirv.c @@ -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); diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index b4bf75cc..67ae3247 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -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, diff --git a/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d-shader/vkd3d_shader_private.h index d4094598..00d1d858 100644 --- a/libs/vkd3d-shader/vkd3d_shader_private.h +++ b/libs/vkd3d-shader/vkd3d_shader_private.h @@ -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;