@@ -216,9 +216,9 @@ class DxilDebugInstrumentation : public ModulePass {
216
216
uint64_t m_UAVSize = 1024 * 1024 ;
217
217
struct PerFunctionValues
218
218
{
219
- CallInst *UAVHandle;
220
- Constant *CounterOffset;
221
- Value *InvocationId;
219
+ CallInst *UAVHandle = nullptr ;
220
+ Constant *CounterOffset = nullptr ;
221
+ Value *InvocationId = nullptr ;
222
222
// Together these two values allow branchless writing to the UAV. An
223
223
// invocation of the shader is either of interest or not (e.g. it writes to
224
224
// the pixel the user selected for debugging or it doesn't). If not of
@@ -227,11 +227,11 @@ class DxilDebugInstrumentation : public ModulePass {
227
227
// will be written to the UAV at sequentially increasing offsets.
228
228
// This value will either be one or zero (one if the invocation is of
229
229
// interest, zero otherwise)
230
- Value *OffsetMultiplicand;
230
+ Value *OffsetMultiplicand = nullptr ;
231
231
// This will either be zero (if the invocation is of interest) or
232
232
// (UAVSize)-(SmallValue) if not.
233
- Value *OffsetAddend;
234
- Constant *OffsetMask;
233
+ Value *OffsetAddend = nullptr ;
234
+ Constant *OffsetMask = nullptr ;
235
235
Value *SelectionCriterion = nullptr ;
236
236
Value *CurrentIndex = nullptr ;
237
237
};
@@ -341,10 +341,10 @@ DxilDebugInstrumentation::SystemValueIndices
341
341
case DXIL::ShaderKind::Mesh:
342
342
case DXIL::ShaderKind::Compute:
343
343
case DXIL::ShaderKind::RayGeneration:
344
- // case DXIL::ShaderKind::Intersection:
345
- // case DXIL::ShaderKind::AnyHit:
346
- // case DXIL::ShaderKind::ClosestHit:
347
- // case DXIL::ShaderKind::Miss:
344
+ case DXIL::ShaderKind::Intersection:
345
+ case DXIL::ShaderKind::AnyHit:
346
+ case DXIL::ShaderKind::ClosestHit:
347
+ case DXIL::ShaderKind::Miss:
348
348
// Dispatch* thread Id is not in the input signature
349
349
break ;
350
350
case DXIL::ShaderKind::Vertex: {
@@ -448,9 +448,11 @@ Value *DxilDebugInstrumentation::addRaygenShaderProlog(BuilderContext &BC) {
448
448
auto CompareToX = BC.Builder .CreateICmpEQ (
449
449
RayX, BC.HlslOP ->GetU32Const (m_Parameters.ComputeShader .ThreadIdX ),
450
450
" CompareToThreadIdX" );
451
+
451
452
auto CompareToY = BC.Builder .CreateICmpEQ (
452
453
RayY, BC.HlslOP ->GetU32Const (m_Parameters.ComputeShader .ThreadIdY ),
453
454
" CompareToThreadIdY" );
455
+
454
456
auto CompareToZ = BC.Builder .CreateICmpEQ (
455
457
RayZ, BC.HlslOP ->GetU32Const (m_Parameters.ComputeShader .ThreadIdZ ),
456
458
" CompareToThreadIdZ" );
@@ -619,15 +621,15 @@ void DxilDebugInstrumentation::addInvocationSelectionProlog(
619
621
Value *ParameterTestResult = nullptr ;
620
622
switch (shaderKind) {
621
623
case DXIL::ShaderKind::RayGeneration:
624
+ case DXIL::ShaderKind::ClosestHit:
625
+ case DXIL::ShaderKind::Intersection:
626
+ case DXIL::ShaderKind::AnyHit:
627
+ case DXIL::ShaderKind::Miss:
622
628
ParameterTestResult = addRaygenShaderProlog (BC);
623
629
break ;
624
630
case DXIL::ShaderKind::Compute:
625
631
case DXIL::ShaderKind::Amplification:
626
632
case DXIL::ShaderKind::Mesh:
627
- // case DXIL::ShaderKind::Intersection:
628
- // case DXIL::ShaderKind::AnyHit:
629
- // case DXIL::ShaderKind::ClosestHit:
630
- // case DXIL::ShaderKind::Miss:
631
633
ParameterTestResult = addDispatchedShaderProlog (BC);
632
634
break ;
633
635
case DXIL::ShaderKind::Geometry:
@@ -806,7 +808,6 @@ void DxilDebugInstrumentation::addInvocationStartMarker(BuilderContext &BC) {
806
808
807
809
marker.Header .Details .SizeDwords =
808
810
DebugShaderModifierRecordPayloadSizeDwords (sizeof (marker));
809
- ;
810
811
marker.Header .Details .Flags = 0 ;
811
812
marker.Header .Details .Type =
812
813
DebugShaderModifierRecordTypeInvocationStartMarker;
@@ -980,16 +981,9 @@ bool DxilDebugInstrumentation::RunOnFunction(
980
981
DxilModule &DM,
981
982
llvm::Function * entryFunction)
982
983
{
983
- DXIL::ShaderKind shaderKind = DXIL::ShaderKind::Invalid;
984
- if (!DM.HasDxilFunctionProps (entryFunction)) {
985
- auto ShaderModel = DM.GetShaderModel ();
986
- shaderKind = ShaderModel->GetKind ();
987
- } else {
988
- hlsl::DxilFunctionProps const &props =
989
- DM.GetDxilFunctionProps (entryFunction);
990
- shaderKind = props.shaderKind ;
991
- }
992
-
984
+ DXIL::ShaderKind shaderKind =
985
+ PIXPassHelpers::GetFunctionShaderKind (DM, entryFunction);
986
+
993
987
switch (shaderKind) {
994
988
case DXIL::ShaderKind::Amplification:
995
989
case DXIL::ShaderKind::Mesh:
@@ -1000,12 +994,11 @@ bool DxilDebugInstrumentation::RunOnFunction(
1000
994
case DXIL::ShaderKind::RayGeneration:
1001
995
case DXIL::ShaderKind::Hull:
1002
996
case DXIL::ShaderKind::Domain:
1003
- break ;
1004
- // todo:
1005
997
case DXIL::ShaderKind::Intersection:
1006
998
case DXIL::ShaderKind::AnyHit:
1007
999
case DXIL::ShaderKind::ClosestHit:
1008
1000
case DXIL::ShaderKind::Miss:
1001
+ break ;
1009
1002
default :
1010
1003
return false ;
1011
1004
}
@@ -1042,8 +1035,24 @@ bool DxilDebugInstrumentation::RunOnFunction(
1042
1035
1043
1036
auto &values = m_FunctionToValues[BC.Builder .GetInsertBlock ()->getParent ()];
1044
1037
1038
+ // PIX binds two UAVs when running this instrumentation: one for raygen shaders
1039
+ // and another for the hitgroups and miss shaders. Since PIX invokes this pass
1040
+ // at the library level, which may contain examples of both types, PIX can't really
1041
+ // specify which UAV index to use per-shader. This pass therefore just has to know this:
1042
+ constexpr unsigned int RayGenUAVRegister = 0 ;
1043
+ constexpr unsigned int HitGroupAndMissUAVRegister = 1 ;
1044
+ unsigned int UAVRegisterId = RayGenUAVRegister;
1045
+ switch (shaderKind) {
1046
+ case DXIL::ShaderKind::ClosestHit:
1047
+ case DXIL::ShaderKind::Intersection:
1048
+ case DXIL::ShaderKind::AnyHit:
1049
+ case DXIL::ShaderKind::Miss:
1050
+ UAVRegisterId = HitGroupAndMissUAVRegister;
1051
+ break ;
1052
+ }
1053
+
1045
1054
values.UAVHandle = PIXPassHelpers::CreateUAV (
1046
- DM, Builder, 0 ,
1055
+ DM, Builder, UAVRegisterId ,
1047
1056
" PIX_DebugUAV_Handle" );
1048
1057
values.CounterOffset = BC.HlslOP ->GetU32Const (UAVDumpingGroundOffset () + CounterOffsetBeyondUsefulData);
1049
1058
0 commit comments