gallium: add a view mask to the draw command

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>
This commit is contained in:
Dave Airlie 2021-03-04 13:52:55 +10:00 committed by Marge Bot
parent 684f97de80
commit e3b8f449e1
4 changed files with 9 additions and 2 deletions

View 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 */

View 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)

View 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;

View 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);