mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
panvk/csf: Use same clear path for color, depth and stencil images
Do the same for cmdClearDepthStencilImage as for cmdClearColorImage, RUN_FRAGMENT with a clear value set is the only thing needed. This skips setting up primitives and executing a shader.
This commit is contained in:
parent
174591a73a
commit
50fd07948f
3 changed files with 38 additions and 21 deletions
|
|
@ -540,10 +540,11 @@ panvk_cache_flush_is_nop(const struct panvk_cache_flush_info *cache_flush)
|
|||
extern const struct vk_command_buffer_ops panvk_per_arch(cmd_buffer_ops);
|
||||
|
||||
void panvk_per_arch(cmd_fb_barrier)(struct panvk_cmd_buffer *cmdbuf);
|
||||
void panvk_per_arch(cmd_clear_color_image)(
|
||||
void panvk_per_arch(cmd_clear_image)(
|
||||
struct panvk_cmd_buffer *cmdbuf, struct panvk_device *dev,
|
||||
struct panvk_image *image, VkImageLayout image_layout,
|
||||
const VkClearColorValue *color_value, uint32_t range_count,
|
||||
const VkClearColorValue *color_value,
|
||||
const VkClearDepthStencilValue *depth_stencil_value, uint32_t range_count,
|
||||
const VkImageSubresourceRange *ranges);
|
||||
|
||||
#if PAN_ARCH == 10
|
||||
|
|
|
|||
|
|
@ -3707,9 +3707,10 @@ static void
|
|||
setup_clear_render_state(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_image_view *clear_image_view,
|
||||
VkImageLayout image_layout,
|
||||
const VkClearValue clear_value, uint32_t layer_count)
|
||||
const VkClearValue clear_value, uint32_t layer_count,
|
||||
VkImageAspectFlags aspects)
|
||||
{
|
||||
const VkRenderingAttachmentInfo color_att = {
|
||||
const VkRenderingAttachmentInfo clear_att = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
|
||||
.imageView = panvk_image_view_to_handle(clear_image_view),
|
||||
.imageLayout = image_layout,
|
||||
|
|
@ -3721,6 +3722,10 @@ setup_clear_render_state(struct panvk_cmd_buffer *cmdbuf,
|
|||
.clearValue = clear_value,
|
||||
};
|
||||
|
||||
const bool clear_color = aspects & VK_IMAGE_ASPECT_COLOR_BIT;
|
||||
const bool clear_depth = aspects & VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
const bool clear_stencil = aspects & VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
const VkRenderingInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
|
||||
.flags = 0,
|
||||
|
|
@ -3735,10 +3740,10 @@ setup_clear_render_state(struct panvk_cmd_buffer *cmdbuf,
|
|||
},
|
||||
.layerCount = layer_count,
|
||||
.viewMask = 0,
|
||||
.colorAttachmentCount = 1,
|
||||
.pColorAttachments = &color_att,
|
||||
.pDepthAttachment = NULL,
|
||||
.pStencilAttachment = NULL,
|
||||
.colorAttachmentCount = clear_color,
|
||||
.pColorAttachments = clear_color ? &clear_att : NULL,
|
||||
.pDepthAttachment = clear_depth ? &clear_att : NULL,
|
||||
.pStencilAttachment = clear_stencil ? &clear_att : NULL,
|
||||
};
|
||||
|
||||
panvk_per_arch(cmd_init_render_state)(cmdbuf, &info);
|
||||
|
|
@ -3779,13 +3784,12 @@ reset_render_state(struct panvk_cmd_buffer *cmdbuf, bool suspending,
|
|||
}
|
||||
|
||||
void
|
||||
panvk_per_arch(cmd_clear_color_image)(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_device *dev,
|
||||
struct panvk_image *image,
|
||||
VkImageLayout image_layout,
|
||||
const VkClearColorValue *color_value,
|
||||
uint32_t range_count,
|
||||
const VkImageSubresourceRange *ranges)
|
||||
panvk_per_arch(cmd_clear_image)(
|
||||
struct panvk_cmd_buffer *cmdbuf, struct panvk_device *dev,
|
||||
struct panvk_image *image, VkImageLayout image_layout,
|
||||
const VkClearColorValue *color_value,
|
||||
const VkClearDepthStencilValue *depth_stencil_value, uint32_t range_count,
|
||||
const VkImageSubresourceRange *ranges)
|
||||
{
|
||||
for (uint32_t r = 0; r < range_count; r++) {
|
||||
const VkImageSubresourceRange *range = &ranges[r];
|
||||
|
|
@ -3815,12 +3819,19 @@ panvk_per_arch(cmd_clear_color_image)(struct panvk_cmd_buffer *cmdbuf,
|
|||
return;
|
||||
}
|
||||
|
||||
const VkClearValue clear_value = {
|
||||
.color = *color_value,
|
||||
};
|
||||
VkImageAspectFlags aspects;
|
||||
VkClearValue clear_value;
|
||||
if (color_value != NULL) {
|
||||
aspects = image_view->vk.aspects;
|
||||
clear_value.color = *color_value;
|
||||
} else {
|
||||
assert(depth_stencil_value);
|
||||
aspects = range->aspectMask;
|
||||
clear_value.depthStencil = *depth_stencil_value;
|
||||
}
|
||||
|
||||
setup_clear_render_state(cmdbuf, image_view, image_layout, clear_value,
|
||||
layer_count);
|
||||
layer_count, aspects);
|
||||
VkResult result = get_render_ctx(cmdbuf);
|
||||
if (unlikely(result != VK_SUCCESS)) {
|
||||
reset_render_state(cmdbuf, false, false);
|
||||
|
|
|
|||
|
|
@ -299,9 +299,14 @@ panvk_per_arch(CmdClearDepthStencilImage)(
|
|||
struct panvk_cmd_meta_graphics_save_ctx save = {0};
|
||||
|
||||
meta_gfx_start(cmdbuf, &save);
|
||||
#if PAN_ARCH >= 10
|
||||
panvk_per_arch(cmd_clear_image)(cmdbuf, dev, img, imageLayout, NULL,
|
||||
pDepthStencil, rangeCount, pRanges);
|
||||
#else
|
||||
vk_meta_clear_depth_stencil_image(&cmdbuf->vk, &dev->meta, &img->vk,
|
||||
imageLayout, pDepthStencil, rangeCount,
|
||||
pRanges);
|
||||
#endif
|
||||
meta_gfx_end(cmdbuf, &save);
|
||||
}
|
||||
|
||||
|
|
@ -319,8 +324,8 @@ panvk_per_arch(CmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image,
|
|||
|
||||
meta_gfx_start(cmdbuf, &save);
|
||||
#if PAN_ARCH >= 10
|
||||
panvk_per_arch(cmd_clear_color_image)(cmdbuf, dev, img, imageLayout, pColor,
|
||||
rangeCount, pRanges);
|
||||
panvk_per_arch(cmd_clear_image)(cmdbuf, dev, img, imageLayout, pColor, NULL,
|
||||
rangeCount, pRanges);
|
||||
#else
|
||||
vk_meta_clear_color_image(&cmdbuf->vk, &dev->meta, &img->vk, imageLayout,
|
||||
img->vk.format, pColor, rangeCount, pRanges);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue