[1/18] d3dx9: Add shader assembler private definitions

Matteo Bruni matteo.mystral at gmail.com
Sun Aug 16 12:50:54 CDT 2009


This is a long patch series that implements the D3D shader assembler
and D3DXAssembleShader function. The first part has already passed a
couple of rounds of review in wine-devel.
-------------- next part --------------
From e0db7788aee16a1e1bd3f61d67618e13b247665a Mon Sep 17 00:00:00 2001
From: Matteo Bruni <matteo.mystral at gmail.com>
Date: Sat, 15 Aug 2009 17:19:38 +0200
Subject: d3dx9: Add shader assembler private definitions

---
 dlls/d3dx9_36/d3dx9_36_private.h |  588 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 588 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dx9_36/d3dx9_36_private.h b/dlls/d3dx9_36/d3dx9_36_private.h
index 8568366..b5c8079 100644
--- a/dlls/d3dx9_36/d3dx9_36_private.h
+++ b/dlls/d3dx9_36/d3dx9_36_private.h
@@ -2,6 +2,8 @@
  * Copyright (C) 2002 Raphael Junqueira
  * Copyright (C) 2008 David Adam
  * Copyright (C) 2008 Tony Wasserka
+ * Copyright (C) 2008 Stefan Dösinger
+ * Copyright (C) 2009 Matteo Bruni
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -112,5 +114,591 @@ typedef struct ID3DXSpriteImpl
     int allocated_sprites; /* number of (pre-)allocated sprites */
 } ID3DXSpriteImpl;
 
+/* Shader assembler definitions */
+typedef enum _shader_type {
+    ST_VERTEX,
+    ST_PIXEL,
+} shader_type;
+
+typedef enum BWRITER_COMPARISON_TYPE {
+    BWRITER_COMPARISON_NONE = 0,
+    BWRITER_COMPARISON_GT   = 1,
+    BWRITER_COMPARISON_EQ   = 2,
+    BWRITER_COMPARISON_GE   = 3,
+    BWRITER_COMPARISON_LT   = 4,
+    BWRITER_COMPARISON_NE   = 5,
+    BWRITER_COMPARISON_LE   = 6
+} BWRITER_COMPARISON_TYPE;
+
+struct constant {
+    DWORD                   regnum;
+    union {
+        float               f;
+        INT                 i;
+        BOOL                b;
+    }                       value[4];
+};
+
+struct shader_reg {
+    DWORD                   type;
+    DWORD                   regnum;
+    struct shader_reg       *rel_reg;
+    DWORD                   srcmod;
+    union {
+        DWORD                   swizzle;
+        DWORD                   writemask;
+    };
+};
+
+struct instruction {
+    DWORD                   opcode;
+    DWORD                   dstmod;
+    DWORD                   shift;
+    BWRITER_COMPARISON_TYPE comptype;
+    BOOL                    has_dst;
+    struct shader_reg       dst;
+    struct shader_reg       *src;
+    unsigned int            num_srcs; /* For freeing the rel_regs */
+    BOOL                    has_predicate;
+    struct shader_reg       predicate;
+    BOOL                    coissue;
+};
+
+struct declaration {
+    DWORD                   usage, usage_idx;
+    DWORD                   regnum;
+    DWORD                   writemask;
+};
+
+struct samplerdecl {
+    DWORD                   type;
+    DWORD                   regnum;
+    unsigned int            line_no; /* for error messages */
+};
+
+#define INSTRARRAY_INITIAL_SIZE 8
+struct bwriter_shader {
+    shader_type             type;
+
+    /* Shader version selected */
+    DWORD                   version;
+
+    /* Local constants. Every constant that is not defined below is loaded from
+     * the global constant set at shader runtime
+     */
+    struct constant         **constF;
+    struct constant         **constI;
+    struct constant         **constB;
+    unsigned int            num_cf, num_ci, num_cb;
+
+    /* Declared input and output varyings */
+    struct declaration      *inputs, *outputs;
+    unsigned int            num_inputs, num_outputs;
+    struct samplerdecl      *samplers;
+    unsigned int            num_samplers;
+
+    /* Are special pixel shader 3.0 registers declared? */
+    BOOL                    vPos, vFace;
+
+    /* Array of shader instructions - The shader code itself */
+    struct instruction      **instr;
+    unsigned int            num_instrs, instr_alloc_size;
+};
+
+static inline LPVOID asm_alloc(SIZE_T size) {
+    return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
+}
+
+static inline LPVOID asm_realloc(LPVOID ptr, SIZE_T size) {
+    return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
+}
+
+static inline BOOL asm_free(LPVOID ptr) {
+    return HeapFree(GetProcessHeap(), 0, ptr);
+}
+
+struct asm_parser;
+
+/* How to map vs 1.0 and 2.0 varyings to 3.0 ones
+ * oTx is mapped to ox, which happens to be an
+ * identical mapping since BWRITERSPR_TEXCRDOUT == BWRITERSPR_OUTPUT
+ * oPos, oFog and point size are mapped to general output regs as well.
+ * the vs 1.x and 2.x parser functions add varying declarations
+ * to the shader, and the 1.x and 2.x output functions check those varyings
+ */
+#define OT0_REG         0
+#define OT1_REG         1
+#define OT2_REG         2
+#define OT3_REG         3
+#define OT4_REG         4
+#define OT5_REG         5
+#define OT6_REG         6
+#define OT7_REG         7
+#define OPOS_REG        8
+#define OFOG_REG        9
+#define OFOG_WRITEMASK  BWRITERSP_WRITEMASK_0
+#define OPTS_REG        9
+#define OPTS_WRITEMASK  BWRITERSP_WRITEMASK_1
+#define OD0_REG         10
+#define OD1_REG         11
+
+#define T0_REG          2
+#define T1_REG          3
+#define T2_REG          4
+#define T3_REG          5
+/* T4 and T5 do not need mapping - they are ps_1_4 registers which are only
+ * useable as varyings
+ */
+#define C0_VARYING      0   /* must be 0 for now, until map_oldps_register is limited to <= ps 2.0 */
+#define C1_VARYING      1   /* must be 1 for now, until map_oldps_register is limited to <= ps 2.0 */
+#define T0_VARYING      2
+#define T1_VARYING      3
+#define T2_VARYING      4
+#define T3_VARYING      5
+#define T4_VARYING      6
+#define T5_VARYING      7
+#define T6_VARYING      8
+#define T7_VARYING      9
+
+/* This structure is only used in asmshader.y, but since the .l file accesses the semantic types
+ * too it has to know it as well
+ */
+struct rel_reg {
+    BOOL            has_rel_reg;
+    DWORD           type;
+    DWORD           additional_offset;
+    DWORD           rel_regnum;
+    DWORD           swizzle;
+};
+
+#define MAX_SRC_REGS 4
+
+struct src_regs {
+    struct shader_reg reg[MAX_SRC_REGS];
+    unsigned int      count;
+};
+
+struct asmparser_backend {
+    void (*constF)(struct asm_parser *This, DWORD reg, float x, float y, float z, float w);
+    void (*constI)(struct asm_parser *This, DWORD reg, INT x, INT y, INT z, INT w);
+    void (*constB)(struct asm_parser *This, DWORD reg, BOOL x);
+
+    void (*dstreg)(struct asm_parser *This, struct instruction *instr,
+                   const struct shader_reg *dst);
+    void (*srcreg)(struct asm_parser *This, struct instruction *instr, int num,
+                   const struct shader_reg *src);
+
+    void (*predicate)(struct asm_parser *This,
+                      const struct shader_reg *predicate);
+    void (*coissue)(struct asm_parser *This);
+
+    void (*dcl_output)(struct asm_parser *This, DWORD usage, DWORD num,
+                       const struct shader_reg *reg);
+    void (*dcl_input)(struct asm_parser *This, DWORD usage, DWORD num,
+                      const struct shader_reg *reg);
+    void (*dcl_sampler)(struct asm_parser *This, DWORD samptype, DWORD regnum,
+                        unsigned int line_no);
+
+    void (*end)(struct asm_parser *This);
+
+    void (*instr)(struct asm_parser *This, DWORD opcode, DWORD mod, DWORD shift,
+                  BWRITER_COMPARISON_TYPE comp, const struct shader_reg *dst,
+                  const struct src_regs *srcs, int expectednsrcs);
+};
+
+struct instruction *alloc_instr(unsigned int srcs);
+BOOL add_instruction(struct bwriter_shader *shader, struct instruction *instr);
+BOOL add_constF(struct bwriter_shader *shader, DWORD reg, float x, float y, float z, float w);
+BOOL add_constI(struct bwriter_shader *shader, DWORD reg, INT x, INT y, INT z, INT w);
+BOOL add_constB(struct bwriter_shader *shader, DWORD reg, BOOL x);
+BOOL record_declaration(struct bwriter_shader *shader, DWORD usage, DWORD usage_idx, BOOL output, DWORD regnum, DWORD writemask);
+BOOL record_sampler(struct bwriter_shader *shader, DWORD samptype, DWORD regnum, unsigned int line_no);
+
+#define MESSAGEBUFFER_INITIAL_SIZE 1024
+struct asm_parser {
+    /* The function table of the parser implementation */
+    struct asmparser_backend *funcs;
+
+    /* Private data follows */
+    struct bwriter_shader    *shader;
+    unsigned int              m3x3pad_count;
+
+    /* Reentrant lexer pointer */
+    void *yyscanner;
+
+    enum parse_status{
+        PARSE_SUCCESS = 0,
+        PARSE_WARN = 1,
+        PARSE_ERR = 2
+    } status;
+    char *messages;
+    unsigned int messagesize;
+    unsigned int messagecapacity;
+    unsigned int line_no;
+};
+
+void create_vs10_parser(struct asm_parser *ret);
+void create_vs11_parser(struct asm_parser *ret);
+void create_vs20_parser(struct asm_parser *ret);
+void create_vs2x_parser(struct asm_parser *ret);
+void create_vs30_parser(struct asm_parser *ret);
+void create_ps10_parser(struct asm_parser *ret);
+void create_ps11_parser(struct asm_parser *ret);
+void create_ps12_parser(struct asm_parser *ret);
+void create_ps13_parser(struct asm_parser *ret);
+void create_ps14_parser(struct asm_parser *ret);
+void create_ps20_parser(struct asm_parser *ret);
+void create_ps2x_parser(struct asm_parser *ret);
+void create_ps30_parser(struct asm_parser *ret);
+
+struct bwriter_shader *parse_asm_shader(struct asm_parser *asm_ctx, char **messages);
+
+#ifdef __GNUC__
+#define PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
+#else
+#define PRINTF_ATTR(fmt,args)
+#endif
+
+void asmparser_message(struct asm_parser *ctx, const char *fmt, ...) PRINTF_ATTR(2,3);
+void set_parse_status(struct asm_parser *ctx, enum parse_status status);
+
+/* Declaration for reentrant lexer/parser */
+#define YY_EXTRA_TYPE struct asm_parser *
+
+/* A reasonable value as initial size */
+#define BYTECODEBUFFER_INITIAL_SIZE 32
+struct bytecode_buffer {
+    DWORD *data;
+    DWORD size;
+    DWORD alloc_size;
+    /* For tracking rare out of memory situations without passing
+     * return values around everywhere
+     */
+    HRESULT state;
+};
+
+struct bc_writer; /* Predeclaration for use in vtable parameters */
+
+typedef void (*instr_writer)(struct bc_writer *This,
+                             const struct instruction *instr,
+                             struct bytecode_buffer *buffer);
+
+struct bytecode_backend {
+    void (*header)(struct bc_writer *This, const struct bwriter_shader *shader, struct bytecode_buffer *buffer);
+    void (*end)(struct bc_writer *This, const struct bwriter_shader *shader,
+                struct bytecode_buffer *buffer);
+    void (*srcreg)(struct bc_writer *This, const struct shader_reg *reg,
+                   struct bytecode_buffer *buffer);
+    void (*dstreg)(struct bc_writer *This, const struct shader_reg *reg,
+                   struct bytecode_buffer *buffer, DWORD shift, DWORD mod);
+    void (*opcode)(struct bc_writer *This, const struct instruction *instr,
+                   DWORD token, struct bytecode_buffer *buffer);
+
+    struct instr_handler_table {
+        DWORD opcode;
+        instr_writer func;
+    } *instructions;
+};
+
+/* Bytecode writing stuff */
+struct bc_writer {
+    struct bytecode_backend     *funcs;
+
+    /* Avoid result checking */
+    HRESULT                     state;
+
+    DWORD                       version;
+
+    /* Vertex shader specific members
+     * All members are carried around for all shaders. In theory a derived structure
+     * could be created for vertex and pixel shaders, but that means extra code and
+     * casting in C, so don't do it for now
+     */
+    /* varying mapping */
+    DWORD                       oPos_regnum;
+    DWORD                       oD_regnum[2];
+    DWORD                       oT_regnum[8];
+    DWORD                       oFog_regnum;
+    DWORD                       oFog_mask;
+    DWORD                       oPts_regnum;
+    DWORD                       oPts_mask;
+
+    /* Pixel shader specific members */
+    DWORD                       t_regnum[8];
+    DWORD                       v_regnum[2];
+};
+
+
+/* Debug utility routines. Some are not reentrant, check asmutils.c */
+const char *debug_print_srcmod(DWORD mod);
+const char *debug_print_dstmod(DWORD mod);
+const char *debug_print_shift(DWORD shift);
+const char *debug_print_dstreg(const struct shader_reg *reg, shader_type st);
+const char *debug_print_srcreg(const struct shader_reg *reg, shader_type st);
+const char *debug_print_swizzle(DWORD swizzle);
+const char *debug_print_writemask(DWORD mask);
+const char *debug_print_comp(DWORD comp);
+const char *debug_print_opcode(DWORD opcode);
+
+/* Utilities for internal->d3d constant mapping */
+DWORD d3d9_swizzle(DWORD bwriter_swizzle);
+DWORD d3d9_writemask(DWORD bwriter_writemask);
+DWORD d3d9_srcmod(DWORD bwriter_srcmod);
+DWORD d3d9_dstmod(DWORD bwriter_mod);
+DWORD d3d9_comparetype(DWORD bwriter_comparetype);
+DWORD d3d9_sampler(DWORD bwriter_sampler);
+DWORD d3d9_register(DWORD bwriter_register);
+DWORD d3d9_opcode(DWORD bwriter_opcode);
+
+/* Misc utility functions */
+#define SWIZZLE_ERR ~0U
+DWORD text2swizzle(const char *text);
+
+
+/*
+  Below there are some enumerations and defines used in the bytecode writer
+  intermediate representation
+*/
+
+typedef enum _BWRITERSHADER_INSTRUCTION_OPCODE_TYPE
+{
+    BWRITERSIO_NOP = 0,
+    BWRITERSIO_MOV = 1,
+    BWRITERSIO_ADD = 2,
+    BWRITERSIO_SUB = 3,
+    BWRITERSIO_MAD = 4,
+    BWRITERSIO_MUL = 5,
+    BWRITERSIO_RCP = 6,
+    BWRITERSIO_RSQ = 7,
+    BWRITERSIO_DP3 = 8,
+    BWRITERSIO_DP4 = 9,
+    BWRITERSIO_MIN = 10,
+    BWRITERSIO_MAX = 11,
+    BWRITERSIO_SLT = 12,
+    BWRITERSIO_SGE = 13,
+    BWRITERSIO_EXP = 14,
+    BWRITERSIO_LOG = 15,
+    BWRITERSIO_LIT = 16,
+    BWRITERSIO_DST = 17,
+    BWRITERSIO_LRP = 18,
+    BWRITERSIO_FRC = 19,
+    BWRITERSIO_M4x4 = 20,
+    BWRITERSIO_M4x3 = 21,
+    BWRITERSIO_M3x4 = 22,
+    BWRITERSIO_M3x3 = 23,
+    BWRITERSIO_M3x2 = 24,
+    BWRITERSIO_CALL = 25,
+    BWRITERSIO_CALLNZ = 26,
+    BWRITERSIO_LOOP = 27,
+    BWRITERSIO_RET = 28,
+    BWRITERSIO_ENDLOOP = 29,
+    BWRITERSIO_LABEL = 30,
+    BWRITERSIO_DCL = 31,
+    BWRITERSIO_POW = 32,
+    BWRITERSIO_CRS = 33,
+    BWRITERSIO_SGN = 34,
+    BWRITERSIO_ABS = 35,
+    BWRITERSIO_NRM = 36,
+    BWRITERSIO_SINCOS = 37,
+    BWRITERSIO_REP = 38,
+    BWRITERSIO_ENDREP = 39,
+    BWRITERSIO_IF = 40,
+    BWRITERSIO_IFC = 41,
+    BWRITERSIO_ELSE = 42,
+    BWRITERSIO_ENDIF = 43,
+    BWRITERSIO_BREAK = 44,
+    BWRITERSIO_BREAKC = 45,
+    BWRITERSIO_MOVA = 46,
+    BWRITERSIO_DEFB = 47,
+    BWRITERSIO_DEFI = 48,
+
+    BWRITERSIO_TEXCOORD = 64,
+    BWRITERSIO_TEXKILL = 65,
+    BWRITERSIO_TEX = 66,
+    BWRITERSIO_TEXBEM = 67,
+    BWRITERSIO_TEXBEML = 68,
+    BWRITERSIO_TEXREG2AR = 69,
+    BWRITERSIO_TEXREG2GB = 70,
+    BWRITERSIO_TEXM3x2PAD = 71,
+    BWRITERSIO_TEXM3x2TEX = 72,
+    BWRITERSIO_TEXM3x3PAD = 73,
+    BWRITERSIO_TEXM3x3TEX = 74,
+    BWRITERSIO_TEXM3x3DIFF = 75,
+    BWRITERSIO_TEXM3x3SPEC = 76,
+    BWRITERSIO_TEXM3x3VSPEC = 77,
+    BWRITERSIO_EXPP = 78,
+    BWRITERSIO_LOGP = 79,
+    BWRITERSIO_CND = 80,
+    BWRITERSIO_DEF = 81,
+    BWRITERSIO_TEXREG2RGB = 82,
+    BWRITERSIO_TEXDP3TEX = 83,
+    BWRITERSIO_TEXM3x2DEPTH = 84,
+    BWRITERSIO_TEXDP3 = 85,
+    BWRITERSIO_TEXM3x3 = 86,
+    BWRITERSIO_TEXDEPTH = 87,
+    BWRITERSIO_CMP = 88,
+    BWRITERSIO_BEM = 89,
+    BWRITERSIO_DP2ADD = 90,
+    BWRITERSIO_DSX = 91,
+    BWRITERSIO_DSY = 92,
+    BWRITERSIO_TEXLDD = 93,
+    BWRITERSIO_SETP = 94,
+    BWRITERSIO_TEXLDL = 95,
+    BWRITERSIO_BREAKP = 96,
+
+    BWRITERSIO_PHASE = 0xfffd,
+    BWRITERSIO_COMMENT = 0xfffe,
+    BWRITERSIO_END = 0Xffff,
+} BWRITERSHADER_INSTRUCTION_OPCODE_TYPE;
+
+typedef enum _BWRITERSHADER_PARAM_REGISTER_TYPE
+{
+    BWRITERSPR_TEMP = 0,
+    BWRITERSPR_INPUT = 1,
+    BWRITERSPR_CONST = 2,
+    BWRITERSPR_ADDR = 3,
+    BWRITERSPR_TEXTURE = 3,
+    BWRITERSPR_RASTOUT = 4,
+    BWRITERSPR_ATTROUT = 5,
+    BWRITERSPR_TEXCRDOUT = 6,
+    BWRITERSPR_OUTPUT = 6,
+    BWRITERSPR_CONSTINT = 7,
+    BWRITERSPR_COLOROUT = 8,
+    BWRITERSPR_DEPTHOUT = 9,
+    BWRITERSPR_SAMPLER = 10,
+    BWRITERSPR_CONST2 = 11,
+    BWRITERSPR_CONST3 = 12,
+    BWRITERSPR_CONST4 = 13,
+    BWRITERSPR_CONSTBOOL = 14,
+    BWRITERSPR_LOOP = 15,
+    BWRITERSPR_TEMPFLOAT16 = 16,
+    BWRITERSPR_MISCTYPE = 17,
+    BWRITERSPR_LABEL = 18,
+    BWRITERSPR_PREDICATE = 19,
+    BWRITERSPR_IMMCONST,
+} BWRITERSHADER_PARAM_REGISTER_TYPE;
+
+typedef enum _BWRITERVS_RASTOUT_OFFSETS
+{
+    BWRITERSRO_POSITION = 0,
+    BWRITERSRO_FOG = 1,
+    BWRITERSRO_POINT_SIZE = 2,
+} BWRITERVS_RASTOUT_OFFSETS;
+
+#define BWRITERSP_WRITEMASK_0   0x1 /* .x r */
+#define BWRITERSP_WRITEMASK_1   0x2 /* .y g */
+#define BWRITERSP_WRITEMASK_2   0x4 /* .z b */
+#define BWRITERSP_WRITEMASK_3   0x8 /* .w a */
+#define BWRITERSP_WRITEMASK_ALL 0xf /* all */
+
+typedef enum _BWRITERSHADER_PARAM_DSTMOD_TYPE
+{
+    BWRITERSPDM_NONE = 0,
+    BWRITERSPDM_SATURATE = 1,
+    BWRITERSPDM_PARTIALPRECISION = 2,
+    BWRITERSPDM_MSAMPCENTROID = 4,
+} BWRITERSHADER_PARAM_DSTMOD_TYPE;
+
+typedef enum _BWRITERSAMPLER_TEXTURE_TYPE
+{
+    BWRITERSTT_UNKNOWN = 0,
+    BWRITERSTT_1D = 1,
+    BWRITERSTT_2D = 2,
+    BWRITERSTT_CUBE = 3,
+    BWRITERSTT_VOLUME = 4,
+} BWRITERSAMPLER_TEXTURE_TYPE;
+
+#define BWRITERSI_TEXLD_PROJECT 1
+#define BWRITERSI_TEXLD_BIAS    2
+
+typedef enum _BWRITERSHADER_PARAM_SRCMOD_TYPE
+{
+    BWRITERSPSM_NONE = 0,
+    BWRITERSPSM_NEG = 1,
+    BWRITERSPSM_BIAS = 2,
+    BWRITERSPSM_BIASNEG = 3,
+    BWRITERSPSM_SIGN = 4,
+    BWRITERSPSM_SIGNNEG = 5,
+    BWRITERSPSM_COMP = 6,
+    BWRITERSPSM_X2 = 7,
+    BWRITERSPSM_X2NEG = 8,
+    BWRITERSPSM_DZ = 9,
+    BWRITERSPSM_DW = 10,
+    BWRITERSPSM_ABS = 11,
+    BWRITERSPSM_ABSNEG = 12,
+    BWRITERSPSM_NOT = 13,
+} BWRITERSHADER_PARAM_SRCMOD_TYPE;
+
+#define BWRITER_SM1_VS  0xfffe
+#define BWRITER_SM1_PS  0xffff
+
+#define BWRITERPS_VERSION(major, minor) ((BWRITER_SM1_PS << 16) | ((major) << 8) | (minor))
+#define BWRITERVS_VERSION(major, minor) ((BWRITER_SM1_VS << 16) | ((major) << 8) | (minor))
+
+/** Source register modifiers **/
+#define BWRITERVS_SWIZZLE_SHIFT      16
+#define BWRITERVS_SWIZZLE_MASK       (0xFF << BWRITERVS_SWIZZLE_SHIFT)
+#define BWRITERSP_SWIZZLE_SHIFT      16
+#define BWRITERSP_SWIZZLE_MASK       (0xFF << BWRITERSP_SWIZZLE_SHIFT)
+
+#define BWRITERVS_X_X       (0 << BWRITERVS_SWIZZLE_SHIFT)
+#define BWRITERVS_X_Y       (1 << BWRITERVS_SWIZZLE_SHIFT)
+#define BWRITERVS_X_Z       (2 << BWRITERVS_SWIZZLE_SHIFT)
+#define BWRITERVS_X_W       (3 << BWRITERVS_SWIZZLE_SHIFT)
+
+#define BWRITERVS_Y_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 2))
+#define BWRITERVS_Y_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 2))
+#define BWRITERVS_Y_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 2))
+#define BWRITERVS_Y_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 2))
+
+#define BWRITERVS_Z_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 4))
+#define BWRITERVS_Z_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 4))
+#define BWRITERVS_Z_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 4))
+#define BWRITERVS_Z_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 4))
+
+#define BWRITERVS_W_X       (0 << (BWRITERVS_SWIZZLE_SHIFT + 6))
+#define BWRITERVS_W_Y       (1 << (BWRITERVS_SWIZZLE_SHIFT + 6))
+#define BWRITERVS_W_Z       (2 << (BWRITERVS_SWIZZLE_SHIFT + 6))
+#define BWRITERVS_W_W       (3 << (BWRITERVS_SWIZZLE_SHIFT + 6))
+
+#define BWRITERVS_NOSWIZZLE (BWRITERVS_X_X | BWRITERVS_Y_Y | BWRITERVS_Z_Z | BWRITERVS_W_W)
+
+#define BWRITERSP_NOSWIZZLE \
+    ((0 << (BWRITERSP_SWIZZLE_SHIFT + 0)) | (1 << (BWRITERSP_SWIZZLE_SHIFT + 2)) | \
+     (2 << (BWRITERSP_SWIZZLE_SHIFT + 4)) | (3 << (BWRITERSP_SWIZZLE_SHIFT + 6)))
+
+#define BWRITERVS_SWIZZLE_X (BWRITERVS_X_X | BWRITERVS_Y_X | BWRITERVS_Z_X | BWRITERVS_W_X)
+#define BWRITERVS_SWIZZLE_Y (BWRITERVS_X_Y | BWRITERVS_Y_Y | BWRITERVS_Z_Y | BWRITERVS_W_Y)
+#define BWRITERVS_SWIZZLE_Z (BWRITERVS_X_Z | BWRITERVS_Y_Z | BWRITERVS_Z_Z | BWRITERVS_W_Z)
+#define BWRITERVS_SWIZZLE_W (BWRITERVS_X_W | BWRITERVS_Y_W | BWRITERVS_Z_W | BWRITERVS_W_W)
+
+typedef enum _BWRITERDECLUSAGE {
+    BWRITERDECLUSAGE_POSITION = 0,
+    BWRITERDECLUSAGE_BLENDWEIGHT = 1,
+    BWRITERDECLUSAGE_BLENDINDICES = 2,
+    BWRITERDECLUSAGE_NORMAL = 3,
+    BWRITERDECLUSAGE_PSIZE = 4,
+    BWRITERDECLUSAGE_TEXCOORD = 5,
+    BWRITERDECLUSAGE_TANGENT = 6,
+    BWRITERDECLUSAGE_BINORMAL = 7,
+    BWRITERDECLUSAGE_TESSFACTOR = 8,
+    BWRITERDECLUSAGE_POSITIONT = 9,
+    BWRITERDECLUSAGE_COLOR = 10,
+    BWRITERDECLUSAGE_FOG = 11,
+    BWRITERDECLUSAGE_DEPTH = 12,
+    BWRITERDECLUSAGE_SAMPLE = 13
+} BWRITERDECLUSAGE;
+
+#define BWRITER_OPCODESPECIFICCONTROL_SHIFT     16
+#define BWRITER_OPCODESPECIFICCONTROL_MASK      (0xff << BWRITER_OPCODESPECIFICCONTROL_SHIFT)
+
+/* Mutex used to guarantee a single invocation at any time
+   of the D3DXAssembleShader function and its variants.
+   This is needed as wpp isn't thread-safe */
+extern CRITICAL_SECTION mutex;
+
+struct bwriter_shader *SlAssembleShader(const char *text, char **messages);
+DWORD SlWriteBytecode(const struct bwriter_shader *shader, int dxversion, DWORD **result);
+void SlDeleteShader(struct bwriter_shader *shader);
 
 #endif /* __WINE_D3DX9_36_PRIVATE_H */
-- 
1.6.3.3


More information about the wine-patches mailing list