1 #ifndef COMMON_CMDBUF_H
2 #define COMMON_CMDBUF_H
4 #include "radeon_bocs_wrapper.h"
6 void rcommonEnsureCmdBufSpace(radeonContextPtr rmesa
, int dwords
, const char *caller
);
7 int rcommonFlushCmdBuf(radeonContextPtr rmesa
, const char *caller
);
8 int rcommonFlushCmdBufLocked(radeonContextPtr rmesa
, const char *caller
);
9 void rcommonInitCmdBuf(radeonContextPtr rmesa
);
10 void rcommonDestroyCmdBuf(radeonContextPtr rmesa
);
12 void rcommonBeginBatch(radeonContextPtr rmesa
,
19 /* +r6/r7 : code here moved */
21 #define CP_PACKET2 (2 << 30)
22 #define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
23 #define CP_PACKET0_ONE(reg, n) (RADEON_CP_PACKET0 | RADEON_CP_PACKET0_ONE_REG_WR | ((n)<<16) | ((reg)>>2))
24 #define CP_PACKET3(pkt, n) (RADEON_CP_PACKET3 | (pkt) | ((n) << 16))
27 * Every function writing to the command buffer needs to declare this
28 * to get the necessary local variables.
30 #define BATCH_LOCALS(rmesa) \
31 const radeonContextPtr b_l_rmesa = rmesa
34 * Prepare writing n dwords to the command buffer,
35 * including producing any necessary state emits on buffer wraparound.
37 #define BEGIN_BATCH(n) rcommonBeginBatch(b_l_rmesa, n, 1, __FILE__, __FUNCTION__, __LINE__)
40 * Same as BEGIN_BATCH, but do not cause automatic state emits.
42 #define BEGIN_BATCH_NO_AUTOSTATE(n) rcommonBeginBatch(b_l_rmesa, n, 0, __FILE__, __FUNCTION__, __LINE__)
45 * Write one dword to the command buffer.
47 #define OUT_BATCH(data) \
49 radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, data);\
53 * Write a relocated dword to the command buffer.
55 #define OUT_BATCH_RELOC(data, bo, offset, rd, wd, flags) \
58 fprintf(stderr, "(%s:%s:%d) offset : %d\n", \
59 __FILE__, __FUNCTION__, __LINE__, offset); \
61 radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, offset); \
62 radeon_cs_write_reloc(b_l_rmesa->cmdbuf.cs, \
64 if (!b_l_rmesa->radeonScreen->kernel_mm) \
65 b_l_rmesa->cmdbuf.cs->section_cdw += 2; \
70 * Write n dwords from ptr to the command buffer.
72 #define OUT_BATCH_TABLE(ptr,n) \
75 for (_i=0; _i < n; _i++) {\
76 radeon_cs_write_dword(b_l_rmesa->cmdbuf.cs, ptr[_i]);\
81 * Finish writing dwords to the command buffer.
82 * The number of (direct or indirect) OUT_BATCH calls between the previous
83 * BEGIN_BATCH and END_BATCH must match the number specified at BEGIN_BATCH time.
87 radeon_cs_end(b_l_rmesa->cmdbuf.cs, __FILE__, __FUNCTION__, __LINE__);\
91 * After the last END_BATCH() of rendering, this indicates that flushing
92 * the command buffer now is okay.
94 #define COMMIT_BATCH() \
99 /** Single register write to command buffer; requires 2 dwords. */
100 #define OUT_BATCH_REGVAL(reg, val) \
101 OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), 1)); \
104 /** Continuous register range write to command buffer; requires 1 dword,
105 * expects count dwords afterwards for register contents. */
106 #define OUT_BATCH_REGSEQ(reg, count) \
107 OUT_BATCH(cmdpacket0(b_l_rmesa->radeonScreen, (reg), (count)))
109 /** Write a 32 bit float to the ring; requires 1 dword. */
110 #define OUT_BATCH_FLOAT32(f) \
111 OUT_BATCH(radeonPackFloat32((f)))
113 /* +r6/r7 : code here moved */
115 /* Fire the buffered vertices no matter what.
117 static INLINE
void radeon_firevertices(radeonContextPtr radeon
)
119 if (radeon
->cmdbuf
.cs
->cdw
|| radeon
->dma
.flush
)
120 radeon
->glCtx
->Driver
.Flush(radeon
->glCtx
); /* +r6/r7 */