llvmpipe: record sample info for color/depth buffers in scene
authorDave Airlie <airlied@redhat.com>
Tue, 10 Mar 2020 05:09:37 +0000 (15:09 +1000)
committerMarge Bot <eric+marge@anholt.net>
Wed, 6 May 2020 06:20:37 +0000 (06:20 +0000)
This adds the nr_samples + sample_stride to the scene records
for cbufs and zsbuf.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4122>

src/gallium/drivers/llvmpipe/lp_rast.c
src/gallium/drivers/llvmpipe/lp_rast_priv.h
src/gallium/drivers/llvmpipe/lp_scene.c
src/gallium/drivers/llvmpipe/lp_scene.h
src/gallium/drivers/llvmpipe/lp_texture.h

index 5309f306109c10bf5e3d32649d1068cc78b14854..c9027e92d4850f64d9ad191cceeb83816021ce48 100644 (file)
@@ -337,7 +337,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
          for (i = 0; i < scene->fb.nr_cbufs; i++){
             if (scene->fb.cbufs[i]) {
                stride[i] = scene->cbufs[i].stride;
-               sample_stride[i] = 0;
+               sample_stride[i] = scene->cbufs[i].sample_stride;
                color[i] = lp_rast_get_color_block_pointer(task, i, tile_x + x,
                                                           tile_y + y, inputs->layer);
             }
@@ -353,6 +353,7 @@ lp_rast_shade_tile(struct lp_rasterizer_task *task,
             depth = lp_rast_get_depth_block_pointer(task, tile_x + x,
                                                     tile_y + y, inputs->layer);
             depth_stride = scene->zsbuf.stride;
+            depth_sample_stride = scene->zsbuf.sample_stride;
          }
 
          /* Propagate non-interpolated raster state. */
@@ -438,7 +439,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
    for (i = 0; i < scene->fb.nr_cbufs; i++) {
       if (scene->fb.cbufs[i]) {
          stride[i] = scene->cbufs[i].stride;
-         sample_stride[i] = 0;
+         sample_stride[i] = scene->cbufs[i].sample_stride;
          color[i] = lp_rast_get_color_block_pointer(task, i, x, y,
                                                     inputs->layer);
       }
@@ -452,6 +453,7 @@ lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
    /* depth buffer */
    if (scene->zsbuf.map) {
       depth_stride = scene->zsbuf.stride;
+      depth_sample_stride = scene->zsbuf.sample_stride;
       depth = lp_rast_get_depth_block_pointer(task, x, y, inputs->layer);
    }
 
index 95454782977fbe4c2f8bf7f0152bd466f5e29950..d4a3e48eff4991c8c9806322c554684b2f1e0e57 100644 (file)
@@ -240,7 +240,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
    for (i = 0; i < scene->fb.nr_cbufs; i++) {
       if (scene->fb.cbufs[i]) {
          stride[i] = scene->cbufs[i].stride;
-         sample_stride[i] = 0;
+         sample_stride[i] = scene->cbufs[i].sample_stride;
          color[i] = lp_rast_get_color_block_pointer(task, i, x, y,
                                                     inputs->layer);
       }
@@ -253,6 +253,7 @@ lp_rast_shade_quads_all( struct lp_rasterizer_task *task,
 
    if (scene->zsbuf.map) {
       depth = lp_rast_get_depth_block_pointer(task, x, y, inputs->layer);
+      depth_sample_stride = scene->zsbuf.sample_stride;
       depth_stride = scene->zsbuf.stride;
    }
 
index beab118ac497564a18ed9a02460ea5d53aabff73..129f5e0b1a246cefa0eb9eb420805b6556dc4634 100644 (file)
@@ -160,6 +160,8 @@ lp_scene_begin_rasterization(struct lp_scene *scene)
       if (!cbuf) {
          scene->cbufs[i].stride = 0;
          scene->cbufs[i].layer_stride = 0;
+         scene->cbufs[i].sample_stride = 0;
+         scene->cbufs[i].nr_samples = 0;
          scene->cbufs[i].map = NULL;
          continue;
       }
@@ -169,18 +171,22 @@ lp_scene_begin_rasterization(struct lp_scene *scene)
                                                            cbuf->u.tex.level);
          scene->cbufs[i].layer_stride = llvmpipe_layer_stride(cbuf->texture,
                                                               cbuf->u.tex.level);
+         scene->cbufs[i].sample_stride = llvmpipe_sample_stride(cbuf->texture);
 
          scene->cbufs[i].map = llvmpipe_resource_map(cbuf->texture,
                                                      cbuf->u.tex.level,
                                                      cbuf->u.tex.first_layer,
                                                      LP_TEX_USAGE_READ_WRITE);
          scene->cbufs[i].format_bytes = util_format_get_blocksize(cbuf->format);
+         scene->cbufs[i].nr_samples = util_res_sample_count(cbuf->texture);
       }
       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].layer_stride = 0;
+         scene->cbufs[i].sample_stride = 0;
+         scene->cbufs[i].nr_samples = 1;
          scene->cbufs[i].map = lpr->data;
          scene->cbufs[i].map += cbuf->u.buf.first_element * pixstride;
          scene->cbufs[i].format_bytes = util_format_get_blocksize(cbuf->format);
@@ -191,7 +197,8 @@ lp_scene_begin_rasterization(struct lp_scene *scene)
       struct pipe_surface *zsbuf = scene->fb.zsbuf;
       scene->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->u.tex.level);
       scene->zsbuf.layer_stride = llvmpipe_layer_stride(zsbuf->texture, zsbuf->u.tex.level);
-
+      scene->zsbuf.sample_stride = llvmpipe_sample_stride(zsbuf->texture);
+      scene->zsbuf.nr_samples = util_res_sample_count(zsbuf->texture);
       scene->zsbuf.map = llvmpipe_resource_map(zsbuf->texture,
                                                zsbuf->u.tex.level,
                                                zsbuf->u.tex.first_layer,
@@ -545,6 +552,7 @@ void lp_scene_begin_binning(struct lp_scene *scene,
       max_layer = MIN2(max_layer, zsbuf->u.tex.last_layer - zsbuf->u.tex.first_layer);
    }
    scene->fb_max_layer = max_layer;
+   scene->fb_max_samples = util_framebuffer_get_num_samples(fb);
 }
 
 
index b4ed8817ea7136ef718c82fe3740f4ce23d0b4b5..41322baf14d07247217e3cc466795da48f803f79 100644 (file)
@@ -143,11 +143,16 @@ struct lp_scene {
       unsigned stride;
       unsigned layer_stride;
       unsigned format_bytes;
+      unsigned sample_stride;
+      unsigned nr_samples;
    } zsbuf, cbufs[PIPE_MAX_COLOR_BUFS];
 
    /* The amount of layers in the fb (minimum of all attachments) */
    unsigned fb_max_layer;
 
+   /* max samples for bound framebuffer */
+   unsigned fb_max_samples;
+
    /** the framebuffer to render the scene into */
    struct pipe_framebuffer_state fb;
 
index f7219da75f213ceb1d33a1d71ae3dc2ecc58493d..5965ef8443ff9e3e260d6d5b91df0544e6769167 100644 (file)
@@ -195,6 +195,12 @@ llvmpipe_resource_stride(struct pipe_resource *resource,
    return lpr->row_stride[level];
 }
 
+static inline unsigned
+llvmpipe_sample_stride(struct pipe_resource *resource)
+{
+   struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
+   return lpr->sample_stride;
+}
 
 void *
 llvmpipe_resource_map(struct pipe_resource *resource,