diff options
author | Eric Anholt <eric@anholt.net> | 2013-04-22 10:38:41 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-05-06 14:33:38 -0700 |
commit | 749a92786d378ee55cf9ebbbe8596c217fbae0f9 (patch) | |
tree | 57b80a3a7cc6378d6db4b8172ea56e58f3410f44 /src/mesa/main/fbobject.c | |
parent | 5b9609f59ac4e9079a6dea1212178070a45ab8e9 (diff) |
mesa: Make core Mesa allocate the texture renderbuffer wrapper.
Every driver did the same thing.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/main/fbobject.c')
-rw-r--r-- | src/mesa/main/fbobject.c | 48 |
1 files changed, 43 insertions, 5 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); } |