diff --git a/patches/vkd3d-latest/0001-Updated-vkd3d-to-44fffee5e1331e1c7e10489d84723c3b9da.patch b/patches/vkd3d-latest/0001-Updated-vkd3d-to-44fffee5e1331e1c7e10489d84723c3b9da.patch index 54977b0e..88dbc48e 100644 --- a/patches/vkd3d-latest/0001-Updated-vkd3d-to-44fffee5e1331e1c7e10489d84723c3b9da.patch +++ b/patches/vkd3d-latest/0001-Updated-vkd3d-to-44fffee5e1331e1c7e10489d84723c3b9da.patch @@ -1,4 +1,4 @@ -From f54b809d2d0402064569abf7843cfc90b8761b2b Mon Sep 17 00:00:00 2001 +From e8e77eb103448eaf3f4334f1e62d89ba83b97f78 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Mon, 26 May 2025 07:03:34 +1000 Subject: [PATCH] Updated vkd3d to 44fffee5e1331e1c7e10489d84723c3b9dad7e17. diff --git a/patches/vkd3d-latest/0002-Updated-vkd3d-to-3b41d99fa9e80dda5844738a226f70f14f7.patch b/patches/vkd3d-latest/0002-Updated-vkd3d-to-3b41d99fa9e80dda5844738a226f70f14f7.patch index 81c9f102..4fdf4545 100644 --- a/patches/vkd3d-latest/0002-Updated-vkd3d-to-3b41d99fa9e80dda5844738a226f70f14f7.patch +++ b/patches/vkd3d-latest/0002-Updated-vkd3d-to-3b41d99fa9e80dda5844738a226f70f14f7.patch @@ -1,4 +1,4 @@ -From 68132ba78fd7988b49a335781c8a0ed8a5ad603c Mon Sep 17 00:00:00 2001 +From 1c686e92c185fcc9efa718e1a6ffe70a14a71a1e Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 22 Aug 2025 07:26:18 +1000 Subject: [PATCH] Updated vkd3d to 3b41d99fa9e80dda5844738a226f70f14f778c8b. diff --git a/patches/vkd3d-latest/0003-Updated-vkd3d-to-d0098b0d5968d1969ec622b91fd360fd0ae.patch b/patches/vkd3d-latest/0003-Updated-vkd3d-to-d0098b0d5968d1969ec622b91fd360fd0ae.patch index bc57eeb4..0541d7c5 100644 --- a/patches/vkd3d-latest/0003-Updated-vkd3d-to-d0098b0d5968d1969ec622b91fd360fd0ae.patch +++ b/patches/vkd3d-latest/0003-Updated-vkd3d-to-d0098b0d5968d1969ec622b91fd360fd0ae.patch @@ -1,4 +1,4 @@ -From 5bb958cb76891665aa91871e976007f0acc3a273 Mon Sep 17 00:00:00 2001 +From 53b2f2d25a1abd14e043e7c927ee16d8f454d970 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 23 Aug 2025 07:27:59 +1000 Subject: [PATCH] Updated vkd3d to d0098b0d5968d1969ec622b91fd360fd0aec2328. diff --git a/patches/vkd3d-latest/0004-Updated-vkd3d-to-158f8b3cf6ff528eb6897baf04db80f0db2.patch b/patches/vkd3d-latest/0004-Updated-vkd3d-to-158f8b3cf6ff528eb6897baf04db80f0db2.patch index c600203a..e754205d 100644 --- a/patches/vkd3d-latest/0004-Updated-vkd3d-to-158f8b3cf6ff528eb6897baf04db80f0db2.patch +++ b/patches/vkd3d-latest/0004-Updated-vkd3d-to-158f8b3cf6ff528eb6897baf04db80f0db2.patch @@ -1,4 +1,4 @@ -From 69c3807e42ff958f23c0c959ad5d065487c4d896 Mon Sep 17 00:00:00 2001 +From eb3e25c8b5d02a3402438ac83002eb936563e85f Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Sat, 30 Aug 2025 07:08:53 +1000 Subject: [PATCH] Updated vkd3d to 158f8b3cf6ff528eb6897baf04db80f0db2b53f8. diff --git a/patches/vkd3d-latest/0005-Updated-vkd3d-to-979d7e4b85f2fb8db60219f4a2673fc8071.patch b/patches/vkd3d-latest/0005-Updated-vkd3d-to-979d7e4b85f2fb8db60219f4a2673fc8071.patch new file mode 100644 index 00000000..e28535e7 --- /dev/null +++ b/patches/vkd3d-latest/0005-Updated-vkd3d-to-979d7e4b85f2fb8db60219f4a2673fc8071.patch @@ -0,0 +1,365 @@ +From 0834b82af4990aad006eb709f50090babb2bf1ee Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Tue, 2 Sep 2025 07:37:13 +1000 +Subject: [PATCH] Updated vkd3d to 979d7e4b85f2fb8db60219f4a2673fc807142ebd. + +--- + libs/vkd3d/libs/vkd3d-shader/glsl.c | 26 ++++++++++++++++ + libs/vkd3d/libs/vkd3d-shader/ir.c | 44 ++++++++++++++-------------- + libs/vkd3d/libs/vkd3d-shader/spirv.c | 29 +++++++++--------- + 3 files changed, 63 insertions(+), 36 deletions(-) + +diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c +index 7325661ea7b..b2679beff9f 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c ++++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c +@@ -288,6 +288,14 @@ static void shader_glsl_print_register_name(struct vkd3d_string_buffer *buffer, + shader_glsl_print_subscript(buffer, gen, reg->idx[1].rel_addr, reg->idx[1].offset); + break; + ++ case VKD3DSPR_SAMPLEMASK: ++ if (gen->program->shader_version.type != VKD3D_SHADER_TYPE_PIXEL) ++ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, ++ "Internal compiler error: Unhandled sample coverage mask in shader type #%x.", ++ gen->program->shader_version.type); ++ vkd3d_string_buffer_printf(buffer, "o_mask"); ++ break; ++ + default: + vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, + "Internal compiler error: Unhandled register type %#x.", reg->type); +@@ -1286,6 +1294,13 @@ static void shader_glsl_print_sysval_name(struct vkd3d_string_buffer *buffer, st + vkd3d_string_buffer_printf(buffer, "intBitsToFloat(ivec4(gl_VertexID, 0, 0, 0))"); + break; + ++ case VKD3D_SHADER_SV_INSTANCE_ID: ++ if (version->type != VKD3D_SHADER_TYPE_VERTEX) ++ vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, ++ "Internal compiler error: Unhandled SV_INSTANCE_ID in shader type #%x.", version->type); ++ vkd3d_string_buffer_printf(buffer, "intBitsToFloat(ivec4(gl_InstanceID, 0, 0, 0))"); ++ break; ++ + case VKD3D_SHADER_SV_IS_FRONT_FACE: + if (version->type != VKD3D_SHADER_TYPE_PIXEL) + vkd3d_glsl_compiler_error(gen, VKD3D_SHADER_ERROR_GLSL_INTERNAL, +@@ -1434,6 +1449,12 @@ static void shader_glsl_shader_epilogue(struct vkd3d_glsl_generator *gen) + shader_glsl_print_write_mask(buffer, e->mask); + vkd3d_string_buffer_printf(buffer, ";\n"); + } ++ ++ if (bitmap_is_set(gen->program->io_dcls, VKD3DSPR_SAMPLEMASK)) ++ { ++ shader_glsl_print_indent(buffer, gen->indent); ++ vkd3d_string_buffer_printf(gen->buffer, "gl_SampleMask[0] = floatBitsToInt(o_mask);\n"); ++ } + } + + static void shader_glsl_ret(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins) +@@ -1650,6 +1671,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen, + case VSIR_OP_UDIV_SIMPLE: + shader_glsl_binop(gen, ins, "/"); + break; ++ case VSIR_OP_UREM: ++ shader_glsl_binop(gen, ins, "%"); ++ break; + case VSIR_OP_XOR: + shader_glsl_binop(gen, ins, "^"); + break; +@@ -2339,6 +2363,8 @@ static void shader_glsl_generate_declarations(struct vkd3d_glsl_generator *gen) + vkd3d_string_buffer_printf(buffer, "vec4 %s_in[%u];\n", gen->prefix, gen->limits.input_count); + if (gen->limits.output_count) + vkd3d_string_buffer_printf(buffer, "vec4 %s_out[%u];\n", gen->prefix, gen->limits.output_count); ++ if (bitmap_is_set(gen->program->io_dcls, VKD3DSPR_SAMPLEMASK)) ++ vkd3d_string_buffer_printf(gen->buffer, "float o_mask;\n"); + if (program->temp_count) + vkd3d_string_buffer_printf(buffer, "vec4 r[%u];\n", program->temp_count); + vkd3d_string_buffer_printf(buffer, "\n"); +diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c +index 396562e65e4..1ab406a9d84 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/ir.c ++++ b/libs/vkd3d/libs/vkd3d-shader/ir.c +@@ -1750,6 +1750,8 @@ static enum vkd3d_result vsir_program_lower_instructions(struct vsir_program *pr + case VSIR_OP_DCL: + case VSIR_OP_DCL_CONSTANT_BUFFER: + case VSIR_OP_DCL_GLOBAL_FLAGS: ++ case VSIR_OP_DCL_INPUT_PRIMITIVE: ++ case VSIR_OP_DCL_OUTPUT_TOPOLOGY: + case VSIR_OP_DCL_SAMPLER: + case VSIR_OP_DCL_TEMPS: + case VSIR_OP_DCL_TESSELLATOR_DOMAIN: +@@ -7167,7 +7169,6 @@ static enum vkd3d_result vsir_program_insert_clip_planes(struct vsir_program *pr + unsigned int low_signature_idx = ~0u, high_signature_idx = ~0u; + const struct vkd3d_shader_parameter1 *mask_parameter = NULL; + uint32_t position_signature_idx, position_temp, mask; +- static const struct vkd3d_shader_location no_loc; + struct signature_element *clip_element; + struct vkd3d_shader_instruction *ins; + unsigned int plane_count; +@@ -7189,13 +7190,13 @@ static enum vkd3d_result vsir_program_insert_clip_planes(struct vsir_program *pr + + if (mask_parameter->type != VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, ++ vkd3d_shader_error(ctx->message_context, NULL, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, + "Unsupported clip plane mask parameter type %#x.", mask_parameter->type); + return VKD3D_ERROR_NOT_IMPLEMENTED; + } + if (mask_parameter->data_type != VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, ++ vkd3d_shader_error(ctx->message_context, NULL, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid clip plane mask parameter data type %#x.", mask_parameter->data_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } +@@ -7208,7 +7209,7 @@ static enum vkd3d_result vsir_program_insert_clip_planes(struct vsir_program *pr + { + if (signature->elements[i].sysval_semantic == VKD3D_SHADER_SV_CLIP_DISTANCE) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_PARAMETER, ++ vkd3d_shader_error(ctx->message_context, &ctx->null_location, VKD3D_SHADER_ERROR_VSIR_INVALID_PARAMETER, + "Clip planes cannot be used if the shader writes clip distance."); + return VKD3D_ERROR_INVALID_ARGUMENT; + } +@@ -7216,7 +7217,7 @@ static enum vkd3d_result vsir_program_insert_clip_planes(struct vsir_program *pr + + if (!vsir_signature_find_sysval(signature, VKD3D_SHADER_SV_POSITION, 0, &position_signature_idx)) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_MISSING_SEMANTIC, ++ vkd3d_shader_error(ctx->message_context, &ctx->null_location, VKD3D_SHADER_ERROR_VSIR_MISSING_SEMANTIC, + "Shader does not write position."); + return VKD3D_ERROR_INVALID_SHADER; + } +@@ -7306,7 +7307,6 @@ static enum vkd3d_result vsir_program_insert_point_size(struct vsir_program *pro + { + struct vsir_program_iterator it = vsir_program_iterator(&program->instructions); + const struct vkd3d_shader_parameter1 *size_parameter = NULL; +- static const struct vkd3d_shader_location no_loc; + struct vkd3d_shader_instruction *ins; + + if (program->has_point_size) +@@ -7328,7 +7328,7 @@ static enum vkd3d_result vsir_program_insert_point_size(struct vsir_program *pro + + if (size_parameter->data_type != VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, ++ vkd3d_shader_error(ctx->message_context, NULL, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid point size parameter data type %#x.", size_parameter->data_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } +@@ -7355,7 +7355,6 @@ static enum vkd3d_result vsir_program_insert_point_size_clamp(struct vsir_progra + { + const struct vkd3d_shader_parameter1 *min_parameter = NULL, *max_parameter = NULL; + struct vsir_program_iterator it = vsir_program_iterator(&program->instructions); +- static const struct vkd3d_shader_location no_loc; + struct vkd3d_shader_instruction *ins; + + if (!program->has_point_size) +@@ -7379,14 +7378,14 @@ static enum vkd3d_result vsir_program_insert_point_size_clamp(struct vsir_progra + + if (min_parameter && min_parameter->data_type != VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, ++ vkd3d_shader_error(ctx->message_context, NULL, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid minimum point size parameter data type %#x.", min_parameter->data_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } + + if (max_parameter && max_parameter->data_type != VKD3D_SHADER_PARAMETER_DATA_TYPE_FLOAT32) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, ++ vkd3d_shader_error(ctx->message_context, NULL, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid maximum point size parameter data type %#x.", max_parameter->data_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } +@@ -7529,7 +7528,7 @@ static enum vkd3d_result vsir_program_insert_point_coord(struct vsir_program *pr + { + struct vsir_program_iterator it = vsir_program_iterator(&program->instructions), it2; + const struct vkd3d_shader_parameter1 *sprite_parameter = NULL; +- static const struct vkd3d_shader_location no_loc; ++ struct vkd3d_shader_location loc = ctx->null_location; + struct vkd3d_shader_instruction *ins; + bool used_texcoord = false; + unsigned int coord_temp; +@@ -7551,13 +7550,13 @@ static enum vkd3d_result vsir_program_insert_point_coord(struct vsir_program *pr + + if (sprite_parameter->type != VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, ++ vkd3d_shader_error(ctx->message_context, NULL, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, + "Unsupported point sprite parameter type %#x.", sprite_parameter->type); + return VKD3D_ERROR_NOT_IMPLEMENTED; + } + if (sprite_parameter->data_type != VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, ++ vkd3d_shader_error(ctx->message_context, NULL, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid point sprite parameter data type %#x.", sprite_parameter->data_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } +@@ -7577,7 +7576,10 @@ static enum vkd3d_result vsir_program_insert_point_coord(struct vsir_program *pr + for (ins = vsir_program_iterator_head(&it); ins; ins = vsir_program_iterator_next(&it)) + { + if (!vsir_instruction_is_dcl(ins) && ins->opcode != VSIR_OP_LABEL && ins->opcode != VSIR_OP_NOP) ++ { ++ loc = ins->location; + break; ++ } + } + + it2 = it; +@@ -7615,7 +7617,7 @@ static enum vkd3d_result vsir_program_insert_point_coord(struct vsir_program *pr + if (!(ins = vsir_program_iterator_insert_before_and_move(&it, 2))) + return VKD3D_ERROR_OUT_OF_MEMORY; + +- vsir_instruction_init_with_params(program, ins, &no_loc, VSIR_OP_MOV, 1, 1); ++ vsir_instruction_init_with_params(program, ins, &loc, VSIR_OP_MOV, 1, 1); + dst_param_init_temp_float4(&ins->dst[0], coord_temp); + ins->dst[0].write_mask = VKD3DSP_WRITEMASK_0 | VKD3DSP_WRITEMASK_1; + vsir_src_param_init(&ins->src[0], VKD3DSPR_POINT_COORD, VSIR_DATA_F32, 0); +@@ -7623,7 +7625,7 @@ static enum vkd3d_result vsir_program_insert_point_coord(struct vsir_program *pr + ins->src[0].swizzle = VKD3D_SHADER_NO_SWIZZLE; + ins = vsir_program_iterator_next(&it); + +- vsir_instruction_init_with_params(program, ins, &no_loc, VSIR_OP_MOV, 1, 1); ++ vsir_instruction_init_with_params(program, ins, &loc, VSIR_OP_MOV, 1, 1); + dst_param_init_temp_float4(&ins->dst[0], coord_temp); + ins->dst[0].write_mask = VKD3DSP_WRITEMASK_2 | VKD3DSP_WRITEMASK_3; + vsir_src_param_init(&ins->src[0], VKD3DSPR_IMMCONST, VSIR_DATA_F32, 0); +@@ -7804,7 +7806,6 @@ static enum vkd3d_result vsir_program_insert_fragment_fog(struct vsir_program *p + struct vkd3d_shader_message_context *message_context = ctx->message_context; + uint32_t colour_signature_idx, fog_signature_idx, colour_temp; + const struct vkd3d_shader_parameter1 *mode_parameter = NULL; +- static const struct vkd3d_shader_location no_loc; + const struct signature_element *fog_element; + enum vkd3d_shader_fog_fragment_mode mode; + struct vkd3d_shader_instruction *ins; +@@ -7821,13 +7822,13 @@ static enum vkd3d_result vsir_program_insert_fragment_fog(struct vsir_program *p + + if (mode_parameter->type != VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT) + { +- vkd3d_shader_error(message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, ++ vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, + "Unsupported fog fragment mode parameter type %#x.", mode_parameter->type); + return VKD3D_ERROR_NOT_IMPLEMENTED; + } + if (mode_parameter->data_type != VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32) + { +- vkd3d_shader_error(message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, ++ vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid fog fragment mode parameter data type %#x.", mode_parameter->data_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } +@@ -7951,7 +7952,6 @@ static enum vkd3d_result vsir_program_insert_vertex_fog(struct vsir_program *pro + struct vkd3d_shader_message_context *message_context = ctx->message_context; + const struct vkd3d_shader_parameter1 *source_parameter = NULL; + uint32_t fog_signature_idx, source_signature_idx, temp; +- static const struct vkd3d_shader_location no_loc; + struct vkd3d_shader_instruction *ins; + enum vkd3d_shader_fog_source source; + const struct signature_element *e; +@@ -7964,13 +7964,13 @@ static enum vkd3d_result vsir_program_insert_vertex_fog(struct vsir_program *pro + + if (source_parameter->type != VKD3D_SHADER_PARAMETER_TYPE_IMMEDIATE_CONSTANT) + { +- vkd3d_shader_error(message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, ++ vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_VSIR_NOT_IMPLEMENTED, + "Unsupported fog source parameter type %#x.", source_parameter->type); + return VKD3D_ERROR_NOT_IMPLEMENTED; + } + if (source_parameter->data_type != VKD3D_SHADER_PARAMETER_DATA_TYPE_UINT32) + { +- vkd3d_shader_error(message_context, &no_loc, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, ++ vkd3d_shader_error(message_context, NULL, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, + "Invalid fog source parameter data type %#x.", source_parameter->data_type); + return VKD3D_ERROR_INVALID_ARGUMENT; + } +@@ -7992,7 +7992,7 @@ static enum vkd3d_result vsir_program_insert_vertex_fog(struct vsir_program *pro + if (!vsir_signature_find_sysval(&program->output_signature, + VKD3D_SHADER_SV_POSITION, 0, &source_signature_idx)) + { +- vkd3d_shader_error(ctx->message_context, &no_loc, ++ vkd3d_shader_error(ctx->message_context, &ctx->null_location, + VKD3D_SHADER_ERROR_VSIR_MISSING_SEMANTIC, "Shader does not write position."); + return VKD3D_ERROR_INVALID_SHADER; + } +diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c +index 97c0d0e73a8..a57c42b167d 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c ++++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c +@@ -7209,10 +7209,9 @@ static void spirv_compiler_emit_output_vertex_count(struct spirv_compiler *compi + SpvExecutionModeOutputVertices, instruction->declaration.count); + } + +-static void spirv_compiler_emit_dcl_input_primitive(struct spirv_compiler *compiler, +- const struct vkd3d_shader_instruction *instruction) ++static void spirv_compiler_emit_input_primitive(struct spirv_compiler *compiler) + { +- enum vkd3d_primitive_type primitive_type = instruction->declaration.primitive_type.type; ++ enum vkd3d_primitive_type primitive_type = compiler->program->input_primitive; + SpvExecutionMode mode; + + switch (primitive_type) +@@ -7233,7 +7232,8 @@ static void spirv_compiler_emit_dcl_input_primitive(struct spirv_compiler *compi + mode = SpvExecutionModeInputTrianglesAdjacency; + break; + default: +- FIXME("Unhandled primitive type %#x.\n", primitive_type); ++ spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_NOT_IMPLEMENTED, ++ "Unhandled input primitive type %#x.", primitive_type); + return; + } + +@@ -7263,10 +7263,9 @@ static void spirv_compiler_emit_point_size(struct spirv_compiler *compiler) + } + } + +-static void spirv_compiler_emit_dcl_output_topology(struct spirv_compiler *compiler, +- const struct vkd3d_shader_instruction *instruction) ++static void spirv_compiler_emit_output_topology(struct spirv_compiler *compiler) + { +- enum vkd3d_primitive_type primitive_type = instruction->declaration.primitive_type.type; ++ enum vkd3d_primitive_type primitive_type = compiler->program->output_topology; + SpvExecutionMode mode; + + switch (primitive_type) +@@ -7282,7 +7281,8 @@ static void spirv_compiler_emit_dcl_output_topology(struct spirv_compiler *compi + mode = SpvExecutionModeOutputTriangleStrip; + break; + default: +- ERR("Unexpected primitive type %#x.\n", primitive_type); ++ spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_NOT_IMPLEMENTED, ++ "Unhandled output topology %#x.", primitive_type); + return; + } + +@@ -10608,12 +10608,6 @@ static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler, + case VSIR_OP_DCL_VERTICES_OUT: + spirv_compiler_emit_output_vertex_count(compiler, instruction); + break; +- case VSIR_OP_DCL_INPUT_PRIMITIVE: +- spirv_compiler_emit_dcl_input_primitive(compiler, instruction); +- break; +- case VSIR_OP_DCL_OUTPUT_TOPOLOGY: +- spirv_compiler_emit_dcl_output_topology(compiler, instruction); +- break; + case VSIR_OP_DCL_GS_INSTANCES: + spirv_compiler_emit_dcl_gs_instances(compiler, instruction); + break; +@@ -11066,7 +11060,14 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, + if (program->ssa_count) + 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); ++ } ++ else if (compiler->shader_type == VKD3D_SHADER_TYPE_GEOMETRY) ++ { ++ spirv_compiler_emit_input_primitive(compiler); ++ spirv_compiler_emit_output_topology(compiler); ++ } + spirv_compiler_emit_global_flags(compiler, program->global_flags); + + spirv_compiler_emit_descriptor_declarations(compiler); +-- +2.50.1 + diff --git a/patches/vkd3d-latest/0006-Updated-vkd3d-to-d6bed4be377432e4c54e23abcd7863fefbe.patch b/patches/vkd3d-latest/0006-Updated-vkd3d-to-d6bed4be377432e4c54e23abcd7863fefbe.patch new file mode 100644 index 00000000..548591cf --- /dev/null +++ b/patches/vkd3d-latest/0006-Updated-vkd3d-to-d6bed4be377432e4c54e23abcd7863fefbe.patch @@ -0,0 +1,1757 @@ +From 923515f00841e6d45c1e91f8cf530bc5dabf7192 Mon Sep 17 00:00:00 2001 +From: Alistair Leslie-Hughes +Date: Wed, 3 Sep 2025 08:08:18 +1000 +Subject: [PATCH] Updated vkd3d to d6bed4be377432e4c54e23abcd7863fefbef94aa. + +--- + libs/vkd3d/libs/vkd3d-shader/d3d_asm.c | 23 +- + libs/vkd3d/libs/vkd3d-shader/hlsl.h | 4 +- + libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 102 ++++--- + libs/vkd3d/libs/vkd3d-shader/ir.c | 167 ++++++++++-- + libs/vkd3d/libs/vkd3d-shader/spirv.c | 249 +++++++++--------- + .../libs/vkd3d-shader/vkd3d_shader_private.h | 2 + + 6 files changed, 331 insertions(+), 216 deletions(-) + +diff --git a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c +index 6425a8f62d2..58135e71f30 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c ++++ b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c +@@ -390,27 +390,10 @@ static void shader_print_resource_type(struct vkd3d_d3d_asm_compiler *compiler, + + static void shader_print_data_type(struct vkd3d_d3d_asm_compiler *compiler, enum vsir_data_type type) + { +- static const char *const data_type_names[] = +- { +- [VSIR_DATA_BOOL ] = "bool", +- [VSIR_DATA_F16 ] = "half", +- [VSIR_DATA_F32 ] = "float", +- [VSIR_DATA_F64 ] = "double", +- [VSIR_DATA_I32 ] = "int", +- [VSIR_DATA_U8 ] = "uint8", +- [VSIR_DATA_U16 ] = "uint16", +- [VSIR_DATA_U32 ] = "uint", +- [VSIR_DATA_U64 ] = "uint64", +- [VSIR_DATA_SNORM ] = "snorm", +- [VSIR_DATA_UNORM ] = "unorm", +- [VSIR_DATA_OPAQUE ] = "opaque", +- [VSIR_DATA_MIXED ] = "mixed", +- [VSIR_DATA_CONTINUED] = "", +- [VSIR_DATA_UNUSED ] = "", +- }; ++ const char *name; + +- if (type < ARRAY_SIZE(data_type_names)) +- vkd3d_string_buffer_printf(&compiler->buffer, "%s", data_type_names[type]); ++ if ((name = vsir_data_type_get_name(type, NULL))) ++ vkd3d_string_buffer_printf(&compiler->buffer, "%s", name); + else + vkd3d_string_buffer_printf(&compiler->buffer, "%s%s", + compiler->colours.error, type, compiler->colours.reset); +diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h +index b6e5f4f2cf3..df1333f55a6 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h ++++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h +@@ -1184,8 +1184,8 @@ struct hlsl_ctx + } constant_defs; + /* 'c' registers where the constants expected by SM2 sincos are stored. */ + struct hlsl_reg d3dsincosconst1, d3dsincosconst2; +- /* Number of allocated SSA IDs, used in translation to vsir. */ +- unsigned int ssa_count; ++ /* Number of allocated SSA and temp IDs, used in translation to vsir. */ ++ unsigned int ssa_count, temp_count; + + /* Number of threads to be executed (on the X, Y, and Z dimensions) in a single thread group in + * compute shader profiles. It is set using the numthreads() attribute in the entry point. */ +diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c +index 8e3ed0a1b8d..5d413c43374 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c ++++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c +@@ -5905,6 +5905,9 @@ static void mark_vars_usage(struct hlsl_ctx *ctx) + + struct register_allocator + { ++ /* Type of registers we are allocating (not counting indexable temps). */ ++ enum vkd3d_shader_register_type type; ++ + struct allocation + { + uint32_t reg; +@@ -6019,7 +6022,7 @@ static struct hlsl_reg allocate_register(struct hlsl_ctx *ctx, struct register_a + unsigned int writemask = hlsl_combine_writemasks(available_writemask, + vkd3d_write_mask_from_component_count(reg_size)); + +- ret.type = VKD3DSPR_TEMP; ++ ret.type = allocator->type; + ret.id = reg_idx; + ret.writemask = hlsl_combine_writemasks(writemask, + vkd3d_write_mask_from_component_count(component_count)); +@@ -6030,7 +6033,7 @@ static struct hlsl_reg allocate_register(struct hlsl_ctx *ctx, struct register_a + } + } + +- ret.type = VKD3DSPR_TEMP; ++ ret.type = allocator->type; + ret.id = allocator->reg_count; + ret.writemask = vkd3d_write_mask_from_component_count(component_count); + record_allocation(ctx, allocator, allocator->reg_count, +@@ -6103,7 +6106,7 @@ static struct hlsl_reg allocate_range(struct hlsl_ctx *ctx, struct register_allo + record_allocation(ctx, allocator, reg_idx + (reg_size / 4), + (1u << (reg_size % 4)) - 1, first_write, last_read, mode, vip); + +- ret.type = VKD3DSPR_TEMP; ++ ret.type = allocator->type; + ret.id = reg_idx; + ret.allocation_size = align(reg_size, 4) / 4; + ret.allocated = true; +@@ -6114,14 +6117,18 @@ static struct hlsl_reg allocate_numeric_registers_for_type(struct hlsl_ctx *ctx, + unsigned int first_write, unsigned int last_read, const struct hlsl_type *type) + { + unsigned int reg_size = type->reg_size[HLSL_REGSET_NUMERIC]; ++ struct hlsl_reg ret; + + /* FIXME: We could potentially pack structs or arrays more efficiently... */ + + if (type->class <= HLSL_CLASS_VECTOR) +- return allocate_register(ctx, allocator, first_write, last_read, ++ ret = allocate_register(ctx, allocator, first_write, last_read, + type->e.numeric.dimx, type->e.numeric.dimx, 0, false, false); + else +- return allocate_range(ctx, allocator, first_write, last_read, reg_size, 0, false); ++ ret = allocate_range(ctx, allocator, first_write, last_read, reg_size, 0, false); ++ if (allocator->type == VKD3DSPR_TEMP) ++ ctx->temp_count = max(ctx->temp_count, ret.id + ret.allocation_size); ++ return ret; + } + + static const char *debug_register(struct hlsl_reg reg, const struct hlsl_type *type) +@@ -6329,11 +6336,21 @@ static void allocate_instr_temp_register(struct hlsl_ctx *ctx, + VKD3D_ASSERT(instr->data_type->class <= HLSL_CLASS_VECTOR); + + if (reg_writemask) ++ { + instr->reg = allocate_register_with_masks(ctx, allocator, + instr->index, instr->last_read, reg_writemask, dst_writemask, 0, false); ++ ctx->temp_count = max(ctx->temp_count, instr->reg.id + 1); ++ } + else if (is_per_component) +- instr->reg = allocate_numeric_registers_for_type(ctx, allocator, +- instr->index, instr->last_read, instr->data_type); ++ { ++ instr->reg.writemask = vkd3d_write_mask_from_component_count(instr->data_type->e.numeric.dimx); ++ instr->reg.allocation_size = 1; ++ instr->reg.allocated = true; ++ instr->reg.type = VKD3DSPR_TEMP; ++ instr->reg.id = ctx->temp_count++; ++ ++ record_allocation(ctx, allocator, ctx->temp_count - 1, VKD3DSP_WRITEMASK_ALL, 1, UINT_MAX, 0, false); ++ } + else + { + instr->reg.writemask = vkd3d_write_mask_from_component_count(instr->data_type->e.numeric.dimx); +@@ -6350,24 +6367,35 @@ static void allocate_instr_temp_register(struct hlsl_ctx *ctx, + static void allocate_variable_temp_register(struct hlsl_ctx *ctx, + struct hlsl_ir_var *var, struct register_allocator *allocator) + { ++ struct hlsl_reg *reg = &var->regs[HLSL_REGSET_NUMERIC]; ++ + if (var->is_input_semantic || var->is_output_semantic || var->is_uniform) + return; + +- if (!var->regs[HLSL_REGSET_NUMERIC].allocated && var->last_read) ++ if (!reg->allocated && var->last_read) + { + if (var->indexable) + { +- var->regs[HLSL_REGSET_NUMERIC].id = allocator->indexable_count++; +- var->regs[HLSL_REGSET_NUMERIC].allocation_size = 1; +- var->regs[HLSL_REGSET_NUMERIC].writemask = 0; +- var->regs[HLSL_REGSET_NUMERIC].allocated = true; ++ reg->id = allocator->indexable_count++; ++ reg->allocation_size = 1; ++ reg->writemask = 0; ++ reg->allocated = true; + +- TRACE("Allocated %s to x%u[].\n", var->name, var->regs[HLSL_REGSET_NUMERIC].id); ++ TRACE("Allocated %s to x%u[].\n", var->name, reg->id); + } + else + { +- var->regs[HLSL_REGSET_NUMERIC] = allocate_numeric_registers_for_type(ctx, allocator, +- var->first_write, var->last_read, var->data_type); ++ reg->type = VKD3DSPR_TEMP; ++ reg->id = ctx->temp_count; ++ reg->allocation_size = align(var->data_type->reg_size[HLSL_REGSET_NUMERIC], 4) / 4; ++ if (var->data_type->class <= HLSL_CLASS_VECTOR) ++ reg->writemask = vkd3d_write_mask_from_component_count(var->data_type->e.numeric.dimx); ++ reg->allocated = true; ++ ++ for (unsigned int i = 0; i < reg->allocation_size; ++i) ++ record_allocation(ctx, allocator, ctx->temp_count + i, VKD3DSP_WRITEMASK_ALL, 1, UINT_MAX, 0, false); ++ ++ ctx->temp_count += reg->allocation_size; + + TRACE("Allocated %s to %s (liveness %u-%u).\n", var->name, + debug_register(var->regs[HLSL_REGSET_NUMERIC], var->data_type), var->first_write, var->last_read); +@@ -6553,7 +6581,6 @@ static void allocate_const_registers_recurse(struct hlsl_ctx *ctx, + } + + constant->reg = allocate_numeric_registers_for_type(ctx, allocator, 1, UINT_MAX, type); +- constant->reg.type = VKD3DSPR_CONST; + TRACE("Allocated constant @%u to %s.\n", instr->index, debug_register(constant->reg, type)); + + for (unsigned int x = 0, i = 0; x < 4; ++x) +@@ -6651,7 +6678,6 @@ static void allocate_sincos_const_registers(struct hlsl_ctx *ctx, struct hlsl_bl + type = hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 4); + + ctx->d3dsincosconst1 = allocate_numeric_registers_for_type(ctx, allocator, 1, UINT_MAX, type); +- ctx->d3dsincosconst1.type = VKD3DSPR_CONST; + TRACE("Allocated D3DSINCOSCONST1 to %s.\n", debug_register(ctx->d3dsincosconst1, type)); + record_constant(ctx, ctx->d3dsincosconst1.id * 4 + 0, -1.55009923e-06f, &instr->loc); + record_constant(ctx, ctx->d3dsincosconst1.id * 4 + 1, -2.17013894e-05f, &instr->loc); +@@ -6659,7 +6685,6 @@ static void allocate_sincos_const_registers(struct hlsl_ctx *ctx, struct hlsl_bl + record_constant(ctx, ctx->d3dsincosconst1.id * 4 + 3, 2.60416680e-04f, &instr->loc); + + ctx->d3dsincosconst2 = allocate_numeric_registers_for_type(ctx, allocator, 1, UINT_MAX, type); +- ctx->d3dsincosconst2.type = VKD3DSPR_CONST; + TRACE("Allocated D3DSINCOSCONST2 to %s.\n", debug_register(ctx->d3dsincosconst2, type)); + record_constant(ctx, ctx->d3dsincosconst2.id * 4 + 0, -2.08333340e-02f, &instr->loc); + record_constant(ctx, ctx->d3dsincosconst2.id * 4 + 1, -1.25000000e-01f, &instr->loc); +@@ -6673,8 +6698,7 @@ static void allocate_sincos_const_registers(struct hlsl_ctx *ctx, struct hlsl_bl + + static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_block *body) + { +- struct register_allocator allocator_used = {0}; +- struct register_allocator allocator = {0}; ++ struct register_allocator allocator = {.type = VKD3DSPR_CONST}, allocator_used = {.type = VKD3DSPR_CONST}; + struct hlsl_ir_var *var; + + sort_uniforms_by_bind_count(ctx, HLSL_REGSET_NUMERIC); +@@ -6730,7 +6754,6 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_block *bo + if (!var->regs[HLSL_REGSET_NUMERIC].allocated) + { + var->regs[HLSL_REGSET_NUMERIC] = allocate_range(ctx, &allocator, 1, UINT_MAX, alloc_size, 0, false); +- var->regs[HLSL_REGSET_NUMERIC].type = VKD3DSPR_CONST; + TRACE("Allocated %s to %s.\n", var->name, + debug_register(var->regs[HLSL_REGSET_NUMERIC], var->data_type)); + } +@@ -6747,9 +6770,9 @@ static void allocate_const_registers(struct hlsl_ctx *ctx, struct hlsl_block *bo + * index to all (simultaneously live) variables or intermediate values. Agnostic + * as to how many registers are actually available for the current backend, and + * does not handle constants. */ +-static uint32_t allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_block *body, struct list *semantic_vars) ++static void allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_block *body, struct list *semantic_vars) + { +- struct register_allocator allocator = {0}; ++ struct register_allocator allocator = {.type = VKD3DSPR_TEMP}; + struct hlsl_scope *scope; + struct hlsl_ir_var *var; + +@@ -6772,6 +6795,7 @@ static uint32_t allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_block + { + record_allocation(ctx, &allocator, 0, VKD3DSP_WRITEMASK_ALL, + var->first_write, UINT_MAX, 0, false); ++ ctx->temp_count = 1; + break; + } + } +@@ -6779,16 +6803,6 @@ static uint32_t allocate_temp_registers(struct hlsl_ctx *ctx, struct hlsl_block + + allocate_temp_registers_recurse(ctx, body, &allocator); + vkd3d_free(allocator.allocations); +- +- if (allocator.indexable_count) +- TRACE("Declaration of %s function required %u temp registers, and %u indexable temps.\n", +- ctx->is_patch_constant_func ? "patch constant" : "main", +- allocator.reg_count, allocator.indexable_count); +- else +- TRACE("Declaration of %s function required %u temp registers.\n", +- ctx->is_patch_constant_func ? "patch constant" : "main", allocator.reg_count); +- +- return allocator.reg_count; + } + + static enum vkd3d_shader_interpolation_mode sm4_get_interpolation_mode(struct hlsl_type *type, +@@ -6929,7 +6943,6 @@ static void allocate_semantic_register(struct hlsl_ctx *ctx, struct hlsl_ir_var + + var->regs[HLSL_REGSET_NUMERIC] = allocate_register(ctx, allocator, 1, UINT_MAX, + reg_size, component_count, mode, var->force_align, vip_allocation); +- var->regs[HLSL_REGSET_NUMERIC].type = output ? VKD3DSPR_OUTPUT : VKD3DSPR_INPUT; + + TRACE("Allocated %s to %s (mode %d).\n", var->name, + debug_register(var->regs[HLSL_REGSET_NUMERIC], var->data_type), mode); +@@ -6944,11 +6957,17 @@ static void allocate_semantic_registers(struct hlsl_ctx *ctx, struct list *seman + bool is_pixel_shader = ctx->profile->type == VKD3D_SHADER_TYPE_PIXEL; + struct hlsl_ir_var *var; + ++ in_prim_allocator.type = VKD3DSPR_INPUT; + in_prim_allocator.prioritize_smaller_writemasks = true; ++ patch_constant_out_patch_allocator.type = VKD3DSPR_INPUT; + patch_constant_out_patch_allocator.prioritize_smaller_writemasks = true; ++ input_allocator.type = VKD3DSPR_INPUT; + input_allocator.prioritize_smaller_writemasks = true; + for (unsigned int i = 0; i < ARRAY_SIZE(output_allocators); ++i) ++ { ++ output_allocators[i].type = VKD3DSPR_OUTPUT; + output_allocators[i].prioritize_smaller_writemasks = true; ++ } + + LIST_FOR_EACH_ENTRY(var, semantic_vars, struct hlsl_ir_var, extern_entry) + { +@@ -10210,7 +10229,8 @@ static void sm1_generate_vsir(struct hlsl_ctx *ctx, const struct vkd3d_shader_co + struct hlsl_block block; + + program->ssa_count = 0; +- program->temp_count = allocate_temp_registers(ctx, body, semantic_vars); ++ program->temp_count = 0; ++ allocate_temp_registers(ctx, body, semantic_vars); + if (ctx->result) + return; + +@@ -10222,6 +10242,7 @@ static void sm1_generate_vsir(struct hlsl_ctx *ctx, const struct vkd3d_shader_co + sm1_generate_vsir_block(ctx, body, program); + + program->ssa_count = ctx->ssa_count; ++ program->temp_count = ctx->temp_count; + + if (ctx->result) + return; +@@ -12370,16 +12391,15 @@ static void sm4_generate_vsir_add_function(struct hlsl_ctx *ctx, struct list *se + struct hlsl_block block = {0}; + struct hlsl_scope *scope; + struct hlsl_ir_var *var; +- uint32_t temp_count; + + ctx->is_patch_constant_func = func == ctx->patch_constant_func; + + compute_liveness(ctx, body); + mark_indexable_vars(ctx, body); +- temp_count = allocate_temp_registers(ctx, body, semantic_vars); ++ allocate_temp_registers(ctx, body, semantic_vars); + if (ctx->result) + return; +- program->temp_count = max(program->temp_count, temp_count); ++ program->temp_count = max(program->temp_count, ctx->temp_count); + + hlsl_block_init(&block); + +@@ -12390,8 +12410,8 @@ static void sm4_generate_vsir_add_function(struct hlsl_ctx *ctx, struct list *se + sm4_generate_vsir_instr_dcl_semantic(ctx, program, var, &block, &var->loc); + } + +- if (temp_count) +- sm4_generate_vsir_instr_dcl_temps(ctx, program, temp_count, &block, &func->loc); ++ if (ctx->temp_count) ++ sm4_generate_vsir_instr_dcl_temps(ctx, program, ctx->temp_count, &block, &func->loc); + + LIST_FOR_EACH_ENTRY(scope, &ctx->scopes, struct hlsl_scope, entry) + { +@@ -13061,6 +13081,7 @@ static void sm4_generate_vsir(struct hlsl_ctx *ctx, + } + + program->ssa_count = 0; ++ program->temp_count = 0; + + if (version->type == VKD3D_SHADER_TYPE_HULL) + generate_vsir_add_program_instruction(ctx, program, +@@ -13078,6 +13099,7 @@ static void sm4_generate_vsir(struct hlsl_ctx *ctx, + generate_vsir_scan_global_flags(ctx, program, semantic_vars, func); + + program->ssa_count = ctx->ssa_count; ++ program->temp_count = ctx->temp_count; + } + + /* For some reason, for matrices, values from default value initializers end +diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c +index 1ab406a9d84..b120801d5f9 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/ir.c ++++ b/libs/vkd3d/libs/vkd3d-shader/ir.c +@@ -45,6 +45,33 @@ static void vsir_transformation_context_init(struct vsir_transformation_context + }; + }; + ++const char *vsir_data_type_get_name(enum vsir_data_type t, const char *error) ++{ ++ static const char * const names[] = ++ { ++ [VSIR_DATA_BOOL ] = "bool", ++ [VSIR_DATA_F16 ] = "half", ++ [VSIR_DATA_F32 ] = "float", ++ [VSIR_DATA_F64 ] = "double", ++ [VSIR_DATA_I32 ] = "int", ++ [VSIR_DATA_U8 ] = "uint8", ++ [VSIR_DATA_U16 ] = "uint16", ++ [VSIR_DATA_U32 ] = "uint", ++ [VSIR_DATA_U64 ] = "uint64", ++ [VSIR_DATA_SNORM ] = "snorm", ++ [VSIR_DATA_UNORM ] = "unorm", ++ [VSIR_DATA_OPAQUE ] = "opaque", ++ [VSIR_DATA_MIXED ] = "mixed", ++ [VSIR_DATA_CONTINUED] = "", ++ [VSIR_DATA_UNUSED ] = "", ++ }; ++ ++ if ((size_t)t < ARRAY_SIZE(names)) ++ return names[t] ? names[t] : error; ++ ++ return error; ++} ++ + const char *vsir_opcode_get_name(enum vkd3d_shader_opcode op, const char *error) + { + static const char * const names[] = +@@ -8428,7 +8455,7 @@ struct liveness_tracker + bool fixed_mask; + uint8_t mask; + unsigned int first_write, last_access; +- } *ssa_regs; ++ } *ssa_regs, *temp_regs; + }; + + static void liveness_track_src(struct liveness_tracker *tracker, +@@ -8442,6 +8469,8 @@ static void liveness_track_src(struct liveness_tracker *tracker, + + if (src->reg.type == VKD3DSPR_SSA) + tracker->ssa_regs[src->reg.idx[0].offset].last_access = index; ++ else if (src->reg.type == VKD3DSPR_TEMP) ++ tracker->temp_regs[src->reg.idx[0].offset].last_access = index; + } + + static void liveness_track_dst(struct liveness_tracker *tracker, struct vkd3d_shader_dst_param *dst, +@@ -8457,6 +8486,8 @@ static void liveness_track_dst(struct liveness_tracker *tracker, struct vkd3d_sh + + if (dst->reg.type == VKD3DSPR_SSA) + reg = &tracker->ssa_regs[dst->reg.idx[0].offset]; ++ else if (dst->reg.type == VKD3DSPR_TEMP) ++ reg = &tracker->temp_regs[dst->reg.idx[0].offset]; + else + return; + +@@ -8552,9 +8583,10 @@ static enum vkd3d_result track_liveness(struct vsir_program *program, struct liv + + memset(tracker, 0, sizeof(*tracker)); + +- if (!(regs = vkd3d_calloc(program->ssa_count, sizeof(*regs)))) ++ if (!(regs = vkd3d_calloc(program->ssa_count + program->temp_count, sizeof(*regs)))) + return VKD3D_ERROR_OUT_OF_MEMORY; + tracker->ssa_regs = regs; ++ tracker->temp_regs = ®s[program->ssa_count]; + + for (ins = vsir_program_iterator_head(&it), i = 0; ins; ins = vsir_program_iterator_next(&it), ++i) + { +@@ -8583,8 +8615,7 @@ static enum vkd3d_result track_liveness(struct vsir_program *program, struct liv + * should be illegal for an SSA value to be read in a block + * containing L.) + * We don't try to perform this optimization yet, in the name of +- * maximal simplicity, and also because this code is intended to +- * be extended to non-SSA values. */ ++ * maximal simplicity. */ + for (unsigned int j = 0; j < program->ssa_count; ++j) + { + struct liveness_tracker_reg *reg = &tracker->ssa_regs[j]; +@@ -8594,6 +8625,16 @@ static enum vkd3d_result track_liveness(struct vsir_program *program, struct liv + if (reg->last_access < i) + reg->last_access = i; + } ++ ++ for (unsigned int j = 0; j < program->temp_count; ++j) ++ { ++ struct liveness_tracker_reg *reg = &tracker->temp_regs[j]; ++ ++ if (reg->first_write > loop_start) ++ reg->first_write = loop_start; ++ if (reg->last_access < i) ++ reg->last_access = i; ++ } + } + } + +@@ -8613,8 +8654,8 @@ struct temp_allocator + { + uint8_t allocated_mask; + uint32_t temp_id; +- } *ssa_regs; +- size_t allocated_ssa_count; ++ } *ssa_regs, *temp_regs; ++ size_t allocated_ssa_count, allocated_temp_count; + enum vkd3d_result result; + }; + +@@ -8641,16 +8682,30 @@ static uint8_t get_available_writemask(const struct temp_allocator *allocator, + return writemask; + } + ++ for (size_t i = 0; i < allocator->allocated_temp_count; ++i) ++ { ++ const struct temp_allocator_reg *reg = &allocator->temp_regs[i]; ++ const struct liveness_tracker_reg *liveness_reg = &tracker->temp_regs[i]; ++ ++ if (reg->temp_id == temp_id ++ && first_write < liveness_reg->last_access ++ && last_access > liveness_reg->first_write) ++ writemask &= ~reg->allocated_mask; ++ ++ if (!writemask) ++ return writemask; ++ } ++ + return writemask; + } + + static bool temp_allocator_allocate(struct temp_allocator *allocator, struct liveness_tracker *tracker, +- struct temp_allocator_reg *reg, const struct liveness_tracker_reg *liveness_reg, uint32_t base_id) ++ struct temp_allocator_reg *reg, const struct liveness_tracker_reg *liveness_reg) + { + if (!liveness_reg->written) + return false; + +- for (uint32_t id = base_id;; ++id) ++ for (uint32_t id = 0;; ++id) + { + uint8_t available_mask = get_available_writemask(allocator, tracker, + liveness_reg->first_write, liveness_reg->last_access, id); +@@ -8667,13 +8722,21 @@ static bool temp_allocator_allocate(struct temp_allocator *allocator, struct liv + else + { + /* For SSA values the mask is always zero-based and contiguous. +- * We don't correctly handle cases where it's not, currently. */ +- VKD3D_ASSERT((liveness_reg->mask | (liveness_reg->mask - 1)) == liveness_reg->mask); +- +- if (vkd3d_popcount(available_mask) >= vkd3d_popcount(liveness_reg->mask)) ++ * For TEMP values we assume the register was allocated that way, ++ * but it may only be partially used. ++ * We currently only handle cases where the mask is zero-based and ++ * contiguous, so we need to fill in the missing components to ++ * ensure this. */ ++ uint8_t mask = (1u << (vkd3d_log2i(liveness_reg->mask) + 1)) - 1; ++ ++ if (vkd3d_popcount(available_mask) >= vkd3d_popcount(mask)) + { ++ if (mask != liveness_reg->mask) ++ WARN("Allocating a mask %#x with used components %#x; this is not optimized.\n", ++ mask, liveness_reg->mask); ++ + reg->temp_id = id; +- reg->allocated_mask = vsir_combine_write_masks(available_mask, liveness_reg->mask); ++ reg->allocated_mask = vsir_combine_write_masks(available_mask, mask); + return true; + } + } +@@ -8692,6 +8755,8 @@ static void temp_allocator_set_src(struct temp_allocator *allocator, struct vkd3 + + if (src->reg.type == VKD3DSPR_SSA) + reg = &allocator->ssa_regs[src->reg.idx[0].offset]; ++ else if (src->reg.type == VKD3DSPR_TEMP) ++ reg = &allocator->temp_regs[src->reg.idx[0].offset]; + else + return; + +@@ -8771,6 +8836,7 @@ static void temp_allocator_set_dst(struct temp_allocator *allocator, + struct vkd3d_shader_dst_param *dst, const struct vkd3d_shader_instruction *ins) + { + struct temp_allocator_reg *reg; ++ uint32_t remapped_mask; + + for (unsigned int k = 0; k < dst->reg.idx_count; ++k) + { +@@ -8780,15 +8846,18 @@ static void temp_allocator_set_dst(struct temp_allocator *allocator, + + if (dst->reg.type == VKD3DSPR_SSA) + reg = &allocator->ssa_regs[dst->reg.idx[0].offset]; ++ else if (dst->reg.type == VKD3DSPR_TEMP) ++ reg = &allocator->temp_regs[dst->reg.idx[0].offset]; + else + return; + + dst->reg.type = VKD3DSPR_TEMP; + dst->reg.dimension = VSIR_DIMENSION_VEC4; + dst->reg.idx[0].offset = reg->temp_id; +- if (reg->allocated_mask != dst->write_mask) ++ remapped_mask = vsir_combine_write_masks(reg->allocated_mask, dst->write_mask); ++ if (dst->write_mask != remapped_mask) + { +- dst->write_mask = reg->allocated_mask; ++ dst->write_mask = remapped_mask; + + if (vsir_opcode_is_double(ins->opcode)) + { +@@ -8804,16 +8873,32 @@ static void temp_allocator_set_dst(struct temp_allocator *allocator, + if (vsir_src_is_masked(ins->opcode, i)) + { + if (src->reg.type == VKD3DSPR_IMMCONST) +- vsir_remap_immconst(src, dst->write_mask); ++ vsir_remap_immconst(src, reg->allocated_mask); + else if (src->reg.type == VKD3DSPR_IMMCONST64) +- vsir_remap_immconst64(src, dst->write_mask); ++ vsir_remap_immconst64(src, reg->allocated_mask); + else +- src->swizzle = vsir_map_swizzle(src->swizzle, dst->write_mask); ++ src->swizzle = vsir_map_swizzle(src->swizzle, reg->allocated_mask); + } + } + } + } + ++/* This pass does two things: ++ * ++ * - converts SSA registers (sr#) into temp registers (r#); ++ * ++ * - contracts temp registers with non-overlapping ranges by reallocating them ++ * into the same register. ++ * ++ * These are done at the same time so that SSA and temp registers with ++ * non-overlapping liveness can share the same register. ++ * ++ * The temp contraction is not particularly sophisticated. In particular, it ++ * does not detect cases where a single temp register has multiple disjoint ++ * ranges of liveness, and it also assumes that the components used by a single ++ * registers is zero-based and contiguous. ++ * The intent for temp contraction is that HLSL will output each distinct ++ * variable to a unique temp ID. */ + enum vkd3d_result vsir_allocate_temp_registers(struct vsir_program *program, + struct vkd3d_shader_message_context *message_context) + { +@@ -8825,28 +8910,53 @@ enum vkd3d_result vsir_allocate_temp_registers(struct vsir_program *program, + struct liveness_tracker tracker; + enum vkd3d_result ret; + +- if (!program->ssa_count) ++ if (!program->ssa_count && !prev_temp_count) + return VKD3D_OK; + + if ((ret = track_liveness(program, &tracker))) + return ret; + +- if (!(regs = vkd3d_calloc(program->ssa_count, sizeof(*regs)))) ++ if (!(regs = vkd3d_calloc(program->ssa_count + prev_temp_count, sizeof(*regs)))) + { + liveness_tracker_cleanup(&tracker); + return VKD3D_ERROR_OUT_OF_MEMORY; + } + allocator.message_context = message_context; + allocator.ssa_regs = regs; ++ allocator.temp_regs = regs + program->ssa_count; ++ ++ program->temp_count = 0; ++ ++ /* Reallocate temps first. We do this specifically to make sure that r0 is ++ * the first register to be allocated, and thus will be reallocated in ++ * place, and left alone. ++ * This is necessary because, in pixel shader model 1.x, r0 doubles as the ++ * output register, and needs to remain at r0. (Note that we need to already ++ * have the output in r0, rather than e.g. putting it in o0 and converting ++ * it to r0 after this pass, so that we know when r0 is live.) */ ++ for (unsigned int i = 0; i < prev_temp_count; ++i) ++ { ++ const struct liveness_tracker_reg *liveness_reg = &tracker.temp_regs[i]; ++ struct temp_allocator_reg *reg = &allocator.temp_regs[i]; ++ ++ if (temp_allocator_allocate(&allocator, &tracker, reg, liveness_reg)) ++ { ++ TRACE("Reallocated r%u%s for r%u (liveness %u-%u).\n", ++ reg->temp_id, debug_vsir_writemask(reg->allocated_mask), i, ++ liveness_reg->first_write, liveness_reg->last_access); ++ program->temp_count = max(program->temp_count, reg->temp_id + 1); ++ } ++ ++allocator.allocated_temp_count; ++ } + + for (unsigned int i = 0; i < program->ssa_count; ++i) + { + const struct liveness_tracker_reg *liveness_reg = &tracker.ssa_regs[i]; + struct temp_allocator_reg *reg = &allocator.ssa_regs[i]; + +- if (temp_allocator_allocate(&allocator, &tracker, reg, liveness_reg, prev_temp_count)) ++ if (temp_allocator_allocate(&allocator, &tracker, reg, liveness_reg)) + { +- TRACE("Allocated r%u%s to sr%u (liveness %u-%u).\n", ++ TRACE("Allocated r%u%s for sr%u (liveness %u-%u).\n", + reg->temp_id, debug_vsir_writemask(reg->allocated_mask), i, + liveness_reg->first_write, liveness_reg->last_access); + program->temp_count = max(program->temp_count, reg->temp_id + 1); +@@ -9441,7 +9551,8 @@ static void vsir_validate_label_register(struct validation_context *ctx, + + if (reg->data_type != VSIR_DATA_UNUSED) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, +- "Invalid data type %#x for a LABEL register.", reg->data_type); ++ "Invalid data type \"%s\" (%#x) for a LABEL register.", ++ vsir_data_type_get_name(reg->data_type, ""), reg->data_type); + + if (reg->dimension != VSIR_DIMENSION_NONE) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION, +@@ -9520,7 +9631,8 @@ static void vsir_validate_sampler_register(struct validation_context *ctx, + + if (reg->data_type != VSIR_DATA_UNUSED) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, +- "Invalid data type %#x for a SAMPLER register.", reg->data_type); ++ "Invalid data type \"%s\" (%#x) for a SAMPLER register.", ++ vsir_data_type_get_name(reg->data_type, ""), reg->data_type); + + /* VEC4 is allowed in gather operations. */ + if (reg->dimension == VSIR_DIMENSION_SCALAR) +@@ -9546,7 +9658,8 @@ static void vsir_validate_resource_register(struct validation_context *ctx, + + if (reg->data_type != VSIR_DATA_UNUSED) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, +- "Invalid data type %#x for a RESOURCE register.", reg->data_type); ++ "Invalid data type \"%s\" (%#x) for a RESOURCE register.", ++ vsir_data_type_get_name(reg->data_type, ""), reg->data_type); + + if (reg->dimension != VSIR_DIMENSION_VEC4) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DIMENSION, +@@ -9572,8 +9685,8 @@ static void vsir_validate_uav_register(struct validation_context *ctx, + + if (reg->data_type != VSIR_DATA_UNUSED) + validator_error(ctx, VKD3D_SHADER_ERROR_VSIR_INVALID_DATA_TYPE, +- "Invalid data type %#x for a UAV register.", +- reg->data_type); ++ "Invalid data type \"%s\" (%#x) for a UAV register.", ++ vsir_data_type_get_name(reg->data_type, ""), reg->data_type); + + /* NONE is allowed in counter operations. */ + if (reg->dimension == VSIR_DIMENSION_SCALAR) +diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c +index a57c42b167d..058a631f25e 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c ++++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c +@@ -2518,7 +2518,7 @@ static uint32_t vkd3d_spirv_build_op_glsl_std450_nclamp(struct vkd3d_spirv_build + GLSLstd450NClamp, operands, ARRAY_SIZE(operands)); + } + +-static uint32_t vkd3d_spirv_get_type_id(struct vkd3d_spirv_builder *builder, ++static uint32_t spirv_get_type_id_for_component_type(struct vkd3d_spirv_builder *builder, + enum vkd3d_shader_component_type component_type, unsigned int component_count) + { + uint32_t scalar_id, type_id; +@@ -2564,7 +2564,7 @@ static uint32_t vkd3d_spirv_get_type_id(struct vkd3d_spirv_builder *builder, + else + { + VKD3D_ASSERT(component_type != VKD3D_SHADER_COMPONENT_VOID); +- scalar_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ scalar_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + type_id = vkd3d_spirv_get_op_type_vector(builder, scalar_id, component_count); + } + +@@ -2573,13 +2573,13 @@ static uint32_t vkd3d_spirv_get_type_id(struct vkd3d_spirv_builder *builder, + return type_id; + } + +-static uint32_t vkd3d_spirv_get_type_id_for_data_type(struct vkd3d_spirv_builder *builder, ++static uint32_t spirv_get_type_id(struct vkd3d_spirv_builder *builder, + enum vsir_data_type data_type, unsigned int component_count) + { + enum vkd3d_shader_component_type component_type; + + component_type = vkd3d_component_type_from_data_type(data_type); +- return vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ return spirv_get_type_id_for_component_type(builder, component_type, component_count); + } + + static void vkd3d_spirv_builder_init(struct vkd3d_spirv_builder *builder, +@@ -3656,7 +3656,7 @@ static uint32_t spirv_compiler_get_constant(struct spirv_compiler *compiler, + unsigned int i; + + VKD3D_ASSERT(0 < component_count && component_count <= VKD3D_VEC4_SIZE); +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + + switch (component_type) + { +@@ -3683,7 +3683,7 @@ static uint32_t spirv_compiler_get_constant(struct spirv_compiler *compiler, + } + else + { +- scalar_type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ scalar_type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + for (i = 0; i < component_count; ++i) + component_ids[i] = vkd3d_spirv_get_op_constant(builder, scalar_type_id, values[i]); + return vkd3d_spirv_get_op_constant_composite(builder, type_id, component_ids, component_count); +@@ -3698,7 +3698,7 @@ static uint32_t spirv_compiler_get_constant64(struct spirv_compiler *compiler, + unsigned int i; + + VKD3D_ASSERT(0 < component_count && component_count <= VKD3D_DVEC2_SIZE); +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + + if (component_type != VKD3D_SHADER_COMPONENT_DOUBLE && component_type != VKD3D_SHADER_COMPONENT_UINT64) + { +@@ -3712,7 +3712,7 @@ static uint32_t spirv_compiler_get_constant64(struct spirv_compiler *compiler, + } + else + { +- scalar_type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ scalar_type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + for (i = 0; i < component_count; ++i) + component_ids[i] = vkd3d_spirv_get_op_constant64(builder, scalar_type_id, values[i]); + return vkd3d_spirv_get_op_constant_composite(builder, type_id, component_ids, component_count); +@@ -3772,9 +3772,7 @@ static uint32_t spirv_compiler_get_type_id_for_reg(struct spirv_compiler *compil + { + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + +- return vkd3d_spirv_get_type_id(builder, +- vkd3d_component_type_from_data_type(reg->data_type), +- vsir_write_mask_component_count(write_mask)); ++ return spirv_get_type_id(builder, reg->data_type, vsir_write_mask_component_count(write_mask)); + } + + static uint32_t spirv_compiler_get_type_id_for_dst(struct spirv_compiler *compiler, +@@ -3901,7 +3899,7 @@ static uint32_t spirv_compiler_emit_array_variable(struct spirv_compiler *compil + uint32_t type_id, length_id, ptr_type_id; + unsigned int i; + +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + for (i = 0; i < length_count; ++i) + { + if (!array_lengths[i]) +@@ -4000,8 +3998,8 @@ static uint32_t spirv_compiler_emit_spec_constant(struct spirv_compiler *compile + info = get_spec_constant_info(name); + default_value = info ? info->default_value.u : 0; + +- scalar_type_id = vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(type), 1); +- vector_type_id = vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(type), component_count); ++ scalar_type_id = spirv_get_type_id(builder, type, 1); ++ vector_type_id = spirv_get_type_id(builder, type, component_count); + + for (unsigned int i = 0; i < component_count; ++i) + { +@@ -4050,7 +4048,7 @@ static uint32_t spirv_compiler_get_buffer_parameter(struct spirv_compiler *compi + unsigned int index = parameter - compiler->program->parameters; + uint32_t type_id, ptr_id, ptr_type_id; + +- type_id = vkd3d_spirv_get_type_id(builder, vkd3d_component_type_from_data_type(type), component_count); ++ type_id = spirv_get_type_id(builder, type, component_count); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassUniform, type_id); + ptr_id = vkd3d_spirv_build_op_access_chain1(builder, ptr_type_id, + compiler->spirv_parameter_info[index].buffer_id, +@@ -4114,7 +4112,7 @@ static uint32_t spirv_compiler_emit_construct_vector(struct spirv_compiler *comp + + VKD3D_ASSERT(val_component_idx < val_component_count); + +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + if (val_component_count == 1) + { + for (i = 0; i < component_count; ++i) +@@ -4147,7 +4145,7 @@ static uint32_t spirv_compiler_emit_register_addressing(struct spirv_compiler *c + addr_id = spirv_compiler_emit_load_src(compiler, reg_index->rel_addr, VKD3DSP_WRITEMASK_0); + if (reg_index->offset) + { +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + addr_id = vkd3d_spirv_build_op_iadd(builder, type_id, + addr_id, spirv_compiler_get_constant_uint(compiler, reg_index->offset)); + } +@@ -4296,7 +4294,7 @@ static uint32_t spirv_compiler_get_descriptor_index(struct spirv_compiler *compi + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + uint32_t type_id, ptr_type_id, ptr_id, offset_id, index_ids[2]; + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + if (!(offset_id = compiler->descriptor_offset_ids[push_constant_index])) + { + index_ids[0] = compiler->descriptor_offsets_member_id; +@@ -4369,7 +4367,7 @@ static void spirv_compiler_emit_dereference_register(struct spirv_compiler *comp + if (index_count) + { + component_count = vsir_write_mask_component_count(register_info->write_mask); +- type_id = vkd3d_spirv_get_type_id(builder, register_info->component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, register_info->component_type, component_count); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, register_info->storage_class, type_id); + register_info->id = vkd3d_spirv_build_op_access_chain(builder, ptr_type_id, + register_info->id, indexes, index_count); +@@ -4428,7 +4426,7 @@ static uint32_t spirv_compiler_emit_swizzle(struct spirv_compiler *compiler, + && (component_count == 1 || vkd3d_swizzle_is_equal(val_write_mask, swizzle, write_mask))) + return val_id; + +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + + if (component_count == 1) + { +@@ -4479,7 +4477,7 @@ static uint32_t spirv_compiler_emit_vector_shuffle(struct spirv_compiler *compil + components[i] = VKD3D_VEC4_SIZE + vsir_swizzle_get_component(swizzle, i); + } + +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + return vkd3d_spirv_build_op_vector_shuffle(builder, + type_id, vector1_id, vector2_id, components, component_count); + } +@@ -4494,7 +4492,7 @@ static uint32_t spirv_compiler_emit_int_to_bool(struct spirv_compiler *compiler, + + VKD3D_ASSERT(!(condition & ~(VKD3D_SHADER_CONDITIONAL_OP_NZ | VKD3D_SHADER_CONDITIONAL_OP_Z))); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); + op = condition & VKD3D_SHADER_CONDITIONAL_OP_Z ? SpvOpIEqual : SpvOpINotEqual; + return vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, op, type_id, val_id, + data_type == VSIR_DATA_U64 +@@ -4510,7 +4508,7 @@ static uint32_t spirv_compiler_emit_bool_to_int(struct spirv_compiler *compiler, + + true_id = spirv_compiler_get_constant_uint_vector(compiler, signedness ? 0xffffffff : 1, component_count); + false_id = spirv_compiler_get_constant_uint_vector(compiler, 0, component_count); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, component_count); + return vkd3d_spirv_build_op_select(builder, type_id, val_id, true_id, false_id); + } + +@@ -4523,7 +4521,7 @@ static uint32_t spirv_compiler_emit_bool_to_int64(struct spirv_compiler *compile + true_id = spirv_compiler_get_constant_uint64_vector(compiler, signedness ? UINT64_MAX : 1, + component_count); + false_id = spirv_compiler_get_constant_uint64_vector(compiler, 0, component_count); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT64, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT64, component_count); + return vkd3d_spirv_build_op_select(builder, type_id, val_id, true_id, false_id); + } + +@@ -4535,7 +4533,7 @@ static uint32_t spirv_compiler_emit_bool_to_float(struct spirv_compiler *compile + + true_id = spirv_compiler_get_constant_float_vector(compiler, signedness ? -1.0f : 1.0f, component_count); + false_id = spirv_compiler_get_constant_float_vector(compiler, 0.0f, component_count); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, component_count); + return vkd3d_spirv_build_op_select(builder, type_id, val_id, true_id, false_id); + } + +@@ -4547,7 +4545,7 @@ static uint32_t spirv_compiler_emit_bool_to_double(struct spirv_compiler *compil + + true_id = spirv_compiler_get_constant_double_vector(compiler, signedness ? -1.0 : 1.0, component_count); + false_id = spirv_compiler_get_constant_double_vector(compiler, 0.0, component_count); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_DOUBLE, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_DOUBLE, component_count); + return vkd3d_spirv_build_op_select(builder, type_id, val_id, true_id, false_id); + } + +@@ -4614,7 +4612,8 @@ static uint32_t spirv_compiler_emit_load_undef(struct spirv_compiler *compiler, + + VKD3D_ASSERT(reg->type == VKD3DSPR_UNDEF); + +- type_id = vkd3d_spirv_get_type_id_for_data_type(builder, reg->data_type, component_count); ++ type_id = spirv_get_type_id(builder, reg->data_type, component_count); ++ + return vkd3d_spirv_get_op_undef(builder, type_id); + } + +@@ -4646,7 +4645,7 @@ static uint32_t spirv_compiler_emit_load_scalar(struct spirv_compiler *compiler, + component_idx, reg->type, reg->idx[0].offset, reg_info->write_mask); + } + +- type_id = vkd3d_spirv_get_type_id(builder, reg_info->component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, reg_info->component_type, 1); + reg_id = reg_info->id; + if (reg_component_count != 1) + { +@@ -4663,7 +4662,7 @@ static uint32_t spirv_compiler_emit_load_scalar(struct spirv_compiler *compiler, + { + if (reg_info->component_type != VKD3D_SHADER_COMPONENT_UINT) + { +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); + } + val_id = spirv_compiler_emit_int_to_bool(compiler, +@@ -4671,7 +4670,7 @@ static uint32_t spirv_compiler_emit_load_scalar(struct spirv_compiler *compiler, + } + else + { +- type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); + } + } +@@ -4691,7 +4690,7 @@ static uint32_t spirv_compiler_emit_constant_array(struct spirv_compiler *compil + + component_type = vkd3d_component_type_from_data_type(icb->data_type); + component_count = icb->component_count; +- elem_type_id = vkd3d_spirv_get_type_id_for_data_type(builder, icb->data_type, component_count); ++ elem_type_id = spirv_get_type_id(builder, icb->data_type, component_count); + length_id = spirv_compiler_get_constant_uint(compiler, element_count); + type_id = vkd3d_spirv_get_op_type_array(builder, elem_type_id, length_id); + +@@ -4777,7 +4776,7 @@ static uint32_t spirv_compiler_emit_load_reg(struct spirv_compiler *compiler, + + if (!spirv_compiler_get_register_info(compiler, reg, ®_info)) + { +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + return vkd3d_spirv_get_op_undef(builder, type_id); + } + spirv_compiler_emit_dereference_register(compiler, reg, ®_info); +@@ -4796,7 +4795,7 @@ static uint32_t spirv_compiler_emit_load_reg(struct spirv_compiler *compiler, + } + else + { +- type_id = vkd3d_spirv_get_type_id(builder, ++ type_id = spirv_get_type_id_for_component_type(builder, + reg_info.component_type, vsir_write_mask_component_count(reg_info.write_mask)); + val_id = vkd3d_spirv_build_op_load(builder, type_id, reg_info.id, SpvMemoryAccessMaskNone); + swizzle = data_type_is_64_bit(reg->data_type) ? vsir_swizzle_32_from_64(swizzle) : swizzle; +@@ -4811,7 +4810,7 @@ static uint32_t spirv_compiler_emit_load_reg(struct spirv_compiler *compiler, + { + if (reg_info.component_type != VKD3D_SHADER_COMPONENT_UINT) + { +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, component_count); + val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); + } + val_id = spirv_compiler_emit_int_to_bool(compiler, +@@ -4819,7 +4818,7 @@ static uint32_t spirv_compiler_emit_load_reg(struct spirv_compiler *compiler, + } + else + { +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); + } + } +@@ -4923,7 +4922,7 @@ static void spirv_compiler_emit_store_scalar(struct spirv_compiler *compiler, + + if (vsir_write_mask_component_count(dst_write_mask) > 1) + { +- type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id); + component_idx = vsir_write_mask_get_component_idx(write_mask); + component_idx -= vsir_write_mask_get_component_idx(dst_write_mask); +@@ -4951,7 +4950,7 @@ static void spirv_compiler_emit_store(struct spirv_compiler *compiler, + + if (dst_component_count == 1 && component_count != 1) + { +- type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + val_id = vkd3d_spirv_build_op_composite_extract1(builder, type_id, val_id, + vsir_write_mask_get_component_idx(dst_write_mask)); + write_mask &= dst_write_mask; +@@ -4966,7 +4965,7 @@ static void spirv_compiler_emit_store(struct spirv_compiler *compiler, + + if (dst_component_count != component_count) + { +- type_id = vkd3d_spirv_get_type_id(builder, component_type, dst_component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, dst_component_count); + dst_val_id = vkd3d_spirv_build_op_load(builder, type_id, dst_id, SpvMemoryAccessMaskNone); + + VKD3D_ASSERT(component_count <= ARRAY_SIZE(components)); +@@ -5018,7 +5017,7 @@ static void spirv_compiler_emit_store_reg(struct spirv_compiler *compiler, + if (component_type == VKD3D_SHADER_COMPONENT_BOOL) + val_id = spirv_compiler_emit_bool_to_int(compiler, + vsir_write_mask_component_count(src_write_mask), val_id, false); +- type_id = vkd3d_spirv_get_type_id(builder, reg_info.component_type, ++ type_id = spirv_get_type_id_for_component_type(builder, reg_info.component_type, + vsir_write_mask_component_count(src_write_mask)); + val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); + component_type = reg_info.component_type; +@@ -5101,7 +5100,7 @@ static void spirv_compiler_emit_store_dst_components(struct spirv_compiler *comp + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + uint32_t type_id, dst_type_id, val_id; + +- type_id = vkd3d_spirv_get_type_id(builder, component_type, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, component_count); + if (component_count > 1) + { + val_id = vkd3d_spirv_build_op_composite_construct(builder, +@@ -5112,7 +5111,7 @@ static void spirv_compiler_emit_store_dst_components(struct spirv_compiler *comp + val_id = *component_ids; + } + +- dst_type_id = vkd3d_spirv_get_type_id_for_data_type(builder, dst->reg.data_type, component_count); ++ dst_type_id = spirv_get_type_id(builder, dst->reg.data_type, component_count); + if (dst_type_id != type_id) + val_id = vkd3d_spirv_build_op_bitcast(builder, dst_type_id, val_id); + +@@ -5281,7 +5280,7 @@ static uint32_t spirv_compiler_emit_draw_parameter_fixup(struct spirv_compiler * + vkd3d_spirv_add_iface_variable(builder, base_var_id); + spirv_compiler_decorate_builtin(compiler, base_var_id, base); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_INT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_INT, 1); + base_id = vkd3d_spirv_build_op_load(builder, + type_id, base_var_id, SpvMemoryAccessMaskNone); + +@@ -5317,11 +5316,11 @@ static uint32_t frag_coord_fixup(struct spirv_compiler *compiler, + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + uint32_t type_id, w_id; + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, 1); + w_id = vkd3d_spirv_build_op_composite_extract1(builder, type_id, frag_coord_id, 3); + w_id = vkd3d_spirv_build_op_fdiv(builder, type_id, + spirv_compiler_get_constant_float(compiler, 1.0f), w_id); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); + return vkd3d_spirv_build_op_composite_insert1(builder, type_id, w_id, frag_coord_id, 3); + } + +@@ -5527,7 +5526,7 @@ static uint32_t spirv_compiler_emit_load_invocation_id(struct spirv_compiler *co + uint32_t type_id, id; + + id = spirv_compiler_get_invocation_id(compiler); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_INT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_INT, 1); + return vkd3d_spirv_build_op_load(builder, type_id, id, SpvMemoryAccessMaskNone); + } + +@@ -5867,7 +5866,7 @@ static void spirv_compiler_emit_input(struct spirv_compiler *compiler, + vsir_register_init(&dst_reg, reg_type, VSIR_DATA_F32, 1); + dst_reg.idx[0].offset = element_idx; + +- type_id = vkd3d_spirv_get_type_id(builder, component_type, input_component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, input_component_count); + + val_id = vkd3d_spirv_build_op_load(builder, type_id, input_id, SpvMemoryAccessMaskNone); + +@@ -5876,7 +5875,8 @@ static void spirv_compiler_emit_input(struct spirv_compiler *compiler, + + if (component_type != VKD3D_SHADER_COMPONENT_FLOAT) + { +- float_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, input_component_count); ++ float_type_id = spirv_get_type_id_for_component_type(builder, ++ VKD3D_SHADER_COMPONENT_FLOAT, input_component_count); + val_id = vkd3d_spirv_build_op_bitcast(builder, float_type_id, val_id); + } + +@@ -6225,7 +6225,7 @@ static void spirv_compiler_emit_store_shader_output(struct spirv_compiler *compi + + if (output_info->component_type != VKD3D_SHADER_COMPONENT_FLOAT) + { +- type_id = vkd3d_spirv_get_type_id(builder, output_info->component_type, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, output_info->component_type, VKD3D_VEC4_SIZE); + val_id = vkd3d_spirv_build_op_bitcast(builder, type_id, val_id); + } + +@@ -6250,7 +6250,7 @@ static void spirv_compiler_emit_store_shader_output(struct spirv_compiler *compi + output_id = output_info->id; + if (output_index_id) + { +- type_id = vkd3d_spirv_get_type_id(builder, ++ type_id = spirv_get_type_id_for_component_type(builder, + output_info->component_type, vsir_write_mask_component_count(dst_write_mask)); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassOutput, type_id); + output_id = vkd3d_spirv_build_op_access_chain1(builder, ptr_type_id, output_id, output_index_id); +@@ -6263,7 +6263,7 @@ static void spirv_compiler_emit_store_shader_output(struct spirv_compiler *compi + return; + } + +- type_id = vkd3d_spirv_get_type_id(builder, output_info->component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, output_info->component_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassOutput, type_id); + mask = output_info->array_element_mask; + array_idx = spirv_compiler_get_output_array_index(compiler, output); +@@ -6305,7 +6305,7 @@ static void spirv_compiler_emit_shader_epilogue_function(struct spirv_compiler * + function_id = compiler->epilogue_function_id; + + void_id = vkd3d_spirv_get_op_type_void(builder); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, 4); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, 4); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassPrivate, type_id); + for (i = 0, count = 0; i < ARRAY_SIZE(compiler->private_output_variable); ++i) + { +@@ -6536,7 +6536,7 @@ static void spirv_compiler_emit_dcl_indexable_temp(struct spirv_compiler *compil + vkd3d_spirv_begin_function_stream_insertion(builder, function_location); + + component_type = vkd3d_component_type_from_data_type(temp->data_type); +- type_id = vkd3d_spirv_get_type_id(builder, component_type, temp->component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, temp->component_count); + length_id = spirv_compiler_get_constant_uint(compiler, temp->register_size); + type_id = vkd3d_spirv_get_op_type_array(builder, type_id, length_id); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id); +@@ -6577,7 +6577,7 @@ static void spirv_compiler_emit_push_constant_buffers(struct spirv_compiler *com + if (!(member_ids = vkd3d_calloc(count, sizeof(*member_ids)))) + return; + +- vec4_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); ++ vec4_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); + + for (i = 0, j = 0; i < compiler->shader_interface.push_constant_buffer_count; ++i) + { +@@ -6594,7 +6594,7 @@ static void spirv_compiler_emit_push_constant_buffers(struct spirv_compiler *com + + if (compiler->offset_info.descriptor_table_count) + { +- uint32_t type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ uint32_t type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + length_id = spirv_compiler_get_constant_uint(compiler, compiler->offset_info.descriptor_table_count); + member_ids[j] = vkd3d_spirv_build_op_type_array(builder, type_id, length_id); + vkd3d_spirv_build_op_decorate1(builder, member_ids[j], SpvDecorationArrayStride, 4); +@@ -6788,7 +6788,7 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler, + return; + } + +- vec4_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); ++ vec4_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, VKD3D_VEC4_SIZE); + length_id = spirv_compiler_get_constant_uint(compiler, size); + array_type_id = vkd3d_spirv_build_op_type_array(builder, vec4_id, length_id); + vkd3d_spirv_build_op_decorate1(builder, array_type_id, SpvDecorationArrayStride, 16); +@@ -6927,7 +6927,7 @@ static uint32_t spirv_compiler_get_image_type_id(struct spirv_compiler *compiler + vkd3d_spirv_enable_capability(builder, SpvCapabilityStorageImageReadWithoutFormat); + } + +- sampled_type_id = vkd3d_spirv_get_type_id(builder, data_type, 1); ++ sampled_type_id = spirv_get_type_id_for_component_type(builder, data_type, 1); + return vkd3d_spirv_get_op_type_image(builder, sampled_type_id, resource_type_info->dim, + 2, resource_type_info->arrayed, resource_type_info->ms, + reg->type == VKD3DSPR_UAV ? 2 : 1, format); +@@ -7053,7 +7053,7 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp + { + uint32_t array_type_id, struct_id; + +- type_id = vkd3d_spirv_get_type_id(builder, sampled_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, sampled_type, 1); + + array_type_id = vkd3d_spirv_get_op_type_runtime_array(builder, type_id); + vkd3d_spirv_build_op_decorate1(builder, array_type_id, SpvDecorationArrayStride, 4); +@@ -7094,7 +7094,7 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp + { + VKD3D_ASSERT(structure_stride); /* counters are valid only for structured buffers */ + +- counter_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ counter_type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + if (spirv_compiler_is_opengl_target(compiler)) + { + vkd3d_spirv_enable_capability(builder, SpvCapabilityAtomicStorage); +@@ -7158,7 +7158,7 @@ static void spirv_compiler_emit_workgroup_memory(struct spirv_compiler *compiler + if (alignment) + TRACE("Ignoring alignment %u.\n", alignment); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + length_id = spirv_compiler_get_constant_uint(compiler, size); + array_type_id = vkd3d_spirv_get_op_type_array(builder, type_id, length_id); + +@@ -7878,7 +7878,8 @@ static void spirv_compiler_emit_ext_glsl_instruction(struct spirv_compiler *comp + component_count = vsir_write_mask_component_count(dst->write_mask); + uint_max_id = spirv_compiler_get_constant_uint_vector(compiler, UINT32_MAX, component_count); + condition_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, SpvOpIEqual, +- vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count), val_id, uint_max_id); ++ spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count), ++ val_id, uint_max_id); + rev_val_id = vkd3d_spirv_build_op_isub(builder, type_id, + spirv_compiler_get_constant_uint_vector(compiler, 31, component_count), val_id); + val_id = vkd3d_spirv_build_op_select(builder, type_id, condition_id, val_id, rev_val_id); +@@ -7928,7 +7929,7 @@ static void spirv_compiler_emit_mov(struct spirv_compiler *compiler, + dst_id = spirv_compiler_get_register_id(compiler, &dst->reg); + src_id = spirv_compiler_get_register_id(compiler, &src->reg); + +- type_id = vkd3d_spirv_get_type_id(builder, dst_reg_info.component_type, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, dst_reg_info.component_type, VKD3D_VEC4_SIZE); + val_id = vkd3d_spirv_build_op_load(builder, type_id, src_id, SpvMemoryAccessMaskNone); + dst_val_id = vkd3d_spirv_build_op_load(builder, type_id, dst_id, SpvMemoryAccessMaskNone); + +@@ -7957,7 +7958,7 @@ general_implementation: + val_id = spirv_compiler_emit_load_src(compiler, src, write_mask); + if (dst->reg.data_type != src->reg.data_type) + { +- val_id = vkd3d_spirv_build_op_bitcast(builder, vkd3d_spirv_get_type_id_for_data_type(builder, ++ val_id = vkd3d_spirv_build_op_bitcast(builder, spirv_get_type_id(builder, + dst->reg.data_type, vsir_write_mask_component_count(dst->write_mask)), val_id); + } + spirv_compiler_emit_store_dst(compiler, dst, val_id); +@@ -7983,8 +7984,8 @@ static void spirv_compiler_emit_movc(struct spirv_compiler *compiler, + { + if (instruction->opcode == VSIR_OP_CMP) + condition_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, SpvOpFOrdGreaterThanEqual, +- vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count), condition_id, +- spirv_compiler_get_constant_float_vector(compiler, 0.0f, component_count)); ++ spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count), ++ condition_id, spirv_compiler_get_constant_float_vector(compiler, 0.0f, component_count)); + else + condition_id = spirv_compiler_emit_int_to_bool(compiler, + VKD3D_SHADER_CONDITIONAL_OP_NZ, src[0].reg.data_type, component_count, condition_id); +@@ -8010,7 +8011,7 @@ static void spirv_compiler_emit_swapc(struct spirv_compiler *compiler, + src2_id = spirv_compiler_emit_load_src(compiler, &src[2], dst->write_mask); + + component_count = vsir_write_mask_component_count(dst->write_mask); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, component_count); + + condition_id = spirv_compiler_emit_int_to_bool(compiler, + VKD3D_SHADER_CONDITIONAL_OP_NZ, src[0].reg.data_type, component_count, condition_id); +@@ -8046,7 +8047,7 @@ static void spirv_compiler_emit_dot(struct spirv_compiler *compiler, + for (i = 0; i < ARRAY_SIZE(src_ids); ++i) + src_ids[i] = spirv_compiler_emit_load_src(compiler, &src[i], write_mask); + +- type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + + val_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, + SpvOpDot, type_id, src_ids[0], src_ids[1]); +@@ -8092,7 +8093,7 @@ static void spirv_compiler_emit_imad(struct spirv_compiler *compiler, + unsigned int i, component_count; + + component_count = vsir_write_mask_component_count(dst->write_mask); +- type_id = vkd3d_spirv_get_type_id_for_data_type(builder, dst->reg.data_type, component_count); ++ type_id = spirv_get_type_id(builder, dst->reg.data_type, component_count); + + for (i = 0; i < ARRAY_SIZE(src_ids); ++i) + src_ids[i] = spirv_compiler_emit_load_src(compiler, &src[i], dst->write_mask); +@@ -8146,7 +8147,7 @@ static void spirv_compiler_emit_ftoi(struct spirv_compiler *compiler, + component_type = vkd3d_component_type_from_data_type(dst->reg.data_type); + + int_max_id = spirv_compiler_get_constant_vector(compiler, component_type, component_count, INT_MAX); +- condition_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); ++ condition_type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); + condition_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, + SpvOpFOrdGreaterThanEqual, condition_type_id, val_id, float_max_id); + +@@ -8199,7 +8200,7 @@ static void spirv_compiler_emit_ftou(struct spirv_compiler *compiler, + val_id = vkd3d_spirv_build_op_glsl_std450_max(builder, src_type_id, src_id, zero_id); + + uint_max_id = spirv_compiler_get_constant_uint_vector(compiler, UINT_MAX, component_count); +- condition_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); ++ condition_type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); + condition_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, + SpvOpFOrdGreaterThanEqual, condition_type_id, val_id, float_max_id); + +@@ -8224,7 +8225,7 @@ static void spirv_compiler_emit_dtof(struct spirv_compiler *compiler, + + src_id = spirv_compiler_emit_load_src(compiler, src, write_mask); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, component_count); + val_id = vkd3d_spirv_build_op_tr1(builder, &builder->function_stream, SpvOpFConvert, type_id, src_id); + if (instruction->flags & VKD3DSI_PRECISE_XYZW) + vkd3d_spirv_build_op_decorate(builder, val_id, SpvDecorationNoContraction, NULL, 0); +@@ -8248,7 +8249,7 @@ static void spirv_compiler_emit_bitfield_instruction(struct spirv_compiler *comp + VKD3D_ASSERT(2 <= src_count && src_count <= ARRAY_SIZE(src_ids)); + + component_type = vkd3d_component_type_from_data_type(dst->reg.data_type); +- type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + size = (src[src_count - 1].reg.data_type == VSIR_DATA_U64) ? 0x40 : 0x20; + mask_id = spirv_compiler_get_constant_uint(compiler, size - 1); + size_id = spirv_compiler_get_constant_uint(compiler, size); +@@ -8305,8 +8306,8 @@ static void spirv_compiler_emit_f16tof32(struct spirv_compiler *compiler, + unsigned int i, j; + + instr_set_id = vkd3d_spirv_get_glsl_std450_instr_set(builder); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); +- scalar_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); ++ scalar_type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, 1); + + /* FIXME: Consider a single UnpackHalf2x16 instruction per 2 components. */ + VKD3D_ASSERT(dst->write_mask & VKD3DSP_WRITEMASK_ALL); +@@ -8338,8 +8339,8 @@ static void spirv_compiler_emit_f32tof16(struct spirv_compiler *compiler, + unsigned int i, j; + + instr_set_id = vkd3d_spirv_get_glsl_std450_instr_set(builder); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); +- scalar_type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); ++ scalar_type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + zero_id = spirv_compiler_get_constant_float(compiler, 0.0f); + + /* FIXME: Consider a single PackHalf2x16 instruction per 2 components. */ +@@ -8418,7 +8419,7 @@ static void spirv_compiler_emit_comparison_instruction(struct spirv_compiler *co + src0_id = spirv_compiler_emit_load_src(compiler, &src[0], write_mask); + src1_id = spirv_compiler_emit_load_src(compiler, &src[1], write_mask); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); + result_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, + op, type_id, src0_id, src1_id); + +@@ -8470,7 +8471,7 @@ static void spirv_compiler_emit_float_comparison_instruction(struct spirv_compil + src0_id = spirv_compiler_emit_load_src(compiler, &src[0], dst->write_mask); + src1_id = spirv_compiler_emit_load_src(compiler, &src[1], dst->write_mask); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, component_count); + result_id = vkd3d_spirv_build_op_tr2(builder, &builder->function_stream, op, type_id, src0_id, src1_id); + + result_id = spirv_compiler_emit_bool_to_float(compiler, component_count, result_id, false); +@@ -8999,7 +9000,7 @@ static void spirv_compiler_emit_ld(struct spirv_compiler *compiler, + + spirv_compiler_prepare_image(compiler, &image, &src[1].reg, NULL, VKD3D_IMAGE_FLAG_NONE); + +- type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, image.sampled_type, VKD3D_VEC4_SIZE); + coordinate_mask = (1u << image.resource_type_info->coordinate_component_count) - 1; + coordinate_id = spirv_compiler_emit_load_src(compiler, &src[0], coordinate_mask); + if (image.resource_type_info->resource_type != VKD3D_SHADER_RESOURCE_BUFFER && !multisample) +@@ -9045,7 +9046,7 @@ static void spirv_compiler_emit_lod(struct spirv_compiler *compiler, + spirv_compiler_prepare_image(compiler, &image, + &resource->reg, &sampler->reg, VKD3D_IMAGE_FLAG_SAMPLED); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); + coordinate_id = spirv_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_ALL); + val_id = vkd3d_spirv_build_op_image_query_lod(builder, + type_id, image.sampled_image_id, coordinate_id); +@@ -9115,7 +9116,7 @@ static void spirv_compiler_emit_sample(struct spirv_compiler *compiler, + instruction, image.resource_type_info); + } + +- sampled_type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, VKD3D_VEC4_SIZE); ++ sampled_type_id = spirv_get_type_id_for_component_type(builder, image.sampled_type, VKD3D_VEC4_SIZE); + coordinate_id = spirv_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_ALL); + VKD3D_ASSERT(image_operand_count <= ARRAY_SIZE(image_operands)); + val_id = vkd3d_spirv_build_op_image_sample(builder, op, sampled_type_id, +@@ -9160,7 +9161,7 @@ static void spirv_compiler_emit_sample_c(struct spirv_compiler *compiler, + instruction, image.resource_type_info); + } + +- sampled_type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, 1); ++ sampled_type_id = spirv_get_type_id_for_component_type(builder, image.sampled_type, 1); + coordinate_id = spirv_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_ALL); + dref_id = spirv_compiler_emit_load_src(compiler, &src[3], VKD3DSP_WRITEMASK_0); + val_id = vkd3d_spirv_build_op_image_sample_dref(builder, op, sampled_type_id, +@@ -9219,7 +9220,7 @@ static void spirv_compiler_emit_gather4(struct spirv_compiler *compiler, + instruction, image.resource_type_info); + } + +- sampled_type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, VKD3D_VEC4_SIZE); ++ sampled_type_id = spirv_get_type_id_for_component_type(builder, image.sampled_type, VKD3D_VEC4_SIZE); + coordinate_mask = (1u << image.resource_type_info->coordinate_component_count) - 1; + coordinate_id = spirv_compiler_emit_load_src(compiler, addr, coordinate_mask); + if (image_flags & VKD3D_IMAGE_FLAG_DEPTH) +@@ -9301,10 +9302,10 @@ static void spirv_compiler_emit_ld_raw_structured_srv_uav(struct spirv_compiler + + if (storage_buffer_uav) + { +- texel_type_id = vkd3d_spirv_get_type_id(builder, resource_symbol->info.resource.sampled_type, 1); ++ texel_type_id = spirv_get_type_id_for_component_type(builder, resource_symbol->info.resource.sampled_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassUniform, texel_type_id); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + base_coordinate_id = spirv_compiler_emit_raw_structured_addressing(compiler, + type_id, resource_symbol->info.resource.structure_stride, + &src[0], VKD3DSP_WRITEMASK_0, &src[1], VKD3DSP_WRITEMASK_0); +@@ -9336,11 +9337,11 @@ static void spirv_compiler_emit_ld_raw_structured_srv_uav(struct spirv_compiler + + spirv_compiler_prepare_image(compiler, &image, &resource->reg, NULL, VKD3D_IMAGE_FLAG_NONE); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + base_coordinate_id = spirv_compiler_emit_raw_structured_addressing(compiler, + type_id, image.structure_stride, &src[0], VKD3DSP_WRITEMASK_0, &src[1], VKD3DSP_WRITEMASK_0); + +- texel_type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, VKD3D_VEC4_SIZE); ++ texel_type_id = spirv_get_type_id_for_component_type(builder, image.sampled_type, VKD3D_VEC4_SIZE); + VKD3D_ASSERT(dst->write_mask & VKD3DSP_WRITEMASK_ALL); + for (i = 0, j = 0; i < VKD3D_VEC4_SIZE; ++i) + { +@@ -9379,7 +9380,7 @@ static void spirv_compiler_emit_ld_tgsm(struct spirv_compiler *compiler, + if (!spirv_compiler_get_register_info(compiler, &resource->reg, ®_info)) + return; + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, reg_info.storage_class, type_id); + base_coordinate_id = spirv_compiler_emit_raw_structured_addressing(compiler, + type_id, reg_info.structure_stride, &src[0], VKD3DSP_WRITEMASK_0, &src[1], VKD3DSP_WRITEMASK_0); +@@ -9438,10 +9439,10 @@ static void spirv_compiler_emit_store_uav_raw_structured(struct spirv_compiler * + + if (spirv_compiler_use_storage_buffer(compiler, &resource_symbol->info.resource)) + { +- type_id = vkd3d_spirv_get_type_id(builder, resource_symbol->info.resource.sampled_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, resource_symbol->info.resource.sampled_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassUniform, type_id); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + base_coordinate_id = spirv_compiler_emit_raw_structured_addressing(compiler, + type_id, resource_symbol->info.resource.structure_stride, + &src[0], VKD3DSP_WRITEMASK_0, &src[1], VKD3DSP_WRITEMASK_0); +@@ -9469,7 +9470,7 @@ static void spirv_compiler_emit_store_uav_raw_structured(struct spirv_compiler * + } + else + { +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + spirv_compiler_prepare_image(compiler, &image, &dst->reg, NULL, VKD3D_IMAGE_FLAG_NONE); + base_coordinate_id = spirv_compiler_emit_raw_structured_addressing(compiler, + type_id, image.structure_stride, &src[0], VKD3DSP_WRITEMASK_0, &src[1], VKD3DSP_WRITEMASK_0); +@@ -9512,7 +9513,7 @@ static void spirv_compiler_emit_store_tgsm(struct spirv_compiler *compiler, + if (!spirv_compiler_get_register_info(compiler, &dst->reg, ®_info)) + return; + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, reg_info.storage_class, type_id); + base_coordinate_id = spirv_compiler_emit_raw_structured_addressing(compiler, + type_id, reg_info.structure_stride, &src[0], VKD3DSP_WRITEMASK_0, &src[1], VKD3DSP_WRITEMASK_0); +@@ -9570,7 +9571,7 @@ static void spirv_compiler_emit_ld_uav_typed(struct spirv_compiler *compiler, + + if (spirv_compiler_use_storage_buffer(compiler, &resource_symbol->info.resource)) + { +- type_id = vkd3d_spirv_get_type_id(builder, resource_symbol->info.resource.sampled_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, resource_symbol->info.resource.sampled_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassUniform, type_id); + coordinate_id = spirv_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_0); + indices[0] = spirv_compiler_get_constant_uint(compiler, 0); +@@ -9585,7 +9586,7 @@ static void spirv_compiler_emit_ld_uav_typed(struct spirv_compiler *compiler, + else + { + spirv_compiler_prepare_image(compiler, &image, &src[1].reg, NULL, VKD3D_IMAGE_FLAG_NONE); +- type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, image.sampled_type, VKD3D_VEC4_SIZE); + coordinate_mask = (1u << image.resource_type_info->coordinate_component_count) - 1; + coordinate_id = spirv_compiler_emit_load_src(compiler, &src[0], coordinate_mask); + +@@ -9613,7 +9614,7 @@ static void spirv_compiler_emit_store_uav_typed(struct spirv_compiler *compiler, + + if (spirv_compiler_use_storage_buffer(compiler, &resource_symbol->info.resource)) + { +- type_id = vkd3d_spirv_get_type_id(builder, resource_symbol->info.resource.sampled_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, resource_symbol->info.resource.sampled_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassUniform, type_id); + coordinate_id = spirv_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_0); + indices[0] = spirv_compiler_get_constant_uint(compiler, 0); +@@ -9658,7 +9659,7 @@ static void spirv_compiler_emit_uav_counter_instruction(struct spirv_compiler *c + counter_id = resource_symbol->info.resource.uav_counter_id; + VKD3D_ASSERT(counter_id); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + + if (resource_symbol->info.resource.uav_counter_array) + { +@@ -9820,7 +9821,7 @@ static void spirv_compiler_emit_atomic_instruction(struct spirv_compiler *compil + } + } + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + if (structure_stride || raw) + { + VKD3D_ASSERT(!raw != !structure_stride); +@@ -9845,7 +9846,7 @@ static void spirv_compiler_emit_atomic_instruction(struct spirv_compiler *compil + if (spirv_compiler_use_storage_buffer(compiler, &resource_symbol->info.resource)) + { + component_type = resource_symbol->info.resource.sampled_type; +- type_id = vkd3d_spirv_get_type_id(builder, component_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassUniform, type_id); + operands[0] = spirv_compiler_get_constant_uint(compiler, 0); + operands[1] = coordinate_id; +@@ -9854,7 +9855,7 @@ static void spirv_compiler_emit_atomic_instruction(struct spirv_compiler *compil + else + { + component_type = image.sampled_type; +- type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, image.sampled_type, 1); + ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, SpvStorageClassImage, type_id); + sample_id = spirv_compiler_get_constant_uint(compiler, 0); + pointer_id = vkd3d_spirv_build_op_image_texel_pointer(builder, +@@ -9907,7 +9908,7 @@ static void spirv_compiler_emit_bufinfo(struct spirv_compiler *compiler, + { + resource_symbol = spirv_compiler_find_resource(compiler, &src->reg); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + val_id = vkd3d_spirv_build_op_array_length(builder, type_id, resource_symbol->id, 0); + write_mask = VKD3DSP_WRITEMASK_0; + } +@@ -9917,7 +9918,7 @@ static void spirv_compiler_emit_bufinfo(struct spirv_compiler *compiler, + + spirv_compiler_prepare_image(compiler, &image, &src->reg, NULL, VKD3D_IMAGE_FLAG_NONE); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + val_id = vkd3d_spirv_build_op_image_query_size(builder, type_id, image.image_id); + write_mask = VKD3DSP_WRITEMASK_0; + } +@@ -9927,7 +9928,7 @@ static void spirv_compiler_emit_bufinfo(struct spirv_compiler *compiler, + stride_id = spirv_compiler_get_constant_uint(compiler, image.structure_stride); + constituents[0] = vkd3d_spirv_build_op_udiv(builder, type_id, val_id, stride_id); + constituents[1] = stride_id; +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, ARRAY_SIZE(constituents)); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, ARRAY_SIZE(constituents)); + val_id = vkd3d_spirv_build_op_composite_construct(builder, + type_id, constituents, ARRAY_SIZE(constituents)); + write_mask |= VKD3DSP_WRITEMASK_1; +@@ -9966,14 +9967,14 @@ static void spirv_compiler_emit_resinfo(struct spirv_compiler *compiler, + size_component_count = image.resource_type_info->coordinate_component_count; + if (image.resource_type_info->dim == SpvDimCube) + --size_component_count; +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, size_component_count); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, size_component_count); + + supports_mipmaps = src[1].reg.type != VKD3DSPR_UAV && !image.resource_type_info->ms; + if (supports_mipmaps) + { + lod_id = spirv_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_0); + val_id = vkd3d_spirv_build_op_image_query_size_lod(builder, type_id, image.image_id, lod_id); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + miplevel_count_id = vkd3d_spirv_build_op_image_query_levels(builder, type_id, image.image_id); + } + else +@@ -9987,14 +9988,14 @@ static void spirv_compiler_emit_resinfo(struct spirv_compiler *compiler, + for (i = 0; i < 3 - size_component_count; ++i) + constituents[i + 1] = spirv_compiler_get_constant_uint(compiler, 0); + constituents[i + 1] = miplevel_count_id; +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, VKD3D_VEC4_SIZE); + val_id = vkd3d_spirv_build_op_composite_construct(builder, + type_id, constituents, i + 2); + + if (!(instruction->flags & VKD3DSI_RESINFO_UINT)) + { + component_type = VKD3D_SHADER_COMPONENT_FLOAT; +- type_id = vkd3d_spirv_get_type_id(builder, component_type, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, VKD3D_VEC4_SIZE); + val_id = vkd3d_spirv_build_op_convert_utof(builder, type_id, val_id); + if (instruction->flags & VKD3DSI_PRECISE_XYZW) + vkd3d_spirv_build_op_decorate(builder, val_id, SpvDecorationNoContraction, NULL, 0); +@@ -10022,7 +10023,7 @@ static uint32_t spirv_compiler_emit_query_sample_count(struct spirv_compiler *co + vkd3d_spirv_enable_capability(builder, SpvCapabilityImageQuery); + + spirv_compiler_prepare_image(compiler, &image, &src->reg, NULL, VKD3D_IMAGE_FLAG_NONE); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + val_id = vkd3d_spirv_build_op_image_query_samples(builder, type_id, image.image_id); + } + +@@ -10049,13 +10050,13 @@ static void spirv_compiler_emit_sample_info(struct spirv_compiler *compiler, + constituents[0] = val_id; + for (i = 1; i < VKD3D_VEC4_SIZE; ++i) + constituents[i] = spirv_compiler_get_constant_uint(compiler, 0); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, VKD3D_VEC4_SIZE); + val_id = vkd3d_spirv_build_op_composite_construct(builder, type_id, constituents, VKD3D_VEC4_SIZE); + + if (!(instruction->flags & VKD3DSI_SAMPLE_INFO_UINT)) + { + component_type = VKD3D_SHADER_COMPONENT_FLOAT; +- type_id = vkd3d_spirv_get_type_id(builder, component_type, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, component_type, VKD3D_VEC4_SIZE); + val_id = vkd3d_spirv_build_op_convert_utof(builder, type_id, val_id); + if (instruction->flags & VKD3DSI_PRECISE_XYZW) + vkd3d_spirv_build_op_decorate(builder, val_id, SpvDecorationNoContraction, NULL, 0); +@@ -10121,13 +10122,13 @@ static void spirv_compiler_emit_sample_position(struct spirv_compiler *compiler, + sample_count_id = spirv_compiler_emit_query_sample_count(compiler, &instruction->src[0]); + sample_index_id = spirv_compiler_emit_load_src(compiler, &instruction->src[1], VKD3DSP_WRITEMASK_0); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + index_id = vkd3d_spirv_build_op_iadd(builder, type_id, sample_count_id, sample_index_id); + index_id = vkd3d_spirv_build_op_isub(builder, + type_id, index_id, spirv_compiler_get_constant_uint(compiler, 1)); + + /* Validate sample index. */ +- bool_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_BOOL, 1); ++ bool_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_BOOL, 1); + id = vkd3d_spirv_build_op_logical_and(builder, bool_id, + vkd3d_spirv_build_op_uless_than(builder, bool_id, sample_index_id, sample_count_id), + vkd3d_spirv_build_op_uless_than_equal(builder, +@@ -10135,7 +10136,7 @@ static void spirv_compiler_emit_sample_position(struct spirv_compiler *compiler, + index_id = vkd3d_spirv_build_op_select(builder, type_id, + id, index_id, spirv_compiler_get_constant_uint(compiler, 0)); + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, 2); + if (!(id = compiler->sample_positions_id)) + { + length_id = spirv_compiler_get_constant_uint(compiler, ARRAY_SIZE(standard_sample_positions)); +@@ -10199,7 +10200,7 @@ static void spirv_compiler_emit_eval_attrib(struct spirv_compiler *compiler, + src_ids[src_count++] = spirv_compiler_emit_load_src(compiler, &src[1], VKD3DSP_WRITEMASK_0); + } + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_FLOAT, ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_FLOAT, + vsir_write_mask_component_count(register_info.write_mask)); + + instr_set_id = vkd3d_spirv_get_glsl_std450_instr_set(builder); +@@ -10334,9 +10335,8 @@ static void spirv_compiler_emit_quad_read_across(struct spirv_compiler *compiler + const struct vkd3d_shader_src_param *src = instruction->src; + uint32_t type_id, direction_type_id, direction_id, val_id; + +- type_id = vkd3d_spirv_get_type_id_for_data_type(builder, dst->reg.data_type, +- vsir_write_mask_component_count(dst->write_mask)); +- direction_type_id = vkd3d_spirv_get_type_id_for_data_type(builder, VSIR_DATA_U32, 1); ++ type_id = spirv_get_type_id(builder, dst->reg.data_type, vsir_write_mask_component_count(dst->write_mask)); ++ direction_type_id = spirv_get_type_id(builder, VSIR_DATA_U32, 1); + val_id = spirv_compiler_emit_load_src(compiler, src, dst->write_mask); + direction_id = map_quad_read_across_direction(instruction->opcode); + direction_id = vkd3d_spirv_get_op_constant(builder, direction_type_id, direction_id); +@@ -10355,14 +10355,12 @@ static void spirv_compiler_emit_quad_read_lane_at(struct spirv_compiler *compile + + if (!register_is_constant_or_undef(&src[1].reg)) + { +- FIXME("Unsupported non-constant quad read lane index.\n"); + spirv_compiler_error(compiler, VKD3D_SHADER_ERROR_SPV_NOT_IMPLEMENTED, + "Non-constant quad read lane indices are not supported."); + return; + } + +- type_id = vkd3d_spirv_get_type_id_for_data_type(builder, dst->reg.data_type, +- vsir_write_mask_component_count(dst->write_mask)); ++ type_id = spirv_get_type_id(builder, dst->reg.data_type, vsir_write_mask_component_count(dst->write_mask)); + val_id = spirv_compiler_emit_load_src(compiler, &src[0], dst->write_mask); + lane_id = spirv_compiler_emit_load_src(compiler, &src[1], VKD3DSP_WRITEMASK_0); + val_id = vkd3d_spirv_build_op_group_nonuniform_quad_broadcast(builder, type_id, val_id, lane_id); +@@ -10411,7 +10409,7 @@ static uint32_t spirv_compiler_emit_group_nonuniform_ballot(struct spirv_compile + struct vkd3d_spirv_builder *builder = &compiler->spirv_builder; + uint32_t type_id, val_id; + +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, VKD3D_VEC4_SIZE); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, VKD3D_VEC4_SIZE); + val_id = spirv_compiler_emit_load_src(compiler, src, VKD3DSP_WRITEMASK_0); + val_id = vkd3d_spirv_build_op_group_nonuniform_ballot(builder, type_id, val_id); + +@@ -10470,8 +10468,7 @@ static void spirv_compiler_emit_wave_alu_op(struct spirv_compiler *compiler, + + op = map_wave_alu_op(instruction->opcode, data_type_is_floating_point(src->reg.data_type)); + +- type_id = vkd3d_spirv_get_type_id_for_data_type(builder, dst->reg.data_type, +- vsir_write_mask_component_count(dst->write_mask)); ++ type_id = spirv_get_type_id(builder, dst->reg.data_type, vsir_write_mask_component_count(dst->write_mask)); + val_id = spirv_compiler_emit_load_src(compiler, &src[0], dst->write_mask); + + vkd3d_spirv_enable_capability(builder, SpvCapabilityGroupNonUniformArithmetic); +@@ -10495,7 +10492,7 @@ static void spirv_compiler_emit_wave_bit_count(struct spirv_compiler *compiler, + : SpvGroupOperationReduce; + + val_id = spirv_compiler_emit_group_nonuniform_ballot(compiler, instruction->src); +- type_id = vkd3d_spirv_get_type_id(builder, VKD3D_SHADER_COMPONENT_UINT, 1); ++ type_id = spirv_get_type_id_for_component_type(builder, VKD3D_SHADER_COMPONENT_UINT, 1); + val_id = vkd3d_spirv_build_op_group_nonuniform_ballot_bit_count(builder, type_id, group_op, val_id); + + spirv_compiler_emit_store_dst(compiler, dst, val_id); +@@ -10520,8 +10517,7 @@ static void spirv_compiler_emit_wave_read_lane_at(struct spirv_compiler *compile + const struct vkd3d_shader_src_param *src = instruction->src; + uint32_t type_id, lane_id, val_id; + +- type_id = vkd3d_spirv_get_type_id_for_data_type(builder, dst->reg.data_type, +- vsir_write_mask_component_count(dst->write_mask)); ++ type_id = spirv_get_type_id(builder, dst->reg.data_type, vsir_write_mask_component_count(dst->write_mask)); + val_id = spirv_compiler_emit_load_src(compiler, &src[0], dst->write_mask); + lane_id = spirv_compiler_emit_load_src(compiler, &src[1], VKD3DSP_WRITEMASK_0); + +@@ -10548,8 +10544,7 @@ static void spirv_compiler_emit_wave_read_lane_first(struct spirv_compiler *comp + const struct vkd3d_shader_src_param *src = instruction->src; + uint32_t type_id, val_id; + +- type_id = vkd3d_spirv_get_type_id_for_data_type(builder, dst->reg.data_type, +- vsir_write_mask_component_count(dst->write_mask)); ++ type_id = spirv_get_type_id(builder, dst->reg.data_type, vsir_write_mask_component_count(dst->write_mask)); + val_id = spirv_compiler_emit_load_src(compiler, src, dst->write_mask); + val_id = vkd3d_spirv_build_op_group_nonuniform_broadcast_first(builder, type_id, val_id); + +@@ -11081,7 +11076,7 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler, + { + uint32_t type_id, struct_id, ptr_type_id, var_id; + +- type_id = vkd3d_spirv_get_type_id(builder, ++ type_id = spirv_get_type_id_for_component_type(builder, + vkd3d_component_type_from_data_type(parameter_data_type_map[parameter->data_type].type), + parameter_data_type_map[parameter->data_type].component_count); + +diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h +index 4102fe53e67..698ad541359 100644 +--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h ++++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h +@@ -734,6 +734,8 @@ enum vsir_data_type + VSIR_DATA_TYPE_COUNT, + }; + ++const char *vsir_data_type_get_name(enum vsir_data_type t, const char *error); ++ + static inline bool data_type_is_integer(enum vsir_data_type data_type) + { + return data_type == VSIR_DATA_I32 || data_type == VSIR_DATA_U8 || data_type == VSIR_DATA_U16 +-- +2.50.1 +