| 1 |
/* |
| 2 |
* Copyright © 2022 Imagination Technologies Ltd. |
| 3 |
* |
| 4 |
* based in part on anv driver which is: |
| 5 |
* Copyright © 2015 Intel Corporation |
| 6 |
* |
| 7 |
* based in part on radv driver which is: |
| 8 |
* Copyright © 2016 Red Hat. |
| 9 |
* Copyright © 2016 Bas Nieuwenhuizen |
| 10 |
* |
| 11 |
* SPDX-License-Identifier: MIT |
| 12 |
*/ |
| 13 |
|
| 14 |
#ifndef PVR_PIPELINE_H |
| 15 |
#define PVR_PIPELINE_H |
| 16 |
|
| 17 |
#include "vk_object.h" |
| 18 |
#include "vk_graphics_state.h" |
| 19 |
|
| 20 |
#include "pvr_common.h" |
| 21 |
#include "pvr_csb.h" |
| 22 |
#include "pvr_pds.h" |
| 23 |
#include "util/shader_stats.h" |
| 24 |
|
| 25 |
struct pvr_suballoc_bo; |
| 26 |
|
| 27 |
struct pvr_pipeline_stage_state { |
| 28 |
uint32_t pds_temps_count; |
| 29 |
}; |
| 30 |
|
| 31 |
struct pvr_compute_shader_state { |
| 32 |
/* Pointer to a buffer object that contains the shader binary. */ |
| 33 |
struct pvr_suballoc_bo *shader_bo; |
| 34 |
|
| 35 |
/* Buffer object for the coefficient update shader binary. */ |
| 36 |
struct pvr_suballoc_bo *coeff_update_shader_bo; |
| 37 |
uint32_t coeff_update_shader_temps; |
| 38 |
}; |
| 39 |
|
| 40 |
struct pvr_pds_attrib_program { |
| 41 |
struct pvr_pds_info info; |
| 42 |
/* The uploaded PDS program stored here only contains the code segment, |
| 43 |
* meaning the data size will be 0, unlike the data size stored in the |
| 44 |
* 'info' member above. |
| 45 |
*/ |
| 46 |
struct pvr_pds_upload program; |
| 47 |
}; |
| 48 |
|
| 49 |
struct pvr_stage_allocation_descriptor_state { |
| 50 |
struct pvr_pds_upload pds_code; |
| 51 |
/* Since we upload the code segment separately from the data segment |
| 52 |
* pds_code->data_size might be 0 whilst |
| 53 |
* pds_info->data_size_in_dwords might be >0 in the case of this struct |
| 54 |
* referring to the code upload. |
| 55 |
*/ |
| 56 |
struct pvr_pds_info pds_info; |
| 57 |
|
| 58 |
/* Already setup compile time static consts. */ |
| 59 |
struct pvr_suballoc_bo *static_consts; |
| 60 |
}; |
| 61 |
|
| 62 |
struct pvr_vertex_shader_state { |
| 63 |
/* Pointer to a buffer object that contains the shader binary. */ |
| 64 |
struct pvr_suballoc_bo *shader_bo; |
| 65 |
|
| 66 |
struct pvr_pds_attrib_program |
| 67 |
pds_attrib_programs[PVR_PDS_VERTEX_ATTRIB_PROGRAM_COUNT]; |
| 68 |
|
| 69 |
struct pvr_pipeline_stage_state stage_state; |
| 70 |
/* FIXME: Move this into stage_state? */ |
| 71 |
struct pvr_stage_allocation_descriptor_state descriptor_state; |
| 72 |
}; |
| 73 |
|
| 74 |
struct pvr_fragment_shader_state { |
| 75 |
/* Pointer to a buffer object that contains the shader binary. */ |
| 76 |
struct pvr_suballoc_bo *shader_bo; |
| 77 |
|
| 78 |
struct pvr_pipeline_stage_state stage_state; |
| 79 |
/* FIXME: Move this into stage_state? */ |
| 80 |
struct pvr_stage_allocation_descriptor_state descriptor_state; |
| 81 |
enum ROGUE_TA_PASSTYPE pass_type; |
| 82 |
|
| 83 |
struct pvr_pds_coeff_loading_program pds_coeff_program; |
| 84 |
uint32_t *pds_coeff_program_buffer; |
| 85 |
|
| 86 |
struct pvr_pds_kickusc_program pds_fragment_program; |
| 87 |
uint32_t *pds_fragment_program_buffer; |
| 88 |
|
| 89 |
bool is_passthrough; |
| 90 |
}; |
| 91 |
|
| 92 |
struct pvr_pipeline { |
| 93 |
struct vk_object_base base; |
| 94 |
enum pvr_pipeline_type type; |
| 95 |
struct vk_pipeline_layout *layout; |
| 96 |
VkPipelineCreateFlags2KHR pipeline_flags; |
| 97 |
}; |
| 98 |
|
| 99 |
struct pvr_compute_pipeline { |
| 100 |
struct pvr_pipeline base; |
| 101 |
|
| 102 |
pco_data cs_data; |
| 103 |
|
| 104 |
struct pvr_compute_shader_state shader_state; |
| 105 |
struct pvr_stage_allocation_descriptor_state descriptor_state; |
| 106 |
|
| 107 |
struct pvr_pds_upload pds_cs_program; |
| 108 |
struct pvr_pds_info pds_cs_program_info; |
| 109 |
|
| 110 |
uint32_t *pds_cs_data_section; |
| 111 |
uint32_t base_workgroup_data_patching_offset; |
| 112 |
uint32_t num_workgroups_data_patching_offset; |
| 113 |
uint32_t num_workgroups_indirect_src_patching_offset; |
| 114 |
uint32_t num_workgroups_indirect_src_dma_patching_offset; |
| 115 |
|
| 116 |
/* Debug Info */ |
| 117 |
struct pvr_stats *cs_stats; |
| 118 |
const char *cs_nir_str; |
| 119 |
}; |
| 120 |
|
| 121 |
struct pvr_graphics_pipeline { |
| 122 |
struct pvr_pipeline base; |
| 123 |
|
| 124 |
struct vk_dynamic_graphics_state dynamic_state; |
| 125 |
|
| 126 |
/* Derived and other state */ |
| 127 |
size_t stage_indices[MESA_SHADER_STAGES]; |
| 128 |
|
| 129 |
pco_data vs_data; |
| 130 |
pco_data fs_data; |
| 131 |
|
| 132 |
struct { |
| 133 |
struct pvr_vertex_shader_state vertex; |
| 134 |
struct pvr_fragment_shader_state fragment; |
| 135 |
} shader_state; |
| 136 |
|
| 137 |
/* Debug Info */ |
| 138 |
struct pvr_stats *vs_stats; |
| 139 |
struct pvr_stats *fs_stats; |
| 140 |
|
| 141 |
const char *vs_nir_str; |
| 142 |
const char *fs_nir_str; |
| 143 |
}; |
| 144 |
|
| 145 |
struct pvr_private_compute_pipeline { |
| 146 |
/* Used by pvr_compute_update_kernel_private(). */ |
| 147 |
uint32_t pds_code_offset; |
| 148 |
uint32_t pds_data_offset; |
| 149 |
uint32_t pds_data_size_dw; |
| 150 |
uint32_t pds_temps_used; |
| 151 |
uint32_t coeff_regs_count; |
| 152 |
uint32_t unified_store_regs_count; |
| 153 |
VkExtent3D workgroup_size; |
| 154 |
|
| 155 |
/* Used by pvr_compute_update_shared_private(). */ |
| 156 |
uint32_t pds_shared_update_code_offset; |
| 157 |
uint32_t pds_shared_update_data_offset; |
| 158 |
uint32_t pds_shared_update_data_size_dw; |
| 159 |
|
| 160 |
/* Used by both pvr_compute_update_{kernel,shared}_private(). */ |
| 161 |
uint32_t const_shared_regs_count; |
| 162 |
|
| 163 |
pvr_dev_addr_t const_buffer_addr; |
| 164 |
}; |
| 165 |
|
| 166 |
VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_pipeline, |
| 167 |
base, |
| 168 |
VkPipeline, |
| 169 |
VK_OBJECT_TYPE_PIPELINE) |
| 170 |
|
| 171 |
static inline struct pvr_compute_pipeline * |
| 172 |
to_pvr_compute_pipeline(struct pvr_pipeline *pipeline) |
| 173 |
{ |
| 174 |
assert(pipeline->type == PVR_PIPELINE_TYPE_COMPUTE); |
| 175 |
return container_of(pipeline, struct pvr_compute_pipeline, base); |
| 176 |
} |
| 177 |
|
| 178 |
static inline struct pvr_graphics_pipeline * |
| 179 |
to_pvr_graphics_pipeline(struct pvr_pipeline *pipeline) |
| 180 |
{ |
| 181 |
assert(pipeline->type == PVR_PIPELINE_TYPE_GRAPHICS); |
| 182 |
return container_of(pipeline, struct pvr_graphics_pipeline, base); |
| 183 |
} |
| 184 |
|
| 185 |
static enum pvr_pipeline_stage_bits |
| 186 |
pvr_stage_mask(VkPipelineStageFlags2 stage_mask) |
| 187 |
{ |
| 188 |
enum pvr_pipeline_stage_bits stages = 0; |
| 189 |
|
| 190 |
if (stage_mask & VK_PIPELINE_STAGE_ALL_COMMANDS_BIT) |
| 191 |
return PVR_PIPELINE_STAGE_ALL_BITS; |
| 192 |
|
| 193 |
if (stage_mask & (VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT)) |
| 194 |
stages |= PVR_PIPELINE_STAGE_ALL_GRAPHICS_BITS; |
| 195 |
|
| 196 |
if (stage_mask & (VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | |
| 197 |
VK_PIPELINE_STAGE_VERTEX_INPUT_BIT | |
| 198 |
VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | |
| 199 |
VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT | |
| 200 |
VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT | |
| 201 |
VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT)) { |
| 202 |
stages |= PVR_PIPELINE_STAGE_GEOM_BIT; |
| 203 |
} |
| 204 |
|
| 205 |
if (stage_mask & (VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | |
| 206 |
VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | |
| 207 |
VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | |
| 208 |
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT)) { |
| 209 |
stages |= PVR_PIPELINE_STAGE_FRAG_BIT; |
| 210 |
} |
| 211 |
|
| 212 |
if (stage_mask & (VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | |
| 213 |
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT)) { |
| 214 |
stages |= PVR_PIPELINE_STAGE_COMPUTE_BIT; |
| 215 |
} |
| 216 |
|
| 217 |
if (stage_mask & (VK_PIPELINE_STAGE_TRANSFER_BIT)) |
| 218 |
stages |= PVR_PIPELINE_STAGE_TRANSFER_BIT; |
| 219 |
|
| 220 |
return stages; |
| 221 |
} |
| 222 |
|
| 223 |
static inline enum pvr_pipeline_stage_bits |
| 224 |
pvr_stage_mask_src(VkPipelineStageFlags2 stage_mask) |
| 225 |
{ |
| 226 |
/* If the source is bottom of pipe, all stages will need to be waited for. */ |
| 227 |
if (stage_mask & VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT) |
| 228 |
return PVR_PIPELINE_STAGE_ALL_BITS; |
| 229 |
|
| 230 |
return pvr_stage_mask(stage_mask); |
| 231 |
} |
| 232 |
|
| 233 |
static inline enum pvr_pipeline_stage_bits |
| 234 |
pvr_stage_mask_dst(VkPipelineStageFlags2 stage_mask) |
| 235 |
{ |
| 236 |
/* If the destination is top of pipe, all stages should be blocked by prior |
| 237 |
* commands. |
| 238 |
*/ |
| 239 |
if (stage_mask & VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT) |
| 240 |
return PVR_PIPELINE_STAGE_ALL_BITS; |
| 241 |
|
| 242 |
return pvr_stage_mask(stage_mask); |
| 243 |
} |
| 244 |
|
| 245 |
#endif /* PVR_PIPELINE_H */ |