From 19c493722e0d7183cb2340e8d53d6bf312c0cb1a Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Fri, 18 Oct 2024 15:21:27 +0200 Subject: [PATCH] vkd3d-shader/glsl: Implement VKD3DSIH_SAMPLE_B. --- libs/vkd3d-shader/glsl.c | 9 ++++++++- tests/hlsl/sample-bias.shader_test | 12 ++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libs/vkd3d-shader/glsl.c b/libs/vkd3d-shader/glsl.c index fbfe6def..ab1428a9 100644 --- a/libs/vkd3d-shader/glsl.c +++ b/libs/vkd3d-shader/glsl.c @@ -900,7 +900,13 @@ static void shader_glsl_sample(struct vkd3d_glsl_generator *gen, const struct vk vkd3d_string_buffer_printf(sample, "texture("); shader_glsl_print_combined_sampler_name(sample, gen, resource_idx, resource_space, sampler_idx, sampler_space); - vkd3d_string_buffer_printf(sample, ", %s)", coord.str->buffer); + vkd3d_string_buffer_printf(sample, ", %s", coord.str->buffer); + if (ins->opcode == VKD3DSIH_SAMPLE_B) + { + vkd3d_string_buffer_printf(sample, ", "); + shader_glsl_print_src(sample, gen, &ins->src[3], VKD3DSP_WRITEMASK_0, ins->src[3].reg.data_type); + } + vkd3d_string_buffer_printf(sample, ")"); shader_glsl_print_swizzle(sample, ins->src[1].swizzle, ins->dst[0].write_mask); shader_glsl_print_assignment_ext(gen, &dst, data_type, "%s", sample->buffer); @@ -1493,6 +1499,7 @@ static void vkd3d_glsl_handle_instruction(struct vkd3d_glsl_generator *gen, shader_glsl_intrinsic(gen, ins, "inversesqrt"); break; case VKD3DSIH_SAMPLE: + case VKD3DSIH_SAMPLE_B: shader_glsl_sample(gen, ins); break; case VKD3DSIH_SQRT: diff --git a/tests/hlsl/sample-bias.shader_test b/tests/hlsl/sample-bias.shader_test index 17926380..1a6a6710 100644 --- a/tests/hlsl/sample-bias.shader_test +++ b/tests/hlsl/sample-bias.shader_test @@ -32,15 +32,15 @@ float4 main(float2 coord : texcoord) : sv_target [test] uniform 0 float4 6.5 0.0 0.0 0.0 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (10.0, 0.0, 10.0, 0.0) uniform 0 float4 7.5 0.0 0.0 0.0 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (4.0, 0.0, 10.0, 0.0) uniform 0 float4 8.5 0.0 0.0 0.0 -todo(sm<4 | glsl) draw quad +todo(sm<4) draw quad probe (0, 0) rgba (0.0, 0.0, 10.0, 0.0) [require] @@ -60,13 +60,13 @@ float4 main(float2 coord : texcoord) : sv_target [test] uniform 0 float4 6.5 0.0 0.0 0.0 -todo(glsl) draw quad +draw quad probe (0, 0) rgba (10.0, 0.0, 10.0, 0.0) uniform 0 float4 7.5 0.0 0.0 0.0 -todo(glsl) draw quad +draw quad todo(sm<4) probe (0,0) rgba (4.0, 0.0, 10.0, 0.0) uniform 0 float4 8.5 0.0 0.0 0.0 -todo(glsl) draw quad +draw quad todo(sm<4) probe (0,0) rgba (0.0, 0.0, 10.0, 0.0)