diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-04-26 12:47:59 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-04-29 09:36:36 +0000 |
commit | 96cdc5be2aa0cf87033591cfd76661291b3f6933 (patch) | |
tree | feac67a35952fcaf9b64db0a4b227957852b66d0 /src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h | |
parent | e88e2940598086b57e6c844afa2eca4153d0f528 (diff) |
D3D12: Long Live Wobble!
D3D12 shader effect node.
Cull mode, atlas (qt_SubRect_*) support, and some nice-to-haves are
currently missing. The built-in shaders won't yet work due to not sending
'source' down the stack so both have to be application-supplied.
Nonetheless..the wobble test works!
Change-Id: If4cd0143fa5794a8d5f89b576ffcfb084efeb343
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h')
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h | 76 |
1 files changed, 74 insertions, 2 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h index f88e028b35..d58233481a 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h +++ b/src/plugins/scenegraph/d3d12/qsgd3d12shadereffectnode_p.h @@ -52,24 +52,96 @@ // #include <private/qsgadaptationlayer_p.h> -#include "qsgd3d12builtinmaterials_p.h" +#include "qsgd3d12material_p.h" QT_BEGIN_NAMESPACE class QSGD3D12RenderContext; class QSGD3D12GuiThreadShaderEffectManager; +class QSGD3D12ShaderEffectNode; -class QSGD3D12ShaderEffectNode : public QSGShaderEffectNode +class QSGD3D12ShaderLinker { public: + void reset(const QByteArray &vertBlob, const QByteArray &fragBlob); + + void feedVertexInput(const QSGShaderEffectNode::ShaderData &shader); + void feedConstants(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr); + void feedSamplers(const QSGShaderEffectNode::ShaderData &shader); + void feedTextures(const QSGShaderEffectNode::ShaderData &shader, const QSet<int> *dirtyIndices = nullptr); + + void dump(); + + struct Constant { + uint size; + QSGShaderEffectNode::VariableData::SpecialType specialType; + QVariant value; + bool operator==(const Constant &other) const { + return size == other.size && specialType == other.specialType + && (specialType == QSGShaderEffectNode::VariableData::None ? value == other.value : true); + } + }; + + bool error; + QByteArray vs; + QByteArray fs; + uint constantBufferSize; + QHash<uint, Constant> constants; // offset -> Constant + QSet<int> samplers; // bindpoint + QHash<int, QVariant> textures; // bindpoint -> value (source ref) +}; + +QDebug operator<<(QDebug debug, const QSGD3D12ShaderLinker::Constant &c); + +class QSGD3D12ShaderEffectMaterial : public QSGD3D12Material +{ +public: + QSGD3D12ShaderEffectMaterial(QSGD3D12ShaderEffectNode *node); + + QSGMaterialType *type() const override; + int compare(const QSGMaterial *other) const override; + + int constantBufferSize() const override; + void preparePipeline(QSGD3D12PipelineState *pipelineState) override; + UpdateResults updatePipeline(const RenderState &state, + QSGD3D12PipelineState *pipelineState, + ExtraState *extraState, + quint8 *constantBuffer) override; + + void updateTextureProviders(bool layoutChange); + + QSGD3D12ShaderEffectNode *node; + bool valid = false; + QSGShaderEffectNode::CullMode cullMode = QSGShaderEffectNode::NoCulling; + bool hasCustomVertexShader = false; + bool hasCustomFragmentShader = false; + QSGD3D12ShaderLinker linker; + QSGMaterialType *mtype = nullptr; + QVector<QSGTextureProvider *> textureProviders; +}; + +class QSGD3D12ShaderEffectNode : public QObject, public QSGShaderEffectNode +{ + Q_OBJECT + +public: QSGD3D12ShaderEffectNode(QSGD3D12RenderContext *rc, QSGD3D12GuiThreadShaderEffectManager *mgr); QRectF normalizedTextureSubRect() const override; void sync(SyncData *syncData) override; + static void cleanupMaterialTypeCache(); + + void preprocess() override; + +private Q_SLOTS: + void handleTextureChange(); + void handleTextureProviderDestroyed(QObject *object); + private: QSGD3D12RenderContext *m_rc; QSGD3D12GuiThreadShaderEffectManager *m_mgr; + QSGD3D12ShaderEffectMaterial m_material; }; class QSGD3D12GuiThreadShaderEffectManager : public QSGGuiThreadShaderEffectManager |