Jump to content

  • Log In with Google      Sign In   
  • Create Account

[SlimDX] Shadow Map


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Ryvola   Members   -  Reputation: 100

Like
0Likes
Like

Posted 23 June 2011 - 06:15 AM

Hi everybody,

I try creating a shadow map in SlimDX using this tutorial

http://takinginitiat...shadow-mapping/

Whenever I create Texture2D for the shadow map I get System.NullReferenceException.

The relevant part of the code is here

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

Anybody knows what I'm doing wrong?
I'm using DirectX11.


Ryvola

Sponsor:

#2 maxest   Members   -  Reputation: 294

Like
1Likes
Like

Posted 23 June 2011 - 06:25 AM

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?

#3 Ryvola   Members   -  Reputation: 100

Like
0Likes
Like

Posted 23 June 2011 - 06:52 AM

Maxest,
thank you for your quick answer.

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.


All these formats give me the same exception. :(


btw: what does the DX debugger says?


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


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)



Edit:


I've got additional info from debugger:

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 ]



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


Ryvola

#4 Mike.Popoloski   Crossbones+   -  Reputation: 2931

Like
1Likes
Like

Posted 23 June 2011 - 09:43 AM

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.

Mike Popoloski | Journal | SlimDX

#5 Ryvola   Members   -  Reputation: 100

Like
0Likes
Like

Posted 23 June 2011 - 11:59 PM

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

#6 MJP   Moderators   -  Reputation: 11736

Like
1Likes
Like

Posted 24 June 2011 - 12:45 AM

You need FEATURE_LEVEL_10_1 to sample a multisampled depth buffer.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS