1 #ifndef COMMON_CMDBUF_H
2 #define COMMON_CMDBUF_H
4 void rcommonEnsureCmdBufSpace(radeonContextPtr rmesa
, int dwords
, const char *caller
);
5 int rcommonFlushCmdBuf(radeonContextPtr rmesa
, const char *caller
);
6 int rcommonFlushCmdBufLocked(radeonContextPtr rmesa
, const char *caller
);
7 void rcommonInitCmdBuf(radeonContextPtr rmesa
, int max_state_size
);
8 void rcommonDestroyCmdBuf(radeonContextPtr rmesa
);
10 void rcommonBeginBatch(radeonContextPtr rmesa
,
17 #define RADEON_CP_PACKET3_NOP 0xC0001000
18 #define RADEON_CP_PACKET3_NEXT_CHAR 0xC0001900
19 #define RADEON_CP_PACKET3_PLY_NEXTSCAN 0xC0001D00
20 #define RADEON_CP_PACKET3_SET_SCISSORS 0xC0001E00
21 #define RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300
22 #define RADEON_CP_PACKET3_LOAD_MICROCODE 0xC0002400
23 #define RADEON_CP_PACKET3_WAIT_FOR_IDLE 0xC0002600
24 #define RADEON_CP_PACKET3_3D_DRAW_VBUF 0xC0002800
25 #define RADEON_CP_PACKET3_3D_DRAW_IMMD 0xC0002900
26 #define RADEON_CP_PACKET3_3D_DRAW_INDX 0xC0002A00
27 #define RADEON_CP_PACKET3_LOAD_PALETTE 0xC0002C00
28 #define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
29 #define RADEON_CP_PACKET3_CNTL_PAINT 0xC0009100
30 #define RADEON_CP_PACKET3_CNTL_BITBLT 0xC0009200
31 #define RADEON_CP_PACKET3_CNTL_SMALLTEXT 0xC0009300
32 #define RADEON_CP_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400
33 #define RADEON_CP_PACKET3_CNTL_POLYLINE 0xC0009500
34 #define RADEON_CP_PACKET3_CNTL_POLYSCANLINES 0xC0009800
35 #define RADEON_CP_PACKET3_CNTL_PAINT_MULTI 0xC0009A00
36 #define RADEON_CP_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
37 #define RADEON_CP_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
39 #define CP_PACKET2 (2 << 30)
40 #define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
41 #define CP_PACKET0_ONE(reg, n) (RADEON_CP_PACKET0 | RADEON_CP_PACKET0_ONE_REG_WR | ((n)<<16) | ((reg)>>2))
42 #define CP_PACKET3( pkt, n ) \
43 (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
46 * Every function writing to the command buffer needs to declare this
47 * to get the necessary local variables.
49 #define BATCH_LOCALS(rmesa) \
50 const radeonContextPtr b_l_rmesa = rmesa
53 * Prepare writing n dwords to the command buffer,
54 * including producing any necessary state emits on buffer wraparound.
56 #define BEGIN_BATCH(n) rcommonBeginBatch(b_l_rmesa, n, 1, __FILE__, __FUNCTION__, __LINE__)
59 * Same as BEGIN_BATCH, but do not cause automatic state emits.
61 #define BEGIN_BATCH_NO_AUTOSTATE(n) rcommonBeginBatch(b_l_rmesa, n, 0, __FILE__, __FUNCTION__, __LINE__)
64 * Write one dword to the command buffer.
66 #define OUT_BATCH(data) \
68 radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, data);\
72 * Write a relocated dword to the command buffer.
74 #define OUT_BATCH_RELOC(data, bo, offset, rd, wd, flags) \
77 fprintf(stderr, "(%s:%s:%d) offset : %d\n",\
78 __FILE__, __FUNCTION__, __LINE__, offset);\
80 radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, offset);\
81 radeon_cs_write_reloc(b_l_rmesa->cmdbuf.cs, \
90 * Write n dwords from ptr to the command buffer.
92 #define OUT_BATCH_TABLE(ptr,n) \
95 for (_i=0; _i < n; _i++) {\
96 radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, ptr[_i]);\
101 * Finish writing dwords to the command buffer.
102 * The number of (direct or indirect) OUT_BATCH calls between the previous
103 * BEGIN_BATCH and END_BATCH must match the number specified at BEGIN_BATCH time.
105 #define END_BATCH() \
107 radeon_cs_end(b_l_rmesa->cmdbuf.cs, __FILE__, __FUNCTION__, __LINE__);\
111 * After the last END_BATCH() of rendering, this indicates that flushing
112 * the command buffer now is okay.
114 #define COMMIT_BATCH() \
119 /** Single register write to command buffer; requires 2 dwords. */
120 #define OUT_BATCH_REGVAL(reg, val) \
121 OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), 1)); \
124 /** Continuous register range write to command buffer; requires 1 dword,
125 * expects count dwords afterwards for register contents. */
126 #define OUT_BATCH_REGSEQ(reg, count) \
127 OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), (count)));
129 /** Write a 32 bit float to the ring; requires 1 dword. */
130 #define OUT_BATCH_FLOAT32(f) \
131 OUT_BATCH(radeonPackFloat32((f)));