mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-10 19:00:13 +01:00
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 5ac16ed047)
This commit is contained in:
parent
312c2f047e
commit
8c384f62a2
1 changed files with 41 additions and 31 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue