Merge remote branch 'upstream/gallium-0.2' into nouveau-gallium-0.2
[mesa.git] / src / gallium / drivers / nouveau / nouveau_push.h
1 #ifndef __NOUVEAU_PUSH_H__
2 #define __NOUVEAU_PUSH_H__
3
4 #include "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, ((size) + 1), NULL); \
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(fence) do { \
40 NOUVEAU_PUSH_CONTEXT(pc); \
41 pc->nvws->push_flush(pc->nvws, 0, fence); \
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, pc->nvws->channel->pushbuf->cur++, \
47 (bo), (data), (flags), (vor), (tor)); \
48 } while(0)
49
50 /* Raw data + flags depending on FB/TT buffer */
51 #define OUT_RELOCd(bo,data,flags,vor,tor) do { \
52 OUT_RELOC((bo), (data), (flags) | NOUVEAU_BO_OR, (vor), (tor)); \
53 } while(0)
54
55 /* FB/TT object handle */
56 #define OUT_RELOCo(bo,flags) do { \
57 OUT_RELOC((bo), 0, (flags) | NOUVEAU_BO_OR, \
58 pc->nvws->channel->vram->handle, \
59 pc->nvws->channel->gart->handle); \
60 } while(0)
61
62 /* Low 32-bits of offset */
63 #define OUT_RELOCl(bo,delta,flags) do { \
64 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_LOW, 0, 0); \
65 } while(0)
66
67 /* High 32-bits of offset */
68 #define OUT_RELOCh(bo,delta,flags) do { \
69 OUT_RELOC((bo), (delta), (flags) | NOUVEAU_BO_HIGH, 0, 0); \
70 } while(0)
71
72 /* A reloc which'll recombine into a NV_DMA_METHOD packet header */
73 #define OUT_RELOCm(bo, flags, obj, mthd, size) do { \
74 NOUVEAU_PUSH_CONTEXT(pc); \
75 if (pc->nvws->channel->pushbuf->remaining < ((size) + 1)) \
76 pc->nvws->push_flush(pc->nvws->channel, ((size) + 1), NULL); \
77 OUT_RELOCd((bo), (pc->obj->subc << 13) | ((size) << 18) | (mthd), \
78 (flags), 0, 0); \
79 pc->nvws->channel->pushbuf->remaining -= ((size) + 1); \
80 } while(0)
81
82 #endif