Qtd3dservice: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(clean-up)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
h1. 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.
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.
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.
Line 7: Line 6:
== Build ==
== Build ==


qtd3dservice is included in the &quot;Qt 5.3 Beta&amp;quot;:http://blog.qt.io/blog/2014/03/25/qt-5-3-beta-released/<br />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.
qtd3dservice is included in the [http://blog.qt.io/blog/2014/03/25/qt-5-3-beta-released/ 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:<br /><code>cd qttools<br />path_to_qt\bin\qmake<br />nmake</code>
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:
<code>cd qttools
path_to_qt\bin\qmake
nmake</code>


== Use ==
== Use ==
Line 21: Line 24:
'''Note''': this process will be more automated by the 5.3.0 official release via tooling support in Qt Creator and Visual Studio.
'''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&amp;gt;3dservicelt;DeviceIndex&amp;gt;lt;AppID&amp;gt;''. The original sources are under the &quot;source&amp;quot; subdirectory, and the compiled blobs are under the &quot;binary&amp;quot; directory. The blobs can be packaged as-is with the application, or recompiled from source for additional D3D feature levels or optimization levels.
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 &quot;binary&amp;quot; and place the files in it. Then set add the following inside your main() function:<br /><code>qputenv(&quot;QT_D3DCOMPILER_DIR&amp;quot;, &quot;:/path_to_shaders&amp;quot;);<code>
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:
<code>qputenv("QT_D3DCOMPILER_DIR", ":/path_to_shaders");<code>


Make sure the blobs are in the &quot;binary&amp;quot; subdirectory directly below this directory.
Make sure the blobs are in the "binary" subdirectory directly below this directory.

Latest revision as of 12:03, 24 March 2016

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.