radv: move some color blend helpers to radv_private.h
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20281>
This commit is contained in:

committed by
Marge Bot

parent
f7dd9e5806
commit
39dcac4f79
@@ -277,128 +277,11 @@ radv_pipeline_init_scratch(const struct radv_device *device, struct radv_pipelin
|
||||
pipeline->max_waves = max_waves;
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
si_translate_blend_function(VkBlendOp op)
|
||||
{
|
||||
switch (op) {
|
||||
case VK_BLEND_OP_ADD:
|
||||
return V_028780_COMB_DST_PLUS_SRC;
|
||||
case VK_BLEND_OP_SUBTRACT:
|
||||
return V_028780_COMB_SRC_MINUS_DST;
|
||||
case VK_BLEND_OP_REVERSE_SUBTRACT:
|
||||
return V_028780_COMB_DST_MINUS_SRC;
|
||||
case VK_BLEND_OP_MIN:
|
||||
return V_028780_COMB_MIN_DST_SRC;
|
||||
case VK_BLEND_OP_MAX:
|
||||
return V_028780_COMB_MAX_DST_SRC;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
si_translate_blend_factor(enum amd_gfx_level gfx_level, VkBlendFactor factor)
|
||||
{
|
||||
switch (factor) {
|
||||
case VK_BLEND_FACTOR_ZERO:
|
||||
return V_028780_BLEND_ZERO;
|
||||
case VK_BLEND_FACTOR_ONE:
|
||||
return V_028780_BLEND_ONE;
|
||||
case VK_BLEND_FACTOR_SRC_COLOR:
|
||||
return V_028780_BLEND_SRC_COLOR;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR:
|
||||
return V_028780_BLEND_ONE_MINUS_SRC_COLOR;
|
||||
case VK_BLEND_FACTOR_DST_COLOR:
|
||||
return V_028780_BLEND_DST_COLOR;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR:
|
||||
return V_028780_BLEND_ONE_MINUS_DST_COLOR;
|
||||
case VK_BLEND_FACTOR_SRC_ALPHA:
|
||||
return V_028780_BLEND_SRC_ALPHA;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA:
|
||||
return V_028780_BLEND_ONE_MINUS_SRC_ALPHA;
|
||||
case VK_BLEND_FACTOR_DST_ALPHA:
|
||||
return V_028780_BLEND_DST_ALPHA;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA:
|
||||
return V_028780_BLEND_ONE_MINUS_DST_ALPHA;
|
||||
case VK_BLEND_FACTOR_CONSTANT_COLOR:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_CONSTANT_COLOR_GFX11
|
||||
: V_028780_BLEND_CONSTANT_COLOR_GFX6;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_ONE_MINUS_CONSTANT_COLOR_GFX11
|
||||
: V_028780_BLEND_ONE_MINUS_CONSTANT_COLOR_GFX6;
|
||||
case VK_BLEND_FACTOR_CONSTANT_ALPHA:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_CONSTANT_ALPHA_GFX11
|
||||
: V_028780_BLEND_CONSTANT_ALPHA_GFX6;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_ONE_MINUS_CONSTANT_ALPHA_GFX11
|
||||
: V_028780_BLEND_ONE_MINUS_CONSTANT_ALPHA_GFX6;
|
||||
case VK_BLEND_FACTOR_SRC_ALPHA_SATURATE:
|
||||
return V_028780_BLEND_SRC_ALPHA_SATURATE;
|
||||
case VK_BLEND_FACTOR_SRC1_COLOR:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_SRC1_COLOR_GFX11 : V_028780_BLEND_SRC1_COLOR_GFX6;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_INV_SRC1_COLOR_GFX11
|
||||
: V_028780_BLEND_INV_SRC1_COLOR_GFX6;
|
||||
case VK_BLEND_FACTOR_SRC1_ALPHA:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_SRC1_ALPHA_GFX11 : V_028780_BLEND_SRC1_ALPHA_GFX6;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA:
|
||||
return gfx_level >= GFX11 ? V_028780_BLEND_INV_SRC1_ALPHA_GFX11
|
||||
: V_028780_BLEND_INV_SRC1_ALPHA_GFX6;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
si_translate_blend_opt_function(VkBlendOp op)
|
||||
{
|
||||
switch (op) {
|
||||
case VK_BLEND_OP_ADD:
|
||||
return V_028760_OPT_COMB_ADD;
|
||||
case VK_BLEND_OP_SUBTRACT:
|
||||
return V_028760_OPT_COMB_SUBTRACT;
|
||||
case VK_BLEND_OP_REVERSE_SUBTRACT:
|
||||
return V_028760_OPT_COMB_REVSUBTRACT;
|
||||
case VK_BLEND_OP_MIN:
|
||||
return V_028760_OPT_COMB_MIN;
|
||||
case VK_BLEND_OP_MAX:
|
||||
return V_028760_OPT_COMB_MAX;
|
||||
default:
|
||||
return V_028760_OPT_COMB_BLEND_DISABLED;
|
||||
}
|
||||
}
|
||||
|
||||
static uint32_t
|
||||
si_translate_blend_opt_factor(VkBlendFactor factor, bool is_alpha)
|
||||
{
|
||||
switch (factor) {
|
||||
case VK_BLEND_FACTOR_ZERO:
|
||||
return V_028760_BLEND_OPT_PRESERVE_NONE_IGNORE_ALL;
|
||||
case VK_BLEND_FACTOR_ONE:
|
||||
return V_028760_BLEND_OPT_PRESERVE_ALL_IGNORE_NONE;
|
||||
case VK_BLEND_FACTOR_SRC_COLOR:
|
||||
return is_alpha ? V_028760_BLEND_OPT_PRESERVE_A1_IGNORE_A0
|
||||
: V_028760_BLEND_OPT_PRESERVE_C1_IGNORE_C0;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR:
|
||||
return is_alpha ? V_028760_BLEND_OPT_PRESERVE_A0_IGNORE_A1
|
||||
: V_028760_BLEND_OPT_PRESERVE_C0_IGNORE_C1;
|
||||
case VK_BLEND_FACTOR_SRC_ALPHA:
|
||||
return V_028760_BLEND_OPT_PRESERVE_A1_IGNORE_A0;
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA:
|
||||
return V_028760_BLEND_OPT_PRESERVE_A0_IGNORE_A1;
|
||||
case VK_BLEND_FACTOR_SRC_ALPHA_SATURATE:
|
||||
return is_alpha ? V_028760_BLEND_OPT_PRESERVE_ALL_IGNORE_NONE
|
||||
: V_028760_BLEND_OPT_PRESERVE_NONE_IGNORE_A0;
|
||||
default:
|
||||
return V_028760_BLEND_OPT_PRESERVE_NONE_IGNORE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get rid of DST in the blend factors by commuting the operands:
|
||||
* func(src * DST, dst * 0) ---> func(src * 0, dst * SRC)
|
||||
*/
|
||||
static void
|
||||
void
|
||||
si_blend_remove_dst(VkBlendOp *func, VkBlendFactor *src_factor, VkBlendFactor *dst_factor,
|
||||
VkBlendFactor expected_dst, VkBlendFactor replacement_src)
|
||||
{
|
||||
@@ -414,29 +297,6 @@ si_blend_remove_dst(VkBlendOp *func, VkBlendFactor *src_factor, VkBlendFactor *d
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
si_blend_factor_uses_dst(VkBlendFactor factor)
|
||||
{
|
||||
return factor == VK_BLEND_FACTOR_DST_COLOR || factor == VK_BLEND_FACTOR_DST_ALPHA ||
|
||||
factor == VK_BLEND_FACTOR_SRC_ALPHA_SATURATE ||
|
||||
factor == VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA ||
|
||||
factor == VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
|
||||
}
|
||||
|
||||
static bool
|
||||
is_dual_src(VkBlendFactor factor)
|
||||
{
|
||||
switch (factor) {
|
||||
case VK_BLEND_FACTOR_SRC1_COLOR:
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR:
|
||||
case VK_BLEND_FACTOR_SRC1_ALPHA:
|
||||
case VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
radv_choose_spi_color_format(const struct radv_device *device, VkFormat vk_format,
|
||||
bool blend_enable, bool blend_need_alpha)
|
||||
@@ -570,7 +430,7 @@ radv_format_meta_fs_key(struct radv_device *device, VkFormat format)
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
bool
|
||||
radv_can_enable_dual_src(const struct vk_color_blend_attachment_state *att)
|
||||
{
|
||||
VkBlendOp eqRGB = att->color_blend_op;
|
||||
@@ -582,9 +442,9 @@ radv_can_enable_dual_src(const struct vk_color_blend_attachment_state *att)
|
||||
bool eqRGB_minmax = eqRGB == VK_BLEND_OP_MIN || eqRGB == VK_BLEND_OP_MAX;
|
||||
bool eqA_minmax = eqA == VK_BLEND_OP_MIN || eqA == VK_BLEND_OP_MAX;
|
||||
|
||||
if (!eqRGB_minmax && (is_dual_src(srcRGB) || is_dual_src(dstRGB)))
|
||||
if (!eqRGB_minmax && (radv_is_dual_src(srcRGB) || radv_is_dual_src(dstRGB)))
|
||||
return true;
|
||||
if (!eqA_minmax && (is_dual_src(srcA) || is_dual_src(dstA)))
|
||||
if (!eqA_minmax && (radv_is_dual_src(srcA) || radv_is_dual_src(dstA)))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user