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