Microsoft DirectX 8.1 (pixel shader versions 1.0, 1.1, 1.2, 1.3, 1.4)

Pixel Shader Reference

The pixel shader assembler is made up of a set of instructions that operate on pixel data contained in registers. Operations are expressed as instructions comprised of an operator and one or more operands. Instructions use registers to transfer data in and out of the pixel shader arithmetic logic unit. Registers can also be used by some instructions to hold temporary results.

Architecture

Architecture contains a block diagram of the pixel shader arithmetic logic unit (ALU) and the shader registers.

Instructions

There are two main categories of pixel shader instructions: arithmetic instructions and texture addressing instructions. Arithmetic instructions modify color data. Texture addressing operations process texture coordinate data and in most cases, sample a texture. Pixel shader instructions are executed on a per-pixel basis, that is, they have no knowledge of other pixels in the pipeline.

Texture addressing instructions each consume one slot, but arithmetic instructions can be paired to enable both color components(RGB) and an alpha component instruction in a single slot.

Instructions contains a list of the available instructions.

When multisampling is enabled, pixel shaders only get executed once per pixel, not once for every sub pixel. Multisampling only increases the resolution of polygon edges, as well as depth and stencil tests. For example, if 3×3 multisampling is enabled, and a triangle being rasterized is found to cover 5 of the 9 subpixels for a particular pixel, the pixel shader gets executed once and the same color result is applied to all 5 sub pixels.

Registers

Registers lists the different registers used by the shader arithmetic logic unit.

Modifiers

Modifiers can be used to change the functionality of an instruction, or the data read from or written to a register.

Microsoft® DirectX® 8.x requires intermediate computations to maintain at least 8-bit precision for all surface formats. Both higher precision (12-bit) for in-stage math, and saturation to 8-bits between texture stages are recommended. No modifiable rounding modes or exceptions are supported. Multiplication should be supported with a round-to-nearest precision to minimize precision loss.