void
lp_scene_begin_rasterization(struct lp_scene *scene)
{
   const struct pipe_framebuffer_state *fb = &scene->fb;
   int i;

   //LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
   
   for (i = 0; i < scene->fb.nr_cbufs; i++) {
      struct pipe_surface *cbuf = scene->fb.cbufs[i];
      scene->cbufs[i].stride = llvmpipe_resource_stride(cbuf->texture,
                                                        cbuf->level);

      scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture,
                                                  cbuf->face,
                                                  cbuf->level,
                                                  cbuf->zslice,
                                                  LP_TEX_USAGE_READ_WRITE,
                                                  LP_TEX_LAYOUT_LINEAR);
   }

   if (fb->zsbuf) {
      struct pipe_surface *zsbuf = scene->fb.zsbuf;
      scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->level);
      scene->zsbuf.blocksize = 
         util_format_get_blocksize(zsbuf->texture->format);

      scene->zsbuf.map = llvmpipe_resource_map(zsbuf->texture,
                                               zsbuf->face,
                                               zsbuf->level,
                                               zsbuf->zslice,
                                               LP_TEX_USAGE_READ_WRITE,
                                               LP_TEX_LAYOUT_NONE);
   }
}
Beispiel #2
0
void
lp_scene_begin_rasterization(struct lp_scene *scene)
{
   const struct pipe_framebuffer_state *fb = &scene->fb;
   int i;

   //LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);

   for (i = 0; i < scene->fb.nr_cbufs; i++) {
      struct pipe_surface *cbuf = scene->fb.cbufs[i];
      if (llvmpipe_resource_is_texture(cbuf->texture)) {
         assert(cbuf->u.tex.first_layer == cbuf->u.tex.last_layer);
         scene->cbufs[i].stride = llvmpipe_resource_stride(cbuf->texture,
                                                           cbuf->u.tex.level);

         scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture,
                                                     cbuf->u.tex.level,
                                                     cbuf->u.tex.first_layer,
                                                     LP_TEX_USAGE_READ_WRITE,
                                                     LP_TEX_LAYOUT_LINEAR);
      }
      else {
         struct llvmpipe_resource *lpr = llvmpipe_resource(cbuf->texture);
         unsigned pixstride = util_format_get_blocksize(cbuf->format);
         scene->cbufs[i].stride = cbuf->texture->width0;
         scene->cbufs[i].map = lpr->data;
         scene->cbufs[i].map += cbuf->u.buf.first_element * pixstride;
      }
   }

   if (fb->zsbuf) {
      struct pipe_surface *zsbuf = scene->fb.zsbuf;
      assert(zsbuf->u.tex.first_layer == zsbuf->u.tex.last_layer);
      scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->u.tex.level);
      scene->zsbuf.blocksize = 
         util_format_get_blocksize(zsbuf->texture->format);

      scene->zsbuf.map = llvmpipe_resource_map(zsbuf->texture,
                                               zsbuf->u.tex.level,
                                               zsbuf->u.tex.first_layer,
                                               LP_TEX_USAGE_READ_WRITE,
                                               LP_TEX_LAYOUT_NONE);
   }
}