| 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_PDS_H |
| 25 |
#define PVR_PDS_H |
| 26 |
|
| 27 |
#include <stdbool.h> |
| 28 |
#include <stdint.h> |
| 29 |
|
| 30 |
#include "pvr_device_info.h" |
| 31 |
#include "pvr_limits.h" |
| 32 |
#include "pds/pvr_rogue_pds_defs.h" |
| 33 |
#include "util/bitset.h" |
| 34 |
#include "util/macros.h" |
| 35 |
|
| 36 |
#ifdef __cplusplus |
| 37 |
# define restrict __restrict__ |
| 38 |
#endif |
| 39 |
|
| 40 |
/***************************************************************************** |
| 41 |
Macro definitions |
| 42 |
*****************************************************************************/ |
| 43 |
|
| 44 |
/* Based on Maximum number of passes that may emit DOUTW x Maximum number that |
| 45 |
* might be emitted. |
| 46 |
*/ |
| 47 |
#define PVR_PDS_MAX_TOTAL_NUM_DWORD_DOUTW 6 |
| 48 |
/* Based on Maximum number of passes that may emit DOUTW x Maximum number that |
| 49 |
* might be emitted. |
| 50 |
*/ |
| 51 |
#define PVR_PDS_MAX_TOTAL_NUM_QWORD_DOUTW 3 |
| 52 |
/* Based on max(max(UBOs,cbuffers), numTextures). */ |
| 53 |
#define PVR_PDS_MAX_NUM_DMA_KICKS 32 |
| 54 |
#define PVR_PDS_NUM_VERTEX_STREAMS 32 |
| 55 |
#define PVR_PDS_NUM_VERTEX_ELEMENTS 32 |
| 56 |
#define PVR_MAXIMUM_ITERATIONS 128 |
| 57 |
|
| 58 |
#define PVR_PDS_NUM_COMPUTE_INPUT_REGS 3 |
| 59 |
|
| 60 |
#define PVR_NEED_SW_COMPUTE_PDS_BARRIER(dev_info) \ |
| 61 |
PVR_HAS_FEATURE(dev_info, compute_morton_capable) && \ |
| 62 |
!PVR_HAS_ENHANCEMENT(dev_info, 45493) |
| 63 |
|
| 64 |
/* FIXME: Change BIL to SPV. */ |
| 65 |
/* Any variable location can have at most 4 32-bit components. */ |
| 66 |
#define BIL_COMPONENTS_PER_LOCATION 4 |
| 67 |
|
| 68 |
/* Maximum number of DDMAD's that may be performed (Num attribs * Num DMA's per |
| 69 |
* attribute). |
| 70 |
*/ |
| 71 |
#define PVR_MAX_VERTEX_ATTRIB_DMAS \ |
| 72 |
(PVR_MAX_VERTEX_INPUT_BINDINGS * BIL_COMPONENTS_PER_LOCATION) |
| 73 |
|
| 74 |
/***************************************************************************** |
| 75 |
Typedefs |
| 76 |
*****************************************************************************/ |
| 77 |
|
| 78 |
/* FIXME: We might need to change some bools to this. */ |
| 79 |
typedef uint32_t PVR_PDS_BOOL; |
| 80 |
|
| 81 |
/***************************************************************************** |
| 82 |
Enums |
| 83 |
*****************************************************************************/ |
| 84 |
|
| 85 |
enum pvr_pds_generate_mode { |
| 86 |
PDS_GENERATE_SIZES, |
| 87 |
PDS_GENERATE_CODE_SEGMENT, |
| 88 |
PDS_GENERATE_DATA_SEGMENT, |
| 89 |
PDS_GENERATE_CODEDATA_SEGMENTS |
| 90 |
}; |
| 91 |
|
| 92 |
enum pvr_pds_store_type { PDS_COMMON_STORE, PDS_UNIFIED_STORE }; |
| 93 |
|
| 94 |
enum pvr_pds_vertex_attrib_program_type { |
| 95 |
PVR_PDS_VERTEX_ATTRIB_PROGRAM_BASIC, |
| 96 |
PVR_PDS_VERTEX_ATTRIB_PROGRAM_BASE_INSTANCE, |
| 97 |
PVR_PDS_VERTEX_ATTRIB_PROGRAM_DRAW_INDIRECT, |
| 98 |
PVR_PDS_VERTEX_ATTRIB_PROGRAM_COUNT |
| 99 |
}; |
| 100 |
|
| 101 |
/***************************************************************************** |
| 102 |
Structure definitions |
| 103 |
*****************************************************************************/ |
| 104 |
|
| 105 |
struct pvr_psc_register { |
| 106 |
uint32_t num; |
| 107 |
|
| 108 |
unsigned int size; /* size of each element. */ |
| 109 |
unsigned int dim : 4; /* max number of elements. */ |
| 110 |
unsigned int index; /* offset into array. */ |
| 111 |
|
| 112 |
unsigned int cast; |
| 113 |
|
| 114 |
unsigned int type; |
| 115 |
uint64_t name; |
| 116 |
bool auto_assign; |
| 117 |
unsigned int original_type; |
| 118 |
}; |
| 119 |
|
| 120 |
struct pvr_psc_program_output { |
| 121 |
const uint32_t *code; |
| 122 |
|
| 123 |
struct pvr_psc_register *data; |
| 124 |
unsigned int data_count; |
| 125 |
|
| 126 |
unsigned int data_size_aligned; |
| 127 |
unsigned int code_size_aligned; |
| 128 |
unsigned int temp_size_aligned; |
| 129 |
|
| 130 |
unsigned int data_size; |
| 131 |
unsigned int code_size; |
| 132 |
unsigned int temp_size; |
| 133 |
|
| 134 |
void (*write_data)(void *data, uint32_t *buffer); |
| 135 |
}; |
| 136 |
|
| 137 |
struct pvr_pds_usc_task_control { |
| 138 |
uint64_t src0; |
| 139 |
}; |
| 140 |
|
| 141 |
/* Up to 4 64-bit state words currently supported. */ |
| 142 |
#define PVR_PDS_MAX_NUM_DOUTW_CONSTANTS 4 |
| 143 |
|
| 144 |
/* Structure for DOUTW. */ |
| 145 |
struct pvr_pds_doutw_control { |
| 146 |
enum pvr_pds_store_type dest_store; |
| 147 |
uint32_t num_const64; |
| 148 |
uint64_t doutw_data[PVR_PDS_MAX_NUM_DOUTW_CONSTANTS]; |
| 149 |
bool last_instruction; |
| 150 |
|
| 151 |
uint32_t *data_segment; |
| 152 |
uint32_t data_size; |
| 153 |
uint32_t code_size; |
| 154 |
}; |
| 155 |
|
| 156 |
/* Structure representing the PDS pixel event program. |
| 157 |
* |
| 158 |
* data_segment - pointer to the data segment |
| 159 |
* task_control - USC task control words |
| 160 |
* emit_words - array of Emit words |
| 161 |
* data_size - size of data segment |
| 162 |
* code_size - size of code segment |
| 163 |
*/ |
| 164 |
struct pvr_pds_event_program { |
| 165 |
uint32_t *data_segment; |
| 166 |
struct pvr_pds_usc_task_control task_control; |
| 167 |
|
| 168 |
uint32_t num_emit_word_pairs; |
| 169 |
uint32_t *emit_words; |
| 170 |
|
| 171 |
uint32_t data_size; |
| 172 |
uint32_t code_size; |
| 173 |
}; |
| 174 |
|
| 175 |
/* |
| 176 |
* Structure representing the PDS pixel shader secondary attribute program. |
| 177 |
* |
| 178 |
* data_segment - pointer to the data segment |
| 179 |
* |
| 180 |
* num_uniform_dma_kicks - number of Uniform DMA kicks |
| 181 |
* uniform_dma_control - array of Uniform DMA control words |
| 182 |
* uniform_dma_address - array of Uniform DMA address words |
| 183 |
* |
| 184 |
* num_texture_dma_kicks - number of Texture State DMA kicks |
| 185 |
* texture_dma_control - array of Texture State DMA control words |
| 186 |
* texture_dma_address - array of Texture State DMA address words |
| 187 |
* |
| 188 |
* data_size - size of data segment |
| 189 |
* code_size - size of code segment |
| 190 |
* |
| 191 |
* temps_used - PDS Temps |
| 192 |
*/ |
| 193 |
struct pvr_pds_pixel_shader_sa_program { |
| 194 |
uint32_t *data_segment; |
| 195 |
|
| 196 |
uint32_t num_dword_doutw; |
| 197 |
uint32_t dword_doutw_value[PVR_PDS_MAX_TOTAL_NUM_DWORD_DOUTW]; |
| 198 |
uint32_t dword_doutw_control[PVR_PDS_MAX_TOTAL_NUM_DWORD_DOUTW]; |
| 199 |
|
| 200 |
uint32_t num_q_word_doutw; |
| 201 |
uint32_t q_word_doutw_value[2 * PVR_PDS_MAX_TOTAL_NUM_QWORD_DOUTW]; |
| 202 |
uint32_t q_word_doutw_control[PVR_PDS_MAX_TOTAL_NUM_QWORD_DOUTW]; |
| 203 |
|
| 204 |
uint32_t num_uniform_dma_kicks; |
| 205 |
uint64_t uniform_dma_address[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 206 |
uint32_t uniform_dma_control[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 207 |
|
| 208 |
uint32_t num_texture_dma_kicks; |
| 209 |
uint64_t texture_dma_address[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 210 |
uint32_t texture_dma_control[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 211 |
|
| 212 |
bool kick_usc; |
| 213 |
bool write_tile_position; |
| 214 |
uint32_t tile_position_attr_dest; |
| 215 |
struct pvr_pds_usc_task_control usc_task_control; |
| 216 |
|
| 217 |
bool clear; |
| 218 |
uint32_t *clear_color; |
| 219 |
uint32_t clear_color_dest_reg; |
| 220 |
bool packed_clear; |
| 221 |
|
| 222 |
uint32_t data_size; |
| 223 |
uint32_t code_size; |
| 224 |
|
| 225 |
uint32_t temps_used; |
| 226 |
}; |
| 227 |
|
| 228 |
/* Structure representing the PDS pixel shader program. |
| 229 |
* |
| 230 |
* data_segment - pointer to the data segment |
| 231 |
* usc_task_control - array of USC task control words |
| 232 |
* |
| 233 |
* data_size - size of data segment |
| 234 |
* code_size - size of code segment |
| 235 |
*/ |
| 236 |
struct pvr_pds_kickusc_program { |
| 237 |
uint32_t *data_segment; |
| 238 |
struct pvr_pds_usc_task_control usc_task_control; |
| 239 |
|
| 240 |
uint32_t doutu_offset; |
| 241 |
|
| 242 |
uint32_t data_size; |
| 243 |
uint32_t code_size; |
| 244 |
}; |
| 245 |
|
| 246 |
/* Structure representing the PDS fence/doutc program. |
| 247 |
* |
| 248 |
* data_segment - pointer to the data segment |
| 249 |
* data_size - size of data segment |
| 250 |
* code_size - size of code segment |
| 251 |
*/ |
| 252 |
struct pvr_pds_fence_program { |
| 253 |
uint32_t *data_segment; |
| 254 |
uint32_t fence_constant_word; |
| 255 |
uint32_t data_size; |
| 256 |
uint32_t code_size; |
| 257 |
}; |
| 258 |
|
| 259 |
/* Structure representing the PDS coefficient loading. |
| 260 |
* |
| 261 |
* data_segment - pointer to the data segment |
| 262 |
* num_fpu_iterators - number of FPU iterators |
| 263 |
* FPU_iterators - array of FPU iterator control words |
| 264 |
* destination - array of Common Store destinations |
| 265 |
* |
| 266 |
* data_size - size of data segment |
| 267 |
* code_size - size of code segment |
| 268 |
*/ |
| 269 |
struct pvr_pds_coeff_loading_program { |
| 270 |
uint32_t *data_segment; |
| 271 |
uint32_t num_fpu_iterators; |
| 272 |
uint32_t FPU_iterators[PVR_MAXIMUM_ITERATIONS]; |
| 273 |
uint32_t destination[PVR_MAXIMUM_ITERATIONS]; |
| 274 |
|
| 275 |
BITSET_DECLARE(flat_iter_mask, PVR_MAXIMUM_ITERATIONS); |
| 276 |
uint32_t dout_src_offsets[PVR_MAXIMUM_ITERATIONS]; |
| 277 |
|
| 278 |
uint32_t z_iterator; |
| 279 |
uint32_t dout_z_iterator_offset; |
| 280 |
|
| 281 |
uint32_t data_size; |
| 282 |
uint32_t code_size; |
| 283 |
|
| 284 |
uint32_t temps_used; |
| 285 |
}; |
| 286 |
|
| 287 |
/* Structure representing the PDS vertex shader secondary attribute program. |
| 288 |
* |
| 289 |
* data_segment - pointer to the data segment |
| 290 |
* num_dma_kicks - number of DMA kicks |
| 291 |
* dma_control - array of DMA control words |
| 292 |
* dma_address - array of DMA address words |
| 293 |
* |
| 294 |
* data_size - size of data segment |
| 295 |
* code_size - size of code segment |
| 296 |
*/ |
| 297 |
struct pvr_pds_vertex_shader_sa_program { |
| 298 |
uint32_t *data_segment; |
| 299 |
|
| 300 |
/* num_uniform_dma_kicks, uniform_dma_address, uniform_dma_control, are not |
| 301 |
* used for generating PDS data section and code section, they are currently |
| 302 |
* only used to simpler the driver implementation. The driver should correct |
| 303 |
* these information into num_dma_kicks, dma_address and dma_control to get |
| 304 |
* the PDS properly generated. |
| 305 |
*/ |
| 306 |
|
| 307 |
uint32_t num_dword_doutw; |
| 308 |
uint32_t dword_doutw_value[PVR_PDS_MAX_TOTAL_NUM_DWORD_DOUTW]; |
| 309 |
uint32_t dword_doutw_control[PVR_PDS_MAX_TOTAL_NUM_DWORD_DOUTW]; |
| 310 |
|
| 311 |
uint32_t num_q_word_doutw; |
| 312 |
uint32_t q_word_doutw_value[2 * PVR_PDS_MAX_TOTAL_NUM_QWORD_DOUTW]; |
| 313 |
uint32_t q_word_doutw_control[PVR_PDS_MAX_TOTAL_NUM_QWORD_DOUTW]; |
| 314 |
|
| 315 |
uint32_t num_uniform_dma_kicks; |
| 316 |
uint64_t uniform_dma_address[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 317 |
uint32_t uniform_dma_control[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 318 |
|
| 319 |
uint32_t num_texture_dma_kicks; |
| 320 |
uint64_t texture_dma_address[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 321 |
uint32_t texture_dma_control[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 322 |
|
| 323 |
uint32_t num_dma_kicks; |
| 324 |
uint64_t dma_address[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 325 |
uint32_t dma_control[PVR_PDS_MAX_NUM_DMA_KICKS]; |
| 326 |
|
| 327 |
bool kick_usc; |
| 328 |
struct pvr_pds_usc_task_control usc_task_control; |
| 329 |
|
| 330 |
/* Shared register buffer base address (VDM/CDM context load case only). */ |
| 331 |
bool clear_pds_barrier; |
| 332 |
|
| 333 |
uint32_t data_size; |
| 334 |
uint32_t code_size; |
| 335 |
}; |
| 336 |
|
| 337 |
/* Structure representing a PDS vertex stream element. |
| 338 |
* |
| 339 |
* There are two types of element, repeat DMA and non-repeat DMA. |
| 340 |
* |
| 341 |
* Non repeat DMA are the classic DMA of some number of bytes from an offset |
| 342 |
* into contiguous registers. It is assumed the address and size are dword |
| 343 |
* aligned. To use this, specify 0 for the component size. Each four bytes read |
| 344 |
* will go to the next HW register. |
| 345 |
* |
| 346 |
* Repeat DMA enables copying of sub dword amounts at non dword aligned |
| 347 |
* addresses. To use this, specify the component size as either 1,2,3 or 4 |
| 348 |
* bytes. Size specifies the number of components, and each component read |
| 349 |
* will go to the next HW register. |
| 350 |
* |
| 351 |
* In both cases, HW registers are written contiguously. |
| 352 |
* |
| 353 |
* offset - offset of the vertex stream element |
| 354 |
* size - size of the vertex stream element in bytes for non repeat DMA, or |
| 355 |
* number of components for repeat DMA. |
| 356 |
* reg - first vertex stream element register to DMA to. |
| 357 |
* component_size - Size of component for repeat DMA, or 0 for non repeat dma. |
| 358 |
*/ |
| 359 |
struct pvr_pds_vertex_element { |
| 360 |
uint32_t offset; |
| 361 |
uint32_t size; |
| 362 |
uint16_t reg; |
| 363 |
uint16_t component_size; |
| 364 |
}; |
| 365 |
|
| 366 |
/* Structure representing a PDS vertex stream. |
| 367 |
* |
| 368 |
* instance_data - flag whether the vertex stream is indexed or instance data |
| 369 |
* read_back - If True, vertex is reading back data output by GPU earlier in |
| 370 |
* same kick. This will enable MCU coherency if relevant. |
| 371 |
* multiplier - vertex stream frequency multiplier |
| 372 |
* shift - vertex stream frequency shift |
| 373 |
* address - vertex stream address in bytes |
| 374 |
* buffer_size_in_bytes - buffer size in bytes if vertex attribute is sourced |
| 375 |
* from buffer object |
| 376 |
* stride - vertex stream stride in bytes |
| 377 |
* num_vertices - number of vertices in buffer. Used for OOB checking. |
| 378 |
- 0 = disable oob checking. |
| 379 |
* num_elements - number of vertex stream elements |
| 380 |
* elements - array of vertex stream elements |
| 381 |
* use_ddmadt - When the has_pds_ddmadt feature is enabled. Boolean allowing |
| 382 |
* DDMADT to be use per stream element. |
| 383 |
*/ |
| 384 |
struct pvr_pds_vertex_stream { |
| 385 |
bool current_state; |
| 386 |
bool instance_data; |
| 387 |
bool read_back; |
| 388 |
uint32_t multiplier; |
| 389 |
uint32_t shift; |
| 390 |
uint64_t address; |
| 391 |
uint32_t buffer_size_in_bytes; |
| 392 |
uint32_t stride; |
| 393 |
uint32_t num_vertices; |
| 394 |
uint32_t num_elements; |
| 395 |
struct pvr_pds_vertex_element elements[PVR_PDS_NUM_VERTEX_ELEMENTS]; |
| 396 |
|
| 397 |
bool use_ddmadt; |
| 398 |
}; |
| 399 |
|
| 400 |
/* Structure representing the PDS vertex shader program. |
| 401 |
* |
| 402 |
* This structure describes the USC code and vertex buffers required |
| 403 |
* by the PDS vertex loading program. |
| 404 |
* |
| 405 |
* data_segment - Pointer to the data segment. |
| 406 |
* usc_task_control - Description of USC task for vertex shader program. |
| 407 |
* num_streams - Number of vertex streams. |
| 408 |
* iterate_vtx_id - If set, the vertex id should be iterated. |
| 409 |
* vtx_id_register - The register to iterate the VertexID into (if applicable) |
| 410 |
* vtx_id_modifier - Value to pvr_add/SUB from index value received by PDS. |
| 411 |
* This is used because the index value received by PDS has |
| 412 |
* INDEX_OFFSET added, and generally VertexID wouldn't. |
| 413 |
* vtx_id_sub_modifier - If true, vtx_id_modifier is subtracted, else added. |
| 414 |
* iterate_instance_id - If set, the instance id should be iterated. |
| 415 |
* instance_id_register - The register to iterate the InstanceID into (if |
| 416 |
* applicable). The vertex and instance id will both be |
| 417 |
* iterated as unsigned ints |
| 418 |
* |
| 419 |
* iterate_remap_id - Should be set to true if vertex shader needs |
| 420 |
* VS_REMAPPED_INDEX_ID (e.g. Another TA shader runs after |
| 421 |
* it). |
| 422 |
* null_idx - Indicates no index buffer is bound, so every index should be |
| 423 |
* null_idx_value. |
| 424 |
* null_idx_value - The value to use as index if null_idx set. |
| 425 |
* data_size - Size of data segment, in dwords. Output by call to |
| 426 |
* pvr_pds_vertex_shader, and used as input when generating data. |
| 427 |
* code_size - Size of code segment. Output by call to pvr_pds_vertex_shader. |
| 428 |
* This is the number of dword instructions that are/were generated. |
| 429 |
* temps_used - Number of temporaries used. Output by call to |
| 430 |
* pvr_pds_vertex_shader. |
| 431 |
*/ |
| 432 |
struct pvr_pds_vertex_shader_program { |
| 433 |
uint32_t *data_segment; |
| 434 |
struct pvr_pds_usc_task_control usc_task_control; |
| 435 |
uint32_t num_streams; |
| 436 |
|
| 437 |
bool iterate_vtx_id; |
| 438 |
uint32_t vtx_id_register; |
| 439 |
uint32_t vtx_id_modifier; |
| 440 |
bool vtx_id_sub_modifier; |
| 441 |
|
| 442 |
bool iterate_instance_id; |
| 443 |
uint32_t instance_id_register; |
| 444 |
uint32_t instance_id_modifier; |
| 445 |
uint32_t base_instance; |
| 446 |
|
| 447 |
bool iterate_remap_id; |
| 448 |
|
| 449 |
bool null_idx; |
| 450 |
uint32_t null_idx_value; |
| 451 |
|
| 452 |
uint32_t *stream_patch_offsets; |
| 453 |
uint32_t num_stream_patches; |
| 454 |
|
| 455 |
uint32_t data_size; |
| 456 |
uint32_t code_size; |
| 457 |
uint32_t temps_used; |
| 458 |
uint32_t ddmadt_enables; |
| 459 |
uint32_t skip_stream_flag; |
| 460 |
|
| 461 |
bool draw_indirect; |
| 462 |
bool indexed; |
| 463 |
|
| 464 |
struct pvr_pds_vertex_stream streams[PVR_PDS_NUM_VERTEX_STREAMS]; |
| 465 |
}; |
| 466 |
|
| 467 |
/* Structure representing PDS shared reg storing program. */ |
| 468 |
struct pvr_pds_shared_storing_program { |
| 469 |
struct pvr_pds_doutw_control doutw_control; /*!< DOUTW state */ |
| 470 |
struct pvr_pds_kickusc_program usc_task; /*!< DOUTU state */ |
| 471 |
bool cc_enable; /*!< cc bit is set on the doutu instruction. */ |
| 472 |
uint32_t data_size; /*!< total data size, non-aligned. */ |
| 473 |
uint32_t code_size; /*!< total code size, non-aligned. */ |
| 474 |
}; |
| 475 |
|
| 476 |
#define PVR_MAX_STREAMOUT_BUFFERS 4 |
| 477 |
|
| 478 |
/* Structure representing stream out init PDS programs. */ |
| 479 |
struct pvr_pds_stream_out_init_program { |
| 480 |
/* --- Input to PDS_STREAM_OUT_INT_PROGRAM --- */ |
| 481 |
|
| 482 |
/* Number of buffers to load/store. |
| 483 |
* This indicates the number of entries in the next two arrays. |
| 484 |
* Data is loaded/stored contiguously to persistent temps. |
| 485 |
*/ |
| 486 |
uint32_t num_buffers; |
| 487 |
|
| 488 |
/* Number of persistent temps in dword to load/store for each buffer. */ |
| 489 |
uint32_t pds_buffer_data_size[PVR_MAX_STREAMOUT_BUFFERS]; |
| 490 |
/* The device address for loading/storing persistent temps for each buffer. |
| 491 |
* If address is zero, then no data is loaded/stored |
| 492 |
* into pt registers for the buffer. |
| 493 |
*/ |
| 494 |
uint64_t dev_address_for_buffer_data[PVR_MAX_STREAMOUT_BUFFERS]; |
| 495 |
|
| 496 |
/* PDS state update Stream Out Init Programs. */ |
| 497 |
uint32_t stream_out_init_pds_data_size; |
| 498 |
uint32_t stream_out_init_pds_code_size; |
| 499 |
}; |
| 500 |
|
| 501 |
/* Structure representing stream out terminate PDS program. */ |
| 502 |
struct pvr_pds_stream_out_terminate_program { |
| 503 |
/* Input to PDS_STREAM_OUT_TERMINATE_PROGRAM. |
| 504 |
* |
| 505 |
* Number of persistent temps in dword used in stream out PDS programs needs |
| 506 |
* to be stored. |
| 507 |
* The terminate program writes pds_persistent_temp_size_to_store number |
| 508 |
* persistent temps to dev_address_for_storing_persistent_temp. |
| 509 |
*/ |
| 510 |
uint32_t pds_persistent_temp_size_to_store; |
| 511 |
|
| 512 |
/* The device address for storing persistent temps. */ |
| 513 |
uint64_t dev_address_for_storing_persistent_temp; |
| 514 |
|
| 515 |
/* PPP state update Stream Out Program for stream out terminate. */ |
| 516 |
uint32_t stream_out_terminate_pds_data_size; |
| 517 |
uint32_t stream_out_terminate_pds_code_size; |
| 518 |
}; |
| 519 |
|
| 520 |
struct pvr_pds_view_index_init_program { |
| 521 |
uint16_t view_index; |
| 522 |
|
| 523 |
uint32_t data_size; |
| 524 |
uint32_t code_size; |
| 525 |
uint32_t temps_used; |
| 526 |
}; |
| 527 |
|
| 528 |
/* Structure representing the PDS compute shader program. |
| 529 |
* This structure describes the USC code and compute buffers required |
| 530 |
* by the PDS compute task loading program |
| 531 |
* |
| 532 |
* data_segment |
| 533 |
* pointer to the data segment |
| 534 |
* usc_task_control |
| 535 |
* Description of USC task for compute shader program. |
| 536 |
* data_size |
| 537 |
* Size of data segment, in dwords. |
| 538 |
* Output by call to pvr_pds_compute_shader, and used as input when |
| 539 |
* generating data. code_size Size of code segment. Output by call to |
| 540 |
* pvr_pds_compute_shader. This is the number of dword instructions that |
| 541 |
* are/were generated. temps_used Number of temporaries used. Output by call |
| 542 |
*to pvr_pds_compute_shader. highest_temp The highest temp number used. Output |
| 543 |
*by call to pvr_pds_compute_shader coeff_update_task_branch_size The number of |
| 544 |
* instructions we need to branch over to skip the coefficient update task. |
| 545 |
*/ |
| 546 |
|
| 547 |
struct pvr_pds_compute_shader_program { |
| 548 |
uint32_t *data_segment; |
| 549 |
struct pvr_pds_usc_task_control usc_task_control; |
| 550 |
struct pvr_pds_usc_task_control usc_task_control_coeff_update; |
| 551 |
|
| 552 |
uint32_t data_size; |
| 553 |
uint32_t code_size; |
| 554 |
|
| 555 |
uint32_t temps_used; |
| 556 |
uint32_t highest_temp; |
| 557 |
|
| 558 |
uint32_t local_input_regs[3]; |
| 559 |
uint32_t work_group_input_regs[3]; |
| 560 |
uint32_t num_work_groups_regs[3]; |
| 561 |
uint32_t global_input_regs[3]; |
| 562 |
|
| 563 |
uint32_t barrier_coefficient; |
| 564 |
|
| 565 |
bool fence; |
| 566 |
|
| 567 |
bool flattened_work_groups; |
| 568 |
|
| 569 |
bool clear_pds_barrier; |
| 570 |
|
| 571 |
bool has_coefficient_update_task; |
| 572 |
|
| 573 |
uint32_t coeff_update_task_branch_size; |
| 574 |
|
| 575 |
uint32_t base_workgroup_constant_offset_in_dwords[3]; |
| 576 |
uint32_t num_workgroups_constant_offset_in_dwords[3]; |
| 577 |
|
| 578 |
uint32_t num_workgroups_indirect_src; |
| 579 |
uint32_t num_workgroups_indirect_src_dma; |
| 580 |
bool kick_usc; |
| 581 |
|
| 582 |
bool conditional_render; |
| 583 |
uint32_t cond_render_const_offset_in_dwords; |
| 584 |
uint32_t cond_render_pred_temp; |
| 585 |
}; |
| 586 |
struct pvr_pds_ldst_control { |
| 587 |
uint64_t cache_control_const; |
| 588 |
}; |
| 589 |
|
| 590 |
/* Define a value we can use as a register number in the driver to denote that |
| 591 |
* the value is unused. |
| 592 |
*/ |
| 593 |
#define PVR_PDS_REG_UNUSED 0xFFFFFFFFU |
| 594 |
|
| 595 |
static inline void pvr_pds_compute_shader_program_init( |
| 596 |
struct pvr_pds_compute_shader_program *program) |
| 597 |
{ |
| 598 |
*program = (struct pvr_pds_compute_shader_program){ |
| 599 |
.local_input_regs = { |
| 600 |
PVR_PDS_REG_UNUSED, |
| 601 |
PVR_PDS_REG_UNUSED, |
| 602 |
PVR_PDS_REG_UNUSED, |
| 603 |
}, |
| 604 |
.work_group_input_regs = { |
| 605 |
PVR_PDS_REG_UNUSED, |
| 606 |
PVR_PDS_REG_UNUSED, |
| 607 |
PVR_PDS_REG_UNUSED, |
| 608 |
}, |
| 609 |
.num_work_groups_regs = { |
| 610 |
PVR_PDS_REG_UNUSED, |
| 611 |
PVR_PDS_REG_UNUSED, |
| 612 |
PVR_PDS_REG_UNUSED, |
| 613 |
}, |
| 614 |
.global_input_regs = { |
| 615 |
PVR_PDS_REG_UNUSED, |
| 616 |
PVR_PDS_REG_UNUSED, |
| 617 |
PVR_PDS_REG_UNUSED, |
| 618 |
}, |
| 619 |
.barrier_coefficient = PVR_PDS_REG_UNUSED, |
| 620 |
}; |
| 621 |
} |
| 622 |
|
| 623 |
/***************************************************************************** |
| 624 |
function declarations |
| 625 |
*****************************************************************************/ |
| 626 |
|
| 627 |
/***************************************************************************** |
| 628 |
Constructors |
| 629 |
*****************************************************************************/ |
| 630 |
|
| 631 |
void pvr_pds_pixel_shader_sa_initialize( |
| 632 |
struct pvr_pds_pixel_shader_sa_program *program); |
| 633 |
void pvr_pds_compute_shader_initialize( |
| 634 |
struct pvr_pds_compute_shader_program *program); |
| 635 |
|
| 636 |
/* Utility */ |
| 637 |
|
| 638 |
uint32_t pvr_pds_append_constant64(uint32_t *constants, |
| 639 |
uint64_t constant_value, |
| 640 |
uint32_t *data_size); |
| 641 |
|
| 642 |
uint32_t pvr_pds_encode_dma_burst(uint32_t *dma_control, |
| 643 |
uint64_t *dma_address, |
| 644 |
uint32_t dest_offset, |
| 645 |
uint32_t dma_size, |
| 646 |
uint64_t src_address, |
| 647 |
bool last, |
| 648 |
const struct pvr_device_info *dev_info); |
| 649 |
|
| 650 |
void pvr_pds_setup_doutu(struct pvr_pds_usc_task_control *usc_task_control, |
| 651 |
uint64_t execution_address, |
| 652 |
uint32_t usc_temps, |
| 653 |
uint32_t sample_rate, |
| 654 |
bool phase_rate_change); |
| 655 |
|
| 656 |
/* Pixel */ |
| 657 |
#define pvr_pds_set_sizes_pixel_shader(X) \ |
| 658 |
pvr_pds_kick_usc(X, NULL, 0, false, PDS_GENERATE_SIZES) |
| 659 |
#define pvr_pds_generate_pixel_shader_program(X, Y) \ |
| 660 |
pvr_pds_kick_usc(X, Y, 0, false, PDS_GENERATE_CODEDATA_SEGMENTS) |
| 661 |
|
| 662 |
#define pvr_pds_generate_VDM_sync_program(X, Y) \ |
| 663 |
pvr_pds_kick_usc(X, Y, 0, false, PDS_GENERATE_CODEDATA_SEGMENTS) |
| 664 |
|
| 665 |
uint32_t *pvr_pds_generate_doutc(struct pvr_pds_fence_program *restrict program, |
| 666 |
uint32_t *restrict buffer, |
| 667 |
enum pvr_pds_generate_mode gen_mode); |
| 668 |
|
| 669 |
uint32_t * |
| 670 |
pvr_pds_generate_doutw(struct pvr_pds_doutw_control *restrict psControl, |
| 671 |
uint32_t *restrict buffer, |
| 672 |
enum pvr_pds_generate_mode gen_mode, |
| 673 |
const struct pvr_device_info *dev_info); |
| 674 |
|
| 675 |
uint32_t *pvr_pds_kick_usc(struct pvr_pds_kickusc_program *restrict program, |
| 676 |
uint32_t *restrict buffer, |
| 677 |
uint32_t start_next_constant, |
| 678 |
bool cc_enabled, |
| 679 |
enum pvr_pds_generate_mode gen_mode); |
| 680 |
|
| 681 |
/* Pixel Secondary */ |
| 682 |
#define pvr_pds_set_sizes_pixel_shader_sa_uniform_data(X, Y) \ |
| 683 |
pvr_pds_pixel_shader_uniform_texture_data(X, \ |
| 684 |
NULL, \ |
| 685 |
PDS_GENERATE_SIZES, \ |
| 686 |
true, \ |
| 687 |
Y) |
| 688 |
#define pvr_pds_set_sizes_pixel_shader_sa_texture_data(X, Y) \ |
| 689 |
pvr_pds_pixel_shader_uniform_texture_data(X, \ |
| 690 |
NULL, \ |
| 691 |
PDS_GENERATE_SIZES, \ |
| 692 |
false, \ |
| 693 |
Y) |
| 694 |
#define pvr_pds_set_sizes_pixel_shader_uniform_texture_code(X) \ |
| 695 |
pvr_pds_pixel_shader_uniform_texture_code(X, NULL, PDS_GENERATE_SIZES) |
| 696 |
|
| 697 |
#define pvr_pds_generate_pixel_shader_sa_texture_state_data(X, Y, Z) \ |
| 698 |
pvr_pds_pixel_shader_uniform_texture_data(X, \ |
| 699 |
Y, \ |
| 700 |
PDS_GENERATE_DATA_SEGMENT, \ |
| 701 |
false, \ |
| 702 |
Z) |
| 703 |
|
| 704 |
#define pvr_pds_generate_pixel_shader_sa_code_segment(X, Y) \ |
| 705 |
pvr_pds_pixel_shader_uniform_texture_code(X, Y, PDS_GENERATE_CODE_SEGMENT) |
| 706 |
|
| 707 |
uint32_t *pvr_pds_pixel_shader_uniform_texture_data( |
| 708 |
struct pvr_pds_pixel_shader_sa_program *restrict program, |
| 709 |
uint32_t *restrict buffer, |
| 710 |
enum pvr_pds_generate_mode gen_mode, |
| 711 |
bool uniform, |
| 712 |
const struct pvr_device_info *dev_info); |
| 713 |
|
| 714 |
uint32_t *pvr_pds_pixel_shader_uniform_texture_code( |
| 715 |
struct pvr_pds_pixel_shader_sa_program *restrict program, |
| 716 |
uint32_t *restrict buffer, |
| 717 |
enum pvr_pds_generate_mode gen_mode); |
| 718 |
|
| 719 |
/* Vertex */ |
| 720 |
#define pvr_pds_set_sizes_vertex_shader(X, Y) \ |
| 721 |
pvr_pds_vertex_shader(X, NULL, PDS_GENERATE_SIZES, Y) |
| 722 |
|
| 723 |
#define pvr_pds_generate_vertex_shader_data_segment(X, Y, Z) \ |
| 724 |
pvr_pds_vertex_shader(X, Y, PDS_GENERATE_DATA_SEGMENT, Z) |
| 725 |
|
| 726 |
#define pvr_pds_generate_vertex_shader_code_segment(X, Y, Z) \ |
| 727 |
pvr_pds_vertex_shader(X, Y, PDS_GENERATE_CODE_SEGMENT, Z) |
| 728 |
|
| 729 |
uint32_t * |
| 730 |
pvr_pds_vertex_shader(struct pvr_pds_vertex_shader_program *restrict program, |
| 731 |
uint32_t *restrict buffer, |
| 732 |
enum pvr_pds_generate_mode gen_mode, |
| 733 |
const struct pvr_device_info *dev_info); |
| 734 |
|
| 735 |
/* Compute */ |
| 736 |
uint32_t * |
| 737 |
pvr_pds_compute_shader(struct pvr_pds_compute_shader_program *restrict program, |
| 738 |
uint32_t *restrict buffer, |
| 739 |
enum pvr_pds_generate_mode gen_mode, |
| 740 |
const struct pvr_device_info *dev_info); |
| 741 |
|
| 742 |
/* Vertex Secondary */ |
| 743 |
#define pvr_pds_set_sizes_vertex_shader_sa(X, Y) \ |
| 744 |
pvr_pds_vertex_shader_sa(X, NULL, PDS_GENERATE_SIZES, Y) |
| 745 |
|
| 746 |
#define pvr_pds_generate_vertex_shader_sa_data_segment(X, Y, Z) \ |
| 747 |
pvr_pds_vertex_shader_sa(X, Y, PDS_GENERATE_DATA_SEGMENT, Z) |
| 748 |
|
| 749 |
#define pvr_pds_generate_vertex_shader_sa_code_segment(X, Y, Z) \ |
| 750 |
pvr_pds_vertex_shader_sa(X, Y, PDS_GENERATE_CODE_SEGMENT, Z) |
| 751 |
|
| 752 |
uint32_t *pvr_pds_vertex_shader_sa( |
| 753 |
struct pvr_pds_vertex_shader_sa_program *restrict program, |
| 754 |
uint32_t *restrict buffer, |
| 755 |
enum pvr_pds_generate_mode gen_mode, |
| 756 |
const struct pvr_device_info *dev_info); |
| 757 |
|
| 758 |
/* Pixel Event */ |
| 759 |
#define pvr_pds_set_sizes_pixel_event(X, Y) \ |
| 760 |
pvr_pds_generate_pixel_event(X, NULL, PDS_GENERATE_SIZES, Y) |
| 761 |
|
| 762 |
#define pvr_pds_generate_pixel_event_data_segment(X, Y, Z) \ |
| 763 |
pvr_pds_generate_pixel_event(X, Y, PDS_GENERATE_DATA_SEGMENT, Z) |
| 764 |
|
| 765 |
#define pvr_pds_generate_pixel_event_code_segment(X, Y, Z) \ |
| 766 |
pvr_pds_generate_pixel_event(X, Y, PDS_GENERATE_CODE_SEGMENT, Z) |
| 767 |
|
| 768 |
uint32_t * |
| 769 |
pvr_pds_generate_pixel_event(struct pvr_pds_event_program *restrict program, |
| 770 |
uint32_t *restrict buffer, |
| 771 |
enum pvr_pds_generate_mode gen_mode, |
| 772 |
const struct pvr_device_info *dev_info); |
| 773 |
|
| 774 |
/* Coefficient Loading */ |
| 775 |
#define pvr_pds_set_sizes_coeff_loading(X) \ |
| 776 |
pvr_pds_coefficient_loading(X, NULL, PDS_GENERATE_SIZES) |
| 777 |
|
| 778 |
#define pvr_pds_generate_coeff_loading_program(X, Y) \ |
| 779 |
pvr_pds_coefficient_loading(X, Y, PDS_GENERATE_CODE_SEGMENT) |
| 780 |
|
| 781 |
uint32_t *pvr_pds_coefficient_loading( |
| 782 |
struct pvr_pds_coeff_loading_program *restrict program, |
| 783 |
uint32_t *restrict buffer, |
| 784 |
enum pvr_pds_generate_mode gen_mode); |
| 785 |
|
| 786 |
/* Compute DM barrier-specific conditional code */ |
| 787 |
uint32_t *pvr_pds_generate_compute_barrier_conditional( |
| 788 |
uint32_t *buffer, |
| 789 |
enum pvr_pds_generate_mode gen_mode); |
| 790 |
|
| 791 |
/* Shared register storing */ |
| 792 |
uint32_t *pvr_pds_generate_shared_storing_program( |
| 793 |
struct pvr_pds_shared_storing_program *restrict program, |
| 794 |
uint32_t *restrict buffer, |
| 795 |
enum pvr_pds_generate_mode gen_mode, |
| 796 |
const struct pvr_device_info *dev_info); |
| 797 |
|
| 798 |
/*Shared register loading */ |
| 799 |
uint32_t *pvr_pds_generate_fence_terminate_program( |
| 800 |
struct pvr_pds_fence_program *restrict program, |
| 801 |
uint32_t *restrict buffer, |
| 802 |
enum pvr_pds_generate_mode gen_mode, |
| 803 |
const struct pvr_device_info *dev_info); |
| 804 |
|
| 805 |
/* CDM Shared register loading */ |
| 806 |
uint32_t *pvr_pds_generate_compute_shared_loading_program( |
| 807 |
struct pvr_pds_shared_storing_program *restrict program, |
| 808 |
uint32_t *restrict buffer, |
| 809 |
enum pvr_pds_generate_mode gen_mode, |
| 810 |
const struct pvr_device_info *dev_info); |
| 811 |
|
| 812 |
/* Stream out */ |
| 813 |
uint32_t *pvr_pds_generate_stream_out_init_program( |
| 814 |
struct pvr_pds_stream_out_init_program *restrict program, |
| 815 |
uint32_t *restrict buffer, |
| 816 |
bool store_mode, |
| 817 |
enum pvr_pds_generate_mode gen_mode, |
| 818 |
const struct pvr_device_info *dev_info); |
| 819 |
|
| 820 |
uint32_t *pvr_pds_generate_stream_out_terminate_program( |
| 821 |
struct pvr_pds_stream_out_terminate_program *restrict program, |
| 822 |
uint32_t *restrict buffer, |
| 823 |
enum pvr_pds_generate_mode gen_mode, |
| 824 |
const struct pvr_device_info *dev_info); |
| 825 |
|
| 826 |
#define PVR_PTEMP_VIEW_INDEX 4U |
| 827 |
|
| 828 |
uint32_t *pvr_pds_generate_view_index_init_program( |
| 829 |
struct pvr_pds_view_index_init_program *restrict program, |
| 830 |
uint32_t *restrict buffer, |
| 831 |
enum pvr_pds_generate_mode gen_mode); |
| 832 |
|
| 833 |
/* Structure representing DrawIndirect PDS programs. */ |
| 834 |
struct pvr_pds_drawindirect_program { |
| 835 |
/* --- Input to pvr_pds_drawindirect_program --- */ |
| 836 |
|
| 837 |
/* Address of the index list block in the VDM control stream. |
| 838 |
* This must point to a 128-bit aligned index list header. |
| 839 |
*/ |
| 840 |
uint64_t index_list_addr_buffer; |
| 841 |
/* Address of arguments for Draw call. Layout is defined by eArgFormat. */ |
| 842 |
uint64_t arg_buffer; |
| 843 |
|
| 844 |
/* Address of index buffer. */ |
| 845 |
uint64_t index_buffer; |
| 846 |
|
| 847 |
/* The raw (without addr msb in [7:0]) index block header. */ |
| 848 |
uint32_t index_block_header; |
| 849 |
|
| 850 |
/* Number of bytes per index. */ |
| 851 |
uint32_t index_stride; |
| 852 |
|
| 853 |
/* Used during/after compilation to fill in constant buffer. */ |
| 854 |
struct pvr_psc_register data[32]; |
| 855 |
|
| 856 |
/* Results of compilation. */ |
| 857 |
struct pvr_psc_program_output program; |
| 858 |
|
| 859 |
/* This is used for ARB_multi_draw_indirect. */ |
| 860 |
unsigned int count; |
| 861 |
unsigned int stride; |
| 862 |
|
| 863 |
/* Internal stuff. */ |
| 864 |
unsigned int num_views; |
| 865 |
|
| 866 |
bool support_base_instance; |
| 867 |
bool increment_draw_id; |
| 868 |
}; |
| 869 |
|
| 870 |
void pvr_pds_generate_draw_arrays_indirect( |
| 871 |
struct pvr_pds_drawindirect_program *restrict program, |
| 872 |
uint32_t *restrict buffer, |
| 873 |
enum pvr_pds_generate_mode gen_mode, |
| 874 |
const struct pvr_device_info *dev_info); |
| 875 |
void pvr_pds_generate_draw_elements_indirect( |
| 876 |
struct pvr_pds_drawindirect_program *restrict program, |
| 877 |
uint32_t *restrict buffer, |
| 878 |
enum pvr_pds_generate_mode gen_mode, |
| 879 |
const struct pvr_device_info *dev_info); |
| 880 |
|
| 881 |
uint64_t pvr_pds_encode_st_src0(uint64_t src, |
| 882 |
uint64_t count4, |
| 883 |
uint64_t dst_add, |
| 884 |
bool write_through, |
| 885 |
const struct pvr_device_info *dev_info); |
| 886 |
|
| 887 |
uint64_t pvr_pds_encode_ld_src0(uint64_t dest, |
| 888 |
uint64_t count8, |
| 889 |
uint64_t src_add, |
| 890 |
bool cached, |
| 891 |
const struct pvr_device_info *dev_info); |
| 892 |
|
| 893 |
uint32_t *pvr_pds_generate_single_ldst_instruction( |
| 894 |
bool ld, |
| 895 |
const struct pvr_pds_ldst_control *control, |
| 896 |
uint32_t temp_index, |
| 897 |
uint64_t address, |
| 898 |
uint32_t count, |
| 899 |
uint32_t *next_constant, |
| 900 |
uint32_t *total_data_size, |
| 901 |
uint32_t *total_code_size, |
| 902 |
uint32_t *buffer, |
| 903 |
bool data_fence, |
| 904 |
enum pvr_pds_generate_mode gen_mode, |
| 905 |
const struct pvr_device_info *dev_info); |
| 906 |
|
| 907 |
struct pvr_pds_descriptor_set { |
| 908 |
unsigned int descriptor_set; /* id of the descriptor set. */ |
| 909 |
unsigned int size_in_dwords; /* Number of dwords to transfer. */ |
| 910 |
unsigned int destination; /* Destination shared register to which |
| 911 |
* descriptor entries should be loaded. |
| 912 |
*/ |
| 913 |
}; |
| 914 |
|
| 915 |
#define PVR_BUFFER_TYPE_UBO (0) |
| 916 |
#define PVR_BUFFER_TYPE_COMPILE_TIME (1) |
| 917 |
#define PVR_BUFFER_TYPE_BLEND_CONSTS (2) |
| 918 |
#define PVR_BUFFER_TYPE_PUSH_CONSTS (3) |
| 919 |
#define PVR_BUFFER_TYPE_BUFFER_LENGTHS (4) |
| 920 |
#define PVR_BUFFER_TYPE_DYNAMIC (5) |
| 921 |
#define PVR_BUFFER_TYPE_UBO_ZEROING (6) |
| 922 |
#define PVR_BUFFER_TYPE_POINT_SAMPLER (7) |
| 923 |
#define PVR_BUFFER_TYPE_IA_SAMPLER (8) |
| 924 |
#define PVR_BUFFER_TYPE_FRONT_FACE_OP (9) |
| 925 |
#define PVR_BUFFER_TYPE_FS_META (10) |
| 926 |
#define PVR_BUFFER_TYPE_TILE_BUFFERS (11) |
| 927 |
#define PVR_BUFFER_TYPE_SPILL_INFO (12) |
| 928 |
#define PVR_BUFFER_TYPE_SCRATCH_INFO (13) |
| 929 |
#define PVR_BUFFER_TYPE_SAMPLE_LOCATIONS (14) |
| 930 |
#define PVR_BUFFER_TYPE_INVALID (~0) |
| 931 |
|
| 932 |
struct pvr_pds_buffer { |
| 933 |
uint16_t type; |
| 934 |
|
| 935 |
uint16_t size_in_dwords; |
| 936 |
uint32_t destination; |
| 937 |
|
| 938 |
union { |
| 939 |
uint32_t *data; |
| 940 |
struct { |
| 941 |
uint32_t buffer_id; |
| 942 |
uint16_t desc_set; |
| 943 |
uint16_t binding; |
| 944 |
uint32_t source_offset; |
| 945 |
}; |
| 946 |
}; |
| 947 |
}; |
| 948 |
|
| 949 |
#define PVR_PDS_MAX_BUFFERS (24) |
| 950 |
|
| 951 |
/* Maximum memory allocation needed for const map entries in |
| 952 |
* pvr_pds_generate_descriptor_upload_program(). |
| 953 |
* It must be >= 688 bytes. This size is calculated as the sum of: |
| 954 |
* |
| 955 |
* 1. Max. number of descriptor sets (8) * ( |
| 956 |
* size of descriptor entry |
| 957 |
* (pvr_const_map_entry_descriptor_set) + |
| 958 |
* size of Common Store burst entry |
| 959 |
* (pvr_const_map_entry_literal32)) |
| 960 |
* |
| 961 |
* 2. Max. number of PDS program buffers (24) * ( |
| 962 |
* size of the largest buffer structure |
| 963 |
* (pvr_const_map_entry_constant_buffer) + |
| 964 |
* size of Common Store burst entry |
| 965 |
* (pvr_const_map_entry_literal32) |
| 966 |
* |
| 967 |
* 3. Size of DOUTU entry (pvr_const_map_entry_doutu_address) |
| 968 |
*/ |
| 969 |
#define PVR_PDS_MAX_DESC_UPLOAD_BYTES \ |
| 970 |
(8 * (sizeof(struct pvr_const_map_entry_descriptor_set) + \ |
| 971 |
sizeof(struct pvr_const_map_entry_literal32)) + \ |
| 972 |
PVR_PDS_MAX_BUFFERS * \ |
| 973 |
(sizeof(struct pvr_const_map_entry_constant_buffer) + \ |
| 974 |
sizeof(struct pvr_const_map_entry_literal32)) + \ |
| 975 |
sizeof(struct pvr_const_map_entry_doutu_address)); |
| 976 |
|
| 977 |
struct pvr_pds_descriptor_program_input { |
| 978 |
/* User-specified descriptor sets. */ |
| 979 |
unsigned int descriptor_set_count; |
| 980 |
struct pvr_pds_descriptor_set descriptor_sets[8]; |
| 981 |
|
| 982 |
/* "State" buffers, including: |
| 983 |
* compile-time constants |
| 984 |
* blend constants |
| 985 |
* push constants |
| 986 |
* UBOs that have been hoisted. |
| 987 |
*/ |
| 988 |
uint32_t buffer_count; |
| 989 |
struct pvr_pds_buffer buffers[PVR_PDS_MAX_BUFFERS]; |
| 990 |
|
| 991 |
uint32_t blend_constants_used_mask; |
| 992 |
|
| 993 |
bool secondary_program_present; |
| 994 |
struct pvr_pds_usc_task_control secondary_task_control; |
| 995 |
|
| 996 |
bool must_not_be_empty; |
| 997 |
}; |
| 998 |
|
| 999 |
#define PVR_PDS_VERTEX_FLAGS_VERTEX_ID_REQUIRED BITFIELD_BIT(0U) |
| 1000 |
#define PVR_PDS_VERTEX_FLAGS_INSTANCE_ID_REQUIRED BITFIELD_BIT(1U) |
| 1001 |
#define PVR_PDS_VERTEX_FLAGS_DRAW_INDIRECT_VARIANT BITFIELD_BIT(2U) |
| 1002 |
#define PVR_PDS_VERTEX_FLAGS_BASE_INSTANCE_VARIANT BITFIELD_BIT(3U) |
| 1003 |
#define PVR_PDS_VERTEX_FLAGS_BASE_INSTANCE_REQUIRED BITFIELD_BIT(4U) |
| 1004 |
|
| 1005 |
/* BaseVertex is used in shader. */ |
| 1006 |
#define PVR_PDS_VERTEX_FLAGS_BASE_VERTEX_REQUIRED BITFIELD_BIT(5U) |
| 1007 |
|
| 1008 |
#define PVR_PDS_VERTEX_FLAGS_DRAW_INDEX_REQUIRED BITFIELD_BIT(6U) |
| 1009 |
#define PVR_PDS_VERTEX_FLAGS_VIEW_INDEX_REQUIRED BITFIELD_BIT(7U) |
| 1010 |
|
| 1011 |
#define PVR_PDS_VERTEX_DMA_FLAGS_INSTANCE_RATE BITFIELD_BIT(0U) |
| 1012 |
|
| 1013 |
struct pvr_pds_vertex_dma { |
| 1014 |
/* Try and keep this structure packing as small as possible. */ |
| 1015 |
uint16_t offset; |
| 1016 |
uint16_t stride; |
| 1017 |
|
| 1018 |
uint8_t flags; |
| 1019 |
uint8_t size_in_dwords; |
| 1020 |
uint8_t attrib_size_in_bytes; |
| 1021 |
uint8_t destination; |
| 1022 |
uint8_t binding_index; |
| 1023 |
uint32_t divisor; |
| 1024 |
|
| 1025 |
uint16_t robustness_buffer_offset; |
| 1026 |
}; |
| 1027 |
|
| 1028 |
struct pvr_pds_vertex_primary_program_input { |
| 1029 |
/* Control for the DOUTU that kicks the vertex USC shader. */ |
| 1030 |
struct pvr_pds_usc_task_control usc_task_control; |
| 1031 |
/* List of DMAs (of size dma_count). */ |
| 1032 |
const struct pvr_pds_vertex_dma *dma_list; |
| 1033 |
uint32_t dma_count; |
| 1034 |
|
| 1035 |
/* ORd bitfield of PVR_PDS_VERTEX_FLAGS_* */ |
| 1036 |
uint32_t flags; |
| 1037 |
|
| 1038 |
uint16_t vertex_id_register; |
| 1039 |
uint16_t instance_id_register; |
| 1040 |
|
| 1041 |
/* API provided baseInstance (i.e. not from drawIndirect). */ |
| 1042 |
uint32_t base_instance; |
| 1043 |
|
| 1044 |
uint16_t base_instance_register; |
| 1045 |
uint16_t base_vertex_register; |
| 1046 |
uint16_t draw_index_register; |
| 1047 |
uint16_t view_index_register; |
| 1048 |
}; |
| 1049 |
|
| 1050 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_NULL (0) |
| 1051 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_LITERAL64 (1) |
| 1052 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_LITERAL32 (2) |
| 1053 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_DESCRIPTOR_SET (3) |
| 1054 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_CONSTANT_BUFFER (4) |
| 1055 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_SPECIAL_BUFFER (5) |
| 1056 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_DOUTU_ADDRESS (6) |
| 1057 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTRIBUTE_ADDRESS (7) |
| 1058 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_ROBUST_VERTEX_ATTRIBUTE_ADDRESS (8) |
| 1059 |
|
| 1060 |
/* Use if pds_ddmadt is enabled. */ |
| 1061 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTR_DDMADT_OOB_BUFFER_SIZE (9) |
| 1062 |
|
| 1063 |
/* Use if pds_ddmadt is not enabled. */ |
| 1064 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTRIBUTE_MAX_INDEX (10) |
| 1065 |
|
| 1066 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_BASE_INSTANCE (11) |
| 1067 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_CONSTANT_BUFFER_ZEROING (12) |
| 1068 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_BASE_VERTEX (13) |
| 1069 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_BASE_WORKGROUP (14) |
| 1070 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_COND_RENDER (15) |
| 1071 |
#define PVR_PDS_CONST_MAP_ENTRY_TYPE_VERTEX_ATTRIBUTE_STRIDE (16) |
| 1072 |
|
| 1073 |
/* We pack all the following structs tightly into a buffer using += sizeof(x) |
| 1074 |
* offsets, this can lead to data that is not native aligned. Supplying the |
| 1075 |
* packed attribute indicates that unaligned accesses may be required, and the |
| 1076 |
* aligned attribute causes the size of the structure to be aligned to a |
| 1077 |
* specific boundary. |
| 1078 |
*/ |
| 1079 |
#define PVR_PACKED __attribute__((packed, aligned(1))) |
| 1080 |
|
| 1081 |
struct pvr_const_map_entry { |
| 1082 |
uint8_t type; |
| 1083 |
uint8_t const_offset; |
| 1084 |
} PVR_PACKED; |
| 1085 |
|
| 1086 |
struct pvr_const_map_entry_literal32 { |
| 1087 |
uint8_t type; |
| 1088 |
uint8_t const_offset; |
| 1089 |
|
| 1090 |
uint32_t literal_value; |
| 1091 |
} PVR_PACKED; |
| 1092 |
|
| 1093 |
struct pvr_const_map_entry_literal64 { |
| 1094 |
uint8_t type; |
| 1095 |
uint8_t const_offset; |
| 1096 |
|
| 1097 |
uint64_t literal_value; |
| 1098 |
} PVR_PACKED; |
| 1099 |
|
| 1100 |
struct pvr_const_map_entry_descriptor_set { |
| 1101 |
uint8_t type; |
| 1102 |
uint8_t const_offset; |
| 1103 |
|
| 1104 |
uint32_t descriptor_set; |
| 1105 |
PVR_PDS_BOOL primary; |
| 1106 |
uint32_t offset_in_dwords; |
| 1107 |
} PVR_PACKED; |
| 1108 |
|
| 1109 |
struct pvr_const_map_entry_constant_buffer { |
| 1110 |
uint8_t type; |
| 1111 |
uint8_t const_offset; |
| 1112 |
|
| 1113 |
uint16_t buffer_id; |
| 1114 |
uint16_t desc_set; |
| 1115 |
uint16_t binding; |
| 1116 |
uint32_t offset; |
| 1117 |
uint32_t size_in_dwords; |
| 1118 |
} PVR_PACKED; |
| 1119 |
|
| 1120 |
struct pvr_const_map_entry_constant_buffer_zeroing { |
| 1121 |
uint8_t type; |
| 1122 |
uint8_t const_offset; |
| 1123 |
|
| 1124 |
uint16_t buffer_id; |
| 1125 |
uint32_t offset; |
| 1126 |
uint32_t size_in_dwords; |
| 1127 |
} PVR_PACKED; |
| 1128 |
|
| 1129 |
struct pvr_const_map_entry_special_buffer { |
| 1130 |
uint8_t type; |
| 1131 |
uint8_t const_offset; |
| 1132 |
|
| 1133 |
uint8_t buffer_type; |
| 1134 |
uint32_t buffer_index; |
| 1135 |
|
| 1136 |
uint32_t size_in_dwords; |
| 1137 |
uint32_t data; |
| 1138 |
} PVR_PACKED; |
| 1139 |
|
| 1140 |
struct pvr_const_map_entry_doutu_address { |
| 1141 |
uint8_t type; |
| 1142 |
uint8_t const_offset; |
| 1143 |
|
| 1144 |
uint64_t doutu_control; |
| 1145 |
} PVR_PACKED; |
| 1146 |
|
| 1147 |
struct pvr_const_map_entry_vertex_attribute_address { |
| 1148 |
uint8_t type; |
| 1149 |
uint8_t const_offset; |
| 1150 |
|
| 1151 |
uint16_t offset; |
| 1152 |
uint16_t stride; |
| 1153 |
uint8_t binding_index; |
| 1154 |
uint8_t size_in_dwords; |
| 1155 |
} PVR_PACKED; |
| 1156 |
|
| 1157 |
struct pvr_const_map_entry_vertex_attribute_stride { |
| 1158 |
uint8_t type; |
| 1159 |
uint8_t const_offset; |
| 1160 |
uint8_t binding_index; |
| 1161 |
} PVR_PACKED; |
| 1162 |
|
| 1163 |
struct pvr_const_map_entry_robust_vertex_attribute_address { |
| 1164 |
uint8_t type; |
| 1165 |
uint8_t const_offset; |
| 1166 |
|
| 1167 |
uint16_t offset; |
| 1168 |
uint16_t stride; |
| 1169 |
uint8_t binding_index; |
| 1170 |
uint8_t size_in_dwords; |
| 1171 |
uint16_t robustness_buffer_offset; |
| 1172 |
uint8_t attrib_size_in_bytes; |
| 1173 |
} PVR_PACKED; |
| 1174 |
|
| 1175 |
struct pvr_const_map_entry_vertex_attribute_max_index { |
| 1176 |
uint8_t type; |
| 1177 |
uint8_t const_offset; |
| 1178 |
|
| 1179 |
uint8_t binding_index; |
| 1180 |
uint8_t size_in_dwords; |
| 1181 |
uint16_t offset; |
| 1182 |
uint16_t stride; |
| 1183 |
uint8_t attrib_size_in_bytes; |
| 1184 |
} PVR_PACKED; |
| 1185 |
|
| 1186 |
struct pvr_const_map_entry_base_instance { |
| 1187 |
uint8_t type; |
| 1188 |
uint8_t const_offset; |
| 1189 |
} PVR_PACKED; |
| 1190 |
|
| 1191 |
struct pvr_const_map_entry_base_vertex { |
| 1192 |
uint8_t type; |
| 1193 |
uint8_t const_offset; |
| 1194 |
}; |
| 1195 |
|
| 1196 |
struct pvr_pds_const_map_entry_base_workgroup { |
| 1197 |
uint8_t type; |
| 1198 |
uint8_t const_offset; |
| 1199 |
uint8_t workgroup_component; |
| 1200 |
} PVR_PACKED; |
| 1201 |
|
| 1202 |
struct pvr_pds_const_map_entry_vertex_attr_ddmadt_oob_buffer_size { |
| 1203 |
uint8_t type; |
| 1204 |
uint8_t const_offset; |
| 1205 |
uint8_t binding_index; |
| 1206 |
uint8_t size_in_dwords; |
| 1207 |
uint16_t offset; |
| 1208 |
uint8_t attrib_size_in_bytes; |
| 1209 |
} PVR_PACKED; |
| 1210 |
|
| 1211 |
struct pvr_pds_const_map_entry_cond_render { |
| 1212 |
uint8_t type; |
| 1213 |
uint8_t const_offset; |
| 1214 |
|
| 1215 |
uint32_t cond_render_pred_temp; |
| 1216 |
} PVR_PACKED; |
| 1217 |
|
| 1218 |
struct pvr_pds_info { |
| 1219 |
uint32_t temps_required; |
| 1220 |
uint32_t code_size_in_dwords; |
| 1221 |
uint32_t data_size_in_dwords; |
| 1222 |
|
| 1223 |
uint32_t entry_count; |
| 1224 |
size_t entries_size_in_bytes; |
| 1225 |
size_t entries_written_size_in_bytes; |
| 1226 |
struct pvr_const_map_entry *entries; |
| 1227 |
}; |
| 1228 |
|
| 1229 |
void pvr_pds_generate_descriptor_upload_program( |
| 1230 |
struct pvr_pds_descriptor_program_input *input_program, |
| 1231 |
uint32_t *code_section, |
| 1232 |
struct pvr_pds_info *info); |
| 1233 |
void pvr_pds_generate_vertex_primary_program( |
| 1234 |
struct pvr_pds_vertex_primary_program_input *input_program, |
| 1235 |
uint32_t *code, |
| 1236 |
struct pvr_pds_info *info, |
| 1237 |
bool use_robust_vertex_fetch, |
| 1238 |
const struct pvr_device_info *dev_info); |
| 1239 |
|
| 1240 |
/** |
| 1241 |
* Generate USC address. |
| 1242 |
* |
| 1243 |
* \param doutu Location to write the generated address. |
| 1244 |
* \param execution_address Address to generate from. |
| 1245 |
*/ |
| 1246 |
static ALWAYS_INLINE void |
| 1247 |
pvr_set_usc_execution_address64(uint64_t *doutu, uint64_t execution_address) |
| 1248 |
{ |
| 1249 |
doutu[0] |= (((execution_address >> |
| 1250 |
PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_SRC0_EXE_OFF_ALIGNSHIFT) |
| 1251 |
<< PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_SRC0_EXE_OFF_SHIFT) & |
| 1252 |
~PVR_ROGUE_PDSINST_DOUT_FIELDS_DOUTU_SRC0_EXE_OFF_CLRMSK); |
| 1253 |
} |
| 1254 |
|
| 1255 |
#endif /* PVR_PDS_H */ |