[PATCH vkd3d 2/9] vkd3d-shader: Support texel offset for sample_c instruction.

Conor McCarthy cmccarthy at codeweavers.com
Tue Sep 28 00:38:11 CDT 2021


From: Philip Rebohle <philip.rebohle at tu-dortmund.de>
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
---
 libs/vkd3d-shader/spirv.c | 13 +++++++++----
 tests/d3d12.c             |  1 -
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/libs/vkd3d-shader/spirv.c b/libs/vkd3d-shader/spirv.c
index f604b8ef..5a8fd9e1 100644
--- a/libs/vkd3d-shader/spirv.c
+++ b/libs/vkd3d-shader/spirv.c
@@ -8196,12 +8196,9 @@ static void vkd3d_dxbc_compiler_emit_sample_c(struct vkd3d_dxbc_compiler *compil
     SpvImageOperandsMask operands_mask = 0;
     unsigned int image_operand_count = 0;
     struct vkd3d_shader_image image;
-    uint32_t image_operands[1];
+    uint32_t image_operands[2];
     SpvOp op;
 
-    if (vkd3d_shader_instruction_has_texel_offset(instruction))
-        FIXME("Texel offset not supported.\n");
-
     if (instruction->handler_idx == VKD3DSIH_SAMPLE_C_LZ)
     {
         op = SpvOpImageSampleDrefExplicitLod;
@@ -8216,6 +8213,14 @@ static void vkd3d_dxbc_compiler_emit_sample_c(struct vkd3d_dxbc_compiler *compil
 
     vkd3d_dxbc_compiler_prepare_image(compiler,
             &image, &src[1].reg, &src[2].reg, VKD3D_IMAGE_FLAG_SAMPLED | VKD3D_IMAGE_FLAG_DEPTH);
+
+    if (vkd3d_shader_instruction_has_texel_offset(instruction))
+    {
+        operands_mask |= SpvImageOperandsConstOffsetMask;
+        image_operands[image_operand_count++] = vkd3d_dxbc_compiler_emit_texel_offset(compiler,
+                instruction, image.resource_type_info);
+    }
+
     sampled_type_id = vkd3d_spirv_get_type_id(builder, image.sampled_type, 1);
     coordinate_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[0], VKD3DSP_WRITEMASK_ALL);
     dref_id = vkd3d_dxbc_compiler_emit_load_src(compiler, &src[3], VKD3DSP_WRITEMASK_0);
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 09cc0e98..6c435ac0 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -14695,7 +14695,6 @@ static void test_sample_c_lz(void)
             transition_resource_state(command_list, context.render_target,
                     D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_COPY_SOURCE);
 
-            todo_if(j && tests[i].d_ref > 0.0f)
             check_sub_resource_float(context.render_target, 0, queue, command_list, tests[i].expected, 2);
 
             reset_command_list(command_list, context.allocator);
-- 
2.32.0




More information about the wine-devel mailing list