The DirectX and OpenGL renderers support the DirectX Pixel Shader Assembler (PSA) versions 1.0 to 1.4. Generally, the same restrictions and limitations apply as documented in the DirectX SDK documentation. Note, in particular, that the constant registers can only be assumed to have a range of -1 to 1. Even though all data types and also state tracking are supported, all values outside the range will typically be clamped to [-1, 1] by each instruction. Additionally XEngine defines the depth value result of a texm3x2depth instruction to be undefined, if z/w as calculated by that instruction is outside the interval [0, 1]. This effectively means that the value written to the depth buffer is undefined, possibly resulting in the fragment to be culled.
Please note that the preprocessor is currently unsupported. This will hopefully change in the future.
Also note that currently XEngine does not support the use of the texbem and texbeml texture addressing instructions or the bem arithmetic instructions in pixel shaders version 1.4. This might change though in future revisions once support for signed texture formats is implemented, if demand warrants it.
When using DirectX pixel shaders with the OpenGL renderer of XEngine additional restrictions apply. The following restrictions apply when DirectX pixel shaders 1.0-1.3 are translated to the NV_register_combiners/NV_texture_shader extensions, which typically happens when running on NVIDIA hardware:
- Pixel shader version 1.0 and 1.1 are fully supported except that for the texm3x3spec and texm3x3vspec instructions a 3D texture cannot be used. Only a cube texture is allowed.
- For versions 1.2 and 1.3 the following additional restrictions apply:
- For texture addressing instructions, the _bx2 source register modifier can only be used with the texm* texture addressing instructions (just as in 1.0 and 1.1).
- The texm3x3 texture addressing instruction is not supported.
- The cmp arithmetic instruction is not supported.
- Using the negate (-r0) or the negate bias (-r0_bias) source register modifier on a source register that was used as a destination register of an instruction using the _sat modifier before is not supported (just as in 1.0 and 1.1).
Currently, pixel shaders written in version 1.4 cannot be used with the OpenGL renderer on NVIDIA hardware, and only on GeForceFX cards or better in Direct3D.
The following restrictions apply when DirectX pixel shaders 1.0-1.3 are internally translated to ATI_text_fragment_shader, which typically happens when running on ATI hardware:
- The texkill and texm3x2depth instructions are not supported simply because ATI_fragment_shader does not offer this functionality.
- The texm3x3vspec instruction is not supported because this instruction in addition to requiring 3-component texture coordinates in each texture register needs to receive a 3-component eye vector spread out over the q components of 3 texture registers. ATI_fragment_shader only allows access to 3 of the 4 components of a texture coordinate register. Therefore this instruction cannot be translated. You could consider using texm3x3spec instead which uses a contant eye vector passed in through a constant parameter register.
- Reading the alpha component of the result of a texdp3, texm3x3, and texcoord instruction is not allowed and will give a "reading from uninitialized component" compile error. This is due to a limitation in ATI_fragment_shader which only gives access to 3 components of a texture coordinate register.
- In certain cases it might not be possible to translate a DirectX pixel shader that uses up all 8 arithmetic instruction slots. This is because additional instructions might have to be inserted into the ATI_fragment_shader during the translation process in certain cases, but ATI_fragment_shader also only provides 8 instruction slots in its output pass (which is where all the arithmetic instructions of the original pixel shader get put into).
The following restrictions apply when DirectX pixel shaders 1.4 are internally translated to ATI_text_fragment_shader, which typically happens when running on ATI hardware:
- The texkill and texdepth instructions are not supported simply because ATI_fragment_shader does not offer this functionality.