chore(debug): name D3D11 resources for RenderDoc#2209
Conversation
📝 WalkthroughWalkthroughThis PR systematically adds debug naming support for Direct3D 11 resources across the codebase. It extends buffer and texture constructors with optional Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
No actionable suggestions for changed features. |
All D3D11 resources created by Community Shaders now carry a descriptive debug name via SetPrivateData(WKPDID_D3DDebugObjectName), so they appear as e.g. "SSGI::Radiance SRV" in RenderDoc instead of generic indices like "Texture community-shaders#47". Changes: - Buffer.h: add optional `name` parameter to all wrapper class constructors (ConstantBuffer, StructuredBuffer, Buffer, Texture1D, Texture2D, Texture3D); view creation methods (CreateSRV/UAV/RTV/DSV) automatically append " SRV" / " UAV" etc. to the base name. detail::SetD3DName delegates to Util::SetResourceName via a forward declaration, keeping the GUID definition in one place (D3D.cpp). - Util::SetResourceName used directly for raw device->Create* objects (samplers, blend states, depth-stencil states, rasterizer states, raw RTVs/SRVs not owned by a wrapper) across: Deferred, CloudShadows, DynamicCubemaps, VolumetricShadows, ScreenSpaceGI, ScreenSpaceShadows, Skylighting, TerrainBlending, TerrainShadows, LightLimitFix, GrassCollision, HairSpecular, HDRDisplay, IBL, VR, VRStereoOpt, VR::StereoBlend, VR::InSceneOverlay, BackgroundBlur, IconLoader, Utils::UI. - .claude/CLAUDE.md: document D3D resource naming convention and add DRY pitfall note for cross-cutting refactors. No behaviour change; naming calls are init-time only with zero per-frame overhead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
e97b661 to
19e53f3
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (3)
src/Buffer.h (1)
128-128: Optional: addexplicitfor consistency.
StructuredBuffer's 2-required-arg constructor is the only wrapper not markedexplicitafter this change. Not user-visible, just a small consistency nit alongsideConstantBuffer/Buffer/Texture*which all gainedexplicitin this PR.♻️ Optional consistency tweak
- StructuredBuffer(D3D11_BUFFER_DESC const& a_desc, UINT a_count, const char* name = nullptr) : + explicit StructuredBuffer(D3D11_BUFFER_DESC const& a_desc, UINT a_count, const char* name = nullptr) :🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Buffer.h` at line 128, The StructuredBuffer constructor overload StructuredBuffer(D3D11_BUFFER_DESC const& a_desc, UINT a_count, const char* name = nullptr) is missing the explicit keyword for consistency with other wrappers; mark this constructor explicit to prevent unintended implicit conversions and match ConstantBuffer/Buffer/Texture* constructors.src/Features/VRStereoOptimizations.cpp (1)
177-177: Consider namingstencilWriteRSfor full pass-state visibility.You named
stencilWriteDSS; adding a name for the rasterizer state would complete this stencil pass’s RenderDoc metadata.Suggested patch
DX::ThrowIfFailed(device->CreateRasterizerState(&rsDesc, stencilWriteRS.put())); + Util::SetResourceName(stencilWriteRS.get(), "VRStereoOpt::StencilWriteRS"); }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Features/VRStereoOptimizations.cpp` at line 177, The stencil pass currently names only the depth-stencil state (stencilWriteDSS); add a corresponding SetResourceName call for the rasterizer state (stencilWriteRS) so RenderDoc shows full pass-state metadata—locate where stencilWriteDSS is named and call Util::SetResourceName(stencilWriteRS.get(), "VRStereoOpt::StencilWriteRS") (or similar consistent label) to match naming convention.src/Features/IBL.cpp (1)
329-329: Recommend namingenvIBLTextureandskyIBLTexturetoo for full IBL coverage.In the same setup path, Line 297 and Line 300 still construct unnamed textures.
Suggested patch
- envIBLTexture = new Texture2D(texDesc); + envIBLTexture = new Texture2D(texDesc, "IBL::EnvIBL"); envIBLTexture->CreateSRV(srvDesc); envIBLTexture->CreateUAV(uavDesc); - skyIBLTexture = new Texture2D(texDesc); + skyIBLTexture = new Texture2D(texDesc, "IBL::SkyIBL"); skyIBLTexture->CreateSRV(srvDesc); skyIBLTexture->CreateUAV(uavDesc);Also applies to: 365-365
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Features/IBL.cpp` at line 329, Several IBL textures are constructed without descriptive names; update the unnamed Texture2D constructions so they use explicit labels similar to staticDiffuseIBLTexture. Locate the Texture2D creations (e.g., the existing staticDiffuseIBLTexture = eastl::make_unique<Texture2D>(... , "IBL::StaticDiffuse")) and change the other two unnamed instances to create envIBLTexture and skyIBLTexture using eastl::make_unique<Texture2D>(reinterpret_cast<ID3D11Texture2D*>(pResource), "IBL::Env") and eastl::make_unique<Texture2D>(reinterpret_cast<ID3D11Texture2D*>(pResource), "IBL::Sky") respectively (also apply the same naming fix at the other occurrence around the later block noted in the comment).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/Buffer.h`:
- Line 128: The StructuredBuffer constructor overload
StructuredBuffer(D3D11_BUFFER_DESC const& a_desc, UINT a_count, const char* name
= nullptr) is missing the explicit keyword for consistency with other wrappers;
mark this constructor explicit to prevent unintended implicit conversions and
match ConstantBuffer/Buffer/Texture* constructors.
In `@src/Features/IBL.cpp`:
- Line 329: Several IBL textures are constructed without descriptive names;
update the unnamed Texture2D constructions so they use explicit labels similar
to staticDiffuseIBLTexture. Locate the Texture2D creations (e.g., the existing
staticDiffuseIBLTexture = eastl::make_unique<Texture2D>(... ,
"IBL::StaticDiffuse")) and change the other two unnamed instances to create
envIBLTexture and skyIBLTexture using
eastl::make_unique<Texture2D>(reinterpret_cast<ID3D11Texture2D*>(pResource),
"IBL::Env") and
eastl::make_unique<Texture2D>(reinterpret_cast<ID3D11Texture2D*>(pResource),
"IBL::Sky") respectively (also apply the same naming fix at the other occurrence
around the later block noted in the comment).
In `@src/Features/VRStereoOptimizations.cpp`:
- Line 177: The stencil pass currently names only the depth-stencil state
(stencilWriteDSS); add a corresponding SetResourceName call for the rasterizer
state (stencilWriteRS) so RenderDoc shows full pass-state metadata—locate where
stencilWriteDSS is named and call Util::SetResourceName(stencilWriteRS.get(),
"VRStereoOpt::StencilWriteRS") (or similar consistent label) to match naming
convention.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 57b9bca5-dfa1-4444-973d-b07d48ee09a7
📒 Files selected for processing (24)
.claude/CLAUDE.mdextern/CommonLibSSE-NGsrc/Buffer.hsrc/Deferred.cppsrc/Features/CloudShadows.cppsrc/Features/DynamicCubemaps.cppsrc/Features/GrassCollision.cppsrc/Features/HDRDisplay.cppsrc/Features/HairSpecular.cppsrc/Features/IBL.cppsrc/Features/LightLimitFix.cppsrc/Features/ScreenSpaceGI.cppsrc/Features/ScreenSpaceShadows.cppsrc/Features/Skylighting.cppsrc/Features/TerrainBlending.cppsrc/Features/TerrainShadows.cppsrc/Features/VR.cppsrc/Features/VR/InSceneOverlay.cppsrc/Features/VR/StereoBlend.cppsrc/Features/VRStereoOptimizations.cppsrc/Features/VolumetricShadows.cppsrc/Menu/BackgroundBlur.cppsrc/Menu/IconLoader.cppsrc/Utils/UI.cpp
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/Menu/IconLoader.cpp (1)
57-57: Optional: trimfilenameto a leaf path for RenderDoc readability.
filenamehere is the full absolute path that was passed intoLoadTextureFromFile(e.g.…\Data\…\Icons\Action Icons\save-settings.png), so the resulting debug names will be very long. Usingstd::filesystem::path(filename).filename().string()(or the relative portion under the icons root) would yield friendlier labels likeIconLoader::save-settings.png/IconLoader::save-settings.png SRVwithout changing behavior.Also applies to: 79-79
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Menu/IconLoader.cpp` at line 57, The debug resource name uses the full absolute path in Util::SetResourceName, making RenderDoc labels unwieldy; in the LoadTextureFromFile call site (where Util::SetResourceName is invoked) trim filename to its leaf name before passing it to Util::SetResourceName (e.g. compute std::filesystem::path(filename).filename().string() or the relative path under your icons root) and use that trimmed string for both the main name and the SRV variant so labels like "IconLoader::save-settings.png" are emitted; update both occurrences around the Util::SetResourceName calls (including the SRV name at the other call site) to use the trimmed filename variable.src/Features/DynamicCubemaps.cpp (1)
674-708: Several core cubemap textures left unnamed.The capture/env textures created here (
envCaptureTexture,envCaptureRawTexture,envCapturePositionTexture,envCaptureReflectionsTexture,envCaptureRawReflectionsTexture,envCapturePositionReflectionsTexture,envTexture,envReflectionsTexture) still use the no-nameTexture2D(texDesc)constructor, whileenvInferredTexture,bc6hScratchTexture, and the BC6H targets do get explicit names. These eight textures are the ones you most often want to identify in RenderDoc when debugging cubemap capture/inferrence/irradiance, so leaving them anonymous partially defeats the PR's goal for this module.♻️ Proposed naming additions
- envCaptureTexture = new Texture2D(texDesc); + envCaptureTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvCapture"); envCaptureTexture->CreateSRV(srvDesc); envCaptureTexture->CreateUAV(uavDesc); - envCaptureRawTexture = new Texture2D(texDesc); + envCaptureRawTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvCaptureRaw"); envCaptureRawTexture->CreateSRV(srvDesc); envCaptureRawTexture->CreateUAV(uavDesc); - envCapturePositionTexture = new Texture2D(texDesc); + envCapturePositionTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvCapturePosition"); envCapturePositionTexture->CreateSRV(srvDesc); envCapturePositionTexture->CreateUAV(uavDesc); - envCaptureReflectionsTexture = new Texture2D(texDesc); + envCaptureReflectionsTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvCaptureReflections"); envCaptureReflectionsTexture->CreateSRV(srvDesc); envCaptureReflectionsTexture->CreateUAV(uavDesc); - envCaptureRawReflectionsTexture = new Texture2D(texDesc); + envCaptureRawReflectionsTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvCaptureRawReflections"); envCaptureRawReflectionsTexture->CreateSRV(srvDesc); envCaptureRawReflectionsTexture->CreateUAV(uavDesc); - envCapturePositionReflectionsTexture = new Texture2D(texDesc); + envCapturePositionReflectionsTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvCapturePositionReflections"); envCapturePositionReflectionsTexture->CreateSRV(srvDesc); envCapturePositionReflectionsTexture->CreateUAV(uavDesc); @@ - envTexture = new Texture2D(texDesc); + envTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvTexture"); envTexture->CreateSRV(srvDesc); envTexture->CreateUAV(uavDesc); - envReflectionsTexture = new Texture2D(texDesc); + envReflectionsTexture = new Texture2D(texDesc, "DynamicCubemaps::EnvReflections"); envReflectionsTexture->CreateSRV(srvDesc); envReflectionsTexture->CreateUAV(uavDesc);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Features/DynamicCubemaps.cpp` around lines 674 - 708, The eight cubemap textures (envCaptureTexture, envCaptureRawTexture, envCapturePositionTexture, envCaptureReflectionsTexture, envCaptureRawReflectionsTexture, envCapturePositionReflectionsTexture, envTexture, envReflectionsTexture) are created with the anonymous Texture2D(texDesc) constructor—give each a descriptive debug name so they show up in RenderDoc; update their construction to use the same naming approach used for envInferredTexture/bc6hScratchTexture (e.g., pass a name string into the Texture2D constructor or call the engine's SetName/SetDebugName method right after creation) so each Texture2D instance is uniquely named when CreateSRV/CreateUAV are called.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/Features/DynamicCubemaps.cpp`:
- Around line 674-708: The eight cubemap textures (envCaptureTexture,
envCaptureRawTexture, envCapturePositionTexture, envCaptureReflectionsTexture,
envCaptureRawReflectionsTexture, envCapturePositionReflectionsTexture,
envTexture, envReflectionsTexture) are created with the anonymous
Texture2D(texDesc) constructor—give each a descriptive debug name so they show
up in RenderDoc; update their construction to use the same naming approach used
for envInferredTexture/bc6hScratchTexture (e.g., pass a name string into the
Texture2D constructor or call the engine's SetName/SetDebugName method right
after creation) so each Texture2D instance is uniquely named when
CreateSRV/CreateUAV are called.
In `@src/Menu/IconLoader.cpp`:
- Line 57: The debug resource name uses the full absolute path in
Util::SetResourceName, making RenderDoc labels unwieldy; in the
LoadTextureFromFile call site (where Util::SetResourceName is invoked) trim
filename to its leaf name before passing it to Util::SetResourceName (e.g.
compute std::filesystem::path(filename).filename().string() or the relative path
under your icons root) and use that trimmed string for both the main name and
the SRV variant so labels like "IconLoader::save-settings.png" are emitted;
update both occurrences around the Util::SetResourceName calls (including the
SRV name at the other call site) to use the trimmed filename variable.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: be996976-92ee-416e-b798-b6ba2fe729e8
📒 Files selected for processing (23)
.claude/CLAUDE.mdsrc/Buffer.hsrc/Deferred.cppsrc/Features/CloudShadows.cppsrc/Features/DynamicCubemaps.cppsrc/Features/GrassCollision.cppsrc/Features/HDRDisplay.cppsrc/Features/HairSpecular.cppsrc/Features/IBL.cppsrc/Features/LightLimitFix.cppsrc/Features/ScreenSpaceGI.cppsrc/Features/ScreenSpaceShadows.cppsrc/Features/Skylighting.cppsrc/Features/TerrainBlending.cppsrc/Features/TerrainShadows.cppsrc/Features/VR.cppsrc/Features/VR/InSceneOverlay.cppsrc/Features/VR/StereoBlend.cppsrc/Features/VRStereoOptimizations.cppsrc/Features/VolumetricShadows.cppsrc/Menu/BackgroundBlur.cppsrc/Menu/IconLoader.cppsrc/Utils/UI.cpp
✅ Files skipped from review due to trivial changes (13)
- src/Features/VR/StereoBlend.cpp
- src/Features/VR/InSceneOverlay.cpp
- .claude/CLAUDE.md
- src/Features/ScreenSpaceShadows.cpp
- src/Features/VRStereoOptimizations.cpp
- src/Features/HDRDisplay.cpp
- src/Menu/BackgroundBlur.cpp
- src/Features/VolumetricShadows.cpp
- src/Features/IBL.cpp
- src/Features/LightLimitFix.cpp
- src/Features/TerrainBlending.cpp
- src/Features/TerrainShadows.cpp
- src/Features/ScreenSpaceGI.cpp
🚧 Files skipped from review as they are similar to previous changes (4)
- src/Features/GrassCollision.cpp
- src/Features/VR.cpp
- src/Deferred.cpp
- src/Buffer.h
|
✅ A pre-release build is available for this PR: |
) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com> (cherry picked from commit 068f624)
All D3D11 resources created by Community Shaders now carry a descriptive debug name via SetPrivateData(WKPDID_D3DDebugObjectName), so they appear as e.g. "SSGI::Radiance SRV" in RenderDoc instead of generic indices like "Texture #47".
Changes:
nameparameter to all wrapper class constructors (ConstantBuffer, StructuredBuffer, Buffer, Texture1D, Texture2D, Texture3D); view creation methods (CreateSRV/UAV/RTV/DSV) automatically append " SRV" / " UAV" etc. to the base name. detail::SetD3DName delegates to Util::SetResourceName via a forward declaration, keeping the GUID definition in one place (D3D.cpp).No behaviour change; naming calls are init-time only with zero per-frame overhead.
Summary by CodeRabbit