radv: Remove VK_SWIZZLE_*.

Values are the same as PIPE_SWIZZLE_*.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8797>
This commit is contained in:
Bas Nieuwenhuizen 2021-01-30 18:49:41 +01:00 committed by Marge Bot
parent 47a380f47c
commit abb2b43c9c
7 changed files with 60 additions and 71 deletions

View file

@ -6860,7 +6860,7 @@ radv_initialise_color_surface(struct radv_device *device,
memset(cb, 0, sizeof(*cb));
/* Intensity is implemented as Red, so treat it that way. */
cb->cb_color_attrib = S_028C74_FORCE_DST_ALPHA_1(desc->swizzle[3] == VK_SWIZZLE_1);
cb->cb_color_attrib = S_028C74_FORCE_DST_ALPHA_1(desc->swizzle[3] == PIPE_SWIZZLE_1);
va = radv_buffer_get_va(iview->bo) + iview->image->offset;

View file

@ -947,7 +947,7 @@ unsigned radv_translate_colorswap(VkFormat format, bool do_endian_swap)
{
const struct vk_format_description *desc = vk_format_description(format);
#define HAS_SWIZZLE(chan,swz) (desc->swizzle[chan] == VK_SWIZZLE_##swz)
#define HAS_SWIZZLE(chan,swz) (desc->swizzle[chan] == PIPE_SWIZZLE_##swz)
if (format == VK_FORMAT_B10G11R11_UFLOAT_PACK32)
return V_028C70_SWAP_STD;
@ -2000,8 +2000,8 @@ bool radv_dcc_formats_compatible(VkFormat format1,
/* Swizzles must be the same. */
for (i = 0; i < desc1->nr_channels; i++)
if (desc1->swizzle[i] <= VK_SWIZZLE_W &&
desc2->swizzle[i] <= VK_SWIZZLE_W &&
if (desc1->swizzle[i] <= PIPE_SWIZZLE_W &&
desc2->swizzle[i] <= PIPE_SWIZZLE_W &&
desc1->swizzle[i] != desc2->swizzle[i])
return false;

View file

@ -519,24 +519,24 @@ si_tile_mode_index(const struct radv_image_plane *plane, unsigned level, bool st
static unsigned radv_map_swizzle(unsigned swizzle)
{
switch (swizzle) {
case VK_SWIZZLE_Y:
case PIPE_SWIZZLE_Y:
return V_008F0C_SQ_SEL_Y;
case VK_SWIZZLE_Z:
case PIPE_SWIZZLE_Z:
return V_008F0C_SQ_SEL_Z;
case VK_SWIZZLE_W:
case PIPE_SWIZZLE_W:
return V_008F0C_SQ_SEL_W;
case VK_SWIZZLE_0:
case PIPE_SWIZZLE_0:
return V_008F0C_SQ_SEL_0;
case VK_SWIZZLE_1:
case PIPE_SWIZZLE_1:
return V_008F0C_SQ_SEL_1;
default: /* VK_SWIZZLE_X */
default: /* PIPE_SWIZZLE_X */
return V_008F0C_SQ_SEL_X;
}
}
static void
radv_compose_swizzle(const struct vk_format_description *desc,
const VkComponentMapping *mapping, enum vk_swizzle swizzle[4])
const VkComponentMapping *mapping, enum pipe_swizzle swizzle[4])
{
if (desc->format == VK_FORMAT_R64_UINT || desc->format == VK_FORMAT_R64_SINT) {
/* 64-bit formats only support storage images and storage images
@ -548,16 +548,16 @@ radv_compose_swizzle(const struct vk_format_description *desc,
* by loads to create the w component, which has to be 0 for
* NULL descriptors.
*/
swizzle[0] = VK_SWIZZLE_X;
swizzle[1] = VK_SWIZZLE_Y;
swizzle[2] = VK_SWIZZLE_1;
swizzle[3] = VK_SWIZZLE_0;
swizzle[0] = PIPE_SWIZZLE_X;
swizzle[1] = PIPE_SWIZZLE_Y;
swizzle[2] = PIPE_SWIZZLE_1;
swizzle[3] = PIPE_SWIZZLE_0;
} else if (!mapping) {
for (unsigned i = 0; i < 4; i++)
swizzle[i] = desc->swizzle[i];
} else if (desc->colorspace == VK_FORMAT_COLORSPACE_ZS) {
const unsigned char swizzle_xxxx[4] = {
VK_SWIZZLE_X, VK_SWIZZLE_0, VK_SWIZZLE_0, VK_SWIZZLE_1
PIPE_SWIZZLE_X, PIPE_SWIZZLE_0, PIPE_SWIZZLE_0, PIPE_SWIZZLE_1
};
vk_format_compose_swizzles(mapping, swizzle_xxxx, swizzle);
} else {
@ -579,7 +579,7 @@ radv_make_buffer_descriptor(struct radv_device *device,
uint64_t va = gpu_address + buffer->offset;
unsigned num_format, data_format;
int first_non_void;
enum vk_swizzle swizzle[4];
enum pipe_swizzle swizzle[4];
desc = vk_format_description(vk_format);
first_non_void = vk_format_get_first_non_void_channel(vk_format);
stride = desc->block.bits / 8;
@ -772,29 +772,29 @@ static unsigned radv_tex_dim(VkImageType image_type, VkImageViewType view_type,
}
}
static unsigned gfx9_border_color_swizzle(const enum vk_swizzle swizzle[4])
static unsigned gfx9_border_color_swizzle(const enum pipe_swizzle swizzle[4])
{
unsigned bc_swizzle = V_008F20_BC_SWIZZLE_XYZW;
if (swizzle[3] == VK_SWIZZLE_X) {
if (swizzle[3] == PIPE_SWIZZLE_X) {
/* For the pre-defined border color values (white, opaque
* black, transparent black), the only thing that matters is
* that the alpha channel winds up in the correct place
* (because the RGB channels are all the same) so either of
* these enumerations will work.
*/
if (swizzle[2] == VK_SWIZZLE_Y)
if (swizzle[2] == PIPE_SWIZZLE_Y)
bc_swizzle = V_008F20_BC_SWIZZLE_WZYX;
else
bc_swizzle = V_008F20_BC_SWIZZLE_WXYZ;
} else if (swizzle[0] == VK_SWIZZLE_X) {
if (swizzle[1] == VK_SWIZZLE_Y)
} else if (swizzle[0] == PIPE_SWIZZLE_X) {
if (swizzle[1] == PIPE_SWIZZLE_Y)
bc_swizzle = V_008F20_BC_SWIZZLE_XYZW;
else
bc_swizzle = V_008F20_BC_SWIZZLE_XWYZ;
} else if (swizzle[1] == VK_SWIZZLE_X) {
} else if (swizzle[1] == PIPE_SWIZZLE_X) {
bc_swizzle = V_008F20_BC_SWIZZLE_YXWZ;
} else if (swizzle[2] == VK_SWIZZLE_X) {
} else if (swizzle[2] == PIPE_SWIZZLE_X) {
bc_swizzle = V_008F20_BC_SWIZZLE_ZYXW;
}
@ -806,7 +806,7 @@ bool vi_alpha_is_on_msb(struct radv_device *device, VkFormat format)
const struct vk_format_description *desc = vk_format_description(format);
if (device->physical_device->rad_info.chip_class >= GFX10 && desc->nr_channels == 1)
return desc->swizzle[3] == VK_SWIZZLE_X;
return desc->swizzle[3] == PIPE_SWIZZLE_X;
return radv_translate_colorswap(format, false) <= 1;
}
@ -827,7 +827,7 @@ gfx10_make_texture_descriptor(struct radv_device *device,
uint32_t *fmask_state)
{
const struct vk_format_description *desc;
enum vk_swizzle swizzle[4];
enum pipe_swizzle swizzle[4];
unsigned img_format;
unsigned type;
@ -957,7 +957,7 @@ si_make_texture_descriptor(struct radv_device *device,
uint32_t *fmask_state)
{
const struct vk_format_description *desc;
enum vk_swizzle swizzle[4];
enum pipe_swizzle swizzle[4];
int first_non_void;
unsigned num_format, data_format, type;

View file

@ -1542,9 +1542,9 @@ static void vi_get_fast_clear_parameters(struct radv_device *device,
return;
for (int i = 0; i < 4; i++) {
int index = desc->swizzle[i] - VK_SWIZZLE_X;
if (desc->swizzle[i] < VK_SWIZZLE_X ||
desc->swizzle[i] > VK_SWIZZLE_W)
int index = desc->swizzle[i] - PIPE_SWIZZLE_X;
if (desc->swizzle[i] < PIPE_SWIZZLE_X ||
desc->swizzle[i] > PIPE_SWIZZLE_W)
continue;
if (desc->channel[i].pure_integer &&
@ -1586,9 +1586,9 @@ static void vi_get_fast_clear_parameters(struct radv_device *device,
for (int i = 0; i < 4; ++i)
if (values[i] != main_value &&
desc->swizzle[i] - VK_SWIZZLE_X != extra_channel &&
desc->swizzle[i] >= VK_SWIZZLE_X &&
desc->swizzle[i] <= VK_SWIZZLE_W)
desc->swizzle[i] - PIPE_SWIZZLE_X != extra_channel &&
desc->swizzle[i] >= PIPE_SWIZZLE_X &&
desc->swizzle[i] <= PIPE_SWIZZLE_W)
return;
*can_avoid_fast_clear_elim = true;

View file

@ -190,7 +190,7 @@ build_swizzled_components(nir_builder *builder,
nir_ssa_def **plane_values)
{
struct swizzle_info plane_swizzle = get_plane_swizzles(format);
enum vk_swizzle swizzles[4];
enum pipe_swizzle swizzles[4];
nir_ssa_def *values[4];
vk_format_compose_swizzles(&mapping, (const unsigned char[4]){0,1,2,3}, swizzles);
@ -200,20 +200,20 @@ build_swizzled_components(nir_builder *builder,
for (unsigned i = 0; i < 4; ++i) {
switch(swizzles[i]) {
case VK_SWIZZLE_X:
case VK_SWIZZLE_Y:
case VK_SWIZZLE_Z:
case VK_SWIZZLE_W: {
unsigned channel = swizzles[i] - VK_SWIZZLE_X;
case PIPE_SWIZZLE_X:
case PIPE_SWIZZLE_Y:
case PIPE_SWIZZLE_Z:
case PIPE_SWIZZLE_W: {
unsigned channel = swizzles[i] - PIPE_SWIZZLE_X;
values[i] = nir_channel(builder,
plane_values[plane_swizzle.plane[channel]],
plane_swizzle.swizzle[channel]);
break;
}
case VK_SWIZZLE_0:
case PIPE_SWIZZLE_0:
values[i] = zero;
break;
case VK_SWIZZLE_1:
case PIPE_SWIZZLE_1:
values[i] = one;
break;
default:
@ -285,7 +285,7 @@ try_lower_tex_ycbcr(const struct radv_pipeline_layout *layout,
nir_ssa_def *result = build_swizzled_components(builder, format, ycbcr_sampler->components, plane_values);
if (state.conversion->ycbcr_model != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
VkFormat first_format = vk_format_get_plane_format(format, 0);
uint32_t bits = vk_format_get_component_bits(first_format, VK_FORMAT_COLORSPACE_RGB, VK_SWIZZLE_X);
uint32_t bits = vk_format_get_component_bits(first_format, VK_FORMAT_COLORSPACE_RGB, PIPE_SWIZZLE_X);
/* TODO: swizzle and bpcs */
uint32_t bpcs[3] = {bits, bits, bits};
result = nir_convert_ycbcr_to_rgb(builder,

View file

@ -198,17 +198,6 @@ vk_format_get_first_non_void_channel(VkFormat format)
return util_format_get_first_non_void_channel(vk_format_to_pipe_format(format));
}
enum vk_swizzle {
VK_SWIZZLE_X,
VK_SWIZZLE_Y,
VK_SWIZZLE_Z,
VK_SWIZZLE_W,
VK_SWIZZLE_0,
VK_SWIZZLE_1,
VK_SWIZZLE_NONE,
VK_SWIZZLE_MAX, /**< Number of enums counter (must be last) */
};
static inline VkImageAspectFlags
vk_format_aspects(VkFormat format)
{
@ -234,21 +223,21 @@ vk_format_aspects(VkFormat format)
}
}
static inline enum vk_swizzle
static inline enum pipe_swizzle
radv_swizzle_conv(VkComponentSwizzle component, const unsigned char chan[4], VkComponentSwizzle vk_swiz)
{
if (vk_swiz == VK_COMPONENT_SWIZZLE_IDENTITY)
vk_swiz = component;
switch (vk_swiz) {
case VK_COMPONENT_SWIZZLE_ZERO:
return VK_SWIZZLE_0;
return PIPE_SWIZZLE_0;
case VK_COMPONENT_SWIZZLE_ONE:
return VK_SWIZZLE_1;
return PIPE_SWIZZLE_1;
case VK_COMPONENT_SWIZZLE_R:
case VK_COMPONENT_SWIZZLE_G:
case VK_COMPONENT_SWIZZLE_B:
case VK_COMPONENT_SWIZZLE_A:
return (enum vk_swizzle)chan[vk_swiz - VK_COMPONENT_SWIZZLE_R];
return (enum pipe_swizzle)chan[vk_swiz - VK_COMPONENT_SWIZZLE_R];
default:
unreachable("Illegal swizzle");
}
@ -256,7 +245,7 @@ radv_swizzle_conv(VkComponentSwizzle component, const unsigned char chan[4], VkC
static inline void vk_format_compose_swizzles(const VkComponentMapping *mapping,
const unsigned char swz[4],
enum vk_swizzle dst[4])
enum pipe_swizzle dst[4])
{
dst[0] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_R, swz, mapping->r);
dst[1] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_G, swz, mapping->g);
@ -280,14 +269,14 @@ static inline bool
vk_format_has_depth(const struct vk_format_description *desc)
{
return desc->colorspace == VK_FORMAT_COLORSPACE_ZS &&
desc->swizzle[0] != VK_SWIZZLE_NONE;
desc->swizzle[0] != PIPE_SWIZZLE_NONE;
}
static inline bool
vk_format_has_stencil(const struct vk_format_description *desc)
{
return desc->colorspace == VK_FORMAT_COLORSPACE_ZS &&
desc->swizzle[1] != VK_SWIZZLE_NONE;
desc->swizzle[1] != PIPE_SWIZZLE_NONE;
}
static inline bool
@ -457,13 +446,13 @@ vk_format_get_component_bits(VkFormat format,
}
switch (desc->swizzle[component]) {
case VK_SWIZZLE_X:
case PIPE_SWIZZLE_X:
return desc->channel[0].size;
case VK_SWIZZLE_Y:
case PIPE_SWIZZLE_Y:
return desc->channel[1].size;
case VK_SWIZZLE_Z:
case PIPE_SWIZZLE_Z:
return desc->channel[2].size;
case VK_SWIZZLE_W:
case PIPE_SWIZZLE_W:
return desc->channel[3].size;
default:
return 0;

View file

@ -67,13 +67,13 @@ def bool_map(value):
swizzle_map = {
SWIZZLE_X: "VK_SWIZZLE_X",
SWIZZLE_Y: "VK_SWIZZLE_Y",
SWIZZLE_Z: "VK_SWIZZLE_Z",
SWIZZLE_W: "VK_SWIZZLE_W",
SWIZZLE_0: "VK_SWIZZLE_0",
SWIZZLE_1: "VK_SWIZZLE_1",
SWIZZLE_NONE: "VK_SWIZZLE_NONE",
SWIZZLE_X: "PIPE_SWIZZLE_X",
SWIZZLE_Y: "PIPE_SWIZZLE_Y",
SWIZZLE_Z: "PIPE_SWIZZLE_Z",
SWIZZLE_W: "PIPE_SWIZZLE_W",
SWIZZLE_0: "PIPE_SWIZZLE_0",
SWIZZLE_1: "PIPE_SWIZZLE_1",
SWIZZLE_NONE: "PIPE_SWIZZLE_NONE",
}
def print_channels(format, func):