[DX 11] object names for debugging & warnings using Effects

Started by
6 comments, last by MJP 12 years, 6 months ago
When I call release on my effects object like the following:

ID3DX11Effect *effect;
hr = D3DX11CreateEffectFromMemory(effectBlob->GetBufferPointer(),
effectBlob->GetBufferSize(), 0,
pDevice, &effect);
...
effect->Release()
------------------

I get the following output after I step over the release of the effect shown above


D3D11: INFO: Destroy Buffer: Name="unnamed", Addr=0x0049F67C [ STATE_CREATION INFO #2097230: DESTROY_BUFFER ]
D3D11: INFO: Destroy VertexShader: Name="unnamed", Addr=0x0049F8DC [ STATE_CREATION INFO #2097251: DESTROY_VERTEXSHADER ]
D3D11: INFO: Destroy PixelShader: Name="unnamed", Addr=0x0049C23C [ STATE_CREATION INFO #2097263: DESTROY_PIXELSHADER ]

I know I'm supposed to call the following...

DXUT_SetDebugName(object, "object name");

I have also created my device with the correct debug flag as such:

D3D11_CREATE_DEVICE_DEBUG;

However, since I'm using effects what object do i pass into my SetDebugName function to fix the above "unnamed" values and how do I get that object from the effect?
Advertisement
Another weird thing is that when I run pix I get the following:
D3D11: WARNING: ID3D11Buffer::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS ]

If I comment out all of my calls to DXUT_SetDebugName I still get that warning. I have also checked for SetPrivateData, but there are no calls being made that I haven't commented out.
Anyone? I'm still having this issue.
You should be using SetPrivateData() to set a custom "debug name".
Take a look here.
[color=#1C2837][size=2]DXUT_SetDebugName calls SetPrivateData on the object... thanks, but that doesn't really help.
Those are objects created by the effect. The first is a buffer (probably a constant buffer), the second is a vertex shader, and the third is a pixel shader. There could be even more of these objects in an effect, depending on how many techniques and passes you have. I know you can access constant buffers through GetConstantBufferByIndex and GetConstantBufferByName, but I don't think there's any way to access the underlying shaders.

Of course, since you have the Effects11 source code you could always modify it to set the debug names or to provide access to the shaders.

Those are objects created by the effect. The first is a buffer (probably a constant buffer), the second is a vertex shader, and the third is a pixel shader. There could be even more of these objects in an effect, depending on how many techniques and passes you have. I know you can access constant buffers through GetConstantBufferByIndex and GetConstantBufferByName, but I don't think there's any way to access the underlying shaders.

Of course, since you have the Effects11 source code you could always modify it to set the debug names or to provide access to the shaders.


Thanks, I was wondering why it wasn't very straight forward. I guess I'm off to editing the effects framework then... sigh =(
Well, here's my implementation if anyone is wanting this for their project. Big thanks to MJP for leading me in the right direction. He was right that the constant buffers are accessible but the shaders aren't. Below is some code that I wrote to add debug names to the shaders. You'd do similar stuff for hull, computer shaders, etc. I can't guarantee that my way is the best way to do it. But it works nevertheless. Hope it helps if anyone was in the same boat as I was...

---The added Code to Effect..

d3dx11effect.h(ID3DX11Effect ~1524)
STDMETHOD_(HRESULT, GetVertexShader)(THIS_ ID3D11VertexShader **ppVS) PURE;
STDMETHOD_(HRESULT, GetPixelShader)(THIS_ ID3D11PixelShader **ppPS) PURE;



Effect.h(CEffect ~1219)
STDMETHOD_(HRESULT, GetVertexShader)(ID3D11VertexShader **ppVS);
STDMETHOD_(HRESULT, GetPixelShader)(ID3D11PixelShader **ppPS);



EffectReflection.cpp(2151)HRESULT CEffect::GetVertexShader(ID3D11VertexShader **ppVS)
{
if(m_pShaderBlocks != NULL)
{
for(UINT i = 0; i < m_ShaderBlockCount; ++i)
{
if(m_pShaderBlocks.GetVertexShader(ppVS) == S_OK)
{
return S_OK;
}
}
}
return S_FALSE;
}
HRESULT CEffect::GetPixelShader(ID3D11PixelShader **ppPS)
{
if(m_pShaderBlocks != NULL)
{
for(UINT i = 0; i < m_ShaderBlockCount; ++i)
{
if(m_pShaderBlocks.GetPixelShader(ppPS) == S_OK)
{
return S_OK;
}
}
}
return S_FALSE;}

---------- Using the code...
// Set the vertex shader name
ID3D11VertexShader* pVertexShader;
effect->GetVertexShader(&pVertexShader);
DXUT_SetDebugName(pVertexShader, YOUR_DEBUG_NAME);
SAFE_RELEASE(pVertexShader);

// Set the pixel shader name
ID3D11PixelShader* pPixelShader;
effect->GetPixelShader(&pPixelShader);
DXUT_SetDebugName(pPixelShader, YOUR_DEBUG_NAME);
SAFE_RELEASE(pPixelShader);

// Set the debug name for the constant buffers
UINT bufferIndex = 0;
ID3DX11EffectConstantBuffer* cBuffer = effect->GetConstantBufferByIndex(bufferIndex);
while(cBuffer->IsValid())
{
ID3D11Buffer* ccBuffer;
cBuffer->GetConstantBuffer(&ccBuffer);
DXUT_SetDebugName(ccBuffer, YOUR_DEBUG_NAME);
SAFE_RELEASE(ccBuffer);
cBuffer = effect->GetConstantBufferByIndex(++bufferIndex);
}


------
VUALA IT WORKS!
Thanks for sharing that here!

This topic is closed to new replies.

Advertisement