gallium: add a view mask to the draw command
authorDave Airlie <airlied@redhat.com>
Thu, 4 Mar 2021 03:52:55 +0000 (13:52 +1000)
committerMarge Bot <eric+marge@anholt.net>
Fri, 12 Mar 2021 05:05:51 +0000 (05:05 +0000)
This allows the caller to specify the view mask for this draw
in a multiview draw environment

This has been packed into the upper nibble and 2 bits of the
index size to retain the struct size as small as possible
for tc.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9399>

src/gallium/include/pipe/p_state.h
src/mesa/main/draw.c
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_draw_feedback.c

index c1c0a46..ec86837 100644 (file)
@@ -746,7 +746,8 @@ struct pipe_draw_info
 {
    enum pipe_prim_type mode:8;  /**< the mode of the primitive */
    ubyte vertices_per_patch; /**< the number of vertices per patch */
-   ubyte index_size;  /**< if 0, the draw is not indexed. */
+   unsigned index_size:4;  /**< if 0, the draw is not indexed. */
+   unsigned view_mask:6; /**< mask of multiviews for this draw */
    bool primitive_restart:1;
    bool has_user_indices:1;   /**< if true, use index.user_buffer */
    bool index_bounds_valid:1; /**< whether min_index and max_index are valid;
@@ -754,7 +755,7 @@ struct pipe_draw_info
    bool increment_draw_id:1;  /**< whether drawid increments for direct draws */
    bool take_index_buffer_ownership:1; /**< callee inherits caller's refcount
          (no need to reference indexbuf, but still needs to unreference it) */
-   char _pad:3;               /**< padding for memcmp */
+   char _pad:1;               /**< padding for memcmp */
 
    unsigned start_instance; /**< first instance id */
    unsigned instance_count; /**< number of instances */
index 118cbe0..d9442f1 100644 (file)
@@ -1336,6 +1336,7 @@ _mesa_draw_arrays(struct gl_context *ctx, GLenum mode, GLint start,
    info.start_instance = baseInstance;
    info.instance_count = numInstances;
    info.drawid = 0;
+   info.view_mask = 0;
    info.min_index = start;
    info.max_index = start + count - 1;
 
@@ -1664,6 +1665,7 @@ _mesa_MultiDrawArrays(GLenum mode, const GLint *first,
    info.start_instance = 0;
    info.instance_count = 1;
    info.drawid = 0;
+   info.view_mask = 0;
 
    for (int i = 0; i < primcount; i++) {
       draw[i].start = first[i];
@@ -1778,6 +1780,7 @@ _mesa_validated_drawrangeelements(struct gl_context *ctx, GLenum mode,
    info.start_instance = baseInstance;
    info.instance_count = numInstances;
    info.drawid = 0;
+   info.view_mask = 0;
    info.index_bias = basevertex;
    info.restart_index = ctx->Array._RestartIndex[index_size_shift];
 
@@ -2176,6 +2179,7 @@ _mesa_validated_multidrawelements(struct gl_context *ctx, GLenum mode,
    info.start_instance = 0;
    info.instance_count = 1;
    info.drawid = 0;
+   info.view_mask = 0;
    info.restart_index = ctx->Array._RestartIndex[index_size_shift];
 
    if (info.has_user_indices)
index 36f570e..ee7b2ec 100644 (file)
@@ -161,6 +161,7 @@ st_draw_vbo(struct gl_context *ctx,
    info.instance_count = num_instances;
    info.take_index_buffer_ownership = false;
    info._pad = 0;
+   info.view_mask = 0;
 
    if (ib) {
       struct gl_buffer_object *bufobj = ib->obj;
index 3900c16..ff2e754 100644 (file)
@@ -127,6 +127,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
    info.take_index_buffer_ownership = false;
    info.vertices_per_patch = ctx->TessCtrlProgram.patch_vertices;
    info.restart_index = 0;
+   info.view_mask = 0;
 
    st_flush_bitmap_cache(st);
    st_invalidate_readpix_cache(st);