diff options
author | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-06-02 15:40:07 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@theqtcompany.com> | 2016-06-03 10:24:25 +0000 |
commit | 0e767eaa29ea0a7edb101ba87fb8367e9f056eed (patch) | |
tree | f84efae2b4fa591cb619e1f26d4e11af64d397f2 /src | |
parent | 878baeda2b1f9da688f81d1d3aa2e7ab0dd3eb24 (diff) |
D3D12: Remove m_lastNN members from text material
To reduce the data size. The data is anyway available in the element-dedicated
area of the constant buffer (better said, the plain CPU memory the
renderer uses to prepare the data for the engine), so compare with that
instead. Note that while the memcmp-memcpy pair may seem to have little
value at first, setting the UpdatedConstantBuffer flag only when needed does
have its benefits since the GPU-visible buffer mapping can be skipped completely
when nothing has changed.
Change-Id: Ie5d6797a06cb4259bd65114c5b69b11ff165e871
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp | 60 | ||||
-rw-r--r-- | src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h | 5 |
2 files changed, 32 insertions, 33 deletions
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp index f51130deb7..b631dd9d6c 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp +++ b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials.cpp @@ -503,56 +503,60 @@ QSGD3D12Material::UpdateResults QSGD3D12TextMaterial::updatePipeline(const QSGD3 } p += TEXT_CB_SIZE_0; - if (state.isCachedMaterialDataDirty() || m_lastGlyphCacheSize != glyphCache()->currentSize()) { - m_lastGlyphCacheSize = glyphCache()->currentSize(); - const float textureScale[2] = { 1.0f / m_lastGlyphCacheSize.width(), - 1.0f / m_lastGlyphCacheSize.height() }; + const QSize sz = glyphCache()->currentSize(); + const float textureScale[] = { 1.0f / sz.width(), 1.0f / sz.height() }; + if (state.isCachedMaterialDataDirty() || memcmp(p, textureScale, TEXT_CB_SIZE_1)) { memcpy(p, textureScale, TEXT_CB_SIZE_1); r |= UpdatedConstantBuffer; } p += TEXT_CB_SIZE_1; const float dpr = m_rc->engine()->windowDevicePixelRatio(); - if (state.isCachedMaterialDataDirty() || m_lastDpr != dpr) { - m_lastDpr = dpr; + if (state.isCachedMaterialDataDirty() || memcmp(p, &dpr, TEXT_CB_SIZE_2)) { memcpy(p, &dpr, TEXT_CB_SIZE_2); r |= UpdatedConstantBuffer; } p += TEXT_CB_SIZE_2; - if (state.isOpacityDirty() || m_lastColor != m_color) { - m_lastColor = m_color; - if (glyphCache()->glyphFormat() == QFontEngine::Format_A32) { - const QVector4D color = qsg_premultiply(m_color, state.opacity()); - const float alpha = color.w(); + if (glyphCache()->glyphFormat() == QFontEngine::Format_A32) { + const QVector4D color = qsg_premultiply(m_color, state.opacity()); + const float alpha = color.w(); + if (state.isOpacityDirty() || memcmp(p, &alpha, TEXT_CB_SIZE_3)) { memcpy(p, &alpha, TEXT_CB_SIZE_3); - } else if (glyphCache()->glyphFormat() == QFontEngine::Format_ARGB) { - const float opacity = m_color.w() * state.opacity(); + r |= UpdatedConstantBuffer; + } + } else if (glyphCache()->glyphFormat() == QFontEngine::Format_ARGB) { + const float opacity = m_color.w() * state.opacity(); + if (state.isOpacityDirty() || memcmp(p, &opacity, TEXT_CB_SIZE_3)) { memcpy(p, &opacity, TEXT_CB_SIZE_3); - } else { - const QVector4D color = qsg_premultiply(m_color, state.opacity()); - const float f[4] = { color.x(), color.y(), color.z(), color.w() }; + r |= UpdatedConstantBuffer; + } + } else { + const QVector4D color = qsg_premultiply(m_color, state.opacity()); + const float f[] = { color.x(), color.y(), color.z(), color.w() }; + if (state.isOpacityDirty() || memcmp(p, f, TEXT_CB_SIZE_4)) { memcpy(p + TEXT_CB_SIZE_3, f, TEXT_CB_SIZE_4); + r |= UpdatedConstantBuffer; } - r |= UpdatedConstantBuffer; } p += TEXT_CB_SIZE_3 + TEXT_CB_SIZE_4; - if (m_styleType == Styled && (state.isCachedMaterialDataDirty() || m_lastStyleShift != m_styleShift)) { - m_lastStyleShift = m_styleShift; - const float f[2] = { m_styleShift.x(), m_styleShift.y() }; - memcpy(p, f, TEXT_CB_SIZE_5); - r |= UpdatedConstantBuffer; + if (m_styleType == Styled) { + const float f[] = { m_styleShift.x(), m_styleShift.y() }; + if (state.isCachedMaterialDataDirty() || memcmp(p, f, TEXT_CB_SIZE_5)) { + memcpy(p, f, TEXT_CB_SIZE_5); + r |= UpdatedConstantBuffer; + } } p += TEXT_CB_SIZE_5 + TEXT_CB_SIZE_5_PADDING; - if ((m_styleType == Styled || m_styleType == Outlined) - && (state.isOpacityDirty() || m_lastStyleColor != m_styleColor)) { - m_lastStyleColor = m_styleColor; + if (m_styleType == Styled || m_styleType == Outlined) { const QVector4D color = qsg_premultiply(m_styleColor, state.opacity()); - const float f[4] = { color.x(), color.y(), color.z(), color.w() }; - memcpy(p, f, TEXT_CB_SIZE_6); - r |= UpdatedConstantBuffer; + const float f[] = { color.x(), color.y(), color.z(), color.w() }; + if (state.isOpacityDirty() || memcmp(p, f, TEXT_CB_SIZE_6)) { + memcpy(p, f, TEXT_CB_SIZE_6); + r |= UpdatedConstantBuffer; + } } QSGD3D12TextureView &tv(pipelineState->shaders.rootSig.textureViews[0]); diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h index c64ff52ab0..e3c3957160 100644 --- a/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h +++ b/src/plugins/scenegraph/d3d12/qsgd3d12builtinmaterials_p.h @@ -224,11 +224,6 @@ private: QVector4D m_styleColor; QRawFont m_font; QExplicitlySharedDataPointer<QFontEngineGlyphCache> m_glyphCache; - QSize m_lastGlyphCacheSize; - float m_lastDpr = 0; - QVector4D m_lastColor; - QVector2D m_lastStyleShift; - QVector4D m_lastStyleColor; }; QT_END_NAMESPACE |