summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2016-11-21 13:44:10 +0100
committerAndy Nichols <andy.nichols@qt.io>2016-11-22 12:24:59 +0000
commitffcfc9099be1425009eda3afe9e5057b73070b66 (patch)
treea8a71a7546e0fbdaf3b48c76033a2b499d4af88d /examples
parent5b2c71877a34597b82d2ce81494b9e91c7e31cb8 (diff)
rendernode example: do not rely on build-time shader compilation
There is no public intrastructure for this. Relying on the internal qmake rule in qtdeclarative is wrong as it is not meant for public consumption and is not available in out of tree examples in the installed Qt anyway. Instead, ship the bytecode for now. Task-number: QTBUG-56327 Change-Id: I19327aa880ad573560d1e9376f36c67aa509b51a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/scenegraph/rendernode/d3d12renderer.cpp25
-rw-r--r--examples/quick/scenegraph/rendernode/rendernode.pro16
-rw-r--r--examples/quick/scenegraph/rendernode/rendernode.qrc2
-rw-r--r--examples/quick/scenegraph/rendernode/shader_frag.csobin0 -> 908 bytes
-rw-r--r--examples/quick/scenegraph/rendernode/shader_vert.csobin0 -> 1720 bytes
5 files changed, 21 insertions, 22 deletions
diff --git a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
index 72ebfe869e..9916769241 100644
--- a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
+++ b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
@@ -42,12 +42,10 @@
#include <QQuickItem>
#include <QQuickWindow>
#include <QSGRendererInterface>
+#include <QFile>
#if QT_CONFIG(d3d12)
-#include "vs_shader.hlslh"
-#include "ps_shader.hlslh"
-
D3D12RenderNode::D3D12RenderNode(QQuickItem *item)
: m_item(item)
{
@@ -111,12 +109,25 @@ void D3D12RenderNode::init()
{ "COLOR", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 8, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }
};
+ QFile f(QStringLiteral(":/scenegraph/rendernode/shader_vert.cso"));
+ if (!f.open(QIODevice::ReadOnly)) {
+ qWarning("Failed to open file with vertex shader bytecode");
+ return;
+ }
+ QByteArray vshader_cso = f.readAll();
+ f.close();
+ f.setFileName(QStringLiteral(":/scenegraph/rendernode/shader_frag.cso"));
+ if (!f.open(QIODevice::ReadOnly)) {
+ qWarning("Failed to open file with fragment shader bytecode");
+ return;
+ }
+ QByteArray fshader_cso = f.readAll();
D3D12_SHADER_BYTECODE vshader;
- vshader.pShaderBytecode = g_VS_Simple;
- vshader.BytecodeLength = sizeof(g_VS_Simple);
+ vshader.pShaderBytecode = vshader_cso.constData();
+ vshader.BytecodeLength = vshader_cso.size();
D3D12_SHADER_BYTECODE pshader;
- pshader.pShaderBytecode = g_PS_Simple;
- pshader.BytecodeLength = sizeof(g_PS_Simple);
+ pshader.pShaderBytecode = fshader_cso.constData();
+ pshader.BytecodeLength = fshader_cso.size();
D3D12_RASTERIZER_DESC rastDesc = {};
rastDesc.FillMode = D3D12_FILL_MODE_SOLID;
diff --git a/examples/quick/scenegraph/rendernode/rendernode.pro b/examples/quick/scenegraph/rendernode/rendernode.pro
index 968902a5be..76e498042b 100644
--- a/examples/quick/scenegraph/rendernode/rendernode.pro
+++ b/examples/quick/scenegraph/rendernode/rendernode.pro
@@ -15,24 +15,10 @@ target.path = $$[QT_INSTALL_EXAMPLES]/quick/scenegraph/rendernode
INSTALLS += target
OTHER_FILES += \
- main.qml \
- shader.hlsl
+ main.qml
qtConfig(d3d12) {
HEADERS += d3d12renderer.h
SOURCES += d3d12renderer.cpp
LIBS += -ld3d12
-
- VSPS = shader.hlsl
- vshader.input = VSPS
- vshader.header = vs_shader.hlslh
- vshader.entry = VS_Simple
- vshader.type = vs_5_0
- pshader.input = VSPS
- pshader.header = ps_shader.hlslh
- pshader.entry = PS_Simple
- pshader.type = ps_5_0
-
- HLSL_SHADERS = vshader pshader
- load(hlsl_bytecode_header)
}
diff --git a/examples/quick/scenegraph/rendernode/rendernode.qrc b/examples/quick/scenegraph/rendernode/rendernode.qrc
index 3674baccd8..049adcf8a6 100644
--- a/examples/quick/scenegraph/rendernode/rendernode.qrc
+++ b/examples/quick/scenegraph/rendernode/rendernode.qrc
@@ -1,5 +1,7 @@
<RCC>
<qresource prefix="/scenegraph/rendernode">
<file>main.qml</file>
+ <file>shader_vert.cso</file>
+ <file>shader_frag.cso</file>
</qresource>
</RCC>
diff --git a/examples/quick/scenegraph/rendernode/shader_frag.cso b/examples/quick/scenegraph/rendernode/shader_frag.cso
new file mode 100644
index 0000000000..686c6af3fc
--- /dev/null
+++ b/examples/quick/scenegraph/rendernode/shader_frag.cso
Binary files differ
diff --git a/examples/quick/scenegraph/rendernode/shader_vert.cso b/examples/quick/scenegraph/rendernode/shader_vert.cso
new file mode 100644
index 0000000000..fa13be5160
--- /dev/null
+++ b/examples/quick/scenegraph/rendernode/shader_vert.cso
Binary files differ