get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support

Posted By: BoH_Havoc

get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support - 03/18/10 13:51

Hi,
I'm trying to get the shader capabilities of a gfx card through D3DCAPS9 but i can't get it to work. What i need is the exact pixelshader version the gfx card supports (ps 2.0, ps 2.a, ps 2.b or ps 3.0) and if the card supports r16f and/or r32f textures as well as MRTs (2 or 4).
Is there anyone who already did this and can give me some help?
Oh and using a dll is not an option. I need it lite-c only.

Any help appreciated laugh
Posted By: Slin

Re: get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support - 03/18/10 15:06

If you havenīt done it yet, you should try messing around with the DirecX SDK documentation. I just tried to check the texture format using: ((LPDIRECT3D9)pd3d)->CheckDeviceFormat(...) But the texture formats arenīt defined, so this needs some more defines....

I am still doing something wrong as it crashes, but I think that I am quite close:
Code:
#include <acknex.h>
#include <d3d9.h>

#define D3DFMT_A8R8G8B8 21
#define D3DFMT_X8R8G8B8 22

#define D3DFMT_R16F 111
#define D3DFMT_G16R16F 112
#define D3DFMT_A16B16G16R16F 113

#define D3DFMT_R32F 114
#define D3DFMT_G32R32F 115
#define D3DFMT_A32B32G32R32F 116

#define D3DRTYPE_SURFACE 1
#define D3DRTYPE_VOLUME 2
#define D3DRTYPE_TEXTURE 3
#define D3DRTYPE_VOLUMETEXTURE 4
#define D3DRTYPE_CubeTexture 5
#define D3DRTYPE_VERTEXBUFFER 6
#define D3DRTYPE_INDEXBUFFER 7

void main()
{
	level_load("");
	wait(1);
	((LPDIRECT3D9)pd3d)->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, 0, D3DRTYPE_TEXTURE, D3DFMT_R32F);
}


Posted By: JibbSmart

Re: get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support - 03/19/10 16:50

The manual's "d3d_shaderversion" variable can be used to check the shader version support.

Quote:
as well as MRTs (2 or 4).
I was under the impression that if a card does support MRTs it usually supports 4 or 8, but the lack of a "2" option was just an assumption on my part.

The "bmap_rendertarget()" -- the old way to do MRTs -- is still supported and can be useful for determining how many render targets the computer supports. See what the manual says about it. I used it in the shader contest last year for disabling deferred rendering when there's no MRT support (as far as I've heard your deferred shaders work with or without MRT support, but I was being lazy laugh ).

Unfortunately the engine doesn't seem to come with anything for checking R16f or R32f texture support, which is obviously also very important to know, so you're probably best-off with Slin's example if he/you/I/someone can get it working.

Jibb

EDIT: Just realized after posting that d3d_shaderversion doesn't seem to differentiate between different 2.x versions.
Posted By: BoH_Havoc

Re: get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support - 03/20/10 17:21

Thanks guys, r32f detection works now

Code:
#define D3DFMT_X8R8G8B8 22
#define D3DFMT_R32F 114
#define D3DRTYPE_TEXTURE 3
#define D3DUSAGE_RENDERTARGET (0x00000001L)

void getR32FSupport()
{
   LPDIRECT3D9 mypD3D;
   mypD3D = pd3d;

   var b_r32f = (mypD3D)->CheckDeviceFormat(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, D3DUSAGE_RENDERTARGET, D3DRTYPE_TEXTURE, D3DFMT_R32F);

   if(b_r32f == 0) //r32f supported for RTs
   else //r32f not supported, b_r32f == -653206
}



No let's see if we can get the pixelshader detection working as well... laugh
Posted By: JibbSmart

Re: get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support - 03/20/10 17:25

Thanks for the code.

What's the big difference between the 2.x's?

Jibb
Posted By: BoH_Havoc

Re: get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support - 03/20/10 17:35

For me the most important part right now is the number of instrcution slots, which is way higher with ps 2.0a/b cards laugh

For more differences, have a look at the comparison table here (there's even more, but this gives a good overview):
http://en.wikipedia.org/wiki/High_Level_Shader_Language
Posted By: JibbSmart

Re: get exact pixelshader version (ps2.0, 2.a, 2.b) and r32f support - 03/20/10 19:09

Oh wow -- the difference is significant. Thanks for that. It definitely makes sense to make the most of those differences where possible.

Jibb
© 2024 lite-C Forums