Module: vkd3d Branch: master Commit: bfdd5c142d2e59b4785111ef8134c2ca36fb8a4e URL: https://gitlab.winehq.org/wine/vkd3d/-/commit/bfdd5c142d2e59b4785111ef8134c2...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Wed Jun 7 20:34:59 2023 +0200
vkd3d-shader/tpf: Add support for writing 'resinfo' instruction.
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com
---
libs/vkd3d-shader/tpf.c | 26 +++++++++++++++++++++++++- tests/hlsl/getdimensions.shader_test | 12 ++++++------ 2 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/tpf.c b/libs/vkd3d-shader/tpf.c index 888d920f..f3ca223c 100644 --- a/libs/vkd3d-shader/tpf.c +++ b/libs/vkd3d-shader/tpf.c @@ -4322,6 +4322,30 @@ static void write_sm4_sampleinfo(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buf write_sm4_instruction(buffer, &instr); }
+static void write_sm4_resinfo(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, + const struct hlsl_ir_resource_load *load) +{ + const struct hlsl_deref *resource = &load->resource; + const struct hlsl_ir_node *dst = &load->node; + struct sm4_instruction instr; + + assert(dst->data_type->base_type == HLSL_TYPE_UINT || dst->data_type->base_type == HLSL_TYPE_FLOAT); + + memset(&instr, 0, sizeof(instr)); + instr.opcode = VKD3D_SM4_OP_RESINFO; + if (dst->data_type->base_type == HLSL_TYPE_UINT) + instr.opcode |= VKD3DSI_RESINFO_UINT << VKD3D_SM4_INSTRUCTION_FLAGS_SHIFT; + + sm4_dst_from_node(&instr.dsts[0], dst); + instr.dst_count = 1; + + sm4_src_from_node(&instr.srcs[0], load->lod.node, VKD3DSP_WRITEMASK_ALL); + sm4_src_from_deref(ctx, &instr.srcs[1], resource, instr.dsts[0].writemask); + instr.src_count = 2; + + write_sm4_instruction(buffer, &instr); +} + static bool type_is_float(const struct hlsl_type *type) { return type->base_type == HLSL_TYPE_FLOAT || type->base_type == HLSL_TYPE_HALF; @@ -5146,7 +5170,7 @@ static void write_sm4_resource_load(struct hlsl_ctx *ctx, break;
case HLSL_RESOURCE_RESINFO: - hlsl_fixme(ctx, &load->node.loc, "Unsupported load type %u.\n", load->load_type); + write_sm4_resinfo(ctx, buffer, load); break; } } diff --git a/tests/hlsl/getdimensions.shader_test b/tests/hlsl/getdimensions.shader_test index f8cf8b71..4d781b32 100644 --- a/tests/hlsl/getdimensions.shader_test +++ b/tests/hlsl/getdimensions.shader_test @@ -7,7 +7,7 @@ size (2, 3) 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0
-[pixel shader todo] +[pixel shader] Texture2D t : register(t0);
float4 main() : sv_target @@ -28,8 +28,8 @@ float4 main() : sv_target }
[test] -todo draw quad -todo probe all rgba (2.0, 3.0, 2.0, 3.0) +draw quad +probe all rgba (2.0, 3.0, 2.0, 3.0)
[texture 1] size (2, 2) @@ -40,7 +40,7 @@ levels 2
0.0 0.0 1.0 0.0
-[pixel shader todo] +[pixel shader] Texture2D t : register(t1);
float4 main() : sv_target @@ -53,5 +53,5 @@ float4 main() : sv_target }
[test] -todo draw quad -todo probe all rgba (2.0, 2.0, 1.0, 2.0) +draw quad +probe all rgba (2.0, 2.0, 1.0, 2.0)