CHECKING FOR SHADER SUPPORT

One of the first things you'll need to do is to check for the supported versions of vertex and pixel shaders in your device. After you've loaded a device, you'll need to get the device capabilities bits and check the shader versions encoded there. The vertex and pixel shaders are encoded as major/minor numbers, and you can use DX macros to separate them.

 // Querying the device capabilities bits // Assumes m_d3dDevice is a valid device pointer D3DCAPS8 d3dCaps; m_d3dDevice->GetDeviceCaps( &d3dCaps ); // get vertex shader version printf(''This device supports %d.%d vertex shaders\n'',    D3DSHADER_VERSION_MAJOR(d3dCaps.VertexShaderVersion),    D3DSHADER_VERSION_MINOR(d3dCaps.VertexShaderVersion)); // get pixel shader version printf(''This device supports %d.%d pixel shaders\n'',    D3DSHADER_VERSION_MAJOR(d3dCaps.Pixel ShaderVersion),    D3DSHADER_VERSION_MINOR(d3dCaps.PixelShaderVersion)); 

If you are using the D3Dapp framework, then there's a function called ConfirmDevice() that you can use to test for the desired amount of support. For example, if your program requires vertex shaders version 1.1 or later and pixel shaders version 1.4 or later, then your ConfirmDevice() function would look something like this.

 HRESULT CMyD3DApplication::ConfirmDevice(      D3DCAPS8* pCaps,      DWORD dwBehavior,      D3DFORMAT Format ) {    // A valid pointer to the capsbits is provided    DWORD PxlVrsn, VtxVrsn;    VtxVsn = pCaps->VertexShaderVersion;    PxlVsn = pCaps->PixelShaderVersion;    // check for vertex shader version 1.1    if ( D3DSVS_VERSION(1.1) > VtxVrsn )       {       return E_FAIL; // bad vertex shader vsn.       }   // check for pixel shader version 1.4   if ( D3DSPS_VERSION(1.4) > PxlVrsn )      {      return E_FAIL; // bad pixel shader vsn.      }   return S_OK; } 

The D3DCAPS that are passed in are fetched from the IDirect3DDevice interface.



Real-Time Shader Programming(c) Covering Directx 9. 0
Real-Time Shader Programming (The Morgan Kaufmann Series in Computer Graphics)
ISBN: 1558608532
EAN: 2147483647
Year: 2005
Pages: 104
Authors: Ron Fosner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net