mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
304 lines
13 KiB
Diff
304 lines
13 KiB
Diff
From 3bca6a7e645ca8f48f2ec73a13b63a412cb7f2be Mon Sep 17 00:00:00 2001
|
|
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
|
Date: Wed, 25 Sep 2024 07:29:36 +1000
|
|
Subject: [PATCH] Updated vkd3d to e8b14d765dbebae32d83aa5d2a7521932d9943f9.
|
|
|
|
---
|
|
libs/vkd3d/libs/vkd3d-shader/glsl.c | 38 ++++++++++++++++++++
|
|
libs/vkd3d/libs/vkd3d-shader/ir.c | 5 +--
|
|
libs/vkd3d/libs/vkd3d-shader/msl.c | 50 ++++++++++++++++++++++++--
|
|
libs/vkd3d/libs/vkd3d-shader/preproc.l | 2 +-
|
|
libs/vkd3d/libs/vkd3d-shader/spirv.c | 25 ++++---------
|
|
libs/vkd3d/libs/vkd3d/vkd3d_main.c | 1 +
|
|
6 files changed, 96 insertions(+), 25 deletions(-)
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/glsl.c b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
|
index b29f13f2b19..a8cc6d87c40 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/glsl.c
|
|
@@ -379,6 +379,9 @@ static void VKD3D_PRINTF_FUNC(3, 4) shader_glsl_print_assignment(
|
|
case VKD3D_DATA_FLOAT:
|
|
close = false;
|
|
break;
|
|
+ case VKD3D_DATA_INT:
|
|
+ vkd3d_string_buffer_printf(buffer, "intBitsToFloat(");
|
|
+ break;
|
|
case VKD3D_DATA_UINT:
|
|
vkd3d_string_buffer_printf(buffer, "uintBitsToFloat(");
|
|
break;
|
|
@@ -457,6 +460,28 @@ static void shader_glsl_relop(struct vkd3d_glsl_generator *gen,
|
|
glsl_dst_cleanup(&dst, &gen->string_buffers);
|
|
}
|
|
|
|
+static void shader_glsl_cast(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins,
|
|
+ const char *scalar_constructor, const char *vector_constructor)
|
|
+{
|
|
+ unsigned int component_count;
|
|
+ struct glsl_src src;
|
|
+ struct glsl_dst dst;
|
|
+ uint32_t mask;
|
|
+
|
|
+ mask = glsl_dst_init(&dst, gen, ins, &ins->dst[0]);
|
|
+ glsl_src_init(&src, gen, &ins->src[0], mask);
|
|
+
|
|
+ if ((component_count = vsir_write_mask_component_count(mask)) > 1)
|
|
+ shader_glsl_print_assignment(gen, &dst, "%s%u(%s)",
|
|
+ vector_constructor, component_count, src.str->buffer);
|
|
+ else
|
|
+ shader_glsl_print_assignment(gen, &dst, "%s(%s)",
|
|
+ scalar_constructor, src.str->buffer);
|
|
+
|
|
+ glsl_src_cleanup(&src, &gen->string_buffers);
|
|
+ glsl_dst_cleanup(&dst, &gen->string_buffers);
|
|
+}
|
|
+
|
|
static void shader_glsl_mov(struct vkd3d_glsl_generator *gen, const struct vkd3d_shader_instruction *ins)
|
|
{
|
|
struct glsl_src src;
|
|
@@ -658,6 +683,12 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
|
case VKD3DSIH_FRC:
|
|
shader_glsl_intrinsic(gen, ins, "fract");
|
|
break;
|
|
+ case VKD3DSIH_FTOI:
|
|
+ shader_glsl_cast(gen, ins, "int", "ivec");
|
|
+ break;
|
|
+ case VKD3DSIH_FTOU:
|
|
+ shader_glsl_cast(gen, ins, "uint", "uvec");
|
|
+ break;
|
|
case VKD3DSIH_GEO:
|
|
shader_glsl_relop(gen, ins, ">=", "greaterThanEqual");
|
|
break;
|
|
@@ -665,6 +696,10 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
|
case VKD3DSIH_NEU:
|
|
shader_glsl_relop(gen, ins, "!=", "notEqual");
|
|
break;
|
|
+ case VKD3DSIH_ITOF:
|
|
+ case VKD3DSIH_UTOF:
|
|
+ shader_glsl_cast(gen, ins, "float", "vec");
|
|
+ break;
|
|
case VKD3DSIH_MOV:
|
|
shader_glsl_mov(gen, ins);
|
|
break;
|
|
@@ -680,6 +715,9 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen,
|
|
case VKD3DSIH_RET:
|
|
shader_glsl_ret(gen, ins);
|
|
break;
|
|
+ case VKD3DSIH_ROUND_PI:
|
|
+ shader_glsl_intrinsic(gen, ins, "ceil");
|
|
+ break;
|
|
default:
|
|
shader_glsl_unhandled(gen, ins);
|
|
break;
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/ir.c b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
|
index db9992d9715..0bbe13ad7d8 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/ir.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/ir.c
|
|
@@ -1211,12 +1211,13 @@ static bool io_normaliser_is_in_control_point_phase(const struct io_normaliser *
|
|
static bool shader_signature_find_element_for_reg(const struct shader_signature *signature,
|
|
unsigned int reg_idx, unsigned int write_mask, unsigned int *element_idx)
|
|
{
|
|
+ const struct signature_element *e;
|
|
unsigned int i, base_write_mask;
|
|
|
|
for (i = 0; i < signature->element_count; ++i)
|
|
{
|
|
- struct signature_element *e = &signature->elements[i];
|
|
- if (e->register_index <= reg_idx && e->register_index + e->register_count > reg_idx
|
|
+ e = &signature->elements[i];
|
|
+ if (e->register_index <= reg_idx && e->register_count > reg_idx - e->register_index
|
|
&& (e->mask & write_mask) == write_mask)
|
|
{
|
|
*element_idx = i;
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/msl.c b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
|
index 7d2e713cddc..6b41363d60e 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/msl.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/msl.c
|
|
@@ -55,12 +55,44 @@ static void msl_print_indent(struct vkd3d_string_buffer *buffer, unsigned int in
|
|
vkd3d_string_buffer_printf(buffer, "%*s", 4 * indent, "");
|
|
}
|
|
|
|
+static void msl_print_register_datatype(struct vkd3d_string_buffer *buffer,
|
|
+ struct msl_generator *gen, const struct vkd3d_shader_register *reg)
|
|
+{
|
|
+ vkd3d_string_buffer_printf(buffer, ".");
|
|
+ switch (reg->data_type)
|
|
+ {
|
|
+ case VKD3D_DATA_FLOAT:
|
|
+ vkd3d_string_buffer_printf(buffer, "f");
|
|
+ break;
|
|
+ case VKD3D_DATA_INT:
|
|
+ vkd3d_string_buffer_printf(buffer, "i");
|
|
+ break;
|
|
+ case VKD3D_DATA_UINT:
|
|
+ vkd3d_string_buffer_printf(buffer, "u");
|
|
+ break;
|
|
+ default:
|
|
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
|
+ "Internal compiler error: Unhandled register datatype %#x.", reg->data_type);
|
|
+ vkd3d_string_buffer_printf(buffer, "<unrecognised register datatype %#x>", reg->data_type);
|
|
+ break;
|
|
+ }
|
|
+}
|
|
+
|
|
static void msl_print_register_name(struct vkd3d_string_buffer *buffer,
|
|
struct msl_generator *gen, const struct vkd3d_shader_register *reg)
|
|
{
|
|
- msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
|
- "Internal compiler error: Unhandled register type %#x.", reg->type);
|
|
- vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
|
+ switch (reg->type)
|
|
+ {
|
|
+ case VKD3DSPR_TEMP:
|
|
+ vkd3d_string_buffer_printf(buffer, "r[%u]", reg->idx[0].offset);
|
|
+ msl_print_register_datatype(buffer, gen, reg);
|
|
+ break;
|
|
+ default:
|
|
+ msl_compiler_error(gen, VKD3D_SHADER_ERROR_MSL_INTERNAL,
|
|
+ "Internal compiler error: Unhandled register type %#x.", reg->type);
|
|
+ vkd3d_string_buffer_printf(buffer, "<unrecognised register %#x>", reg->type);
|
|
+ break;
|
|
+ }
|
|
}
|
|
|
|
static void msl_print_swizzle(struct vkd3d_string_buffer *buffer, uint32_t swizzle, uint32_t mask)
|
|
@@ -221,9 +253,21 @@ static void msl_generator_generate(struct msl_generator *gen)
|
|
|
|
vkd3d_string_buffer_printf(gen->buffer, "/* Generated by %s. */\n\n", vkd3d_shader_get_version(NULL, NULL));
|
|
|
|
+ vkd3d_string_buffer_printf(gen->buffer, "union vkd3d_vec4\n{\n");
|
|
+ vkd3d_string_buffer_printf(gen->buffer, " uint4 u;\n");
|
|
+ vkd3d_string_buffer_printf(gen->buffer, " int4 i;\n");
|
|
+ vkd3d_string_buffer_printf(gen->buffer, " float4 f;\n};\n\n");
|
|
+
|
|
vkd3d_string_buffer_printf(gen->buffer, "void shader_main()\n{\n");
|
|
|
|
++gen->indent;
|
|
+
|
|
+ if (gen->program->temp_count)
|
|
+ {
|
|
+ msl_print_indent(gen->buffer, gen->indent);
|
|
+ vkd3d_string_buffer_printf(gen->buffer, "vkd3d_vec4 r[%u];\n\n", gen->program->temp_count);
|
|
+ }
|
|
+
|
|
for (i = 0; i < instructions->count; ++i)
|
|
{
|
|
msl_handle_instruction(gen, &instructions->elements[i]);
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/preproc.l b/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
|
index 7fc963192cf..41c21cca1f5 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/preproc.l
|
|
@@ -67,7 +67,7 @@ static void update_location(struct preproc_ctx *ctx);
|
|
|
|
NEWLINE \r?\n
|
|
WS [ \t\r]
|
|
-IDENTIFIER [A-Za-z_][A-Za-z0-9_]*
|
|
+IDENTIFIER (::)?[A-Za-z_]((::)?[A-Za-z0-9_]+)*
|
|
INT_SUFFIX [uUlL]{0,2}
|
|
|
|
%%
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
index 1876ad38653..0278a6ca232 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
@@ -6354,7 +6354,7 @@ static SpvImageFormat image_format_for_image_read(enum vkd3d_shader_component_ty
|
|
static uint32_t spirv_compiler_get_image_type_id(struct spirv_compiler *compiler,
|
|
const struct vkd3d_shader_register *reg, const struct vkd3d_shader_register_range *range,
|
|
const struct vkd3d_spirv_resource_type *resource_type_info, enum vkd3d_shader_component_type data_type,
|
|
- bool raw_structured, uint32_t depth)
|
|
+ bool raw_structured)
|
|
{
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
const struct vkd3d_shader_descriptor_info1 *d;
|
|
@@ -6377,7 +6377,7 @@ static uint32_t spirv_compiler_get_image_type_id(struct spirv_compiler *compiler
|
|
|
|
sampled_type_id = vkd3d_spirv_get_type_id(builder, data_type, 1);
|
|
return vkd3d_spirv_get_op_type_image(builder, sampled_type_id, resource_type_info->dim,
|
|
- depth, resource_type_info->arrayed, resource_type_info->ms,
|
|
+ 2, resource_type_info->arrayed, resource_type_info->ms,
|
|
reg->type == VKD3DSPR_UAV ? 2 : 1, format);
|
|
}
|
|
|
|
@@ -6392,18 +6392,14 @@ static void spirv_compiler_emit_combined_sampler_declarations(struct spirv_compi
|
|
const struct vkd3d_shader_combined_resource_sampler *current;
|
|
uint32_t image_type_id, type_id, ptr_type_id, var_id;
|
|
enum vkd3d_shader_binding_flag resource_type_flag;
|
|
- const struct vkd3d_shader_descriptor_info1 *d;
|
|
struct vkd3d_symbol symbol;
|
|
unsigned int i;
|
|
- bool depth;
|
|
|
|
resource_type_flag = resource_type == VKD3D_SHADER_RESOURCE_BUFFER
|
|
? VKD3D_SHADER_BINDING_FLAG_BUFFER : VKD3D_SHADER_BINDING_FLAG_IMAGE;
|
|
|
|
for (i = 0; i < shader_interface->combined_sampler_count; ++i)
|
|
{
|
|
- struct vkd3d_shader_register_range sampler_range;
|
|
-
|
|
current = &shader_interface->combined_samplers[i];
|
|
|
|
if (current->resource_space != resource_range->space || current->resource_index != resource_range->first)
|
|
@@ -6425,16 +6421,8 @@ static void spirv_compiler_emit_combined_sampler_declarations(struct spirv_compi
|
|
current->sampler_space, current->binding.count);
|
|
}
|
|
|
|
- sampler_range.space = current->sampler_space;
|
|
- sampler_range.first = current->sampler_index;
|
|
- sampler_range.last = current->sampler_index;
|
|
- d = spirv_compiler_get_descriptor_info(compiler,
|
|
- VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER, &sampler_range);
|
|
- depth = current->sampler_index != VKD3D_SHADER_DUMMY_SAMPLER_INDEX
|
|
- && (d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_SAMPLER_COMPARISON_MODE);
|
|
-
|
|
image_type_id = spirv_compiler_get_image_type_id(compiler, resource, resource_range,
|
|
- resource_type_info, sampled_type, structure_stride || raw, depth);
|
|
+ resource_type_info, sampled_type, structure_stride || raw);
|
|
type_id = vkd3d_spirv_get_op_type_sampled_image(builder, image_type_id);
|
|
|
|
ptr_type_id = vkd3d_spirv_get_op_type_pointer(builder, storage_class, type_id);
|
|
@@ -6528,7 +6516,7 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
else
|
|
{
|
|
type_id = spirv_compiler_get_image_type_id(compiler, ®, range,
|
|
- resource_type_info, sampled_type, structure_stride || raw, 0);
|
|
+ resource_type_info, sampled_type, structure_stride || raw);
|
|
}
|
|
|
|
var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class,
|
|
@@ -8440,11 +8428,10 @@ static void spirv_compiler_prepare_image(struct spirv_compiler *compiler,
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
uint32_t sampler_var_id, sampler_id, sampled_image_type_id;
|
|
const struct vkd3d_symbol *symbol = NULL;
|
|
- bool load, sampled, depth_comparison;
|
|
+ bool load, sampled;
|
|
|
|
load = !(flags & VKD3D_IMAGE_FLAG_NO_LOAD);
|
|
sampled = flags & VKD3D_IMAGE_FLAG_SAMPLED;
|
|
- depth_comparison = flags & VKD3D_IMAGE_FLAG_DEPTH;
|
|
|
|
if (resource_reg->type == VKD3DSPR_RESOURCE)
|
|
symbol = spirv_compiler_find_combined_sampler(compiler, resource_reg, sampler_reg);
|
|
@@ -8498,7 +8485,7 @@ static void spirv_compiler_prepare_image(struct spirv_compiler *compiler,
|
|
|
|
image->image_type_id = spirv_compiler_get_image_type_id(compiler, resource_reg,
|
|
&symbol->info.resource.range, image->resource_type_info,
|
|
- image->sampled_type, image->structure_stride || image->raw, depth_comparison);
|
|
+ image->sampled_type, image->structure_stride || image->raw);
|
|
|
|
if (sampled)
|
|
{
|
|
diff --git a/libs/vkd3d/libs/vkd3d/vkd3d_main.c b/libs/vkd3d/libs/vkd3d/vkd3d_main.c
|
|
index 9eccec111c7..5215cf8ef86 100644
|
|
--- a/libs/vkd3d/libs/vkd3d/vkd3d_main.c
|
|
+++ b/libs/vkd3d/libs/vkd3d/vkd3d_main.c
|
|
@@ -415,6 +415,7 @@ HRESULT vkd3d_create_versioned_root_signature_deserializer(const void *data, SIZ
|
|
if (FAILED(hr = d3d12_versioned_root_signature_deserializer_init(object, &dxbc)))
|
|
{
|
|
vkd3d_free(object);
|
|
+ *deserializer = NULL;
|
|
return hr;
|
|
}
|
|
|
|
--
|
|
2.45.2
|
|
|