gallium: Add new PIPE_CAP_SURFACE_SAMPLE_COUNT
authorKristian H. Kristensen <hoegsberg@chromium.org>
Tue, 6 Nov 2018 21:08:32 +0000 (13:08 -0800)
committerKristian H. Kristensen <hoegsberg@chromium.org>
Fri, 7 Dec 2018 00:55:43 +0000 (16:55 -0800)
This new pipe cap and the new nr_samples field in pipe_surface lets a
state tracker bind a render target with a different sample count than
the resource. This allows for implementing
EXT_multisampled_render_to_texture and
EXT_multisampled_render_to_texture2.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kristian H. Kristensen <hoegsberg@chromium.org>
src/gallium/auxiliary/util/u_framebuffer.c
src/gallium/docs/source/screen.rst
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_state.h

index 5bafddc726fb73d86bb68467dda9f28a2545ea80..f569511393bcd2df35227d2974fa05ea913a95c3 100644 (file)
@@ -229,13 +229,19 @@ util_framebuffer_get_num_samples(const struct pipe_framebuffer_state *fb)
    if (!(fb->nr_cbufs || fb->zsbuf))
       return MAX2(fb->samples, 1);
 
+   /**
+    * If a driver doesn't advertise PIPE_CAP_SURFACE_SAMPLE_COUNT,
+    * pipe_surface::nr_samples will always be 0.
+    */
    for (i = 0; i < fb->nr_cbufs; i++) {
       if (fb->cbufs[i]) {
-         return MAX2(1, fb->cbufs[i]->texture->nr_samples);
+         return MAX3(1, fb->cbufs[i]->texture->nr_samples,
+                     fb->cbufs[i]->nr_samples);
       }
    }
    if (fb->zsbuf) {
-      return MAX2(1, fb->zsbuf->texture->nr_samples);
+      return MAX3(1, fb->zsbuf->texture->nr_samples,
+                  fb->zsbuf->nr_samples);
    }
 
    return 1;
index 0abd164494ce1f576c7054dbc87694eff85b7f7e..24a4d5031e5d13bb575c753d935f3c2cdace4499 100644 (file)
@@ -477,6 +477,9 @@ subpixel precision bias in bits during conservative rasterization.
   0 means no limit.
 * ``PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET``: The maximum supported value for
   of pipe_vertex_element::src_offset.
+* ``PIPE_CAP_SURFACE_SAMPLE_COUNT_TEXTURE``: Whether the driver
+  supports pipe_surface overrides of resource nr_samples. If set, will
+  enable EXT_multisampled_render_to_texture.
 
 .. _pipe_capf:
 
index e99895d30d8c271521ebb0683d5c99a3b3a71e31..6d96f1ccb5beb01096ddcf7a1df46a940f123579 100644 (file)
@@ -832,6 +832,7 @@ enum pipe_cap
    PIPE_CAP_MAX_COMBINED_HW_ATOMIC_COUNTER_BUFFERS,
    PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET,
    PIPE_CAP_MAX_VERTEX_ELEMENT_SRC_OFFSET,
+   PIPE_CAP_SURFACE_SAMPLE_COUNT,
 };
 
 /**
index fd670345aad3924dde3e345e917175b8b2635d15..38052e5fd3d5a01480dc9e8461a4d325a2cc8f0e 100644 (file)
@@ -443,6 +443,13 @@ struct pipe_surface
    uint16_t width;               /**< logical width in pixels */
    uint16_t height;              /**< logical height in pixels */
 
+   /**
+    * Number of samples for the surface.  This will be 0 if rendering
+    * should use the resource's nr_samples, or another value if the resource
+    * is bound using FramebufferTexture2DMultisampleEXT.
+    */
+   unsigned nr_samples:8;
+
    union pipe_surface_desc u;
 };