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