From: Rob Clark Date: Thu, 30 Apr 2020 00:31:56 +0000 (-0700) Subject: gallium: extract out logicop helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f78af3372131e4c2f0344396d3490abe816992cf;p=mesa.git gallium: extract out logicop helper Signed-off-by: Rob Clark Reviewed-by: Kristian H. Kristensen Part-of: --- diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 8adf343cf8a..8d656f63fa3 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -736,6 +736,32 @@ util_texrange_covers_whole_level(const struct pipe_resource *tex, depth == util_num_layers(tex, level); } +static inline bool +util_logicop_reads_dest(enum pipe_logicop op) +{ + switch (op) { + case PIPE_LOGICOP_NOR: + case PIPE_LOGICOP_AND_INVERTED: + case PIPE_LOGICOP_AND_REVERSE: + case PIPE_LOGICOP_INVERT: + case PIPE_LOGICOP_XOR: + case PIPE_LOGICOP_NAND: + case PIPE_LOGICOP_AND: + case PIPE_LOGICOP_EQUIV: + case PIPE_LOGICOP_NOOP: + case PIPE_LOGICOP_OR_INVERTED: + case PIPE_LOGICOP_OR_REVERSE: + case PIPE_LOGICOP_OR: + return true; + case PIPE_LOGICOP_CLEAR: + case PIPE_LOGICOP_COPY_INVERTED: + case PIPE_LOGICOP_COPY: + case PIPE_LOGICOP_SET: + return false; + } + unreachable("bad logicop"); +} + static inline struct pipe_context * pipe_create_multimedia_context(struct pipe_screen *screen) { diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_blend.c b/src/gallium/drivers/freedreno/a3xx/fd3_blend.c index 383e557f18e..5773ed2eef4 100644 --- a/src/gallium/drivers/freedreno/a3xx/fd3_blend.c +++ b/src/gallium/drivers/freedreno/a3xx/fd3_blend.c @@ -66,23 +66,7 @@ fd3_blend_state_create(struct pipe_context *pctx, if (cso->logicop_enable) { rop = cso->logicop_func; /* maps 1:1 */ - - switch (cso->logicop_func) { - case PIPE_LOGICOP_NOR: - case PIPE_LOGICOP_AND_INVERTED: - case PIPE_LOGICOP_AND_REVERSE: - case PIPE_LOGICOP_INVERT: - case PIPE_LOGICOP_XOR: - case PIPE_LOGICOP_NAND: - case PIPE_LOGICOP_AND: - case PIPE_LOGICOP_EQUIV: - case PIPE_LOGICOP_NOOP: - case PIPE_LOGICOP_OR_INVERTED: - case PIPE_LOGICOP_OR_REVERSE: - case PIPE_LOGICOP_OR: - reads_dest = true; - break; - } + reads_dest = util_logicop_reads_dest(cso->logicop_func); } so = CALLOC_STRUCT(fd3_blend_stateobj); diff --git a/src/gallium/drivers/freedreno/a4xx/fd4_blend.c b/src/gallium/drivers/freedreno/a4xx/fd4_blend.c index 9a728088192..9b067e0e07b 100644 --- a/src/gallium/drivers/freedreno/a4xx/fd4_blend.c +++ b/src/gallium/drivers/freedreno/a4xx/fd4_blend.c @@ -64,23 +64,7 @@ fd4_blend_state_create(struct pipe_context *pctx, if (cso->logicop_enable) { rop = cso->logicop_func; /* maps 1:1 */ - - switch (cso->logicop_func) { - case PIPE_LOGICOP_NOR: - case PIPE_LOGICOP_AND_INVERTED: - case PIPE_LOGICOP_AND_REVERSE: - case PIPE_LOGICOP_INVERT: - case PIPE_LOGICOP_XOR: - case PIPE_LOGICOP_NAND: - case PIPE_LOGICOP_AND: - case PIPE_LOGICOP_EQUIV: - case PIPE_LOGICOP_NOOP: - case PIPE_LOGICOP_OR_INVERTED: - case PIPE_LOGICOP_OR_REVERSE: - case PIPE_LOGICOP_OR: - reads_dest = true; - break; - } + reads_dest = util_logicop_reads_dest(cso->logicop_func); } so = CALLOC_STRUCT(fd4_blend_stateobj); diff --git a/src/gallium/drivers/freedreno/a5xx/fd5_blend.c b/src/gallium/drivers/freedreno/a5xx/fd5_blend.c index a7efcca6187..c98d7c5863a 100644 --- a/src/gallium/drivers/freedreno/a5xx/fd5_blend.c +++ b/src/gallium/drivers/freedreno/a5xx/fd5_blend.c @@ -65,23 +65,7 @@ fd5_blend_state_create(struct pipe_context *pctx, if (cso->logicop_enable) { rop = cso->logicop_func; /* maps 1:1 */ - - switch (cso->logicop_func) { - case PIPE_LOGICOP_NOR: - case PIPE_LOGICOP_AND_INVERTED: - case PIPE_LOGICOP_AND_REVERSE: - case PIPE_LOGICOP_INVERT: - case PIPE_LOGICOP_XOR: - case PIPE_LOGICOP_NAND: - case PIPE_LOGICOP_AND: - case PIPE_LOGICOP_EQUIV: - case PIPE_LOGICOP_NOOP: - case PIPE_LOGICOP_OR_INVERTED: - case PIPE_LOGICOP_OR_REVERSE: - case PIPE_LOGICOP_OR: - reads_dest = true; - break; - } + reads_dest = util_logicop_reads_dest(cso->logicop_func); } so = CALLOC_STRUCT(fd5_blend_stateobj); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_blend.c b/src/gallium/drivers/freedreno/a6xx/fd6_blend.c index 734f1868b01..40a99822297 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_blend.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_blend.c @@ -68,23 +68,7 @@ fd6_blend_state_create(struct pipe_context *pctx, if (cso->logicop_enable) { rop = cso->logicop_func; /* maps 1:1 */ - - switch (cso->logicop_func) { - case PIPE_LOGICOP_NOR: - case PIPE_LOGICOP_AND_INVERTED: - case PIPE_LOGICOP_AND_REVERSE: - case PIPE_LOGICOP_INVERT: - case PIPE_LOGICOP_XOR: - case PIPE_LOGICOP_NAND: - case PIPE_LOGICOP_AND: - case PIPE_LOGICOP_EQUIV: - case PIPE_LOGICOP_NOOP: - case PIPE_LOGICOP_OR_INVERTED: - case PIPE_LOGICOP_OR_REVERSE: - case PIPE_LOGICOP_OR: - reads_dest = true; - break; - } + reads_dest = util_logicop_reads_dest(cso->logicop_func); } so = CALLOC_STRUCT(fd6_blend_stateobj);