aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Marek <[email protected]>2020-04-15 14:38:04 -0400
committerMarge Bot <[email protected]>2020-04-16 14:04:18 +0000
commitb6455e9a6a7dcd37483d1ff2193161c3568e74f6 (patch)
tree62dc205194c81ed90cdf16b54f8b7deec7cb567d
parentd80fb024302aa6058945826a79ba0caf9611fcc1 (diff)
turnip: compute render_components/srgb_cntl at renderpass creation time
Signed-off-by: Jonathan Marek <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4581>
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c32
-rw-r--r--src/freedreno/vulkan/tu_pass.c26
-rw-r--r--src/freedreno/vulkan/tu_private.h4
3 files changed, 30 insertions, 32 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index 941f4ba6be7..179abefbdd2 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -421,8 +421,6 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
struct tu_cs *cs)
{
const struct tu_framebuffer *fb = cmd->state.framebuffer;
- unsigned char mrt_comp[MAX_RTS] = { 0 };
- unsigned srgb_cntl = 0;
for (uint32_t i = 0; i < subpass->color_count; ++i) {
uint32_t a = subpass->color_attachments[i].attachment;
@@ -431,10 +429,6 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
const struct tu_image_view *iview = fb->attachments[a].attachment;
- mrt_comp[i] = 0xf;
-
- if (vk_format_is_srgb(iview->vk_format))
- srgb_cntl |= (1 << i);
struct tu_native_format format =
tu6_format_image(iview->image, iview->vk_format, iview->base_mip);
@@ -462,32 +456,14 @@ tu6_emit_mrt(struct tu_cmd_buffer *cmd,
}
tu_cs_emit_regs(cs,
- A6XX_RB_SRGB_CNTL(.dword = srgb_cntl));
-
+ A6XX_RB_SRGB_CNTL(.dword = subpass->srgb_cntl));
tu_cs_emit_regs(cs,
- A6XX_SP_SRGB_CNTL(.dword = srgb_cntl));
+ A6XX_SP_SRGB_CNTL(.dword = subpass->srgb_cntl));
tu_cs_emit_regs(cs,
- A6XX_RB_RENDER_COMPONENTS(
- .rt0 = mrt_comp[0],
- .rt1 = mrt_comp[1],
- .rt2 = mrt_comp[2],
- .rt3 = mrt_comp[3],
- .rt4 = mrt_comp[4],
- .rt5 = mrt_comp[5],
- .rt6 = mrt_comp[6],
- .rt7 = mrt_comp[7]));
-
+ A6XX_RB_RENDER_COMPONENTS(.dword = subpass->render_components));
tu_cs_emit_regs(cs,
- A6XX_SP_FS_RENDER_COMPONENTS(
- .rt0 = mrt_comp[0],
- .rt1 = mrt_comp[1],
- .rt2 = mrt_comp[2],
- .rt3 = mrt_comp[3],
- .rt4 = mrt_comp[4],
- .rt5 = mrt_comp[5],
- .rt6 = mrt_comp[6],
- .rt7 = mrt_comp[7]));
+ A6XX_SP_FS_RENDER_COMPONENTS(.dword = subpass->render_components));
tu_cs_emit_regs(cs, A6XX_GRAS_MAX_LAYER_INDEX(fb->layers - 1));
}
diff --git a/src/freedreno/vulkan/tu_pass.c b/src/freedreno/vulkan/tu_pass.c
index 4f075e173e2..b14eab022fa 100644
--- a/src/freedreno/vulkan/tu_pass.c
+++ b/src/freedreno/vulkan/tu_pass.c
@@ -39,8 +39,8 @@ static void update_samples(struct tu_subpass *subpass,
#define GMEM_ALIGN 0x4000
static void
-compute_gmem_offsets(struct tu_render_pass *pass,
- const struct tu_physical_device *phys_dev)
+create_render_pass_common(struct tu_render_pass *pass,
+ const struct tu_physical_device *phys_dev)
{
/* calculate total bytes per pixel */
uint32_t cpp_total = 0;
@@ -84,6 +84,24 @@ compute_gmem_offsets(struct tu_render_pass *pass,
}
pass->gmem_pixels = pixels;
+
+ for (uint32_t i = 0; i < pass->subpass_count; i++) {
+ struct tu_subpass *subpass = &pass->subpasses[i];
+
+ subpass->srgb_cntl = 0;
+ subpass->render_components = 0;
+
+ for (uint32_t i = 0; i < subpass->color_count; ++i) {
+ uint32_t a = subpass->color_attachments[i].attachment;
+ if (a == VK_ATTACHMENT_UNUSED)
+ continue;
+
+ subpass->render_components |= 0xf << (i * 4);
+
+ if (vk_format_is_srgb(pass->attachments[a].format))
+ subpass->srgb_cntl |= 1 << i;
+ }
+ }
}
VkResult
@@ -209,7 +227,7 @@ tu_CreateRenderPass(VkDevice _device,
*pRenderPass = tu_render_pass_to_handle(pass);
- compute_gmem_offsets(pass, device->physical_device);
+ create_render_pass_common(pass, device->physical_device);
return VK_SUCCESS;
}
@@ -338,7 +356,7 @@ tu_CreateRenderPass2(VkDevice _device,
*pRenderPass = tu_render_pass_to_handle(pass);
- compute_gmem_offsets(pass, device->physical_device);
+ create_render_pass_common(pass, device->physical_device);
return VK_SUCCESS;
}
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index 656f63f8d84..1c081a2ddda 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -1648,6 +1648,10 @@ struct tu_subpass
struct tu_subpass_attachment depth_stencil_attachment;
VkSampleCountFlagBits samples;
+
+ /* pre-filled register values */
+ uint32_t render_components;
+ uint32_t srgb_cntl;
};
struct tu_render_pass_attachment