1 /* 2 * Copyright © 2022 Imagination Technologies Ltd. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a copy 5 * of this software and associated documentation files (the "Software"), to deal 6 * in the Software without restriction, including without limitation the rights 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 * copies of the Software, and to permit persons to whom the Software is 9 * furnished to do so, subject to the following conditions: 10 * 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 13 * Software. 14 * 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 THE 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 * SOFTWARE. 22 */ 23 24 #ifndef PVR_JOB_RENDER_H 25 #define PVR_JOB_RENDER_H 26 27 #include <stdbool.h> 28 #include <stdint.h> 29 #include <vulkan/vulkan.h> 30 31 #include "hwdef/rogue_hw_defs.h" 32 #include "pvr_csb.h" 33 #include "pvr_limits.h" 34 #include "pvr_types.h" 35 36 struct pvr_device; 37 struct pvr_device_info; 38 struct pvr_free_list; 39 struct pvr_render_ctx; 40 struct pvr_rt_dataset; 41 struct vk_sync; 42 43 /* Macrotile information. */ 44 struct pvr_rt_mtile_info { 45 uint32_t tile_size_x; 46 uint32_t tile_size_y; 47 48 uint32_t num_tiles_x; 49 uint32_t num_tiles_y; 50 51 uint32_t tiles_per_mtile_x; 52 uint32_t tiles_per_mtile_y; 53 54 uint32_t x_tile_max; 55 uint32_t y_tile_max; 56 57 uint32_t mtiles_x; 58 uint32_t mtiles_y; 59 60 uint32_t mtile_x1; 61 uint32_t mtile_y1; 62 uint32_t mtile_x2; 63 uint32_t mtile_y2; 64 uint32_t mtile_x3; 65 uint32_t mtile_y3; 66 }; 67 68 /* FIXME: Turn 'struct pvr_sub_cmd' into 'struct pvr_job' and change 'struct 69 * pvr_render_job' to subclass it? This is approximately what v3dv does 70 * (although it doesn't subclass). 71 */ 72 struct pvr_render_job { 73 struct pvr_rt_dataset *rt_dataset; 74 75 struct { 76 bool run_frag : 1; 77 bool geometry_terminate : 1; 78 bool frag_uses_atomic_ops : 1; 79 bool disable_compute_overlap : 1; 80 bool enable_bg_tag : 1; 81 bool process_empty_tiles : 1; 82 bool get_vis_results : 1; 83 bool has_depth_attachment : 1; 84 bool has_stencil_attachment : 1; 85 bool requires_spm_scratch_buffer : 1; 86 }; 87 88 uint32_t pds_pixel_event_data_offset; 89 uint32_t pr_pds_pixel_event_data_offset; 90 91 pvr_dev_addr_t ctrl_stream_addr; 92 93 pvr_dev_addr_t depth_bias_table_addr; 94 pvr_dev_addr_t scissor_table_addr; 95 96 /* Unless VK_KHR_dynamic_rendering or core 1.3 is supported, Vulkan does not 97 * allow for separate depth and stencil attachments. We don't bother storing 98 * separate parameters for them here (yet). If both has_depth_attachment and 99 * has_stencil_attachment are false, the contents are undefined. 100 */ 101 struct pvr_ds_attachment { 102 struct { 103 bool d : 1; 104 bool s : 1; 105 } load, store; 106 107 pvr_dev_addr_t addr; 108 uint32_t stride; 109 uint32_t height; 110 VkExtent2D physical_extent; 111 uint32_t layer_size; 112 enum PVRX(CR_ZLS_FORMAT_TYPE) zls_format; 113 /* FIXME: This should be of type 'enum pvr_memlayout', but this is defined 114 * in pvr_private.h, which causes a circular include dependency. For now, 115 * treat it as a uint32_t. A couple of ways to possibly fix this: 116 * 117 * 1. Merge the contents of this header file into pvr_private.h. 118 * 2. Move 'enum pvr_memlayout' into it a new header that can be 119 * included by both this header and pvr_private.h. 120 */ 121 uint32_t memlayout; 122 123 /* TODO: Is this really necessary? Maybe we can extract all useful 124 * information and drop this member. */ 125 const struct pvr_image_view *iview; 126 127 bool has_alignment_transfers; 128 } ds; 129 130 VkClearDepthStencilValue ds_clear_value; 131 132 uint32_t samples; 133 134 uint32_t pixel_output_width; 135 136 uint8_t max_shared_registers; 137 138 /* Upper limit for tiles in flight, '0' means use default limit based 139 * on partition store. 140 */ 141 uint32_t max_tiles_in_flight; 142 143 static_assert(pvr_cmd_length(PBESTATE_REG_WORD0) == 2, 144 "PBESTATE_REG_WORD0 cannot be stored in uint64_t"); 145 static_assert(pvr_cmd_length(PBESTATE_REG_WORD1) == 2, 146 "PBESTATE_REG_WORD1 cannot be stored in uint64_t"); 147 static_assert(ROGUE_NUM_PBESTATE_REG_WORDS >= 2, 148 "Cannot store both PBESTATE_REG_WORD{0,1}"); 149 uint64_t pbe_reg_words[PVR_MAX_COLOR_ATTACHMENTS] 150 [ROGUE_NUM_PBESTATE_REG_WORDS]; 151 uint64_t pr_pbe_reg_words[PVR_MAX_COLOR_ATTACHMENTS] 152 [ROGUE_NUM_PBESTATE_REG_WORDS]; 153 154 static_assert(pvr_cmd_length(CR_PDS_BGRND0_BASE) == 2, 155 "CR_PDS_BGRND0_BASE cannot be stored in uint64_t"); 156 static_assert(pvr_cmd_length(CR_PDS_BGRND1_BASE) == 2, 157 "CR_PDS_BGRND1_BASE cannot be stored in uint64_t"); 158 static_assert(pvr_cmd_length(CR_PDS_BGRND3_SIZEINFO) == 2, 159 "CR_PDS_BGRND3_SIZEINFO cannot be stored in uint64_t"); 160 static_assert(ROGUE_NUM_CR_PDS_BGRND_WORDS == 3, 161 "Cannot store all CR_PDS_BGRND words"); 162 uint64_t pds_bgnd_reg_values[ROGUE_NUM_CR_PDS_BGRND_WORDS]; 163 uint64_t pds_pr_bgnd_reg_values[ROGUE_NUM_CR_PDS_BGRND_WORDS]; 164 }; 165 166 void pvr_rt_mtile_info_init(const struct pvr_device_info *dev_info, 167 struct pvr_rt_mtile_info *info, 168 uint32_t width, 169 uint32_t height, 170 uint32_t samples); 171 172 VkResult pvr_free_list_create(struct pvr_device *device, 173 uint32_t initial_size, 174 uint32_t max_size, 175 uint32_t grow_size, 176 uint32_t grow_threshold, 177 struct pvr_free_list *parent_free_list, 178 struct pvr_free_list **const free_list_out); 179 void pvr_free_list_destroy(struct pvr_free_list *free_list); 180 181 VkResult 182 pvr_render_target_dataset_create(struct pvr_device *device, 183 uint32_t width, 184 uint32_t height, 185 uint32_t samples, 186 uint32_t layers, 187 struct pvr_rt_dataset **const rt_dataset_out); 188 void pvr_render_target_dataset_destroy(struct pvr_rt_dataset *dataset); 189 190 VkResult pvr_render_job_submit(struct pvr_render_ctx *ctx, 191 struct pvr_render_job *job, 192 struct vk_sync *wait_geom, 193 struct vk_sync *wait_frag, 194 struct vk_sync *signal_sync_geom, 195 struct vk_sync *signal_sync_frag); 196 197 #endif /* PVR_JOB_RENDER_H */ 198