st/mesa: don't set PIPE_BIND_DISPLAY_TARGET for user-created renderbuffers
authorBrian Paul <brianp@vmware.com>
Sat, 11 Feb 2012 01:57:15 +0000 (18:57 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 15 Feb 2012 21:07:43 +0000 (14:07 -0700)
The st_renderbuffer_alloc_storage() function is used to allocate both
window-system buffers and user-created renderbuffers.  The later kind
are never directly displayed so don't set PIPE_BIND_DISPLAY_TARGET for
those surfaces.

NOTE: This is a candidate for the 8.0 branch.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/mesa/state_tracker/st_cb_fbo.c

index 19bbdc5..5a3186d 100644 (file)
@@ -138,7 +138,12 @@ st_renderbuffer_alloc_storage(struct gl_context * ctx,
       if (util_format_is_depth_or_stencil(format)) {
          template.bind = PIPE_BIND_DEPTH_STENCIL;
       }
+      else if (strb->Base.Name != 0) {
+         /* this is a user-created renderbuffer */
+         template.bind = PIPE_BIND_RENDER_TARGET;
+      }
       else {
+         /* this is a window-system buffer */
          template.bind = (PIPE_BIND_DISPLAY_TARGET |
                           PIPE_BIND_RENDER_TARGET);
       }
@@ -198,6 +203,7 @@ st_new_renderbuffer(struct gl_context *ctx, GLuint name)
 {
    struct st_renderbuffer *strb = ST_CALLOC_STRUCT(st_renderbuffer);
    if (strb) {
+      assert(name != 0);
       _mesa_init_renderbuffer(&strb->Base, name);
       strb->Base.Delete = st_renderbuffer_delete;
       strb->Base.AllocStorage = st_renderbuffer_alloc_storage;