/** * Re-validate the framebuffer. */ void vg_manager_validate_framebuffer(struct vg_context *ctx) { struct st_framebuffer *stfb = ctx->draw_buffer; struct pipe_resource *pt; /* no binding surface */ if (!stfb) return; if (!p_atomic_read(&ctx->draw_buffer_invalid)) return; /* validate the fb */ if (!stfb->iface->validate(stfb->iface, &stfb->strb_att, 1, &pt) || !pt) return; p_atomic_set(&ctx->draw_buffer_invalid, FALSE); if (vg_context_update_color_rb(ctx, pt) || stfb->width != pt->width0 || stfb->height != pt->height0) ctx->state.dirty |= FRAMEBUFFER_DIRTY; stfb->width = pt->width0; stfb->height = pt->height0; }
static void vg_context_update_draw_buffer(struct vg_context *ctx, struct pipe_resource *pt) { struct st_framebuffer *stfb = ctx->draw_buffer; boolean new_cbuf, new_zsbuf, new_size; new_cbuf = vg_context_update_color_rb(ctx, pt); new_zsbuf = vg_context_update_depth_stencil_rb(ctx, pt->width0, pt->height0); new_size = (stfb->width != pt->width0 || stfb->height != pt->height0); stfb->width = pt->width0; stfb->height = pt->height0; if (new_cbuf || new_zsbuf || new_size) { struct pipe_framebuffer_state *state = &ctx->state.g3d.fb; memset(state, 0, sizeof(struct pipe_framebuffer_state)); state->width = stfb->width; state->height = stfb->height; state->nr_cbufs = 1; state->cbufs[0] = stfb->strb->surface; state->zsbuf = stfb->dsrb->surface; cso_set_framebuffer(ctx->cso_context, state); } if (new_zsbuf || new_size) { ctx->state.dirty |= VIEWPORT_DIRTY; ctx->state.dirty |= DEPTH_STENCIL_DIRTY;/*to reset the scissors*/ ctx->pipe->clear(ctx->pipe, PIPE_CLEAR_DEPTHSTENCIL, NULL, 0.0, 0); /* we need all the other state already set */ setup_new_alpha_mask(ctx, stfb); pipe_sampler_view_reference( &stfb->blend_texture_view, NULL); stfb->blend_texture_view = create_tex_and_view(ctx->pipe, PIPE_FORMAT_B8G8R8A8_UNORM, stfb->width, stfb->height); } }
/** * Re-validate the framebuffer. */ void vg_manager_validate_framebuffer(struct vg_context *ctx) { struct st_framebuffer *stfb = ctx->draw_buffer; struct pipe_resource *pt; int32_t new_stamp; /* no binding surface */ if (!stfb) return; new_stamp = p_atomic_read(&stfb->iface->stamp); if (stfb->iface_stamp != new_stamp) { do { /* validate the fb */ if (!stfb->iface->validate((struct st_context_iface *)ctx, stfb->iface, &stfb->strb_att, 1, &pt) || !pt) return; stfb->iface_stamp = new_stamp; new_stamp = p_atomic_read(&stfb->iface->stamp); } while (stfb->iface_stamp != new_stamp); if (vg_context_update_color_rb(ctx, pt) || stfb->width != pt->width0 || stfb->height != pt->height0) ++stfb->stamp; stfb->width = pt->width0; stfb->height = pt->height0; } if (ctx->draw_stamp != stfb->stamp) { ctx->state.dirty |= FRAMEBUFFER_DIRTY; ctx->draw_stamp = stfb->stamp; } }