From c77efa6d3881554b9e593658fff80acbb8b1388d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 19 Dec 2019 21:33:10 +0100 Subject: Disable support for RasterOpModes in GL paint engine This leads to crashes for instance when displaying a text cursor in a graphics scene. Change-Id: I1b5c884ddb8325a7f5bdbc6027f0fae13f139a1c Reviewed-by: Eirik Aavitsland --- src/gui/opengl/qopenglpaintengine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/gui') diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 47394999c6..6c796776c0 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -1330,6 +1330,7 @@ void QOpenGL2PaintEngineExPrivate::drawVertexArrays(const float *data, int *stop QOpenGL2PaintEngineEx::QOpenGL2PaintEngineEx() : QPaintEngineEx(*(new QOpenGL2PaintEngineExPrivate(this))) { + gccaps &= ~QPaintEngine::RasterOpModes; } QOpenGL2PaintEngineEx::~QOpenGL2PaintEngineEx() -- cgit v1.2.3 From 0c37bc11b5f379d442ed3475483d57449b63963d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 20 Dec 2019 17:45:58 +0100 Subject: Share updates to QGuiApplicationPrivate::app_pal via helper function Change-Id: I2f582358efaadcd33b39c52317222322c589423f Reviewed-by: Simon Hausmann --- src/gui/kernel/qguiapplication.cpp | 19 ++++++++++++++----- src/gui/kernel/qguiapplication_p.h | 2 ++ 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 888ccd8453..bdcea275c3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -3293,12 +3293,8 @@ QPalette QGuiApplication::palette() */ void QGuiApplication::setPalette(const QPalette &pal) { - if (QGuiApplicationPrivate::app_pal && pal.isCopyOf(*QGuiApplicationPrivate::app_pal)) + if (!QGuiApplicationPrivate::setPalette(pal)) return; - if (!QGuiApplicationPrivate::app_pal) - QGuiApplicationPrivate::app_pal = new QPalette(pal); - else - *QGuiApplicationPrivate::app_pal = pal; QCoreApplication::setAttribute(Qt::AA_SetPalette); @@ -3306,6 +3302,19 @@ void QGuiApplication::setPalette(const QPalette &pal) qGuiApp->d_func()->sendApplicationPaletteChange(); } +bool QGuiApplicationPrivate::setPalette(const QPalette &palette) +{ + if (app_pal && palette.isCopyOf(*app_pal)) + return false; + + if (!app_pal) + app_pal = new QPalette(palette); + else + *app_pal = palette; + + return true; +} + void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window) { windowGeometrySpecification.applyTo(window); diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 26f65b2f16..7454bba0e5 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -323,6 +323,8 @@ public: static void resetCachedDevicePixelRatio(); + static bool setPalette(const QPalette &palette); + protected: virtual void notifyThemeChanged(); virtual void sendApplicationPaletteChange(bool toAllWidgets = false, const char *className = nullptr); -- cgit v1.2.3 From 2385ab73be79e5eb69b4feb3d4c787060a56da5f Mon Sep 17 00:00:00 2001 From: Samuli Piippo Date: Tue, 7 Jan 2020 13:52:11 +0200 Subject: QInputDeviceManager: initialize device counts The device counts were used before they were initialized, causing problems e.g. with mouse cursor. Fixes: QTBUG-81207 Change-Id: Ic9dadcaebeb4c4a64bb506e4236d5a9260e0fdbc Reviewed-by: Paul Wicking --- src/gui/kernel/qinputdevicemanager_p_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui') diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h index 871f9315c3..82a86446a0 100644 --- a/src/gui/kernel/qinputdevicemanager_p_p.h +++ b/src/gui/kernel/qinputdevicemanager_p_p.h @@ -69,7 +69,7 @@ public: int deviceCount(QInputDeviceManager::DeviceType type) const; void setDeviceCount(QInputDeviceManager::DeviceType type, int count); - std::array m_deviceCount; + std::array m_deviceCount = {}; Qt::KeyboardModifiers keyboardModifiers; }; -- cgit v1.2.3 From 2671fb27773fa318cde486d310dcf853a8290639 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 8 Jan 2020 13:23:59 +0100 Subject: rhi: Remove ugly fallthroughs The coding style does not actually require this. Change-Id: I2be7cd29c4dabfed2822cd7fb63e597c071e5e15 Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhid3d11.cpp | 26 -------------------------- src/gui/rhi/qrhigles2.cpp | 13 ------------- src/gui/rhi/qrhimetal.mm | 12 ------------ src/gui/rhi/qrhivulkan.cpp | 21 --------------------- 4 files changed, 72 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index c5923fe411..e58ce88095 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -630,9 +630,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -644,9 +642,7 @@ void QRhiD3D11::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -1128,39 +1124,24 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return srgb ? DXGI_FORMAT_BC7_UNORM_SRGB : DXGI_FORMAT_BC7_UNORM; case QRhiTexture::ETC2_RGB8: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGB8A1: - Q_FALLTHROUGH(); case QRhiTexture::ETC2_RGBA8: qWarning("QRhiD3D11 does not support ETC2 textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; case QRhiTexture::ASTC_4x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x4: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_5x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_6x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_8x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x5: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x6: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x8: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_10x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x10: - Q_FALLTHROUGH(); case QRhiTexture::ASTC_12x12: qWarning("QRhiD3D11 does not support ASTC textures"); return DXGI_FORMAT_R8G8B8A8_UNORM; @@ -1201,7 +1182,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format) { switch (format) { case QRhiTexture::Format::D16: - Q_FALLTHROUGH(); case QRhiTexture::Format::D32F: return true; @@ -1867,9 +1847,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QD3D11Texture *texD = QRHI_RES(QD3D11Texture, b->u.simage.tex); @@ -1885,9 +1863,7 @@ void QRhiD3D11::updateShaderResourceBindings(QD3D11ShaderResourceBindings *srbD) } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QD3D11Buffer *bufD = QRHI_RES(QD3D11Buffer, b->u.sbuf.buf); @@ -3356,11 +3332,9 @@ static inline D3D11_BLEND toD3DBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::OneMinusDstAlpha: return D3D11_BLEND_INV_DEST_ALPHA; case QRhiGraphicsPipeline::ConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::ConstantAlpha: return D3D11_BLEND_BLEND_FACTOR; case QRhiGraphicsPipeline::OneMinusConstantColor: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusConstantAlpha: return D3D11_BLEND_INV_BLEND_FACTOR; case QRhiGraphicsPipeline::SrcAlphaSaturate: diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index e63ed11dd4..24ae0a3740 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -681,7 +681,6 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture switch (format) { case QRhiTexture::D16: - Q_FALLTHROUGH(); case QRhiTexture::D32F: return caps.depthTexture; @@ -695,7 +694,6 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture return caps.r16Format; case QRhiTexture::RGBA16F: - Q_FALLTHROUGH(); case QRhiTexture::RGBA32F: return caps.floatFormats; @@ -899,9 +897,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind QRhiPassResourceTracker::toPassTrackerTextureStage(b->stage)); break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); @@ -917,9 +913,7 @@ void QRhiGles2::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); @@ -1654,11 +1648,8 @@ static inline GLenum toGlBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::SrcAlphaSaturate: return GL_SRC_ALPHA_SATURATE; case QRhiGraphicsPipeline::Src1Color: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusSrc1Color: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::Src1Alpha: - Q_FALLTHROUGH(); case QRhiGraphicsPipeline::OneMinusSrc1Alpha: qWarning("Unsupported blend factor %d", f); return GL_ZERO; @@ -2573,9 +2564,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QGles2Texture *texD = QRHI_RES(QGles2Texture, b->u.simage.tex); @@ -2591,9 +2580,7 @@ void QRhiGles2::bindShaderResources(QRhiGraphicsPipeline *maybeGraphicsPs, QRhiC } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QGles2Buffer *bufD = QRHI_RES(QGles2Buffer, b->u.sbuf.buf); diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 222bf170dc..ef2de8c994 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -761,9 +761,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -786,9 +784,7 @@ void QRhiMetal::enqueueShaderResourceBindings(QMetalShaderResourceBindings *srbD } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); @@ -996,9 +992,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -1011,9 +1005,7 @@ void QRhiMetal::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBind } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); @@ -2928,9 +2920,7 @@ bool QMetalShaderResourceBindings::build() } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QMetalTexture *texD = QRHI_RES(QMetalTexture, b->u.simage.tex); @@ -2939,9 +2929,7 @@ bool QMetalShaderResourceBindings::build() } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QMetalBuffer *bufD = QRHI_RES(QMetalBuffer, b->u.sbuf.buf); diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index c5719b54aa..2c9249e911 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -864,7 +864,6 @@ static inline bool isDepthTextureFormat(QRhiTexture::Format format) { switch (format) { case QRhiTexture::Format::D16: - Q_FALLTHROUGH(); case QRhiTexture::Format::D32F: return true; @@ -2373,9 +2372,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); @@ -2394,9 +2391,7 @@ void QRhiVulkan::updateShaderResourceBindings(QRhiShaderResourceBindings *srb, i } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); @@ -3564,9 +3559,7 @@ static inline VkImageLayout toVkLayout(QRhiPassResourceTracker::TextureAccess ac case QRhiPassResourceTracker::TexDepthOutput: return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; case QRhiPassResourceTracker::TexStorageLoad: - Q_FALLTHROUGH(); case QRhiPassResourceTracker::TexStorageStore: - Q_FALLTHROUGH(); case QRhiPassResourceTracker::TexStorageLoadStore: return VK_IMAGE_LAYOUT_GENERAL; default: @@ -4045,9 +4038,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin } break; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: { QVkTexture *texD = QRHI_RES(QVkTexture, b->u.simage.tex); @@ -4072,9 +4063,7 @@ void QRhiVulkan::setShaderResources(QRhiCommandBuffer *cb, QRhiShaderResourceBin } break; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: { QVkBuffer *bufD = QRHI_RES(QVkBuffer, b->u.sbuf.buf); @@ -4863,16 +4852,12 @@ static inline VkDescriptorType toVkDescriptorType(const QRhiShaderResourceBindin return VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; case QRhiShaderResourceBinding::ImageLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::ImageLoadStore: return VK_DESCRIPTOR_TYPE_STORAGE_IMAGE; case QRhiShaderResourceBinding::BufferLoad: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferStore: - Q_FALLTHROUGH(); case QRhiShaderResourceBinding::BufferLoadStore: return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -6356,17 +6341,11 @@ static inline bool isSrgbFormat(VkFormat format) { switch (format) { case VK_FORMAT_R8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8B8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_B8G8R8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_R8G8B8A8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_B8G8R8A8_SRGB: - Q_FALLTHROUGH(); case VK_FORMAT_A8B8G8R8_SRGB_PACK32: return true; default: -- cgit v1.2.3 From e4d0187edc8aa5c70d181728b18630c1749ca288 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 8 Jan 2020 11:15:42 +0100 Subject: rhi: metal: Fix incorrect native res. binding map check Checking for nullptr is insufficient: just because there is an empty map present, it does not mean it is valid. The two cases must be handled identically. This fixes a regression when using QShaders that do not have an associated native resource binding map. Amends 4639660dedceba7c16e1a8110bba16eff30be312 Change-Id: Icb239bf9a9261ed32f2cb7b22c60b608195618fc Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhimetal.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index ef2de8c994..53422470e8 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -664,15 +664,15 @@ static inline int mapBinding(int binding, BindingType type) { const QShader::NativeResourceBindingMap *map = nativeResourceBindingMaps[stageIndex]; - if (!map) + if (!map || map->isEmpty()) return binding; // old QShader versions do not have this map, assume 1:1 mapping then auto it = map->constFind(binding); if (it != map->cend()) return type == BindingType::Sampler ? it->second : it->first; // may be -1, if the resource is inactive - // Hitting this path is normal too, is not given that the resource (e.g. a - // uniform block) is really present in the shaders for all the stages + // Hitting this path is normal too. It is not given that the resource (for + // example, a uniform block) is present in the shaders for all the stages // specified by the visibility mask in the QRhiShaderResourceBinding. return -1; } -- cgit v1.2.3 From e8199a5c4d8c7218178db809bbfc0464f49714b1 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 9 Jan 2020 15:28:54 +0100 Subject: rhi: Add R16F and R32F Can be relevant for Qt Quick 3D shadows, where the shadow map is R16F. Task-number: QTBUG-81268 Change-Id: Ic33e100929e133d1cbe0b062a15697c82536f62a Reviewed-by: Paul Olav Tvete --- src/gui/rhi/qrhi.cpp | 6 ++++++ src/gui/rhi/qrhi_p.h | 2 ++ src/gui/rhi/qrhid3d11.cpp | 4 ++++ src/gui/rhi/qrhigles2.cpp | 24 ++++++++++++++++++++++++ src/gui/rhi/qrhimetal.mm | 4 ++++ src/gui/rhi/qrhivulkan.cpp | 4 ++++ 6 files changed, 44 insertions(+) (limited to 'src/gui') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 00d4df53bd..d2c8ae104e 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -3939,6 +3939,12 @@ void QRhiImplementation::textureFormatInfo(QRhiTexture::Format format, const QSi case QRhiTexture::RGBA32F: bpc = 16; break; + case QRhiTexture::R16F: + bpc = 2; + break; + case QRhiTexture::R32F: + bpc = 4; + break; case QRhiTexture::D16: bpc = 2; diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index a6c65aac5e..3a64835c22 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -728,6 +728,8 @@ public: RGBA16F, RGBA32F, + R16F, + R32F, D16, D32F, diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index e58ce88095..445d162595 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -1102,6 +1102,10 @@ static inline DXGI_FORMAT toD3DTextureFormat(QRhiTexture::Format format, QRhiTex return DXGI_FORMAT_R16G16B16A16_FLOAT; case QRhiTexture::RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case QRhiTexture::R16F: + return DXGI_FORMAT_R16_FLOAT; + case QRhiTexture::R32F: + return DXGI_FORMAT_R32_FLOAT; case QRhiTexture::D16: return DXGI_FORMAT_R16_TYPELESS; diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 24ae0a3740..afa3a397e6 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -165,6 +165,14 @@ QT_BEGIN_NAMESPACE #define GL_RGBA16F 0x881A #endif +#ifndef GL_R16F +#define GL_R16F 0x822D +#endif + +#ifndef GL_R32F +#define GL_R32F 0x822E +#endif + #ifndef GL_HALF_FLOAT #define GL_HALF_FLOAT 0x140B #endif @@ -697,6 +705,10 @@ bool QRhiGles2::isTextureFormatSupported(QRhiTexture::Format format, QRhiTexture case QRhiTexture::RGBA32F: return caps.floatFormats; + case QRhiTexture::R16F: + case QRhiTexture::R32F: + return caps.floatFormats; + default: break; } @@ -3384,6 +3396,18 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize) glformat = GL_RGBA; gltype = GL_FLOAT; break; + case QRhiTexture::R16F: + glintformat = GL_R16F; + glsizedintformat = glintformat; + glformat = GL_RED; + gltype = GL_HALF_FLOAT; + break; + case QRhiTexture::R32F: + glintformat = GL_R32F; + glsizedintformat = glintformat; + glformat = GL_RED; + gltype = GL_FLOAT; + break; case QRhiTexture::D16: glintformat = GL_DEPTH_COMPONENT16; glsizedintformat = glintformat; diff --git a/src/gui/rhi/qrhimetal.mm b/src/gui/rhi/qrhimetal.mm index 53422470e8..883d6923b9 100644 --- a/src/gui/rhi/qrhimetal.mm +++ b/src/gui/rhi/qrhimetal.mm @@ -2320,6 +2320,10 @@ static inline MTLPixelFormat toMetalTextureFormat(QRhiTexture::Format format, QR return MTLPixelFormatRGBA16Float; case QRhiTexture::RGBA32F: return MTLPixelFormatRGBA32Float; + case QRhiTexture::R16F: + return MTLPixelFormatR16Float; + case QRhiTexture::R32F: + return MTLPixelFormatR32Float; case QRhiTexture::D16: #ifdef Q_OS_MACOS diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 2c9249e911..c4f56f2dd2 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -767,6 +767,10 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture return VK_FORMAT_R16G16B16A16_SFLOAT; case QRhiTexture::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; + case QRhiTexture::R16F: + return VK_FORMAT_R16_SFLOAT; + case QRhiTexture::R32F: + return VK_FORMAT_R32_SFLOAT; case QRhiTexture::D16: return VK_FORMAT_D16_UNORM; -- cgit v1.2.3 From f1e5c5575cc362bc23da500d069dc98e082492e4 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 7 Jan 2020 11:29:04 +0100 Subject: Remove use of QImage::alphaChannel() A direct logical replacement. Not sure what is going on though or why an inversion is necessary, but logic is unchanged. Change-Id: Id9b5531895371f6467018fa82336aff6238ae126 Reviewed-by: Friedemann Kleint Reviewed-by: Eirik Aavitsland --- src/gui/painting/qtextureglyphcache.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/gui') diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index f40ca9d8b4..91214f27ca 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -341,9 +341,10 @@ void QImageTextureGlyphCache::fillTexture(const Coord &c, glyph_t g, QFixed subP } else if (m_format == QFontEngine::Format_Mono) { if (mask.depth() > 1) { // TODO optimize this - mask = mask.alphaChannel(); + mask.convertTo(QImage::Format_Alpha8); + mask.reinterpretAsFormat(QImage::Format_Grayscale8); mask.invertPixels(); - mask = mask.convertToFormat(QImage::Format_Mono, Qt::ThresholdDither); + mask.convertTo(QImage::Format_Mono, Qt::ThresholdDither); } int mw = qMin(mask.width(), c.w); -- cgit v1.2.3 From 69e7dfdb289b65ac27b581a164aefbbc28fc4fae Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 9 Jan 2020 10:50:35 +0100 Subject: Remove QShaderDescription::toBinaryJson(), deprecated fromBinaryJson() Binary Json is deprecated and we should not use it. We can already serialize shaders to CBOR. Push the deprecation warning mechanism to the only user of fromBinaryJson(). Change-Id: I1d56157ab92f74eaab49400be647317e7833e35e Reviewed-by: Sona Kurazyan Reviewed-by: Laszlo Agocs --- src/gui/rhi/qshader.cpp | 13 +++++++++++-- src/gui/rhi/qshaderdescription.cpp | 37 ++++++++----------------------------- src/gui/rhi/qshaderdescription_p.h | 4 +++- 3 files changed, 22 insertions(+), 32 deletions(-) (limited to 'src/gui') diff --git a/src/gui/rhi/qshader.cpp b/src/gui/rhi/qshader.cpp index 0b99281f08..9203d63cd2 100644 --- a/src/gui/rhi/qshader.cpp +++ b/src/gui/rhi/qshader.cpp @@ -439,10 +439,19 @@ QShader QShader::fromSerialized(const QByteArray &data) d->stage = Stage(intVal); QByteArray descBin; ds >> descBin; - if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) + if (d->qsbVersion > QShaderPrivate::QSB_VERSION_WITH_BINARY_JSON) { d->desc = QShaderDescription::fromCbor(descBin); - else + } else { +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_WARNING_PUSH + QT_WARNING_DISABLE_DEPRECATED d->desc = QShaderDescription::fromBinaryJson(descBin); + QT_WARNING_POP +#else + qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); + d->desc = QShaderDescription(); +#endif + } int count; ds >> count; for (int i = 0; i < count; ++i) { diff --git a/src/gui/rhi/qshaderdescription.cpp b/src/gui/rhi/qshaderdescription.cpp index 7e9b7d7b8e..76c5d0ebef 100644 --- a/src/gui/rhi/qshaderdescription.cpp +++ b/src/gui/rhi/qshaderdescription.cpp @@ -102,8 +102,8 @@ QT_BEGIN_NAMESPACE float \c opacity at offset 64. All this is described by a QShaderDescription object. QShaderDescription - can also be serialized to JSON and binary JSON, and can be deserialized - from binary JSON. In practice this is rarely needed since QShader + can also be serialized to JSON and CBOR, and can be deserialized + from CBOR. In practice this is rarely needed since QShader takes care of the associated QShaderDescription automatically, but if the QShaderDescription of the above shader would be written out as JSON, it would look like the following: @@ -335,29 +335,11 @@ bool QShaderDescription::isValid() const || !d->combinedImageSamplers.isEmpty() || !d->storageImages.isEmpty(); } -/*! - \return a serialized binary version of the data. - - \sa toJson(), toCbor() - */ -QByteArray QShaderDescription::toBinaryJson() const -{ -#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) -QT_WARNING_PUSH -QT_WARNING_DISABLE_DEPRECATED - return d->makeDoc().toBinaryData(); -QT_WARNING_POP -#else - qWarning("Cannot generate binary JSON from QShaderDescription due to disabled binaryjson feature"); - return QByteArray(); -#endif -} - /*! \return a serialized binary version of the data in CBOR (Concise Binary Object Representation) format. - \sa QCborValue, toBinaryJson(), toJson() + \sa QCborValue, toJson() */ QByteArray QShaderDescription::toCbor() const { @@ -369,14 +351,17 @@ QByteArray QShaderDescription::toCbor() const \note There is no deserialization method provided for JSON text. - \sa toBinaryJson(), toCbor() + \sa toCbor() */ QByteArray QShaderDescription::toJson() const { return d->makeDoc().toJson(); } +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + Deserializes the given binary JSON \a data and returns a new QShaderDescription. @@ -385,22 +370,16 @@ QByteArray QShaderDescription::toJson() const QShaderDescription QShaderDescription::fromBinaryJson(const QByteArray &data) { QShaderDescription desc; -#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED QShaderDescriptionPrivate::get(&desc)->loadDoc(QJsonDocument::fromBinaryData(data)); QT_WARNING_POP -#else - Q_UNUSED(data); - qWarning("Cannot load QShaderDescription from binary JSON due to disabled binaryjson feature"); -#endif return desc; } +#endif /*! Deserializes the given CBOR \a data and returns a new QShaderDescription. - - \sa fromBinaryJson() */ QShaderDescription QShaderDescription::fromCbor(const QByteArray &data) { diff --git a/src/gui/rhi/qshaderdescription_p.h b/src/gui/rhi/qshaderdescription_p.h index e02a53dcb5..872ee8b138 100644 --- a/src/gui/rhi/qshaderdescription_p.h +++ b/src/gui/rhi/qshaderdescription_p.h @@ -68,11 +68,13 @@ public: bool isValid() const; - QByteArray toBinaryJson() const; QByteArray toCbor() const; QByteArray toJson() const; +#if QT_CONFIG(binaryjson) && QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use CBOR format instead") static QShaderDescription fromBinaryJson(const QByteArray &data); +#endif static QShaderDescription fromCbor(const QByteArray &data); enum VariableType { -- cgit v1.2.3