summaryrefslogtreecommitdiffstats
path: root/src/freedreno
diff options
context:
space:
mode:
authorJonathan Marek <[email protected]>2020-02-12 19:57:49 -0500
committerMarge Bot <[email protected]>2020-02-28 12:48:11 +0000
commit80ceebcdd10450d5d465f4a0917196da006ba479 (patch)
tree00e92783390611c1b0abb3b18cb831bbc9ac9d21 /src/freedreno
parent89c6ef4233583469f30b266fcec8486f5d7d2b5a (diff)
turnip: rework format table to support r5g5b5a1_unorm/b5g5r5a1_unorm
These formats are an exception that can't be modeled in the current format table. Switch to a table with only a single a6xx_format per vk format, and deal with the exceptions separately (currently the only exception is 10_10_10_2_UNORM which has a different color format). Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3806>
Diffstat (limited to 'src/freedreno')
-rw-r--r--src/freedreno/vulkan/tu_blit.c42
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c20
-rw-r--r--src/freedreno/vulkan/tu_formats.c142
-rw-r--r--src/freedreno/vulkan/tu_image.c15
-rw-r--r--src/freedreno/vulkan/tu_meta_clear.c4
-rw-r--r--src/freedreno/vulkan/tu_pipeline.c8
-rw-r--r--src/freedreno/vulkan/tu_private.h21
7 files changed, 138 insertions, 114 deletions
diff --git a/src/freedreno/vulkan/tu_blit.c b/src/freedreno/vulkan/tu_blit.c
index a81a2f0c119..bdd45d0db77 100644
--- a/src/freedreno/vulkan/tu_blit.c
+++ b/src/freedreno/vulkan/tu_blit.c
@@ -58,22 +58,17 @@ blit_copy_format(VkFormat format)
}
static uint32_t
-blit_image_info(const struct tu_blit_surf *img, bool src, bool stencil_read)
+blit_image_info(const struct tu_blit_surf *img, struct tu_native_format fmt, bool stencil_read)
{
- const struct tu_native_format *fmt = tu6_get_native_format(img->fmt);
- enum a6xx_format rb = fmt->rb;
- enum a3xx_color_swap swap = img->tiled ? WZYX : fmt->swap;
- if (rb == FMT6_10_10_10_2_UNORM_DEST && src)
- rb = FMT6_10_10_10_2_UNORM;
- if (rb == FMT6_Z24_UNORM_S8_UINT)
- rb = FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8;
+ if (fmt.fmt == FMT6_Z24_UNORM_S8_UINT)
+ fmt.fmt = FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8;
if (stencil_read)
- swap = XYZW;
+ fmt.swap = XYZW;
- return A6XX_SP_PS_2D_SRC_INFO_COLOR_FORMAT(rb) |
+ return A6XX_SP_PS_2D_SRC_INFO_COLOR_FORMAT(fmt.fmt) |
A6XX_SP_PS_2D_SRC_INFO_TILE_MODE(img->tile_mode) |
- A6XX_SP_PS_2D_SRC_INFO_COLOR_SWAP(swap) |
+ A6XX_SP_PS_2D_SRC_INFO_COLOR_SWAP(fmt.swap) |
COND(vk_format_is_srgb(img->fmt), A6XX_SP_PS_2D_SRC_INFO_SRGB) |
COND(img->ubwc_size, A6XX_SP_PS_2D_SRC_INFO_FLAGS);
}
@@ -84,11 +79,13 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
{
struct tu_physical_device *phys_dev = cmdbuf->device->physical_device;
- enum a6xx_format fmt = tu6_get_native_format(blt->dst.fmt)->rb;
- if (fmt == FMT6_Z24_UNORM_S8_UINT)
- fmt = FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8;
+ struct tu_native_format dfmt = tu6_format_color(blt->dst.fmt, blt->dst.tiled);
+ struct tu_native_format sfmt = tu6_format_texture(blt->src.fmt, blt->src.tiled);
- enum a6xx_2d_ifmt ifmt = tu6_fmt_to_ifmt(fmt);
+ if (dfmt.fmt == FMT6_Z24_UNORM_S8_UINT)
+ dfmt.fmt = FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8;
+
+ enum a6xx_2d_ifmt ifmt = tu6_fmt_to_ifmt(dfmt.fmt);
if (vk_format_is_srgb(blt->dst.fmt)) {
assert(ifmt == R2D_UNORM8);
@@ -97,8 +94,9 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
uint32_t blit_cntl = A6XX_RB_2D_BLIT_CNTL_ROTATE(blt->rotation) |
COND(blt->type == TU_BLIT_CLEAR, A6XX_RB_2D_BLIT_CNTL_SOLID_COLOR) |
- A6XX_RB_2D_BLIT_CNTL_COLOR_FORMAT(fmt) | /* not required? */
- COND(fmt == FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8, A6XX_RB_2D_BLIT_CNTL_D24S8) |
+ A6XX_RB_2D_BLIT_CNTL_COLOR_FORMAT(dfmt.fmt) | /* not required? */
+ COND(dfmt.fmt == FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8,
+ A6XX_RB_2D_BLIT_CNTL_D24S8) |
A6XX_RB_2D_BLIT_CNTL_MASK(0xf) |
A6XX_RB_2D_BLIT_CNTL_IFMT(ifmt);
@@ -119,7 +117,7 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
tu_cs_emit(cs, blt->clear_value[3]);
} else {
tu_cs_emit_pkt4(cs, REG_A6XX_SP_PS_2D_SRC_INFO, 10);
- tu_cs_emit(cs, blit_image_info(&blt->src, true, blt->stencil_read) |
+ tu_cs_emit(cs, blit_image_info(&blt->src, sfmt, blt->stencil_read) |
A6XX_SP_PS_2D_SRC_INFO_SAMPLES(tu_msaa_samples(blt->src.samples)) |
/* TODO: should disable this bit for integer formats ? */
COND(blt->src.samples > 1, A6XX_SP_PS_2D_SRC_INFO_SAMPLES_AVERAGE) |
@@ -151,7 +149,7 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
* Emit destination:
*/
tu_cs_emit_pkt4(cs, REG_A6XX_RB_2D_DST_INFO, 9);
- tu_cs_emit(cs, blit_image_info(&blt->dst, false, false));
+ tu_cs_emit(cs, blit_image_info(&blt->dst, dfmt, false));
tu_cs_emit_qw(cs, blt->dst.va);
tu_cs_emit(cs, A6XX_RB_2D_DST_SIZE_PITCH(blt->dst.pitch));
tu_cs_emit(cs, 0x00000000);
@@ -189,13 +187,13 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs,
tu_cs_emit_pkt4(cs, REG_A6XX_RB_UNKNOWN_8C01, 1);
tu_cs_emit(cs, 0);
- if (fmt == FMT6_10_10_10_2_UNORM_DEST)
- fmt = FMT6_16_16_16_16_FLOAT;
+ if (dfmt.fmt == FMT6_10_10_10_2_UNORM_DEST)
+ dfmt.fmt = FMT6_16_16_16_16_FLOAT;
tu_cs_emit_pkt4(cs, REG_A6XX_SP_2D_SRC_FORMAT, 1);
tu_cs_emit(cs, COND(vk_format_is_sint(blt->src.fmt), A6XX_SP_2D_SRC_FORMAT_SINT) |
COND(vk_format_is_uint(blt->src.fmt), A6XX_SP_2D_SRC_FORMAT_UINT) |
- A6XX_SP_2D_SRC_FORMAT_COLOR_FORMAT(fmt) |
+ A6XX_SP_2D_SRC_FORMAT_COLOR_FORMAT(dfmt.fmt) |
COND(ifmt == R2D_UNORM8_SRGB, A6XX_SP_2D_SRC_FORMAT_SRGB) |
A6XX_SP_2D_SRC_FORMAT_MASK(0xf));
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index 2a513c911f4..5c99808b004 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -495,15 +495,14 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
if (vk_format_is_srgb(iview->vk_format))
srgb_cntl |= (1 << i);
- const struct tu_native_format *format =
- tu6_get_native_format(iview->vk_format);
- assert(format && format->rb >= 0);
+ const struct tu_native_format format =
+ tu6_format_color(iview->vk_format, iview->image->layout.tile_mode);
tu_cs_emit_regs(cs,
A6XX_RB_MRT_BUF_INFO(i,
.color_tile_mode = tile_mode,
- .color_format = format->rb,
- .color_swap = format->swap),
+ .color_format = format.fmt,
+ .color_swap = format.swap),
A6XX_RB_MRT_PITCH(i, tu_image_stride(iview->image, iview->base_mip)),
A6XX_RB_MRT_ARRAY_PITCH(i, iview->image->layout.layer_size),
A6XX_RB_MRT_BASE(i, tu_image_view_base_ref(iview)),
@@ -511,7 +510,7 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
tu_cs_emit_regs(cs,
A6XX_SP_FS_MRT_REG(i,
- .color_format = format->rb,
+ .color_format = format.fmt,
.color_sint = vk_format_is_sint(iview->vk_format),
.color_uint = vk_format_is_uint(iview->vk_format)));
@@ -678,9 +677,8 @@ tu6_emit_blit_info(struct tu_cmd_buffer *cmd,
tu_cs_emit_regs(cs,
A6XX_RB_BLIT_INFO(.unk0 = !resolve, .gmem = !resolve));
- const struct tu_native_format *format =
- tu6_get_native_format(iview->vk_format);
- assert(format && format->rb >= 0);
+ const struct tu_native_format format =
+ tu6_format_color(iview->vk_format, iview->image->layout.tile_mode);
enum a6xx_tile_mode tile_mode =
tu6_get_image_tile_mode(iview->image, iview->base_mip);
@@ -688,8 +686,8 @@ tu6_emit_blit_info(struct tu_cmd_buffer *cmd,
A6XX_RB_BLIT_DST_INFO(
.tile_mode = tile_mode,
.samples = tu_msaa_samples(iview->image->samples),
- .color_format = format->rb,
- .color_swap = format->swap,
+ .color_format = format.fmt,
+ .color_swap = format.swap,
.flags = iview->image->layout.ubwc_layer_size != 0),
A6XX_RB_BLIT_DST(tu_image_view_base_ref(iview)),
A6XX_RB_BLIT_DST_PITCH(tu_image_stride(iview->image, iview->base_mip)),
diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c
index 660557b043e..05dd0e87f02 100644
--- a/src/freedreno/vulkan/tu_formats.c
+++ b/src/freedreno/vulkan/tu_formats.c
@@ -36,47 +36,22 @@
#include "vk_util.h"
#include "drm-uapi/drm_fourcc.h"
-/**
- * Declare a format table. A format table is an array of tu_native_format.
- * It can map a consecutive range of VkFormat to the corresponding
- * tu_native_format.
- *
- * TU_FORMAT_TABLE_FIRST and TU_FORMAT_TABLE_LAST must already be defined and
- * have the values of the first and last VkFormat of the array respectively.
- */
-#define TU_FORMAT_TABLE(var) \
- static const VkFormat var##_first = TU_FORMAT_TABLE_FIRST; \
- static const VkFormat var##_last = TU_FORMAT_TABLE_LAST; \
- static const struct tu_native_format var[TU_FORMAT_TABLE_LAST - TU_FORMAT_TABLE_FIRST + 1]
-#undef TU_FORMAT_TABLE_FIRST
-#undef TU_FORMAT_TABLE_LAST
-
#define FMT6_x -1
-#define TU6_FMT(vkfmt, vtxfmt, texfmt, rbfmt, swapfmt, valid) \
- [VK_FORMAT_##vkfmt - TU_FORMAT_TABLE_FIRST] = { \
- .vtx = FMT6_##vtxfmt, \
- .tex = FMT6_##texfmt, \
- .rb = (FMT6_##rbfmt == FMT6_10_10_10_2_UNORM) ? FMT6_10_10_10_2_UNORM_DEST : FMT6_##rbfmt, \
- .swap = swapfmt, \
- .present = valid, \
+#define TU6_FMT(vkfmt, hwfmt, swapfmt, valid) \
+ [VK_FORMAT_##vkfmt] = { \
+ .fmt = FMT6_##hwfmt, \
+ .swap = swapfmt, \
+ .supported = valid, \
}
-/**
- * fmt/alias/swap are derived from VkFormat mechanically (and might not even
- * exist). It is the macro of choice that decides whether a VkFormat is
- * supported and how.
- */
-#define TU6_VTC(vk, fmt, swap) TU6_FMT(vk, fmt, fmt, fmt, swap, true)
-#define TU6_xTC(vk, fmt, swap) TU6_FMT(vk, x, fmt, fmt, swap, true)
-#define TU6_VTx(vk, fmt, swap) TU6_FMT(vk, fmt, fmt, x, swap, true)
-#define TU6_Vxx(vk, fmt, swap) TU6_FMT(vk, fmt, x, x, swap, true)
-#define TU6_xTx(vk, fmt, swap) TU6_FMT(vk, x, fmt, x, swap, true)
-#define TU6_xxx(vk, fmt, swap) TU6_FMT(vk, x, x, x, WZYX, false)
-
-#define TU_FORMAT_TABLE_FIRST VK_FORMAT_UNDEFINED
-#define TU_FORMAT_TABLE_LAST VK_FORMAT_ASTC_12x12_SRGB_BLOCK
-TU_FORMAT_TABLE(tu6_format_table0) = {
+#define TU6_VTC(vk, fmt, swap) TU6_FMT(vk, fmt, swap, FMT_VERTEX | FMT_TEXTURE | FMT_COLOR)
+#define TU6_xTC(vk, fmt, swap) TU6_FMT(vk, fmt, swap, FMT_TEXTURE | FMT_COLOR)
+#define TU6_Vxx(vk, fmt, swap) TU6_FMT(vk, fmt, swap, FMT_VERTEX)
+#define TU6_xTx(vk, fmt, swap) TU6_FMT(vk, fmt, swap, FMT_TEXTURE)
+#define TU6_xxx(vk, fmt, swap) TU6_FMT(vk, x, WZYX, false)
+
+static const struct tu_native_format tu6_format_table[] = {
TU6_xxx(UNDEFINED, x, x), /* 0 */
/* 8-bit packed */
@@ -311,26 +286,71 @@ TU_FORMAT_TABLE(tu6_format_table0) = {
TU6_xTx(ASTC_12x12_UNORM_BLOCK, ASTC_12x12, WZYX), /* 183 */
TU6_xTx(ASTC_12x12_SRGB_BLOCK, ASTC_12x12, WZYX), /* 184 */
};
-#undef TU_FORMAT_TABLE_FIRST
-#undef TU_FORMAT_TABLE_LAST
-const struct tu_native_format *
+struct tu_native_format
tu6_get_native_format(VkFormat format)
{
- const struct tu_native_format *fmt = NULL;
+ struct tu_native_format fmt = {};
- if (format >= tu6_format_table0_first && format <= tu6_format_table0_last)
- fmt = &tu6_format_table0[format - tu6_format_table0_first];
+ if (format >= ARRAY_SIZE(tu6_format_table))
+ return fmt;
- if (!fmt || !fmt->present)
- return NULL;
+ if (!tu6_format_table[format].supported)
+ return fmt;
if (vk_format_to_pipe_format(format) == PIPE_FORMAT_NONE) {
tu_finishme("vk_format %d missing matching pipe format.\n", format);
- return NULL;
+ return fmt;
}
- return (fmt && fmt->present) ? fmt : NULL;
+ return tu6_format_table[format];
+}
+
+struct tu_native_format
+tu6_format_vtx(VkFormat format)
+{
+ struct tu_native_format fmt = tu6_get_native_format(format);
+ assert(fmt.supported & FMT_VERTEX);
+ return fmt;
+}
+
+enum a6xx_format
+tu6_format_gmem(VkFormat format)
+{
+ struct tu_native_format fmt = tu6_get_native_format(format);
+ assert(fmt.supported & FMT_COLOR);
+
+ if (fmt.fmt == FMT6_10_10_10_2_UNORM)
+ return FMT6_10_10_10_2_UNORM_DEST;
+
+ return fmt.fmt;
+}
+
+struct tu_native_format
+tu6_format_color(VkFormat format, bool tiled)
+{
+ struct tu_native_format fmt = tu6_get_native_format(format);
+ assert(fmt.supported & FMT_COLOR);
+
+ if (fmt.fmt == FMT6_10_10_10_2_UNORM)
+ fmt.fmt = FMT6_10_10_10_2_UNORM_DEST;
+
+ if (tiled)
+ fmt.swap = WZYX;
+
+ return fmt;
+}
+
+struct tu_native_format
+tu6_format_texture(VkFormat format, bool tiled)
+{
+ struct tu_native_format fmt = tu6_get_native_format(format);
+ assert(fmt.supported & FMT_TEXTURE);
+
+ if (tiled)
+ fmt.swap = WZYX;
+
+ return fmt;
}
enum a6xx_2d_ifmt
@@ -392,6 +412,7 @@ tu6_fmt_to_ifmt(enum a6xx_format fmt)
case FMT6_16_16_FLOAT:
case FMT6_16_16_16_16_FLOAT:
case FMT6_11_11_10_FLOAT:
+ case FMT6_10_10_10_2_UNORM:
case FMT6_10_10_10_2_UNORM_DEST:
return R2D_FLOAT16;
@@ -658,7 +679,7 @@ tu_2d_clear_color(const VkClearColorValue *val, VkFormat format, uint32_t buf[4]
return;
}
- enum a6xx_2d_ifmt ifmt = tu6_fmt_to_ifmt(tu6_get_native_format(format)->rb);
+ enum a6xx_2d_ifmt ifmt = tu6_fmt_to_ifmt(tu6_get_native_format(format).fmt);
assert(desc && (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN ||
format == VK_FORMAT_B10G11R11_UFLOAT_PACK32));
@@ -725,26 +746,29 @@ tu_physical_device_get_format_properties(
{
VkFormatFeatureFlags linear = 0, optimal = 0, buffer = 0;
const struct util_format_description *desc = vk_format_description(format);
- const struct tu_native_format *native_fmt = tu6_get_native_format(format);
- if (!desc || !native_fmt) {
+ const struct tu_native_format native_fmt = tu6_get_native_format(format);
+ if (!desc || !native_fmt.supported) {
goto end;
}
buffer |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
- if (native_fmt->vtx >= 0) {
+ if (native_fmt.supported & FMT_VERTEX)
buffer |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT;
- }
-
- if (native_fmt->tex >= 0 || native_fmt->rb >= 0)
- optimal |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
- if (native_fmt->tex >= 0) {
- optimal |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
+ if (native_fmt.supported & FMT_TEXTURE) {
+ optimal |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
+ VK_FORMAT_FEATURE_TRANSFER_DST_BIT |
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
buffer |= VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT;
}
- if (native_fmt->rb >= 0)
- optimal |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT;
+ if (native_fmt.supported & FMT_COLOR) {
+ assert(native_fmt.supported & FMT_TEXTURE);
+ optimal |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT |
+ VK_FORMAT_FEATURE_BLIT_SRC_BIT |
+ VK_FORMAT_FEATURE_BLIT_DST_BIT;
+ }
/* For the most part, we can do anything with a linear image that we could
* do with a tiled image. However, we can't support sysmem rendering with a
diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c
index a9ed203439a..9f22c93e0ed 100644
--- a/src/freedreno/vulkan/tu_image.c
+++ b/src/freedreno/vulkan/tu_image.c
@@ -275,7 +275,8 @@ tu_image_view_init(struct tu_image_view *iview,
memset(iview->descriptor, 0, sizeof(iview->descriptor));
- const struct tu_native_format *fmt = tu6_get_native_format(iview->vk_format);
+ struct tu_native_format fmt =
+ tu6_format_texture(iview->vk_format, image->layout.tile_mode);
uint64_t base_addr = tu_image_base(image, iview->base_mip, iview->base_layer);
uint64_t ubwc_addr = tu_image_ubwc_base(image, iview->base_mip, iview->base_layer);
@@ -286,7 +287,7 @@ tu_image_view_init(struct tu_image_view *iview,
uint32_t depth = pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_3D ?
u_minify(image->extent.depth, iview->base_mip) : iview->layer_count;
- unsigned fmt_tex = fmt->tex;
+ unsigned fmt_tex = fmt.fmt;
if (iview->aspect_mask == VK_IMAGE_ASPECT_STENCIL_BIT &&
iview->vk_format == VK_FORMAT_D24_UNORM_S8_UINT)
fmt_tex = FMT6_S8Z24_UINT;
@@ -296,7 +297,7 @@ tu_image_view_init(struct tu_image_view *iview,
COND(vk_format_is_srgb(iview->vk_format), A6XX_TEX_CONST_0_SRGB) |
A6XX_TEX_CONST_0_FMT(fmt_tex) |
A6XX_TEX_CONST_0_SAMPLES(tu_msaa_samples(image->samples)) |
- A6XX_TEX_CONST_0_SWAP(image->layout.tile_mode ? WZYX : fmt->swap) |
+ A6XX_TEX_CONST_0_SWAP(fmt.swap) |
tu6_texswiz(&pCreateInfo->components, iview->vk_format, iview->aspect_mask) |
A6XX_TEX_CONST_0_MIPLVLS(iview->level_count - 1);
iview->descriptor[1] = A6XX_TEX_CONST_1_WIDTH(width) | A6XX_TEX_CONST_1_HEIGHT(height);
@@ -332,7 +333,7 @@ tu_image_view_init(struct tu_image_view *iview,
memset(iview->storage_descriptor, 0, sizeof(iview->storage_descriptor));
iview->storage_descriptor[0] =
- A6XX_IBO_0_FMT(fmt->tex) |
+ A6XX_IBO_0_FMT(fmt.fmt) |
A6XX_IBO_0_TILE_MODE(tile_mode);
iview->storage_descriptor[1] =
A6XX_IBO_1_WIDTH(width) |
@@ -518,7 +519,7 @@ tu_buffer_view_init(struct tu_buffer_view *view,
enum VkFormat vfmt = pCreateInfo->format;
enum pipe_format pfmt = vk_format_to_pipe_format(vfmt);
- const struct tu_native_format *fmt = tu6_get_native_format(vfmt);
+ const struct tu_native_format fmt = tu6_format_texture(vfmt, false);
uint32_t range;
if (pCreateInfo->range == VK_WHOLE_SIZE)
@@ -540,8 +541,8 @@ tu_buffer_view_init(struct tu_buffer_view *view,
view->descriptor[0] =
A6XX_TEX_CONST_0_TILE_MODE(TILE6_LINEAR) |
- A6XX_TEX_CONST_0_SWAP(fmt->swap) |
- A6XX_TEX_CONST_0_FMT(fmt->tex) |
+ A6XX_TEX_CONST_0_SWAP(fmt.swap) |
+ A6XX_TEX_CONST_0_FMT(fmt.fmt) |
A6XX_TEX_CONST_0_MIPLVLS(0) |
tu6_texswiz(&components, vfmt, VK_IMAGE_ASPECT_COLOR_BIT);
COND(vk_format_is_srgb(vfmt), A6XX_TEX_CONST_0_SRGB);
diff --git a/src/freedreno/vulkan/tu_meta_clear.c b/src/freedreno/vulkan/tu_meta_clear.c
index 1454afe68f2..b3a7354c286 100644
--- a/src/freedreno/vulkan/tu_meta_clear.c
+++ b/src/freedreno/vulkan/tu_meta_clear.c
@@ -133,11 +133,9 @@ tu_clear_gmem_attachment(struct tu_cmd_buffer *cmd,
const VkClearValue *value)
{
VkFormat fmt = cmd->state.pass->attachments[attachment].format;
- const struct tu_native_format *format = tu6_get_native_format(fmt);
- assert(format && format->rb >= 0);
tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_DST_INFO, 1);
- tu_cs_emit(cs, A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(format->rb));
+ tu_cs_emit(cs, A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(tu6_format_gmem(fmt)));
tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_INFO, 1);
tu_cs_emit(cs, A6XX_RB_BLIT_INFO_GMEM | A6XX_RB_BLIT_INFO_CLEAR_MASK(component_mask));
diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c
index ba13e7b4008..d1dc5644cc6 100644
--- a/src/freedreno/vulkan/tu_pipeline.c
+++ b/src/freedreno/vulkan/tu_pipeline.c
@@ -1116,13 +1116,11 @@ tu6_emit_vertex_input(struct tu_cs *cs,
tu_find_vertex_input_binding(vi_info, vi_attr);
assert(vi_attr && vi_binding);
- const struct tu_native_format *format =
- tu6_get_native_format(vi_attr->format);
- assert(format && format->vtx >= 0);
+ const struct tu_native_format format = tu6_format_vtx(vi_attr->format);
uint32_t vfd_decode = A6XX_VFD_DECODE_INSTR_IDX(vfd_decode_idx) |
- A6XX_VFD_DECODE_INSTR_FORMAT(format->vtx) |
- A6XX_VFD_DECODE_INSTR_SWAP(format->swap) |
+ A6XX_VFD_DECODE_INSTR_FORMAT(format.fmt) |
+ A6XX_VFD_DECODE_INSTR_SWAP(format.swap) |
A6XX_VFD_DECODE_INSTR_UNK30;
if (vi_binding->inputRate == VK_VERTEX_INPUT_RATE_INSTANCE)
vfd_decode |= A6XX_VFD_DECODE_INSTR_INSTANCED;
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index faaf86cd05f..f0b6943f465 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -1261,17 +1261,24 @@ struct tu_graphics_pipeline_create_info
uint32_t custom_blend_mode;
};
+enum tu_supported_formats {
+ FMT_VERTEX = 1,
+ FMT_TEXTURE = 2,
+ FMT_COLOR = 4,
+};
+
struct tu_native_format
{
- int vtx; /* VFMTn_xxx or -1 */
- int tex; /* TFMTn_xxx or -1 */
- int rb; /* RBn_xxx or -1 */
- int swap; /* enum a3xx_color_swap */
- bool present; /* internal only; always true to external users */
+ enum a6xx_format fmt : 8;
+ enum a3xx_color_swap swap : 8;
+ enum tu_supported_formats supported : 8;
};
-const struct tu_native_format *
-tu6_get_native_format(VkFormat format);
+struct tu_native_format tu6_get_native_format(VkFormat format);
+struct tu_native_format tu6_format_vtx(VkFormat format);
+enum a6xx_format tu6_format_gmem(VkFormat format);
+struct tu_native_format tu6_format_color(VkFormat format, bool tiled);
+struct tu_native_format tu6_format_texture(VkFormat format, bool tiled);
void
tu_pack_clear_value(const VkClearValue *val,