D3D12: Enable D3D12 debug names in Dawn builds.

Labels GPU allocations by Dawn resource type so we
can debug GPU memory consumption given traces or
full memory dumps.

BUG=dawn:967

Change-Id: I7eb19b4f2f9dd4c55c9039d39ffec9f09461556f
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/60620
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
This commit is contained in:
Bryan Bernhart 2021-08-04 21:52:29 +00:00 committed by Dawn LUCI CQ
parent b5e2089768
commit 18bc89ee62
5 changed files with 20 additions and 0 deletions

View File

@ -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) &&

View File

@ -14,6 +14,7 @@
#include "dawn_native/d3d12/ResourceHeapAllocationD3D12.h"
#include "dawn_native/d3d12/D3D12Error.h"
#include "dawn_native/d3d12/HeapD3D12.h"
#include <utility>
@ -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

View File

@ -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;

View File

@ -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(

View File

@ -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 {};
}