Share via


Optimize Hardware, BSP, or Drivers, for Graphics Performance (Compact 7)

3/12/2014

To help improve graphics performance, you can optimize the board support package (BSP), hardware, or device drivers for the Windows Embedded Compact powered device that the UI runs on.

Adding Minimum Graphics Hardware Components to the Hardware Board

When you work with a hardware vendor to create a hardware board for your Windows Embedded Compact powered device, make sure that the board includes the recommended requirements for graphics hardware and memory.

When you include graphics hardware that supports hardware acceleration, you can implement an OpenGL or DirectDraw graphics renderer and support bitmap caching, which can help improve load time and animation frame rate.

For information about the recommended requirements for Microsoft Silverlight for Windows Embedded, see Silverlight for Windows Embedded Hardware Recommendations.

Adding Support for Binary Shaders to the BSP

OpenGL Embedded Systems (ES) hardware acceleration uses OpenGL ES drivers and binary shaders, including a vertex shader and a fragment shader.

An OpenGL ES fragment shader is a program for the Graphics Processing Unit (GPU) that provides calculations required to render pixels for your Silverlight for Windows Embedded UI. An OpenGL ES vertex shader is a program for the GPU that processes vertexes of primitives, such as vertexes drawn by DrawTriangleStrip.

Note

Not all OpenGL ES drivers support binary shaders.

Windows Embedded Compact 7 provides default binary shaders in Shaders.dll, which a board support package (BSP) provider can customize for your hardware and add to your BSP. By customizing Shaders.dll, you can help improve load time and graphics performance, and you can tune the shaders code for the capabilities of the device hardware.

We recommend that you develop a custom shader.dll library that the OpenGLRendering engine can use to replace the default fragment shader. However, if this is not possible, you can still make modifications to the default fragment shader’s source code in order to tune graphics performance.

Silverlight for Windows Embedded uses BGRA pixel format. If your GPU hardware currently supports BGRA pixel format, you will not have to use the color conversion algorithm implemented in the default fragment shader. The fragment shader is used for each pixel of each surface, and the additional color conversion algorithm negatively impacts graphics performance and is only required for GPU hardware that supports RGBA pixel format.

The COpenGLDevice::InitializeState() method in %_WINCE700%\Public\COMMON\Oak\XamlRenderPlugin\OpenGLXaml\OpenGLDevice.cpp includes a call to the InitializeShader function, which compiles default source code that includes the color conversion algorithm. The default source code is provided as an input parameter in InitializeShader in %_WINCE700%\Public\COMMON\Oak\XamlRenderPlugin\OpenGLXaml\OpenGLDevice.cpp. The color conversion algorithm is beneath the following code comment:

"   // This is worth removing if you know your hardware does BGRA;\r\n
"   // even the if() test can be expensive.\r\n"

For GPU hardware that does not use BGRA pixel format and requires color conversion, modify the default source code for InitializeShader to remove the if (expression) portion of the if statement, because evaluating the if (expression) code for each pixel is unnecessary and negatively impacts performance.

For GPU hardware that supports BGRA pixel format and does not require color conversion, remove all the code beneath the comment, including the if statement.

To customize Shaders.dll for the device hardware

  1. Obtain a command-line shader compiler from your GPU hardware manufacturer.

  2. Copy files from %_WINCEROOT%\PUBLIC\COMMON\OAK\XamlRendererPlugin\OpenGL\shaders to your BSP directory.

  3. (Optional) customize the source code for the fragment shader (defaulteffect.fs.glsl) and the vertex shader (defaulteffect.vs.glsl).

  4. Link defaulteffect.fs.glsl and defaulteffect.vs.glsl to Shaders.dll.

  5. Use the GPU hardware manufacturer’s instructions for compiling Shaders.dll for the GPU by using the command-line shader compiler.

    Be sure to check the default settings of the shader compiler optimizer parameters, and adjust them if necessary.

  6. Add the recompiled Shaders.dll to the BSP for your hardware board.

Note

At run time, Silverlight for Windows Embedded and Internet Explorer Embedded will both try to load Shaders.dll, extract defaulteffect.vs.bin and defaulteffect.fs.bin, and load the files onto the GPU.

If Shaders.dll is not found, or if the extracted files do not match the GPU type, Silverlight for Windows Embedded and Internet Explorer Embedded will instead try to compile their own default shader source code at run time. However, run-time compilation is not supported by all OpenGL ES drivers, and might result in less robust graphics performance than that of shaders that are compiled for the GPU.

The source code in the vertex shader and pixel shader is based on OpenGL Shading Language. For more information about OpenGL programming, see the OpenGL API Documentation.

See Also

Concepts

Graphics and Performance in Silverlight for Windows Embedded