diff options
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/fbobject.c | 48 | ||||
-rw-r--r-- | src/mesa/main/fbobject.h | 5 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 3 |
3 files changed, 49 insertions, 7 deletions
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c index e7da58d43d2..867798cc291 100644 --- a/src/mesa/main/fbobject.c +++ b/src/mesa/main/fbobject.c @@ -341,6 +341,47 @@ _mesa_remove_attachment(struct gl_context *ctx, att->Complete = GL_TRUE; } +/** + * Create a renderbuffer which will be set up by the driver to wrap the + * texture image slice. + * + * By using a gl_renderbuffer (like user-allocated renderbuffers), drivers get + * to share most of their framebuffer rendering code between winsys, + * renderbuffer, and texture attachments. + * + * The allocated renderbuffer uses a non-zero Name so that drivers can check + * it for determining vertical orientation, but we use ~0 to make it fairly + * unambiguous with actual user (non-texture) renderbuffers. + */ +void +_mesa_update_texture_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att) +{ + struct gl_texture_image *texImage; + struct gl_renderbuffer *rb; + + texImage = _mesa_get_attachment_teximage(att); + if (!texImage) + return; + + rb = att->Renderbuffer; + if (!rb) { + rb = ctx->Driver.NewRenderbuffer(ctx, ~0); + if (!rb) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture()"); + return; + } + _mesa_reference_renderbuffer(&att->Renderbuffer, rb); + + /* This can't get called on a texture renderbuffer, so set it to NULL + * for clarity compared to user renderbuffers. + */ + rb->AllocStorage = NULL; + } + + ctx->Driver.RenderTexture(ctx, fb, att); +} /** * Bind a texture object to an attachment point. @@ -369,6 +410,7 @@ _mesa_set_texture_attachment(struct gl_context *ctx, assert(!att->Texture); _mesa_reference_texobj(&att->Texture, texObj); } + invalidate_framebuffer(fb); /* always update these fields */ att->TextureLevel = level; @@ -377,11 +419,7 @@ _mesa_set_texture_attachment(struct gl_context *ctx, att->Layered = layered; att->Complete = GL_FALSE; - if (_mesa_get_attachment_teximage(att)) { - ctx->Driver.RenderTexture(ctx, fb, att); - } - - invalidate_framebuffer(fb); + _mesa_update_texture_renderbuffer(ctx, fb, att); } diff --git a/src/mesa/main/fbobject.h b/src/mesa/main/fbobject.h index e5d096f0937..bfab6e17da7 100644 --- a/src/mesa/main/fbobject.h +++ b/src/mesa/main/fbobject.h @@ -107,6 +107,11 @@ _mesa_set_renderbuffer_attachment(struct gl_context *ctx, struct gl_renderbuffer_attachment *att, struct gl_renderbuffer *rb); +void +_mesa_update_texture_renderbuffer(struct gl_context *ctx, + struct gl_framebuffer *fb, + struct gl_renderbuffer_attachment *att); + extern void _mesa_framebuffer_renderbuffer(struct gl_context *ctx, struct gl_framebuffer *fb, diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index c48b86d1563..26fa4c38190 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -2760,8 +2760,7 @@ check_rtt_cb(GLuint key, void *data, void *userData) att->TextureLevel == level && att->CubeMapFace == face) { ASSERT(_mesa_get_attachment_teximage(att)); - /* Tell driver about the new renderbuffer texture */ - ctx->Driver.RenderTexture(ctx, ctx->DrawBuffer, att); + _mesa_update_texture_renderbuffer(ctx, ctx->DrawBuffer, att); /* Mark fb status as indeterminate to force re-validation */ fb->_Status = 0; } |