Output Color Register

The pixel shader color output registers (oC#) are write-only registers that output results to multiple render targets.

Syntax

oC#

 

Where:

NameDescription
oC0render target #0
oC1render target #1
oC2render target #2
oC3render target #3

 

Remarks

  • If oCn is written but there is no corresponding render target, then this write to oCn is ignored.
  • The render states D3DRS_COLORWRITEENABLE, D3DRS_COLORWRITEENABLE1, D3DRS_COLORWRITEENABLE2 and D3DRS_COLORWRITEENABLE3 determine which components of oCn ultimately get written to the render target (after blend, if applicable). If the shader writes some but not all of the components defined by the D3DRS_COLORWRITEENABLE* render states for a given oCn register, then the unwritten channels produce undefined values in the corresponding render target. If none of the components of an oCn are written, the corresponding render target must not be updated at all (as stated above), so the D3DRS_COLORWRITEENABLE* render states do not apply.

Shader Model 2 Restrictions

  • oCn can only be written with the mov - ps instruction.
  • oC0 must be always written in the shader.
  • No source swizzle (except .xyzw = default swizzle) or source modifier is allowed when writing to any oCn.
  • No destination write mask (except .xyzw = default mask) or instruction modifier is allowed when writing to any oCn.
  • If oCn is written, then oC0 - oCn-1 must also be written. For example, to write to oC2, you must also write to oC0 and oC1.
  • At most one write to any oC# per shader is allowed.
  • For ps_2_x and ps_3_0, you cannot write to oC# and oD# registers within dynamic flow control or predication (writes to oC# inside static flow control is fine).

Shader Model 3 Restrictions

  • For ps_3_0, output registers oC# and oD# can be written any number of times. The output of the pixel shader comes from the contents of the output registers at the end of shader execution. If a write to an output register does not happen, perhaps due to flow control or if the shader just did not write it, the corresponding rendertarget is also not updated. If a subset of the channels in an output register are written, then undefined values will be written to the remaining channels.
  • For ps_3_0, the oC# registers can be written with any writemasks.
  • For ps_2_x and ps_3_0, you cannot write to oC# and oD# registers within dynamic flow control or predication (writes to oC# inside static flow control is fine).
  • You may not perform any gradient calculations (or operations that implicitly invoke gradient calculations such as texld - ps_2_0 and up, texldb - ps, texldp - ps) inside of flow control statements whose branching conditions vary on a per-primitive basis (ie: dynamic flow control instructions). Instruction predication is not considered dynamic flow control.

Related topics

Registers
Multiple Render Targets (Direct3D 9)

 

 

Show: