summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRhys Perry <pendingchaos02@gmail.com>2018-05-04 23:27:51 +0100
committerJuan A. Suarez Romero <jasuarez@igalia.com>2018-05-15 11:14:49 +0200
commit43688542600a848892116c1feb4a10973361711b (patch)
tree6e714d1d148a529c50e6cc439a78bf4af0dd7285
parent5f0c3879e6544881e6d82a129d453fedc2077449 (diff)
mesa: fix error handling in get_framebuffer_parameteriv
CC: <mesa-stable@lists.freedesktop.org> Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> (cherry picked from commit 5ac16ed0476d9914927b8e7a592d8d7ac1589586)
-rw-r--r--src/mesa/main/fbobject.c72
1 files changed, 41 insertions, 31 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index d23916d1ad7..196e2e73169 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -1488,45 +1488,66 @@ _mesa_FramebufferParameteri(GLenum target, GLenum pname, GLint param)
}
static bool
-_pname_valid_for_default_framebuffer(struct gl_context *ctx,
- GLenum pname)
+validate_get_framebuffer_parameteriv_pname(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLuint pname, const char *func)
{
- if (!_mesa_is_desktop_gl(ctx))
- return false;
+ bool cannot_be_winsys_fbo = true;
switch (pname) {
+ case GL_FRAMEBUFFER_DEFAULT_LAYERS:
+ /*
+ * According to the OpenGL ES 3.1 specification section 9.2.3, the
+ * GL_FRAMEBUFFER_LAYERS parameter name is not supported.
+ */
+ if (_mesa_is_gles31(ctx) && !ctx->Extensions.OES_geometry_shader) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
+ return false;
+ }
+ break;
+ case GL_FRAMEBUFFER_DEFAULT_WIDTH:
+ case GL_FRAMEBUFFER_DEFAULT_HEIGHT:
+ case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
+ case GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS:
+ break;
case GL_DOUBLEBUFFER:
case GL_IMPLEMENTATION_COLOR_READ_FORMAT:
case GL_IMPLEMENTATION_COLOR_READ_TYPE:
case GL_SAMPLES:
case GL_SAMPLE_BUFFERS:
case GL_STEREO:
- return true;
+ /* From OpenGL 4.5 spec, section 9.2.3 "Framebuffer Object Queries:
+ *
+ * "An INVALID_OPERATION error is generated by GetFramebufferParameteriv
+ * if the default framebuffer is bound to target and pname is not one
+ * of the accepted values from table 23.73, other than
+ * SAMPLE_POSITION."
+ *
+ * For OpenGL ES, using default framebuffer raises INVALID_OPERATION
+ * for any pname.
+ */
+ cannot_be_winsys_fbo = !_mesa_is_desktop_gl(ctx);
+ break;
default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
return false;
}
+
+ if (cannot_be_winsys_fbo && _mesa_is_winsys_fbo(fb)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid pname=0x%x for default framebuffer)", func, pname);
+ return false;
+ }
+
+ return true;
}
static void
get_framebuffer_parameteriv(struct gl_context *ctx, struct gl_framebuffer *fb,
GLenum pname, GLint *params, const char *func)
{
- /* From OpenGL 4.5 spec, section 9.2.3 "Framebuffer Object Queries:
- *
- * "An INVALID_OPERATION error is generated by GetFramebufferParameteriv
- * if the default framebuffer is bound to target and pname is not one
- * of the accepted values from table 23.73, other than
- * SAMPLE_POSITION."
- *
- * For OpenGL ES, using default framebuffer still raises INVALID_OPERATION
- * for any pname.
- */
- if (_mesa_is_winsys_fbo(fb) &&
- !_pname_valid_for_default_framebuffer(ctx, pname)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid pname=0x%x for default framebuffer)", func, pname);
+ if (!validate_get_framebuffer_parameteriv_pname(ctx, fb, pname, func))
return;
- }
switch (pname) {
case GL_FRAMEBUFFER_DEFAULT_WIDTH:
@@ -1536,14 +1557,6 @@ get_framebuffer_parameteriv(struct gl_context *ctx, struct gl_framebuffer *fb,
*params = fb->DefaultGeometry.Height;
break;
case GL_FRAMEBUFFER_DEFAULT_LAYERS:
- /*
- * According to the OpenGL ES 3.1 specification section 9.2.3, the
- * GL_FRAMEBUFFER_LAYERS parameter name is not supported.
- */
- if (_mesa_is_gles31(ctx) && !ctx->Extensions.OES_geometry_shader) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(pname=0x%x)", func, pname);
- break;
- }
*params = fb->DefaultGeometry.Layers;
break;
case GL_FRAMEBUFFER_DEFAULT_SAMPLES:
@@ -1570,9 +1583,6 @@ get_framebuffer_parameteriv(struct gl_context *ctx, struct gl_framebuffer *fb,
case GL_STEREO:
*params = fb->Visual.stereoMode;
break;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM,
- "%s(pname=0x%x)", func, pname);
}
}