Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/DxilPIXPasses/PixPassHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,18 @@ constexpr uint32_t toolsUAVRegister = 0;
template <typename RootSigDesc, typename RootParameterDesc>
void ExtendRootSig(RootSigDesc &rootSigDesc) {
auto *existingParams = rootSigDesc.pParameters;
for (uint32_t i = 0; i < rootSigDesc.NumParameters; ++i) {
if (rootSigDesc.pParameters[i].ParameterType ==
DxilRootParameterType::UAV) {
if (rootSigDesc.pParameters[i].Descriptor.RegisterSpace ==
toolsRegisterSpace &&
rootSigDesc.pParameters[i].Descriptor.ShaderRegister ==
toolsUAVRegister) {
// Already added
return;
}
}
}
auto *newParams = new RootParameterDesc[rootSigDesc.NumParameters + 1];
if (existingParams != nullptr) {
memcpy(newParams, existingParams,
Expand Down
40 changes: 39 additions & 1 deletion tools/clang/unittests/HLSL/PixTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class PixTest : public ::testing::Test {
TEST_METHOD(RootSignatureUpgrade_Annotation)

TEST_METHOD(DxilPIXDXRInvocationsLog_SanityTest)
TEST_METHOD(DxilPIXDXRInvocationsLog_EmbeddedRootSigs)

TEST_METHOD(DebugInstrumentation_TextOutput)
TEST_METHOD(DebugInstrumentation_BlockReport)
Expand Down Expand Up @@ -660,7 +661,7 @@ CComPtr<IDxcBlob> PixTest::RunDxilPIXDXRInvocationsLog(IDxcBlob *blob) {
CComPtr<IDxcBlob> pOptimizedModule;
CComPtr<IDxcBlobEncoding> pText;
VERIFY_SUCCEEDED(pOptimizer->RunOptimizer(
dxil, Options.data(), Options.size(), &pOptimizedModule, &pText));
blob, Options.data(), Options.size(), &pOptimizedModule, &pText));

std::string outputText;
if (pText->GetBufferSize() != 0) {
Expand Down Expand Up @@ -2945,6 +2946,43 @@ void MyMiss(inout MyPayload payload)
RunDxilPIXDXRInvocationsLog(compiledLib);
}

TEST_F(PixTest, DxilPIXDXRInvocationsLog_EmbeddedRootSigs) {

const char *source = R"x(

GlobalRootSignature grs = {"CBV(b0)"};
struct MyPayload
{
float4 color;
};

[shader("raygeneration")]
void MyRayGen()
{
}

[shader("closesthit")]
void MyClosestHit(inout MyPayload payload, in BuiltInTriangleIntersectionAttributes attr)
{
}

[shader("anyhit")]
void MyAnyHit(inout MyPayload payload, in BuiltInTriangleIntersectionAttributes attr)
{
}

[shader("miss")]
void MyMiss(inout MyPayload payload)
{
}

)x";

auto compiledLib = Compile(m_dllSupport, source, L"lib_6_3",
{L"-Qstrip_reflect"}, L"RootSig");
RunDxilPIXDXRInvocationsLog(compiledLib);
}

TEST_F(PixTest, DebugInstrumentation_TextOutput) {

const char *source = R"x(
Expand Down
2 changes: 1 addition & 1 deletion tools/clang/unittests/HLSL/PixTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ CComPtr<IDxcBlob> Compile(dxc::DxcDllSupport &dllSupport, const char *hlsl,
CheckOperationSucceeded(pResult, &pProgram);

CComPtr<IDxcLibrary> pLib;
VERIFY_SUCCEEDED(m_dllSupport.CreateInstance(CLSID_DxcLibrary, &pLib));
VERIFY_SUCCEEDED(dllSupport.CreateInstance(CLSID_DxcLibrary, &pLib));
const hlsl::DxilContainerHeader *pContainer = hlsl::IsDxilContainerLike(
pProgram->GetBufferPointer(), pProgram->GetBufferSize());
VERIFY_IS_NOT_NULL(pContainer);
Expand Down