Qtd3dservice
qtd3dservice
qtd3dservice is a background service for monitoring Windows Store Apps (Windows 8/RT/Phone) which request compilation of HLSL shader programs (shaders) used by Qt applications. HLSL shaders are produced by ANGLE from GLSL shader source code at runtime, and must be compiled before use. GLSL shader programs are used essentially anywhere modern OpenGL is used, including within QtQuick 2. A typical QtQuick 2 application will request five or six shaders to be compiled at runtime, not counting any additional shaders written in QML or C++. These shader "blobs" must then be packaged with the final app for distribution in the Windows Store.
Due to the way Direct3D specifies compiled HLSL shader programs (as effectively universal binaries), and for power and performance reasons, there is no runtime shader compilation support in Windows Store Apps. Traditionally, Windows applications have used the d3dcompiler_XX DLL to provide this functionality. In fact, Windows 8/RT applications may still use this DLL at development time to avoid the overhead of the qtd3dservice, but they will not pass Windows Store certification if they package the DLL for distribution. Windows Phone does not have a runtime shader compiler at all, and must use qtd3dservice (or pre-compiled shader blobs) in order to use OpenGL/Qt Quick.
Build
qtd3dservice is included in the Qt 5.3 Beta You will find shortcuts to the service installed for each Qt version. However, all copies of the service are the same and so you only need to start one of them, regardless of the target platform.
If building the service by hand, qtd3dservice should build along with the rest of Qt if you used qt5.git. If you are building Qt modules separately, you can find qtd3dservice in the qttools repository. Simply run:
cd qttools
path_to_qt\bin\qmake
nmake
Use
qtd3dservice is a command-line tool which can be run directly from the command line. It can be found in your Qt bin path, or started from the Start menu shortcut with the Beta release. If you experience problems (e.g. shaders not compiling, or the device or app not being detected), you can pass the -verbose 2 option to get additional debug output.
If you experience issues such as these, please report bugs to https://bugreports.qt.io
Packaging of shader blobs
Note: this process will be more automated by the 5.3.0 official release via tooling support in Qt Creator and Visual Studio.
When a shader blob is compiled, it is stored in C:lt;Username>3dservicelt;DeviceIndex>lt;AppID>. The original sources are under the "source" subdirectory, and the compiled blobs are under the "binary" directory. The blobs can be packaged as-is with the application, or recompiled from source for additional D3D feature levels or optimization levels.
You may then place the blobs in a qrc file or simply package them with as part of the application package. Create a directory called "binary" and place the files in it. Then set add the following inside your main() function:
qputenv("QT_D3DCOMPILER_DIR", ":/path_to_shaders");
Make sure the blobs are in the "binary" subdirectory directly below this directory.