diff --git a/src/dawn_native/d3d12/BufferD3D12.cpp b/src/dawn_native/d3d12/BufferD3D12.cpp index b24a7a21e0..aea387e102 100644 --- a/src/dawn_native/d3d12/BufferD3D12.cpp +++ b/src/dawn_native/d3d12/BufferD3D12.cpp @@ -147,6 +147,8 @@ namespace dawn_native { namespace d3d12 { mResourceAllocation, ToBackend(GetDevice())->AllocateMemory(heapType, resourceDescriptor, bufferUsage)); + DAWN_TRY(mResourceAllocation.SetDebugName("Dawn_Buffer")); + // The buffers with mappedAtCreation == true will be initialized in // BufferBase::MapAtCreation(). if (GetDevice()->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting) && diff --git a/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.cpp b/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.cpp index edf21c1e06..10a43d8076 100644 --- a/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.cpp +++ b/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.cpp @@ -14,6 +14,7 @@ #include "dawn_native/d3d12/ResourceHeapAllocationD3D12.h" +#include "dawn_native/d3d12/D3D12Error.h" #include "dawn_native/d3d12/HeapD3D12.h" #include @@ -39,4 +40,11 @@ namespace dawn_native { namespace d3d12 { D3D12_GPU_VIRTUAL_ADDRESS ResourceHeapAllocation::GetGPUPointer() const { return mResource->GetGPUVirtualAddress(); } + + MaybeError ResourceHeapAllocation::SetDebugName(const char* name) { + DAWN_TRY(CheckHRESULT( + mResource->SetPrivateData(WKPDID_D3DDebugObjectName, std::strlen(name), name), + "ID3D12Resource::SetName")); + return {}; + } }} // namespace dawn_native::d3d12 diff --git a/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.h b/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.h index 1bdaf2511c..892a72cc4e 100644 --- a/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.h +++ b/src/dawn_native/d3d12/ResourceHeapAllocationD3D12.h @@ -15,6 +15,7 @@ #ifndef DAWNNATIVE_D3D12_RESOURCEHEAPALLOCATIOND3D12_H_ #define DAWNNATIVE_D3D12_RESOURCEHEAPALLOCATIOND3D12_H_ +#include "dawn_native/Error.h" #include "dawn_native/ResourceMemoryAllocation.h" #include "dawn_native/d3d12/d3d12_platform.h" @@ -34,6 +35,7 @@ namespace dawn_native { namespace d3d12 { ResourceHeapAllocation& operator=(const ResourceHeapAllocation&) = default; void Invalidate() override; + MaybeError SetDebugName(const char* name); ID3D12Resource* GetD3D12Resource() const; D3D12_GPU_VIRTUAL_ADDRESS GetGPUPointer() const; diff --git a/src/dawn_native/d3d12/StagingBufferD3D12.cpp b/src/dawn_native/d3d12/StagingBufferD3D12.cpp index 11c612ba82..d525276a4c 100644 --- a/src/dawn_native/d3d12/StagingBufferD3D12.cpp +++ b/src/dawn_native/d3d12/StagingBufferD3D12.cpp @@ -42,6 +42,8 @@ namespace dawn_native { namespace d3d12 { mDevice->AllocateMemory(D3D12_HEAP_TYPE_UPLOAD, resourceDescriptor, D3D12_RESOURCE_STATE_GENERIC_READ)); + DAWN_TRY(mUploadHeap.SetDebugName("Dawn_StagingBuffer")); + // The mapped buffer can be accessed at any time, so it must be locked to ensure it is never // evicted. This buffer should already have been made resident when it was created. DAWN_TRY(mDevice->GetResidencyManager()->LockAllocation( diff --git a/src/dawn_native/d3d12/TextureD3D12.cpp b/src/dawn_native/d3d12/TextureD3D12.cpp index d76e021d3b..e269dafa50 100644 --- a/src/dawn_native/d3d12/TextureD3D12.cpp +++ b/src/dawn_native/d3d12/TextureD3D12.cpp @@ -481,6 +481,8 @@ namespace dawn_native { namespace d3d12 { // memory management. mResourceAllocation = {info, 0, std::move(d3d12Texture), nullptr}; + DAWN_TRY(mResourceAllocation.SetDebugName("Dawn_ExternalTexture")); + return {}; } @@ -517,6 +519,8 @@ namespace dawn_native { namespace d3d12 { ->AllocateMemory(D3D12_HEAP_TYPE_DEFAULT, resourceDescriptor, D3D12_RESOURCE_STATE_COMMON)); + DAWN_TRY(mResourceAllocation.SetDebugName("Dawn_InternalTexture")); + Device* device = ToBackend(GetDevice()); if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) { @@ -537,6 +541,8 @@ namespace dawn_native { namespace d3d12 { // texture is owned externally. The texture's owning entity must remain responsible for // memory management. mResourceAllocation = {info, 0, std::move(d3d12Texture), nullptr}; + + DAWN_TRY(mResourceAllocation.SetDebugName("Dawn_SwapChainTexture")); return {}; }