So we can use it with imageless framebuffers. Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>tags/19.2-branchpoint
@@ -1528,19 +1528,18 @@ radv_update_bound_fast_clear_ds(struct radv_cmd_buffer *cmd_buffer, | |||
VkClearDepthStencilValue ds_clear_value, | |||
VkImageAspectFlags aspects) | |||
{ | |||
struct radv_framebuffer *framebuffer = cmd_buffer->state.framebuffer; | |||
const struct radv_subpass *subpass = cmd_buffer->state.subpass; | |||
struct radeon_cmdbuf *cs = cmd_buffer->cs; | |||
uint32_t att_idx; | |||
if (!framebuffer || !subpass) | |||
if (!cmd_buffer->state.attachments || !subpass) | |||
return; | |||
if (!subpass->depth_stencil_attachment) | |||
return; | |||
att_idx = subpass->depth_stencil_attachment->attachment; | |||
if (framebuffer->attachments[att_idx]->image != image) | |||
if (cmd_buffer->state.attachments[att_idx].iview->image != image) | |||
return; | |||
radeon_set_context_reg_seq(cs, R_028028_DB_STENCIL_CLEAR, 2); | |||
@@ -1776,19 +1775,18 @@ radv_update_bound_fast_clear_color(struct radv_cmd_buffer *cmd_buffer, | |||
int cb_idx, | |||
uint32_t color_values[2]) | |||
{ | |||
struct radv_framebuffer *framebuffer = cmd_buffer->state.framebuffer; | |||
const struct radv_subpass *subpass = cmd_buffer->state.subpass; | |||
struct radeon_cmdbuf *cs = cmd_buffer->cs; | |||
uint32_t att_idx; | |||
if (!framebuffer || !subpass) | |||
if (!cmd_buffer->state.attachments || !subpass) | |||
return; | |||
att_idx = subpass->color_attachments[cb_idx].attachment; | |||
if (att_idx == VK_ATTACHMENT_UNUSED) | |||
return; | |||
if (framebuffer->attachments[att_idx]->image != image) | |||
if (cmd_buffer->state.attachments[att_idx].iview->image != image) | |||
return; | |||
radeon_set_context_reg_seq(cs, R_028C8C_CB_COLOR0_CLEAR_WORD0 + cb_idx * 0x3c, 2); | |||
@@ -1913,7 +1911,7 @@ radv_emit_framebuffer_state(struct radv_cmd_buffer *cmd_buffer) | |||
} | |||
int idx = subpass->color_attachments[i].attachment; | |||
struct radv_image_view *iview = framebuffer->attachments[idx]; | |||
struct radv_image_view *iview = cmd_buffer->state.attachments[idx].iview; | |||
VkImageLayout layout = subpass->color_attachments[i].layout; | |||
radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, iview->bo); | |||
@@ -1928,8 +1926,8 @@ radv_emit_framebuffer_state(struct radv_cmd_buffer *cmd_buffer) | |||
if (subpass->depth_stencil_attachment) { | |||
int idx = subpass->depth_stencil_attachment->attachment; | |||
VkImageLayout layout = subpass->depth_stencil_attachment->layout; | |||
struct radv_image *image = framebuffer->attachments[idx]->image; | |||
radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, framebuffer->attachments[idx]->bo); | |||
struct radv_image *image = cmd_buffer->state.attachments[idx].iview->image; | |||
radv_cs_add_buffer(cmd_buffer->device->ws, cmd_buffer->cs, cmd_buffer->state.attachments[idx].iview->bo); | |||
ASSERTED uint32_t queue_mask = radv_image_queue_family_mask(image, | |||
cmd_buffer->queue_family_index, | |||
cmd_buffer->queue_family_index); | |||
@@ -2839,7 +2837,7 @@ radv_get_attachment_sample_locations(struct radv_cmd_buffer *cmd_buffer, | |||
{ | |||
struct radv_cmd_state *state = &cmd_buffer->state; | |||
uint32_t subpass_id = radv_get_subpass_id(cmd_buffer); | |||
struct radv_image_view *view = state->framebuffer->attachments[att_idx]; | |||
struct radv_image_view *view = state->attachments[att_idx].iview; | |||
if (view->image->info.samples == 1) | |||
return NULL; | |||
@@ -2878,7 +2876,7 @@ static void radv_handle_subpass_image_transition(struct radv_cmd_buffer *cmd_buf | |||
bool begin_subpass) | |||
{ | |||
unsigned idx = att.attachment; | |||
struct radv_image_view *view = cmd_buffer->state.framebuffer->attachments[idx]; | |||
struct radv_image_view *view = cmd_buffer->state.attachments[idx].iview; | |||
struct radv_sample_locations_state *sample_locs; | |||
VkImageSubresourceRange range; | |||
range.aspectMask = 0; | |||
@@ -2932,7 +2930,6 @@ radv_cmd_state_setup_sample_locations(struct radv_cmd_buffer *cmd_buffer, | |||
vk_find_struct_const(info->pNext, | |||
RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT); | |||
struct radv_cmd_state *state = &cmd_buffer->state; | |||
struct radv_framebuffer *framebuffer = state->framebuffer; | |||
if (!sample_locs) { | |||
state->subpass_sample_locs = NULL; | |||
@@ -2943,7 +2940,7 @@ radv_cmd_state_setup_sample_locations(struct radv_cmd_buffer *cmd_buffer, | |||
const VkAttachmentSampleLocationsEXT *att_sample_locs = | |||
&sample_locs->pAttachmentInitialSampleLocations[i]; | |||
uint32_t att_idx = att_sample_locs->attachmentIndex; | |||
struct radv_image *image = framebuffer->attachments[att_idx]->image; | |||
struct radv_image *image = cmd_buffer->state.attachments[att_idx].iview->image; | |||
assert(vk_format_is_depth_or_stencil(image->vk_format)); | |||
@@ -367,10 +367,10 @@ emit_color_clear(struct radv_cmd_buffer *cmd_buffer, | |||
{ | |||
struct radv_device *device = cmd_buffer->device; | |||
const struct radv_subpass *subpass = cmd_buffer->state.subpass; | |||
const struct radv_framebuffer *fb = cmd_buffer->state.framebuffer; | |||
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 = fb ? fb->attachments[pass_att] : NULL; | |||
const struct radv_image_view *iview = cmd_buffer->state.attachments ? | |||
cmd_buffer->state.attachments[pass_att].iview : NULL; | |||
uint32_t samples, samples_log2; | |||
VkFormat format; | |||
unsigned fs_key; | |||
@@ -721,11 +721,11 @@ emit_depthstencil_clear(struct radv_cmd_buffer *cmd_buffer, | |||
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 struct radv_framebuffer *fb = cmd_buffer->state.framebuffer; | |||
const uint32_t pass_att = ds_att->attachment; | |||
VkClearDepthStencilValue clear_value = clear_att->clearValue.depthStencil; | |||
VkImageAspectFlags aspects = clear_att->aspectMask; | |||
const struct radv_image_view *iview = fb ? fb->attachments[pass_att] : NULL; | |||
const 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); | |||
@@ -1679,7 +1679,7 @@ emit_clear(struct radv_cmd_buffer *cmd_buffer, | |||
return; | |||
VkImageLayout image_layout = subpass->color_attachments[subpass_att].layout; | |||
const struct radv_image_view *iview = fb ? fb->attachments[pass_att] : NULL; | |||
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, | |||
@@ -1700,7 +1700,7 @@ emit_clear(struct radv_cmd_buffer *cmd_buffer, | |||
return; | |||
VkImageLayout image_layout = ds_att->layout; | |||
const struct radv_image_view *iview = fb ? fb->attachments[ds_att->attachment] : NULL; | |||
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 | |
@@ -641,9 +641,9 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) | |||
struct radv_subpass_attachment src_att = *subpass->depth_stencil_attachment; | |||
struct radv_subpass_attachment dst_att = *subpass->ds_resolve_attachment; | |||
struct radv_image_view *src_iview = | |||
cmd_buffer->state.framebuffer->attachments[src_att.attachment]; | |||
cmd_buffer->state.attachments[src_att.attachment].iview; | |||
struct radv_image_view *dst_iview = | |||
cmd_buffer->state.framebuffer->attachments[dst_att.attachment]; | |||
cmd_buffer->state.attachments[dst_att.attachment].iview; | |||
radv_pick_resolve_method_images(src_iview->image, | |||
src_iview->vk_format, | |||
@@ -694,8 +694,8 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) | |||
/* Make sure to not clear color attachments after resolves. */ | |||
cmd_buffer->state.attachments[dest_att.attachment].pending_clear_aspects = 0; | |||
struct radv_image *dst_img = cmd_buffer->state.framebuffer->attachments[dest_att.attachment]->image; | |||
struct radv_image_view *src_iview= cmd_buffer->state.framebuffer->attachments[src_att.attachment]; | |||
struct radv_image *dst_img = cmd_buffer->state.attachments[dest_att.attachment].iview->image; | |||
struct radv_image_view *src_iview= cmd_buffer->state.attachments[src_att.attachment].iview; | |||
struct radv_image *src_img = src_iview->image; | |||
radv_pick_resolve_method_images(src_img, src_iview->vk_format, | |||
@@ -725,7 +725,7 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) | |||
if (dest_att.attachment == VK_ATTACHMENT_UNUSED) | |||
continue; | |||
struct radv_image_view *dest_iview = cmd_buffer->state.framebuffer->attachments[dest_att.attachment]; | |||
struct radv_image_view *dest_iview = cmd_buffer->state.attachments[dest_att.attachment].iview; | |||
struct radv_image *dst_img = dest_iview->image; | |||
if (radv_dcc_enabled(dst_img, dest_iview->base_mip)) { | |||
@@ -787,7 +787,7 @@ radv_decompress_resolve_subpass_src(struct radv_cmd_buffer *cmd_buffer) | |||
if (dest_att.attachment == VK_ATTACHMENT_UNUSED) | |||
continue; | |||
struct radv_image_view *src_iview = fb->attachments[src_att.attachment]; | |||
struct radv_image_view *src_iview = cmd_buffer->state.attachments[src_att.attachment].iview; | |||
struct radv_image *src_image = src_iview->image; | |||
VkImageResolve region = {}; |
@@ -921,8 +921,8 @@ radv_cmd_buffer_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer) | |||
if (dst_att.attachment == VK_ATTACHMENT_UNUSED) | |||
continue; | |||
struct radv_image_view *src_iview = fb->attachments[src_att.attachment]; | |||
struct radv_image_view *dst_iview = fb->attachments[dst_att.attachment]; | |||
struct radv_image_view *src_iview = cmd_buffer->state.attachments[src_att.attachment].iview; | |||
struct radv_image_view *dst_iview = cmd_buffer->state.attachments[dst_att.attachment].iview; | |||
VkImageResolve region = { | |||
.extent = (VkExtent3D){ fb->width, fb->height, 0 }, | |||
@@ -989,9 +989,9 @@ radv_depth_stencil_resolve_subpass_cs(struct radv_cmd_buffer *cmd_buffer, | |||
struct radv_subpass_attachment dest_att = *subpass->ds_resolve_attachment; | |||
struct radv_image_view *src_iview = | |||
cmd_buffer->state.framebuffer->attachments[src_att.attachment]; | |||
cmd_buffer->state.attachments[src_att.attachment].iview; | |||
struct radv_image_view *dst_iview = | |||
cmd_buffer->state.framebuffer->attachments[dest_att.attachment]; | |||
cmd_buffer->state.attachments[dest_att.attachment].iview; | |||
struct radv_image *src_image = src_iview->image; | |||
struct radv_image *dst_image = dst_iview->image; |
@@ -1146,8 +1146,8 @@ radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer) | |||
if (dest_att.attachment == VK_ATTACHMENT_UNUSED) | |||
continue; | |||
struct radv_image_view *dest_iview = cmd_buffer->state.framebuffer->attachments[dest_att.attachment]; | |||
struct radv_image_view *src_iview = cmd_buffer->state.framebuffer->attachments[src_att.attachment]; | |||
struct radv_image_view *dest_iview = cmd_buffer->state.attachments[dest_att.attachment].iview; | |||
struct radv_image_view *src_iview = cmd_buffer->state.attachments[src_att.attachment].iview; | |||
struct radv_subpass resolve_subpass = { | |||
.color_count = 1, | |||
@@ -1201,10 +1201,10 @@ radv_depth_stencil_resolve_subpass_fs(struct radv_cmd_buffer *cmd_buffer, | |||
struct radv_subpass_attachment dst_att = *subpass->ds_resolve_attachment; | |||
struct radv_image_view *src_iview = | |||
cmd_buffer->state.framebuffer->attachments[src_att.attachment]; | |||
cmd_buffer->state.attachments[src_att.attachment].iview; | |||
struct radv_image *src_image = src_iview->image; | |||
struct radv_image_view *dst_iview = | |||
cmd_buffer->state.framebuffer->attachments[dst_att.attachment]; | |||
cmd_buffer->state.attachments[dst_att.attachment].iview; | |||
struct radv_subpass resolve_subpass = { | |||
.color_count = 0, |
@@ -1104,6 +1104,7 @@ struct radv_attachment_state { | |||
struct radv_color_buffer_info cb; | |||
struct radv_ds_buffer_info ds; | |||
}; | |||
struct radv_image_view *iview; | |||
}; | |||
struct radv_descriptor_state { |