Skip to content

Commit 6ce1b3b

Browse files
authored
Merge fixes for release branch #3630
Merge fixes for release branch
2 parents feef2ff + 3409368 commit 6ce1b3b

13 files changed

Lines changed: 575 additions & 141 deletions

lib/DxilPIXPasses/DxilShaderAccessTracking.cpp

Lines changed: 428 additions & 134 deletions
Large diffs are not rendered by default.

lib/HLSL/DxilValidation.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,6 +2567,17 @@ static void ValidateDxilOperationCallInProfile(CallInst *CI,
25672567
ValCtx.EmitInstrFormatError(CI, ValidationRule::SmOpcodeInInvalidFunction,
25682568
{"64-bit atomic operations", "Shader Model 6.6+"});
25692569
} break;
2570+
case DXIL::OpCode::CreateHandle:
2571+
if (ValCtx.isLibProfile) {
2572+
ValCtx.EmitInstrFormatError(CI, ValidationRule::SmOpcodeInInvalidFunction,
2573+
{"CreateHandle", "non-library targets"});
2574+
}
2575+
// CreateHandle should not be used in SM 6.6 and above:
2576+
if (DXIL::CompareVersions(ValCtx.m_DxilMajor, ValCtx.m_DxilMinor, 1, 5) > 0) {
2577+
ValCtx.EmitInstrFormatError(CI, ValidationRule::SmOpcodeInInvalidFunction,
2578+
{"CreateHandle", "Shader model 6.5 and below"});
2579+
}
2580+
break;
25702581
default:
25712582
// TODO: make sure every opcode is checked.
25722583
// Skip opcodes don't need special check.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// RUN: %dxc -E main -T ps_6_0 %s
22

3+
Buffer<float4> g_buf;
4+
5+
[shader("pixel")]
36
float4 main() : SV_Target {
4-
return float4(1, 0, 0, 1);
7+
return g_buf.Load(0);
58
}

tools/clang/test/HLSLFileCheck/pix/AccessTracking.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -ECSMain -Tcs_6_0 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=S0:1:1i1;U0:2:10i0;.. | %FileCheck %s
1+
// RUN: %dxc -ECSMain -Tcs_6_0 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=S0:1:1i1;U0:2:10i0;.0;0;0. | %FileCheck %s
22

33
// Check we added the UAV:
44
// CHECK: %PIX_CountUAV_Handle = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 1, i32 0, i1 false)

tools/clang/test/HLSLFileCheck/pix/AccessTrackingForSamplerFeedback.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -Emain -Tcs_6_5 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=M0:0:1i0;S0:1:1i0;U0:2:10i0;.. | %FileCheck %s
1+
// RUN: %dxc -Emain -Tcs_6_5 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=M0:0:1i0;S0:1:1i0;U0:2:10i0;.0;0;0. | %FileCheck %s
22

33
// Check we added the UAV:
44
// CHECK: %PIX_CountUAV_Handle = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 1, i32 0, i1 false)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %dxc -EMain -Tcs_6_6 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=.256;512;1024. | %FileCheck %s
2+
3+
static RWByteAddressBuffer DynamicBuffer = ResourceDescriptorHeap[1];
4+
[numthreads(1, 1, 1)]
5+
void Main()
6+
{
7+
uint val = DynamicBuffer.Load(0u);
8+
DynamicBuffer.Store(0u, val);
9+
}
10+
11+
// check it's 6.6:
12+
// CHECK: call %dx.types.Handle @dx.op.createHandleFromBinding
13+
14+
// Check we wrote to the PIX UAV:
15+
// CHECK: call void @dx.op.bufferStore.i32
16+
17+
// Offset for buffer Load should be 256 + 8 (skip out-of-bounds record) + 8 (it's the 1th resource) + 4 (offset to the "read" field) = 276
18+
// The large integer is encoded flags for the ResourceAccessStyle (an enumerated type in lib\DxilPIXPasses\DxilShaderAccessTracking.cpp) for this access
19+
// CHECK:i32 276, i32 undef, i32 1375731712
20+
// CHECK:rawBufferLoad
21+
22+
// Offset for buffer Store should be 256 + 8 (skip out-of-bounds record) + 8 (it's the 1th resource) + 0 (offset to the "write" field) = 272
23+
// The large integer is encoded flags for the ResourceAccessStyle (an enumerated type in lib\DxilPIXPasses\DxilShaderAccessTracking.cpp) for this access
24+
// CHECK:i32 272, i32 undef, i32 1392508928
25+
// CHECK:rawBufferStore
26+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %dxc -EMain -Tcs_6_6 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=.256;272;1024. | %FileCheck %s
2+
3+
static RWByteAddressBuffer DynamicBuffer = ResourceDescriptorHeap[1];
4+
[numthreads(1, 1, 1)]
5+
void Main()
6+
{
7+
uint val = DynamicBuffer.Load(0u);
8+
DynamicBuffer.Store(0u, val);
9+
}
10+
11+
// check it's 6.6:
12+
// CHECK: call %dx.types.Handle @dx.op.createHandleFromBinding
13+
14+
// The start of resource records has been passed in as 256. The limit of resource records is 272. 272-256 = 16.
15+
// 8 bytes per record means we have one record for out-of-bounds (that comes first), and one record for resource index 0.
16+
// The above HLSL references resource descriptor 1, so is out-of-bounds. Offset for out-of-bounds should thus be 256:
17+
// The large integer is encoded flags for the ResourceAccessStyle (an enumerated type in lib\DxilPIXPasses\DxilShaderAccessTracking.cpp) for this access
18+
// CHECK:i32 256, i32 undef, i32 1375731712
19+
// CHECK:rawBufferLoad
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %dxc -EMain -Tps_6_6 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=S0:1:1i1;.256;512;1024. | %FileCheck %s
2+
3+
static sampler sampler0 = SamplerDescriptorHeap[0];
4+
static sampler sampler3 = SamplerDescriptorHeap[3];
5+
Texture2D tx : register(t2);
6+
7+
float4 Main() : SV_Target
8+
{
9+
float4 a = tx.Sample(sampler0, float2(0,0));
10+
float4 b = tx.Sample(sampler3, float2(0,0));
11+
return a + b;
12+
}
13+
14+
// check it's 6.6:
15+
// CHECK: call %dx.types.Handle @dx.op.createHandleFromBinding
16+
17+
// The large integers are encoded flags for the ResourceAccessStyle (an enumerated type in lib\DxilPIXPasses\DxilShaderAccessTracking.cpp) for this access
18+
19+
// Check we wrote sampler data to the PIX UAV. We told the pass to output starting at offset 512.
20+
// Add 8 to skip the "out of bounds" record. Add 4 to point to the "read" field within the next entry = 524
21+
// CHECK: call void @dx.op.bufferStore.i32(
22+
// CHECK:i32 524, i32 undef, i32 16777216
23+
24+
// twice: 512 + 8 + 8*3+4 = 548
25+
// CHECK: call void @dx.op.bufferStore.i32(
26+
// CHECK:i32 548, i32 undef, i32 16777216
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %dxc -EMain -Tps_6_6 %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=S0:1:1i1;.256;512;520. | %FileCheck %s
2+
3+
static sampler sampler0 = SamplerDescriptorHeap[0];
4+
static sampler sampler3 = SamplerDescriptorHeap[3];
5+
Texture2D tx : register(t2);
6+
7+
float4 Main() : SV_Target
8+
{
9+
float4 a = tx.Sample(sampler0, float2(0,0));
10+
float4 b = tx.Sample(sampler3, float2(0,0));
11+
return a + b;
12+
}
13+
14+
// check it's 6.6:
15+
// CHECK: call %dx.types.Handle @dx.op.createHandleFromBinding
16+
17+
// The large integers are encoded flags for the ResourceAccessStyle (an enumerated type in lib\DxilPIXPasses\DxilShaderAccessTracking.cpp) for this access
18+
19+
// The start of sampler records has been passed in as 512. The limit of the whole buffer is 520, leaving just one eight-byte record for the out-of-bounds record.
20+
// There are therefore no expected in-bounds references to samplers, so any such reference should go to the out-of-bounds offset at 512:
21+
22+
// Out of bounds sampler access should be at offset 512
23+
// CHECK: call void @dx.op.bufferStore.i32(
24+
// CHECK:i32 512, i32 undef, i32 16777216

tools/clang/test/HLSLFileCheck/pix/TraceRayInline.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %dxc -T vs_6_5 -E main %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=S0:1:1i1;U0:2:10i0;.. | FileCheck %s
1+
// RUN: %dxc -T vs_6_5 -E main %s | %opt -S -hlsl-dxil-pix-shader-access-instrumentation,config=S0:1:1i1;U0:2:10i0;.0;0;0. | FileCheck %s
22

33
// CHECK: call void @dx.op.rayQuery_TraceRayInline
44
// CHECK: call void @dx.op.bufferStore.i32(i32 69, %dx.types.Handle

0 commit comments

Comments
 (0)