2 * Copyright 2009 Henri Verbeet for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include "wine/port.h"
22 #include "wined3d_private.h"
24 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader
);
25 WINE_DECLARE_DEBUG_CHANNEL(d3d_bytecode
);
27 #define WINED3D_SM4_INSTRUCTION_MODIFIER (0x1u << 31)
29 #define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT 24
30 #define WINED3D_SM4_INSTRUCTION_LENGTH_MASK (0x1fu << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT)
32 #define WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT 11
33 #define WINED3D_SM4_INSTRUCTION_FLAGS_MASK (0x7u << WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT)
35 #define WINED3D_SM4_RESOURCE_TYPE_SHIFT 11
36 #define WINED3D_SM4_RESOURCE_TYPE_MASK (0xfu << WINED3D_SM4_RESOURCE_TYPE_SHIFT)
38 #define WINED3D_SM4_PRIMITIVE_TYPE_SHIFT 11
39 #define WINED3D_SM4_PRIMITIVE_TYPE_MASK (0x7u << WINED3D_SM4_PRIMITIVE_TYPE_SHIFT)
41 #define WINED3D_SM4_INDEX_TYPE_SHIFT 11
42 #define WINED3D_SM4_INDEX_TYPE_MASK (0x1u << WINED3D_SM4_INDEX_TYPE_SHIFT)
44 #define WINED3D_SM4_SAMPLER_MODE_SHIFT 11
45 #define WINED3D_SM4_SAMPLER_MODE_MASK (0xfu << WINED3D_SM4_SAMPLER_MODE_SHIFT)
47 #define WINED3D_SM4_SHADER_DATA_TYPE_SHIFT 11
48 #define WINED3D_SM4_SHADER_DATA_TYPE_MASK (0xfu << WINED3D_SM4_SHADER_DATA_TYPE_SHIFT)
50 #define WINED3D_SM4_INTERPOLATION_MODE_SHIFT 11
51 #define WINED3D_SM4_INTERPOLATION_MODE_MASK (0xfu << WINED3D_SM4_INTERPOLATION_MODE_SHIFT)
53 #define WINED3D_SM4_GLOBAL_FLAGS_SHIFT 11
54 #define WINED3D_SM4_GLOBAL_FLAGS_MASK (0xffu << WINED3D_SM4_GLOBAL_FLAGS_SHIFT)
56 #define WINED3D_SM4_OPCODE_MASK 0xff
58 #define WINED3D_SM4_REGISTER_MODIFIER (0x1u << 31)
60 #define WINED3D_SM4_ADDRESSING_SHIFT1 25
61 #define WINED3D_SM4_ADDRESSING_MASK1 (0x3u << WINED3D_SM4_ADDRESSING_SHIFT1)
63 #define WINED3D_SM4_ADDRESSING_SHIFT0 22
64 #define WINED3D_SM4_ADDRESSING_MASK0 (0x3u << WINED3D_SM4_ADDRESSING_SHIFT0)
66 #define WINED3D_SM4_REGISTER_ORDER_SHIFT 20
67 #define WINED3D_SM4_REGISTER_ORDER_MASK (0x3u << WINED3D_SM4_REGISTER_ORDER_SHIFT)
69 #define WINED3D_SM4_REGISTER_TYPE_SHIFT 12
70 #define WINED3D_SM4_REGISTER_TYPE_MASK (0xfu << WINED3D_SM4_REGISTER_TYPE_SHIFT)
72 #define WINED3D_SM4_SWIZZLE_TYPE_SHIFT 2
73 #define WINED3D_SM4_SWIZZLE_TYPE_MASK (0x3u << WINED3D_SM4_SWIZZLE_TYPE_SHIFT)
75 #define WINED3D_SM4_IMMCONST_TYPE_SHIFT 0
76 #define WINED3D_SM4_IMMCONST_TYPE_MASK (0x3u << WINED3D_SM4_IMMCONST_TYPE_SHIFT)
78 #define WINED3D_SM4_WRITEMASK_SHIFT 4
79 #define WINED3D_SM4_WRITEMASK_MASK (0xfu << WINED3D_SM4_WRITEMASK_SHIFT)
81 #define WINED3D_SM4_SWIZZLE_SHIFT 4
82 #define WINED3D_SM4_SWIZZLE_MASK (0xffu << WINED3D_SM4_SWIZZLE_SHIFT)
84 #define WINED3D_SM4_VERSION_MAJOR(version) (((version) >> 4) & 0xf)
85 #define WINED3D_SM4_VERSION_MINOR(version) (((version) >> 0) & 0xf)
87 #define WINED3D_SM4_ADDRESSING_RELATIVE 0x2
88 #define WINED3D_SM4_ADDRESSING_OFFSET 0x1
90 #define WINED3D_SM4_INSTRUCTION_FLAG_SATURATE 0x4
92 enum wined3d_sm4_opcode
94 WINED3D_SM4_OP_ADD
= 0x00,
95 WINED3D_SM4_OP_AND
= 0x01,
96 WINED3D_SM4_OP_BREAK
= 0x02,
97 WINED3D_SM4_OP_BREAKC
= 0x03,
98 WINED3D_SM4_OP_CUT
= 0x09,
99 WINED3D_SM4_OP_DERIV_RTX
= 0x0b,
100 WINED3D_SM4_OP_DERIV_RTY
= 0x0c,
101 WINED3D_SM4_OP_DISCARD
= 0x0d,
102 WINED3D_SM4_OP_DIV
= 0x0e,
103 WINED3D_SM4_OP_DP2
= 0x0f,
104 WINED3D_SM4_OP_DP3
= 0x10,
105 WINED3D_SM4_OP_DP4
= 0x11,
106 WINED3D_SM4_OP_ELSE
= 0x12,
107 WINED3D_SM4_OP_EMIT
= 0x13,
108 WINED3D_SM4_OP_ENDIF
= 0x15,
109 WINED3D_SM4_OP_ENDLOOP
= 0x16,
110 WINED3D_SM4_OP_EQ
= 0x18,
111 WINED3D_SM4_OP_EXP
= 0x19,
112 WINED3D_SM4_OP_FRC
= 0x1a,
113 WINED3D_SM4_OP_FTOI
= 0x1b,
114 WINED3D_SM4_OP_FTOU
= 0x1c,
115 WINED3D_SM4_OP_GE
= 0x1d,
116 WINED3D_SM4_OP_IADD
= 0x1e,
117 WINED3D_SM4_OP_IF
= 0x1f,
118 WINED3D_SM4_OP_IEQ
= 0x20,
119 WINED3D_SM4_OP_IGE
= 0x21,
120 WINED3D_SM4_OP_ILT
= 0x22,
121 WINED3D_SM4_OP_IMAD
= 0x23,
122 WINED3D_SM4_OP_IMAX
= 0x24,
123 WINED3D_SM4_OP_IMIN
= 0x25,
124 WINED3D_SM4_OP_IMUL
= 0x26,
125 WINED3D_SM4_OP_INE
= 0x27,
126 WINED3D_SM4_OP_INEG
= 0x28,
127 WINED3D_SM4_OP_ISHL
= 0x29,
128 WINED3D_SM4_OP_ITOF
= 0x2b,
129 WINED3D_SM4_OP_LD
= 0x2d,
130 WINED3D_SM4_OP_LOG
= 0x2f,
131 WINED3D_SM4_OP_LOOP
= 0x30,
132 WINED3D_SM4_OP_LT
= 0x31,
133 WINED3D_SM4_OP_MAD
= 0x32,
134 WINED3D_SM4_OP_MIN
= 0x33,
135 WINED3D_SM4_OP_MAX
= 0x34,
136 WINED3D_SM4_OP_SHADER_DATA
= 0x35,
137 WINED3D_SM4_OP_MOV
= 0x36,
138 WINED3D_SM4_OP_MOVC
= 0x37,
139 WINED3D_SM4_OP_MUL
= 0x38,
140 WINED3D_SM4_OP_NE
= 0x39,
141 WINED3D_SM4_OP_NOT
= 0x3b,
142 WINED3D_SM4_OP_OR
= 0x3c,
143 WINED3D_SM4_OP_RESINFO
= 0x3d,
144 WINED3D_SM4_OP_RET
= 0x3e,
145 WINED3D_SM4_OP_ROUND_NI
= 0x41,
146 WINED3D_SM4_OP_ROUND_PI
= 0x42,
147 WINED3D_SM4_OP_ROUND_Z
= 0x43,
148 WINED3D_SM4_OP_RSQ
= 0x44,
149 WINED3D_SM4_OP_SAMPLE
= 0x45,
150 WINED3D_SM4_OP_SAMPLE_C
= 0x46,
151 WINED3D_SM4_OP_SAMPLE_C_LZ
= 0x47,
152 WINED3D_SM4_OP_SAMPLE_LOD
= 0x48,
153 WINED3D_SM4_OP_SAMPLE_GRAD
= 0x49,
154 WINED3D_SM4_OP_SAMPLE_B
= 0x4a,
155 WINED3D_SM4_OP_SQRT
= 0x4b,
156 WINED3D_SM4_OP_SINCOS
= 0x4d,
157 WINED3D_SM4_OP_UDIV
= 0x4e,
158 WINED3D_SM4_OP_UGE
= 0x50,
159 WINED3D_SM4_OP_USHR
= 0x55,
160 WINED3D_SM4_OP_UTOF
= 0x56,
161 WINED3D_SM4_OP_XOR
= 0x57,
162 WINED3D_SM4_OP_DCL_RESOURCE
= 0x58,
163 WINED3D_SM4_OP_DCL_CONSTANT_BUFFER
= 0x59,
164 WINED3D_SM4_OP_DCL_SAMPLER
= 0x5a,
165 WINED3D_SM4_OP_DCL_OUTPUT_TOPOLOGY
= 0x5c,
166 WINED3D_SM4_OP_DCL_INPUT_PRIMITIVE
= 0x5d,
167 WINED3D_SM4_OP_DCL_VERTICES_OUT
= 0x5e,
168 WINED3D_SM4_OP_DCL_INPUT
= 0x5f,
169 WINED3D_SM4_OP_DCL_INPUT_SGV
= 0x60,
170 WINED3D_SM4_OP_DCL_INPUT_SIV
= 0x61,
171 WINED3D_SM4_OP_DCL_INPUT_PS
= 0x62,
172 WINED3D_SM4_OP_DCL_INPUT_PS_SGV
= 0x63,
173 WINED3D_SM4_OP_DCL_INPUT_PS_SIV
= 0x64,
174 WINED3D_SM4_OP_DCL_OUTPUT
= 0x65,
175 WINED3D_SM4_OP_DCL_OUTPUT_SIV
= 0x67,
176 WINED3D_SM4_OP_DCL_TEMPS
= 0x68,
177 WINED3D_SM4_OP_DCL_GLOBAL_FLAGS
= 0x6a,
180 enum wined3d_sm4_register_type
182 WINED3D_SM4_RT_TEMP
= 0x0,
183 WINED3D_SM4_RT_INPUT
= 0x1,
184 WINED3D_SM4_RT_OUTPUT
= 0x2,
185 WINED3D_SM4_RT_IMMCONST
= 0x4,
186 WINED3D_SM4_RT_SAMPLER
= 0x6,
187 WINED3D_SM4_RT_RESOURCE
= 0x7,
188 WINED3D_SM4_RT_CONSTBUFFER
= 0x8,
189 WINED3D_SM4_RT_IMMCONSTBUFFER
= 0x9,
190 WINED3D_SM4_RT_PRIMID
= 0xb,
191 WINED3D_SM4_RT_DEPTHOUT
= 0xc,
192 WINED3D_SM4_RT_NULL
= 0xd,
195 enum wined3d_sm4_output_primitive_type
197 WINED3D_SM4_OUTPUT_PT_POINTLIST
= 0x1,
198 WINED3D_SM4_OUTPUT_PT_LINELIST
= 0x3,
199 WINED3D_SM4_OUTPUT_PT_TRIANGLESTRIP
= 0x5,
202 enum wined3d_sm4_input_primitive_type
204 WINED3D_SM4_INPUT_PT_POINT
= 0x1,
205 WINED3D_SM4_INPUT_PT_LINE
= 0x2,
206 WINED3D_SM4_INPUT_PT_TRIANGLE
= 0x3,
207 WINED3D_SM4_INPUT_PT_LINEADJ
= 0x6,
208 WINED3D_SM4_INPUT_PT_TRIANGLEADJ
= 0x7,
211 enum wined3d_sm4_swizzle_type
213 WINED3D_SM4_SWIZZLE_NONE
= 0x0,
214 WINED3D_SM4_SWIZZLE_VEC4
= 0x1,
215 WINED3D_SM4_SWIZZLE_SCALAR
= 0x2,
218 enum wined3d_sm4_immconst_type
220 WINED3D_SM4_IMMCONST_SCALAR
= 0x1,
221 WINED3D_SM4_IMMCONST_VEC4
= 0x2,
224 enum wined3d_sm4_resource_type
226 WINED3D_SM4_RESOURCE_BUFFER
= 0x1,
227 WINED3D_SM4_RESOURCE_TEXTURE_1D
= 0x2,
228 WINED3D_SM4_RESOURCE_TEXTURE_2D
= 0x3,
229 WINED3D_SM4_RESOURCE_TEXTURE_2DMS
= 0x4,
230 WINED3D_SM4_RESOURCE_TEXTURE_3D
= 0x5,
231 WINED3D_SM4_RESOURCE_TEXTURE_CUBE
= 0x6,
232 WINED3D_SM4_RESOURCE_TEXTURE_1DARRAY
= 0x7,
233 WINED3D_SM4_RESOURCE_TEXTURE_2DARRAY
= 0x8,
234 WINED3D_SM4_RESOURCE_TEXTURE_2DMSARRAY
= 0x9,
237 enum wined3d_sm4_data_type
239 WINED3D_SM4_DATA_UNORM
= 0x1,
240 WINED3D_SM4_DATA_SNORM
= 0x2,
241 WINED3D_SM4_DATA_INT
= 0x3,
242 WINED3D_SM4_DATA_UINT
= 0x4,
243 WINED3D_SM4_DATA_FLOAT
= 0x5,
246 enum wined3d_sm4_sampler_mode
248 WINED3D_SM4_SAMPLER_DEFAULT
= 0x0,
249 WINED3D_SM4_SAMPLER_COMPARISON
= 0x1,
252 enum wined3d_sm4_shader_data_type
254 WINED3D_SM4_SHADER_DATA_IMMEDIATE_CONSTANT_BUFFER
= 0x3,
255 WINED3D_SM4_SHADER_DATA_MESSAGE
= 0x4,
258 struct wined3d_shader_src_param_entry
261 struct wined3d_shader_src_param param
;
264 struct wined3d_sm4_data
266 struct wined3d_shader_version shader_version
;
269 unsigned int output_map
[MAX_REG_OUTPUT
];
271 struct wined3d_shader_src_param src_param
[5];
272 struct wined3d_shader_dst_param dst_param
[2];
273 struct list src_free
;
275 struct wined3d_shader_immediate_constant_buffer icb
;
278 struct wined3d_sm4_opcode_info
280 enum wined3d_sm4_opcode opcode
;
281 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
;
282 const char *dst_info
;
283 const char *src_info
;
287 * F -> WINED3D_DATA_FLOAT
288 * I -> WINED3D_DATA_INT
289 * R -> WINED3D_DATA_RESOURCE
290 * S -> WINED3D_DATA_SAMPLER
291 * U -> WINED3D_DATA_UINT
293 static const struct wined3d_sm4_opcode_info opcode_table
[] =
295 {WINED3D_SM4_OP_ADD
, WINED3DSIH_ADD
, "F", "FF"},
296 {WINED3D_SM4_OP_AND
, WINED3DSIH_AND
, "U", "UU"},
297 {WINED3D_SM4_OP_BREAK
, WINED3DSIH_BREAK
, "", ""},
298 {WINED3D_SM4_OP_BREAKC
, WINED3DSIH_BREAKP
, "", "U"},
299 {WINED3D_SM4_OP_CUT
, WINED3DSIH_CUT
, "", ""},
300 {WINED3D_SM4_OP_DERIV_RTX
, WINED3DSIH_DSX
, "F", "F"},
301 {WINED3D_SM4_OP_DERIV_RTY
, WINED3DSIH_DSY
, "F", "F"},
302 {WINED3D_SM4_OP_DISCARD
, WINED3DSIH_TEXKILL
, "", "U"},
303 {WINED3D_SM4_OP_DIV
, WINED3DSIH_DIV
, "F", "FF"},
304 {WINED3D_SM4_OP_DP2
, WINED3DSIH_DP2
, "F", "FF"},
305 {WINED3D_SM4_OP_DP3
, WINED3DSIH_DP3
, "F", "FF"},
306 {WINED3D_SM4_OP_DP4
, WINED3DSIH_DP4
, "F", "FF"},
307 {WINED3D_SM4_OP_ELSE
, WINED3DSIH_ELSE
, "", ""},
308 {WINED3D_SM4_OP_EMIT
, WINED3DSIH_EMIT
, "", ""},
309 {WINED3D_SM4_OP_ENDIF
, WINED3DSIH_ENDIF
, "", ""},
310 {WINED3D_SM4_OP_ENDLOOP
, WINED3DSIH_ENDLOOP
, "", ""},
311 {WINED3D_SM4_OP_EQ
, WINED3DSIH_EQ
, "U", "FF"},
312 {WINED3D_SM4_OP_EXP
, WINED3DSIH_EXP
, "F", "F"},
313 {WINED3D_SM4_OP_FRC
, WINED3DSIH_FRC
, "F", "F"},
314 {WINED3D_SM4_OP_FTOI
, WINED3DSIH_FTOI
, "I", "F"},
315 {WINED3D_SM4_OP_FTOU
, WINED3DSIH_FTOU
, "U", "F"},
316 {WINED3D_SM4_OP_GE
, WINED3DSIH_GE
, "U", "FF"},
317 {WINED3D_SM4_OP_IADD
, WINED3DSIH_IADD
, "I", "II"},
318 {WINED3D_SM4_OP_IF
, WINED3DSIH_IF
, "", "U"},
319 {WINED3D_SM4_OP_IEQ
, WINED3DSIH_IEQ
, "U", "II"},
320 {WINED3D_SM4_OP_IGE
, WINED3DSIH_IGE
, "U", "II"},
321 {WINED3D_SM4_OP_ILT
, WINED3DSIH_ILT
, "U", "II"},
322 {WINED3D_SM4_OP_IMAD
, WINED3DSIH_IMAD
, "I", "III"},
323 {WINED3D_SM4_OP_IMAX
, WINED3DSIH_IMAX
, "I", "II"},
324 {WINED3D_SM4_OP_IMIN
, WINED3DSIH_IMIN
, "I", "II"},
325 {WINED3D_SM4_OP_IMUL
, WINED3DSIH_IMUL
, "II", "II"},
326 {WINED3D_SM4_OP_INE
, WINED3DSIH_INE
, "U", "II"},
327 {WINED3D_SM4_OP_INEG
, WINED3DSIH_INEG
, "I", "I"},
328 {WINED3D_SM4_OP_ISHL
, WINED3DSIH_ISHL
, "I", "II"},
329 {WINED3D_SM4_OP_ITOF
, WINED3DSIH_ITOF
, "F", "I"},
330 {WINED3D_SM4_OP_LD
, WINED3DSIH_LD
, "U", "IR"},
331 {WINED3D_SM4_OP_LOG
, WINED3DSIH_LOG
, "F", "F"},
332 {WINED3D_SM4_OP_LOOP
, WINED3DSIH_LOOP
, "", ""},
333 {WINED3D_SM4_OP_LT
, WINED3DSIH_LT
, "U", "FF"},
334 {WINED3D_SM4_OP_MAD
, WINED3DSIH_MAD
, "F", "FFF"},
335 {WINED3D_SM4_OP_MIN
, WINED3DSIH_MIN
, "F", "FF"},
336 {WINED3D_SM4_OP_MAX
, WINED3DSIH_MAX
, "F", "FF"},
337 {WINED3D_SM4_OP_SHADER_DATA
, WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
, "", ""},
338 {WINED3D_SM4_OP_MOV
, WINED3DSIH_MOV
, "F", "F"},
339 {WINED3D_SM4_OP_MOVC
, WINED3DSIH_MOVC
, "F", "UFF"},
340 {WINED3D_SM4_OP_MUL
, WINED3DSIH_MUL
, "F", "FF"},
341 {WINED3D_SM4_OP_NE
, WINED3DSIH_NE
, "U", "FF"},
342 {WINED3D_SM4_OP_NOT
, WINED3DSIH_NOT
, "U", "U"},
343 {WINED3D_SM4_OP_OR
, WINED3DSIH_OR
, "U", "UU"},
344 {WINED3D_SM4_OP_RESINFO
, WINED3DSIH_RESINFO
, "F", "IR"},
345 {WINED3D_SM4_OP_RET
, WINED3DSIH_RET
, "", ""},
346 {WINED3D_SM4_OP_ROUND_NI
, WINED3DSIH_ROUND_NI
, "F", "F"},
347 {WINED3D_SM4_OP_ROUND_PI
, WINED3DSIH_ROUND_PI
, "F", "F"},
348 {WINED3D_SM4_OP_ROUND_Z
, WINED3DSIH_ROUND_Z
, "F", "F"},
349 {WINED3D_SM4_OP_RSQ
, WINED3DSIH_RSQ
, "F", "F"},
350 {WINED3D_SM4_OP_SAMPLE
, WINED3DSIH_SAMPLE
, "U", "FRS"},
351 {WINED3D_SM4_OP_SAMPLE_C
, WINED3DSIH_SAMPLE_C
, "F", "FRSF"},
352 {WINED3D_SM4_OP_SAMPLE_C_LZ
, WINED3DSIH_SAMPLE_C_LZ
, "F", "FRSF"},
353 {WINED3D_SM4_OP_SAMPLE_LOD
, WINED3DSIH_SAMPLE_LOD
, "U", "FRSF"},
354 {WINED3D_SM4_OP_SAMPLE_GRAD
, WINED3DSIH_SAMPLE_GRAD
, "U", "FRSFF"},
355 {WINED3D_SM4_OP_SAMPLE_B
, WINED3DSIH_SAMPLE_B
, "U", "FRSF"},
356 {WINED3D_SM4_OP_SQRT
, WINED3DSIH_SQRT
, "F", "F"},
357 {WINED3D_SM4_OP_SINCOS
, WINED3DSIH_SINCOS
, "FF", "F"},
358 {WINED3D_SM4_OP_UDIV
, WINED3DSIH_UDIV
, "UU", "UU"},
359 {WINED3D_SM4_OP_UGE
, WINED3DSIH_UGE
, "U", "UU"},
360 {WINED3D_SM4_OP_USHR
, WINED3DSIH_USHR
, "U", "UU"},
361 {WINED3D_SM4_OP_UTOF
, WINED3DSIH_UTOF
, "F", "U"},
362 {WINED3D_SM4_OP_XOR
, WINED3DSIH_XOR
, "U", "UU"},
363 {WINED3D_SM4_OP_DCL_RESOURCE
, WINED3DSIH_DCL
, "R", ""},
364 {WINED3D_SM4_OP_DCL_CONSTANT_BUFFER
, WINED3DSIH_DCL_CONSTANT_BUFFER
, "", ""},
365 {WINED3D_SM4_OP_DCL_SAMPLER
, WINED3DSIH_DCL_SAMPLER
, "", ""},
366 {WINED3D_SM4_OP_DCL_OUTPUT_TOPOLOGY
, WINED3DSIH_DCL_OUTPUT_TOPOLOGY
, "", ""},
367 {WINED3D_SM4_OP_DCL_INPUT_PRIMITIVE
, WINED3DSIH_DCL_INPUT_PRIMITIVE
, "", ""},
368 {WINED3D_SM4_OP_DCL_VERTICES_OUT
, WINED3DSIH_DCL_VERTICES_OUT
, "", ""},
369 {WINED3D_SM4_OP_DCL_INPUT
, WINED3DSIH_DCL_INPUT
, "", ""},
370 {WINED3D_SM4_OP_DCL_INPUT_SGV
, WINED3DSIH_DCL_INPUT_SGV
, "", ""},
371 {WINED3D_SM4_OP_DCL_INPUT_SIV
, WINED3DSIH_DCL_INPUT_SIV
, "", ""},
372 {WINED3D_SM4_OP_DCL_INPUT_PS
, WINED3DSIH_DCL_INPUT_PS
, "", ""},
373 {WINED3D_SM4_OP_DCL_INPUT_PS_SGV
, WINED3DSIH_DCL_INPUT_PS_SGV
, "", ""},
374 {WINED3D_SM4_OP_DCL_INPUT_PS_SIV
, WINED3DSIH_DCL_INPUT_PS_SIV
, "", ""},
375 {WINED3D_SM4_OP_DCL_OUTPUT
, WINED3DSIH_DCL_OUTPUT
, "", ""},
376 {WINED3D_SM4_OP_DCL_OUTPUT_SIV
, WINED3DSIH_DCL_OUTPUT_SIV
, "", ""},
377 {WINED3D_SM4_OP_DCL_TEMPS
, WINED3DSIH_DCL_TEMPS
, "", ""},
378 {WINED3D_SM4_OP_DCL_GLOBAL_FLAGS
, WINED3DSIH_DCL_GLOBAL_FLAGS
, "", ""},
381 static const enum wined3d_shader_register_type register_type_table
[] =
383 /* WINED3D_SM4_RT_TEMP */ WINED3DSPR_TEMP
,
384 /* WINED3D_SM4_RT_INPUT */ WINED3DSPR_INPUT
,
385 /* WINED3D_SM4_RT_OUTPUT */ WINED3DSPR_OUTPUT
,
387 /* WINED3D_SM4_RT_IMMCONST */ WINED3DSPR_IMMCONST
,
389 /* WINED3D_SM4_RT_SAMPLER */ WINED3DSPR_SAMPLER
,
390 /* WINED3D_SM4_RT_RESOURCE */ WINED3DSPR_RESOURCE
,
391 /* WINED3D_SM4_RT_CONSTBUFFER */ WINED3DSPR_CONSTBUFFER
,
392 /* WINED3D_SM4_RT_IMMCONSTBUFFER */ WINED3DSPR_IMMCONSTBUFFER
,
394 /* WINED3D_SM4_RT_PRIMID */ WINED3DSPR_PRIMID
,
395 /* WINED3D_SM4_RT_DEPTHOUT */ WINED3DSPR_DEPTHOUT
,
396 /* WINED3D_SM4_RT_NULL */ WINED3DSPR_NULL
,
399 static const enum wined3d_primitive_type output_primitive_type_table
[] =
401 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
402 /* WINED3D_SM4_OUTPUT_PT_POINTLIST */ WINED3D_PT_POINTLIST
,
403 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
404 /* WINED3D_SM4_OUTPUT_PT_LINELIST */ WINED3D_PT_LINELIST
,
405 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
406 /* WINED3D_SM4_OUTPUT_PT_TRIANGLESTRIP */ WINED3D_PT_TRIANGLESTRIP
,
409 static const enum wined3d_primitive_type input_primitive_type_table
[] =
411 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
412 /* WINED3D_SM4_INPUT_PT_POINT */ WINED3D_PT_POINTLIST
,
413 /* WINED3D_SM4_INPUT_PT_LINE */ WINED3D_PT_LINELIST
,
414 /* WINED3D_SM4_INPUT_PT_TRIANGLE */ WINED3D_PT_TRIANGLELIST
,
415 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
416 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
417 /* WINED3D_SM4_INPUT_PT_LINEADJ */ WINED3D_PT_LINELIST_ADJ
,
418 /* WINED3D_SM4_INPUT_PT_TRIANGLEADJ */ WINED3D_PT_TRIANGLELIST_ADJ
,
421 static const enum wined3d_shader_resource_type resource_type_table
[] =
423 /* 0 */ WINED3D_SHADER_RESOURCE_NONE
,
424 /* WINED3D_SM4_RESOURCE_BUFFER */ WINED3D_SHADER_RESOURCE_BUFFER
,
425 /* WINED3D_SM4_RESOURCE_TEXTURE_1D */ WINED3D_SHADER_RESOURCE_TEXTURE_1D
,
426 /* WINED3D_SM4_RESOURCE_TEXTURE_2D */ WINED3D_SHADER_RESOURCE_TEXTURE_2D
,
427 /* WINED3D_SM4_RESOURCE_TEXTURE_2DMS */ WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
,
428 /* WINED3D_SM4_RESOURCE_TEXTURE_3D */ WINED3D_SHADER_RESOURCE_TEXTURE_3D
,
429 /* WINED3D_SM4_RESOURCE_TEXTURE_CUBE */ WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
,
430 /* WINED3D_SM4_RESOURCE_TEXTURE_1DARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
,
431 /* WINED3D_SM4_RESOURCE_TEXTURE_2DARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
,
432 /* WINED3D_SM4_RESOURCE_TEXTURE_2DMSARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
,
435 static const enum wined3d_data_type data_type_table
[] =
437 /* 0 */ WINED3D_DATA_FLOAT
,
438 /* WINED3D_SM4_DATA_UNORM */ WINED3D_DATA_UNORM
,
439 /* WINED3D_SM4_DATA_SNORM */ WINED3D_DATA_SNORM
,
440 /* WINED3D_SM4_DATA_INT */ WINED3D_DATA_INT
,
441 /* WINED3D_SM4_DATA_UINT */ WINED3D_DATA_UINT
,
442 /* WINED3D_SM4_DATA_FLOAT */ WINED3D_DATA_FLOAT
,
445 static BOOL
shader_sm4_read_src_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
446 enum wined3d_data_type data_type
, struct wined3d_shader_src_param
*src_param
);
448 static const struct wined3d_sm4_opcode_info
*get_opcode_info(enum wined3d_sm4_opcode opcode
)
452 for (i
= 0; i
< sizeof(opcode_table
) / sizeof(*opcode_table
); ++i
)
454 if (opcode
== opcode_table
[i
].opcode
) return &opcode_table
[i
];
460 static void map_register(const struct wined3d_sm4_data
*priv
, struct wined3d_shader_register
*reg
)
462 switch (priv
->shader_version
.type
)
464 case WINED3D_SHADER_TYPE_PIXEL
:
465 if (reg
->type
== WINED3DSPR_OUTPUT
)
467 unsigned int reg_idx
= reg
->idx
[0].offset
;
469 if (reg_idx
>= ARRAY_SIZE(priv
->output_map
))
471 ERR("Invalid output index %u.\n", reg_idx
);
475 reg
->type
= WINED3DSPR_COLOROUT
;
476 reg
->idx
[0].offset
= priv
->output_map
[reg_idx
];
485 static enum wined3d_data_type
map_data_type(char t
)
490 return WINED3D_DATA_FLOAT
;
492 return WINED3D_DATA_INT
;
494 return WINED3D_DATA_RESOURCE
;
496 return WINED3D_DATA_SAMPLER
;
498 return WINED3D_DATA_UINT
;
500 ERR("Invalid data type '%c'.\n", t
);
501 return WINED3D_DATA_FLOAT
;
505 static void *shader_sm4_init(const DWORD
*byte_code
, const struct wined3d_shader_signature
*output_signature
)
507 struct wined3d_sm4_data
*priv
;
510 if (!(priv
= HeapAlloc(GetProcessHeap(), 0, sizeof(*priv
))))
512 ERR("Failed to allocate private data\n");
516 memset(priv
->output_map
, 0xff, sizeof(priv
->output_map
));
517 for (i
= 0; i
< output_signature
->element_count
; ++i
)
519 struct wined3d_shader_signature_element
*e
= &output_signature
->elements
[i
];
521 if (e
->register_idx
>= ARRAY_SIZE(priv
->output_map
))
523 WARN("Invalid output index %u.\n", e
->register_idx
);
527 priv
->output_map
[e
->register_idx
] = e
->semantic_idx
;
530 list_init(&priv
->src_free
);
531 list_init(&priv
->src
);
536 static void shader_sm4_free(void *data
)
538 struct wined3d_shader_src_param_entry
*e1
, *e2
;
539 struct wined3d_sm4_data
*priv
= data
;
541 list_move_head(&priv
->src_free
, &priv
->src
);
542 LIST_FOR_EACH_ENTRY_SAFE(e1
, e2
, &priv
->src_free
, struct wined3d_shader_src_param_entry
, entry
)
544 HeapFree(GetProcessHeap(), 0, e1
);
546 HeapFree(GetProcessHeap(), 0, priv
);
549 static struct wined3d_shader_src_param
*get_src_param(struct wined3d_sm4_data
*priv
)
551 struct wined3d_shader_src_param_entry
*e
;
554 if (!list_empty(&priv
->src_free
))
556 elem
= list_head(&priv
->src_free
);
561 if (!(e
= HeapAlloc(GetProcessHeap(), 0, sizeof(*e
))))
566 list_add_tail(&priv
->src
, elem
);
567 e
= LIST_ENTRY(elem
, struct wined3d_shader_src_param_entry
, entry
);
571 static void shader_sm4_read_header(void *data
, const DWORD
**ptr
, struct wined3d_shader_version
*shader_version
)
573 struct wined3d_sm4_data
*priv
= data
;
578 version_token
= *(*ptr
)++;
579 TRACE("version: 0x%08x\n", version_token
);
581 TRACE("token count: %u\n", **ptr
);
582 priv
->end
+= *(*ptr
)++;
584 switch (version_token
>> 16)
587 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_PIXEL
;
591 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_VERTEX
;
595 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_GEOMETRY
;
599 FIXME("Unrecognized shader type %#x\n", version_token
>> 16);
601 priv
->shader_version
.major
= WINED3D_SM4_VERSION_MAJOR(version_token
);
602 priv
->shader_version
.minor
= WINED3D_SM4_VERSION_MINOR(version_token
);
604 *shader_version
= priv
->shader_version
;
607 static BOOL
shader_sm4_read_reg_idx(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
608 DWORD addressing
, struct wined3d_shader_register_index
*reg_idx
)
610 if (addressing
& WINED3D_SM4_ADDRESSING_RELATIVE
)
612 struct wined3d_shader_src_param
*rel_addr
= get_src_param(priv
);
614 if (!(reg_idx
->rel_addr
= rel_addr
))
616 ERR("Failed to get src param for relative addressing.\n");
620 if (addressing
& WINED3D_SM4_ADDRESSING_OFFSET
)
621 reg_idx
->offset
= *(*ptr
)++;
624 shader_sm4_read_src_param(priv
, ptr
, WINED3D_DATA_INT
, rel_addr
);
628 reg_idx
->rel_addr
= NULL
;
629 reg_idx
->offset
= *(*ptr
)++;
635 static BOOL
shader_sm4_read_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
636 enum wined3d_data_type data_type
, struct wined3d_shader_register
*param
,
637 enum wined3d_shader_src_modifier
*modifier
)
639 enum wined3d_sm4_register_type register_type
;
640 DWORD token
= *(*ptr
)++;
643 register_type
= (token
& WINED3D_SM4_REGISTER_TYPE_MASK
) >> WINED3D_SM4_REGISTER_TYPE_SHIFT
;
644 if (register_type
>= sizeof(register_type_table
) / sizeof(*register_type_table
))
646 FIXME("Unhandled register type %#x.\n", register_type
);
647 param
->type
= WINED3DSPR_TEMP
;
651 param
->type
= register_type_table
[register_type
];
653 param
->data_type
= data_type
;
655 if (token
& WINED3D_SM4_REGISTER_MODIFIER
)
662 *modifier
= WINED3DSPSM_NEG
;
666 *modifier
= WINED3DSPSM_ABS
;
670 *modifier
= WINED3DSPSM_ABSNEG
;
674 FIXME("Skipping modifier 0x%08x.\n", m
);
675 *modifier
= WINED3DSPSM_NONE
;
681 *modifier
= WINED3DSPSM_NONE
;
684 order
= (token
& WINED3D_SM4_REGISTER_ORDER_MASK
) >> WINED3D_SM4_REGISTER_ORDER_SHIFT
;
687 param
->idx
[0].offset
= ~0U;
690 DWORD addressing
= (token
& WINED3D_SM4_ADDRESSING_MASK0
) >> WINED3D_SM4_ADDRESSING_SHIFT0
;
691 if (!(shader_sm4_read_reg_idx(priv
, ptr
, addressing
, ¶m
->idx
[0])))
693 ERR("Failed to read register index.\n");
699 param
->idx
[1].offset
= ~0U;
702 DWORD addressing
= (token
& WINED3D_SM4_ADDRESSING_MASK1
) >> WINED3D_SM4_ADDRESSING_SHIFT1
;
703 if (!(shader_sm4_read_reg_idx(priv
, ptr
, addressing
, ¶m
->idx
[1])))
705 ERR("Failed to read register index.\n");
711 FIXME("Unhandled order %u.\n", order
);
713 if (register_type
== WINED3D_SM4_RT_IMMCONST
)
715 enum wined3d_sm4_immconst_type immconst_type
=
716 (token
& WINED3D_SM4_IMMCONST_TYPE_MASK
) >> WINED3D_SM4_IMMCONST_TYPE_SHIFT
;
718 switch (immconst_type
)
720 case WINED3D_SM4_IMMCONST_SCALAR
:
721 param
->immconst_type
= WINED3D_IMMCONST_SCALAR
;
722 memcpy(param
->immconst_data
, *ptr
, 1 * sizeof(DWORD
));
726 case WINED3D_SM4_IMMCONST_VEC4
:
727 param
->immconst_type
= WINED3D_IMMCONST_VEC4
;
728 memcpy(param
->immconst_data
, *ptr
, 4 * sizeof(DWORD
));
733 FIXME("Unhandled immediate constant type %#x.\n", immconst_type
);
738 map_register(priv
, param
);
743 static BOOL
shader_sm4_read_src_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
744 enum wined3d_data_type data_type
, struct wined3d_shader_src_param
*src_param
)
748 if (!shader_sm4_read_param(priv
, ptr
, data_type
, &src_param
->reg
, &src_param
->modifiers
))
750 ERR("Failed to read parameter.\n");
754 if (src_param
->reg
.type
== WINED3DSPR_IMMCONST
)
756 src_param
->swizzle
= WINED3DSP_NOSWIZZLE
;
760 enum wined3d_sm4_swizzle_type swizzle_type
=
761 (token
& WINED3D_SM4_SWIZZLE_TYPE_MASK
) >> WINED3D_SM4_SWIZZLE_TYPE_SHIFT
;
763 switch (swizzle_type
)
765 case WINED3D_SM4_SWIZZLE_NONE
:
766 src_param
->swizzle
= WINED3DSP_NOSWIZZLE
;
769 case WINED3D_SM4_SWIZZLE_SCALAR
:
770 src_param
->swizzle
= (token
& WINED3D_SM4_SWIZZLE_MASK
) >> WINED3D_SM4_SWIZZLE_SHIFT
;
771 src_param
->swizzle
= (src_param
->swizzle
& 0x3) * 0x55;
774 case WINED3D_SM4_SWIZZLE_VEC4
:
775 src_param
->swizzle
= (token
& WINED3D_SM4_SWIZZLE_MASK
) >> WINED3D_SM4_SWIZZLE_SHIFT
;
779 FIXME("Unhandled swizzle type %#x.\n", swizzle_type
);
787 static BOOL
shader_sm4_read_dst_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
788 enum wined3d_data_type data_type
, struct wined3d_shader_dst_param
*dst_param
)
790 enum wined3d_shader_src_modifier modifier
;
793 if (!shader_sm4_read_param(priv
, ptr
, data_type
, &dst_param
->reg
, &modifier
))
795 ERR("Failed to read parameter.\n");
799 if (modifier
!= WINED3DSPSM_NONE
)
801 ERR("Invalid source modifier %#x on destination register.\n", modifier
);
805 dst_param
->write_mask
= (token
& WINED3D_SM4_WRITEMASK_MASK
) >> WINED3D_SM4_WRITEMASK_SHIFT
;
806 dst_param
->modifiers
= 0;
807 dst_param
->shift
= 0;
812 static void shader_sm4_read_instruction(void *data
, const DWORD
**ptr
, struct wined3d_shader_instruction
*ins
)
814 const struct wined3d_sm4_opcode_info
*opcode_info
;
815 struct wined3d_sm4_data
*priv
= data
;
816 DWORD opcode_token
, opcode
;
820 list_move_head(&priv
->src_free
, &priv
->src
);
822 opcode_token
= *(*ptr
)++;
823 opcode
= opcode_token
& WINED3D_SM4_OPCODE_MASK
;
825 len
= ((opcode_token
& WINED3D_SM4_INSTRUCTION_LENGTH_MASK
) >> WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT
);
830 if (TRACE_ON(d3d_bytecode
))
832 TRACE_(d3d_bytecode
)("[ %08x ", opcode_token
);
833 for (i
= 0; i
< len
; ++i
)
835 TRACE_(d3d_bytecode
)("%08x ", (*ptr
)[i
]);
837 TRACE_(d3d_bytecode
)("]\n");
840 if (!(opcode_info
= get_opcode_info(opcode
)))
842 FIXME("Unrecognized opcode %#x, opcode_token 0x%08x.\n", opcode
, opcode_token
);
843 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
848 ins
->handler_idx
= opcode_info
->handler_idx
;
851 ins
->predicate
= NULL
;
852 ins
->dst_count
= strlen(opcode_info
->dst_info
);
853 ins
->dst
= priv
->dst_param
;
854 ins
->src_count
= strlen(opcode_info
->src_info
);
855 ins
->src
= priv
->src_param
;
860 if (opcode_token
& WINED3D_SM4_INSTRUCTION_MODIFIER
)
862 DWORD modifier
= *p
++;
863 FIXME("Skipping modifier 0x%08x.\n", modifier
);
866 if (opcode
== WINED3D_SM4_OP_SHADER_DATA
)
868 unsigned int icb_size
;
869 enum wined3d_sm4_shader_data_type type
;
871 type
= (opcode_token
& WINED3D_SM4_SHADER_DATA_TYPE_MASK
) >> WINED3D_SM4_SHADER_DATA_TYPE_SHIFT
;
872 if (type
!= WINED3D_SM4_SHADER_DATA_IMMEDIATE_CONSTANT_BUFFER
)
874 FIXME("Unhandled shader data type %#x.\n", type
);
875 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
881 if (icb_size
% 4 || icb_size
> MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
)
883 FIXME("Unexpected immediate constant buffer size %u.\n", len
);
884 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
888 priv
->icb
.element_count
= len
;
889 memcpy(priv
->icb
.data
, p
, sizeof(*p
) * icb_size
);
890 ins
->declaration
.icb
= &priv
->icb
;
892 else if (opcode
== WINED3D_SM4_OP_DCL_RESOURCE
)
894 enum wined3d_sm4_resource_type resource_type
;
895 enum wined3d_sm4_data_type data_type
;
898 resource_type
= (opcode_token
& WINED3D_SM4_RESOURCE_TYPE_MASK
) >> WINED3D_SM4_RESOURCE_TYPE_SHIFT
;
899 if (!resource_type
|| (resource_type
>= ARRAY_SIZE(resource_type_table
)))
901 FIXME("Unhandled resource type %#x.\n", resource_type
);
902 ins
->declaration
.semantic
.resource_type
= WINED3D_SHADER_RESOURCE_NONE
;
906 ins
->declaration
.semantic
.resource_type
= resource_type_table
[resource_type
];
908 shader_sm4_read_dst_param(priv
, &p
, WINED3D_DATA_RESOURCE
, &ins
->declaration
.semantic
.reg
);
911 if ((components
& 0xfff0) != (components
& 0xf) * 0x1110)
912 FIXME("Components (%#x) have different data types.\n", components
);
913 data_type
= components
& 0xf;
915 if (!data_type
|| (data_type
>= ARRAY_SIZE(data_type_table
)))
917 FIXME("Unhandled data type %#x.\n", data_type
);
918 ins
->declaration
.semantic
.resource_data_type
= WINED3D_DATA_FLOAT
;
922 ins
->declaration
.semantic
.resource_data_type
= data_type_table
[data_type
];
925 else if (opcode
== WINED3D_SM4_OP_DCL_CONSTANT_BUFFER
)
927 shader_sm4_read_src_param(priv
, &p
, WINED3D_DATA_FLOAT
, &ins
->declaration
.src
);
928 if (opcode_token
& WINED3D_SM4_INDEX_TYPE_MASK
)
929 ins
->flags
|= WINED3DSI_INDEXED_DYNAMIC
;
931 else if (opcode
== WINED3D_SM4_OP_DCL_SAMPLER
)
933 ins
->flags
= (opcode_token
& WINED3D_SM4_SAMPLER_MODE_MASK
) >> WINED3D_SM4_SAMPLER_MODE_SHIFT
;
934 if (ins
->flags
& ~WINED3D_SM4_SAMPLER_COMPARISON
)
935 FIXME("Unhandled sampler mode %#x.\n", ins
->flags
);
936 shader_sm4_read_dst_param(priv
, &p
, WINED3D_DATA_SAMPLER
, &ins
->declaration
.dst
);
938 else if (opcode
== WINED3D_SM4_OP_DCL_OUTPUT_TOPOLOGY
)
940 enum wined3d_sm4_output_primitive_type primitive_type
;
942 primitive_type
= (opcode_token
& WINED3D_SM4_PRIMITIVE_TYPE_MASK
) >> WINED3D_SM4_PRIMITIVE_TYPE_SHIFT
;
943 if (primitive_type
>= sizeof(output_primitive_type_table
) / sizeof(*output_primitive_type_table
))
945 FIXME("Unhandled output primitive type %#x.\n", primitive_type
);
946 ins
->declaration
.primitive_type
= WINED3D_PT_UNDEFINED
;
950 ins
->declaration
.primitive_type
= output_primitive_type_table
[primitive_type
];
953 else if (opcode
== WINED3D_SM4_OP_DCL_INPUT_PRIMITIVE
)
955 enum wined3d_sm4_input_primitive_type primitive_type
;
957 primitive_type
= (opcode_token
& WINED3D_SM4_PRIMITIVE_TYPE_MASK
) >> WINED3D_SM4_PRIMITIVE_TYPE_SHIFT
;
958 if (primitive_type
>= sizeof(input_primitive_type_table
) / sizeof(*input_primitive_type_table
))
960 FIXME("Unhandled input primitive type %#x.\n", primitive_type
);
961 ins
->declaration
.primitive_type
= WINED3D_PT_UNDEFINED
;
965 ins
->declaration
.primitive_type
= input_primitive_type_table
[primitive_type
];
968 else if (opcode
== WINED3D_SM4_OP_DCL_INPUT_PS
)
970 ins
->flags
= (opcode_token
& WINED3D_SM4_INTERPOLATION_MODE_MASK
) >> WINED3D_SM4_INTERPOLATION_MODE_SHIFT
;
971 shader_sm4_read_dst_param(priv
, &p
, WINED3D_DATA_FLOAT
, &ins
->declaration
.dst
);
973 else if (opcode
== WINED3D_SM4_OP_DCL_INPUT_PS_SGV
974 || opcode
== WINED3D_SM4_OP_DCL_INPUT_SGV
975 || opcode
== WINED3D_SM4_OP_DCL_INPUT_SIV
976 || opcode
== WINED3D_SM4_OP_DCL_OUTPUT_SIV
)
978 shader_sm4_read_dst_param(priv
, &p
, WINED3D_DATA_FLOAT
, &ins
->declaration
.register_semantic
.reg
);
979 ins
->declaration
.register_semantic
.sysval_semantic
= *p
++;
981 else if (opcode
== WINED3D_SM4_OP_DCL_INPUT_PS_SIV
)
983 ins
->flags
= (opcode_token
& WINED3D_SM4_INTERPOLATION_MODE_MASK
) >> WINED3D_SM4_INTERPOLATION_MODE_SHIFT
;
984 shader_sm4_read_dst_param(priv
, &p
, WINED3D_DATA_FLOAT
, &ins
->declaration
.register_semantic
.reg
);
985 ins
->declaration
.register_semantic
.sysval_semantic
= *p
++;
987 else if (opcode
== WINED3D_SM4_OP_DCL_INPUT
988 || opcode
== WINED3D_SM4_OP_DCL_OUTPUT
)
990 shader_sm4_read_dst_param(priv
, &p
, WINED3D_DATA_FLOAT
, &ins
->declaration
.dst
);
992 else if (opcode
== WINED3D_SM4_OP_DCL_VERTICES_OUT
993 || opcode
== WINED3D_SM4_OP_DCL_TEMPS
)
995 ins
->declaration
.count
= *p
++;
997 else if (opcode
== WINED3D_SM4_OP_DCL_GLOBAL_FLAGS
)
999 ins
->flags
= (opcode_token
& WINED3D_SM4_GLOBAL_FLAGS_MASK
) >> WINED3D_SM4_GLOBAL_FLAGS_SHIFT
;
1003 enum wined3d_shader_dst_modifier instruction_dst_modifier
= WINED3DSPDM_NONE
;
1005 ins
->flags
= (opcode_token
& WINED3D_SM4_INSTRUCTION_FLAGS_MASK
) >> WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT
;
1007 if (ins
->flags
& WINED3D_SM4_INSTRUCTION_FLAG_SATURATE
)
1009 ins
->flags
&= ~WINED3D_SM4_INSTRUCTION_FLAG_SATURATE
;
1010 instruction_dst_modifier
= WINED3DSPDM_SATURATE
;
1013 for (i
= 0; i
< ins
->dst_count
; ++i
)
1015 if (!(shader_sm4_read_dst_param(priv
, &p
, map_data_type(opcode_info
->dst_info
[i
]), &priv
->dst_param
[i
])))
1017 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
1020 priv
->dst_param
[i
].modifiers
|= instruction_dst_modifier
;
1023 for (i
= 0; i
< ins
->src_count
; ++i
)
1025 if (!(shader_sm4_read_src_param(priv
, &p
, map_data_type(opcode_info
->src_info
[i
]), &priv
->src_param
[i
])))
1027 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
1034 static BOOL
shader_sm4_is_end(void *data
, const DWORD
**ptr
)
1036 struct wined3d_sm4_data
*priv
= data
;
1037 return *ptr
== priv
->end
;
1040 const struct wined3d_shader_frontend sm4_shader_frontend
=
1044 shader_sm4_read_header
,
1045 shader_sm4_read_instruction
,