mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
948 lines
43 KiB
Diff
948 lines
43 KiB
Diff
From 247ab6630dc34db194033b3721d30246c8fb8012 Mon Sep 17 00:00:00 2001
|
|
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
|
|
Date: Tue, 29 Aug 2023 07:21:37 +1000
|
|
Subject: [PATCH] Updated vkd3d to 269747dbf3ee32bf23e6d1ab388d2a058ca90f9f.
|
|
|
|
---
|
|
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 1 +
|
|
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 47 ++-
|
|
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 5 +-
|
|
libs/vkd3d/libs/vkd3d-shader/spirv.c | 296 +++++++++---------
|
|
libs/vkd3d/libs/vkd3d-shader/tpf.c | 144 +++++++--
|
|
.../libs/vkd3d-shader/vkd3d_shader_private.h | 37 +++
|
|
libs/vkd3d/libs/vkd3d/command.c | 5 +-
|
|
7 files changed, 347 insertions(+), 188 deletions(-)
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
index 0a8d3a692a3..070fec74326 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
|
|
@@ -356,6 +356,7 @@ struct hlsl_attribute
|
|
#define HLSL_MODIFIER_COLUMN_MAJOR 0x00000400
|
|
#define HLSL_STORAGE_IN 0x00000800
|
|
#define HLSL_STORAGE_OUT 0x00001000
|
|
+#define HLSL_MODIFIER_INLINE 0x00002000
|
|
|
|
#define HLSL_TYPE_MODIFIERS_MASK (HLSL_MODIFIER_PRECISE | HLSL_MODIFIER_VOLATILE | \
|
|
HLSL_MODIFIER_CONST | HLSL_MODIFIER_ROW_MAJOR | \
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
|
index 29e0ff0c5be..43ea4b4d038 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
|
|
@@ -493,11 +493,11 @@ static struct hlsl_block *create_loop(struct hlsl_ctx *ctx, enum loop_type type,
|
|
|| !strcmp(attr->name, "fastopt")
|
|
|| !strcmp(attr->name, "allow_uav_condition"))
|
|
{
|
|
- hlsl_fixme(ctx, loc, "Unhandled attribute %s.", attr->name);
|
|
+ hlsl_fixme(ctx, loc, "Unhandled attribute '%s'.", attr->name);
|
|
}
|
|
else
|
|
{
|
|
- hlsl_warning(ctx, loc, VKD3D_SHADER_ERROR_HLSL_NOT_IMPLEMENTED, "Unrecognized attribute %s.", attr->name);
|
|
+ hlsl_warning(ctx, loc, VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE, "Unrecognized attribute '%s'.", attr->name);
|
|
}
|
|
}
|
|
|
|
@@ -5129,6 +5129,9 @@ func_prototype_no_attrs:
|
|
struct hlsl_ir_var *var;
|
|
struct hlsl_type *type;
|
|
|
|
+ /* Functions are unconditionally inlined. */
|
|
+ modifiers &= ~HLSL_MODIFIER_INLINE;
|
|
+
|
|
if (modifiers & ~HLSL_MODIFIERS_MAJORITY_MASK)
|
|
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
|
|
"Only majority modifiers are allowed on functions.");
|
|
@@ -5970,6 +5973,10 @@ var_modifiers:
|
|
{
|
|
$$ = add_modifiers(ctx, $2, HLSL_STORAGE_IN | HLSL_STORAGE_OUT, &@1);
|
|
}
|
|
+ | KW_INLINE var_modifiers
|
|
+ {
|
|
+ $$ = add_modifiers(ctx, $2, HLSL_MODIFIER_INLINE, &@1);
|
|
+ }
|
|
|
|
|
|
complex_initializer:
|
|
@@ -6108,19 +6115,39 @@ jump_statement:
|
|
}
|
|
|
|
selection_statement:
|
|
- KW_IF '(' expr ')' if_body
|
|
+ attribute_list_optional KW_IF '(' expr ')' if_body
|
|
{
|
|
- struct hlsl_ir_node *condition = node_from_block($3);
|
|
+ struct hlsl_ir_node *condition = node_from_block($4);
|
|
+ const struct parse_attribute_list *attributes = &$1;
|
|
struct hlsl_ir_node *instr;
|
|
+ unsigned int i;
|
|
+
|
|
+ if (attribute_list_has_duplicates(attributes))
|
|
+ hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, "Found duplicate attribute.");
|
|
+
|
|
+ for (i = 0; i < attributes->count; ++i)
|
|
+ {
|
|
+ const struct hlsl_attribute *attr = attributes->attrs[i];
|
|
+
|
|
+ if (!strcmp(attr->name, "branch")
|
|
+ || !strcmp(attr->name, "flatten"))
|
|
+ {
|
|
+ hlsl_warning(ctx, &@1, VKD3D_SHADER_WARNING_HLSL_IGNORED_ATTRIBUTE, "Unhandled attribute '%s'.", attr->name);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ hlsl_warning(ctx, &@1, VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE, "Unrecognized attribute '%s'.", attr->name);
|
|
+ }
|
|
+ }
|
|
|
|
- if (!(instr = hlsl_new_if(ctx, condition, $5.then_block, $5.else_block, &@1)))
|
|
+ if (!(instr = hlsl_new_if(ctx, condition, $6.then_block, $6.else_block, &@2)))
|
|
{
|
|
- destroy_block($5.then_block);
|
|
- destroy_block($5.else_block);
|
|
+ destroy_block($6.then_block);
|
|
+ destroy_block($6.else_block);
|
|
YYABORT;
|
|
}
|
|
- destroy_block($5.then_block);
|
|
- destroy_block($5.else_block);
|
|
+ destroy_block($6.then_block);
|
|
+ destroy_block($6.else_block);
|
|
if (condition->data_type->dimx > 1 || condition->data_type->dimy > 1)
|
|
{
|
|
struct vkd3d_string_buffer *string;
|
|
@@ -6130,7 +6157,7 @@ selection_statement:
|
|
"if condition type %s is not scalar.", string->buffer);
|
|
hlsl_release_string_buffer(ctx, string);
|
|
}
|
|
- $$ = $3;
|
|
+ $$ = $4;
|
|
hlsl_block_add_instr($$, instr);
|
|
}
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
index bfa605f4ba7..bae8e5f9a5f 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
|
|
@@ -321,9 +321,10 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_block *block, s
|
|
if (!semantic->name)
|
|
return;
|
|
|
|
- vector_type_src = hlsl_get_vector_type(ctx, type->base_type,
|
|
- (ctx->profile->major_version < 4) ? 4 : hlsl_type_minor_size(type));
|
|
vector_type_dst = hlsl_get_vector_type(ctx, type->base_type, hlsl_type_minor_size(type));
|
|
+ vector_type_src = vector_type_dst;
|
|
+ if (ctx->profile->major_version < 4 && ctx->profile->type == VKD3D_SHADER_TYPE_VERTEX)
|
|
+ vector_type_src = hlsl_get_vector_type(ctx, type->base_type, 4);
|
|
|
|
for (i = 0; i < hlsl_type_major_size(type); ++i)
|
|
{
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
index fa605f185ae..9b3084538ba 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
|
|
@@ -204,11 +204,6 @@ static inline bool register_is_undef(const struct vkd3d_shader_register *reg)
|
|
return reg->type == VKD3DSPR_UNDEF;
|
|
}
|
|
|
|
-static inline bool register_is_constant(const struct vkd3d_shader_register *reg)
|
|
-{
|
|
- return (reg->type == VKD3DSPR_IMMCONST || reg->type == VKD3DSPR_IMMCONST64);
|
|
-}
|
|
-
|
|
static inline bool register_is_constant_or_undef(const struct vkd3d_shader_register *reg)
|
|
{
|
|
return register_is_constant(reg) || register_is_undef(reg);
|
|
@@ -2599,8 +2594,8 @@ static struct vkd3d_push_constant_buffer_binding *spirv_compiler_find_push_const
|
|
return NULL;
|
|
}
|
|
|
|
-static bool spirv_compiler_has_combined_sampler(const struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_resource *resource, const struct vkd3d_shader_sampler *sampler)
|
|
+static bool spirv_compiler_has_combined_sampler_for_resource(const struct spirv_compiler *compiler,
|
|
+ const struct vkd3d_shader_register_range *range)
|
|
{
|
|
const struct vkd3d_shader_interface_info *shader_interface = &compiler->shader_interface;
|
|
const struct vkd3d_shader_combined_resource_sampler *combined_sampler;
|
|
@@ -2609,10 +2604,35 @@ static bool spirv_compiler_has_combined_sampler(const struct spirv_compiler *com
|
|
if (!shader_interface->combined_sampler_count)
|
|
return false;
|
|
|
|
- if (resource && (resource->reg.reg.type == VKD3DSPR_UAV || resource->range.last != resource->range.first))
|
|
+ if (range->last != range->first)
|
|
+ return false;
|
|
+
|
|
+ for (i = 0; i < shader_interface->combined_sampler_count; ++i)
|
|
+ {
|
|
+ combined_sampler = &shader_interface->combined_samplers[i];
|
|
+
|
|
+ if (!spirv_compiler_check_shader_visibility(compiler, combined_sampler->shader_visibility))
|
|
+ continue;
|
|
+
|
|
+ if ((combined_sampler->resource_space == range->space
|
|
+ && combined_sampler->resource_index == range->first))
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return false;
|
|
+}
|
|
+
|
|
+static bool spirv_compiler_has_combined_sampler_for_sampler(const struct spirv_compiler *compiler,
|
|
+ const struct vkd3d_shader_register_range *range)
|
|
+{
|
|
+ const struct vkd3d_shader_interface_info *shader_interface = &compiler->shader_interface;
|
|
+ const struct vkd3d_shader_combined_resource_sampler *combined_sampler;
|
|
+ unsigned int i;
|
|
+
|
|
+ if (!shader_interface->combined_sampler_count)
|
|
return false;
|
|
|
|
- if (sampler && sampler->range.first != sampler->range.last)
|
|
+ if (range->last != range->first)
|
|
return false;
|
|
|
|
for (i = 0; i < shader_interface->combined_sampler_count; ++i)
|
|
@@ -2622,10 +2642,8 @@ static bool spirv_compiler_has_combined_sampler(const struct spirv_compiler *com
|
|
if (!spirv_compiler_check_shader_visibility(compiler, combined_sampler->shader_visibility))
|
|
continue;
|
|
|
|
- if ((!resource || (combined_sampler->resource_space == resource->range.space
|
|
- && combined_sampler->resource_index == resource->range.first))
|
|
- && (!sampler || (combined_sampler->sampler_space == sampler->range.space
|
|
- && combined_sampler->sampler_index == sampler->range.first)))
|
|
+ if (combined_sampler->sampler_space == range->space
|
|
+ && combined_sampler->sampler_index == range->first)
|
|
return true;
|
|
}
|
|
|
|
@@ -2643,6 +2661,16 @@ static void VKD3D_PRINTF_FUNC(3, 4) spirv_compiler_error(struct spirv_compiler *
|
|
compiler->failed = true;
|
|
}
|
|
|
|
+static void VKD3D_PRINTF_FUNC(3, 4) spirv_compiler_warning(struct spirv_compiler *compiler,
|
|
+ enum vkd3d_shader_error error, const char *format, ...)
|
|
+{
|
|
+ va_list args;
|
|
+
|
|
+ va_start(args, format);
|
|
+ vkd3d_shader_vwarning(compiler->message_context, &compiler->location, error, format, args);
|
|
+ va_end(args);
|
|
+}
|
|
+
|
|
static struct vkd3d_string_buffer *vkd3d_shader_register_range_string(struct spirv_compiler *compiler,
|
|
const struct vkd3d_shader_register_range *range)
|
|
{
|
|
@@ -5538,8 +5566,8 @@ static uint32_t spirv_compiler_build_descriptor_variable(struct spirv_compiler *
|
|
return var_id;
|
|
}
|
|
|
|
-static void spirv_compiler_emit_constant_buffer(struct spirv_compiler *compiler, unsigned int size,
|
|
- const struct vkd3d_shader_register_range *range, const struct vkd3d_shader_register *reg)
|
|
+static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler,
|
|
+ const struct vkd3d_shader_register_range *range, unsigned int register_id, unsigned int size)
|
|
{
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
uint32_t vec4_id, array_type_id, length_id, struct_id, var_id;
|
|
@@ -5548,13 +5576,20 @@ static void spirv_compiler_emit_constant_buffer(struct spirv_compiler *compiler,
|
|
struct vkd3d_descriptor_variable_info var_info;
|
|
struct vkd3d_symbol reg_symbol;
|
|
|
|
+ struct vkd3d_shader_register reg =
|
|
+ {
|
|
+ .type = VKD3DSPR_CONSTBUFFER,
|
|
+ .idx[0].offset = register_id,
|
|
+ .idx_count = 1,
|
|
+ };
|
|
+
|
|
if ((push_cb = spirv_compiler_find_push_constant_buffer(compiler, range)))
|
|
{
|
|
/* Push constant buffers are handled in
|
|
* spirv_compiler_emit_push_constant_buffers().
|
|
*/
|
|
unsigned int cb_size_in_bytes = size * VKD3D_VEC4_SIZE * sizeof(uint32_t);
|
|
- push_cb->reg = *reg;
|
|
+ push_cb->reg = reg;
|
|
push_cb->size = size;
|
|
if (cb_size_in_bytes > push_cb->pc.size)
|
|
{
|
|
@@ -5575,9 +5610,9 @@ static void spirv_compiler_emit_constant_buffer(struct spirv_compiler *compiler,
|
|
vkd3d_spirv_build_op_name(builder, struct_id, "cb%u_struct", size);
|
|
|
|
var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, struct_id,
|
|
- reg, range, VKD3D_SHADER_RESOURCE_BUFFER, false, &var_info);
|
|
+ ®, range, VKD3D_SHADER_RESOURCE_BUFFER, false, &var_info);
|
|
|
|
- vkd3d_symbol_make_register(®_symbol, reg);
|
|
+ vkd3d_symbol_make_register(®_symbol, ®);
|
|
vkd3d_symbol_set_register_info(®_symbol, var_id, storage_class,
|
|
VKD3D_SHADER_COMPONENT_FLOAT, VKD3DSP_WRITEMASK_ALL);
|
|
reg_symbol.descriptor_array = var_info.array_symbol;
|
|
@@ -5585,16 +5620,6 @@ static void spirv_compiler_emit_constant_buffer(struct spirv_compiler *compiler,
|
|
spirv_compiler_put_symbol(compiler, ®_symbol);
|
|
}
|
|
|
|
-static void spirv_compiler_emit_dcl_constant_buffer(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_instruction *instruction)
|
|
-{
|
|
- const struct vkd3d_shader_constant_buffer *cb = &instruction->declaration.cb;
|
|
-
|
|
- assert(!(instruction->flags & ~VKD3DSI_INDEXED_DYNAMIC));
|
|
-
|
|
- spirv_compiler_emit_constant_buffer(compiler, cb->size, &cb->range, &cb->src.reg);
|
|
-}
|
|
-
|
|
static void spirv_compiler_emit_dcl_immediate_constant_buffer(struct spirv_compiler *compiler,
|
|
const struct vkd3d_shader_instruction *instruction)
|
|
{
|
|
@@ -5628,29 +5653,34 @@ static void spirv_compiler_emit_dcl_immediate_constant_buffer(struct spirv_compi
|
|
spirv_compiler_put_symbol(compiler, ®_symbol);
|
|
}
|
|
|
|
-static void spirv_compiler_emit_dcl_sampler(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_instruction *instruction)
|
|
+static void spirv_compiler_emit_sampler_declaration(struct spirv_compiler *compiler,
|
|
+ const struct vkd3d_shader_register_range *range, unsigned int register_id)
|
|
{
|
|
- const struct vkd3d_shader_sampler *sampler = &instruction->declaration.sampler;
|
|
const SpvStorageClass storage_class = SpvStorageClassUniformConstant;
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
- const struct vkd3d_shader_register *reg = &sampler->src.reg;
|
|
struct vkd3d_descriptor_variable_info var_info;
|
|
struct vkd3d_symbol reg_symbol;
|
|
uint32_t type_id, var_id;
|
|
|
|
- vkd3d_symbol_make_sampler(®_symbol, reg);
|
|
- reg_symbol.info.sampler.range = sampler->range;
|
|
+ const struct vkd3d_shader_register reg =
|
|
+ {
|
|
+ .type = VKD3DSPR_SAMPLER,
|
|
+ .idx[0].offset = register_id,
|
|
+ .idx_count = 1,
|
|
+ };
|
|
+
|
|
+ vkd3d_symbol_make_sampler(®_symbol, ®);
|
|
+ reg_symbol.info.sampler.range = *range;
|
|
spirv_compiler_put_symbol(compiler, ®_symbol);
|
|
|
|
- if (spirv_compiler_has_combined_sampler(compiler, NULL, sampler))
|
|
+ if (spirv_compiler_has_combined_sampler_for_sampler(compiler, range))
|
|
return;
|
|
|
|
type_id = vkd3d_spirv_get_op_type_sampler(builder);
|
|
- var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id, reg,
|
|
- &sampler->range, VKD3D_SHADER_RESOURCE_NONE, false, &var_info);
|
|
+ var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id, ®,
|
|
+ range, VKD3D_SHADER_RESOURCE_NONE, false, &var_info);
|
|
|
|
- vkd3d_symbol_make_register(®_symbol, reg);
|
|
+ vkd3d_symbol_make_register(®_symbol, ®);
|
|
vkd3d_symbol_set_register_info(®_symbol, var_id, storage_class,
|
|
VKD3D_SHADER_COMPONENT_FLOAT, VKD3DSP_WRITEMASK_ALL);
|
|
reg_symbol.descriptor_array = var_info.array_symbol;
|
|
@@ -5832,20 +5862,30 @@ static void spirv_compiler_emit_combined_sampler_declarations(struct spirv_compi
|
|
}
|
|
|
|
static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_resource *resource, enum vkd3d_shader_resource_type resource_type,
|
|
- enum vkd3d_data_type resource_data_type, unsigned int structure_stride, bool raw)
|
|
+ const struct vkd3d_shader_register_range *range, unsigned int register_id,
|
|
+ unsigned int sample_count, bool is_uav, enum vkd3d_shader_resource_type resource_type,
|
|
+ enum vkd3d_shader_resource_data_type resource_data_type, unsigned int structure_stride, bool raw)
|
|
{
|
|
struct vkd3d_descriptor_variable_info var_info, counter_var_info = {0};
|
|
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
|
|
SpvStorageClass storage_class = SpvStorageClassUniformConstant;
|
|
uint32_t counter_type_id, type_id, var_id, counter_var_id = 0;
|
|
- const struct vkd3d_shader_register *reg = &resource->reg.reg;
|
|
const struct vkd3d_spirv_resource_type *resource_type_info;
|
|
enum vkd3d_shader_component_type sampled_type;
|
|
struct vkd3d_symbol resource_symbol;
|
|
- bool is_uav;
|
|
|
|
- is_uav = reg->type == VKD3DSPR_UAV;
|
|
+ struct vkd3d_shader_register reg =
|
|
+ {
|
|
+ .type = is_uav ? VKD3DSPR_UAV : VKD3DSPR_RESOURCE,
|
|
+ .idx[0].offset = register_id,
|
|
+ .idx_count = 1,
|
|
+ };
|
|
+
|
|
+ if (resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMS && sample_count == 1)
|
|
+ resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2D;
|
|
+ else if (resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY && sample_count == 1)
|
|
+ resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY;
|
|
+
|
|
if (!(resource_type_info = spirv_compiler_enable_resource_type(compiler,
|
|
resource_type, is_uav)))
|
|
{
|
|
@@ -5853,11 +5893,11 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
return;
|
|
}
|
|
|
|
- sampled_type = vkd3d_component_type_from_data_type(resource_data_type);
|
|
+ sampled_type = vkd3d_component_type_from_resource_data_type(resource_data_type);
|
|
|
|
- if (spirv_compiler_has_combined_sampler(compiler, resource, NULL))
|
|
+ if (!is_uav && spirv_compiler_has_combined_sampler_for_resource(compiler, range))
|
|
{
|
|
- spirv_compiler_emit_combined_sampler_declarations(compiler, reg, &resource->range,
|
|
+ spirv_compiler_emit_combined_sampler_declarations(compiler, ®, range,
|
|
resource_type, sampled_type, structure_stride, raw, resource_type_info);
|
|
return;
|
|
}
|
|
@@ -5880,19 +5920,18 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
}
|
|
else
|
|
{
|
|
- type_id = spirv_compiler_get_image_type_id(compiler, reg, &resource->range,
|
|
+ type_id = spirv_compiler_get_image_type_id(compiler, ®, range,
|
|
resource_type_info, sampled_type, structure_stride || raw, 0);
|
|
}
|
|
|
|
- var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id, reg,
|
|
- &resource->range, resource_type, false, &var_info);
|
|
+ var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id, ®,
|
|
+ range, resource_type, false, &var_info);
|
|
|
|
if (is_uav)
|
|
{
|
|
const struct vkd3d_shader_descriptor_info1 *d;
|
|
|
|
- d = spirv_compiler_get_descriptor_info(compiler,
|
|
- VKD3D_SHADER_DESCRIPTOR_TYPE_UAV, &resource->range);
|
|
+ d = spirv_compiler_get_descriptor_info(compiler, VKD3D_SHADER_DESCRIPTOR_TYPE_UAV, range);
|
|
|
|
if (!(d->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_UAV_READ))
|
|
vkd3d_spirv_build_op_decorate(builder, var_id, SpvDecorationNonReadable, NULL, 0);
|
|
@@ -5924,15 +5963,15 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
type_id = struct_id;
|
|
}
|
|
|
|
- counter_var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class, type_id, reg,
|
|
- &resource->range, resource_type, true, &counter_var_info);
|
|
+ counter_var_id = spirv_compiler_build_descriptor_variable(compiler, storage_class,
|
|
+ type_id, ®, range, resource_type, true, &counter_var_info);
|
|
}
|
|
}
|
|
|
|
- vkd3d_symbol_make_resource(&resource_symbol, reg);
|
|
+ vkd3d_symbol_make_resource(&resource_symbol, ®);
|
|
resource_symbol.id = var_id;
|
|
resource_symbol.descriptor_array = var_info.array_symbol;
|
|
- resource_symbol.info.resource.range = resource->range;
|
|
+ resource_symbol.info.resource.range = *range;
|
|
resource_symbol.info.resource.sampled_type = sampled_type;
|
|
resource_symbol.info.resource.type_id = type_id;
|
|
resource_symbol.info.resource.resource_type_info = resource_type_info;
|
|
@@ -5945,58 +5984,6 @@ static void spirv_compiler_emit_resource_declaration(struct spirv_compiler *comp
|
|
spirv_compiler_put_symbol(compiler, &resource_symbol);
|
|
}
|
|
|
|
-static void spirv_compiler_emit_dcl_resource(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_instruction *instruction)
|
|
-{
|
|
- const struct vkd3d_shader_semantic *semantic = &instruction->declaration.semantic;
|
|
- enum vkd3d_shader_resource_type resource_type = semantic->resource_type;
|
|
- uint32_t flags = instruction->flags;
|
|
-
|
|
- /* We don't distinguish between APPEND and COUNTER UAVs. */
|
|
- flags &= ~VKD3DSUF_ORDER_PRESERVING_COUNTER;
|
|
- if (flags)
|
|
- FIXME("Unhandled UAV flags %#x.\n", flags);
|
|
-
|
|
- if (resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMS && semantic->sample_count == 1)
|
|
- resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2D;
|
|
- else if (resource_type == VKD3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY && semantic->sample_count == 1)
|
|
- resource_type = VKD3D_SHADER_RESOURCE_TEXTURE_2DARRAY;
|
|
-
|
|
- spirv_compiler_emit_resource_declaration(compiler, &semantic->resource,
|
|
- resource_type, semantic->resource_data_type[0], 0, false);
|
|
-}
|
|
-
|
|
-static void spirv_compiler_emit_dcl_resource_raw(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_instruction *instruction)
|
|
-{
|
|
- const struct vkd3d_shader_raw_resource *resource = &instruction->declaration.raw_resource;
|
|
- uint32_t flags = instruction->flags;
|
|
-
|
|
- /* We don't distinguish between APPEND and COUNTER UAVs. */
|
|
- flags &= ~VKD3DSUF_ORDER_PRESERVING_COUNTER;
|
|
- if (flags)
|
|
- FIXME("Unhandled UAV flags %#x.\n", flags);
|
|
-
|
|
- spirv_compiler_emit_resource_declaration(compiler, &resource->resource,
|
|
- VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_DATA_UINT, 0, true);
|
|
-}
|
|
-
|
|
-static void spirv_compiler_emit_dcl_resource_structured(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_instruction *instruction)
|
|
-{
|
|
- const struct vkd3d_shader_structured_resource *resource = &instruction->declaration.structured_resource;
|
|
- unsigned int stride = resource->byte_stride;
|
|
- uint32_t flags = instruction->flags;
|
|
-
|
|
- /* We don't distinguish between APPEND and COUNTER UAVs. */
|
|
- flags &= ~VKD3DSUF_ORDER_PRESERVING_COUNTER;
|
|
- if (flags)
|
|
- FIXME("Unhandled UAV flags %#x.\n", flags);
|
|
-
|
|
- spirv_compiler_emit_resource_declaration(compiler, &resource->resource,
|
|
- VKD3D_SHADER_RESOURCE_BUFFER, VKD3D_DATA_UINT, stride / 4, false);
|
|
-}
|
|
-
|
|
static void spirv_compiler_emit_workgroup_memory(struct spirv_compiler *compiler,
|
|
const struct vkd3d_shader_register *reg, unsigned int size, unsigned int structure_stride)
|
|
{
|
|
@@ -7466,7 +7453,13 @@ static int spirv_compiler_emit_control_flow_instruction(struct spirv_compiler *c
|
|
assert(compiler->control_flow_depth);
|
|
assert(cf_info->current_block == VKD3D_BLOCK_SWITCH);
|
|
|
|
- assert(src->swizzle == VKD3D_SHADER_NO_SWIZZLE && src->reg.type == VKD3DSPR_IMMCONST);
|
|
+ if (src->swizzle != VKD3D_SHADER_SWIZZLE(X, X, X, X))
|
|
+ {
|
|
+ WARN("Unexpected src swizzle %#x.\n", src->swizzle);
|
|
+ spirv_compiler_warning(compiler, VKD3D_SHADER_WARNING_SPV_INVALID_SWIZZLE,
|
|
+ "The swizzle for a switch case value is not scalar.");
|
|
+ }
|
|
+ assert(src->reg.type == VKD3DSPR_IMMCONST);
|
|
value = *src->reg.u.immconst_uint;
|
|
|
|
if (!vkd3d_array_reserve((void **)&cf_info->u.switch_.case_blocks, &cf_info->u.switch_.case_blocks_size,
|
|
@@ -9174,27 +9167,9 @@ static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler,
|
|
case VKD3DSIH_DCL_INDEXABLE_TEMP:
|
|
spirv_compiler_emit_dcl_indexable_temp(compiler, instruction);
|
|
break;
|
|
- case VKD3DSIH_DCL_CONSTANT_BUFFER:
|
|
- spirv_compiler_emit_dcl_constant_buffer(compiler, instruction);
|
|
- break;
|
|
case VKD3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER:
|
|
spirv_compiler_emit_dcl_immediate_constant_buffer(compiler, instruction);
|
|
break;
|
|
- case VKD3DSIH_DCL_SAMPLER:
|
|
- spirv_compiler_emit_dcl_sampler(compiler, instruction);
|
|
- break;
|
|
- case VKD3DSIH_DCL:
|
|
- case VKD3DSIH_DCL_UAV_TYPED:
|
|
- spirv_compiler_emit_dcl_resource(compiler, instruction);
|
|
- break;
|
|
- case VKD3DSIH_DCL_RESOURCE_RAW:
|
|
- case VKD3DSIH_DCL_UAV_RAW:
|
|
- spirv_compiler_emit_dcl_resource_raw(compiler, instruction);
|
|
- break;
|
|
- case VKD3DSIH_DCL_RESOURCE_STRUCTURED:
|
|
- case VKD3DSIH_DCL_UAV_STRUCTURED:
|
|
- spirv_compiler_emit_dcl_resource_structured(compiler, instruction);
|
|
- break;
|
|
case VKD3DSIH_DCL_TGSM_RAW:
|
|
spirv_compiler_emit_dcl_tgsm_raw(compiler, instruction);
|
|
break;
|
|
@@ -9490,8 +9465,16 @@ static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler,
|
|
case VKD3DSIH_CUT_STREAM:
|
|
spirv_compiler_emit_cut_stream(compiler, instruction);
|
|
break;
|
|
+ case VKD3DSIH_DCL:
|
|
+ case VKD3DSIH_DCL_CONSTANT_BUFFER:
|
|
case VKD3DSIH_DCL_HS_MAX_TESSFACTOR:
|
|
+ case VKD3DSIH_DCL_RESOURCE_RAW:
|
|
+ case VKD3DSIH_DCL_RESOURCE_STRUCTURED:
|
|
+ case VKD3DSIH_DCL_SAMPLER:
|
|
case VKD3DSIH_DCL_TEMPS:
|
|
+ case VKD3DSIH_DCL_UAV_RAW:
|
|
+ case VKD3DSIH_DCL_UAV_STRUCTURED:
|
|
+ case VKD3DSIH_DCL_UAV_TYPED:
|
|
case VKD3DSIH_HS_DECLS:
|
|
case VKD3DSIH_NOP:
|
|
/* nothing to do */
|
|
@@ -9503,24 +9486,48 @@ static int spirv_compiler_handle_instruction(struct spirv_compiler *compiler,
|
|
return ret;
|
|
}
|
|
|
|
-static void spirv_compiler_emit_sm1_constant_buffer(struct spirv_compiler *compiler,
|
|
- const struct vkd3d_shader_desc *desc, enum vkd3d_shader_d3dbc_constant_register set,
|
|
- enum vkd3d_data_type data_type)
|
|
+static void spirv_compiler_emit_descriptor_declarations(struct spirv_compiler *compiler)
|
|
{
|
|
- struct vkd3d_shader_register_range range = {.space = 0, .first = set, .last = set};
|
|
- uint32_t count = desc->flat_constant_count[set].external;
|
|
- struct vkd3d_shader_register reg =
|
|
+ unsigned int i;
|
|
+
|
|
+ for (i = 0; i < compiler->scan_descriptor_info->descriptor_count; ++i)
|
|
{
|
|
- .type = VKD3DSPR_CONSTBUFFER,
|
|
- .idx[0].offset = set, /* register ID */
|
|
- .idx[1].offset = set, /* register index */
|
|
- .idx[2].offset = count, /* size */
|
|
- .idx_count = 3,
|
|
- .data_type = data_type,
|
|
- };
|
|
+ const struct vkd3d_shader_descriptor_info1 *descriptor = &compiler->scan_descriptor_info->descriptors[i];
|
|
+ struct vkd3d_shader_register_range range;
|
|
+
|
|
+ range.first = descriptor->register_index;
|
|
+ if (descriptor->count == ~0u)
|
|
+ range.last = ~0u;
|
|
+ else
|
|
+ range.last = descriptor->register_index + descriptor->count - 1;
|
|
+ range.space = descriptor->register_space;
|
|
+
|
|
+ switch (descriptor->type)
|
|
+ {
|
|
+ case VKD3D_SHADER_DESCRIPTOR_TYPE_SAMPLER:
|
|
+ spirv_compiler_emit_sampler_declaration(compiler, &range, descriptor->register_id);
|
|
+ break;
|
|
+
|
|
+ case VKD3D_SHADER_DESCRIPTOR_TYPE_CBV:
|
|
+ spirv_compiler_emit_cbv_declaration(compiler, &range, descriptor->register_id, descriptor->buffer_size);
|
|
+ break;
|
|
|
|
- if (count)
|
|
- spirv_compiler_emit_constant_buffer(compiler, count, &range, ®);
|
|
+ case VKD3D_SHADER_DESCRIPTOR_TYPE_SRV:
|
|
+ spirv_compiler_emit_resource_declaration(compiler, &range, descriptor->register_id,
|
|
+ descriptor->sample_count, false, descriptor->resource_type, descriptor->resource_data_type,
|
|
+ descriptor->structure_stride / 4, descriptor->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER);
|
|
+ break;
|
|
+
|
|
+ case VKD3D_SHADER_DESCRIPTOR_TYPE_UAV:
|
|
+ spirv_compiler_emit_resource_declaration(compiler, &range, descriptor->register_id,
|
|
+ descriptor->sample_count, true, descriptor->resource_type, descriptor->resource_data_type,
|
|
+ descriptor->structure_stride / 4, descriptor->flags & VKD3D_SHADER_DESCRIPTOR_INFO_FLAG_RAW_BUFFER);
|
|
+ break;
|
|
+
|
|
+ default:
|
|
+ vkd3d_unreachable();
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
|
|
@@ -9538,12 +9545,7 @@ static int spirv_compiler_generate_spirv(struct spirv_compiler *compiler,
|
|
if (parser->shader_desc.temp_count)
|
|
spirv_compiler_emit_temps(compiler, parser->shader_desc.temp_count);
|
|
|
|
- spirv_compiler_emit_sm1_constant_buffer(compiler, &parser->shader_desc,
|
|
- VKD3D_SHADER_D3DBC_FLOAT_CONSTANT_REGISTER, VKD3D_DATA_FLOAT);
|
|
- spirv_compiler_emit_sm1_constant_buffer(compiler, &parser->shader_desc,
|
|
- VKD3D_SHADER_D3DBC_INT_CONSTANT_REGISTER, VKD3D_DATA_INT);
|
|
- spirv_compiler_emit_sm1_constant_buffer(compiler, &parser->shader_desc,
|
|
- VKD3D_SHADER_D3DBC_BOOL_CONSTANT_REGISTER, VKD3D_DATA_UINT);
|
|
+ spirv_compiler_emit_descriptor_declarations(compiler);
|
|
|
|
compiler->location.column = 0;
|
|
compiler->location.line = 1;
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
index 550f9b27cc7..7949be150bf 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
|
|
@@ -507,7 +507,7 @@ enum vkd3d_sm4_input_primitive_type
|
|
|
|
enum vkd3d_sm4_swizzle_type
|
|
{
|
|
- VKD3D_SM4_SWIZZLE_NONE = 0x0,
|
|
+ VKD3D_SM4_SWIZZLE_NONE = 0x0, /* swizzle bitfield contains a mask */
|
|
VKD3D_SM4_SWIZZLE_VEC4 = 0x1,
|
|
VKD3D_SM4_SWIZZLE_SCALAR = 0x2,
|
|
};
|
|
@@ -707,6 +707,19 @@ static void shader_sm4_read_conditional_op(struct vkd3d_shader_instruction *ins,
|
|
VKD3D_SHADER_CONDITIONAL_OP_NZ : VKD3D_SHADER_CONDITIONAL_OP_Z;
|
|
}
|
|
|
|
+static void shader_sm4_read_case_condition(struct vkd3d_shader_instruction *ins, uint32_t opcode,
|
|
+ uint32_t opcode_token, const uint32_t *tokens, unsigned int token_count, struct vkd3d_shader_sm4_parser *priv)
|
|
+{
|
|
+ shader_sm4_read_src_param(priv, &tokens, &tokens[token_count], VKD3D_DATA_UINT,
|
|
+ (struct vkd3d_shader_src_param *)&ins->src[0]);
|
|
+ if (ins->src[0].reg.type != VKD3DSPR_IMMCONST)
|
|
+ {
|
|
+ FIXME("Switch case value is not a 32-bit constant.\n");
|
|
+ vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_CASE_VALUE,
|
|
+ "Switch case value is not a 32-bit immediate constant register.");
|
|
+ }
|
|
+}
|
|
+
|
|
static void shader_sm4_read_shader_data(struct vkd3d_shader_instruction *ins, uint32_t opcode, uint32_t opcode_token,
|
|
const uint32_t *tokens, unsigned int token_count, struct vkd3d_shader_sm4_parser *priv)
|
|
{
|
|
@@ -1215,7 +1228,8 @@ static const struct vkd3d_sm4_opcode_info opcode_table[] =
|
|
{VKD3D_SM4_OP_BREAK, VKD3DSIH_BREAK, "", ""},
|
|
{VKD3D_SM4_OP_BREAKC, VKD3DSIH_BREAKP, "", "u",
|
|
shader_sm4_read_conditional_op},
|
|
- {VKD3D_SM4_OP_CASE, VKD3DSIH_CASE, "", "u"},
|
|
+ {VKD3D_SM4_OP_CASE, VKD3DSIH_CASE, "", "u",
|
|
+ shader_sm4_read_case_condition},
|
|
{VKD3D_SM4_OP_CONTINUE, VKD3DSIH_CONTINUE, "", ""},
|
|
{VKD3D_SM4_OP_CONTINUEC, VKD3DSIH_CONTINUEP, "", "u",
|
|
shader_sm4_read_conditional_op},
|
|
@@ -2012,6 +2026,7 @@ static bool shader_sm4_validate_input_output_register(struct vkd3d_shader_sm4_pa
|
|
static bool shader_sm4_read_src_param(struct vkd3d_shader_sm4_parser *priv, const uint32_t **ptr,
|
|
const uint32_t *end, enum vkd3d_data_type data_type, struct vkd3d_shader_src_param *src_param)
|
|
{
|
|
+ unsigned int dimension, mask;
|
|
DWORD token;
|
|
|
|
if (*ptr >= end)
|
|
@@ -2027,37 +2042,63 @@ static bool shader_sm4_read_src_param(struct vkd3d_shader_sm4_parser *priv, cons
|
|
return false;
|
|
}
|
|
|
|
- if (src_param->reg.type == VKD3DSPR_IMMCONST || src_param->reg.type == VKD3DSPR_IMMCONST64)
|
|
+ switch ((dimension = (token & VKD3D_SM4_DIMENSION_MASK) >> VKD3D_SM4_DIMENSION_SHIFT))
|
|
{
|
|
- src_param->swizzle = VKD3D_SHADER_NO_SWIZZLE;
|
|
- }
|
|
- else
|
|
- {
|
|
- enum vkd3d_sm4_swizzle_type swizzle_type =
|
|
- (token & VKD3D_SM4_SWIZZLE_TYPE_MASK) >> VKD3D_SM4_SWIZZLE_TYPE_SHIFT;
|
|
+ case VKD3D_SM4_DIMENSION_NONE:
|
|
+ case VKD3D_SM4_DIMENSION_SCALAR:
|
|
+ src_param->swizzle = VKD3D_SHADER_SWIZZLE(X, X, X, X);
|
|
+ break;
|
|
|
|
- switch (swizzle_type)
|
|
+ case VKD3D_SM4_DIMENSION_VEC4:
|
|
{
|
|
- case VKD3D_SM4_SWIZZLE_NONE:
|
|
- if (shader_sm4_is_scalar_register(&src_param->reg))
|
|
- src_param->swizzle = VKD3D_SHADER_SWIZZLE(X, X, X, X);
|
|
- else
|
|
+ enum vkd3d_sm4_swizzle_type swizzle_type =
|
|
+ (token & VKD3D_SM4_SWIZZLE_TYPE_MASK) >> VKD3D_SM4_SWIZZLE_TYPE_SHIFT;
|
|
+
|
|
+ switch (swizzle_type)
|
|
+ {
|
|
+ case VKD3D_SM4_SWIZZLE_NONE:
|
|
src_param->swizzle = VKD3D_SHADER_NO_SWIZZLE;
|
|
- break;
|
|
|
|
- case VKD3D_SM4_SWIZZLE_SCALAR:
|
|
- src_param->swizzle = (token & VKD3D_SM4_SWIZZLE_MASK) >> VKD3D_SM4_SWIZZLE_SHIFT;
|
|
- src_param->swizzle = (src_param->swizzle & 0x3) * 0x01010101;
|
|
- break;
|
|
+ mask = (token & VKD3D_SM4_WRITEMASK_MASK) >> VKD3D_SM4_WRITEMASK_SHIFT;
|
|
+ /* Mask seems only to be used for vec4 constants and is always zero. */
|
|
+ if (!register_is_constant(&src_param->reg))
|
|
+ {
|
|
+ FIXME("Source mask %#x is not for a constant.\n", mask);
|
|
+ vkd3d_shader_parser_warning(&priv->p, VKD3D_SHADER_WARNING_TPF_UNHANDLED_REGISTER_MASK,
|
|
+ "Unhandled mask %#x for a non-constant source register.", mask);
|
|
+ }
|
|
+ else if (mask)
|
|
+ {
|
|
+ FIXME("Unhandled mask %#x.\n", mask);
|
|
+ vkd3d_shader_parser_warning(&priv->p, VKD3D_SHADER_WARNING_TPF_UNHANDLED_REGISTER_MASK,
|
|
+ "Unhandled source register mask %#x.", mask);
|
|
+ }
|
|
|
|
- case VKD3D_SM4_SWIZZLE_VEC4:
|
|
- src_param->swizzle = swizzle_from_sm4((token & VKD3D_SM4_SWIZZLE_MASK) >> VKD3D_SM4_SWIZZLE_SHIFT);
|
|
- break;
|
|
+ break;
|
|
|
|
- default:
|
|
- FIXME("Unhandled swizzle type %#x.\n", swizzle_type);
|
|
- break;
|
|
+ case VKD3D_SM4_SWIZZLE_SCALAR:
|
|
+ src_param->swizzle = (token & VKD3D_SM4_SWIZZLE_MASK) >> VKD3D_SM4_SWIZZLE_SHIFT;
|
|
+ src_param->swizzle = (src_param->swizzle & 0x3) * 0x01010101;
|
|
+ break;
|
|
+
|
|
+ case VKD3D_SM4_SWIZZLE_VEC4:
|
|
+ src_param->swizzle = swizzle_from_sm4((token & VKD3D_SM4_SWIZZLE_MASK) >> VKD3D_SM4_SWIZZLE_SHIFT);
|
|
+ break;
|
|
+
|
|
+ default:
|
|
+ FIXME("Unhandled swizzle type %#x.\n", swizzle_type);
|
|
+ vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_SWIZZLE,
|
|
+ "Source register swizzle type %#x is invalid.", swizzle_type);
|
|
+ break;
|
|
+ }
|
|
+ break;
|
|
}
|
|
+
|
|
+ default:
|
|
+ FIXME("Unhandled dimension %#x.\n", dimension);
|
|
+ vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_DIMENSION,
|
|
+ "Source register dimension %#x is invalid.", dimension);
|
|
+ break;
|
|
}
|
|
|
|
if (register_is_input_output(&src_param->reg) && !shader_sm4_validate_input_output_register(priv,
|
|
@@ -2070,7 +2111,9 @@ static bool shader_sm4_read_src_param(struct vkd3d_shader_sm4_parser *priv, cons
|
|
static bool shader_sm4_read_dst_param(struct vkd3d_shader_sm4_parser *priv, const uint32_t **ptr,
|
|
const uint32_t *end, enum vkd3d_data_type data_type, struct vkd3d_shader_dst_param *dst_param)
|
|
{
|
|
+ enum vkd3d_sm4_swizzle_type swizzle_type;
|
|
enum vkd3d_shader_src_modifier modifier;
|
|
+ unsigned int dimension, swizzle;
|
|
DWORD token;
|
|
|
|
if (*ptr >= end)
|
|
@@ -2092,10 +2135,53 @@ static bool shader_sm4_read_dst_param(struct vkd3d_shader_sm4_parser *priv, cons
|
|
return false;
|
|
}
|
|
|
|
- dst_param->write_mask = (token & VKD3D_SM4_WRITEMASK_MASK) >> VKD3D_SM4_WRITEMASK_SHIFT;
|
|
+ switch ((dimension = (token & VKD3D_SM4_DIMENSION_MASK) >> VKD3D_SM4_DIMENSION_SHIFT))
|
|
+ {
|
|
+ case VKD3D_SM4_DIMENSION_NONE:
|
|
+ dst_param->write_mask = 0;
|
|
+ break;
|
|
+
|
|
+ case VKD3D_SM4_DIMENSION_SCALAR:
|
|
+ dst_param->write_mask = VKD3DSP_WRITEMASK_0;
|
|
+ break;
|
|
+
|
|
+ case VKD3D_SM4_DIMENSION_VEC4:
|
|
+ swizzle_type = (token & VKD3D_SM4_SWIZZLE_TYPE_MASK) >> VKD3D_SM4_SWIZZLE_TYPE_SHIFT;
|
|
+ switch (swizzle_type)
|
|
+ {
|
|
+ case VKD3D_SM4_SWIZZLE_NONE:
|
|
+ dst_param->write_mask = (token & VKD3D_SM4_WRITEMASK_MASK) >> VKD3D_SM4_WRITEMASK_SHIFT;
|
|
+ break;
|
|
+
|
|
+ case VKD3D_SM4_SWIZZLE_VEC4:
|
|
+ swizzle = swizzle_from_sm4((token & VKD3D_SM4_SWIZZLE_MASK) >> VKD3D_SM4_SWIZZLE_SHIFT);
|
|
+ if (swizzle != VKD3D_SHADER_NO_SWIZZLE)
|
|
+ {
|
|
+ FIXME("Unhandled swizzle %#x.\n", swizzle);
|
|
+ vkd3d_shader_parser_warning(&priv->p, VKD3D_SHADER_WARNING_TPF_UNHANDLED_REGISTER_SWIZZLE,
|
|
+ "Unhandled destination register swizzle %#x.", swizzle);
|
|
+ }
|
|
+ dst_param->write_mask = VKD3DSP_WRITEMASK_ALL;
|
|
+ break;
|
|
+
|
|
+ default:
|
|
+ FIXME("Unhandled swizzle type %#x.\n", swizzle_type);
|
|
+ vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_SWIZZLE,
|
|
+ "Destination register swizzle type %#x is invalid.", swizzle_type);
|
|
+ break;
|
|
+ }
|
|
+ break;
|
|
+
|
|
+ default:
|
|
+ FIXME("Unhandled dimension %#x.\n", dimension);
|
|
+ vkd3d_shader_parser_error(&priv->p, VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_DIMENSION,
|
|
+ "Destination register dimension %#x is invalid.", dimension);
|
|
+ break;
|
|
+ }
|
|
+
|
|
if (data_type == VKD3D_DATA_DOUBLE)
|
|
dst_param->write_mask = vkd3d_write_mask_64_from_32(dst_param->write_mask);
|
|
- /* Scalar registers are declared with no write mask in shader bytecode. */
|
|
+ /* Some scalar registers are declared with no write mask in shader bytecode. */
|
|
if (!dst_param->write_mask && shader_sm4_is_scalar_register(&dst_param->reg))
|
|
dst_param->write_mask = VKD3DSP_WRITEMASK_0;
|
|
dst_param->modifiers = 0;
|
|
@@ -3715,8 +3801,10 @@ static void sm4_src_from_constant_value(struct sm4_src_register *src,
|
|
src->reg.dim = VKD3D_SM4_DIMENSION_VEC4;
|
|
for (i = 0; i < 4; ++i)
|
|
{
|
|
- if (map_writemask & (1u << i))
|
|
+ if ((map_writemask & (1u << i)) && (j < width))
|
|
src->reg.immconst_uint[i] = value->u[j++].u;
|
|
+ else
|
|
+ src->reg.immconst_uint[i] = 0;
|
|
}
|
|
}
|
|
}
|
|
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
index bf925a44690..84614a4eb79 100644
|
|
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_private.h
|
|
@@ -78,9 +78,14 @@ enum vkd3d_shader_error
|
|
VKD3D_SHADER_ERROR_TPF_TOO_MANY_REGISTERS = 1004,
|
|
VKD3D_SHADER_ERROR_TPF_INVALID_IO_REGISTER = 1005,
|
|
VKD3D_SHADER_ERROR_TPF_INVALID_INDEX_RANGE_DCL = 1006,
|
|
+ VKD3D_SHADER_ERROR_TPF_INVALID_CASE_VALUE = 1007,
|
|
+ VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_DIMENSION = 1008,
|
|
+ VKD3D_SHADER_ERROR_TPF_INVALID_REGISTER_SWIZZLE = 1009,
|
|
|
|
VKD3D_SHADER_WARNING_TPF_MASK_NOT_CONTIGUOUS = 1300,
|
|
VKD3D_SHADER_WARNING_TPF_UNHANDLED_INDEX_RANGE_MASK = 1301,
|
|
+ VKD3D_SHADER_WARNING_TPF_UNHANDLED_REGISTER_MASK = 1302,
|
|
+ VKD3D_SHADER_WARNING_TPF_UNHANDLED_REGISTER_SWIZZLE = 1303,
|
|
|
|
VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_BINDING_NOT_FOUND = 2000,
|
|
VKD3D_SHADER_ERROR_SPV_INVALID_REGISTER_TYPE = 2001,
|
|
@@ -88,6 +93,8 @@ enum vkd3d_shader_error
|
|
VKD3D_SHADER_ERROR_SPV_DESCRIPTOR_IDX_UNSUPPORTED = 2003,
|
|
VKD3D_SHADER_ERROR_SPV_STENCIL_EXPORT_UNSUPPORTED = 2004,
|
|
|
|
+ VKD3D_SHADER_WARNING_SPV_INVALID_SWIZZLE = 2300,
|
|
+
|
|
VKD3D_SHADER_ERROR_RS_OUT_OF_MEMORY = 3000,
|
|
VKD3D_SHADER_ERROR_RS_INVALID_VERSION = 3001,
|
|
VKD3D_SHADER_ERROR_RS_INVALID_ROOT_PARAMETER_TYPE = 3002,
|
|
@@ -140,6 +147,7 @@ enum vkd3d_shader_error
|
|
VKD3D_SHADER_WARNING_HLSL_UNKNOWN_ATTRIBUTE = 5302,
|
|
VKD3D_SHADER_WARNING_HLSL_IMAGINARY_NUMERIC_RESULT = 5303,
|
|
VKD3D_SHADER_WARNING_HLSL_NON_FINITE_RESULT = 5304,
|
|
+ VKD3D_SHADER_WARNING_HLSL_IGNORED_ATTRIBUTE = 5305,
|
|
|
|
VKD3D_SHADER_ERROR_GLSL_INTERNAL = 6000,
|
|
|
|
@@ -1012,6 +1020,11 @@ static inline bool vkd3d_shader_register_is_patch_constant(const struct vkd3d_sh
|
|
return reg->type == VKD3DSPR_PATCHCONST;
|
|
}
|
|
|
|
+static inline bool register_is_constant(const struct vkd3d_shader_register *reg)
|
|
+{
|
|
+ return (reg->type == VKD3DSPR_IMMCONST || reg->type == VKD3DSPR_IMMCONST64);
|
|
+}
|
|
+
|
|
struct vkd3d_shader_location
|
|
{
|
|
const char *source_name;
|
|
@@ -1310,6 +1323,30 @@ static inline enum vkd3d_data_type vkd3d_data_type_from_component_type(
|
|
}
|
|
}
|
|
|
|
+static inline enum vkd3d_shader_component_type vkd3d_component_type_from_resource_data_type(
|
|
+ enum vkd3d_shader_resource_data_type data_type)
|
|
+{
|
|
+ switch (data_type)
|
|
+ {
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_FLOAT:
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_UNORM:
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_SNORM:
|
|
+ return VKD3D_SHADER_COMPONENT_FLOAT;
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_UINT:
|
|
+ return VKD3D_SHADER_COMPONENT_UINT;
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_INT:
|
|
+ return VKD3D_SHADER_COMPONENT_INT;
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_DOUBLE:
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_CONTINUED:
|
|
+ return VKD3D_SHADER_COMPONENT_DOUBLE;
|
|
+ default:
|
|
+ FIXME("Unhandled data type %#x.\n", data_type);
|
|
+ /* fall-through */
|
|
+ case VKD3D_SHADER_RESOURCE_DATA_MIXED:
|
|
+ return VKD3D_SHADER_COMPONENT_UINT;
|
|
+ }
|
|
+}
|
|
+
|
|
enum vkd3d_shader_input_sysval_semantic vkd3d_siv_from_sysval_indexed(enum vkd3d_shader_sysval_semantic sysval,
|
|
unsigned int index);
|
|
|
|
diff --git a/libs/vkd3d/libs/vkd3d/command.c b/libs/vkd3d/libs/vkd3d/command.c
|
|
index 8b5f7899cf3..42a98763438 100644
|
|
--- a/libs/vkd3d/libs/vkd3d/command.c
|
|
+++ b/libs/vkd3d/libs/vkd3d/command.c
|
|
@@ -3225,7 +3225,10 @@ static void command_list_add_descriptor_heap(struct d3d12_command_list *list, st
|
|
{
|
|
/* Descriptors can be written after binding. */
|
|
FIXME("Flushing descriptor updates while list %p is not closed.\n", list);
|
|
- command_list_flush_vk_heap_updates(list);
|
|
+ vkd3d_mutex_lock(&heap->vk_sets_mutex);
|
|
+ d3d12_desc_flush_vk_heap_updates_locked(heap, list->device);
|
|
+ vkd3d_mutex_unlock(&heap->vk_sets_mutex);
|
|
+ return;
|
|
}
|
|
list->descriptor_heaps[list->descriptor_heap_count++] = heap;
|
|
}
|
|
--
|
|
2.40.1
|
|
|