Confirming Pixel Shader Support

DirectX8

Microsoft DirectX 8.1 (C++)

Confirming Pixel Shader Support

You can query members of D3DCAPS8 to determine the level of support for operations involving pixel shaders. The following table lists the device capabilities related to programmable pixel processing in Microsoft® DirectX® 8.1.

Device capability Description
MaxPixelShaderValue Range of values that may be stored in registers is
[-MaxPixelShaderValue, MaxPixelShaderValue].
MaxSimultaneousTextures Number of texture stages that can be used in the programmable pixel shader.
PixelShaderVersion Level of support for pixel shaders.

The PixelShaderVersion capability indicates the level of pixel shader supported. Only pixel shaders with version numbers equal to or less than this value will be successfully created. The major version number is encoded in the second byte of PixelShaderVersion. The low byte contains a minor version number. The pixel shader version is indicated by the first token in each shader.

Each implementation sets the PixelShaderVersion member to indicate the maximum pixel shader version that it can fully support. This implies that implementations should never fail the creation of a valid shader of the version less than or equal to the version reported by PixelShaderVersion.

Setting Pixel Shader Texture Inputs

The texture coordinate data is interpolated from the vertex texture coordinate data and is associated with a specific texture stage. The default association is a one-to-one mapping between texture stage number and texture coordinate declaration order. This means that the first set of texture coordinates defined in the vertex format are, by default, associated with texture stage 0.

Texture coordinates can be associated with any stage, using either of the following two techniques. When using a fixed function vertex shader, the texture stage state flag TSS_TEXCOORDINDEX can be used in IDirect3DDevice8::SetTextureStageState to associate coordinates with a stage. Otherwise, the texture coordinates are output by the vertex shader oTn registers when using a programmable vertex shader.

Setting the Pixel Shader Constant Registers

You can use the following methods to set and retrieve the values in the pixel shader constant registers.

In addition, you can use the def instruction to set the constant registers of a pixel shader, inside a pixel shader. This instruction must come before all other instructions except the version instruction.

Compiling and Creating a Pixel Shader

The Direct3DX utility library provides a set of functions to compile pixel shaders. The following functions are provided.

The IDirect3DDevice8::CreatePixelShader create a pixel shader in DirectX 8.1 from a compiled shader declaration. The compiled shader declaration is obtained from D3DXAssembleShader.

A given shader might fail creation because of the restraints of the DirectX 8.1 hardware model.