r300: Add blend state.
[mesa.git] / src / gallium / drivers / r300 / r300_cs.h
1 /*
2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #ifndef R300_CS_H
24 #define R300_CS_H
25
26 #include "r300_reg.h"
27 #include "r300_winsys.h"
28
29 /* Yes, I know macros are ugly. However, they are much prettier than the code
30 * that they neatly hide away, and don't have the cost of function setup,so
31 * we're going to use them. */
32
33 #define MAX_CS_SIZE 64 * 1024 / 4
34
35 /* XXX stolen from radeon_drm.h */
36 #define RADEON_GEM_DOMAIN_CPU 0x1
37 #define RADEON_GEM_DOMAIN_GTT 0x2
38 #define RADEON_GEM_DOMAIN_VRAM 0x4
39
40 #define CP_PACKET0(register, count) \
41 (RADEON_CP_PACKET0 | ((count) << 16) | ((register) >> 2))
42
43 #define CS_LOCALS(context) \
44 struct r300_winsys* cs_winsys = context->winsys; \
45 struct radeon_cs* cs = cs_winsys->cs
46
47
48 #define CHECK_CS(size) \
49 cs_winsys->check_cs(cs, (size))
50
51 #define BEGIN_CS(size) do { \
52 CHECK_CS(size); \
53 cs_winsys->begin_cs(cs, (size), __FILE__, __FUNCTION__, __LINE__); \
54 } while (0)
55
56 #define OUT_CS(value) \
57 cs_winsys->write_cs_dword(cs, value)
58
59 #define OUT_CS_REG(register, value) do { \
60 OUT_CS(CP_PACKET0(register, 0)); \
61 OUT_CS(value); } while (0)
62
63 #define OUT_CS_RELOC(bo, offset, rd, wd, flags) do { \
64 OUT_CS(offset); \
65 cs_winsys->write_cs_reloc(cs, bo, rd, wd, flags); \
66 } while (0)
67
68 #define END_CS \
69 cs_winsys->end_cs(cs, __FILE__, __FUNCTION__, __LINE__)
70
71 #define FLUSH_CS \
72 cs_winsys->flush_cs(cs)
73
74 #endif /* R300_CS_H */