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_MODIFIER_AOFFIMMI 0x1
30 #define WINED3D_SM4_AOFFIMMI_U_SHIFT 9
31 #define WINED3D_SM4_AOFFIMMI_U_MASK (0xfu << WINED3D_SM4_AOFFIMMI_U_SHIFT)
32 #define WINED3D_SM4_AOFFIMMI_V_SHIFT 13
33 #define WINED3D_SM4_AOFFIMMI_V_MASK (0xfu << WINED3D_SM4_AOFFIMMI_V_SHIFT)
34 #define WINED3D_SM4_AOFFIMMI_W_SHIFT 17
35 #define WINED3D_SM4_AOFFIMMI_W_MASK (0xfu << WINED3D_SM4_AOFFIMMI_W_SHIFT)
37 #define WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT 24
38 #define WINED3D_SM4_INSTRUCTION_LENGTH_MASK (0x1fu << WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT)
40 #define WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT 11
41 #define WINED3D_SM4_INSTRUCTION_FLAGS_MASK (0x7u << WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT)
43 #define WINED3D_SM4_RESOURCE_TYPE_SHIFT 11
44 #define WINED3D_SM4_RESOURCE_TYPE_MASK (0xfu << WINED3D_SM4_RESOURCE_TYPE_SHIFT)
46 #define WINED3D_SM4_PRIMITIVE_TYPE_SHIFT 11
47 #define WINED3D_SM4_PRIMITIVE_TYPE_MASK (0x7u << WINED3D_SM4_PRIMITIVE_TYPE_SHIFT)
49 #define WINED3D_SM4_INDEX_TYPE_SHIFT 11
50 #define WINED3D_SM4_INDEX_TYPE_MASK (0x1u << WINED3D_SM4_INDEX_TYPE_SHIFT)
52 #define WINED3D_SM4_SAMPLER_MODE_SHIFT 11
53 #define WINED3D_SM4_SAMPLER_MODE_MASK (0xfu << WINED3D_SM4_SAMPLER_MODE_SHIFT)
55 #define WINED3D_SM4_SHADER_DATA_TYPE_SHIFT 11
56 #define WINED3D_SM4_SHADER_DATA_TYPE_MASK (0xfu << WINED3D_SM4_SHADER_DATA_TYPE_SHIFT)
58 #define WINED3D_SM4_INTERPOLATION_MODE_SHIFT 11
59 #define WINED3D_SM4_INTERPOLATION_MODE_MASK (0xfu << WINED3D_SM4_INTERPOLATION_MODE_SHIFT)
61 #define WINED3D_SM4_GLOBAL_FLAGS_SHIFT 11
62 #define WINED3D_SM4_GLOBAL_FLAGS_MASK (0xffu << WINED3D_SM4_GLOBAL_FLAGS_SHIFT)
64 #define WINED3D_SM5_CONTROL_POINT_COUNT_SHIFT 11
65 #define WINED3D_SM5_CONTROL_POINT_COUNT_MASK (0xffu << WINED3D_SM5_CONTROL_POINT_COUNT_SHIFT)
67 #define WINED3D_SM5_FP_ARRAY_SIZE_SHIFT 16
68 #define WINED3D_SM5_FP_TABLE_COUNT_MASK 0xffffu
70 #define WINED3D_SM5_UAV_FLAGS_SHIFT 11
71 #define WINED3D_SM5_UAV_FLAGS_MASK (0x8fffu << WINED3D_SM5_UAV_FLAGS_SHIFT)
73 #define WINED3D_SM5_SYNC_FLAGS_SHIFT 11
74 #define WINED3D_SM5_SYNC_FLAGS_MASK (0xffu << WINED3D_SM5_SYNC_FLAGS_SHIFT)
76 #define WINED3D_SM5_TESSELLATOR_SHIFT 11
77 #define WINED3D_SM5_TESSELLATOR_MASK (0xfu << WINED3D_SM5_TESSELLATOR_SHIFT)
79 #define WINED3D_SM4_OPCODE_MASK 0xff
81 #define WINED3D_SM4_REGISTER_MODIFIER (0x1u << 31)
83 #define WINED3D_SM4_ADDRESSING_SHIFT1 25
84 #define WINED3D_SM4_ADDRESSING_MASK1 (0x3u << WINED3D_SM4_ADDRESSING_SHIFT1)
86 #define WINED3D_SM4_ADDRESSING_SHIFT0 22
87 #define WINED3D_SM4_ADDRESSING_MASK0 (0x3u << WINED3D_SM4_ADDRESSING_SHIFT0)
89 #define WINED3D_SM4_REGISTER_ORDER_SHIFT 20
90 #define WINED3D_SM4_REGISTER_ORDER_MASK (0x3u << WINED3D_SM4_REGISTER_ORDER_SHIFT)
92 #define WINED3D_SM4_REGISTER_TYPE_SHIFT 12
93 #define WINED3D_SM4_REGISTER_TYPE_MASK (0xffu << WINED3D_SM4_REGISTER_TYPE_SHIFT)
95 #define WINED3D_SM4_SWIZZLE_TYPE_SHIFT 2
96 #define WINED3D_SM4_SWIZZLE_TYPE_MASK (0x3u << WINED3D_SM4_SWIZZLE_TYPE_SHIFT)
98 #define WINED3D_SM4_IMMCONST_TYPE_SHIFT 0
99 #define WINED3D_SM4_IMMCONST_TYPE_MASK (0x3u << WINED3D_SM4_IMMCONST_TYPE_SHIFT)
101 #define WINED3D_SM4_WRITEMASK_SHIFT 4
102 #define WINED3D_SM4_WRITEMASK_MASK (0xfu << WINED3D_SM4_WRITEMASK_SHIFT)
104 #define WINED3D_SM4_SWIZZLE_SHIFT 4
105 #define WINED3D_SM4_SWIZZLE_MASK (0xffu << WINED3D_SM4_SWIZZLE_SHIFT)
107 #define WINED3D_SM4_VERSION_MAJOR(version) (((version) >> 4) & 0xf)
108 #define WINED3D_SM4_VERSION_MINOR(version) (((version) >> 0) & 0xf)
110 #define WINED3D_SM4_ADDRESSING_RELATIVE 0x2
111 #define WINED3D_SM4_ADDRESSING_OFFSET 0x1
113 #define WINED3D_SM4_INSTRUCTION_FLAG_SATURATE 0x4
115 #define WINED3D_SM4_CONDITIONAL_NZ (0x1u << 18)
117 enum wined3d_sm4_opcode
119 WINED3D_SM4_OP_ADD
= 0x00,
120 WINED3D_SM4_OP_AND
= 0x01,
121 WINED3D_SM4_OP_BREAK
= 0x02,
122 WINED3D_SM4_OP_BREAKC
= 0x03,
123 WINED3D_SM4_OP_CASE
= 0x06,
124 WINED3D_SM4_OP_CONTINUE
= 0x07,
125 WINED3D_SM4_OP_CUT
= 0x09,
126 WINED3D_SM4_OP_DEFAULT
= 0x0a,
127 WINED3D_SM4_OP_DERIV_RTX
= 0x0b,
128 WINED3D_SM4_OP_DERIV_RTY
= 0x0c,
129 WINED3D_SM4_OP_DISCARD
= 0x0d,
130 WINED3D_SM4_OP_DIV
= 0x0e,
131 WINED3D_SM4_OP_DP2
= 0x0f,
132 WINED3D_SM4_OP_DP3
= 0x10,
133 WINED3D_SM4_OP_DP4
= 0x11,
134 WINED3D_SM4_OP_ELSE
= 0x12,
135 WINED3D_SM4_OP_EMIT
= 0x13,
136 WINED3D_SM4_OP_ENDIF
= 0x15,
137 WINED3D_SM4_OP_ENDLOOP
= 0x16,
138 WINED3D_SM4_OP_ENDSWITCH
= 0x17,
139 WINED3D_SM4_OP_EQ
= 0x18,
140 WINED3D_SM4_OP_EXP
= 0x19,
141 WINED3D_SM4_OP_FRC
= 0x1a,
142 WINED3D_SM4_OP_FTOI
= 0x1b,
143 WINED3D_SM4_OP_FTOU
= 0x1c,
144 WINED3D_SM4_OP_GE
= 0x1d,
145 WINED3D_SM4_OP_IADD
= 0x1e,
146 WINED3D_SM4_OP_IF
= 0x1f,
147 WINED3D_SM4_OP_IEQ
= 0x20,
148 WINED3D_SM4_OP_IGE
= 0x21,
149 WINED3D_SM4_OP_ILT
= 0x22,
150 WINED3D_SM4_OP_IMAD
= 0x23,
151 WINED3D_SM4_OP_IMAX
= 0x24,
152 WINED3D_SM4_OP_IMIN
= 0x25,
153 WINED3D_SM4_OP_IMUL
= 0x26,
154 WINED3D_SM4_OP_INE
= 0x27,
155 WINED3D_SM4_OP_INEG
= 0x28,
156 WINED3D_SM4_OP_ISHL
= 0x29,
157 WINED3D_SM4_OP_ISHR
= 0x2a,
158 WINED3D_SM4_OP_ITOF
= 0x2b,
159 WINED3D_SM4_OP_LABEL
= 0x2c,
160 WINED3D_SM4_OP_LD
= 0x2d,
161 WINED3D_SM4_OP_LD2DMS
= 0x2e,
162 WINED3D_SM4_OP_LOG
= 0x2f,
163 WINED3D_SM4_OP_LOOP
= 0x30,
164 WINED3D_SM4_OP_LT
= 0x31,
165 WINED3D_SM4_OP_MAD
= 0x32,
166 WINED3D_SM4_OP_MIN
= 0x33,
167 WINED3D_SM4_OP_MAX
= 0x34,
168 WINED3D_SM4_OP_SHADER_DATA
= 0x35,
169 WINED3D_SM4_OP_MOV
= 0x36,
170 WINED3D_SM4_OP_MOVC
= 0x37,
171 WINED3D_SM4_OP_MUL
= 0x38,
172 WINED3D_SM4_OP_NE
= 0x39,
173 WINED3D_SM4_OP_NOT
= 0x3b,
174 WINED3D_SM4_OP_OR
= 0x3c,
175 WINED3D_SM4_OP_RESINFO
= 0x3d,
176 WINED3D_SM4_OP_RET
= 0x3e,
177 WINED3D_SM4_OP_ROUND_NE
= 0x40,
178 WINED3D_SM4_OP_ROUND_NI
= 0x41,
179 WINED3D_SM4_OP_ROUND_PI
= 0x42,
180 WINED3D_SM4_OP_ROUND_Z
= 0x43,
181 WINED3D_SM4_OP_RSQ
= 0x44,
182 WINED3D_SM4_OP_SAMPLE
= 0x45,
183 WINED3D_SM4_OP_SAMPLE_C
= 0x46,
184 WINED3D_SM4_OP_SAMPLE_C_LZ
= 0x47,
185 WINED3D_SM4_OP_SAMPLE_LOD
= 0x48,
186 WINED3D_SM4_OP_SAMPLE_GRAD
= 0x49,
187 WINED3D_SM4_OP_SAMPLE_B
= 0x4a,
188 WINED3D_SM4_OP_SQRT
= 0x4b,
189 WINED3D_SM4_OP_SWITCH
= 0x4c,
190 WINED3D_SM4_OP_SINCOS
= 0x4d,
191 WINED3D_SM4_OP_UDIV
= 0x4e,
192 WINED3D_SM4_OP_ULT
= 0x4f,
193 WINED3D_SM4_OP_UGE
= 0x50,
194 WINED3D_SM4_OP_UMAX
= 0x53,
195 WINED3D_SM4_OP_UMIN
= 0x54,
196 WINED3D_SM4_OP_USHR
= 0x55,
197 WINED3D_SM4_OP_UTOF
= 0x56,
198 WINED3D_SM4_OP_XOR
= 0x57,
199 WINED3D_SM4_OP_DCL_RESOURCE
= 0x58,
200 WINED3D_SM4_OP_DCL_CONSTANT_BUFFER
= 0x59,
201 WINED3D_SM4_OP_DCL_SAMPLER
= 0x5a,
202 WINED3D_SM4_OP_DCL_OUTPUT_TOPOLOGY
= 0x5c,
203 WINED3D_SM4_OP_DCL_INPUT_PRIMITIVE
= 0x5d,
204 WINED3D_SM4_OP_DCL_VERTICES_OUT
= 0x5e,
205 WINED3D_SM4_OP_DCL_INPUT
= 0x5f,
206 WINED3D_SM4_OP_DCL_INPUT_SGV
= 0x60,
207 WINED3D_SM4_OP_DCL_INPUT_SIV
= 0x61,
208 WINED3D_SM4_OP_DCL_INPUT_PS
= 0x62,
209 WINED3D_SM4_OP_DCL_INPUT_PS_SGV
= 0x63,
210 WINED3D_SM4_OP_DCL_INPUT_PS_SIV
= 0x64,
211 WINED3D_SM4_OP_DCL_OUTPUT
= 0x65,
212 WINED3D_SM4_OP_DCL_OUTPUT_SIV
= 0x67,
213 WINED3D_SM4_OP_DCL_TEMPS
= 0x68,
214 WINED3D_SM4_OP_DCL_INDEXABLE_TEMP
= 0x69,
215 WINED3D_SM4_OP_DCL_GLOBAL_FLAGS
= 0x6a,
216 WINED3D_SM4_OP_LOD
= 0x6c,
217 WINED3D_SM4_OP_GATHER4
= 0x6d,
218 WINED3D_SM4_OP_SAMPLE_POS
= 0x6e,
219 WINED3D_SM4_OP_SAMPLE_INFO
= 0x6f,
220 WINED3D_SM5_OP_HS_DECLS
= 0x71,
221 WINED3D_SM5_OP_HS_CONTROL_POINT_PHASE
= 0x72,
222 WINED3D_SM5_OP_HS_FORK_PHASE
= 0x73,
223 WINED3D_SM5_OP_HS_JOIN_PHASE
= 0x74,
224 WINED3D_SM5_OP_EMIT_STREAM
= 0x75,
225 WINED3D_SM5_OP_CUT_STREAM
= 0x76,
226 WINED3D_SM5_OP_FCALL
= 0x78,
227 WINED3D_SM5_OP_BUFINFO
= 0x79,
228 WINED3D_SM5_OP_DERIV_RTX_COARSE
= 0x7a,
229 WINED3D_SM5_OP_DERIV_RTX_FINE
= 0x7b,
230 WINED3D_SM5_OP_DERIV_RTY_COARSE
= 0x7c,
231 WINED3D_SM5_OP_DERIV_RTY_FINE
= 0x7d,
232 WINED3D_SM5_OP_GATHER4_C
= 0x7e,
233 WINED3D_SM5_OP_RCP
= 0x81,
234 WINED3D_SM5_OP_UBFE
= 0x8a,
235 WINED3D_SM5_OP_BFI
= 0x8c,
236 WINED3D_SM5_OP_BFREV
= 0x8d,
237 WINED3D_SM5_OP_SWAPC
= 0x8e,
238 WINED3D_SM5_OP_DCL_STREAM
= 0x8f,
239 WINED3D_SM5_OP_DCL_FUNCTION_BODY
= 0x90,
240 WINED3D_SM5_OP_DCL_FUNCTION_TABLE
= 0x91,
241 WINED3D_SM5_OP_DCL_INTERFACE
= 0x92,
242 WINED3D_SM5_OP_DCL_INPUT_CONTROL_POINT_COUNT
= 0x93,
243 WINED3D_SM5_OP_DCL_OUTPUT_CONTROL_POINT_COUNT
= 0x94,
244 WINED3D_SM5_OP_DCL_TESSELLATOR_DOMAIN
= 0x95,
245 WINED3D_SM5_OP_DCL_TESSELLATOR_PARTITIONING
= 0x96,
246 WINED3D_SM5_OP_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
= 0x97,
247 WINED3D_SM5_OP_DCL_HS_MAX_TESSFACTOR
= 0x98,
248 WINED3D_SM5_OP_DCL_HS_FORK_PHASE_INSTANCE_COUNT
= 0x99,
249 WINED3D_SM5_OP_DCL_THREAD_GROUP
= 0x9b,
250 WINED3D_SM5_OP_DCL_UAV_TYPED
= 0x9c,
251 WINED3D_SM5_OP_DCL_UAV_RAW
= 0x9d,
252 WINED3D_SM5_OP_DCL_UAV_STRUCTURED
= 0x9e,
253 WINED3D_SM5_OP_DCL_TGSM_RAW
= 0x9f,
254 WINED3D_SM5_OP_DCL_TGSM_STRUCTURED
= 0xa0,
255 WINED3D_SM5_OP_DCL_RESOURCE_STRUCTURED
= 0xa2,
256 WINED3D_SM5_OP_LD_UAV_TYPED
= 0xa3,
257 WINED3D_SM5_OP_STORE_UAV_TYPED
= 0xa4,
258 WINED3D_SM5_OP_LD_RAW
= 0xa5,
259 WINED3D_SM5_OP_STORE_RAW
= 0xa6,
260 WINED3D_SM5_OP_LD_STRUCTURED
= 0xa7,
261 WINED3D_SM5_OP_STORE_STRUCTURED
= 0xa8,
262 WINED3D_SM5_OP_ATOMIC_AND
= 0xa9,
263 WINED3D_SM5_OP_ATOMIC_OR
= 0xaa,
264 WINED3D_SM5_OP_ATOMIC_XOR
= 0xab,
265 WINED3D_SM5_OP_ATOMIC_CMP_STORE
= 0xac,
266 WINED3D_SM5_OP_ATOMIC_IADD
= 0xad,
267 WINED3D_SM5_OP_ATOMIC_IMAX
= 0xae,
268 WINED3D_SM5_OP_ATOMIC_UMAX
= 0xb0,
269 WINED3D_SM5_OP_ATOMIC_UMIN
= 0xb1,
270 WINED3D_SM5_OP_IMM_ATOMIC_ALLOC
= 0xb2,
271 WINED3D_SM5_OP_IMM_ATOMIC_CONSUME
= 0xb3,
272 WINED3D_SM5_OP_IMM_ATOMIC_AND
= 0xb5,
273 WINED3D_SM5_OP_IMM_ATOMIC_OR
= 0xb6,
274 WINED3D_SM5_OP_IMM_ATOMIC_XOR
= 0xb7,
275 WINED3D_SM5_OP_IMM_ATOMIC_EXCH
= 0xb8,
276 WINED3D_SM5_OP_IMM_ATOMIC_CMP_EXCH
= 0xb9,
277 WINED3D_SM5_OP_IMM_ATOMIC_UMAX
= 0xbc,
278 WINED3D_SM5_OP_IMM_ATOMIC_UMIN
= 0xbd,
279 WINED3D_SM5_OP_SYNC
= 0xbe,
282 enum wined3d_sm4_register_type
284 WINED3D_SM4_RT_TEMP
= 0x00,
285 WINED3D_SM4_RT_INPUT
= 0x01,
286 WINED3D_SM4_RT_OUTPUT
= 0x02,
287 WINED3D_SM4_RT_INDEXABLE_TEMP
= 0x03,
288 WINED3D_SM4_RT_IMMCONST
= 0x04,
289 WINED3D_SM4_RT_SAMPLER
= 0x06,
290 WINED3D_SM4_RT_RESOURCE
= 0x07,
291 WINED3D_SM4_RT_CONSTBUFFER
= 0x08,
292 WINED3D_SM4_RT_IMMCONSTBUFFER
= 0x09,
293 WINED3D_SM4_RT_PRIMID
= 0x0b,
294 WINED3D_SM4_RT_DEPTHOUT
= 0x0c,
295 WINED3D_SM4_RT_NULL
= 0x0d,
296 WINED3D_SM4_RT_OMASK
= 0x0f,
297 WINED3D_SM5_RT_STREAM
= 0x10,
298 WINED3D_SM5_RT_FUNCTION_BODY
= 0x11,
299 WINED3D_SM5_RT_FUNCTION_POINTER
= 0x13,
300 WINED3D_SM5_RT_OUTPUT_CONTROL_POINT_ID
= 0x16,
301 WINED3D_SM5_RT_FORK_INSTANCE_ID
= 0x17,
302 WINED3D_SM5_RT_INPUT_CONTROL_POINT
= 0x19,
303 WINED3D_SM5_RT_OUTPUT_CONTROL_POINT
= 0x1a,
304 WINED3D_SM5_RT_PATCH_CONSTANT_DATA
= 0x1b,
305 WINED3D_SM5_RT_DOMAIN_LOCATION
= 0x1c,
306 WINED3D_SM5_RT_UAV
= 0x1e,
307 WINED3D_SM5_RT_SHARED_MEMORY
= 0x1f,
308 WINED3D_SM5_RT_THREAD_ID
= 0x20,
309 WINED3D_SM5_RT_THREAD_GROUP_ID
= 0x21,
310 WINED3D_SM5_RT_LOCAL_THREAD_ID
= 0x22,
311 WINED3D_SM5_RT_COVERAGE
= 0x23,
312 WINED3D_SM5_RT_LOCAL_THREAD_INDEX
= 0x24,
315 enum wined3d_sm4_output_primitive_type
317 WINED3D_SM4_OUTPUT_PT_POINTLIST
= 0x1,
318 WINED3D_SM4_OUTPUT_PT_LINELIST
= 0x3,
319 WINED3D_SM4_OUTPUT_PT_TRIANGLESTRIP
= 0x5,
322 enum wined3d_sm4_input_primitive_type
324 WINED3D_SM4_INPUT_PT_POINT
= 0x1,
325 WINED3D_SM4_INPUT_PT_LINE
= 0x2,
326 WINED3D_SM4_INPUT_PT_TRIANGLE
= 0x3,
327 WINED3D_SM4_INPUT_PT_LINEADJ
= 0x6,
328 WINED3D_SM4_INPUT_PT_TRIANGLEADJ
= 0x7,
331 enum wined3d_sm4_swizzle_type
333 WINED3D_SM4_SWIZZLE_NONE
= 0x0,
334 WINED3D_SM4_SWIZZLE_VEC4
= 0x1,
335 WINED3D_SM4_SWIZZLE_SCALAR
= 0x2,
338 enum wined3d_sm4_immconst_type
340 WINED3D_SM4_IMMCONST_SCALAR
= 0x1,
341 WINED3D_SM4_IMMCONST_VEC4
= 0x2,
344 enum wined3d_sm4_resource_type
346 WINED3D_SM4_RESOURCE_BUFFER
= 0x1,
347 WINED3D_SM4_RESOURCE_TEXTURE_1D
= 0x2,
348 WINED3D_SM4_RESOURCE_TEXTURE_2D
= 0x3,
349 WINED3D_SM4_RESOURCE_TEXTURE_2DMS
= 0x4,
350 WINED3D_SM4_RESOURCE_TEXTURE_3D
= 0x5,
351 WINED3D_SM4_RESOURCE_TEXTURE_CUBE
= 0x6,
352 WINED3D_SM4_RESOURCE_TEXTURE_1DARRAY
= 0x7,
353 WINED3D_SM4_RESOURCE_TEXTURE_2DARRAY
= 0x8,
354 WINED3D_SM4_RESOURCE_TEXTURE_2DMSARRAY
= 0x9,
357 enum wined3d_sm4_data_type
359 WINED3D_SM4_DATA_UNORM
= 0x1,
360 WINED3D_SM4_DATA_SNORM
= 0x2,
361 WINED3D_SM4_DATA_INT
= 0x3,
362 WINED3D_SM4_DATA_UINT
= 0x4,
363 WINED3D_SM4_DATA_FLOAT
= 0x5,
366 enum wined3d_sm4_sampler_mode
368 WINED3D_SM4_SAMPLER_DEFAULT
= 0x0,
369 WINED3D_SM4_SAMPLER_COMPARISON
= 0x1,
372 enum wined3d_sm4_shader_data_type
374 WINED3D_SM4_SHADER_DATA_IMMEDIATE_CONSTANT_BUFFER
= 0x3,
375 WINED3D_SM4_SHADER_DATA_MESSAGE
= 0x4,
378 struct wined3d_shader_src_param_entry
381 struct wined3d_shader_src_param param
;
384 struct wined3d_sm4_data
386 struct wined3d_shader_version shader_version
;
389 unsigned int output_map
[MAX_REG_OUTPUT
];
391 struct wined3d_shader_src_param src_param
[5];
392 struct wined3d_shader_dst_param dst_param
[2];
393 struct list src_free
;
395 struct wined3d_shader_immediate_constant_buffer icb
;
398 struct wined3d_sm4_opcode_info
400 enum wined3d_sm4_opcode opcode
;
401 enum WINED3D_SHADER_INSTRUCTION_HANDLER handler_idx
;
402 const char *dst_info
;
403 const char *src_info
;
404 void (*read_opcode_func
)(struct wined3d_shader_instruction
*ins
,
405 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
406 struct wined3d_sm4_data
*priv
);
409 static const enum wined3d_primitive_type output_primitive_type_table
[] =
411 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
412 /* WINED3D_SM4_OUTPUT_PT_POINTLIST */ WINED3D_PT_POINTLIST
,
413 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
414 /* WINED3D_SM4_OUTPUT_PT_LINELIST */ WINED3D_PT_LINELIST
,
415 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
416 /* WINED3D_SM4_OUTPUT_PT_TRIANGLESTRIP */ WINED3D_PT_TRIANGLESTRIP
,
419 static const enum wined3d_primitive_type input_primitive_type_table
[] =
421 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
422 /* WINED3D_SM4_INPUT_PT_POINT */ WINED3D_PT_POINTLIST
,
423 /* WINED3D_SM4_INPUT_PT_LINE */ WINED3D_PT_LINELIST
,
424 /* WINED3D_SM4_INPUT_PT_TRIANGLE */ WINED3D_PT_TRIANGLELIST
,
425 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
426 /* UNKNOWN */ WINED3D_PT_UNDEFINED
,
427 /* WINED3D_SM4_INPUT_PT_LINEADJ */ WINED3D_PT_LINELIST_ADJ
,
428 /* WINED3D_SM4_INPUT_PT_TRIANGLEADJ */ WINED3D_PT_TRIANGLELIST_ADJ
,
431 static const enum wined3d_shader_resource_type resource_type_table
[] =
433 /* 0 */ WINED3D_SHADER_RESOURCE_NONE
,
434 /* WINED3D_SM4_RESOURCE_BUFFER */ WINED3D_SHADER_RESOURCE_BUFFER
,
435 /* WINED3D_SM4_RESOURCE_TEXTURE_1D */ WINED3D_SHADER_RESOURCE_TEXTURE_1D
,
436 /* WINED3D_SM4_RESOURCE_TEXTURE_2D */ WINED3D_SHADER_RESOURCE_TEXTURE_2D
,
437 /* WINED3D_SM4_RESOURCE_TEXTURE_2DMS */ WINED3D_SHADER_RESOURCE_TEXTURE_2DMS
,
438 /* WINED3D_SM4_RESOURCE_TEXTURE_3D */ WINED3D_SHADER_RESOURCE_TEXTURE_3D
,
439 /* WINED3D_SM4_RESOURCE_TEXTURE_CUBE */ WINED3D_SHADER_RESOURCE_TEXTURE_CUBE
,
440 /* WINED3D_SM4_RESOURCE_TEXTURE_1DARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
,
441 /* WINED3D_SM4_RESOURCE_TEXTURE_2DARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
,
442 /* WINED3D_SM4_RESOURCE_TEXTURE_2DMSARRAY */ WINED3D_SHADER_RESOURCE_TEXTURE_2DMSARRAY
,
445 static const enum wined3d_data_type data_type_table
[] =
447 /* 0 */ WINED3D_DATA_FLOAT
,
448 /* WINED3D_SM4_DATA_UNORM */ WINED3D_DATA_UNORM
,
449 /* WINED3D_SM4_DATA_SNORM */ WINED3D_DATA_SNORM
,
450 /* WINED3D_SM4_DATA_INT */ WINED3D_DATA_INT
,
451 /* WINED3D_SM4_DATA_UINT */ WINED3D_DATA_UINT
,
452 /* WINED3D_SM4_DATA_FLOAT */ WINED3D_DATA_FLOAT
,
455 static BOOL
shader_sm4_read_src_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
456 enum wined3d_data_type data_type
, struct wined3d_shader_src_param
*src_param
);
457 static BOOL
shader_sm4_read_dst_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
458 enum wined3d_data_type data_type
, struct wined3d_shader_dst_param
*dst_param
);
460 static void shader_sm4_read_conditional_op(struct wined3d_shader_instruction
*ins
,
461 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
462 struct wined3d_sm4_data
*priv
)
464 shader_sm4_read_src_param(priv
, &tokens
, WINED3D_DATA_UINT
, &priv
->src_param
[0]);
465 ins
->flags
= (opcode_token
& WINED3D_SM4_CONDITIONAL_NZ
) ?
466 WINED3D_SHADER_CONDITIONAL_OP_NZ
: WINED3D_SHADER_CONDITIONAL_OP_Z
;
469 static void shader_sm4_read_shader_data(struct wined3d_shader_instruction
*ins
,
470 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
471 struct wined3d_sm4_data
*priv
)
473 enum wined3d_sm4_shader_data_type type
;
474 unsigned int icb_size
;
476 type
= (opcode_token
& WINED3D_SM4_SHADER_DATA_TYPE_MASK
) >> WINED3D_SM4_SHADER_DATA_TYPE_SHIFT
;
477 if (type
!= WINED3D_SM4_SHADER_DATA_IMMEDIATE_CONSTANT_BUFFER
)
479 FIXME("Unhandled shader data type %#x.\n", type
);
480 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
485 icb_size
= token_count
- 1;
486 if (icb_size
% 4 || icb_size
> MAX_IMMEDIATE_CONSTANT_BUFFER_SIZE
)
488 FIXME("Unexpected immediate constant buffer size %u.\n", icb_size
);
489 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
493 priv
->icb
.vec4_count
= icb_size
/ 4;
494 memcpy(priv
->icb
.data
, tokens
, sizeof(*tokens
) * icb_size
);
495 ins
->declaration
.icb
= &priv
->icb
;
498 static void shader_sm4_read_dcl_resource(struct wined3d_shader_instruction
*ins
,
499 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
500 struct wined3d_sm4_data
*priv
)
502 enum wined3d_sm4_resource_type resource_type
;
503 enum wined3d_sm4_data_type data_type
;
504 enum wined3d_data_type reg_data_type
;
507 resource_type
= (opcode_token
& WINED3D_SM4_RESOURCE_TYPE_MASK
) >> WINED3D_SM4_RESOURCE_TYPE_SHIFT
;
508 if (!resource_type
|| (resource_type
>= ARRAY_SIZE(resource_type_table
)))
510 FIXME("Unhandled resource type %#x.\n", resource_type
);
511 ins
->declaration
.semantic
.resource_type
= WINED3D_SHADER_RESOURCE_NONE
;
515 ins
->declaration
.semantic
.resource_type
= resource_type_table
[resource_type
];
517 reg_data_type
= opcode
== WINED3D_SM4_OP_DCL_RESOURCE
? WINED3D_DATA_RESOURCE
: WINED3D_DATA_UAV
;
518 shader_sm4_read_dst_param(priv
, &tokens
, reg_data_type
, &ins
->declaration
.semantic
.reg
);
520 components
= *tokens
++;
521 if ((components
& 0xfff0) != (components
& 0xf) * 0x1110)
522 FIXME("Components (%#x) have different data types.\n", components
);
523 data_type
= components
& 0xf;
525 if (!data_type
|| (data_type
>= ARRAY_SIZE(data_type_table
)))
527 FIXME("Unhandled data type %#x.\n", data_type
);
528 ins
->declaration
.semantic
.resource_data_type
= WINED3D_DATA_FLOAT
;
532 ins
->declaration
.semantic
.resource_data_type
= data_type_table
[data_type
];
536 static void shader_sm4_read_dcl_constant_buffer(struct wined3d_shader_instruction
*ins
,
537 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
538 struct wined3d_sm4_data
*priv
)
540 shader_sm4_read_src_param(priv
, &tokens
, WINED3D_DATA_FLOAT
, &ins
->declaration
.src
);
541 if (opcode_token
& WINED3D_SM4_INDEX_TYPE_MASK
)
542 ins
->flags
|= WINED3DSI_INDEXED_DYNAMIC
;
545 static void shader_sm4_read_dcl_sampler(struct wined3d_shader_instruction
*ins
,
546 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
547 struct wined3d_sm4_data
*priv
)
549 ins
->flags
= (opcode_token
& WINED3D_SM4_SAMPLER_MODE_MASK
) >> WINED3D_SM4_SAMPLER_MODE_SHIFT
;
550 if (ins
->flags
& ~WINED3D_SM4_SAMPLER_COMPARISON
)
551 FIXME("Unhandled sampler mode %#x.\n", ins
->flags
);
552 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_SAMPLER
, &ins
->declaration
.dst
);
555 static void shader_sm4_read_dcl_output_topology(struct wined3d_shader_instruction
*ins
,
556 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
557 struct wined3d_sm4_data
*priv
)
559 enum wined3d_sm4_output_primitive_type primitive_type
;
561 primitive_type
= (opcode_token
& WINED3D_SM4_PRIMITIVE_TYPE_MASK
) >> WINED3D_SM4_PRIMITIVE_TYPE_SHIFT
;
562 if (primitive_type
>= sizeof(output_primitive_type_table
) / sizeof(*output_primitive_type_table
))
564 FIXME("Unhandled output primitive type %#x.\n", primitive_type
);
565 ins
->declaration
.primitive_type
= WINED3D_PT_UNDEFINED
;
569 ins
->declaration
.primitive_type
= output_primitive_type_table
[primitive_type
];
573 static void shader_sm4_read_dcl_input_primitive(struct wined3d_shader_instruction
*ins
,
574 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
575 struct wined3d_sm4_data
*priv
)
577 enum wined3d_sm4_input_primitive_type primitive_type
;
579 primitive_type
= (opcode_token
& WINED3D_SM4_PRIMITIVE_TYPE_MASK
) >> WINED3D_SM4_PRIMITIVE_TYPE_SHIFT
;
580 if (primitive_type
>= sizeof(input_primitive_type_table
) / sizeof(*input_primitive_type_table
))
582 FIXME("Unhandled input primitive type %#x.\n", primitive_type
);
583 ins
->declaration
.primitive_type
= WINED3D_PT_UNDEFINED
;
587 ins
->declaration
.primitive_type
= input_primitive_type_table
[primitive_type
];
591 static void shader_sm4_read_declaration_count(struct wined3d_shader_instruction
*ins
,
592 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
593 struct wined3d_sm4_data
*priv
)
595 ins
->declaration
.count
= *tokens
;
598 static void shader_sm4_read_declaration_dst(struct wined3d_shader_instruction
*ins
,
599 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
600 struct wined3d_sm4_data
*priv
)
602 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_FLOAT
, &ins
->declaration
.dst
);
605 static void shader_sm4_read_declaration_register_semantic(struct wined3d_shader_instruction
*ins
,
606 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
607 struct wined3d_sm4_data
*priv
)
609 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_FLOAT
, &ins
->declaration
.register_semantic
.reg
);
610 ins
->declaration
.register_semantic
.sysval_semantic
= *tokens
;
613 static void shader_sm4_read_dcl_input_ps(struct wined3d_shader_instruction
*ins
,
614 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
615 struct wined3d_sm4_data
*priv
)
617 ins
->flags
= (opcode_token
& WINED3D_SM4_INTERPOLATION_MODE_MASK
) >> WINED3D_SM4_INTERPOLATION_MODE_SHIFT
;
618 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_FLOAT
, &ins
->declaration
.dst
);
621 static void shader_sm4_read_dcl_input_ps_siv(struct wined3d_shader_instruction
*ins
,
622 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
623 struct wined3d_sm4_data
*priv
)
625 ins
->flags
= (opcode_token
& WINED3D_SM4_INTERPOLATION_MODE_MASK
) >> WINED3D_SM4_INTERPOLATION_MODE_SHIFT
;
626 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_FLOAT
, &ins
->declaration
.register_semantic
.reg
);
627 ins
->declaration
.register_semantic
.sysval_semantic
= *tokens
;
630 static void shader_sm4_read_dcl_indexable_temp(struct wined3d_shader_instruction
*ins
,
631 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
632 struct wined3d_sm4_data
*priv
)
634 ins
->declaration
.indexable_temp
.register_idx
= *tokens
++;
635 ins
->declaration
.indexable_temp
.register_size
= *tokens
++;
636 ins
->declaration
.indexable_temp
.component_count
= *tokens
;
639 static void shader_sm4_read_dcl_global_flags(struct wined3d_shader_instruction
*ins
,
640 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
641 struct wined3d_sm4_data
*priv
)
643 ins
->flags
= (opcode_token
& WINED3D_SM4_GLOBAL_FLAGS_MASK
) >> WINED3D_SM4_GLOBAL_FLAGS_SHIFT
;
646 static void shader_sm5_read_fcall(struct wined3d_shader_instruction
*ins
,
647 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
648 struct wined3d_sm4_data
*priv
)
650 priv
->src_param
[0].reg
.u
.fp_body_idx
= *tokens
++;
651 shader_sm4_read_src_param(priv
, &tokens
, WINED3D_DATA_OPAQUE
, &priv
->src_param
[0]);
654 static void shader_sm5_read_dcl_function_body(struct wined3d_shader_instruction
*ins
,
655 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
656 struct wined3d_sm4_data
*priv
)
658 ins
->declaration
.index
= *tokens
;
661 static void shader_sm5_read_dcl_function_table(struct wined3d_shader_instruction
*ins
,
662 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
663 struct wined3d_sm4_data
*priv
)
665 ins
->declaration
.index
= *tokens
++;
666 FIXME("Ignoring set of function bodies (count %u).\n", *tokens
);
669 static void shader_sm5_read_dcl_interface(struct wined3d_shader_instruction
*ins
,
670 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
671 struct wined3d_sm4_data
*priv
)
673 ins
->declaration
.fp
.index
= *tokens
++;
674 ins
->declaration
.fp
.body_count
= *tokens
++;
675 ins
->declaration
.fp
.array_size
= *tokens
>> WINED3D_SM5_FP_ARRAY_SIZE_SHIFT
;
676 ins
->declaration
.fp
.table_count
= *tokens
++ & WINED3D_SM5_FP_TABLE_COUNT_MASK
;
677 FIXME("Ignoring set of function tables (count %u).\n", ins
->declaration
.fp
.table_count
);
680 static void shader_sm5_read_control_point_count(struct wined3d_shader_instruction
*ins
,
681 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
682 struct wined3d_sm4_data
*priv
)
684 ins
->declaration
.count
= (opcode_token
& WINED3D_SM5_CONTROL_POINT_COUNT_MASK
)
685 >> WINED3D_SM5_CONTROL_POINT_COUNT_SHIFT
;
688 static void shader_sm5_read_dcl_tessellator_domain(struct wined3d_shader_instruction
*ins
,
689 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
690 struct wined3d_sm4_data
*priv
)
692 ins
->declaration
.tessellator_domain
= (opcode_token
& WINED3D_SM5_TESSELLATOR_MASK
)
693 >> WINED3D_SM5_TESSELLATOR_SHIFT
;
696 static void shader_sm5_read_dcl_tessellator_partitioning(struct wined3d_shader_instruction
*ins
,
697 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
698 struct wined3d_sm4_data
*priv
)
700 ins
->declaration
.tessellator_partitioning
= (opcode_token
& WINED3D_SM5_TESSELLATOR_MASK
)
701 >> WINED3D_SM5_TESSELLATOR_SHIFT
;
704 static void shader_sm5_read_dcl_tessellator_output_primitive(struct wined3d_shader_instruction
*ins
,
705 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
706 struct wined3d_sm4_data
*priv
)
708 ins
->declaration
.tessellator_output_primitive
= (opcode_token
& WINED3D_SM5_TESSELLATOR_MASK
)
709 >> WINED3D_SM5_TESSELLATOR_SHIFT
;
712 static void shader_sm5_read_dcl_hs_max_tessfactor(struct wined3d_shader_instruction
*ins
,
713 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
714 struct wined3d_sm4_data
*priv
)
716 ins
->declaration
.max_tessellation_factor
= *(float *)tokens
;
719 static void shader_sm5_read_dcl_thread_group(struct wined3d_shader_instruction
*ins
,
720 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
721 struct wined3d_sm4_data
*priv
)
723 ins
->declaration
.thread_group_size
.x
= *tokens
++;
724 ins
->declaration
.thread_group_size
.y
= *tokens
++;
725 ins
->declaration
.thread_group_size
.z
= *tokens
++;
728 static void shader_sm5_read_dcl_uav_raw(struct wined3d_shader_instruction
*ins
,
729 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
730 struct wined3d_sm4_data
*priv
)
732 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_UAV
, &ins
->declaration
.dst
);
733 ins
->flags
= (opcode_token
& WINED3D_SM5_UAV_FLAGS_MASK
) >> WINED3D_SM5_UAV_FLAGS_SHIFT
;
736 static void shader_sm5_read_dcl_uav_structured(struct wined3d_shader_instruction
*ins
,
737 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
738 struct wined3d_sm4_data
*priv
)
740 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_UAV
, &ins
->declaration
.structured_resource
.reg
);
741 ins
->flags
= (opcode_token
& WINED3D_SM5_UAV_FLAGS_MASK
) >> WINED3D_SM5_UAV_FLAGS_SHIFT
;
742 ins
->declaration
.structured_resource
.byte_stride
= *tokens
;
745 static void shader_sm5_read_dcl_tgsm_raw(struct wined3d_shader_instruction
*ins
,
746 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
747 struct wined3d_sm4_data
*priv
)
749 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_FLOAT
, &ins
->declaration
.tgsm_raw
.reg
);
750 ins
->declaration
.tgsm_raw
.byte_count
= *tokens
;
753 static void shader_sm5_read_dcl_tgsm_structured(struct wined3d_shader_instruction
*ins
,
754 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
755 struct wined3d_sm4_data
*priv
)
757 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_FLOAT
, &ins
->declaration
.tgsm_structured
.reg
);
758 ins
->declaration
.tgsm_structured
.byte_stride
= *tokens
++;
759 ins
->declaration
.tgsm_structured
.structure_count
= *tokens
;
762 static void shader_sm5_read_dcl_resource_structured(struct wined3d_shader_instruction
*ins
,
763 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
764 struct wined3d_sm4_data
*priv
)
766 shader_sm4_read_dst_param(priv
, &tokens
, WINED3D_DATA_RESOURCE
, &ins
->declaration
.structured_resource
.reg
);
767 ins
->declaration
.structured_resource
.byte_stride
= *tokens
;
770 static void shader_sm5_read_sync(struct wined3d_shader_instruction
*ins
,
771 DWORD opcode
, DWORD opcode_token
, const DWORD
*tokens
, unsigned int token_count
,
772 struct wined3d_sm4_data
*priv
)
774 ins
->flags
= (opcode_token
& WINED3D_SM5_SYNC_FLAGS_MASK
) >> WINED3D_SM5_SYNC_FLAGS_SHIFT
;
778 * f -> WINED3D_DATA_FLOAT
779 * i -> WINED3D_DATA_INT
780 * u -> WINED3D_DATA_UINT
781 * O -> WINED3D_DATA_OPAQUE
782 * R -> WINED3D_DATA_RESOURCE
783 * S -> WINED3D_DATA_SAMPLER
784 * U -> WINED3D_DATA_UAV
786 static const struct wined3d_sm4_opcode_info opcode_table
[] =
788 {WINED3D_SM4_OP_ADD
, WINED3DSIH_ADD
, "f", "ff"},
789 {WINED3D_SM4_OP_AND
, WINED3DSIH_AND
, "u", "uu"},
790 {WINED3D_SM4_OP_BREAK
, WINED3DSIH_BREAK
, "", ""},
791 {WINED3D_SM4_OP_BREAKC
, WINED3DSIH_BREAKP
, "", "u",
792 shader_sm4_read_conditional_op
},
793 {WINED3D_SM4_OP_CASE
, WINED3DSIH_CASE
, "", "u"},
794 {WINED3D_SM4_OP_CONTINUE
, WINED3DSIH_CONTINUE
, "", ""},
795 {WINED3D_SM4_OP_CUT
, WINED3DSIH_CUT
, "", ""},
796 {WINED3D_SM4_OP_DEFAULT
, WINED3DSIH_DEFAULT
, "", ""},
797 {WINED3D_SM4_OP_DERIV_RTX
, WINED3DSIH_DSX
, "f", "f"},
798 {WINED3D_SM4_OP_DERIV_RTY
, WINED3DSIH_DSY
, "f", "f"},
799 {WINED3D_SM4_OP_DISCARD
, WINED3DSIH_TEXKILL
, "", "u"},
800 {WINED3D_SM4_OP_DIV
, WINED3DSIH_DIV
, "f", "ff"},
801 {WINED3D_SM4_OP_DP2
, WINED3DSIH_DP2
, "f", "ff"},
802 {WINED3D_SM4_OP_DP3
, WINED3DSIH_DP3
, "f", "ff"},
803 {WINED3D_SM4_OP_DP4
, WINED3DSIH_DP4
, "f", "ff"},
804 {WINED3D_SM4_OP_ELSE
, WINED3DSIH_ELSE
, "", ""},
805 {WINED3D_SM4_OP_EMIT
, WINED3DSIH_EMIT
, "", ""},
806 {WINED3D_SM4_OP_ENDIF
, WINED3DSIH_ENDIF
, "", ""},
807 {WINED3D_SM4_OP_ENDLOOP
, WINED3DSIH_ENDLOOP
, "", ""},
808 {WINED3D_SM4_OP_ENDSWITCH
, WINED3DSIH_ENDSWITCH
, "", ""},
809 {WINED3D_SM4_OP_EQ
, WINED3DSIH_EQ
, "u", "ff"},
810 {WINED3D_SM4_OP_EXP
, WINED3DSIH_EXP
, "f", "f"},
811 {WINED3D_SM4_OP_FRC
, WINED3DSIH_FRC
, "f", "f"},
812 {WINED3D_SM4_OP_FTOI
, WINED3DSIH_FTOI
, "i", "f"},
813 {WINED3D_SM4_OP_FTOU
, WINED3DSIH_FTOU
, "u", "f"},
814 {WINED3D_SM4_OP_GE
, WINED3DSIH_GE
, "u", "ff"},
815 {WINED3D_SM4_OP_IADD
, WINED3DSIH_IADD
, "i", "ii"},
816 {WINED3D_SM4_OP_IF
, WINED3DSIH_IF
, "", "u",
817 shader_sm4_read_conditional_op
},
818 {WINED3D_SM4_OP_IEQ
, WINED3DSIH_IEQ
, "u", "ii"},
819 {WINED3D_SM4_OP_IGE
, WINED3DSIH_IGE
, "u", "ii"},
820 {WINED3D_SM4_OP_ILT
, WINED3DSIH_ILT
, "u", "ii"},
821 {WINED3D_SM4_OP_IMAD
, WINED3DSIH_IMAD
, "i", "iii"},
822 {WINED3D_SM4_OP_IMAX
, WINED3DSIH_IMAX
, "i", "ii"},
823 {WINED3D_SM4_OP_IMIN
, WINED3DSIH_IMIN
, "i", "ii"},
824 {WINED3D_SM4_OP_IMUL
, WINED3DSIH_IMUL
, "ii", "ii"},
825 {WINED3D_SM4_OP_INE
, WINED3DSIH_INE
, "u", "ii"},
826 {WINED3D_SM4_OP_INEG
, WINED3DSIH_INEG
, "i", "i"},
827 {WINED3D_SM4_OP_ISHL
, WINED3DSIH_ISHL
, "i", "ii"},
828 {WINED3D_SM4_OP_ISHR
, WINED3DSIH_ISHR
, "i", "ii"},
829 {WINED3D_SM4_OP_ITOF
, WINED3DSIH_ITOF
, "f", "i"},
830 {WINED3D_SM4_OP_LABEL
, WINED3DSIH_LABEL
, "", "O"},
831 {WINED3D_SM4_OP_LD
, WINED3DSIH_LD
, "u", "iR"},
832 {WINED3D_SM4_OP_LD2DMS
, WINED3DSIH_LD2DMS
, "u", "iRi"},
833 {WINED3D_SM4_OP_LOG
, WINED3DSIH_LOG
, "f", "f"},
834 {WINED3D_SM4_OP_LOOP
, WINED3DSIH_LOOP
, "", ""},
835 {WINED3D_SM4_OP_LT
, WINED3DSIH_LT
, "u", "ff"},
836 {WINED3D_SM4_OP_MAD
, WINED3DSIH_MAD
, "f", "fff"},
837 {WINED3D_SM4_OP_MIN
, WINED3DSIH_MIN
, "f", "ff"},
838 {WINED3D_SM4_OP_MAX
, WINED3DSIH_MAX
, "f", "ff"},
839 {WINED3D_SM4_OP_SHADER_DATA
, WINED3DSIH_DCL_IMMEDIATE_CONSTANT_BUFFER
, "", "",
840 shader_sm4_read_shader_data
},
841 {WINED3D_SM4_OP_MOV
, WINED3DSIH_MOV
, "f", "f"},
842 {WINED3D_SM4_OP_MOVC
, WINED3DSIH_MOVC
, "f", "uff"},
843 {WINED3D_SM4_OP_MUL
, WINED3DSIH_MUL
, "f", "ff"},
844 {WINED3D_SM4_OP_NE
, WINED3DSIH_NE
, "u", "ff"},
845 {WINED3D_SM4_OP_NOT
, WINED3DSIH_NOT
, "u", "u"},
846 {WINED3D_SM4_OP_OR
, WINED3DSIH_OR
, "u", "uu"},
847 {WINED3D_SM4_OP_RESINFO
, WINED3DSIH_RESINFO
, "f", "iR"},
848 {WINED3D_SM4_OP_RET
, WINED3DSIH_RET
, "", ""},
849 {WINED3D_SM4_OP_ROUND_NE
, WINED3DSIH_ROUND_NE
, "f", "f"},
850 {WINED3D_SM4_OP_ROUND_NI
, WINED3DSIH_ROUND_NI
, "f", "f"},
851 {WINED3D_SM4_OP_ROUND_PI
, WINED3DSIH_ROUND_PI
, "f", "f"},
852 {WINED3D_SM4_OP_ROUND_Z
, WINED3DSIH_ROUND_Z
, "f", "f"},
853 {WINED3D_SM4_OP_RSQ
, WINED3DSIH_RSQ
, "f", "f"},
854 {WINED3D_SM4_OP_SAMPLE
, WINED3DSIH_SAMPLE
, "u", "fRS"},
855 {WINED3D_SM4_OP_SAMPLE_C
, WINED3DSIH_SAMPLE_C
, "f", "fRSf"},
856 {WINED3D_SM4_OP_SAMPLE_C_LZ
, WINED3DSIH_SAMPLE_C_LZ
, "f", "fRSf"},
857 {WINED3D_SM4_OP_SAMPLE_LOD
, WINED3DSIH_SAMPLE_LOD
, "u", "fRSf"},
858 {WINED3D_SM4_OP_SAMPLE_GRAD
, WINED3DSIH_SAMPLE_GRAD
, "u", "fRSff"},
859 {WINED3D_SM4_OP_SAMPLE_B
, WINED3DSIH_SAMPLE_B
, "u", "fRSf"},
860 {WINED3D_SM4_OP_SQRT
, WINED3DSIH_SQRT
, "f", "f"},
861 {WINED3D_SM4_OP_SWITCH
, WINED3DSIH_SWITCH
, "", "u"},
862 {WINED3D_SM4_OP_SINCOS
, WINED3DSIH_SINCOS
, "ff", "f"},
863 {WINED3D_SM4_OP_UDIV
, WINED3DSIH_UDIV
, "uu", "uu"},
864 {WINED3D_SM4_OP_ULT
, WINED3DSIH_ULT
, "u", "uu"},
865 {WINED3D_SM4_OP_UGE
, WINED3DSIH_UGE
, "u", "uu"},
866 {WINED3D_SM4_OP_UMAX
, WINED3DSIH_UMAX
, "u", "uu"},
867 {WINED3D_SM4_OP_UMIN
, WINED3DSIH_UMIN
, "u", "uu"},
868 {WINED3D_SM4_OP_USHR
, WINED3DSIH_USHR
, "u", "uu"},
869 {WINED3D_SM4_OP_UTOF
, WINED3DSIH_UTOF
, "f", "u"},
870 {WINED3D_SM4_OP_XOR
, WINED3DSIH_XOR
, "u", "uu"},
871 {WINED3D_SM4_OP_DCL_RESOURCE
, WINED3DSIH_DCL
, "R", "",
872 shader_sm4_read_dcl_resource
},
873 {WINED3D_SM4_OP_DCL_CONSTANT_BUFFER
, WINED3DSIH_DCL_CONSTANT_BUFFER
, "", "",
874 shader_sm4_read_dcl_constant_buffer
},
875 {WINED3D_SM4_OP_DCL_SAMPLER
, WINED3DSIH_DCL_SAMPLER
, "", "",
876 shader_sm4_read_dcl_sampler
},
877 {WINED3D_SM4_OP_DCL_OUTPUT_TOPOLOGY
, WINED3DSIH_DCL_OUTPUT_TOPOLOGY
, "", "",
878 shader_sm4_read_dcl_output_topology
},
879 {WINED3D_SM4_OP_DCL_INPUT_PRIMITIVE
, WINED3DSIH_DCL_INPUT_PRIMITIVE
, "", "",
880 shader_sm4_read_dcl_input_primitive
},
881 {WINED3D_SM4_OP_DCL_VERTICES_OUT
, WINED3DSIH_DCL_VERTICES_OUT
, "", "",
882 shader_sm4_read_declaration_count
},
883 {WINED3D_SM4_OP_DCL_INPUT
, WINED3DSIH_DCL_INPUT
, "", "",
884 shader_sm4_read_declaration_dst
},
885 {WINED3D_SM4_OP_DCL_INPUT_SGV
, WINED3DSIH_DCL_INPUT_SGV
, "", "",
886 shader_sm4_read_declaration_register_semantic
},
887 {WINED3D_SM4_OP_DCL_INPUT_SIV
, WINED3DSIH_DCL_INPUT_SIV
, "", "",
888 shader_sm4_read_declaration_register_semantic
},
889 {WINED3D_SM4_OP_DCL_INPUT_PS
, WINED3DSIH_DCL_INPUT_PS
, "", "",
890 shader_sm4_read_dcl_input_ps
},
891 {WINED3D_SM4_OP_DCL_INPUT_PS_SGV
, WINED3DSIH_DCL_INPUT_PS_SGV
, "", "",
892 shader_sm4_read_declaration_register_semantic
},
893 {WINED3D_SM4_OP_DCL_INPUT_PS_SIV
, WINED3DSIH_DCL_INPUT_PS_SIV
, "", "",
894 shader_sm4_read_dcl_input_ps_siv
},
895 {WINED3D_SM4_OP_DCL_OUTPUT
, WINED3DSIH_DCL_OUTPUT
, "", "",
896 shader_sm4_read_declaration_dst
},
897 {WINED3D_SM4_OP_DCL_OUTPUT_SIV
, WINED3DSIH_DCL_OUTPUT_SIV
, "", "",
898 shader_sm4_read_declaration_register_semantic
},
899 {WINED3D_SM4_OP_DCL_TEMPS
, WINED3DSIH_DCL_TEMPS
, "", "",
900 shader_sm4_read_declaration_count
},
901 {WINED3D_SM4_OP_DCL_INDEXABLE_TEMP
, WINED3DSIH_DCL_INDEXABLE_TEMP
, "", "",
902 shader_sm4_read_dcl_indexable_temp
},
903 {WINED3D_SM4_OP_DCL_GLOBAL_FLAGS
, WINED3DSIH_DCL_GLOBAL_FLAGS
, "", "",
904 shader_sm4_read_dcl_global_flags
},
905 {WINED3D_SM4_OP_LOD
, WINED3DSIH_LOD
, "f", "fRS"},
906 {WINED3D_SM4_OP_GATHER4
, WINED3DSIH_GATHER4
, "u", "fRS"},
907 {WINED3D_SM4_OP_SAMPLE_POS
, WINED3DSIH_SAMPLE_POS
, "f", "Ru"},
908 {WINED3D_SM4_OP_SAMPLE_INFO
, WINED3DSIH_SAMPLE_INFO
, "f", "R"},
909 {WINED3D_SM5_OP_HS_DECLS
, WINED3DSIH_HS_DECLS
, "", ""},
910 {WINED3D_SM5_OP_HS_CONTROL_POINT_PHASE
, WINED3DSIH_HS_CONTROL_POINT_PHASE
, "", ""},
911 {WINED3D_SM5_OP_HS_FORK_PHASE
, WINED3DSIH_HS_FORK_PHASE
, "", ""},
912 {WINED3D_SM5_OP_HS_JOIN_PHASE
, WINED3DSIH_HS_JOIN_PHASE
, "", ""},
913 {WINED3D_SM5_OP_EMIT_STREAM
, WINED3DSIH_EMIT_STREAM
, "", "f"},
914 {WINED3D_SM5_OP_CUT_STREAM
, WINED3DSIH_CUT_STREAM
, "", "f"},
915 {WINED3D_SM5_OP_FCALL
, WINED3DSIH_FCALL
, "", "O",
916 shader_sm5_read_fcall
},
917 {WINED3D_SM5_OP_BUFINFO
, WINED3DSIH_BUFINFO
, "i", "U"},
918 {WINED3D_SM5_OP_DERIV_RTX_COARSE
, WINED3DSIH_DSX_COARSE
, "f", "f"},
919 {WINED3D_SM5_OP_DERIV_RTX_FINE
, WINED3DSIH_DSX_FINE
, "f", "f"},
920 {WINED3D_SM5_OP_DERIV_RTY_COARSE
, WINED3DSIH_DSY_COARSE
, "f", "f"},
921 {WINED3D_SM5_OP_DERIV_RTY_FINE
, WINED3DSIH_DSY_FINE
, "f", "f"},
922 {WINED3D_SM5_OP_GATHER4_C
, WINED3DSIH_GATHER4_C
, "f", "fRSf"},
923 {WINED3D_SM5_OP_RCP
, WINED3DSIH_RCP
, "f", "f"},
924 {WINED3D_SM5_OP_UBFE
, WINED3DSIH_UBFE
, "u", "iiu"},
925 {WINED3D_SM5_OP_BFI
, WINED3DSIH_BFI
, "u", "iiuu"},
926 {WINED3D_SM5_OP_BFREV
, WINED3DSIH_BFREV
, "u", "u"},
927 {WINED3D_SM5_OP_SWAPC
, WINED3DSIH_SWAPC
, "ff", "uff"},
928 {WINED3D_SM5_OP_DCL_STREAM
, WINED3DSIH_DCL_STREAM
, "", "O"},
929 {WINED3D_SM5_OP_DCL_FUNCTION_BODY
, WINED3DSIH_DCL_FUNCTION_BODY
, "", "",
930 shader_sm5_read_dcl_function_body
},
931 {WINED3D_SM5_OP_DCL_FUNCTION_TABLE
, WINED3DSIH_DCL_FUNCTION_TABLE
, "", "",
932 shader_sm5_read_dcl_function_table
},
933 {WINED3D_SM5_OP_DCL_INTERFACE
, WINED3DSIH_DCL_INTERFACE
, "", "",
934 shader_sm5_read_dcl_interface
},
935 {WINED3D_SM5_OP_DCL_INPUT_CONTROL_POINT_COUNT
, WINED3DSIH_DCL_INPUT_CONTROL_POINT_COUNT
, "", "",
936 shader_sm5_read_control_point_count
},
937 {WINED3D_SM5_OP_DCL_OUTPUT_CONTROL_POINT_COUNT
, WINED3DSIH_DCL_OUTPUT_CONTROL_POINT_COUNT
, "", "",
938 shader_sm5_read_control_point_count
},
939 {WINED3D_SM5_OP_DCL_TESSELLATOR_DOMAIN
, WINED3DSIH_DCL_TESSELLATOR_DOMAIN
, "", "",
940 shader_sm5_read_dcl_tessellator_domain
},
941 {WINED3D_SM5_OP_DCL_TESSELLATOR_PARTITIONING
, WINED3DSIH_DCL_TESSELLATOR_PARTITIONING
, "", "",
942 shader_sm5_read_dcl_tessellator_partitioning
},
943 {WINED3D_SM5_OP_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
, WINED3DSIH_DCL_TESSELLATOR_OUTPUT_PRIMITIVE
, "", "",
944 shader_sm5_read_dcl_tessellator_output_primitive
},
945 {WINED3D_SM5_OP_DCL_HS_MAX_TESSFACTOR
, WINED3DSIH_DCL_HS_MAX_TESSFACTOR
, "", "",
946 shader_sm5_read_dcl_hs_max_tessfactor
},
947 {WINED3D_SM5_OP_DCL_HS_FORK_PHASE_INSTANCE_COUNT
, WINED3DSIH_DCL_HS_FORK_PHASE_INSTANCE_COUNT
, "", "",
948 shader_sm4_read_declaration_count
},
949 {WINED3D_SM5_OP_DCL_THREAD_GROUP
, WINED3DSIH_DCL_THREAD_GROUP
, "", "",
950 shader_sm5_read_dcl_thread_group
},
951 {WINED3D_SM5_OP_DCL_UAV_TYPED
, WINED3DSIH_DCL_UAV_TYPED
, "", "",
952 shader_sm4_read_dcl_resource
},
953 {WINED3D_SM5_OP_DCL_UAV_RAW
, WINED3DSIH_DCL_UAV_RAW
, "", "",
954 shader_sm5_read_dcl_uav_raw
},
955 {WINED3D_SM5_OP_DCL_UAV_STRUCTURED
, WINED3DSIH_DCL_UAV_STRUCTURED
, "", "",
956 shader_sm5_read_dcl_uav_structured
},
957 {WINED3D_SM5_OP_DCL_TGSM_RAW
, WINED3DSIH_DCL_TGSM_RAW
, "", "",
958 shader_sm5_read_dcl_tgsm_raw
},
959 {WINED3D_SM5_OP_DCL_TGSM_STRUCTURED
, WINED3DSIH_DCL_TGSM_STRUCTURED
, "", "",
960 shader_sm5_read_dcl_tgsm_structured
},
961 {WINED3D_SM5_OP_DCL_RESOURCE_STRUCTURED
, WINED3DSIH_DCL_RESOURCE_STRUCTURED
, "", "",
962 shader_sm5_read_dcl_resource_structured
},
963 {WINED3D_SM5_OP_LD_UAV_TYPED
, WINED3DSIH_LD_UAV_TYPED
, "u", "iU"},
964 {WINED3D_SM5_OP_STORE_UAV_TYPED
, WINED3DSIH_STORE_UAV_TYPED
, "U", "iu"},
965 {WINED3D_SM5_OP_LD_RAW
, WINED3DSIH_LD_RAW
, "u", "iU"},
966 {WINED3D_SM5_OP_STORE_RAW
, WINED3DSIH_STORE_RAW
, "U", "iu"},
967 {WINED3D_SM5_OP_LD_STRUCTURED
, WINED3DSIH_LD_STRUCTURED
, "u", "iiR"},
968 {WINED3D_SM5_OP_STORE_STRUCTURED
, WINED3DSIH_STORE_STRUCTURED
, "U", "iiu"},
969 {WINED3D_SM5_OP_ATOMIC_AND
, WINED3DSIH_ATOMIC_AND
, "U", "iu"},
970 {WINED3D_SM5_OP_ATOMIC_OR
, WINED3DSIH_ATOMIC_OR
, "U", "iu"},
971 {WINED3D_SM5_OP_ATOMIC_XOR
, WINED3DSIH_ATOMIC_XOR
, "U", "iu"},
972 {WINED3D_SM5_OP_ATOMIC_CMP_STORE
, WINED3DSIH_ATOMIC_CMP_STORE
, "U", "iuu"},
973 {WINED3D_SM5_OP_ATOMIC_IADD
, WINED3DSIH_ATOMIC_IADD
, "U", "ii"},
974 {WINED3D_SM5_OP_ATOMIC_IMAX
, WINED3DSIH_ATOMIC_IMAX
, "U", "ii"},
975 {WINED3D_SM5_OP_ATOMIC_UMAX
, WINED3DSIH_ATOMIC_UMAX
, "U", "iu"},
976 {WINED3D_SM5_OP_ATOMIC_UMIN
, WINED3DSIH_ATOMIC_UMIN
, "U", "iu"},
977 {WINED3D_SM5_OP_IMM_ATOMIC_ALLOC
, WINED3DSIH_IMM_ATOMIC_ALLOC
, "u", "U"},
978 {WINED3D_SM5_OP_IMM_ATOMIC_CONSUME
, WINED3DSIH_IMM_ATOMIC_CONSUME
, "u", "U"},
979 {WINED3D_SM5_OP_IMM_ATOMIC_AND
, WINED3DSIH_IMM_ATOMIC_AND
, "uU", "iu"},
980 {WINED3D_SM5_OP_IMM_ATOMIC_OR
, WINED3DSIH_IMM_ATOMIC_OR
, "uU", "iu"},
981 {WINED3D_SM5_OP_IMM_ATOMIC_XOR
, WINED3DSIH_IMM_ATOMIC_XOR
, "uU", "iu"},
982 {WINED3D_SM5_OP_IMM_ATOMIC_EXCH
, WINED3DSIH_IMM_ATOMIC_EXCH
, "uU", "iu"},
983 {WINED3D_SM5_OP_IMM_ATOMIC_CMP_EXCH
, WINED3DSIH_IMM_ATOMIC_CMP_EXCH
, "uU", "iuu"},
984 {WINED3D_SM5_OP_IMM_ATOMIC_UMAX
, WINED3DSIH_IMM_ATOMIC_UMAX
, "uU", "iu"},
985 {WINED3D_SM5_OP_IMM_ATOMIC_UMIN
, WINED3DSIH_IMM_ATOMIC_UMIN
, "uU", "iu"},
986 {WINED3D_SM5_OP_SYNC
, WINED3DSIH_SYNC
, "", "",
987 shader_sm5_read_sync
},
990 static const enum wined3d_shader_register_type register_type_table
[] =
992 /* WINED3D_SM4_RT_TEMP */ WINED3DSPR_TEMP
,
993 /* WINED3D_SM4_RT_INPUT */ WINED3DSPR_INPUT
,
994 /* WINED3D_SM4_RT_OUTPUT */ WINED3DSPR_OUTPUT
,
995 /* WINED3D_SM4_RT_INDEXABLE_TEMP */ WINED3DSPR_IDXTEMP
,
996 /* WINED3D_SM4_RT_IMMCONST */ WINED3DSPR_IMMCONST
,
998 /* WINED3D_SM4_RT_SAMPLER */ WINED3DSPR_SAMPLER
,
999 /* WINED3D_SM4_RT_RESOURCE */ WINED3DSPR_RESOURCE
,
1000 /* WINED3D_SM4_RT_CONSTBUFFER */ WINED3DSPR_CONSTBUFFER
,
1001 /* WINED3D_SM4_RT_IMMCONSTBUFFER */ WINED3DSPR_IMMCONSTBUFFER
,
1003 /* WINED3D_SM4_RT_PRIMID */ WINED3DSPR_PRIMID
,
1004 /* WINED3D_SM4_RT_DEPTHOUT */ WINED3DSPR_DEPTHOUT
,
1005 /* WINED3D_SM4_RT_NULL */ WINED3DSPR_NULL
,
1007 /* WINED3D_SM4_RT_OMASK */ WINED3DSPR_SAMPLEMASK
,
1008 /* WINED3D_SM5_RT_STREAM */ WINED3DSPR_STREAM
,
1009 /* WINED3D_SM5_RT_FUNCTION_BODY */ WINED3DSPR_FUNCTIONBODY
,
1011 /* WINED3D_SM5_RT_FUNCTION_POINTER */ WINED3DSPR_FUNCTIONPOINTER
,
1014 /* WINED3D_SM5_RT_OUTPUT_CONTROL_POINT_ID */ WINED3DSPR_OUTPOINTID
,
1015 /* WINED3D_SM5_RT_FORK_INSTANCE_ID */ WINED3DSPR_FORKINSTID
,
1017 /* WINED3D_SM5_RT_INPUT_CONTROL_POINT */ WINED3DSPR_INCONTROLPOINT
,
1018 /* WINED3D_SM5_RT_OUTPUT_CONTROL_POINT */ WINED3DSPR_OUTCONTROLPOINT
,
1019 /* WINED3D_SM5_RT_PATCH_CONSTANT_DATA */ WINED3DSPR_PATCHCONST
,
1020 /* WINED3D_SM5_RT_DOMAIN_LOCATION */ WINED3DSPR_TESSCOORD
,
1022 /* WINED3D_SM5_RT_UAV */ WINED3DSPR_UAV
,
1023 /* WINED3D_SM5_RT_SHARED_MEMORY */ WINED3DSPR_GROUPSHAREDMEM
,
1024 /* WINED3D_SM5_RT_THREAD_ID */ WINED3DSPR_THREADID
,
1025 /* WINED3D_SM5_RT_THREAD_GROUP_ID */ WINED3DSPR_THREADGROUPID
,
1026 /* WINED3D_SM5_RT_LOCAL_THREAD_ID */ WINED3DSPR_LOCALTHREADID
,
1027 /* WINED3D_SM5_RT_COVERAGE */ WINED3DSPR_COVERAGE
,
1028 /* WINED3D_SM5_RT_LOCAL_THREAD_INDEX */ WINED3DSPR_LOCALTHREADINDEX
,
1031 static const struct wined3d_sm4_opcode_info
*get_opcode_info(enum wined3d_sm4_opcode opcode
)
1035 for (i
= 0; i
< sizeof(opcode_table
) / sizeof(*opcode_table
); ++i
)
1037 if (opcode
== opcode_table
[i
].opcode
) return &opcode_table
[i
];
1043 static void map_register(const struct wined3d_sm4_data
*priv
, struct wined3d_shader_register
*reg
)
1045 switch (priv
->shader_version
.type
)
1047 case WINED3D_SHADER_TYPE_PIXEL
:
1048 if (reg
->type
== WINED3DSPR_OUTPUT
)
1050 unsigned int reg_idx
= reg
->idx
[0].offset
;
1052 if (reg_idx
>= ARRAY_SIZE(priv
->output_map
))
1054 ERR("Invalid output index %u.\n", reg_idx
);
1058 reg
->type
= WINED3DSPR_COLOROUT
;
1059 reg
->idx
[0].offset
= priv
->output_map
[reg_idx
];
1068 static enum wined3d_data_type
map_data_type(char t
)
1073 return WINED3D_DATA_FLOAT
;
1075 return WINED3D_DATA_INT
;
1077 return WINED3D_DATA_UINT
;
1079 return WINED3D_DATA_OPAQUE
;
1081 return WINED3D_DATA_RESOURCE
;
1083 return WINED3D_DATA_SAMPLER
;
1085 return WINED3D_DATA_UAV
;
1087 ERR("Invalid data type '%c'.\n", t
);
1088 return WINED3D_DATA_FLOAT
;
1092 static void *shader_sm4_init(const DWORD
*byte_code
, const struct wined3d_shader_signature
*output_signature
)
1094 struct wined3d_sm4_data
*priv
;
1097 if (!(priv
= HeapAlloc(GetProcessHeap(), 0, sizeof(*priv
))))
1099 ERR("Failed to allocate private data\n");
1103 memset(priv
->output_map
, 0xff, sizeof(priv
->output_map
));
1104 for (i
= 0; i
< output_signature
->element_count
; ++i
)
1106 struct wined3d_shader_signature_element
*e
= &output_signature
->elements
[i
];
1108 if (e
->register_idx
>= ARRAY_SIZE(priv
->output_map
))
1110 WARN("Invalid output index %u.\n", e
->register_idx
);
1114 priv
->output_map
[e
->register_idx
] = e
->semantic_idx
;
1117 list_init(&priv
->src_free
);
1118 list_init(&priv
->src
);
1123 static void shader_sm4_free(void *data
)
1125 struct wined3d_shader_src_param_entry
*e1
, *e2
;
1126 struct wined3d_sm4_data
*priv
= data
;
1128 list_move_head(&priv
->src_free
, &priv
->src
);
1129 LIST_FOR_EACH_ENTRY_SAFE(e1
, e2
, &priv
->src_free
, struct wined3d_shader_src_param_entry
, entry
)
1131 HeapFree(GetProcessHeap(), 0, e1
);
1133 HeapFree(GetProcessHeap(), 0, priv
);
1136 static struct wined3d_shader_src_param
*get_src_param(struct wined3d_sm4_data
*priv
)
1138 struct wined3d_shader_src_param_entry
*e
;
1141 if (!list_empty(&priv
->src_free
))
1143 elem
= list_head(&priv
->src_free
);
1148 if (!(e
= HeapAlloc(GetProcessHeap(), 0, sizeof(*e
))))
1153 list_add_tail(&priv
->src
, elem
);
1154 e
= LIST_ENTRY(elem
, struct wined3d_shader_src_param_entry
, entry
);
1158 static void shader_sm4_read_header(void *data
, const DWORD
**ptr
, struct wined3d_shader_version
*shader_version
)
1160 struct wined3d_sm4_data
*priv
= data
;
1161 DWORD version_token
;
1165 version_token
= *(*ptr
)++;
1166 TRACE("Version: 0x%08x.\n", version_token
);
1168 TRACE("Token count: %u.\n", **ptr
);
1169 priv
->end
+= *(*ptr
)++;
1171 switch (version_token
>> 16)
1173 case WINED3D_SM4_PS
:
1174 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_PIXEL
;
1177 case WINED3D_SM4_VS
:
1178 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_VERTEX
;
1181 case WINED3D_SM4_GS
:
1182 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_GEOMETRY
;
1185 case WINED3D_SM5_HS
:
1186 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_HULL
;
1189 case WINED3D_SM5_DS
:
1190 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_DOMAIN
;
1193 case WINED3D_SM5_CS
:
1194 priv
->shader_version
.type
= WINED3D_SHADER_TYPE_COMPUTE
;
1198 FIXME("Unrecognized shader type %#x.\n", version_token
>> 16);
1200 priv
->shader_version
.major
= WINED3D_SM4_VERSION_MAJOR(version_token
);
1201 priv
->shader_version
.minor
= WINED3D_SM4_VERSION_MINOR(version_token
);
1203 *shader_version
= priv
->shader_version
;
1206 static BOOL
shader_sm4_read_reg_idx(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
1207 DWORD addressing
, struct wined3d_shader_register_index
*reg_idx
)
1209 if (addressing
& WINED3D_SM4_ADDRESSING_RELATIVE
)
1211 struct wined3d_shader_src_param
*rel_addr
= get_src_param(priv
);
1213 if (!(reg_idx
->rel_addr
= rel_addr
))
1215 ERR("Failed to get src param for relative addressing.\n");
1219 if (addressing
& WINED3D_SM4_ADDRESSING_OFFSET
)
1220 reg_idx
->offset
= *(*ptr
)++;
1222 reg_idx
->offset
= 0;
1223 shader_sm4_read_src_param(priv
, ptr
, WINED3D_DATA_INT
, rel_addr
);
1227 reg_idx
->rel_addr
= NULL
;
1228 reg_idx
->offset
= *(*ptr
)++;
1234 static BOOL
shader_sm4_read_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
1235 enum wined3d_data_type data_type
, struct wined3d_shader_register
*param
,
1236 enum wined3d_shader_src_modifier
*modifier
)
1238 enum wined3d_sm4_register_type register_type
;
1239 DWORD token
= *(*ptr
)++;
1242 register_type
= (token
& WINED3D_SM4_REGISTER_TYPE_MASK
) >> WINED3D_SM4_REGISTER_TYPE_SHIFT
;
1243 if (register_type
>= sizeof(register_type_table
) / sizeof(*register_type_table
)
1244 || register_type_table
[register_type
] == ~0u)
1246 FIXME("Unhandled register type %#x.\n", register_type
);
1247 param
->type
= WINED3DSPR_TEMP
;
1251 param
->type
= register_type_table
[register_type
];
1253 param
->data_type
= data_type
;
1255 if (token
& WINED3D_SM4_REGISTER_MODIFIER
)
1257 DWORD m
= *(*ptr
)++;
1262 *modifier
= WINED3DSPSM_NEG
;
1266 *modifier
= WINED3DSPSM_ABS
;
1270 *modifier
= WINED3DSPSM_ABSNEG
;
1274 FIXME("Skipping modifier 0x%08x.\n", m
);
1275 *modifier
= WINED3DSPSM_NONE
;
1281 *modifier
= WINED3DSPSM_NONE
;
1284 order
= (token
& WINED3D_SM4_REGISTER_ORDER_MASK
) >> WINED3D_SM4_REGISTER_ORDER_SHIFT
;
1287 param
->idx
[0].offset
= ~0U;
1290 DWORD addressing
= (token
& WINED3D_SM4_ADDRESSING_MASK0
) >> WINED3D_SM4_ADDRESSING_SHIFT0
;
1291 if (!(shader_sm4_read_reg_idx(priv
, ptr
, addressing
, ¶m
->idx
[0])))
1293 ERR("Failed to read register index.\n");
1299 param
->idx
[1].offset
= ~0U;
1302 DWORD addressing
= (token
& WINED3D_SM4_ADDRESSING_MASK1
) >> WINED3D_SM4_ADDRESSING_SHIFT1
;
1303 if (!(shader_sm4_read_reg_idx(priv
, ptr
, addressing
, ¶m
->idx
[1])))
1305 ERR("Failed to read register index.\n");
1311 FIXME("Unhandled order %u.\n", order
);
1313 if (register_type
== WINED3D_SM4_RT_IMMCONST
)
1315 enum wined3d_sm4_immconst_type immconst_type
=
1316 (token
& WINED3D_SM4_IMMCONST_TYPE_MASK
) >> WINED3D_SM4_IMMCONST_TYPE_SHIFT
;
1318 switch (immconst_type
)
1320 case WINED3D_SM4_IMMCONST_SCALAR
:
1321 param
->immconst_type
= WINED3D_IMMCONST_SCALAR
;
1322 memcpy(param
->u
.immconst_data
, *ptr
, 1 * sizeof(DWORD
));
1326 case WINED3D_SM4_IMMCONST_VEC4
:
1327 param
->immconst_type
= WINED3D_IMMCONST_VEC4
;
1328 memcpy(param
->u
.immconst_data
, *ptr
, 4 * sizeof(DWORD
));
1333 FIXME("Unhandled immediate constant type %#x.\n", immconst_type
);
1338 map_register(priv
, param
);
1343 static BOOL
shader_sm4_read_src_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
1344 enum wined3d_data_type data_type
, struct wined3d_shader_src_param
*src_param
)
1346 DWORD token
= **ptr
;
1348 if (!shader_sm4_read_param(priv
, ptr
, data_type
, &src_param
->reg
, &src_param
->modifiers
))
1350 ERR("Failed to read parameter.\n");
1354 if (src_param
->reg
.type
== WINED3DSPR_IMMCONST
)
1356 src_param
->swizzle
= WINED3DSP_NOSWIZZLE
;
1360 enum wined3d_sm4_swizzle_type swizzle_type
=
1361 (token
& WINED3D_SM4_SWIZZLE_TYPE_MASK
) >> WINED3D_SM4_SWIZZLE_TYPE_SHIFT
;
1363 switch (swizzle_type
)
1365 case WINED3D_SM4_SWIZZLE_NONE
:
1366 src_param
->swizzle
= WINED3DSP_NOSWIZZLE
;
1369 case WINED3D_SM4_SWIZZLE_SCALAR
:
1370 src_param
->swizzle
= (token
& WINED3D_SM4_SWIZZLE_MASK
) >> WINED3D_SM4_SWIZZLE_SHIFT
;
1371 src_param
->swizzle
= (src_param
->swizzle
& 0x3) * 0x55;
1374 case WINED3D_SM4_SWIZZLE_VEC4
:
1375 src_param
->swizzle
= (token
& WINED3D_SM4_SWIZZLE_MASK
) >> WINED3D_SM4_SWIZZLE_SHIFT
;
1379 FIXME("Unhandled swizzle type %#x.\n", swizzle_type
);
1387 static BOOL
shader_sm4_read_dst_param(struct wined3d_sm4_data
*priv
, const DWORD
**ptr
,
1388 enum wined3d_data_type data_type
, struct wined3d_shader_dst_param
*dst_param
)
1390 enum wined3d_shader_src_modifier modifier
;
1391 DWORD token
= **ptr
;
1393 if (!shader_sm4_read_param(priv
, ptr
, data_type
, &dst_param
->reg
, &modifier
))
1395 ERR("Failed to read parameter.\n");
1399 if (modifier
!= WINED3DSPSM_NONE
)
1401 ERR("Invalid source modifier %#x on destination register.\n", modifier
);
1405 dst_param
->write_mask
= (token
& WINED3D_SM4_WRITEMASK_MASK
) >> WINED3D_SM4_WRITEMASK_SHIFT
;
1406 dst_param
->modifiers
= 0;
1407 dst_param
->shift
= 0;
1412 static void shader_sm4_read_instruction_modifier(DWORD modifier
, struct wined3d_shader_instruction
*ins
)
1414 static const DWORD recognized_bits
= WINED3D_SM4_INSTRUCTION_MODIFIER
1415 | WINED3D_SM4_MODIFIER_AOFFIMMI
1416 | WINED3D_SM4_AOFFIMMI_U_MASK
1417 | WINED3D_SM4_AOFFIMMI_V_MASK
1418 | WINED3D_SM4_AOFFIMMI_W_MASK
;
1420 if (modifier
& ~recognized_bits
)
1422 FIXME("Unhandled modifier 0x%08x.\n", modifier
);
1426 /* Bit fields are used for sign extension */
1434 aoffimmi
.u
= (modifier
& WINED3D_SM4_AOFFIMMI_U_MASK
) >> WINED3D_SM4_AOFFIMMI_U_SHIFT
;
1435 aoffimmi
.v
= (modifier
& WINED3D_SM4_AOFFIMMI_V_MASK
) >> WINED3D_SM4_AOFFIMMI_V_SHIFT
;
1436 aoffimmi
.w
= (modifier
& WINED3D_SM4_AOFFIMMI_W_MASK
) >> WINED3D_SM4_AOFFIMMI_W_SHIFT
;
1437 ins
->texel_offset
.u
= aoffimmi
.u
;
1438 ins
->texel_offset
.v
= aoffimmi
.v
;
1439 ins
->texel_offset
.w
= aoffimmi
.w
;
1443 static void shader_sm4_read_instruction(void *data
, const DWORD
**ptr
, struct wined3d_shader_instruction
*ins
)
1445 const struct wined3d_sm4_opcode_info
*opcode_info
;
1446 DWORD opcode_token
, opcode
, previous_token
;
1447 struct wined3d_sm4_data
*priv
= data
;
1448 unsigned int i
, len
;
1451 list_move_head(&priv
->src_free
, &priv
->src
);
1453 opcode_token
= *(*ptr
)++;
1454 opcode
= opcode_token
& WINED3D_SM4_OPCODE_MASK
;
1456 len
= ((opcode_token
& WINED3D_SM4_INSTRUCTION_LENGTH_MASK
) >> WINED3D_SM4_INSTRUCTION_LENGTH_SHIFT
);
1461 if (TRACE_ON(d3d_bytecode
))
1463 TRACE_(d3d_bytecode
)("[ %08x ", opcode_token
);
1464 for (i
= 0; i
< len
; ++i
)
1466 TRACE_(d3d_bytecode
)("%08x ", (*ptr
)[i
]);
1468 TRACE_(d3d_bytecode
)("]\n");
1471 if (!(opcode_info
= get_opcode_info(opcode
)))
1473 FIXME("Unrecognized opcode %#x, opcode_token 0x%08x.\n", opcode
, opcode_token
);
1474 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
1479 ins
->handler_idx
= opcode_info
->handler_idx
;
1482 ins
->predicate
= NULL
;
1483 ins
->dst_count
= strlen(opcode_info
->dst_info
);
1484 ins
->dst
= priv
->dst_param
;
1485 ins
->src_count
= strlen(opcode_info
->src_info
);
1486 ins
->src
= priv
->src_param
;
1487 memset(&ins
->texel_offset
, 0, sizeof(ins
->texel_offset
));
1492 previous_token
= opcode_token
;
1493 while (previous_token
& WINED3D_SM4_INSTRUCTION_MODIFIER
)
1494 shader_sm4_read_instruction_modifier(previous_token
= *p
++, ins
);
1496 if (opcode_info
->read_opcode_func
)
1498 opcode_info
->read_opcode_func(ins
, opcode
, opcode_token
, p
, len
, priv
);
1502 enum wined3d_shader_dst_modifier instruction_dst_modifier
= WINED3DSPDM_NONE
;
1504 ins
->flags
= (opcode_token
& WINED3D_SM4_INSTRUCTION_FLAGS_MASK
) >> WINED3D_SM4_INSTRUCTION_FLAGS_SHIFT
;
1506 if (ins
->flags
& WINED3D_SM4_INSTRUCTION_FLAG_SATURATE
)
1508 ins
->flags
&= ~WINED3D_SM4_INSTRUCTION_FLAG_SATURATE
;
1509 instruction_dst_modifier
= WINED3DSPDM_SATURATE
;
1512 for (i
= 0; i
< ins
->dst_count
; ++i
)
1514 if (!(shader_sm4_read_dst_param(priv
, &p
, map_data_type(opcode_info
->dst_info
[i
]), &priv
->dst_param
[i
])))
1516 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
1519 priv
->dst_param
[i
].modifiers
|= instruction_dst_modifier
;
1522 for (i
= 0; i
< ins
->src_count
; ++i
)
1524 if (!(shader_sm4_read_src_param(priv
, &p
, map_data_type(opcode_info
->src_info
[i
]), &priv
->src_param
[i
])))
1526 ins
->handler_idx
= WINED3DSIH_TABLE_SIZE
;
1533 static BOOL
shader_sm4_is_end(void *data
, const DWORD
**ptr
)
1535 struct wined3d_sm4_data
*priv
= data
;
1536 return *ptr
== priv
->end
;
1539 const struct wined3d_shader_frontend sm4_shader_frontend
=
1543 shader_sm4_read_header
,
1544 shader_sm4_read_instruction
,