Capability to alpha test/blend on a R32F rendertarget

Started by
7 comments, last by Namethatnobodyelsetook 16 years, 1 month ago
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
Advertisement
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.
Many thanks to you [smile]
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
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.
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
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.
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.
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.
deathkrushPS3/Xbox360 Graphics Programmer, Mass Media.Completed Projects: Stuntman Ignition (PS3), Saints Row 2 (PS3), Darksiders(PS3, 360)
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.

This topic is closed to new replies.

Advertisement