Skip to content
This repository has been archived by the owner on Mar 30, 2019. It is now read-only.

DepthStencilState.DebugNames not being assigned correctly #358

Closed
Gavin-Williams opened this issue Apr 26, 2014 · 5 comments
Closed

DepthStencilState.DebugNames not being assigned correctly #358

Gavin-Williams opened this issue Apr 26, 2014 · 5 comments

Comments

@Gavin-Williams
Copy link
Contributor

Hi,

I've got a problem with my DepthStencilState objects. I am receiving the following warnings:

D3D11 WARNING: ID3D11DepthStencilState::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS]
D3D11 WARNING: ID3D11DepthStencilState::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS]

And when i look at the object table in graphics diagnostics I see that the DepthStencilState has a DebugName="None", although I'm setting DebugName="DepthStencilState.DepthOn" etc. When I inspect my DepthStencilStates collection, they have the DebugNames I gave them.

I have my DepthStencilStates collection inheriting from Dictionary, with some default states added in the constructor. Here's the code:

public class DepthStencilStates : Dictionary<string,DepthStencilState>
{
    /// <summary>
    /// Setup default DepthStencilStates: DepthOn, DepthOff
    /// </summary>
    /// <param name="window"></param>
    public DepthStencilStates(Window window) : base()
    {
        DepthStencilOperationDescription frontFaceOp = new DepthStencilOperationDescription()
        {
            Comparison = Comparison.Always,
            DepthFailOperation = StencilOperation.Decrement,
            FailOperation = StencilOperation.Keep,
            PassOperation = StencilOperation.Keep
        };

        DepthStencilOperationDescription backFaceOp = new DepthStencilOperationDescription()
        {
            Comparison = Comparison.Always,
            DepthFailOperation = StencilOperation.Decrement,
            FailOperation = StencilOperation.Keep,
            PassOperation = StencilOperation.Keep
        };

        // depth on
        DepthStencilStateDescription dsStateDesc = new DepthStencilStateDescription()
        {
            // depth test parameters
            IsDepthEnabled = true,
            DepthWriteMask = DepthWriteMask.All,
            DepthComparison = Comparison.Less,

            // stencil test parameters
            IsStencilEnabled = false,
            StencilReadMask = 0xFF,
            StencilWriteMask = 0xFF,

            // stencil operations if pixel is front-facing
            FrontFace = frontFaceOp,

            // stencil operations if pixel is back-facing
            BackFace = backFaceOp
        };

        DepthStencilState depthStateOn = new DepthStencilState(window.Device3D, dsStateDesc);
        depthStateOn.DebugName = "DepthStencilState.DepthOn";
        this.Add(depthStateOn.DebugName, depthStateOn);

        // depth off
        dsStateDesc = new DepthStencilStateDescription()
        {
            // depth test parameters
            IsDepthEnabled = false,
            DepthWriteMask = DepthWriteMask.All,
            DepthComparison = Comparison.Less,

            // stencil test parameters
            IsStencilEnabled = false,
            StencilReadMask = 0xFF,
            StencilWriteMask = 0xFF,

            // stencil operations if pixel is front-facing
            FrontFace = frontFaceOp,

            // stencil operations if pixel is back-facing
            BackFace = backFaceOp
        };

        DepthStencilState depthStateOff = new DepthStencilState(window.Device3D, dsStateDesc);
        depthStateOff.DebugName = "DepthStencilState.DepthOff";
        this.Add(depthStateOff.DebugName, depthStateOff);
    }
}

I have searched and there are no other calls to new DepthStencilState in my solution. So there is no-where that I could be creating extra unnamed states. It seems that the wrapper is not applying the debug names to the gpu resource, although it is storing the name and returning it on the managed side.

@xoofx
Copy link
Member

xoofx commented Apr 26, 2014

I can't reproduce this. Looks like more likely an installation problem of the debug layer. I'm not sure it is related to ReportLiveObjects() isn't giving me enough information., but native DX debug layer seems to be somehow broken with latest upgrade and we can't fix this on SharpDX side.

@xoofx xoofx closed this as completed Apr 26, 2014
@Gavin-Williams
Copy link
Contributor Author

Could this be a 2.5.0 issue ?

@xoofx
Copy link
Member

xoofx commented Apr 27, 2014

Oh, could be yes, 2.5.0 is almost one year old and lots of fixes came into the repository since then.

@Gavin-Williams
Copy link
Contributor Author

Hmmm, still having some problems here, even after switching from 2.5.0 to DX11.2 via git master branch. This is a tricky one, and terribly frustrating for me. Even after disposing all my render states, one of which has a debug name of "DepthOn", I am still seeing the following line in the live object report...

D3D11 WARNING: Live ID3D11DepthStencilState at 0x0090708C, Name: DepthOn, Refcount: 0, IntRef: 1 [ STATE_CREATION WARNING #436: LIVE_DEPTHSTENCILSTATE]

None of my other render-states are still alive. And I still have that warning up top ...

D3D11 WARNING: ID3D11DepthStencilState::SetPrivateData: Existing private data of same name with different size found! [ STATE_SETTING WARNING #55: SETPRIVATEDATA_CHANGINGPARAMS]

I can't help but think these warnings are indicative of a common problem. A name not being set properly or something.

I have noticed that in the source code there is the following comment:

If an application attempts to create a rasterizer-state interface with the same state as an existing interface, the same interface will be returned and the total number of unique rasterizer state objects will stay the same.

So what I think is happening, is when I create a new DepthStencilState, I'm getting back one that already exists (maybe as part of the device or toolkit or spritebatch), and I'm then renaming it's debugName. But why then is it not disposed still.

@xoofx
Copy link
Member

xoofx commented Apr 27, 2014

I would not bother much about these warnings. The state has an external RefCount of 0, so your application does not hold a reference to it, only some internals of D3D11. But as it is just a state, that's not a big issue.

Waning for debug names are also just warning, you can ignore them (as explained in Direct3D SDK Debug Layer Tricks )

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants