mshtml: Added IDispatchEx support to HTMLDOMAttribute object.
[wine] / dlls / d3dcompiler_43 / d3dcompiler_private.h
1 /*
2  * Copyright 2008 Stefan Dösinger
3  * Copyright 2009 Matteo Bruni
4  * Copyright 2010 Rico Schüller
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #ifndef __WINE_D3DCOMPILER_PRIVATE_H
22 #define __WINE_D3DCOMPILER_PRIVATE_H
23
24 #include "wine/debug.h"
25 #include "wine/list.h"
26 #include "wine/rbtree.h"
27
28 #define COBJMACROS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "objbase.h"
32
33 #include "d3dcompiler.h"
34
35 /*
36  * This doesn't belong here, but for some functions it is possible to return that value,
37  * see http://msdn.microsoft.com/en-us/library/bb205278%28v=VS.85%29.aspx
38  * The original definition is in D3DX10core.h.
39  */
40 #define D3DERR_INVALIDCALL 0x8876086c
41
42 /* TRACE helper functions */
43 const char *debug_d3dcompiler_d3d_blob_part(D3D_BLOB_PART part) DECLSPEC_HIDDEN;
44
45 /* ID3DBlob */
46 struct d3dcompiler_blob
47 {
48     ID3DBlob ID3DBlob_iface;
49     LONG refcount;
50
51     SIZE_T size;
52     void *data;
53 };
54
55 HRESULT d3dcompiler_blob_init(struct d3dcompiler_blob *blob, SIZE_T data_size) DECLSPEC_HIDDEN;
56
57 /* blob handling */
58 HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN;
59 HRESULT d3dcompiler_strip_shader(const void *data, SIZE_T data_size, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN;
60
61 struct d3dcompiler_shader_signature
62 {
63     D3D11_SIGNATURE_PARAMETER_DESC *elements;
64     UINT element_count;
65     char *string_data;
66 };
67
68 struct d3dcompiler_shader_reflection_type
69 {
70     ID3D11ShaderReflectionType ID3D11ShaderReflectionType_iface;
71
72     DWORD id;
73     struct wine_rb_entry entry;
74
75     struct d3dcompiler_shader_reflection *reflection;
76
77     D3D11_SHADER_TYPE_DESC desc;
78 };
79
80 struct d3dcompiler_shader_reflection_variable
81 {
82     ID3D11ShaderReflectionVariable ID3D11ShaderReflectionVariable_iface;
83
84     struct d3dcompiler_shader_reflection_constant_buffer *constant_buffer;
85     struct d3dcompiler_shader_reflection_type *type;
86
87     char *name;
88     UINT start_offset;
89     UINT size;
90     UINT flags;
91     LPVOID default_value;
92 };
93
94 struct d3dcompiler_shader_reflection_constant_buffer
95 {
96     ID3D11ShaderReflectionConstantBuffer ID3D11ShaderReflectionConstantBuffer_iface;
97
98     struct d3dcompiler_shader_reflection *reflection;
99
100     char *name;
101     D3D_CBUFFER_TYPE type;
102     UINT variable_count;
103     UINT size;
104     UINT flags;
105
106     struct d3dcompiler_shader_reflection_variable *variables;
107 };
108
109 /* ID3D11ShaderReflection */
110 struct d3dcompiler_shader_reflection
111 {
112     ID3D11ShaderReflection ID3D11ShaderReflection_iface;
113     LONG refcount;
114
115     DWORD target;
116     char *creator;
117     UINT flags;
118     UINT version;
119     UINT bound_resource_count;
120     UINT constant_buffer_count;
121
122     UINT mov_instruction_count;
123     UINT conversion_instruction_count;
124     UINT instruction_count;
125     UINT emit_instruction_count;
126     D3D_PRIMITIVE_TOPOLOGY gs_output_topology;
127     UINT gs_max_output_vertex_count;
128     D3D_PRIMITIVE input_primitive;
129     UINT cut_instruction_count;
130     UINT dcl_count;
131     UINT static_flow_control_count;
132     UINT float_instruction_count;
133     UINT temp_register_count;
134     UINT int_instruction_count;
135     UINT uint_instruction_count;
136     UINT temp_array_count;
137     UINT array_instruction_count;
138     UINT texture_normal_instructions;
139     UINT texture_load_instructions;
140     UINT texture_comp_instructions;
141     UINT texture_bias_instructions;
142     UINT texture_gradient_instructions;
143     UINT dynamic_flow_control_count;
144     UINT c_control_points;
145     D3D_TESSELLATOR_OUTPUT_PRIMITIVE hs_output_primitive;
146     D3D_TESSELLATOR_PARTITIONING hs_prtitioning;
147     D3D_TESSELLATOR_DOMAIN tessellator_domain;
148
149     struct d3dcompiler_shader_signature *isgn;
150     struct d3dcompiler_shader_signature *osgn;
151     struct d3dcompiler_shader_signature *pcsg;
152     char *resource_string;
153     D3D11_SHADER_INPUT_BIND_DESC *bound_resources;
154     struct d3dcompiler_shader_reflection_constant_buffer *constant_buffers;
155     struct wine_rb_tree types;
156 };
157
158 /* reflection handling */
159 HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_reflection *reflection, const void *data, SIZE_T data_size) DECLSPEC_HIDDEN;
160
161 /* Shader assembler definitions */
162 typedef enum _shader_type {
163     ST_VERTEX,
164     ST_PIXEL,
165 } shader_type;
166
167 typedef enum BWRITER_COMPARISON_TYPE {
168     BWRITER_COMPARISON_NONE,
169     BWRITER_COMPARISON_GT,
170     BWRITER_COMPARISON_EQ,
171     BWRITER_COMPARISON_GE,
172     BWRITER_COMPARISON_LT,
173     BWRITER_COMPARISON_NE,
174     BWRITER_COMPARISON_LE
175 } BWRITER_COMPARISON_TYPE;
176
177 struct constant {
178     DWORD                   regnum;
179     union {
180         float               f;
181         INT                 i;
182         BOOL                b;
183         DWORD               d;
184     }                       value[4];
185 };
186
187 struct shader_reg {
188     DWORD                   type;
189     DWORD                   regnum;
190     struct shader_reg       *rel_reg;
191     DWORD                   srcmod;
192     union {
193         DWORD               swizzle;
194         DWORD               writemask;
195     } u;
196 };
197
198 struct instruction {
199     DWORD                   opcode;
200     DWORD                   dstmod;
201     DWORD                   shift;
202     BWRITER_COMPARISON_TYPE comptype;
203     BOOL                    has_dst;
204     struct shader_reg       dst;
205     struct shader_reg       *src;
206     unsigned int            num_srcs; /* For freeing the rel_regs */
207     BOOL                    has_predicate;
208     struct shader_reg       predicate;
209     BOOL                    coissue;
210 };
211
212 struct declaration {
213     DWORD                   usage, usage_idx;
214     DWORD                   regnum;
215     DWORD                   mod;
216     DWORD                   writemask;
217     BOOL                    builtin;
218 };
219
220 struct samplerdecl {
221     DWORD                   type;
222     DWORD                   regnum;
223     DWORD                   mod;
224 };
225
226 #define INSTRARRAY_INITIAL_SIZE 8
227 struct bwriter_shader {
228     shader_type             type;
229
230     /* Shader version selected */
231     DWORD                   version;
232
233     /* Local constants. Every constant that is not defined below is loaded from
234      * the global constant set at shader runtime
235      */
236     struct constant         **constF;
237     struct constant         **constI;
238     struct constant         **constB;
239     unsigned int            num_cf, num_ci, num_cb;
240
241     /* Declared input and output varyings */
242     struct declaration      *inputs, *outputs;
243     unsigned int            num_inputs, num_outputs;
244     struct samplerdecl      *samplers;
245     unsigned int            num_samplers;
246
247     /* Are special pixel shader 3.0 registers declared? */
248     BOOL                    vPos, vFace;
249
250     /* Array of shader instructions - The shader code itself */
251     struct instruction      **instr;
252     unsigned int            num_instrs, instr_alloc_size;
253 };
254
255 static inline LPVOID asm_alloc(SIZE_T size) {
256     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
257 }
258
259 static inline LPVOID asm_realloc(LPVOID ptr, SIZE_T size) {
260     return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
261 }
262
263 static inline BOOL asm_free(LPVOID ptr) {
264     return HeapFree(GetProcessHeap(), 0, ptr);
265 }
266
267 struct asm_parser;
268
269 /* This structure is only used in asmshader.y, but since the .l file accesses the semantic types
270  * too it has to know it as well
271  */
272 struct rel_reg {
273     BOOL            has_rel_reg;
274     DWORD           type;
275     DWORD           additional_offset;
276     DWORD           rel_regnum;
277     DWORD           swizzle;
278 };
279
280 #define MAX_SRC_REGS 4
281
282 struct src_regs {
283     struct shader_reg reg[MAX_SRC_REGS];
284     unsigned int      count;
285 };
286
287 struct asmparser_backend {
288     void (*constF)(struct asm_parser *This, DWORD reg, float x, float y, float z, float w);
289     void (*constI)(struct asm_parser *This, DWORD reg, INT x, INT y, INT z, INT w);
290     void (*constB)(struct asm_parser *This, DWORD reg, BOOL x);
291
292     void (*dstreg)(struct asm_parser *This, struct instruction *instr,
293                    const struct shader_reg *dst);
294     void (*srcreg)(struct asm_parser *This, struct instruction *instr, int num,
295                    const struct shader_reg *src);
296
297     void (*predicate)(struct asm_parser *This,
298                       const struct shader_reg *predicate);
299     void (*coissue)(struct asm_parser *This);
300
301     void (*dcl_output)(struct asm_parser *This, DWORD usage, DWORD num,
302                        const struct shader_reg *reg);
303     void (*dcl_input)(struct asm_parser *This, DWORD usage, DWORD num,
304                       DWORD mod, const struct shader_reg *reg);
305     void (*dcl_sampler)(struct asm_parser *This, DWORD samptype, DWORD mod,
306                         DWORD regnum, unsigned int line_no);
307
308     void (*end)(struct asm_parser *This);
309
310     void (*instr)(struct asm_parser *This, DWORD opcode, DWORD mod, DWORD shift,
311                   BWRITER_COMPARISON_TYPE comp, const struct shader_reg *dst,
312                   const struct src_regs *srcs, int expectednsrcs);
313 };
314
315 struct instruction *alloc_instr(unsigned int srcs) DECLSPEC_HIDDEN;
316 BOOL add_instruction(struct bwriter_shader *shader, struct instruction *instr) DECLSPEC_HIDDEN;
317 BOOL add_constF(struct bwriter_shader *shader, DWORD reg, float x, float y, float z, float w) DECLSPEC_HIDDEN;
318 BOOL add_constI(struct bwriter_shader *shader, DWORD reg, INT x, INT y, INT z, INT w) DECLSPEC_HIDDEN;
319 BOOL add_constB(struct bwriter_shader *shader, DWORD reg, BOOL x) DECLSPEC_HIDDEN;
320 BOOL record_declaration(struct bwriter_shader *shader, DWORD usage, DWORD usage_idx,
321         DWORD mod, BOOL output, DWORD regnum, DWORD writemask, BOOL builtin) DECLSPEC_HIDDEN;
322 BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD mod, DWORD regnum) DECLSPEC_HIDDEN;
323
324 #define MESSAGEBUFFER_INITIAL_SIZE 256
325
326 struct asm_parser {
327     /* The function table of the parser implementation */
328     const struct asmparser_backend *funcs;
329
330     /* Private data follows */
331     struct bwriter_shader *shader;
332     unsigned int m3x3pad_count;
333
334     enum parse_status {
335         PARSE_SUCCESS = 0,
336         PARSE_WARN = 1,
337         PARSE_ERR = 2
338     } status;
339     char *messages;
340     unsigned int messagesize;
341     unsigned int messagecapacity;
342     unsigned int line_no;
343 };
344
345 extern struct asm_parser asm_ctx DECLSPEC_HIDDEN;
346
347 void create_vs10_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
348 void create_vs11_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
349 void create_vs20_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
350 void create_vs2x_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
351 void create_vs30_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
352 void create_ps10_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
353 void create_ps11_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
354 void create_ps12_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
355 void create_ps13_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
356 void create_ps14_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
357 void create_ps20_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
358 void create_ps2x_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
359 void create_ps30_parser(struct asm_parser *ret) DECLSPEC_HIDDEN;
360
361 struct bwriter_shader *parse_asm_shader(char **messages) DECLSPEC_HIDDEN;
362
363 #ifdef __GNUC__
364 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
365 #else
366 #define PRINTF_ATTR(fmt,args)
367 #endif
368
369 void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
370 void set_parse_status(struct asm_parser *ctx, enum parse_status status) DECLSPEC_HIDDEN;
371
372 /* A reasonable value as initial size */
373 #define BYTECODEBUFFER_INITIAL_SIZE 32
374 struct bytecode_buffer {
375     DWORD *data;
376     DWORD size;
377     DWORD alloc_size;
378     /* For tracking rare out of memory situations without passing
379      * return values around everywhere
380      */
381     HRESULT state;
382 };
383
384 struct bc_writer; /* Predeclaration for use in vtable parameters */
385
386 typedef void (*instr_writer)(struct bc_writer *This,
387                              const struct instruction *instr,
388                              struct bytecode_buffer *buffer);
389
390 struct bytecode_backend {
391     void (*header)(struct bc_writer *This, const struct bwriter_shader *shader,
392                    struct bytecode_buffer *buffer);
393     void (*end)(struct bc_writer *This, const struct bwriter_shader *shader,
394                 struct bytecode_buffer *buffer);
395     void (*srcreg)(struct bc_writer *This, const struct shader_reg *reg,
396                    struct bytecode_buffer *buffer);
397     void (*dstreg)(struct bc_writer *This, const struct shader_reg *reg,
398                    struct bytecode_buffer *buffer, DWORD shift, DWORD mod);
399     void (*opcode)(struct bc_writer *This, const struct instruction *instr,
400                    DWORD token, struct bytecode_buffer *buffer);
401
402     const struct instr_handler_table {
403         DWORD opcode;
404         instr_writer func;
405     } *instructions;
406 };
407
408 /* Bytecode writing stuff */
409 struct bc_writer {
410     const struct bytecode_backend *funcs;
411
412     /* Avoid result checking */
413     HRESULT                       state;
414
415     DWORD                         version;
416
417     /* Vertex shader varying mapping */
418     DWORD                         oPos_regnum;
419     DWORD                         oD_regnum[2];
420     DWORD                         oT_regnum[8];
421     DWORD                         oFog_regnum;
422     DWORD                         oFog_mask;
423     DWORD                         oPts_regnum;
424     DWORD                         oPts_mask;
425
426     /* Pixel shader specific members */
427     DWORD                         t_regnum[8];
428     DWORD                         v_regnum[2];
429 };
430
431 /* Debug utility routines */
432 const char *debug_print_srcmod(DWORD mod) DECLSPEC_HIDDEN;
433 const char *debug_print_dstmod(DWORD mod) DECLSPEC_HIDDEN;
434 const char *debug_print_shift(DWORD shift) DECLSPEC_HIDDEN;
435 const char *debug_print_dstreg(const struct shader_reg *reg) DECLSPEC_HIDDEN;
436 const char *debug_print_srcreg(const struct shader_reg *reg) DECLSPEC_HIDDEN;
437 const char *debug_print_comp(DWORD comp) DECLSPEC_HIDDEN;
438 const char *debug_print_opcode(DWORD opcode) DECLSPEC_HIDDEN;
439
440 /* Used to signal an incorrect swizzle/writemask */
441 #define SWIZZLE_ERR ~0U
442
443 /*
444   Enumerations and defines used in the bytecode writer
445   intermediate representation
446 */
447 typedef enum _BWRITERSHADER_INSTRUCTION_OPCODE_TYPE {
448     BWRITERSIO_NOP,
449     BWRITERSIO_MOV,
450     BWRITERSIO_ADD,
451     BWRITERSIO_SUB,
452     BWRITERSIO_MAD,
453     BWRITERSIO_MUL,
454     BWRITERSIO_RCP,
455     BWRITERSIO_RSQ,
456     BWRITERSIO_DP3,
457     BWRITERSIO_DP4,
458     BWRITERSIO_MIN,
459     BWRITERSIO_MAX,
460     BWRITERSIO_SLT,
461     BWRITERSIO_SGE,
462     BWRITERSIO_EXP,
463     BWRITERSIO_LOG,
464     BWRITERSIO_LIT,
465     BWRITERSIO_DST,
466     BWRITERSIO_LRP,
467     BWRITERSIO_FRC,
468     BWRITERSIO_M4x4,
469     BWRITERSIO_M4x3,
470     BWRITERSIO_M3x4,
471     BWRITERSIO_M3x3,
472     BWRITERSIO_M3x2,
473     BWRITERSIO_CALL,
474     BWRITERSIO_CALLNZ,
475     BWRITERSIO_LOOP,
476     BWRITERSIO_RET,
477     BWRITERSIO_ENDLOOP,
478     BWRITERSIO_LABEL,
479     BWRITERSIO_DCL,
480     BWRITERSIO_POW,
481     BWRITERSIO_CRS,
482     BWRITERSIO_SGN,
483     BWRITERSIO_ABS,
484     BWRITERSIO_NRM,
485     BWRITERSIO_SINCOS,
486     BWRITERSIO_REP,
487     BWRITERSIO_ENDREP,
488     BWRITERSIO_IF,
489     BWRITERSIO_IFC,
490     BWRITERSIO_ELSE,
491     BWRITERSIO_ENDIF,
492     BWRITERSIO_BREAK,
493     BWRITERSIO_BREAKC,
494     BWRITERSIO_MOVA,
495     BWRITERSIO_DEFB,
496     BWRITERSIO_DEFI,
497
498     BWRITERSIO_TEXCOORD,
499     BWRITERSIO_TEXKILL,
500     BWRITERSIO_TEX,
501     BWRITERSIO_TEXBEM,
502     BWRITERSIO_TEXBEML,
503     BWRITERSIO_TEXREG2AR,
504     BWRITERSIO_TEXREG2GB,
505     BWRITERSIO_TEXM3x2PAD,
506     BWRITERSIO_TEXM3x2TEX,
507     BWRITERSIO_TEXM3x3PAD,
508     BWRITERSIO_TEXM3x3TEX,
509     BWRITERSIO_TEXM3x3SPEC,
510     BWRITERSIO_TEXM3x3VSPEC,
511     BWRITERSIO_EXPP,
512     BWRITERSIO_LOGP,
513     BWRITERSIO_CND,
514     BWRITERSIO_DEF,
515     BWRITERSIO_TEXREG2RGB,
516     BWRITERSIO_TEXDP3TEX,
517     BWRITERSIO_TEXM3x2DEPTH,
518     BWRITERSIO_TEXDP3,
519     BWRITERSIO_TEXM3x3,
520     BWRITERSIO_TEXDEPTH,
521     BWRITERSIO_CMP,
522     BWRITERSIO_BEM,
523     BWRITERSIO_DP2ADD,
524     BWRITERSIO_DSX,
525     BWRITERSIO_DSY,
526     BWRITERSIO_TEXLDD,
527     BWRITERSIO_SETP,
528     BWRITERSIO_TEXLDL,
529     BWRITERSIO_BREAKP,
530     BWRITERSIO_TEXLDP,
531     BWRITERSIO_TEXLDB,
532
533     BWRITERSIO_PHASE,
534     BWRITERSIO_COMMENT,
535     BWRITERSIO_END,
536 } BWRITERSHADER_INSTRUCTION_OPCODE_TYPE;
537
538 typedef enum _BWRITERSHADER_PARAM_REGISTER_TYPE {
539     BWRITERSPR_TEMP,
540     BWRITERSPR_INPUT,
541     BWRITERSPR_CONST,
542     BWRITERSPR_ADDR,
543     BWRITERSPR_TEXTURE,
544     BWRITERSPR_RASTOUT,
545     BWRITERSPR_ATTROUT,
546     BWRITERSPR_TEXCRDOUT,
547     BWRITERSPR_OUTPUT,
548     BWRITERSPR_CONSTINT,
549     BWRITERSPR_COLOROUT,
550     BWRITERSPR_DEPTHOUT,
551     BWRITERSPR_SAMPLER,
552     BWRITERSPR_CONSTBOOL,
553     BWRITERSPR_LOOP,
554     BWRITERSPR_MISCTYPE,
555     BWRITERSPR_LABEL,
556     BWRITERSPR_PREDICATE
557 } BWRITERSHADER_PARAM_REGISTER_TYPE;
558
559 typedef enum _BWRITERVS_RASTOUT_OFFSETS
560 {
561     BWRITERSRO_POSITION,
562     BWRITERSRO_FOG,
563     BWRITERSRO_POINT_SIZE
564 } BWRITERVS_RASTOUT_OFFSETS;
565
566 #define BWRITERSP_WRITEMASK_0   0x1 /* .x r */
567 #define BWRITERSP_WRITEMASK_1   0x2 /* .y g */
568 #define BWRITERSP_WRITEMASK_2   0x4 /* .z b */
569 #define BWRITERSP_WRITEMASK_3   0x8 /* .w a */
570 #define BWRITERSP_WRITEMASK_ALL 0xf /* all */
571
572 typedef enum _BWRITERSHADER_PARAM_DSTMOD_TYPE {
573     BWRITERSPDM_NONE = 0,
574     BWRITERSPDM_SATURATE = 1,
575     BWRITERSPDM_PARTIALPRECISION = 2,
576     BWRITERSPDM_MSAMPCENTROID = 4,
577 } BWRITERSHADER_PARAM_DSTMOD_TYPE;
578
579 typedef enum _BWRITERSAMPLER_TEXTURE_TYPE {
580     BWRITERSTT_UNKNOWN = 0,
581     BWRITERSTT_1D = 1,
582     BWRITERSTT_2D = 2,
583     BWRITERSTT_CUBE = 3,
584     BWRITERSTT_VOLUME = 4,
585 } BWRITERSAMPLER_TEXTURE_TYPE;
586
587 #define BWRITERSI_TEXLD_PROJECT 1
588 #define BWRITERSI_TEXLD_BIAS    2
589
590 typedef enum _BWRITERSHADER_PARAM_SRCMOD_TYPE {
591     BWRITERSPSM_NONE = 0,
592     BWRITERSPSM_NEG,
593     BWRITERSPSM_BIAS,
594     BWRITERSPSM_BIASNEG,
595     BWRITERSPSM_SIGN,
596     BWRITERSPSM_SIGNNEG,
597     BWRITERSPSM_COMP,
598     BWRITERSPSM_X2,
599     BWRITERSPSM_X2NEG,
600     BWRITERSPSM_DZ,
601     BWRITERSPSM_DW,
602     BWRITERSPSM_ABS,
603     BWRITERSPSM_ABSNEG,
604     BWRITERSPSM_NOT,
605 } BWRITERSHADER_PARAM_SRCMOD_TYPE;
606
607 #define BWRITER_SM1_VS  0xfffe
608 #define BWRITER_SM1_PS  0xffff
609
610 #define BWRITERPS_VERSION(major, minor) ((BWRITER_SM1_PS << 16) | ((major) << 8) | (minor))
611 #define BWRITERVS_VERSION(major, minor) ((BWRITER_SM1_VS << 16) | ((major) << 8) | (minor))
612
613 #define BWRITERVS_SWIZZLE_SHIFT      16
614 #define BWRITERVS_SWIZZLE_MASK       (0xFF << BWRITERVS_SWIZZLE_SHIFT)
615
616 #define BWRITERVS_X_X       (0 << BWRITERVS_SWIZZLE_SHIFT)
617 #define BWRITERVS_X_Y       (1 << BWRITERVS_SWIZZLE_SHIFT)
618 #define BWRITERVS_X_Z       (2 << BWRITERVS_SWIZZLE_SHIFT)
619 #define BWRITERVS_X_W       (3 << BWRITERVS_SWIZZLE_SHIFT)
620
621 #define BWRITERVS_Y_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 2))
622 #define BWRITERVS_Y_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 2))
623 #define BWRITERVS_Y_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 2))
624 #define BWRITERVS_Y_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 2))
625
626 #define BWRITERVS_Z_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 4))
627 #define BWRITERVS_Z_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 4))
628 #define BWRITERVS_Z_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 4))
629 #define BWRITERVS_Z_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 4))
630
631 #define BWRITERVS_W_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 6))
632 #define BWRITERVS_W_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 6))
633 #define BWRITERVS_W_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 6))
634 #define BWRITERVS_W_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 6))
635
636 #define BWRITERVS_NOSWIZZLE (BWRITERVS_X_X | BWRITERVS_Y_Y | BWRITERVS_Z_Z | BWRITERVS_W_W)
637
638 #define BWRITERVS_SWIZZLE_X (BWRITERVS_X_X | BWRITERVS_Y_X | BWRITERVS_Z_X | BWRITERVS_W_X)
639 #define BWRITERVS_SWIZZLE_Y (BWRITERVS_X_Y | BWRITERVS_Y_Y | BWRITERVS_Z_Y | BWRITERVS_W_Y)
640 #define BWRITERVS_SWIZZLE_Z (BWRITERVS_X_Z | BWRITERVS_Y_Z | BWRITERVS_Z_Z | BWRITERVS_W_Z)
641 #define BWRITERVS_SWIZZLE_W (BWRITERVS_X_W | BWRITERVS_Y_W | BWRITERVS_Z_W | BWRITERVS_W_W)
642
643 typedef enum _BWRITERDECLUSAGE {
644     BWRITERDECLUSAGE_POSITION,
645     BWRITERDECLUSAGE_BLENDWEIGHT,
646     BWRITERDECLUSAGE_BLENDINDICES,
647     BWRITERDECLUSAGE_NORMAL,
648     BWRITERDECLUSAGE_PSIZE,
649     BWRITERDECLUSAGE_TEXCOORD,
650     BWRITERDECLUSAGE_TANGENT,
651     BWRITERDECLUSAGE_BINORMAL,
652     BWRITERDECLUSAGE_TESSFACTOR,
653     BWRITERDECLUSAGE_POSITIONT,
654     BWRITERDECLUSAGE_COLOR,
655     BWRITERDECLUSAGE_FOG,
656     BWRITERDECLUSAGE_DEPTH,
657     BWRITERDECLUSAGE_SAMPLE
658 } BWRITERDECLUSAGE;
659
660 /* ps 1.x texture registers mappings */
661 #define T0_REG          2
662 #define T1_REG          3
663 #define T2_REG          4
664 #define T3_REG          5
665
666 struct bwriter_shader *SlAssembleShader(const char *text, char **messages) DECLSPEC_HIDDEN;
667 DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result) DECLSPEC_HIDDEN;
668 void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
669
670 #define MAKE_TAG(ch0, ch1, ch2, ch3) \
671     ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \
672     ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 ))
673 #define TAG_Aon9 MAKE_TAG('A', 'o', 'n', '9')
674 #define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C')
675 #define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N')
676 #define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N')
677 #define TAG_OSG5 MAKE_TAG('O', 'S', 'G', '5')
678 #define TAG_PCSG MAKE_TAG('P', 'C', 'S', 'G')
679 #define TAG_RDEF MAKE_TAG('R', 'D', 'E', 'F')
680 #define TAG_SDBG MAKE_TAG('S', 'D', 'B', 'G')
681 #define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R')
682 #define TAG_SHEX MAKE_TAG('S', 'H', 'E', 'X')
683 #define TAG_STAT MAKE_TAG('S', 'T', 'A', 'T')
684 #define TAG_XNAP MAKE_TAG('X', 'N', 'A', 'P')
685 #define TAG_XNAS MAKE_TAG('X', 'N', 'A', 'S')
686
687 struct dxbc_section
688 {
689     DWORD tag;
690     const char *data;
691     DWORD data_size;
692 };
693
694 struct dxbc
695 {
696     UINT size;
697     UINT count;
698     struct dxbc_section *sections;
699 };
700
701 HRESULT dxbc_write_blob(struct dxbc *dxbc, ID3DBlob **blob) DECLSPEC_HIDDEN;
702 void dxbc_destroy(struct dxbc *dxbc) DECLSPEC_HIDDEN;
703 HRESULT dxbc_parse(const char *data, SIZE_T data_size, struct dxbc *dxbc) DECLSPEC_HIDDEN;
704 HRESULT dxbc_add_section(struct dxbc *dxbc, DWORD tag, const char *data, DWORD data_size) DECLSPEC_HIDDEN;
705 HRESULT dxbc_init(struct dxbc *dxbc, DWORD count) DECLSPEC_HIDDEN;
706
707 static inline void read_dword(const char **ptr, DWORD *d)
708 {
709     memcpy(d, *ptr, sizeof(*d));
710     *ptr += sizeof(*d);
711 }
712
713 static inline void write_dword(char **ptr, DWORD d)
714 {
715     memcpy(*ptr, &d, sizeof(d));
716     *ptr += sizeof(d);
717 }
718
719 void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN;
720 void write_dword_unknown(char **ptr, DWORD d) DECLSPEC_HIDDEN;
721
722 #endif /* __WINE_D3DCOMPILER_PRIVATE_H */