2 * Copyright © 2014 Broadcom
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
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
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 NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30 #include "util/u_simple_list.h"
78 struct simple_node
*next
;
79 struct simple_node
*prev
;
83 struct simple_node link
;
92 * Coordinate shader, runs during binning, before the VS, and just
100 enum quniform_contents
{
102 * Indicates that a constant 32-bit value is copied from the program's
107 * Indicates that the program's uniform contents are used as an index
108 * into the GL uniform storage.
113 * Scaling factors from clip coordinates to relative to the viewport
116 * This is used by the coordinate and vertex shaders to produce the
117 * 32-bit entry consisting of 2 16-bit fields with 12.4 signed fixed
118 * point offsets from the viewport ccenter.
120 QUNIFORM_VIEWPORT_X_SCALE
,
121 QUNIFORM_VIEWPORT_Y_SCALE
,
129 struct simple_node instructions
;
130 uint32_t immediates
[1024];
132 struct simple_node qpu_inst_list
;
134 uint32_t qpu_inst_count
;
135 uint32_t qpu_inst_size
;
139 struct qcompile
*qir_compile_init(void);
140 void qir_compile_destroy(struct qcompile
*c
);
141 struct qinst
*qir_inst(enum qop op
, struct qreg dst
,
142 struct qreg src0
, struct qreg src1
);
143 struct qinst
*qir_inst4(enum qop op
, struct qreg dst
,
148 void qir_emit(struct qcompile
*c
, struct qinst
*inst
);
149 struct qreg
qir_get_temp(struct qcompile
*c
);
150 int qir_get_op_nsrc(enum qop qop
);
151 bool qir_reg_equals(struct qreg a
, struct qreg b
);
152 bool qir_has_side_effects(struct qinst
*inst
);
154 void qir_dump(struct qcompile
*c
);
155 void qir_dump_inst(struct qinst
*inst
);
156 const char *qir_get_stage_name(enum qstage stage
);
158 void qir_optimize(struct qcompile
*c
);
159 bool qir_opt_algebraic(struct qcompile
*c
);
160 bool qir_opt_copy_propagation(struct qcompile
*c
);
161 bool qir_opt_dead_code(struct qcompile
*c
);
163 #define QIR_ALU1(name) \
164 static inline struct qreg \
165 qir_##name(struct qcompile *c, struct qreg a) \
167 struct qreg t = qir_get_temp(c); \
168 qir_emit(c, qir_inst(QOP_##name, t, a, c->undef)); \
172 #define QIR_ALU2(name) \
173 static inline struct qreg \
174 qir_##name(struct qcompile *c, struct qreg a, struct qreg b) \
176 struct qreg t = qir_get_temp(c); \
177 qir_emit(c, qir_inst(QOP_##name, t, a, b)); \
195 QIR_ALU2(PACK_SCALED
)
199 qir_VPM_WRITE(struct qcompile
*c
, struct qreg a
)
201 qir_emit(c
, qir_inst(QOP_VPM_WRITE
, c
->undef
, a
, c
->undef
));
204 static inline struct qreg
205 qir_CMP(struct qcompile
*c
, struct qreg cmp
, struct qreg a
, struct qreg b
)
207 struct qreg t
= qir_get_temp(c
);
208 qir_emit(c
, qir_inst4(QOP_CMP
, t
, cmp
, a
, b
, c
->undef
));
212 #endif /* VC4_QIR_H */