discard (sm4 - asm)
Conditionally flag results of Pixel Shader to be discarded when the end of the program is reached.
[in] The value that determines whether to discard the current pixel being processed.
This instruction flags the current pixel as terminated, while continuing execution, so that other pixels executing in parallel may obtain derivatives if necessary. Even though execution continues, all Pixel Shader output writes before or after the discard instruction are discarded.
For discard_z, if all bits in src0.select_component are zero, then the pixel is discarded.
For discard_nz, if any bits in src0.select_component are nonzero, then the pixel is discarded.
In addition, the discard instruction can be present inside any flow control construct.
Multiple discard instructions may be present in a Shader, and if any is executed, the pixel is terminated.
This instruction applies to the following shader stages:
|Vertex Shader||Geometry Shader||Pixel Shader|
This function is supported in the following shader models.
|Shader Model 5||yes|
|Shader Model 4.1||yes|
|Shader Model 4||yes|
|Shader Model 3 (DirectX HLSL)||no|
|Shader Model 2 (DirectX HLSL)||no|
|Shader Model 1 (DirectX HLSL)||no|