v3d: Put default vertex attribute values into the state uploader as well.
[mesa.git] / src / gallium / drivers / nouveau / nv30 / nv30_winsys.h
1 #ifndef __NV30_WINSYS_H__
2 #define __NV30_WINSYS_H__
3
4 #include <string.h>
5 #include "nouveau_winsys.h"
6 #include "nouveau_buffer.h"
7
8 /*XXX: rnn */
9 #define NV40_3D_VTXTEX_OFFSET(i) (0x0900 + ((i) * 0x20)) // 401e80
10 #define NV40_3D_VTXTEX_FORMAT(i) (0x0904 + ((i) * 0x20)) // 401e90
11 #define NV40_3D_VTXTEX_WRAP(i) (0x0908 + ((i) * 0x20)) // 401ea0
12 #define NV40_3D_VTXTEX_ENABLE(i) (0x090c + ((i) * 0x20)) // 401eb0
13 #define NV40_3D_VTXTEX_SWZ(i) (0x0910 + ((i) * 0x20)) // 401ec0
14 #define NV40_3D_VTXTEX_FILTER(i) (0x0914 + ((i) * 0x20)) // 401ed0
15 #define NV40_3D_VTXTEX_SIZE(i) (0x0918 + ((i) * 0x20)) // 401ee0
16 #define NV40_3D_VTXTEX_BCOL(i) (0x091c + ((i) * 0x20)) // 401ef0
17 #define NV30_3D_VTX_CACHE_INVALIDATE_1710 0x1710
18 #define NV30_3D_R1718 0x1718
19 #define NV40_3D_PRIM_RESTART_ENABLE 0x1dac
20 #define NV40_3D_PRIM_RESTART_INDEX 0x1db0
21
22 static inline void
23 PUSH_RELOC(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t offset,
24 uint32_t flags, uint32_t vor, uint32_t tor)
25 {
26 nouveau_pushbuf_reloc(push, bo, offset, flags, vor, tor);
27 }
28
29 static inline struct nouveau_bufctx *
30 bufctx(struct nouveau_pushbuf *push)
31 {
32 struct nouveau_bufctx **pctx = push->user_priv;
33 return *pctx;
34 }
35
36 static inline void
37 PUSH_RESET(struct nouveau_pushbuf *push, int bin)
38 {
39 nouveau_bufctx_reset(bufctx(push), bin);
40 }
41
42 static inline void
43 PUSH_REFN(struct nouveau_pushbuf *push, int bin,
44 struct nouveau_bo *bo, uint32_t access)
45 {
46 nouveau_bufctx_refn(bufctx(push), bin, bo, access);
47 }
48
49 static inline void
50 PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
51 struct nouveau_bo *bo, uint32_t offset, uint32_t access)
52 {
53 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
54 bo, offset, access | NOUVEAU_BO_LOW, 0, 0)->priv = NULL;
55 PUSH_DATA(push, bo->offset + offset);
56 }
57
58 static inline void
59 PUSH_MTHDo(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
60 struct nouveau_bo *bo, uint32_t access, uint32_t vor, uint32_t tor)
61 {
62 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
63 bo, 0, access | NOUVEAU_BO_OR, vor, tor)->priv = NULL;
64 if (bo->flags & NOUVEAU_BO_VRAM)
65 PUSH_DATA(push, vor);
66 else
67 PUSH_DATA(push, tor);
68 }
69
70 static inline void
71 PUSH_MTHDs(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
72 struct nouveau_bo *bo, uint32_t data, uint32_t access,
73 uint32_t vor, uint32_t tor)
74 {
75 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
76 bo, data, access | NOUVEAU_BO_OR, vor, tor)->priv = NULL;
77 if (bo->flags & NOUVEAU_BO_VRAM)
78 PUSH_DATA(push, data | vor);
79 else
80 PUSH_DATA(push, data | tor);
81 }
82
83 static inline struct nouveau_bufref *
84 PUSH_MTHD(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
85 struct nouveau_bo *bo, uint32_t data, uint32_t access,
86 uint32_t vor, uint32_t tor)
87 {
88 struct nouveau_bufref *bref =
89 nouveau_bufctx_mthd(bufctx(push), bin, (1 << 18) | (subc << 13) | mthd,
90 bo, data, access | NOUVEAU_BO_OR, vor, tor);
91 if (access & NOUVEAU_BO_LOW)
92 data += bo->offset;
93 if (bo->flags & NOUVEAU_BO_VRAM)
94 data |= vor;
95 else
96 data |= tor;
97 PUSH_DATA(push, data);
98 bref->priv = NULL;
99 return bref;
100 }
101
102 static inline void
103 PUSH_RESRC(struct nouveau_pushbuf *push, int subc, int mthd, int bin,
104 struct nv04_resource *r, uint32_t data, uint32_t access,
105 uint32_t vor, uint32_t tor)
106 {
107 PUSH_MTHD(push, subc, mthd, bin, r->bo, r->offset + data,
108 r->domain | access, vor, tor)->priv = r;
109 }
110
111 static inline void
112 BEGIN_NV04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
113 {
114 PUSH_SPACE(push, size + 1);
115 PUSH_DATA (push, 0x00000000 | (size << 18) | (subc << 13) | mthd);
116 }
117
118 static inline void
119 BEGIN_NI04(struct nouveau_pushbuf *push, int subc, int mthd, int size)
120 {
121 PUSH_SPACE(push, size + 1);
122 PUSH_DATA (push, 0x40000000 | (size << 18) | (subc << 13) | mthd);
123 }
124
125 /* subchannel assignment
126 *
127 * 0: <1.0.0 - used by kernel for m2mf
128 * 1.0.0 - used by kernel for nvsw
129 *
130 * 1: <1.0.0 - used by kernel for nvsw
131 * 1.0.0 - free for userspace
132 *
133 * 2-7: free for userspace on all kernel versions
134 */
135
136 #define SUBC_M2MF(mthd) 2, (mthd)
137 #define NV03_M2MF(mthd) SUBC_M2MF(NV03_M2MF_##mthd)
138
139 #define SUBC_SF2D(mthd) 3, (mthd)
140 #define NV04_SF2D(mthd) SUBC_SF2D(NV04_SURFACE_2D_##mthd)
141
142 #define SUBC_SSWZ(mthd) 4, (mthd)
143 #define NV04_SSWZ(mthd) SUBC_SSWZ(NV04_SURFACE_SWZ_##mthd)
144
145 #define SUBC_SIFM(mthd) 5, (mthd)
146 #define NV03_SIFM(mthd) SUBC_SIFM(NV03_SIFM_##mthd)
147 #define NV05_SIFM(mthd) SUBC_SIFM(NV05_SIFM_##mthd)
148
149 #define SUBC_3D(mthd) 7, (mthd)
150 #define NV30_3D(mthd) SUBC_3D(NV30_3D_##mthd)
151 #define NV40_3D(mthd) SUBC_3D(NV40_3D_##mthd)
152
153 #define NV01_SUBC(subc, mthd) SUBC_##subc((NV01_SUBCHAN_##mthd))
154 #define NV11_SUBC(subc, mthd) SUBC_##subc((NV11_SUBCHAN_##mthd))
155
156 #define NV04_GRAPH(subc, mthd) SUBC_##subc((NV04_GRAPH_##mthd))
157
158 #endif