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>
This commit is contained in:
parent
5b2c71877a
commit
ffcfc9099b
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue