summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-10-06 23:35:22 -0700
committerJason Ekstrand <[email protected]>2016-10-14 15:39:41 -0700
commit58f2315c3819bbd6bab9ee62b0743309feac42cb (patch)
treefbd5ffd2cbe95aaa79673e8ddb1b806749dd7a31
parent29e289fa655938f7814bdbb3de7996a8a0f04b60 (diff)
anv: Use blorp for ClearDepthStencilImage
Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Topi Pohjolainen <[email protected]>
-rw-r--r--src/intel/vulkan/anv_blorp.c59
-rw-r--r--src/intel/vulkan/anv_meta_clear.c141
2 files changed, 59 insertions, 141 deletions
diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c
index 699032b85e7..60ed98e3d5d 100644
--- a/src/intel/vulkan/anv_blorp.c
+++ b/src/intel/vulkan/anv_blorp.c
@@ -809,6 +809,65 @@ void anv_CmdClearColorImage(
blorp_batch_finish(&batch);
}
+void anv_CmdClearDepthStencilImage(
+ VkCommandBuffer commandBuffer,
+ VkImage image_h,
+ VkImageLayout imageLayout,
+ const VkClearDepthStencilValue* pDepthStencil,
+ uint32_t rangeCount,
+ const VkImageSubresourceRange* pRanges)
+{
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
+ ANV_FROM_HANDLE(anv_image, image, image_h);
+
+ struct blorp_batch batch;
+ blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0);
+
+ struct blorp_surf depth, stencil;
+ if (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) {
+ get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_DEPTH_BIT,
+ &depth);
+ } else {
+ memset(&depth, 0, sizeof(depth));
+ }
+
+ if (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
+ get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_STENCIL_BIT,
+ &stencil);
+ } else {
+ memset(&stencil, 0, sizeof(stencil));
+ }
+
+ for (unsigned r = 0; r < rangeCount; r++) {
+ if (pRanges[r].aspectMask == 0)
+ continue;
+
+ bool clear_depth = pRanges[r].aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT;
+ bool clear_stencil = pRanges[r].aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT;
+
+ unsigned base_layer = pRanges[r].baseArrayLayer;
+ unsigned layer_count = pRanges[r].layerCount;
+
+ for (unsigned i = 0; i < pRanges[r].levelCount; i++) {
+ const unsigned level = pRanges[r].baseMipLevel + i;
+ const unsigned level_width = anv_minify(image->extent.width, level);
+ const unsigned level_height = anv_minify(image->extent.height, level);
+
+ if (image->type == VK_IMAGE_TYPE_3D)
+ layer_count = anv_minify(image->extent.depth, level);
+
+ blorp_clear_depth_stencil(&batch, &depth, &stencil,
+ level, base_layer, layer_count,
+ 0, 0, level_width, level_height,
+ clear_depth, pDepthStencil->depth,
+ clear_stencil ? 0xff : 0,
+ pDepthStencil->stencil);
+ }
+ }
+
+ blorp_batch_finish(&batch);
+}
+
static void
resolve_image(struct blorp_batch *batch,
const struct anv_image *src_image,
diff --git a/src/intel/vulkan/anv_meta_clear.c b/src/intel/vulkan/anv_meta_clear.c
index 11b471fc69a..ce7f8a71129 100644
--- a/src/intel/vulkan/anv_meta_clear.c
+++ b/src/intel/vulkan/anv_meta_clear.c
@@ -752,147 +752,6 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer)
meta_clear_end(&saved_state, cmd_buffer);
}
-void anv_CmdClearDepthStencilImage(
- VkCommandBuffer commandBuffer,
- VkImage image_h,
- VkImageLayout imageLayout,
- const VkClearDepthStencilValue* pDepthStencil,
- uint32_t rangeCount,
- const VkImageSubresourceRange* pRanges)
-{
- ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
- ANV_FROM_HANDLE(anv_image, image, image_h);
- struct anv_meta_saved_state saved_state;
-
- meta_clear_begin(&saved_state, cmd_buffer);
-
- VkDevice device_h = anv_device_to_handle(cmd_buffer->device);
-
- for (uint32_t r = 0; r < rangeCount; r++) {
- const VkImageSubresourceRange *range = &pRanges[r];
- for (uint32_t l = 0; l < anv_get_levelCount(image, range); ++l) {
- const uint32_t layer_count = image->type == VK_IMAGE_TYPE_3D ?
- anv_minify(image->extent.depth, l) :
- anv_get_layerCount(image, range);
- for (uint32_t s = 0; s < layer_count; ++s) {
- struct anv_image_view iview;
- anv_image_view_init(&iview, cmd_buffer->device,
- &(VkImageViewCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
- .image = anv_image_to_handle(image),
- .viewType = anv_meta_get_view_type(image),
- .format = image->vk_format,
- .subresourceRange = {
- .aspectMask = range->aspectMask,
- .baseMipLevel = range->baseMipLevel + l,
- .levelCount = 1,
- .baseArrayLayer = range->baseArrayLayer + s,
- .layerCount = 1
- },
- },
- cmd_buffer, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT);
-
- VkFramebuffer fb;
- anv_CreateFramebuffer(device_h,
- &(VkFramebufferCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO,
- .attachmentCount = 1,
- .pAttachments = (VkImageView[]) {
- anv_image_view_to_handle(&iview),
- },
- .width = iview.extent.width,
- .height = iview.extent.height,
- .layers = 1
- },
- &cmd_buffer->pool->alloc,
- &fb);
-
- VkAttachmentDescription att_desc = {
- .format = image->vk_format,
- .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
- .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
- .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
- .stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE,
- .initialLayout = imageLayout,
- .finalLayout = imageLayout,
- };
-
- const VkAttachmentReference att_ref = {
- .attachment = 0,
- .layout = imageLayout,
- };
-
- VkSubpassDescription subpass_desc = {
- .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
- .inputAttachmentCount = 0,
- .colorAttachmentCount = 0,
- .pColorAttachments = NULL,
- .pResolveAttachments = NULL,
- .pDepthStencilAttachment = &att_ref,
- .preserveAttachmentCount = 0,
- .pPreserveAttachments = NULL,
- };
-
- VkRenderPass pass;
- anv_CreateRenderPass(device_h,
- &(VkRenderPassCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
- .attachmentCount = 1,
- .pAttachments = &att_desc,
- .subpassCount = 1,
- .pSubpasses = &subpass_desc,
- },
- &cmd_buffer->pool->alloc,
- &pass);
-
- ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer),
- &(VkRenderPassBeginInfo) {
- .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
- .renderArea = {
- .offset = { 0, 0, },
- .extent = {
- .width = iview.extent.width,
- .height = iview.extent.height,
- },
- },
- .renderPass = pass,
- .framebuffer = fb,
- .clearValueCount = 0,
- .pClearValues = NULL,
- },
- VK_SUBPASS_CONTENTS_INLINE);
-
- VkClearAttachment clear_att = {
- .aspectMask = range->aspectMask,
- .colorAttachment = 0,
- .clearValue = {
- .depthStencil = *pDepthStencil,
- },
- };
-
- VkClearRect clear_rect = {
- .rect = {
- .offset = { 0, 0 },
- .extent = { iview.extent.width, iview.extent.height },
- },
- .baseArrayLayer = range->baseArrayLayer,
- .layerCount = 1, /* FINISHME: clear multi-layer framebuffer */
- };
-
- emit_clear(cmd_buffer, &clear_att, &clear_rect);
-
- ANV_CALL(CmdEndRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer));
- ANV_CALL(DestroyRenderPass)(device_h, pass,
- &cmd_buffer->pool->alloc);
- ANV_CALL(DestroyFramebuffer)(device_h, fb,
- &cmd_buffer->pool->alloc);
- }
- }
- }
-
- meta_clear_end(&saved_state, cmd_buffer);
-}
-
void anv_CmdClearAttachments(
VkCommandBuffer commandBuffer,
uint32_t attachmentCount,