Skip to content

Commit 1071f1f

Browse files
authored
No sinking coord calc for sample in libs (microsoft#3661)
Merge microsoft#3658 into release-1.6.2104 Amidst catching the CS/AS/MS cases where convergent markers weren't getting generated, it was pointed out that libs may need these too. (cherry picked from commit cac37e6)
1 parent 1e84ea8 commit 1071f1f

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

lib/HLSL/DxilConvergent.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class DxilConvergentMark : public ModulePass {
4848
bool runOnModule(Module &M) override {
4949
if (M.HasHLModule()) {
5050
const ShaderModel *SM = M.GetHLModule().GetShaderModel();
51-
if (!SM->IsPS() && (!SM->IsSM66Plus() || (!SM->IsCS() && !SM->IsMS() && !SM->IsAS())))
51+
if (!SM->IsPS() && !SM->IsLib() && (!SM->IsSM66Plus() || (!SM->IsCS() && !SM->IsMS() && !SM->IsAS())))
5252
return false;
5353
}
5454
bool bUpdated = false;
Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,57 @@
1+
// RUN: %dxc -E MainPS -T ps_6_6 %s | FileCheck %s
12
// RUN: %dxc -E MainCS -T cs_6_6 %s | FileCheck %s
23
// RUN: %dxc -E MainAS -T as_6_6 %s | FileCheck %s
34
// RUN: %dxc -E MainMS -T ms_6_6 %s | FileCheck %s
5+
// RUN: %dxc -T lib_6_6 %s | FileCheck %s
46

57
// Make sure add is not sunk into if.
68
// Compute shader variant of convergent.hlsl
79

8-
// CHECK: add
9-
// CHECK: add
10-
// CHECK: icmp
10+
// CHECK: fadd
11+
// CHECK: fadd
12+
// CHECK: fcmp
1113
// CHECK-NEXT: br
1214

1315

1416
Texture2D<float4> tex;
1517
RWBuffer<float4> output;
1618
SamplerState s;
1719

18-
void doit(uint ix, uint3 id){
20+
float4 doit(float2 a, float b){
1921

20-
float2 coord = id.xy + id.z;
21-
float4 c = id.z;
22-
if (id.z > 2) {
22+
float2 coord = a + b;
23+
float4 c = b;
24+
if (b > 2) {
2325
c += tex.Sample(s, coord);
2426
}
25-
output[ix] = c;
26-
27+
return c;
2728
}
2829

30+
[shader("compute")]
2931
[numthreads(4,4,4)]
3032
void MainCS(uint ix : SV_GroupIndex, uint3 id : SV_GroupThreadID) {
31-
doit(ix, id);
33+
output[ix] = doit(id.xy, id.z);
3234
}
3335

3436
struct Payload { int nothing; };
3537

38+
[shader("amplification")]
3639
[numthreads(4,4,4)]
3740
void MainAS(uint ix : SV_GroupIndex, uint3 id : SV_GroupThreadID) {
38-
doit(ix, id);
41+
output[ix] = doit(id.xy, id.z);
3942
Payload pld = (Payload)0;
4043
DispatchMesh(1,1,1,pld);
4144
}
4245

4346

47+
[shader("mesh")]
4448
[numthreads(4,4,4)]
4549
[outputtopology("triangle")]
4650
void MainMS(uint ix : SV_GroupIndex, uint3 id : SV_GroupThreadID) {
47-
doit(ix, id);
51+
output[ix] = doit(id.xy, id.z);
52+
}
53+
54+
[shader("pixel")]
55+
float4 MainPS(float2 a:A, float b:B) : SV_Target {
56+
return doit(a, b);
4857
}

0 commit comments

Comments
 (0)