| 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_CMD_BUFFER_H |
| 15 |
#define PVR_CMD_BUFFER_H |
| 16 |
|
| 17 |
#include "vk_command_buffer.h" |
| 18 |
|
| 19 |
#include "pvr_common.h" |
| 20 |
#include "pvr_framebuffer.h" |
| 21 |
#include "pvr_job_render.h" |
| 22 |
#include "pvr_hw_pass.h" |
| 23 |
#include "pvr_types.h" |
| 24 |
|
| 25 |
struct pvr_pds_upload; |
| 26 |
struct pvr_private_compute_pipeline; |
| 27 |
struct pvr_query_info; |
| 28 |
|
| 29 |
struct pvr_vertex_binding { |
| 30 |
struct pvr_buffer *buffer; |
| 31 |
VkDeviceSize offset; |
| 32 |
VkDeviceSize size; |
| 33 |
}; |
| 34 |
|
| 35 |
#define PVR_TRANSFER_MAX_SOURCES 10U |
| 36 |
#define PVR_TRANSFER_MAX_CUSTOM_MAPPINGS 6U |
| 37 |
|
| 38 |
/** A surface describes a source or destination for a transfer operation. */ |
| 39 |
struct pvr_transfer_cmd_surface { |
| 40 |
pvr_dev_addr_t dev_addr; |
| 41 |
|
| 42 |
/* Memory address for extra U/V planes. */ |
| 43 |
pvr_dev_addr_t uv_address[2]; |
| 44 |
|
| 45 |
/* Surface width in texels. */ |
| 46 |
uint32_t width; |
| 47 |
|
| 48 |
/* Surface height in texels. */ |
| 49 |
uint32_t height; |
| 50 |
|
| 51 |
uint32_t depth; |
| 52 |
|
| 53 |
/* Z position in a 3D tecture. 0.0f <= z_position <= depth. */ |
| 54 |
float z_position; |
| 55 |
|
| 56 |
/* Stride in texels. */ |
| 57 |
uint32_t stride; |
| 58 |
|
| 59 |
VkFormat vk_format; |
| 60 |
|
| 61 |
enum pvr_memlayout mem_layout; |
| 62 |
|
| 63 |
uint32_t sample_count; |
| 64 |
}; |
| 65 |
|
| 66 |
struct pvr_rect_mapping { |
| 67 |
VkRect2D src_rect; |
| 68 |
VkRect2D dst_rect; |
| 69 |
bool flip_x; |
| 70 |
bool flip_y; |
| 71 |
}; |
| 72 |
|
| 73 |
struct pvr_transfer_cmd_source { |
| 74 |
struct pvr_transfer_cmd_surface surface; |
| 75 |
|
| 76 |
uint32_t mapping_count; |
| 77 |
struct pvr_rect_mapping mappings[PVR_TRANSFER_MAX_CUSTOM_MAPPINGS]; |
| 78 |
|
| 79 |
/* In the case of a simple 1:1 copy, this setting does not affect the output |
| 80 |
* but will affect performance. Use clamp to edge when possible. |
| 81 |
*/ |
| 82 |
/* This is of type enum ROGUE_TEXSTATE_ADDRMODE. */ |
| 83 |
int addr_mode; |
| 84 |
|
| 85 |
/* Source filtering method. */ |
| 86 |
enum pvr_filter filter; |
| 87 |
|
| 88 |
/* MSAA resolve operation. */ |
| 89 |
enum pvr_resolve_op resolve_op; |
| 90 |
}; |
| 91 |
|
| 92 |
struct pvr_transfer_cmd { |
| 93 |
/* Node to link this cmd into the transfer_cmds list in |
| 94 |
* pvr_sub_cmd::transfer structure. |
| 95 |
*/ |
| 96 |
struct list_head link; |
| 97 |
|
| 98 |
uint32_t flags; |
| 99 |
|
| 100 |
uint32_t source_count; |
| 101 |
|
| 102 |
struct pvr_transfer_cmd_source sources[PVR_TRANSFER_MAX_SOURCES]; |
| 103 |
|
| 104 |
union fi clear_color[4]; |
| 105 |
|
| 106 |
struct pvr_transfer_cmd_surface dst; |
| 107 |
|
| 108 |
VkRect2D scissor; |
| 109 |
|
| 110 |
/* Pointer to cmd buffer this transfer cmd belongs to. This is mainly used |
| 111 |
* to link buffer objects allocated during job submission into |
| 112 |
* cmd_buffer::bo_list head. |
| 113 |
*/ |
| 114 |
struct pvr_cmd_buffer *cmd_buffer; |
| 115 |
}; |
| 116 |
|
| 117 |
struct pvr_unbound_deferred_clear { |
| 118 |
union fi clear_color[4]; |
| 119 |
VkOffset3D offset; |
| 120 |
VkExtent3D extent; |
| 121 |
uint32_t array_layer; |
| 122 |
VkImageAspectFlags aspect_mask; |
| 123 |
uint32_t attachment_index; |
| 124 |
}; |
| 125 |
|
| 126 |
struct pvr_color_attachment_output_map { |
| 127 |
uint32_t index_color; |
| 128 |
uint32_t index_resolve; |
| 129 |
}; |
| 130 |
|
| 131 |
struct pvr_dynamic_render_info { |
| 132 |
/* Inputs */ |
| 133 |
struct pvr_render_pass_attachment *attachments; |
| 134 |
uint32_t attachment_count; |
| 135 |
|
| 136 |
/* Outputs */ |
| 137 |
struct pvr_color_attachment_output_map *color_attachments; |
| 138 |
uint32_t color_attachment_count; |
| 139 |
|
| 140 |
struct usc_mrt_setup *mrt_setup; |
| 141 |
|
| 142 |
struct pvr_renderpass_hwsetup_render hw_render; |
| 143 |
}; |
| 144 |
|
| 145 |
struct pvr_sub_cmd_gfx { |
| 146 |
struct pvr_dynamic_render_info *dr_info; |
| 147 |
struct pvr_renderpass_hwsetup_render *hw_render; |
| 148 |
uint32_t attachment_count; |
| 149 |
|
| 150 |
const struct pvr_render_state *rstate; |
| 151 |
|
| 152 |
struct pvr_render_job job; |
| 153 |
|
| 154 |
struct pvr_suballoc_bo *depth_bias_bo; |
| 155 |
struct pvr_suballoc_bo *scissor_bo; |
| 156 |
|
| 157 |
/* Tracking how the loaded depth/stencil values are being used. */ |
| 158 |
enum pvr_depth_stencil_usage depth_usage; |
| 159 |
enum pvr_depth_stencil_usage stencil_usage; |
| 160 |
|
| 161 |
/* Tracking whether the subcommand modifies depth/stencil. */ |
| 162 |
bool modifies_depth; |
| 163 |
bool modifies_stencil; |
| 164 |
|
| 165 |
/* Store the render to a scratch buffer. */ |
| 166 |
bool barrier_store; |
| 167 |
/* Load the render (stored with a `barrier_store`) as a background to the |
| 168 |
* current render. |
| 169 |
*/ |
| 170 |
bool barrier_load; |
| 171 |
|
| 172 |
const struct pvr_query_pool *query_pool; |
| 173 |
struct util_dynarray sec_query_indices; |
| 174 |
|
| 175 |
/* Control stream builder object */ |
| 176 |
struct pvr_csb control_stream; |
| 177 |
|
| 178 |
struct pvr_bo *multiview_ctrl_stream; |
| 179 |
uint32_t multiview_ctrl_stream_stride; |
| 180 |
|
| 181 |
/* Required iff pvr_sub_cmd_gfx_requires_split_submit() returns true. */ |
| 182 |
struct pvr_bo *terminate_ctrl_stream; |
| 183 |
|
| 184 |
uint32_t hw_render_idx; |
| 185 |
|
| 186 |
uint32_t max_tiles_in_flight; |
| 187 |
|
| 188 |
bool empty_cmd; |
| 189 |
|
| 190 |
/* True if any fragment shader used in this sub command uses atomic |
| 191 |
* operations. |
| 192 |
*/ |
| 193 |
bool frag_uses_atomic_ops; |
| 194 |
|
| 195 |
bool disable_compute_overlap; |
| 196 |
|
| 197 |
/* True if any fragment shader used in this sub command has side |
| 198 |
* effects. |
| 199 |
*/ |
| 200 |
bool frag_has_side_effects; |
| 201 |
|
| 202 |
/* True if any vertex shader used in this sub command contains both |
| 203 |
* texture reads and texture writes. |
| 204 |
*/ |
| 205 |
bool vertex_uses_texture_rw; |
| 206 |
|
| 207 |
/* True if any fragment shader used in this sub command contains |
| 208 |
* both texture reads and texture writes. |
| 209 |
*/ |
| 210 |
bool frag_uses_texture_rw; |
| 211 |
|
| 212 |
bool has_query; |
| 213 |
|
| 214 |
bool wait_on_previous_transfer; |
| 215 |
|
| 216 |
bool has_depth_feedback; |
| 217 |
|
| 218 |
uint32_t view_mask; |
| 219 |
bool multiview_enabled; |
| 220 |
bool view_index_wanted; |
| 221 |
|
| 222 |
/* Recorded deferred RTA clears for secondary command buffers */ |
| 223 |
struct util_dynarray unbound_deferred_clears; |
| 224 |
}; |
| 225 |
|
| 226 |
struct pvr_sub_cmd_compute { |
| 227 |
/* Control stream builder object. */ |
| 228 |
struct pvr_csb control_stream; |
| 229 |
|
| 230 |
uint32_t num_shared_regs; |
| 231 |
|
| 232 |
/* True if any shader used in this sub command uses atomic |
| 233 |
* operations. |
| 234 |
*/ |
| 235 |
bool uses_atomic_ops; |
| 236 |
|
| 237 |
bool uses_barrier; |
| 238 |
|
| 239 |
bool pds_sw_barrier_requires_clearing; |
| 240 |
}; |
| 241 |
|
| 242 |
struct pvr_sub_cmd_transfer { |
| 243 |
bool serialize_with_frag; |
| 244 |
|
| 245 |
/* Pointer to the actual transfer command list, allowing primary and |
| 246 |
* secondary sub-commands to share the same list. |
| 247 |
*/ |
| 248 |
struct list_head *transfer_cmds; |
| 249 |
|
| 250 |
/* List of pvr_transfer_cmd type structures. Do not access the list |
| 251 |
* directly, but always use the transfer_cmds pointer above. |
| 252 |
*/ |
| 253 |
struct list_head transfer_cmds_priv; |
| 254 |
}; |
| 255 |
|
| 256 |
struct pvr_sub_cmd_event { |
| 257 |
enum pvr_event_type type; |
| 258 |
|
| 259 |
union { |
| 260 |
struct pvr_sub_cmd_event_set_reset { |
| 261 |
struct pvr_event *event; |
| 262 |
/* Stages to wait for until the event is set or reset. */ |
| 263 |
uint32_t wait_for_stage_mask; |
| 264 |
} set_reset; |
| 265 |
|
| 266 |
struct pvr_sub_cmd_event_wait { |
| 267 |
uint32_t count; |
| 268 |
/* Events to wait for before resuming. */ |
| 269 |
struct pvr_event **events; |
| 270 |
/* Stages to wait at. */ |
| 271 |
uint32_t *wait_at_stage_masks; |
| 272 |
} wait; |
| 273 |
|
| 274 |
struct pvr_sub_cmd_event_barrier { |
| 275 |
/* Stages to wait for. */ |
| 276 |
uint32_t wait_for_stage_mask; |
| 277 |
/* Stages to wait at. */ |
| 278 |
uint32_t wait_at_stage_mask; |
| 279 |
} barrier; |
| 280 |
}; |
| 281 |
}; |
| 282 |
|
| 283 |
struct pvr_sub_cmd { |
| 284 |
/* This links the subcommand in pvr_cmd_buffer:sub_cmds list. */ |
| 285 |
struct list_head link; |
| 286 |
|
| 287 |
enum pvr_sub_cmd_type type; |
| 288 |
|
| 289 |
struct { |
| 290 |
/* True if the sub_cmd is owned by this command buffer. False if taken |
| 291 |
* from a secondary command buffer, in that case we are not supposed to |
| 292 |
* free any resources associated with the sub_cmd. |
| 293 |
*/ |
| 294 |
bool owned : 1; |
| 295 |
bool is_dynamic_render : 1; |
| 296 |
bool is_suspend : 1; |
| 297 |
bool is_resume : 1; |
| 298 |
}; |
| 299 |
|
| 300 |
union { |
| 301 |
struct pvr_sub_cmd_gfx gfx; |
| 302 |
struct pvr_sub_cmd_compute compute; |
| 303 |
struct pvr_sub_cmd_transfer transfer; |
| 304 |
struct pvr_sub_cmd_event event; |
| 305 |
}; |
| 306 |
}; |
| 307 |
|
| 308 |
struct pvr_render_pass_info { |
| 309 |
const struct pvr_render_pass *pass; |
| 310 |
struct pvr_framebuffer *framebuffer; |
| 311 |
|
| 312 |
struct pvr_dynamic_render_info *dr_info; |
| 313 |
struct pvr_renderpass_hwsetup_render *hw_render; |
| 314 |
struct pvr_render_state *rstate; |
| 315 |
|
| 316 |
uint32_t attachment_count; |
| 317 |
struct pvr_image_view **attachments; |
| 318 |
|
| 319 |
uint32_t subpass_idx; |
| 320 |
uint32_t current_hw_subpass; |
| 321 |
uint32_t sample_count; |
| 322 |
|
| 323 |
VkRect2D render_area; |
| 324 |
|
| 325 |
uint32_t clear_value_count; |
| 326 |
VkClearValue *clear_values; |
| 327 |
|
| 328 |
VkPipelineBindPoint pipeline_bind_point; |
| 329 |
|
| 330 |
bool process_empty_tiles; |
| 331 |
bool enable_bg_tag; |
| 332 |
uint32_t isp_userpass; |
| 333 |
|
| 334 |
bool dynamic_render; |
| 335 |
bool suspend; |
| 336 |
bool resume; |
| 337 |
}; |
| 338 |
|
| 339 |
struct pvr_ppp_state { |
| 340 |
uint32_t header; |
| 341 |
|
| 342 |
struct { |
| 343 |
/* TODO: Can we get rid of the "control" field? */ |
| 344 |
struct ROGUE_TA_STATE_ISPCTL control_struct; |
| 345 |
uint32_t control; |
| 346 |
|
| 347 |
uint32_t front_a; |
| 348 |
uint32_t front_b; |
| 349 |
uint32_t back_a; |
| 350 |
uint32_t back_b; |
| 351 |
} isp; |
| 352 |
|
| 353 |
struct pvr_ppp_dbsc { |
| 354 |
uint16_t scissor_index; |
| 355 |
uint16_t depthbias_index; |
| 356 |
} depthbias_scissor_indices; |
| 357 |
|
| 358 |
struct { |
| 359 |
uint32_t pixel_shader_base; |
| 360 |
uint32_t texture_uniform_code_base; |
| 361 |
uint32_t size_info1; |
| 362 |
uint32_t size_info2; |
| 363 |
uint32_t varying_base; |
| 364 |
uint32_t texture_state_data_base; |
| 365 |
uint32_t uniform_state_data_base; |
| 366 |
} pds; |
| 367 |
|
| 368 |
struct { |
| 369 |
uint32_t word0; |
| 370 |
uint32_t word1; |
| 371 |
} region_clipping; |
| 372 |
|
| 373 |
struct { |
| 374 |
uint32_t a0; |
| 375 |
uint32_t m0; |
| 376 |
uint32_t a1; |
| 377 |
uint32_t m1; |
| 378 |
uint32_t a2; |
| 379 |
uint32_t m2; |
| 380 |
} viewports[PVR_MAX_VIEWPORTS]; |
| 381 |
|
| 382 |
uint32_t viewport_count; |
| 383 |
|
| 384 |
uint32_t output_selects; |
| 385 |
|
| 386 |
uint32_t varying_word[2]; |
| 387 |
|
| 388 |
uint32_t ppp_control; |
| 389 |
}; |
| 390 |
|
| 391 |
/* Represents a control stream related command that is deferred for execution in |
| 392 |
* a secondary command buffer. |
| 393 |
*/ |
| 394 |
struct pvr_deferred_cs_command { |
| 395 |
enum pvr_deferred_cs_command_type type; |
| 396 |
union { |
| 397 |
struct { |
| 398 |
struct pvr_ppp_dbsc state; |
| 399 |
|
| 400 |
uint32_t *vdm_state; |
| 401 |
} dbsc; |
| 402 |
|
| 403 |
struct { |
| 404 |
struct pvr_ppp_dbsc state; |
| 405 |
|
| 406 |
struct pvr_suballoc_bo *ppp_cs_bo; |
| 407 |
uint32_t patch_offset; |
| 408 |
} dbsc2; |
| 409 |
}; |
| 410 |
}; |
| 411 |
|
| 412 |
struct pvr_cmd_buffer_draw_state { |
| 413 |
uint32_t base_instance; |
| 414 |
uint32_t base_vertex; |
| 415 |
bool draw_indirect; |
| 416 |
bool draw_indexed; |
| 417 |
}; |
| 418 |
|
| 419 |
struct pvr_push_constants { |
| 420 |
uint8_t data[PVR_MAX_PUSH_CONSTANTS_SIZE]; |
| 421 |
unsigned bytes_updated; |
| 422 |
pvr_dev_addr_t dev_addr; |
| 423 |
bool dirty; |
| 424 |
}; |
| 425 |
|
| 426 |
struct pvr_cmd_buffer_state { |
| 427 |
/* Pipeline binding. */ |
| 428 |
const struct pvr_graphics_pipeline *gfx_pipeline; |
| 429 |
|
| 430 |
const struct pvr_compute_pipeline *compute_pipeline; |
| 431 |
|
| 432 |
struct pvr_render_pass_info render_pass_info; |
| 433 |
|
| 434 |
struct pvr_sub_cmd *current_sub_cmd; |
| 435 |
|
| 436 |
struct pvr_ppp_state ppp_state; |
| 437 |
|
| 438 |
struct ROGUE_TA_STATE_HEADER emit_header; |
| 439 |
|
| 440 |
struct pvr_vertex_binding vertex_bindings[PVR_MAX_VERTEX_INPUT_BINDINGS]; |
| 441 |
|
| 442 |
struct { |
| 443 |
struct pvr_buffer *buffer; |
| 444 |
VkDeviceSize offset; |
| 445 |
VkIndexType type; |
| 446 |
} index_buffer_binding; |
| 447 |
|
| 448 |
/* Array size of barriers_needed is based on number of sync pipeline |
| 449 |
* stages. |
| 450 |
*/ |
| 451 |
uint32_t barriers_needed[PVR_NUM_SYNC_PIPELINE_STAGES]; |
| 452 |
|
| 453 |
struct pvr_descriptor_state gfx_desc_state; |
| 454 |
struct pvr_descriptor_state compute_desc_state; |
| 455 |
|
| 456 |
struct pvr_push_constants push_consts[PVR_STAGE_ALLOCATION_COUNT]; |
| 457 |
|
| 458 |
VkFormat depth_format; |
| 459 |
|
| 460 |
struct { |
| 461 |
bool compute_pipeline_binding : 1; |
| 462 |
bool compute_desc_dirty : 1; |
| 463 |
|
| 464 |
bool gfx_pipeline_binding : 1; |
| 465 |
bool gfx_desc_dirty : 1; |
| 466 |
|
| 467 |
bool vertex_bindings : 1; |
| 468 |
bool index_buffer_binding : 1; |
| 469 |
bool vertex_descriptors : 1; |
| 470 |
bool fragment_descriptors : 1; |
| 471 |
|
| 472 |
bool isp_userpass : 1; |
| 473 |
|
| 474 |
/* Some draw state needs to be tracked for changes between draw calls |
| 475 |
* i.e. if we get a draw with baseInstance=0, followed by a call with |
| 476 |
* baseInstance=1 that needs to cause us to select a different PDS |
| 477 |
* attrib program and update the BASE_INSTANCE PDS const. If only |
| 478 |
* baseInstance changes then we just have to update the data section. |
| 479 |
*/ |
| 480 |
bool draw_base_instance : 1; |
| 481 |
bool draw_variant : 1; |
| 482 |
|
| 483 |
bool vis_test; |
| 484 |
} dirty; |
| 485 |
|
| 486 |
struct pvr_cmd_buffer_draw_state draw_state; |
| 487 |
|
| 488 |
struct { |
| 489 |
uint32_t code_offset; |
| 490 |
const struct pvr_pds_info *info; |
| 491 |
} pds_shader; |
| 492 |
|
| 493 |
const struct pvr_query_pool *query_pool; |
| 494 |
bool vis_test_enabled; |
| 495 |
uint32_t vis_reg; |
| 496 |
|
| 497 |
struct util_dynarray query_indices; |
| 498 |
|
| 499 |
uint32_t max_shared_regs; |
| 500 |
|
| 501 |
/* Address of data segment for vertex attrib upload program. */ |
| 502 |
uint32_t pds_vertex_attrib_offset; |
| 503 |
|
| 504 |
uint32_t pds_fragment_descriptor_data_offset; |
| 505 |
uint32_t pds_compute_descriptor_data_offset; |
| 506 |
}; |
| 507 |
|
| 508 |
/* Do not change this. This is the format used for the depth_bias_array |
| 509 |
* elements uploaded to the device. |
| 510 |
*/ |
| 511 |
struct pvr_depth_bias_state { |
| 512 |
/* Saved information from pCreateInfo. */ |
| 513 |
float constant_factor; |
| 514 |
float slope_factor; |
| 515 |
float clamp; |
| 516 |
}; |
| 517 |
|
| 518 |
/* Do not change this. This is the format used for the scissor_array |
| 519 |
* elements uploaded to the device. |
| 520 |
*/ |
| 521 |
struct pvr_scissor_words { |
| 522 |
/* Contains a packed IPF_SCISSOR_WORD_0. */ |
| 523 |
uint32_t w0; |
| 524 |
/* Contains a packed IPF_SCISSOR_WORD_1. */ |
| 525 |
uint32_t w1; |
| 526 |
}; |
| 527 |
|
| 528 |
struct pvr_cmd_buffer { |
| 529 |
struct vk_command_buffer vk; |
| 530 |
|
| 531 |
struct pvr_device *device; |
| 532 |
|
| 533 |
/* Buffer usage flags */ |
| 534 |
VkCommandBufferUsageFlags usage_flags; |
| 535 |
|
| 536 |
/* Array of struct pvr_depth_bias_state. */ |
| 537 |
struct util_dynarray depth_bias_array; |
| 538 |
|
| 539 |
/* Array of struct pvr_scissor_words. */ |
| 540 |
struct util_dynarray scissor_array; |
| 541 |
struct pvr_scissor_words scissor_words; |
| 542 |
|
| 543 |
struct pvr_cmd_buffer_state state; |
| 544 |
|
| 545 |
/* List of struct pvr_deferred_cs_command control stream related commands to |
| 546 |
* execute in secondary command buffer. |
| 547 |
*/ |
| 548 |
struct util_dynarray deferred_csb_commands; |
| 549 |
/* List of struct pvr_transfer_cmd used to emulate RTA clears on non RTA |
| 550 |
* capable cores. |
| 551 |
*/ |
| 552 |
struct list_head deferred_clears; |
| 553 |
|
| 554 |
/* List of pvr_bo structs associated with this cmd buffer. */ |
| 555 |
struct list_head bo_list; |
| 556 |
|
| 557 |
struct list_head sub_cmds; |
| 558 |
}; |
| 559 |
|
| 560 |
VK_DEFINE_HANDLE_CASTS(pvr_cmd_buffer, |
| 561 |
vk.base, |
| 562 |
VkCommandBuffer, |
| 563 |
VK_OBJECT_TYPE_COMMAND_BUFFER) |
| 564 |
|
| 565 |
/* This function is intended to be used when the error being set has been |
| 566 |
* returned from a function call, i.e. the error happened further down the |
| 567 |
* stack. `vk_command_buffer_set_error()` should be used at the point an error |
| 568 |
* occurs, i.e. VK_ERROR_* is being passed in. |
| 569 |
* This ensures we only ever get the error printed once. |
| 570 |
*/ |
| 571 |
static inline VkResult |
| 572 |
pvr_cmd_buffer_set_error_unwarned(struct pvr_cmd_buffer *cmd_buffer, |
| 573 |
VkResult error) |
| 574 |
{ |
| 575 |
assert(error != VK_SUCCESS); |
| 576 |
|
| 577 |
if (cmd_buffer->vk.record_result == VK_SUCCESS) |
| 578 |
cmd_buffer->vk.record_result = error; |
| 579 |
|
| 580 |
return error; |
| 581 |
} |
| 582 |
|
| 583 |
static inline bool pvr_sub_cmd_gfx_requires_split_submit( |
| 584 |
const struct pvr_sub_cmd_gfx *const sub_cmd) |
| 585 |
{ |
| 586 |
return sub_cmd->job.run_frag && sub_cmd->rstate->layers > 1; |
| 587 |
} |
| 588 |
|
| 589 |
#define PVR_CHECK_COMMAND_BUFFER_BUILDING_STATE(cmd_buffer) \ |
| 590 |
do { \ |
| 591 |
struct pvr_cmd_buffer *const _cmd_buffer = (cmd_buffer); \ |
| 592 |
const VkResult _record_result = \ |
| 593 |
vk_command_buffer_get_record_result(&_cmd_buffer->vk); \ |
| 594 |
\ |
| 595 |
if (_cmd_buffer->vk.state != MESA_VK_COMMAND_BUFFER_STATE_RECORDING) { \ |
| 596 |
vk_errorf(_cmd_buffer, \ |
| 597 |
VK_ERROR_OUT_OF_DEVICE_MEMORY, \ |
| 598 |
"Command buffer is not in recording state"); \ |
| 599 |
return; \ |
| 600 |
} else if (_record_result < VK_SUCCESS) { \ |
| 601 |
vk_errorf(_cmd_buffer, \ |
| 602 |
_record_result, \ |
| 603 |
"Skipping function as command buffer has " \ |
| 604 |
"previous build error"); \ |
| 605 |
return; \ |
| 606 |
} \ |
| 607 |
} while (0) |
| 608 |
|
| 609 |
#ifdef PVR_PER_ARCH |
| 610 |
|
| 611 |
VkResult PVR_PER_ARCH(cmd_buffer_add_transfer_cmd)( |
| 612 |
struct pvr_cmd_buffer *cmd_buffer, |
| 613 |
struct pvr_transfer_cmd *transfer_cmd); |
| 614 |
|
| 615 |
# define pvr_arch_cmd_buffer_add_transfer_cmd \ |
| 616 |
PVR_PER_ARCH(cmd_buffer_add_transfer_cmd) |
| 617 |
|
| 618 |
VkResult PVR_PER_ARCH(cmd_buffer_alloc_mem)( |
| 619 |
struct pvr_cmd_buffer *cmd_buffer, |
| 620 |
struct pvr_winsys_heap *heap, |
| 621 |
uint64_t size, |
| 622 |
struct pvr_suballoc_bo **const pvr_bo_out); |
| 623 |
|
| 624 |
# define pvr_arch_cmd_buffer_alloc_mem PVR_PER_ARCH(cmd_buffer_alloc_mem) |
| 625 |
|
| 626 |
VkResult PVR_PER_ARCH(cmd_buffer_upload_general)( |
| 627 |
struct pvr_cmd_buffer *const cmd_buffer, |
| 628 |
const void *const data, |
| 629 |
const size_t size, |
| 630 |
struct pvr_suballoc_bo **const pvr_bo_out); |
| 631 |
|
| 632 |
# define pvr_arch_cmd_buffer_upload_general \ |
| 633 |
PVR_PER_ARCH(cmd_buffer_upload_general) |
| 634 |
|
| 635 |
VkResult PVR_PER_ARCH(cmd_buffer_upload_pds)( |
| 636 |
struct pvr_cmd_buffer *const cmd_buffer, |
| 637 |
const uint32_t *data, |
| 638 |
uint32_t data_size_dwords, |
| 639 |
uint32_t data_alignment, |
| 640 |
const uint32_t *code, |
| 641 |
uint32_t code_size_dwords, |
| 642 |
uint32_t code_alignment, |
| 643 |
uint64_t min_alignment, |
| 644 |
struct pvr_pds_upload *const pds_upload_out); |
| 645 |
|
| 646 |
# define pvr_arch_cmd_buffer_upload_pds PVR_PER_ARCH(cmd_buffer_upload_pds) |
| 647 |
|
| 648 |
VkResult |
| 649 |
PVR_PER_ARCH(cmd_buffer_start_sub_cmd)(struct pvr_cmd_buffer *cmd_buffer, |
| 650 |
enum pvr_sub_cmd_type type); |
| 651 |
|
| 652 |
# define pvr_arch_cmd_buffer_start_sub_cmd \ |
| 653 |
PVR_PER_ARCH(cmd_buffer_start_sub_cmd) |
| 654 |
|
| 655 |
VkResult |
| 656 |
PVR_PER_ARCH(cmd_buffer_end_sub_cmd)(struct pvr_cmd_buffer *cmd_buffer); |
| 657 |
|
| 658 |
# define pvr_arch_cmd_buffer_end_sub_cmd PVR_PER_ARCH(cmd_buffer_end_sub_cmd) |
| 659 |
|
| 660 |
void PVR_PER_ARCH(compute_generate_fence)( |
| 661 |
struct pvr_cmd_buffer *cmd_buffer, |
| 662 |
struct pvr_sub_cmd_compute *const sub_cmd, |
| 663 |
bool deallocate_shareds); |
| 664 |
|
| 665 |
# define pvr_arch_compute_generate_fence PVR_PER_ARCH(compute_generate_fence) |
| 666 |
|
| 667 |
void PVR_PER_ARCH(compute_update_shared_private)( |
| 668 |
struct pvr_cmd_buffer *cmd_buffer, |
| 669 |
struct pvr_sub_cmd_compute *const sub_cmd, |
| 670 |
struct pvr_private_compute_pipeline *pipeline); |
| 671 |
|
| 672 |
# define pvr_arch_compute_update_shared_private \ |
| 673 |
PVR_PER_ARCH(compute_update_shared_private) |
| 674 |
|
| 675 |
void PVR_PER_ARCH(compute_update_kernel_private)( |
| 676 |
struct pvr_cmd_buffer *cmd_buffer, |
| 677 |
struct pvr_sub_cmd_compute *const sub_cmd, |
| 678 |
struct pvr_private_compute_pipeline *pipeline, |
| 679 |
const uint32_t global_workgroup_size[static const PVR_WORKGROUP_DIMENSIONS]); |
| 680 |
|
| 681 |
# define pvr_arch_compute_update_kernel_private \ |
| 682 |
PVR_PER_ARCH(compute_update_kernel_private) |
| 683 |
|
| 684 |
VkResult |
| 685 |
PVR_PER_ARCH(add_query_program)(struct pvr_cmd_buffer *cmd_buffer, |
| 686 |
const struct pvr_query_info *query_info); |
| 687 |
|
| 688 |
# define pvr_arch_add_query_program PVR_PER_ARCH(add_query_program) |
| 689 |
|
| 690 |
void PVR_PER_ARCH(reset_graphics_dirty_state)( |
| 691 |
struct pvr_cmd_buffer *const cmd_buffer, |
| 692 |
bool start_geom); |
| 693 |
|
| 694 |
# define pvr_arch_reset_graphics_dirty_state \ |
| 695 |
PVR_PER_ARCH(reset_graphics_dirty_state) |
| 696 |
|
| 697 |
void PVR_PER_ARCH(calculate_vertex_cam_size)( |
| 698 |
const struct pvr_device_info *dev_info, |
| 699 |
const uint32_t vs_output_size, |
| 700 |
const bool raster_enable, |
| 701 |
uint32_t *const cam_size_out, |
| 702 |
uint32_t *const vs_max_instances_out); |
| 703 |
|
| 704 |
# define pvr_arch_cmd_buffer_end_sub_cmd PVR_PER_ARCH(cmd_buffer_end_sub_cmd) |
| 705 |
|
| 706 |
void PVR_PER_ARCH(compute_generate_fence)( |
| 707 |
struct pvr_cmd_buffer *cmd_buffer, |
| 708 |
struct pvr_sub_cmd_compute *const sub_cmd, |
| 709 |
bool deallocate_shareds); |
| 710 |
|
| 711 |
# define pvr_arch_compute_generate_fence PVR_PER_ARCH(compute_generate_fence) |
| 712 |
|
| 713 |
void PVR_PER_ARCH(compute_update_shared_private)( |
| 714 |
struct pvr_cmd_buffer *cmd_buffer, |
| 715 |
struct pvr_sub_cmd_compute *const sub_cmd, |
| 716 |
struct pvr_private_compute_pipeline *pipeline); |
| 717 |
|
| 718 |
# define pvr_arch_compute_update_shared_private \ |
| 719 |
PVR_PER_ARCH(compute_update_shared_private) |
| 720 |
|
| 721 |
void PVR_PER_ARCH(compute_update_kernel_private)( |
| 722 |
struct pvr_cmd_buffer *cmd_buffer, |
| 723 |
struct pvr_sub_cmd_compute *const sub_cmd, |
| 724 |
struct pvr_private_compute_pipeline *pipeline, |
| 725 |
const uint32_t global_workgroup_size[static const PVR_WORKGROUP_DIMENSIONS]); |
| 726 |
|
| 727 |
# define pvr_arch_compute_update_kernel_private \ |
| 728 |
PVR_PER_ARCH(compute_update_kernel_private) |
| 729 |
|
| 730 |
VkResult |
| 731 |
PVR_PER_ARCH(add_query_program)(struct pvr_cmd_buffer *cmd_buffer, |
| 732 |
const struct pvr_query_info *query_info); |
| 733 |
|
| 734 |
# define pvr_arch_add_query_program PVR_PER_ARCH(add_query_program) |
| 735 |
|
| 736 |
void PVR_PER_ARCH(reset_graphics_dirty_state)( |
| 737 |
struct pvr_cmd_buffer *const cmd_buffer, |
| 738 |
bool start_geom); |
| 739 |
|
| 740 |
# define pvr_arch_reset_graphics_dirty_state \ |
| 741 |
PVR_PER_ARCH(reset_graphics_dirty_state) |
| 742 |
|
| 743 |
void PVR_PER_ARCH(calculate_vertex_cam_size)( |
| 744 |
const struct pvr_device_info *dev_info, |
| 745 |
const uint32_t vs_output_size, |
| 746 |
const bool raster_enable, |
| 747 |
uint32_t *const cam_size_out, |
| 748 |
uint32_t *const vs_max_instances_out); |
| 749 |
|
| 750 |
# define pvr_arch_calculate_vertex_cam_size \ |
| 751 |
PVR_PER_ARCH(calculate_vertex_cam_size) |
| 752 |
|
| 753 |
const struct pvr_renderpass_hwsetup_subpass * |
| 754 |
PVR_PER_ARCH(get_hw_subpass)(const struct pvr_render_pass *pass, |
| 755 |
const uint32_t subpass); |
| 756 |
|
| 757 |
# define pvr_arch_get_hw_subpass PVR_PER_ARCH(get_hw_subpass) |
| 758 |
|
| 759 |
struct pvr_renderpass_hwsetup_render *PVR_PER_ARCH(pass_info_get_hw_render)( |
| 760 |
const struct pvr_render_pass_info *render_pass_info, |
| 761 |
uint32_t idx); |
| 762 |
|
| 763 |
# define pvr_arch_pass_info_get_hw_render \ |
| 764 |
PVR_PER_ARCH(pass_info_get_hw_render) |
| 765 |
|
| 766 |
#endif /* PVR_PER_ARCH */ |
| 767 |
|
| 768 |
#endif /* PVR_CMD_BUFFER_H */ |