ac,radv,radeonsi: add a function for getting border color swizzle
The swizzle for 8-bit stencil shuld be also fine on RadeonSI. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29307>
This commit is contained in:
committed by
Marge Bot
parent
25a206b9ac
commit
bb09fac659
@@ -451,3 +451,39 @@ ac_is_zs_format_supported(enum pipe_format format)
|
||||
{
|
||||
return ac_translate_dbformat(format) != V_028040_Z_INVALID;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
ac_border_color_swizzle(const struct util_format_description *desc)
|
||||
{
|
||||
unsigned bc_swizzle = V_008F20_BC_SWIZZLE_XYZW;
|
||||
|
||||
if (desc->format == PIPE_FORMAT_S8_UINT) {
|
||||
/* Swizzle of 8-bit stencil format is defined as _x__ but the hw expects XYZW. */
|
||||
assert(desc->swizzle[1] == PIPE_SWIZZLE_X);
|
||||
return bc_swizzle;
|
||||
}
|
||||
|
||||
if (desc->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 (desc->swizzle[2] == PIPE_SWIZZLE_Y)
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_WZYX;
|
||||
else
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_WXYZ;
|
||||
} else if (desc->swizzle[0] == PIPE_SWIZZLE_X) {
|
||||
if (desc->swizzle[1] == PIPE_SWIZZLE_Y)
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_XYZW;
|
||||
else
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_XWYZ;
|
||||
} else if (desc->swizzle[1] == PIPE_SWIZZLE_X) {
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_YXWZ;
|
||||
} else if (desc->swizzle[2] == PIPE_SWIZZLE_X) {
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_ZYXW;
|
||||
}
|
||||
|
||||
return bc_swizzle;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,9 @@ ac_translate_dbformat(enum pipe_format format);
|
||||
bool
|
||||
ac_is_zs_format_supported(enum pipe_format format);
|
||||
|
||||
uint32_t
|
||||
ac_border_color_swizzle(const struct util_format_description *desc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -17,44 +17,9 @@
|
||||
#include "radv_image.h"
|
||||
|
||||
#include "ac_descriptors.h"
|
||||
#include "ac_formats.h"
|
||||
#include "gfx10_format_table.h"
|
||||
|
||||
static unsigned
|
||||
gfx9_border_color_swizzle(const struct util_format_description *desc)
|
||||
{
|
||||
unsigned bc_swizzle = V_008F20_BC_SWIZZLE_XYZW;
|
||||
|
||||
if (desc->format == PIPE_FORMAT_S8_UINT) {
|
||||
/* Swizzle of 8-bit stencil format is defined as _x__ but the hw expects XYZW. */
|
||||
assert(desc->swizzle[1] == PIPE_SWIZZLE_X);
|
||||
return bc_swizzle;
|
||||
}
|
||||
|
||||
if (desc->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 (desc->swizzle[2] == PIPE_SWIZZLE_Y)
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_WZYX;
|
||||
else
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_WXYZ;
|
||||
} else if (desc->swizzle[0] == PIPE_SWIZZLE_X) {
|
||||
if (desc->swizzle[1] == PIPE_SWIZZLE_Y)
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_XYZW;
|
||||
else
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_XWYZ;
|
||||
} else if (desc->swizzle[1] == PIPE_SWIZZLE_X) {
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_YXWZ;
|
||||
} else if (desc->swizzle[2] == PIPE_SWIZZLE_X) {
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_ZYXW;
|
||||
}
|
||||
|
||||
return bc_swizzle;
|
||||
}
|
||||
|
||||
static unsigned
|
||||
radv_tex_dim(VkImageType image_type, VkImageViewType view_type, unsigned nr_layers, unsigned nr_samples,
|
||||
bool is_storage_image, bool gfx9)
|
||||
@@ -200,7 +165,7 @@ gfx10_make_texture_descriptor(struct radv_device *device, struct radv_image *ima
|
||||
S_00A00C_DST_SEL_Z(radv_map_swizzle(swizzle[2])) | S_00A00C_DST_SEL_W(radv_map_swizzle(swizzle[3])) |
|
||||
S_00A00C_BASE_LEVEL(image->vk.samples > 1 ? 0 : first_level) |
|
||||
S_00A00C_LAST_LEVEL_GFX10(image->vk.samples > 1 ? util_logbase2(image->vk.samples) : last_level) |
|
||||
S_00A00C_BC_SWIZZLE(gfx9_border_color_swizzle(desc)) | S_00A00C_TYPE(type);
|
||||
S_00A00C_BC_SWIZZLE(ac_border_color_swizzle(desc)) | S_00A00C_TYPE(type);
|
||||
/* Depth is the the last accessible layer on gfx9+. The hw doesn't need
|
||||
* to know the total number of layers.
|
||||
*/
|
||||
@@ -343,7 +308,7 @@ gfx6_make_texture_descriptor(struct radv_device *device, struct radv_image *imag
|
||||
state[7] = 0;
|
||||
|
||||
if (pdev->info.gfx_level == GFX9) {
|
||||
unsigned bc_swizzle = gfx9_border_color_swizzle(desc);
|
||||
unsigned bc_swizzle = ac_border_color_swizzle(desc);
|
||||
|
||||
/* Depth is the last accessible layer on Gfx9.
|
||||
* The hw doesn't need to know the total number of layers.
|
||||
|
||||
@@ -4487,35 +4487,6 @@ void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned gfx9_border_color_swizzle(const unsigned char swizzle[4])
|
||||
{
|
||||
unsigned bc_swizzle = V_008F20_BC_SWIZZLE_XYZW;
|
||||
|
||||
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] == PIPE_SWIZZLE_Y)
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_WZYX;
|
||||
else
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_WXYZ;
|
||||
} 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] == PIPE_SWIZZLE_X) {
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_YXWZ;
|
||||
} else if (swizzle[2] == PIPE_SWIZZLE_X) {
|
||||
bc_swizzle = V_008F20_BC_SWIZZLE_ZYXW;
|
||||
}
|
||||
|
||||
return bc_swizzle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate the parameters to an image descriptor for CDNA image emulation.
|
||||
* In this function, we choose our own image descriptor format because we emulate image opcodes
|
||||
@@ -4716,7 +4687,7 @@ static void gfx10_make_texture_descriptor(
|
||||
util_format_is_compressed(res->format) &&
|
||||
!util_format_is_compressed(pipe_format)) |
|
||||
S_00A00C_LAST_LEVEL_GFX12(field_last_level) |
|
||||
S_00A00C_BC_SWIZZLE(gfx9_border_color_swizzle(desc->swizzle)) |
|
||||
S_00A00C_BC_SWIZZLE(ac_border_color_swizzle(desc)) |
|
||||
S_00A00C_TYPE(type);
|
||||
/* Depth is the the last accessible layer on gfx9+. The hw doesn't need
|
||||
* to know the total number of layers.
|
||||
@@ -4741,7 +4712,7 @@ static void gfx10_make_texture_descriptor(
|
||||
S_00A00C_DST_SEL_W(si_map_swizzle(swizzle[3])) |
|
||||
S_00A00C_BASE_LEVEL(res->nr_samples > 1 ? 0 : first_level) |
|
||||
S_00A00C_LAST_LEVEL_GFX10(res->nr_samples > 1 ? util_logbase2(res->nr_samples) : last_level) |
|
||||
S_00A00C_BC_SWIZZLE(gfx9_border_color_swizzle(desc->swizzle)) | S_00A00C_TYPE(type);
|
||||
S_00A00C_BC_SWIZZLE(ac_border_color_swizzle(desc)) | S_00A00C_TYPE(type);
|
||||
/* Depth is the the last accessible layer on gfx9+. The hw doesn't need
|
||||
* to know the total number of layers.
|
||||
*/
|
||||
@@ -4899,7 +4870,7 @@ static void si_make_texture_descriptor(struct si_screen *screen, struct si_textu
|
||||
state[7] = 0;
|
||||
|
||||
if (screen->info.gfx_level == GFX9) {
|
||||
unsigned bc_swizzle = gfx9_border_color_swizzle(desc->swizzle);
|
||||
unsigned bc_swizzle = ac_border_color_swizzle(desc);
|
||||
|
||||
/* Depth is the the last accessible layer on Gfx9.
|
||||
* The hw doesn't need to know the total number of layers.
|
||||
|
||||
Reference in New Issue
Block a user