PIX: Test for source locations for class methods (#5176)

As tested in the accompanying test, the DebugLoc for a class method
contains a DICompositeType as part of its scope hierarchy. Lack of a
test for this was breaking PIX shader debugging for class methods.
This commit is contained in:
Jeff Noyle 2024-05-14 09:43:59 -07:00 коммит произвёл GitHub
Родитель f9389db7c3
Коммит ccdc4fdd5c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 115 добавлений и 15 удалений

Просмотреть файл

@ -156,8 +156,6 @@ public:
TEST_METHOD(PixTypeManager_SamplersAndResources)
TEST_METHOD(PixTypeManager_XBoxDiaAssert)
TEST_METHOD(DxcPixDxilDebugInfo_InstructionOffsets)
TEST_METHOD(PixDebugCompileInfo)
TEST_METHOD(SymbolManager_Embedded2DArray)
@ -168,6 +166,9 @@ public:
DxcPixDxilDebugInfo_GlobalBackedGlobalStaticEmbeddedArrays_WithDbgValue)
TEST_METHOD(
DxcPixDxilDebugInfo_GlobalBackedGlobalStaticEmbeddedArrays_ArrayInValues)
TEST_METHOD(DxcPixDxilDebugInfo_InstructionOffsets)
TEST_METHOD(DxcPixDxilDebugInfo_InstructionOffsetsInClassMethods)
TEST_METHOD(DxcPixDxilDebugInfo_DuplicateGlobals)
TEST_METHOD(DxcPixDxilDebugInfo_StructInheritance)
TEST_METHOD(DxcPixDxilDebugInfo_StructContainedResource)
@ -1916,6 +1917,105 @@ void MyMissShader(inout RayPayload payload)
}
}
TEST_F(PixDiaTest, DxcPixDxilDebugInfo_InstructionOffsetsInClassMethods) {
if (m_ver.SkipDxilVersion(1, 5))
return;
const char *hlsl = R"(
RWByteAddressBuffer RawUAV: register(u1);
class AClass
{
float Saturate(float f) // StartClassMethod
{
float l = RawUAV.Load(0);
return saturate(f * l);
} //EndClassMethod
};
[numthreads(1, 1, 1)]
void main()
{
uint orig;
AClass aClass;
float i = orig;
float f = aClass.Saturate(i);
uint fi = (uint)f;
RawUAV.InterlockedAdd(0, 42, fi);
}
)";
auto lines = SplitAndPreserveEmptyLines(std::string(hlsl), '\n');
CComPtr<IDiaDataSource> pDiaDataSource;
CompileAndRunAnnotationAndLoadDiaSource(m_dllSupport, hlsl, L"cs_6_6",
nullptr, &pDiaDataSource);
CComPtr<IDiaSession> session;
VERIFY_SUCCEEDED(pDiaDataSource->openSession(&session));
CComPtr<IDxcPixDxilDebugInfoFactory> Factory;
VERIFY_SUCCEEDED(session->QueryInterface(IID_PPV_ARGS(&Factory)));
CComPtr<IDxcPixDxilDebugInfo> dxilDebugger;
VERIFY_SUCCEEDED(Factory->NewDxcPixDxilDebugInfo(&dxilDebugger));
size_t lineAfterMethod = 0;
size_t lineBeforeMethod = static_cast<size_t>(-1);
for (size_t line = 0; line < lines.size(); ++line) {
if (lines[line].find("StartClassMethod") != std::string::npos)
lineBeforeMethod = line;
if (lines[line].find("EndClassMethod") != std::string::npos)
lineAfterMethod = line;
}
VERIFY_IS_TRUE(lineAfterMethod > lineBeforeMethod);
// For each source line, get the instruction numbers.
// For each instruction number, map back to source line.
// Some of them better be in the class method
bool foundClassMethodLines = false;
for (size_t line = 0; line < lines.size(); ++line) {
auto lineNumber = static_cast<DWORD>(line);
constexpr DWORD sourceLocationReaderOnlySupportsColumnZero = 0;
CComPtr<IDxcPixDxilInstructionOffsets> offsets;
dxilDebugger->InstructionOffsetsFromSourceLocation(
defaultFilename, lineNumber, sourceLocationReaderOnlySupportsColumnZero,
&offsets);
auto offsetCount = offsets->GetCount();
for (DWORD offsetOrdinal = 0; offsetOrdinal < offsetCount;
++offsetOrdinal) {
DWORD instructionOffsetFromSource =
offsets->GetOffsetByIndex(offsetOrdinal);
CComPtr<IDxcPixDxilSourceLocations> sourceLocations;
VERIFY_SUCCEEDED(dxilDebugger->SourceLocationsFromInstructionOffset(
instructionOffsetFromSource, &sourceLocations));
auto count = sourceLocations->GetCount();
for (DWORD sourceLocationOrdinal = 0; sourceLocationOrdinal < count;
++sourceLocationOrdinal) {
DWORD lineNumber =
sourceLocations->GetLineNumberByIndex(sourceLocationOrdinal);
if (lineNumber >= lineBeforeMethod && lineNumber <= lineAfterMethod) {
foundClassMethodLines = true;
}
}
}
}
VERIFY_IS_TRUE(foundClassMethodLines);
}
TEST_F(PixDiaTest, PixTypeManager_InheritancePointerTypedef) {
if (m_ver.SkipDxilVersion(1, 5))
return;

Просмотреть файл

@ -1033,7 +1033,7 @@ void RaygenCommon()
{
float3 rayDir;
float3 origin;
// Generate a ray for a camera pixel corresponding to an index from the dispatched 2D grid.
GenerateCameraRay(DispatchRaysIndex().xy, origin, rayDir);
@ -1119,7 +1119,7 @@ void RaygenCommon()
{
float3 rayDir;
float3 origin;
// Generate a ray for a camera pixel corresponding to an index from the dispatched 2D grid.
GenerateCameraRay(DispatchRaysIndex().xy, origin, rayDir);
@ -1797,7 +1797,7 @@ Texture2DArray<uint4> g_gbuffer : register(t0, space0);
[numthreads(1, 1, 1)]
void main()
{
{
const Gbuffer gbuffer = loadGbuffer(int2(0,0), g_gbuffer);
smallPayload p;
p.i = gbuffer.materialParams1.x + gbuffer.materialParams1.y + gbuffer.materialParams1.z + gbuffer.materialParams1.w;
@ -2161,7 +2161,7 @@ void RaygenCommon()
{
float3 rayDir;
float3 origin;
// Generate a ray for a camera pixel corresponding to an index from the dispatched 2D grid.
GenerateCameraRay(DispatchRaysIndex().xy, origin, rayDir);
@ -2366,21 +2366,21 @@ GlobalRootSignature so_GlobalRootSignature =
"RootConstants(num32BitConstants=1, b8), "
};
StateObjectConfig so_StateObjectConfig =
{
StateObjectConfig so_StateObjectConfig =
{
STATE_OBJECT_FLAGS_ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITONS
};
LocalRootSignature so_LocalRootSignature1 =
LocalRootSignature so_LocalRootSignature1 =
{
"RootConstants(num32BitConstants=3, b2), "
"UAV(u6),RootFlags(LOCAL_ROOT_SIGNATURE)"
"UAV(u6),RootFlags(LOCAL_ROOT_SIGNATURE)"
};
LocalRootSignature so_LocalRootSignature2 =
LocalRootSignature so_LocalRootSignature2 =
{
"RootConstants(num32BitConstants=3, b2), "
"UAV(u8, flags=DATA_STATIC), "
"UAV(u8, flags=DATA_STATIC), "
"RootFlags(LOCAL_ROOT_SIGNATURE)"
};
@ -2404,13 +2404,13 @@ TriangleHitGroup MyHitGroup =
SubobjectToExportsAssociation so_Association1 =
{
"so_LocalRootSignature1", // subobject name
"MyRayGen" // export association
"MyRayGen" // export association
};
SubobjectToExportsAssociation so_Association2 =
{
"so_LocalRootSignature2", // subobject name
"MyAnyHit" // export association
"MyAnyHit" // export association
};
struct MyPayload
@ -2425,7 +2425,7 @@ void MyRayGen()
[shader("closesthit")]
void MyClosestHit(inout MyPayload payload, in BuiltInTriangleIntersectionAttributes attr)
{
{
}
[shader("anyhit")]