• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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       bool disable_pixel_merging : 1;
87    };
88 
89    uint32_t pds_pixel_event_data_offset;
90    uint32_t pr_pds_pixel_event_data_offset;
91 
92    pvr_dev_addr_t ctrl_stream_addr;
93 
94    pvr_dev_addr_t depth_bias_table_addr;
95    pvr_dev_addr_t scissor_table_addr;
96 
97    /* Unless VK_KHR_dynamic_rendering or core 1.3 is supported, Vulkan does not
98     * allow for separate depth and stencil attachments. We don't bother storing
99     * separate parameters for them here (yet). If both has_depth_attachment and
100     * has_stencil_attachment are false, the contents are undefined.
101     */
102    struct pvr_ds_attachment {
103       struct {
104          bool d : 1;
105          bool s : 1;
106       } load, store;
107 
108       pvr_dev_addr_t addr;
109       uint32_t stride;
110       uint32_t height;
111       VkExtent2D physical_extent;
112       uint32_t layer_size;
113       enum ROGUE_CR_ZLS_FORMAT_TYPE zls_format;
114       /* FIXME: This should be of type 'enum pvr_memlayout', but this is defined
115        * in pvr_private.h, which causes a circular include dependency. For now,
116        * treat it as a uint32_t. A couple of ways to possibly fix this:
117        *
118        *   1. Merge the contents of this header file into pvr_private.h.
119        *   2. Move 'enum pvr_memlayout' into it a new header that can be
120        *      included by both this header and pvr_private.h.
121        */
122       uint32_t memlayout;
123 
124       /* TODO: Is this really necessary? Maybe we can extract all useful
125        * information and drop this member. */
126       const struct pvr_image_view *iview;
127 
128       bool has_alignment_transfers;
129    } ds;
130 
131    VkClearDepthStencilValue ds_clear_value;
132 
133    uint32_t samples;
134 
135    uint32_t pixel_output_width;
136 
137    uint8_t max_shared_registers;
138 
139    /* Upper limit for tiles in flight, '0' means use default limit based
140     * on partition store.
141     */
142    uint32_t max_tiles_in_flight;
143 
144    static_assert(pvr_cmd_length(PBESTATE_REG_WORD0) == 2,
145                  "PBESTATE_REG_WORD0 cannot be stored in uint64_t");
146    static_assert(pvr_cmd_length(PBESTATE_REG_WORD1) == 2,
147                  "PBESTATE_REG_WORD1 cannot be stored in uint64_t");
148    static_assert(ROGUE_NUM_PBESTATE_REG_WORDS >= 2,
149                  "Cannot store both PBESTATE_REG_WORD{0,1}");
150    uint64_t pbe_reg_words[PVR_MAX_COLOR_ATTACHMENTS]
151                          [ROGUE_NUM_PBESTATE_REG_WORDS];
152    uint64_t pr_pbe_reg_words[PVR_MAX_COLOR_ATTACHMENTS]
153                             [ROGUE_NUM_PBESTATE_REG_WORDS];
154 
155    static_assert(pvr_cmd_length(CR_PDS_BGRND0_BASE) == 2,
156                  "CR_PDS_BGRND0_BASE cannot be stored in uint64_t");
157    static_assert(pvr_cmd_length(CR_PDS_BGRND1_BASE) == 2,
158                  "CR_PDS_BGRND1_BASE cannot be stored in uint64_t");
159    static_assert(pvr_cmd_length(CR_PDS_BGRND3_SIZEINFO) == 2,
160                  "CR_PDS_BGRND3_SIZEINFO cannot be stored in uint64_t");
161    static_assert(ROGUE_NUM_CR_PDS_BGRND_WORDS == 3,
162                  "Cannot store all CR_PDS_BGRND words");
163    uint64_t pds_bgnd_reg_values[ROGUE_NUM_CR_PDS_BGRND_WORDS];
164    uint64_t pds_pr_bgnd_reg_values[ROGUE_NUM_CR_PDS_BGRND_WORDS];
165 };
166 
167 void pvr_rt_mtile_info_init(const struct pvr_device_info *dev_info,
168                             struct pvr_rt_mtile_info *info,
169                             uint32_t width,
170                             uint32_t height,
171                             uint32_t samples);
172 
173 VkResult pvr_free_list_create(struct pvr_device *device,
174                               uint32_t initial_size,
175                               uint32_t max_size,
176                               uint32_t grow_size,
177                               uint32_t grow_threshold,
178                               struct pvr_free_list *parent_free_list,
179                               struct pvr_free_list **const free_list_out);
180 void pvr_free_list_destroy(struct pvr_free_list *free_list);
181 
182 VkResult
183 pvr_render_target_dataset_create(struct pvr_device *device,
184                                  uint32_t width,
185                                  uint32_t height,
186                                  uint32_t samples,
187                                  uint32_t layers,
188                                  struct pvr_rt_dataset **const rt_dataset_out);
189 void pvr_render_target_dataset_destroy(struct pvr_rt_dataset *dataset);
190 
191 VkResult pvr_render_job_submit(struct pvr_render_ctx *ctx,
192                                struct pvr_render_job *job,
193                                struct vk_sync *wait_geom,
194                                struct vk_sync *wait_frag,
195                                struct vk_sync *signal_sync_geom,
196                                struct vk_sync *signal_sync_frag);
197 
198 #endif /* PVR_JOB_RENDER_H */
199