Updated vkd3d-latest patchset

This commit is contained in:
Alistair Leslie-Hughes
2025-02-18 08:44:04 +11:00
parent 4901d72e77
commit 2b9cd3663b
6 changed files with 450 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
From d30eac3fdc363ff812a1e4d188885a8d8b84ae06 Mon Sep 17 00:00:00 2001
From 2a2567f35d07ebd3c2c56787137578bc735aa8f9 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 29 Nov 2024 07:14:57 +1100
Subject: [PATCH] Updated vkd3d to 5b2d62e59a6365e32aac3fa37fe16ab3582deae4.

View File

@@ -1,4 +1,4 @@
From 59fb4f466f878128e98328ecf8506ad452bb0df6 Mon Sep 17 00:00:00 2001
From de8bae91ae7f7bd8ed11446a6039632b7f885016 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Thu, 23 Jan 2025 07:16:22 +1100
Subject: [PATCH] Updated vkd3d to 5bfcd811824e9ca03c09a54204bff645225c3408.

View File

@@ -1,4 +1,4 @@
From bf784f53870b65406c152779529569f9f2ec08ed Mon Sep 17 00:00:00 2001
From edd0f7568f18fc201d268fabe178d9e509e40a28 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 28 Jan 2025 08:24:16 +1100
Subject: [PATCH] Updated vkd3d to 40c225095f64dacfe8b88780a5d43ecdeafe4d2a.

View File

@@ -1,4 +1,4 @@
From 8de3a6475f21e12fc05532ddc836e14c9abc4f4f Mon Sep 17 00:00:00 2001
From 0b997e16483a911049de4382f993a9c267c568b5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 4 Feb 2025 06:59:46 +1100
Subject: [PATCH] Updated vkd3d to 2f77d56b7748f89ae85fd08bba956fbb60387bd2.

View File

@@ -0,0 +1,414 @@
From c80cc1042c1765e95e674d1d7544dd80042c1c43 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Thu, 6 Feb 2025 13:52:27 +1100
Subject: [PATCH] Updated vkd3d to fe52e696629c27abd7e4097e1e44a81b377f4f4f.
---
libs/vkd3d/libs/vkd3d-shader/hlsl.y | 67 ++++++++++++-------
libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c | 55 ++++++++-------
.../libs/vkd3d-shader/hlsl_constant_ops.c | 42 +++++++-----
3 files changed, 98 insertions(+), 66 deletions(-)
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl.y b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
index 4813940e89c..7afc9274c2e 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl.y
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl.y
@@ -6889,6 +6889,46 @@ static void check_duplicated_switch_cases(struct hlsl_ctx *ctx, const struct hls
}
}
+static bool add_switch(struct hlsl_ctx *ctx, struct hlsl_block *block,
+ struct parse_attribute_list *attributes, struct list *cases, const struct vkd3d_shader_location *loc)
+{
+ struct hlsl_ir_node *selector = node_from_block(block);
+ struct hlsl_ir_node *s;
+
+ if (selector->data_type->class == HLSL_CLASS_ERROR)
+ {
+ destroy_switch_cases(cases);
+ destroy_block(block);
+ cleanup_parse_attribute_list(attributes);
+ return true;
+ }
+
+ if (!(selector = add_implicit_conversion(ctx, block, selector,
+ hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), &selector->loc)))
+ {
+ destroy_switch_cases(cases);
+ destroy_block(block);
+ cleanup_parse_attribute_list(attributes);
+ return false;
+ }
+
+ s = hlsl_new_switch(ctx, selector, cases, loc);
+
+ destroy_switch_cases(cases);
+
+ if (!s)
+ {
+ destroy_block(block);
+ cleanup_parse_attribute_list(attributes);
+ return false;
+ }
+
+ hlsl_block_add_instr(block, s);
+
+ cleanup_parse_attribute_list(attributes);
+ return true;
+}
+
static void validate_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim,
struct hlsl_type *format, const struct vkd3d_shader_location* loc)
{
@@ -9237,33 +9277,10 @@ loop_statement:
switch_statement:
attribute_list_optional switch_scope_start KW_SWITCH '(' expr ')' '{' switch_cases '}'
{
- struct hlsl_ir_node *selector = node_from_block($5);
- struct hlsl_ir_node *s;
-
- if (!(selector = add_implicit_conversion(ctx, $5, selector, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), &@5)))
- {
- destroy_switch_cases($8);
- destroy_block($5);
- cleanup_parse_attribute_list(&$1);
- YYABORT;
- }
-
- s = hlsl_new_switch(ctx, selector, $8, &@3);
-
- destroy_switch_cases($8);
-
- if (!s)
- {
- destroy_block($5);
- cleanup_parse_attribute_list(&$1);
- YYABORT;
- }
-
$$ = $5;
- hlsl_block_add_instr($$, s);
-
+ if (!add_switch(ctx, $$, &$1, $8, &@3))
+ YYABORT;
hlsl_pop_scope(ctx);
- cleanup_parse_attribute_list(&$1);
}
switch_case:
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
index a7798bf8e9f..2afd3e1e1e5 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_codegen.c
@@ -386,7 +386,7 @@ static uint32_t combine_field_storage_modifiers(uint32_t modifiers, uint32_t fie
}
static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func,
- struct hlsl_ir_var *top_var, uint32_t patch_index, struct hlsl_ir_load *lhs,
+ struct hlsl_block *block, struct hlsl_ir_var *top_var, uint32_t patch_index, struct hlsl_ir_load *lhs,
uint32_t modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index, bool force_align)
{
struct hlsl_type *type = lhs->node.data_type, *vector_type_src, *vector_type_dst;
@@ -438,11 +438,11 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_dec
if (!(idx = hlsl_new_uint_constant(ctx, patch_index, &var->loc)))
return;
- list_add_after(&lhs->node.entry, &idx->entry);
+ hlsl_block_add_instr(block, idx);
if (!(load = hlsl_new_load_index(ctx, &patch_deref, idx, loc)))
return;
- list_add_after(&idx->entry, &load->node.entry);
+ hlsl_block_add_instr(block, &load->node);
}
else
{
@@ -452,22 +452,22 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_dec
if (!(load = hlsl_new_var_load(ctx, input, &var->loc)))
return;
- list_add_after(&lhs->node.entry, &load->node.entry);
+ hlsl_block_add_instr(block, &load->node);
}
if (!(cast = hlsl_new_cast(ctx, &load->node, vector_type_dst, &var->loc)))
return;
- list_add_after(&load->node.entry, &cast->entry);
+ hlsl_block_add_instr(block, cast);
if (type->class == HLSL_CLASS_MATRIX)
{
if (!(c = hlsl_new_uint_constant(ctx, i, &var->loc)))
return;
- list_add_after(&cast->entry, &c->entry);
+ hlsl_block_add_instr(block, c);
if (!(store = hlsl_new_store_index(ctx, &lhs->src, c, cast, 0, &var->loc)))
return;
- list_add_after(&c->entry, &store->entry);
+ hlsl_block_add_instr(block, store);
}
else
{
@@ -475,14 +475,14 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_dec
if (!(store = hlsl_new_store_index(ctx, &lhs->src, NULL, cast, 0, &var->loc)))
return;
- list_add_after(&cast->entry, &store->entry);
+ hlsl_block_add_instr(block, store);
}
}
}
static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func,
- struct hlsl_ir_var *top_var, uint32_t patch_index, struct hlsl_ir_load *lhs, uint32_t modifiers,
- struct hlsl_semantic *semantic, uint32_t semantic_index, bool force_align)
+ struct hlsl_block *block, struct hlsl_ir_var *top_var, uint32_t patch_index, struct hlsl_ir_load *lhs,
+ uint32_t modifiers, struct hlsl_semantic *semantic, uint32_t semantic_index, bool force_align)
{
struct vkd3d_shader_location *loc = &lhs->node.loc;
struct hlsl_type *type = lhs->node.data_type;
@@ -528,20 +528,20 @@ static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_ir_func
if (!(c = hlsl_new_uint_constant(ctx, i, &var->loc)))
return;
- list_add_after(&lhs->node.entry, &c->entry);
+ hlsl_block_add_instr(block, c);
/* This redundant load is expected to be deleted later by DCE. */
if (!(element_load = hlsl_new_load_index(ctx, &lhs->src, c, loc)))
return;
- list_add_after(&c->entry, &element_load->node.entry);
+ hlsl_block_add_instr(block, &element_load->node);
- prepend_input_copy_recurse(ctx, func, top_var, patch_index, element_load, element_modifiers,
- semantic, elem_semantic_index, force_align);
+ prepend_input_copy_recurse(ctx, func, block, top_var, patch_index, element_load,
+ element_modifiers, semantic, elem_semantic_index, force_align);
}
}
else
{
- prepend_input_copy(ctx, func, var, patch_index, lhs, modifiers, semantic, semantic_index, force_align);
+ prepend_input_copy(ctx, func, block, var, patch_index, lhs, modifiers, semantic, semantic_index, force_align);
}
}
@@ -550,14 +550,19 @@ static void prepend_input_copy_recurse(struct hlsl_ctx *ctx, struct hlsl_ir_func
static void prepend_input_var_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func, struct hlsl_ir_var *var)
{
struct hlsl_ir_load *load;
+ struct hlsl_block block;
+
+ hlsl_block_init(&block);
/* This redundant load is expected to be deleted later by DCE. */
if (!(load = hlsl_new_var_load(ctx, var, &var->loc)))
return;
- list_add_head(&func->body.instrs, &load->node.entry);
+ hlsl_block_add_instr(&block, &load->node);
- prepend_input_copy_recurse(ctx, func, var, 0, load, var->storage_modifiers, &var->semantic,
- var->semantic.index, false);
+ prepend_input_copy_recurse(ctx, func, &block, var, 0, load,
+ var->storage_modifiers, &var->semantic, var->semantic.index, false);
+
+ list_move_head(&func->body.instrs, &block.instrs);
}
static void append_output_copy(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *func,
@@ -1087,8 +1092,8 @@ static bool lower_calls(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *
return true;
}
-static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct hlsl_ir_node *index,
- const struct vkd3d_shader_location *loc)
+static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct hlsl_block *block,
+ struct hlsl_ir_node *index, const struct vkd3d_shader_location *loc)
{
unsigned int dim_count = index->data_type->e.numeric.dimx;
struct hlsl_ir_node *store, *zero;
@@ -1105,19 +1110,19 @@ static struct hlsl_ir_node *add_zero_mipmap_level(struct hlsl_ctx *ctx, struct h
hlsl_init_simple_deref_from_var(&coords_deref, coords);
if (!(store = hlsl_new_store_index(ctx, &coords_deref, NULL, index, (1u << dim_count) - 1, loc)))
return NULL;
- list_add_after(&index->entry, &store->entry);
+ hlsl_block_add_instr(block, store);
if (!(zero = hlsl_new_uint_constant(ctx, 0, loc)))
return NULL;
- list_add_after(&store->entry, &zero->entry);
+ hlsl_block_add_instr(block, zero);
if (!(store = hlsl_new_store_index(ctx, &coords_deref, NULL, zero, 1u << dim_count, loc)))
return NULL;
- list_add_after(&zero->entry, &store->entry);
+ hlsl_block_add_instr(block, store);
if (!(coords_load = hlsl_new_var_load(ctx, coords, loc)))
return NULL;
- list_add_after(&store->entry, &coords_load->node.entry);
+ hlsl_block_add_instr(block, &coords_load->node);
return &coords_load->node;
}
@@ -1283,7 +1288,7 @@ static bool lower_index_loads(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
VKD3D_ASSERT(coords->data_type->e.numeric.type == HLSL_TYPE_UINT);
VKD3D_ASSERT(coords->data_type->e.numeric.dimx == dim_count);
- if (!(coords = add_zero_mipmap_level(ctx, coords, &instr->loc)))
+ if (!(coords = add_zero_mipmap_level(ctx, block, coords, &instr->loc)))
return false;
params.type = HLSL_RESOURCE_LOAD;
diff --git a/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c
index 8d112fb57a7..538f0f46854 100644
--- a/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c
+++ b/libs/vkd3d/libs/vkd3d-shader/hlsl_constant_ops.c
@@ -1588,7 +1588,7 @@ static bool is_op_left_distributive(enum hlsl_ir_expr_op opl, enum hlsl_ir_expr_
}
/* Attempt to collect together the expression (x OPL a) OPR (x OPL b) -> x OPL (a OPR b). */
-static struct hlsl_ir_node *collect_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr,
+static struct hlsl_ir_node *collect_exprs(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *instr,
enum hlsl_ir_expr_op opr, struct hlsl_ir_node *node1, struct hlsl_ir_node *node2)
{
enum hlsl_base_type type = instr->data_type->e.numeric.type;
@@ -1612,14 +1612,14 @@ static struct hlsl_ir_node *collect_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_n
if (!(ab = hlsl_new_binary_expr(ctx, opr, e1->operands[1].node, e2->operands[1].node)))
return NULL;
- list_add_before(&instr->entry, &ab->entry);
+ hlsl_block_add_instr(block, ab);
operands[0] = e1->operands[0].node;
operands[1] = ab;
if (!(res = hlsl_new_expr(ctx, opl, operands, instr->data_type, &instr->loc)))
return NULL;
- list_add_before(&instr->entry, &res->entry);
+ hlsl_block_add_instr(block, res);
return res;
}
@@ -1629,6 +1629,7 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
struct hlsl_ir_expr *expr;
enum hlsl_base_type type;
enum hlsl_ir_expr_op op;
+ struct hlsl_block block;
bool progress = false;
if (instr->type != HLSL_IR_EXPR)
@@ -1638,6 +1639,8 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
if (instr->data_type->class > HLSL_CLASS_VECTOR)
return false;
+ hlsl_block_init(&block);
+
arg1 = expr->operands[0].node;
arg2 = expr->operands[1].node;
type = instr->data_type->e.numeric.type;
@@ -1646,9 +1649,10 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
if (!arg1 || !arg2)
return false;
- if ((tmp = collect_exprs(ctx, instr, op, arg1, arg2)))
+ if ((tmp = collect_exprs(ctx, &block, instr, op, arg1, arg2)))
{
/* (x OPL a) OPR (x OPL b) -> x OPL (a OPR b) */
+ list_move_before(&instr->entry, &block.instrs);
hlsl_replace_node(instr, tmp);
return true;
}
@@ -1676,8 +1680,8 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
struct hlsl_ir_node *ab;
if (!(ab = hlsl_new_binary_expr(ctx, op, e1->operands[1].node, arg2)))
- return false;
- list_add_before(&instr->entry, &ab->entry);
+ goto fail;
+ hlsl_block_add_instr(&block, ab);
arg1 = e1->operands[0].node;
arg2 = ab;
@@ -1689,8 +1693,8 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
struct hlsl_ir_node *xy;
if (!(xy = hlsl_new_binary_expr(ctx, op, e1->operands[0].node, arg2)))
- return false;
- list_add_before(&instr->entry, &xy->entry);
+ goto fail;
+ hlsl_block_add_instr(&block, xy);
arg1 = xy;
arg2 = e1->operands[1].node;
@@ -1705,15 +1709,15 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
struct hlsl_ir_node *xy;
if (!(xy = hlsl_new_binary_expr(ctx, op, arg1, e2->operands[0].node)))
- return false;
- list_add_before(&instr->entry, &xy->entry);
+ goto fail;
+ hlsl_block_add_instr(&block, xy);
arg1 = xy;
arg2 = e2->operands[1].node;
progress = true;
}
- if (!progress && e1 && (tmp = collect_exprs(ctx, instr, op, e1->operands[1].node, arg2)))
+ if (!progress && e1 && (tmp = collect_exprs(ctx, &block, instr, op, e1->operands[1].node, arg2)))
{
/* (y OPR (x OPL a)) OPR (x OPL b) -> y OPR (x OPL (a OPR b)) */
arg1 = e1->operands[0].node;
@@ -1722,7 +1726,7 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
}
if (!progress && is_op_commutative(op) && e1
- && (tmp = collect_exprs(ctx, instr, op, e1->operands[0].node, arg2)))
+ && (tmp = collect_exprs(ctx, &block, instr, op, e1->operands[0].node, arg2)))
{
/* ((x OPL a) OPR y) OPR (x OPL b) -> (x OPL (a OPR b)) OPR y */
arg1 = tmp;
@@ -1730,7 +1734,7 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
progress = true;
}
- if (!progress && e2 && (tmp = collect_exprs(ctx, instr, op, arg1, e2->operands[0].node)))
+ if (!progress && e2 && (tmp = collect_exprs(ctx, &block, instr, op, arg1, e2->operands[0].node)))
{
/* (x OPL a) OPR ((x OPL b) OPR y) -> (x OPL (a OPR b)) OPR y */
arg1 = tmp;
@@ -1739,7 +1743,7 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
}
if (!progress && is_op_commutative(op) && e2
- && (tmp = collect_exprs(ctx, instr, op, arg1, e2->operands[1].node)))
+ && (tmp = collect_exprs(ctx, &block, instr, op, arg1, e2->operands[1].node)))
{
/* (x OPL a) OPR (y OPR (x OPL b)) -> (x OPL (a OPR b)) OPR y */
arg1 = tmp;
@@ -1754,12 +1758,18 @@ bool hlsl_normalize_binary_exprs(struct hlsl_ctx *ctx, struct hlsl_ir_node *inst
struct hlsl_ir_node *res;
if (!(res = hlsl_new_expr(ctx, op, operands, instr->data_type, &instr->loc)))
- return false;
- list_add_before(&instr->entry, &res->entry);
+ goto fail;
+ hlsl_block_add_instr(&block, res);
+
+ list_move_before(&instr->entry, &block.instrs);
hlsl_replace_node(instr, res);
}
return progress;
+
+fail:
+ hlsl_block_cleanup(&block);
+ return false;
}
bool hlsl_fold_constant_swizzles(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context)
--
2.47.2

View File

@@ -0,0 +1,32 @@
From e3e8d077accc84b6dbb73658afc12c8eb73c72e5 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 18 Feb 2025 08:11:04 +1100
Subject: [PATCH] Updated vkd3d to c3555a34dcf291e0811b0acce8884651d4e728a4.
---
libs/vkd3d/libs/vkd3d/state.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libs/vkd3d/libs/vkd3d/state.c b/libs/vkd3d/libs/vkd3d/state.c
index bd3c3758ecb..c8a67479a22 100644
--- a/libs/vkd3d/libs/vkd3d/state.c
+++ b/libs/vkd3d/libs/vkd3d/state.c
@@ -3595,7 +3595,6 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
mask |= 1u << e->InputSlot;
}
graphics->attribute_count = j;
- vkd3d_shader_free_shader_signature(&input_signature);
switch (desc->strip_cut_value)
{
@@ -3661,6 +3660,7 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
if (FAILED(hr = vkd3d_private_store_init(&state->private_store)))
goto fail;
+ vkd3d_shader_free_shader_signature(&input_signature);
state->vk_bind_point = VK_PIPELINE_BIND_POINT_GRAPHICS;
state->implicit_root_signature = NULL;
d3d12_device_add_ref(state->device = device);
--
2.47.2