10d98afaf00ce6830a88ee82f5909c95b524f2c3
[mesa.git] / src / gallium / drivers / r600 / r600_asm.h
1 /*
2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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 R600_ASM_H
24 #define R600_ASM_H
25
26 #include "radeon.h"
27 #include "util/u_double_list.h"
28
29 struct r600_bc_alu_src {
30 unsigned sel;
31 unsigned chan;
32 unsigned neg;
33 unsigned abs;
34 };
35
36 struct r600_bc_alu_dst {
37 unsigned sel;
38 unsigned chan;
39 unsigned clamp;
40 unsigned write;
41 };
42
43 struct r600_bc_alu {
44 struct list_head list;
45 struct r600_bc_alu_src src[3];
46 struct r600_bc_alu_dst dst;
47 unsigned inst;
48 unsigned last;
49 unsigned is_op3;
50 unsigned nliteral;
51 unsigned literal_added;
52 u32 value[4];
53 };
54
55 struct r600_bc_tex {
56 struct list_head list;
57 unsigned inst;
58 unsigned resource_id;
59 unsigned src_gpr;
60 unsigned src_rel;
61 unsigned dst_gpr;
62 unsigned dst_rel;
63 unsigned dst_sel_x;
64 unsigned dst_sel_y;
65 unsigned dst_sel_z;
66 unsigned dst_sel_w;
67 unsigned lod_bias;
68 unsigned coord_type_x;
69 unsigned coord_type_y;
70 unsigned coord_type_z;
71 unsigned coord_type_w;
72 unsigned offset_x;
73 unsigned offset_y;
74 unsigned offset_z;
75 unsigned sampler_id;
76 unsigned src_sel_x;
77 unsigned src_sel_y;
78 unsigned src_sel_z;
79 unsigned src_sel_w;
80 };
81
82 struct r600_bc_vtx {
83 struct list_head list;
84 unsigned inst;
85 unsigned fetch_type;
86 unsigned buffer_id;
87 unsigned src_gpr;
88 unsigned src_sel_x;
89 unsigned mega_fetch_count;
90 unsigned dst_gpr;
91 unsigned dst_sel_x;
92 unsigned dst_sel_y;
93 unsigned dst_sel_z;
94 unsigned dst_sel_w;
95 };
96
97 struct r600_bc_output {
98 unsigned array_base;
99 unsigned type;
100 unsigned end_of_program;
101 unsigned inst;
102 unsigned elem_size;
103 unsigned gpr;
104 unsigned swizzle_x;
105 unsigned swizzle_y;
106 unsigned swizzle_z;
107 unsigned swizzle_w;
108 unsigned barrier;
109 };
110
111 struct r600_bc_cf {
112 struct list_head list;
113 unsigned inst;
114 unsigned addr;
115 unsigned ndw;
116 unsigned id;
117 struct list_head alu;
118 struct list_head tex;
119 struct list_head vtx;
120 struct r600_bc_output output;
121 };
122
123 struct r600_bc {
124 enum radeon_family family;
125 struct list_head cf;
126 struct r600_bc_cf *cf_last;
127 unsigned ndw;
128 unsigned ncf;
129 unsigned ngpr;
130 unsigned nresource;
131 unsigned force_add_cf;
132 u32 *bytecode;
133 };
134
135 int r600_bc_init(struct r600_bc *bc, enum radeon_family family);
136 int r600_bc_add_alu(struct r600_bc *bc, const struct r600_bc_alu *alu);
137 int r600_bc_add_literal(struct r600_bc *bc, const u32 *value);
138 int r600_bc_add_vtx(struct r600_bc *bc, const struct r600_bc_vtx *vtx);
139 int r600_bc_add_tex(struct r600_bc *bc, const struct r600_bc_tex *tex);
140 int r600_bc_add_output(struct r600_bc *bc, const struct r600_bc_output *output);
141 int r600_bc_build(struct r600_bc *bc);
142
143 #endif