d3dx9: Implement D3DXCheckTextureRequirements.
[wine] / dlls / d3dx9_36 / d3dx9_36_private.h
1 /*
2  * Copyright (C) 2002 Raphael Junqueira
3  * Copyright (C) 2008 David Adam
4  * Copyright (C) 2008 Tony Wasserka
5  * Copyright (C) 2008 Stefan Dösinger
6  * Copyright (C) 2009 Matteo Bruni
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21  *
22  */
23
24 #ifndef __WINE_D3DX9_36_PRIVATE_H
25 #define __WINE_D3DX9_36_PRIVATE_H
26
27 #include <stdarg.h>
28
29 #define COBJMACROS
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "d3dx9.h"
34
35 /* for internal use */
36 typedef enum _FormatType {
37     FORMAT_ARGB,   /* unsigned */
38     FORMAT_UNKNOWN
39 } FormatType;
40
41 typedef struct _PixelFormatDesc {
42     D3DFORMAT format;
43     BYTE bits[4];
44     BYTE shift[4];
45     UINT bytes_per_pixel;
46     FormatType type;
47 } PixelFormatDesc;
48
49 HRESULT map_view_of_file(LPCWSTR filename, LPVOID *buffer, DWORD *length);
50 HRESULT load_resource_into_memory(HMODULE module, HRSRC resinfo, LPVOID *buffer, DWORD *length);
51
52 const PixelFormatDesc *get_format_info(D3DFORMAT format);
53
54
55 extern const ID3DXBufferVtbl D3DXBuffer_Vtbl;
56
57 /* ID3DXBUFFER */
58 typedef struct ID3DXBufferImpl
59 {
60     /* IUnknown fields */
61     const ID3DXBufferVtbl *lpVtbl;
62     LONG           ref;
63
64     /* ID3DXBuffer fields */
65     DWORD         *buffer;
66     DWORD          bufferSize;
67 } ID3DXBufferImpl;
68
69
70 /* ID3DXFont */
71 typedef struct ID3DXFontImpl
72 {
73     /* IUnknown fields */
74     const ID3DXFontVtbl *lpVtbl;
75     LONG ref;
76
77     /* ID3DXFont fields */
78     IDirect3DDevice9 *device;
79     D3DXFONT_DESCW desc;
80
81     HDC hdc;
82     HFONT hfont;
83 } ID3DXFontImpl;
84
85 /* ID3DXMatrixStack */
86 typedef struct ID3DXMatrixStackImpl
87 {
88   /* IUnknown fields */
89   const ID3DXMatrixStackVtbl *lpVtbl;
90   LONG                   ref;
91
92   /* ID3DXMatrixStack fields */
93   unsigned int current;
94   unsigned int stack_size;
95   D3DXMATRIX *stack;
96 } ID3DXMatrixStackImpl;
97
98 /*ID3DXSprite */
99 typedef struct _SPRITE {
100     LPDIRECT3DTEXTURE9 texture;
101     UINT texw, texh;
102     RECT rect;
103     D3DXVECTOR3 center;
104     D3DXVECTOR3 pos;
105     D3DCOLOR color;
106 } SPRITE;
107
108 typedef struct ID3DXSpriteImpl
109 {
110     /* IUnknown fields */
111     const ID3DXSpriteVtbl *lpVtbl;
112     LONG ref;
113
114     /* ID3DXSprite fields */
115     IDirect3DDevice9 *device;
116     IDirect3DVertexDeclaration9 *vdecl;
117     IDirect3DStateBlock9 *stateblock;
118     D3DXMATRIX transform;
119     D3DXMATRIX view;
120     DWORD flags;
121     BOOL ready;
122
123     /* Store the relevant caps to prevent multiple GetDeviceCaps calls */
124     DWORD texfilter_caps;
125     DWORD maxanisotropy;
126     DWORD alphacmp_caps;
127
128     SPRITE *sprites;
129     int sprite_count;      /* number of sprites to be drawn */
130     int allocated_sprites; /* number of (pre-)allocated sprites */
131 } ID3DXSpriteImpl;
132
133 /* Shader assembler definitions */
134 typedef enum _shader_type {
135     ST_VERTEX,
136     ST_PIXEL,
137 } shader_type;
138
139 typedef enum BWRITER_COMPARISON_TYPE {
140     BWRITER_COMPARISON_NONE,
141     BWRITER_COMPARISON_GT,
142     BWRITER_COMPARISON_EQ,
143     BWRITER_COMPARISON_GE,
144     BWRITER_COMPARISON_LT,
145     BWRITER_COMPARISON_NE,
146     BWRITER_COMPARISON_LE
147 } BWRITER_COMPARISON_TYPE;
148
149 struct constant {
150     DWORD                   regnum;
151     union {
152         float               f;
153         INT                 i;
154         BOOL                b;
155         DWORD               d;
156     }                       value[4];
157 };
158
159 struct shader_reg {
160     DWORD                   type;
161     DWORD                   regnum;
162     struct shader_reg       *rel_reg;
163     DWORD                   srcmod;
164     union {
165         DWORD               swizzle;
166         DWORD               writemask;
167     };
168 };
169
170 struct instruction {
171     DWORD                   opcode;
172     DWORD                   dstmod;
173     DWORD                   shift;
174     BWRITER_COMPARISON_TYPE comptype;
175     BOOL                    has_dst;
176     struct shader_reg       dst;
177     struct shader_reg       *src;
178     unsigned int            num_srcs; /* For freeing the rel_regs */
179     BOOL                    has_predicate;
180     struct shader_reg       predicate;
181     BOOL                    coissue;
182 };
183
184 struct declaration {
185     DWORD                   usage, usage_idx;
186     DWORD                   regnum;
187     DWORD                   mod;
188     DWORD                   writemask;
189     BOOL                    builtin;
190 };
191
192 struct samplerdecl {
193     DWORD                   type;
194     DWORD                   regnum;
195     DWORD                   mod;
196 };
197
198 #define INSTRARRAY_INITIAL_SIZE 8
199 struct bwriter_shader {
200     shader_type             type;
201
202     /* Shader version selected */
203     DWORD                   version;
204
205     /* Local constants. Every constant that is not defined below is loaded from
206      * the global constant set at shader runtime
207      */
208     struct constant         **constF;
209     struct constant         **constI;
210     struct constant         **constB;
211     unsigned int            num_cf, num_ci, num_cb;
212
213     /* Declared input and output varyings */
214     struct declaration      *inputs, *outputs;
215     unsigned int            num_inputs, num_outputs;
216     struct samplerdecl      *samplers;
217     unsigned int            num_samplers;
218
219     /* Are special pixel shader 3.0 registers declared? */
220     BOOL                    vPos, vFace;
221
222     /* Array of shader instructions - The shader code itself */
223     struct instruction      **instr;
224     unsigned int            num_instrs, instr_alloc_size;
225 };
226
227 static inline LPVOID asm_alloc(SIZE_T size) {
228     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
229 }
230
231 static inline LPVOID asm_realloc(LPVOID ptr, SIZE_T size) {
232     return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
233 }
234
235 static inline BOOL asm_free(LPVOID ptr) {
236     return HeapFree(GetProcessHeap(), 0, ptr);
237 }
238
239 struct asm_parser;
240
241 /* This structure is only used in asmshader.y, but since the .l file accesses the semantic types
242  * too it has to know it as well
243  */
244 struct rel_reg {
245     BOOL            has_rel_reg;
246     DWORD           type;
247     DWORD           additional_offset;
248     DWORD           rel_regnum;
249     DWORD           swizzle;
250 };
251
252 #define MAX_SRC_REGS 4
253
254 struct src_regs {
255     struct shader_reg reg[MAX_SRC_REGS];
256     unsigned int      count;
257 };
258
259 struct asmparser_backend {
260     void (*constF)(struct asm_parser *This, DWORD reg, float x, float y, float z, float w);
261     void (*constI)(struct asm_parser *This, DWORD reg, INT x, INT y, INT z, INT w);
262     void (*constB)(struct asm_parser *This, DWORD reg, BOOL x);
263
264     void (*dstreg)(struct asm_parser *This, struct instruction *instr,
265                    const struct shader_reg *dst);
266     void (*srcreg)(struct asm_parser *This, struct instruction *instr, int num,
267                    const struct shader_reg *src);
268
269     void (*predicate)(struct asm_parser *This,
270                       const struct shader_reg *predicate);
271     void (*coissue)(struct asm_parser *This);
272
273     void (*dcl_output)(struct asm_parser *This, DWORD usage, DWORD num,
274                        const struct shader_reg *reg);
275     void (*dcl_input)(struct asm_parser *This, DWORD usage, DWORD num,
276                       DWORD mod, const struct shader_reg *reg);
277     void (*dcl_sampler)(struct asm_parser *This, DWORD samptype, DWORD mod,
278                         DWORD regnum, unsigned int line_no);
279
280     void (*end)(struct asm_parser *This);
281
282     void (*instr)(struct asm_parser *This, DWORD opcode, DWORD mod, DWORD shift,
283                   BWRITER_COMPARISON_TYPE comp, const struct shader_reg *dst,
284                   const struct src_regs *srcs, int expectednsrcs);
285 };
286
287 struct instruction *alloc_instr(unsigned int srcs);
288 BOOL add_instruction(struct bwriter_shader *shader, struct instruction *instr);
289 BOOL add_constF(struct bwriter_shader *shader, DWORD reg, float x, float y, float z, float w);
290 BOOL add_constI(struct bwriter_shader *shader, DWORD reg, INT x, INT y, INT z, INT w);
291 BOOL add_constB(struct bwriter_shader *shader, DWORD reg, BOOL x);
292 BOOL record_declaration(struct bwriter_shader *shader, DWORD usage,
293                         DWORD usage_idx, DWORD mod, BOOL output,
294                         DWORD regnum, DWORD writemask, BOOL builtin);
295 BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype,
296                     DWORD mod, DWORD regnum);
297
298 #define MESSAGEBUFFER_INITIAL_SIZE 256
299
300 struct asm_parser {
301     /* The function table of the parser implementation */
302     const struct asmparser_backend *funcs;
303
304     /* Private data follows */
305     struct bwriter_shader *shader;
306     unsigned int m3x3pad_count;
307
308     enum parse_status {
309         PARSE_SUCCESS = 0,
310         PARSE_WARN = 1,
311         PARSE_ERR = 2
312     } status;
313     char *messages;
314     unsigned int messagesize;
315     unsigned int messagecapacity;
316     unsigned int line_no;
317 };
318
319 extern struct asm_parser asm_ctx;
320
321 void create_vs10_parser(struct asm_parser *ret);
322 void create_vs11_parser(struct asm_parser *ret);
323 void create_vs20_parser(struct asm_parser *ret);
324 void create_vs2x_parser(struct asm_parser *ret);
325 void create_vs30_parser(struct asm_parser *ret);
326 void create_ps10_parser(struct asm_parser *ret);
327 void create_ps11_parser(struct asm_parser *ret);
328 void create_ps12_parser(struct asm_parser *ret);
329 void create_ps13_parser(struct asm_parser *ret);
330 void create_ps14_parser(struct asm_parser *ret);
331 void create_ps20_parser(struct asm_parser *ret);
332 void create_ps2x_parser(struct asm_parser *ret);
333 void create_ps30_parser(struct asm_parser *ret);
334
335 struct bwriter_shader *parse_asm_shader(char **messages);
336
337 #ifdef __GNUC__
338 #define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
339 #else
340 #define PRINTF_ATTR(fmt,args)
341 #endif
342
343 void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) PRINTF_ATTR(2,3);
344 void set_parse_status(struct asm_parser *ctx, enum parse_status status);
345
346 /* A reasonable value as initial size */
347 #define BYTECODEBUFFER_INITIAL_SIZE 32
348 struct bytecode_buffer {
349     DWORD *data;
350     DWORD size;
351     DWORD alloc_size;
352     /* For tracking rare out of memory situations without passing
353      * return values around everywhere
354      */
355     HRESULT state;
356 };
357
358 struct bc_writer; /* Predeclaration for use in vtable parameters */
359
360 typedef void (*instr_writer)(struct bc_writer *This,
361                              const struct instruction *instr,
362                              struct bytecode_buffer *buffer);
363
364 struct bytecode_backend {
365     void (*header)(struct bc_writer *This, const struct bwriter_shader *shader,
366                    struct bytecode_buffer *buffer);
367     void (*end)(struct bc_writer *This, const struct bwriter_shader *shader,
368                 struct bytecode_buffer *buffer);
369     void (*srcreg)(struct bc_writer *This, const struct shader_reg *reg,
370                    struct bytecode_buffer *buffer);
371     void (*dstreg)(struct bc_writer *This, const struct shader_reg *reg,
372                    struct bytecode_buffer *buffer, DWORD shift, DWORD mod);
373     void (*opcode)(struct bc_writer *This, const struct instruction *instr,
374                    DWORD token, struct bytecode_buffer *buffer);
375
376     const struct instr_handler_table {
377         DWORD opcode;
378         instr_writer func;
379     } *instructions;
380 };
381
382 /* Bytecode writing stuff */
383 struct bc_writer {
384     const struct bytecode_backend *funcs;
385
386     /* Avoid result checking */
387     HRESULT                       state;
388
389     DWORD                         version;
390
391     /* Vertex shader varying mapping */
392     DWORD                         oPos_regnum;
393     DWORD                         oD_regnum[2];
394     DWORD                         oT_regnum[8];
395     DWORD                         oFog_regnum;
396     DWORD                         oFog_mask;
397     DWORD                         oPts_regnum;
398     DWORD                         oPts_mask;
399
400     /* Pixel shader specific members */
401     DWORD                         t_regnum[8];
402     DWORD                         v_regnum[2];
403 };
404
405 /* Debug utility routines */
406 const char *debug_print_srcmod(DWORD mod);
407 const char *debug_print_dstmod(DWORD mod);
408 const char *debug_print_shift(DWORD shift);
409 const char *debug_print_dstreg(const struct shader_reg *reg);
410 const char *debug_print_srcreg(const struct shader_reg *reg);
411 const char *debug_print_swizzle(DWORD swizzle);
412 const char *debug_print_writemask(DWORD mask);
413 const char *debug_print_comp(DWORD comp);
414 const char *debug_print_opcode(DWORD opcode);
415
416 /* Utilities for internal->d3d constant mapping */
417 DWORD d3d9_swizzle(DWORD bwriter_swizzle);
418 DWORD d3d9_writemask(DWORD bwriter_writemask);
419 DWORD d3d9_srcmod(DWORD bwriter_srcmod);
420 DWORD d3d9_dstmod(DWORD bwriter_mod);
421 DWORD d3d9_comparetype(DWORD bwriter_comparetype);
422 DWORD d3d9_sampler(DWORD bwriter_sampler);
423 DWORD d3d9_register(DWORD bwriter_register);
424 DWORD d3d9_opcode(DWORD bwriter_opcode);
425
426 /* Used to signal an incorrect swizzle/writemask */
427 #define SWIZZLE_ERR ~0U
428
429 /*
430   Enumerations and defines used in the bytecode writer
431   intermediate representation
432 */
433 typedef enum _BWRITERSHADER_INSTRUCTION_OPCODE_TYPE {
434     BWRITERSIO_NOP,
435     BWRITERSIO_MOV,
436     BWRITERSIO_ADD,
437     BWRITERSIO_SUB,
438     BWRITERSIO_MAD,
439     BWRITERSIO_MUL,
440     BWRITERSIO_RCP,
441     BWRITERSIO_RSQ,
442     BWRITERSIO_DP3,
443     BWRITERSIO_DP4,
444     BWRITERSIO_MIN,
445     BWRITERSIO_MAX,
446     BWRITERSIO_SLT,
447     BWRITERSIO_SGE,
448     BWRITERSIO_EXP,
449     BWRITERSIO_LOG,
450     BWRITERSIO_LIT,
451     BWRITERSIO_DST,
452     BWRITERSIO_LRP,
453     BWRITERSIO_FRC,
454     BWRITERSIO_M4x4,
455     BWRITERSIO_M4x3,
456     BWRITERSIO_M3x4,
457     BWRITERSIO_M3x3,
458     BWRITERSIO_M3x2,
459     BWRITERSIO_CALL,
460     BWRITERSIO_CALLNZ,
461     BWRITERSIO_LOOP,
462     BWRITERSIO_RET,
463     BWRITERSIO_ENDLOOP,
464     BWRITERSIO_LABEL,
465     BWRITERSIO_DCL,
466     BWRITERSIO_POW,
467     BWRITERSIO_CRS,
468     BWRITERSIO_SGN,
469     BWRITERSIO_ABS,
470     BWRITERSIO_NRM,
471     BWRITERSIO_SINCOS,
472     BWRITERSIO_REP,
473     BWRITERSIO_ENDREP,
474     BWRITERSIO_IF,
475     BWRITERSIO_IFC,
476     BWRITERSIO_ELSE,
477     BWRITERSIO_ENDIF,
478     BWRITERSIO_BREAK,
479     BWRITERSIO_BREAKC,
480     BWRITERSIO_MOVA,
481     BWRITERSIO_DEFB,
482     BWRITERSIO_DEFI,
483
484     BWRITERSIO_TEXCOORD,
485     BWRITERSIO_TEXKILL,
486     BWRITERSIO_TEX,
487     BWRITERSIO_TEXBEM,
488     BWRITERSIO_TEXBEML,
489     BWRITERSIO_TEXREG2AR,
490     BWRITERSIO_TEXREG2GB,
491     BWRITERSIO_TEXM3x2PAD,
492     BWRITERSIO_TEXM3x2TEX,
493     BWRITERSIO_TEXM3x3PAD,
494     BWRITERSIO_TEXM3x3TEX,
495     BWRITERSIO_TEXM3x3SPEC,
496     BWRITERSIO_TEXM3x3VSPEC,
497     BWRITERSIO_EXPP,
498     BWRITERSIO_LOGP,
499     BWRITERSIO_CND,
500     BWRITERSIO_DEF,
501     BWRITERSIO_TEXREG2RGB,
502     BWRITERSIO_TEXDP3TEX,
503     BWRITERSIO_TEXM3x2DEPTH,
504     BWRITERSIO_TEXDP3,
505     BWRITERSIO_TEXM3x3,
506     BWRITERSIO_TEXDEPTH,
507     BWRITERSIO_CMP,
508     BWRITERSIO_BEM,
509     BWRITERSIO_DP2ADD,
510     BWRITERSIO_DSX,
511     BWRITERSIO_DSY,
512     BWRITERSIO_TEXLDD,
513     BWRITERSIO_SETP,
514     BWRITERSIO_TEXLDL,
515     BWRITERSIO_BREAKP,
516     BWRITERSIO_TEXLDP,
517     BWRITERSIO_TEXLDB,
518
519     BWRITERSIO_PHASE,
520     BWRITERSIO_COMMENT,
521     BWRITERSIO_END,
522 } BWRITERSHADER_INSTRUCTION_OPCODE_TYPE;
523
524 typedef enum _BWRITERSHADER_PARAM_REGISTER_TYPE {
525     BWRITERSPR_TEMP,
526     BWRITERSPR_INPUT,
527     BWRITERSPR_CONST,
528     BWRITERSPR_ADDR,
529     BWRITERSPR_TEXTURE,
530     BWRITERSPR_RASTOUT,
531     BWRITERSPR_ATTROUT,
532     BWRITERSPR_TEXCRDOUT,
533     BWRITERSPR_OUTPUT,
534     BWRITERSPR_CONSTINT,
535     BWRITERSPR_COLOROUT,
536     BWRITERSPR_DEPTHOUT,
537     BWRITERSPR_SAMPLER,
538     BWRITERSPR_CONSTBOOL,
539     BWRITERSPR_LOOP,
540     BWRITERSPR_MISCTYPE,
541     BWRITERSPR_LABEL,
542     BWRITERSPR_PREDICATE
543 } BWRITERSHADER_PARAM_REGISTER_TYPE;
544
545 typedef enum _BWRITERVS_RASTOUT_OFFSETS
546 {
547     BWRITERSRO_POSITION,
548     BWRITERSRO_FOG,
549     BWRITERSRO_POINT_SIZE
550 } BWRITERVS_RASTOUT_OFFSETS;
551
552 #define BWRITERSP_WRITEMASK_0   0x1 /* .x r */
553 #define BWRITERSP_WRITEMASK_1   0x2 /* .y g */
554 #define BWRITERSP_WRITEMASK_2   0x4 /* .z b */
555 #define BWRITERSP_WRITEMASK_3   0x8 /* .w a */
556 #define BWRITERSP_WRITEMASK_ALL 0xf /* all */
557
558 typedef enum _BWRITERSHADER_PARAM_DSTMOD_TYPE {
559     BWRITERSPDM_NONE = 0,
560     BWRITERSPDM_SATURATE = 1,
561     BWRITERSPDM_PARTIALPRECISION = 2,
562     BWRITERSPDM_MSAMPCENTROID = 4,
563 } BWRITERSHADER_PARAM_DSTMOD_TYPE;
564
565 typedef enum _BWRITERSAMPLER_TEXTURE_TYPE {
566     BWRITERSTT_UNKNOWN = 0,
567     BWRITERSTT_1D = 1,
568     BWRITERSTT_2D = 2,
569     BWRITERSTT_CUBE = 3,
570     BWRITERSTT_VOLUME = 4,
571 } BWRITERSAMPLER_TEXTURE_TYPE;
572
573 #define BWRITERSI_TEXLD_PROJECT 1
574 #define BWRITERSI_TEXLD_BIAS    2
575
576 typedef enum _BWRITERSHADER_PARAM_SRCMOD_TYPE {
577     BWRITERSPSM_NONE = 0,
578     BWRITERSPSM_NEG,
579     BWRITERSPSM_BIAS,
580     BWRITERSPSM_BIASNEG,
581     BWRITERSPSM_SIGN,
582     BWRITERSPSM_SIGNNEG,
583     BWRITERSPSM_COMP,
584     BWRITERSPSM_X2,
585     BWRITERSPSM_X2NEG,
586     BWRITERSPSM_DZ,
587     BWRITERSPSM_DW,
588     BWRITERSPSM_ABS,
589     BWRITERSPSM_ABSNEG,
590     BWRITERSPSM_NOT,
591 } BWRITERSHADER_PARAM_SRCMOD_TYPE;
592
593 #define BWRITER_SM1_VS  0xfffe
594 #define BWRITER_SM1_PS  0xffff
595
596 #define BWRITERPS_VERSION(major, minor) ((BWRITER_SM1_PS << 16) | ((major) << 8) | (minor))
597 #define BWRITERVS_VERSION(major, minor) ((BWRITER_SM1_VS << 16) | ((major) << 8) | (minor))
598
599 #define BWRITERVS_SWIZZLE_SHIFT      16
600 #define BWRITERVS_SWIZZLE_MASK       (0xFF << BWRITERVS_SWIZZLE_SHIFT)
601
602 #define BWRITERVS_X_X       (0 << BWRITERVS_SWIZZLE_SHIFT)
603 #define BWRITERVS_X_Y       (1 << BWRITERVS_SWIZZLE_SHIFT)
604 #define BWRITERVS_X_Z       (2 << BWRITERVS_SWIZZLE_SHIFT)
605 #define BWRITERVS_X_W       (3 << BWRITERVS_SWIZZLE_SHIFT)
606
607 #define BWRITERVS_Y_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 2))
608 #define BWRITERVS_Y_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 2))
609 #define BWRITERVS_Y_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 2))
610 #define BWRITERVS_Y_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 2))
611
612 #define BWRITERVS_Z_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 4))
613 #define BWRITERVS_Z_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 4))
614 #define BWRITERVS_Z_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 4))
615 #define BWRITERVS_Z_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 4))
616
617 #define BWRITERVS_W_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 6))
618 #define BWRITERVS_W_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 6))
619 #define BWRITERVS_W_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 6))
620 #define BWRITERVS_W_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 6))
621
622 #define BWRITERVS_NOSWIZZLE (BWRITERVS_X_X | BWRITERVS_Y_Y | BWRITERVS_Z_Z | BWRITERVS_W_W)
623
624 #define BWRITERVS_SWIZZLE_X (BWRITERVS_X_X | BWRITERVS_Y_X | BWRITERVS_Z_X | BWRITERVS_W_X)
625 #define BWRITERVS_SWIZZLE_Y (BWRITERVS_X_Y | BWRITERVS_Y_Y | BWRITERVS_Z_Y | BWRITERVS_W_Y)
626 #define BWRITERVS_SWIZZLE_Z (BWRITERVS_X_Z | BWRITERVS_Y_Z | BWRITERVS_Z_Z | BWRITERVS_W_Z)
627 #define BWRITERVS_SWIZZLE_W (BWRITERVS_X_W | BWRITERVS_Y_W | BWRITERVS_Z_W | BWRITERVS_W_W)
628
629 typedef enum _BWRITERDECLUSAGE {
630     BWRITERDECLUSAGE_POSITION,
631     BWRITERDECLUSAGE_BLENDWEIGHT,
632     BWRITERDECLUSAGE_BLENDINDICES,
633     BWRITERDECLUSAGE_NORMAL,
634     BWRITERDECLUSAGE_PSIZE,
635     BWRITERDECLUSAGE_TEXCOORD,
636     BWRITERDECLUSAGE_TANGENT,
637     BWRITERDECLUSAGE_BINORMAL,
638     BWRITERDECLUSAGE_TESSFACTOR,
639     BWRITERDECLUSAGE_POSITIONT,
640     BWRITERDECLUSAGE_COLOR,
641     BWRITERDECLUSAGE_FOG,
642     BWRITERDECLUSAGE_DEPTH,
643     BWRITERDECLUSAGE_SAMPLE
644 } BWRITERDECLUSAGE;
645
646 /* ps 1.x texture registers mappings */
647 #define T0_REG          2
648 #define T1_REG          3
649 #define T2_REG          4
650 #define T3_REG          5
651
652 struct bwriter_shader *SlAssembleShader(const char *text, char **messages);
653 DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result);
654 void SlDeleteShader(struct bwriter_shader *shader);
655
656 #endif /* __WINE_D3DX9_36_PRIVATE_H */