• Advertisement
Sign in to follow this  

[SlimDX] Shadow Map

This topic is 2402 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

Hi everybody,

I try creating a shadow map in SlimDX using this tutorial

[url="http://takinginitiative.net/2011/05/15/directx10-tutorial-10-shadow-mapping/"]http://takinginitiat...shadow-mapping/[/url]

Whenever I create Texture2D for the shadow map I get [i]System.NullReferenceException[/i].

The relevant part of the code is here

[code]
Texture2DDescription shadowMapTexDesc = new Texture2DDescription()
{
Width = form.ClientSize.Width,
Height = form.ClientSize.Height,
MipLevels = 1,
ArraySize = 1,
Format = Format.R32_Typeless,
SampleDescription = swapDesc.SampleDescription,
Usage = ResourceUsage.Default,
BindFlags = BindFlags.DepthStencil | BindFlags.ShaderResource,
CpuAccessFlags = CpuAccessFlags.None,
OptionFlags = ResourceOptionFlags.None
};
shadowMap = new Texture2D(device, shadowMapTexDesc); // the exception is raised here

[/code]
Anybody knows what I'm doing wrong?
I'm using DirectX11.


Ryvola

Share this post


Link to post
Share on other sites
Advertisement
Quick guess: Format is wrong to me. Shouldn't that be R32F or D24? I would assume D24 after taking into account you have DepthStencil bind flag.
btw: what does the DX debugger says?

Share this post


Link to post
Share on other sites
Maxest,
thank you for your quick answer.

[quote name='maxest' timestamp='1308831938' post='4826743']
Quick guess: Format is wrong to me. Shouldn't that be R32F or D24? I would assume D24 after taking into account you have DepthStencil bind flag.
[/quote]

All these formats give me the same exception. :(


[quote name='maxest' timestamp='1308831938' post='4826743']
btw: what does the DX debugger says?

[/quote]

Is it this? (I'm still new to DirectX)


[code]
An unhandled exception of type 'SlimDX.Direct3D11.Direct3D11Exception' occurred in SlimDX.dll
Additional information: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)
[/code]



Edit:


I've got additional info from debugger:

[code]D3D11: ERROR: ID3D11Device::CreateTexture2D: If the device interface is D3D10.0 or the driver/hardware are D3D10.0 (regardless of API version),

a Texture2D with sample count > 1 cannot have both D3D11_BIND_DEPTH_STENCIL and D3D11_BIND_SHADER_RESOURCE.

This call may appear to incorrectly return success on older/current D3D runtimes due to missing validation, despite this debug layer message.

[ STATE_CREATION ERROR #99: CREATETEXTURE2D_INVALIDBINDFLAGS ][/code]



Does it mean I can't run it on DX10.0 graphics card?


Ryvola

Share this post


Link to post
Share on other sites
It says right in the message that a 2D texture with a sample count of greater than 1 cannot have both BindFlags.DepthStencil and BindFlags.ShaderResource set on it.

Share this post


Link to post
Share on other sites
Yes, running this code on DX10.0 hardware doesn't allow to use more than 1 sample count. On DX11 hardware this code runs smoothly.

Thank you for helping me.

Ryvola

Share this post


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

  • Advertisement