aboutsummaryrefslogtreecommitdiffstats
path: root/src/freedreno/vulkan
diff options
context:
space:
mode:
authorChia-I Wu <[email protected]>2019-02-14 10:53:20 -0800
committerChia-I Wu <[email protected]>2019-03-11 10:02:13 -0700
commit08b1c3fc7f1c5ea5b5bee1eccb635b855c4f383b (patch)
tree572acddb13c5370a5581f658df2a297d600bb05a /src/freedreno/vulkan
parent68c27ea92b92e4d8ba6a687523975ac383adb836 (diff)
turnip: respect color attachment formats
Make tu6_get_native_format available to tu_cmd_buffer and start using of it.
Diffstat (limited to 'src/freedreno/vulkan')
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c28
-rw-r--r--src/freedreno/vulkan/tu_formats.c11
-rw-r--r--src/freedreno/vulkan/tu_private.h16
3 files changed, 33 insertions, 22 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index 51f97971335..f307c145e16 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -427,8 +427,6 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
const struct tu_image_level *slice =
&iview->image->levels[iview->base_mip];
const enum a6xx_tile_mode tile_mode = TILE6_LINEAR;
- const enum a6xx_color_fmt format = RB6_R8G8B8A8_UNORM;
- const enum a3xx_color_swap swap = WZYX;
uint32_t stride = 0;
uint32_t offset = 0;
@@ -437,13 +435,17 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
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);
+
offset = slice->offset + slice->size * iview->base_layer;
stride = slice->pitch * vk_format_get_blocksize(iview->vk_format);
tu_cs_emit_pkt4(cs, REG_A6XX_RB_MRT_BUF_INFO(i), 6);
- tu_cs_emit(cs, A6XX_RB_MRT_BUF_INFO_COLOR_FORMAT(format) |
+ tu_cs_emit(cs, A6XX_RB_MRT_BUF_INFO_COLOR_FORMAT(format->rb) |
A6XX_RB_MRT_BUF_INFO_COLOR_TILE_MODE(tile_mode) |
- A6XX_RB_MRT_BUF_INFO_COLOR_SWAP(swap));
+ A6XX_RB_MRT_BUF_INFO_COLOR_SWAP(format->swap));
tu_cs_emit(cs, A6XX_RB_MRT_PITCH(stride));
tu_cs_emit(cs, A6XX_RB_MRT_ARRAY_PITCH(slice->size));
tu_cs_emit_qw(cs, iview->image->bo->iova + iview->image->bo_offset +
@@ -452,7 +454,7 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd, struct tu_cs *cs)
cs, tiling->gmem_offsets[gmem_index++]); /* RB_MRT[i].BASE_GMEM */
tu_cs_emit_pkt4(cs, REG_A6XX_SP_FS_MRT_REG(i), 1);
- tu_cs_emit(cs, A6XX_SP_FS_MRT_REG_COLOR_FORMAT(RB6_R8G8B8A8_UNORM));
+ tu_cs_emit(cs, A6XX_SP_FS_MRT_REG_COLOR_FORMAT(format->rb));
#if 0
/* when we support UBWC, these would be the system memory
@@ -592,19 +594,20 @@ tu6_emit_blit_info(struct tu_cmd_buffer *cmd,
slice->pitch * vk_format_get_blocksize(iview->vk_format);
const enum a6xx_tile_mode tile_mode = TILE6_LINEAR;
const enum a3xx_msaa_samples samples = tu6_msaa_samples(1);
- const enum a6xx_color_fmt format = RB6_R8G8B8A8_UNORM;
- const enum a3xx_color_swap swap = WZYX;
tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_INFO, 1);
tu_cs_emit(cs, blit_info);
/* tile mode? */
+ const struct tu_native_format *format =
+ tu6_get_native_format(iview->vk_format);
+ assert(format && format->rb >= 0);
tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_DST_INFO, 5);
tu_cs_emit(cs, A6XX_RB_BLIT_DST_INFO_TILE_MODE(tile_mode) |
A6XX_RB_BLIT_DST_INFO_SAMPLES(samples) |
- A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(format) |
- A6XX_RB_BLIT_DST_INFO_COLOR_SWAP(swap));
+ A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(format->rb) |
+ A6XX_RB_BLIT_DST_INFO_COLOR_SWAP(format->swap));
tu_cs_emit_qw(cs,
iview->image->bo->iova + iview->image->bo_offset + offset);
tu_cs_emit(cs, A6XX_RB_BLIT_DST_PITCH(stride));
@@ -623,14 +626,17 @@ tu6_emit_blit_clear(struct tu_cmd_buffer *cmd,
{
const enum a6xx_tile_mode tile_mode = TILE6_LINEAR;
const enum a3xx_msaa_samples samples = tu6_msaa_samples(1);
- const enum a6xx_color_fmt format = RB6_R8G8B8A8_UNORM;
+
+ const struct tu_native_format *format =
+ tu6_get_native_format(iview->vk_format);
+ assert(format && format->rb >= 0);
/* must be WZYX; other values are ignored */
const enum a3xx_color_swap swap = WZYX;
tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_DST_INFO, 1);
tu_cs_emit(cs, A6XX_RB_BLIT_DST_INFO_TILE_MODE(tile_mode) |
A6XX_RB_BLIT_DST_INFO_SAMPLES(samples) |
- A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(format) |
+ A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(format->rb) |
A6XX_RB_BLIT_DST_INFO_COLOR_SWAP(swap));
tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_INFO, 1);
diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c
index 00a45aaac01..1dbb6de3380 100644
--- a/src/freedreno/vulkan/tu_formats.c
+++ b/src/freedreno/vulkan/tu_formats.c
@@ -34,15 +34,6 @@
#include "vk_format.h"
#include "vk_util.h"
-struct tu_native_format
-{
- int vtx; /* VFMTn_xxx or -1 */
- int tex; /* TFMTn_xxx or -1 */
- int rb; /* RBn_xxx or -1 */
- enum a3xx_color_swap swap;
- bool present;
-};
-
/**
* 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
@@ -325,7 +316,7 @@ TU_FORMAT_TABLE(tu6_format_table0) = {
#undef TU_FORMAT_TABLE_FIRST
#undef TU_FORMAT_TABLE_LAST
-static const struct tu_native_format *
+const struct tu_native_format *
tu6_get_native_format(VkFormat format)
{
const struct tu_native_format *fmt = NULL;
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 6643168af5f..9b179f666cf 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -1002,8 +1002,22 @@ tu_graphics_pipeline_create(
const VkAllocationCallbacks *alloc,
VkPipeline *pPipeline);
+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 */
+};
+
+const struct tu_native_format *
+tu6_get_native_format(VkFormat format);
+
int
-tu_pack_clear_value(const VkClearValue *val, VkFormat format, uint32_t buf[4]);
+tu_pack_clear_value(const VkClearValue *val,
+ VkFormat format,
+ uint32_t buf[4]);
struct tu_image_level
{