From 8f3c447a614ad504f79f97657210ddaf2e5f9ac4 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Tue, 9 May 2023 16:08:25 +0200 Subject: [PATCH] [hlsl-out] work around https://github.com/microsoft/DirectXShaderCompiler/issues/5082#issuecomment-1540147807 --- src/back/hlsl/writer.rs | 2 ++ tests/out/hlsl/image.hlsl | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/back/hlsl/writer.rs b/src/back/hlsl/writer.rs index 0547e1ab17..1e8deb4ea8 100644 --- a/src/back/hlsl/writer.rs +++ b/src/back/hlsl/writer.rs @@ -2366,7 +2366,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if let Some(offset) = offset { write!(self.out, ", ")?; + write!(self.out, "int2(")?; // work around https://github.com/microsoft/DirectXShaderCompiler/issues/5082#issuecomment-1540147807 self.write_const_expression(module, offset)?; + write!(self.out, ")")?; } write!(self.out, ")")?; diff --git a/tests/out/hlsl/image.hlsl b/tests/out/hlsl/image.hlsl index d70a3866af..11bd879f55 100644 --- a/tests/out/hlsl/image.hlsl +++ b/tests/out/hlsl/image.hlsl @@ -242,10 +242,10 @@ float4 texture_sample() : SV_Target0 float2 tc = (0.5).xx; float4 s1d = image_1d.Sample(sampler_reg, 0.5); float4 s2d = image_2d.Sample(sampler_reg, tc); - float4 s2d_offset = image_2d.Sample(sampler_reg, tc, int2(3, 1)); + float4 s2d_offset = image_2d.Sample(sampler_reg, tc, int2(int2(3, 1))); float4 s2d_level = image_2d.SampleLevel(sampler_reg, tc, 2.3); - float4 s2d_level_offset = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(3, 1)); - float4 s2d_bias_offset = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(3, 1)); + float4 s2d_level_offset = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(int2(3, 1))); + float4 s2d_bias_offset = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(int2(3, 1))); return ((((s1d + s2d) + s2d_offset) + s2d_level) + s2d_level_offset); } @@ -262,9 +262,9 @@ float4 gather() : SV_Target0 { float2 tc_2 = (0.5).xx; float4 s2d_1 = image_2d.GatherGreen(sampler_reg, tc_2); - float4 s2d_offset_1 = image_2d.GatherAlpha(sampler_reg, tc_2, int2(3, 1)); + float4 s2d_offset_1 = image_2d.GatherAlpha(sampler_reg, tc_2, int2(int2(3, 1))); float4 s2d_depth_1 = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5); - float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5, (3).xx); + float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5, int2((3).xx)); uint4 u = image_2d_u32_.Gather(sampler_reg, tc_2); int4 i = image_2d_i32_.Gather(sampler_reg, tc_2); float4 f = (float4(u) + float4(i));