1 /**************************************************************************
3 * Copyright 2009 Younes Manton.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "vl_shader_build.h"
30 #include <tgsi/tgsi_parse.h>
31 #include <tgsi/tgsi_build.h>
33 struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
35 struct tgsi_full_declaration decl = tgsi_default_full_declaration();
37 decl.Declaration.File = TGSI_FILE_INPUT;
38 decl.Declaration.Semantic = 1;
39 decl.Semantic.Name = name;
40 decl.Semantic.Index = index;
41 decl.Range.First = first;
42 decl.Range.Last = last;
47 struct tgsi_full_declaration vl_decl_interpolated_input
56 struct tgsi_full_declaration decl = tgsi_default_full_declaration();
60 interpolation == TGSI_INTERPOLATE_CONSTANT ||
61 interpolation == TGSI_INTERPOLATE_LINEAR ||
62 interpolation == TGSI_INTERPOLATE_PERSPECTIVE
65 decl.Declaration.File = TGSI_FILE_INPUT;
66 decl.Declaration.Semantic = 1;
67 decl.Semantic.Name = name;
68 decl.Semantic.Index = index;
69 decl.Declaration.Interpolate = interpolation;;
70 decl.Range.First = first;
71 decl.Range.Last = last;
76 struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
78 struct tgsi_full_declaration decl = tgsi_default_full_declaration();
80 decl.Declaration.File = TGSI_FILE_CONSTANT;
81 decl.Declaration.Semantic = 1;
82 decl.Semantic.Name = name;
83 decl.Semantic.Index = index;
84 decl.Range.First = first;
85 decl.Range.Last = last;
90 struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
92 struct tgsi_full_declaration decl = tgsi_default_full_declaration();
94 decl.Declaration.File = TGSI_FILE_OUTPUT;
95 decl.Declaration.Semantic = 1;
96 decl.Semantic.Name = name;
97 decl.Semantic.Index = index;
98 decl.Range.First = first;
99 decl.Range.Last = last;
104 struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last)
106 struct tgsi_full_declaration decl = tgsi_default_full_declaration();
108 decl = tgsi_default_full_declaration();
109 decl.Declaration.File = TGSI_FILE_TEMPORARY;
110 decl.Range.First = first;
111 decl.Range.Last = last;
116 struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last)
118 struct tgsi_full_declaration decl = tgsi_default_full_declaration();
120 decl = tgsi_default_full_declaration();
121 decl.Declaration.File = TGSI_FILE_SAMPLER;
122 decl.Range.First = first;
123 decl.Range.Last = last;
128 struct tgsi_full_instruction vl_inst2
131 enum tgsi_file_type dst_file,
132 unsigned int dst_index,
133 enum tgsi_file_type src_file,
134 unsigned int src_index
137 struct tgsi_full_instruction inst = tgsi_default_full_instruction();
139 inst.Instruction.Opcode = opcode;
140 inst.Instruction.NumDstRegs = 1;
141 inst.Dst[0].Register.File = dst_file;
142 inst.Dst[0].Register.Index = dst_index;
143 inst.Instruction.NumSrcRegs = 1;
144 inst.Src[0].Register.File = src_file;
145 inst.Src[0].Register.Index = src_index;
150 struct tgsi_full_instruction vl_inst3
153 enum tgsi_file_type dst_file,
154 unsigned int dst_index,
155 enum tgsi_file_type src1_file,
156 unsigned int src1_index,
157 enum tgsi_file_type src2_file,
158 unsigned int src2_index
161 struct tgsi_full_instruction inst = tgsi_default_full_instruction();
163 inst.Instruction.Opcode = opcode;
164 inst.Instruction.NumDstRegs = 1;
165 inst.Dst[0].Register.File = dst_file;
166 inst.Dst[0].Register.Index = dst_index;
167 inst.Instruction.NumSrcRegs = 2;
168 inst.Src[0].Register.File = src1_file;
169 inst.Src[0].Register.Index = src1_index;
170 inst.Src[1].Register.File = src2_file;
171 inst.Src[1].Register.Index = src2_index;
176 struct tgsi_full_instruction vl_tex
179 enum tgsi_file_type dst_file,
180 unsigned int dst_index,
181 enum tgsi_file_type src1_file,
182 unsigned int src1_index,
183 enum tgsi_file_type src2_file,
184 unsigned int src2_index
187 struct tgsi_full_instruction inst = tgsi_default_full_instruction();
189 inst.Instruction.Opcode = TGSI_OPCODE_TEX;
190 inst.Instruction.NumDstRegs = 1;
191 inst.Dst[0].Register.File = dst_file;
192 inst.Dst[0].Register.Index = dst_index;
193 inst.Instruction.NumSrcRegs = 2;
194 inst.Instruction.Texture = 1;
195 inst.Texture.Texture = tex;
196 inst.Src[0].Register.File = src1_file;
197 inst.Src[0].Register.Index = src1_index;
198 inst.Src[1].Register.File = src2_file;
199 inst.Src[1].Register.Index = src2_index;
204 struct tgsi_full_instruction vl_inst4
207 enum tgsi_file_type dst_file,
208 unsigned int dst_index,
209 enum tgsi_file_type src1_file,
210 unsigned int src1_index,
211 enum tgsi_file_type src2_file,
212 unsigned int src2_index,
213 enum tgsi_file_type src3_file,
214 unsigned int src3_index
217 struct tgsi_full_instruction inst = tgsi_default_full_instruction();
219 inst.Instruction.Opcode = opcode;
220 inst.Instruction.NumDstRegs = 1;
221 inst.Dst[0].Register.File = dst_file;
222 inst.Dst[0].Register.Index = dst_index;
223 inst.Instruction.NumSrcRegs = 3;
224 inst.Src[0].Register.File = src1_file;
225 inst.Src[0].Register.Index = src1_index;
226 inst.Src[1].Register.File = src2_file;
227 inst.Src[1].Register.Index = src2_index;
228 inst.Src[2].Register.File = src3_file;
229 inst.Src[2].Register.Index = src3_index;
234 struct tgsi_full_instruction vl_end(void)
236 struct tgsi_full_instruction inst = tgsi_default_full_instruction();
238 inst.Instruction.Opcode = TGSI_OPCODE_END;
239 inst.Instruction.NumDstRegs = 0;
240 inst.Instruction.NumSrcRegs = 0;