[Mesa-dev] [PATCH 2/2] mesa: Fix glFramebufferTexture* error codes (v2)
Chad Versace
chad at kiwitree.net
Thu Aug 11 18:27:51 UTC 2016
If check_textarget() determined that textarget was incorrect, it emitted
GL_INVALID_OPERATION. This is the correct behavior when target and
textarget are mismatched but textarget is a valid textarget enum.
When textarget is not a valid textarget enum, the GL spec requires that
GL_INVALID_ENUM be emitted.
Fixes test dEQP-GLES3.functional.negative_api.buffer.framebuffer_texture2d.
v2:
- Continue emitting GL_INVALID_OPERATION when textarget is
a valid textarget enum mismatched with target. [idr and imirkin]
Cc: Ian Romanick <idr at freedesktop.org>
Cc: Ilia Mirkin <imirkin at alum.mit.edu>
Cc: Haixia Shi <hshi at chromium.org>
Change-Id: I86c492f228720ec8cf9939e741cfc99a5d9fa1bc
---
I'm now checking that textarget is a valid textarget enum with a switch
at the top of the function, which emits error GL_INVALID_ENUM. The
switch lists every textarget I know of, but I'm not confident that it's
correct.
Should some textargets not be in the switch?
src/mesa/main/fbobject.c | 33 ++++++++++++++++++++++++++-------
1 file changed, 26 insertions(+), 7 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 2c01526..76adb29 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -2979,6 +2979,32 @@ check_textarget(struct gl_context *ctx, int dims, GLenum target,
{
bool err = false;
+ /* Check that textarget is a valid textarget enum. */
+ switch (textarget) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_3D:
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid textarget %s)",
+ caller, _mesa_enum_to_string(textarget));
+ return false;
+ }
+
+ /* Check that target and textarget match. */
switch (dims) {
case 1:
switch (textarget) {
@@ -3029,13 +3055,6 @@ check_textarget(struct gl_context *ctx, int dims, GLenum target,
err = true;
}
- if (err) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(invalid textarget %s)",
- caller, _mesa_enum_to_string(textarget));
- return false;
- }
-
/* Make sure textarget is consistent with the texture's type */
err = (target == GL_TEXTURE_CUBE_MAP) ?
!_mesa_is_cube_face(textarget): (target != textarget);
--
2.9.2
More information about the mesa-dev
mailing list