st: create renderbuffer's pipe_surface in st_render_texture()
authorBrian Paul <brianp@vmware.com>
Sat, 2 May 2009 00:17:34 +0000 (18:17 -0600)
committerBrian Paul <brianp@vmware.com>
Sat, 2 May 2009 00:17:34 +0000 (18:17 -0600)
Previously we created the pipe_surface during framebuffer validation.
But if we did a glCopyTex[Sub]Image() before anything else we wouldn't yet
have the surface.  This fixes that.

src/mesa/state_tracker/st_cb_fbo.c

index 1590f275e2a3c435d090b3cc2a612b6b6ba1a0f5..e003b6db5cf06f858ca80472452f28435664ba4c 100644 (file)
@@ -343,6 +343,7 @@ st_render_texture(GLcontext *ctx,
                   struct gl_framebuffer *fb,
                   struct gl_renderbuffer_attachment *att)
 {
+   struct pipe_screen *screen = ctx->st->pipe->screen;
    struct st_renderbuffer *strb;
    struct gl_renderbuffer *rb;
    struct pipe_texture *pt = st_get_texobj_texture(att->Texture);
@@ -365,6 +366,8 @@ st_render_texture(GLcontext *ctx,
    rb->AllocStorage = NULL; /* should not get called */
    strb = st_renderbuffer(rb);
 
+   assert(strb->Base.RefCount > 0);
+
    /* get the texture for the texture object */
    stObj = st_texture_object(att->Texture);
 
@@ -384,7 +387,14 @@ st_render_texture(GLcontext *ctx,
 
    pipe_surface_reference(&strb->surface, NULL);
 
-   /* the new surface will be created during framebuffer validation */
+   /* new surface for rendering into the texture */
+   strb->surface = screen->get_tex_surface(screen,
+                                           strb->texture,
+                                           strb->rtt_face,
+                                           strb->rtt_level,
+                                           strb->rtt_slice,
+                                           PIPE_BUFFER_USAGE_GPU_READ |
+                                           PIPE_BUFFER_USAGE_GPU_WRITE);
 
    init_renderbuffer_bits(strb, pt->format);