st_atom_framebuffer.c File Reference

Include dependency graph for st_atom_framebuffer.c:

Go to the source code of this file.

Functions

static void update_renderbuffer_surface (struct st_context *st, struct st_renderbuffer *strb)
 When doing GL render to texture, we have to be sure that finalize_texture() didn't yank out the pipe_texture that we earlier created a surface for.
static void update_framebuffer_state (struct st_context *st)
 Update framebuffer state (color, depth, stencil, etc.

Variables

struct st_tracked_state st_update_framebuffer


Function Documentation

static void update_framebuffer_state ( struct st_context st  )  [static]

Update framebuffer state (color, depth, stencil, etc.

buffers)

Definition at line 93 of file st_atom_framebuffer.c.

References assert, st_renderbuffer::Base, pipe_framebuffer_state::cbufs, st_context::cso_context, cso_set_framebuffer(), st_context::ctx, st_context::framebuffer, FRONT_STATUS_COPY_OF_BACK, FRONT_STATUS_DIRTY, st_context::frontbuffer_status, pipe_framebuffer_state::height, pipe_framebuffer_state::num_cbufs, st_renderbuffer::rtt, st_renderbuffer(), st_context::state, st_renderbuffer::surface, update_renderbuffer_surface(), pipe_framebuffer_state::width, and pipe_framebuffer_state::zsbuf.

00094 {
00095    struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
00096    struct gl_framebuffer *fb = st->ctx->DrawBuffer;
00097    struct st_renderbuffer *strb;
00098    GLuint i, j;
00099 
00100    memset(framebuffer, 0, sizeof(*framebuffer));
00101 
00102    framebuffer->width = fb->Width;
00103    framebuffer->height = fb->Height;
00104 
00105    /*printf("------ fb size %d x %d\n", fb->Width, fb->Height);*/
00106 
00107    /* Examine Mesa's ctx->DrawBuffer->_ColorDrawBuffers state
00108     * to determine which surfaces to draw to
00109     */
00110    framebuffer->num_cbufs = 0;
00111    for (j = 0; j < MAX_DRAW_BUFFERS; j++) {
00112       for (i = 0; i < fb->_NumColorDrawBuffers[j]; i++) {
00113          strb = st_renderbuffer(fb->_ColorDrawBuffers[j][i]);
00114 
00115          /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/
00116          if (strb->rtt) {
00117             /* rendering to a GL texture, may have to update surface */
00118             update_renderbuffer_surface(st, strb);
00119          }
00120 
00121          if (strb->surface) {
00122             framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface;
00123             framebuffer->num_cbufs++;
00124          }
00125       }
00126    }
00127 
00128    strb = st_renderbuffer(fb->Attachment[BUFFER_DEPTH].Renderbuffer);
00129    if (strb) {
00130       strb = st_renderbuffer(strb->Base.Wrapped);
00131       if (strb->rtt) {
00132          /* rendering to a GL texture, may have to update surface */
00133          update_renderbuffer_surface(st, strb);
00134       }
00135 
00136       framebuffer->zsbuf = strb->surface;
00137    }
00138    else {
00139       strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
00140       if (strb) {
00141          strb = st_renderbuffer(strb->Base.Wrapped);
00142          assert(strb->surface);
00143          framebuffer->zsbuf = strb->surface;
00144       }
00145    }
00146 
00147    cso_set_framebuffer(st->cso_context, framebuffer);
00148 
00149    if (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) {
00150       if (st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) {
00151          /* XXX copy back buf to front? */
00152       }
00153       /* we're assuming we'll really draw to the front buffer */
00154       st->frontbuffer_status = FRONT_STATUS_DIRTY;
00155    }
00156 }

static void update_renderbuffer_surface ( struct st_context st,
struct st_renderbuffer strb 
) [static]

When doing GL render to texture, we have to be sure that finalize_texture() didn't yank out the pipe_texture that we earlier created a surface for.

Check for that here and create a new surface if needed.

Definition at line 50 of file st_atom_framebuffer.c.

References st_renderbuffer::Base, pipe_screen::get_tex_surface, pipe_texture::height, pipe_surface::height, pipe_texture::last_level, st_context::pipe, PIPE_BUFFER_USAGE_GPU_READ, PIPE_BUFFER_USAGE_GPU_WRITE, pipe_surface_reference(), st_texture_object::pt, st_renderbuffer::rtt, st_renderbuffer::rtt_face, st_renderbuffer::rtt_slice, pipe_context::screen, st_renderbuffer::surface, pipe_surface::texture, pipe_texture::width, and pipe_surface::width.

00052 {
00053    struct pipe_screen *screen = st->pipe->screen;
00054    struct pipe_texture *texture = strb->rtt->pt;
00055    int rtt_width = strb->Base.Width;
00056    int rtt_height = strb->Base.Height;
00057 
00058    if (!strb->surface ||
00059        strb->surface->texture != texture ||
00060        strb->surface->width != rtt_width ||
00061        strb->surface->height != rtt_height) {
00062       GLuint level;
00063       /* find matching mipmap level size */
00064       for (level = 0; level <= texture->last_level; level++) {
00065          if (texture->width[level] == rtt_width &&
00066              texture->height[level] == rtt_height) {
00067 
00068             pipe_surface_reference(&strb->surface, NULL);
00069 
00070             strb->surface = screen->get_tex_surface(screen,
00071                                               texture,
00072                                               strb->rtt_face,
00073                                               level,
00074                                               strb->rtt_slice,
00075                                               PIPE_BUFFER_USAGE_GPU_READ |
00076                                               PIPE_BUFFER_USAGE_GPU_WRITE);
00077 #if 0
00078             printf("-- alloc new surface %d x %d into tex %p\n",
00079                    strb->surface->width, strb->surface->height,
00080                    texture);
00081 #endif
00082             break;
00083          }
00084       }
00085    }
00086 }


Variable Documentation

struct st_tracked_state st_update_framebuffer

Initial value:

 {
   "st_update_framebuffer",                             
   {                                                    
      _NEW_BUFFERS,                                     
       0x8 ,                            
   },
   update_framebuffer_state                             
}

Definition at line 159 of file st_atom_framebuffer.c.


Generated on Tue Sep 29 06:25:51 2009 for Gallium3D by  doxygen 1.5.4