aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickgenericshadereffect.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-04-26 12:47:59 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-04-29 09:36:36 +0000
commit96cdc5be2aa0cf87033591cfd76661291b3f6933 (patch)
treefeac67a35952fcaf9b64db0a4b227957852b66d0 /src/quick/items/qquickgenericshadereffect.cpp
parente88e2940598086b57e6c844afa2eca4153d0f528 (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/quick/items/qquickgenericshadereffect.cpp')
-rw-r--r--src/quick/items/qquickgenericshadereffect.cpp27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp
index 769c408672..0e88868aea 100644
--- a/src/quick/items/qquickgenericshadereffect.cpp
+++ b/src/quick/items/qquickgenericshadereffect.cpp
@@ -80,7 +80,7 @@ void QQuickGenericShaderEffect::setFragmentShader(const QByteArray &src)
return;
m_fragShader = src;
- m_dirty |= QSGShaderEffectNode::DirtyShaderFragment;
+ m_dirty |= QSGShaderEffectNode::DirtyShaders;
if (m_item->isComponentComplete())
updateShader(Fragment, src);
@@ -95,7 +95,7 @@ void QQuickGenericShaderEffect::setVertexShader(const QByteArray &src)
return;
m_vertShader = src;
- m_dirty |= QSGShaderEffectNode::DirtyShaderVertex;
+ m_dirty |= QSGShaderEffectNode::DirtyShaders;
if (m_item->isComponentComplete())
updateShader(Vertex, src);
@@ -264,9 +264,7 @@ QSGNode *QQuickGenericShaderEffect::handleUpdatePaintNode(QSGNode *oldNode, QQui
if (!node) {
QSGRenderContext *rc = QQuickWindowPrivate::get(m_item->window())->context;
node = rc->sceneGraphContext()->createShaderEffectNode(rc, mgr);
- m_dirty = QSGShaderEffectNode::DirtyShaderVertex | QSGShaderEffectNode::DirtyShaderFragment
- | QSGShaderEffectNode::DirtyShaderConstant | QSGShaderEffectNode::DirtyShaderTexture
- | QSGShaderEffectNode::DirtyShaderGeometry | QSGShaderEffectNode::DirtyShaderMesh;
+ m_dirty = QSGShaderEffectNode::DirtyShaderAll;
}
// Dirty mesh and geometry are handled here, the rest is passed on to the node.
@@ -295,12 +293,20 @@ QSGNode *QQuickGenericShaderEffect::handleUpdatePaintNode(QSGNode *oldNode, QQui
sd.cullMode = QSGShaderEffectNode::CullMode(m_cullMode);
sd.blending = m_blending;
sd.supportsAtlasTextures = m_supportsAtlasTextures;
- sd.vertexShader = (m_dirty & QSGShaderEffectNode::DirtyShaderVertex) ? &m_shaders[Vertex] : nullptr;
- sd.fragmentShader = (m_dirty & QSGShaderEffectNode::DirtyShaderFragment) ? &m_shaders[Fragment] : nullptr;
+ sd.vertex.shader = &m_shaders[Vertex];
+ sd.vertex.dirtyConstants = &m_dirtyConstants[Vertex];
+ sd.vertex.dirtyTextures = &m_dirtyTextures[Vertex];
+ sd.fragment.shader = &m_shaders[Fragment];
+ sd.fragment.dirtyConstants = &m_dirtyConstants[Fragment];
+ sd.fragment.dirtyTextures = &m_dirtyTextures[Fragment];
node->sync(&sd);
m_dirty = 0;
+ for (int i = 0; i < NShader; ++i) {
+ m_dirtyConstants[i].clear();
+ m_dirtyTextures[i].clear();
+ }
return node;
}
@@ -396,6 +402,7 @@ void QQuickGenericShaderEffect::updateShader(Shader shaderType, const QByteArray
// For file-based shader source/bytecode this is where the data is pulled
// in from the file.
QSGGuiThreadShaderEffectManager::ShaderInfo shaderInfo;
+ // ### this will need some sort of caching mechanism
if (!mgr->reflect(src, &shaderInfo)) {
qWarning("ShaderEffect: shader reflection failed for %s", src.constData());
m_shaders[shaderType].valid = false;
@@ -416,7 +423,7 @@ void QQuickGenericShaderEffect::updateShader(Shader shaderType, const QByteArray
const bool texturesSeparate = mgr->hasSeparateSamplerAndTextureObjects();
// Hook up the signals to get notified about changes for properties that
- // correspond to variables in the shader.
+ // correspond to variables in the shader. Store also the values.
for (int i = 0; i < varCount; ++i) {
const auto &v(shaderInfo.variables.at(i));
QSGShaderEffectNode::VariableData &vd(m_shaders[shaderType].varData[i]);
@@ -433,7 +440,7 @@ void QQuickGenericShaderEffect::updateShader(Shader shaderType, const QByteArray
// The value of a property corresponding to a sampler is the source
// item ref, unless there are separate texture objects in which case
- // the sampler is ignored.
+ // the sampler is ignored (here).
if (v.type == QSGGuiThreadShaderEffectManager::ShaderInfo::Sampler) {
if (texturesSeparate) {
vd.specialType = QSGShaderEffectNode::VariableData::Unused;
@@ -532,10 +539,12 @@ void QQuickGenericShaderEffect::propertyChanged(int mappedId)
}
m_dirty |= QSGShaderEffectNode::DirtyShaderTexture;
+ m_dirtyTextures[type].insert(idx);
} else {
vd.value = m_item->property(v.name.constData());
m_dirty |= QSGShaderEffectNode::DirtyShaderConstant;
+ m_dirtyConstants[type].insert(idx);
}
m_item->update();