diff options
author | Jonathan Marek <[email protected]> | 2020-04-08 10:56:16 -0400 |
---|---|---|
committer | Marge Bot <[email protected]> | 2020-04-09 14:43:02 +0000 |
commit | 51fe52d2fdf6dad6de424c8110ab83b90f1ea0aa (patch) | |
tree | f8f55e23e53fd8a2bedef0f8635d279c6d38c8ac /src | |
parent | 009082dcfff5cbbce007d1b455ad33db1954c7aa (diff) |
turnip: rework format helpers
* Take tile_mode as input directly
* tu6_format_gmem to tu6_base_format, use may not be limited to GMEM
* Add new helpers that will return the correct tile_mode as for image level
as part of the format.
Signed-off-by: Jonathan Marek <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3783>
Diffstat (limited to 'src')
-rw-r--r-- | src/freedreno/vulkan/tu_blit.c | 8 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_blit.h | 4 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_formats.c | 22 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_image.c | 2 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_meta_clear.c | 2 | ||||
-rw-r--r-- | src/freedreno/vulkan/tu_private.h | 32 |
6 files changed, 41 insertions, 29 deletions
diff --git a/src/freedreno/vulkan/tu_blit.c b/src/freedreno/vulkan/tu_blit.c index 116528d5a4f..469fb517dd6 100644 --- a/src/freedreno/vulkan/tu_blit.c +++ b/src/freedreno/vulkan/tu_blit.c @@ -79,8 +79,8 @@ emit_blit_step(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs, { struct tu_physical_device *phys_dev = cmdbuf->device->physical_device; - 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); + struct tu_native_format dfmt = tu6_format_color(blt->dst.fmt, blt->dst.image_tile_mode); + struct tu_native_format sfmt = tu6_format_texture(blt->src.fmt, blt->src.image_tile_mode); if (dfmt.fmt == FMT6_Z24_UNORM_S8_UINT) dfmt.fmt = FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8; @@ -318,7 +318,7 @@ void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs, } } else if ((blt->src.va & 63) || (blt->src.pitch & 63)) { /* per line copy path (buffer_to_image) */ - assert(blt->type == TU_BLIT_COPY && !blt->src.tiled); + assert(blt->type == TU_BLIT_COPY && !blt->src.image_tile_mode); struct tu_blit line_blt = *blt; uint64_t src_va = line_blt.src.va + blt->src.pitch * blt->src.y; @@ -338,7 +338,7 @@ void tu_blit(struct tu_cmd_buffer *cmdbuf, struct tu_cs *cs, } } else if ((blt->dst.va & 63) || (blt->dst.pitch & 63)) { /* per line copy path (image_to_buffer) */ - assert(blt->type == TU_BLIT_COPY && !blt->dst.tiled); + assert(blt->type == TU_BLIT_COPY && !blt->dst.image_tile_mode); struct tu_blit line_blt = *blt; uint64_t dst_va = line_blt.dst.va + blt->dst.pitch * blt->dst.y; diff --git a/src/freedreno/vulkan/tu_blit.h b/src/freedreno/vulkan/tu_blit.h index 6400fa9d2bc..62851d74778 100644 --- a/src/freedreno/vulkan/tu_blit.h +++ b/src/freedreno/vulkan/tu_blit.h @@ -35,7 +35,7 @@ struct tu_blit_surf { VkFormat fmt; enum a6xx_tile_mode tile_mode; - bool tiled; + enum a6xx_tile_mode image_tile_mode; uint64_t va; uint32_t pitch, layer_size; uint32_t x, y; @@ -60,7 +60,7 @@ tu_blit_surf(struct tu_image *image, return (struct tu_blit_surf) { .fmt = image->vk_format, .tile_mode = tu6_get_image_tile_mode(image, subres.mipLevel), - .tiled = image->layout.tile_mode != TILE6_LINEAR, + .image_tile_mode = image->layout.tile_mode, .va = tu_image_base(image, subres.mipLevel, layer), .pitch = tu_image_stride(image, subres.mipLevel), .layer_size = tu_layer_size(image, subres.mipLevel), diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c index 0d2351d0066..6a8f3d022a2 100644 --- a/src/freedreno/vulkan/tu_formats.c +++ b/src/freedreno/vulkan/tu_formats.c @@ -287,7 +287,7 @@ static const struct tu_native_format tu6_format_table[] = { TU6_xTx(ASTC_12x12_SRGB_BLOCK, ASTC_12x12, WZYX), /* 184 */ }; -struct tu_native_format +static struct tu_native_format tu6_get_native_format(VkFormat format) { struct tu_native_format fmt = {}; @@ -314,20 +314,8 @@ tu6_format_vtx(VkFormat format) 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) +tu6_format_color(VkFormat format, enum a6xx_tile_mode tile_mode) { struct tu_native_format fmt = tu6_get_native_format(format); assert(fmt.supported & FMT_COLOR); @@ -335,19 +323,19 @@ tu6_format_color(VkFormat format, bool tiled) if (fmt.fmt == FMT6_10_10_10_2_UNORM) fmt.fmt = FMT6_10_10_10_2_UNORM_DEST; - if (tiled) + if (tile_mode) fmt.swap = WZYX; return fmt; } struct tu_native_format -tu6_format_texture(VkFormat format, bool tiled) +tu6_format_texture(VkFormat format, enum a6xx_tile_mode tile_mode) { struct tu_native_format fmt = tu6_get_native_format(format); assert(fmt.supported & FMT_TEXTURE); - if (!tiled) { + if (!tile_mode) { /* different from format table when used as linear src */ if (format == VK_FORMAT_R5G5B5A1_UNORM_PACK16) fmt.fmt = FMT6_1_5_5_5_UNORM, fmt.swap = WXYZ; diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index d77f3c8df43..ddb8dbebf7b 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -520,7 +520,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_format_texture(vfmt, false); + const struct tu_native_format fmt = tu6_format_texture(vfmt, TILE6_LINEAR); uint32_t range; if (pCreateInfo->range == VK_WHOLE_SIZE) diff --git a/src/freedreno/vulkan/tu_meta_clear.c b/src/freedreno/vulkan/tu_meta_clear.c index b3a7354c286..500f6ae3529 100644 --- a/src/freedreno/vulkan/tu_meta_clear.c +++ b/src/freedreno/vulkan/tu_meta_clear.c @@ -135,7 +135,7 @@ tu_clear_gmem_attachment(struct tu_cmd_buffer *cmd, VkFormat fmt = cmd->state.pass->attachments[attachment].format; tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_DST_INFO, 1); - tu_cs_emit(cs, A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(tu6_format_gmem(fmt))); + tu_cs_emit(cs, A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(tu6_base_format(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_private.h b/src/freedreno/vulkan/tu_private.h index 3de415304d8..50365371dad 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1315,14 +1315,20 @@ struct tu_native_format { enum a6xx_format fmt : 8; enum a3xx_color_swap swap : 8; + enum a6xx_tile_mode tile_mode : 8; enum tu_supported_formats supported : 8; }; -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); +struct tu_native_format tu6_format_color(VkFormat format, enum a6xx_tile_mode tile_mode); +struct tu_native_format tu6_format_texture(VkFormat format, enum a6xx_tile_mode tile_mode); + +static inline enum a6xx_format +tu6_base_format(VkFormat format) +{ + /* note: tu6_format_color doesn't care about tiling for .fmt field */ + return tu6_format_color(format, TILE6_LINEAR).fmt; +} void tu_pack_clear_value(const VkClearValue *val, @@ -1457,6 +1463,24 @@ tu6_get_image_tile_mode(struct tu_image *image, int level); enum a3xx_msaa_samples tu_msaa_samples(uint32_t samples); +static inline struct tu_native_format +tu6_format_image(struct tu_image *image, VkFormat format, uint32_t level) +{ + struct tu_native_format fmt = + tu6_format_color(format, image->layout.tile_mode); + fmt.tile_mode = tu6_get_image_tile_mode(image, level); + return fmt; +} + +static inline struct tu_native_format +tu6_format_image_src(struct tu_image *image, VkFormat format, uint32_t level) +{ + struct tu_native_format fmt = + tu6_format_texture(format, image->layout.tile_mode); + fmt.tile_mode = tu6_get_image_tile_mode(image, level); + return fmt; +} + struct tu_image_view { struct tu_image *image; /**< VkImageViewCreateInfo::image */ |