call (sm4 - asm)
Collapse the table of content
Expand the table of content

call (sm4 - asm)

Calls a subroutine marked by where the label l# appears in the program.

call l#




[in] The label of the subroutine.



When a ret is encountered, return execution to the instruction after this call.

The token format contains the offset of the corresponding label in the Shader as a convenience.

The following example shows the call instruction.

                call l3
                label l3
                    retc_nz r0.x


  • Subroutines can nest 32 deep.
  • The return address stack is managed transparently by the implementation.
  • If there are already 32 entries on the return address stack and a call is issued, the call is skipped over.
  • There is no automatic parameter stack. The application can use an indexable temporary register array (x#[]) to manually implement a stack. However, the subroutine call return addresses are not visible and are orthogonal to any manual stack management done by the application.
  • Indexing of the l# parameter is not permitted.
  • Recursion is not permitted.

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




© 2016 Microsoft