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 */
98 if (tex_dim
== GLSL_SAMPLER_DIM_2D
)
100 tex
->coord_components
= 3;
102 tex
->sampler
= nir_deref_var_create(tex
, sampler
);
104 nir_ssa_dest_init(&tex
->instr
, &tex
->dest
, 4, "tex");
105 nir_builder_instr_insert(&b
, &tex
->instr
);
107 nir_variable
*color_out
= nir_variable_create(b
.shader
, nir_var_shader_out
,
108 color_type
, "f_color");
109 color_out
->data
.location
= FRAG_RESULT_DATA0
;
110 nir_store_var(&b
, color_out
, &tex
->dest
.ssa
);
116 anv_meta_save(struct anv_meta_saved_state
*state
,
117 const struct anv_cmd_buffer
*cmd_buffer
,
118 uint32_t dynamic_mask
)
120 state
->old_pipeline
= cmd_buffer
->state
.pipeline
;
121 state
->old_descriptor_set0
= cmd_buffer
->state
.descriptors
[0];
122 memcpy(state
->old_vertex_bindings
, cmd_buffer
->state
.vertex_bindings
,
123 sizeof(state
->old_vertex_bindings
));
125 state
->dynamic_mask
= dynamic_mask
;
126 anv_dynamic_state_copy(&state
->dynamic
, &cmd_buffer
->state
.dynamic
,
131 anv_meta_restore(const struct anv_meta_saved_state
*state
,
132 struct anv_cmd_buffer
*cmd_buffer
)
134 cmd_buffer
->state
.pipeline
= state
->old_pipeline
;
135 cmd_buffer
->state
.descriptors
[0] = state
->old_descriptor_set0
;
136 memcpy(cmd_buffer
->state
.vertex_bindings
, state
->old_vertex_bindings
,
137 sizeof(state
->old_vertex_bindings
));
139 cmd_buffer
->state
.vb_dirty
|= (1 << ANV_META_VERTEX_BINDING_COUNT
) - 1;
140 cmd_buffer
->state
.dirty
|= ANV_CMD_DIRTY_PIPELINE
;
141 cmd_buffer
->state
.descriptors_dirty
|= VK_SHADER_STAGE_VERTEX_BIT
;
143 anv_dynamic_state_copy(&cmd_buffer
->state
.dynamic
, &state
->dynamic
,
144 state
->dynamic_mask
);
145 cmd_buffer
->state
.dirty
|= state
->dynamic_mask
;
148 static VkImageViewType
149 meta_blit_get_src_image_view_type(const struct anv_image
*src_image
)
151 switch (src_image
->type
) {
152 case VK_IMAGE_TYPE_1D
:
153 return VK_IMAGE_VIEW_TYPE_1D
;
154 case VK_IMAGE_TYPE_2D
:
155 return VK_IMAGE_VIEW_TYPE_2D
;
156 case VK_IMAGE_TYPE_3D
:
157 return VK_IMAGE_VIEW_TYPE_3D
;
159 assert(!"bad VkImageType");
165 meta_blit_get_dest_view_base_array_slice(const struct anv_image
*dest_image
,
166 const VkImageSubresourceLayers
*dest_subresource
,
167 const VkOffset3D
*dest_offset
)
169 switch (dest_image
->type
) {
170 case VK_IMAGE_TYPE_1D
:
171 case VK_IMAGE_TYPE_2D
:
172 return dest_subresource
->baseArrayLayer
;
173 case VK_IMAGE_TYPE_3D
:
174 /* HACK: Vulkan does not allow attaching a 3D image to a framebuffer,
175 * but meta does it anyway. When doing so, we translate the
176 * destination's z offset into an array offset.
178 return dest_offset
->z
;
180 assert(!"bad VkImageType");
186 anv_device_init_meta_blit_state(struct anv_device
*device
)
188 anv_CreateRenderPass(anv_device_to_handle(device
),
189 &(VkRenderPassCreateInfo
) {
190 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO
,
191 .attachmentCount
= 1,
192 .pAttachments
= &(VkAttachmentDescription
) {
193 .format
= VK_FORMAT_UNDEFINED
, /* Our shaders don't care */
194 .loadOp
= VK_ATTACHMENT_LOAD_OP_LOAD
,
195 .storeOp
= VK_ATTACHMENT_STORE_OP_STORE
,
196 .initialLayout
= VK_IMAGE_LAYOUT_GENERAL
,
197 .finalLayout
= VK_IMAGE_LAYOUT_GENERAL
,
200 .pSubpasses
= &(VkSubpassDescription
) {
201 .pipelineBindPoint
= VK_PIPELINE_BIND_POINT_GRAPHICS
,
202 .inputAttachmentCount
= 0,
203 .colorAttachmentCount
= 1,
204 .pColorAttachments
= &(VkAttachmentReference
) {
206 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
208 .pResolveAttachments
= NULL
,
209 .pDepthStencilAttachment
= &(VkAttachmentReference
) {
210 .attachment
= VK_ATTACHMENT_UNUSED
,
211 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
213 .preserveAttachmentCount
= 1,
214 .pPreserveAttachments
= &(VkAttachmentReference
) {
216 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
219 .dependencyCount
= 0,
220 }, &device
->meta_state
.blit
.render_pass
);
222 /* We don't use a vertex shader for clearing, but instead build and pass
223 * the VUEs directly to the rasterization backend. However, we do need
224 * to provide GLSL source for the vertex shader so that the compiler
225 * does not dead-code our inputs.
227 struct anv_shader_module vsm
= {
228 .nir
= build_nir_vertex_shader(false),
231 struct anv_shader_module fsm_2d
= {
232 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D
),
235 struct anv_shader_module fsm_3d
= {
236 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_3D
),
240 anv_CreateShader(anv_device_to_handle(device
),
241 &(VkShaderCreateInfo
) {
242 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
243 .module
= anv_shader_module_to_handle(&vsm
),
248 anv_CreateShader(anv_device_to_handle(device
),
249 &(VkShaderCreateInfo
) {
250 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
251 .module
= anv_shader_module_to_handle(&fsm_2d
),
256 anv_CreateShader(anv_device_to_handle(device
),
257 &(VkShaderCreateInfo
) {
258 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
259 .module
= anv_shader_module_to_handle(&fsm_3d
),
263 VkPipelineVertexInputStateCreateInfo vi_create_info
= {
264 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
,
265 .vertexBindingDescriptionCount
= 2,
266 .pVertexBindingDescriptions
= (VkVertexInputBindingDescription
[]) {
270 .inputRate
= VK_VERTEX_INPUT_RATE_VERTEX
274 .stride
= 5 * sizeof(float),
275 .inputRate
= VK_VERTEX_INPUT_RATE_VERTEX
278 .vertexAttributeDescriptionCount
= 3,
279 .pVertexAttributeDescriptions
= (VkVertexInputAttributeDescription
[]) {
284 .format
= VK_FORMAT_R32G32B32A32_UINT
,
291 .format
= VK_FORMAT_R32G32_SFLOAT
,
295 /* Texture Coordinate */
298 .format
= VK_FORMAT_R32G32B32_SFLOAT
,
304 VkDescriptorSetLayoutCreateInfo ds_layout_info
= {
305 .sType
= VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
,
307 .pBinding
= (VkDescriptorSetLayoutBinding
[]) {
310 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
311 .descriptorCount
= 1,
312 .stageFlags
= VK_SHADER_STAGE_FRAGMENT_BIT
,
313 .pImmutableSamplers
= NULL
317 anv_CreateDescriptorSetLayout(anv_device_to_handle(device
), &ds_layout_info
,
318 &device
->meta_state
.blit
.ds_layout
);
320 anv_CreatePipelineLayout(anv_device_to_handle(device
),
321 &(VkPipelineLayoutCreateInfo
) {
322 .sType
= VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
,
324 .pSetLayouts
= &device
->meta_state
.blit
.ds_layout
,
326 &device
->meta_state
.blit
.pipeline_layout
);
328 VkPipelineShaderStageCreateInfo pipeline_shader_stages
[] = {
330 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
331 .stage
= VK_SHADER_STAGE_VERTEX
,
333 .pSpecializationInfo
= NULL
335 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
336 .stage
= VK_SHADER_STAGE_FRAGMENT
,
337 .shader
= VK_NULL_HANDLE
, /* TEMPLATE VALUE! FILL ME IN! */
338 .pSpecializationInfo
= NULL
342 const VkGraphicsPipelineCreateInfo vk_pipeline_info
= {
343 .sType
= VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
,
344 .stageCount
= ARRAY_SIZE(pipeline_shader_stages
),
345 .pStages
= pipeline_shader_stages
,
346 .pVertexInputState
= &vi_create_info
,
347 .pInputAssemblyState
= &(VkPipelineInputAssemblyStateCreateInfo
) {
348 .sType
= VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
,
349 .topology
= VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
,
350 .primitiveRestartEnable
= false,
352 .pViewportState
= &(VkPipelineViewportStateCreateInfo
) {
353 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
,
357 .pRasterizationState
= &(VkPipelineRasterizationStateCreateInfo
) {
358 .sType
= VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
,
359 .depthClipEnable
= true,
360 .rasterizerDiscardEnable
= false,
361 .polygonMode
= VK_POLYGON_MODE_FILL
,
362 .cullMode
= VK_CULL_MODE_NONE
,
363 .frontFace
= VK_FRONT_FACE_COUNTER_CLOCKWISE
365 .pMultisampleState
= &(VkPipelineMultisampleStateCreateInfo
) {
366 .sType
= VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
,
367 .rasterizationSamples
= 1,
368 .sampleShadingEnable
= false,
369 .pSampleMask
= (VkSampleMask
[]) { UINT32_MAX
},
371 .pColorBlendState
= &(VkPipelineColorBlendStateCreateInfo
) {
372 .sType
= VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
,
373 .attachmentCount
= 1,
374 .pAttachments
= (VkPipelineColorBlendAttachmentState
[]) {
376 VK_COLOR_COMPONENT_A_BIT
|
377 VK_COLOR_COMPONENT_R_BIT
|
378 VK_COLOR_COMPONENT_G_BIT
|
379 VK_COLOR_COMPONENT_B_BIT
},
382 .pDynamicState
= &(VkPipelineDynamicStateCreateInfo
) {
383 .sType
= VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
,
384 .dynamicStateCount
= 9,
385 .pDynamicStates
= (VkDynamicState
[]) {
386 VK_DYNAMIC_STATE_VIEWPORT
,
387 VK_DYNAMIC_STATE_SCISSOR
,
388 VK_DYNAMIC_STATE_LINE_WIDTH
,
389 VK_DYNAMIC_STATE_DEPTH_BIAS
,
390 VK_DYNAMIC_STATE_BLEND_CONSTANTS
,
391 VK_DYNAMIC_STATE_DEPTH_BOUNDS
,
392 VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK
,
393 VK_DYNAMIC_STATE_STENCIL_WRITE_MASK
,
394 VK_DYNAMIC_STATE_STENCIL_REFERENCE
,
398 .layout
= device
->meta_state
.blit
.pipeline_layout
,
399 .renderPass
= device
->meta_state
.blit
.render_pass
,
403 const struct anv_graphics_pipeline_create_info anv_pipeline_info
= {
404 .use_repclear
= false,
405 .disable_viewport
= true,
406 .disable_scissor
= true,
411 pipeline_shader_stages
[1].shader
= fs_2d
;
412 anv_graphics_pipeline_create(anv_device_to_handle(device
),
413 &vk_pipeline_info
, &anv_pipeline_info
,
414 &device
->meta_state
.blit
.pipeline_2d_src
);
416 pipeline_shader_stages
[1].shader
= fs_3d
;
417 anv_graphics_pipeline_create(anv_device_to_handle(device
),
418 &vk_pipeline_info
, &anv_pipeline_info
,
419 &device
->meta_state
.blit
.pipeline_3d_src
);
421 anv_DestroyShader(anv_device_to_handle(device
), vs
);
422 anv_DestroyShader(anv_device_to_handle(device
), fs_2d
);
423 anv_DestroyShader(anv_device_to_handle(device
), fs_3d
);
424 ralloc_free(vsm
.nir
);
425 ralloc_free(fsm_2d
.nir
);
426 ralloc_free(fsm_3d
.nir
);
430 meta_prepare_blit(struct anv_cmd_buffer
*cmd_buffer
,
431 struct anv_meta_saved_state
*saved_state
)
433 anv_meta_save(saved_state
, cmd_buffer
,
434 (1 << VK_DYNAMIC_STATE_VIEWPORT
));
438 VkOffset3D src_offset
;
439 VkExtent3D src_extent
;
440 VkOffset3D dest_offset
;
441 VkExtent3D dest_extent
;
445 meta_emit_blit(struct anv_cmd_buffer
*cmd_buffer
,
446 struct anv_image
*src_image
,
447 struct anv_image_view
*src_iview
,
448 VkOffset3D src_offset
,
449 VkExtent3D src_extent
,
450 struct anv_image
*dest_image
,
451 struct anv_image_view
*dest_iview
,
452 VkOffset3D dest_offset
,
453 VkExtent3D dest_extent
,
454 VkFilter blit_filter
)
456 struct anv_device
*device
= cmd_buffer
->device
;
457 VkDescriptorPool dummy_desc_pool
= (VkDescriptorPool
)1;
459 struct blit_vb_data
{
464 unsigned vb_size
= sizeof(struct anv_vue_header
) + 3 * sizeof(*vb_data
);
466 struct anv_state vb_state
=
467 anv_cmd_buffer_alloc_dynamic_state(cmd_buffer
, vb_size
, 16);
468 memset(vb_state
.map
, 0, sizeof(struct anv_vue_header
));
469 vb_data
= vb_state
.map
+ sizeof(struct anv_vue_header
);
471 vb_data
[0] = (struct blit_vb_data
) {
473 dest_offset
.x
+ dest_extent
.width
,
474 dest_offset
.y
+ dest_extent
.height
,
477 (float)(src_offset
.x
+ src_extent
.width
) / (float)src_iview
->extent
.width
,
478 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
479 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
483 vb_data
[1] = (struct blit_vb_data
) {
486 dest_offset
.y
+ dest_extent
.height
,
489 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
490 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
491 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
495 vb_data
[2] = (struct blit_vb_data
) {
501 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
502 (float)src_offset
.y
/ (float)src_iview
->extent
.height
,
503 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
507 struct anv_buffer vertex_buffer
= {
510 .bo
= &device
->dynamic_state_block_pool
.bo
,
511 .offset
= vb_state
.offset
,
514 anv_CmdBindVertexBuffers(anv_cmd_buffer_to_handle(cmd_buffer
), 0, 2,
516 anv_buffer_to_handle(&vertex_buffer
),
517 anv_buffer_to_handle(&vertex_buffer
)
521 sizeof(struct anv_vue_header
),
525 ANV_CALL(CreateSampler
)(anv_device_to_handle(device
),
526 &(VkSamplerCreateInfo
) {
527 .sType
= VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
,
528 .magFilter
= blit_filter
,
529 .minFilter
= blit_filter
,
533 anv_AllocateDescriptorSets(anv_device_to_handle(device
),
534 &(VkDescriptorSetAllocateInfo
) {
535 .sType
= VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
,
536 .descriptorPool
= dummy_desc_pool
,
538 .pSetLayouts
= &device
->meta_state
.blit
.ds_layout
540 anv_UpdateDescriptorSets(anv_device_to_handle(device
),
542 (VkWriteDescriptorSet
[]) {
544 .sType
= VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
,
547 .dstArrayElement
= 0,
548 .descriptorCount
= 1,
549 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
550 .pImageInfo
= (VkDescriptorImageInfo
[]) {
553 .imageView
= anv_image_view_to_handle(src_iview
),
554 .imageLayout
= VK_IMAGE_LAYOUT_GENERAL
,
561 anv_CreateFramebuffer(anv_device_to_handle(device
),
562 &(VkFramebufferCreateInfo
) {
563 .sType
= VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
,
564 .attachmentCount
= 1,
565 .pAttachments
= (VkImageView
[]) {
566 anv_image_view_to_handle(dest_iview
),
568 .width
= dest_iview
->extent
.width
,
569 .height
= dest_iview
->extent
.height
,
573 ANV_CALL(CmdBeginRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
),
574 &(VkRenderPassBeginInfo
) {
575 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
,
576 .renderPass
= device
->meta_state
.blit
.render_pass
,
579 .offset
= { dest_offset
.x
, dest_offset
.y
},
580 .extent
= { dest_extent
.width
, dest_extent
.height
},
582 .clearValueCount
= 0,
583 .pClearValues
= NULL
,
584 }, VK_SUBPASS_CONTENTS_INLINE
);
588 switch (src_image
->type
) {
589 case VK_IMAGE_TYPE_1D
:
590 anv_finishme("VK_IMAGE_TYPE_1D");
591 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
593 case VK_IMAGE_TYPE_2D
:
594 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
596 case VK_IMAGE_TYPE_3D
:
597 pipeline
= device
->meta_state
.blit
.pipeline_3d_src
;
600 unreachable(!"bad VkImageType");
603 if (cmd_buffer
->state
.pipeline
!= anv_pipeline_from_handle(pipeline
)) {
604 anv_CmdBindPipeline(anv_cmd_buffer_to_handle(cmd_buffer
),
605 VK_PIPELINE_BIND_POINT_GRAPHICS
, pipeline
);
608 anv_CmdSetViewport(anv_cmd_buffer_to_handle(cmd_buffer
), 1,
612 .width
= dest_iview
->extent
.width
,
613 .height
= dest_iview
->extent
.height
,
618 anv_CmdBindDescriptorSets(anv_cmd_buffer_to_handle(cmd_buffer
),
619 VK_PIPELINE_BIND_POINT_GRAPHICS
,
620 device
->meta_state
.blit
.pipeline_layout
, 0, 1,
623 ANV_CALL(CmdDraw
)(anv_cmd_buffer_to_handle(cmd_buffer
), 3, 1, 0, 0);
625 ANV_CALL(CmdEndRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
));
627 /* At the point where we emit the draw call, all data from the
628 * descriptor sets, etc. has been used. We are free to delete it.
630 anv_descriptor_set_destroy(device
, anv_descriptor_set_from_handle(set
));
631 anv_DestroySampler(anv_device_to_handle(device
), sampler
);
632 anv_DestroyFramebuffer(anv_device_to_handle(device
), fb
);
636 meta_finish_blit(struct anv_cmd_buffer
*cmd_buffer
,
637 const struct anv_meta_saved_state
*saved_state
)
639 anv_meta_restore(saved_state
, cmd_buffer
);
643 vk_format_for_size(int bs
)
646 case 1: return VK_FORMAT_R8_UINT
;
647 case 2: return VK_FORMAT_R8G8_UINT
;
648 case 3: return VK_FORMAT_R8G8B8_UINT
;
649 case 4: return VK_FORMAT_R8G8B8A8_UINT
;
650 case 6: return VK_FORMAT_R16G16B16_UINT
;
651 case 8: return VK_FORMAT_R16G16B16A16_UINT
;
652 case 12: return VK_FORMAT_R32G32B32_UINT
;
653 case 16: return VK_FORMAT_R32G32B32A32_UINT
;
655 unreachable("Invalid format block size");
660 do_buffer_copy(struct anv_cmd_buffer
*cmd_buffer
,
661 struct anv_bo
*src
, uint64_t src_offset
,
662 struct anv_bo
*dest
, uint64_t dest_offset
,
663 int width
, int height
, VkFormat copy_format
)
665 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
667 VkImageCreateInfo image_info
= {
668 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
669 .imageType
= VK_IMAGE_TYPE_2D
,
670 .format
= copy_format
,
679 .tiling
= VK_IMAGE_TILING_LINEAR
,
685 image_info
.usage
= VK_IMAGE_USAGE_SAMPLED_BIT
;
686 anv_CreateImage(vk_device
, &image_info
, &src_image
);
689 image_info
.usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
;
690 anv_CreateImage(vk_device
, &image_info
, &dest_image
);
692 /* We could use a vk call to bind memory, but that would require
693 * creating a dummy memory object etc. so there's really no point.
695 anv_image_from_handle(src_image
)->bo
= src
;
696 anv_image_from_handle(src_image
)->offset
= src_offset
;
697 anv_image_from_handle(dest_image
)->bo
= dest
;
698 anv_image_from_handle(dest_image
)->offset
= dest_offset
;
700 struct anv_image_view src_iview
;
701 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
702 &(VkImageViewCreateInfo
) {
703 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
705 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
706 .format
= copy_format
,
707 .subresourceRange
= {
708 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
717 struct anv_image_view dest_iview
;
718 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
719 &(VkImageViewCreateInfo
) {
720 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
722 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
723 .format
= copy_format
,
724 .subresourceRange
= {
725 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
734 meta_emit_blit(cmd_buffer
,
735 anv_image_from_handle(src_image
),
737 (VkOffset3D
) { 0, 0, 0 },
738 (VkExtent3D
) { width
, height
, 1 },
739 anv_image_from_handle(dest_image
),
741 (VkOffset3D
) { 0, 0, 0 },
742 (VkExtent3D
) { width
, height
, 1 },
745 anv_DestroyImage(vk_device
, src_image
);
746 anv_DestroyImage(vk_device
, dest_image
);
749 void anv_CmdCopyBuffer(
750 VkCommandBuffer commandBuffer
,
753 uint32_t regionCount
,
754 const VkBufferCopy
* pRegions
)
756 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
757 ANV_FROM_HANDLE(anv_buffer
, src_buffer
, srcBuffer
);
758 ANV_FROM_HANDLE(anv_buffer
, dest_buffer
, destBuffer
);
760 struct anv_meta_saved_state saved_state
;
762 meta_prepare_blit(cmd_buffer
, &saved_state
);
764 for (unsigned r
= 0; r
< regionCount
; r
++) {
765 uint64_t src_offset
= src_buffer
->offset
+ pRegions
[r
].srcOffset
;
766 uint64_t dest_offset
= dest_buffer
->offset
+ pRegions
[r
].dstOffset
;
767 uint64_t copy_size
= pRegions
[r
].size
;
769 /* First, we compute the biggest format that can be used with the
770 * given offsets and size.
774 int fs
= ffs(src_offset
) - 1;
776 bs
= MIN2(bs
, 1 << fs
);
777 assert(src_offset
% bs
== 0);
779 fs
= ffs(dest_offset
) - 1;
781 bs
= MIN2(bs
, 1 << fs
);
782 assert(dest_offset
% bs
== 0);
784 fs
= ffs(pRegions
[r
].size
) - 1;
786 bs
= MIN2(bs
, 1 << fs
);
787 assert(pRegions
[r
].size
% bs
== 0);
789 VkFormat copy_format
= vk_format_for_size(bs
);
791 /* This is maximum possible width/height our HW can handle */
792 uint64_t max_surface_dim
= 1 << 14;
794 /* First, we make a bunch of max-sized copies */
795 uint64_t max_copy_size
= max_surface_dim
* max_surface_dim
* bs
;
796 while (copy_size
> max_copy_size
) {
797 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
798 dest_buffer
->bo
, dest_offset
,
799 max_surface_dim
, max_surface_dim
, copy_format
);
800 copy_size
-= max_copy_size
;
801 src_offset
+= max_copy_size
;
802 dest_offset
+= max_copy_size
;
805 uint64_t height
= copy_size
/ (max_surface_dim
* bs
);
806 assert(height
< max_surface_dim
);
808 uint64_t rect_copy_size
= height
* max_surface_dim
* bs
;
809 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
810 dest_buffer
->bo
, dest_offset
,
811 max_surface_dim
, height
, copy_format
);
812 copy_size
-= rect_copy_size
;
813 src_offset
+= rect_copy_size
;
814 dest_offset
+= rect_copy_size
;
817 if (copy_size
!= 0) {
818 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
819 dest_buffer
->bo
, dest_offset
,
820 copy_size
/ bs
, 1, copy_format
);
824 meta_finish_blit(cmd_buffer
, &saved_state
);
827 void anv_CmdCopyImage(
828 VkCommandBuffer commandBuffer
,
830 VkImageLayout srcImageLayout
,
832 VkImageLayout destImageLayout
,
833 uint32_t regionCount
,
834 const VkImageCopy
* pRegions
)
836 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
837 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
838 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
840 const VkImageViewType src_iview_type
=
841 meta_blit_get_src_image_view_type(src_image
);
843 struct anv_meta_saved_state saved_state
;
845 meta_prepare_blit(cmd_buffer
, &saved_state
);
847 for (unsigned r
= 0; r
< regionCount
; r
++) {
848 struct anv_image_view src_iview
;
849 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
850 &(VkImageViewCreateInfo
) {
851 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
853 .viewType
= src_iview_type
,
854 .format
= src_image
->format
->vk_format
,
855 .subresourceRange
= {
856 .aspectMask
= pRegions
[r
].srcSubresource
.aspectMask
,
857 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
859 .baseArrayLayer
= pRegions
[r
].srcSubresource
.baseArrayLayer
,
860 .layerCount
= pRegions
[r
].dstSubresource
.layerCount
,
865 const VkOffset3D dest_offset
= {
866 .x
= pRegions
[r
].dstOffset
.x
,
867 .y
= pRegions
[r
].dstOffset
.y
,
872 if (src_image
->type
== VK_IMAGE_TYPE_3D
) {
873 assert(pRegions
[r
].srcSubresource
.layerCount
== 1 &&
874 pRegions
[r
].dstSubresource
.layerCount
== 1);
875 num_slices
= pRegions
[r
].extent
.depth
;
877 assert(pRegions
[r
].srcSubresource
.layerCount
==
878 pRegions
[r
].dstSubresource
.layerCount
);
879 assert(pRegions
[r
].extent
.depth
== 1);
880 num_slices
= pRegions
[r
].dstSubresource
.layerCount
;
883 const uint32_t dest_base_array_slice
=
884 meta_blit_get_dest_view_base_array_slice(dest_image
,
885 &pRegions
[r
].dstSubresource
,
886 &pRegions
[r
].dstOffset
);
888 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
889 VkOffset3D src_offset
= pRegions
[r
].srcOffset
;
890 src_offset
.z
+= slice
;
892 struct anv_image_view dest_iview
;
893 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
894 &(VkImageViewCreateInfo
) {
895 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
897 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
898 .format
= dest_image
->format
->vk_format
,
899 .subresourceRange
= {
900 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
901 .baseMipLevel
= pRegions
[r
].dstSubresource
.mipLevel
,
903 .baseArrayLayer
= dest_base_array_slice
+ slice
,
909 meta_emit_blit(cmd_buffer
,
910 src_image
, &src_iview
,
913 dest_image
, &dest_iview
,
920 meta_finish_blit(cmd_buffer
, &saved_state
);
923 void anv_CmdBlitImage(
924 VkCommandBuffer commandBuffer
,
926 VkImageLayout srcImageLayout
,
928 VkImageLayout destImageLayout
,
929 uint32_t regionCount
,
930 const VkImageBlit
* pRegions
,
934 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
935 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
936 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
938 const VkImageViewType src_iview_type
=
939 meta_blit_get_src_image_view_type(src_image
);
941 struct anv_meta_saved_state saved_state
;
943 anv_finishme("respect VkFilter");
945 meta_prepare_blit(cmd_buffer
, &saved_state
);
947 for (unsigned r
= 0; r
< regionCount
; r
++) {
948 struct anv_image_view src_iview
;
949 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
950 &(VkImageViewCreateInfo
) {
951 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
953 .viewType
= src_iview_type
,
954 .format
= src_image
->format
->vk_format
,
955 .subresourceRange
= {
956 .aspectMask
= pRegions
[r
].srcSubresource
.aspectMask
,
957 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
959 .baseArrayLayer
= pRegions
[r
].srcSubresource
.baseArrayLayer
,
965 const VkOffset3D dest_offset
= {
966 .x
= pRegions
[r
].dstOffset
.x
,
967 .y
= pRegions
[r
].dstOffset
.y
,
971 const uint32_t dest_array_slice
=
972 meta_blit_get_dest_view_base_array_slice(dest_image
,
973 &pRegions
[r
].dstSubresource
,
974 &pRegions
[r
].dstOffset
);
976 if (pRegions
[r
].srcSubresource
.layerCount
> 1)
977 anv_finishme("FINISHME: copy multiple array layers");
979 if (pRegions
[r
].dstExtent
.depth
> 1)
980 anv_finishme("FINISHME: copy multiple depth layers");
982 struct anv_image_view dest_iview
;
983 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
984 &(VkImageViewCreateInfo
) {
985 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
987 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
988 .format
= dest_image
->format
->vk_format
,
989 .subresourceRange
= {
990 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
991 .baseMipLevel
= pRegions
[r
].dstSubresource
.mipLevel
,
993 .baseArrayLayer
= dest_array_slice
,
999 meta_emit_blit(cmd_buffer
,
1000 src_image
, &src_iview
,
1001 pRegions
[r
].srcOffset
,
1002 pRegions
[r
].srcExtent
,
1003 dest_image
, &dest_iview
,
1005 pRegions
[r
].dstExtent
,
1009 meta_finish_blit(cmd_buffer
, &saved_state
);
1012 static struct anv_image
*
1013 make_image_for_buffer(VkDevice vk_device
, VkBuffer vk_buffer
, VkFormat format
,
1014 VkImageUsageFlags usage
,
1015 VkImageType image_type
,
1016 const VkBufferImageCopy
*copy
)
1018 ANV_FROM_HANDLE(anv_buffer
, buffer
, vk_buffer
);
1020 VkExtent3D extent
= copy
->imageExtent
;
1021 if (copy
->bufferRowLength
)
1022 extent
.width
= copy
->bufferRowLength
;
1023 if (copy
->bufferImageHeight
)
1024 extent
.height
= copy
->bufferImageHeight
;
1028 VkResult result
= anv_CreateImage(vk_device
,
1029 &(VkImageCreateInfo
) {
1030 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
1031 .imageType
= VK_IMAGE_TYPE_2D
,
1037 .tiling
= VK_IMAGE_TILING_LINEAR
,
1041 assert(result
== VK_SUCCESS
);
1043 ANV_FROM_HANDLE(anv_image
, image
, vk_image
);
1045 /* We could use a vk call to bind memory, but that would require
1046 * creating a dummy memory object etc. so there's really no point.
1048 image
->bo
= buffer
->bo
;
1049 image
->offset
= buffer
->offset
+ copy
->bufferOffset
;
1054 void anv_CmdCopyBufferToImage(
1055 VkCommandBuffer commandBuffer
,
1058 VkImageLayout destImageLayout
,
1059 uint32_t regionCount
,
1060 const VkBufferImageCopy
* pRegions
)
1062 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
1063 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
1064 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1065 const VkFormat orig_format
= dest_image
->format
->vk_format
;
1066 struct anv_meta_saved_state saved_state
;
1068 meta_prepare_blit(cmd_buffer
, &saved_state
);
1070 for (unsigned r
= 0; r
< regionCount
; r
++) {
1071 VkFormat proxy_format
= orig_format
;
1072 VkImageAspectFlags proxy_aspect
= pRegions
[r
].imageSubresource
.aspectMask
;
1074 if (orig_format
== VK_FORMAT_S8_UINT
) {
1075 proxy_format
= VK_FORMAT_R8_UINT
;
1076 proxy_aspect
= VK_IMAGE_ASPECT_COLOR_BIT
;
1079 struct anv_image
*src_image
=
1080 make_image_for_buffer(vk_device
, srcBuffer
, proxy_format
,
1081 VK_IMAGE_USAGE_SAMPLED_BIT
,
1082 dest_image
->type
, &pRegions
[r
]);
1084 const uint32_t dest_base_array_slice
=
1085 meta_blit_get_dest_view_base_array_slice(dest_image
,
1086 &pRegions
[r
].imageSubresource
,
1087 &pRegions
[r
].imageOffset
);
1089 unsigned num_slices
;
1090 if (dest_image
->type
== VK_IMAGE_TYPE_3D
) {
1091 assert(pRegions
[r
].imageSubresource
.layerCount
== 1);
1092 num_slices
= pRegions
[r
].imageExtent
.depth
;
1094 assert(pRegions
[r
].imageExtent
.depth
== 1);
1095 num_slices
= pRegions
[r
].imageSubresource
.layerCount
;
1098 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
1099 struct anv_image_view src_iview
;
1100 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1101 &(VkImageViewCreateInfo
) {
1102 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1103 .image
= anv_image_to_handle(src_image
),
1104 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1105 .format
= proxy_format
,
1106 .subresourceRange
= {
1107 .aspectMask
= proxy_aspect
,
1110 .baseArrayLayer
= 0,
1116 struct anv_image_view dest_iview
;
1117 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1118 &(VkImageViewCreateInfo
) {
1119 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1120 .image
= anv_image_to_handle(dest_image
),
1121 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1122 .format
= proxy_format
,
1123 .subresourceRange
= {
1124 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1125 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1127 .baseArrayLayer
= dest_base_array_slice
+ slice
,
1133 VkOffset3D src_offset
= { 0, 0, slice
};
1135 const VkOffset3D dest_offset
= {
1136 .x
= pRegions
[r
].imageOffset
.x
,
1137 .y
= pRegions
[r
].imageOffset
.y
,
1141 meta_emit_blit(cmd_buffer
,
1145 pRegions
[r
].imageExtent
,
1149 pRegions
[r
].imageExtent
,
1152 /* Once we've done the blit, all of the actual information about
1153 * the image is embedded in the command buffer so we can just
1154 * increment the offset directly in the image effectively
1155 * re-binding it to different backing memory.
1157 /* XXX: Insert a real CPP */
1158 src_image
->offset
+= src_image
->extent
.width
*
1159 src_image
->extent
.height
* 4;
1162 anv_DestroyImage(vk_device
, anv_image_to_handle(src_image
));
1165 meta_finish_blit(cmd_buffer
, &saved_state
);
1168 void anv_CmdCopyImageToBuffer(
1169 VkCommandBuffer commandBuffer
,
1171 VkImageLayout srcImageLayout
,
1172 VkBuffer destBuffer
,
1173 uint32_t regionCount
,
1174 const VkBufferImageCopy
* pRegions
)
1176 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
1177 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
1178 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1179 struct anv_meta_saved_state saved_state
;
1181 const VkImageViewType src_iview_type
=
1182 meta_blit_get_src_image_view_type(src_image
);
1184 meta_prepare_blit(cmd_buffer
, &saved_state
);
1186 for (unsigned r
= 0; r
< regionCount
; r
++) {
1187 struct anv_image_view src_iview
;
1188 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1189 &(VkImageViewCreateInfo
) {
1190 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1192 .viewType
= src_iview_type
,
1193 .format
= src_image
->format
->vk_format
,
1194 .subresourceRange
= {
1195 .aspectMask
= pRegions
[r
].imageSubresource
.aspectMask
,
1196 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1198 .baseArrayLayer
= pRegions
[r
].imageSubresource
.baseArrayLayer
,
1199 .layerCount
= pRegions
[r
].imageSubresource
.layerCount
,
1204 VkFormat dest_format
= src_image
->format
->vk_format
;
1205 if (dest_format
== VK_FORMAT_S8_UINT
) {
1206 dest_format
= VK_FORMAT_R8_UINT
;
1209 struct anv_image
*dest_image
=
1210 make_image_for_buffer(vk_device
, destBuffer
, dest_format
,
1211 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
,
1212 src_image
->type
, &pRegions
[r
]);
1214 unsigned num_slices
;
1215 if (src_image
->type
== VK_IMAGE_TYPE_3D
) {
1216 assert(pRegions
[r
].imageSubresource
.layerCount
== 1);
1217 num_slices
= pRegions
[r
].imageExtent
.depth
;
1219 assert(pRegions
[r
].imageExtent
.depth
== 1);
1220 num_slices
= pRegions
[r
].imageSubresource
.layerCount
;
1223 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
1224 VkOffset3D src_offset
= pRegions
[r
].imageOffset
;
1225 src_offset
.z
+= slice
;
1227 struct anv_image_view dest_iview
;
1228 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1229 &(VkImageViewCreateInfo
) {
1230 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1231 .image
= anv_image_to_handle(dest_image
),
1232 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1233 .format
= dest_format
,
1234 .subresourceRange
= {
1235 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1238 .baseArrayLayer
= 0,
1244 meta_emit_blit(cmd_buffer
,
1245 anv_image_from_handle(srcImage
),
1248 pRegions
[r
].imageExtent
,
1251 (VkOffset3D
) { 0, 0, 0 },
1252 pRegions
[r
].imageExtent
,
1255 /* Once we've done the blit, all of the actual information about
1256 * the image is embedded in the command buffer so we can just
1257 * increment the offset directly in the image effectively
1258 * re-binding it to different backing memory.
1260 /* XXX: Insert a real CPP */
1261 dest_image
->offset
+= dest_image
->extent
.width
*
1262 dest_image
->extent
.height
* 4;
1265 anv_DestroyImage(vk_device
, anv_image_to_handle(dest_image
));
1268 meta_finish_blit(cmd_buffer
, &saved_state
);
1271 void anv_CmdUpdateBuffer(
1272 VkCommandBuffer commandBuffer
,
1273 VkBuffer destBuffer
,
1274 VkDeviceSize destOffset
,
1275 VkDeviceSize dataSize
,
1276 const uint32_t* pData
)
1281 void anv_CmdFillBuffer(
1282 VkCommandBuffer commandBuffer
,
1283 VkBuffer destBuffer
,
1284 VkDeviceSize destOffset
,
1285 VkDeviceSize fillSize
,
1291 void anv_CmdResolveImage(
1292 VkCommandBuffer commandBuffer
,
1294 VkImageLayout srcImageLayout
,
1296 VkImageLayout destImageLayout
,
1297 uint32_t regionCount
,
1298 const VkImageResolve
* pRegions
)
1304 anv_device_init_meta(struct anv_device
*device
)
1306 anv_device_init_meta_clear_state(device
);
1307 anv_device_init_meta_blit_state(device
);
1311 anv_device_finish_meta(struct anv_device
*device
)
1313 anv_device_finish_meta_clear_state(device
);
1316 anv_DestroyRenderPass(anv_device_to_handle(device
),
1317 device
->meta_state
.blit
.render_pass
);
1318 anv_DestroyPipeline(anv_device_to_handle(device
),
1319 device
->meta_state
.blit
.pipeline_2d_src
);
1320 anv_DestroyPipeline(anv_device_to_handle(device
),
1321 device
->meta_state
.blit
.pipeline_3d_src
);
1322 anv_DestroyPipelineLayout(anv_device_to_handle(device
),
1323 device
->meta_state
.blit
.pipeline_layout
);
1324 anv_DestroyDescriptorSetLayout(anv_device_to_handle(device
),
1325 device
->meta_state
.blit
.ds_layout
);