/** * Re-validate the framebuffers. */ void st_manager_validate_framebuffers(struct st_context *st) { struct st_framebuffer *stdraw = st_ws_framebuffer(st->ctx->DrawBuffer); struct st_framebuffer *stread = st_ws_framebuffer(st->ctx->ReadBuffer); if (stdraw) st_framebuffer_validate(stdraw, st); if (stread && stread != stdraw) st_framebuffer_validate(stread, st); }
/** * Add a color renderbuffer on demand. */ boolean st_manager_add_color_renderbuffer(struct st_context *st, struct gl_framebuffer *fb, gl_buffer_index idx) { struct st_framebuffer *stfb = st_ws_framebuffer(fb); /* FBO */ if (!stfb) return FALSE; if (stfb->Base.Attachment[idx].Renderbuffer) return TRUE; switch (idx) { case BUFFER_FRONT_LEFT: case BUFFER_BACK_LEFT: case BUFFER_FRONT_RIGHT: case BUFFER_BACK_RIGHT: break; default: return FALSE; break; } if (!st_framebuffer_add_renderbuffer(stfb, idx)) return FALSE; st_framebuffer_update_attachments(stfb); st_invalidate_state(st->ctx, _NEW_BUFFERS); return TRUE; }
/** * Flush the front buffer if the current context renders to the front buffer. */ void st_manager_flush_frontbuffer(struct st_context *st) { struct st_framebuffer *stfb = st_ws_framebuffer(st->ctx->DrawBuffer); struct st_renderbuffer *strb = NULL; if (stfb) strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer); if (!strb) return; /* never a dummy fb */ assert(&stfb->Base != _mesa_get_incomplete_framebuffer()); stfb->iface->flush_front(stfb->iface, ST_ATTACHMENT_FRONT_LEFT); }
static void st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi, struct st_framebuffer_iface *stfbi) { struct st_context *st = (struct st_context *) stctxi; struct st_framebuffer *stfb; /* either draw or read winsys fb */ stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer); if (!stfb || stfb->iface != stfbi) stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer); if (stfb && stfb->iface == stfbi) { p_atomic_set(&stfb->revalidate, TRUE); } else { /* This function is probably getting called when we've detected a * change in a window's size but the currently bound context is * not bound to that window. * If the st_framebuffer_iface structure had a pointer to the * corresponding st_framebuffer we'd be able to handle this. */ } }
static void st_viewport(struct gl_context *ctx) { struct st_context *st = ctx->st; struct st_framebuffer *stdraw; struct st_framebuffer *stread; if (!st->invalidate_on_gl_viewport) return; /* * Normally we'd want the state tracker manager to mark the drawables * invalid only when needed. This will force the state tracker manager * to revalidate the drawable, rather than just update the context with * the latest cached drawable info. */ stdraw = st_ws_framebuffer(st->ctx->DrawBuffer); stread = st_ws_framebuffer(st->ctx->ReadBuffer); if (stdraw) stdraw->iface_stamp = p_atomic_read(&stdraw->iface->stamp) - 1; if (stread && stread != stdraw) stread->iface_stamp = p_atomic_read(&stread->iface->stamp) - 1; }
static struct st_framebuffer * st_framebuffer_reuse_or_create(struct gl_framebuffer *fb, struct st_framebuffer_iface *stfbi) { struct st_framebuffer *cur = st_ws_framebuffer(fb), *stfb = NULL; if (cur && cur->iface == stfbi) { /* reuse the current stfb */ st_framebuffer_reference(&stfb, cur); } else { /* create a new one */ stfb = st_framebuffer_create(stfbi); } return stfb; }
static struct st_framebuffer * st_framebuffer_reuse_or_create(struct gl_framebuffer *fb, struct st_framebuffer_iface *stfbi) { struct st_framebuffer *cur = st_ws_framebuffer(fb), *stfb = NULL; /* dummy framebuffers cant be used as st_framebuffer */ if (cur && &cur->Base != _mesa_get_incomplete_framebuffer() && cur->iface == stfbi) { /* reuse the current stfb */ st_framebuffer_reference(&stfb, cur); } else { /* create a new one */ stfb = st_framebuffer_create(stfbi); } return stfb; }
/** * Add a color renderbuffer on demand. */ boolean st_manager_add_color_renderbuffer(struct st_context *st, struct gl_framebuffer *fb, gl_buffer_index idx) { struct st_framebuffer *stfb = st_ws_framebuffer(fb); /* FBO */ if (!stfb) return FALSE; if (stfb->Base.Attachment[idx].Renderbuffer) return TRUE; switch (idx) { case BUFFER_FRONT_LEFT: case BUFFER_BACK_LEFT: case BUFFER_FRONT_RIGHT: case BUFFER_BACK_RIGHT: break; default: return FALSE; break; } if (!st_framebuffer_add_renderbuffer(stfb, idx)) return FALSE; st_framebuffer_update_attachments(stfb); /* * Force a call to the state tracker manager to validate the * new renderbuffer. It might be that there is a window system * renderbuffer available. */ if(stfb->iface) stfb->iface_stamp = p_atomic_read(&stfb->iface->stamp) - 1; st_invalidate_state(st->ctx, _NEW_BUFFERS); return TRUE; }