• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012 Advanced Micro Devices, Inc.
3  *
4  * SPDX-License-Identifier: MIT
5  */
6 
7 #ifndef SI_PM4_H
8 #define SI_PM4_H
9 
10 #include <stdint.h>
11 #include <stdbool.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /* forward definitions */
18 struct si_screen;
19 struct si_context;
20 
21 /* State atoms are callbacks which write a sequence of packets into a GPU
22  * command buffer (AKA indirect buffer, AKA IB, AKA command stream, AKA CS).
23  */
24 struct si_atom {
25    /* The index is only used by si_pm4_emit_state. Non-pm4 atoms don't use it. */
26    void (*emit)(struct si_context *ctx, unsigned index);
27 };
28 
29 struct si_pm4_state {
30    struct si_screen *screen;
31 
32    /* PKT3_SET_*_REG handling */
33    uint16_t last_reg;   /* register offset in dwords */
34    uint16_t last_pm4;
35    uint16_t ndw;        /* number of dwords in pm4 */
36    uint8_t last_opcode;
37    uint8_t last_idx;
38    bool is_compute_queue;
39    bool packed_is_padded; /* whether SET_*_REG_PAIRS_PACKED is padded to an even number of regs */
40 
41    /* For shader states only */
42    struct si_atom atom;
43 
44    /* commands for the DE */
45    uint16_t max_dw;
46 
47    /* Used by SQTT to override the shader address */
48    uint32_t spi_shader_pgm_lo_reg;
49 
50    /* This must be the last field because the array can continue after the structure. */
51    uint32_t pm4[64];
52 };
53 
54 void si_pm4_cmd_add(struct si_pm4_state *state, uint32_t dw);
55 void si_pm4_set_reg(struct si_pm4_state *state, unsigned reg, uint32_t val);
56 void si_pm4_set_reg_idx3(struct si_pm4_state *state, unsigned reg, uint32_t val);
57 void si_pm4_finalize(struct si_pm4_state *state);
58 
59 void si_pm4_clear_state(struct si_pm4_state *state, struct si_screen *sscreen,
60                         bool is_compute_queue);
61 void si_pm4_free_state(struct si_context *sctx, struct si_pm4_state *state, unsigned idx);
62 
63 void si_pm4_emit_commands(struct si_context *sctx, struct si_pm4_state *state);
64 void si_pm4_emit_state(struct si_context *sctx, unsigned index);
65 void si_pm4_emit_shader(struct si_context *sctx, unsigned index);
66 void si_pm4_reset_emitted(struct si_context *sctx);
67 struct si_pm4_state *si_pm4_create_sized(struct si_screen *sscreen, unsigned max_dw,
68                                          bool is_compute_queue);
69 struct si_pm4_state *si_pm4_clone(struct si_pm4_state *orig);
70 
71 #ifdef __cplusplus
72 }
73 #endif
74 
75 #endif
76