summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-06-04 15:54:25 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-06 02:51:32 +0200
commitd1c00155464fe9a8ce08216141ca978fe6415dcc (patch)
tree7856c3fba6c7a78338a2b1765554c696e3945dbb /src/gui/opengl
parentfce9c2dd26e7b489cfe7a3de0f21a77f4dca62a2 (diff)
Make multisampling more robust in QOpenGLFramebufferObject
Some drivers are reported to get confused when passing different sample counts (requested vs. actual) to the color and depth/stencil attachments. To overcome this, pass the requested sample count to all the attachments. Task-number: QTBUG-33406 Change-Id: I17b0e3dbbd78de2ab0f45e95164b4f326d47aeff Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com> Reviewed-by: Kimmo Leppälä <kimmo.leppala@digia.com>
Diffstat (limited to 'src/gui/opengl')
-rw-r--r--src/gui/opengl/qopenglframebufferobject.cpp10
-rw-r--r--src/gui/opengl/qopenglframebufferobject_p.h1
2 files changed, 9 insertions, 2 deletions
diff --git a/src/gui/opengl/qopenglframebufferobject.cpp b/src/gui/opengl/qopenglframebufferobject.cpp
index 7d91d2c497..cd6468cccd 100644
--- a/src/gui/opengl/qopenglframebufferobject.cpp
+++ b/src/gui/opengl/qopenglframebufferobject.cpp
@@ -436,9 +436,9 @@ void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *, const QSi
samples = qBound(0, int(samples), int(maxSamples));
#endif
+ requestedSamples = samples;
size = sz;
target = texture_target;
- // texture dimensions
QT_RESET_GLERROR(); // reset error state
GLuint fbo = 0;
@@ -472,6 +472,9 @@ void QOpenGLFramebufferObjectPrivate::init(QOpenGLFramebufferObject *, const QSi
valid = checkFramebufferStatus(ctx);
if (valid) {
+ // Query the actual number of samples. This can be greater than the requested
+ // value since the typically supported values are 0, 4, 8, ..., and the
+ // requests are mapped to the next supported value.
funcs.glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_SAMPLES, &samples);
color_buffer_guard = new QOpenGLSharedResourceGuard(ctx, color_buffer, freeRenderbufferFunc);
}
@@ -542,7 +545,10 @@ void QOpenGLFramebufferObjectPrivate::initTexture(GLenum target, GLenum internal
void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpenGLFramebufferObject::Attachment attachment)
{
- int samples = format.samples();
+ // Use the same sample count for all attachments. format.samples() already contains
+ // the actual number of samples for the color attachment and is not suitable. Use
+ // requestedSamples instead.
+ const int samples = requestedSamples;
// free existing attachments
if (depth_buffer_guard) {
diff --git a/src/gui/opengl/qopenglframebufferobject_p.h b/src/gui/opengl/qopenglframebufferobject_p.h
index 7a653bc16d..75348d1481 100644
--- a/src/gui/opengl/qopenglframebufferobject_p.h
+++ b/src/gui/opengl/qopenglframebufferobject_p.h
@@ -131,6 +131,7 @@ public:
GLenum target;
QSize size;
QOpenGLFramebufferObjectFormat format;
+ int requestedSamples;
uint valid : 1;
QOpenGLFramebufferObject::Attachment fbo_attachment;
QOpenGLExtensions funcs;