Commit d809147f by Rafael Cintron Committed by Commit Bot

Enable D3D11 debug names in ANGLE release builds

Previously, D3D11 debug names were only output in debug builds. This change enables them in release builds so we can debug GPU memory consumption given traces or full memory dumps. Where it made sense, existing names were shortened for brevity. A future CL can shorten the names further by removing the words texture, SRV, DSV, etc since D3D already outputs this type information. Bug: chromium:1164111 Change-Id: Iadd6222c29dd945115e844ec28ee395ce16c139f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2780564 Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 90e3d86c
...@@ -272,7 +272,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(DisplayD3D *displayD3D, ...@@ -272,7 +272,7 @@ EGLint SwapChain11::resetOffscreenColorBuffer(DisplayD3D *displayD3D,
return EGL_BAD_ALLOC; return EGL_BAD_ALLOC;
} }
mOffscreenTexture.setDebugName("Offscreen back buffer texture"); mOffscreenTexture.setDebugName("OffscreenBackBufferTexture");
// EGL_ANGLE_surface_d3d_texture_2d_share_handle requires that we store a share handle for // EGL_ANGLE_surface_d3d_texture_2d_share_handle requires that we store a share handle for
// the client // the client
...@@ -416,7 +416,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(DisplayD3D *displayD3D, ...@@ -416,7 +416,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(DisplayD3D *displayD3D,
release(); release();
return EGL_BAD_ALLOC; return EGL_BAD_ALLOC;
} }
mDepthStencilTexture.setDebugName("Offscreen depth stencil texture"); mDepthStencilTexture.setDebugName("OffscreenDepthStencilTexture");
D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc; D3D11_DEPTH_STENCIL_VIEW_DESC depthStencilDesc;
depthStencilDesc.Format = depthBufferFormatInfo.dsvFormat; depthStencilDesc.Format = depthBufferFormatInfo.dsvFormat;
...@@ -428,7 +428,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(DisplayD3D *displayD3D, ...@@ -428,7 +428,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(DisplayD3D *displayD3D,
result = mRenderer->allocateResource(displayD3D, depthStencilDesc, result = mRenderer->allocateResource(displayD3D, depthStencilDesc,
mDepthStencilTexture.get(), &mDepthStencilDSView); mDepthStencilTexture.get(), &mDepthStencilDSView);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mDepthStencilDSView.setDebugName("Offscreen depth stencil view"); mDepthStencilDSView.setDebugName("OffscreenDSV");
if (depthStencilSRV) if (depthStencilSRV)
{ {
...@@ -443,7 +443,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(DisplayD3D *displayD3D, ...@@ -443,7 +443,7 @@ EGLint SwapChain11::resetOffscreenDepthBuffer(DisplayD3D *displayD3D,
result = mRenderer->allocateResource(displayD3D, depthStencilSRVDesc, result = mRenderer->allocateResource(displayD3D, depthStencilSRVDesc,
mDepthStencilTexture.get(), &mDepthStencilSRView); mDepthStencilTexture.get(), &mDepthStencilSRView);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mDepthStencilSRView.setDebugName("Offscreen depth stencil shader resource"); mDepthStencilSRView.setDebugName("OffscreenDepthStencilSRV");
} }
} }
...@@ -517,17 +517,17 @@ EGLint SwapChain11::resize(DisplayD3D *displayD3D, EGLint backbufferWidth, EGLin ...@@ -517,17 +517,17 @@ EGLint SwapChain11::resize(DisplayD3D *displayD3D, EGLint backbufferWidth, EGLin
const auto &format = const auto &format =
d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps());
mBackBufferTexture.set(backbufferTexture, format); mBackBufferTexture.set(backbufferTexture, format);
mBackBufferTexture.setDebugName("Back buffer texture"); mBackBufferTexture.setDebugName("BackBufferTexture");
angle::Result result = mRenderer->allocateResourceNoDesc( angle::Result result = mRenderer->allocateResourceNoDesc(
displayD3D, mBackBufferTexture.get(), &mBackBufferRTView); displayD3D, mBackBufferTexture.get(), &mBackBufferRTView);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mBackBufferRTView.setDebugName("Back buffer render target"); mBackBufferRTView.setDebugName("BackBufferRTV");
result = mRenderer->allocateResourceNoDesc(displayD3D, mBackBufferTexture.get(), result = mRenderer->allocateResourceNoDesc(displayD3D, mBackBufferTexture.get(),
&mBackBufferSRView); &mBackBufferSRView);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mBackBufferSRView.setDebugName("Back buffer shader resource"); mBackBufferSRView.setDebugName("BackBufferSRV");
} }
mFirstSwap = true; mFirstSwap = true;
...@@ -638,17 +638,17 @@ EGLint SwapChain11::reset(DisplayD3D *displayD3D, ...@@ -638,17 +638,17 @@ EGLint SwapChain11::reset(DisplayD3D *displayD3D,
const auto &format = const auto &format =
d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps()); d3d11::Format::Get(mOffscreenRenderTargetFormat, mRenderer->getRenderer11DeviceCaps());
mBackBufferTexture.set(backbufferTex, format); mBackBufferTexture.set(backbufferTex, format);
mBackBufferTexture.setDebugName("Back buffer texture"); mBackBufferTexture.setDebugName("BackBufferTexture");
angle::Result result = mRenderer->allocateResourceNoDesc( angle::Result result = mRenderer->allocateResourceNoDesc(
displayD3D, mBackBufferTexture.get(), &mBackBufferRTView); displayD3D, mBackBufferTexture.get(), &mBackBufferRTView);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mBackBufferRTView.setDebugName("Back buffer render target"); mBackBufferRTView.setDebugName("BackBufferRTV");
result = mRenderer->allocateResourceNoDesc(displayD3D, mBackBufferTexture.get(), result = mRenderer->allocateResourceNoDesc(displayD3D, mBackBufferTexture.get(),
&mBackBufferSRView); &mBackBufferSRView);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mBackBufferSRView.setDebugName("Back buffer shader resource view"); mBackBufferSRView.setDebugName("BackBufferSRV");
} }
mFirstSwap = true; mFirstSwap = true;
...@@ -681,7 +681,7 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D) ...@@ -681,7 +681,7 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D)
vbDesc.StructureByteStride = 0; vbDesc.StructureByteStride = 0;
ANGLE_TRY(mRenderer->allocateResource(displayD3D, vbDesc, &mQuadVB)); ANGLE_TRY(mRenderer->allocateResource(displayD3D, vbDesc, &mQuadVB));
mQuadVB.setDebugName("Swap chain quad vertex buffer"); mQuadVB.setDebugName("SwapChainQuadVB");
D3D11_SAMPLER_DESC samplerDesc; D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
...@@ -699,7 +699,7 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D) ...@@ -699,7 +699,7 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D)
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX; samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
ANGLE_TRY(mRenderer->allocateResource(displayD3D, samplerDesc, &mPassThroughSampler)); ANGLE_TRY(mRenderer->allocateResource(displayD3D, samplerDesc, &mPassThroughSampler));
mPassThroughSampler.setDebugName("Swap chain pass through sampler"); mPassThroughSampler.setDebugName("SwapChainPassThroughSampler");
D3D11_INPUT_ELEMENT_DESC quadLayout[] = { D3D11_INPUT_ELEMENT_DESC quadLayout[] = {
{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
...@@ -711,10 +711,10 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D) ...@@ -711,10 +711,10 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D)
ANGLE_TRY( ANGLE_TRY(
mRenderer->allocateResource(displayD3D, quadElements, &vertexShaderData, &mPassThroughIL)); mRenderer->allocateResource(displayD3D, quadElements, &vertexShaderData, &mPassThroughIL));
mPassThroughIL.setDebugName("Swap chain pass through layout"); mPassThroughIL.setDebugName("SwapChainPassThroughIL");
ANGLE_TRY(mRenderer->allocateResource(displayD3D, vertexShaderData, &mPassThroughVS)); ANGLE_TRY(mRenderer->allocateResource(displayD3D, vertexShaderData, &mPassThroughVS));
mPassThroughVS.setDebugName("Swap chain pass through vertex shader"); mPassThroughVS.setDebugName("SwapChainPassThroughVS");
if (mEGLSamples <= 1) if (mEGLSamples <= 1)
{ {
...@@ -738,7 +738,7 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D) ...@@ -738,7 +738,7 @@ angle::Result SwapChain11::initPassThroughResources(DisplayD3D *displayD3D)
} }
} }
mPassThroughOrResolvePS.setDebugName("Swap chain pass through pixel shader"); mPassThroughOrResolvePS.setDebugName("SwapChainPassThroughPS");
// Use the default rasterizer state but without culling // Use the default rasterizer state but without culling
D3D11_RASTERIZER_DESC rasterizerDesc; D3D11_RASTERIZER_DESC rasterizerDesc;
...@@ -977,7 +977,7 @@ const d3d11::SharedSRV &SwapChain11::getRenderTargetShaderResource(d3d::Context ...@@ -977,7 +977,7 @@ const d3d11::SharedSRV &SwapChain11::getRenderTargetShaderResource(d3d::Context
angle::Result result = mRenderer->allocateTexture( angle::Result result = mRenderer->allocateTexture(
context, offscreenCopyDesc, backbufferFormatInfo, &mOffscreenTextureCopyForSRV); context, offscreenCopyDesc, backbufferFormatInfo, &mOffscreenTextureCopyForSRV);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mOffscreenTextureCopyForSRV.setDebugName("Offscreen back buffer copy for SRV"); mOffscreenTextureCopyForSRV.setDebugName("OffscreenBackBufferCopyForSRV");
D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc; D3D11_SHADER_RESOURCE_VIEW_DESC offscreenSRVDesc;
offscreenSRVDesc.Format = backbufferFormatInfo.srvFormat; offscreenSRVDesc.Format = backbufferFormatInfo.srvFormat;
...@@ -989,7 +989,7 @@ const d3d11::SharedSRV &SwapChain11::getRenderTargetShaderResource(d3d::Context ...@@ -989,7 +989,7 @@ const d3d11::SharedSRV &SwapChain11::getRenderTargetShaderResource(d3d::Context
result = mRenderer->allocateResource(context, offscreenSRVDesc, result = mRenderer->allocateResource(context, offscreenSRVDesc,
mOffscreenTextureCopyForSRV.get(), &mOffscreenSRView); mOffscreenTextureCopyForSRV.get(), &mOffscreenSRView);
ASSERT(result != angle::Result::Stop); ASSERT(result != angle::Result::Stop);
mOffscreenSRView.setDebugName("Offscreen back buffer shader resource"); mOffscreenSRView.setDebugName("OffscreenBackBufferSRV");
} }
// Need to copy the offscreen texture into the shader-readable copy, since it's external and // Need to copy the offscreen texture into the shader-readable copy, since it's external and
......
...@@ -2273,7 +2273,6 @@ bool operator!=(const RasterizerStateKey &a, const RasterizerStateKey &b) ...@@ -2273,7 +2273,6 @@ bool operator!=(const RasterizerStateKey &a, const RasterizerStateKey &b)
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name) HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
{ {
#if defined(_DEBUG)
UINT existingDataSize = 0; UINT existingDataSize = 0;
resource->GetPrivateData(WKPDID_D3DDebugObjectName, &existingDataSize, nullptr); resource->GetPrivateData(WKPDID_D3DDebugObjectName, &existingDataSize, nullptr);
// Don't check the HRESULT- if it failed then that probably just means that no private data // Don't check the HRESULT- if it failed then that probably just means that no private data
...@@ -2285,28 +2284,22 @@ HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name) ...@@ -2285,28 +2284,22 @@ HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
// a D3D SDK Layers warning. This can occur if, for example, you 'create' two objects // a D3D SDK Layers warning. This can occur if, for example, you 'create' two objects
// (e.g.Rasterizer States) with identical DESCs on the same device. D3D11 will optimize // (e.g.Rasterizer States) with identical DESCs on the same device. D3D11 will optimize
// these calls and return the same object both times. // these calls and return the same object both times.
static const char *multipleNamesUsed = "Multiple names set by ANGLE"; static const char *multipleNamesUsed = "MultipleNamesSetByANGLE";
// Remove the existing name // Remove the existing name
HRESULT hr = resource->SetPrivateData(WKPDID_D3DDebugObjectName, 0, nullptr); const HRESULT hr = resource->SetPrivateData(WKPDID_D3DDebugObjectName, 0, nullptr);
if (FAILED(hr)) if (FAILED(hr))
{ {
return hr; return hr;
} }
// Apply the new name name = multipleNamesUsed;
return resource->SetPrivateData(WKPDID_D3DDebugObjectName,
static_cast<unsigned int>(strlen(multipleNamesUsed)),
multipleNamesUsed);
} }
else
{ // Prepend ANGLE_ to separate names from other components in the same process.
return resource->SetPrivateData(WKPDID_D3DDebugObjectName, const std::string d3dName = std::string("ANGLE_") + name;
static_cast<unsigned int>(strlen(name)), name); return resource->SetPrivateData(WKPDID_D3DDebugObjectName, static_cast<UINT>(d3dName.size()),
} d3dName.c_str());
#else
return S_OK;
#endif
} }
// Keep this in cpp file where it has visibility of Renderer11.h, otherwise calling // Keep this in cpp file where it has visibility of Renderer11.h, otherwise calling
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment