On Fri, Oct 07, 2016 at 09:41:13PM -0700, Jason Ekstrand wrote: > Signed-off-by: Jason Ekstrand <ja...@jlekstrand.net> > --- > src/intel/vulkan/anv_blorp.c | 60 ++++++++++++++++ > src/intel/vulkan/anv_meta_clear.c | 141 > -------------------------------------- > 2 files changed, 60 insertions(+), 141 deletions(-) > > diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c > index 699032b..546737b 100644 > --- a/src/intel/vulkan/anv_blorp.c > +++ b/src/intel/vulkan/anv_blorp.c > @@ -809,6 +809,66 @@ 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) { > + base_layer = 0;
In the current pass below we only override the layer_count leaving base_layer alone. Otherwise this looks functionally the same. With some explanation or comment added: Reviewed-by: Topi Pohjolainen <topi.pohjolai...@intel.com> > + 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, 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 11b471f..ce7f8a7 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, > -- > 2.5.0.400.gff86faf > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev