Share via


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

3/26/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.

Add 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 XAML for Windows Embedded, see XAML for Windows Embedded Hardware Recommendations.

Add support for binary shaders to the BSP

OpenGL Embedded Systems (ES) hardware acceleration uses OpenGL ES drivers and binary shaders that include 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 XAML 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 2013 provides default binary shaders in Shaders.dll, which a 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 modify the default fragment shader’s source code in order to tune graphics performance.

XAML 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 adversely affects graphics performance and is only required for GPU hardware that supports RGBA pixel format.

The COpenGLDevice::InitializeState() method in %_WINCE800%\Public\Common\Oak\XamlRenderPlugin\OpenGL\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 %_WINCE800%\Public\Common\Oak\XamlRenderPlugin\OpenGL\OpenGLDevice.cpp. The color conversion algorithm appears underneath 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) part of the if statement, because evaluating the if (expression) code for each pixel is unnecessary and adversely affects performance.

For GPU hardware that supports BGRA pixel format and does not require color conversion, remove all the code underneath 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 %_WINCE800%\Public\Common\Oak\XamlRenderPlugin\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, XAML for Windows Embedded will 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, XAML for Windows Embedded will instead try to compile the 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 XAML for Windows Embedded