def - ps

Defines pixel shader floating-point constants.

Syntax

def dst, fVvalue1, fValue2, fValue3, fValue4

 

Where:

  • dst is the destination register.
  • fValue1 to fValue4 are floating-point values..

Remarks

Pixel shader versions 1_1 1_2 1_3 1_4 2_0 2_x 2_sw 3_0 3_sw
def x x x x x x x x x

 

There are two ways to set a floating-point constant in a pixel shader.

  1. Use def to define the constant directly inside a shader.
  2. Use the API to set a constant with SetPixelShaderConstantF.

def defines a shader constant whose value is loaded any time a shader is set to a device. These are called immediate constants. Immediate constants take precedence over constants set by the API method.

  • Must appear before the first arithmetic or addressing instruction in shader.
  • Can be intermixed with dcl - (sm2, sm3 - ps asm) instructions (which are the other type of instruction that resides at the beginning of a shader).
  • dst register must be a constant register.
  • Write mask must be full (default).
  • If a constant register is defined multiple times in a shader, the last one persists.

Pixel Shader Instructions