Sign in to follow this  
janta

Capability to alpha test/blend on a R32F rendertarget

Recommended Posts

Hey, quick question: I can't find the DirectX caps to check in order to determine whether a particular card supports alpha blending/testing on a D3DFMT_R32F rendertarget. Any idea people? Thanks! -JA

Share this post


Link to post
Share on other sites
Call IDirect3D9::CheckDeviceFormat with D3DUSAGE_RENDERTARGET and D3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING as the Usage parameter. BTW I believe only DX10-class GPU's can blend this format.

Share this post


Link to post
Share on other sites
Looks like I talked way to fast.
The following code:

D3D->CheckDeviceFormat(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
D3DFMT_X8B8G8R8,
D3DUSAGE_RENDERTARGET | 3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING,
D3DRTYPE_SURFACE, // or D3DRTYPE_TEXTURE, same results
D3DFMT_R32F);


returns D3DERR_NOTAVAILABLE on both a ATI Radeon X1800 and a ATI HD 2600.
In fact i realize that this query might not be exactly what I want. All I need is support for alpha TESTING, whereas 3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING queris about support for "alpha test, pixel fog, render-target blending, color write enable, and dithering"

I'm rendering some alpha tested foliage quads to my shadowmap, and on the HD 2600, everything is perfectly OK

Any ideas?

Thanks
JA

Share this post


Link to post
Share on other sites
Alpha testing should be supported for any D3DFMT. Unlike alpha blending, alpha testing doesn't need access to the framebuffer. It just needs the alpha value from the pixel shader, so it should be completely independent of D3DFMT.

Share this post


Link to post
Share on other sites
Quote:
Original post by deathkrush
Alpha testing should be supported for any D3DFMT. Unlike alpha blending, alpha testing doesn't need access to the framebuffer. It just needs the alpha value from the pixel shader, so it should be completely independent of D3DFMT.


Should be, yes, but oddly it's not. It took me by surprise the first time someone here ran into it too. Alphatest does indeed require the postpixelshaderblending option to be available for the format in question. An alternative is to call clip() in your HLSL code, which works regardless of alphatest support.

Share this post


Link to post
Share on other sites
Yes, I ended up choosing that alternative, which I had rejected first since it was more work and I had not enough time on my hands. But it looks like I don't really have the choice anyway. So clip() it will be.

Share this post


Link to post
Share on other sites
Quote:
Original post by Namethatnobodyelsetook

Should be, yes, but oddly it's not. It took me by surprise the first time someone here ran into it too. Alphatest does indeed require the postpixelshaderblending option to be available for the format in question. An alternative is to call clip() in your HLSL code, which works regardless of alphatest support.


Damn these high level APIs and their restrictions. I'm sure the hardware supports alpha testing in any format, but the API just doesn't expose that functionality. The only hardware restriction that I can think of is that alpha testing is not supported in MRT mode.

Share this post


Link to post
Share on other sites
Quote:
Original post by deathkrush
Quote:
Original post by Namethatnobodyelsetook

Should be, yes, but oddly it's not. It took me by surprise the first time someone here ran into it too. Alphatest does indeed require the postpixelshaderblending option to be available for the format in question. An alternative is to call clip() in your HLSL code, which works regardless of alphatest support.


Damn these high level APIs and their restrictions. I'm sure the hardware supports alpha testing in any format, but the API just doesn't expose that functionality. The only hardware restriction that I can think of is that alpha testing is not supported in MRT mode.


That's not quite right either. There's another caps bit for post pixel shader blending w/ MRT, which ATI doesn't support and nVidia does. When it's available, the alphatest result performed on the first output applies to all targets.

Open the SDK help, click index, then 'multiple render targets'. It's all covered in there.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this