gallium: change pipe_draw_info::mode to uint8_t on MSVC to make it 1 byte large

needed by u_threaded_context

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12480>
This commit is contained in:
Marek Olšák 2021-08-19 22:51:11 -04:00
parent 8886bf9a47
commit 625f00d37c
6 changed files with 21 additions and 10 deletions

View File

@ -21,6 +21,7 @@
*/
#include "u_prim.h"
#include "pipe/p_state.h"
/** Return string name of given primitive type */
@ -32,6 +33,10 @@ u_prim_name(enum pipe_prim_type prim)
STATIC_ASSERT(sizeof(enum pipe_prim_type) == 1);
#endif
/* Draw merging in u_threaded_context requires that sizeof(mode) == 1. */
struct pipe_draw_info info;
STATIC_ASSERT(sizeof(info.mode) == 1);
static const struct debug_named_value names[] = {
DEBUG_NAMED_VALUE(PIPE_PRIM_POINTS),
DEBUG_NAMED_VALUE(PIPE_PRIM_LINES),

View File

@ -400,7 +400,7 @@ get_provoking_vertex(struct d3d12_selection_context *sel_ctx, bool *alternate)
mode = (enum pipe_prim_type)last_vertex_stage->current->nir->info.gs.output_primitive;
break;
case PIPE_SHADER_VERTEX:
mode = sel_ctx->dinfo ? sel_ctx->dinfo->mode : PIPE_PRIM_TRIANGLES;
mode = sel_ctx->dinfo ? (enum pipe_prim_type)sel_ctx->dinfo->mode : PIPE_PRIM_TRIANGLES;
break;
default:
unreachable("Tesselation shaders are not supported");

View File

@ -461,16 +461,16 @@ d3d12_draw_vbo(struct pipe_context *pctx,
unsigned index_offset = 0;
enum d3d12_surface_conversion_mode conversion_modes[PIPE_MAX_COLOR_BUFS] = {};
if (!prim_supported(dinfo->mode) ||
if (!prim_supported((enum pipe_prim_type)dinfo->mode) ||
dinfo->index_size == 1 ||
(dinfo->primitive_restart && dinfo->restart_index != 0xffff &&
dinfo->restart_index != 0xffffffff)) {
if (!dinfo->primitive_restart &&
!u_trim_pipe_prim(dinfo->mode, (unsigned *)&draws[0].count))
!u_trim_pipe_prim((enum pipe_prim_type)dinfo->mode, (unsigned *)&draws[0].count))
return;
ctx->initial_api_prim = dinfo->mode;
ctx->initial_api_prim = (enum pipe_prim_type)dinfo->mode;
util_primconvert_save_rasterizer_state(ctx->primconvert, &ctx->gfx_pipeline_state.rast->base);
util_primconvert_draw_vbo(ctx->primconvert, dinfo, drawid_offset, indirect, draws, num_draws);
return;
@ -497,13 +497,13 @@ d3d12_draw_vbo(struct pipe_context *pctx,
D3D12_SHADER_DIRTY_SAMPLERS;
/* this should *really* be fixed at a higher level than here! */
enum pipe_prim_type reduced_prim = u_reduced_prim(dinfo->mode);
enum pipe_prim_type reduced_prim = u_reduced_prim((enum pipe_prim_type)dinfo->mode);
if (reduced_prim == PIPE_PRIM_TRIANGLES &&
ctx->gfx_pipeline_state.rast->base.cull_face == PIPE_FACE_FRONT_AND_BACK)
return;
if (ctx->gfx_pipeline_state.prim_type != dinfo->mode) {
ctx->gfx_pipeline_state.prim_type = dinfo->mode;
ctx->gfx_pipeline_state.prim_type = (enum pipe_prim_type)dinfo->mode;
ctx->state_dirty |= D3D12_DIRTY_PRIM_MODE;
}
@ -640,7 +640,7 @@ d3d12_draw_vbo(struct pipe_context *pctx,
ctx->cmdlist->OMSetStencilRef(ctx->stencil_ref.ref_value[0]);
if (ctx->cmdlist_dirty & D3D12_DIRTY_PRIM_MODE)
ctx->cmdlist->IASetPrimitiveTopology(topology(dinfo->mode));
ctx->cmdlist->IASetPrimitiveTopology(topology((enum pipe_prim_type)dinfo->mode));
for (unsigned i = 0; i < ctx->num_vbs; ++i) {
if (ctx->vbs[i].buffer.resource) {

View File

@ -1787,7 +1787,7 @@ static void si_draw_vbo(struct pipe_context *ctx,
}
}
enum pipe_prim_type prim = info->mode;
enum pipe_prim_type prim = (enum pipe_prim_type)info->mode;
unsigned instance_count = info->instance_count;
/* GFX6-GFX7 treat instance_count==0 as instance_count==1. There is

View File

@ -425,7 +425,7 @@ zink_draw_vbo(struct pipe_context *pctx,
bool reads_drawid = ctx->shader_reads_drawid;
bool reads_basevertex = ctx->shader_reads_basevertex;
unsigned work_count = ctx->batch.work_count;
enum pipe_prim_type mode = dinfo->mode;
enum pipe_prim_type mode = (enum pipe_prim_type)dinfo->mode;
update_barriers(ctx, false);

View File

@ -764,7 +764,13 @@ struct pipe_draw_start_count_bias {
*/
struct pipe_draw_info
{
enum pipe_prim_type mode:8; /**< the mode of the primitive */
#if defined(__GNUC__)
/* sizeof(mode) == 1 because it's a packed enum. */
enum pipe_prim_type mode; /**< the mode of the primitive */
#else
/* sizeof(mode) == 1 is required by draw merging in u_threaded_context. */
uint8_t mode; /**< the mode of the primitive */
#endif
uint8_t index_size; /**< if 0, the draw is not indexed. */
uint8_t view_mask; /**< mask of multiviews for this draw */
bool primitive_restart:1;