diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-28 15:24:17 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2016-06-29 12:00:03 +0000 |
commit | ee595e9c0a4a24733195db22244cbf17b8514f72 (patch) | |
tree | a21d439445f17c1a43eee71c368fe5bbc34503fb /src/plugins | |
parent | 5ee02242d72ac9a536584b36ba549480a97303f7 (diff) |
D3D12: Add support for file selectors in ShaderEffect
Now that both OpenGL and D3D supports files, it is trivial to add support
for file selectors. This means that one can add for example a
shaders/wobble.frag with GLSL source code and a
shaders/+hlsl/wobble.frag with D3D bytecode, while simply writing
fragmentShader: "file:shaders/wobble.frag" in QML. The rest is automatic.
Change-Id: Iaf71a6998bbd31050bc6c2b2f33b03d27c59fb6c
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode.cpp | 7 | ||||
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h | 2 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode.cpp index 8c46e781e9..baf7571910 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode.cpp @@ -43,6 +43,7 @@ #include "qsgd3d12engine_p.h" #include <QtCore/qthreadpool.h> #include <QtCore/qfile.h> +#include <QtCore/qfileselector.h> #include <QtQml/qqmlfile.h> #include <qsgtextureprovider.h> @@ -850,7 +851,11 @@ void QSGD3D12GuiThreadShaderEffectManager::prepareShaderCode(ShaderInfo::Type ty // For simplicity, assume that file = bytecode, string = HLSL. QUrl srcUrl(src); if (!srcUrl.scheme().compare(QLatin1String("qrc"), Qt::CaseInsensitive) || srcUrl.isLocalFile()) { - const QString fn = QQmlFile::urlToLocalFileOrQrc(src); + if (!m_fileSelector) { + m_fileSelector = new QFileSelector(this); + m_fileSelector->setExtraSelectors(QStringList() << QStringLiteral("hlsl")); + } + const QString fn = m_fileSelector->select(QQmlFile::urlToLocalFileOrQrc(srcUrl)); QFile f(fn); if (!f.open(QIODevice::ReadOnly)) { qWarning("ShaderEffect: Failed to read %s", qPrintable(fn)); diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h index c36ee1a6e6..ee17e59130 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h +++ b/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h @@ -60,6 +60,7 @@ class QSGD3D12RenderContext; class QSGD3D12GuiThreadShaderEffectManager; class QSGD3D12ShaderEffectNode; class QSGD3D12Texture; +class QFileSelector; class QSGD3D12ShaderLinker { @@ -166,6 +167,7 @@ private: bool reflect(ShaderInfo *result); QString m_log; Status m_status = Uncompiled; + QFileSelector *m_fileSelector = nullptr; friend class QSGD3D12ShaderCompileTask; }; |