mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
util/blend: Add helpers for normalizing inverts
To avoid duplicating piles of cases. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Italo Nicola <italonicola@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24076>
This commit is contained in:
parent
5764071f95
commit
521d596d27
1 changed files with 22 additions and 2 deletions
|
|
@ -7,6 +7,10 @@
|
|||
#ifndef UTIL_BLEND_H
|
||||
#define UTIL_BLEND_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PIPE_BLENDFACTOR_INVERT_BIT (0x10)
|
||||
|
||||
enum pipe_blendfactor {
|
||||
PIPE_BLENDFACTOR_ONE = 1,
|
||||
PIPE_BLENDFACTOR_SRC_COLOR,
|
||||
|
|
@ -19,18 +23,34 @@ enum pipe_blendfactor {
|
|||
PIPE_BLENDFACTOR_SRC1_COLOR,
|
||||
PIPE_BLENDFACTOR_SRC1_ALPHA,
|
||||
|
||||
PIPE_BLENDFACTOR_ZERO = 0x11,
|
||||
PIPE_BLENDFACTOR_ZERO = PIPE_BLENDFACTOR_INVERT_BIT | PIPE_BLENDFACTOR_ONE,
|
||||
PIPE_BLENDFACTOR_INV_SRC_COLOR,
|
||||
PIPE_BLENDFACTOR_INV_SRC_ALPHA,
|
||||
PIPE_BLENDFACTOR_INV_DST_ALPHA,
|
||||
PIPE_BLENDFACTOR_INV_DST_COLOR,
|
||||
|
||||
PIPE_BLENDFACTOR_INV_CONST_COLOR = 0x17,
|
||||
/* Intentionally weird wrapping due to Gallium trace parsing this file */
|
||||
PIPE_BLENDFACTOR_INV_CONST_COLOR = PIPE_BLENDFACTOR_INVERT_BIT
|
||||
| PIPE_BLENDFACTOR_CONST_COLOR,
|
||||
PIPE_BLENDFACTOR_INV_CONST_ALPHA,
|
||||
PIPE_BLENDFACTOR_INV_SRC1_COLOR,
|
||||
PIPE_BLENDFACTOR_INV_SRC1_ALPHA,
|
||||
};
|
||||
|
||||
static inline bool
|
||||
util_blendfactor_is_inverted(enum pipe_blendfactor factor)
|
||||
{
|
||||
/* By construction of the enum */
|
||||
return (factor & PIPE_BLENDFACTOR_INVERT_BIT);
|
||||
}
|
||||
|
||||
static inline enum pipe_blendfactor
|
||||
util_blendfactor_without_invert(enum pipe_blendfactor factor)
|
||||
{
|
||||
/* By construction of the enum */
|
||||
return (enum pipe_blendfactor)(factor & ~PIPE_BLENDFACTOR_INVERT_BIT);
|
||||
}
|
||||
|
||||
enum pipe_blend_func {
|
||||
PIPE_BLEND_ADD,
|
||||
PIPE_BLEND_SUBTRACT,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue