Commit ee60c754 authored by Jason Ekstrand's avatar Jason Ekstrand
Browse files

radv: Switch to dynamic rendering only

parent 53737c03
......@@ -671,25 +671,16 @@ sqtt_CmdPushConstants(VkCommandBuffer commandBuffer, VkPipelineLayout layout,
}
VKAPI_ATTR void VKAPI_CALL
sqtt_CmdBeginRenderPass2(VkCommandBuffer commandBuffer,
const VkRenderPassBeginInfo *pRenderPassBeginInfo,
const VkSubpassBeginInfo *pSubpassBeginInfo)
sqtt_CmdBeginRendering(VkCommandBuffer commandBuffer,
const VkRenderingInfo *pRenderingInfo)
{
API_MARKER_ALIAS(BeginRenderPass2, BeginRenderPass, commandBuffer, pRenderPassBeginInfo,
pSubpassBeginInfo);
API_MARKER_ALIAS(BeginRendering, BeginRenderPass, commandBuffer, pRenderingInfo);
}
VKAPI_ATTR void VKAPI_CALL
sqtt_CmdNextSubpass2(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo *pSubpassBeginInfo,
const VkSubpassEndInfo *pSubpassEndInfo)
sqtt_CmdEndRendering(VkCommandBuffer commandBuffer)
{
API_MARKER_ALIAS(NextSubpass2, NextSubpass, commandBuffer, pSubpassBeginInfo, pSubpassEndInfo);
}
VKAPI_ATTR void VKAPI_CALL
sqtt_CmdEndRenderPass2(VkCommandBuffer commandBuffer, const VkSubpassEndInfo *pSubpassEndInfo)
{
API_MARKER_ALIAS(EndRenderPass2, EndRenderPass, commandBuffer, pSubpassEndInfo);
API_MARKER_ALIAS(EndRendering, EndRenderPass, commandBuffer);
}
VKAPI_ATTR void VKAPI_CALL
......
......@@ -75,7 +75,6 @@ libradv_files = files(
'radv_nir_lower_abi.c',
'radv_nir_lower_ray_queries.c',
'radv_nir_lower_ycbcr_textures.c',
'radv_pass.c',
'radv_perfcounter.c',
'radv_pipeline.c',
'radv_pipeline_cache.c',
......
This diff is collapsed.
......@@ -124,12 +124,9 @@ radv_meta_save(struct radv_meta_saved_state *state, struct radv_cmd_buffer *cmd_
memcpy(state->push_constants, cmd_buffer->push_constants, MAX_PUSH_CONSTANTS_SIZE);
}
if (state->flags & RADV_META_SAVE_PASS) {
state->pass = cmd_buffer->state.pass;
state->subpass = cmd_buffer->state.subpass;
state->framebuffer = cmd_buffer->state.framebuffer;
state->attachments = cmd_buffer->state.attachments;
state->render_area = cmd_buffer->state.render_area;
if (state->flags & RADV_META_SAVE_RENDER) {
state->render = cmd_buffer->state.render;
radv_cmd_buffer_reset_rendering(cmd_buffer);
}
if (state->flags & RADV_META_SUSPEND_PREDICATING) {
......@@ -179,14 +176,9 @@ radv_meta_restore(const struct radv_meta_saved_state *state, struct radv_cmd_buf
MAX_PUSH_CONSTANTS_SIZE, state->push_constants);
}
if (state->flags & RADV_META_SAVE_PASS) {
cmd_buffer->state.pass = state->pass;
cmd_buffer->state.subpass = state->subpass;
cmd_buffer->state.framebuffer = state->framebuffer;
cmd_buffer->state.attachments = state->attachments;
cmd_buffer->state.render_area = state->render_area;
if (state->subpass)
cmd_buffer->state.dirty |= RADV_CMD_DIRTY_FRAMEBUFFER;
if (state->flags & RADV_META_SAVE_RENDER) {
cmd_buffer->state.render = state->render;
cmd_buffer->state.dirty |= RADV_CMD_DIRTY_FRAMEBUFFER;
}
if (state->flags & RADV_META_SUSPEND_PREDICATING)
......
......@@ -34,7 +34,7 @@ extern "C" {
#endif
enum radv_meta_save_flags {
RADV_META_SAVE_PASS = (1 << 0),
RADV_META_SAVE_RENDER = (1 << 0),
RADV_META_SAVE_CONSTANTS = (1 << 1),
RADV_META_SAVE_DESCRIPTORS = (1 << 2),
RADV_META_SAVE_GRAPHICS_PIPELINE = (1 << 3),
......@@ -52,11 +52,7 @@ struct radv_meta_saved_state {
char push_constants[MAX_PUSH_CONSTANTS_SIZE];
struct radv_render_pass *pass;
const struct radv_subpass *subpass;
struct radv_attachment_state *attachments;
struct vk_framebuffer *framebuffer;
VkRect2D render_area;
struct radv_rendering_state render;
unsigned active_pipeline_gds_queries;
......@@ -213,7 +209,7 @@ void radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer,
VkImageLayout dest_image_layout,
const VkImageResolve2 *region);
void radv_decompress_resolve_subpass_src(struct radv_cmd_buffer *cmd_buffer);
void radv_decompress_resolve_rendering_src(struct radv_cmd_buffer *cmd_buffer);
void radv_decompress_resolve_src(struct radv_cmd_buffer *cmd_buffer, struct radv_image *src_image,
VkImageLayout src_image_layout, const VkImageResolve2 *region);
......
......@@ -313,11 +313,7 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachment *cl
const VkClearRect *clear_rect, uint32_t view_mask)
{
struct radv_device *device = cmd_buffer->device;
const struct radv_subpass *subpass = cmd_buffer->state.subpass;
const uint32_t subpass_att = clear_att->colorAttachment;
const uint32_t pass_att = subpass->color_attachments[subpass_att].attachment;
const struct radv_image_view *iview =
cmd_buffer->state.attachments ? cmd_buffer->state.attachments[pass_att].iview : NULL;
const struct radv_rendering_state *render = &cmd_buffer->state.render;
uint32_t samples, samples_log2;
VkFormat format;
unsigned fs_key;
......@@ -325,18 +321,25 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachment *cl
VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
VkPipeline pipeline;
assert(clear_att->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
assert(clear_att->colorAttachment < render->color_att_count);
const struct radv_attachment *color_att =
&render->color_att[clear_att->colorAttachment];
/* When a framebuffer is bound to the current command buffer, get the
* number of samples from it. Otherwise, get the number of samples from
* the render pass because it's likely a secondary command buffer.
*/
if (iview) {
samples = iview->image->info.samples;
format = iview->vk.format;
if (color_att->iview) {
samples = color_att->iview->image->info.samples;
format = color_att->iview->vk.format;
} else {
samples = cmd_buffer->state.pass->attachments[pass_att].samples;
format = cmd_buffer->state.pass->attachments[pass_att].format;
samples = render->max_samples;
format = color_att->format;
}
assert(format != VK_FORMAT_UNDEFINED);
assert(util_is_power_of_two_nonzero(samples));
samples_log2 = ffs(samples) - 1;
fs_key = radv_format_meta_fs_key(device, format);
assert(fs_key != -1);
......@@ -358,8 +361,6 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachment *cl
assert(samples_log2 < ARRAY_SIZE(device->meta_state.color_clear));
assert(pipeline);
assert(clear_att->aspectMask == VK_IMAGE_ASPECT_COLOR_BIT);
assert(clear_att->colorAttachment < subpass->color_count);
radv_CmdPushConstants(radv_cmd_buffer_to_handle(cmd_buffer),
device->meta_state.clear_color_p_layout, VK_SHADER_STAGE_FRAGMENT_BIT, 0,
......@@ -561,17 +562,13 @@ pick_depthstencil_pipeline(struct radv_cmd_buffer *cmd_buffer, struct radv_meta_
static void
emit_depthstencil_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachment *clear_att,
const VkClearRect *clear_rect, struct radv_subpass_attachment *ds_att,
uint32_t view_mask, bool ds_resolve_clear)
const VkClearRect *clear_rect, uint32_t view_mask)
{
struct radv_device *device = cmd_buffer->device;
struct radv_meta_state *meta_state = &device->meta_state;
const struct radv_subpass *subpass = cmd_buffer->state.subpass;
const uint32_t pass_att = ds_att->attachment;
const struct radv_rendering_state *render = &cmd_buffer->state.render;
VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil;
VkImageAspectFlags aspects = clear_att->aspectMask;
struct radv_image_view *iview =
cmd_buffer->state.attachments ? cmd_buffer->state.attachments[pass_att].iview : NULL;
uint32_t samples, samples_log2;
VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
......@@ -579,16 +576,17 @@ emit_depthstencil_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachm
* number of samples from it. Otherwise, get the number of samples from
* the render pass because it's likely a secondary command buffer.
*/
struct radv_image_view *iview = render->ds_att.iview;
if (iview) {
samples = iview->image->info.samples;
} else {
samples = cmd_buffer->state.pass->attachments[pass_att].samples;
assert(render->ds_att.format != VK_FORMAT_UNDEFINED);
samples = render->max_samples;
}
assert(util_is_power_of_two_nonzero(samples));
samples_log2 = ffs(samples) - 1;
assert(pass_att != VK_ATTACHMENT_UNUSED);
if (!(aspects & VK_IMAGE_ASPECT_DEPTH_BIT))
clear_value.depth = 1.0f;
......@@ -609,43 +607,14 @@ emit_depthstencil_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachm
VkPipeline pipeline =
pick_depthstencil_pipeline(cmd_buffer, meta_state, iview, samples_log2, aspects,
ds_att->layout, clear_rect, clear_value, view_mask);
render->ds_att.layout, clear_rect, clear_value, view_mask);
if (!pipeline)
return;
if (ds_resolve_clear) {
const VkRenderingAttachmentInfo depth_att = {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
.imageView = radv_image_view_to_handle(iview),
.imageLayout = cmd_buffer->state.attachments[pass_att].current_layout,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
};
const VkRenderingAttachmentInfo stencil_att = {
.sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
.imageView = radv_image_view_to_handle(iview),
.imageLayout = cmd_buffer->state.attachments[pass_att].current_stencil_layout,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
};
const VkRenderingInfo rendering_info = {
.sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
.renderArea = clear_rect->rect,
.layerCount = clear_rect->layerCount,
.viewMask = subpass->view_mask,
.pDepthAttachment = (aspects & VK_IMAGE_ASPECT_DEPTH_BIT) ? &depth_att : NULL,
.pStencilAttachment = (aspects & VK_IMAGE_ASPECT_STENCIL_BIT) ? &stencil_att : NULL,
};
radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
}
radv_CmdBindPipeline(cmd_buffer_h, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
if (radv_can_fast_clear_depth(cmd_buffer, iview, ds_att->layout, aspects, clear_rect,
clear_value, view_mask))
if (radv_can_fast_clear_depth(cmd_buffer, iview, render->ds_att.layout, aspects,
clear_rect, clear_value, view_mask))
radv_update_ds_clear_metadata(cmd_buffer, iview, clear_value, aspects);
radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1,
......@@ -667,9 +636,6 @@ emit_depthstencil_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachm
if (aspects & VK_IMAGE_ASPECT_STENCIL_BIT) {
radv_CmdSetStencilReference(cmd_buffer_h, VK_STENCIL_FACE_FRONT_BIT, prev_reference);
}
if (ds_resolve_clear)
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
}
static uint32_t
......@@ -1863,116 +1829,85 @@ radv_fast_clear_color(struct radv_cmd_buffer *cmd_buffer, const struct radv_imag
static void
emit_clear(struct radv_cmd_buffer *cmd_buffer, const VkClearAttachment *clear_att,
const VkClearRect *clear_rect, enum radv_cmd_flush_bits *pre_flush,
enum radv_cmd_flush_bits *post_flush, uint32_t view_mask, bool ds_resolve_clear)
enum radv_cmd_flush_bits *post_flush, uint32_t view_mask)
{
const struct vk_framebuffer *fb = cmd_buffer->state.framebuffer;
const struct radv_subpass *subpass = cmd_buffer->state.subpass;
const struct radv_rendering_state *render = &cmd_buffer->state.render;
VkImageAspectFlags aspects = clear_att->aspectMask;
if (aspects & VK_IMAGE_ASPECT_COLOR_BIT) {
const uint32_t subpass_att = clear_att->colorAttachment;
assert(subpass_att < subpass->color_count);
const uint32_t pass_att = subpass->color_attachments[subpass_att].attachment;
if (pass_att == VK_ATTACHMENT_UNUSED)
assert(clear_att->colorAttachment < render->color_att_count);
const struct radv_attachment *color_att =
&render->color_att[clear_att->colorAttachment];
if (color_att->format == VK_FORMAT_UNDEFINED)
return;
VkImageLayout image_layout = subpass->color_attachments[subpass_att].layout;
const struct radv_image_view *iview =
fb ? cmd_buffer->state.attachments[pass_att].iview : NULL;
VkClearColorValue clear_value = clear_att->clearValue.color;
if (radv_can_fast_clear_color(cmd_buffer, iview, image_layout, clear_rect,
if (radv_can_fast_clear_color(cmd_buffer, color_att->iview, color_att->layout, clear_rect,
clear_value, view_mask)) {
radv_fast_clear_color(cmd_buffer, iview, clear_att, pre_flush, post_flush);
radv_fast_clear_color(cmd_buffer, color_att->iview, clear_att, pre_flush, post_flush);
} else {
emit_color_clear(cmd_buffer, clear_att, clear_rect, view_mask);
}
} else {
struct radv_subpass_attachment *ds_att = subpass->depth_stencil_attachment;
if (ds_resolve_clear)
ds_att = subpass->ds_resolve_attachment;
const struct radv_attachment *ds_att = &render->ds_att;
if (!ds_att || ds_att->attachment == VK_ATTACHMENT_UNUSED)
if (ds_att->format == VK_FORMAT_UNDEFINED)
return;
VkImageLayout image_layout = ds_att->layout;
const struct radv_image_view *iview =
fb ? cmd_buffer->state.attachments[ds_att->attachment].iview : NULL;
VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil;
assert(aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
if (radv_can_fast_clear_depth(cmd_buffer, iview, image_layout, aspects,
if (radv_can_fast_clear_depth(cmd_buffer, ds_att->iview, ds_att->layout, aspects,
clear_rect, clear_value, view_mask)) {
radv_fast_clear_depth(cmd_buffer, iview, clear_att, pre_flush, post_flush);
radv_fast_clear_depth(cmd_buffer, ds_att->iview, clear_att, pre_flush, post_flush);
} else {
emit_depthstencil_clear(cmd_buffer, clear_att, clear_rect, ds_att, view_mask,
ds_resolve_clear);
emit_depthstencil_clear(cmd_buffer, clear_att, clear_rect, view_mask);
}
}
}
static inline bool
radv_attachment_needs_clear(struct radv_cmd_state *cmd_state, uint32_t a)
{
uint32_t view_mask = cmd_state->subpass->view_mask;
return (a != VK_ATTACHMENT_UNUSED && cmd_state->attachments[a].pending_clear_aspects &&
(!view_mask || (view_mask & ~cmd_state->attachments[a].cleared_views)));
}
static bool
radv_subpass_needs_clear(struct radv_cmd_buffer *cmd_buffer)
radv_rendering_needs_clear(const VkRenderingInfo *pRenderingInfo)
{
struct radv_cmd_state *cmd_state = &cmd_buffer->state;
uint32_t a;
if (!cmd_state->subpass)
return false;
for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) {
a = cmd_state->subpass->color_attachments[i].attachment;
if (radv_attachment_needs_clear(cmd_state, a))
for (uint32_t i = 0; i < pRenderingInfo->colorAttachmentCount; i++) {
if (pRenderingInfo->pColorAttachments[i].imageView != VK_NULL_HANDLE &&
pRenderingInfo->pColorAttachments[i].loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
return true;
}
if (cmd_state->subpass->depth_stencil_attachment) {
a = cmd_state->subpass->depth_stencil_attachment->attachment;
if (radv_attachment_needs_clear(cmd_state, a))
return true;
}
if (pRenderingInfo->pDepthAttachment != NULL &&
pRenderingInfo->pDepthAttachment->imageView != VK_NULL_HANDLE &&
pRenderingInfo->pDepthAttachment->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
return true;
if (!cmd_state->subpass->ds_resolve_attachment)
return false;
if (pRenderingInfo->pStencilAttachment != NULL &&
pRenderingInfo->pStencilAttachment->imageView != VK_NULL_HANDLE &&
pRenderingInfo->pStencilAttachment->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
return true;
a = cmd_state->subpass->ds_resolve_attachment->attachment;
return radv_attachment_needs_clear(cmd_state, a);
return false;
}
static void
radv_subpass_clear_attachment(struct radv_cmd_buffer *cmd_buffer,
struct radv_attachment_state *attachment,
const VkClearAttachment *clear_att,
enum radv_cmd_flush_bits *pre_flush,
enum radv_cmd_flush_bits *post_flush, bool ds_resolve_clear)
enum radv_cmd_flush_bits *post_flush)
{
struct radv_cmd_state *cmd_state = &cmd_buffer->state;
uint32_t view_mask = cmd_state->subpass->view_mask;
const struct radv_rendering_state *render = &cmd_buffer->state.render;
VkClearRect clear_rect = {
.rect = cmd_state->render_area,
.rect = render->area,
.baseArrayLayer = 0,
.layerCount = cmd_state->framebuffer->layers,
.layerCount = render->layer_count,
};
radv_describe_begin_render_pass_clear(cmd_buffer, clear_att->aspectMask);
emit_clear(cmd_buffer, clear_att, &clear_rect, pre_flush, post_flush,
view_mask & ~attachment->cleared_views, ds_resolve_clear);
if (view_mask)
attachment->cleared_views |= view_mask;
else
attachment->pending_clear_aspects = 0;
emit_clear(cmd_buffer, clear_att, &clear_rect, pre_flush, post_flush, render->view_mask);
radv_describe_end_render_pass_clear(cmd_buffer);
}
......@@ -1983,14 +1918,15 @@ radv_subpass_clear_attachment(struct radv_cmd_buffer *cmd_buffer,
* @see radv_attachment_state::pending_clear_aspects
*/
void
radv_cmd_buffer_clear_subpass(struct radv_cmd_buffer *cmd_buffer)
radv_cmd_buffer_clear_rendering(struct radv_cmd_buffer *cmd_buffer,
const VkRenderingInfo *pRenderingInfo)
{
struct radv_cmd_state *cmd_state = &cmd_buffer->state;
const struct radv_rendering_state *render = &cmd_buffer->state.render;
struct radv_meta_saved_state saved_state;
enum radv_cmd_flush_bits pre_flush = 0;
enum radv_cmd_flush_bits post_flush = 0;
if (!radv_subpass_needs_clear(cmd_buffer))
if (!radv_rendering_needs_clear(pRenderingInfo))
return;
/* Subpass clear should not be affected by conditional rendering. */
......@@ -1998,60 +1934,47 @@ radv_cmd_buffer_clear_subpass(struct radv_cmd_buffer *cmd_buffer)
&saved_state, cmd_buffer,
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_CONSTANTS | RADV_META_SUSPEND_PREDICATING);
for (uint32_t i = 0; i < cmd_state->subpass->color_count; ++i) {
uint32_t a = cmd_state->subpass->color_attachments[i].attachment;
if (!radv_attachment_needs_clear(cmd_state, a))
assert(render->color_att_count == pRenderingInfo->colorAttachmentCount);
for (uint32_t i = 0; i < render->color_att_count; i++) {
if (render->color_att[i].iview == NULL ||
pRenderingInfo->pColorAttachments[i].loadOp != VK_ATTACHMENT_LOAD_OP_CLEAR)
continue;
assert(cmd_state->attachments[a].pending_clear_aspects == VK_IMAGE_ASPECT_COLOR_BIT);
VkClearAttachment clear_att = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.colorAttachment = i, /* Use attachment index relative to subpass */
.clearValue = cmd_state->attachments[a].clear_value,
.colorAttachment = i,
.clearValue = pRenderingInfo->pColorAttachments[i].clearValue,
};
radv_subpass_clear_attachment(cmd_buffer, &cmd_state->attachments[a], &clear_att, &pre_flush,
&post_flush, false);
radv_subpass_clear_attachment(cmd_buffer, &clear_att, &pre_flush, &post_flush);
}
if (cmd_state->subpass->depth_stencil_attachment) {
uint32_t ds = cmd_state->subpass->depth_stencil_attachment->attachment;
if (radv_attachment_needs_clear(cmd_state, ds)) {
VkClearAttachment clear_att = {
.aspectMask = cmd_state->attachments[ds].pending_clear_aspects,
.clearValue = cmd_state->attachments[ds].clear_value,
};
if (render->ds_att.iview != NULL) {
VkClearAttachment clear_att = { .aspectMask = 0 };
radv_subpass_clear_attachment(cmd_buffer, &cmd_state->attachments[ds], &clear_att,
&pre_flush, &post_flush, false);
if (pRenderingInfo->pDepthAttachment != NULL &&
pRenderingInfo->pDepthAttachment->imageView != VK_NULL_HANDLE &&
pRenderingInfo->pDepthAttachment->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) {
clear_att.aspectMask |= VK_IMAGE_ASPECT_DEPTH_BIT;
clear_att.clearValue.depthStencil.depth =
pRenderingInfo->pDepthAttachment->clearValue.depthStencil.depth;
}
}
radv_meta_restore(&saved_state, cmd_buffer);
cmd_buffer->state.flush_bits |= post_flush;
if (cmd_state->subpass->ds_resolve_attachment) {
uint32_t ds_resolve = cmd_state->subpass->ds_resolve_attachment->attachment;
if (radv_attachment_needs_clear(cmd_state, ds_resolve)) {
radv_meta_save(&saved_state, cmd_buffer,
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_CONSTANTS |
RADV_META_SAVE_PASS | RADV_META_SUSPEND_PREDICATING);
VkClearAttachment clear_att = {
.aspectMask = cmd_state->attachments[ds_resolve].pending_clear_aspects,
.clearValue = cmd_state->attachments[ds_resolve].clear_value,
};
radv_subpass_clear_attachment(cmd_buffer, &cmd_state->attachments[ds_resolve], &clear_att,
&pre_flush, &post_flush, true);
if (pRenderingInfo->pStencilAttachment != NULL &&
pRenderingInfo->pStencilAttachment->imageView != VK_NULL_HANDLE &&
pRenderingInfo->pStencilAttachment->loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR) {
clear_att.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
clear_att.clearValue.depthStencil.stencil =
pRenderingInfo->pStencilAttachment->clearValue.depthStencil.stencil;
}
radv_meta_restore(&saved_state, cmd_buffer);
cmd_buffer->state.flush_bits |= post_flush;
if (clear_att.aspectMask != 0) {
radv_subpass_clear_attachment(cmd_buffer, &clear_att, &pre_flush, &post_flush);
}
}
radv_meta_restore(&saved_state, cmd_buffer);
cmd_buffer->state.flush_bits |= post_flush;
}
static void
......@@ -2122,7 +2045,7 @@ radv_clear_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_image *im
radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
emit_clear(cmd_buffer, &clear_att, &clear_rect, NULL, NULL, 0, false);
emit_clear(cmd_buffer, &clear_att, &clear_rect, NULL, NULL, 0);
radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
......@@ -2348,7 +2271,7 @@ radv_CmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount
enum radv_cmd_flush_bits pre_flush = 0;
enum radv_cmd_flush_bits post_flush = 0;
if (!cmd_buffer->state.subpass)
if (attachmentCount == 0)
return;
radv_meta_save(&saved_state, cmd_buffer,
......@@ -2360,7 +2283,7 @@ radv_CmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount
for (uint32_t a = 0; a < attachmentCount; ++a) {
for (uint32_t r = 0; r < rectCount; ++r) {
emit_clear(cmd_buffer, &pAttachments[a], &pRects[r], &pre_flush, &post_flush,
cmd_buffer->state.subpass->view_mask, false);
cmd_buffer->state.render.view_mask);
}
}
......
......@@ -470,7 +470,7 @@ radv_process_depth_stencil(struct radv_cmd_buffer *cmd_buffer, struct radv_image
radv_meta_save(
&saved_state, cmd_buffer,
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_PASS);
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_RENDER);
pipeline = radv_get_depth_pipeline(cmd_buffer, image, subresourceRange, op);
......
......@@ -591,7 +591,8 @@ radv_process_color_image(struct radv_cmd_buffer *cmd_buffer, struct radv_image *
}
}
radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_PASS);
radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS_PIPELINE |
RADV_META_SAVE_RENDER);
if (pred_offset) {
pred_offset += 8 * subresourceRange->baseMipLevel;
......
......@@ -563,34 +563,30 @@ radv_CmdResolveImage2(VkCommandBuffer commandBuffer,
}
static void
radv_cmd_buffer_resolve_subpass_hw(struct radv_cmd_buffer *cmd_buffer)
radv_cmd_buffer_resolve_rendering_hw(struct radv_cmd_buffer *cmd_buffer)
{
const struct radv_subpass *subpass = cmd_buffer->state.subpass;
VkRect2D resolve_area = cmd_buffer->state.render_area;
uint32_t layer_count = cmd_buffer->state.framebuffer->layers;
struct radv_meta_saved_state saved_state;
radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_PASS);
radv_meta_save(&saved_state, cmd_buffer,
RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_RENDER);
for (uint32_t i = 0; i < subpass->color_count; ++i) {
struct radv_subpass_attachment src_att = subpass->color_attachments[i];
struct radv_subpass_attachment dst_att = subpass->resolve_attachments[i];
if (dst_att.attachment == VK_ATTACHMENT_UNUSED)
for (uint32_t i = 0; i < saved_state.render.color_att_count; ++i) {
if (saved_state.render.color_att[i].resolve_iview == NULL)
continue;
struct radv_image_view *src_iview = saved_state.attachments[src_att.attachment].iview;
struct radv_image_view *src_iview = saved_state.render.color_att[i].iview;
VkImageLayout src_layout = saved_state.render.color_att[i].layout;
struct radv_image *src_img = src_iview->image;