Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / mesa / pipe / nouveau / nouveau_push.h
1 #ifndef __NOUVEAU_PUSH_H__
2 #define __NOUVEAU_PUSH_H__
3
4 #include "pipe/nouveau/nouveau_winsys.h"
5
6 #ifndef NOUVEAU_PUSH_CONTEXT
7 #error undefined push context
8 #endif
9
10 #define OUT_RING(data) do { \
11 NOUVEAU_PUSH_CONTEXT(pc); \
12 (*pc->nvws->channel->pushbuf->cur++) = (data); \
13 } while(0)
14
15 #define OUT_RINGp(src,size) do { \
16 NOUVEAU_PUSH_CONTEXT(pc); \
17 memcpy(pc->nvws->channel->pushbuf->cur, (src), (size) * 4); \
18 pc->nvws->channel->pushbuf->cur += (size); \
19 } while(0)
20
21 #define OUT_RINGf(data) do { \
22 union { float v; uint32_t u; } c; \
23 c.v = (data); \
24 OUT_RING(c.u); \
25 } while(0)
26
27 #define BEGIN_RING(obj,mthd,size) do { \
28 NOUVEAU_PUSH_CONTEXT(pc); \
29 if (pc->nvws->channel->pushbuf->remaining < ((size) + 1)) \
30 pc->nvws->push_flush(pc->nvws->channel, ((size) + 1)); \
31 OUT_RING((pc->obj->subc << 13) | ((size) << 18) | (mthd)); \
32 pc->nvws->channel->pushbuf->remaining -= ((size) + 1); \
33 } while(0)
34
35 #define BEGIN_RING_NI(obj,mthd,size) do { \
36 BEGIN_RING(obj, (mthd) | 0x40000000, (size)); \
37 } while(0)
38
39 #define FIRE_RING() do { \
40 NOUVEAU_PUSH_CONTEXT(pc); \
41 pc->nvws->push_flush(pc->nvws->channel, 0); \
42 } while(0)
43
44 #define OUT_RELOC(bo,data,flags,vor,tor) do { \
45 NOUVEAU_PUSH_CONTEXT(pc); \
46 pc->nvws->push_reloc(pc->nvws->channel, \
47 pc->nvws->channel->pushbuf->cur++, \
48 (bo), (data), (flags), (vor), (tor)); \
49 } while(0)
50
51 /* Raw data + flags depending on FB/TT buffer */
52 #define OUT_RELOCd(bo,data,flags,vor,tor) do { \
53 OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor)); \
54 } while(0)
55
56 /* FB/TT object handle */
57 #define OUT_RELOCo(bo,flags) do { \
58 OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR, \
59 pc->nvws->channel->vram->handle, \
60 pc->nvws->channel->gart->handle); \
61 } while(0)
62
63 /* Low 32-bits of offset */
64 #define OUT_RELOCl(bo,delta,flags) do { \
65 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0); \
66 } while(0)
67
68 /* High 32-bits of offset */
69 #define OUT_RELOCh(bo,delta,flags) do { \
70 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0); \
71 } while(0)
72
73 /* A reloc which'll recombine into a NV_DMA_METHOD packet header */
74 #define OUT_RELOCm(bo, flags, obj, mthd, size) do { \
75 NOUVEAU_PUSH_CONTEXT(pc); \
76 if (pc->nvws->channel->pushbuf->remaining < ((size) + 1)) \
77 pc->nvws->push_flush(pc->nvws->channel, ((size) + 1)); \
78 OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd), \
79 (flags), 0, 0); \
80 pc->nvws->channel->pushbuf->remaining -= ((size) + 1); \
81 } while(0)
82
83 #endif