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