Shader model support for Windows Phone 8

Shader model support for Windows Phone 8

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

On Windows Phone 8, developers can use custom vertex shaders and pixel shaders in apps that use Direct3D. The supported features and limitations of custom shaders on Windows Phone 8 devices are defined by the shader model 4_0_level_9_3. For more info on shader models, see Shader Model vs. Shader Profiles.

The 4_0_level_9_3 shader model encompasses all of the features of the Direct3D 9-era shader model 2.0 with several important differences.

  • Shaders must be written in High Level Shading Language for DirectX. For more info, see HLSL.

  • Static and dynamic flow control is supported.

  • Vertex shaders may be up to 256 equivalent shader assembler instructions in length.

  • Pixel shaders may be up to 512 equivalent shader assembler instructions in lenth.

HLSL is a C-like programming language optimized for writing GPU shader code. When writing shader code in HLSL for use in Windows Phone 8 apps, you should consider the following:

  • Shader code must be compiled offline using FXC.exe, the effect-compiler tool. This is used by Visual Studio by default and can also be invoked from the command line. Runtime shader compilation is not supported.

  • The shader compiler targets for 4_0_level_9_3 are vs_4_0_level_9_3 for vertex shaders and ps_4_0_level_9_3 for pixel shaders. For more info on shader compiler targets, see Specifying Compiler Targets.

  • The semantics for the 4_0_level_9_3 shader model are the same as those documented for Direct3D 9 and, as a result, most system-value semantics, introduced with Direct3D 10 and shader model 4.0, are not available. The exceptions to this are SV_Position, SV_Target, and SV_Depth, which are supported. For more info on semantics, including system-value semantics, see Semantics.

  • When writing larger shaders that may be approaching the instruction count limits, you can use the “/Fc” switch when compiling a shader to obtain and review the resulting assembler code output. For more information on command line options for the effect compiler tool, see Syntax.

Show:
© 2017 Microsoft