|
@@ -216,9 +216,9 @@ private:
|
|
uint64_t m_UAVSize = 1024 * 1024;
|
|
uint64_t m_UAVSize = 1024 * 1024;
|
|
struct PerFunctionValues
|
|
struct PerFunctionValues
|
|
{
|
|
{
|
|
- CallInst *UAVHandle;
|
|
|
|
- Constant *CounterOffset;
|
|
|
|
- Value *InvocationId;
|
|
|
|
|
|
+ CallInst *UAVHandle = nullptr;
|
|
|
|
+ Constant *CounterOffset = nullptr;
|
|
|
|
+ Value *InvocationId = nullptr;
|
|
// Together these two values allow branchless writing to the UAV. An
|
|
// Together these two values allow branchless writing to the UAV. An
|
|
// invocation of the shader is either of interest or not (e.g. it writes to
|
|
// invocation of the shader is either of interest or not (e.g. it writes to
|
|
// the pixel the user selected for debugging or it doesn't). If not of
|
|
// the pixel the user selected for debugging or it doesn't). If not of
|
|
@@ -227,11 +227,11 @@ private:
|
|
// will be written to the UAV at sequentially increasing offsets.
|
|
// will be written to the UAV at sequentially increasing offsets.
|
|
// This value will either be one or zero (one if the invocation is of
|
|
// This value will either be one or zero (one if the invocation is of
|
|
// interest, zero otherwise)
|
|
// interest, zero otherwise)
|
|
- Value *OffsetMultiplicand;
|
|
|
|
|
|
+ Value *OffsetMultiplicand = nullptr;
|
|
// This will either be zero (if the invocation is of interest) or
|
|
// This will either be zero (if the invocation is of interest) or
|
|
// (UAVSize)-(SmallValue) if not.
|
|
// (UAVSize)-(SmallValue) if not.
|
|
- Value *OffsetAddend;
|
|
|
|
- Constant *OffsetMask;
|
|
|
|
|
|
+ Value *OffsetAddend = nullptr;
|
|
|
|
+ Constant *OffsetMask = nullptr;
|
|
Value *SelectionCriterion = nullptr;
|
|
Value *SelectionCriterion = nullptr;
|
|
Value *CurrentIndex = nullptr;
|
|
Value *CurrentIndex = nullptr;
|
|
};
|
|
};
|
|
@@ -341,10 +341,10 @@ DxilDebugInstrumentation::SystemValueIndices
|
|
case DXIL::ShaderKind::Mesh:
|
|
case DXIL::ShaderKind::Mesh:
|
|
case DXIL::ShaderKind::Compute:
|
|
case DXIL::ShaderKind::Compute:
|
|
case DXIL::ShaderKind::RayGeneration:
|
|
case DXIL::ShaderKind::RayGeneration:
|
|
- //case DXIL::ShaderKind::Intersection:
|
|
|
|
- //case DXIL::ShaderKind::AnyHit:
|
|
|
|
- //case DXIL::ShaderKind::ClosestHit:
|
|
|
|
- //case DXIL::ShaderKind::Miss:
|
|
|
|
|
|
+ case DXIL::ShaderKind::Intersection:
|
|
|
|
+ case DXIL::ShaderKind::AnyHit:
|
|
|
|
+ case DXIL::ShaderKind::ClosestHit:
|
|
|
|
+ case DXIL::ShaderKind::Miss:
|
|
// Dispatch* thread Id is not in the input signature
|
|
// Dispatch* thread Id is not in the input signature
|
|
break;
|
|
break;
|
|
case DXIL::ShaderKind::Vertex: {
|
|
case DXIL::ShaderKind::Vertex: {
|
|
@@ -448,9 +448,11 @@ Value *DxilDebugInstrumentation::addRaygenShaderProlog(BuilderContext &BC) {
|
|
auto CompareToX = BC.Builder.CreateICmpEQ(
|
|
auto CompareToX = BC.Builder.CreateICmpEQ(
|
|
RayX, BC.HlslOP->GetU32Const(m_Parameters.ComputeShader.ThreadIdX),
|
|
RayX, BC.HlslOP->GetU32Const(m_Parameters.ComputeShader.ThreadIdX),
|
|
"CompareToThreadIdX");
|
|
"CompareToThreadIdX");
|
|
|
|
+
|
|
auto CompareToY = BC.Builder.CreateICmpEQ(
|
|
auto CompareToY = BC.Builder.CreateICmpEQ(
|
|
RayY, BC.HlslOP->GetU32Const(m_Parameters.ComputeShader.ThreadIdY),
|
|
RayY, BC.HlslOP->GetU32Const(m_Parameters.ComputeShader.ThreadIdY),
|
|
"CompareToThreadIdY");
|
|
"CompareToThreadIdY");
|
|
|
|
+
|
|
auto CompareToZ = BC.Builder.CreateICmpEQ(
|
|
auto CompareToZ = BC.Builder.CreateICmpEQ(
|
|
RayZ, BC.HlslOP->GetU32Const(m_Parameters.ComputeShader.ThreadIdZ),
|
|
RayZ, BC.HlslOP->GetU32Const(m_Parameters.ComputeShader.ThreadIdZ),
|
|
"CompareToThreadIdZ");
|
|
"CompareToThreadIdZ");
|
|
@@ -619,15 +621,15 @@ void DxilDebugInstrumentation::addInvocationSelectionProlog(
|
|
Value *ParameterTestResult = nullptr;
|
|
Value *ParameterTestResult = nullptr;
|
|
switch (shaderKind) {
|
|
switch (shaderKind) {
|
|
case DXIL::ShaderKind::RayGeneration:
|
|
case DXIL::ShaderKind::RayGeneration:
|
|
|
|
+ case DXIL::ShaderKind::ClosestHit:
|
|
|
|
+ case DXIL::ShaderKind::Intersection:
|
|
|
|
+ case DXIL::ShaderKind::AnyHit:
|
|
|
|
+ case DXIL::ShaderKind::Miss:
|
|
ParameterTestResult = addRaygenShaderProlog(BC);
|
|
ParameterTestResult = addRaygenShaderProlog(BC);
|
|
break;
|
|
break;
|
|
case DXIL::ShaderKind::Compute:
|
|
case DXIL::ShaderKind::Compute:
|
|
case DXIL::ShaderKind::Amplification:
|
|
case DXIL::ShaderKind::Amplification:
|
|
case DXIL::ShaderKind::Mesh:
|
|
case DXIL::ShaderKind::Mesh:
|
|
- //case DXIL::ShaderKind::Intersection:
|
|
|
|
- //case DXIL::ShaderKind::AnyHit:
|
|
|
|
- //case DXIL::ShaderKind::ClosestHit:
|
|
|
|
- //case DXIL::ShaderKind::Miss:
|
|
|
|
ParameterTestResult = addDispatchedShaderProlog(BC);
|
|
ParameterTestResult = addDispatchedShaderProlog(BC);
|
|
break;
|
|
break;
|
|
case DXIL::ShaderKind::Geometry:
|
|
case DXIL::ShaderKind::Geometry:
|
|
@@ -806,7 +808,6 @@ void DxilDebugInstrumentation::addInvocationStartMarker(BuilderContext &BC) {
|
|
|
|
|
|
marker.Header.Details.SizeDwords =
|
|
marker.Header.Details.SizeDwords =
|
|
DebugShaderModifierRecordPayloadSizeDwords(sizeof(marker));
|
|
DebugShaderModifierRecordPayloadSizeDwords(sizeof(marker));
|
|
- ;
|
|
|
|
marker.Header.Details.Flags = 0;
|
|
marker.Header.Details.Flags = 0;
|
|
marker.Header.Details.Type =
|
|
marker.Header.Details.Type =
|
|
DebugShaderModifierRecordTypeInvocationStartMarker;
|
|
DebugShaderModifierRecordTypeInvocationStartMarker;
|
|
@@ -980,16 +981,9 @@ bool DxilDebugInstrumentation::RunOnFunction(
|
|
DxilModule &DM,
|
|
DxilModule &DM,
|
|
llvm::Function * entryFunction)
|
|
llvm::Function * entryFunction)
|
|
{
|
|
{
|
|
- DXIL::ShaderKind shaderKind = DXIL::ShaderKind::Invalid;
|
|
|
|
- if (!DM.HasDxilFunctionProps(entryFunction)) {
|
|
|
|
- auto ShaderModel = DM.GetShaderModel();
|
|
|
|
- shaderKind = ShaderModel->GetKind();
|
|
|
|
- } else {
|
|
|
|
- hlsl::DxilFunctionProps const &props =
|
|
|
|
- DM.GetDxilFunctionProps(entryFunction);
|
|
|
|
- shaderKind = props.shaderKind;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ DXIL::ShaderKind shaderKind =
|
|
|
|
+ PIXPassHelpers::GetFunctionShaderKind(DM, entryFunction);
|
|
|
|
+
|
|
switch (shaderKind) {
|
|
switch (shaderKind) {
|
|
case DXIL::ShaderKind::Amplification:
|
|
case DXIL::ShaderKind::Amplification:
|
|
case DXIL::ShaderKind::Mesh:
|
|
case DXIL::ShaderKind::Mesh:
|
|
@@ -1000,12 +994,11 @@ bool DxilDebugInstrumentation::RunOnFunction(
|
|
case DXIL::ShaderKind::RayGeneration:
|
|
case DXIL::ShaderKind::RayGeneration:
|
|
case DXIL::ShaderKind::Hull:
|
|
case DXIL::ShaderKind::Hull:
|
|
case DXIL::ShaderKind::Domain:
|
|
case DXIL::ShaderKind::Domain:
|
|
- break;
|
|
|
|
- //todo:
|
|
|
|
case DXIL::ShaderKind::Intersection:
|
|
case DXIL::ShaderKind::Intersection:
|
|
case DXIL::ShaderKind::AnyHit:
|
|
case DXIL::ShaderKind::AnyHit:
|
|
case DXIL::ShaderKind::ClosestHit:
|
|
case DXIL::ShaderKind::ClosestHit:
|
|
case DXIL::ShaderKind::Miss:
|
|
case DXIL::ShaderKind::Miss:
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -1042,8 +1035,24 @@ bool DxilDebugInstrumentation::RunOnFunction(
|
|
|
|
|
|
auto &values = m_FunctionToValues[BC.Builder.GetInsertBlock()->getParent()];
|
|
auto &values = m_FunctionToValues[BC.Builder.GetInsertBlock()->getParent()];
|
|
|
|
|
|
|
|
+ // PIX binds two UAVs when running this instrumentation: one for raygen shaders
|
|
|
|
+ // and another for the hitgroups and miss shaders. Since PIX invokes this pass
|
|
|
|
+ // at the library level, which may contain examples of both types, PIX can't really
|
|
|
|
+ // specify which UAV index to use per-shader. This pass therefore just has to know this:
|
|
|
|
+ constexpr unsigned int RayGenUAVRegister = 0;
|
|
|
|
+ constexpr unsigned int HitGroupAndMissUAVRegister = 1;
|
|
|
|
+ unsigned int UAVRegisterId = RayGenUAVRegister;
|
|
|
|
+ switch (shaderKind) {
|
|
|
|
+ case DXIL::ShaderKind::ClosestHit:
|
|
|
|
+ case DXIL::ShaderKind::Intersection:
|
|
|
|
+ case DXIL::ShaderKind::AnyHit:
|
|
|
|
+ case DXIL::ShaderKind::Miss:
|
|
|
|
+ UAVRegisterId = HitGroupAndMissUAVRegister;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
values.UAVHandle = PIXPassHelpers::CreateUAV(
|
|
values.UAVHandle = PIXPassHelpers::CreateUAV(
|
|
- DM, Builder, 0,
|
|
|
|
|
|
+ DM, Builder, UAVRegisterId,
|
|
"PIX_DebugUAV_Handle");
|
|
"PIX_DebugUAV_Handle");
|
|
values.CounterOffset = BC.HlslOP->GetU32Const(UAVDumpingGroundOffset() + CounterOffsetBeyondUsefulData);
|
|
values.CounterOffset = BC.HlslOP->GetU32Const(UAVDumpingGroundOffset() + CounterOffsetBeyondUsefulData);
|
|
|
|
|