summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2017-10-07 11:19:42 -0700
committerKenneth Graunke <[email protected]>2017-10-07 13:26:55 -0700
commit37e128b9b7fc99bc57edb031e0481658e524f1a4 (patch)
tree04fd13bb855c108b649f5830b6df29f579c6fd01 /src/mesa
parent5a47abb63e11853bf1f2f72e3c5371a720346b7d (diff)
mesa: make glFramebuffer* check immutable texture level bounds
When a texture is immutable, we can't tack on extra levels after-the-fact like we could with glTexImage. So check against that level limit and return an error if it's surpassed. This fixes: KHR-GL45.geometry_shader.layered_fbo.fb_texture_invalid_level_number (Based on a patch by Ilia Mirkin.) Reviewed-by: Antia Puentes <[email protected]> [imirkin v2] Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/fbobject.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 0867ff70fa7..f4552076a2e 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3223,11 +3223,19 @@ check_layer(struct gl_context *ctx, GLenum target, GLint layer,
* \return true if no errors, false if errors
*/
static bool
-check_level(struct gl_context *ctx, GLenum target, GLint level,
- const char *caller)
+check_level(struct gl_context *ctx, struct gl_texture_object *texObj,
+ GLenum target, GLint level, const char *caller)
{
- if ((level < 0) ||
- (level >= _mesa_max_texture_levels(ctx, target))) {
+ /* Section 9.2.8 of the OpenGL 4.6 specification says:
+ *
+ * "If texture refers to an immutable-format texture, level must be
+ * greater than or equal to zero and smaller than the value of
+ * TEXTURE_VIEW_NUM_LEVELS for texture."
+ */
+ const int max_levels = texObj->Immutable ? texObj->ImmutableLevels :
+ _mesa_max_texture_levels(ctx, target);
+
+ if (level < 0 || level >= max_levels) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(invalid level %d)", caller, level);
return false;
@@ -3393,7 +3401,7 @@ framebuffer_texture_with_dims(int dims, GLenum target,
if ((dims == 3) && !check_layer(ctx, texObj->Target, layer, caller))
return;
- if (!check_level(ctx, textarget, level, caller))
+ if (!check_level(ctx, texObj, textarget, level, caller))
return;
}
@@ -3539,7 +3547,7 @@ frame_buffer_texture(GLuint framebuffer, GLenum target,
return;
}
- if (!check_level(ctx, texObj->Target, level, func))
+ if (!check_level(ctx, texObj, texObj->Target, level, func))
return;
}