Exemplo n.º 1
0
void st_resize_framebuffer(struct st_framebuffer *stfb,
                           uint width, uint height)
{
   struct vg_context *ctx = vg_current_context();
   struct st_renderbuffer *strb = stfb->strb;
   struct pipe_framebuffer_state *state;

   if (!ctx)
      return;

   state = &ctx->state.g3d.fb;

   /* If this is a noop, exit early and don't do the clear, etc below.
    */
   if (strb->width == width &&
       strb->height == height &&
       state->zsbuf)
      return;

   if (strb->width != width || strb->height != height)
      st_renderbuffer_alloc_storage(ctx, strb,
                                 width, height);

   if (stfb->dsrb->width != width || stfb->dsrb->height != height)
      st_renderbuffer_alloc_storage(ctx, stfb->dsrb,
                                 width, height);

   {
      VGuint i;

      memset(state, 0, sizeof(struct pipe_framebuffer_state));

      state->width  = width;
      state->height = height;

      state->nr_cbufs = 1;
      state->cbufs[0] = strb->surface;
      for (i = 1; i < PIPE_MAX_COLOR_BUFS; ++i)
         state->cbufs[i] = 0;

      state->zsbuf = stfb->dsrb->surface;

      cso_set_framebuffer(ctx->cso_context, state);
   }

   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, width, height);

   pipe_texture_reference( &stfb->blend_texture, NULL );
   stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_A8R8G8B8_UNORM,
                                        width, height);
}
Exemplo n.º 2
0
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);
   }
}