Jump to content

  • Log In with Google      Sign In   
  • Create Account


brasslips2

Member Since 27 Sep 2008
Offline Last Active May 26 2013 07:04 PM
-----

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

Posted by brasslips2 on 03 October 2011 - 04:26 AM

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[i].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[i].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!


PARTNERS