Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 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 | |
Edward O'Callaghan | ba43768 | 2016-10-07 22:19:19 +1100 | [diff] [blame] | 26 | #ifndef RADV_META_H |
| 27 | #define RADV_META_H |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 28 | |
| 29 | #include "radv_private.h" |
Samuel Pitoiset | d4d7773 | 2017-09-01 11:41:18 +0200 | [diff] [blame] | 30 | #include "radv_shader.h" |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 31 | |
| 32 | #ifdef __cplusplus |
| 33 | extern "C" { |
| 34 | #endif |
| 35 | |
Samuel Pitoiset | 807f2d4 | 2017-10-03 14:12:05 +0200 | [diff] [blame] | 36 | enum radv_meta_save_flags { |
| 37 | RADV_META_SAVE_PASS = (1 << 0), |
| 38 | RADV_META_SAVE_CONSTANTS = (1 << 1), |
| 39 | RADV_META_SAVE_DESCRIPTORS = (1 << 2), |
| 40 | RADV_META_SAVE_GRAPHICS_PIPELINE = (1 << 3), |
Samuel Pitoiset | 213f86e | 2017-10-03 14:47:32 +0200 | [diff] [blame] | 41 | RADV_META_SAVE_COMPUTE_PIPELINE = (1 << 4), |
Samuel Pitoiset | 807f2d4 | 2017-10-03 14:12:05 +0200 | [diff] [blame] | 42 | }; |
| 43 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 44 | struct radv_meta_saved_state { |
Samuel Pitoiset | 807f2d4 | 2017-10-03 14:12:05 +0200 | [diff] [blame] | 45 | uint32_t flags; |
| 46 | |
Dave Airlie | f45e768 | 2017-09-06 13:37:42 +1000 | [diff] [blame] | 47 | struct radv_descriptor_set *old_descriptor_set0; |
| 48 | struct radv_pipeline *old_pipeline; |
Samuel Pitoiset | 1cf508b | 2017-09-25 14:02:49 +0200 | [diff] [blame] | 49 | struct radv_viewport_state viewport; |
| 50 | struct radv_scissor_state scissor; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 51 | |
| 52 | char push_constants[128]; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 53 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 54 | struct radv_render_pass *pass; |
| 55 | const struct radv_subpass *subpass; |
| 56 | struct radv_attachment_state *attachments; |
| 57 | struct radv_framebuffer *framebuffer; |
| 58 | VkRect2D render_area; |
| 59 | }; |
| 60 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 61 | VkResult radv_device_init_meta_clear_state(struct radv_device *device, bool on_demand); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 62 | void radv_device_finish_meta_clear_state(struct radv_device *device); |
| 63 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 64 | VkResult radv_device_init_meta_resolve_state(struct radv_device *device, bool on_demand); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 65 | void radv_device_finish_meta_resolve_state(struct radv_device *device); |
| 66 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 67 | VkResult radv_device_init_meta_depth_decomp_state(struct radv_device *device, bool on_demand); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 68 | void radv_device_finish_meta_depth_decomp_state(struct radv_device *device); |
| 69 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 70 | VkResult radv_device_init_meta_fast_clear_flush_state(struct radv_device *device, bool on_demand); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 71 | void radv_device_finish_meta_fast_clear_flush_state(struct radv_device *device); |
| 72 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 73 | VkResult radv_device_init_meta_blit_state(struct radv_device *device, bool on_demand); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 74 | void radv_device_finish_meta_blit_state(struct radv_device *device); |
| 75 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 76 | VkResult radv_device_init_meta_blit2d_state(struct radv_device *device, bool on_demand); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 77 | void radv_device_finish_meta_blit2d_state(struct radv_device *device); |
| 78 | |
| 79 | VkResult radv_device_init_meta_buffer_state(struct radv_device *device); |
| 80 | void radv_device_finish_meta_buffer_state(struct radv_device *device); |
| 81 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 82 | VkResult radv_device_init_meta_query_state(struct radv_device *device, bool on_demand); |
Bas Nieuwenhuizen | ce0c8cf | 2017-02-26 18:21:01 +0100 | [diff] [blame] | 83 | void radv_device_finish_meta_query_state(struct radv_device *device); |
| 84 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 85 | VkResult radv_device_init_meta_resolve_compute_state(struct radv_device *device, bool on_demand); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 86 | void radv_device_finish_meta_resolve_compute_state(struct radv_device *device); |
Dave Airlie | 69136f4 | 2017-04-27 01:47:22 +0100 | [diff] [blame] | 87 | |
Bas Nieuwenhuizen | fbcd167 | 2018-08-14 00:07:57 +0200 | [diff] [blame] | 88 | VkResult radv_device_init_meta_resolve_fragment_state(struct radv_device *device, bool on_demand); |
Dave Airlie | 69136f4 | 2017-04-27 01:47:22 +0100 | [diff] [blame] | 89 | void radv_device_finish_meta_resolve_fragment_state(struct radv_device *device); |
| 90 | |
Samuel Pitoiset | 6b97602 | 2018-12-17 20:59:33 +0100 | [diff] [blame] | 91 | VkResult radv_device_init_meta_fmask_expand_state(struct radv_device *device); |
| 92 | void radv_device_finish_meta_fmask_expand_state(struct radv_device *device); |
| 93 | |
Samuel Pitoiset | ba3dc35 | 2017-10-03 14:37:56 +0200 | [diff] [blame] | 94 | void radv_meta_save(struct radv_meta_saved_state *saved_state, |
| 95 | struct radv_cmd_buffer *cmd_buffer, uint32_t flags); |
| 96 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 97 | void radv_meta_restore(const struct radv_meta_saved_state *state, |
| 98 | struct radv_cmd_buffer *cmd_buffer); |
| 99 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 100 | VkImageViewType radv_meta_get_view_type(const struct radv_image *image); |
| 101 | |
| 102 | uint32_t radv_meta_get_iview_layer(const struct radv_image *dest_image, |
| 103 | const VkImageSubresourceLayers *dest_subresource, |
| 104 | const VkOffset3D *dest_offset); |
| 105 | |
| 106 | struct radv_meta_blit2d_surf { |
| 107 | /** The size of an element in bytes. */ |
| 108 | uint8_t bs; |
| 109 | VkFormat format; |
| 110 | |
| 111 | struct radv_image *image; |
| 112 | unsigned level; |
| 113 | unsigned layer; |
| 114 | VkImageAspectFlags aspect_mask; |
Dave Airlie | 821b537 | 2017-12-21 16:23:30 +1000 | [diff] [blame] | 115 | VkImageLayout current_layout; |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | struct radv_meta_blit2d_buffer { |
| 119 | struct radv_buffer *buffer; |
| 120 | uint32_t offset; |
| 121 | uint32_t pitch; |
| 122 | uint8_t bs; |
| 123 | VkFormat format; |
| 124 | }; |
| 125 | |
| 126 | struct radv_meta_blit2d_rect { |
| 127 | uint32_t src_x, src_y; |
| 128 | uint32_t dst_x, dst_y; |
| 129 | uint32_t width, height; |
| 130 | }; |
| 131 | |
| 132 | void radv_meta_begin_blit2d(struct radv_cmd_buffer *cmd_buffer, |
| 133 | struct radv_meta_saved_state *save); |
| 134 | |
| 135 | void radv_meta_blit2d(struct radv_cmd_buffer *cmd_buffer, |
| 136 | struct radv_meta_blit2d_surf *src_img, |
| 137 | struct radv_meta_blit2d_buffer *src_buf, |
| 138 | struct radv_meta_blit2d_surf *dst, |
| 139 | unsigned num_rects, |
| 140 | struct radv_meta_blit2d_rect *rects); |
| 141 | |
| 142 | void radv_meta_end_blit2d(struct radv_cmd_buffer *cmd_buffer, |
| 143 | struct radv_meta_saved_state *save); |
| 144 | |
| 145 | |
| 146 | VkResult radv_device_init_meta_bufimage_state(struct radv_device *device); |
| 147 | void radv_device_finish_meta_bufimage_state(struct radv_device *device); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 148 | void radv_meta_image_to_buffer(struct radv_cmd_buffer *cmd_buffer, |
| 149 | struct radv_meta_blit2d_surf *src, |
| 150 | struct radv_meta_blit2d_buffer *dst, |
| 151 | unsigned num_rects, |
| 152 | struct radv_meta_blit2d_rect *rects); |
| 153 | |
Dave Airlie | 983af3a | 2016-11-29 23:52:55 +0000 | [diff] [blame] | 154 | void radv_meta_buffer_to_image_cs(struct radv_cmd_buffer *cmd_buffer, |
| 155 | struct radv_meta_blit2d_buffer *src, |
| 156 | struct radv_meta_blit2d_surf *dst, |
| 157 | unsigned num_rects, |
| 158 | struct radv_meta_blit2d_rect *rects); |
Dave Airlie | ef5f59c | 2016-11-30 00:26:47 +0000 | [diff] [blame] | 159 | void radv_meta_image_to_image_cs(struct radv_cmd_buffer *cmd_buffer, |
| 160 | struct radv_meta_blit2d_surf *src, |
| 161 | struct radv_meta_blit2d_surf *dst, |
| 162 | unsigned num_rects, |
| 163 | struct radv_meta_blit2d_rect *rects); |
Dave Airlie | f11ea87 | 2016-11-30 01:45:24 +0000 | [diff] [blame] | 164 | void radv_meta_clear_image_cs(struct radv_cmd_buffer *cmd_buffer, |
| 165 | struct radv_meta_blit2d_surf *dst, |
| 166 | const VkClearColorValue *clear_color); |
Dave Airlie | 983af3a | 2016-11-29 23:52:55 +0000 | [diff] [blame] | 167 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 168 | void radv_decompress_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer, |
| 169 | struct radv_image *image, |
| 170 | VkImageSubresourceRange *subresourceRange); |
| 171 | void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer *cmd_buffer, |
| 172 | struct radv_image *image, |
| 173 | VkImageSubresourceRange *subresourceRange); |
| 174 | void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer *cmd_buffer, |
Dave Airlie | 9aec76a | 2017-02-19 16:33:14 +1000 | [diff] [blame] | 175 | struct radv_image *image, |
| 176 | const VkImageSubresourceRange *subresourceRange); |
Bas Nieuwenhuizen | 3e2a619 | 2017-12-23 13:17:52 +0100 | [diff] [blame] | 177 | void radv_decompress_dcc(struct radv_cmd_buffer *cmd_buffer, |
| 178 | struct radv_image *image, |
| 179 | const VkImageSubresourceRange *subresourceRange); |
Samuel Pitoiset | 6b97602 | 2018-12-17 20:59:33 +0100 | [diff] [blame] | 180 | void radv_expand_fmask_image_inplace(struct radv_cmd_buffer *cmd_buffer, |
| 181 | struct radv_image *image, |
| 182 | const VkImageSubresourceRange *subresourceRange); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 183 | |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 184 | void radv_meta_resolve_compute_image(struct radv_cmd_buffer *cmd_buffer, |
| 185 | struct radv_image *src_image, |
| 186 | VkImageLayout src_image_layout, |
| 187 | struct radv_image *dest_image, |
| 188 | VkImageLayout dest_image_layout, |
| 189 | uint32_t region_count, |
| 190 | const VkImageResolve *regions); |
| 191 | |
Dave Airlie | 69136f4 | 2017-04-27 01:47:22 +0100 | [diff] [blame] | 192 | void radv_meta_resolve_fragment_image(struct radv_cmd_buffer *cmd_buffer, |
| 193 | struct radv_image *src_image, |
| 194 | VkImageLayout src_image_layout, |
| 195 | struct radv_image *dest_image, |
| 196 | VkImageLayout dest_image_layout, |
| 197 | uint32_t region_count, |
| 198 | const VkImageResolve *regions); |
| 199 | |
Samuel Pitoiset | ab0e625 | 2018-04-11 14:09:16 +0200 | [diff] [blame] | 200 | void radv_decompress_resolve_subpass_src(struct radv_cmd_buffer *cmd_buffer); |
| 201 | |
| 202 | void radv_decompress_resolve_src(struct radv_cmd_buffer *cmd_buffer, |
| 203 | struct radv_image *src_image, |
Samuel Pitoiset | dc3d397 | 2018-04-17 16:05:17 +0200 | [diff] [blame] | 204 | VkImageLayout src_image_layout, |
Samuel Pitoiset | ab0e625 | 2018-04-11 14:09:16 +0200 | [diff] [blame] | 205 | uint32_t region_count, |
| 206 | const VkImageResolve *regions); |
| 207 | |
Samuel Pitoiset | f882c62 | 2018-04-06 12:22:02 +0200 | [diff] [blame] | 208 | uint32_t radv_clear_cmask(struct radv_cmd_buffer *cmd_buffer, |
| 209 | struct radv_image *image, uint32_t value); |
Samuel Pitoiset | fa16da5 | 2018-12-17 21:23:42 +0100 | [diff] [blame] | 210 | uint32_t radv_clear_fmask(struct radv_cmd_buffer *cmd_buffer, |
| 211 | struct radv_image *image, uint32_t value); |
Samuel Pitoiset | f882c62 | 2018-04-06 12:22:02 +0200 | [diff] [blame] | 212 | uint32_t radv_clear_dcc(struct radv_cmd_buffer *cmd_buffer, |
| 213 | struct radv_image *image, uint32_t value); |
| 214 | |
Dave Airlie | 399ebd2 | 2017-04-19 06:18:23 +1000 | [diff] [blame] | 215 | /* common nir builder helpers */ |
Mike Lothian | 2284d6b | 2017-04-19 03:09:05 +0100 | [diff] [blame] | 216 | #include "nir/nir_builder.h" |
Dave Airlie | 399ebd2 | 2017-04-19 06:18:23 +1000 | [diff] [blame] | 217 | |
| 218 | nir_ssa_def *radv_meta_gen_rect_vertices(nir_builder *vs_b); |
Dave Airlie | dd17e4c | 2017-04-18 15:50:10 +1000 | [diff] [blame] | 219 | nir_ssa_def *radv_meta_gen_rect_vertices_comp2(nir_builder *vs_b, nir_ssa_def *comp2); |
Dave Airlie | 03a2ca6 | 2017-04-19 09:13:06 +1000 | [diff] [blame] | 220 | nir_shader *radv_meta_build_nir_vs_generate_vertices(void); |
| 221 | nir_shader *radv_meta_build_nir_fs_noop(void); |
Dave Airlie | ff47866 | 2017-05-03 04:23:04 +0100 | [diff] [blame] | 222 | |
| 223 | void radv_meta_build_resolve_shader_core(nir_builder *b, |
| 224 | bool is_integer, |
Dave Airlie | ff47866 | 2017-05-03 04:23:04 +0100 | [diff] [blame] | 225 | int samples, |
| 226 | nir_variable *input_img, |
| 227 | nir_variable *color, |
| 228 | nir_ssa_def *img_coord); |
Dave Airlie | f4e499e | 2016-10-07 09:16:09 +1000 | [diff] [blame] | 229 | #ifdef __cplusplus |
| 230 | } |
| 231 | #endif |
Edward O'Callaghan | ba43768 | 2016-10-07 22:19:19 +1100 | [diff] [blame] | 232 | |
| 233 | #endif /* RADV_META_H */ |