Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualMatthew Meeks

Posted 08 January 2013 - 08:23 PM

Nevermind passed the wrong description.


#2Matthew Meeks

Posted 08 January 2013 - 08:10 PM

So... this is probably a dumb question but how would I go about binding a depth buffer as a shader resource?

 

I tried this:


            Texture2DDescription shadowBufferDesc = new Texture2DDescription
            {
                ArraySize = 1,
                BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = Format.R32_Typeless,
                Height = 512,
                Width = 512,
                MipLevels = 1,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default
            };
 
            var shadowBuffer = new Texture2D(device, depthBufferDesc);
            var shadowView = new DepthStencilView(device, shadowBuffer, new DepthStencilViewDescription()
            {
                Format = Format.D32_Float,
                Dimension = DepthStencilViewDimension.Texture2D,
                MipSlice = 0,
            });
            shadowSView = new ShaderResourceView(device, shadowBuffer, new ShaderResourceViewDescription()
            {
                Format = Format.R32_Float,
                Dimension = ShaderResourceViewDimension.Texture2D,
                MostDetailedMip = 0,
                MipLevels = 1,
            });

 

with depthFormat being d32 float but it throws an error at creation of the resource view I believe referring to the format.

 

I was able to retrieve this error with DebugView:

 

[5812] D3D11: ERROR: ID3D11Device::CreateShaderResourceView: The Format (0x29, R32_FLOAT) is invalid, when creating a View; the Resource was already created with a fully qualified Format, which is not castable (0x28, D32_FLOAT). [ STATE_CREATION ERROR #127: CREATESHADERRESOURCEVIEW_INVALIDFORMAT ]
 
Why is this error happening when i create two separate views to the texture?

#1Matthew Meeks

Posted 08 January 2013 - 07:11 PM

So... this is probably a dumb question but how would I go about binding a depth buffer as a shader resource?

 

I tried this:

            Texture2DDescription shadowBufferDesc = new Texture2DDescription
            {
                ArraySize = 1,
                BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
                CpuAccessFlags = CpuAccessFlags.None,
                Format = depthFormat,
                Height = 512,
                Width = 512,
                MipLevels = 1,
                OptionFlags = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage = ResourceUsage.Default
            };

            var shadowBuffer = new Texture2D(device, depthBufferDesc);
            var shadowView = new DepthStencilView(device, shadowBuffer, new DepthStencilViewDescription()
            {
                Format = depthFormat,
                Dimension = DepthStencilViewDimension.Texture2D,
                MipSlice = 0,
            });
            shadowSView = new ShaderResourceView(device, shadowBuffer, new ShaderResourceViewDescription()
            {
                Format = Format.R32_Float,
                Dimension = ShaderResourceViewDimension.Texture2D,
                MostDetailedMip = 0,
                MipLevels = 1,
            });

 

with depthFormat being d32 float but it throws an error at creation of the resource view I believe referring to the format.


PARTNERS