wine-staging/patches/vkd3d-latest/0004-Updated-vkd3d-to-374c5fcbdd91b6b7e6c362c79871ddf30f0.patch
2024-03-22 17:43:13 +11:00

582 lines
28 KiB
Diff

From bd4a3d1a0a0a8e60d2f51a6e113dc9095ebad586 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Thu, 14 Mar 2024 20:16:07 +1100
Subject: [PATCH] Updated vkd3d to 374c5fcbdd91b6b7e6c362c79871ddf30f0ccee2.
---
libs/vkd3d/libs/vkd3d-shader/glsl.c | 20 +--
libs/vkd3d/libs/vkd3d-shader/ir.c | 178 +++++++++++++++------------
libs/vkd3d/libs/vkd3d-shader/spirv.c | 19 +++
3 files changed, 125 insertions(+), 92 deletions(-)
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
index 7c630d181ef..da90782c814 100644
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
@@ -20,7 +20,7 @@
struct vkd3d_glsl_generator
{
- struct vkd3d_shader_version version;
+ struct vsir_program *program;
struct vkd3d_string_buffer buffer;
struct vkd3d_shader_location location;
struct vkd3d_shader_message_context *message_context;
@@ -42,7 +42,7 @@ static void VKD3D_PRINTF_FUNC(3, 4) vkd3d_glsl_compiler_error(
static void shader_glsl_ret(struct vkd3d_glsl_generator *generator,
const struct vkd3d_shader_instruction *ins)
{
- const struct vkd3d_shader_version *version = &generator->version;
+ const struct vkd3d_shader_version *version = &generator->program->shader_version;
/*
* TODO: Implement in_subroutine
@@ -76,9 +76,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *generator
}
}
-static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
- struct vsir_program *program, struct vkd3d_shader_code *out)
+static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator, struct vkd3d_shader_code *out)
{
+ const struct vkd3d_shader_instruction_array *instructions = &generator->program->instructions;
unsigned int i;
void *code;
@@ -87,9 +87,9 @@ static int vkd3d_glsl_generator_generate(struct vkd3d_glsl_generator *generator,
vkd3d_string_buffer_printf(&generator->buffer, "#version 440\n\n");
vkd3d_string_buffer_printf(&generator->buffer, "void main()\n{\n");
- for (i = 0; i < program->instructions.count; ++i)
+ for (i = 0; i < instructions->count; ++i)
{
- vkd3d_glsl_handle_instruction(generator, &program->instructions.elements[i]);
+ vkd3d_glsl_handle_instruction(generator, &instructions->elements[i]);
}
if (generator->failed)
@@ -114,10 +114,10 @@ static void vkd3d_glsl_generator_cleanup(struct vkd3d_glsl_generator *gen)
}
static void vkd3d_glsl_generator_init(struct vkd3d_glsl_generator *gen,
- const struct vkd3d_shader_version *version, struct vkd3d_shader_message_context *message_context)
+ struct vsir_program *program, struct vkd3d_shader_message_context *message_context)
{
memset(gen, 0, sizeof(*gen));
- gen->version = *version;
+ gen->program = program;
vkd3d_string_buffer_init(&gen->buffer);
gen->message_context = message_context;
}
@@ -128,8 +128,8 @@ int glsl_compile(struct vsir_program *program, struct vkd3d_shader_code *out,
struct vkd3d_glsl_generator generator;
int ret;
- vkd3d_glsl_generator_init(&generator, &program->shader_version, message_context);
- ret = vkd3d_glsl_generator_generate(&generator, program, out);
+ vkd3d_glsl_generator_init(&generator, program, message_context);
+ ret = vkd3d_glsl_generator_generate(&generator, out);
vkd3d_glsl_generator_cleanup(&generator);
return ret;
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
index 759c89957d6..0dd31af9192 100644
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
@@ -94,9 +94,8 @@ static bool vsir_instruction_init_with_params(struct vsir_program *program,
return true;
}
-static enum vkd3d_result instruction_array_lower_texkills(struct vkd3d_shader_parser *parser)
+static enum vkd3d_result vsir_program_lower_texkills(struct vsir_program *program)
{
- struct vsir_program *program = &parser->program;
struct vkd3d_shader_instruction_array *instructions = &program->instructions;
struct vkd3d_shader_instruction *texkill_ins, *ins;
unsigned int components_read = 3 + (program->shader_version.major >= 2);
@@ -230,10 +229,11 @@ static const struct vkd3d_shader_varying_map *find_varying_map(
return NULL;
}
-static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *parser,
- const struct vkd3d_shader_compile_info *compile_info)
+static enum vkd3d_result vsir_program_remap_output_signature(struct vsir_program *program,
+ const struct vkd3d_shader_compile_info *compile_info, struct vkd3d_shader_message_context *message_context)
{
- struct shader_signature *signature = &parser->program.output_signature;
+ const struct vkd3d_shader_location location = {.source_name = compile_info->source_name};
+ struct shader_signature *signature = &program->output_signature;
const struct vkd3d_shader_varying_map_info *varying_map;
unsigned int i;
@@ -255,7 +255,7 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars
* location with a different mask. */
if (input_mask && input_mask != e->mask)
{
- vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
+ vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
"Aborting due to not yet implemented feature: "
"Output mask %#x does not match input mask %#x.",
e->mask, input_mask);
@@ -272,7 +272,7 @@ static enum vkd3d_result remap_output_signature(struct vkd3d_shader_parser *pars
{
if (varying_map->varying_map[i].output_signature_index >= signature->element_count)
{
- vkd3d_shader_parser_error(parser, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
+ vkd3d_shader_error(message_context, &location, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED,
"Aborting due to not yet implemented feature: "
"The next stage consumes varyings not written by this stage.");
return VKD3D_ERROR_NOT_IMPLEMENTED;
@@ -2666,33 +2666,36 @@ fail:
return VKD3D_ERROR_OUT_OF_MEMORY;
}
-static void materialize_ssas_to_temps_process_src_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_src_param *src);
+static void materialize_ssas_to_temps_process_src_param(struct vsir_program *program,
+ struct vkd3d_shader_src_param *src);
/* This is idempotent: it can be safely applied more than once on the
* same register. */
-static void materialize_ssas_to_temps_process_reg(struct vkd3d_shader_parser *parser, struct vkd3d_shader_register *reg)
+static void materialize_ssas_to_temps_process_reg(struct vsir_program *program, struct vkd3d_shader_register *reg)
{
unsigned int i;
if (reg->type == VKD3DSPR_SSA)
{
reg->type = VKD3DSPR_TEMP;
- reg->idx[0].offset += parser->program.temp_count;
+ reg->idx[0].offset += program->temp_count;
}
for (i = 0; i < reg->idx_count; ++i)
if (reg->idx[i].rel_addr)
- materialize_ssas_to_temps_process_src_param(parser, reg->idx[i].rel_addr);
+ materialize_ssas_to_temps_process_src_param(program, reg->idx[i].rel_addr);
}
-static void materialize_ssas_to_temps_process_dst_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_dst_param *dst)
+static void materialize_ssas_to_temps_process_dst_param(struct vsir_program *program,
+ struct vkd3d_shader_dst_param *dst)
{
- materialize_ssas_to_temps_process_reg(parser, &dst->reg);
+ materialize_ssas_to_temps_process_reg(program, &dst->reg);
}
-static void materialize_ssas_to_temps_process_src_param(struct vkd3d_shader_parser *parser, struct vkd3d_shader_src_param *src)
+static void materialize_ssas_to_temps_process_src_param(struct vsir_program *program,
+ struct vkd3d_shader_src_param *src)
{
- materialize_ssas_to_temps_process_reg(parser, &src->reg);
+ materialize_ssas_to_temps_process_reg(program, &src->reg);
}
static const struct vkd3d_shader_src_param *materialize_ssas_to_temps_compute_source(struct vkd3d_shader_instruction *ins,
@@ -2711,7 +2714,7 @@ static const struct vkd3d_shader_src_param *materialize_ssas_to_temps_compute_so
vkd3d_unreachable();
}
-static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser *parser,
+static bool materialize_ssas_to_temps_synthesize_mov(struct vsir_program *program,
struct vkd3d_shader_instruction *instruction, const struct vkd3d_shader_location *loc,
const struct vkd3d_shader_dst_param *dest, const struct vkd3d_shader_src_param *cond,
const struct vkd3d_shader_src_param *source, bool invert)
@@ -2719,7 +2722,7 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser
struct vkd3d_shader_src_param *src;
struct vkd3d_shader_dst_param *dst;
- if (!vsir_instruction_init_with_params(&parser->program, instruction, loc,
+ if (!vsir_instruction_init_with_params(program, instruction, loc,
cond ? VKD3DSIH_MOVC : VKD3DSIH_MOV, 1, cond ? 3 : 1))
return false;
@@ -2727,7 +2730,7 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser
src = instruction->src;
dst[0] = *dest;
- materialize_ssas_to_temps_process_dst_param(parser, &dst[0]);
+ materialize_ssas_to_temps_process_dst_param(program, &dst[0]);
assert(dst[0].write_mask == VKD3DSP_WRITEMASK_0);
assert(dst[0].modifiers == 0);
@@ -2739,19 +2742,19 @@ static bool materialize_ssas_to_temps_synthesize_mov(struct vkd3d_shader_parser
src[1 + invert] = *source;
memset(&src[2 - invert], 0, sizeof(src[2 - invert]));
src[2 - invert].reg = dst[0].reg;
- materialize_ssas_to_temps_process_src_param(parser, &src[1]);
- materialize_ssas_to_temps_process_src_param(parser, &src[2]);
+ materialize_ssas_to_temps_process_src_param(program, &src[1]);
+ materialize_ssas_to_temps_process_src_param(program, &src[2]);
}
else
{
src[0] = *source;
- materialize_ssas_to_temps_process_src_param(parser, &src[0]);
+ materialize_ssas_to_temps_process_src_param(program, &src[0]);
}
return true;
}
-static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *parser)
+static enum vkd3d_result vsir_program_materialise_ssas_to_temps(struct vsir_program *program)
{
struct vkd3d_shader_instruction *instructions = NULL;
struct materialize_ssas_to_temps_block_data
@@ -2762,18 +2765,18 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
size_t ins_capacity = 0, ins_count = 0, i;
unsigned int current_label = 0;
- if (!reserve_instructions(&instructions, &ins_capacity, parser->program.instructions.count))
+ if (!reserve_instructions(&instructions, &ins_capacity, program->instructions.count))
goto fail;
- if (!(block_index = vkd3d_calloc(parser->program.block_count, sizeof(*block_index))))
+ if (!(block_index = vkd3d_calloc(program->block_count, sizeof(*block_index))))
{
ERR("Failed to allocate block index.\n");
goto fail;
}
- for (i = 0; i < parser->program.instructions.count; ++i)
+ for (i = 0; i < program->instructions.count; ++i)
{
- struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i];
+ struct vkd3d_shader_instruction *ins = &program->instructions.elements[i];
switch (ins->handler_idx)
{
@@ -2795,16 +2798,16 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
}
}
- for (i = 0; i < parser->program.instructions.count; ++i)
+ for (i = 0; i < program->instructions.count; ++i)
{
- struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i];
+ struct vkd3d_shader_instruction *ins = &program->instructions.elements[i];
size_t j;
for (j = 0; j < ins->dst_count; ++j)
- materialize_ssas_to_temps_process_dst_param(parser, &ins->dst[j]);
+ materialize_ssas_to_temps_process_dst_param(program, &ins->dst[j]);
for (j = 0; j < ins->src_count; ++j)
- materialize_ssas_to_temps_process_src_param(parser, &ins->src[j]);
+ materialize_ssas_to_temps_process_src_param(program, &ins->src[j]);
switch (ins->handler_idx)
{
@@ -2825,9 +2828,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
{
const struct vkd3d_shader_src_param *source;
- source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label);
- if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location,
- &parser->program.instructions.elements[j].dst[0], NULL, source, false))
+ source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j],
+ current_label);
+ if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count],
+ &ins->location, &program->instructions.elements[j].dst[0], NULL, source, false))
goto fail;
++ins_count;
@@ -2847,9 +2851,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
{
const struct vkd3d_shader_src_param *source;
- source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label);
- if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location,
- &parser->program.instructions.elements[j].dst[0], cond, source, false))
+ source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j],
+ current_label);
+ if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count],
+ &ins->location, &program->instructions.elements[j].dst[0], cond, source, false))
goto fail;
++ins_count;
@@ -2859,9 +2864,10 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
{
const struct vkd3d_shader_src_param *source;
- source = materialize_ssas_to_temps_compute_source(&parser->program.instructions.elements[j], current_label);
- if (!materialize_ssas_to_temps_synthesize_mov(parser, &instructions[ins_count], &ins->location,
- &parser->program.instructions.elements[j].dst[0], cond, source, true))
+ source = materialize_ssas_to_temps_compute_source(&program->instructions.elements[j],
+ current_label);
+ if (!materialize_ssas_to_temps_synthesize_mov(program, &instructions[ins_count],
+ &ins->location, &program->instructions.elements[j].dst[0], cond, source, true))
goto fail;
++ins_count;
@@ -2883,13 +2889,13 @@ static enum vkd3d_result materialize_ssas_to_temps(struct vkd3d_shader_parser *p
instructions[ins_count++] = *ins;
}
- vkd3d_free(parser->program.instructions.elements);
+ vkd3d_free(program->instructions.elements);
vkd3d_free(block_index);
- parser->program.instructions.elements = instructions;
- parser->program.instructions.capacity = ins_capacity;
- parser->program.instructions.count = ins_count;
- parser->program.temp_count += parser->program.ssa_count;
- parser->program.ssa_count = 0;
+ program->instructions.elements = instructions;
+ program->instructions.capacity = ins_capacity;
+ program->instructions.count = ins_count;
+ program->temp_count += program->ssa_count;
+ program->ssa_count = 0;
return VKD3D_OK;
@@ -2900,20 +2906,20 @@ fail:
return VKD3D_ERROR_OUT_OF_MEMORY;
}
-static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *parser)
+static enum vkd3d_result vsir_program_structurise(struct vsir_program *program)
{
- const unsigned int block_temp_idx = parser->program.temp_count;
+ const unsigned int block_temp_idx = program->temp_count;
struct vkd3d_shader_instruction *instructions = NULL;
const struct vkd3d_shader_location no_loc = {0};
size_t ins_capacity = 0, ins_count = 0, i;
bool first_label_found = false;
- if (!reserve_instructions(&instructions, &ins_capacity, parser->program.instructions.count))
+ if (!reserve_instructions(&instructions, &ins_capacity, program->instructions.count))
goto fail;
- for (i = 0; i < parser->program.instructions.count; ++i)
+ for (i = 0; i < program->instructions.count; ++i)
{
- struct vkd3d_shader_instruction *ins = &parser->program.instructions.elements[i];
+ struct vkd3d_shader_instruction *ins = &program->instructions.elements[i];
switch (ins->handler_idx)
{
@@ -2929,23 +2935,27 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
{
first_label_found = true;
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
+ if (!vsir_instruction_init_with_params(program,
+ &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
goto fail;
dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx);
src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0]));
ins_count++;
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_LOOP, 0, 0))
+ if (!vsir_instruction_init_with_params(program,
+ &instructions[ins_count], &no_loc, VKD3DSIH_LOOP, 0, 0))
goto fail;
ins_count++;
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_SWITCH, 0, 1))
+ if (!vsir_instruction_init_with_params(program,
+ &instructions[ins_count], &no_loc, VKD3DSIH_SWITCH, 0, 1))
goto fail;
src_param_init_temp_uint(&instructions[ins_count].src[0], block_temp_idx);
ins_count++;
}
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_CASE, 0, 1))
+ if (!vsir_instruction_init_with_params(program,
+ &instructions[ins_count], &no_loc, VKD3DSIH_CASE, 0, 1))
goto fail;
src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0]));
ins_count++;
@@ -2957,7 +2967,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
if (vsir_register_is_label(&ins->src[0].reg))
{
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
+ if (!vsir_instruction_init_with_params(program,
+ &instructions[ins_count], &no_loc, VKD3DSIH_MOV, 1, 1))
goto fail;
dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx);
src_param_init_const_uint(&instructions[ins_count].src[0], label_from_src_param(&ins->src[0]));
@@ -2965,7 +2976,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
}
else
{
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_MOVC, 1, 3))
+ if (!vsir_instruction_init_with_params(program,
+ &instructions[ins_count], &no_loc, VKD3DSIH_MOVC, 1, 3))
goto fail;
dst_param_init_temp_uint(&instructions[ins_count].dst[0], block_temp_idx);
instructions[ins_count].src[0] = ins->src[0];
@@ -2974,7 +2986,8 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
ins_count++;
}
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_BREAK, 0, 0))
+ if (!vsir_instruction_init_with_params(program,
+ &instructions[ins_count], &no_loc, VKD3DSIH_BREAK, 0, 0))
goto fail;
ins_count++;
break;
@@ -2994,23 +3007,23 @@ static enum vkd3d_result simple_structurizer_run(struct vkd3d_shader_parser *par
if (!reserve_instructions(&instructions, &ins_capacity, ins_count + 3))
goto fail;
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDSWITCH, 0, 0))
+ if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDSWITCH, 0, 0))
goto fail;
ins_count++;
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDLOOP, 0, 0))
+ if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_ENDLOOP, 0, 0))
goto fail;
ins_count++;
- if (!vsir_instruction_init_with_params(&parser->program, &instructions[ins_count], &no_loc, VKD3DSIH_RET, 0, 0))
+ if (!vsir_instruction_init_with_params(program, &instructions[ins_count], &no_loc, VKD3DSIH_RET, 0, 0))
goto fail;
ins_count++;
- vkd3d_free(parser->program.instructions.elements);
- parser->program.instructions.elements = instructions;
- parser->program.instructions.capacity = ins_capacity;
- parser->program.instructions.count = ins_count;
- parser->program.temp_count += 1;
+ vkd3d_free(program->instructions.elements);
+ program->instructions.elements = instructions;
+ program->instructions.capacity = ins_capacity;
+ program->instructions.count = ins_count;
+ program->temp_count += 1;
return VKD3D_OK;
@@ -3906,25 +3919,26 @@ static enum vkd3d_result vsir_cfg_generate_synthetic_loop_intervals(struct vsir_
enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
const struct vkd3d_shader_compile_info *compile_info)
{
- struct vkd3d_shader_instruction_array *instructions = &parser->program.instructions;
+ struct vkd3d_shader_message_context *message_context = parser->message_context;
+ struct vsir_program *program = &parser->program;
enum vkd3d_result result = VKD3D_OK;
- remove_dcl_temps(&parser->program);
+ remove_dcl_temps(program);
- if ((result = instruction_array_lower_texkills(parser)) < 0)
+ if ((result = vsir_program_lower_texkills(program)) < 0)
return result;
- if (parser->program.shader_version.major >= 6)
+ if (program->shader_version.major >= 6)
{
struct vsir_cfg cfg;
- if ((result = lower_switch_to_if_ladder(&parser->program)) < 0)
+ if ((result = lower_switch_to_if_ladder(program)) < 0)
return result;
- if ((result = materialize_ssas_to_temps(parser)) < 0)
+ if ((result = vsir_program_materialise_ssas_to_temps(program)) < 0)
return result;
- if ((result = vsir_cfg_init(&cfg, &parser->program, parser->message_context)) < 0)
+ if ((result = vsir_cfg_init(&cfg, program, message_context)) < 0)
return result;
vsir_cfg_compute_dominators(&cfg);
@@ -3947,7 +3961,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
return result;
}
- if ((result = simple_structurizer_run(parser)) < 0)
+ if ((result = vsir_program_structurise(program)) < 0)
{
vsir_cfg_cleanup(&cfg);
return result;
@@ -3957,29 +3971,29 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
}
else
{
- if (parser->program.shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
+ if (program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL)
{
- if ((result = remap_output_signature(parser, compile_info)) < 0)
+ if ((result = vsir_program_remap_output_signature(program, compile_info, message_context)) < 0)
return result;
}
- if (parser->program.shader_version.type == VKD3D_SHADER_TYPE_HULL)
+ if (program->shader_version.type == VKD3D_SHADER_TYPE_HULL)
{
- if ((result = instruction_array_flatten_hull_shader_phases(instructions)) < 0)
+ if ((result = instruction_array_flatten_hull_shader_phases(&program->instructions)) < 0)
return result;
- if ((result = instruction_array_normalise_hull_shader_control_point_io(instructions,
- &parser->program.input_signature)) < 0)
+ if ((result = instruction_array_normalise_hull_shader_control_point_io(&program->instructions,
+ &program->input_signature)) < 0)
return result;
}
if ((result = shader_normalise_io_registers(parser)) < 0)
return result;
- if ((result = instruction_array_normalise_flat_constants(&parser->program)) < 0)
+ if ((result = instruction_array_normalise_flat_constants(program)) < 0)
return result;
- remove_dead_code(&parser->program);
+ remove_dead_code(program);
if ((result = normalise_combined_samplers(parser)) < 0)
return result;
@@ -3989,7 +4003,7 @@ enum vkd3d_result vkd3d_shader_normalise(struct vkd3d_shader_parser *parser,
return result;
if (TRACE_ON())
- vkd3d_shader_trace(&parser->program);
+ vkd3d_shader_trace(program);
if (!parser->failed && (result = vsir_validate(parser)) < 0)
return result;
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
index 0568407f997..1518afa93be 100644
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
@@ -7020,6 +7020,15 @@ static enum vkd3d_result spirv_compiler_emit_alu_instruction(struct spirv_compil
SpvOp op = SpvOpMax;
unsigned int i;
+ if (src->reg.data_type == VKD3D_DATA_UINT64 && instruction->handler_idx == VKD3DSIH_COUNTBITS)
+ {
+ /* At least some drivers support this anyway, but if validation is enabled it will fail. */
+ FIXME("Unsupported 64-bit source for bit count.\n");
+ spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_NOT_IMPLEMENTED,
+ "64-bit source for bit count is not supported.");
+ return VKD3D_ERROR_INVALID_SHADER;
+ }
+
if (src->reg.data_type == VKD3D_DATA_BOOL)
{
if (dst->reg.data_type == VKD3D_DATA_BOOL)
@@ -7160,6 +7169,16 @@ static void spirv_compiler_emit_ext_glsl_instruction(struct spirv_compiler *comp
unsigned int i, component_count;
enum GLSLstd450 glsl_inst;
+ if (src[0].reg.data_type == VKD3D_DATA_UINT64 && (instruction->handler_idx == VKD3DSIH_FIRSTBIT_HI
+ || instruction->handler_idx == VKD3DSIH_FIRSTBIT_LO || instruction->handler_idx == VKD3DSIH_FIRSTBIT_SHI))
+ {
+ /* At least some drivers support this anyway, but if validation is enabled it will fail. */
+ FIXME("Unsupported 64-bit source for handler %#x.\n", instruction->handler_idx);
+ spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_NOT_IMPLEMENTED,
+ "64-bit source for handler %#x is not supported.", instruction->handler_idx);
+ return;
+ }
+
glsl_inst = spirv_compiler_map_ext_glsl_instruction(instruction);
if (glsl_inst == GLSLstd450Bad)
{
--
2.43.0