Skip to content

Commit

Permalink
PIX: Educate debug data interface about nested namespaces (#5558)
Browse files Browse the repository at this point in the history
The comment from the checkin kinda says it all:
// DINamespace has a getScope member (that hides DIScope's)
// that returns a DIScope directly, but if that namespace
                // is at file-level scope, it will return nullptr.
(The upshot of this is that you couldn't step into functions within a
namespace in WinPIX's shader debugger)
  • Loading branch information
jeffnn authored Aug 21, 2023
1 parent d2a0baf commit c2233c6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/DxilDia/DxcPixDxilDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,18 @@ dxil_debug_info::DxcPixDxilSourceLocations::DxcPixDxilSourceLocations(
auto* S = llvm::dyn_cast<llvm::DIScope>(DL.getScope());
while (S != nullptr && !llvm::isa<llvm::DIFile>(S))
{
S = S->getScope().resolve(EmptyMap);
if(auto Namespace = llvm::dyn_cast<llvm::DINamespace>(S))
{
// DINamespace has a getScope member (that hides DIScope's)
// that returns a DIScope directly, but if that namespace
// is at file-level scope, it will return nullptr.
if (auto * ContainingScope = Namespace->getScope())
S = ContainingScope;
else
S = S->getFile();
}
else
S = S->getScope().resolve(EmptyMap);
}

if (S != nullptr)
Expand Down
14 changes: 13 additions & 1 deletion tools/clang/unittests/HLSL/PixTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2331,10 +2331,22 @@ void Raygen()
typedef BuiltInTriangleIntersectionAttributes MyAttributes;
namespace ANameSpace
{
namespace AContainedNamespace
{
float4 RoundaboutWayToReturnAmbientColor()
{
return g_sceneCB.lightAmbientColor;
}
}
}
[shader("closesthit")]
void InnerClosestHitShader(inout RayPayload payload, in MyAttributes attr)
{
payload.color = float4(0,1,0,0);
payload.color = ANameSpace::AContainedNamespace::RoundaboutWayToReturnAmbientColor();
}
Expand Down

0 comments on commit c2233c6

Please sign in to comment.