2 * Copyright © 2015 Intel Corporation
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
31 #include "anv_meta_clear.h"
32 #include "anv_private.h"
33 #include "anv_nir_builder.h"
35 struct anv_render_pass anv_meta_dummy_renderpass
= {0};
38 build_nir_vertex_shader(bool attr_flat
)
42 const struct glsl_type
*vertex_type
= glsl_vec4_type();
44 nir_builder_init_simple_shader(&b
, MESA_SHADER_VERTEX
);
46 nir_variable
*pos_in
= nir_variable_create(b
.shader
, nir_var_shader_in
,
47 vertex_type
, "a_pos");
48 pos_in
->data
.location
= VERT_ATTRIB_GENERIC0
;
49 nir_variable
*pos_out
= nir_variable_create(b
.shader
, nir_var_shader_out
,
50 vertex_type
, "gl_Position");
51 pos_in
->data
.location
= VARYING_SLOT_POS
;
52 nir_copy_var(&b
, pos_out
, pos_in
);
54 /* Add one more pass-through attribute. For clear shaders, this is used
55 * to store the color and for blit shaders it's the texture coordinate.
57 const struct glsl_type
*attr_type
= glsl_vec4_type();
58 nir_variable
*attr_in
= nir_variable_create(b
.shader
, nir_var_shader_in
,
60 attr_in
->data
.location
= VERT_ATTRIB_GENERIC1
;
61 nir_variable
*attr_out
= nir_variable_create(b
.shader
, nir_var_shader_out
,
63 attr_out
->data
.location
= VARYING_SLOT_VAR0
;
64 attr_out
->data
.interpolation
= attr_flat
? INTERP_QUALIFIER_FLAT
:
65 INTERP_QUALIFIER_SMOOTH
;
66 nir_copy_var(&b
, attr_out
, attr_in
);
72 build_nir_copy_fragment_shader(enum glsl_sampler_dim tex_dim
)
76 nir_builder_init_simple_shader(&b
, MESA_SHADER_FRAGMENT
);
78 const struct glsl_type
*color_type
= glsl_vec4_type();
80 nir_variable
*tex_pos_in
= nir_variable_create(b
.shader
, nir_var_shader_in
,
81 glsl_vec4_type(), "v_attr");
82 tex_pos_in
->data
.location
= VARYING_SLOT_VAR0
;
84 const struct glsl_type
*sampler_type
=
85 glsl_sampler_type(tex_dim
, false, false, glsl_get_base_type(color_type
));
86 nir_variable
*sampler
= nir_variable_create(b
.shader
, nir_var_uniform
,
87 sampler_type
, "s_tex");
88 sampler
->data
.descriptor_set
= 0;
89 sampler
->data
.binding
= 0;
91 nir_tex_instr
*tex
= nir_tex_instr_create(b
.shader
, 1);
92 tex
->sampler_dim
= tex_dim
;
93 tex
->op
= nir_texop_tex
;
94 tex
->src
[0].src_type
= nir_tex_src_coord
;
95 tex
->src
[0].src
= nir_src_for_ssa(nir_load_var(&b
, tex_pos_in
));
96 tex
->dest_type
= nir_type_float
; /* TODO */
99 case GLSL_SAMPLER_DIM_2D
:
100 tex
->coord_components
= 2;
102 case GLSL_SAMPLER_DIM_3D
:
103 tex
->coord_components
= 3;
106 assert(!"Unsupported texture dimension");
109 tex
->sampler
= nir_deref_var_create(tex
, sampler
);
111 nir_ssa_dest_init(&tex
->instr
, &tex
->dest
, 4, "tex");
112 nir_builder_instr_insert(&b
, &tex
->instr
);
114 nir_variable
*color_out
= nir_variable_create(b
.shader
, nir_var_shader_out
,
115 color_type
, "f_color");
116 color_out
->data
.location
= FRAG_RESULT_DATA0
;
117 nir_store_var(&b
, color_out
, &tex
->dest
.ssa
);
123 anv_meta_save(struct anv_meta_saved_state
*state
,
124 const struct anv_cmd_buffer
*cmd_buffer
,
125 uint32_t dynamic_mask
)
127 state
->old_pipeline
= cmd_buffer
->state
.pipeline
;
128 state
->old_descriptor_set0
= cmd_buffer
->state
.descriptors
[0];
129 memcpy(state
->old_vertex_bindings
, cmd_buffer
->state
.vertex_bindings
,
130 sizeof(state
->old_vertex_bindings
));
132 state
->dynamic_mask
= dynamic_mask
;
133 anv_dynamic_state_copy(&state
->dynamic
, &cmd_buffer
->state
.dynamic
,
138 anv_meta_restore(const struct anv_meta_saved_state
*state
,
139 struct anv_cmd_buffer
*cmd_buffer
)
141 cmd_buffer
->state
.pipeline
= state
->old_pipeline
;
142 cmd_buffer
->state
.descriptors
[0] = state
->old_descriptor_set0
;
143 memcpy(cmd_buffer
->state
.vertex_bindings
, state
->old_vertex_bindings
,
144 sizeof(state
->old_vertex_bindings
));
146 cmd_buffer
->state
.vb_dirty
|= (1 << ANV_META_VERTEX_BINDING_COUNT
) - 1;
147 cmd_buffer
->state
.dirty
|= ANV_CMD_DIRTY_PIPELINE
;
148 cmd_buffer
->state
.descriptors_dirty
|= VK_SHADER_STAGE_VERTEX_BIT
;
150 anv_dynamic_state_copy(&cmd_buffer
->state
.dynamic
, &state
->dynamic
,
151 state
->dynamic_mask
);
152 cmd_buffer
->state
.dirty
|= state
->dynamic_mask
;
155 static VkImageViewType
156 meta_blit_get_src_image_view_type(const struct anv_image
*src_image
)
158 switch (src_image
->type
) {
159 case VK_IMAGE_TYPE_1D
:
160 return VK_IMAGE_VIEW_TYPE_1D
;
161 case VK_IMAGE_TYPE_2D
:
162 return VK_IMAGE_VIEW_TYPE_2D
;
163 case VK_IMAGE_TYPE_3D
:
164 return VK_IMAGE_VIEW_TYPE_3D
;
166 assert(!"bad VkImageType");
172 meta_blit_get_dest_view_base_array_slice(const struct anv_image
*dest_image
,
173 const VkImageSubresourceCopy
*dest_subresource
,
174 const VkOffset3D
*dest_offset
)
176 switch (dest_image
->type
) {
177 case VK_IMAGE_TYPE_1D
:
178 case VK_IMAGE_TYPE_2D
:
179 return dest_subresource
->arrayLayer
;
180 case VK_IMAGE_TYPE_3D
:
181 /* HACK: Vulkan does not allow attaching a 3D image to a framebuffer,
182 * but meta does it anyway. When doing so, we translate the
183 * destination's z offset into an array offset.
185 return dest_offset
->z
;
187 assert(!"bad VkImageType");
193 anv_device_init_meta_blit_state(struct anv_device
*device
)
195 anv_CreateRenderPass(anv_device_to_handle(device
),
196 &(VkRenderPassCreateInfo
) {
197 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO
,
198 .attachmentCount
= 1,
199 .pAttachments
= &(VkAttachmentDescription
) {
200 .sType
= VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION
,
201 .format
= VK_FORMAT_UNDEFINED
, /* Our shaders don't care */
202 .loadOp
= VK_ATTACHMENT_LOAD_OP_LOAD
,
203 .storeOp
= VK_ATTACHMENT_STORE_OP_STORE
,
204 .initialLayout
= VK_IMAGE_LAYOUT_GENERAL
,
205 .finalLayout
= VK_IMAGE_LAYOUT_GENERAL
,
208 .pSubpasses
= &(VkSubpassDescription
) {
209 .sType
= VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION
,
210 .pipelineBindPoint
= VK_PIPELINE_BIND_POINT_GRAPHICS
,
213 .pColorAttachments
= &(VkAttachmentReference
) {
215 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
217 .pResolveAttachments
= NULL
,
218 .depthStencilAttachment
= (VkAttachmentReference
) {
219 .attachment
= VK_ATTACHMENT_UNUSED
,
220 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
223 .pPreserveAttachments
= &(VkAttachmentReference
) {
225 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
228 .dependencyCount
= 0,
229 }, &device
->meta_state
.blit
.render_pass
);
231 /* We don't use a vertex shader for clearing, but instead build and pass
232 * the VUEs directly to the rasterization backend. However, we do need
233 * to provide GLSL source for the vertex shader so that the compiler
234 * does not dead-code our inputs.
236 struct anv_shader_module vsm
= {
237 .nir
= build_nir_vertex_shader(false),
240 struct anv_shader_module fsm_2d
= {
241 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D
),
244 struct anv_shader_module fsm_3d
= {
245 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_3D
),
249 anv_CreateShader(anv_device_to_handle(device
),
250 &(VkShaderCreateInfo
) {
251 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
252 .module
= anv_shader_module_to_handle(&vsm
),
257 anv_CreateShader(anv_device_to_handle(device
),
258 &(VkShaderCreateInfo
) {
259 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
260 .module
= anv_shader_module_to_handle(&fsm_2d
),
265 anv_CreateShader(anv_device_to_handle(device
),
266 &(VkShaderCreateInfo
) {
267 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
268 .module
= anv_shader_module_to_handle(&fsm_3d
),
272 VkPipelineVertexInputStateCreateInfo vi_create_info
= {
273 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
,
275 .pVertexBindingDescriptions
= (VkVertexInputBindingDescription
[]) {
279 .stepRate
= VK_VERTEX_INPUT_STEP_RATE_VERTEX
283 .strideInBytes
= 5 * sizeof(float),
284 .stepRate
= VK_VERTEX_INPUT_STEP_RATE_VERTEX
288 .pVertexAttributeDescriptions
= (VkVertexInputAttributeDescription
[]) {
293 .format
= VK_FORMAT_R32G32B32A32_UINT
,
300 .format
= VK_FORMAT_R32G32_SFLOAT
,
304 /* Texture Coordinate */
307 .format
= VK_FORMAT_R32G32B32_SFLOAT
,
313 VkDescriptorSetLayoutCreateInfo ds_layout_info
= {
314 .sType
= VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
,
316 .pBinding
= (VkDescriptorSetLayoutBinding
[]) {
318 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
320 .stageFlags
= VK_SHADER_STAGE_FRAGMENT_BIT
,
321 .pImmutableSamplers
= NULL
325 anv_CreateDescriptorSetLayout(anv_device_to_handle(device
), &ds_layout_info
,
326 &device
->meta_state
.blit
.ds_layout
);
328 anv_CreatePipelineLayout(anv_device_to_handle(device
),
329 &(VkPipelineLayoutCreateInfo
) {
330 .sType
= VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
,
331 .descriptorSetCount
= 1,
332 .pSetLayouts
= &device
->meta_state
.blit
.ds_layout
,
334 &device
->meta_state
.blit
.pipeline_layout
);
336 VkPipelineShaderStageCreateInfo pipeline_shader_stages
[] = {
338 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
339 .stage
= VK_SHADER_STAGE_VERTEX
,
341 .pSpecializationInfo
= NULL
343 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
344 .stage
= VK_SHADER_STAGE_FRAGMENT
,
345 .shader
= {0}, /* TEMPLATE VALUE! FILL ME IN! */
346 .pSpecializationInfo
= NULL
350 const VkGraphicsPipelineCreateInfo vk_pipeline_info
= {
351 .sType
= VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
,
352 .stageCount
= ARRAY_SIZE(pipeline_shader_stages
),
353 .pStages
= pipeline_shader_stages
,
354 .pVertexInputState
= &vi_create_info
,
355 .pInputAssemblyState
= &(VkPipelineInputAssemblyStateCreateInfo
) {
356 .sType
= VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
,
357 .topology
= VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
,
358 .primitiveRestartEnable
= false,
360 .pViewportState
= &(VkPipelineViewportStateCreateInfo
) {
361 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
,
365 .pRasterState
= &(VkPipelineRasterStateCreateInfo
) {
366 .sType
= VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO
,
367 .depthClipEnable
= true,
368 .rasterizerDiscardEnable
= false,
369 .fillMode
= VK_FILL_MODE_SOLID
,
370 .cullMode
= VK_CULL_MODE_NONE
,
371 .frontFace
= VK_FRONT_FACE_CCW
373 .pMultisampleState
= &(VkPipelineMultisampleStateCreateInfo
) {
374 .sType
= VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
,
376 .sampleShadingEnable
= false,
377 .pSampleMask
= (VkSampleMask
[]) { UINT32_MAX
},
379 .pColorBlendState
= &(VkPipelineColorBlendStateCreateInfo
) {
380 .sType
= VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
,
381 .attachmentCount
= 1,
382 .pAttachments
= (VkPipelineColorBlendAttachmentState
[]) {
383 { .channelWriteMask
= VK_CHANNEL_A_BIT
|
384 VK_CHANNEL_R_BIT
| VK_CHANNEL_G_BIT
| VK_CHANNEL_B_BIT
},
387 .pDynamicState
= &(VkPipelineDynamicStateCreateInfo
) {
388 .sType
= VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
,
389 .dynamicStateCount
= 9,
390 .pDynamicStates
= (VkDynamicState
[]) {
391 VK_DYNAMIC_STATE_VIEWPORT
,
392 VK_DYNAMIC_STATE_SCISSOR
,
393 VK_DYNAMIC_STATE_LINE_WIDTH
,
394 VK_DYNAMIC_STATE_DEPTH_BIAS
,
395 VK_DYNAMIC_STATE_BLEND_CONSTANTS
,
396 VK_DYNAMIC_STATE_DEPTH_BOUNDS
,
397 VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK
,
398 VK_DYNAMIC_STATE_STENCIL_WRITE_MASK
,
399 VK_DYNAMIC_STATE_STENCIL_REFERENCE
,
403 .layout
= device
->meta_state
.blit
.pipeline_layout
,
404 .renderPass
= device
->meta_state
.blit
.render_pass
,
408 const struct anv_graphics_pipeline_create_info anv_pipeline_info
= {
409 .use_repclear
= false,
410 .disable_viewport
= true,
411 .disable_scissor
= true,
416 pipeline_shader_stages
[1].shader
= fs_2d
;
417 anv_graphics_pipeline_create(anv_device_to_handle(device
),
418 &vk_pipeline_info
, &anv_pipeline_info
,
419 &device
->meta_state
.blit
.pipeline_2d_src
);
421 pipeline_shader_stages
[1].shader
= fs_3d
;
422 anv_graphics_pipeline_create(anv_device_to_handle(device
),
423 &vk_pipeline_info
, &anv_pipeline_info
,
424 &device
->meta_state
.blit
.pipeline_3d_src
);
426 anv_DestroyShader(anv_device_to_handle(device
), vs
);
427 anv_DestroyShader(anv_device_to_handle(device
), fs_2d
);
428 anv_DestroyShader(anv_device_to_handle(device
), fs_3d
);
429 ralloc_free(vsm
.nir
);
430 ralloc_free(fsm_2d
.nir
);
431 ralloc_free(fsm_3d
.nir
);
435 meta_prepare_blit(struct anv_cmd_buffer
*cmd_buffer
,
436 struct anv_meta_saved_state
*saved_state
)
438 anv_meta_save(saved_state
, cmd_buffer
,
439 (1 << VK_DYNAMIC_STATE_VIEWPORT
));
443 VkOffset3D src_offset
;
444 VkExtent3D src_extent
;
445 VkOffset3D dest_offset
;
446 VkExtent3D dest_extent
;
450 meta_emit_blit(struct anv_cmd_buffer
*cmd_buffer
,
451 struct anv_image
*src_image
,
452 struct anv_image_view
*src_iview
,
453 VkOffset3D src_offset
,
454 VkExtent3D src_extent
,
455 struct anv_image
*dest_image
,
456 struct anv_image_view
*dest_iview
,
457 VkOffset3D dest_offset
,
458 VkExtent3D dest_extent
,
459 VkTexFilter blit_filter
)
461 struct anv_device
*device
= cmd_buffer
->device
;
462 VkDescriptorPool dummy_desc_pool
= { .handle
= 1 };
464 struct blit_vb_data
{
469 unsigned vb_size
= sizeof(struct anv_vue_header
) + 3 * sizeof(*vb_data
);
471 struct anv_state vb_state
=
472 anv_cmd_buffer_alloc_dynamic_state(cmd_buffer
, vb_size
, 16);
473 memset(vb_state
.map
, 0, sizeof(struct anv_vue_header
));
474 vb_data
= vb_state
.map
+ sizeof(struct anv_vue_header
);
476 vb_data
[0] = (struct blit_vb_data
) {
478 dest_offset
.x
+ dest_extent
.width
,
479 dest_offset
.y
+ dest_extent
.height
,
482 (float)(src_offset
.x
+ src_extent
.width
) / (float)src_iview
->extent
.width
,
483 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
484 (float)(src_offset
.z
+ src_extent
.depth
) / (float)src_iview
->extent
.depth
,
488 vb_data
[1] = (struct blit_vb_data
) {
491 dest_offset
.y
+ dest_extent
.height
,
494 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
495 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
496 (float)(src_offset
.z
+ src_extent
.depth
) / (float)src_iview
->extent
.depth
,
500 vb_data
[2] = (struct blit_vb_data
) {
506 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
507 (float)src_offset
.y
/ (float)src_iview
->extent
.height
,
508 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
512 struct anv_buffer vertex_buffer
= {
515 .bo
= &device
->dynamic_state_block_pool
.bo
,
516 .offset
= vb_state
.offset
,
519 anv_CmdBindVertexBuffers(anv_cmd_buffer_to_handle(cmd_buffer
), 0, 2,
521 anv_buffer_to_handle(&vertex_buffer
),
522 anv_buffer_to_handle(&vertex_buffer
)
526 sizeof(struct anv_vue_header
),
530 ANV_CALL(CreateSampler
)(anv_device_to_handle(device
),
531 &(VkSamplerCreateInfo
) {
532 .sType
= VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
,
533 .magFilter
= blit_filter
,
534 .minFilter
= blit_filter
,
538 anv_AllocDescriptorSets(anv_device_to_handle(device
), dummy_desc_pool
,
539 VK_DESCRIPTOR_SET_USAGE_ONE_SHOT
,
540 1, &device
->meta_state
.blit
.ds_layout
, &set
);
541 anv_UpdateDescriptorSets(anv_device_to_handle(device
),
543 (VkWriteDescriptorSet
[]) {
545 .sType
= VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
,
548 .destArrayElement
= 0,
550 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
551 .pDescriptors
= (VkDescriptorInfo
[]) {
553 .imageView
= anv_image_view_to_handle(src_iview
),
554 .imageLayout
= VK_IMAGE_LAYOUT_GENERAL
,
562 anv_CreateFramebuffer(anv_device_to_handle(device
),
563 &(VkFramebufferCreateInfo
) {
564 .sType
= VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
,
565 .attachmentCount
= 1,
566 .pAttachments
= (VkImageView
[]) {
567 anv_image_view_to_handle(dest_iview
),
569 .width
= dest_iview
->extent
.width
,
570 .height
= dest_iview
->extent
.height
,
574 ANV_CALL(CmdBeginRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
),
575 &(VkRenderPassBeginInfo
) {
576 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
,
577 .renderPass
= device
->meta_state
.blit
.render_pass
,
580 .offset
= { dest_offset
.x
, dest_offset
.y
},
581 .extent
= { dest_extent
.width
, dest_extent
.height
},
583 .clearValueCount
= 0,
584 .pClearValues
= NULL
,
585 }, VK_RENDER_PASS_CONTENTS_INLINE
);
589 switch (src_image
->type
) {
590 case VK_IMAGE_TYPE_1D
:
591 anv_finishme("VK_IMAGE_TYPE_1D");
592 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
594 case VK_IMAGE_TYPE_2D
:
595 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
597 case VK_IMAGE_TYPE_3D
:
598 pipeline
= device
->meta_state
.blit
.pipeline_3d_src
;
601 unreachable(!"bad VkImageType");
604 if (cmd_buffer
->state
.pipeline
!= anv_pipeline_from_handle(pipeline
)) {
605 anv_CmdBindPipeline(anv_cmd_buffer_to_handle(cmd_buffer
),
606 VK_PIPELINE_BIND_POINT_GRAPHICS
, pipeline
);
609 anv_CmdSetViewport(anv_cmd_buffer_to_handle(cmd_buffer
), 1,
613 .width
= dest_iview
->extent
.width
,
614 .height
= dest_iview
->extent
.height
,
619 anv_CmdBindDescriptorSets(anv_cmd_buffer_to_handle(cmd_buffer
),
620 VK_PIPELINE_BIND_POINT_GRAPHICS
,
621 device
->meta_state
.blit
.pipeline_layout
, 0, 1,
624 ANV_CALL(CmdDraw
)(anv_cmd_buffer_to_handle(cmd_buffer
), 3, 1, 0, 0);
626 ANV_CALL(CmdEndRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
));
628 /* At the point where we emit the draw call, all data from the
629 * descriptor sets, etc. has been used. We are free to delete it.
631 anv_descriptor_set_destroy(device
, anv_descriptor_set_from_handle(set
));
632 anv_DestroySampler(anv_device_to_handle(device
), sampler
);
633 anv_DestroyFramebuffer(anv_device_to_handle(device
), fb
);
637 meta_finish_blit(struct anv_cmd_buffer
*cmd_buffer
,
638 const struct anv_meta_saved_state
*saved_state
)
640 anv_meta_restore(saved_state
, cmd_buffer
);
644 vk_format_for_size(int bs
)
647 case 1: return VK_FORMAT_R8_UINT
;
648 case 2: return VK_FORMAT_R8G8_UINT
;
649 case 3: return VK_FORMAT_R8G8B8_UINT
;
650 case 4: return VK_FORMAT_R8G8B8A8_UINT
;
651 case 6: return VK_FORMAT_R16G16B16_UINT
;
652 case 8: return VK_FORMAT_R16G16B16A16_UINT
;
653 case 12: return VK_FORMAT_R32G32B32_UINT
;
654 case 16: return VK_FORMAT_R32G32B32A32_UINT
;
656 unreachable("Invalid format block size");
661 do_buffer_copy(struct anv_cmd_buffer
*cmd_buffer
,
662 struct anv_bo
*src
, uint64_t src_offset
,
663 struct anv_bo
*dest
, uint64_t dest_offset
,
664 int width
, int height
, VkFormat copy_format
)
666 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
668 VkImageCreateInfo image_info
= {
669 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
670 .imageType
= VK_IMAGE_TYPE_2D
,
671 .format
= copy_format
,
680 .tiling
= VK_IMAGE_TILING_LINEAR
,
686 image_info
.usage
= VK_IMAGE_USAGE_SAMPLED_BIT
;
687 anv_CreateImage(vk_device
, &image_info
, &src_image
);
690 image_info
.usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
;
691 anv_CreateImage(vk_device
, &image_info
, &dest_image
);
693 /* We could use a vk call to bind memory, but that would require
694 * creating a dummy memory object etc. so there's really no point.
696 anv_image_from_handle(src_image
)->bo
= src
;
697 anv_image_from_handle(src_image
)->offset
= src_offset
;
698 anv_image_from_handle(dest_image
)->bo
= dest
;
699 anv_image_from_handle(dest_image
)->offset
= dest_offset
;
701 struct anv_image_view src_iview
;
702 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
703 &(VkImageViewCreateInfo
) {
704 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
706 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
707 .format
= copy_format
,
709 VK_CHANNEL_SWIZZLE_R
,
710 VK_CHANNEL_SWIZZLE_G
,
711 VK_CHANNEL_SWIZZLE_B
,
714 .subresourceRange
= {
715 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
724 struct anv_image_view dest_iview
;
725 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
726 &(VkImageViewCreateInfo
) {
727 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
729 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
730 .format
= copy_format
,
732 .r
= VK_CHANNEL_SWIZZLE_R
,
733 .g
= VK_CHANNEL_SWIZZLE_G
,
734 .b
= VK_CHANNEL_SWIZZLE_B
,
735 .a
= VK_CHANNEL_SWIZZLE_A
,
737 .subresourceRange
= {
738 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
747 meta_emit_blit(cmd_buffer
,
748 anv_image_from_handle(src_image
),
750 (VkOffset3D
) { 0, 0, 0 },
751 (VkExtent3D
) { width
, height
, 1 },
752 anv_image_from_handle(dest_image
),
754 (VkOffset3D
) { 0, 0, 0 },
755 (VkExtent3D
) { width
, height
, 1 },
756 VK_TEX_FILTER_NEAREST
);
758 anv_DestroyImage(vk_device
, src_image
);
759 anv_DestroyImage(vk_device
, dest_image
);
762 void anv_CmdCopyBuffer(
763 VkCmdBuffer cmdBuffer
,
766 uint32_t regionCount
,
767 const VkBufferCopy
* pRegions
)
769 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, cmdBuffer
);
770 ANV_FROM_HANDLE(anv_buffer
, src_buffer
, srcBuffer
);
771 ANV_FROM_HANDLE(anv_buffer
, dest_buffer
, destBuffer
);
773 struct anv_meta_saved_state saved_state
;
775 meta_prepare_blit(cmd_buffer
, &saved_state
);
777 for (unsigned r
= 0; r
< regionCount
; r
++) {
778 uint64_t src_offset
= src_buffer
->offset
+ pRegions
[r
].srcOffset
;
779 uint64_t dest_offset
= dest_buffer
->offset
+ pRegions
[r
].destOffset
;
780 uint64_t copy_size
= pRegions
[r
].copySize
;
782 /* First, we compute the biggest format that can be used with the
783 * given offsets and size.
787 int fs
= ffs(src_offset
) - 1;
789 bs
= MIN2(bs
, 1 << fs
);
790 assert(src_offset
% bs
== 0);
792 fs
= ffs(dest_offset
) - 1;
794 bs
= MIN2(bs
, 1 << fs
);
795 assert(dest_offset
% bs
== 0);
797 fs
= ffs(pRegions
[r
].copySize
) - 1;
799 bs
= MIN2(bs
, 1 << fs
);
800 assert(pRegions
[r
].copySize
% bs
== 0);
802 VkFormat copy_format
= vk_format_for_size(bs
);
804 /* This is maximum possible width/height our HW can handle */
805 uint64_t max_surface_dim
= 1 << 14;
807 /* First, we make a bunch of max-sized copies */
808 uint64_t max_copy_size
= max_surface_dim
* max_surface_dim
* bs
;
809 while (copy_size
> max_copy_size
) {
810 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
811 dest_buffer
->bo
, dest_offset
,
812 max_surface_dim
, max_surface_dim
, copy_format
);
813 copy_size
-= max_copy_size
;
814 src_offset
+= max_copy_size
;
815 dest_offset
+= max_copy_size
;
818 uint64_t height
= copy_size
/ (max_surface_dim
* bs
);
819 assert(height
< max_surface_dim
);
821 uint64_t rect_copy_size
= height
* max_surface_dim
* bs
;
822 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
823 dest_buffer
->bo
, dest_offset
,
824 max_surface_dim
, height
, copy_format
);
825 copy_size
-= rect_copy_size
;
826 src_offset
+= rect_copy_size
;
827 dest_offset
+= rect_copy_size
;
830 if (copy_size
!= 0) {
831 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
832 dest_buffer
->bo
, dest_offset
,
833 copy_size
/ bs
, 1, copy_format
);
837 meta_finish_blit(cmd_buffer
, &saved_state
);
840 void anv_CmdCopyImage(
841 VkCmdBuffer cmdBuffer
,
843 VkImageLayout srcImageLayout
,
845 VkImageLayout destImageLayout
,
846 uint32_t regionCount
,
847 const VkImageCopy
* pRegions
)
849 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, cmdBuffer
);
850 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
851 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
853 const VkImageViewType src_iview_type
=
854 meta_blit_get_src_image_view_type(src_image
);
856 struct anv_meta_saved_state saved_state
;
858 meta_prepare_blit(cmd_buffer
, &saved_state
);
860 for (unsigned r
= 0; r
< regionCount
; r
++) {
861 struct anv_image_view src_iview
;
862 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
863 &(VkImageViewCreateInfo
) {
864 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
866 .viewType
= src_iview_type
,
867 .format
= src_image
->format
->vk_format
,
869 VK_CHANNEL_SWIZZLE_R
,
870 VK_CHANNEL_SWIZZLE_G
,
871 VK_CHANNEL_SWIZZLE_B
,
874 .subresourceRange
= {
875 .aspectMask
= 1 << pRegions
[r
].srcSubresource
.aspect
,
876 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
878 .baseArrayLayer
= pRegions
[r
].srcSubresource
.arrayLayer
,
884 const VkOffset3D dest_offset
= {
885 .x
= pRegions
[r
].destOffset
.x
,
886 .y
= pRegions
[r
].destOffset
.y
,
890 const uint32_t dest_array_slice
=
891 meta_blit_get_dest_view_base_array_slice(dest_image
,
892 &pRegions
[r
].destSubresource
,
893 &pRegions
[r
].destOffset
);
895 if (pRegions
[r
].srcSubresource
.arraySize
> 1)
896 anv_finishme("FINISHME: copy multiple array layers");
898 if (pRegions
[r
].extent
.depth
> 1)
899 anv_finishme("FINISHME: copy multiple depth layers");
901 struct anv_image_view dest_iview
;
902 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
903 &(VkImageViewCreateInfo
) {
904 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
906 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
907 .format
= dest_image
->format
->vk_format
,
909 VK_CHANNEL_SWIZZLE_R
,
910 VK_CHANNEL_SWIZZLE_G
,
911 VK_CHANNEL_SWIZZLE_B
,
914 .subresourceRange
= {
915 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
916 .baseMipLevel
= pRegions
[r
].destSubresource
.mipLevel
,
918 .baseArrayLayer
= dest_array_slice
,
924 meta_emit_blit(cmd_buffer
,
925 src_image
, &src_iview
,
926 pRegions
[r
].srcOffset
,
928 dest_image
, &dest_iview
,
931 VK_TEX_FILTER_NEAREST
);
934 meta_finish_blit(cmd_buffer
, &saved_state
);
937 void anv_CmdBlitImage(
938 VkCmdBuffer cmdBuffer
,
940 VkImageLayout srcImageLayout
,
942 VkImageLayout destImageLayout
,
943 uint32_t regionCount
,
944 const VkImageBlit
* pRegions
,
948 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, cmdBuffer
);
949 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
950 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
952 const VkImageViewType src_iview_type
=
953 meta_blit_get_src_image_view_type(src_image
);
955 struct anv_meta_saved_state saved_state
;
957 anv_finishme("respect VkTexFilter");
959 meta_prepare_blit(cmd_buffer
, &saved_state
);
961 for (unsigned r
= 0; r
< regionCount
; r
++) {
962 struct anv_image_view src_iview
;
963 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
964 &(VkImageViewCreateInfo
) {
965 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
967 .viewType
= src_iview_type
,
968 .format
= src_image
->format
->vk_format
,
970 VK_CHANNEL_SWIZZLE_R
,
971 VK_CHANNEL_SWIZZLE_G
,
972 VK_CHANNEL_SWIZZLE_B
,
975 .subresourceRange
= {
976 .aspectMask
= 1 << pRegions
[r
].srcSubresource
.aspect
,
977 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
979 .baseArrayLayer
= pRegions
[r
].srcSubresource
.arrayLayer
,
985 const VkOffset3D dest_offset
= {
986 .x
= pRegions
[r
].destOffset
.x
,
987 .y
= pRegions
[r
].destOffset
.y
,
991 const uint32_t dest_array_slice
=
992 meta_blit_get_dest_view_base_array_slice(dest_image
,
993 &pRegions
[r
].destSubresource
,
994 &pRegions
[r
].destOffset
);
996 if (pRegions
[r
].srcSubresource
.arraySize
> 1)
997 anv_finishme("FINISHME: copy multiple array layers");
999 if (pRegions
[r
].destExtent
.depth
> 1)
1000 anv_finishme("FINISHME: copy multiple depth layers");
1002 struct anv_image_view dest_iview
;
1003 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1004 &(VkImageViewCreateInfo
) {
1005 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1007 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1008 .format
= dest_image
->format
->vk_format
,
1010 VK_CHANNEL_SWIZZLE_R
,
1011 VK_CHANNEL_SWIZZLE_G
,
1012 VK_CHANNEL_SWIZZLE_B
,
1013 VK_CHANNEL_SWIZZLE_A
1015 .subresourceRange
= {
1016 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1017 .baseMipLevel
= pRegions
[r
].destSubresource
.mipLevel
,
1019 .baseArrayLayer
= dest_array_slice
,
1025 meta_emit_blit(cmd_buffer
,
1026 src_image
, &src_iview
,
1027 pRegions
[r
].srcOffset
,
1028 pRegions
[r
].srcExtent
,
1029 dest_image
, &dest_iview
,
1031 pRegions
[r
].destExtent
,
1035 meta_finish_blit(cmd_buffer
, &saved_state
);
1039 make_image_for_buffer(VkDevice vk_device
, VkBuffer vk_buffer
, VkFormat format
,
1040 VkImageUsageFlags usage
,
1041 const VkBufferImageCopy
*copy
)
1043 ANV_FROM_HANDLE(anv_buffer
, buffer
, vk_buffer
);
1045 VkExtent3D extent
= copy
->imageExtent
;
1046 if (copy
->bufferRowLength
)
1047 extent
.width
= copy
->bufferRowLength
;
1048 if (copy
->bufferImageHeight
)
1049 extent
.height
= copy
->bufferImageHeight
;
1053 VkResult result
= anv_CreateImage(vk_device
,
1054 &(VkImageCreateInfo
) {
1055 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
1056 .imageType
= VK_IMAGE_TYPE_2D
,
1062 .tiling
= VK_IMAGE_TILING_LINEAR
,
1066 assert(result
== VK_SUCCESS
);
1068 ANV_FROM_HANDLE(anv_image
, image
, vk_image
);
1070 /* We could use a vk call to bind memory, but that would require
1071 * creating a dummy memory object etc. so there's really no point.
1073 image
->bo
= buffer
->bo
;
1074 image
->offset
= buffer
->offset
+ copy
->bufferOffset
;
1076 return anv_image_to_handle(image
);
1079 void anv_CmdCopyBufferToImage(
1080 VkCmdBuffer cmdBuffer
,
1083 VkImageLayout destImageLayout
,
1084 uint32_t regionCount
,
1085 const VkBufferImageCopy
* pRegions
)
1087 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, cmdBuffer
);
1088 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
1089 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1090 const VkFormat orig_format
= dest_image
->format
->vk_format
;
1091 struct anv_meta_saved_state saved_state
;
1093 meta_prepare_blit(cmd_buffer
, &saved_state
);
1095 for (unsigned r
= 0; r
< regionCount
; r
++) {
1096 VkFormat proxy_format
= orig_format
;
1097 VkImageAspect proxy_aspect
= pRegions
[r
].imageSubresource
.aspect
;
1099 if (orig_format
== VK_FORMAT_S8_UINT
) {
1100 proxy_format
= VK_FORMAT_R8_UINT
;
1101 proxy_aspect
= VK_IMAGE_ASPECT_COLOR
;
1104 VkImage srcImage
= make_image_for_buffer(vk_device
, srcBuffer
,
1105 proxy_format
, VK_IMAGE_USAGE_SAMPLED_BIT
, &pRegions
[r
]);
1107 struct anv_image_view src_iview
;
1108 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1109 &(VkImageViewCreateInfo
) {
1110 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1112 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1113 .format
= proxy_format
,
1115 VK_CHANNEL_SWIZZLE_R
,
1116 VK_CHANNEL_SWIZZLE_G
,
1117 VK_CHANNEL_SWIZZLE_B
,
1118 VK_CHANNEL_SWIZZLE_A
1120 .subresourceRange
= {
1121 .aspectMask
= 1 << proxy_aspect
,
1124 .baseArrayLayer
= 0,
1130 const VkOffset3D dest_offset
= {
1131 .x
= pRegions
[r
].imageOffset
.x
,
1132 .y
= pRegions
[r
].imageOffset
.y
,
1136 const uint32_t dest_array_slice
=
1137 meta_blit_get_dest_view_base_array_slice(dest_image
,
1138 &pRegions
[r
].imageSubresource
,
1139 &pRegions
[r
].imageOffset
);
1141 if (pRegions
[r
].imageExtent
.depth
> 1)
1142 anv_finishme("FINISHME: copy multiple depth layers");
1144 struct anv_image_view dest_iview
;
1145 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1146 &(VkImageViewCreateInfo
) {
1147 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1148 .image
= anv_image_to_handle(dest_image
),
1149 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1150 .format
= proxy_format
,
1152 VK_CHANNEL_SWIZZLE_R
,
1153 VK_CHANNEL_SWIZZLE_G
,
1154 VK_CHANNEL_SWIZZLE_B
,
1155 VK_CHANNEL_SWIZZLE_A
1157 .subresourceRange
= {
1158 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1159 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1161 .baseArrayLayer
= dest_array_slice
,
1167 meta_emit_blit(cmd_buffer
,
1168 anv_image_from_handle(srcImage
),
1170 (VkOffset3D
) { 0, 0, 0 },
1171 pRegions
[r
].imageExtent
,
1175 pRegions
[r
].imageExtent
,
1176 VK_TEX_FILTER_NEAREST
);
1178 anv_DestroyImage(vk_device
, srcImage
);
1181 meta_finish_blit(cmd_buffer
, &saved_state
);
1184 void anv_CmdCopyImageToBuffer(
1185 VkCmdBuffer cmdBuffer
,
1187 VkImageLayout srcImageLayout
,
1188 VkBuffer destBuffer
,
1189 uint32_t regionCount
,
1190 const VkBufferImageCopy
* pRegions
)
1192 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, cmdBuffer
);
1193 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
1194 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1195 struct anv_meta_saved_state saved_state
;
1197 const VkImageViewType src_iview_type
=
1198 meta_blit_get_src_image_view_type(src_image
);
1200 meta_prepare_blit(cmd_buffer
, &saved_state
);
1202 for (unsigned r
= 0; r
< regionCount
; r
++) {
1203 if (pRegions
[r
].imageSubresource
.arraySize
> 1)
1204 anv_finishme("FINISHME: copy multiple array layers");
1206 if (pRegions
[r
].imageExtent
.depth
> 1)
1207 anv_finishme("FINISHME: copy multiple depth layers");
1209 struct anv_image_view src_iview
;
1210 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1211 &(VkImageViewCreateInfo
) {
1212 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1214 .viewType
= src_iview_type
,
1215 .format
= src_image
->format
->vk_format
,
1217 VK_CHANNEL_SWIZZLE_R
,
1218 VK_CHANNEL_SWIZZLE_G
,
1219 VK_CHANNEL_SWIZZLE_B
,
1220 VK_CHANNEL_SWIZZLE_A
1222 .subresourceRange
= {
1223 .aspectMask
= 1 << pRegions
[r
].imageSubresource
.aspect
,
1224 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1226 .baseArrayLayer
= pRegions
[r
].imageSubresource
.arrayLayer
,
1232 VkFormat dest_format
= src_image
->format
->vk_format
;
1233 if (dest_format
== VK_FORMAT_S8_UINT
) {
1234 dest_format
= VK_FORMAT_R8_UINT
;
1237 VkImage destImage
= make_image_for_buffer(vk_device
, destBuffer
,
1238 dest_format
, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
, &pRegions
[r
]);
1240 struct anv_image_view dest_iview
;
1241 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1242 &(VkImageViewCreateInfo
) {
1243 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1245 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1246 .format
= dest_format
,
1248 VK_CHANNEL_SWIZZLE_R
,
1249 VK_CHANNEL_SWIZZLE_G
,
1250 VK_CHANNEL_SWIZZLE_B
,
1251 VK_CHANNEL_SWIZZLE_A
1253 .subresourceRange
= {
1254 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1257 .baseArrayLayer
= 0,
1263 meta_emit_blit(cmd_buffer
,
1264 anv_image_from_handle(srcImage
),
1266 pRegions
[r
].imageOffset
,
1267 pRegions
[r
].imageExtent
,
1268 anv_image_from_handle(destImage
),
1270 (VkOffset3D
) { 0, 0, 0 },
1271 pRegions
[r
].imageExtent
,
1272 VK_TEX_FILTER_NEAREST
);
1274 anv_DestroyImage(vk_device
, destImage
);
1277 meta_finish_blit(cmd_buffer
, &saved_state
);
1280 void anv_CmdUpdateBuffer(
1281 VkCmdBuffer cmdBuffer
,
1282 VkBuffer destBuffer
,
1283 VkDeviceSize destOffset
,
1284 VkDeviceSize dataSize
,
1285 const uint32_t* pData
)
1290 void anv_CmdFillBuffer(
1291 VkCmdBuffer cmdBuffer
,
1292 VkBuffer destBuffer
,
1293 VkDeviceSize destOffset
,
1294 VkDeviceSize fillSize
,
1300 void anv_CmdResolveImage(
1301 VkCmdBuffer cmdBuffer
,
1303 VkImageLayout srcImageLayout
,
1305 VkImageLayout destImageLayout
,
1306 uint32_t regionCount
,
1307 const VkImageResolve
* pRegions
)
1313 anv_device_init_meta(struct anv_device
*device
)
1315 anv_device_init_meta_clear_state(device
);
1316 anv_device_init_meta_blit_state(device
);
1320 anv_device_finish_meta(struct anv_device
*device
)
1322 anv_device_finish_meta_clear_state(device
);
1325 anv_DestroyRenderPass(anv_device_to_handle(device
),
1326 device
->meta_state
.blit
.render_pass
);
1327 anv_DestroyPipeline(anv_device_to_handle(device
),
1328 device
->meta_state
.blit
.pipeline_2d_src
);
1329 anv_DestroyPipeline(anv_device_to_handle(device
),
1330 device
->meta_state
.blit
.pipeline_3d_src
);
1331 anv_DestroyPipelineLayout(anv_device_to_handle(device
),
1332 device
->meta_state
.blit
.pipeline_layout
);
1333 anv_DestroyDescriptorSetLayout(anv_device_to_handle(device
),
1334 device
->meta_state
.blit
.ds_layout
);