From d049d7cdba4ec63d728b5433bf8c0e2b61e27572 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 3 Jul 2024 14:57:41 +0200 Subject: [PATCH] rhi: gl: Map with write+invalidate Presumably the equivalent of D3D11_MAP_WRITE_DISCARD. Stating READ is pointless given reading is not possible with other backends such as D3D11. Task-number: QTBUG-125087 Pick-to: 6.7 6.6 6.5 Change-Id: I3c0aeb2a3669d4f8c279f7ace9a8a55e92988807 Reviewed-by: Andy Nichols (cherry picked from commit f52018e45ff19fd487e729321b6d2d1750f33a4a) Reviewed-by: Qt Cherry-pick Bot --- src/gui/rhi/qrhigles2.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index 525c519ff2f..175cebfdb3e 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -356,6 +356,10 @@ QT_BEGIN_NAMESPACE #define GL_MAP_WRITE_BIT 0x0002 #endif +#ifndef GL_MAP_INVALIDATE_BUFFER_BIT +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#endif + #ifndef GL_TEXTURE_2D_MULTISAMPLE #define GL_TEXTURE_2D_MULTISAMPLE 0x9100 #endif @@ -5328,7 +5332,7 @@ char *QGles2Buffer::beginFullDynamicBufferUpdateForCurrentFrame() rhiD->f->glBindBuffer(targetForDataOps, buffer); if (rhiD->caps.properMapBuffer) { return static_cast(rhiD->f->glMapBufferRange(targetForDataOps, 0, nonZeroSize, - GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)); + GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)); } else { // Need some storage for the data, use the otherwise unused 'data' member. if (data.isEmpty())