2 * Copyright © 2016 Dave Airlie
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 #include "radv_meta.h"
29 #include "radv_private.h"
30 #include "nir/nir_builder.h"
32 #include "vk_format.h"
35 build_nir_vertex_shader(void)
37 const struct glsl_type
*vec4
= glsl_vec4_type();
40 nir_builder_init_simple_shader(&b
, NULL
, MESA_SHADER_VERTEX
, NULL
);
41 b
.shader
->info
.name
= ralloc_strdup(b
.shader
, "meta_resolve_vs");
43 nir_variable
*pos_out
= nir_variable_create(b
.shader
, nir_var_shader_out
,
45 pos_out
->data
.location
= VARYING_SLOT_POS
;
47 nir_ssa_def
*outvec
= radv_meta_gen_rect_vertices(&b
);
49 nir_store_var(&b
, pos_out
, outvec
, 0xf);
54 build_resolve_fragment_shader(struct radv_device
*dev
, bool is_integer
, int samples
)
58 const struct glsl_type
*vec2
= glsl_vector_type(GLSL_TYPE_FLOAT
, 2);
59 const struct glsl_type
*vec4
= glsl_vec4_type();
60 const struct glsl_type
*sampler_type
= glsl_sampler_type(GLSL_SAMPLER_DIM_MS
,
65 snprintf(name
, 64, "meta_resolve_fs-%d-%s", samples
, is_integer
? "int" : "float");
66 nir_builder_init_simple_shader(&b
, NULL
, MESA_SHADER_FRAGMENT
, NULL
);
67 b
.shader
->info
.name
= ralloc_strdup(b
.shader
, name
);
69 nir_variable
*input_img
= nir_variable_create(b
.shader
, nir_var_uniform
,
70 sampler_type
, "s_tex");
71 input_img
->data
.descriptor_set
= 0;
72 input_img
->data
.binding
= 0;
74 nir_variable
*fs_pos_in
= nir_variable_create(b
.shader
, nir_var_shader_in
, vec2
, "fs_pos_in");
75 fs_pos_in
->data
.location
= VARYING_SLOT_POS
;
77 nir_variable
*color_out
= nir_variable_create(b
.shader
, nir_var_shader_out
,
79 color_out
->data
.location
= FRAG_RESULT_DATA0
;
81 nir_ssa_def
*pos_in
= nir_load_var(&b
, fs_pos_in
);
82 nir_intrinsic_instr
*src_offset
= nir_intrinsic_instr_create(b
.shader
, nir_intrinsic_load_push_constant
);
83 nir_intrinsic_set_base(src_offset
, 0);
84 nir_intrinsic_set_range(src_offset
, 8);
85 src_offset
->src
[0] = nir_src_for_ssa(nir_imm_int(&b
, 0));
86 src_offset
->num_components
= 2;
87 nir_ssa_dest_init(&src_offset
->instr
, &src_offset
->dest
, 2, 32, "src_offset");
88 nir_builder_instr_insert(&b
, &src_offset
->instr
);
90 nir_ssa_def
*pos_int
= nir_f2i32(&b
, pos_in
);
92 nir_ssa_def
*img_coord
= nir_channels(&b
, nir_iadd(&b
, pos_int
, &src_offset
->dest
.ssa
), 0x3);
93 nir_variable
*color
= nir_local_variable_create(b
.impl
, glsl_vec4_type(), "color");
95 radv_meta_build_resolve_shader_core(&b
, is_integer
, samples
, input_img
,
98 nir_ssa_def
*outval
= nir_load_var(&b
, color
);
99 nir_store_var(&b
, color_out
, outval
, 0xf);
105 create_layout(struct radv_device
*device
)
109 * one descriptors for the image being sampled
111 VkDescriptorSetLayoutCreateInfo ds_create_info
= {
112 .sType
= VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
,
113 .flags
= VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR
,
115 .pBindings
= (VkDescriptorSetLayoutBinding
[]) {
118 .descriptorType
= VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
,
119 .descriptorCount
= 1,
120 .stageFlags
= VK_SHADER_STAGE_FRAGMENT_BIT
,
121 .pImmutableSamplers
= NULL
126 result
= radv_CreateDescriptorSetLayout(radv_device_to_handle(device
),
128 &device
->meta_state
.alloc
,
129 &device
->meta_state
.resolve_fragment
.ds_layout
);
130 if (result
!= VK_SUCCESS
)
134 VkPipelineLayoutCreateInfo pl_create_info
= {
135 .sType
= VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
,
137 .pSetLayouts
= &device
->meta_state
.resolve_fragment
.ds_layout
,
138 .pushConstantRangeCount
= 1,
139 .pPushConstantRanges
= &(VkPushConstantRange
){VK_SHADER_STAGE_FRAGMENT_BIT
, 0, 8},
142 result
= radv_CreatePipelineLayout(radv_device_to_handle(device
),
144 &device
->meta_state
.alloc
,
145 &device
->meta_state
.resolve_fragment
.p_layout
);
146 if (result
!= VK_SUCCESS
)
153 static const VkPipelineVertexInputStateCreateInfo normal_vi_create_info
= {
154 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
,
155 .vertexBindingDescriptionCount
= 0,
156 .vertexAttributeDescriptionCount
= 0,
160 create_resolve_pipeline(struct radv_device
*device
,
165 bool is_integer
= false;
166 uint32_t samples
= 1 << samples_log2
;
167 unsigned fs_key
= radv_format_meta_fs_key(format
);
168 const VkPipelineVertexInputStateCreateInfo
*vi_create_info
;
169 vi_create_info
= &normal_vi_create_info
;
170 if (vk_format_is_int(format
))
173 struct radv_shader_module fs
= { .nir
= NULL
};
174 fs
.nir
= build_resolve_fragment_shader(device
, is_integer
, samples
);
175 struct radv_shader_module vs
= {
176 .nir
= build_nir_vertex_shader(),
179 VkRenderPass
*rp
= &device
->meta_state
.resolve_fragment
.rc
[samples_log2
].render_pass
[fs_key
][0];
183 VkPipeline
*pipeline
= &device
->meta_state
.resolve_fragment
.rc
[samples_log2
].pipeline
[fs_key
];
186 VkPipelineShaderStageCreateInfo pipeline_shader_stages
[] = {
188 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
189 .stage
= VK_SHADER_STAGE_VERTEX_BIT
,
190 .module
= radv_shader_module_to_handle(&vs
),
192 .pSpecializationInfo
= NULL
194 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
195 .stage
= VK_SHADER_STAGE_FRAGMENT_BIT
,
196 .module
= radv_shader_module_to_handle(&fs
),
198 .pSpecializationInfo
= NULL
203 for (unsigned dst_layout
= 0; dst_layout
< RADV_META_DST_LAYOUT_COUNT
; ++dst_layout
) {
204 VkImageLayout layout
= radv_meta_dst_layout_to_layout(dst_layout
);
205 result
= radv_CreateRenderPass(radv_device_to_handle(device
),
206 &(VkRenderPassCreateInfo
) {
207 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO
,
208 .attachmentCount
= 1,
209 .pAttachments
= &(VkAttachmentDescription
) {
211 .loadOp
= VK_ATTACHMENT_LOAD_OP_LOAD
,
212 .storeOp
= VK_ATTACHMENT_STORE_OP_STORE
,
213 .initialLayout
= layout
,
214 .finalLayout
= layout
,
217 .pSubpasses
= &(VkSubpassDescription
) {
218 .pipelineBindPoint
= VK_PIPELINE_BIND_POINT_GRAPHICS
,
219 .inputAttachmentCount
= 0,
220 .colorAttachmentCount
= 1,
221 .pColorAttachments
= &(VkAttachmentReference
) {
225 .pResolveAttachments
= NULL
,
226 .pDepthStencilAttachment
= &(VkAttachmentReference
) {
227 .attachment
= VK_ATTACHMENT_UNUSED
,
228 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
230 .preserveAttachmentCount
= 1,
231 .pPreserveAttachments
= (uint32_t[]) { 0 },
233 .dependencyCount
= 0,
234 }, &device
->meta_state
.alloc
, rp
+ dst_layout
);
238 const VkGraphicsPipelineCreateInfo vk_pipeline_info
= {
239 .sType
= VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
,
240 .stageCount
= ARRAY_SIZE(pipeline_shader_stages
),
241 .pStages
= pipeline_shader_stages
,
242 .pVertexInputState
= vi_create_info
,
243 .pInputAssemblyState
= &(VkPipelineInputAssemblyStateCreateInfo
) {
244 .sType
= VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
,
245 .topology
= VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
,
246 .primitiveRestartEnable
= false,
248 .pViewportState
= &(VkPipelineViewportStateCreateInfo
) {
249 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
,
253 .pRasterizationState
= &(VkPipelineRasterizationStateCreateInfo
) {
254 .sType
= VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
,
255 .rasterizerDiscardEnable
= false,
256 .polygonMode
= VK_POLYGON_MODE_FILL
,
257 .cullMode
= VK_CULL_MODE_NONE
,
258 .frontFace
= VK_FRONT_FACE_COUNTER_CLOCKWISE
260 .pMultisampleState
= &(VkPipelineMultisampleStateCreateInfo
) {
261 .sType
= VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
,
262 .rasterizationSamples
= 1,
263 .sampleShadingEnable
= false,
264 .pSampleMask
= (VkSampleMask
[]) { UINT32_MAX
},
266 .pColorBlendState
= &(VkPipelineColorBlendStateCreateInfo
) {
267 .sType
= VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
,
268 .attachmentCount
= 1,
269 .pAttachments
= (VkPipelineColorBlendAttachmentState
[]) {
271 VK_COLOR_COMPONENT_A_BIT
|
272 VK_COLOR_COMPONENT_R_BIT
|
273 VK_COLOR_COMPONENT_G_BIT
|
274 VK_COLOR_COMPONENT_B_BIT
},
277 .pDynamicState
= &(VkPipelineDynamicStateCreateInfo
) {
278 .sType
= VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
,
279 .dynamicStateCount
= 9,
280 .pDynamicStates
= (VkDynamicState
[]) {
281 VK_DYNAMIC_STATE_VIEWPORT
,
282 VK_DYNAMIC_STATE_SCISSOR
,
283 VK_DYNAMIC_STATE_LINE_WIDTH
,
284 VK_DYNAMIC_STATE_DEPTH_BIAS
,
285 VK_DYNAMIC_STATE_BLEND_CONSTANTS
,
286 VK_DYNAMIC_STATE_DEPTH_BOUNDS
,
287 VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK
,
288 VK_DYNAMIC_STATE_STENCIL_WRITE_MASK
,
289 VK_DYNAMIC_STATE_STENCIL_REFERENCE
,
293 .layout
= device
->meta_state
.resolve_fragment
.p_layout
,
298 const struct radv_graphics_pipeline_create_info radv_pipeline_info
= {
302 result
= radv_graphics_pipeline_create(radv_device_to_handle(device
),
303 radv_pipeline_cache_to_handle(&device
->meta_state
.cache
),
304 &vk_pipeline_info
, &radv_pipeline_info
,
305 &device
->meta_state
.alloc
,
314 radv_device_init_meta_resolve_fragment_state(struct radv_device
*device
)
318 res
= create_layout(device
);
319 if (res
!= VK_SUCCESS
)
322 for (uint32_t i
= 0; i
< MAX_SAMPLES_LOG2
; ++i
) {
323 for (unsigned j
= 0; j
< NUM_META_FS_KEYS
; ++j
) {
324 res
= create_resolve_pipeline(device
, i
, radv_fs_key_format_exemplars
[j
]);
325 if (res
!= VK_SUCCESS
)
332 radv_device_finish_meta_resolve_fragment_state(device
);
337 radv_device_finish_meta_resolve_fragment_state(struct radv_device
*device
)
339 struct radv_meta_state
*state
= &device
->meta_state
;
340 for (uint32_t i
= 0; i
< MAX_SAMPLES_LOG2
; ++i
) {
341 for (unsigned j
= 0; j
< NUM_META_FS_KEYS
; ++j
) {
342 for(unsigned k
=0; k
< RADV_META_DST_LAYOUT_COUNT
; ++k
) {
343 radv_DestroyRenderPass(radv_device_to_handle(device
),
344 state
->resolve_fragment
.rc
[i
].render_pass
[j
][k
],
347 radv_DestroyPipeline(radv_device_to_handle(device
),
348 state
->resolve_fragment
.rc
[i
].pipeline
[j
],
353 radv_DestroyDescriptorSetLayout(radv_device_to_handle(device
),
354 state
->resolve_fragment
.ds_layout
,
356 radv_DestroyPipelineLayout(radv_device_to_handle(device
),
357 state
->resolve_fragment
.p_layout
,
362 emit_resolve(struct radv_cmd_buffer
*cmd_buffer
,
363 struct radv_image_view
*src_iview
,
364 struct radv_image_view
*dest_iview
,
365 const VkOffset2D
*src_offset
,
366 const VkOffset2D
*dest_offset
,
367 const VkExtent2D
*resolve_extent
)
369 struct radv_device
*device
= cmd_buffer
->device
;
370 VkCommandBuffer cmd_buffer_h
= radv_cmd_buffer_to_handle(cmd_buffer
);
371 const uint32_t samples
= src_iview
->image
->info
.samples
;
372 const uint32_t samples_log2
= ffs(samples
) - 1;
373 radv_meta_push_descriptor_set(cmd_buffer
,
374 VK_PIPELINE_BIND_POINT_GRAPHICS
,
375 cmd_buffer
->device
->meta_state
.resolve_fragment
.p_layout
,
377 1, /* descriptorWriteCount */
378 (VkWriteDescriptorSet
[]) {
380 .sType
= VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
,
382 .dstArrayElement
= 0,
383 .descriptorCount
= 1,
384 .descriptorType
= VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
,
385 .pImageInfo
= (VkDescriptorImageInfo
[]) {
387 .sampler
= VK_NULL_HANDLE
,
388 .imageView
= radv_image_view_to_handle(src_iview
),
389 .imageLayout
= VK_IMAGE_LAYOUT_GENERAL
,
395 cmd_buffer
->state
.flush_bits
|= RADV_CMD_FLAG_FLUSH_AND_INV_CB
;
397 unsigned push_constants
[2] = {
398 src_offset
->x
- dest_offset
->x
,
399 src_offset
->y
- dest_offset
->y
,
401 radv_CmdPushConstants(radv_cmd_buffer_to_handle(cmd_buffer
),
402 device
->meta_state
.resolve_fragment
.p_layout
,
403 VK_SHADER_STAGE_FRAGMENT_BIT
, 0, 8,
406 unsigned fs_key
= radv_format_meta_fs_key(dest_iview
->vk_format
);
407 VkPipeline pipeline_h
= device
->meta_state
.resolve_fragment
.rc
[samples_log2
].pipeline
[fs_key
];
409 radv_CmdBindPipeline(cmd_buffer_h
, VK_PIPELINE_BIND_POINT_GRAPHICS
,
412 radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer
), 0, 1, &(VkViewport
) {
415 .width
= resolve_extent
->width
,
416 .height
= resolve_extent
->height
,
421 radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer
), 0, 1, &(VkRect2D
) {
422 .offset
= *dest_offset
,
423 .extent
= *resolve_extent
,
426 radv_CmdDraw(cmd_buffer_h
, 3, 1, 0, 0);
427 cmd_buffer
->state
.flush_bits
|= RADV_CMD_FLAG_FLUSH_AND_INV_CB
;
430 void radv_meta_resolve_fragment_image(struct radv_cmd_buffer
*cmd_buffer
,
431 struct radv_image
*src_image
,
432 VkImageLayout src_image_layout
,
433 struct radv_image
*dest_image
,
434 VkImageLayout dest_image_layout
,
435 uint32_t region_count
,
436 const VkImageResolve
*regions
)
438 struct radv_device
*device
= cmd_buffer
->device
;
439 struct radv_meta_saved_state saved_state
;
440 const uint32_t samples
= src_image
->info
.samples
;
441 const uint32_t samples_log2
= ffs(samples
) - 1;
442 unsigned fs_key
= radv_format_meta_fs_key(dest_image
->vk_format
);
443 unsigned dst_layout
= radv_meta_dst_layout_from_layout(dest_image_layout
);
446 radv_decompress_resolve_src(cmd_buffer
, src_image
, src_image_layout
,
447 region_count
, regions
);
449 rp
= device
->meta_state
.resolve_fragment
.rc
[samples_log2
].render_pass
[fs_key
][dst_layout
];
451 radv_meta_save(&saved_state
, cmd_buffer
,
452 RADV_META_SAVE_GRAPHICS_PIPELINE
|
453 RADV_META_SAVE_CONSTANTS
|
454 RADV_META_SAVE_DESCRIPTORS
);
456 for (uint32_t r
= 0; r
< region_count
; ++r
) {
457 const VkImageResolve
*region
= ®ions
[r
];
459 assert(region
->srcSubresource
.aspectMask
== VK_IMAGE_ASPECT_COLOR_BIT
);
460 assert(region
->dstSubresource
.aspectMask
== VK_IMAGE_ASPECT_COLOR_BIT
);
461 assert(region
->srcSubresource
.layerCount
== region
->dstSubresource
.layerCount
);
463 const uint32_t src_base_layer
=
464 radv_meta_get_iview_layer(src_image
, ®ion
->srcSubresource
,
467 const uint32_t dest_base_layer
=
468 radv_meta_get_iview_layer(dest_image
, ®ion
->dstSubresource
,
471 const struct VkExtent3D extent
=
472 radv_sanitize_image_extent(src_image
->type
, region
->extent
);
473 const struct VkOffset3D srcOffset
=
474 radv_sanitize_image_offset(src_image
->type
, region
->srcOffset
);
475 const struct VkOffset3D dstOffset
=
476 radv_sanitize_image_offset(dest_image
->type
, region
->dstOffset
);
478 for (uint32_t layer
= 0; layer
< region
->srcSubresource
.layerCount
;
481 struct radv_image_view src_iview
;
482 radv_image_view_init(&src_iview
, cmd_buffer
->device
,
483 &(VkImageViewCreateInfo
) {
484 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
485 .image
= radv_image_to_handle(src_image
),
486 .viewType
= radv_meta_get_view_type(src_image
),
487 .format
= src_image
->vk_format
,
488 .subresourceRange
= {
489 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
490 .baseMipLevel
= region
->srcSubresource
.mipLevel
,
492 .baseArrayLayer
= src_base_layer
+ layer
,
497 struct radv_image_view dest_iview
;
498 radv_image_view_init(&dest_iview
, cmd_buffer
->device
,
499 &(VkImageViewCreateInfo
) {
500 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
501 .image
= radv_image_to_handle(dest_image
),
502 .viewType
= radv_meta_get_view_type(dest_image
),
503 .format
= dest_image
->vk_format
,
504 .subresourceRange
= {
505 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
506 .baseMipLevel
= region
->dstSubresource
.mipLevel
,
508 .baseArrayLayer
= dest_base_layer
+ layer
,
515 radv_CreateFramebuffer(radv_device_to_handle(cmd_buffer
->device
),
516 &(VkFramebufferCreateInfo
) {
517 .sType
= VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
,
518 .attachmentCount
= 1,
519 .pAttachments
= (VkImageView
[]) {
520 radv_image_view_to_handle(&dest_iview
),
522 .width
= extent
.width
+ dstOffset
.x
,
523 .height
= extent
.height
+ dstOffset
.y
,
525 }, &cmd_buffer
->pool
->alloc
, &fb
);
527 radv_CmdBeginRenderPass(radv_cmd_buffer_to_handle(cmd_buffer
),
528 &(VkRenderPassBeginInfo
) {
529 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
,
533 .offset
= { dstOffset
.x
, dstOffset
.y
, },
534 .extent
= { extent
.width
, extent
.height
},
536 .clearValueCount
= 0,
537 .pClearValues
= NULL
,
538 }, VK_SUBPASS_CONTENTS_INLINE
);
542 emit_resolve(cmd_buffer
,
545 &(VkOffset2D
) { srcOffset
.x
, srcOffset
.y
},
546 &(VkOffset2D
) { dstOffset
.x
, dstOffset
.y
},
547 &(VkExtent2D
) { extent
.width
, extent
.height
});
549 radv_CmdEndRenderPass(radv_cmd_buffer_to_handle(cmd_buffer
));
551 radv_DestroyFramebuffer(radv_device_to_handle(cmd_buffer
->device
), fb
, &cmd_buffer
->pool
->alloc
);
555 radv_meta_restore(&saved_state
, cmd_buffer
);
560 * Emit any needed resolves for the current subpass.
563 radv_cmd_buffer_resolve_subpass_fs(struct radv_cmd_buffer
*cmd_buffer
)
565 struct radv_framebuffer
*fb
= cmd_buffer
->state
.framebuffer
;
566 const struct radv_subpass
*subpass
= cmd_buffer
->state
.subpass
;
567 struct radv_meta_saved_state saved_state
;
568 struct radv_subpass_barrier barrier
;
570 /* Resolves happen before the end-of-subpass barriers get executed,
571 * so we have to make the attachment shader-readable */
572 barrier
.src_stage_mask
= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
;
573 barrier
.src_access_mask
= VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
;
574 barrier
.dst_access_mask
= VK_ACCESS_INPUT_ATTACHMENT_READ_BIT
;
575 radv_subpass_barrier(cmd_buffer
, &barrier
);
577 radv_decompress_resolve_subpass_src(cmd_buffer
);
579 radv_meta_save(&saved_state
, cmd_buffer
,
580 RADV_META_SAVE_GRAPHICS_PIPELINE
|
581 RADV_META_SAVE_CONSTANTS
|
582 RADV_META_SAVE_DESCRIPTORS
);
584 for (uint32_t i
= 0; i
< subpass
->color_count
; ++i
) {
585 struct radv_subpass_attachment src_att
= subpass
->color_attachments
[i
];
586 struct radv_subpass_attachment dest_att
= subpass
->resolve_attachments
[i
];
588 if (src_att
.attachment
== VK_ATTACHMENT_UNUSED
||
589 dest_att
.attachment
== VK_ATTACHMENT_UNUSED
)
592 struct radv_image_view
*dest_iview
= cmd_buffer
->state
.framebuffer
->attachments
[dest_att
.attachment
].attachment
;
593 struct radv_image_view
*src_iview
= cmd_buffer
->state
.framebuffer
->attachments
[src_att
.attachment
].attachment
;
595 struct radv_subpass resolve_subpass
= {
597 .color_attachments
= (struct radv_subpass_attachment
[]) { dest_att
},
598 .depth_stencil_attachment
= { .attachment
= VK_ATTACHMENT_UNUSED
},
601 radv_cmd_buffer_set_subpass(cmd_buffer
, &resolve_subpass
, false);
603 emit_resolve(cmd_buffer
,
606 &(VkOffset2D
) { 0, 0 },
607 &(VkOffset2D
) { 0, 0 },
608 &(VkExtent2D
) { fb
->width
, fb
->height
});
611 cmd_buffer
->state
.subpass
= subpass
;
612 radv_meta_restore(&saved_state
, cmd_buffer
);