Zebediah Figura : vkd3d-shader/hlsl: Propagate copies for resource load instructions.
Alexandre Julliard
julliard at winehq.org
Mon Jan 24 16:14:12 CST 2022
Module: vkd3d
Branch: master
Commit: 8cb3ec4640ece8c1a093bf333c88ed105dc8a211
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=8cb3ec4640ece8c1a093bf333c88ed105dc8a211
Author: Zebediah Figura <zfigura at codeweavers.com>
Date: Fri Jan 21 22:22:29 2022 +0100
vkd3d-shader/hlsl: Propagate copies for resource load instructions.
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
Makefile.am | 3 ---
libs/vkd3d-shader/hlsl_codegen.c | 39 ++++++++++++++++++++++++++++++++++++---
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index a3ec685..1c14f95 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -306,9 +306,6 @@ XFAIL_TESTS = \
tests/hlsl-vector-indexing.shader_test \
tests/hlsl-vector-indexing-uniform.shader_test \
tests/max.shader_test \
- tests/sampler.shader_test \
- tests/texture-load.shader_test \
- tests/texture-load-typed.shader_test \
tests/trigonometry.shader_test
endif
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index e19b204..98afd0e 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -399,8 +399,8 @@ static struct hlsl_ir_node *copy_propagation_compute_replacement(const struct co
return node;
}
-static bool copy_propagation_analyze_load(struct hlsl_ctx *ctx, struct hlsl_ir_load *load,
- struct copy_propagation_state *state)
+static bool copy_propagation_transform_load(struct hlsl_ctx *ctx,
+ struct hlsl_ir_load *load, struct copy_propagation_state *state)
{
struct hlsl_ir_node *node = &load->node, *new_node;
struct hlsl_type *type = node->data_type;
@@ -441,6 +441,35 @@ static bool copy_propagation_analyze_load(struct hlsl_ctx *ctx, struct hlsl_ir_l
return true;
}
+static bool copy_propagation_transform_object_load(struct hlsl_ctx *ctx,
+ struct hlsl_deref *deref, struct copy_propagation_state *state)
+{
+ struct hlsl_ir_load *load;
+ struct hlsl_ir_node *node;
+ unsigned int swizzle;
+
+ if (!(node = copy_propagation_compute_replacement(state, deref, 1, &swizzle)))
+ return false;
+
+ /* Only HLSL_IR_LOAD can produce an object. */
+ load = hlsl_ir_load(node);
+ deref->var = load->src.var;
+ hlsl_src_remove(&deref->offset);
+ hlsl_src_from_node(&deref->offset, load->src.offset.node);
+ return true;
+}
+
+static bool copy_propagation_transform_resource_load(struct hlsl_ctx *ctx,
+ struct hlsl_ir_resource_load *load, struct copy_propagation_state *state)
+{
+ bool progress = false;
+
+ progress |= copy_propagation_transform_object_load(ctx, &load->resource, state);
+ if (load->sampler.var)
+ progress |= copy_propagation_transform_object_load(ctx, &load->sampler, state);
+ return progress;
+}
+
static void copy_propagation_record_store(struct hlsl_ctx *ctx, struct hlsl_ir_store *store,
struct copy_propagation_state *state)
{
@@ -477,7 +506,11 @@ static bool copy_propagation_transform_block(struct hlsl_ctx *ctx, struct hlsl_b
switch (instr->type)
{
case HLSL_IR_LOAD:
- progress |= copy_propagation_analyze_load(ctx, hlsl_ir_load(instr), state);
+ progress |= copy_propagation_transform_load(ctx, hlsl_ir_load(instr), state);
+ break;
+
+ case HLSL_IR_RESOURCE_LOAD:
+ progress |= copy_propagation_transform_resource_load(ctx, hlsl_ir_resource_load(instr), state);
break;
case HLSL_IR_STORE:
More information about the wine-cvs
mailing list