1 /* 2 * Copyright 2016 Red Hat 3 * based on intel anv code: 4 * Copyright 2015 Intel Corporation 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the "Software"), 8 * to deal in the Software without restriction, including without limitation 9 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 * and/or sell copies of the Software, and to permit persons to whom the 11 * Software is furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice (including the next 14 * paragraph) shall be included in all copies or substantial portions of the 15 * Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23 * IN THE SOFTWARE. 24 */ 25 26 #ifndef RADV_META_H 27 #define RADV_META_H 28 29 #include "radv_private.h" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #define RADV_META_VERTEX_BINDING_COUNT 2 36 37 struct radv_meta_saved_state { 38 struct radv_vertex_binding old_vertex_bindings[RADV_META_VERTEX_BINDING_COUNT]; 39 struct radv_descriptor_set *old_descriptor_set0; 40 struct radv_pipeline *old_pipeline; 41 42 /** 43 * Bitmask of (1 << VK_DYNAMIC_STATE_*). Defines the set of saved dynamic 44 * state. 45 */ 46 uint32_t dynamic_mask; 47 struct radv_dynamic_state dynamic; 48 49 char push_constants[128]; 50 }; 51 52 struct radv_meta_saved_pass_state { 53 struct radv_render_pass *pass; 54 const struct radv_subpass *subpass; 55 struct radv_attachment_state *attachments; 56 struct radv_framebuffer *framebuffer; 57 VkRect2D render_area; 58 }; 59 60 struct radv_meta_saved_compute_state { 61 struct radv_descriptor_set *old_descriptor_set0; 62 struct radv_pipeline *old_pipeline; 63 64 char push_constants[128]; 65 }; 66 67 VkResult radv_device_init_meta_clear_state(struct radv_device *device); 68 void radv_device_finish_meta_clear_state(struct radv_device *device); 69 70 VkResult radv_device_init_meta_resolve_state(struct radv_device *device); 71 void radv_device_finish_meta_resolve_state(struct radv_device *device); 72 73 VkResult radv_device_init_meta_depth_decomp_state(struct radv_device *device); 74 void radv_device_finish_meta_depth_decomp_state(struct radv_device *device); 75 76 VkResult radv_device_init_meta_fast_clear_flush_state(struct radv_device *device); 77 void radv_device_finish_meta_fast_clear_flush_state(struct radv_device *device); 78 79 VkResult radv_device_init_meta_blit_state(struct radv_device *device); 80 void radv_device_finish_meta_blit_state(struct radv_device *device); 81 82 VkResult radv_device_init_meta_blit2d_state(struct radv_device *device); 83 void radv_device_finish_meta_blit2d_state(struct radv_device *device); 84 85 VkResult radv_device_init_meta_buffer_state(struct radv_device *device); 86 void radv_device_finish_meta_buffer_state(struct radv_device *device); 87 88 VkResult radv_device_init_meta_resolve_compute_state(struct radv_device *device); 89 void radv_device_finish_meta_resolve_compute_state(struct radv_device *device); 90 void radv_meta_save(struct radv_meta_saved_state *state, 91 const struct radv_cmd_buffer *cmd_buffer, 92 uint32_t dynamic_mask); 93 94 void radv_meta_restore(const struct radv_meta_saved_state *state, 95 struct radv_cmd_buffer *cmd_buffer); 96 97 void radv_meta_save_pass(struct radv_meta_saved_pass_state *state, 98 const struct radv_cmd_buffer *cmd_buffer); 99 100 void radv_meta_restore_pass(const struct radv_meta_saved_pass_state *state, 101 struct radv_cmd_buffer *cmd_buffer); 102 103 void radv_meta_save_compute(struct radv_meta_saved_compute_state *state, 104 const struct radv_cmd_buffer *cmd_buffer, 105 unsigned push_constant_size); 106 107 void radv_meta_restore_compute(const struct radv_meta_saved_compute_state *state, 108 struct radv_cmd_buffer *cmd_buffer, 109 unsigned push_constant_size); 110 111 VkImageViewType radv_meta_get_view_type(const struct radv_image *image); 112 113 uint32_t radv_meta_get_iview_layer(const struct radv_image *dest_image, 114 const VkImageSubresourceLayers *dest_subresource, 115 const VkOffset3D *dest_offset); 116 117 struct radv_meta_blit2d_surf { 118 /** The size of an element in bytes. */ 119 uint8_t bs; 120 VkFormat format; 121 122 struct radv_image *image; 123 unsigned level; 124 unsigned layer; 125 VkImageAspectFlags aspect_mask; 126 }; 127 128 struct radv_meta_blit2d_buffer { 129 struct radv_buffer *buffer; 130 uint32_t offset; 131 uint32_t pitch; 132 uint8_t bs; 133 VkFormat format; 134 }; 135 136 struct radv_meta_blit2d_rect { 137 uint32_t src_x, src_y; 138 uint32_t dst_x, dst_y; 139 uint32_t width, height; 140 }; 141 142 void radv_meta_begin_blit2d(struct radv_cmd_buffer *cmd_buffer, 143 struct radv_meta_saved_state *save); 144 145 void radv_meta_blit2d(struct radv_cmd_buffer *cmd_buffer, 146 struct radv_meta_blit2d_surf *src_img, 147 struct radv_meta_blit2d_buffer *src_buf, 148 struct radv_meta_blit2d_surf *dst, 149 unsigned num_rects, 150 struct radv_meta_blit2d_rect *rects); 151 152 void radv_meta_end_blit2d(struct radv_cmd_buffer *cmd_buffer, 153 struct radv_meta_saved_state *save); 154 155 156 VkResult radv_device_init_meta_bufimage_state(struct radv_device *device); 157 void radv_device_finish_meta_bufimage_state(struct radv_device *device); 158 void radv_meta_begin_bufimage(struct radv_cmd_buffer *cmd_buffer, 159 struct radv_meta_saved_compute_state *save); 160 void radv_meta_end_bufimage(struct radv_cmd_buffer *cmd_buffer, 161 struct radv_meta_saved_compute_state *save); 162 void radv_meta_begin_itoi(struct radv_cmd_buffer *cmd_buffer, 163 struct radv_meta_saved_compute_state *save); 164 void radv_meta_end_itoi(struct radv_cmd_buffer *cmd_buffer, 165 struct radv_meta_saved_compute_state *save); 166 void radv_meta_begin_cleari(struct radv_cmd_buffer *cmd_buffer, 167 struct radv_meta_saved_compute_state *save); 168 void radv_meta_end_cleari(struct radv_cmd_buffer *cmd_buffer, 169 struct radv_meta_saved_compute_state *save); 170 void radv_meta_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, 171 struct radv_meta_blit2d_surf *src, 172 struct radv_meta_blit2d_buffer *dst, 173 unsigned num_rects, 174 struct radv_meta_blit2d_rect *rects); 175 176 void radv_meta_buffer_to_image_cs(struct radv_cmd_buffer *cmd_buffer, 177 struct radv_meta_blit2d_buffer *src, 178 struct radv_meta_blit2d_surf *dst, 179 unsigned num_rects, 180 struct radv_meta_blit2d_rect *rects); 181 void radv_meta_image_to_image_cs(struct radv_cmd_buffer *cmd_buffer, 182 struct radv_meta_blit2d_surf *src, 183 struct radv_meta_blit2d_surf *dst, 184 unsigned num_rects, 185 struct radv_meta_blit2d_rect *rects); 186 void radv_meta_clear_image_cs(struct radv_cmd_buffer *cmd_buffer, 187 struct radv_meta_blit2d_surf *dst, 188 const VkClearColorValue *clear_color); 189 190 void radv_decompress_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer, 191 struct radv_image *image, 192 VkImageSubresourceRange *subresourceRange); 193 void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer, 194 struct radv_image *image, 195 VkImageSubresourceRange *subresourceRange); 196 void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer, 197 struct radv_image *image); 198 199 void radv_meta_save_graphics_reset_vport_scissor(struct radv_meta_saved_state *saved_state, 200 struct radv_cmd_buffer *cmd_buffer); 201 202 void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, 203 struct radv_image *src_image, 204 VkImageLayout src_image_layout, 205 struct radv_image *dest_image, 206 VkImageLayout dest_image_layout, 207 uint32_t region_count, 208 const VkImageResolve *regions); 209 210 #ifdef __cplusplus 211 } 212 #endif 213 214 #endif /* RADV_META_H */ 215