aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickgenericshadereffect.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-04-28 12:22:36 +0200
committerLaszlo Agocs <laszlo.agocs@theqtcompany.com>2016-04-29 09:36:40 +0000
commitcb1033fd603a438041a16ba55547d77133ad1e79 (patch)
treee7af709074277664cb203f2c2e4a02a08e0bfb8d /src/quick/items/qquickgenericshadereffect.cpp
parent96cdc5be2aa0cf87033591cfd76661291b3f6933 (diff)
D3D12: Handle special shader effect cases
Like when there is only one shader is given by the ShaderEffect item, or when texture providers disappear (use a dummy texture in this case). Changing the cull mode works now too. Fix also the inconsistent naming (activate -> use) for textures in the glpyh cache. The cbuffer is now correctly aligned. Filtering and wrap modes are now taken from the texture, meaning 'smooth' and 'wrapMode' works. Change-Id: I265a7676d87d470dc8b3a8f59ea64bdadbc58c5d Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquickgenericshadereffect.cpp')
-rw-r--r--src/quick/items/qquickgenericshadereffect.cpp54
1 files changed, 33 insertions, 21 deletions
diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp
index 0e88868aea..ae34a65a2f 100644
--- a/src/quick/items/qquickgenericshadereffect.cpp
+++ b/src/quick/items/qquickgenericshadereffect.cpp
@@ -389,30 +389,44 @@ void QQuickGenericShaderEffect::updateShader(Shader shaderType, const QByteArray
if (!mgr)
return;
+ const bool texturesSeparate = mgr->hasSeparateSamplerAndTextureObjects();
+
disconnectSignals(shaderType);
+ m_shaders[shaderType].shaderInfo = QSGGuiThreadShaderEffectManager::ShaderInfo();
m_shaders[shaderType].varData.clear();
- if (src.isEmpty()) {
- m_shaders[shaderType].valid = false;
- return;
- }
-
- // Figure out what input parameters and variables are used in the shader.
- // 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;
- return;
+ if (!src.isEmpty()) {
+ // Figure out what input parameters and variables are used in the shader.
+ // For file-based shader source/bytecode this is where the data is pulled
+ // in from the file.
+ QSGGuiThreadShaderEffectManager::ShaderInfo shaderInfo;
+ // ### this may need some sort of caching mechanism
+ if (!mgr->reflect(src, &shaderInfo)) {
+ qWarning("ShaderEffect: shader reflection failed for %s", src.constData());
+ m_shaders[shaderType].hasShaderCode = false;
+ return;
+ }
+ m_shaders[shaderType].shaderInfo = shaderInfo;
+ m_shaders[shaderType].hasShaderCode = true;
+ } else {
+ m_shaders[shaderType].hasShaderCode = false;
+ if (shaderType == Fragment) {
+ // With built-in shaders hasShaderCode is set to false and all
+ // metadata is empty, as it is left up to the node to provide a
+ // built-in default shader and its metadata. However, in case of
+ // the built-in fragment shader the value for 'source' has to be
+ // provided and monitored like with an application-provided shader.
+ QSGGuiThreadShaderEffectManager::ShaderInfo::Variable v;
+ v.name = QByteArrayLiteral("source");
+ v.bindPoint = 0;
+ v.type = texturesSeparate ? QSGGuiThreadShaderEffectManager::ShaderInfo::Texture
+ : QSGGuiThreadShaderEffectManager::ShaderInfo::Sampler;
+ m_shaders[shaderType].shaderInfo.variables.append(v);
+ }
}
- m_shaders[shaderType].shaderInfo = shaderInfo;
- m_shaders[shaderType].valid = true;
-
- const int varCount = shaderInfo.variables.count();
+ const int varCount = m_shaders[shaderType].shaderInfo.variables.count();
m_shaders[shaderType].varData.resize(varCount);
// Reuse signal mappers as much as possible since the mapping is based on
@@ -420,12 +434,10 @@ void QQuickGenericShaderEffect::updateShader(Shader shaderType, const QByteArray
if (m_signalMappers[shaderType].count() < varCount)
m_signalMappers[shaderType].resize(varCount);
- const bool texturesSeparate = mgr->hasSeparateSamplerAndTextureObjects();
-
// Hook up the signals to get notified about changes for properties that
// correspond to variables in the shader. Store also the values.
for (int i = 0; i < varCount; ++i) {
- const auto &v(shaderInfo.variables.at(i));
+ const auto &v(m_shaders[shaderType].shaderInfo.variables.at(i));
QSGShaderEffectNode::VariableData &vd(m_shaders[shaderType].varData[i]);
const bool isSpecial = v.name.startsWith("qt_"); // special names not mapped to properties
if (isSpecial) {