Tizen 2.0 Release
[profile/ivi/osmesa.git] / src / mesa / drivers / dri / nouveau / nouveau_bo_state.h
1 /*
2  * Copyright (C) 2009 Francisco Jerez.
3  * All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice (including the
14  * next paragraph) shall be included in all copies or substantial
15  * portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  *
25  */
26
27 #ifndef __NOUVEAU_BO_STATE_H__
28 #define __NOUVEAU_BO_STATE_H__
29
30 enum {
31         NOUVEAU_BO_CONTEXT_FRAMEBUFFER = 0,
32         NOUVEAU_BO_CONTEXT_HIERZ,
33         NOUVEAU_BO_CONTEXT_SURFACE,
34         NOUVEAU_BO_CONTEXT_TEXTURE0,
35         NOUVEAU_BO_CONTEXT_TEXTURE1,
36         NOUVEAU_BO_CONTEXT_TEXTURE2,
37         NOUVEAU_BO_CONTEXT_TEXTURE3,
38         NOUVEAU_BO_CONTEXT_VERTEX,
39         NUM_NOUVEAU_BO_CONTEXT
40 };
41
42 struct nouveau_bo_marker {
43         struct nouveau_grobj *gr;
44         uint32_t mthd;
45
46         struct nouveau_bo *bo;
47         uint32_t data;
48         uint32_t data2;
49         uint32_t vor;
50         uint32_t tor;
51         uint32_t flags;
52 };
53
54 struct nouveau_bo_context {
55         struct gl_context *ctx;
56
57         struct nouveau_bo_marker *marker;
58         int allocated;
59         int count;
60 };
61
62 struct nouveau_bo_state {
63         struct nouveau_bo_context context[NUM_NOUVEAU_BO_CONTEXT];
64         int count;
65 };
66
67 GLboolean
68 nouveau_bo_mark(struct nouveau_bo_context *bctx, struct nouveau_grobj *gr,
69                 uint32_t mthd, struct nouveau_bo *bo,
70                 uint32_t data, uint32_t data2, uint32_t vor, uint32_t tor,
71                 uint32_t flags);
72
73 #define nouveau_bo_markl(bctx, gr, mthd, bo, data, flags)               \
74         nouveau_bo_mark(bctx, gr, mthd, bo, data, 0, 0, 0,              \
75                         flags | NOUVEAU_BO_LOW);
76
77 #define nouveau_bo_marko(bctx, gr, mthd, bo, flags)                     \
78         nouveau_bo_mark(bctx, gr, mthd, bo, 0, 0,                       \
79                         context_chan(ctx)->vram->handle,                \
80                         context_chan(ctx)->gart->handle,                \
81                         flags | NOUVEAU_BO_OR);
82
83 void
84 nouveau_bo_context_reset(struct nouveau_bo_context *bctx);
85
86 GLboolean
87 nouveau_bo_state_emit(struct gl_context *ctx);
88
89 void
90 nouveau_bo_state_init(struct gl_context *ctx);
91
92 void
93 nouveau_bo_state_destroy(struct gl_context *ctx);
94
95 #define __context_bctx(ctx, i)                                          \
96         ({                                                              \
97                 struct nouveau_context *nctx = to_nouveau_context(ctx); \
98                 struct nouveau_bo_context *bctx = &nctx->bo.context[i]; \
99                 nouveau_bo_context_reset(bctx);                         \
100                 bctx;                                                   \
101         })
102 #define context_bctx(ctx, s) \
103         __context_bctx(ctx, NOUVEAU_BO_CONTEXT_##s)
104 #define context_bctx_i(ctx, s, i) \
105         __context_bctx(ctx, NOUVEAU_BO_CONTEXT_##s##0 + (i))
106
107 #endif