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_limits.h"
33#include "pvr_types.h"
34
35struct pvr_device;
36struct pvr_free_list;
37struct pvr_render_ctx;
38struct pvr_rt_dataset;
39struct pvr_winsys_job_bo;
40struct vk_sync;
41
42/* FIXME: Turn 'struct pvr_sub_cmd' into 'struct pvr_job' and change 'struct
43 * pvr_render_job' to subclass it? This is approximately what v3dv does
44 * (although it doesn't subclass).
45 */
46struct pvr_render_job {
47   struct pvr_rt_dataset *rt_dataset;
48
49   bool run_frag;
50   bool geometry_terminate;
51   bool frag_uses_atomic_ops;
52   bool disable_compute_overlap;
53   bool enable_bg_tag;
54   bool process_empty_tiles;
55
56   uint32_t pds_pixel_event_data_offset;
57
58   pvr_dev_addr_t ctrl_stream_addr;
59
60   pvr_dev_addr_t border_colour_table_addr;
61   pvr_dev_addr_t depth_bias_table_addr;
62   pvr_dev_addr_t scissor_table_addr;
63
64   pvr_dev_addr_t depth_addr;
65   uint32_t depth_stride;
66   uint32_t depth_height;
67   uint32_t depth_physical_width;
68   uint32_t depth_physical_height;
69   uint32_t depth_layer_size;
70   float depth_clear_value;
71   VkFormat depth_vk_format;
72   /* FIXME: This should be of type 'enum pvr_memlayout', but this is defined
73    * in pvr_private.h, which causes a circular include dependency. For now,
74    * treat it has a uint32_t. A couple of ways to possibly fix this:
75    *
76    *   1. Merge the contents of this header file into pvr_private.h.
77    *   2. Move 'enum pvr_memlayout' into it a new header that can be included
78    *      by both this header and pvr_private.h.
79    */
80   uint32_t depth_memlayout;
81
82   pvr_dev_addr_t stencil_addr;
83
84   uint32_t samples;
85
86   uint32_t pixel_output_width;
87
88   uint8_t max_shared_registers;
89
90   /* Upper limit for tiles in flight, '0' means use default limit based
91    * on partition store.
92    */
93   uint32_t max_tiles_in_flight;
94
95   uint64_t pbe_reg_words[PVR_MAX_COLOR_ATTACHMENTS]
96                         [ROGUE_NUM_PBESTATE_REG_WORDS];
97
98   uint64_t pds_bgnd_reg_values[ROGUE_NUM_CR_PDS_BGRND_WORDS];
99};
100
101VkResult pvr_free_list_create(struct pvr_device *device,
102                              uint32_t initial_size,
103                              uint32_t max_size,
104                              uint32_t grow_size,
105                              uint32_t grow_threshold,
106                              struct pvr_free_list *parent_free_list,
107                              struct pvr_free_list **const free_list_out);
108void pvr_free_list_destroy(struct pvr_free_list *free_list);
109
110VkResult
111pvr_render_target_dataset_create(struct pvr_device *device,
112                                 uint32_t width,
113                                 uint32_t height,
114                                 uint32_t samples,
115                                 uint32_t layers,
116                                 struct pvr_rt_dataset **const rt_dataset_out);
117void pvr_render_target_dataset_destroy(struct pvr_rt_dataset *dataset);
118
119VkResult pvr_render_job_submit(struct pvr_render_ctx *ctx,
120                               struct pvr_render_job *job,
121                               const struct pvr_winsys_job_bo *bos,
122                               uint32_t bo_count,
123                               struct vk_sync **waits,
124                               uint32_t wait_count,
125                               uint32_t *stage_flags,
126                               struct vk_sync *signal_sync_geom,
127                               struct vk_sync *signal_sync_frag);
128
129#endif /* PVR_JOB_RENDER_H */
130