Jump to content
  • Advertisement
Sign in to follow this  
brasslips2

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

This topic is 2477 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Hidden
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!