aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/texobj.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main/texobj.c')
-rw-r--r--mesalib/src/mesa/main/texobj.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 334dee77b..7c8f04db9 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -548,12 +548,13 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx,
ASSERT(maxLevels > 0);
- t->_MaxLevel =
- baseLevel + baseImage->MaxNumLevels - 1; /* 'p' in the GL spec */
- t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel);
- t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1); /* 'q' in the GL spec */
+ t->_MaxLevel = MIN3(t->MaxLevel,
+ /* 'p' in the GL spec */
+ baseLevel + baseImage->MaxNumLevels - 1,
+ /* 'q' in the GL spec */
+ maxLevels - 1);
- /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */
+ /* Compute _MaxLambda = q - p in the spec used during mipmapping */
t->_MaxLambda = (GLfloat) (t->_MaxLevel - baseLevel);
if (t->Immutable) {
@@ -1040,23 +1041,35 @@ static void
unbind_texobj_from_fbo(struct gl_context *ctx,
struct gl_texture_object *texObj)
{
- const GLuint n = (ctx->DrawBuffer == ctx->ReadBuffer) ? 1 : 2;
- GLuint i;
+ bool progress = false;
- for (i = 0; i < n; i++) {
- struct gl_framebuffer *fb = (i == 0) ? ctx->DrawBuffer : ctx->ReadBuffer;
- if (_mesa_is_user_fbo(fb)) {
- GLuint j;
- for (j = 0; j < BUFFER_COUNT; j++) {
- if (fb->Attachment[j].Type == GL_TEXTURE &&
- fb->Attachment[j].Texture == texObj) {
- /* Vertices are already flushed by _mesa_DeleteTextures */
- ctx->NewState |= _NEW_BUFFERS;
- _mesa_remove_attachment(ctx, fb->Attachment + j);
- }
- }
- }
+ /* Section 4.4.2 (Attaching Images to Framebuffer Objects), subsection
+ * "Attaching Texture Images to a Framebuffer," of the OpenGL 3.1 spec
+ * says:
+ *
+ * "If a texture object is deleted while its image is attached to one
+ * or more attachment points in the currently bound framebuffer, then
+ * it is as if FramebufferTexture* had been called, with a texture of
+ * zero, for each attachment point to which this image was attached in
+ * the currently bound framebuffer. In other words, this texture image
+ * is first detached from all attachment points in the currently bound
+ * framebuffer. Note that the texture image is specifically not
+ * detached from any other framebuffer objects. Detaching the texture
+ * image from any other framebuffer objects is the responsibility of
+ * the application."
+ */
+ if (_mesa_is_user_fbo(ctx->DrawBuffer)) {
+ progress = _mesa_detach_renderbuffer(ctx, ctx->DrawBuffer, texObj);
}
+ if (_mesa_is_user_fbo(ctx->ReadBuffer)
+ && ctx->ReadBuffer != ctx->DrawBuffer) {
+ progress = _mesa_detach_renderbuffer(ctx, ctx->ReadBuffer, texObj)
+ || progress;
+ }
+
+ if (progress)
+ /* Vertices are already flushed by _mesa_DeleteTextures */
+ ctx->NewState |= _NEW_BUFFERS;
}