From cac37e68905f8cbd98a24984df2320ecf42baae3 Mon Sep 17 00:00:00 2001 From: Greg Roth Date: Thu, 1 Apr 2021 16:40:34 -0600 Subject: [PATCH] No sinking coord calc for sample in libs (#3658) Amidst catching the CS/AS/MS cases where convergent markers weren't getting generated, it was pointed out that libs may need these too. --- lib/HLSL/DxilConvergent.cpp | 2 +- .../hlsl/objects/Texture/convergent_cs.hlsl | 33 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/lib/HLSL/DxilConvergent.cpp b/lib/HLSL/DxilConvergent.cpp index 9f70ab2b9..be3ec0646 100644 --- a/lib/HLSL/DxilConvergent.cpp +++ b/lib/HLSL/DxilConvergent.cpp @@ -48,7 +48,7 @@ public: bool runOnModule(Module &M) override { if (M.HasHLModule()) { const ShaderModel *SM = M.GetHLModule().GetShaderModel(); - if (!SM->IsPS() && (!SM->IsSM66Plus() || (!SM->IsCS() && !SM->IsMS() && !SM->IsAS()))) + if (!SM->IsPS() && !SM->IsLib() && (!SM->IsSM66Plus() || (!SM->IsCS() && !SM->IsMS() && !SM->IsAS()))) return false; } bool bUpdated = false; diff --git a/tools/clang/test/HLSLFileCheck/hlsl/objects/Texture/convergent_cs.hlsl b/tools/clang/test/HLSLFileCheck/hlsl/objects/Texture/convergent_cs.hlsl index e8df47342..8b260845b 100644 --- a/tools/clang/test/HLSLFileCheck/hlsl/objects/Texture/convergent_cs.hlsl +++ b/tools/clang/test/HLSLFileCheck/hlsl/objects/Texture/convergent_cs.hlsl @@ -1,13 +1,15 @@ +// RUN: %dxc -E MainPS -T ps_6_6 %s | FileCheck %s // RUN: %dxc -E MainCS -T cs_6_6 %s | FileCheck %s // RUN: %dxc -E MainAS -T as_6_6 %s | FileCheck %s // RUN: %dxc -E MainMS -T ms_6_6 %s | FileCheck %s +// RUN: %dxc -T lib_6_6 %s | FileCheck %s // Make sure add is not sunk into if. // Compute shader variant of convergent.hlsl -// CHECK: add -// CHECK: add -// CHECK: icmp +// CHECK: fadd +// CHECK: fadd +// CHECK: fcmp // CHECK-NEXT: br @@ -15,34 +17,41 @@ Texture2D tex; RWBuffer output; SamplerState s; -void doit(uint ix, uint3 id){ +float4 doit(float2 a, float b){ - float2 coord = id.xy + id.z; - float4 c = id.z; - if (id.z > 2) { + float2 coord = a + b; + float4 c = b; + if (b > 2) { c += tex.Sample(s, coord); } - output[ix] = c; - + return c; } +[shader("compute")] [numthreads(4,4,4)] void MainCS(uint ix : SV_GroupIndex, uint3 id : SV_GroupThreadID) { - doit(ix, id); + output[ix] = doit(id.xy, id.z); } struct Payload { int nothing; }; +[shader("amplification")] [numthreads(4,4,4)] void MainAS(uint ix : SV_GroupIndex, uint3 id : SV_GroupThreadID) { - doit(ix, id); + output[ix] = doit(id.xy, id.z); Payload pld = (Payload)0; DispatchMesh(1,1,1,pld); } +[shader("mesh")] [numthreads(4,4,4)] [outputtopology("triangle")] void MainMS(uint ix : SV_GroupIndex, uint3 id : SV_GroupThreadID) { - doit(ix, id); + output[ix] = doit(id.xy, id.z); +} + +[shader("pixel")] +float4 MainPS(float2 a:A, float b:B) : SV_Target { + return doit(a, b); } \ No newline at end of file