ret (sm4 - asm)

Return statement.




If within a subroutine, return to the instruction after the call. If not inside a subroutine, terminate program execution.

The following example shows how to use this instruction.

                call l3
                label l3


  • ret can appear anywhere in a program, any number of times.
  • If a label instruction appears in a Shader, it must be preceded by a ret command that is not nested in any flow control statements.
  • If there are subroutines in a Shader, the last instruction in the Shader must be a ret.

This instruction applies to the following shader stages:

Vertex ShaderGeometry ShaderPixel Shader


Minimum Shader Model

This function is supported in the following shader models.

Shader ModelSupported
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


Related topics

Shader Model 4 Assembly (DirectX HLSL)