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 }, NULL
, &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 vs
= {
228 .nir
= build_nir_vertex_shader(false),
231 struct anv_shader_module fs_2d
= {
232 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D
),
235 struct anv_shader_module fs_3d
= {
236 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_3D
),
239 VkPipelineVertexInputStateCreateInfo vi_create_info
= {
240 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
,
241 .vertexBindingDescriptionCount
= 2,
242 .pVertexBindingDescriptions
= (VkVertexInputBindingDescription
[]) {
246 .inputRate
= VK_VERTEX_INPUT_RATE_VERTEX
250 .stride
= 5 * sizeof(float),
251 .inputRate
= VK_VERTEX_INPUT_RATE_VERTEX
254 .vertexAttributeDescriptionCount
= 3,
255 .pVertexAttributeDescriptions
= (VkVertexInputAttributeDescription
[]) {
260 .format
= VK_FORMAT_R32G32B32A32_UINT
,
267 .format
= VK_FORMAT_R32G32_SFLOAT
,
271 /* Texture Coordinate */
274 .format
= VK_FORMAT_R32G32B32_SFLOAT
,
280 VkDescriptorSetLayoutCreateInfo ds_layout_info
= {
281 .sType
= VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
,
283 .pBinding
= (VkDescriptorSetLayoutBinding
[]) {
286 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
287 .descriptorCount
= 1,
288 .stageFlags
= VK_SHADER_STAGE_FRAGMENT_BIT
,
289 .pImmutableSamplers
= NULL
293 anv_CreateDescriptorSetLayout(anv_device_to_handle(device
), &ds_layout_info
,
294 NULL
, &device
->meta_state
.blit
.ds_layout
);
296 anv_CreatePipelineLayout(anv_device_to_handle(device
),
297 &(VkPipelineLayoutCreateInfo
) {
298 .sType
= VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
,
300 .pSetLayouts
= &device
->meta_state
.blit
.ds_layout
,
302 NULL
, &device
->meta_state
.blit
.pipeline_layout
);
304 VkPipelineShaderStageCreateInfo pipeline_shader_stages
[] = {
306 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
307 .stage
= VK_SHADER_STAGE_VERTEX_BIT
,
308 .module
= anv_shader_module_to_handle(&vs
),
310 .pSpecializationInfo
= NULL
312 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
313 .stage
= VK_SHADER_STAGE_FRAGMENT_BIT
,
314 .module
= VK_NULL_HANDLE
, /* TEMPLATE VALUE! FILL ME IN! */
316 .pSpecializationInfo
= NULL
320 const VkGraphicsPipelineCreateInfo vk_pipeline_info
= {
321 .sType
= VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
,
322 .stageCount
= ARRAY_SIZE(pipeline_shader_stages
),
323 .pStages
= pipeline_shader_stages
,
324 .pVertexInputState
= &vi_create_info
,
325 .pInputAssemblyState
= &(VkPipelineInputAssemblyStateCreateInfo
) {
326 .sType
= VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
,
327 .topology
= VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
,
328 .primitiveRestartEnable
= false,
330 .pViewportState
= &(VkPipelineViewportStateCreateInfo
) {
331 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
,
335 .pRasterizationState
= &(VkPipelineRasterizationStateCreateInfo
) {
336 .sType
= VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO
,
337 .rasterizerDiscardEnable
= false,
338 .polygonMode
= VK_POLYGON_MODE_FILL
,
339 .cullMode
= VK_CULL_MODE_NONE
,
340 .frontFace
= VK_FRONT_FACE_COUNTER_CLOCKWISE
342 .pMultisampleState
= &(VkPipelineMultisampleStateCreateInfo
) {
343 .sType
= VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
,
344 .rasterizationSamples
= 1,
345 .sampleShadingEnable
= false,
346 .pSampleMask
= (VkSampleMask
[]) { UINT32_MAX
},
348 .pColorBlendState
= &(VkPipelineColorBlendStateCreateInfo
) {
349 .sType
= VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
,
350 .attachmentCount
= 1,
351 .pAttachments
= (VkPipelineColorBlendAttachmentState
[]) {
353 VK_COLOR_COMPONENT_A_BIT
|
354 VK_COLOR_COMPONENT_R_BIT
|
355 VK_COLOR_COMPONENT_G_BIT
|
356 VK_COLOR_COMPONENT_B_BIT
},
359 .pDynamicState
= &(VkPipelineDynamicStateCreateInfo
) {
360 .sType
= VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
,
361 .dynamicStateCount
= 9,
362 .pDynamicStates
= (VkDynamicState
[]) {
363 VK_DYNAMIC_STATE_VIEWPORT
,
364 VK_DYNAMIC_STATE_SCISSOR
,
365 VK_DYNAMIC_STATE_LINE_WIDTH
,
366 VK_DYNAMIC_STATE_DEPTH_BIAS
,
367 VK_DYNAMIC_STATE_BLEND_CONSTANTS
,
368 VK_DYNAMIC_STATE_DEPTH_BOUNDS
,
369 VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK
,
370 VK_DYNAMIC_STATE_STENCIL_WRITE_MASK
,
371 VK_DYNAMIC_STATE_STENCIL_REFERENCE
,
375 .layout
= device
->meta_state
.blit
.pipeline_layout
,
376 .renderPass
= device
->meta_state
.blit
.render_pass
,
380 const struct anv_graphics_pipeline_create_info anv_pipeline_info
= {
381 .use_repclear
= false,
382 .disable_viewport
= true,
383 .disable_scissor
= true,
388 pipeline_shader_stages
[1].module
= anv_shader_module_to_handle(&fs_2d
);
389 anv_graphics_pipeline_create(anv_device_to_handle(device
),
390 &vk_pipeline_info
, &anv_pipeline_info
,
391 NULL
, &device
->meta_state
.blit
.pipeline_2d_src
);
393 pipeline_shader_stages
[1].module
= anv_shader_module_to_handle(&fs_3d
);
394 anv_graphics_pipeline_create(anv_device_to_handle(device
),
395 &vk_pipeline_info
, &anv_pipeline_info
,
396 NULL
, &device
->meta_state
.blit
.pipeline_3d_src
);
399 ralloc_free(fs_2d
.nir
);
400 ralloc_free(fs_3d
.nir
);
404 meta_prepare_blit(struct anv_cmd_buffer
*cmd_buffer
,
405 struct anv_meta_saved_state
*saved_state
)
407 anv_meta_save(saved_state
, cmd_buffer
,
408 (1 << VK_DYNAMIC_STATE_VIEWPORT
));
412 VkOffset3D src_offset
;
413 VkExtent3D src_extent
;
414 VkOffset3D dest_offset
;
415 VkExtent3D dest_extent
;
419 meta_emit_blit(struct anv_cmd_buffer
*cmd_buffer
,
420 struct anv_image
*src_image
,
421 struct anv_image_view
*src_iview
,
422 VkOffset3D src_offset
,
423 VkExtent3D src_extent
,
424 struct anv_image
*dest_image
,
425 struct anv_image_view
*dest_iview
,
426 VkOffset3D dest_offset
,
427 VkExtent3D dest_extent
,
428 VkFilter blit_filter
)
430 struct anv_device
*device
= cmd_buffer
->device
;
431 VkDescriptorPool dummy_desc_pool
= (VkDescriptorPool
)1;
433 struct blit_vb_data
{
438 unsigned vb_size
= sizeof(struct anv_vue_header
) + 3 * sizeof(*vb_data
);
440 struct anv_state vb_state
=
441 anv_cmd_buffer_alloc_dynamic_state(cmd_buffer
, vb_size
, 16);
442 memset(vb_state
.map
, 0, sizeof(struct anv_vue_header
));
443 vb_data
= vb_state
.map
+ sizeof(struct anv_vue_header
);
445 vb_data
[0] = (struct blit_vb_data
) {
447 dest_offset
.x
+ dest_extent
.width
,
448 dest_offset
.y
+ dest_extent
.height
,
451 (float)(src_offset
.x
+ src_extent
.width
) / (float)src_iview
->extent
.width
,
452 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
453 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
457 vb_data
[1] = (struct blit_vb_data
) {
460 dest_offset
.y
+ dest_extent
.height
,
463 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
464 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
465 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
469 vb_data
[2] = (struct blit_vb_data
) {
475 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
476 (float)src_offset
.y
/ (float)src_iview
->extent
.height
,
477 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
481 anv_state_clflush(vb_state
);
483 struct anv_buffer vertex_buffer
= {
486 .bo
= &device
->dynamic_state_block_pool
.bo
,
487 .offset
= vb_state
.offset
,
490 anv_CmdBindVertexBuffers(anv_cmd_buffer_to_handle(cmd_buffer
), 0, 2,
492 anv_buffer_to_handle(&vertex_buffer
),
493 anv_buffer_to_handle(&vertex_buffer
)
497 sizeof(struct anv_vue_header
),
501 ANV_CALL(CreateSampler
)(anv_device_to_handle(device
),
502 &(VkSamplerCreateInfo
) {
503 .sType
= VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
,
504 .magFilter
= blit_filter
,
505 .minFilter
= blit_filter
,
506 }, &cmd_buffer
->pool
->alloc
, &sampler
);
509 anv_AllocateDescriptorSets(anv_device_to_handle(device
),
510 &(VkDescriptorSetAllocateInfo
) {
511 .sType
= VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
,
512 .descriptorPool
= dummy_desc_pool
,
514 .pSetLayouts
= &device
->meta_state
.blit
.ds_layout
516 anv_UpdateDescriptorSets(anv_device_to_handle(device
),
518 (VkWriteDescriptorSet
[]) {
520 .sType
= VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
,
523 .dstArrayElement
= 0,
524 .descriptorCount
= 1,
525 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
526 .pImageInfo
= (VkDescriptorImageInfo
[]) {
529 .imageView
= anv_image_view_to_handle(src_iview
),
530 .imageLayout
= VK_IMAGE_LAYOUT_GENERAL
,
537 anv_CreateFramebuffer(anv_device_to_handle(device
),
538 &(VkFramebufferCreateInfo
) {
539 .sType
= VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
,
540 .attachmentCount
= 1,
541 .pAttachments
= (VkImageView
[]) {
542 anv_image_view_to_handle(dest_iview
),
544 .width
= dest_iview
->extent
.width
,
545 .height
= dest_iview
->extent
.height
,
547 }, &cmd_buffer
->pool
->alloc
, &fb
);
549 ANV_CALL(CmdBeginRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
),
550 &(VkRenderPassBeginInfo
) {
551 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
,
552 .renderPass
= device
->meta_state
.blit
.render_pass
,
555 .offset
= { dest_offset
.x
, dest_offset
.y
},
556 .extent
= { dest_extent
.width
, dest_extent
.height
},
558 .clearValueCount
= 0,
559 .pClearValues
= NULL
,
560 }, VK_SUBPASS_CONTENTS_INLINE
);
564 switch (src_image
->type
) {
565 case VK_IMAGE_TYPE_1D
:
566 anv_finishme("VK_IMAGE_TYPE_1D");
567 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
569 case VK_IMAGE_TYPE_2D
:
570 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
572 case VK_IMAGE_TYPE_3D
:
573 pipeline
= device
->meta_state
.blit
.pipeline_3d_src
;
576 unreachable(!"bad VkImageType");
579 if (cmd_buffer
->state
.pipeline
!= anv_pipeline_from_handle(pipeline
)) {
580 anv_CmdBindPipeline(anv_cmd_buffer_to_handle(cmd_buffer
),
581 VK_PIPELINE_BIND_POINT_GRAPHICS
, pipeline
);
584 anv_CmdSetViewport(anv_cmd_buffer_to_handle(cmd_buffer
), 1,
588 .width
= dest_iview
->extent
.width
,
589 .height
= dest_iview
->extent
.height
,
594 anv_CmdBindDescriptorSets(anv_cmd_buffer_to_handle(cmd_buffer
),
595 VK_PIPELINE_BIND_POINT_GRAPHICS
,
596 device
->meta_state
.blit
.pipeline_layout
, 0, 1,
599 ANV_CALL(CmdDraw
)(anv_cmd_buffer_to_handle(cmd_buffer
), 3, 1, 0, 0);
601 ANV_CALL(CmdEndRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
));
603 /* At the point where we emit the draw call, all data from the
604 * descriptor sets, etc. has been used. We are free to delete it.
606 anv_descriptor_set_destroy(device
, anv_descriptor_set_from_handle(set
));
607 anv_DestroySampler(anv_device_to_handle(device
), sampler
,
608 &cmd_buffer
->pool
->alloc
);
609 anv_DestroyFramebuffer(anv_device_to_handle(device
), fb
,
610 &cmd_buffer
->pool
->alloc
);
614 meta_finish_blit(struct anv_cmd_buffer
*cmd_buffer
,
615 const struct anv_meta_saved_state
*saved_state
)
617 anv_meta_restore(saved_state
, cmd_buffer
);
621 vk_format_for_size(int bs
)
624 case 1: return VK_FORMAT_R8_UINT
;
625 case 2: return VK_FORMAT_R8G8_UINT
;
626 case 3: return VK_FORMAT_R8G8B8_UINT
;
627 case 4: return VK_FORMAT_R8G8B8A8_UINT
;
628 case 6: return VK_FORMAT_R16G16B16_UINT
;
629 case 8: return VK_FORMAT_R16G16B16A16_UINT
;
630 case 12: return VK_FORMAT_R32G32B32_UINT
;
631 case 16: return VK_FORMAT_R32G32B32A32_UINT
;
633 unreachable("Invalid format block size");
638 do_buffer_copy(struct anv_cmd_buffer
*cmd_buffer
,
639 struct anv_bo
*src
, uint64_t src_offset
,
640 struct anv_bo
*dest
, uint64_t dest_offset
,
641 int width
, int height
, VkFormat copy_format
)
643 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
645 VkImageCreateInfo image_info
= {
646 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
647 .imageType
= VK_IMAGE_TYPE_2D
,
648 .format
= copy_format
,
657 .tiling
= VK_IMAGE_TILING_LINEAR
,
663 image_info
.usage
= VK_IMAGE_USAGE_SAMPLED_BIT
;
664 anv_CreateImage(vk_device
, &image_info
,
665 &cmd_buffer
->pool
->alloc
, &src_image
);
668 image_info
.usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
;
669 anv_CreateImage(vk_device
, &image_info
,
670 &cmd_buffer
->pool
->alloc
, &dest_image
);
672 /* We could use a vk call to bind memory, but that would require
673 * creating a dummy memory object etc. so there's really no point.
675 anv_image_from_handle(src_image
)->bo
= src
;
676 anv_image_from_handle(src_image
)->offset
= src_offset
;
677 anv_image_from_handle(dest_image
)->bo
= dest
;
678 anv_image_from_handle(dest_image
)->offset
= dest_offset
;
680 struct anv_image_view src_iview
;
681 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
682 &(VkImageViewCreateInfo
) {
683 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
685 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
686 .format
= copy_format
,
687 .subresourceRange
= {
688 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
697 struct anv_image_view dest_iview
;
698 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
699 &(VkImageViewCreateInfo
) {
700 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
702 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
703 .format
= copy_format
,
704 .subresourceRange
= {
705 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
714 meta_emit_blit(cmd_buffer
,
715 anv_image_from_handle(src_image
),
717 (VkOffset3D
) { 0, 0, 0 },
718 (VkExtent3D
) { width
, height
, 1 },
719 anv_image_from_handle(dest_image
),
721 (VkOffset3D
) { 0, 0, 0 },
722 (VkExtent3D
) { width
, height
, 1 },
725 anv_DestroyImage(vk_device
, src_image
, &cmd_buffer
->pool
->alloc
);
726 anv_DestroyImage(vk_device
, dest_image
, &cmd_buffer
->pool
->alloc
);
729 void anv_CmdCopyBuffer(
730 VkCommandBuffer commandBuffer
,
733 uint32_t regionCount
,
734 const VkBufferCopy
* pRegions
)
736 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
737 ANV_FROM_HANDLE(anv_buffer
, src_buffer
, srcBuffer
);
738 ANV_FROM_HANDLE(anv_buffer
, dest_buffer
, destBuffer
);
740 struct anv_meta_saved_state saved_state
;
742 meta_prepare_blit(cmd_buffer
, &saved_state
);
744 for (unsigned r
= 0; r
< regionCount
; r
++) {
745 uint64_t src_offset
= src_buffer
->offset
+ pRegions
[r
].srcOffset
;
746 uint64_t dest_offset
= dest_buffer
->offset
+ pRegions
[r
].dstOffset
;
747 uint64_t copy_size
= pRegions
[r
].size
;
749 /* First, we compute the biggest format that can be used with the
750 * given offsets and size.
754 int fs
= ffs(src_offset
) - 1;
756 bs
= MIN2(bs
, 1 << fs
);
757 assert(src_offset
% bs
== 0);
759 fs
= ffs(dest_offset
) - 1;
761 bs
= MIN2(bs
, 1 << fs
);
762 assert(dest_offset
% bs
== 0);
764 fs
= ffs(pRegions
[r
].size
) - 1;
766 bs
= MIN2(bs
, 1 << fs
);
767 assert(pRegions
[r
].size
% bs
== 0);
769 VkFormat copy_format
= vk_format_for_size(bs
);
771 /* This is maximum possible width/height our HW can handle */
772 uint64_t max_surface_dim
= 1 << 14;
774 /* First, we make a bunch of max-sized copies */
775 uint64_t max_copy_size
= max_surface_dim
* max_surface_dim
* bs
;
776 while (copy_size
> max_copy_size
) {
777 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
778 dest_buffer
->bo
, dest_offset
,
779 max_surface_dim
, max_surface_dim
, copy_format
);
780 copy_size
-= max_copy_size
;
781 src_offset
+= max_copy_size
;
782 dest_offset
+= max_copy_size
;
785 uint64_t height
= copy_size
/ (max_surface_dim
* bs
);
786 assert(height
< max_surface_dim
);
788 uint64_t rect_copy_size
= height
* max_surface_dim
* bs
;
789 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
790 dest_buffer
->bo
, dest_offset
,
791 max_surface_dim
, height
, copy_format
);
792 copy_size
-= rect_copy_size
;
793 src_offset
+= rect_copy_size
;
794 dest_offset
+= rect_copy_size
;
797 if (copy_size
!= 0) {
798 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
799 dest_buffer
->bo
, dest_offset
,
800 copy_size
/ bs
, 1, copy_format
);
804 meta_finish_blit(cmd_buffer
, &saved_state
);
807 void anv_CmdCopyImage(
808 VkCommandBuffer commandBuffer
,
810 VkImageLayout srcImageLayout
,
812 VkImageLayout destImageLayout
,
813 uint32_t regionCount
,
814 const VkImageCopy
* pRegions
)
816 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
817 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
818 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
820 const VkImageViewType src_iview_type
=
821 meta_blit_get_src_image_view_type(src_image
);
823 struct anv_meta_saved_state saved_state
;
825 meta_prepare_blit(cmd_buffer
, &saved_state
);
827 for (unsigned r
= 0; r
< regionCount
; r
++) {
828 struct anv_image_view src_iview
;
829 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
830 &(VkImageViewCreateInfo
) {
831 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
833 .viewType
= src_iview_type
,
834 .format
= src_image
->format
->vk_format
,
835 .subresourceRange
= {
836 .aspectMask
= pRegions
[r
].srcSubresource
.aspectMask
,
837 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
839 .baseArrayLayer
= pRegions
[r
].srcSubresource
.baseArrayLayer
,
840 .layerCount
= pRegions
[r
].dstSubresource
.layerCount
,
845 const VkOffset3D dest_offset
= {
846 .x
= pRegions
[r
].dstOffset
.x
,
847 .y
= pRegions
[r
].dstOffset
.y
,
852 if (src_image
->type
== VK_IMAGE_TYPE_3D
) {
853 assert(pRegions
[r
].srcSubresource
.layerCount
== 1 &&
854 pRegions
[r
].dstSubresource
.layerCount
== 1);
855 num_slices
= pRegions
[r
].extent
.depth
;
857 assert(pRegions
[r
].srcSubresource
.layerCount
==
858 pRegions
[r
].dstSubresource
.layerCount
);
859 assert(pRegions
[r
].extent
.depth
== 1);
860 num_slices
= pRegions
[r
].dstSubresource
.layerCount
;
863 const uint32_t dest_base_array_slice
=
864 meta_blit_get_dest_view_base_array_slice(dest_image
,
865 &pRegions
[r
].dstSubresource
,
866 &pRegions
[r
].dstOffset
);
868 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
869 VkOffset3D src_offset
= pRegions
[r
].srcOffset
;
870 src_offset
.z
+= slice
;
872 struct anv_image_view dest_iview
;
873 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
874 &(VkImageViewCreateInfo
) {
875 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
877 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
878 .format
= dest_image
->format
->vk_format
,
879 .subresourceRange
= {
880 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
881 .baseMipLevel
= pRegions
[r
].dstSubresource
.mipLevel
,
883 .baseArrayLayer
= dest_base_array_slice
+ slice
,
889 meta_emit_blit(cmd_buffer
,
890 src_image
, &src_iview
,
893 dest_image
, &dest_iview
,
900 meta_finish_blit(cmd_buffer
, &saved_state
);
903 void anv_CmdBlitImage(
904 VkCommandBuffer commandBuffer
,
906 VkImageLayout srcImageLayout
,
908 VkImageLayout destImageLayout
,
909 uint32_t regionCount
,
910 const VkImageBlit
* pRegions
,
914 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
915 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
916 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
918 const VkImageViewType src_iview_type
=
919 meta_blit_get_src_image_view_type(src_image
);
921 struct anv_meta_saved_state saved_state
;
923 anv_finishme("respect VkFilter");
925 meta_prepare_blit(cmd_buffer
, &saved_state
);
927 for (unsigned r
= 0; r
< regionCount
; r
++) {
928 struct anv_image_view src_iview
;
929 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
930 &(VkImageViewCreateInfo
) {
931 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
933 .viewType
= src_iview_type
,
934 .format
= src_image
->format
->vk_format
,
935 .subresourceRange
= {
936 .aspectMask
= pRegions
[r
].srcSubresource
.aspectMask
,
937 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
939 .baseArrayLayer
= pRegions
[r
].srcSubresource
.baseArrayLayer
,
945 const VkOffset3D dest_offset
= {
946 .x
= pRegions
[r
].dstOffset
.x
,
947 .y
= pRegions
[r
].dstOffset
.y
,
951 const uint32_t dest_array_slice
=
952 meta_blit_get_dest_view_base_array_slice(dest_image
,
953 &pRegions
[r
].dstSubresource
,
954 &pRegions
[r
].dstOffset
);
956 if (pRegions
[r
].srcSubresource
.layerCount
> 1)
957 anv_finishme("FINISHME: copy multiple array layers");
959 if (pRegions
[r
].dstExtent
.depth
> 1)
960 anv_finishme("FINISHME: copy multiple depth layers");
962 struct anv_image_view dest_iview
;
963 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
964 &(VkImageViewCreateInfo
) {
965 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
967 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
968 .format
= dest_image
->format
->vk_format
,
969 .subresourceRange
= {
970 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
971 .baseMipLevel
= pRegions
[r
].dstSubresource
.mipLevel
,
973 .baseArrayLayer
= dest_array_slice
,
979 meta_emit_blit(cmd_buffer
,
980 src_image
, &src_iview
,
981 pRegions
[r
].srcOffset
,
982 pRegions
[r
].srcExtent
,
983 dest_image
, &dest_iview
,
985 pRegions
[r
].dstExtent
,
989 meta_finish_blit(cmd_buffer
, &saved_state
);
992 static struct anv_image
*
993 make_image_for_buffer(VkDevice vk_device
, VkBuffer vk_buffer
, VkFormat format
,
994 VkImageUsageFlags usage
,
995 VkImageType image_type
,
996 const VkAllocationCallbacks
*alloc
,
997 const VkBufferImageCopy
*copy
)
999 ANV_FROM_HANDLE(anv_buffer
, buffer
, vk_buffer
);
1001 VkExtent3D extent
= copy
->imageExtent
;
1002 if (copy
->bufferRowLength
)
1003 extent
.width
= copy
->bufferRowLength
;
1004 if (copy
->bufferImageHeight
)
1005 extent
.height
= copy
->bufferImageHeight
;
1009 VkResult result
= anv_CreateImage(vk_device
,
1010 &(VkImageCreateInfo
) {
1011 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
1012 .imageType
= VK_IMAGE_TYPE_2D
,
1018 .tiling
= VK_IMAGE_TILING_LINEAR
,
1021 }, alloc
, &vk_image
);
1022 assert(result
== VK_SUCCESS
);
1024 ANV_FROM_HANDLE(anv_image
, image
, vk_image
);
1026 /* We could use a vk call to bind memory, but that would require
1027 * creating a dummy memory object etc. so there's really no point.
1029 image
->bo
= buffer
->bo
;
1030 image
->offset
= buffer
->offset
+ copy
->bufferOffset
;
1035 void anv_CmdCopyBufferToImage(
1036 VkCommandBuffer commandBuffer
,
1039 VkImageLayout destImageLayout
,
1040 uint32_t regionCount
,
1041 const VkBufferImageCopy
* pRegions
)
1043 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
1044 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
1045 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1046 const VkFormat orig_format
= dest_image
->format
->vk_format
;
1047 struct anv_meta_saved_state saved_state
;
1049 meta_prepare_blit(cmd_buffer
, &saved_state
);
1051 for (unsigned r
= 0; r
< regionCount
; r
++) {
1052 VkFormat proxy_format
= orig_format
;
1053 VkImageAspectFlags proxy_aspect
= pRegions
[r
].imageSubresource
.aspectMask
;
1055 if (orig_format
== VK_FORMAT_S8_UINT
) {
1056 proxy_format
= VK_FORMAT_R8_UINT
;
1057 proxy_aspect
= VK_IMAGE_ASPECT_COLOR_BIT
;
1060 struct anv_image
*src_image
=
1061 make_image_for_buffer(vk_device
, srcBuffer
, proxy_format
,
1062 VK_IMAGE_USAGE_SAMPLED_BIT
,
1063 dest_image
->type
, &cmd_buffer
->pool
->alloc
,
1066 const uint32_t dest_base_array_slice
=
1067 meta_blit_get_dest_view_base_array_slice(dest_image
,
1068 &pRegions
[r
].imageSubresource
,
1069 &pRegions
[r
].imageOffset
);
1071 unsigned num_slices
;
1072 if (dest_image
->type
== VK_IMAGE_TYPE_3D
) {
1073 assert(pRegions
[r
].imageSubresource
.layerCount
== 1);
1074 num_slices
= pRegions
[r
].imageExtent
.depth
;
1076 assert(pRegions
[r
].imageExtent
.depth
== 1);
1077 num_slices
= pRegions
[r
].imageSubresource
.layerCount
;
1080 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
1081 struct anv_image_view src_iview
;
1082 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1083 &(VkImageViewCreateInfo
) {
1084 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1085 .image
= anv_image_to_handle(src_image
),
1086 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1087 .format
= proxy_format
,
1088 .subresourceRange
= {
1089 .aspectMask
= proxy_aspect
,
1092 .baseArrayLayer
= 0,
1098 struct anv_image_view dest_iview
;
1099 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1100 &(VkImageViewCreateInfo
) {
1101 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1102 .image
= anv_image_to_handle(dest_image
),
1103 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1104 .format
= proxy_format
,
1105 .subresourceRange
= {
1106 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1107 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1109 .baseArrayLayer
= dest_base_array_slice
+ slice
,
1115 VkOffset3D src_offset
= { 0, 0, slice
};
1117 const VkOffset3D dest_offset
= {
1118 .x
= pRegions
[r
].imageOffset
.x
,
1119 .y
= pRegions
[r
].imageOffset
.y
,
1123 meta_emit_blit(cmd_buffer
,
1127 pRegions
[r
].imageExtent
,
1131 pRegions
[r
].imageExtent
,
1134 /* Once we've done the blit, all of the actual information about
1135 * the image is embedded in the command buffer so we can just
1136 * increment the offset directly in the image effectively
1137 * re-binding it to different backing memory.
1139 /* XXX: Insert a real CPP */
1140 src_image
->offset
+= src_image
->extent
.width
*
1141 src_image
->extent
.height
* 4;
1144 anv_DestroyImage(vk_device
, anv_image_to_handle(src_image
),
1145 &cmd_buffer
->pool
->alloc
);
1148 meta_finish_blit(cmd_buffer
, &saved_state
);
1151 void anv_CmdCopyImageToBuffer(
1152 VkCommandBuffer commandBuffer
,
1154 VkImageLayout srcImageLayout
,
1155 VkBuffer destBuffer
,
1156 uint32_t regionCount
,
1157 const VkBufferImageCopy
* pRegions
)
1159 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
1160 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
1161 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1162 struct anv_meta_saved_state saved_state
;
1164 const VkImageViewType src_iview_type
=
1165 meta_blit_get_src_image_view_type(src_image
);
1167 meta_prepare_blit(cmd_buffer
, &saved_state
);
1169 for (unsigned r
= 0; r
< regionCount
; r
++) {
1170 struct anv_image_view src_iview
;
1171 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1172 &(VkImageViewCreateInfo
) {
1173 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1175 .viewType
= src_iview_type
,
1176 .format
= src_image
->format
->vk_format
,
1177 .subresourceRange
= {
1178 .aspectMask
= pRegions
[r
].imageSubresource
.aspectMask
,
1179 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1181 .baseArrayLayer
= pRegions
[r
].imageSubresource
.baseArrayLayer
,
1182 .layerCount
= pRegions
[r
].imageSubresource
.layerCount
,
1187 VkFormat dest_format
= src_image
->format
->vk_format
;
1188 if (dest_format
== VK_FORMAT_S8_UINT
) {
1189 dest_format
= VK_FORMAT_R8_UINT
;
1192 struct anv_image
*dest_image
=
1193 make_image_for_buffer(vk_device
, destBuffer
, dest_format
,
1194 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
,
1195 src_image
->type
, &cmd_buffer
->pool
->alloc
,
1198 unsigned num_slices
;
1199 if (src_image
->type
== VK_IMAGE_TYPE_3D
) {
1200 assert(pRegions
[r
].imageSubresource
.layerCount
== 1);
1201 num_slices
= pRegions
[r
].imageExtent
.depth
;
1203 assert(pRegions
[r
].imageExtent
.depth
== 1);
1204 num_slices
= pRegions
[r
].imageSubresource
.layerCount
;
1207 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
1208 VkOffset3D src_offset
= pRegions
[r
].imageOffset
;
1209 src_offset
.z
+= slice
;
1211 struct anv_image_view dest_iview
;
1212 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1213 &(VkImageViewCreateInfo
) {
1214 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1215 .image
= anv_image_to_handle(dest_image
),
1216 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1217 .format
= dest_format
,
1218 .subresourceRange
= {
1219 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1222 .baseArrayLayer
= 0,
1228 meta_emit_blit(cmd_buffer
,
1229 anv_image_from_handle(srcImage
),
1232 pRegions
[r
].imageExtent
,
1235 (VkOffset3D
) { 0, 0, 0 },
1236 pRegions
[r
].imageExtent
,
1239 /* Once we've done the blit, all of the actual information about
1240 * the image is embedded in the command buffer so we can just
1241 * increment the offset directly in the image effectively
1242 * re-binding it to different backing memory.
1244 /* XXX: Insert a real CPP */
1245 dest_image
->offset
+= dest_image
->extent
.width
*
1246 dest_image
->extent
.height
* 4;
1249 anv_DestroyImage(vk_device
, anv_image_to_handle(dest_image
),
1250 &cmd_buffer
->pool
->alloc
);
1253 meta_finish_blit(cmd_buffer
, &saved_state
);
1256 void anv_CmdUpdateBuffer(
1257 VkCommandBuffer commandBuffer
,
1258 VkBuffer destBuffer
,
1259 VkDeviceSize destOffset
,
1260 VkDeviceSize dataSize
,
1261 const uint32_t* pData
)
1266 void anv_CmdFillBuffer(
1267 VkCommandBuffer commandBuffer
,
1268 VkBuffer destBuffer
,
1269 VkDeviceSize destOffset
,
1270 VkDeviceSize fillSize
,
1276 void anv_CmdResolveImage(
1277 VkCommandBuffer commandBuffer
,
1279 VkImageLayout srcImageLayout
,
1281 VkImageLayout destImageLayout
,
1282 uint32_t regionCount
,
1283 const VkImageResolve
* pRegions
)
1289 anv_device_init_meta(struct anv_device
*device
)
1291 anv_device_init_meta_clear_state(device
);
1292 anv_device_init_meta_blit_state(device
);
1296 anv_device_finish_meta(struct anv_device
*device
)
1298 anv_device_finish_meta_clear_state(device
);
1301 anv_DestroyRenderPass(anv_device_to_handle(device
),
1302 device
->meta_state
.blit
.render_pass
, NULL
);
1303 anv_DestroyPipeline(anv_device_to_handle(device
),
1304 device
->meta_state
.blit
.pipeline_2d_src
, NULL
);
1305 anv_DestroyPipeline(anv_device_to_handle(device
),
1306 device
->meta_state
.blit
.pipeline_3d_src
, NULL
);
1307 anv_DestroyPipelineLayout(anv_device_to_handle(device
),
1308 device
->meta_state
.blit
.pipeline_layout
, NULL
);
1309 anv_DestroyDescriptorSetLayout(anv_device_to_handle(device
),
1310 device
->meta_state
.blit
.ds_layout
, NULL
);