From 21952f1400aff00f3a04e95e9f960318e1853cb8 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 22 Jun 2020 15:05:17 +0200 Subject: [PATCH] gallium/indices: introduce u_primconvert_config This struct allows us to pass the configuration as a struct, which can more easily be extended to take more arguemnts as long as we're careful about zero-initialization. We keep the old create-function, but implement it as a wrapper on top so we don't have to update all existing call-sites right now. Reviewed-By: Mike Blumenkrantz Reviewed-by: Gert Wollny Part-of: --- src/gallium/auxiliary/indices/u_primconvert.c | 18 +++++++++++++----- src/gallium/auxiliary/indices/u_primconvert.h | 7 +++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/indices/u_primconvert.c b/src/gallium/auxiliary/indices/u_primconvert.c index 778f174..5b3c66a 100644 --- a/src/gallium/auxiliary/indices/u_primconvert.c +++ b/src/gallium/auxiliary/indices/u_primconvert.c @@ -52,22 +52,30 @@ struct primconvert_context { struct pipe_context *pipe; - uint32_t primtypes_mask; + struct primconvert_config cfg; unsigned api_pv; }; struct primconvert_context * -util_primconvert_create(struct pipe_context *pipe, uint32_t primtypes_mask) +util_primconvert_create_config(struct pipe_context *pipe, + struct primconvert_config *cfg) { struct primconvert_context *pc = CALLOC_STRUCT(primconvert_context); if (!pc) return NULL; pc->pipe = pipe; - pc->primtypes_mask = primtypes_mask; + pc->cfg = *cfg; return pc; } +struct primconvert_context * +util_primconvert_create(struct pipe_context *pipe, uint32_t primtypes_mask) +{ + struct primconvert_config cfg = { .primtypes_mask = primtypes_mask }; + return util_primconvert_create_config(pipe, &cfg); +} + void util_primconvert_destroy(struct primconvert_context *pc) { @@ -110,7 +118,7 @@ util_primconvert_draw_vbo(struct primconvert_context *pc, enum pipe_prim_type mode = 0; unsigned index_size; - u_index_translator(pc->primtypes_mask, + u_index_translator(pc->cfg.primtypes_mask, info->mode, info->index_size, info->count, pc->api_pv, pc->api_pv, info->primitive_restart ? PR_ENABLE : PR_DISABLE, @@ -129,7 +137,7 @@ util_primconvert_draw_vbo(struct primconvert_context *pc, enum pipe_prim_type mode = 0; unsigned index_size; - u_index_generator(pc->primtypes_mask, + u_index_generator(pc->cfg.primtypes_mask, info->mode, info->start, info->count, pc->api_pv, pc->api_pv, &mode, &index_size, &new_info.count, diff --git a/src/gallium/auxiliary/indices/u_primconvert.h b/src/gallium/auxiliary/indices/u_primconvert.h index 02ee063..dfec9f9 100644 --- a/src/gallium/auxiliary/indices/u_primconvert.h +++ b/src/gallium/auxiliary/indices/u_primconvert.h @@ -31,8 +31,15 @@ struct primconvert_context; +struct primconvert_config { + uint32_t primtypes_mask; +}; + struct primconvert_context *util_primconvert_create(struct pipe_context *pipe, uint32_t primtypes_mask); +struct primconvert_context *util_primconvert_create_config(struct pipe_context *pipe, + struct primconvert_config *cfg); + void util_primconvert_destroy(struct primconvert_context *pc); void util_primconvert_save_rasterizer_state(struct primconvert_context *pc, const struct pipe_rasterizer_state -- 2.7.4