Rebase against 6558611fa2d24447297cb62d168b924c33839c43.

This commit is contained in:
Alistair Leslie-Hughes 2023-09-20 08:16:07 +10:00
parent 53515d7e75
commit c4da0a8993
9 changed files with 3930 additions and 5031 deletions

View File

@ -1,19 +1,19 @@
From 87bf08071997f446498bdea2d18d1bb539a1990e Mon Sep 17 00:00:00 2001
From cdbd2714d5454e6518b699e3cdbedd3e0a1243c5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 2 Dec 2022 14:41:30 +1100
Subject: [PATCH] dmime: Implement IDirectMusicSegment8 Download
---
dlls/dmime/dmime_private.h | 2 +
dlls/dmime/performance.c | 7 +++
dlls/dmime/segment.c | 87 ++++++++++++++++++++++++++++++++++++--
3 files changed, 93 insertions(+), 3 deletions(-)
dlls/dmime/performance.c | 7 ++++
dlls/dmime/segment.c | 80 +++++++++++++++++++++++++++++++++++++-
3 files changed, 88 insertions(+), 1 deletion(-)
diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h
index 6102fd5ec2f..da40b58ad9b 100644
index eacde4b46be..cd34378b66e 100644
--- a/dlls/dmime/dmime_private.h
+++ b/dlls/dmime/dmime_private.h
@@ -71,6 +71,8 @@ extern void set_audiopath_perf_pointer(IDirectMusicAudioPath*,IDirectMusicPerfor
@@ -70,6 +70,8 @@ extern void set_audiopath_perf_pointer(IDirectMusicAudioPath*,IDirectMusicPerfor
extern void set_audiopath_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffer*);
extern void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffer*);
@ -23,10 +23,10 @@ index 6102fd5ec2f..da40b58ad9b 100644
* Auxiliary definitions
*/
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c
index 1f8de0837d5..622939f3553 100644
index d8624427423..a707de39d50 100644
--- a/dlls/dmime/performance.c
+++ b/dlls/dmime/performance.c
@@ -253,6 +253,13 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi
@@ -251,6 +251,13 @@ static inline struct performance *impl_from_IDirectMusicPerformance8(IDirectMusi
return CONTAINING_RECORD(iface, struct performance, IDirectMusicPerformance8_iface);
}
@ -41,34 +41,31 @@ index 1f8de0837d5..622939f3553 100644
static HRESULT WINAPI performance_QueryInterface(IDirectMusicPerformance8 *iface, REFIID riid, void **ret_iface)
{
diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c
index 39a5333fbbb..ce49ddc9940 100644
index a72ec786623..ebee90eee92 100644
--- a/dlls/dmime/segment.c
+++ b/dlls/dmime/segment.c
@@ -37,6 +37,7 @@ typedef struct IDirectMusicSegment8Impl {
@@ -54,6 +54,7 @@ struct segment
PCMWAVEFORMAT wave_format;
void *wave_data;
int data_size;
+ IDirectSoundBuffer *buffer;
} IDirectMusicSegment8Impl;
};
IDirectMusicSegment8Impl *create_segment(void);
@@ -90,6 +91,8 @@ static ULONG WINAPI IDirectMusicSegment8Impl_Release(IDirectMusicSegment8 *iface
TRACE("(%p) ref=%ld\n", This, ref);
static struct segment *segment_create(void);
@@ -114,6 +115,8 @@ static ULONG WINAPI segment_Release(IDirectMusicSegment8 *iface)
track_entry_destroy(entry);
}
if (!ref) {
+ if (This->buffer)
+ IDirectSoundBuffer_Release(This->buffer);
if (This->wave_data)
free(This->wave_data);
@@ -559,9 +562,87 @@ static HRESULT WINAPI IDirectMusicSegment8Impl_Compose(IDirectMusicSegment8 *ifa
static HRESULT WINAPI IDirectMusicSegment8Impl_Download(IDirectMusicSegment8 *iface,
IUnknown *pAudioPath)
@@ -517,7 +520,82 @@ static HRESULT WINAPI segment_Compose(IDirectMusicSegment8 *iface, MUSIC_TIME mt
static HRESULT WINAPI segment_Download(IDirectMusicSegment8 *iface, IUnknown *pAudioPath)
{
- IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
- FIXME("(%p, %p): stub\n", This, pAudioPath);
- return S_OK;
+ IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
struct segment *This = impl_from_IDirectMusicSegment8(iface);
- FIXME("(%p, %p): stub\n", This, pAudioPath);
+ IDirectMusicPerformance8 *perf;
+ IDirectMusicAudioPath *audio;
+ IDirectSound *dsound;
@ -145,13 +142,9 @@ index 39a5333fbbb..ce49ddc9940 100644
+ hr = IDirectSoundBuffer_Unlock(This->buffer, data, This->data_size, NULL, 0);
+ TRACE("IDirectSoundBuffer_Unlock hr 0x%08lx\n", hr);
+
+ /*hr = IDirectSoundBuffer_Play(This->buffer, 0, 0, 0);
+ TRACE("IDirectSoundBuffer_Play hr 0x%08lx\n", hr);*/
+
+ return S_OK;
return S_OK;
}
static HRESULT WINAPI IDirectMusicSegment8Impl_Unload(IDirectMusicSegment8 *iface,
--
2.40.1

View File

@ -1,4 +1,4 @@
From 43007318a6303312b6226c9ede009e4299826af3 Mon Sep 17 00:00:00 2001
From ea9bd0ec85254305b5783e1890ded6b21d200f41 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Mon, 12 Dec 2022 15:20:10 +1100
Subject: [PATCH] dmime: Play a sound in IDirectMusicPerformance8 PlaySegmentEx
@ -10,10 +10,10 @@ Subject: [PATCH] dmime: Play a sound in IDirectMusicPerformance8 PlaySegmentEx
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/dmime/dmime_private.h b/dlls/dmime/dmime_private.h
index da40b58ad9b..4532528f535 100644
index cd34378b66e..c83f6675333 100644
--- a/dlls/dmime/dmime_private.h
+++ b/dlls/dmime/dmime_private.h
@@ -72,6 +72,7 @@ extern void set_audiopath_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffe
@@ -71,6 +71,7 @@ extern void set_audiopath_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffe
extern void set_audiopath_primary_dsound_buffer(IDirectMusicAudioPath*,IDirectSoundBuffer*);
extern IDirectSound *get_dsound_interface(IDirectMusicPerformance8*);
@ -22,10 +22,10 @@ index da40b58ad9b..4532528f535 100644
/*****************************************************************************
* Auxiliary definitions
diff --git a/dlls/dmime/performance.c b/dlls/dmime/performance.c
index 622939f3553..c7b149f0686 100644
index a707de39d50..2b09814cd6b 100644
--- a/dlls/dmime/performance.c
+++ b/dlls/dmime/performance.c
@@ -1028,13 +1028,26 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface,
@@ -1053,13 +1053,26 @@ static HRESULT WINAPI performance_PlaySegmentEx(IDirectMusicPerformance8 *iface,
WCHAR *pwzSegmentName, IUnknown *pTransition, DWORD dwFlags, __int64 i64StartTime,
IDirectMusicSegmentState **ppSegmentState, IUnknown *pFrom, IUnknown *pAudioPath)
{
@ -59,22 +59,22 @@ index 622939f3553..c7b149f0686 100644
static HRESULT WINAPI performance_StopEx(IDirectMusicPerformance8 *iface, IUnknown *pObjectToStop,
diff --git a/dlls/dmime/segment.c b/dlls/dmime/segment.c
index ce49ddc9940..ad121736acd 100644
index ebee90eee92..8482cb21d34 100644
--- a/dlls/dmime/segment.c
+++ b/dlls/dmime/segment.c
@@ -47,6 +47,12 @@ static inline IDirectMusicSegment8Impl *impl_from_IDirectMusicSegment8(IDirectMu
return CONTAINING_RECORD(iface, IDirectMusicSegment8Impl, IDirectMusicSegment8_iface);
@@ -64,6 +64,12 @@ static inline struct segment *impl_from_IDirectMusicSegment8(IDirectMusicSegment
return CONTAINING_RECORD(iface, struct segment, IDirectMusicSegment8_iface);
}
+IDirectSoundBuffer *get_segment_buffer(IDirectMusicSegment8 *iface)
+{
+ IDirectMusicSegment8Impl *This = impl_from_IDirectMusicSegment8(iface);
+ struct segment *This = impl_from_IDirectMusicSegment8(iface);
+ return This->buffer;
+}
+
static HRESULT WINAPI IDirectMusicSegment8Impl_QueryInterface(IDirectMusicSegment8 *iface,
REFIID riid, void **ret_iface)
static HRESULT WINAPI segment_QueryInterface(IDirectMusicSegment8 *iface, REFIID riid, void **ret_iface)
{
struct segment *This = impl_from_IDirectMusicSegment8(iface);
--
2.40.1

View File

@ -1,4 +1,4 @@
From ffc72a34adff66a7e763f682288f95498b8b5f28 Mon Sep 17 00:00:00 2001
From c02f983dde361302e69fb6da9526801b59e41b07 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 17 May 2023 08:35:40 +1000
Subject: [PATCH] Update vkd3d to 771e442af16228a977eebba82224f06f6d0202fe
@ -27970,7 +27970,7 @@ index 79be999adf9..406d53a3391 100644
+
#endif /* __VKD3D_SHADER_PRIVATE_H */
diff --git a/libs/vkd3d/libs/vkd3d/command.c b/libs/vkd3d/libs/vkd3d/command.c
index 6eddcfa2d14..32439eec7eb 100644
index 4e2d4295935..c5bd687bd69 100644
--- a/libs/vkd3d/libs/vkd3d/command.c
+++ b/libs/vkd3d/libs/vkd3d/command.c
@@ -1437,7 +1437,7 @@ static VkDescriptorPool d3d12_command_allocator_allocate_descriptor_pool(

View File

@ -1,947 +0,0 @@
From 5d17ecf1f2fc977fe26e8a7acaf54e9d60b97204 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);
+ &reg, range, VKD3D_SHADER_RESOURCE_BUFFER, false, &var_info);
- vkd3d_symbol_make_register(&reg_symbol, reg);
+ vkd3d_symbol_make_register(&reg_symbol, &reg);
vkd3d_symbol_set_register_info(&reg_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, &reg_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, &reg_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(&reg_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(&reg_symbol, &reg);
+ reg_symbol.info.sampler.range = *range;
spirv_compiler_put_symbol(compiler, &reg_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, &reg,
+ range, VKD3D_SHADER_RESOURCE_NONE, false, &var_info);
- vkd3d_symbol_make_register(&reg_symbol, reg);
+ vkd3d_symbol_make_register(&reg_symbol, &reg);
vkd3d_symbol_set_register_info(&reg_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, &reg, 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, &reg, 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, &reg,
+ 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, &reg, range, resource_type, true, &counter_var_info);
}
}
- vkd3d_symbol_make_resource(&resource_symbol, reg);
+ vkd3d_symbol_make_resource(&resource_symbol, &reg);
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, &reg);
+ 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

View File

@ -1,432 +0,0 @@
From d781aee2d58e59b61a34fefef0a4ce4b527a6c99 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 16 Sep 2023 07:19:25 +1000
Subject: [PATCH] Updated vkd3d to ee28861837c825818ace2e1e50825ade87a9c723.
---
libs/vkd3d/libs/vkd3d-shader/d3d_asm.c | 2 +-
libs/vkd3d/libs/vkd3d-shader/d3dbc.c | 4 -
libs/vkd3d/libs/vkd3d-shader/hlsl.c | 3 +-
libs/vkd3d/libs/vkd3d-shader/hlsl.h | 9 +-
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 56 +++++++++-
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 100 ++++++++++++++++++
libs/vkd3d/libs/vkd3d-shader/spirv.c | 10 +-
libs/vkd3d/libs/vkd3d-shader/tpf.c | 25 +++++
.../libs/vkd3d-shader/vkd3d_shader_main.c | 3 +-
9 files changed, 197 insertions(+), 15 deletions(-)
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c
index d72402eb250..f0c386f1b3a 100644
--- a/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c
+++ b/libs/vkd3d/libs/vkd3d-shader/d3d_asm.c
@@ -714,7 +714,7 @@ static void shader_dump_decl_usage(struct vkd3d_d3d_asm_compiler *compiler,
break;
case VKD3D_DECL_USAGE_TEXCOORD:
- shader_addline(buffer, "texture%u", semantic->usage_idx);
+ shader_addline(buffer, "texcoord%u", semantic->usage_idx);
break;
case VKD3D_DECL_USAGE_TANGENT:
diff --git a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
index 2b02d51f59a..d5104ae9b79 100644
--- a/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
+++ b/libs/vkd3d/libs/vkd3d-shader/d3dbc.c
@@ -1982,10 +1982,6 @@ static void write_sm1_sampler_dcl(struct hlsl_ctx *ctx, struct vkd3d_bytecode_bu
switch (sampler_dim)
{
- case HLSL_SAMPLER_DIM_1D:
- res_type = VKD3D_SM1_RESOURCE_TEXTURE_1D;
- break;
-
case HLSL_SAMPLER_DIM_2D:
res_type = VKD3D_SM1_RESOURCE_TEXTURE_2D;
break;
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.c b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
index b8cf6813f67..5fe9047bf25 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.c
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.c
@@ -2486,7 +2486,8 @@ const char *debug_hlsl_expr_op(enum hlsl_ir_expr_op op)
[HLSL_OP2_RSHIFT] = ">>",
[HLSL_OP3_DP2ADD] = "dp2add",
- [HLSL_OP3_LERP] = "lerp",
+ [HLSL_OP3_MOVC] = "movc",
+ [HLSL_OP3_TERNARY] = "ternary",
};
return op_names[op];
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.h b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
index 73b08ee3ea0..2cde5d58eba 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.h
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.h
@@ -550,8 +550,15 @@ enum hlsl_ir_expr_op
HLSL_OP2_NEQUAL,
HLSL_OP2_RSHIFT,
+ /* DP2ADD(a, b, c) computes the scalar product of a.xy and b.xy,
+ * then adds c. */
HLSL_OP3_DP2ADD,
- HLSL_OP3_LERP,
+ /* MOVC(a, b, c) returns c if a is bitwise zero and b otherwise.
+ * TERNARY(a, b, c) returns c if a == 0 and b otherwise.
+ * They differ for floating point numbers, because
+ * -0.0 == 0.0, but it is not bitwise zero. */
+ HLSL_OP3_MOVC,
+ HLSL_OP3_TERNARY,
};
#define HLSL_MAX_OPERANDS 3
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
index 161d1ab42c3..fb6d485ea69 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
@@ -2913,6 +2913,7 @@ static bool intrinsic_fmod(struct hlsl_ctx *ctx, const struct parse_initializer
const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_node *x, *y, *div, *abs, *frac, *neg_frac, *ge, *select, *zero;
+ struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS] = { 0 };
static const struct hlsl_constant_value zero_value;
if (!(x = intrinsic_float_convert_arg(ctx, params, params->args[0], loc)))
@@ -2940,7 +2941,10 @@ static bool intrinsic_fmod(struct hlsl_ctx *ctx, const struct parse_initializer
if (!(ge = add_binary_comparison_expr(ctx, params->instrs, HLSL_OP2_GEQUAL, div, zero, loc)))
return false;
- if (!(select = hlsl_add_conditional(ctx, params->instrs, ge, frac, neg_frac)))
+ operands[0] = ge;
+ operands[1] = frac;
+ operands[2] = neg_frac;
+ if (!(select = add_expr(ctx, params->instrs, HLSL_OP3_TERNARY, operands, x->data_type, loc)))
return false;
return !!add_binary_arithmetic_expr(ctx, params->instrs, HLSL_OP2_MUL, select, y, loc);
@@ -3453,7 +3457,42 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
if (!(coords = add_implicit_conversion(ctx, params->instrs, params->args[1],
hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, hlsl_sampler_dim_count(dim)), loc)))
- coords = params->args[1];
+ {
+ return false;
+ }
+
+ /* tex1D() functions never produce 1D resource declarations. For newer profiles half offset
+ is used for the second coordinate, while older ones appear to replicate first coordinate.*/
+ if (dim == HLSL_SAMPLER_DIM_1D)
+ {
+ struct hlsl_ir_load *load;
+ struct hlsl_ir_node *half;
+ struct hlsl_ir_var *var;
+ unsigned int idx = 0;
+
+ if (!(var = hlsl_new_synthetic_var(ctx, "coords", hlsl_get_vector_type(ctx, HLSL_TYPE_FLOAT, 2), loc)))
+ return false;
+
+ initialize_var_components(ctx, params->instrs, var, &idx, coords);
+ if (shader_profile_version_ge(ctx, 4, 0))
+ {
+ if (!(half = hlsl_new_float_constant(ctx, 0.5f, loc)))
+ return false;
+ hlsl_block_add_instr(params->instrs, half);
+
+ initialize_var_components(ctx, params->instrs, var, &idx, half);
+ }
+ else
+ initialize_var_components(ctx, params->instrs, var, &idx, coords);
+
+ if (!(load = hlsl_new_var_load(ctx, var, loc)))
+ return false;
+ hlsl_block_add_instr(params->instrs, &load->node);
+
+ coords = &load->node;
+
+ dim = HLSL_SAMPLER_DIM_2D;
+ }
load_params.coords = coords;
load_params.resource = params->args[0];
@@ -3466,6 +3505,12 @@ static bool intrinsic_tex(struct hlsl_ctx *ctx, const struct parse_initializer *
return true;
}
+static bool intrinsic_tex1D(struct hlsl_ctx *ctx,
+ const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
+{
+ return intrinsic_tex(ctx, params, loc, "tex1D", HLSL_SAMPLER_DIM_1D);
+}
+
static bool intrinsic_tex2D(struct hlsl_ctx *ctx,
const struct parse_initializer *params, const struct vkd3d_shader_location *loc)
{
@@ -3652,6 +3697,7 @@ intrinsic_functions[] =
{"smoothstep", 3, true, intrinsic_smoothstep},
{"sqrt", 1, true, intrinsic_sqrt},
{"step", 2, true, intrinsic_step},
+ {"tex1D", -1, false, intrinsic_tex1D},
{"tex2D", -1, false, intrinsic_tex2D},
{"tex3D", -1, false, intrinsic_tex3D},
{"texCUBE", -1, false, intrinsic_texCUBE},
@@ -6555,6 +6601,7 @@ conditional_expr:
struct hlsl_ir_node *cond = node_from_block($1);
struct hlsl_ir_node *first = node_from_block($3);
struct hlsl_ir_node *second = node_from_block($5);
+ struct hlsl_ir_node *args[HLSL_MAX_OPERANDS] = { 0 };
struct hlsl_type *common_type;
hlsl_block_add_block($1, $3);
@@ -6571,7 +6618,10 @@ conditional_expr:
if (!(second = add_implicit_conversion(ctx, $1, second, common_type, &@5)))
YYABORT;
- if (!hlsl_add_conditional(ctx, $1, cond, first, second))
+ args[0] = cond;
+ args[1] = first;
+ args[2] = second;
+ if (!add_expr(ctx, $1, HLSL_OP3_TERNARY, args, common_type, &@1))
YYABORT;
$$ = $1;
}
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
index 710d2908166..be024842164 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
@@ -934,6 +934,55 @@ static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct h
return &coords_load->node;
}
+/* hlsl_ir_swizzle nodes that directly point to a matrix value are only a parse-time construct that
+ * represents matrix swizzles (e.g. mat._m01_m23) before we know if they will be used in the lhs of
+ * an assignment or as a value made from different components of the matrix. The former cases should
+ * have already been split into several separate assignments, but the latter are lowered by this
+ * pass. */
+static bool lower_matrix_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, struct hlsl_block *block)
+{
+ struct hlsl_ir_swizzle *swizzle;
+ struct hlsl_ir_load *var_load;
+ struct hlsl_deref var_deref;
+ struct hlsl_type *matrix_type;
+ struct hlsl_ir_var *var;
+ unsigned int x, y, k, i;
+
+ if (instr->type != HLSL_IR_SWIZZLE)
+ return false;
+ swizzle = hlsl_ir_swizzle(instr);
+ matrix_type = swizzle->val.node->data_type;
+ if (matrix_type->class != HLSL_CLASS_MATRIX)
+ return false;
+
+ if (!(var = hlsl_new_synthetic_var(ctx, "matrix-swizzle", instr->data_type, &instr->loc)))
+ return false;
+ hlsl_init_simple_deref_from_var(&var_deref, var);
+
+ for (i = 0; i < instr->data_type->dimx; ++i)
+ {
+ struct hlsl_block store_block;
+ struct hlsl_ir_node *load;
+
+ y = (swizzle->swizzle >> (8 * i + 4)) & 0xf;
+ x = (swizzle->swizzle >> 8 * i) & 0xf;
+ k = y * matrix_type->dimx + x;
+
+ if (!(load = hlsl_add_load_component(ctx, block, swizzle->val.node, k, &instr->loc)))
+ return false;
+
+ if (!hlsl_new_store_component(ctx, &store_block, &var_deref, i, load))
+ return false;
+ hlsl_block_add_block(block, &store_block);
+ }
+
+ if (!(var_load = hlsl_new_var_load(ctx, var, &instr->loc)))
+ return false;
+ hlsl_block_add_instr(block, &var_load->node);
+
+ return true;
+}
+
/* hlsl_ir_index nodes are a parse-time construct used to represent array indexing and struct
* record access before knowing if they will be used in the lhs of an assignment --in which case
* they are lowered into a deref-- or as the load of an element within a larger value.
@@ -2391,6 +2440,54 @@ static bool lower_round(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *
return true;
}
+/* Use 'movc' for the ternary operator. */
+static bool lower_ternary(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
+{
+ struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS], *replacement;
+ struct hlsl_ir_node *zero, *cond, *first, *second;
+ struct hlsl_constant_value zero_value = { 0 };
+ struct hlsl_ir_expr *expr;
+ struct hlsl_type *type;
+
+ if (instr->type != HLSL_IR_EXPR)
+ return false;
+
+ expr = hlsl_ir_expr(instr);
+ if (expr->op != HLSL_OP3_TERNARY)
+ return false;
+
+ cond = expr->operands[0].node;
+ first = expr->operands[1].node;
+ second = expr->operands[2].node;
+
+ if (cond->data_type->base_type == HLSL_TYPE_FLOAT)
+ {
+ if (!(zero = hlsl_new_constant(ctx, cond->data_type, &zero_value, &instr->loc)))
+ return false;
+ list_add_tail(&instr->entry, &zero->entry);
+
+ memset(operands, 0, sizeof(operands));
+ operands[0] = zero;
+ operands[1] = cond;
+ type = cond->data_type;
+ type = hlsl_get_numeric_type(ctx, type->class, HLSL_TYPE_BOOL, type->dimx, type->dimy);
+ if (!(cond = hlsl_new_expr(ctx, HLSL_OP2_NEQUAL, operands, type, &instr->loc)))
+ return false;
+ list_add_before(&instr->entry, &cond->entry);
+ }
+
+ memset(operands, 0, sizeof(operands));
+ operands[0] = cond;
+ operands[1] = first;
+ operands[2] = second;
+ if (!(replacement = hlsl_new_expr(ctx, HLSL_OP3_MOVC, operands, first->data_type, &instr->loc)))
+ return false;
+ list_add_before(&instr->entry, &replacement->entry);
+
+ hlsl_replace_node(instr, replacement);
+ return true;
+}
+
static bool lower_casts_to_bool(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
{
struct hlsl_type *type = instr->data_type, *arg_type;
@@ -4247,6 +4344,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
while (hlsl_transform_ir(ctx, lower_calls, body, NULL));
+ lower_ir(ctx, lower_matrix_swizzles, body);
hlsl_transform_ir(ctx, lower_index_loads, body, NULL);
LIST_FOR_EACH_ENTRY(var, &ctx->globals->vars, struct hlsl_ir_var, scope_entry)
@@ -4349,6 +4447,8 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry
hlsl_transform_ir(ctx, track_object_components_usage, body, NULL);
sort_synthetic_separated_samplers_first(ctx);
+ if (profile->major_version >= 4)
+ hlsl_transform_ir(ctx, lower_ternary, body, NULL);
if (profile->major_version < 4)
{
hlsl_transform_ir(ctx, lower_division, body, NULL);
diff --git a/libs/vkd3d/libs/vkd3d-shader/spirv.c b/libs/vkd3d/libs/vkd3d-shader/spirv.c
index f93960d6d54..95f6914acb7 100644
--- a/libs/vkd3d/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d/libs/vkd3d-shader/spirv.c
@@ -5564,7 +5564,7 @@ static uint32_t spirv_compiler_build_descriptor_variable(struct spirv_compiler *
}
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)
+ const struct vkd3d_shader_register_range *range, unsigned int register_id, unsigned int size_in_bytes)
{
struct vkd3d_spirv_builder *builder = &compiler->spirv_builder;
uint32_t vec4_id, array_type_id, length_id, struct_id, var_id;
@@ -5572,6 +5572,7 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler,
struct vkd3d_push_constant_buffer_binding *push_cb;
struct vkd3d_descriptor_variable_info var_info;
struct vkd3d_symbol reg_symbol;
+ unsigned int size;
struct vkd3d_shader_register reg =
{
@@ -5580,18 +5581,19 @@ static void spirv_compiler_emit_cbv_declaration(struct spirv_compiler *compiler,
.idx_count = 1,
};
+ size = size_in_bytes / (VKD3D_VEC4_SIZE * sizeof(uint32_t));
+
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->size = size;
- if (cb_size_in_bytes > push_cb->pc.size)
+ if (size_in_bytes > push_cb->pc.size)
{
WARN("Constant buffer size %u exceeds push constant size %u.\n",
- cb_size_in_bytes, push_cb->pc.size);
+ size_in_bytes, push_cb->pc.size);
}
return;
}
diff --git a/libs/vkd3d/libs/vkd3d-shader/tpf.c b/libs/vkd3d/libs/vkd3d-shader/tpf.c
index 7949be150bf..045fb6c5f64 100644
--- a/libs/vkd3d/libs/vkd3d-shader/tpf.c
+++ b/libs/vkd3d/libs/vkd3d-shader/tpf.c
@@ -4341,6 +4341,26 @@ static void write_sm4_binary_op_with_two_destinations(const struct tpf_writer *t
write_sm4_instruction(tpf, &instr);
}
+static void write_sm4_ternary_op(const struct tpf_writer *tpf, enum vkd3d_sm4_opcode opcode,
+ const struct hlsl_ir_node *dst, const struct hlsl_ir_node *src1, const struct hlsl_ir_node *src2,
+ const struct hlsl_ir_node *src3)
+{
+ struct sm4_instruction instr;
+
+ memset(&instr, 0, sizeof(instr));
+ instr.opcode = opcode;
+
+ sm4_dst_from_node(&instr.dsts[0], dst);
+ instr.dst_count = 1;
+
+ sm4_src_from_node(&instr.srcs[0], src1, instr.dsts[0].writemask);
+ sm4_src_from_node(&instr.srcs[1], src2, instr.dsts[0].writemask);
+ sm4_src_from_node(&instr.srcs[2], src3, instr.dsts[0].writemask);
+ instr.src_count = 3;
+
+ write_sm4_instruction(tpf, &instr);
+}
+
static void write_sm4_ld(const struct tpf_writer *tpf, const struct hlsl_ir_node *dst,
const struct hlsl_deref *resource, const struct hlsl_ir_node *coords,
const struct hlsl_ir_node *sample_index, const struct hlsl_ir_node *texel_offset,
@@ -4702,6 +4722,7 @@ static void write_sm4_expr(const struct tpf_writer *tpf, const struct hlsl_ir_ex
{
const struct hlsl_ir_node *arg1 = expr->operands[0].node;
const struct hlsl_ir_node *arg2 = expr->operands[1].node;
+ const struct hlsl_ir_node *arg3 = expr->operands[2].node;
const struct hlsl_type *dst_type = expr->node.data_type;
struct vkd3d_string_buffer *dst_type_string;
@@ -5127,6 +5148,10 @@ static void write_sm4_expr(const struct tpf_writer *tpf, const struct hlsl_ir_ex
&expr->node, arg1, arg2);
break;
+ case HLSL_OP3_MOVC:
+ write_sm4_ternary_op(tpf, VKD3D_SM4_OP_MOVC, &expr->node, arg1, arg2, arg3);
+ break;
+
default:
hlsl_fixme(tpf->ctx, &expr->node.loc, "SM4 %s expression.", debug_hlsl_expr_op(expr->op));
}
diff --git a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
index a70894a160d..9d8fa82fb86 100644
--- a/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
+++ b/libs/vkd3d/libs/vkd3d-shader/vkd3d_shader_main.c
@@ -705,7 +705,8 @@ static void vkd3d_shader_scan_add_uav_flag(const struct vkd3d_shader_scan_contex
for (i = 0; i < context->scan_descriptor_info->descriptor_count; ++i)
{
- if (context->scan_descriptor_info->descriptors[i].register_id == range_id)
+ if (context->scan_descriptor_info->descriptors[i].type == VKD3D_SHADER_DESCRIPTOR_TYPE_UAV
+ && context->scan_descriptor_info->descriptors[i].register_id == range_id)
{
context->scan_descriptor_info->descriptors[i].flags |= flag;
break;
--
2.40.1

View File

@ -1 +1 @@
cf5e073d14925d3cdd489a869e3c2c5317b1ff38
6558611fa2d24447297cb62d168b924c33839c43