2 * Copyright © 2016 Red Hat
3 * based on intel anv code:
4 * Copyright © 2015 Intel Corporation
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:
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
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
29 #include "radv_private.h"
30 #include "radv_shader.h"
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),
43 struct radv_meta_saved_state
{
46 struct radv_descriptor_set
*old_descriptor_set0
;
47 struct radv_pipeline
*old_pipeline
;
48 struct radv_viewport_state viewport
;
49 struct radv_scissor_state scissor
;
51 char push_constants
[128];
53 struct radv_render_pass
*pass
;
54 const struct radv_subpass
*subpass
;
55 struct radv_attachment_state
*attachments
;
56 struct radv_framebuffer
*framebuffer
;
60 struct radv_meta_saved_compute_state
{
61 struct radv_descriptor_set
*old_descriptor_set0
;
62 struct radv_pipeline
*old_pipeline
;
64 unsigned push_constant_size
;
65 char push_constants
[128];
68 VkResult
radv_device_init_meta_clear_state(struct radv_device
*device
);
69 void radv_device_finish_meta_clear_state(struct radv_device
*device
);
71 VkResult
radv_device_init_meta_resolve_state(struct radv_device
*device
);
72 void radv_device_finish_meta_resolve_state(struct radv_device
*device
);
74 VkResult
radv_device_init_meta_depth_decomp_state(struct radv_device
*device
);
75 void radv_device_finish_meta_depth_decomp_state(struct radv_device
*device
);
77 VkResult
radv_device_init_meta_fast_clear_flush_state(struct radv_device
*device
);
78 void radv_device_finish_meta_fast_clear_flush_state(struct radv_device
*device
);
80 VkResult
radv_device_init_meta_blit_state(struct radv_device
*device
);
81 void radv_device_finish_meta_blit_state(struct radv_device
*device
);
83 VkResult
radv_device_init_meta_blit2d_state(struct radv_device
*device
);
84 void radv_device_finish_meta_blit2d_state(struct radv_device
*device
);
86 VkResult
radv_device_init_meta_buffer_state(struct radv_device
*device
);
87 void radv_device_finish_meta_buffer_state(struct radv_device
*device
);
89 VkResult
radv_device_init_meta_query_state(struct radv_device
*device
);
90 void radv_device_finish_meta_query_state(struct radv_device
*device
);
92 VkResult
radv_device_init_meta_resolve_compute_state(struct radv_device
*device
);
93 void radv_device_finish_meta_resolve_compute_state(struct radv_device
*device
);
95 VkResult
radv_device_init_meta_resolve_fragment_state(struct radv_device
*device
);
96 void radv_device_finish_meta_resolve_fragment_state(struct radv_device
*device
);
98 void radv_meta_save(struct radv_meta_saved_state
*saved_state
,
99 struct radv_cmd_buffer
*cmd_buffer
, uint32_t flags
);
101 void radv_meta_restore(const struct radv_meta_saved_state
*state
,
102 struct radv_cmd_buffer
*cmd_buffer
);
104 void radv_meta_save_compute(struct radv_meta_saved_compute_state
*state
,
105 const struct radv_cmd_buffer
*cmd_buffer
,
106 unsigned push_constant_size
);
108 void radv_meta_restore_compute(const struct radv_meta_saved_compute_state
*state
,
109 struct radv_cmd_buffer
*cmd_buffer
);
111 VkImageViewType
radv_meta_get_view_type(const struct radv_image
*image
);
113 uint32_t radv_meta_get_iview_layer(const struct radv_image
*dest_image
,
114 const VkImageSubresourceLayers
*dest_subresource
,
115 const VkOffset3D
*dest_offset
);
117 struct radv_meta_blit2d_surf
{
118 /** The size of an element in bytes. */
122 struct radv_image
*image
;
125 VkImageAspectFlags aspect_mask
;
128 struct radv_meta_blit2d_buffer
{
129 struct radv_buffer
*buffer
;
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
;
142 void radv_meta_begin_blit2d(struct radv_cmd_buffer
*cmd_buffer
,
143 struct radv_meta_saved_state
*save
);
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
,
150 struct radv_meta_blit2d_rect
*rects
);
152 void radv_meta_end_blit2d(struct radv_cmd_buffer
*cmd_buffer
,
153 struct radv_meta_saved_state
*save
);
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_image_to_buffer(struct radv_cmd_buffer
*cmd_buffer
,
159 struct radv_meta_blit2d_surf
*src
,
160 struct radv_meta_blit2d_buffer
*dst
,
162 struct radv_meta_blit2d_rect
*rects
);
164 void radv_meta_buffer_to_image_cs(struct radv_cmd_buffer
*cmd_buffer
,
165 struct radv_meta_blit2d_buffer
*src
,
166 struct radv_meta_blit2d_surf
*dst
,
168 struct radv_meta_blit2d_rect
*rects
);
169 void radv_meta_image_to_image_cs(struct radv_cmd_buffer
*cmd_buffer
,
170 struct radv_meta_blit2d_surf
*src
,
171 struct radv_meta_blit2d_surf
*dst
,
173 struct radv_meta_blit2d_rect
*rects
);
174 void radv_meta_clear_image_cs(struct radv_cmd_buffer
*cmd_buffer
,
175 struct radv_meta_blit2d_surf
*dst
,
176 const VkClearColorValue
*clear_color
);
178 void radv_decompress_depth_image_inplace(struct radv_cmd_buffer
*cmd_buffer
,
179 struct radv_image
*image
,
180 VkImageSubresourceRange
*subresourceRange
);
181 void radv_resummarize_depth_image_inplace(struct radv_cmd_buffer
*cmd_buffer
,
182 struct radv_image
*image
,
183 VkImageSubresourceRange
*subresourceRange
);
184 void radv_fast_clear_flush_image_inplace(struct radv_cmd_buffer
*cmd_buffer
,
185 struct radv_image
*image
,
186 const VkImageSubresourceRange
*subresourceRange
);
188 void radv_meta_resolve_compute_image(struct radv_cmd_buffer
*cmd_buffer
,
189 struct radv_image
*src_image
,
190 VkImageLayout src_image_layout
,
191 struct radv_image
*dest_image
,
192 VkImageLayout dest_image_layout
,
193 uint32_t region_count
,
194 const VkImageResolve
*regions
);
196 void radv_meta_resolve_fragment_image(struct radv_cmd_buffer
*cmd_buffer
,
197 struct radv_image
*src_image
,
198 VkImageLayout src_image_layout
,
199 struct radv_image
*dest_image
,
200 VkImageLayout dest_image_layout
,
201 uint32_t region_count
,
202 const VkImageResolve
*regions
);
204 void radv_blit_to_prime_linear(struct radv_cmd_buffer
*cmd_buffer
,
205 struct radv_image
*image
,
206 struct radv_image
*linear_image
);
208 /* common nir builder helpers */
209 #include "nir/nir_builder.h"
211 nir_ssa_def
*radv_meta_gen_rect_vertices(nir_builder
*vs_b
);
212 nir_ssa_def
*radv_meta_gen_rect_vertices_comp2(nir_builder
*vs_b
, nir_ssa_def
*comp2
);
213 nir_shader
*radv_meta_build_nir_vs_generate_vertices(void);
214 nir_shader
*radv_meta_build_nir_fs_noop(void);
216 void radv_meta_build_resolve_shader_core(nir_builder
*b
,
219 nir_variable
*input_img
,
221 nir_ssa_def
*img_coord
);
226 #endif /* RADV_META_H */