-
Notifications
You must be signed in to change notification settings - Fork 697
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pix: Cope with group shared AS->MS payload (#6619)
This change copes with the AS->MS payload being placed in group-shared by the application (and MSFT's samples do indeed do this). (TIL, thanks to pow2clk, that the spec says that the payload counts against the group-shared total, implying, if not explicitly stating, that at least on some platforms, the payload will be in group-shared anyway.) The MS pass needs to be given data from the AS about the AS's thread group topology, and this is done by extending the payload struct to add three uints. This can't be done when the payload is resident in group-shared, of course, because that would change the layout of group-shared memory. So the new approach here is to copy the payload to a new alloca (in the default address space) struct with the members of the base struct plus the extended data the MS needs, and then to copy piece-wise because llvm.memcpy isn't appropriate for group-shared-to-normal address space copies.
- Loading branch information
Showing
5 changed files
with
326 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
tools/clang/test/HLSLFileCheck/pix/DebugAsGroupSharedComplexPayload.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// RUN: %dxc -enable-16bit-types -Od -Emain -Tas_6_6 %s | %opt -S -hlsl-dxil-PIX-add-tid-to-as-payload,dispatchArgY=3,dispatchArgZ=7 | %FileCheck %s | ||
|
||
// Check that the payload was piece-wise copied into a local copy from group-shared: | ||
// There are 28 elements: | ||
|
||
// CHECK: [[LOAD0:%.*]] = load [[TYPE0:.*]], [[TYPE0]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE0]] [[LOAD0]] | ||
// CHECK: [[LOAD1:%.*]] = load [[TYPE1:.*]], [[TYPE1]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE1]] [[LOAD1]] | ||
// CHECK: [[LOAD2:%.*]] = load [[TYPE2:.*]], [[TYPE2]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE2]] [[LOAD2]] | ||
// CHECK: [[LOAD3:%.*]] = load [[TYPE3:.*]], [[TYPE3]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE3]] [[LOAD3]] | ||
// CHECK: [[LOAD4:%.*]] = load [[TYPE4:.*]], [[TYPE4]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE4]] [[LOAD4]] | ||
// CHECK: [[LOAD5:%.*]] = load [[TYPE5:.*]], [[TYPE5]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE5]] [[LOAD5]] | ||
// CHECK: [[LOAD6:%.*]] = load [[TYPE6:.*]], [[TYPE6]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE6]] [[LOAD6]] | ||
// CHECK: [[LOAD7:%.*]] = load [[TYPE7:.*]], [[TYPE7]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE7]] [[LOAD7]] | ||
// CHECK: [[LOAD8:%.*]] = load [[TYPE8:.*]], [[TYPE8]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE8]] [[LOAD8]] | ||
// CHECK: [[LOAD9:%.*]] = load [[TYPE9:.*]], [[TYPE9]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE9]] [[LOAD9]] | ||
|
||
// CHECK: [[LOAD10:%.*]] = load [[TYPE10:.*]], [[TYPE10]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE10]] [[LOAD10]] | ||
// CHECK: [[LOAD11:%.*]] = load [[TYPE11:.*]], [[TYPE11]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE11]] [[LOAD11]] | ||
// CHECK: [[LOAD12:%.*]] = load [[TYPE12:.*]], [[TYPE12]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE12]] [[LOAD12]] | ||
// CHECK: [[LOAD13:%.*]] = load [[TYPE13:.*]], [[TYPE13]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE13]] [[LOAD13]] | ||
// CHECK: [[LOAD14:%.*]] = load [[TYPE14:.*]], [[TYPE14]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE14]] [[LOAD14]] | ||
// CHECK: [[LOAD15:%.*]] = load [[TYPE15:.*]], [[TYPE15]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE15]] [[LOAD15]] | ||
// CHECK: [[LOAD16:%.*]] = load [[TYPE16:.*]], [[TYPE16]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE16]] [[LOAD16]] | ||
// CHECK: [[LOAD17:%.*]] = load [[TYPE17:.*]], [[TYPE17]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE17]] [[LOAD17]] | ||
// CHECK: [[LOAD18:%.*]] = load [[TYPE18:.*]], [[TYPE18]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE18]] [[LOAD18]] | ||
// CHECK: [[LOAD19:%.*]] = load [[TYPE19:.*]], [[TYPE19]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE19]] [[LOAD19]] | ||
|
||
// CHECK: [[LOAD20:%.*]] = load [[TYPE20:.*]], [[TYPE20]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE20]] [[LOAD20]] | ||
// CHECK: [[LOAD21:%.*]] = load [[TYPE21:.*]], [[TYPE21]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE21]] [[LOAD21]] | ||
// CHECK: [[LOAD22:%.*]] = load [[TYPE22:.*]], [[TYPE22]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE22]] [[LOAD22]] | ||
// CHECK: [[LOAD23:%.*]] = load [[TYPE23:.*]], [[TYPE23]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE23]] [[LOAD23]] | ||
// CHECK: [[LOAD24:%.*]] = load [[TYPE24:.*]], [[TYPE24]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE24]] [[LOAD24]] | ||
// CHECK: [[LOAD25:%.*]] = load [[TYPE25:.*]], [[TYPE25]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE25]] [[LOAD25]] | ||
// CHECK: [[LOAD26:%.*]] = load [[TYPE26:.*]], [[TYPE26]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE26]] [[LOAD26]] | ||
// CHECK: [[LOAD27:%.*]] = load [[TYPE27:.*]], [[TYPE27]] addrspace(3)* getelementptr inbounds | ||
// CHECK:store volatile [[TYPE27]] [[LOAD27]] | ||
|
||
// And no more: | ||
// CHECK-NOT: [[LOAD28:%.*]] = load [[TYPE28:.*]], [[TYPE28]] addrspace(3)* getelementptr inbounds | ||
|
||
struct Contained { | ||
uint j; | ||
float af[3]; | ||
}; | ||
|
||
struct Bigger { | ||
half h; | ||
Contained a[2]; | ||
}; | ||
|
||
struct MyPayload { | ||
uint i; | ||
Bigger big[3]; | ||
}; | ||
|
||
groupshared MyPayload payload; | ||
|
||
[numthreads(1, 1, 1)] void main(uint gid | ||
: SV_GroupID) { | ||
DispatchMesh(1, 1, 1, payload); | ||
} |
21 changes: 21 additions & 0 deletions
21
tools/clang/test/HLSLFileCheck/pix/DebugAsGroupSharedPayload.hlsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// RUN: %dxc -Od -Emain -Tas_6_6 %s | %opt -S -hlsl-dxil-PIX-add-tid-to-as-payload,dispatchArgY=3,dispatchArgZ=7 | %FileCheck %s | ||
|
||
// Check that the payload was piece-wise copied into a local copy | ||
// CHECK: [[LOADGEP:%.*]] = getelementptr %struct.MyPayload | ||
// CHECK: [[LOAD:%.*]] = load i32, i32* [[LOADGEP]] | ||
// CHECK: store volatile i32 [[LOAD]] | ||
|
||
struct MyPayload | ||
{ | ||
uint i; | ||
}; | ||
|
||
groupshared MyPayload payload; | ||
|
||
[numthreads(1, 1, 1)] | ||
void main(uint gid : SV_GroupID) | ||
{ | ||
MyPayload copy; | ||
copy = payload; | ||
DispatchMesh(1, 1, 1, copy); | ||
} |
Oops, something went wrong.