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 .sType
= VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION
,
194 .format
= VK_FORMAT_UNDEFINED
, /* Our shaders don't care */
195 .loadOp
= VK_ATTACHMENT_LOAD_OP_LOAD
,
196 .storeOp
= VK_ATTACHMENT_STORE_OP_STORE
,
197 .initialLayout
= VK_IMAGE_LAYOUT_GENERAL
,
198 .finalLayout
= VK_IMAGE_LAYOUT_GENERAL
,
201 .pSubpasses
= &(VkSubpassDescription
) {
202 .sType
= VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION
,
203 .pipelineBindPoint
= VK_PIPELINE_BIND_POINT_GRAPHICS
,
206 .pColorAttachments
= &(VkAttachmentReference
) {
208 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
210 .pResolveAttachments
= NULL
,
211 .depthStencilAttachment
= (VkAttachmentReference
) {
212 .attachment
= VK_ATTACHMENT_UNUSED
,
213 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
216 .pPreserveAttachments
= &(VkAttachmentReference
) {
218 .layout
= VK_IMAGE_LAYOUT_GENERAL
,
221 .dependencyCount
= 0,
222 }, &device
->meta_state
.blit
.render_pass
);
224 /* We don't use a vertex shader for clearing, but instead build and pass
225 * the VUEs directly to the rasterization backend. However, we do need
226 * to provide GLSL source for the vertex shader so that the compiler
227 * does not dead-code our inputs.
229 struct anv_shader_module vsm
= {
230 .nir
= build_nir_vertex_shader(false),
233 struct anv_shader_module fsm_2d
= {
234 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D
),
237 struct anv_shader_module fsm_3d
= {
238 .nir
= build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_3D
),
242 anv_CreateShader(anv_device_to_handle(device
),
243 &(VkShaderCreateInfo
) {
244 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
245 .module
= anv_shader_module_to_handle(&vsm
),
250 anv_CreateShader(anv_device_to_handle(device
),
251 &(VkShaderCreateInfo
) {
252 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
253 .module
= anv_shader_module_to_handle(&fsm_2d
),
258 anv_CreateShader(anv_device_to_handle(device
),
259 &(VkShaderCreateInfo
) {
260 .sType
= VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
,
261 .module
= anv_shader_module_to_handle(&fsm_3d
),
265 VkPipelineVertexInputStateCreateInfo vi_create_info
= {
266 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
,
267 .vertexBindingDescriptionCount
= 2,
268 .pVertexBindingDescriptions
= (VkVertexInputBindingDescription
[]) {
272 .inputRate
= VK_VERTEX_INPUT_RATE_VERTEX
276 .stride
= 5 * sizeof(float),
277 .inputRate
= VK_VERTEX_INPUT_RATE_VERTEX
280 .vertexAttributeDescriptionCount
= 3,
281 .pVertexAttributeDescriptions
= (VkVertexInputAttributeDescription
[]) {
286 .format
= VK_FORMAT_R32G32B32A32_UINT
,
293 .format
= VK_FORMAT_R32G32_SFLOAT
,
297 /* Texture Coordinate */
300 .format
= VK_FORMAT_R32G32B32_SFLOAT
,
306 VkDescriptorSetLayoutCreateInfo ds_layout_info
= {
307 .sType
= VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO
,
309 .pBinding
= (VkDescriptorSetLayoutBinding
[]) {
311 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
313 .stageFlags
= VK_SHADER_STAGE_FRAGMENT_BIT
,
314 .pImmutableSamplers
= NULL
318 anv_CreateDescriptorSetLayout(anv_device_to_handle(device
), &ds_layout_info
,
319 &device
->meta_state
.blit
.ds_layout
);
321 anv_CreatePipelineLayout(anv_device_to_handle(device
),
322 &(VkPipelineLayoutCreateInfo
) {
323 .sType
= VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
,
324 .descriptorSetCount
= 1,
325 .pSetLayouts
= &device
->meta_state
.blit
.ds_layout
,
327 &device
->meta_state
.blit
.pipeline_layout
);
329 VkPipelineShaderStageCreateInfo pipeline_shader_stages
[] = {
331 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
332 .stage
= VK_SHADER_STAGE_VERTEX
,
334 .pSpecializationInfo
= NULL
336 .sType
= VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
,
337 .stage
= VK_SHADER_STAGE_FRAGMENT
,
338 .shader
= VK_NULL_HANDLE
, /* TEMPLATE VALUE! FILL ME IN! */
339 .pSpecializationInfo
= NULL
343 const VkGraphicsPipelineCreateInfo vk_pipeline_info
= {
344 .sType
= VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
,
345 .stageCount
= ARRAY_SIZE(pipeline_shader_stages
),
346 .pStages
= pipeline_shader_stages
,
347 .pVertexInputState
= &vi_create_info
,
348 .pInputAssemblyState
= &(VkPipelineInputAssemblyStateCreateInfo
) {
349 .sType
= VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
,
350 .topology
= VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
,
351 .primitiveRestartEnable
= false,
353 .pViewportState
= &(VkPipelineViewportStateCreateInfo
) {
354 .sType
= VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
,
358 .pRasterState
= &(VkPipelineRasterStateCreateInfo
) {
359 .sType
= VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO
,
360 .depthClipEnable
= true,
361 .rasterizerDiscardEnable
= false,
362 .polygonMode
= VK_POLYGON_MODE_FILL
,
363 .cullMode
= VK_CULL_MODE_NONE
,
364 .frontFace
= VK_FRONT_FACE_COUNTER_CLOCKWISE
366 .pMultisampleState
= &(VkPipelineMultisampleStateCreateInfo
) {
367 .sType
= VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO
,
369 .sampleShadingEnable
= false,
370 .pSampleMask
= (VkSampleMask
[]) { UINT32_MAX
},
372 .pColorBlendState
= &(VkPipelineColorBlendStateCreateInfo
) {
373 .sType
= VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
,
374 .attachmentCount
= 1,
375 .pAttachments
= (VkPipelineColorBlendAttachmentState
[]) {
376 { .channelWriteMask
= VK_CHANNEL_A_BIT
|
377 VK_CHANNEL_R_BIT
| VK_CHANNEL_G_BIT
| VK_CHANNEL_B_BIT
},
380 .pDynamicState
= &(VkPipelineDynamicStateCreateInfo
) {
381 .sType
= VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
,
382 .dynamicStateCount
= 9,
383 .pDynamicStates
= (VkDynamicState
[]) {
384 VK_DYNAMIC_STATE_VIEWPORT
,
385 VK_DYNAMIC_STATE_SCISSOR
,
386 VK_DYNAMIC_STATE_LINE_WIDTH
,
387 VK_DYNAMIC_STATE_DEPTH_BIAS
,
388 VK_DYNAMIC_STATE_BLEND_CONSTANTS
,
389 VK_DYNAMIC_STATE_DEPTH_BOUNDS
,
390 VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK
,
391 VK_DYNAMIC_STATE_STENCIL_WRITE_MASK
,
392 VK_DYNAMIC_STATE_STENCIL_REFERENCE
,
396 .layout
= device
->meta_state
.blit
.pipeline_layout
,
397 .renderPass
= device
->meta_state
.blit
.render_pass
,
401 const struct anv_graphics_pipeline_create_info anv_pipeline_info
= {
402 .use_repclear
= false,
403 .disable_viewport
= true,
404 .disable_scissor
= true,
409 pipeline_shader_stages
[1].shader
= fs_2d
;
410 anv_graphics_pipeline_create(anv_device_to_handle(device
),
411 &vk_pipeline_info
, &anv_pipeline_info
,
412 &device
->meta_state
.blit
.pipeline_2d_src
);
414 pipeline_shader_stages
[1].shader
= fs_3d
;
415 anv_graphics_pipeline_create(anv_device_to_handle(device
),
416 &vk_pipeline_info
, &anv_pipeline_info
,
417 &device
->meta_state
.blit
.pipeline_3d_src
);
419 anv_DestroyShader(anv_device_to_handle(device
), vs
);
420 anv_DestroyShader(anv_device_to_handle(device
), fs_2d
);
421 anv_DestroyShader(anv_device_to_handle(device
), fs_3d
);
422 ralloc_free(vsm
.nir
);
423 ralloc_free(fsm_2d
.nir
);
424 ralloc_free(fsm_3d
.nir
);
428 meta_prepare_blit(struct anv_cmd_buffer
*cmd_buffer
,
429 struct anv_meta_saved_state
*saved_state
)
431 anv_meta_save(saved_state
, cmd_buffer
,
432 (1 << VK_DYNAMIC_STATE_VIEWPORT
));
436 VkOffset3D src_offset
;
437 VkExtent3D src_extent
;
438 VkOffset3D dest_offset
;
439 VkExtent3D dest_extent
;
443 meta_emit_blit(struct anv_cmd_buffer
*cmd_buffer
,
444 struct anv_image
*src_image
,
445 struct anv_image_view
*src_iview
,
446 VkOffset3D src_offset
,
447 VkExtent3D src_extent
,
448 struct anv_image
*dest_image
,
449 struct anv_image_view
*dest_iview
,
450 VkOffset3D dest_offset
,
451 VkExtent3D dest_extent
,
452 VkFilter blit_filter
)
454 struct anv_device
*device
= cmd_buffer
->device
;
455 VkDescriptorPool dummy_desc_pool
= (VkDescriptorPool
)1;
457 struct blit_vb_data
{
462 unsigned vb_size
= sizeof(struct anv_vue_header
) + 3 * sizeof(*vb_data
);
464 struct anv_state vb_state
=
465 anv_cmd_buffer_alloc_dynamic_state(cmd_buffer
, vb_size
, 16);
466 memset(vb_state
.map
, 0, sizeof(struct anv_vue_header
));
467 vb_data
= vb_state
.map
+ sizeof(struct anv_vue_header
);
469 vb_data
[0] = (struct blit_vb_data
) {
471 dest_offset
.x
+ dest_extent
.width
,
472 dest_offset
.y
+ dest_extent
.height
,
475 (float)(src_offset
.x
+ src_extent
.width
) / (float)src_iview
->extent
.width
,
476 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
477 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
481 vb_data
[1] = (struct blit_vb_data
) {
484 dest_offset
.y
+ dest_extent
.height
,
487 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
488 (float)(src_offset
.y
+ src_extent
.height
) / (float)src_iview
->extent
.height
,
489 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
493 vb_data
[2] = (struct blit_vb_data
) {
499 (float)src_offset
.x
/ (float)src_iview
->extent
.width
,
500 (float)src_offset
.y
/ (float)src_iview
->extent
.height
,
501 (float)src_offset
.z
/ (float)src_iview
->extent
.depth
,
505 struct anv_buffer vertex_buffer
= {
508 .bo
= &device
->dynamic_state_block_pool
.bo
,
509 .offset
= vb_state
.offset
,
512 anv_CmdBindVertexBuffers(anv_cmd_buffer_to_handle(cmd_buffer
), 0, 2,
514 anv_buffer_to_handle(&vertex_buffer
),
515 anv_buffer_to_handle(&vertex_buffer
)
519 sizeof(struct anv_vue_header
),
523 ANV_CALL(CreateSampler
)(anv_device_to_handle(device
),
524 &(VkSamplerCreateInfo
) {
525 .sType
= VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO
,
526 .magFilter
= blit_filter
,
527 .minFilter
= blit_filter
,
531 anv_AllocDescriptorSets(anv_device_to_handle(device
), dummy_desc_pool
,
532 VK_DESCRIPTOR_SET_USAGE_ONE_SHOT
,
533 1, &device
->meta_state
.blit
.ds_layout
, &set
);
534 anv_UpdateDescriptorSets(anv_device_to_handle(device
),
536 (VkWriteDescriptorSet
[]) {
538 .sType
= VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
,
541 .destArrayElement
= 0,
543 .descriptorType
= VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
,
544 .pDescriptors
= (VkDescriptorInfo
[]) {
546 .imageView
= anv_image_view_to_handle(src_iview
),
547 .imageLayout
= VK_IMAGE_LAYOUT_GENERAL
,
555 anv_CreateFramebuffer(anv_device_to_handle(device
),
556 &(VkFramebufferCreateInfo
) {
557 .sType
= VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO
,
558 .attachmentCount
= 1,
559 .pAttachments
= (VkImageView
[]) {
560 anv_image_view_to_handle(dest_iview
),
562 .width
= dest_iview
->extent
.width
,
563 .height
= dest_iview
->extent
.height
,
567 ANV_CALL(CmdBeginRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
),
568 &(VkRenderPassBeginInfo
) {
569 .sType
= VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO
,
570 .renderPass
= device
->meta_state
.blit
.render_pass
,
573 .offset
= { dest_offset
.x
, dest_offset
.y
},
574 .extent
= { dest_extent
.width
, dest_extent
.height
},
576 .clearValueCount
= 0,
577 .pClearValues
= NULL
,
578 }, VK_SUBPASS_CONTENTS_INLINE
);
582 switch (src_image
->type
) {
583 case VK_IMAGE_TYPE_1D
:
584 anv_finishme("VK_IMAGE_TYPE_1D");
585 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
587 case VK_IMAGE_TYPE_2D
:
588 pipeline
= device
->meta_state
.blit
.pipeline_2d_src
;
590 case VK_IMAGE_TYPE_3D
:
591 pipeline
= device
->meta_state
.blit
.pipeline_3d_src
;
594 unreachable(!"bad VkImageType");
597 if (cmd_buffer
->state
.pipeline
!= anv_pipeline_from_handle(pipeline
)) {
598 anv_CmdBindPipeline(anv_cmd_buffer_to_handle(cmd_buffer
),
599 VK_PIPELINE_BIND_POINT_GRAPHICS
, pipeline
);
602 anv_CmdSetViewport(anv_cmd_buffer_to_handle(cmd_buffer
), 1,
606 .width
= dest_iview
->extent
.width
,
607 .height
= dest_iview
->extent
.height
,
612 anv_CmdBindDescriptorSets(anv_cmd_buffer_to_handle(cmd_buffer
),
613 VK_PIPELINE_BIND_POINT_GRAPHICS
,
614 device
->meta_state
.blit
.pipeline_layout
, 0, 1,
617 ANV_CALL(CmdDraw
)(anv_cmd_buffer_to_handle(cmd_buffer
), 3, 1, 0, 0);
619 ANV_CALL(CmdEndRenderPass
)(anv_cmd_buffer_to_handle(cmd_buffer
));
621 /* At the point where we emit the draw call, all data from the
622 * descriptor sets, etc. has been used. We are free to delete it.
624 anv_descriptor_set_destroy(device
, anv_descriptor_set_from_handle(set
));
625 anv_DestroySampler(anv_device_to_handle(device
), sampler
);
626 anv_DestroyFramebuffer(anv_device_to_handle(device
), fb
);
630 meta_finish_blit(struct anv_cmd_buffer
*cmd_buffer
,
631 const struct anv_meta_saved_state
*saved_state
)
633 anv_meta_restore(saved_state
, cmd_buffer
);
637 vk_format_for_size(int bs
)
640 case 1: return VK_FORMAT_R8_UINT
;
641 case 2: return VK_FORMAT_R8G8_UINT
;
642 case 3: return VK_FORMAT_R8G8B8_UINT
;
643 case 4: return VK_FORMAT_R8G8B8A8_UINT
;
644 case 6: return VK_FORMAT_R16G16B16_UINT
;
645 case 8: return VK_FORMAT_R16G16B16A16_UINT
;
646 case 12: return VK_FORMAT_R32G32B32_UINT
;
647 case 16: return VK_FORMAT_R32G32B32A32_UINT
;
649 unreachable("Invalid format block size");
654 do_buffer_copy(struct anv_cmd_buffer
*cmd_buffer
,
655 struct anv_bo
*src
, uint64_t src_offset
,
656 struct anv_bo
*dest
, uint64_t dest_offset
,
657 int width
, int height
, VkFormat copy_format
)
659 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
661 VkImageCreateInfo image_info
= {
662 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
663 .imageType
= VK_IMAGE_TYPE_2D
,
664 .format
= copy_format
,
673 .tiling
= VK_IMAGE_TILING_LINEAR
,
679 image_info
.usage
= VK_IMAGE_USAGE_SAMPLED_BIT
;
680 anv_CreateImage(vk_device
, &image_info
, &src_image
);
683 image_info
.usage
= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
;
684 anv_CreateImage(vk_device
, &image_info
, &dest_image
);
686 /* We could use a vk call to bind memory, but that would require
687 * creating a dummy memory object etc. so there's really no point.
689 anv_image_from_handle(src_image
)->bo
= src
;
690 anv_image_from_handle(src_image
)->offset
= src_offset
;
691 anv_image_from_handle(dest_image
)->bo
= dest
;
692 anv_image_from_handle(dest_image
)->offset
= dest_offset
;
694 struct anv_image_view src_iview
;
695 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
696 &(VkImageViewCreateInfo
) {
697 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
699 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
700 .format
= copy_format
,
701 .subresourceRange
= {
702 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
711 struct anv_image_view dest_iview
;
712 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
713 &(VkImageViewCreateInfo
) {
714 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
716 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
717 .format
= copy_format
,
718 .subresourceRange
= {
719 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
728 meta_emit_blit(cmd_buffer
,
729 anv_image_from_handle(src_image
),
731 (VkOffset3D
) { 0, 0, 0 },
732 (VkExtent3D
) { width
, height
, 1 },
733 anv_image_from_handle(dest_image
),
735 (VkOffset3D
) { 0, 0, 0 },
736 (VkExtent3D
) { width
, height
, 1 },
739 anv_DestroyImage(vk_device
, src_image
);
740 anv_DestroyImage(vk_device
, dest_image
);
743 void anv_CmdCopyBuffer(
744 VkCommandBuffer commandBuffer
,
747 uint32_t regionCount
,
748 const VkBufferCopy
* pRegions
)
750 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
751 ANV_FROM_HANDLE(anv_buffer
, src_buffer
, srcBuffer
);
752 ANV_FROM_HANDLE(anv_buffer
, dest_buffer
, destBuffer
);
754 struct anv_meta_saved_state saved_state
;
756 meta_prepare_blit(cmd_buffer
, &saved_state
);
758 for (unsigned r
= 0; r
< regionCount
; r
++) {
759 uint64_t src_offset
= src_buffer
->offset
+ pRegions
[r
].srcOffset
;
760 uint64_t dest_offset
= dest_buffer
->offset
+ pRegions
[r
].dstOffset
;
761 uint64_t copy_size
= pRegions
[r
].size
;
763 /* First, we compute the biggest format that can be used with the
764 * given offsets and size.
768 int fs
= ffs(src_offset
) - 1;
770 bs
= MIN2(bs
, 1 << fs
);
771 assert(src_offset
% bs
== 0);
773 fs
= ffs(dest_offset
) - 1;
775 bs
= MIN2(bs
, 1 << fs
);
776 assert(dest_offset
% bs
== 0);
778 fs
= ffs(pRegions
[r
].size
) - 1;
780 bs
= MIN2(bs
, 1 << fs
);
781 assert(pRegions
[r
].size
% bs
== 0);
783 VkFormat copy_format
= vk_format_for_size(bs
);
785 /* This is maximum possible width/height our HW can handle */
786 uint64_t max_surface_dim
= 1 << 14;
788 /* First, we make a bunch of max-sized copies */
789 uint64_t max_copy_size
= max_surface_dim
* max_surface_dim
* bs
;
790 while (copy_size
> max_copy_size
) {
791 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
792 dest_buffer
->bo
, dest_offset
,
793 max_surface_dim
, max_surface_dim
, copy_format
);
794 copy_size
-= max_copy_size
;
795 src_offset
+= max_copy_size
;
796 dest_offset
+= max_copy_size
;
799 uint64_t height
= copy_size
/ (max_surface_dim
* bs
);
800 assert(height
< max_surface_dim
);
802 uint64_t rect_copy_size
= height
* max_surface_dim
* bs
;
803 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
804 dest_buffer
->bo
, dest_offset
,
805 max_surface_dim
, height
, copy_format
);
806 copy_size
-= rect_copy_size
;
807 src_offset
+= rect_copy_size
;
808 dest_offset
+= rect_copy_size
;
811 if (copy_size
!= 0) {
812 do_buffer_copy(cmd_buffer
, src_buffer
->bo
, src_offset
,
813 dest_buffer
->bo
, dest_offset
,
814 copy_size
/ bs
, 1, copy_format
);
818 meta_finish_blit(cmd_buffer
, &saved_state
);
821 void anv_CmdCopyImage(
822 VkCommandBuffer commandBuffer
,
824 VkImageLayout srcImageLayout
,
826 VkImageLayout destImageLayout
,
827 uint32_t regionCount
,
828 const VkImageCopy
* pRegions
)
830 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
831 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
832 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
834 const VkImageViewType src_iview_type
=
835 meta_blit_get_src_image_view_type(src_image
);
837 struct anv_meta_saved_state saved_state
;
839 meta_prepare_blit(cmd_buffer
, &saved_state
);
841 for (unsigned r
= 0; r
< regionCount
; r
++) {
842 struct anv_image_view src_iview
;
843 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
844 &(VkImageViewCreateInfo
) {
845 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
847 .viewType
= src_iview_type
,
848 .format
= src_image
->format
->vk_format
,
849 .subresourceRange
= {
850 .aspectMask
= pRegions
[r
].srcSubresource
.aspectMask
,
851 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
853 .baseArrayLayer
= pRegions
[r
].srcSubresource
.baseArrayLayer
,
854 .arraySize
= pRegions
[r
].dstSubresource
.layerCount
,
859 const VkOffset3D dest_offset
= {
860 .x
= pRegions
[r
].dstOffset
.x
,
861 .y
= pRegions
[r
].dstOffset
.y
,
866 if (src_image
->type
== VK_IMAGE_TYPE_3D
) {
867 assert(pRegions
[r
].srcSubresource
.layerCount
== 1 &&
868 pRegions
[r
].dstSubresource
.layerCount
== 1);
869 num_slices
= pRegions
[r
].extent
.depth
;
871 assert(pRegions
[r
].srcSubresource
.layerCount
==
872 pRegions
[r
].dstSubresource
.layerCount
);
873 assert(pRegions
[r
].extent
.depth
== 1);
874 num_slices
= pRegions
[r
].dstSubresource
.layerCount
;
877 const uint32_t dest_base_array_slice
=
878 meta_blit_get_dest_view_base_array_slice(dest_image
,
879 &pRegions
[r
].dstSubresource
,
880 &pRegions
[r
].dstOffset
);
882 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
883 VkOffset3D src_offset
= pRegions
[r
].srcOffset
;
884 src_offset
.z
+= slice
;
886 struct anv_image_view dest_iview
;
887 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
888 &(VkImageViewCreateInfo
) {
889 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
891 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
892 .format
= dest_image
->format
->vk_format
,
893 .subresourceRange
= {
894 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
895 .baseMipLevel
= pRegions
[r
].dstSubresource
.mipLevel
,
897 .baseArrayLayer
= dest_base_array_slice
+ slice
,
903 meta_emit_blit(cmd_buffer
,
904 src_image
, &src_iview
,
907 dest_image
, &dest_iview
,
914 meta_finish_blit(cmd_buffer
, &saved_state
);
917 void anv_CmdBlitImage(
918 VkCommandBuffer commandBuffer
,
920 VkImageLayout srcImageLayout
,
922 VkImageLayout destImageLayout
,
923 uint32_t regionCount
,
924 const VkImageBlit
* pRegions
,
928 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
929 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
930 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
932 const VkImageViewType src_iview_type
=
933 meta_blit_get_src_image_view_type(src_image
);
935 struct anv_meta_saved_state saved_state
;
937 anv_finishme("respect VkFilter");
939 meta_prepare_blit(cmd_buffer
, &saved_state
);
941 for (unsigned r
= 0; r
< regionCount
; r
++) {
942 struct anv_image_view src_iview
;
943 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
944 &(VkImageViewCreateInfo
) {
945 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
947 .viewType
= src_iview_type
,
948 .format
= src_image
->format
->vk_format
,
949 .subresourceRange
= {
950 .aspectMask
= pRegions
[r
].srcSubresource
.aspectMask
,
951 .baseMipLevel
= pRegions
[r
].srcSubresource
.mipLevel
,
953 .baseArrayLayer
= pRegions
[r
].srcSubresource
.baseArrayLayer
,
959 const VkOffset3D dest_offset
= {
960 .x
= pRegions
[r
].dstOffset
.x
,
961 .y
= pRegions
[r
].dstOffset
.y
,
965 const uint32_t dest_array_slice
=
966 meta_blit_get_dest_view_base_array_slice(dest_image
,
967 &pRegions
[r
].dstSubresource
,
968 &pRegions
[r
].dstOffset
);
970 if (pRegions
[r
].srcSubresource
.layerCount
> 1)
971 anv_finishme("FINISHME: copy multiple array layers");
973 if (pRegions
[r
].dstExtent
.depth
> 1)
974 anv_finishme("FINISHME: copy multiple depth layers");
976 struct anv_image_view dest_iview
;
977 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
978 &(VkImageViewCreateInfo
) {
979 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
981 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
982 .format
= dest_image
->format
->vk_format
,
983 .subresourceRange
= {
984 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
985 .baseMipLevel
= pRegions
[r
].dstSubresource
.mipLevel
,
987 .baseArrayLayer
= dest_array_slice
,
993 meta_emit_blit(cmd_buffer
,
994 src_image
, &src_iview
,
995 pRegions
[r
].srcOffset
,
996 pRegions
[r
].srcExtent
,
997 dest_image
, &dest_iview
,
999 pRegions
[r
].dstExtent
,
1003 meta_finish_blit(cmd_buffer
, &saved_state
);
1006 static struct anv_image
*
1007 make_image_for_buffer(VkDevice vk_device
, VkBuffer vk_buffer
, VkFormat format
,
1008 VkImageUsageFlags usage
,
1009 VkImageType image_type
,
1010 const VkBufferImageCopy
*copy
)
1012 ANV_FROM_HANDLE(anv_buffer
, buffer
, vk_buffer
);
1014 VkExtent3D extent
= copy
->imageExtent
;
1015 if (copy
->bufferRowLength
)
1016 extent
.width
= copy
->bufferRowLength
;
1017 if (copy
->bufferImageHeight
)
1018 extent
.height
= copy
->bufferImageHeight
;
1022 VkResult result
= anv_CreateImage(vk_device
,
1023 &(VkImageCreateInfo
) {
1024 .sType
= VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
,
1025 .imageType
= VK_IMAGE_TYPE_2D
,
1031 .tiling
= VK_IMAGE_TILING_LINEAR
,
1035 assert(result
== VK_SUCCESS
);
1037 ANV_FROM_HANDLE(anv_image
, image
, vk_image
);
1039 /* We could use a vk call to bind memory, but that would require
1040 * creating a dummy memory object etc. so there's really no point.
1042 image
->bo
= buffer
->bo
;
1043 image
->offset
= buffer
->offset
+ copy
->bufferOffset
;
1048 void anv_CmdCopyBufferToImage(
1049 VkCommandBuffer commandBuffer
,
1052 VkImageLayout destImageLayout
,
1053 uint32_t regionCount
,
1054 const VkBufferImageCopy
* pRegions
)
1056 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
1057 ANV_FROM_HANDLE(anv_image
, dest_image
, destImage
);
1058 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1059 const VkFormat orig_format
= dest_image
->format
->vk_format
;
1060 struct anv_meta_saved_state saved_state
;
1062 meta_prepare_blit(cmd_buffer
, &saved_state
);
1064 for (unsigned r
= 0; r
< regionCount
; r
++) {
1065 VkFormat proxy_format
= orig_format
;
1066 VkImageAspectFlags proxy_aspect
= pRegions
[r
].imageSubresource
.aspectMask
;
1068 if (orig_format
== VK_FORMAT_S8_UINT
) {
1069 proxy_format
= VK_FORMAT_R8_UINT
;
1070 proxy_aspect
= VK_IMAGE_ASPECT_COLOR_BIT
;
1073 struct anv_image
*src_image
=
1074 make_image_for_buffer(vk_device
, srcBuffer
, proxy_format
,
1075 VK_IMAGE_USAGE_SAMPLED_BIT
,
1076 dest_image
->type
, &pRegions
[r
]);
1078 const uint32_t dest_base_array_slice
=
1079 meta_blit_get_dest_view_base_array_slice(dest_image
,
1080 &pRegions
[r
].imageSubresource
,
1081 &pRegions
[r
].imageOffset
);
1083 unsigned num_slices
;
1084 if (dest_image
->type
== VK_IMAGE_TYPE_3D
) {
1085 assert(pRegions
[r
].imageSubresource
.layerCount
== 1);
1086 num_slices
= pRegions
[r
].imageExtent
.depth
;
1088 assert(pRegions
[r
].imageExtent
.depth
== 1);
1089 num_slices
= pRegions
[r
].imageSubresource
.layerCount
;
1092 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
1093 struct anv_image_view src_iview
;
1094 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1095 &(VkImageViewCreateInfo
) {
1096 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1097 .image
= anv_image_to_handle(src_image
),
1098 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1099 .format
= proxy_format
,
1100 .subresourceRange
= {
1101 .aspectMask
= proxy_aspect
,
1104 .baseArrayLayer
= 0,
1110 struct anv_image_view dest_iview
;
1111 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1112 &(VkImageViewCreateInfo
) {
1113 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1114 .image
= anv_image_to_handle(dest_image
),
1115 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1116 .format
= proxy_format
,
1117 .subresourceRange
= {
1118 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1119 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1121 .baseArrayLayer
= dest_base_array_slice
+ slice
,
1127 VkOffset3D src_offset
= { 0, 0, slice
};
1129 const VkOffset3D dest_offset
= {
1130 .x
= pRegions
[r
].imageOffset
.x
,
1131 .y
= pRegions
[r
].imageOffset
.y
,
1135 meta_emit_blit(cmd_buffer
,
1139 pRegions
[r
].imageExtent
,
1143 pRegions
[r
].imageExtent
,
1146 /* Once we've done the blit, all of the actual information about
1147 * the image is embedded in the command buffer so we can just
1148 * increment the offset directly in the image effectively
1149 * re-binding it to different backing memory.
1151 /* XXX: Insert a real CPP */
1152 src_image
->offset
+= src_image
->extent
.width
*
1153 src_image
->extent
.height
* 4;
1156 anv_DestroyImage(vk_device
, anv_image_to_handle(src_image
));
1159 meta_finish_blit(cmd_buffer
, &saved_state
);
1162 void anv_CmdCopyImageToBuffer(
1163 VkCommandBuffer commandBuffer
,
1165 VkImageLayout srcImageLayout
,
1166 VkBuffer destBuffer
,
1167 uint32_t regionCount
,
1168 const VkBufferImageCopy
* pRegions
)
1170 ANV_FROM_HANDLE(anv_cmd_buffer
, cmd_buffer
, commandBuffer
);
1171 ANV_FROM_HANDLE(anv_image
, src_image
, srcImage
);
1172 VkDevice vk_device
= anv_device_to_handle(cmd_buffer
->device
);
1173 struct anv_meta_saved_state saved_state
;
1175 const VkImageViewType src_iview_type
=
1176 meta_blit_get_src_image_view_type(src_image
);
1178 meta_prepare_blit(cmd_buffer
, &saved_state
);
1180 for (unsigned r
= 0; r
< regionCount
; r
++) {
1181 struct anv_image_view src_iview
;
1182 anv_image_view_init(&src_iview
, cmd_buffer
->device
,
1183 &(VkImageViewCreateInfo
) {
1184 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1186 .viewType
= src_iview_type
,
1187 .format
= src_image
->format
->vk_format
,
1188 .subresourceRange
= {
1189 .aspectMask
= pRegions
[r
].imageSubresource
.aspectMask
,
1190 .baseMipLevel
= pRegions
[r
].imageSubresource
.mipLevel
,
1192 .baseArrayLayer
= pRegions
[r
].imageSubresource
.baseArrayLayer
,
1193 .arraySize
= pRegions
[r
].imageSubresource
.layerCount
,
1198 VkFormat dest_format
= src_image
->format
->vk_format
;
1199 if (dest_format
== VK_FORMAT_S8_UINT
) {
1200 dest_format
= VK_FORMAT_R8_UINT
;
1203 struct anv_image
*dest_image
=
1204 make_image_for_buffer(vk_device
, destBuffer
, dest_format
,
1205 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
,
1206 src_image
->type
, &pRegions
[r
]);
1208 unsigned num_slices
;
1209 if (src_image
->type
== VK_IMAGE_TYPE_3D
) {
1210 assert(pRegions
[r
].imageSubresource
.layerCount
== 1);
1211 num_slices
= pRegions
[r
].imageExtent
.depth
;
1213 assert(pRegions
[r
].imageExtent
.depth
== 1);
1214 num_slices
= pRegions
[r
].imageSubresource
.layerCount
;
1217 for (unsigned slice
= 0; slice
< num_slices
; slice
++) {
1218 VkOffset3D src_offset
= pRegions
[r
].imageOffset
;
1219 src_offset
.z
+= slice
;
1221 struct anv_image_view dest_iview
;
1222 anv_image_view_init(&dest_iview
, cmd_buffer
->device
,
1223 &(VkImageViewCreateInfo
) {
1224 .sType
= VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
,
1225 .image
= anv_image_to_handle(dest_image
),
1226 .viewType
= VK_IMAGE_VIEW_TYPE_2D
,
1227 .format
= dest_format
,
1228 .subresourceRange
= {
1229 .aspectMask
= VK_IMAGE_ASPECT_COLOR_BIT
,
1232 .baseArrayLayer
= 0,
1238 meta_emit_blit(cmd_buffer
,
1239 anv_image_from_handle(srcImage
),
1242 pRegions
[r
].imageExtent
,
1245 (VkOffset3D
) { 0, 0, 0 },
1246 pRegions
[r
].imageExtent
,
1249 /* Once we've done the blit, all of the actual information about
1250 * the image is embedded in the command buffer so we can just
1251 * increment the offset directly in the image effectively
1252 * re-binding it to different backing memory.
1254 /* XXX: Insert a real CPP */
1255 dest_image
->offset
+= dest_image
->extent
.width
*
1256 dest_image
->extent
.height
* 4;
1259 anv_DestroyImage(vk_device
, anv_image_to_handle(dest_image
));
1262 meta_finish_blit(cmd_buffer
, &saved_state
);
1265 void anv_CmdUpdateBuffer(
1266 VkCommandBuffer commandBuffer
,
1267 VkBuffer destBuffer
,
1268 VkDeviceSize destOffset
,
1269 VkDeviceSize dataSize
,
1270 const uint32_t* pData
)
1275 void anv_CmdFillBuffer(
1276 VkCommandBuffer commandBuffer
,
1277 VkBuffer destBuffer
,
1278 VkDeviceSize destOffset
,
1279 VkDeviceSize fillSize
,
1285 void anv_CmdResolveImage(
1286 VkCommandBuffer commandBuffer
,
1288 VkImageLayout srcImageLayout
,
1290 VkImageLayout destImageLayout
,
1291 uint32_t regionCount
,
1292 const VkImageResolve
* pRegions
)
1298 anv_device_init_meta(struct anv_device
*device
)
1300 anv_device_init_meta_clear_state(device
);
1301 anv_device_init_meta_blit_state(device
);
1305 anv_device_finish_meta(struct anv_device
*device
)
1307 anv_device_finish_meta_clear_state(device
);
1310 anv_DestroyRenderPass(anv_device_to_handle(device
),
1311 device
->meta_state
.blit
.render_pass
);
1312 anv_DestroyPipeline(anv_device_to_handle(device
),
1313 device
->meta_state
.blit
.pipeline_2d_src
);
1314 anv_DestroyPipeline(anv_device_to_handle(device
),
1315 device
->meta_state
.blit
.pipeline_3d_src
);
1316 anv_DestroyPipelineLayout(anv_device_to_handle(device
),
1317 device
->meta_state
.blit
.pipeline_layout
);
1318 anv_DestroyDescriptorSetLayout(anv_device_to_handle(device
),
1319 device
->meta_state
.blit
.ds_layout
);