summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Marek <jonathan@marek.ca>2019-11-22 18:09:32 -0500
committerJonathan Marek <jonathan@marek.ca>2019-12-04 14:39:06 -0500
commit4babdc73812cc4d2ffb8b4097d1e44b5fa400f16 (patch)
treed3fc7319260dcf535619db897b97de0b76c9de70
parent1dfa2e6c99caa5df84fd1d12e64f0a4167a88a3f (diff)
downloadmesa-4babdc73812cc4d2ffb8b4097d1e44b5fa400f16.tar.gz
turnip: implement CmdClearAttachments
Passes these deqp tests: dEQP-VK.api.image_clearing.core.*attach*single* Signed-off-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Eric Anholt <eric@anholt.net>
-rw-r--r--src/freedreno/vulkan/tu_meta_clear.c66
1 files changed, 65 insertions, 1 deletions
diff --git a/src/freedreno/vulkan/tu_meta_clear.c b/src/freedreno/vulkan/tu_meta_clear.c
index fdfd0ec36e8..48754e46601 100644
--- a/src/freedreno/vulkan/tu_meta_clear.c
+++ b/src/freedreno/vulkan/tu_meta_clear.c
@@ -23,6 +23,7 @@
#include "tu_private.h"
#include "tu_blit.h"
+#include "tu_cs.h"
static void
clear_image(struct tu_cmd_buffer *cmdbuf,
@@ -99,5 +100,68 @@ tu_CmdClearAttachments(VkCommandBuffer commandBuffer,
uint32_t rectCount,
const VkClearRect *pRects)
{
- tu_finishme("CmdClearAttachments");
+ TU_FROM_HANDLE(tu_cmd_buffer, cmd, commandBuffer);
+ const struct tu_subpass *subpass = cmd->state.subpass;
+ struct tu_cs *cs = &cmd->draw_cs;
+
+ VkResult result = tu_cs_reserve_space(cmd->device, cs,
+ rectCount * (3 + 15 * attachmentCount));
+ if (result != VK_SUCCESS) {
+ cmd->record_result = result;
+ return;
+ }
+
+ /* TODO: deal with layered rendering (when layered rendering is implemented)
+ * TODO: disable bypass rendering for subpass (when bypass is implemented)
+ */
+
+ for (unsigned i = 0; i < rectCount; i++) {
+ unsigned x1 = pRects[i].rect.offset.x;
+ unsigned y1 = pRects[i].rect.offset.y;
+ unsigned x2 = x1 + pRects[i].rect.extent.width - 1;
+ unsigned y2 = y1 + pRects[i].rect.extent.height - 1;
+
+ tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_SCISSOR_TL, 2);
+ tu_cs_emit(cs, A6XX_RB_BLIT_SCISSOR_TL_X(x1) | A6XX_RB_BLIT_SCISSOR_TL_Y(y1));
+ tu_cs_emit(cs, A6XX_RB_BLIT_SCISSOR_BR_X(x2) | A6XX_RB_BLIT_SCISSOR_BR_Y(y2));
+
+ for (unsigned j = 0; j < attachmentCount; j++) {
+ uint32_t index, a;
+ if (pAttachments[j].aspectMask & VK_IMAGE_ASPECT_COLOR_BIT) {
+ index = pAttachments[j].colorAttachment;
+ a = subpass->color_attachments[index].attachment;
+ } else {
+ index = subpass->color_count;
+ a = subpass->depth_stencil_attachment.attachment;
+ }
+ /* TODO: partial depth/stencil clear? */
+
+ VkFormat fmt = cmd->state.pass->attachments[a].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_pkt4(cs, REG_A6XX_RB_BLIT_INFO, 1);
+ tu_cs_emit(cs, A6XX_RB_BLIT_INFO_GMEM | A6XX_RB_BLIT_INFO_CLEAR_MASK(0xf));
+
+ tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_BASE_GMEM, 1);
+ tu_cs_emit(cs, cmd->state.tiling_config.gmem_offsets[index]);
+
+ tu_cs_emit_pkt4(cs, REG_A6XX_RB_UNKNOWN_88D0, 1);
+ tu_cs_emit(cs, 0);
+
+ uint32_t clear_vals[4] = { 0 };
+ tu_pack_clear_value(&pAttachments[j].clearValue, fmt, clear_vals);
+
+ tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_CLEAR_COLOR_DW0, 4);
+ tu_cs_emit(cs, clear_vals[0]);
+ tu_cs_emit(cs, clear_vals[1]);
+ tu_cs_emit(cs, clear_vals[2]);
+ tu_cs_emit(cs, clear_vals[3]);
+
+ tu6_emit_event_write(cmd, cs, BLIT, false);
+ }
+ }
}