- sync wined3d with wine
authorKamil Hornicek <kamil.hornicek@reactos.org>
Tue, 9 Dec 2008 12:16:19 +0000 (12:16 +0000)
committerKamil Hornicek <kamil.hornicek@reactos.org>
Tue, 9 Dec 2008 12:16:19 +0000 (12:16 +0000)
svn path=/trunk/; revision=37957

35 files changed:
reactos/dll/directx/wine/wined3d/arb_program_shader.c
reactos/dll/directx/wine/wined3d/ati_fragment_shader.c
reactos/dll/directx/wine/wined3d/baseshader.c
reactos/dll/directx/wine/wined3d/basetexture.c
reactos/dll/directx/wine/wined3d/clipper.c
reactos/dll/directx/wine/wined3d/context.c
reactos/dll/directx/wine/wined3d/cubetexture.c
reactos/dll/directx/wine/wined3d/device.c
reactos/dll/directx/wine/wined3d/directx.c
reactos/dll/directx/wine/wined3d/drawprim.c
reactos/dll/directx/wine/wined3d/glsl_shader.c
reactos/dll/directx/wine/wined3d/indexbuffer.c
reactos/dll/directx/wine/wined3d/nvidia_texture_shader.c
reactos/dll/directx/wine/wined3d/palette.c
reactos/dll/directx/wine/wined3d/pixelshader.c
reactos/dll/directx/wine/wined3d/resource.c
reactos/dll/directx/wine/wined3d/state.c
reactos/dll/directx/wine/wined3d/stateblock.c
reactos/dll/directx/wine/wined3d/surface.c
reactos/dll/directx/wine/wined3d/surface_base.c
reactos/dll/directx/wine/wined3d/surface_gdi.c
reactos/dll/directx/wine/wined3d/swapchain.c
reactos/dll/directx/wine/wined3d/swapchain_base.c
reactos/dll/directx/wine/wined3d/swapchain_gdi.c
reactos/dll/directx/wine/wined3d/texture.c
reactos/dll/directx/wine/wined3d/utils.c
reactos/dll/directx/wine/wined3d/vertexbuffer.c
reactos/dll/directx/wine/wined3d/vertexshader.c
reactos/dll/directx/wine/wined3d/volume.c
reactos/dll/directx/wine/wined3d/volumetexture.c
reactos/dll/directx/wine/wined3d/wined3d.idl [new file with mode: 0644]
reactos/dll/directx/wine/wined3d/wined3d.rbuild
reactos/dll/directx/wine/wined3d/wined3d_gl.h [new file with mode: 0644]
reactos/dll/directx/wine/wined3d/wined3d_main.c
reactos/dll/directx/wine/wined3d/wined3d_private.h

index 12148e6..9d51250 100644 (file)
@@ -36,6 +36,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
 WINE_DECLARE_DEBUG_CHANNEL(d3d_constants);
 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
+WINE_DECLARE_DEBUG_CHANNEL(d3d);
 
 #define GLINFO_LOCATION      (*gl_info)
 
@@ -66,8 +67,9 @@ struct shader_arb_priv {
  * @target_type should be either GL_VERTEX_PROGRAM_ARB (for vertex shaders)
  *  or GL_FRAGMENT_PROGRAM_ARB (for pixel shaders)
  */
-static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl* This, WineD3D_GL_Info *gl_info, GLuint target_type,
-        unsigned int max_constants, float* constants, char *dirty_consts) {
+static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl* This, const WineD3D_GL_Info *gl_info,
+        GLuint target_type, unsigned int max_constants, const float *constants, char *dirty_consts)
+{
     local_constant* lconst;
     DWORD i, j;
     unsigned int ret;
@@ -173,7 +175,7 @@ static void shader_arb_load_constants(
    
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device; 
     IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
-    WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
     unsigned char i;
 
     if (useVertexShader) {
@@ -205,7 +207,7 @@ static void shader_arb_load_constants(
         for(i = 0; i < psi->numbumpenvmatconsts; i++) {
             /* The state manager takes care that this function is always called if the bump env matrix changes
              */
-            float *data = (float *) &stateBlock->textureState[(int) psi->bumpenvmatconst[i].texunit][WINED3DTSS_BUMPENVMAT00];
+            const float *data = (const float *)&stateBlock->textureState[(int) psi->bumpenvmatconst[i].texunit][WINED3DTSS_BUMPENVMAT00];
             GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->bumpenvmatconst[i].const_num, data));
             deviceImpl->activeContext->pshader_const_dirty[psi->bumpenvmatconst[i].const_num] = 1;
 
@@ -215,47 +217,18 @@ static void shader_arb_load_constants(
                  * don't care about them. The pointers are valid for sure because the stateblock is bigger.
                  * (they're WINED3DTSS_TEXTURETRANSFORMFLAGS and WINED3DTSS_ADDRESSW, so most likely 0 or NaN
                  */
-                float *scale = (float *) &stateBlock->textureState[(int) psi->luminanceconst[i].texunit][WINED3DTSS_BUMPENVLSCALE];
+                const float *scale = (const float *)&stateBlock->textureState[(int) psi->luminanceconst[i].texunit][WINED3DTSS_BUMPENVLSCALE];
                 GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->luminanceconst[i].const_num, scale));
                 deviceImpl->activeContext->pshader_const_dirty[psi->luminanceconst[i].const_num] = 1;
             }
         }
-
-        if(((IWineD3DPixelShaderImpl *) pshader)->srgb_enabled &&
-           !((IWineD3DPixelShaderImpl *) pshader)->srgb_mode_hardcoded) {
-            float comparison[4];
-            float mul_low[4];
-
-            if(stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE]) {
-                comparison[0] = srgb_cmp; comparison[1] = srgb_cmp;
-                comparison[2] = srgb_cmp; comparison[3] = srgb_cmp;
-
-                mul_low[0] = srgb_mul_low; mul_low[1] = srgb_mul_low;
-                mul_low[2] = srgb_mul_low; mul_low[3] = srgb_mul_low;
-            } else {
-                comparison[0] = 1.0 / 0.0; comparison[1] = 1.0 / 0.0;
-                comparison[2] = 1.0 / 0.0; comparison[3] = 1.0 / 0.0;
-
-                mul_low[0] = 1.0; mul_low[1] = 1.0;
-                mul_low[2] = 1.0; mul_low[3] = 1.0;
-            }
-            GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->srgb_cmp_const, comparison));
-            GL_EXTCALL(glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, psi->srgb_low_const, mul_low));
-            checkGLcall("Load sRGB correction constants\n");
-            deviceImpl->activeContext->pshader_const_dirty[psi->srgb_low_const] = 1;
-            deviceImpl->activeContext->pshader_const_dirty[psi->srgb_cmp_const] = 1;
-
-        }
     }
 }
 
 /* Generate the variable & register declarations for the ARB_vertex_program output target */
-static void shader_generate_arb_declarations(
-    IWineD3DBaseShader *iface,
-    shader_reg_maps* reg_maps,
-    SHADER_BUFFER* buffer,
-    WineD3D_GL_Info* gl_info) {
-
+static void shader_generate_arb_declarations(IWineD3DBaseShader *iface, const shader_reg_maps *reg_maps,
+        SHADER_BUFFER *buffer, const WineD3D_GL_Info *gl_info)
+{
     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
     DWORD i, cur;
@@ -263,7 +236,7 @@ static void shader_generate_arb_declarations(
     unsigned max_constantsF = min(This->baseShader.limits.constant_float, 
             (pshader ? GL_LIMITS(pshader_constantsF) : GL_LIMITS(vshader_constantsF)));
     UINT extra_constants_needed = 0;
-    local_constant* lconst;
+    const local_constant *lconst;
 
     /* Temporary Output register */
     shader_addline(buffer, "TEMP TMP_OUT;\n");
@@ -325,49 +298,16 @@ static void shader_generate_arb_declarations(
     }
 
     if(device->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE] && pshader) {
-        IWineD3DPixelShaderImpl *ps_impl = (IWineD3DPixelShaderImpl *) This;
-        /* If there are 2 constants left to use, use them to pass the sRGB correction values in. This way
-         * srgb write correction can be turned on and off dynamically without recompilation. Otherwise
-         * hardcode them. The drawback of hardcoding is that the shader needs recompilation to turn sRGB
-         * off again
-         */
-        if(max_constantsF + extra_constants_needed + 1 < GL_LIMITS(pshader_constantsF) && FALSE) {
-            /* The idea is that if srgb is enabled, then disabled, the constant loading code
-             * can effectively disable sRGB correction by passing 1.0 and INF as the multiplication
-             * and comparison constants. If it disables it that way, the shader won't be recompiled
-             * and the code will stay in, so sRGB writing can be turned on again by setting the
-             * constants from the spec
-             */
-            ps_impl->srgb_mode_hardcoded = 0;
-            ps_impl->srgb_low_const = GL_LIMITS(pshader_constantsF) - extra_constants_needed;
-            ps_impl->srgb_cmp_const = GL_LIMITS(pshader_constantsF) - extra_constants_needed - 1;
-            shader_addline(buffer, "PARAM srgb_mul_low = program.env[%d];\n", ps_impl->srgb_low_const);
-            shader_addline(buffer, "PARAM srgb_comparison = program.env[%d];\n", ps_impl->srgb_cmp_const);
-        } else {
-            shader_addline(buffer, "PARAM srgb_mul_low = {%f, %f, %f, 1.0};\n",
-                           srgb_mul_low, srgb_mul_low, srgb_mul_low);
-            shader_addline(buffer, "PARAM srgb_comparison =  {%f, %f, %f, %f};\n",
-                           srgb_cmp, srgb_cmp, srgb_cmp, srgb_cmp);
-            ps_impl->srgb_mode_hardcoded = 1;
-        }
-        /* These can be hardcoded, they do not cause any harm because no fragment will enter the high
-         * path if the comparison value is set to INF
-         */
+        shader_addline(buffer, "PARAM srgb_mul_low = {%f, %f, %f, 1.0};\n",
+                        srgb_mul_low, srgb_mul_low, srgb_mul_low);
+        shader_addline(buffer, "PARAM srgb_comparison =  {%f, %f, %f, %f};\n",
+                        srgb_cmp, srgb_cmp, srgb_cmp, srgb_cmp);
         shader_addline(buffer, "PARAM srgb_pow =  {%f, %f, %f, 1.0};\n",
                        srgb_pow, srgb_pow, srgb_pow);
         shader_addline(buffer, "PARAM srgb_mul_hi =  {%f, %f, %f, 1.0};\n",
                        srgb_mul_high, srgb_mul_high, srgb_mul_high);
         shader_addline(buffer, "PARAM srgb_sub_hi =  {%f, %f, %f, 0.0};\n",
                        srgb_sub_high, srgb_sub_high, srgb_sub_high);
-        ps_impl->srgb_enabled = 1;
-    } else if(pshader) {
-        IWineD3DPixelShaderImpl *ps_impl = (IWineD3DPixelShaderImpl *) This;
-
-        /* Do not write any srgb fixup into the shader to save shader size and processing time.
-         * As a consequence, we can't toggle srgb write on without recompilation
-         */
-        ps_impl->srgb_enabled = 0;
-        ps_impl->srgb_mode_hardcoded = 1;
     }
 
     /* Load local constants using the program-local space,
@@ -418,7 +358,8 @@ static const char * const shift_tab[] = {
     "coefdiv.x"  /* 15 (d2)   */
 };
 
-static void shader_arb_get_write_mask(SHADER_OPCODE_ARG* arg, const DWORD param, char *write_mask) {
+static void shader_arb_get_write_mask(const SHADER_OPCODE_ARG *arg, const DWORD param, char *write_mask)
+{
     IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) arg->shader;
     char *ptr = write_mask;
     char vshader = shader_is_vshader_version(This->baseShader.hex_version);
@@ -522,8 +463,8 @@ static void pshader_get_register_name(IWineD3DBaseShader* iface,
 }
 
 /* TODO: merge with pixel shader */
-static void vshader_program_add_param(SHADER_OPCODE_ARG *arg, const DWORD param, BOOL is_input, char *hwLine) {
-
+static void vshader_program_add_param(const SHADER_OPCODE_ARG *arg, const DWORD param, BOOL is_input, char *hwLine)
+{
   IWineD3DVertexShaderImpl* This = (IWineD3DVertexShaderImpl*) arg->shader;
 
   /* oPos, oFog and oPts in D3D */
@@ -605,7 +546,9 @@ static void vshader_program_add_param(SHADER_OPCODE_ARG *arg, const DWORD param,
   }
 }
 
-static void shader_hw_sample(SHADER_OPCODE_ARG* arg, DWORD sampler_idx, const char *dst_str, const char *coord_reg, BOOL projected, BOOL bias) {
+static void shader_hw_sample(const SHADER_OPCODE_ARG *arg, DWORD sampler_idx, const char *dst_str,
+        const char *coord_reg, BOOL projected, BOOL bias)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     DWORD sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
     const char *tex_type;
@@ -653,229 +596,81 @@ static void shader_hw_sample(SHADER_OPCODE_ARG* arg, DWORD sampler_idx, const ch
     }
 }
 
-static void gen_color_correction(SHADER_BUFFER *buffer, const char *reg, const char *writemask,
-                                 const char *one, const char *two, WINED3DFORMAT fmt,
-                                 WineD3D_GL_Info *gl_info) {
-    switch(fmt) {
-        case WINED3DFMT_V8U8:
-        case WINED3DFMT_V16U16:
-            if(GL_SUPPORT(NV_TEXTURE_SHADER) && fmt == WINED3DFMT_V8U8) {
-                if(0) {
-                    /* The 3rd channel returns 1.0 in d3d, but 0.0 in gl. Fix this while we're at it :-)
-                     * disabled until an application that needs it is found because it causes unneeded
-                     * shader recompilation in some game
-                     */
-                    if(strlen(writemask) >= 4) {
-                        shader_addline(buffer, "MOV %s.%c, %s;\n", reg, writemask[3], one);
-                    }
-                }
-            } else {
-                /* Correct the sign, but leave the blue as it is - it was loaded correctly already
-                 * ARB shaders are a bit picky wrt writemasks and swizzles. If we're free to scale
-                 * all registers, do so, this saves an instruction.
-                 */
-                if(strlen(writemask) >= 5) {
-                    shader_addline(buffer, "MAD %s, %s, %s, -%s;\n", reg, reg, two, one);
-                } else if(strlen(writemask) >= 3) {
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",
-                                   reg, writemask[1],
-                                   reg, writemask[1],
-                                   two, one);
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",
-                                   reg, writemask[2],
-                                   reg, writemask[2],
-                                   two, one);
-                } else if(strlen(writemask) == 2) {
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n", reg, writemask[1],
-                                   reg, writemask[1], two, one);
-                }
-            }
-            break;
-
-        case WINED3DFMT_X8L8V8U8:
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
-                /* Red and blue are the signed channels, fix them up; Blue(=L) is correct already,
-                 * and a(X) is always 1.0. Cannot do a full conversion due to L(blue)
-                 */
-                if(strlen(writemask) >= 3) {
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",
-                                   reg, writemask[1],
-                                   reg, writemask[1],
-                                   two, one);
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",
-                                   reg, writemask[2],
-                                   reg, writemask[2],
-                                   two, one);
-                } else if(strlen(writemask) == 2) {
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",
-                                   reg, writemask[1],
-                                   reg, writemask[1],
-                                   two, one);
-                }
-            }
-            break;
-
-        case WINED3DFMT_L6V5U5:
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
-                if(strlen(writemask) >= 4) {
-                    /* Swap y and z (U and L), and do a sign conversion on x and the new y(V and U) */
-                    shader_addline(buffer, "MOV TMP.g, %s.%c;\n",
-                                   reg, writemask[2]);
-                    shader_addline(buffer, "MAD %s.%c%c, %s.%c%c%c%c, %s, -%s;\n",
-                                   reg, writemask[1], writemask[2],
-                                   reg, writemask[3], writemask[1], writemask[3], writemask[1],
-                                   two, one);
-                    shader_addline(buffer, "MOV %s.%c, TMP.g;\n", reg,
-                                   writemask[3]);
-                } else if(strlen(writemask) == 3) {
-                    /* This is bad: We have VL, but we need VU */
-                    FIXME("2 components sampled from a converted L6V5U5 texture\n");
-                } else {
-                    shader_addline(buffer, "MAD %s.%c, %s.%c, %s, -%s;\n",
-                                   reg, writemask[1],
-                                   reg, writemask[1],
-                                   two, one);
-                }
-            }
-            break;
-
-        case WINED3DFMT_Q8W8V8U8:
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
-                /* Correct the sign in all channels */
-                switch(strlen(writemask)) {
-                    case 4:
-                        shader_addline(buffer, "MAD %s.%c, %s.%c, coefmul.x, -one;\n",
-                                       reg, writemask[3],
-                                       reg, writemask[3]);
-                        /* drop through */
-                    case 3:
-                        shader_addline(buffer, "MAD %s.%c, %s.%c, coefmul.x, -one;\n",
-                                       reg, writemask[2],
-                                       reg, writemask[2]);
-                        /* drop through */
-                    case 2:
-                        shader_addline(buffer, "MAD %s.%c, %s.%c, coefmul.x, -one;\n",
-                                       reg, writemask[1],
-                                       reg, writemask[1]);
-                        break;
-
-                        /* Should not occur, since it's at minimum '.' and a letter */
-                    case 1:
-                        ERR("Unexpected writemask: \"%s\"\n", writemask);
-                        break;
-
-                    case 5:
-                    default:
-                        shader_addline(buffer, "MAD %s, %s, coefmul.x, -one;\n", reg, reg);
-                }
-            }
-            break;
-
-        case WINED3DFMT_ATI2N:
-            /* GL_ATI_texture_compression_3dc returns the two channels as luminance-alpha,
-             * which means the first one is replicated across .rgb, and the 2nd one is in
-             * .a. We need the 2nd in .g
-             *
-             * GL_EXT_texture_compression_rgtc returns the values in .rg, however, they
-             * are swapped compared to d3d. So swap red and green.
-             */
-            if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {
-                shader_addline(buffer, "SWZ %s, %s, %c, %c, 1, 0;\n",
-                               reg, reg, writemask[2], writemask[1]);
-            } else {
-                if(strlen(writemask) == 5) {
-                    shader_addline(buffer, "MOV %s.%c, %s.%c;\n",
-                                reg, writemask[2], reg, writemask[4]);
-                } else if(strlen(writemask) == 2) {
-                    /* Nothing to do */
-                } else {
-                    /* This is bad: We have VL, but we need VU */
-                    FIXME("2 or 3 components sampled from a converted ATI2N texture\n");
-                }
-            }
-            break;
-
-            /* stupid compiler */
+static const char *shader_arb_get_fixup_swizzle(enum fixup_channel_source channel_source)
+{
+    switch(channel_source)
+    {
+        case CHANNEL_SOURCE_ZERO: return "0";
+        case CHANNEL_SOURCE_ONE: return "1";
+        case CHANNEL_SOURCE_X: return "x";
+        case CHANNEL_SOURCE_Y: return "y";
+        case CHANNEL_SOURCE_Z: return "z";
+        case CHANNEL_SOURCE_W: return "w";
         default:
-            break;
+            FIXME("Unhandled channel source %#x\n", channel_source);
+            return "undefined";
     }
 }
 
-static void shader_arb_color_correction(SHADER_OPCODE_ARG* arg) {
-    IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) shader->baseShader.device;
-    WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
-    WINED3DFORMAT fmt;
-    WINED3DFORMAT conversion_group;
-    IWineD3DBaseTextureImpl *texture;
-    UINT i;
-    BOOL recorded = FALSE;
-    DWORD sampler_idx;
-    DWORD hex_version = shader->baseShader.hex_version;
-    char reg[256];
-    char writemask[6];
+static void gen_color_correction(SHADER_BUFFER *buffer, const char *reg, DWORD dst_mask,
+        const char *one, const char *two, struct color_fixup_desc fixup)
+{
+    DWORD mask;
 
-    switch(arg->opcode->opcode) {
-        case WINED3DSIO_TEX:
-            if (hex_version < WINED3DPS_VERSION(2,0)) {
-                sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
-            } else {
-                sampler_idx = arg->src[1] & WINED3DSP_REGNUM_MASK;
-            }
-            break;
+    if (is_yuv_fixup(fixup))
+    {
+        enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup);
+        FIXME("YUV fixup (%#x) not supported\n", yuv_fixup);
+        return;
+    }
 
-        case WINED3DSIO_TEXLDL:
-            FIXME("Add color fixup for vertex texture WINED3DSIO_TEXLDL\n");
-            return;
+    mask = 0;
+    if (fixup.x_source != CHANNEL_SOURCE_X) mask |= WINED3DSP_WRITEMASK_0;
+    if (fixup.y_source != CHANNEL_SOURCE_Y) mask |= WINED3DSP_WRITEMASK_1;
+    if (fixup.z_source != CHANNEL_SOURCE_Z) mask |= WINED3DSP_WRITEMASK_2;
+    if (fixup.w_source != CHANNEL_SOURCE_W) mask |= WINED3DSP_WRITEMASK_3;
+    mask &= dst_mask;
 
-        case WINED3DSIO_TEXDP3TEX:
-        case WINED3DSIO_TEXM3x3TEX:
-        case WINED3DSIO_TEXM3x3SPEC:
-        case WINED3DSIO_TEXM3x3VSPEC:
-        case WINED3DSIO_TEXBEM:
-        case WINED3DSIO_TEXREG2AR:
-        case WINED3DSIO_TEXREG2GB:
-        case WINED3DSIO_TEXREG2RGB:
-            sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
-            break;
+    if (mask)
+    {
+        shader_addline(buffer, "SWZ %s, %s, %s, %s, %s, %s;\n", reg, reg,
+                shader_arb_get_fixup_swizzle(fixup.x_source), shader_arb_get_fixup_swizzle(fixup.y_source),
+                shader_arb_get_fixup_swizzle(fixup.z_source), shader_arb_get_fixup_swizzle(fixup.w_source));
+    }
 
-        default:
-            /* Not a texture sampling instruction, nothing to do */
-            return;
-    };
+    mask = 0;
+    if (fixup.x_sign_fixup) mask |= WINED3DSP_WRITEMASK_0;
+    if (fixup.y_sign_fixup) mask |= WINED3DSP_WRITEMASK_1;
+    if (fixup.z_sign_fixup) mask |= WINED3DSP_WRITEMASK_2;
+    if (fixup.w_sign_fixup) mask |= WINED3DSP_WRITEMASK_3;
+    mask &= dst_mask;
 
-    texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler_idx];
-    if(texture) {
-        fmt = texture->resource.format;
-        conversion_group = texture->baseTexture.shader_conversion_group;
-    } else {
-        fmt = WINED3DFMT_UNKNOWN;
-        conversion_group = WINED3DFMT_UNKNOWN;
-    }
+    if (mask)
+    {
+        char reg_mask[6];
+        char *ptr = reg_mask;
 
-    /* before doing anything, record the sampler with the format in the format conversion list,
-     * but check if it's not there already
-     */
-    for(i = 0; i < shader->baseShader.num_sampled_samplers; i++) {
-        if(shader->baseShader.sampled_samplers[i] == sampler_idx) {
-            recorded = TRUE;
+        if (mask != WINED3DSP_WRITEMASK_ALL)
+        {
+            *ptr++ = '.';
+            if (mask & WINED3DSP_WRITEMASK_0) *ptr++ = 'x';
+            if (mask & WINED3DSP_WRITEMASK_1) *ptr++ = 'y';
+            if (mask & WINED3DSP_WRITEMASK_2) *ptr++ = 'z';
+            if (mask & WINED3DSP_WRITEMASK_3) *ptr++ = 'w';
         }
+        *ptr = '\0';
+
+        shader_addline(buffer, "MAD %s%s, %s, %s, -%s;\n", reg, reg_mask, reg, two, one);
     }
-    if(!recorded) {
-        shader->baseShader.sampled_samplers[shader->baseShader.num_sampled_samplers] = sampler_idx;
-        shader->baseShader.num_sampled_samplers++;
-        shader->baseShader.sampled_format[sampler_idx] = conversion_group;
-    }
+}
 
+static void shader_arb_color_correction(const struct SHADER_OPCODE_ARG* arg, struct color_fixup_desc fixup)
+{
+    char reg[256];
     pshader_get_register_name(arg->shader, arg->dst, reg);
-    shader_arb_get_write_mask(arg, arg->dst, writemask);
-    if(strlen(writemask) == 0) strcpy(writemask, ".xyzw");
-
-    gen_color_correction(arg->buffer, reg, writemask, "one", "coefmul.x", fmt, gl_info);
-
+    gen_color_correction(arg->buffer, reg, arg->dst & WINED3DSP_WRITEMASK_ALL, "one", "coefmul.x", fixup);
 }
 
-
 static void pshader_gen_input_modifier_line (
     IWineD3DBaseShader *iface,
     SHADER_BUFFER* buffer,
@@ -943,19 +738,16 @@ static void pshader_gen_input_modifier_line (
         sprintf(outregstr, "T%c%s", 'A' + tmpreg, swzstr);
 }
 
-static inline void pshader_gen_output_modifier_line(
-    SHADER_BUFFER* buffer,
-    int saturate,
-    char *write_mask,
-    int shift,
-    char *regstr) {
-
+static inline void pshader_gen_output_modifier_line(SHADER_BUFFER *buffer, int saturate, const char *write_mask,
+        int shift, const char *regstr)
+{
     /* Generate a line that does the output modifier computation */
     shader_addline(buffer, "MUL%s %s%s, %s, %s;\n", saturate ? "_SAT" : "",
         regstr, write_mask, regstr, shift_tab[shift]);
 }
 
-static void pshader_hw_bem(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_bem(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
 
     SHADER_BUFFER* buffer = arg->buffer;
@@ -993,8 +785,8 @@ static void pshader_hw_bem(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void pshader_hw_cnd(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_cnd(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
     SHADER_BUFFER* buffer = arg->buffer;
     char dst_wmask[20];
@@ -1027,8 +819,8 @@ static void pshader_hw_cnd(SHADER_OPCODE_ARG* arg) {
         pshader_gen_output_modifier_line(buffer, FALSE, dst_wmask, shift, dst_name);
 }
 
-static void pshader_hw_cmp(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_cmp(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     char dst_wmask[20];
     char dst_name[50];
@@ -1056,7 +848,8 @@ static void pshader_hw_cmp(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_DP2ADD instruction in ARB.
  * dst = dot2(src0, src1) + src2 */
-static void pshader_hw_dp2add(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_dp2add(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     char dst_wmask[20];
     char dst_name[50];
@@ -1082,13 +875,13 @@ static void pshader_hw_dp2add(SHADER_OPCODE_ARG* arg) {
 }
 
 /* Map the opcode 1-to-1 to the GL code */
-static void shader_hw_map2gl(SHADER_OPCODE_ARG* arg)
+static void shader_hw_map2gl(const SHADER_OPCODE_ARG *arg)
 {
     IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl*)arg->shader;
     CONST SHADER_OPCODE* curOpcode = arg->opcode;
     SHADER_BUFFER* buffer = arg->buffer;
     DWORD dst = arg->dst;
-    DWORD* src = arg->src;
+    const DWORD *src = arg->src;
     char arguments[256];
     unsigned int i;
 
@@ -1166,7 +959,7 @@ static void shader_hw_map2gl(SHADER_OPCODE_ARG* arg)
     }
 }
 
-static void shader_hw_mov(SHADER_OPCODE_ARG *arg)
+static void shader_hw_mov(const SHADER_OPCODE_ARG *arg)
 {
     IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl*)arg->shader;
 
@@ -1213,7 +1006,8 @@ static void shader_hw_mov(SHADER_OPCODE_ARG *arg)
     }
 }
 
-static void pshader_hw_texkill(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_texkill(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     DWORD hex_version = This->baseShader.hex_version;
     SHADER_BUFFER* buffer = arg->buffer;
@@ -1237,12 +1031,13 @@ static void pshader_hw_texkill(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void pshader_hw_tex(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_tex(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
 
     DWORD dst = arg->dst;
-    DWORD* src = arg->src;
+    const DWORD *src = arg->src;
     SHADER_BUFFER* buffer = arg->buffer;
     DWORD hex_version = This->baseShader.hex_version;
     BOOL projected = FALSE, bias = FALSE;
@@ -1301,8 +1096,8 @@ static void pshader_hw_tex(SHADER_OPCODE_ARG* arg) {
   shader_hw_sample(arg, reg_sampler_code, reg_dest, reg_coord, projected, bias);
 }
 
-static void pshader_hw_texcoord(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texcoord(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     DWORD dst = arg->dst;
     SHADER_BUFFER* buffer = arg->buffer;
@@ -1322,8 +1117,8 @@ static void pshader_hw_texcoord(SHADER_OPCODE_ARG* arg) {
    }
 }
 
-static void pshader_hw_texreg2ar(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texreg2ar(const SHADER_OPCODE_ARG *arg)
+{
      SHADER_BUFFER* buffer = arg->buffer;
      IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
      IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
@@ -1341,8 +1136,8 @@ static void pshader_hw_texreg2ar(SHADER_OPCODE_ARG* arg) {
      shader_hw_sample(arg, reg1, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
 }
 
-static void pshader_hw_texreg2gb(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texreg2gb(const SHADER_OPCODE_ARG *arg)
+{
      SHADER_BUFFER* buffer = arg->buffer;
 
      DWORD reg1 = arg->dst & WINED3DSP_REGNUM_MASK;
@@ -1356,8 +1151,8 @@ static void pshader_hw_texreg2gb(SHADER_OPCODE_ARG* arg) {
      shader_hw_sample(arg, reg1, dst_str, "TMP", FALSE, FALSE);
 }
 
-static void pshader_hw_texreg2rgb(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texreg2rgb(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     DWORD reg1 = arg->dst & WINED3DSP_REGNUM_MASK;
     char dst_str[8];
@@ -1368,7 +1163,8 @@ static void pshader_hw_texreg2rgb(SHADER_OPCODE_ARG* arg) {
     shader_hw_sample(arg, reg1, dst_str, src_str, FALSE, FALSE);
 }
 
-static void pshader_hw_texbem(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_texbem(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     BOOL has_bumpmat = FALSE;
     BOOL has_luminance = FALSE;
@@ -1439,8 +1235,8 @@ static void pshader_hw_texbem(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void pshader_hw_texm3x2pad(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texm3x2pad(const SHADER_OPCODE_ARG *arg)
+{
     DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
     SHADER_BUFFER* buffer = arg->buffer;
     char src0_name[50];
@@ -1449,8 +1245,8 @@ static void pshader_hw_texm3x2pad(SHADER_OPCODE_ARG* arg) {
     shader_addline(buffer, "DP3 TMP.x, T%u, %s;\n", reg, src0_name);
 }
 
-static void pshader_hw_texm3x2tex(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texm3x2tex(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     DWORD flags;
@@ -1466,8 +1262,8 @@ static void pshader_hw_texm3x2tex(SHADER_OPCODE_ARG* arg) {
     shader_hw_sample(arg, reg, dst_str, "TMP", flags & WINED3DTTFF_PROJECTED, FALSE);
 }
 
-static void pshader_hw_texm3x3pad(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texm3x3pad(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
     SHADER_BUFFER* buffer = arg->buffer;
@@ -1479,8 +1275,8 @@ static void pshader_hw_texm3x3pad(SHADER_OPCODE_ARG* arg) {
     current_state->texcoord_w[current_state->current_row++] = reg;
 }
 
-static void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texm3x3tex(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     DWORD flags;
@@ -1500,8 +1296,8 @@ static void pshader_hw_texm3x3tex(SHADER_OPCODE_ARG* arg) {
     current_state->current_row = 0;
 }
 
-static void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texm3x3vspec(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     DWORD flags;
@@ -1536,8 +1332,8 @@ static void pshader_hw_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
     current_state->current_row = 0;
 }
 
-static void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_hw_texm3x3spec(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     DWORD flags;
@@ -1573,7 +1369,8 @@ static void pshader_hw_texm3x3spec(SHADER_OPCODE_ARG* arg) {
     current_state->current_row = 0;
 }
 
-static void pshader_hw_texdepth(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_texdepth(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     char dst_name[50];
 
@@ -1602,7 +1399,8 @@ static void pshader_hw_texdepth(SHADER_OPCODE_ARG* arg) {
 /** Process the WINED3DSIO_TEXDP3TEX instruction in ARB:
  * Take a 3-component dot product of the TexCoord[dstreg] and src,
  * then perform a 1D texture lookup from stage dstregnum, place into dst. */
-static void pshader_hw_texdp3tex(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_texdp3tex(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     DWORD sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
     char src0[50];
@@ -1618,7 +1416,8 @@ static void pshader_hw_texdp3tex(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXDP3 instruction in ARB:
  * Take a 3-component dot product of the TexCoord[dstreg] and src. */
-static void pshader_hw_texdp3(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_texdp3(const SHADER_OPCODE_ARG *arg)
+{
     char src0[50];
     char dst_str[50];
     char dst_mask[6];
@@ -1637,7 +1436,8 @@ static void pshader_hw_texdp3(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXM3X3 instruction in ARB
  * Perform the 3rd row of a 3x3 matrix multiply */
-static void pshader_hw_texm3x3(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_texm3x3(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     char dst_str[50];
     char dst_mask[6];
@@ -1659,7 +1459,8 @@ static void pshader_hw_texm3x3(SHADER_OPCODE_ARG* arg) {
  * Calculate tmp0.y = TexCoord[dstreg] . src.xyz;  (tmp0.x has already been calculated)
  * depth = (tmp0.y == 0.0) ? 1.0 : tmp0.x / tmp0.y
  */
-static void pshader_hw_texm3x2depth(SHADER_OPCODE_ARG* arg) {
+static void pshader_hw_texm3x2depth(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     DWORD dst_reg = arg->dst & WINED3DSP_REGNUM_MASK;
     char src0[50];
@@ -1679,11 +1480,14 @@ static void pshader_hw_texm3x2depth(SHADER_OPCODE_ARG* arg) {
 
 /** Handles transforming all WINED3DSIO_M?x? opcodes for
     Vertex/Pixel shaders to ARB_vertex_program codes */
-static void shader_hw_mnxn(SHADER_OPCODE_ARG* arg) {
-
+static void shader_hw_mnxn(const SHADER_OPCODE_ARG *arg)
+{
     int i;
     int nComponents = 0;
     SHADER_OPCODE_ARG tmpArg;
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)arg->shader;
+    const SHADER_OPCODE *opcode_table = shader->baseShader.shader_ins;
+    DWORD shader_version = shader->baseShader.hex_version;
 
     memset(&tmpArg, 0, sizeof(SHADER_OPCODE_ARG));
 
@@ -1698,23 +1502,23 @@ static void shader_hw_mnxn(SHADER_OPCODE_ARG* arg) {
     switch(arg->opcode->opcode) {
     case WINED3DSIO_M4x4:
         nComponents = 4;
-        tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP4);
+        tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
         break;
     case WINED3DSIO_M4x3:
         nComponents = 3;
-        tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP4);
+        tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
         break;
     case WINED3DSIO_M3x4:
         nComponents = 4;
-        tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP3);
+        tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
         break;
     case WINED3DSIO_M3x3:
         nComponents = 3;
-        tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP3);
+        tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
         break;
     case WINED3DSIO_M3x2:
         nComponents = 2;
-        tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP3);
+        tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
         break;
     default:
         break;
@@ -1727,7 +1531,8 @@ static void shader_hw_mnxn(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void vshader_hw_rsq_rcp(SHADER_OPCODE_ARG* arg) {
+static void vshader_hw_rsq_rcp(const SHADER_OPCODE_ARG *arg)
+{
     CONST SHADER_OPCODE* curOpcode = arg->opcode;
     SHADER_BUFFER* buffer = arg->buffer;
     DWORD dst = arg->dst;
@@ -1750,7 +1555,8 @@ static void vshader_hw_rsq_rcp(SHADER_OPCODE_ARG* arg) {
     shader_addline(buffer, "%s;\n", tmpLine);
 }
 
-static void shader_hw_nrm(SHADER_OPCODE_ARG* arg) {
+static void shader_hw_nrm(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     char dst_name[50];
     char src_name[50];
@@ -1772,7 +1578,8 @@ static void shader_hw_nrm(SHADER_OPCODE_ARG* arg) {
         pshader_gen_output_modifier_line(buffer, FALSE, dst_wmask, shift, dst_name);
 }
 
-static void shader_hw_sincos(SHADER_OPCODE_ARG* arg) {
+static void shader_hw_sincos(const SHADER_OPCODE_ARG *arg)
+{
     /* This instruction exists in ARB, but the d3d instruction takes two extra parameters which
      * must contain fixed constants. So we need a separate function to filter those constants and
      * can't use map2gl
@@ -1796,7 +1603,8 @@ static void shader_hw_sincos(SHADER_OPCODE_ARG* arg) {
 
 }
 
-static GLuint create_arb_blt_vertex_program(WineD3D_GL_Info *gl_info) {
+static GLuint create_arb_blt_vertex_program(const WineD3D_GL_Info *gl_info)
+{
     GLuint program_id = 0;
     const char *blt_vprogram =
         "!!ARBvp1.0\n"
@@ -1820,7 +1628,7 @@ static GLuint create_arb_blt_vertex_program(WineD3D_GL_Info *gl_info) {
     return program_id;
 }
 
-static GLuint create_arb_blt_fragment_program(WineD3D_GL_Info *gl_info, enum tex_types tex_type)
+static GLuint create_arb_blt_fragment_program(const WineD3D_GL_Info *gl_info, enum tex_types tex_type)
 {
     GLuint program_id = 0;
     const char *blt_fprograms[tex_type_count] =
@@ -1872,12 +1680,13 @@ static GLuint create_arb_blt_fragment_program(WineD3D_GL_Info *gl_info, enum tex
 static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct shader_arb_priv *priv = (struct shader_arb_priv *) This->shader_priv;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
 
     if (useVS) {
         TRACE("Using vertex shader\n");
+        IWineD3DVertexShaderImpl_CompileShader(This->stateBlock->vertexShader);
 
-        priv->current_vprogram_id = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.prgId;
+        priv->current_vprogram_id = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->prgId;
 
         /* Bind the vertex program */
         GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id));
@@ -1894,9 +1703,11 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
     }
 
     if (usePS) {
+        struct ps_compile_args compile_args;
         TRACE("Using pixel shader\n");
-
-        priv->current_fprogram_id = ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.prgId;
+        find_ps_compile_args((IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader, This->stateBlock, &compile_args);
+        priv->current_fprogram_id = find_gl_pshader((IWineD3DPixelShaderImpl *) This->stateBlock->pixelShader,
+                                                    &compile_args);
 
         /* Bind the fragment program */
         GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, priv->current_fprogram_id));
@@ -1923,7 +1734,7 @@ static void shader_arb_select_depth_blt(IWineD3DDevice *iface, enum tex_types te
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct shader_arb_priv *priv = (struct shader_arb_priv *) This->shader_priv;
     GLuint *blt_fprogram = &priv->depth_blt_fprogram_id[tex_type];
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
 
     if (!priv->depth_blt_vprogram_id) priv->depth_blt_vprogram_id = create_arb_blt_vertex_program(gl_info);
     GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->depth_blt_vprogram_id));
@@ -1937,7 +1748,7 @@ static void shader_arb_select_depth_blt(IWineD3DDevice *iface, enum tex_types te
 static void shader_arb_deselect_depth_blt(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct shader_arb_priv *priv = (struct shader_arb_priv *) This->shader_priv;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
 
     if (priv->current_vprogram_id) {
         GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, priv->current_vprogram_id));
@@ -1968,21 +1779,39 @@ static void shader_arb_deselect_depth_blt(IWineD3DDevice *iface) {
 
 static void shader_arb_cleanup(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
     if (GL_SUPPORT(ARB_VERTEX_PROGRAM)) glDisable(GL_VERTEX_PROGRAM_ARB);
     if (GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) glDisable(GL_FRAGMENT_PROGRAM_ARB);
 }
 
 static void shader_arb_destroy(IWineD3DBaseShader *iface) {
-    IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) iface;
-    WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *) This->baseShader.device)->adapter->gl_info;
+    IWineD3DBaseShaderImpl *baseShader = (IWineD3DBaseShaderImpl *) iface;
+    const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)baseShader->baseShader.device)->adapter->gl_info;
+    char pshader = shader_is_pshader_version(baseShader->baseShader.hex_version);
 
-    ENTER_GL();
-    GL_EXTCALL(glDeleteProgramsARB(1, &This->baseShader.prgId));
-    checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &This->baseShader.prgId))");
-    LEAVE_GL();
-    This->baseShader.prgId = 0;
-    This->baseShader.is_compiled = FALSE;
+    if(pshader) {
+        IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface;
+        UINT i;
+
+        ENTER_GL();
+        for(i = 0; i < This->num_gl_shaders; i++) {
+            GL_EXTCALL(glDeleteProgramsARB(1, &This->gl_shaders[i].prgId));
+            checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &This->gl_shaders[i].prgId))");
+        }
+        LEAVE_GL();
+        HeapFree(GetProcessHeap(), 0, This->gl_shaders);
+        This->gl_shaders = NULL;
+        This->num_gl_shaders = 0;
+    } else {
+        IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface;
+
+        ENTER_GL();
+        GL_EXTCALL(glDeleteProgramsARB(1, &This->prgId));
+        checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &This->prgId))");
+        ((IWineD3DVertexShaderImpl *) This)->prgId = 0;
+        LEAVE_GL();
+    }
+    baseShader->baseShader.is_compiled = FALSE;
 }
 
 static HRESULT shader_arb_alloc(IWineD3DDevice *iface) {
@@ -1993,7 +1822,7 @@ static HRESULT shader_arb_alloc(IWineD3DDevice *iface) {
 
 static void shader_arb_free(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
     struct shader_arb_priv *priv = (struct shader_arb_priv *) This->shader_priv;
     int i;
 
@@ -2035,13 +1864,14 @@ static void arbfp_add_sRGB_correction(SHADER_BUFFER *buffer, const char *fragcol
     /* [0.0;1.0] clamping. Not needed, this is done implicitly */
 }
 
-static void shader_arb_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
+static GLuint shader_arb_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
     IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
-    shader_reg_maps* reg_maps = &This->baseShader.reg_maps;
+    const shader_reg_maps* reg_maps = &This->baseShader.reg_maps;
     CONST DWORD *function = This->baseShader.function;
     const char *fragcolor;
-    WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
-    local_constant* lconst;
+    const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
+    const local_constant *lconst;
+    GLuint retval;
 
     /*  Create the hw ARB shader */
     shader_addline(buffer, "!!ARBfp1.0\n");
@@ -2078,7 +1908,7 @@ static void shader_arb_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFE
     } else {
         fragcolor = "TMP_COLOR";
     }
-    if(This->srgb_enabled) {
+    if(((IWineD3DDeviceImpl *)This->baseShader.device)->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE]) {
         arbfp_add_sRGB_correction(buffer, fragcolor, "TMP", "TMP2", "TA", "TB");
     }
     if (This->baseShader.hex_version < WINED3DPS_VERSION(3,0)) {
@@ -2089,12 +1919,12 @@ static void shader_arb_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFE
     shader_addline(buffer, "END\n");
 
     /* TODO: change to resource.glObjectHandle or something like that */
-    GL_EXTCALL(glGenProgramsARB(1, &This->baseShader.prgId));
+    GL_EXTCALL(glGenProgramsARB(1, &retval));
 
-    TRACE("Creating a hw pixel shader, prg=%d\n", This->baseShader.prgId);
-    GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, This->baseShader.prgId));
+    TRACE("Creating a hw pixel shader, prg=%d\n", retval);
+    GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, retval));
 
-    TRACE("Created hw pixel shader, prg=%d\n", This->baseShader.prgId);
+    TRACE("Created hw pixel shader, prg=%d\n", retval);
     /* Create the program and check for errors */
     GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
                buffer->bsize, buffer->buffer));
@@ -2104,26 +1934,28 @@ static void shader_arb_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFE
         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
         FIXME("HW PixelShader Error at position %d: %s\n",
               errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
-        This->baseShader.prgId = -1;
+        retval = 0;
     }
 
     /* Load immediate constants */
     if(!This->baseShader.load_local_constsF) {
         LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
-            float *value = (float *) lconst->value;
+            const float *value = (const float *)lconst->value;
             GL_EXTCALL(glProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, lconst->idx, value));
             checkGLcall("glProgramLocalParameter4fvARB");
         }
     }
+
+    return retval;
 }
 
 static void shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer) {
     IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
-    shader_reg_maps* reg_maps = &This->baseShader.reg_maps;
+    const shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
     CONST DWORD *function = This->baseShader.function;
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
-    WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
-    local_constant* lconst;
+    const WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
+    const local_constant *lconst;
 
     /*  Create the hw ARB shader */
     shader_addline(buffer, "!!ARBvp1.0\n");
@@ -2195,12 +2027,12 @@ static void shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFF
     shader_addline(buffer, "END\n");
 
     /* TODO: change to resource.glObjectHandle or something like that */
-    GL_EXTCALL(glGenProgramsARB(1, &This->baseShader.prgId));
+    GL_EXTCALL(glGenProgramsARB(1, &This->prgId));
 
-    TRACE("Creating a hw vertex shader, prg=%d\n", This->baseShader.prgId);
-    GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, This->baseShader.prgId));
+    TRACE("Creating a hw vertex shader, prg=%d\n", This->prgId);
+    GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, This->prgId));
 
-    TRACE("Created hw vertex shader, prg=%d\n", This->baseShader.prgId);
+    TRACE("Created hw vertex shader, prg=%d\n", This->prgId);
     /* Create the program and check for errors */
     GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
                buffer->bsize, buffer->buffer));
@@ -2210,19 +2042,20 @@ static void shader_arb_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFF
         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
         FIXME("HW VertexShader Error at position %d: %s\n",
               errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
-        This->baseShader.prgId = -1;
+        This->prgId = -1;
     }
 
     /* Load immediate constants */
     if(!This->baseShader.load_local_constsF) {
         LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
-            float *value = (float *) lconst->value;
+            const float *value = (const float *)lconst->value;
             GL_EXTCALL(glProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, lconst->idx, value));
         }
     }
 }
 
-static void shader_arb_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) {
+static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps)
+{
     /* We don't have an ARB fixed function pipeline yet, so let the none backend set its caps,
      * then overwrite the shader specific ones
      */
@@ -2241,21 +2074,23 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info
     }
 }
 
-static BOOL shader_arb_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt));
-    switch(fmt) {
-        case WINED3DFMT_V8U8:
-        case WINED3DFMT_V16U16:
-        case WINED3DFMT_X8L8V8U8:
-        case WINED3DFMT_L6V5U5:
-        case WINED3DFMT_Q8W8V8U8:
-        case WINED3DFMT_ATI2N:
-            TRACE("[OK]\n");
-            return TRUE;
-        default:
-            TRACE("[FAILED\n");
-            return FALSE;
+static BOOL shader_arb_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
+    {
+        TRACE("Checking support for color_fixup:\n");
+        dump_color_fixup_desc(fixup);
+    }
+
+    /* We support everything except YUV conversions. */
+    if (!is_yuv_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
     }
+
+    TRACE("[FAILED]\n");
+    return FALSE;
 }
 
 static const SHADER_HANDLER shader_arb_instruction_handler_table[WINED3DSIH_TABLE_SIZE] =
@@ -2360,7 +2195,7 @@ const shader_backend_t arb_program_shader_backend = {
     shader_arb_generate_pshader,
     shader_arb_generate_vshader,
     shader_arb_get_caps,
-    shader_arb_conv_supported,
+    shader_arb_color_fixup_supported,
 };
 
 /* ARB_fragment_program fixed function pipeline replacement definitions */
@@ -2407,7 +2242,7 @@ static HRESULT arbfp_alloc(IWineD3DDevice *iface) {
 }
 
 static void arbfp_free_ffpshader(void *value, void *gli) {
-    WineD3D_GL_Info *gl_info = gli;
+    const WineD3D_GL_Info *gl_info = gli;
     struct arbfp_ffp_desc *entry_arb = value;
 
     ENTER_GL();
@@ -2429,7 +2264,8 @@ static void arbfp_free(IWineD3DDevice *iface) {
     }
 }
 
-static void arbfp_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *caps) {
+static void arbfp_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *caps)
+{
     caps->TextureOpCaps =  WINED3DTEXOPCAPS_DISABLE                     |
                            WINED3DTEXOPCAPS_SELECTARG1                  |
                            WINED3DTEXOPCAPS_SELECTARG2                  |
@@ -2792,7 +2628,8 @@ static void gen_ffp_instr(SHADER_BUFFER *buffer, unsigned int stage, BOOL color,
 }
 
 /* The stateblock is passed for GLINFO_LOCATION */
-static GLuint gen_arbfp_ffp_shader(struct ffp_frag_settings *settings, IWineD3DStateBlockImpl *stateblock) {
+static GLuint gen_arbfp_ffp_shader(const struct ffp_frag_settings *settings, IWineD3DStateBlockImpl *stateblock)
+{
     unsigned int stage;
     SHADER_BUFFER buffer;
     BOOL tex_read[MAX_TEXTURES] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE};
@@ -2976,8 +2813,8 @@ static GLuint gen_arbfp_ffp_shader(struct ffp_frag_settings *settings, IWineD3DS
         }
 
         sprintf(colorcor_dst, "tex%u", stage);
-        gen_color_correction(&buffer, colorcor_dst, ".rgba", "const.x", "const.y",
-                                settings->op[stage].color_correction, &GLINFO_LOCATION);
+        gen_color_correction(&buffer, colorcor_dst, WINED3DSP_WRITEMASK_ALL, "const.x", "const.y",
+                settings->op[stage].color_correction);
     }
 
     /* Generate the main shader */
@@ -3061,13 +2898,11 @@ static void fragment_prog_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock,
     BOOL use_pshader = use_ps(device);
     BOOL use_vshader = use_vs(device);
     struct ffp_frag_settings settings;
-    struct arbfp_ffp_desc *desc;
+    const struct arbfp_ffp_desc *desc;
     unsigned int i;
 
     if(isStateDirty(context, STATE_RENDER(WINED3DRS_FOGENABLE))) {
-        if(use_pshader) {
-            IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
-        } else if(device->shader_backend == &arb_program_shader_backend && context->last_was_pshader) {
+        if(!use_pshader && device->shader_backend == &arb_program_shader_backend && context->last_was_pshader) {
             /* Reload fixed function constants since they collide with the pixel shader constants */
             for(i = 0; i < MAX_TEXTURES; i++) {
                 set_bumpmat_arbfp(STATE_TEXTURESTAGE(i, WINED3DTSS_BUMPENVMAT00), stateblock, context);
@@ -3078,28 +2913,28 @@ static void fragment_prog_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock,
         return;
     }
 
-    if(use_pshader) {
-        IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
-    } else {
+    if(!use_pshader) {
         /* Find or create a shader implementing the fixed function pipeline settings, then activate it */
         gen_ffp_frag_op(stateblock, &settings, FALSE);
-        desc = (struct arbfp_ffp_desc *) find_ffp_frag_shader(priv->fragment_shaders, &settings);
+        desc = (const struct arbfp_ffp_desc *)find_ffp_frag_shader(priv->fragment_shaders, &settings);
         if(!desc) {
-            desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*desc));
-            if(!desc) {
+            struct arbfp_ffp_desc *new_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_desc));
+            if (!new_desc)
+            {
                 ERR("Out of memory\n");
                 return;
             }
-            desc->num_textures_used = 0;
+            new_desc->num_textures_used = 0;
             for(i = 0; i < GL_LIMITS(texture_stages); i++) {
                 if(settings.op[i].cop == WINED3DTOP_DISABLE) break;
-                desc->num_textures_used = i;
+                new_desc->num_textures_used = i;
             }
 
-            memcpy(&desc->parent.settings, &settings, sizeof(settings));
-            desc->shader = gen_arbfp_ffp_shader(&settings, stateblock);
-            add_ffp_frag_shader(priv->fragment_shaders, &desc->parent);
-            TRACE("Allocated fixed function replacement shader descriptor %p\n", desc);
+            memcpy(&new_desc->parent.settings, &settings, sizeof(settings));
+            new_desc->shader = gen_arbfp_ffp_shader(&settings, stateblock);
+            add_ffp_frag_shader(priv->fragment_shaders, &new_desc->parent);
+            TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
+            desc = new_desc;
         }
 
         /* Now activate the replacement program. GL_FRAGMENT_PROGRAM_ARB is already active(however, note the
@@ -3313,7 +3148,7 @@ const struct fragment_pipeline arbfp_fragment_pipeline = {
     arbfp_get_caps,
     arbfp_alloc,
     arbfp_free,
-    shader_arb_conv_supported,
+    shader_arb_color_fixup_supported,
     arbfp_fragmentstate_template,
     TRUE /* We can disable projected textures */
 };
@@ -3350,11 +3185,12 @@ static void arbfp_blit_free(IWineD3DDevice *iface) {
     LEAVE_GL();
 }
 
-static BOOL gen_planar_yuv_read(SHADER_BUFFER *buffer, WINED3DFORMAT fmt, GLenum textype, char *luminance) {
+static BOOL gen_planar_yuv_read(SHADER_BUFFER *buffer, enum yuv_fixup yuv_fixup, GLenum textype, char *luminance)
+{
     char chroma;
     const char *tex, *texinstr;
 
-    if(fmt == WINED3DFMT_UYVY) {
+    if (yuv_fixup == YUV_FIXUP_UYVY) {
         chroma = 'r';
         *luminance = 'a';
     } else {
@@ -3436,7 +3272,8 @@ static BOOL gen_planar_yuv_read(SHADER_BUFFER *buffer, WINED3DFORMAT fmt, GLenum
     return TRUE;
 }
 
-static BOOL gen_yv12_read(SHADER_BUFFER *buffer, WINED3DFORMAT fmt, GLenum textype, char *luminance) {
+static BOOL gen_yv12_read(SHADER_BUFFER *buffer, GLenum textype, char *luminance)
+{
     const char *tex;
 
     switch(textype) {
@@ -3581,7 +3418,8 @@ static BOOL gen_yv12_read(SHADER_BUFFER *buffer, WINED3DFORMAT fmt, GLenum texty
     return TRUE;
 }
 
-static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, WINED3DFORMAT fmt, GLenum textype) {
+static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, enum yuv_fixup yuv_fixup, GLenum textype)
+{
     GLenum shader;
     SHADER_BUFFER buffer;
     char luminance_component;
@@ -3649,16 +3487,29 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, WINED3DFORMAT fmt, GLen
     shader_addline(&buffer, "PARAM yuv_coef = {1.403, 0.344, 0.714, 1.770};\n");
     shader_addline(&buffer, "PARAM size = program.local[0];\n");
 
-    if(fmt == WINED3DFMT_UYVY || fmt ==WINED3DFMT_YUY2) {
-        if(gen_planar_yuv_read(&buffer, fmt, textype, &luminance_component) == FALSE) {
-            HeapFree(GetProcessHeap(), 0, buffer.buffer);
-            return 0;
-        }
-    } else {
-        if(gen_yv12_read(&buffer, fmt, textype, &luminance_component) == FALSE) {
+    switch (yuv_fixup)
+    {
+        case YUV_FIXUP_UYVY:
+        case YUV_FIXUP_YUY2:
+            if (!gen_planar_yuv_read(&buffer, yuv_fixup, textype, &luminance_component))
+            {
+                HeapFree(GetProcessHeap(), 0, buffer.buffer);
+                return 0;
+            }
+            break;
+
+        case YUV_FIXUP_YV12:
+            if (!gen_yv12_read(&buffer, textype, &luminance_component))
+            {
+                HeapFree(GetProcessHeap(), 0, buffer.buffer);
+                return 0;
+            }
+            break;
+
+        default:
+            FIXME("Unsupported YUV fixup %#x\n", yuv_fixup);
             HeapFree(GetProcessHeap(), 0, buffer.buffer);
             return 0;
-        }
     }
 
     /* Calculate the final result. Formula is taken from
@@ -3685,25 +3536,24 @@ static GLuint gen_yuv_shader(IWineD3DDeviceImpl *device, WINED3DFORMAT fmt, GLen
     HeapFree(GetProcessHeap(), 0, buffer.buffer);
     LEAVE_GL();
 
-    if(fmt == WINED3DFMT_YUY2) {
-        if(textype == GL_TEXTURE_RECTANGLE_ARB) {
-            priv->yuy2_rect_shader = shader;
-        } else {
-            priv->yuy2_2d_shader = shader;
-        }
-    } else if(fmt == WINED3DFMT_UYVY) {
-        if(textype == GL_TEXTURE_RECTANGLE_ARB) {
-            priv->uyvy_rect_shader = shader;
-        } else {
-            priv->uyvy_2d_shader = shader;
-        }
-    } else {
-        if(textype == GL_TEXTURE_RECTANGLE_ARB) {
-            priv->yv12_rect_shader = shader;
-        } else {
-            priv->yv12_2d_shader = shader;
-        }
+    switch (yuv_fixup)
+    {
+        case YUV_FIXUP_YUY2:
+            if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yuy2_rect_shader = shader;
+            else priv->yuy2_2d_shader = shader;
+            break;
+
+        case YUV_FIXUP_UYVY:
+            if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->uyvy_rect_shader = shader;
+            else priv->uyvy_2d_shader = shader;
+            break;
+
+        case YUV_FIXUP_YV12:
+            if (textype == GL_TEXTURE_RECTANGLE_ARB) priv->yv12_rect_shader = shader;
+            else priv->yv12_2d_shader = shader;
+            break;
     }
+
     return shader;
 }
 
@@ -3712,13 +3562,15 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, WINED3DFORMAT fmt, GLenum t
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface;
     float size[4] = {width, height, 1, 1};
     struct arbfp_blit_priv *priv = (struct arbfp_blit_priv *) device->blit_priv;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
+    enum yuv_fixup yuv_fixup;
 
     getFormatDescEntry(fmt, &GLINFO_LOCATION, &glDesc);
 
-    if(glDesc->conversion_group != WINED3DFMT_YUY2 && glDesc->conversion_group != WINED3DFMT_UYVY &&
-       glDesc->conversion_group != WINED3DFMT_YV12) {
-        TRACE("Format: %s\n", debug_d3dformat(glDesc->conversion_group));
+    if (!is_yuv_fixup(glDesc->color_fixup))
+    {
+        TRACE("Fixup:\n");
+        dump_color_fixup_desc(glDesc->color_fixup);
         /* Don't bother setting up a shader for unconverted formats */
         ENTER_GL();
         glEnable(textype);
@@ -3727,30 +3579,33 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, WINED3DFORMAT fmt, GLenum t
         return WINED3D_OK;
     }
 
-    if(glDesc->conversion_group == WINED3DFMT_YUY2) {
-        if(textype == GL_TEXTURE_RECTANGLE_ARB) {
-            shader = priv->yuy2_rect_shader;
-        } else {
-            shader = priv->yuy2_2d_shader;
-        }
-    } else if(glDesc->conversion_group == WINED3DFMT_UYVY) {
-        if(textype == GL_TEXTURE_RECTANGLE_ARB) {
-            shader = priv->uyvy_rect_shader;
-        } else {
-            shader = priv->uyvy_2d_shader;
-        }
-    } else {
-        if(textype == GL_TEXTURE_RECTANGLE_ARB) {
-            shader = priv->yv12_rect_shader;
-        } else {
-            shader = priv->yv12_2d_shader;
-        }
-    }
+    yuv_fixup = get_yuv_fixup(glDesc->color_fixup);
 
-    if(!shader) {
-        shader = gen_yuv_shader(device, glDesc->conversion_group, textype);
+    switch(yuv_fixup)
+    {
+        case YUV_FIXUP_YUY2:
+            shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yuy2_rect_shader : priv->yuy2_2d_shader;
+            break;
+
+        case YUV_FIXUP_UYVY:
+            shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->uyvy_rect_shader : priv->uyvy_2d_shader;
+            break;
+
+        case YUV_FIXUP_YV12:
+            shader = textype == GL_TEXTURE_RECTANGLE_ARB ? priv->yv12_rect_shader : priv->yv12_2d_shader;
+            break;
+
+        default:
+            FIXME("Unsupported YUV fixup %#x, not setting a shader\n", yuv_fixup);
+            ENTER_GL();
+            glEnable(textype);
+            checkGLcall("glEnable(textype)");
+            LEAVE_GL();
+            return E_NOTIMPL;
     }
 
+    if (!shader) shader = gen_yuv_shader(device, yuv_fixup, textype);
+
     ENTER_GL();
     glEnable(GL_FRAGMENT_PROGRAM_ARB);
     checkGLcall("glEnable(GL_FRAGMENT_PROGRAM_ARB)");
@@ -3782,15 +3637,40 @@ static void arbfp_blit_unset(IWineD3DDevice *iface) {
     LEAVE_GL();
 }
 
-static BOOL arbfp_blit_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking blit format support for format %s:", debug_d3dformat(fmt));
-    switch(fmt) {
-        case WINED3DFMT_YUY2:
-        case WINED3DFMT_UYVY:
-        case WINED3DFMT_YV12:
+static BOOL arbfp_blit_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    enum yuv_fixup yuv_fixup;
+
+    if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
+    }
+
+    if (is_identity_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
+    }
+
+    /* We only support YUV conversions. */
+    if (!is_yuv_fixup(fixup))
+    {
+        TRACE("[FAILED]\n");
+        return FALSE;
+    }
+
+    yuv_fixup = get_yuv_fixup(fixup);
+    switch(yuv_fixup)
+    {
+        case YUV_FIXUP_YUY2:
+        case YUV_FIXUP_UYVY:
+        case YUV_FIXUP_YV12:
             TRACE("[OK]\n");
             return TRUE;
+
         default:
+            FIXME("Unsupported YUV fixup %#x\n", yuv_fixup);
             TRACE("[FAILED]\n");
             return FALSE;
     }
@@ -3801,7 +3681,7 @@ const struct blit_shader arbfp_blit = {
     arbfp_blit_free,
     arbfp_blit_set,
     arbfp_blit_unset,
-    arbfp_blit_conv_supported
+    arbfp_blit_color_fixup_supported,
 };
 
 #undef GLINFO_LOCATION
index a53108e..90ca192 100644 (file)
@@ -26,6 +26,7 @@
 #include "wined3d_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
+WINE_DECLARE_DEBUG_CHANNEL(d3d);
 
 /* Some private defines, Constant associations, etc.
  * Env bump matrix and per stage constant should be independent,
@@ -159,7 +160,9 @@ static const char *debug_rep(GLuint rep) {
 }
 
 #define GLINFO_LOCATION (*gl_info)
-static GLuint register_for_arg(DWORD arg, WineD3D_GL_Info *gl_info, unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg) {
+static GLuint register_for_arg(DWORD arg, const WineD3D_GL_Info *gl_info,
+        unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg)
+{
     GLenum ret;
 
     if(mod) *mod = GL_NONE;
@@ -224,7 +227,8 @@ static GLuint register_for_arg(DWORD arg, WineD3D_GL_Info *gl_info, unsigned int
     return ret;
 }
 
-static GLuint find_tmpreg(struct texture_stage_op op[MAX_TEXTURES]) {
+static GLuint find_tmpreg(const struct texture_stage_op op[MAX_TEXTURES])
+{
     int lowest_read = -1;
     int lowest_write = -1;
     int i;
@@ -284,7 +288,8 @@ static GLuint find_tmpreg(struct texture_stage_op op[MAX_TEXTURES]) {
     }
 }
 
-static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_GL_Info *gl_info) {
+static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], const WineD3D_GL_Info *gl_info)
+{
     GLuint ret = GL_EXTCALL(glGenFragmentShadersATI(1));
     unsigned int stage;
     GLuint arg0, arg1, arg2, extrarg;
@@ -339,21 +344,30 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
 
     /* Pass 2: Generate perturbation calculations */
     for(stage = 0; stage < GL_LIMITS(textures); stage++) {
+        GLuint argmodextra_x, argmodextra_y;
+        struct color_fixup_desc fixup;
+
         if(op[stage].cop == WINED3DTOP_DISABLE) break;
         if(op[stage].cop != WINED3DTOP_BUMPENVMAP &&
            op[stage].cop != WINED3DTOP_BUMPENVMAPLUMINANCE) continue;
 
-        /* Nice thing, we get the color correction for free :-) */
-        if(op[stage].color_correction == WINED3DFMT_V8U8) {
-            argmodextra = GL_2X_BIT_ATI | GL_BIAS_BIT_ATI;
-        } else {
-            argmodextra = 0;
+        if (fixup.x_source != CHANNEL_SOURCE_X || fixup.y_source != CHANNEL_SOURCE_Y)
+        {
+            FIXME("Swizzles not implemented\n");
+            argmodextra_x = GL_NONE;
+            argmodextra_y = GL_NONE;
+        }
+        else
+        {
+            /* Nice thing, we get the color correction for free :-) */
+            argmodextra_x = fixup.x_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
+            argmodextra_y = fixup.y_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
         }
 
         TRACE("glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_%d_ATI, GL_RED_BIT_ATI, GL_NONE, GL_REG_%d_ATI, GL_NONE, %s, ATI_FFP_CONST_BUMPMAT(%d), GL_NONE, GL_NONE, GL_REG_%d_ATI, GL_RED, GL_NONE)\n",
-              stage + 1, stage, debug_argmod(argmodextra), stage, stage + 1);
+              stage + 1, stage, debug_argmod(argmodextra_x), stage, stage + 1);
         GL_EXTCALL(glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_RED_BIT_ATI, GL_NONE,
-                                         GL_REG_0_ATI + stage, GL_NONE, argmodextra,
+                                         GL_REG_0_ATI + stage, GL_NONE, argmodextra_x,
                                          ATI_FFP_CONST_BUMPMAT(stage), GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
                                          GL_REG_0_ATI + stage + 1, GL_RED, GL_NONE));
 
@@ -372,9 +386,9 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
         GL_EXTCALL(glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_5_ATI, GL_GREEN_BIT_ATI, GL_NONE,
                                         ATI_FFP_CONST_BUMPMAT(stage), GL_ALPHA, GL_NONE));
         TRACE("glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_%d_ATI, GL_GREEN_BIT_ATI, GL_NONE, GL_REG_%d_ATI, GL_NONE, %s, GL_REG_5_ATI, GL_NONE, GL_NONE, GL_REG_%d_ATI, GL_GREEN, GL_NONE)\n",
-              stage + 1, stage, debug_argmod(argmodextra), stage + 1);
+              stage + 1, stage, debug_argmod(argmodextra_y), stage + 1);
         GL_EXTCALL(glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_GREEN_BIT_ATI, GL_NONE,
-                                         GL_REG_0_ATI + stage, GL_NONE, argmodextra,
+                                         GL_REG_0_ATI + stage, GL_NONE, argmodextra_y,
                                          GL_REG_5_ATI, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
                                          GL_REG_0_ATI + stage + 1, GL_GREEN, GL_NONE));
     }
@@ -802,30 +816,32 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
 #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
 static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     IWineD3DDeviceImpl          *This = stateblock->wineD3DDevice;
-    struct atifs_ffp_desc       *desc;
+    const struct atifs_ffp_desc *desc;
     struct ffp_frag_settings     settings;
     struct atifs_private_data   *priv = (struct atifs_private_data *) This->fragment_priv;
     DWORD mapped_stage;
     unsigned int i;
 
     gen_ffp_frag_op(stateblock, &settings, TRUE);
-    desc = (struct atifs_ffp_desc *) find_ffp_frag_shader(priv->fragment_shaders, &settings);
+    desc = (const struct atifs_ffp_desc *)find_ffp_frag_shader(priv->fragment_shaders, &settings);
     if(!desc) {
-        desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*desc));
-        if(!desc) {
+        struct atifs_ffp_desc *new_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_desc));
+        if (!new_desc)
+        {
             ERR("Out of memory\n");
             return;
         }
-        desc->num_textures_used = 0;
+        new_desc->num_textures_used = 0;
         for(i = 0; i < GL_LIMITS(texture_stages); i++) {
             if(settings.op[i].cop == WINED3DTOP_DISABLE) break;
-            desc->num_textures_used = i;
+            new_desc->num_textures_used = i;
         }
 
-        memcpy(&desc->parent.settings, &settings, sizeof(settings));
-        desc->shader = gen_ati_shader(settings.op, &GLINFO_LOCATION);
-        add_ffp_frag_shader(priv->fragment_shaders, &desc->parent);
-        TRACE("Allocated fixed function replacement shader descriptor %p\n", desc);
+        memcpy(&new_desc->parent.settings, &settings, sizeof(settings));
+        new_desc->shader = gen_ati_shader(settings.op, &GLINFO_LOCATION);
+        add_ffp_frag_shader(priv->fragment_shaders, &new_desc->parent);
+        TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
+        desc = new_desc;
     }
 
     /* GL_ATI_fragment_shader depends on the GL_TEXTURE_xD enable settings. Update the texture stages
@@ -1017,7 +1033,8 @@ static void atifs_enable(IWineD3DDevice *iface, BOOL enable) {
     }
 }
 
-static void atifs_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *caps) {
+static void atifs_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *caps)
+{
     caps->TextureOpCaps =  WINED3DTEXOPCAPS_DISABLE                     |
                            WINED3DTEXOPCAPS_SELECTARG1                  |
                            WINED3DTEXOPCAPS_SELECTARG2                  |
@@ -1101,17 +1118,25 @@ static void atifs_free(IWineD3DDevice *iface) {
 }
 #undef GLINFO_LOCATION
 
-static BOOL atifs_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt));
-    switch(fmt) {
-        case WINED3DFMT_V8U8:
-        case WINED3DFMT_V16U16:
-            TRACE("[OK]\n");
-            return TRUE;
-        default:
-            TRACE("[FAILED\n");
-            return FALSE;
+static BOOL atifs_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
     }
+
+    /* We only support sign fixup of the first two channels. */
+    if (fixup.x_source == CHANNEL_SOURCE_X && fixup.y_source == CHANNEL_SOURCE_Y
+            && fixup.z_source == CHANNEL_SOURCE_Z && fixup.w_source == CHANNEL_SOURCE_W
+            && !fixup.z_sign_fixup && !fixup.w_sign_fixup)
+    {
+        TRACE("[OK]\n");
+        return TRUE;
+    }
+
+    TRACE("[FAILED]\n");
+    return FALSE;
 }
 
 const struct fragment_pipeline atifs_fragment_pipeline = {
@@ -1119,7 +1144,7 @@ const struct fragment_pipeline atifs_fragment_pipeline = {
     atifs_get_caps,
     atifs_alloc,
     atifs_free,
-    atifs_conv_supported,
+    atifs_color_fixup_supported,
     atifs_fragmentstate_template,
     TRUE /* We can disable projected textures */
 };
index f7c8d35..c0b149f 100644 (file)
 #include "wined3d_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
+WINE_DECLARE_DEBUG_CHANNEL(d3d);
 
 #define GLNAME_REQUIRE_GLSL  ((const char *)1)
 
+static void shader_dump_param(const DWORD param, const DWORD addr_token, int input, DWORD shader_version);
+
 static inline BOOL shader_is_version_token(DWORD token) {
     return shader_is_pshader_version(token) ||
            shader_is_vshader_version(token);
@@ -73,45 +76,39 @@ int shader_addline(
     return 0;
 }
 
-const SHADER_OPCODE* shader_get_opcode(
-    IWineD3DBaseShader *iface, const DWORD code) {
-
-    IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl*) iface;
-
+const SHADER_OPCODE *shader_get_opcode(const SHADER_OPCODE *opcode_table, DWORD shader_version, DWORD code)
+{
     DWORD i = 0;
-    DWORD hex_version = This->baseShader.hex_version;
-    const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
 
     /** TODO: use dichotomic search */
-    while (NULL != shader_ins[i].name) {
-        if (((code & WINED3DSI_OPCODE_MASK) == shader_ins[i].opcode) &&
-            (((hex_version >= shader_ins[i].min_version) && (hex_version <= shader_ins[i].max_version)) ||
-            ((shader_ins[i].min_version == 0) && (shader_ins[i].max_version == 0)))) {
-            return &shader_ins[i];
+    while (opcode_table[i].name)
+    {
+        if ((code & WINED3DSI_OPCODE_MASK) == opcode_table[i].opcode
+                && shader_version >= opcode_table[i].min_version
+                && (!opcode_table[i].max_version || shader_version <= opcode_table[i].max_version))
+        {
+            return &opcode_table[i];
         }
         ++i;
     }
-    FIXME("Unsupported opcode %#x(%d) masked %#x, shader version %#x\n", 
-       code, code, code & WINED3DSI_OPCODE_MASK, hex_version);
+
+    FIXME("Unsupported opcode %#x(%d) masked %#x, shader version %#x\n",
+            code, code, code & WINED3DSI_OPCODE_MASK, shader_version);
+
     return NULL;
 }
 
 /* Read a parameter opcode from the input stream,
  * and possibly a relative addressing token.
  * Return the number of tokens read */
-int shader_get_param(
-    IWineD3DBaseShader* iface,
-    const DWORD* pToken,
-    DWORD* param,
-    DWORD* addr_token) {
-
+static int shader_get_param(const DWORD *pToken, DWORD shader_version, DWORD *param, DWORD *addr_token)
+{
     /* PS >= 3.0 have relative addressing (with token)
      * VS >= 2.0 have relative addressing (with token)
      * VS >= 1.0 < 2.0 have relative addressing (without token)
      * The version check below should work in general */
 
-    IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
-    char rel_token = WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2 &&
+    char rel_token = WINED3DSHADER_VERSION_MAJOR(shader_version) >= 2 &&
         ((*pToken & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
 
     *param = *pToken;
@@ -139,11 +136,8 @@ static inline int shader_skip_opcode(
  * Note: This function assumes source or destination token format.
  * It will not work with specially-formatted tokens like DEF or DCL, 
  * but hopefully those would be recognized */
-
-int shader_skip_unrecognized(
-    IWineD3DBaseShader* iface,
-    const DWORD* pToken) {
-
+static int shader_skip_unrecognized(const DWORD *pToken, DWORD shader_version)
+{
     int tokens_read = 0;
     int i = 0;
 
@@ -151,12 +145,12 @@ int shader_skip_unrecognized(
     while (*pToken & 0x80000000) {
 
         DWORD param, addr_token;
-        tokens_read += shader_get_param(iface, pToken, &param, &addr_token);
+        tokens_read += shader_get_param(pToken, shader_version, &param, &addr_token);
         pToken += tokens_read;
 
         FIXME("Unrecognized opcode param: token=0x%08x "
             "addr_token=0x%08x name=", param, addr_token);
-        shader_dump_param(iface, param, addr_token, i);
+        shader_dump_param(param, addr_token, i, shader_version);
         FIXME("\n");
         ++i;
     }
@@ -165,9 +159,8 @@ int shader_skip_unrecognized(
 
 /* Convert floating point offset relative
  * to a register file to an absolute offset for float constants */
-
-unsigned int shader_get_float_offset(const DWORD reg) {
-
+static unsigned int shader_get_float_offset(const DWORD reg)
+{
      unsigned int regnum = reg & WINED3DSP_REGNUM_MASK;
      int regtype = shader_get_regtype(reg);
 
@@ -208,6 +201,8 @@ HRESULT shader_get_registers_used(
     IWineD3DStateBlockImpl *stateBlock) {
 
     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
+    const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
+    DWORD shader_version = This->baseShader.hex_version;
     unsigned int cur_loop_depth = 0, max_loop_depth = 0;
 
     /* There are some minor differences between pixel and vertex shaders */
@@ -245,7 +240,7 @@ HRESULT shader_get_registers_used(
 
         /* Fetch opcode */
         opcode_token = *pToken++;
-        curOpcode = shader_get_opcode(iface, opcode_token);
+        curOpcode = shader_get_opcode(shader_ins, shader_version, opcode_token);
 
         /* Unhandled opcode, and its parameters */
         if (NULL == curOpcode) {
@@ -425,7 +420,7 @@ HRESULT shader_get_registers_used(
             for (i = 0; i < limit; ++i) {
 
                 DWORD param, addr_token, reg, regtype;
-                pToken += shader_get_param(iface, pToken, &param, &addr_token);
+                pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
 
                 regtype = shader_get_regtype(param);
                 reg = param & WINED3DSP_REGNUM_MASK;
@@ -495,11 +490,8 @@ HRESULT shader_get_registers_used(
     return WINED3D_OK;
 }
 
-static void shader_dump_decl_usage(
-    IWineD3DBaseShaderImpl* This,
-    DWORD decl, 
-    DWORD param) {
-
+static void shader_dump_decl_usage(DWORD decl, DWORD param, DWORD shader_version)
+{
     DWORD regtype = shader_get_regtype(param);
 
     TRACE("dcl");
@@ -520,8 +512,7 @@ static void shader_dump_decl_usage(
         DWORD idx = (decl & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
 
         /* Pixel shaders 3.0 don't have usage semantics */
-        char pshader = shader_is_pshader_version(This->baseShader.hex_version);
-        if (pshader && This->baseShader.hex_version < WINED3DPS_VERSION(3,0))
+        if (shader_is_pshader_version(shader_version) && shader_version < WINED3DPS_VERSION(3,0))
             return;
         else
             TRACE("_");
@@ -579,20 +570,16 @@ static void shader_dump_decl_usage(
     }
 }
 
-static void shader_dump_arr_entry(
-    IWineD3DBaseShader *iface,
-    const DWORD param,
-    const DWORD addr_token,
-    unsigned int reg,
-    int input) {
-
+static void shader_dump_arr_entry(const DWORD param, const DWORD addr_token,
+        unsigned int reg, int input, DWORD shader_version)
+{
     char relative =
         ((param & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
 
     if (relative) {
         TRACE("[");
         if (addr_token)
-            shader_dump_param(iface, addr_token, 0, input);
+            shader_dump_param(addr_token, 0, input, shader_version);
         else
             TRACE("a0.x");
         TRACE(" + ");
@@ -602,13 +589,8 @@ static void shader_dump_arr_entry(
          TRACE("]");
 }
 
-void shader_dump_param(
-    IWineD3DBaseShader *iface,
-    const DWORD param, 
-    const DWORD addr_token,
-    int input) {
-
-    IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
+static void shader_dump_param(const DWORD param, const DWORD addr_token, int input, DWORD shader_version)
+{
     static const char * const rastout_reg_names[] = { "oPos", "oFog", "oPts" };
     static const char * const misctype_reg_names[] = { "vPos", "vFace"};
     char swizzle_reg_chars[4];
@@ -618,7 +600,7 @@ void shader_dump_param(
     DWORD modifier = param & WINED3DSP_SRCMOD_MASK;
 
     /* There are some minor differences between pixel and vertex shaders */
-    char pshader = shader_is_pshader_version(This->baseShader.hex_version);
+    char pshader = shader_is_pshader_version(shader_version);
 
     /* For one, we'd prefer color components to be shown for pshaders.
      * FIXME: use the swizzle function for this */
@@ -650,14 +632,14 @@ void shader_dump_param(
             break;
         case WINED3DSPR_INPUT:
             TRACE("v");
-            shader_dump_arr_entry(iface, param, addr_token, reg, input);
+            shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
             break;
         case WINED3DSPR_CONST:
         case WINED3DSPR_CONST2:
         case WINED3DSPR_CONST3:
         case WINED3DSPR_CONST4:
             TRACE("c");
-            shader_dump_arr_entry(iface, param, addr_token, shader_get_float_offset(param), input);
+            shader_dump_arr_entry(param, addr_token, shader_get_float_offset(param), input, shader_version);
             break;
         case WINED3DSPR_TEXTURE: /* vs: case D3DSPR_ADDR */
             TRACE("%c%u", (pshader? 't':'a'), reg);
@@ -679,20 +661,20 @@ void shader_dump_param(
             /* Vertex shaders >= 3.0 use general purpose output registers
              * (WINED3DSPR_OUTPUT), which can include an address token */
 
-            if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3) {
+            if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 3) {
                 TRACE("o");
-                shader_dump_arr_entry(iface, param, addr_token, reg, input);
+                shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
             }
             else 
                TRACE("oT%u", reg);
             break;
         case WINED3DSPR_CONSTINT:
             TRACE("i");
-            shader_dump_arr_entry(iface, param, addr_token, reg, input);
+            shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
             break;
         case WINED3DSPR_CONSTBOOL:
             TRACE("b");
-            shader_dump_arr_entry(iface, param, addr_token, reg, input);
+            shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
             break;
         case WINED3DSPR_LABEL:
             TRACE("l%u", reg);
@@ -778,19 +760,79 @@ void shader_dump_param(
     }
 }
 
+static void shader_color_correction(IWineD3DBaseShaderImpl *shader,
+        IWineD3DDeviceImpl *device, const struct SHADER_OPCODE_ARG *arg)
+{
+    DWORD hex_version = shader->baseShader.hex_version;
+    IWineD3DBaseTextureImpl *texture;
+    struct color_fixup_desc fixup;
+    BOOL recorded = FALSE;
+    DWORD sampler_idx;
+    UINT i;
+
+    switch(arg->opcode->opcode)
+    {
+        case WINED3DSIO_TEX:
+            if (hex_version < WINED3DPS_VERSION(2,0)) sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
+            else sampler_idx = arg->src[1] & WINED3DSP_REGNUM_MASK;
+            break;
+
+        case WINED3DSIO_TEXLDL:
+            FIXME("Add color fixup for vertex texture WINED3DSIO_TEXLDL\n");
+            return;
+
+        case WINED3DSIO_TEXDP3TEX:
+        case WINED3DSIO_TEXM3x3TEX:
+        case WINED3DSIO_TEXM3x3SPEC:
+        case WINED3DSIO_TEXM3x3VSPEC:
+        case WINED3DSIO_TEXBEM:
+        case WINED3DSIO_TEXREG2AR:
+        case WINED3DSIO_TEXREG2GB:
+        case WINED3DSIO_TEXREG2RGB:
+            sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
+            break;
+
+        default:
+            /* Not a texture sampling instruction, nothing to do */
+            return;
+    };
+
+    texture = (IWineD3DBaseTextureImpl *)device->stateBlock->textures[sampler_idx];
+    if (texture) fixup = texture->baseTexture.shader_color_fixup;
+    else fixup = COLOR_FIXUP_IDENTITY;
+
+    /* before doing anything, record the sampler with the format in the format conversion list,
+     * but check if it's not there already */
+    for (i = 0; i < shader->baseShader.num_sampled_samplers; ++i)
+    {
+        if (shader->baseShader.sampled_samplers[i] == sampler_idx)
+        {
+            recorded = TRUE;
+            break;
+        }
+    }
+
+    if (!recorded)
+    {
+        shader->baseShader.sampled_samplers[shader->baseShader.num_sampled_samplers] = sampler_idx;
+        ++shader->baseShader.num_sampled_samplers;
+    }
+
+    device->shader_backend->shader_color_correction(arg, fixup);
+}
+
 /** Shared code in order to generate the bulk of the shader string.
     Use the shader_header_fct & shader_footer_fct to add strings
     that are specific to pixel or vertex functions
     NOTE: A description of how to parse tokens can be found on msdn */
-void shader_generate_main(
-    IWineD3DBaseShader *iface,
-    SHADER_BUFFER* buffer,
-    shader_reg_maps* reg_maps,
-    CONST DWORD* pFunction) {
-
+void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
+        const shader_reg_maps* reg_maps, CONST DWORD* pFunction)
+{
     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
+    const SHADER_OPCODE *opcode_table = This->baseShader.shader_ins;
     const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
+    DWORD shader_version = This->baseShader.hex_version;
     const DWORD *pToken = pFunction;
     const SHADER_OPCODE *curOpcode = NULL;
     SHADER_HANDLER hw_fct = NULL;
@@ -824,7 +866,7 @@ void shader_generate_main(
 
             /* Read opcode */
             hw_arg.opcode_token = *pToken++;
-            curOpcode = shader_get_opcode(iface, hw_arg.opcode_token);
+            curOpcode = shader_get_opcode(opcode_table, shader_version, hw_arg.opcode_token);
 
             /* Select handler */
             if (curOpcode == NULL)
@@ -835,7 +877,7 @@ void shader_generate_main(
             /* Unknown opcode and its parameters */
             if (NULL == curOpcode) {
                 FIXME("Unrecognized opcode: token=0x%08x\n", hw_arg.opcode_token);
-                pToken += shader_skip_unrecognized(iface, pToken); 
+                pToken += shader_skip_unrecognized(pToken, shader_version);
 
             /* Nothing to do */
             } else if (WINED3DSIO_DCL == curOpcode->opcode ||
@@ -857,7 +899,7 @@ void shader_generate_main(
                 if (curOpcode->dst_token) {
 
                     DWORD param, addr_token = 0;
-                    pToken += shader_get_param(iface, pToken, &param, &addr_token);
+                    pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
                     hw_arg.dst = param;
                     hw_arg.dst_addr = addr_token;
                 }
@@ -870,7 +912,7 @@ void shader_generate_main(
                 for (i = 0; i < (curOpcode->num_params - curOpcode->dst_token); i++) {
 
                     DWORD param, addr_token = 0; 
-                    pToken += shader_get_param(iface, pToken, &param, &addr_token);
+                    pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
                     hw_arg.src[i] = param;
                     hw_arg.src_addr[i] = addr_token;
                 }
@@ -879,7 +921,7 @@ void shader_generate_main(
                 hw_fct(&hw_arg);
 
                 /* Add color correction if needed */
-                device->shader_backend->shader_color_correction(&hw_arg);
+                shader_color_correction(This, device, &hw_arg);
 
                 /* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
                 /* FIXME: This should be internal to the shader backend.
@@ -899,8 +941,8 @@ void shader_generate_main(
     }
 }
 
-void shader_dump_ins_modifiers(const DWORD output) {
-
+static void shader_dump_ins_modifiers(const DWORD output)
+{
     DWORD shift = (output & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
     DWORD mmask = output & WINED3DSP_DSTMOD_MASK;
 
@@ -939,155 +981,167 @@ void shader_trace_init(
 
     TRACE("(%p) : Parsing program\n", This);
 
-    if (NULL != pToken) {
-        while (WINED3DVS_END() != *pToken) {
-            if (shader_is_version_token(*pToken)) { /** version */
-                This->baseShader.hex_version = *pToken;
-                TRACE("%s_%u_%u\n", shader_is_pshader_version(This->baseShader.hex_version)? "ps": "vs",
-                    WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version),
-                    WINED3DSHADER_VERSION_MINOR(This->baseShader.hex_version));
-                ++pToken;
-                ++len;
-                continue;
+    if (!pFunction)
+    {
+        WARN("Got a NULL pFunction, returning.\n");
+        This->baseShader.functionLength = 1; /* no Function defined use fixed function vertex processing */
+        return;
+    }
+
+    while (WINED3DVS_END() != *pToken)
+    {
+        if (shader_is_version_token(*pToken)) /* version */
+        {
+            This->baseShader.hex_version = *pToken;
+            TRACE("%s_%u_%u\n", shader_is_pshader_version(This->baseShader.hex_version)? "ps": "vs",
+                WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version),
+                WINED3DSHADER_VERSION_MINOR(This->baseShader.hex_version));
+            ++pToken;
+            ++len;
+            continue;
+        }
+        if (shader_is_comment(*pToken)) /* comment */
+        {
+            DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
+            ++pToken;
+            TRACE("//%s\n", (const char*)pToken);
+            pToken += comment_len;
+            len += comment_len + 1;
+            continue;
+        }
+        opcode_token = *pToken++;
+        curOpcode = shader_get_opcode(This->baseShader.shader_ins, This->baseShader.hex_version, opcode_token);
+        len++;
+
+        if (!curOpcode)
+        {
+            int tokens_read;
+            FIXME("Unrecognized opcode: token=0x%08x\n", opcode_token);
+            tokens_read = shader_skip_unrecognized(pToken, This->baseShader.hex_version);
+            pToken += tokens_read;
+            len += tokens_read;
+        }
+        else
+        {
+            if (curOpcode->opcode == WINED3DSIO_DCL)
+            {
+                DWORD usage = *pToken;
+                DWORD param = *(pToken + 1);
+
+                shader_dump_decl_usage(usage, param, This->baseShader.hex_version);
+                shader_dump_ins_modifiers(param);
+                TRACE(" ");
+                shader_dump_param(param, 0, 0, This->baseShader.hex_version);
+                pToken += 2;
+                len += 2;
             }
-            if (shader_is_comment(*pToken)) { /** comment */
-                DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
-                ++pToken;
-                TRACE("//%s\n", (const char*)pToken);
-                pToken += comment_len;
-                len += comment_len + 1;
-                continue;
+            else if (curOpcode->opcode == WINED3DSIO_DEF)
+            {
+                unsigned int offset = shader_get_float_offset(*pToken);
+
+                TRACE("def c%u = %f, %f, %f, %f", offset,
+                        *(const float *)(pToken + 1),
+                        *(const float *)(pToken + 2),
+                        *(const float *)(pToken + 3),
+                        *(const float *)(pToken + 4));
+                pToken += 5;
+                len += 5;
             }
-            opcode_token = *pToken++;
-            curOpcode = shader_get_opcode(iface, opcode_token);
-            len++;
-
-            if (NULL == curOpcode) {
+            else if (curOpcode->opcode == WINED3DSIO_DEFI)
+            {
+                TRACE("defi i%u = %d, %d, %d, %d", *pToken & WINED3DSP_REGNUM_MASK,
+                        *(pToken + 1),
+                        *(pToken + 2),
+                        *(pToken + 3),
+                        *(pToken + 4));
+                pToken += 5;
+                len += 5;
+            }
+            else if (curOpcode->opcode == WINED3DSIO_DEFB)
+            {
+                TRACE("defb b%u = %s", *pToken & WINED3DSP_REGNUM_MASK,
+                        *(pToken + 1)? "true": "false");
+                pToken += 2;
+                len += 2;
+            }
+            else
+            {
+                DWORD param, addr_token;
                 int tokens_read;
-                FIXME("Unrecognized opcode: token=0x%08x\n", opcode_token);
-                tokens_read = shader_skip_unrecognized(iface, pToken);
-                pToken += tokens_read;
-                len += tokens_read;
-
-            } else {
-                if (curOpcode->opcode == WINED3DSIO_DCL) {
-
-                    DWORD usage = *pToken;
-                    DWORD param = *(pToken + 1);
-
-                    shader_dump_decl_usage(This, usage, param);
-                    shader_dump_ins_modifiers(param);
-                    TRACE(" ");
-                    shader_dump_param(iface, param, 0, 0);
-                    pToken += 2;
-                    len += 2;
-
-                } else if (curOpcode->opcode == WINED3DSIO_DEF) {
-
-                        unsigned int offset = shader_get_float_offset(*pToken);
-
-                        TRACE("def c%u = %f, %f, %f, %f", offset,
-                            *(const float *)(pToken + 1),
-                            *(const float *)(pToken + 2),
-                            *(const float *)(pToken + 3),
-                            *(const float *)(pToken + 4));
-
-                        pToken += 5;
-                        len += 5;
-                } else if (curOpcode->opcode == WINED3DSIO_DEFI) {
-
-                        TRACE("defi i%u = %d, %d, %d, %d", *pToken & WINED3DSP_REGNUM_MASK,
-                            *(pToken + 1),
-                            *(pToken + 2),
-                            *(pToken + 3),
-                            *(pToken + 4));
-
-                        pToken += 5;
-                        len += 5;
-
-                } else if (curOpcode->opcode == WINED3DSIO_DEFB) {
-
-                        TRACE("defb b%u = %s", *pToken & WINED3DSP_REGNUM_MASK,
-                            *(pToken + 1)? "true": "false");
-
-                        pToken += 2;
-                        len += 2;
-
-                } else {
 
-                    DWORD param, addr_token;
-                    int tokens_read;
-
-                    /* Print out predication source token first - it follows
-                     * the destination token. */
-                    if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) {
-                        TRACE("(");
-                        shader_dump_param(iface, *(pToken + 2), 0, 1);
-                        TRACE(") ");
-                    }
-                    if (opcode_token & WINED3DSI_COISSUE) {
-                        /* PixWin marks instructions with the coissue flag with a '+' */
-                        TRACE("+");
-                    }
-
-                    TRACE("%s", curOpcode->name);
-
-                    if (curOpcode->opcode == WINED3DSIO_IFC ||
-                        curOpcode->opcode == WINED3DSIO_BREAKC) {
-
-                        DWORD op = (opcode_token & INST_CONTROLS_MASK) >> INST_CONTROLS_SHIFT;
-                        switch (op) {
-                            case COMPARISON_GT: TRACE("_gt"); break;
-                            case COMPARISON_EQ: TRACE("_eq"); break;
-                            case COMPARISON_GE: TRACE("_ge"); break;
-                            case COMPARISON_LT: TRACE("_lt"); break;
-                            case COMPARISON_NE: TRACE("_ne"); break;
-                            case COMPARISON_LE: TRACE("_le"); break;
-                            default:
-                                TRACE("_(%u)", op);
-                        }
-                    } else if (curOpcode->opcode == WINED3DSIO_TEX &&
-                               This->baseShader.hex_version >= WINED3DPS_VERSION(2,0)) {
-                        if(opcode_token & WINED3DSI_TEXLD_PROJECT) TRACE("p");
-                    }
-
-                    /* Destination token */
-                    if (curOpcode->dst_token) {
-
-                        /* Destination token */
-                        tokens_read = shader_get_param(iface, pToken, &param, &addr_token);
-                        pToken += tokens_read;
-                        len += tokens_read;
+                /* Print out predication source token first - it follows
+                 * the destination token. */
+                if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
+                {
+                    TRACE("(");
+                    shader_dump_param(*(pToken + 2), 0, 1, This->baseShader.hex_version);
+                    TRACE(") ");
+                }
+                if (opcode_token & WINED3DSI_COISSUE)
+                {
+                    /* PixWin marks instructions with the coissue flag with a '+' */
+                    TRACE("+");
+                }
 
-                        shader_dump_ins_modifiers(param);
-                        TRACE(" ");
-                        shader_dump_param(iface, param, addr_token, 0);
+                TRACE("%s", curOpcode->name);
+
+                if (curOpcode->opcode == WINED3DSIO_IFC
+                        || curOpcode->opcode == WINED3DSIO_BREAKC)
+                {
+                    DWORD op = (opcode_token & INST_CONTROLS_MASK) >> INST_CONTROLS_SHIFT;
+
+                    switch (op)
+                    {
+                        case COMPARISON_GT: TRACE("_gt"); break;
+                        case COMPARISON_EQ: TRACE("_eq"); break;
+                        case COMPARISON_GE: TRACE("_ge"); break;
+                        case COMPARISON_LT: TRACE("_lt"); break;
+                        case COMPARISON_NE: TRACE("_ne"); break;
+                        case COMPARISON_LE: TRACE("_le"); break;
+                        default: TRACE("_(%u)", op);
                     }
+                }
+                else if (curOpcode->opcode == WINED3DSIO_TEX
+                        && This->baseShader.hex_version >= WINED3DPS_VERSION(2,0)
+                        && (opcode_token & WINED3DSI_TEXLD_PROJECT))
+                {
+                    TRACE("p");
+                }
 
-                    /* Predication token - already printed out, just skip it */
-                    if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) {
-                        pToken++;
-                        len++;
-                    }
+                /* Destination token */
+                if (curOpcode->dst_token)
+                {
+                    tokens_read = shader_get_param(pToken, This->baseShader.hex_version, &param, &addr_token);
+                    pToken += tokens_read;
+                    len += tokens_read;
 
-                    /* Other source tokens */
-                    for (i = curOpcode->dst_token; i < curOpcode->num_params; ++i) {
+                    shader_dump_ins_modifiers(param);
+                    TRACE(" ");
+                    shader_dump_param(param, addr_token, 0, This->baseShader.hex_version);
+                }
 
-                        tokens_read = shader_get_param(iface, pToken, &param, &addr_token);
-                        pToken += tokens_read;
-                        len += tokens_read;
+                /* Predication token - already printed out, just skip it */
+                if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
+                {
+                    pToken++;
+                    len++;
+                }
 
-                        TRACE((i == 0)? " " : ", ");
-                        shader_dump_param(iface, param, addr_token, 1);
-                    }
+                /* Other source tokens */
+                for (i = curOpcode->dst_token; i < curOpcode->num_params; ++i)
+                {
+                    tokens_read = shader_get_param(pToken, This->baseShader.hex_version, &param, &addr_token);
+                    pToken += tokens_read;
+                    len += tokens_read;
+
+                    TRACE((i == 0)? " " : ", ");
+                    shader_dump_param(param, addr_token, 1, This->baseShader.hex_version);
                 }
-                TRACE("\n");
             }
+            TRACE("\n");
         }
-        This->baseShader.functionLength = (len + 1) * sizeof(DWORD);
-    } else {
-        This->baseShader.functionLength = 1; /* no Function defined use fixed function vertex processing */
     }
+    This->baseShader.functionLength = (len + 1) * sizeof(DWORD);
 }
 
 static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0};
@@ -1096,41 +1150,45 @@ static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types t
 static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
 static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
 static void shader_none_cleanup(IWineD3DDevice *iface) {}
-static void shader_none_color_correction(SHADER_OPCODE_ARG* arg) {}
+static void shader_none_color_correction(const struct SHADER_OPCODE_ARG *arg, struct color_fixup_desc fixup) {}
 static void shader_none_destroy(IWineD3DBaseShader *iface) {}
 static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
 static void shader_none_free(IWineD3DDevice *iface) {}
 static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
-static void shader_none_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
+static GLuint shader_none_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
     FIXME("NONE shader backend asked to generate a pixel shader\n");
+    return 0;
 }
 static void shader_none_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer) {
     FIXME("NONE shader backend asked to generate a vertex shader\n");
 }
 
 #define GLINFO_LOCATION      (*gl_info)
-static void shader_none_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) {
+static void shader_none_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps)
+{
     /* Set the shader caps to 0 for the none shader backend */
     pCaps->VertexShaderVersion  = 0;
     pCaps->PixelShaderVersion    = 0;
     pCaps->PixelShader1xMaxValue = 0.0;
 }
 #undef GLINFO_LOCATION
-static BOOL shader_none_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking shader format support for format %s", debug_d3dformat(fmt));
-    switch(fmt) {
-        /* Faked to make some apps happy. */
-        case WINED3DFMT_V8U8:
-        case WINED3DFMT_V16U16:
-        case WINED3DFMT_L6V5U5:
-        case WINED3DFMT_X8L8V8U8:
-        case WINED3DFMT_Q8W8V8U8:
-            TRACE("[OK]\n");
-            return TRUE;
-        default:
-            TRACE("[FAILED]\n");
-            return FALSE;
+static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
     }
+
+    /* Faked to make some apps happy. */
+    if (!is_yuv_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
+    }
+
+    TRACE("[FAILED]\n");
+    return FALSE;
 }
 
 const shader_backend_t none_shader_backend = {
@@ -1148,7 +1206,7 @@ const shader_backend_t none_shader_backend = {
     shader_none_generate_pshader,
     shader_none_generate_vshader,
     shader_none_get_caps,
-    shader_none_conv_supported
+    shader_none_color_fixup_supported,
 };
 
 /* *******************************************
index 69574b2..158650e 100644 (file)
 WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
 #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
 
-/* *******************************************
-   IWineD3DBaseTexture IUnknown parts follow
-   ******************************************* */
-HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, LPVOID *ppobj)
+void basetexture_cleanup(IWineD3DBaseTexture *iface)
 {
-    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
-    TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
-    if (IsEqualGUID(riid, &IID_IUnknown)
-        || IsEqualGUID(riid, &IID_IWineD3DBase)
-        || IsEqualGUID(riid, &IID_IWineD3DResource)
-        || IsEqualGUID(riid, &IID_IWineD3DBaseTexture)) {
-        IUnknown_AddRef(iface);
-        *ppobj = This;
-        return S_OK;
-    }
-    *ppobj = NULL;
-    return E_NOINTERFACE;
-}
-
-ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) {
-    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
-    ULONG ref = InterlockedIncrement(&This->resource.ref);
-
-    TRACE("(%p) : AddRef increasing from %d\n", This,ref - 1);
-    return ref;
-}
-
-ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
-    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
-    ULONG ref = InterlockedDecrement(&This->resource.ref);
-    TRACE("(%p) : Releasing from %d\n", This, ref + 1);
-    if (ref == 0) {
-        IWineD3DBaseTextureImpl_CleanUp(iface);
-        HeapFree(GetProcessHeap(), 0, This);
-    }
-    return ref;
-}
-
-/* class static */
-void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
 
@@ -78,41 +40,12 @@ void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
         glDeleteTextures(1, &This->baseTexture.textureName);
         LEAVE_GL();
     }
-    IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
-}
 
-/* ****************************************************
-   IWineD3DBaseTexture IWineD3DResource parts follow
-   **************************************************** */
-HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    resource_cleanup((IWineD3DResource *)iface);
 }
 
-HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
-}
-
-HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
-}
-
-HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
-}
-
-DWORD    WINAPI        IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
-}
-
-DWORD    WINAPI        IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
-}
-
-void     WINAPI        IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface) {
-    IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
-}
-
-void     WINAPI        IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface) {
+void basetexture_unload(IWineD3DBaseTexture *iface)
+{
     IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
 
@@ -126,21 +59,10 @@ void     WINAPI        IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface
     This->baseTexture.dirty = TRUE;
 }
 
-WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface) {
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
-}
-
-HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent) {
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
-}
-
-/* ******************************************************
-   IWineD3DBaseTexture IWineD3DBaseTexture parts follow
-   ****************************************************** */
-
 /* There is no OpenGL equivalent of setLOD, getLOD. All they do anyway is prioritize texture loading
  * so just pretend that they work unless something really needs a failure. */
-DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew) {
+DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
+{
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
 
     if (This->resource.pool != WINED3DPOOL_MANAGED) {
@@ -156,7 +78,8 @@ DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LO
     return This->baseTexture.LOD;
 }
 
-DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
+DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
+{
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
 
     if (This->resource.pool != WINED3DPOOL_MANAGED) {
@@ -168,13 +91,15 @@ DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
     return This->baseTexture.LOD;
 }
 
-DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface) {
+DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface)
+{
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
     TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
     return This->baseTexture.levels;
 }
 
-HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
+HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType)
+{
   IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
   IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
   UINT textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
@@ -216,7 +141,8 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture
   return WINED3D_OK;
 }
 
-WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface) {
+WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface)
+{
   IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
   FIXME("(%p) : stub\n", This);
   if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
@@ -225,15 +151,16 @@ WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWi
   return This->baseTexture.filterType;
 }
 
-void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface) {
+void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface)
+{
   IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
   /* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
   FIXME("(%p) : stub\n", This);
   return ;
 }
 
-/* Internal function, No d3d mapping */
-BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL dirty) {
+BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty)
+{
     BOOL old;
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
     old = This->baseTexture.dirty;
@@ -241,12 +168,14 @@ BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL di
     return old;
 }
 
-BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) {
+BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
+{
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
     return This->baseTexture.dirty;
 }
 
-HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
+HRESULT basetexture_bind(IWineD3DBaseTexture *iface)
+{
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
     HRESULT hr = WINED3D_OK;
     UINT textureDimensions;
@@ -330,32 +259,6 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
     return hr;
 }
 
-UINT WINAPI IWineD3DBaseTextureImpl_GetTextureDimensions(IWineD3DBaseTexture *iface){
-    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
-    FIXME("(%p) : This shouldn't be called\n", This);
-    return WINED3D_OK;
-}
-
-BOOL WINAPI IWineD3DBaseTextureImpl_IsCondNP2(IWineD3DBaseTexture *iface){
-    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
-    FIXME("(%p) : This shouldn't be called\n", This);
-    return FALSE;
-}
-
-static inline GLenum warpLookupType(WINED3DSAMPLERSTATETYPE Type) {
-    switch(Type) {
-    case WINED3DSAMP_ADDRESSU:
-        return GL_TEXTURE_WRAP_S;
-    case WINED3DSAMP_ADDRESSV:
-        return GL_TEXTURE_WRAP_T;
-    case WINED3DSAMP_ADDRESSW:
-        return GL_TEXTURE_WRAP_R;
-    default:
-        FIXME("Unexpected warp type %d\n", Type);
-        return 0;
-    }
-}
-
 static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type,
                               BOOL cond_np2) {
     GLint wrapParm;
@@ -381,9 +284,10 @@ static inline void apply_wrap(const GLint textureDimensions, const DWORD state,
     }
 }
 
-void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface,
-                                    const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
-                                    const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
+void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
+        const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
+        const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1])
+{
     IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
     DWORD state;
     GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
@@ -426,7 +330,7 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
         if (state > WINED3DTEXF_ANISOTROPIC) {
             FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
         } else {
-            glValue = (*This->baseTexture.magLookup)[state - WINED3DTEXF_NONE];
+            glValue = This->baseTexture.magLookup[state - WINED3DTEXF_NONE];
             TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
             glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
             /* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
@@ -455,9 +359,9 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
                   This->baseTexture.states[WINED3DTEXSTA_MINFILTER],
                   This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]);
         }
-        glValue = (*This->baseTexture.minMipLookup)
+        glValue = This->baseTexture.minMipLookup
                 [min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
-                [min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
+                .mip[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
 
         TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
               samplerStates[WINED3DSAMP_MINFILTER],
@@ -487,38 +391,3 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
         This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY];
     }
 }
-
-
-static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
-{
-    /* IUnknown */
-    IWineD3DBaseTextureImpl_QueryInterface,
-    IWineD3DBaseTextureImpl_AddRef,
-    IWineD3DBaseTextureImpl_Release,
-    /* IWineD3DResource */
-    IWineD3DBaseTextureImpl_GetParent,
-    IWineD3DBaseTextureImpl_GetDevice,
-    IWineD3DBaseTextureImpl_SetPrivateData,
-    IWineD3DBaseTextureImpl_GetPrivateData,
-    IWineD3DBaseTextureImpl_FreePrivateData,
-    IWineD3DBaseTextureImpl_SetPriority,
-    IWineD3DBaseTextureImpl_GetPriority,
-    IWineD3DBaseTextureImpl_PreLoad,
-    IWineD3DBaseTextureImpl_UnLoad,
-    IWineD3DBaseTextureImpl_GetType,
-    /*IWineD3DBaseTexture*/
-    IWineD3DBaseTextureImpl_SetLOD,
-    IWineD3DBaseTextureImpl_GetLOD,
-    IWineD3DBaseTextureImpl_GetLevelCount,
-    IWineD3DBaseTextureImpl_SetAutoGenFilterType,
-    IWineD3DBaseTextureImpl_GetAutoGenFilterType,
-    IWineD3DBaseTextureImpl_GenerateMipSubLevels,
-    IWineD3DBaseTextureImpl_SetDirty,
-    IWineD3DBaseTextureImpl_GetDirty,
-    /* internal */
-    IWineD3DBaseTextureImpl_BindTexture,
-    IWineD3DBaseTextureImpl_GetTextureDimensions,
-    IWineD3DBaseTextureImpl_IsCondNP2,
-    IWineD3DBaseTextureImpl_ApplyStateChanges
-
-};
index feb6e23..2d3184f 100644 (file)
@@ -96,7 +96,8 @@ static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, RECT *Rect, RGNDATA *ClipList, DWORD *Size)
+static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
+        RGNDATA *ClipList, DWORD *Size)
 {
     IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
     TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
@@ -140,7 +141,7 @@ static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, RE
     }
 }
 
-static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, RGNDATA *rgn, DWORD Flags)
+static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
 {
     IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
     static int warned = 0;
index acfe36b..05afe5d 100644 (file)
@@ -1253,7 +1253,7 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf
      * the alpha blend state changes with different render target formats
      */
     if(oldFmt != newFmt) {
-        const GlPixelFormatDesc *glDesc;
+        const struct GlPixelFormatDesc *glDesc;
         const StaticPixelFormatDesc *old = getFormatDescEntry(oldFmt, NULL, NULL);
         const StaticPixelFormatDesc *new = getFormatDescEntry(newFmt, &GLINFO_LOCATION, &glDesc);
 
index 9ccb2d1..90b1221 100644 (file)
@@ -68,27 +68,27 @@ static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface)
    IWineD3DCubeTexture IWineD3DResource parts follow
    **************************************************** */
 static HRESULT WINAPI IWineD3DCubeTextureImpl_GetDevice(IWineD3DCubeTexture *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    return resource_get_device((IWineD3DResource *)iface, ppDevice);
 }
 
 static HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
 }
 
 static HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
 }
 
 static HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
+    return resource_free_private_data((IWineD3DResource *)iface, refguid);
 }
 
 static DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
+    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
 }
 
 static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
+    return resource_get_priority((IWineD3DResource *)iface);
 }
 
 static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
@@ -176,52 +176,52 @@ static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface) {
         }
     }
 
-    IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface);
+    basetexture_unload((IWineD3DBaseTexture *)iface);
 }
 
 static WINED3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface) {
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
+    return resource_get_type((IWineD3DResource *)iface);
 }
 
 static HRESULT WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface, IUnknown **pParent) {
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
+    return resource_get_parent((IWineD3DResource *)iface, pParent);
 }
 
 /* ******************************************************
    IWineD3DCubeTexture IWineD3DBaseTexture parts follow
    ****************************************************** */
 static DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew) {
-    return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew);
+    return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
 }
 
 static DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface);
+    return basetexture_get_lod((IWineD3DBaseTexture *)iface);
 }
 
 static DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface);
+    return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
 }
 
 static HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
-  return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType);
+  return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
 }
 
 static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface) {
-  return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface);
+  return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
 }
 
 static void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface) {
-    IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface);
+    basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
 }
 
 /* Internal function, No d3d mapping */
 static BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL dirty) {
-    return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty);
+    return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
 }
 
 /* Internal function, No d3d mapping */
 static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface);
+    return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
 }
 
 static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface) {
@@ -231,7 +231,7 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *i
 
     TRACE("(%p) : relay to BaseTexture\n", This);
 
-    hr = IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
+    hr = basetexture_bind((IWineD3DBaseTexture *)iface);
     if (set_gl_texture_desc && SUCCEEDED(hr)) {
         UINT i, j;
         for (i = 0; i < This->baseTexture.levels; ++i) {
@@ -262,7 +262,7 @@ static void WINAPI IWineD3DCubeTextureImpl_ApplyStateChanges(IWineD3DCubeTexture
                                                         const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], 
                                                         const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
     TRACE("(%p) : relay to BaseTexture\n", iface);
-    IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
+    basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
 }
 
 
@@ -286,7 +286,7 @@ static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D
             }
         }
     }
-    IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
+    basetexture_cleanup((IWineD3DBaseTexture *)iface);
     /* finally delete the object */
     HeapFree(GetProcessHeap(), 0, This);
 }
index 0cb539b..836ad3b 100644 (file)
@@ -52,7 +52,7 @@ const WINED3DLIGHT WINED3D_default_light = {
 };
 
 /* static function declarations */
-static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource);
+static void IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource);
 
 /* helper macros */
 #define D3DMEMCHECK(object, ppResult) if(NULL == object) { *ppResult = NULL; WARN("Out of memory\n"); return WINED3DERR_OUTOFVIDEOMEMORY;}
@@ -457,12 +457,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
         object->num_contained_ps_consts_f = GL_LIMITS(pshader_constantsF);
         for (i = 0; i < MAX_CONST_B; ++i) {
             object->contained_ps_consts_b[i] = i;
-            object->changed.pixelShaderConstantsB[i] = TRUE;
+            object->changed.pixelShaderConstantsB |= (1 << i);
         }
         object->num_contained_ps_consts_b = MAX_CONST_B;
         for (i = 0; i < MAX_CONST_I; ++i) {
             object->contained_ps_consts_i[i] = i;
-            object->changed.pixelShaderConstantsI[i] = TRUE;
+            object->changed.pixelShaderConstantsI |= (1 << i);
         }
         object->num_contained_ps_consts_i = MAX_CONST_I;
 
@@ -514,13 +514,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
         }
         object->num_contained_vs_consts_f = GL_LIMITS(vshader_constantsF);
         for (i = 0; i < MAX_CONST_B; ++i) {
-            object->changed.vertexShaderConstantsB[i] = TRUE;
             object->contained_vs_consts_b[i] = i;
+            object->changed.vertexShaderConstantsB |= (1 << i);
         }
         object->num_contained_vs_consts_b = MAX_CONST_B;
         for (i = 0; i < MAX_CONST_I; ++i) {
-            object->changed.vertexShaderConstantsI[i] = TRUE;
             object->contained_vs_consts_i[i] = i;
+            object->changed.vertexShaderConstantsI |= (1 << i);
         }
         object->num_contained_vs_consts_i = MAX_CONST_I;
         for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
@@ -587,7 +587,7 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
     IWineD3DDeviceImpl  *This = (IWineD3DDeviceImpl *)iface;    
     IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
     unsigned int Size       = 1;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
     UINT mul_4w, mul_4h;
     TRACE("(%p) Create surface\n",This);
@@ -759,7 +759,7 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
     HRESULT hr;
     unsigned int pow2Width;
     unsigned int pow2Height;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
 
     TRACE("(%p) : Width %d, Height %d, Levels %d, Usage %#x\n", This, Width, Height, Levels, Usage);
@@ -779,11 +779,11 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
     object->height = Height;
 
     if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
-        object->baseTexture.minMipLookup = &minMipLookup;
-        object->baseTexture.magLookup    = &magLookup;
+        object->baseTexture.minMipLookup = minMipLookup;
+        object->baseTexture.magLookup    = magLookup;
     } else {
-        object->baseTexture.minMipLookup = &minMipLookup_noFilter;
-        object->baseTexture.magLookup    = &magLookup_noFilter;
+        object->baseTexture.minMipLookup = minMipLookup_noFilter;
+        object->baseTexture.magLookup    = magLookup_noFilter;
     }
 
     /** Non-power2 support **/
@@ -821,7 +821,7 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
         object->baseTexture.pow2Matrix[15] = 1.0;
         object->target = GL_TEXTURE_2D;
         object->cond_np2 = TRUE;
-        object->baseTexture.minMipLookup = &minMipLookup_noFilter;
+        object->baseTexture.minMipLookup = minMipLookup_noFilter;
     } else if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE) &&
        (Width != pow2Width || Height != pow2Height) &&
        !((Format == WINED3DFMT_P8) && GL_SUPPORT(EXT_PALETTED_TEXTURE) && (wined3d_settings.rendertargetlock_mode == RTL_READTEX || wined3d_settings.rendertargetlock_mode == RTL_TEXTEX)))
@@ -832,7 +832,7 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
         object->baseTexture.pow2Matrix[15] = 1.0;
         object->target = GL_TEXTURE_RECTANGLE_ARB;
         object->cond_np2 = TRUE;
-        object->baseTexture.minMipLookup = &minMipLookup_noFilter;
+        object->baseTexture.minMipLookup = minMipLookup_noFilter;
     } else {
         object->baseTexture.pow2Matrix[0] =  (((float)Width)  / ((float)pow2Width));
         object->baseTexture.pow2Matrix[5] =  (((float)Height) / ((float)pow2Height));
@@ -891,7 +891,7 @@ static HRESULT  WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
         tmpW = max(1, tmpW >> 1);
         tmpH = max(1, tmpH >> 1);
     }
-    object->baseTexture.shader_conversion_group = glDesc->conversion_group;
+    object->baseTexture.shader_color_fixup = glDesc->color_fixup;
 
     TRACE("(%p) : Created  texture %p\n", This, object);
     return WINED3D_OK;
@@ -911,7 +911,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
     UINT                       tmpW;
     UINT                       tmpH;
     UINT                       tmpD;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
 
     getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
 
@@ -932,10 +932,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
     TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
           Depth, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
 
-    object->width  = Width;
-    object->height = Height;
-    object->depth  = Depth;
-
     /* Is NP2 support for volumes needed? */
     object->baseTexture.pow2Matrix[ 0] = 1.0;
     object->baseTexture.pow2Matrix[ 5] = 1.0;
@@ -943,11 +939,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
     object->baseTexture.pow2Matrix[15] = 1.0;
 
     if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
-        object->baseTexture.minMipLookup = &minMipLookup;
-        object->baseTexture.magLookup    = &magLookup;
+        object->baseTexture.minMipLookup = minMipLookup;
+        object->baseTexture.magLookup    = magLookup;
     } else {
-        object->baseTexture.minMipLookup = &minMipLookup_noFilter;
-        object->baseTexture.magLookup    = &magLookup_noFilter;
+        object->baseTexture.minMipLookup = minMipLookup_noFilter;
+        object->baseTexture.magLookup    = magLookup_noFilter;
     }
 
     /* Calculate levels for mip mapping */
@@ -1002,7 +998,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
         tmpH = max(1, tmpH >> 1);
         tmpD = max(1, tmpD >> 1);
     }
-    object->baseTexture.shader_conversion_group = glDesc->conversion_group;
+    object->baseTexture.shader_color_fixup = glDesc->color_fixup;
 
     *ppVolumeTexture = (IWineD3DVolumeTexture *) object;
     TRACE("(%p) : Created volume texture %p\n", This, object);
@@ -1057,7 +1053,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
     UINT                     tmpW;
     HRESULT                  hr;
     unsigned int pow2EdgeLength;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
 
     /* TODO: It should only be possible to create textures for formats 
@@ -1081,8 +1077,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
     pow2EdgeLength = 1;
     while (pow2EdgeLength < EdgeLength) pow2EdgeLength <<= 1;
 
-    object->edgeLength           = EdgeLength;
-
     if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
         /* Precalculated scaling for 'faked' non power of two texture coords */
         object->baseTexture.pow2Matrix[ 0] = 1.0;
@@ -1098,11 +1092,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
     }
 
     if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
-        object->baseTexture.minMipLookup = &minMipLookup;
-        object->baseTexture.magLookup    = &magLookup;
+        object->baseTexture.minMipLookup = minMipLookup;
+        object->baseTexture.magLookup    = magLookup;
     } else {
-        object->baseTexture.minMipLookup = &minMipLookup_noFilter;
-        object->baseTexture.magLookup    = &magLookup_noFilter;
+        object->baseTexture.minMipLookup = minMipLookup_noFilter;
+        object->baseTexture.magLookup    = magLookup_noFilter;
     }
 
     /* Calculate levels for mip mapping */
@@ -1174,7 +1168,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
         }
         tmpW = max(1, tmpW >> 1);
     }
-    object->baseTexture.shader_conversion_group = glDesc->conversion_group;
+    object->baseTexture.shader_color_fixup = glDesc->color_fixup;
 
     TRACE("(%p) : Created Cube Texture %p\n", This, object);
     *ppCubeTexture = (IWineD3DCubeTexture *) object;
@@ -1243,13 +1237,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
 
         if(GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
             TRACE("(%p) Allocating data for an occlusion query\n", This);
+
+            ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
+            ENTER_GL();
             GL_EXTCALL(glGenQueriesARB(1, &((WineQueryOcclusionData *)(object->extendedData))->queryId));
+            LEAVE_GL();
             break;
         }
     case WINED3DQUERYTYPE_EVENT:
         object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
         ((WineQueryEventData *)(object->extendedData))->ctx = This->activeContext;
 
+        ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
+        ENTER_GL();
         if(GL_SUPPORT(APPLE_FENCE)) {
             GL_EXTCALL(glGenFencesAPPLE(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
             checkGLcall("glGenFencesAPPLE");
@@ -1257,6 +1257,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
             GL_EXTCALL(glGenFencesNV(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
             checkGLcall("glGenFencesNV");
         }
+        LEAVE_GL();
         break;
 
     case WINED3DQUERYTYPE_VCACHE:
@@ -1311,7 +1312,7 @@ static LONG fullscreen_exStyle(LONG orig_exStyle) {
     return exStyle;
 }
 
-static void WINAPI IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *iface, HWND window, UINT w, UINT h) {
+static void IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *iface, HWND window, UINT w, UINT h) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
 
     LONG style, exStyle;
@@ -1355,7 +1356,7 @@ static void WINAPI IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *ifac
  *  window: Window to setup
  *
  *****************************************************************************/
-static void WINAPI IWineD3DDeviceImpl_RestoreWindow(IWineD3DDevice *iface, HWND window) {
+static void IWineD3DDeviceImpl_RestoreWindow(IWineD3DDevice *iface, HWND window) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     LONG style, exStyle;
 
@@ -1934,7 +1935,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface
     return hr;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags, PALETTEENTRY *PalEnt, IWineD3DPalette **Palette, IUnknown *Parent) {
+static HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags,
+        const PALETTEENTRY *PalEnt, IWineD3DPalette **Palette, IUnknown *Parent)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     IWineD3DPaletteImpl *object;
     HRESULT hr;
@@ -2478,7 +2481,8 @@ static void WINAPI IWineD3DDeviceImpl_SetMultithreaded(IWineD3DDevice *iface) {
     return;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, WINED3DDISPLAYMODE* pMode) {
+static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain,
+        const WINED3DDISPLAYMODE* pMode) {
     DEVMODEW devmode;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     LONG ret;
@@ -2772,7 +2776,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetTransform(IWineD3DDevice *iface, WIN
 }
 
 static HRESULT WINAPI IWineD3DDeviceImpl_MultiplyTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE State, CONST WINED3DMATRIX* pMatrix) {
-    WINED3DMATRIX *mat = NULL;
+    const WINED3DMATRIX *mat = NULL;
     WINED3DMATRIX temp;
 
     /* Note: Using 'updateStateBlock' rather than 'stateblock' in the code
@@ -3541,7 +3545,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(
         TRACE("Set BOOL constant %u to %s\n", start + i, srcData[i]? "true":"false");
 
     for (i = start; i < cnt + start; ++i) {
-        This->updateStateBlock->changed.vertexShaderConstantsB[i] = TRUE;
+        This->updateStateBlock->changed.vertexShaderConstantsB |= (1 << i);
     }
 
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
@@ -3589,7 +3593,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(
            srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
 
     for (i = start; i < cnt + start; ++i) {
-        This->updateStateBlock->changed.vertexShaderConstantsI[i] = TRUE;
+        This->updateStateBlock->changed.vertexShaderConstantsI |= (1 << i);
     }
 
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
@@ -3806,7 +3810,8 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
 }
 
 static void device_map_psamplers(IWineD3DDeviceImpl *This) {
-    DWORD *sampler_tokens = ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.samplers;
+    const DWORD *sampler_tokens =
+            ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.samplers;
     int i;
 
     for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
@@ -3820,7 +3825,9 @@ static void device_map_psamplers(IWineD3DDeviceImpl *This) {
     }
 }
 
-static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, DWORD *pshader_sampler_tokens, DWORD *vshader_sampler_tokens, int unit) {
+static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshader_sampler_tokens,
+        const DWORD *vshader_sampler_tokens, int unit)
+{
     int current_mapping = This->rev_tex_unit_map[unit];
 
     if (current_mapping == -1) {
@@ -3845,8 +3852,9 @@ static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, DWORD *pshader_sam
 }
 
 static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
-    DWORD *vshader_sampler_tokens = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.samplers;
-    DWORD *pshader_sampler_tokens = NULL;
+    const DWORD *vshader_sampler_tokens =
+            ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.samplers;
+    const DWORD *pshader_sampler_tokens = NULL;
     int start = GL_LIMITS(combined_samplers) - 1;
     int i;
 
@@ -3854,7 +3862,7 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
         IWineD3DPixelShaderImpl *pshader = (IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader;
 
         /* Make sure the shader's reg_maps are up to date. This is only relevant for 1.x pixelshaders. */
-        IWineD3DPixelShader_CompileShader((IWineD3DPixelShader *)pshader);
+        IWineD3DPixelShader_UpdateSamplers((IWineD3DPixelShader *)pshader);
         pshader_sampler_tokens = pshader->baseShader.reg_maps.samplers;
     }
 
@@ -3970,7 +3978,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(
         TRACE("Set BOOL constant %u to %s\n", start + i, srcData[i]? "true":"false");
 
     for (i = start; i < cnt + start; ++i) {
-        This->updateStateBlock->changed.pixelShaderConstantsB[i] = TRUE;
+        This->updateStateBlock->changed.pixelShaderConstantsB |= (1 << i);
     }
 
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
@@ -4018,7 +4026,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(
            srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
 
     for (i = start; i < cnt + start; ++i) {
-        This->updateStateBlock->changed.pixelShaderConstantsI[i] = TRUE;
+        This->updateStateBlock->changed.pixelShaderConstantsI |= (1 << i);
     }
 
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
@@ -4140,8 +4148,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantF(
 }
 
 #define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
-static HRESULT
-process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount, WineDirect3DVertexStridedData *lpStrideData, IWineD3DVertexBufferImpl *dest, DWORD dwFlags) {
+static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount,
+        const WineDirect3DVertexStridedData *lpStrideData, IWineD3DVertexBufferImpl *dest, DWORD dwFlags)
+{
     char *dest_ptr, *dest_conv = NULL, *dest_conv_addr = NULL;
     unsigned int i;
     DWORD DestFVF = dest->fvf;
@@ -4173,7 +4182,7 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
             return E_OUTOFMEMORY;
         }
         if(dest->vbo) {
-            void *src;
+            const void *src;
             GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, dest->vbo));
             checkGLcall("glBindBufferARB");
             src = GL_EXTCALL(glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB));
@@ -4274,8 +4283,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
         if ( ((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZ ) ||
              ((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) ) {
             /* The position first */
-            float *p =
-              (float *) (((char *) lpStrideData->u.s.position.lpData) + i * lpStrideData->u.s.position.dwStride);
+            const float *p =
+                    (const float *)(lpStrideData->u.s.position.lpData + i * lpStrideData->u.s.position.dwStride);
             float x, y, z, rhw;
             TRACE("In: ( %06.2f %06.2f %06.2f )\n", p[0], p[1], p[2]);
 
@@ -4390,8 +4399,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
             if(dest_conv) dest_conv += sizeof(DWORD);
         }
         if (DestFVF & WINED3DFVF_NORMAL) {
-            float *normal =
-              (float *) (((float *) lpStrideData->u.s.normal.lpData) + i * lpStrideData->u.s.normal.dwStride);
+            const float *normal =
+                    (const float *)(lpStrideData->u.s.normal.lpData + i * lpStrideData->u.s.normal.dwStride);
             /* AFAIK this should go into the lighting information */
             FIXME("Didn't expect the destination to have a normal\n");
             copy_and_next(dest_ptr, normal, 3 * sizeof(float));
@@ -4401,8 +4410,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
         }
 
         if (DestFVF & WINED3DFVF_DIFFUSE) {
-            DWORD *color_d = 
-              (DWORD *) (((char *) lpStrideData->u.s.diffuse.lpData) + i * lpStrideData->u.s.diffuse.dwStride);
+            const DWORD *color_d =
+                    (const DWORD *)(lpStrideData->u.s.diffuse.lpData + i * lpStrideData->u.s.diffuse.dwStride);
             if(!color_d) {
                 static BOOL warned = FALSE;
 
@@ -4432,8 +4441,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
 
         if (DestFVF & WINED3DFVF_SPECULAR) { 
             /* What's the color value in the feedback buffer? */
-            DWORD *color_s = 
-              (DWORD *) (((char *) lpStrideData->u.s.specular.lpData) + i * lpStrideData->u.s.specular.dwStride);
+            const DWORD *color_s =
+                    (const DWORD *)(lpStrideData->u.s.specular.lpData + i * lpStrideData->u.s.specular.dwStride);
             if(!color_s) {
                 static BOOL warned = FALSE;
 
@@ -4462,8 +4471,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
         }
 
         for (tex_index = 0; tex_index < numTextures; tex_index++) {
-            float *tex_coord =
-              (float *) (((char *) lpStrideData->u.s.texCoords[tex_index].lpData) + 
+            const float *tex_coord =
+                    (const float *)(lpStrideData->u.s.texCoords[tex_index].lpData +
                             i * lpStrideData->u.s.texCoords[tex_index].dwStride);
             if(!tex_coord) {
                 ERR("No source texture, but destination requests one\n");
@@ -4901,25 +4910,29 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
         }
     }
     for(i = 0; i < MAX_CONST_I; i++) {
-        if(object->changed.vertexShaderConstantsI[i]) {
+        if (object->changed.vertexShaderConstantsI & (1 << i))
+        {
             object->contained_vs_consts_i[object->num_contained_vs_consts_i] = i;
             object->num_contained_vs_consts_i++;
         }
     }
     for(i = 0; i < MAX_CONST_B; i++) {
-        if(object->changed.vertexShaderConstantsB[i]) {
+        if (object->changed.vertexShaderConstantsB & (1 << i))
+        {
             object->contained_vs_consts_b[object->num_contained_vs_consts_b] = i;
             object->num_contained_vs_consts_b++;
         }
     }
     for(i = 0; i < MAX_CONST_I; i++) {
-        if(object->changed.pixelShaderConstantsI[i]) {
+        if (object->changed.pixelShaderConstantsI & (1 << i))
+        {
             object->contained_ps_consts_i[object->num_contained_ps_consts_i] = i;
             object->num_contained_ps_consts_i++;
         }
     }
     for(i = 0; i < MAX_CONST_B; i++) {
-        if(object->changed.pixelShaderConstantsB[i]) {
+        if (object->changed.pixelShaderConstantsB & (1 << i))
+        {
             object->contained_ps_consts_b[object->num_contained_ps_consts_b] = i;
             object->num_contained_ps_consts_b++;
         }
@@ -5018,7 +5031,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This,  IWineD3DSurfa
     unsigned int   i;
     WINED3DRECT curRect;
     RECT vp_rect;
-    WINED3DVIEWPORT *vp = &This->stateBlock->viewport;
+    const WINED3DVIEWPORT *vp = &This->stateBlock->viewport;
     UINT drawable_width, drawable_height;
     IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) This->stencilBufferTarget;
     IWineD3DSwapChainImpl *swapchain = NULL;
@@ -5131,7 +5144,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This,  IWineD3DSurfa
         /* Now process each rect in turn */
         for (i = 0; i < Count; i++) {
             /* Note gl uses lower left, width/height */
-            IntersectRect((RECT *) &curRect, &vp_rect, (RECT *) &pRects[i]);
+            IntersectRect((RECT *)&curRect, &vp_rect, (const RECT *)&pRects[i]);
             if(This->stateBlock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
                 IntersectRect((RECT *) &curRect, (RECT *) &curRect, &This->stateBlock->scissorRect);
             }
@@ -5399,7 +5412,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData) {
+static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *iface,
+        WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
+        const WineDirect3DVertexStridedData *DrawPrimStrideData)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
 
     /* Mark the state dirty until we have nicer tracking
@@ -5415,7 +5431,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *i
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData, UINT NumVertices, CONST void *pIndexData, WINED3DFORMAT IndexDataFormat) {
+static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface,
+        WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
+        const WineDirect3DVertexStridedData *DrawPrimStrideData, UINT NumVertices, const void *pIndexData,
+        WINED3DFORMAT IndexDataFormat)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     DWORD idxSize = (IndexDataFormat == WINED3DFMT_INDEX32 ? 4 : 2);
 
@@ -5607,7 +5627,7 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *if
 static HRESULT  WINAPI  IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, DWORD* pNumPasses) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     IWineD3DBaseTextureImpl *texture;
-    const GlPixelFormatDesc *gl_info;
+    const struct GlPixelFormatDesc *gl_info;
     DWORD i;
 
     TRACE("(%p) : %p\n", This, pNumPasses);
@@ -5759,10 +5779,11 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_GetCurrentTexturePalette(IWineD3DDevi
 
 static HRESULT  WINAPI  IWineD3DDeviceImpl_SetSoftwareVertexProcessing(IWineD3DDevice *iface, BOOL bSoftware) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    static BOOL showFixmes = TRUE;
-    if (showFixmes) {
+    static BOOL warned;
+    if (!warned)
+    {
         FIXME("(%p) : stub\n", This);
-        showFixmes = FALSE;
+        warned = TRUE;
     }
 
     This->softwareVertexProcessing = bSoftware;
@@ -5772,10 +5793,11 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_SetSoftwareVertexProcessing(IWineD3DD
 
 static BOOL     WINAPI  IWineD3DDeviceImpl_GetSoftwareVertexProcessing(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    static BOOL showFixmes = TRUE;
-    if (showFixmes) {
+    static BOOL warned;
+    if (!warned)
+    {
         FIXME("(%p) : stub\n", This);
-        showFixmes = FALSE;
+        warned = TRUE;
     }
     return This->softwareVertexProcessing;
 }
@@ -5801,11 +5823,12 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface
 
 static HRESULT  WINAPI  IWineD3DDeviceImpl_SetNPatchMode(IWineD3DDevice *iface, float nSegments) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    static BOOL showfixmes = TRUE;
+    static BOOL warned;
     if(nSegments != 0.0f) {
-        if( showfixmes) {
+        if (!warned)
+        {
             FIXME("(%p) : stub nSegments(%f)\n", This, nSegments);
-            showfixmes = FALSE;
+            warned = TRUE;
         }
     }
     return WINED3D_OK;
@@ -5813,10 +5836,11 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_SetNPatchMode(IWineD3DDevice *iface,
 
 static float    WINAPI  IWineD3DDeviceImpl_GetNPatchMode(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    static BOOL showfixmes = TRUE;
-    if( showfixmes) {
+    static BOOL warned;
+    if (!warned)
+    {
         FIXME("(%p) : stub returning(%f)\n", This, 0.0f);
-        showfixmes = FALSE;
+        warned = TRUE;
     }
     return 0.0f;
 }
@@ -5875,7 +5899,7 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
         return IWineD3DSurface_BltFast(pDestinationSurface,
                                         pDestPoint  ? pDestPoint->x : 0,
                                         pDestPoint  ? pDestPoint->y : 0,
-                                        pSourceSurface, (RECT *) pSourceRect, 0);
+                                        pSourceSurface, pSourceRect, 0);
     }
 
     if (destFormat == WINED3DFMT_UNKNOWN) {
@@ -6319,7 +6343,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface, IWineD
         memset(&BltFx, 0, sizeof(BltFx));
         BltFx.dwSize = sizeof(BltFx);
         BltFx.u5.dwFillColor = argb_to_fmt(color, surface->resource.format);
-        return IWineD3DSurface_Blt(pSurface, (RECT *) pRect, NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_NONE);
+        return IWineD3DSurface_Blt(pSurface, (const RECT *)pRect, NULL, NULL,
+                WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_NONE);
     }
 }
 
@@ -6443,7 +6468,8 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice
 }
 
 void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED3DRECT *src_rect,
-        IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) {
+        IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     GLbitfield mask = GL_COLOR_BUFFER_BIT; /* TODO: Support blitting depth/stencil surfaces */
     IWineD3DSwapChain *src_swapchain, *dst_swapchain;
@@ -6736,7 +6762,7 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
             This->cursorHeight = pSur->currentDesc.Height;
             if (SUCCEEDED(IWineD3DSurface_LockRect(pCursorBitmap, &rect, NULL, WINED3DLOCK_READONLY)))
             {
-                const GlPixelFormatDesc *glDesc;
+                const struct GlPixelFormatDesc *glDesc;
                 const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &GLINFO_LOCATION, &glDesc);
                 char *mem, *bits = (char *)rect.pBits;
                 GLint intfmt = glDesc->glInternal;
@@ -6914,7 +6940,8 @@ static HRESULT  WINAPI  IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice*
     return WINED3D_OK;
 }
 
-static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, WINED3DPRESENT_PARAMETERS* pPresentationParameters) {
+static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT_PARAMETERS* pPresentationParameters)
+{
     IWineD3DDeviceImpl *This = surface->resource.wineD3DDevice; /* for GL_SUPPORT */
 
     /* Reallocate proper memory for the front and back buffer and adjust their sizes */
@@ -6977,7 +7004,8 @@ static HRESULT WINAPI reset_unload_resources(IWineD3DResource *resource, void *d
     return S_OK;
 }
 
-static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, WINED3DPRESENT_PARAMETERS *pp) {
+static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, const WINED3DPRESENT_PARAMETERS *pp)
+{
     UINT i, count;
     WINED3DDISPLAYMODE m;
     HRESULT hr;
@@ -7291,7 +7319,7 @@ static void WINAPI IWineD3DDeviceImpl_SetGammaRamp(IWineD3DDevice * iface, UINT
     TRACE("Relaying  to swapchain\n");
 
     if (IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain) == WINED3D_OK) {
-        IWineD3DSwapChain_SetGammaRamp(swapchain, Flags, (WINED3DGAMMARAMP *)pRamp);
+        IWineD3DSwapChain_SetGammaRamp(swapchain, Flags, pRamp);
         IWineD3DSwapChain_Release(swapchain);
     }
     return;
@@ -7318,14 +7346,14 @@ static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT i
 * any handles to other resource held by the caller must be closed
 * (e.g. a texture should release all held surfaces because telling the device that it's been released.)
  *****************************************************/
-static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource){
+static void IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource){
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
 
     TRACE("(%p) : Adding Resource %p\n", This, resource);
     list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
 }
 
-static void WINAPI IWineD3DDeviceImpl_RemoveResource(IWineD3DDevice *iface, IWineD3DResource *resource){
+static void IWineD3DDeviceImpl_RemoveResource(IWineD3DDevice *iface, IWineD3DResource *resource){
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
 
     TRACE("(%p) : Removing resource %p\n", This, resource);
index 4a1846a..253860f 100644 (file)
@@ -154,20 +154,30 @@ static const shader_backend_t *select_shader_backend(UINT Adapter, WINED3DDEVTYP
 static const struct blit_shader *select_blit_implementation(UINT Adapter, WINED3DDEVTYPE DeviceType);
 
 /* lookup tables */
-int minLookup[MAX_LOOKUPS];
-int maxLookup[MAX_LOOKUPS];
+const int minLookup[MAX_LOOKUPS] =
+{
+    WINED3DTADDRESS_WRAP, /* WINELOOKUP_WARPPARAM */
+};
+
+const int maxLookup[MAX_LOOKUPS] =
+{
+    WINED3DTADDRESS_MIRRORONCE, /* WINELOOKUP_WARPPARAM */
+};
+
 DWORD *stateLookup[MAX_LOOKUPS];
 
-DWORD minMipLookup[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
-DWORD minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1] = {
-    {GL_NEAREST, GL_NEAREST, GL_NEAREST},
-    {GL_NEAREST, GL_NEAREST, GL_NEAREST},
-    {GL_NEAREST, GL_NEAREST, GL_NEAREST},
-    {GL_NEAREST, GL_NEAREST, GL_NEAREST},
+struct min_lookup minMipLookup[WINED3DTEXF_ANISOTROPIC + 1];
+const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
+{
+    {{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
+    {{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
+    {{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
+    {{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
 };
 
-DWORD magLookup[WINED3DTEXF_ANISOTROPIC + 1];
-DWORD magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] = {
+GLenum magLookup[WINED3DTEXF_ANISOTROPIC + 1];
+const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
+{
     GL_NEAREST, GL_NEAREST, GL_NEAREST, GL_NEAREST
 };
 
@@ -367,12 +377,8 @@ static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
 /* Set the shader type for this device, depending on the given capabilities,
  * the device type, and the user preferences in wined3d_settings */
 
-void select_shader_mode(
-    WineD3D_GL_Info *gl_info,
-    WINED3DDEVTYPE DeviceType,
-    int* ps_selected,
-    int* vs_selected) {
-
+static void select_shader_mode(const WineD3D_GL_Info *gl_info, WINED3DDEVTYPE DeviceType, int *ps_selected, int *vs_selected)
+{
     if (wined3d_settings.vs_mode == VS_NONE) {
         *vs_selected = SHADER_NONE;
     } else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested) {
@@ -450,7 +456,8 @@ static void select_shader_max_constants(
  **********************************************************/
 
 #define GLINFO_LOCATION (*gl_info)
-static inline BOOL test_arb_vs_offset_limit(WineD3D_GL_Info *gl_info) {
+static inline BOOL test_arb_vs_offset_limit(const WineD3D_GL_Info *gl_info)
+{
     GLuint prog;
     BOOL ret = FALSE;
     const char *testcode =
@@ -494,7 +501,7 @@ static DWORD ver_for_ext(GL_SupportedExt ext)
     return 0;
 }
 
-BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
+static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
     const char *GL_Extensions    = NULL;
     const char *WGL_Extensions   = NULL;
     const char *gl_string        = NULL;
@@ -1075,8 +1082,13 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
              * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
              */
             if(WINE_D3D9_CAPABLE(gl_info) && (gl_info->vs_nv_version == VS_VERSION_30)) {
+                /* Geforce GTX - highend */
+                if(strstr(gl_info->gl_renderer, "GTX 280")) {
+                    gl_info->gl_card = CARD_NVIDIA_GEFORCE_GTX280;
+                    vidmem = 1024;
+                }
                 /* Geforce9 - highend */
-                if(strstr(gl_info->gl_renderer, "9800")) {
+                else if(strstr(gl_info->gl_renderer, "9800")) {
                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_9800GT;
                     vidmem = 512;
                 }
@@ -1336,11 +1348,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
     else
         gl_info->vidmem = WINE_DEFAULT_VIDMEM;
 
-    /* Load all the lookup tables
-    TODO: It may be a good idea to make minLookup and maxLookup const and populate them in wined3d_private.h where they are declared */
-    minLookup[WINELOOKUP_WARPPARAM] = WINED3DTADDRESS_WRAP;
-    maxLookup[WINELOOKUP_WARPPARAM] = WINED3DTADDRESS_MIRRORONCE;
-
+    /* Load all the lookup tables */
     for (i = 0; i < MAX_LOOKUPS; i++) {
         stateLookup[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(*stateLookup[i]) * (1 + maxLookup[i] - minLookup[i]) );
     }
@@ -1363,19 +1371,21 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
              gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR : GL_NEAREST;
 
 
-    minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_NONE]     = GL_LINEAR;
-    minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_POINT]    = GL_LINEAR;
-    minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_LINEAR]   = GL_LINEAR;
-    minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_NONE]    = GL_NEAREST;
-    minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_POINT]   = GL_NEAREST_MIPMAP_NEAREST;
-    minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_LINEAR]  = GL_NEAREST_MIPMAP_LINEAR;
-    minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_NONE]   = GL_LINEAR;
-    minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_POINT]  = GL_LINEAR_MIPMAP_NEAREST;
-    minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR;
-    minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_NONE]   = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ?
-    GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
-    minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_POINT]  = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
-    minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_LINEAR] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
+    minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_NONE]     = GL_LINEAR;
+    minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_POINT]    = GL_LINEAR;
+    minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_LINEAR]   = GL_LINEAR;
+    minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_NONE]    = GL_NEAREST;
+    minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_POINT]   = GL_NEAREST_MIPMAP_NEAREST;
+    minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_LINEAR]  = GL_NEAREST_MIPMAP_LINEAR;
+    minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_NONE]   = GL_LINEAR;
+    minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_POINT]  = GL_LINEAR_MIPMAP_NEAREST;
+    minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR;
+    minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_NONE]
+            = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
+    minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_POINT]
+            = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
+    minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_LINEAR]
+            = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
 
 /* TODO: config lookups */
 
@@ -1527,7 +1537,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
     if (Adapter == 0 && !DEBUG_SINGLE_MODE) { /* Display */
         DEVMODEW DevModeW;
         int ModeIdx = 0;
-        int i = 0;
+        UINT i = 0;
         int j = 0;
 
         ZeroMemory(&DevModeW, sizeof(DevModeW));
@@ -1665,6 +1675,18 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Ad
     *(pIdentifier->Revision) = 0;
     *pIdentifier->DeviceIdentifier = IID_D3DDEVICE_D3DUID;
 
+    if(wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
+    {
+        TRACE_(d3d_caps)("Overriding pci device id with: %x\n", wined3d_settings.pci_device_id);
+        *(pIdentifier->DeviceId) = wined3d_settings.pci_device_id;
+    }
+
+    if(wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
+    {
+        TRACE_(d3d_caps)("Overriding pci vendor id with: %x\n", wined3d_settings.pci_vendor_id);
+        *(pIdentifier->VendorId) = wined3d_settings.pci_vendor_id;
+    }
+
     if (Flags & WINED3DENUM_NO_WHQL_LEVEL) {
         *(pIdentifier->WHQLLevel) = 0;
     } else {
@@ -1755,7 +1777,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT
                                                    WINED3DFORMAT DepthStencilFormat) {
     IWineD3DImpl *This = (IWineD3DImpl *)iface;
     int nCfgs;
-    WineD3D_PixelFormat *cfgs;
+    const WineD3D_PixelFormat *cfgs;
     int it;
 
     WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
@@ -1790,7 +1812,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
                                                        BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD*   pQualityLevels) {
 
     IWineD3DImpl *This = (IWineD3DImpl *)iface;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     const StaticPixelFormatDesc *desc;
 
     TRACE_(d3d_caps)("(%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
@@ -1823,7 +1845,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
 
     if(glDesc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) {
         int i, nCfgs;
-        WineD3D_PixelFormat *cfgs;
+        const WineD3D_PixelFormat *cfgs;
 
         cfgs = Adapters[Adapter].cfgs;
         nCfgs = Adapters[Adapter].nCfgs;
@@ -1844,7 +1866,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
     else if(glDesc->Flags & WINED3DFMT_FLAG_RENDERTARGET) {
         short redSize, greenSize, blueSize, alphaSize, colorBits;
         int i, nCfgs;
-        WineD3D_PixelFormat *cfgs;
+        const WineD3D_PixelFormat *cfgs;
 
         if(!getColorBits(SurfaceFormat, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
             ERR("Unable to color bits for format %#x, can't check multisampling capability!\n", SurfaceFormat);
@@ -1965,7 +1987,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter
 static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat)
 {
     const struct fragment_pipeline *fp;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
 
     switch(CheckFormat) {
         case WINED3DFMT_V8U8:
@@ -1973,24 +1995,18 @@ static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
         case WINED3DFMT_L6V5U5:
         case WINED3DFMT_X8L8V8U8:
         case WINED3DFMT_Q8W8V8U8:
+            /* Ask the fixed function pipeline implementation if it can deal
+             * with the conversion. If we've got a GL extension giving native
+             * support this will be an identity conversion. */
             getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
-            if(glDesc->conversion_group == WINED3DFMT_UNKNOWN) {
-                /* We have a GL extension giving native support */
-                TRACE_(d3d_caps)("[OK]\n");
-                return TRUE;
-            }
-
-            /* No native support: Ask the fixed function pipeline implementation if it
-             * can deal with the conversion
-             */
             fp = select_fragment_implementation(Adapter, DeviceType);
-            if(fp->conv_supported(CheckFormat)) {
+            if (fp->color_fixup_supported(glDesc->color_fixup))
+            {
                 TRACE_(d3d_caps)("[OK]\n");
                 return TRUE;
-            } else {
-                TRACE_(d3d_caps)("[FAILED]\n");
-                return FALSE;
             }
+            TRACE_(d3d_caps)("[FAILED]\n");
+            return FALSE;
 
         default:
             TRACE_(d3d_caps)("[FAILED]\n");
@@ -2002,7 +2018,7 @@ static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
 static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayFormat, WINED3DFORMAT DepthStencilFormat)
 {
     int it=0;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     const StaticPixelFormatDesc *desc = getFormatDescEntry(DepthStencilFormat, &GLINFO_LOCATION, &glDesc);
 
     /* Fail if we weren't able to get a description of the format */
@@ -2028,7 +2044,7 @@ static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayForma
 
 static BOOL CheckFilterCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
 {
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
 
     /* Fail if we weren't able to get a description of the format */
@@ -2046,7 +2062,7 @@ static BOOL CheckFilterCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
 static BOOL CheckRenderTargetCapability(WINED3DFORMAT AdapterFormat, WINED3DFORMAT CheckFormat)
 {
     UINT Adapter = 0;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
 
     /* Fail if we weren't able to get a description of the format */
@@ -2153,7 +2169,7 @@ static BOOL CheckSrgbWriteCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WI
 /* Check if a format support blending in combination with pixel shaders */
 static BOOL CheckPostPixelShaderBlendingCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
 {
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
 
     /* Fail if we weren't able to get a description of the format */
@@ -2185,7 +2201,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
 {
     const shader_backend_t *shader_backend;
     const struct fragment_pipeline *fp;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
 
     switch (CheckFormat) {
 
@@ -2260,25 +2276,18 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
         case WINED3DFMT_L6V5U5:
         case WINED3DFMT_Q8W8V8U8:
         case WINED3DFMT_V16U16:
-        case WINED3DFMT_W11V11U10:
+            /* Ask the shader backend if it can deal with the conversion. If
+             * we've got a GL extension giving native support this will be an
+             * identity conversion. */
             getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
-            if(glDesc->conversion_group == WINED3DFMT_UNKNOWN) {
-                /* We have a GL extension giving native support */
-                TRACE_(d3d_caps)("[OK]\n");
-                return TRUE;
-            }
-
-            /* No native support: Ask the fixed function pipeline implementation if it
-             * can deal with the conversion
-             */
             shader_backend = select_shader_backend(Adapter, DeviceType);
-            if(shader_backend->shader_conv_supported(CheckFormat)) {
+            if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup))
+            {
                 TRACE_(d3d_caps)("[OK]\n");
                 return TRUE;
-            } else {
-                TRACE_(d3d_caps)("[FAILED]\n");
-                return FALSE;
             }
+            TRACE_(d3d_caps)("[FAILED]\n");
+            return FALSE;
 
         case WINED3DFMT_DXT1:
         case WINED3DFMT_DXT2:
@@ -2301,6 +2310,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
         case WINED3DFMT_INDEX32:
         case WINED3DFMT_Q16W16V16U16:
         case WINED3DFMT_A2W10V10U10:
+        case WINED3DFMT_W11V11U10:
             TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
             return FALSE;
 
@@ -2383,10 +2393,12 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
         /* Vendor specific formats */
         case WINED3DFMT_ATI2N:
             if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {
+                getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
                 shader_backend = select_shader_backend(Adapter, DeviceType);
                 fp = select_fragment_implementation(Adapter, DeviceType);
-                if(shader_backend->shader_conv_supported(CheckFormat) &&
-                   fp->conv_supported(CheckFormat)) {
+                if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup)
+                        && fp->color_fixup_supported(glDesc->color_fixup))
+                {
                     TRACE_(d3d_caps)("[OK]\n");
                     return TRUE;
                 }
@@ -2419,6 +2431,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
 }
 
 static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT AdapterFormat, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE SurfaceType) {
+    const struct GlPixelFormatDesc *format_desc;
     const struct blit_shader *blitter;
 
     if(SurfaceType == SURFACE_GDI) {
@@ -2455,8 +2468,10 @@ static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT AdapterFormat, WI
     if(CheckDepthStencilCapability(Adapter, AdapterFormat, CheckFormat)) return TRUE;
 
     /* If opengl can't process the format natively, the blitter may be able to convert it */
+    getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &format_desc);
     blitter = select_blit_implementation(Adapter, DeviceType);
-    if(blitter->conv_supported(CheckFormat)) {
+    if (blitter->color_fixup_supported(format_desc->color_fixup))
+    {
         TRACE_(d3d_caps)("[OK]\n");
         return TRUE;
     }
@@ -3726,7 +3741,8 @@ ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pVolume) {
     return IUnknown_Release(volumeParent);
 }
 
-static BOOL implementation_is_apple(WineD3D_GL_Info *gl_info) {
+static BOOL implementation_is_apple(const WineD3D_GL_Info *gl_info)
+{
     /* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
      * the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
      * detect the Apple OpenGL implementation to apply some extension fixups afterwards.
@@ -3848,6 +3864,7 @@ static const struct driver_version_information driver_version_table[] = {
     {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_8800GTS,    7,  15, 11, 7341   },
     {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9600GT,     7,  15, 11, 7341    },
     {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_9800GT,     7,  15, 11, 7341    },
+    {VENDOR_NVIDIA,     CARD_NVIDIA_GEFORCE_GTX280,     7,  15, 11, 7341    },
 
     /* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode */
     {VENDOR_ATI,        CARD_ATI_RADEON_9500,           6,  14, 10, 6764    },
@@ -3964,12 +3981,14 @@ static void fixup_extensions(WineD3D_GL_Info *gl_info) {
     }
 }
 
-static void WINE_GLAPI invalid_func(void *data) {
+static void WINE_GLAPI invalid_func(const void *data)
+{
     ERR("Invalid vertex attribute function called\n");
     DebugBreak();
 }
 
-static void WINE_GLAPI invalid_texcoord_func(GLenum unit, void * data) {
+static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
+{
     ERR("Invalid texcoord function called\n");
     DebugBreak();
 }
@@ -3979,8 +3998,9 @@ static void WINE_GLAPI invalid_texcoord_func(GLenum unit, void * data) {
 /* Helper functions for providing vertex data to opengl. The arrays are initialized based on
  * the extension detection and are used in drawStridedSlow
  */
-static void WINE_GLAPI position_d3dcolor(void *data) {
-    DWORD pos = *((DWORD *) data);
+static void WINE_GLAPI position_d3dcolor(const void *data)
+{
+    DWORD pos = *((const DWORD *)data);
 
     FIXME("Add a test for fixed function position from d3dcolor type\n");
     glVertex4s(D3DCOLOR_B_R(pos),
@@ -3988,8 +4008,10 @@ static void WINE_GLAPI position_d3dcolor(void *data) {
                D3DCOLOR_B_B(pos),
                D3DCOLOR_B_A(pos));
 }
-static void WINE_GLAPI position_float4(void *data) {
-    GLfloat *pos = (float *) data;
+
+static void WINE_GLAPI position_float4(const void *data)
+{
+    const GLfloat *pos = data;
 
     if (pos[3] < eps && pos[3] > -eps)
         glVertex3fv(pos);
@@ -4000,8 +4022,9 @@ static void WINE_GLAPI position_float4(void *data) {
     }
 }
 
-static void WINE_GLAPI diffuse_d3dcolor(void *data) {
-    DWORD diffuseColor = *((DWORD *) data);
+static void WINE_GLAPI diffuse_d3dcolor(const void *data)
+{
+    DWORD diffuseColor = *((const DWORD *)data);
 
     glColor4ub(D3DCOLOR_B_R(diffuseColor),
                D3DCOLOR_B_G(diffuseColor),
@@ -4009,148 +4032,152 @@ static void WINE_GLAPI diffuse_d3dcolor(void *data) {
                D3DCOLOR_B_A(diffuseColor));
 }
 
-static void WINE_GLAPI specular_d3dcolor(void *data) {
-    DWORD specularColor = *((DWORD *) data);
+static void WINE_GLAPI specular_d3dcolor(const void *data)
+{
+    DWORD specularColor = *((const DWORD *)data);
 
     GL_EXTCALL(glSecondaryColor3ubEXT)(D3DCOLOR_B_R(specularColor),
                                        D3DCOLOR_B_G(specularColor),
                                        D3DCOLOR_B_B(specularColor));
 }
-static void WINE_GLAPI warn_no_specular_func(void *data) {
+
+static void WINE_GLAPI warn_no_specular_func(const void *data)
+{
     WARN("GL_EXT_secondary_color not supported\n");
 }
 
-void fillGLAttribFuncs(WineD3D_GL_Info *gl_info) {
-    position_funcs[WINED3DDECLTYPE_FLOAT1]      = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_FLOAT2]      = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_FLOAT3]      = (void *) glVertex3fv;
-    position_funcs[WINED3DDECLTYPE_FLOAT4]      = (void *) position_float4;
-    position_funcs[WINED3DDECLTYPE_D3DCOLOR]    = (void *) position_d3dcolor;
-    position_funcs[WINED3DDECLTYPE_UBYTE4]      = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_SHORT2]      = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_SHORT4]      = (void *) glVertex2sv;
-    position_funcs[WINED3DDECLTYPE_UBYTE4N]     = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_SHORT2N]     = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_SHORT4N]     = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_USHORT2N]    = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_USHORT4N]    = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_UDEC3]       = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_DEC3N]       = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_FLOAT16_2]   = (void *) invalid_func;
-    position_funcs[WINED3DDECLTYPE_FLOAT16_4]   = (void *) invalid_func;
-
-    diffuse_funcs[WINED3DDECLTYPE_FLOAT1]       = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_FLOAT2]       = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_FLOAT3]       = (void *) glColor3fv;
-    diffuse_funcs[WINED3DDECLTYPE_FLOAT4]       = (void *) glColor4fv;
-    diffuse_funcs[WINED3DDECLTYPE_D3DCOLOR]     = (void *) diffuse_d3dcolor;
-    diffuse_funcs[WINED3DDECLTYPE_UBYTE4]       = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_SHORT2]       = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_SHORT4]       = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_UBYTE4N]      = (void *) glColor4ubv;
-    diffuse_funcs[WINED3DDECLTYPE_SHORT2N]      = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_SHORT4N]      = (void *) glColor4sv;
-    diffuse_funcs[WINED3DDECLTYPE_USHORT2N]     = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_USHORT4N]     = (void *) glColor4usv;
-    diffuse_funcs[WINED3DDECLTYPE_UDEC3]        = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_DEC3N]        = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_FLOAT16_2]    = (void *) invalid_func;
-    diffuse_funcs[WINED3DDECLTYPE_FLOAT16_4]    = (void *) invalid_func;
+static void fillGLAttribFuncs(const WineD3D_GL_Info *gl_info)
+{
+    position_funcs[WINED3DDECLTYPE_FLOAT1]      = invalid_func;
+    position_funcs[WINED3DDECLTYPE_FLOAT2]      = invalid_func;
+    position_funcs[WINED3DDECLTYPE_FLOAT3]      = (glAttribFunc)glVertex3fv;
+    position_funcs[WINED3DDECLTYPE_FLOAT4]      = position_float4;
+    position_funcs[WINED3DDECLTYPE_D3DCOLOR]    = position_d3dcolor;
+    position_funcs[WINED3DDECLTYPE_UBYTE4]      = invalid_func;
+    position_funcs[WINED3DDECLTYPE_SHORT2]      = invalid_func;
+    position_funcs[WINED3DDECLTYPE_SHORT4]      = (glAttribFunc)glVertex2sv;
+    position_funcs[WINED3DDECLTYPE_UBYTE4N]     = invalid_func;
+    position_funcs[WINED3DDECLTYPE_SHORT2N]     = invalid_func;
+    position_funcs[WINED3DDECLTYPE_SHORT4N]     = invalid_func;
+    position_funcs[WINED3DDECLTYPE_USHORT2N]    = invalid_func;
+    position_funcs[WINED3DDECLTYPE_USHORT4N]    = invalid_func;
+    position_funcs[WINED3DDECLTYPE_UDEC3]       = invalid_func;
+    position_funcs[WINED3DDECLTYPE_DEC3N]       = invalid_func;
+    position_funcs[WINED3DDECLTYPE_FLOAT16_2]   = invalid_func;
+    position_funcs[WINED3DDECLTYPE_FLOAT16_4]   = invalid_func;
+
+    diffuse_funcs[WINED3DDECLTYPE_FLOAT1]       = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_FLOAT2]       = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_FLOAT3]       = (glAttribFunc)glColor3fv;
+    diffuse_funcs[WINED3DDECLTYPE_FLOAT4]       = (glAttribFunc)glColor4fv;
+    diffuse_funcs[WINED3DDECLTYPE_D3DCOLOR]     = diffuse_d3dcolor;
+    diffuse_funcs[WINED3DDECLTYPE_UBYTE4]       = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_SHORT2]       = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_SHORT4]       = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_UBYTE4N]      = (glAttribFunc)glColor4ubv;
+    diffuse_funcs[WINED3DDECLTYPE_SHORT2N]      = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_SHORT4N]      = (glAttribFunc)glColor4sv;
+    diffuse_funcs[WINED3DDECLTYPE_USHORT2N]     = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_USHORT4N]     = (glAttribFunc)glColor4usv;
+    diffuse_funcs[WINED3DDECLTYPE_UDEC3]        = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_DEC3N]        = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_FLOAT16_2]    = invalid_func;
+    diffuse_funcs[WINED3DDECLTYPE_FLOAT16_4]    = invalid_func;
 
     /* No 4 component entry points here */
-    specular_funcs[WINED3DDECLTYPE_FLOAT1]      = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_FLOAT2]      = (void *) invalid_func;
+    specular_funcs[WINED3DDECLTYPE_FLOAT1]      = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_FLOAT2]      = invalid_func;
     if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
-        specular_funcs[WINED3DDECLTYPE_FLOAT3]      = (void *) GL_EXTCALL(glSecondaryColor3fvEXT);
+        specular_funcs[WINED3DDECLTYPE_FLOAT3]      = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
     } else {
-        specular_funcs[WINED3DDECLTYPE_FLOAT3]      = (void *) warn_no_specular_func;
+        specular_funcs[WINED3DDECLTYPE_FLOAT3]      = warn_no_specular_func;
     }
-    specular_funcs[WINED3DDECLTYPE_FLOAT4]      = (void *) invalid_func;
+    specular_funcs[WINED3DDECLTYPE_FLOAT4]      = invalid_func;
     if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
-        specular_funcs[WINED3DDECLTYPE_D3DCOLOR]    = (void *) specular_d3dcolor;
+        specular_funcs[WINED3DDECLTYPE_D3DCOLOR]    = specular_d3dcolor;
     } else {
-        specular_funcs[WINED3DDECLTYPE_D3DCOLOR]      = (void *) warn_no_specular_func;
+        specular_funcs[WINED3DDECLTYPE_D3DCOLOR]      = warn_no_specular_func;
     }
-    specular_funcs[WINED3DDECLTYPE_UBYTE4]      = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_SHORT2]      = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_SHORT4]      = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_UBYTE4N]     = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_SHORT2N]     = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_SHORT4N]     = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_USHORT2N]    = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_USHORT4N]    = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_UDEC3]       = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_DEC3N]       = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_FLOAT16_2]   = (void *) invalid_func;
-    specular_funcs[WINED3DDECLTYPE_FLOAT16_4]   = (void *) invalid_func;
+    specular_funcs[WINED3DDECLTYPE_UBYTE4]      = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_SHORT2]      = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_SHORT4]      = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_UBYTE4N]     = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_SHORT2N]     = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_SHORT4N]     = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_USHORT2N]    = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_USHORT4N]    = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_UDEC3]       = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_DEC3N]       = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_FLOAT16_2]   = invalid_func;
+    specular_funcs[WINED3DDECLTYPE_FLOAT16_4]   = invalid_func;
 
     /* Only 3 component entry points here. Test how others behave. Float4 normals are used
      * by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
      */
-    normal_funcs[WINED3DDECLTYPE_FLOAT1]         = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_FLOAT2]         = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_FLOAT3]         = (void *) glNormal3fv;
-    normal_funcs[WINED3DDECLTYPE_FLOAT4]         = (void *) glNormal3fv; /* Just ignore the 4th value */
-    normal_funcs[WINED3DDECLTYPE_D3DCOLOR]       = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_UBYTE4]         = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_SHORT2]         = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_SHORT4]         = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_UBYTE4N]        = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_SHORT2N]        = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_SHORT4N]        = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_USHORT2N]       = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_USHORT4N]       = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_UDEC3]          = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_DEC3N]          = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_FLOAT16_2]      = (void *) invalid_func;
-    normal_funcs[WINED3DDECLTYPE_FLOAT16_4]      = (void *) invalid_func;
-
-    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT1]    = (void *) GL_EXTCALL(glMultiTexCoord1fvARB);
-    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT2]    = (void *) GL_EXTCALL(glMultiTexCoord2fvARB);
-    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT3]    = (void *) GL_EXTCALL(glMultiTexCoord3fvARB);
-    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT4]    = (void *) GL_EXTCALL(glMultiTexCoord4fvARB);
-    multi_texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR]  = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4]    = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2]    = (void *) GL_EXTCALL(glMultiTexCoord2svARB);
-    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4]    = (void *) GL_EXTCALL(glMultiTexCoord4svARB);
-    multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4N]   = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2N]   = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4N]   = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_USHORT2N]  = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_USHORT4N]  = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_UDEC3]     = (void *) invalid_texcoord_func;
-    multi_texcoord_funcs[WINED3DDECLTYPE_DEC3N]     = (void *) invalid_texcoord_func;
+    normal_funcs[WINED3DDECLTYPE_FLOAT1]         = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_FLOAT2]         = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_FLOAT3]         = (glAttribFunc)glNormal3fv;
+    normal_funcs[WINED3DDECLTYPE_FLOAT4]         = (glAttribFunc)glNormal3fv; /* Just ignore the 4th value */
+    normal_funcs[WINED3DDECLTYPE_D3DCOLOR]       = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_UBYTE4]         = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_SHORT2]         = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_SHORT4]         = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_UBYTE4N]        = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_SHORT2N]        = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_SHORT4N]        = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_USHORT2N]       = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_USHORT4N]       = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_UDEC3]          = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_DEC3N]          = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_FLOAT16_2]      = invalid_func;
+    normal_funcs[WINED3DDECLTYPE_FLOAT16_4]      = invalid_func;
+
+    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT1]    = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
+    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT2]    = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
+    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT3]    = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
+    multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT4]    = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
+    multi_texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR]  = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4]    = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2]    = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
+    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4]    = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
+    multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4N]   = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2N]   = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4N]   = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_USHORT2N]  = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_USHORT4N]  = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_UDEC3]     = invalid_texcoord_func;
+    multi_texcoord_funcs[WINED3DDECLTYPE_DEC3N]     = invalid_texcoord_func;
     if (GL_SUPPORT(NV_HALF_FLOAT))
     {
-        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) GL_EXTCALL(glMultiTexCoord2hvNV);
-        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) GL_EXTCALL(glMultiTexCoord4hvNV);
+        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
+        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
     } else {
-        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_texcoord_func;
-        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_texcoord_func;
+        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_texcoord_func;
+        multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_texcoord_func;
     }
 
-    texcoord_funcs[WINED3DDECLTYPE_FLOAT1]      = (void *) glTexCoord1fv;
-    texcoord_funcs[WINED3DDECLTYPE_FLOAT2]      = (void *) glTexCoord2fv;
-    texcoord_funcs[WINED3DDECLTYPE_FLOAT3]      = (void *) glTexCoord3fv;
-    texcoord_funcs[WINED3DDECLTYPE_FLOAT4]      = (void *) glTexCoord4fv;
-    texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR]    = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_UBYTE4]      = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_SHORT2]      = (void *) glTexCoord2sv;
-    texcoord_funcs[WINED3DDECLTYPE_SHORT4]      = (void *) glTexCoord4sv;
-    texcoord_funcs[WINED3DDECLTYPE_UBYTE4N]     = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_SHORT2N]     = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_SHORT4N]     = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_USHORT2N]    = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_USHORT4N]    = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_UDEC3]       = (void *) invalid_func;
-    texcoord_funcs[WINED3DDECLTYPE_DEC3N]       = (void *) invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_FLOAT1]      = (glAttribFunc)glTexCoord1fv;
+    texcoord_funcs[WINED3DDECLTYPE_FLOAT2]      = (glAttribFunc)glTexCoord2fv;
+    texcoord_funcs[WINED3DDECLTYPE_FLOAT3]      = (glAttribFunc)glTexCoord3fv;
+    texcoord_funcs[WINED3DDECLTYPE_FLOAT4]      = (glAttribFunc)glTexCoord4fv;
+    texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR]    = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_UBYTE4]      = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_SHORT2]      = (glAttribFunc)glTexCoord2sv;
+    texcoord_funcs[WINED3DDECLTYPE_SHORT4]      = (glAttribFunc)glTexCoord4sv;
+    texcoord_funcs[WINED3DDECLTYPE_UBYTE4N]     = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_SHORT2N]     = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_SHORT4N]     = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_USHORT2N]    = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_USHORT4N]    = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_UDEC3]       = invalid_func;
+    texcoord_funcs[WINED3DDECLTYPE_DEC3N]       = invalid_func;
     if (GL_SUPPORT(NV_HALF_FLOAT))
     {
-        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2]   = (void *) GL_EXTCALL(glTexCoord2hvNV);
-        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4]   = (void *) GL_EXTCALL(glTexCoord4hvNV);
+        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2]   = (glAttribFunc)GL_EXTCALL(glTexCoord2hvNV);
+        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4]   = (glAttribFunc)GL_EXTCALL(glTexCoord4hvNV);
     } else {
-        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2]   = (void *) invalid_func;
-        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4]   = (void *) invalid_func;
+        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2]   = invalid_func;
+        texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4]   = invalid_func;
     }
 }
 
index 545bad1..7603103 100644 (file)
@@ -142,14 +142,14 @@ void primitiveDeclarationConvertToStridedData(
 
      /* We need to deal with frequency data!*/
 
-    BYTE  *data    = NULL;
+    const BYTE *data = NULL;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
-    int i;
-    WINED3DVERTEXELEMENT *element;
+    unsigned int i;
+    const WINED3DVERTEXELEMENT *element;
     DWORD stride;
     DWORD numPreloadStreams = This->stateBlock->streamIsUP ? 0 : vertexDeclaration->num_streams;
-    DWORD *streams = vertexDeclaration->streams;
+    const DWORD *streams = vertexDeclaration->streams;
 
     /* Check for transformed vertices, disable vertex shader if present */
     strided->u.s.position_transformed = vertexDeclaration->position_transformed;
@@ -164,7 +164,7 @@ void primitiveDeclarationConvertToStridedData(
         unsigned int idx;
 
         element = vertexDeclaration->pDeclarationWine + i;
-        TRACE("%p Element %p (%d of %d)\n", vertexDeclaration->pDeclarationWine,
+        TRACE("%p Element %p (%u of %u)\n", vertexDeclaration->pDeclarationWine,
             element,  i + 1, vertexDeclaration->declarationWNumElements - 1);
 
         if (This->stateBlock->streamSource[element->Stream] == NULL)
@@ -286,21 +286,22 @@ static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum
  * Slower GL version which extracts info about each vertex in turn
  */
 
-static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd,
-                     UINT NumVertexes, GLenum glPrimType,
-                     const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) {
-
+static void drawStridedSlow(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT NumVertexes,
+        GLenum glPrimType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex)
+{
     unsigned int               textureNo    = 0;
     const WORD                *pIdxBufS     = NULL;
     const DWORD               *pIdxBufL     = NULL;
-    LONG                       vx_index;
+    ULONG                      vx_index;
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    UINT *streamOffset = This->stateBlock->streamOffset;
+    const UINT *streamOffset = This->stateBlock->streamOffset;
     long                      SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex;
     BOOL                      pixelShader = use_ps(This);
-
-    BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
-    BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
+    BOOL specular_fog = FALSE;
+    UINT texture_stages = GL_LIMITS(texture_stages);
+    const BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
+    const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
+    DWORD tex_mask = 0;
 
     TRACE("Using slow vertex array code\n");
 
@@ -321,56 +322,92 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
         return;
     }
 
-    /* Adding the stream offset once is cheaper than doing it every iteration. Do not modify the strided data, it is a pointer
-     * to the strided Data in the device and might be needed intact on the next draw
-     */
-    for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
-        if(sd->u.s.texCoords[textureNo].lpData) {
-            texCoords[textureNo] = sd->u.s.texCoords[textureNo].lpData + streamOffset[sd->u.s.texCoords[textureNo].streamNo];
-        } else {
-            texCoords[textureNo] = NULL;
-        }
-    }
-    if(sd->u.s.diffuse.lpData) {
-        diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
-    }
-    if(sd->u.s.specular.lpData) {
+    /* Start drawing in GL */
+    VTRACE(("glBegin(%x)\n", glPrimType));
+    glBegin(glPrimType);
+
+    if (sd->u.s.position.lpData) position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
+
+    if (sd->u.s.normal.lpData) normal = sd->u.s.normal.lpData + streamOffset[sd->u.s.normal.streamNo];
+    else glNormal3f(0, 0, 0);
+
+    if (sd->u.s.diffuse.lpData) diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
+    else glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    if (This->activeContext->num_untracked_materials && sd->u.s.diffuse.dwType != WINED3DDECLTYPE_D3DCOLOR)
+        FIXME("Implement diffuse color tracking from %s\n", debug_d3ddecltype(sd->u.s.diffuse.dwType));
+
+    if (sd->u.s.specular.lpData)
+    {
         specular = sd->u.s.specular.lpData + streamOffset[sd->u.s.specular.streamNo];
-    }
-    if(sd->u.s.normal.lpData) {
-        normal = sd->u.s.normal.lpData + streamOffset[sd->u.s.normal.streamNo];
-    }
-    if(sd->u.s.position.lpData) {
-        position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
-    }
 
-    if(FIXME_ON(d3d_draw)) {
-        if(specular && This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
-           (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position_transformed )&&
-           This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) {
-            if(GL_SUPPORT(EXT_FOG_COORD) && sd->u.s.specular.dwType != WINED3DDECLTYPE_D3DCOLOR) {
-                FIXME("Implement fog coordinates from %s\n", debug_d3ddecltype(sd->u.s.specular.dwType));
+        /* special case where the fog density is stored in the specular alpha channel */
+        if (This->stateBlock->renderState[WINED3DRS_FOGENABLE]
+                && (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE
+                    || sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4)
+                && This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
+        {
+            if (GL_SUPPORT(EXT_FOG_COORD))
+            {
+                if (sd->u.s.specular.dwType == WINED3DDECLTYPE_D3DCOLOR) specular_fog = TRUE;
+                else FIXME("Implement fog coordinates from %s\n", debug_d3ddecltype(sd->u.s.specular.dwType));
+            }
+            else
+            {
+                static BOOL warned;
+
+                if (!warned)
+                {
+                    /* TODO: Use the fog table code from old ddraw */
+                    FIXME("Implement fog for transformed vertices in software\n");
+                    warned = TRUE;
+                }
             }
         }
-        if(This->activeContext->num_untracked_materials && sd->u.s.diffuse.dwType != WINED3DDECLTYPE_D3DCOLOR) {
-            FIXME("Implement diffuse color tracking from %s\n", debug_d3ddecltype(sd->u.s.diffuse.dwType));
-        }
+    }
+    else if (GL_SUPPORT(EXT_SECONDARY_COLOR))
+    {
+        GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
     }
 
-    /* Start drawing in GL */
-    VTRACE(("glBegin(%x)\n", glPrimType));
-    glBegin(glPrimType);
+    for (textureNo = 0; textureNo < texture_stages; ++textureNo)
+    {
+        int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
+        int texture_idx = This->texUnitMap[textureNo];
 
-    /* Default settings for data that is not passed */
-    if (sd->u.s.normal.lpData == NULL) {
-        glNormal3f(0, 0, 0);
-    }
-    if(sd->u.s.diffuse.lpData == NULL) {
-        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-    }
-    if(sd->u.s.specular.lpData == NULL) {
-        if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
-            GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
+        if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0)
+        {
+            FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
+            continue;
+        }
+
+        if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;
+
+        if (texture_idx == -1) continue;
+
+        if (coordIdx > 7)
+        {
+            TRACE("tex: %d - Skip tex coords, as being system generated\n", textureNo);
+            continue;
+        }
+        else if (coordIdx < 0)
+        {
+            FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
+            continue;
+        }
+
+        if(sd->u.s.texCoords[coordIdx].lpData)
+        {
+            texCoords[coordIdx] =
+                    sd->u.s.texCoords[coordIdx].lpData + streamOffset[sd->u.s.texCoords[coordIdx].streamNo];
+            tex_mask |= (1 << textureNo);
+        }
+        else
+        {
+            TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
+            if (GL_SUPPORT(ARB_MULTITEXTURE))
+                GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
+            else
+                glTexCoord4f(0, 0, 0, 1);
         }
     }
 
@@ -380,6 +417,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
 
     /* For each primitive */
     for (vx_index = 0; vx_index < NumVertexes; ++vx_index) {
+        UINT texture, tmp_tex_mask;
         /* Blending data and Point sizes are not supported by this function. They are not supported by the fixed
          * function pipeline at all. A Fixme for them is printed after decoding the vertex declaration
          */
@@ -389,63 +427,43 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
 
             /* Indexed so work out the number of strides to skip */
             if (idxSize == 2) {
-                VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufS[startIdx+vx_index]));
+                VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufS[startIdx+vx_index]));
                 SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
             } else {
-                VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufL[startIdx+vx_index]));
+                VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufL[startIdx+vx_index]));
                 SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
             }
         }
 
-        /* Texture coords --------------------------- */
-        for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
-
-            if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) {
-                FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
-                continue ;
-            }
-
-            /* Query tex coords */
-            if (This->stateBlock->textures[textureNo] != NULL || pixelShader) {
-                int    coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
-                int texture_idx = This->texUnitMap[textureNo];
-                void *ptrToCoords;
-
-                if (coordIdx > 7) {
-                    VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
-                    continue;
-                } else if (coordIdx < 0) {
-                    FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
-                    continue;
-                }
+        tmp_tex_mask = tex_mask;
+        for (texture = 0; tmp_tex_mask; tmp_tex_mask >>= 1, ++texture)
+        {
+            int coord_idx;
+            const void *ptr;
 
-                if (texture_idx == -1) continue;
+            if (!(tmp_tex_mask & 1)) continue;
 
-                if (texCoords[coordIdx] == NULL) {
-                    TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
-                    if (GL_SUPPORT(ARB_MULTITEXTURE)) {
-                        GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
-                    } else {
-                        glTexCoord4f(0, 0, 0, 1);
-                    }
-                    continue;
-                }
+            coord_idx = This->stateBlock->textureState[texture][WINED3DTSS_TEXCOORDINDEX];
+            ptr = texCoords[coord_idx] + (SkipnStrides * sd->u.s.texCoords[coord_idx].dwStride);
 
-                ptrToCoords = texCoords[coordIdx] + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride);
-                if (GL_SUPPORT(ARB_MULTITEXTURE))
-                    multi_texcoord_funcs[sd->u.s.texCoords[coordIdx].dwType](GL_TEXTURE0_ARB + texture_idx, ptrToCoords);
-                else
-                    texcoord_funcs[sd->u.s.texCoords[coordIdx].dwType](ptrToCoords);
+            if (GL_SUPPORT(ARB_MULTITEXTURE))
+            {
+                int texture_idx = This->texUnitMap[texture];
+                multi_texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](GL_TEXTURE0_ARB + texture_idx, ptr);
             }
-        } /* End of textures */
+            else
+            {
+                texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](ptr);
+            }
+        }
 
         /* Diffuse -------------------------------- */
         if (diffuse) {
-            DWORD *ptrToCoords = (DWORD *)(diffuse + (SkipnStrides * sd->u.s.diffuse.dwStride));
+            const void *ptrToCoords = diffuse + SkipnStrides * sd->u.s.diffuse.dwStride;
 
-            diffuse_funcs[sd->u.s.diffuse.dwType]((void *) ptrToCoords);
+            diffuse_funcs[sd->u.s.diffuse.dwType](ptrToCoords);
             if(This->activeContext->num_untracked_materials) {
-                DWORD diffuseColor = ptrToCoords[0];
+                DWORD diffuseColor = ((const DWORD *)ptrToCoords)[0];
                 unsigned char i;
                 float color[4];
 
@@ -462,37 +480,26 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
 
         /* Specular ------------------------------- */
         if (specular) {
-            DWORD *ptrToCoords = (DWORD *)(specular + (SkipnStrides * sd->u.s.specular.dwStride));
-
-            /* special case where the fog density is stored in the specular alpha channel */
-            if(This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
-              (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4 )&&
-              This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) {
-                if(GL_SUPPORT(EXT_FOG_COORD)) {
-                    DWORD specularColor = ptrToCoords[0];
-                    GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
-                } else {
-                    static BOOL warned = FALSE;
-                    if(!warned) {
-                        /* TODO: Use the fog table code from old ddraw */
-                        FIXME("Implement fog for transformed vertices in software\n");
-                        warned = TRUE;
-                    }
-                }
-            }
+            const void *ptrToCoords = specular + SkipnStrides * sd->u.s.specular.dwStride;
 
-            specular_funcs[sd->u.s.specular.dwType]((void *) ptrToCoords);
+            specular_funcs[sd->u.s.specular.dwType](ptrToCoords);
+
+            if (specular_fog)
+            {
+                DWORD specularColor = *(const DWORD *)ptrToCoords;
+                GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
+            }
         }
 
         /* Normal -------------------------------- */
         if (normal != NULL) {
-            float *ptrToCoords = (float *)(normal + (SkipnStrides * sd->u.s.normal.dwStride));
+            const void *ptrToCoords = normal + SkipnStrides * sd->u.s.normal.dwStride;
             normal_funcs[sd->u.s.normal.dwType](ptrToCoords);
         }
 
         /* Position -------------------------------- */
         if (position) {
-            float *ptrToCoords = (float *)(position + (SkipnStrides * sd->u.s.position.dwStride));
+            const void *ptrToCoords = position + SkipnStrides * sd->u.s.position.dwStride;
             position_funcs[sd->u.s.position.dwType](ptrToCoords);
         }
 
@@ -509,16 +516,16 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
 static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, const UINT index, const void *ptr) {
     switch(type) {
         case WINED3DDECLTYPE_FLOAT1:
-            GL_EXTCALL(glVertexAttrib1fvARB(index, (float *) ptr));
+            GL_EXTCALL(glVertexAttrib1fvARB(index, (const float *)ptr));
             break;
         case WINED3DDECLTYPE_FLOAT2:
-            GL_EXTCALL(glVertexAttrib2fvARB(index, (float *) ptr));
+            GL_EXTCALL(glVertexAttrib2fvARB(index, (const float *)ptr));
             break;
         case WINED3DDECLTYPE_FLOAT3:
-            GL_EXTCALL(glVertexAttrib3fvARB(index, (float *) ptr));
+            GL_EXTCALL(glVertexAttrib3fvARB(index, (const float *)ptr));
             break;
         case WINED3DDECLTYPE_FLOAT4:
-            GL_EXTCALL(glVertexAttrib4fvARB(index, (float *) ptr));
+            GL_EXTCALL(glVertexAttrib4fvARB(index, (const float *)ptr));
             break;
 
         case WINED3DDECLTYPE_UBYTE4:
@@ -530,29 +537,29 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
             break;
 
         case WINED3DDECLTYPE_SHORT2:
-            GL_EXTCALL(glVertexAttrib4svARB(index, (GLshort *) ptr));
+            GL_EXTCALL(glVertexAttrib4svARB(index, (const GLshort *)ptr));
             break;
         case WINED3DDECLTYPE_SHORT4:
-            GL_EXTCALL(glVertexAttrib4svARB(index, (GLshort *) ptr));
+            GL_EXTCALL(glVertexAttrib4svARB(index, (const GLshort *)ptr));
             break;
 
         case WINED3DDECLTYPE_SHORT2N:
         {
-            GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1};
+            GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
             GL_EXTCALL(glVertexAttrib4NsvARB(index, s));
             break;
         }
         case WINED3DDECLTYPE_USHORT2N:
         {
-            GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1};
+            GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
             GL_EXTCALL(glVertexAttrib4NusvARB(index, s));
             break;
         }
         case WINED3DDECLTYPE_SHORT4N:
-            GL_EXTCALL(glVertexAttrib4NsvARB(index, (GLshort *) ptr));
+            GL_EXTCALL(glVertexAttrib4NsvARB(index, (const GLshort *)ptr));
             break;
         case WINED3DDECLTYPE_USHORT4N:
-            GL_EXTCALL(glVertexAttrib4NusvARB(index, (GLushort *) ptr));
+            GL_EXTCALL(glVertexAttrib4NusvARB(index, (const GLushort *)ptr));
             break;
 
         case WINED3DDECLTYPE_UDEC3:
@@ -569,21 +576,21 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
              * byte float according to the IEEE standard
              */
             if (GL_SUPPORT(NV_HALF_FLOAT)) {
-                GL_EXTCALL(glVertexAttrib2hvNV(index, (GLhalfNV *)ptr));
+                GL_EXTCALL(glVertexAttrib2hvNV(index, (const GLhalfNV *)ptr));
             } else {
-                float x = float_16_to_32(((unsigned short *) ptr) + 0);
-                float y = float_16_to_32(((unsigned short *) ptr) + 1);
+                float x = float_16_to_32(((const unsigned short *)ptr) + 0);
+                float y = float_16_to_32(((const unsigned short *)ptr) + 1);
                 GL_EXTCALL(glVertexAttrib2fARB(index, x, y));
             }
             break;
         case WINED3DDECLTYPE_FLOAT16_4:
             if (GL_SUPPORT(NV_HALF_FLOAT)) {
-                GL_EXTCALL(glVertexAttrib4hvNV(index, (GLhalfNV *)ptr));
+                GL_EXTCALL(glVertexAttrib4hvNV(index, (const GLhalfNV *)ptr));
             } else {
-                float x = float_16_to_32(((unsigned short *) ptr) + 0);
-                float y = float_16_to_32(((unsigned short *) ptr) + 1);
-                float z = float_16_to_32(((unsigned short *) ptr) + 2);
-                float w = float_16_to_32(((unsigned short *) ptr) + 3);
+                float x = float_16_to_32(((const unsigned short *)ptr) + 0);
+                float y = float_16_to_32(((const unsigned short *)ptr) + 1);
+                float z = float_16_to_32(((const unsigned short *)ptr) + 2);
+                float w = float_16_to_32(((const unsigned short *)ptr) + 3);
                 GL_EXTCALL(glVertexAttrib4fARB(index, x, y, z, w));
             }
             break;
@@ -595,18 +602,17 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
     }
 }
 
-static void drawStridedSlowVs(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
-                              GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx,
-                              ULONG startVertex) {
-
+static void drawStridedSlowVs(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
+        GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex)
+{
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     long                      SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex;
     const WORD                *pIdxBufS     = NULL;
     const DWORD               *pIdxBufL     = NULL;
-    LONG                       vx_index;
+    ULONG                      vx_index;
     int i;
     IWineD3DStateBlockImpl *stateblock = This->stateBlock;
-    BYTE *ptr;
+    const BYTE *ptr;
 
     if (idxSize != 0) {
         /* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer.
@@ -656,11 +662,12 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, WineDirect3DVertexStridedDa
     glEnd();
 }
 
-static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
-                                 GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex,
-                                 ULONG startIdx, ULONG startVertex) {
-    UINT numInstances = 0;
-    int numInstancedAttribs = 0, i, j;
+static inline void drawStridedInstanced(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd,
+        UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex,
+        ULONG startIdx, ULONG startVertex)
+{
+    UINT numInstances = 0, i;
+    int numInstancedAttribs = 0, j;
     UINT instancedData[sizeof(sd->u.input) / sizeof(sd->u.input[0]) /* 16 */];
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     IWineD3DStateBlockImpl *stateblock = This->stateBlock;
@@ -704,7 +711,7 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVerte
     for(i = 0; i < numInstances; i++) {
         /* Specify the instanced attributes using immediate mode calls */
         for(j = 0; j < numInstancedAttribs; j++) {
-            BYTE *ptr = sd->u.input[instancedData[j]].lpData +
+            const BYTE *ptr = sd->u.input[instancedData[j]].lpData +
                         sd->u.input[instancedData[j]].dwStride * i +
                         stateblock->streamOffset[sd->u.input[instancedData[j]].streamNo];
             if(sd->u.input[instancedData[j]].VBO) {
@@ -823,7 +830,7 @@ void drawPrimitive(IWineD3DDevice *iface,
 
     IWineD3DDeviceImpl           *This = (IWineD3DDeviceImpl *)iface;
     IWineD3DSurfaceImpl          *target;
-    int i;
+    unsigned int i;
 
     if (NumPrimitives == 0) return;
 
@@ -854,7 +861,7 @@ void drawPrimitive(IWineD3DDevice *iface,
     {
         GLenum glPrimType;
         BOOL emulation = FALSE;
-        WineDirect3DVertexStridedData *strided = &This->strided_streams;
+        const WineDirect3DVertexStridedData *strided = &This->strided_streams;
         WineDirect3DVertexStridedData stridedlcl;
         /* Ok, Work out which primitive is requested and how many vertexes that
            will be                                                              */
@@ -865,10 +872,10 @@ void drawPrimitive(IWineD3DDevice *iface,
         if(!use_vs(This)) {
             if(!This->strided_streams.u.s.position_transformed && This->activeContext->num_untracked_materials &&
                 This->stateBlock->renderState[WINED3DRS_LIGHTING]) {
-                static BOOL first = TRUE;
-                if(first) {
+                static BOOL warned;
+                if (!warned) {
                     FIXME("Using software emulation because not all material properties could be tracked\n");
-                    first = FALSE;
+                    warned = TRUE;
                 } else {
                     TRACE("Using software emulation because not all material properties could be tracked\n");
                 }
@@ -878,10 +885,10 @@ void drawPrimitive(IWineD3DDevice *iface,
                 /* Either write a pipeline replacement shader or convert the specular alpha from unsigned byte
                  * to a float in the vertex buffer
                  */
-                static BOOL first = TRUE;
-                if(first) {
+                static BOOL warned;
+                if (!warned) {
                     FIXME("Using software emulation because manual fog coordinates are provided\n");
-                    first = FALSE;
+                    warned = TRUE;
                 } else {
                     TRACE("Using software emulation because manual fog coordinates are provided\n");
                 }
@@ -898,10 +905,10 @@ void drawPrimitive(IWineD3DDevice *iface,
         if (This->useDrawStridedSlow || emulation) {
             /* Immediate mode drawing */
             if(use_vs(This)) {
-                static BOOL first = TRUE;
-                if(first) {
+                static BOOL warned;
+                if (!warned) {
                     FIXME("Using immediate mode with vertex shaders for half float emulation\n");
-                    first = FALSE;
+                    warned = TRUE;
                 } else {
                     TRACE("Using immediate mode with vertex shaders for half float emulation\n");
                 }
@@ -1005,8 +1012,8 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
     unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size;
     float max_x = 0.0, max_y = 0.0, max_z = 0.0, neg_z = 0.0;
     WineDirect3DVertexStridedData strided;
-    BYTE *data;
-    WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo;
+    const BYTE *data;
+    const WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo;
     DWORD vtxStride;
     GLenum feedback_type;
     GLfloat *feedbuffer;
@@ -1048,7 +1055,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
     /* First, get the boundary cube of the input data */
     for(j = 0; j < info->Height; j++) {
         for(i = 0; i < info->Width; i++) {
-            float *v = (float *) (data + vtxStride * i + vtxStride * info->Stride * j);
+            const float *v = (const float *)(data + vtxStride * i + vtxStride * info->Stride * j);
             if(fabs(v[0]) > max_x) max_x = fabs(v[0]);
             if(fabs(v[1]) > max_y) max_y = fabs(v[1]);
             if(fabs(v[2]) > max_z) max_z = fabs(v[2]);
@@ -1085,11 +1092,11 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
     checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
     IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_FILLMODE));
     if(patch->has_normals) {
-        float black[4] = {0, 0, 0, 0};
-        float red[4]   = {1, 0, 0, 0};
-        float green[4] = {0, 1, 0, 0};
-        float blue[4]  = {0, 0, 1, 0};
-        float white[4] = {1, 1, 1, 1};
+        const GLfloat black[4] = {0, 0, 0, 0};
+        const GLfloat red[4]   = {1, 0, 0, 0};
+        const GLfloat green[4] = {0, 1, 0, 0};
+        const GLfloat blue[4]  = {0, 0, 1, 0};
+        const GLfloat white[4] = {1, 1, 1, 1};
         glEnable(GL_LIGHTING);
         checkGLcall("glEnable(GL_LIGHTING)");
         glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black);
@@ -1172,13 +1179,13 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
     glMap2f(GL_MAP2_VERTEX_3,
             0, 1, vtxStride / sizeof(float), info->Width,
             0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
-            (float *) data);
+            (const GLfloat *)data);
     checkGLcall("glMap2f");
     if(patch->has_texcoords) {
         glMap2f(GL_MAP2_TEXTURE_COORD_4,
                 0, 1, vtxStride / sizeof(float), info->Width,
                 0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
-                (float *) data);
+                (const GLfloat *)data);
         checkGLcall("glMap2f");
     }
     glMapGrid2f(ceilf(patch->numSegs[0]), 0.0, 1.0, ceilf(patch->numSegs[1]), 0.0, 1.0);
@@ -1256,9 +1263,9 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
 
     if(patch->has_normals) {
         /* Now do the same with reverse light directions */
-        float x[4] = {-1,  0,  0, 0};
-        float y[4] = { 0, -1,  0, 0};
-        float z[4] = { 0,  0, -1, 0};
+        const GLfloat x[4] = {-1,  0,  0, 0};
+        const GLfloat y[4] = { 0, -1,  0, 0};
+        const GLfloat z[4] = { 0,  0, -1, 0};
         glLightfv(GL_LIGHT0, GL_POSITION, x);
         glLightfv(GL_LIGHT1, GL_POSITION, y);
         glLightfv(GL_LIGHT2, GL_POSITION, z);
index bb9a871..4c1d223 100644 (file)
@@ -35,6 +35,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
 WINE_DECLARE_DEBUG_CHANNEL(d3d_constants);
 WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
+WINE_DECLARE_DEBUG_CHANNEL(d3d);
 
 #define GLINFO_LOCATION      (*gl_info)
 
@@ -56,42 +57,43 @@ typedef struct {
 /* GLSL shader private data */
 struct shader_glsl_priv {
     struct hash_table_t *glsl_program_lookup;
-    struct glsl_shader_prog_link *glsl_program;
+    const struct glsl_shader_prog_link *glsl_program;
     GLhandleARB depth_blt_program[tex_type_count];
 };
 
 /* Struct to maintain data about a linked GLSL program */
 struct glsl_shader_prog_link {
-    struct list             vshader_entry;
-    struct list             pshader_entry;
-    GLhandleARB             programId;
-    GLhandleARB             *vuniformF_locations;
-    GLhandleARB             *puniformF_locations;
-    GLhandleARB             vuniformI_locations[MAX_CONST_I];
-    GLhandleARB             puniformI_locations[MAX_CONST_I];
-    GLhandleARB             posFixup_location;
-    GLhandleARB             bumpenvmat_location[MAX_TEXTURES];
-    GLhandleARB             luminancescale_location[MAX_TEXTURES];
-    GLhandleARB             luminanceoffset_location[MAX_TEXTURES];
-    GLhandleARB             srgb_comparison_location;
-    GLhandleARB             srgb_mul_low_location;
-    GLhandleARB             ycorrection_location;
-    GLenum                  vertex_color_clamp;
-    GLhandleARB             vshader;
-    GLhandleARB             pshader;
+    struct list                 vshader_entry;
+    struct list                 pshader_entry;
+    GLhandleARB                 programId;
+    GLhandleARB                 *vuniformF_locations;
+    GLhandleARB                 *puniformF_locations;
+    GLhandleARB                 vuniformI_locations[MAX_CONST_I];
+    GLhandleARB                 puniformI_locations[MAX_CONST_I];
+    GLhandleARB                 posFixup_location;
+    GLhandleARB                 bumpenvmat_location[MAX_TEXTURES];
+    GLhandleARB                 luminancescale_location[MAX_TEXTURES];
+    GLhandleARB                 luminanceoffset_location[MAX_TEXTURES];
+    GLhandleARB                 ycorrection_location;
+    GLenum                      vertex_color_clamp;
+    GLhandleARB                 vshader;
+    IWineD3DPixelShader         *pshader;
+    struct ps_compile_args      ps_args;
 };
 
 typedef struct {
-    GLhandleARB vshader;
-    GLhandleARB pshader;
+    GLhandleARB                 vshader;
+    IWineD3DPixelShader         *pshader;
+    struct ps_compile_args      ps_args;
 } glsl_program_key_t;
 
 
 /** Prints the GLSL info log which will contain error messages if they exist */
-static void print_glsl_info_log(WineD3D_GL_Info *gl_info, GLhandleARB obj) {
+static void print_glsl_info_log(const WineD3D_GL_Info *gl_info, GLhandleARB obj)
+{
     int infologLength = 0;
     char *infoLog;
-    int i;
+    unsigned int i;
     BOOL is_spam;
 
     const char *spam[] = {
@@ -140,11 +142,8 @@ static void print_glsl_info_log(WineD3D_GL_Info *gl_info, GLhandleARB obj) {
 /**
  * Loads (pixel shader) samplers
  */
-static void shader_glsl_load_psamplers(
-    WineD3D_GL_Info *gl_info,
-    IWineD3DStateBlock* iface,
-    GLhandleARB programId) {
-
+static void shader_glsl_load_psamplers(const WineD3D_GL_Info *gl_info, IWineD3DStateBlock *iface, GLhandleARB programId)
+{
     IWineD3DStateBlockImpl* stateBlock = (IWineD3DStateBlockImpl*) iface;
     GLhandleARB name_loc;
     int i;
@@ -166,7 +165,8 @@ static void shader_glsl_load_psamplers(
     }
 }
 
-static void shader_glsl_load_vsamplers(WineD3D_GL_Info *gl_info, IWineD3DStateBlock* iface, GLhandleARB programId) {
+static void shader_glsl_load_vsamplers(const WineD3D_GL_Info *gl_info, IWineD3DStateBlock *iface, GLhandleARB programId)
+{
     IWineD3DStateBlockImpl* stateBlock = (IWineD3DStateBlockImpl*) iface;
     GLhandleARB name_loc;
     char sampler_name[20];
@@ -192,14 +192,15 @@ static void shader_glsl_load_vsamplers(WineD3D_GL_Info *gl_info, IWineD3DStateBl
  * Loads floating point constants (aka uniforms) into the currently set GLSL program.
  * When constant_list == NULL, it will load all the constants.
  */
-static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl* This, WineD3D_GL_Info *gl_info,
-        unsigned int max_constants, float* constants, GLhandleARB *constant_locations,
-        struct list *constant_list) {
-    constants_entry *constant;
-    local_constant* lconst;
+static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl *This, const WineD3D_GL_Info *gl_info,
+        unsigned int max_constants, const float *constants, const GLhandleARB *constant_locations,
+        const struct list *constant_list)
+{
+    const constants_entry *constant;
+    const local_constant *lconst;
     GLhandleARB tmp_loc;
     DWORD i, j, k;
-    DWORD *idx;
+    const DWORD *idx;
 
     if (TRACE_ON(d3d_shader)) {
         LIST_FOR_EACH_ENTRY(constant, constant_list, constants_entry, entry) {
@@ -274,7 +275,7 @@ static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl* This, WineD3D_GL
         LIST_FOR_EACH_ENTRY(lconst, &This->baseShader.constantsF, local_constant, entry) {
             tmp_loc = constant_locations[lconst->idx];
             if (tmp_loc != -1) {
-                GLfloat* values = (GLfloat*)lconst->value;
+                const GLfloat *values = (const GLfloat *)lconst->value;
                 TRACE_(d3d_constants)("Loading local constants %i: %f, %f, %f, %f\n", lconst->idx,
                         values[0], values[1], values[2], values[3]);
             }
@@ -285,46 +286,37 @@ static void shader_glsl_load_constantsF(IWineD3DBaseShaderImpl* This, WineD3D_GL
         tmp_loc = constant_locations[lconst->idx];
         if (tmp_loc != -1) {
             /* We found this uniform name in the program - go ahead and send the data */
-            GL_EXTCALL(glUniform4fvARB(tmp_loc, 1, (GLfloat*)lconst->value));
+            GL_EXTCALL(glUniform4fvARB(tmp_loc, 1, (const GLfloat *)lconst->value));
         }
     }
     checkGLcall("glUniform4fvARB()");
 }
 
-/** 
- * Loads integer constants (aka uniforms) into the currently set GLSL program.
- * When @constants_set == NULL, it will load all the constants.
- */
-static void shader_glsl_load_constantsI(
-    IWineD3DBaseShaderImpl* This,
-    WineD3D_GL_Info *gl_info,
-    GLhandleARB programId,
-    GLhandleARB locations[MAX_CONST_I],
-    unsigned max_constants,
-    int* constants,
-    BOOL* constants_set) {
-    
-    int i;
+/* Loads integer constants (aka uniforms) into the currently set GLSL program. */
+static void shader_glsl_load_constantsI(IWineD3DBaseShaderImpl *This, const WineD3D_GL_Info *gl_info,
+        const GLhandleARB locations[MAX_CONST_I], const int *constants, WORD constants_set)
+{
+    unsigned int i;
     struct list* ptr;
 
-    for (i=0; i<max_constants; ++i) {
-        if (NULL == constants_set || constants_set[i]) {
+    for (i = 0; constants_set; constants_set >>= 1, ++i)
+    {
+        if (!(constants_set & 1)) continue;
 
-            TRACE_(d3d_constants)("Loading constants %i: %i, %i, %i, %i\n",
-                  i, constants[i*4], constants[i*4+1], constants[i*4+2], constants[i*4+3]);
+        TRACE_(d3d_constants)("Loading constants %u: %i, %i, %i, %i\n",
+                i, constants[i*4], constants[i*4+1], constants[i*4+2], constants[i*4+3]);
 
-            /* We found this uniform name in the program - go ahead and send the data */
-            GL_EXTCALL(glUniform4ivARB(locations[i], 1, &constants[i*4]));
-            checkGLcall("glUniform4ivARB");
-        }
+        /* We found this uniform name in the program - go ahead and send the data */
+        GL_EXTCALL(glUniform4ivARB(locations[i], 1, &constants[i*4]));
+        checkGLcall("glUniform4ivARB");
     }
 
     /* Load immediate constants */
     ptr = list_head(&This->baseShader.constantsI);
     while (ptr) {
-        local_constant* lconst = LIST_ENTRY(ptr, struct local_constant, entry);
+        const struct local_constant *lconst = LIST_ENTRY(ptr, const struct local_constant, entry);
         unsigned int idx = lconst->idx;
-        GLint* values = (GLint*) lconst->value;
+        const GLint *values = (const GLint *)lconst->value;
 
         TRACE_(d3d_constants)("Loading local constants %i: %i, %i, %i, %i\n", idx,
             values[0], values[1], values[2], values[3]);
@@ -336,48 +328,43 @@ static void shader_glsl_load_constantsI(
     }
 }
 
-/** 
- * Loads boolean constants (aka uniforms) into the currently set GLSL program.
- * When @constants_set == NULL, it will load all the constants.
- */
-static void shader_glsl_load_constantsB(
-    IWineD3DBaseShaderImpl* This,
-    WineD3D_GL_Info *gl_info,
-    GLhandleARB programId,
-    unsigned max_constants,
-    BOOL* constants,
-    BOOL* constants_set) {
-    
+/* Loads boolean constants (aka uniforms) into the currently set GLSL program. */
+static void shader_glsl_load_constantsB(IWineD3DBaseShaderImpl *This, const WineD3D_GL_Info *gl_info,
+        GLhandleARB programId, const BOOL *constants, WORD constants_set)
+{
     GLhandleARB tmp_loc;
-    int i;
+    unsigned int i;
     char tmp_name[8];
     char is_pshader = shader_is_pshader_version(This->baseShader.hex_version);
     const char* prefix = is_pshader? "PB":"VB";
     struct list* ptr;
 
-    for (i=0; i<max_constants; ++i) {
-        if (NULL == constants_set || constants_set[i]) {
+    /* TODO: Benchmark and see if it would be beneficial to store the
+     * locations of the constants to avoid looking up each time */
+    for (i = 0; constants_set; constants_set >>= 1, ++i)
+    {
+        if (!(constants_set & 1)) continue;
 
-            TRACE_(d3d_constants)("Loading constants %i: %i;\n", i, constants[i]);
+        TRACE_(d3d_constants)("Loading constants %i: %i;\n", i, constants[i]);
 
-            /* TODO: Benchmark and see if it would be beneficial to store the 
-             * locations of the constants to avoid looking up each time */
-            snprintf(tmp_name, sizeof(tmp_name), "%s[%i]", prefix, i);
-            tmp_loc = GL_EXTCALL(glGetUniformLocationARB(programId, tmp_name));
-            if (tmp_loc != -1) {
-                /* We found this uniform name in the program - go ahead and send the data */
-                GL_EXTCALL(glUniform1ivARB(tmp_loc, 1, &constants[i]));
-                checkGLcall("glUniform1ivARB");
-            }
+        /* TODO: Benchmark and see if it would be beneficial to store the
+         * locations of the constants to avoid looking up each time */
+        snprintf(tmp_name, sizeof(tmp_name), "%s[%i]", prefix, i);
+        tmp_loc = GL_EXTCALL(glGetUniformLocationARB(programId, tmp_name));
+        if (tmp_loc != -1)
+        {
+            /* We found this uniform name in the program - go ahead and send the data */
+            GL_EXTCALL(glUniform1ivARB(tmp_loc, 1, &constants[i]));
+            checkGLcall("glUniform1ivARB");
         }
     }
 
     /* Load immediate constants */
     ptr = list_head(&This->baseShader.constantsB);
     while (ptr) {
-        local_constant* lconst = LIST_ENTRY(ptr, struct local_constant, entry);
+        const struct local_constant *lconst = LIST_ENTRY(ptr, const struct local_constant, entry);
         unsigned int idx = lconst->idx;
-        GLint* values = (GLint*) lconst->value;
+        const GLint *values = (const GLint *)lconst->value;
 
         TRACE_(d3d_constants)("Loading local constants %i: %i\n", idx, values[0]);
 
@@ -403,15 +390,15 @@ static void shader_glsl_load_constants(
     char useVertexShader) {
    
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
-    struct shader_glsl_priv *priv = (struct shader_glsl_priv *)deviceImpl->shader_priv;
+    const struct shader_glsl_priv *priv = (struct shader_glsl_priv *)deviceImpl->shader_priv;
     IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
-    WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
 
-    GLhandleARB *constant_locations;
-    struct list *constant_list;
+    const GLhandleARB *constant_locations;
+    const struct list *constant_list;
     GLhandleARB programId;
-    struct glsl_shader_prog_link *prog = priv->glsl_program;
-    unsigned int i;
+    const struct glsl_shader_prog_link *prog = priv->glsl_program;
+    int i;
 
     if (!prog) {
         /* No GLSL program set - nothing to do. */
@@ -430,15 +417,12 @@ static void shader_glsl_load_constants(
                 stateBlock->vertexShaderConstantF, constant_locations, constant_list);
 
         /* Load DirectX 9 integer constants/uniforms for vertex shader */
-        shader_glsl_load_constantsI(vshader, gl_info, programId,
-                                    prog->vuniformI_locations, MAX_CONST_I,
-                                    stateBlock->vertexShaderConstantI,
-                                    stateBlock->changed.vertexShaderConstantsI);
+        shader_glsl_load_constantsI(vshader, gl_info, prog->vuniformI_locations,
+                stateBlock->vertexShaderConstantI, stateBlock->changed.vertexShaderConstantsI);
 
         /* Load DirectX 9 boolean constants/uniforms for vertex shader */
-        shader_glsl_load_constantsB(vshader, gl_info, programId, MAX_CONST_B,
-                                    stateBlock->vertexShaderConstantB,
-                                    stateBlock->changed.vertexShaderConstantsB);
+        shader_glsl_load_constantsB(vshader, gl_info, programId,
+                stateBlock->vertexShaderConstantB, stateBlock->changed.vertexShaderConstantsB);
 
         /* Upload the position fixup params */
         GL_EXTCALL(glUniform4fvARB(prog->posFixup_location, 1, &deviceImpl->posFixup[0]));
@@ -457,15 +441,12 @@ static void shader_glsl_load_constants(
                 stateBlock->pixelShaderConstantF, constant_locations, constant_list);
 
         /* Load DirectX 9 integer constants/uniforms for pixel shader */
-        shader_glsl_load_constantsI(pshader, gl_info, programId,
-                                    prog->puniformI_locations, MAX_CONST_I,
-                                    stateBlock->pixelShaderConstantI, 
-                                    stateBlock->changed.pixelShaderConstantsI);
+        shader_glsl_load_constantsI(pshader, gl_info, prog->puniformI_locations,
+                stateBlock->pixelShaderConstantI, stateBlock->changed.pixelShaderConstantsI);
 
         /* Load DirectX 9 boolean constants/uniforms for pixel shader */
-        shader_glsl_load_constantsB(pshader, gl_info, programId, MAX_CONST_B,
-                                    stateBlock->pixelShaderConstantB, 
-                                    stateBlock->changed.pixelShaderConstantsB);
+        shader_glsl_load_constantsB(pshader, gl_info, programId,
+                stateBlock->pixelShaderConstantB, stateBlock->changed.pixelShaderConstantsB);
 
         /* Upload the environment bump map matrix if needed. The needsbumpmat member specifies the texture stage to load the matrix from.
          * It can't be 0 for a valid texbem instruction.
@@ -474,7 +455,7 @@ static void shader_glsl_load_constants(
             IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) pshader;
             int stage = ps->luminanceconst[i].texunit;
 
-            float *data = (float *) &stateBlock->textureState[(int) ps->bumpenvmatconst[i].texunit][WINED3DTSS_BUMPENVMAT00];
+            const float *data = (const float *)&stateBlock->textureState[(int)ps->bumpenvmatconst[i].texunit][WINED3DTSS_BUMPENVMAT00];
             GL_EXTCALL(glUniformMatrix2fvARB(prog->bumpenvmat_location[i], 1, 0, data));
             checkGLcall("glUniformMatrix2fvARB");
 
@@ -482,8 +463,8 @@ static void shader_glsl_load_constants(
              * is set too, so we can check that in the needsbumpmat check
              */
             if(ps->baseShader.reg_maps.luminanceparams[stage]) {
-                GLfloat *scale = (GLfloat *) &stateBlock->textureState[stage][WINED3DTSS_BUMPENVLSCALE];
-                GLfloat *offset = (GLfloat *) &stateBlock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET];
+                const GLfloat *scale = (const GLfloat *)&stateBlock->textureState[stage][WINED3DTSS_BUMPENVLSCALE];
+                const GLfloat *offset = (const GLfloat *)&stateBlock->textureState[stage][WINED3DTSS_BUMPENVLOFFSET];
 
                 GL_EXTCALL(glUniform1fvARB(prog->luminancescale_location[i], 1, scale));
                 checkGLcall("glUniform1fvARB");
@@ -492,28 +473,6 @@ static void shader_glsl_load_constants(
             }
         }
 
-        if(((IWineD3DPixelShaderImpl *) pshader)->srgb_enabled &&
-                  !((IWineD3DPixelShaderImpl *) pshader)->srgb_mode_hardcoded) {
-            float comparison[4];
-            float mul_low[4];
-
-            if(stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE]) {
-                comparison[0] = srgb_cmp; comparison[1] = srgb_cmp;
-                comparison[2] = srgb_cmp; comparison[3] = srgb_cmp;
-
-                mul_low[0] = srgb_mul_low; mul_low[1] = srgb_mul_low;
-                mul_low[2] = srgb_mul_low; mul_low[3] = srgb_mul_low;
-            } else {
-                comparison[0] = 1.0 / 0.0; comparison[1] = 1.0 / 0.0;
-                comparison[2] = 1.0 / 0.0; comparison[3] = 1.0 / 0.0;
-
-                mul_low[0] = 1.0; mul_low[1] = 1.0;
-                mul_low[2] = 1.0; mul_low[3] = 1.0;
-            }
-
-            GL_EXTCALL(glUniform4fvARB(prog->srgb_comparison_location, 1, comparison));
-            GL_EXTCALL(glUniform4fvARB(prog->srgb_mul_low_location, 1, mul_low));
-        }
         if(((IWineD3DPixelShaderImpl *) pshader)->vpos_uniform) {
             float correction_params[4];
             if(deviceImpl->render_offscreen) {
@@ -530,17 +489,13 @@ static void shader_glsl_load_constants(
 }
 
 /** Generate the variable & register declarations for the GLSL output target */
-static void shader_generate_glsl_declarations(
-    IWineD3DBaseShader *iface,
-    shader_reg_maps* reg_maps,
-    SHADER_BUFFER* buffer,
-    WineD3D_GL_Info* gl_info) {
-
+static void shader_generate_glsl_declarations(IWineD3DBaseShader *iface, const shader_reg_maps *reg_maps,
+        SHADER_BUFFER *buffer, const WineD3D_GL_Info *gl_info)
+{
     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device;
-    int i;
-    unsigned int extra_constants_needed = 0;
-    local_constant* lconst;
+    unsigned int i, extra_constants_needed = 0;
+    const local_constant *lconst;
 
     /* There are some minor differences between pixel and vertex shaders */
     char pshader = shader_is_pshader_version(This->baseShader.hex_version);
@@ -608,27 +563,10 @@ static void shader_generate_glsl_declarations(
         }
 
         if(device->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE]) {
-            ps_impl->srgb_enabled = 1;
-            if(This->baseShader.limits.constant_float + extra_constants_needed + 1 < GL_LIMITS(pshader_constantsF)) {
-                shader_addline(buffer, "uniform vec4 srgb_mul_low;\n");
-                shader_addline(buffer, "uniform vec4 srgb_comparison;\n");
-                ps_impl->srgb_mode_hardcoded = 0;
-                extra_constants_needed++;
-            } else {
-                ps_impl->srgb_mode_hardcoded = 1;
-                shader_addline(buffer, "const vec4 srgb_mul_low = vec4(%f, %f, %f, %f);\n",
-                               srgb_mul_low, srgb_mul_low, srgb_mul_low, srgb_mul_low);
-                shader_addline(buffer, "const vec4 srgb_comparison = vec4(%f, %f, %f, %f);\n",
-                               srgb_cmp, srgb_cmp, srgb_cmp, srgb_cmp);
-            }
-        } else {
-            IWineD3DPixelShaderImpl *ps_impl = (IWineD3DPixelShaderImpl *) This;
-
-            /* Do not write any srgb fixup into the shader to save shader size and processing time.
-             * As a consequence, we can't toggle srgb write on without recompilation
-             */
-            ps_impl->srgb_enabled = 0;
-            ps_impl->srgb_mode_hardcoded = 1;
+            shader_addline(buffer, "const vec4 srgb_mul_low = vec4(%f, %f, %f, %f);\n",
+                            srgb_mul_low, srgb_mul_low, srgb_mul_low, srgb_mul_low);
+            shader_addline(buffer, "const vec4 srgb_comparison = vec4(%f, %f, %f, %f);\n",
+                            srgb_cmp, srgb_cmp, srgb_cmp, srgb_cmp);
         }
         if(reg_maps->vpos || reg_maps->usesdsy) {
             if(This->baseShader.limits.constant_float + extra_constants_needed + 1 < GL_LIMITS(pshader_constantsF)) {
@@ -772,7 +710,7 @@ static void shader_generate_glsl_declarations(
  ****************************************************************************/
 
 /* Prototypes */
-static void shader_glsl_add_src_param(SHADER_OPCODE_ARG* arg, const DWORD param,
+static void shader_glsl_add_src_param(const SHADER_OPCODE_ARG *arg, const DWORD param,
         const DWORD addr_token, DWORD mask, glsl_src_param_t *src_param);
 
 /** Used for opcode modifiers - They multiply the result by the specified amount */
@@ -854,13 +792,9 @@ static void shader_glsl_gen_modifier (
 
 /** Writes the GLSL variable name that corresponds to the register that the
  * DX opcode parameter is trying to access */
-static void shader_glsl_get_register_name(
-    const DWORD param,
-    const DWORD addr_token,
-    char* regstr,
-    BOOL* is_color,
-    SHADER_OPCODE_ARG* arg) {
-
+static void shader_glsl_get_register_name(const DWORD param, const DWORD addr_token,
+        char *regstr, BOOL *is_color, const SHADER_OPCODE_ARG *arg)
+{
     /* oPos, oFog and oPts in D3D */
     static const char * const hwrastout_reg_names[] = { "gl_Position", "gl_FogFragCoord", "gl_PointSize" };
 
@@ -868,7 +802,7 @@ static void shader_glsl_get_register_name(
     DWORD regtype = shader_get_regtype(param);
     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
-    WineD3D_GL_Info* gl_info = &deviceImpl->adapter->gl_info;
+    const WineD3D_GL_Info* gl_info = &deviceImpl->adapter->gl_info;
 
     char pshader = shader_is_pshader_version(This->baseShader.hex_version);
     char tmpStr[150];
@@ -1103,8 +1037,9 @@ static void shader_glsl_get_swizzle(const DWORD param, BOOL fixup, DWORD mask, c
 /* From a given parameter token, generate the corresponding GLSL string.
  * Also, return the actual register name and swizzle in case the
  * caller needs this information as well. */
-static void shader_glsl_add_src_param(SHADER_OPCODE_ARG* arg, const DWORD param,
-        const DWORD addr_token, DWORD mask, glsl_src_param_t *src_param) {
+static void shader_glsl_add_src_param(const SHADER_OPCODE_ARG *arg, const DWORD param,
+        const DWORD addr_token, DWORD mask, glsl_src_param_t *src_param)
+{
     BOOL is_color = FALSE;
     char swizzle_str[6];
 
@@ -1121,8 +1056,9 @@ static void shader_glsl_add_src_param(SHADER_OPCODE_ARG* arg, const DWORD param,
 /* From a given parameter token, generate the corresponding GLSL string.
  * Also, return the actual register name and swizzle in case the
  * caller needs this information as well. */
-static DWORD shader_glsl_add_dst_param(SHADER_OPCODE_ARG* arg, const DWORD param,
-        const DWORD addr_token, glsl_dst_param_t *dst_param) {
+static DWORD shader_glsl_add_dst_param(const SHADER_OPCODE_ARG* arg, const DWORD param,
+        const DWORD addr_token, glsl_dst_param_t *dst_param)
+{
     BOOL is_color = FALSE;
 
     dst_param->mask_str[0] = '\0';
@@ -1133,7 +1069,8 @@ static DWORD shader_glsl_add_dst_param(SHADER_OPCODE_ARG* arg, const DWORD param
 }
 
 /* Append the destination part of the instruction to the buffer, return the effective write mask */
-static DWORD shader_glsl_append_dst_ext(SHADER_BUFFER *buffer, SHADER_OPCODE_ARG *arg, const DWORD param) {
+static DWORD shader_glsl_append_dst_ext(SHADER_BUFFER *buffer, const SHADER_OPCODE_ARG *arg, const DWORD param)
+{
     glsl_dst_param_t dst_param;
     DWORD mask;
     int shift;
@@ -1149,13 +1086,14 @@ static DWORD shader_glsl_append_dst_ext(SHADER_BUFFER *buffer, SHADER_OPCODE_ARG
 }
 
 /* Append the destination part of the instruction to the buffer, return the effective write mask */
-static DWORD shader_glsl_append_dst(SHADER_BUFFER *buffer, SHADER_OPCODE_ARG *arg) {
+static DWORD shader_glsl_append_dst(SHADER_BUFFER *buffer, const SHADER_OPCODE_ARG *arg)
+{
     return shader_glsl_append_dst_ext(buffer, arg, arg->dst);
 }
 
 /** Process GLSL instruction modifiers */
-void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG* arg) {
-    
+void shader_glsl_add_instruction_modifiers(const SHADER_OPCODE_ARG* arg)
+{
     DWORD mask = arg->dst & WINED3DSP_DSTMOD_MASK;
  
     if (arg->opcode->dst_token && mask != 0) {
@@ -1225,198 +1163,112 @@ static void shader_glsl_get_sample_function(DWORD sampler_type, BOOL projected,
     }
 }
 
-static void shader_glsl_color_correction(SHADER_OPCODE_ARG* arg) {
-    IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
-    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) shader->baseShader.device;
-    WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
-    glsl_dst_param_t dst_param;
-    glsl_dst_param_t dst_param2;
-    WINED3DFORMAT fmt;
-    WINED3DFORMAT conversion_group;
-    IWineD3DBaseTextureImpl *texture;
-    DWORD mask, mask_size;
-    UINT i;
-    BOOL recorded = FALSE;
-    DWORD sampler_idx;
-    DWORD hex_version = shader->baseShader.hex_version;
-
-    switch(arg->opcode->opcode) {
-        case WINED3DSIO_TEX:
-            if (hex_version < WINED3DPS_VERSION(2,0)) {
-                sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
-            } else {
-                sampler_idx = arg->src[1] & WINED3DSP_REGNUM_MASK;
-            }
+static void shader_glsl_append_fixup_arg(char *arguments, const char *reg_name,
+        BOOL sign_fixup, enum fixup_channel_source channel_source)
+{
+    switch(channel_source)
+    {
+        case CHANNEL_SOURCE_ZERO:
+            strcat(arguments, "0.0");
             break;
 
-        case WINED3DSIO_TEXLDL:
-            FIXME("Add color fixup for vertex texture WINED3DSIO_TEXLDL\n");
-            return;
-
-        case WINED3DSIO_TEXDP3TEX:
-        case WINED3DSIO_TEXM3x3TEX:
-        case WINED3DSIO_TEXM3x3SPEC:
-        case WINED3DSIO_TEXM3x3VSPEC:
-        case WINED3DSIO_TEXBEM:
-        case WINED3DSIO_TEXREG2AR:
-        case WINED3DSIO_TEXREG2GB:
-        case WINED3DSIO_TEXREG2RGB:
-            sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
+        case CHANNEL_SOURCE_ONE:
+            strcat(arguments, "1.0");
             break;
 
-        default:
-            /* Not a texture sampling instruction, nothing to do */
-            return;
-    };
-
-    texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler_idx];
-    if(texture) {
-        fmt = texture->resource.format;
-        conversion_group = texture->baseTexture.shader_conversion_group;
-    } else {
-        fmt = WINED3DFMT_UNKNOWN;
-        conversion_group = WINED3DFMT_UNKNOWN;
-    }
-
-    /* before doing anything, record the sampler with the format in the format conversion list,
-     * but check if it's not there already
-     */
-    for(i = 0; i < shader->baseShader.num_sampled_samplers; i++) {
-        if(shader->baseShader.sampled_samplers[i] == sampler_idx) {
-            recorded = TRUE;
-            break;
-        }
-    }
-    if(!recorded) {
-        shader->baseShader.sampled_samplers[shader->baseShader.num_sampled_samplers] = sampler_idx;
-        shader->baseShader.num_sampled_samplers++;
-        shader->baseShader.sampled_format[sampler_idx] = conversion_group;
-    }
-
-    switch(fmt) {
-        case WINED3DFMT_V8U8:
-        case WINED3DFMT_V16U16:
-            if(GL_SUPPORT(NV_TEXTURE_SHADER) && fmt == WINED3DFMT_V8U8) {
-                /* The 3rd channel returns 1.0 in d3d, but 0.0 in gl. Fix this while we're at it :-) */
-                mask = shader_glsl_add_dst_param(arg, arg->dst, WINED3DSP_WRITEMASK_2, &dst_param);
-                mask_size = shader_glsl_get_write_mask_size(mask);
-                if(mask_size >= 3) {
-                    shader_addline(arg->buffer, "%s.%c = 1.0;\n", dst_param.reg_name, dst_param.mask_str[3]);
-                }
-            } else {
-                /* Correct the sign, but leave the blue as it is - it was loaded correctly already */
-                mask = shader_glsl_add_dst_param(arg, arg->dst,
-                                          WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1,
-                                          &dst_param);
-                mask_size = shader_glsl_get_write_mask_size(mask);
-                if(mask_size >= 2) {
-                    shader_addline(arg->buffer, "%s.%c%c = %s.%c%c * 2.0 - 1.0;\n",
-                    dst_param.reg_name, dst_param.mask_str[1], dst_param.mask_str[2],
-                    dst_param.reg_name, dst_param.mask_str[1], dst_param.mask_str[2]);
-                } else if(mask_size == 1) {
-                    shader_addline(arg->buffer, "%s.%c = %s.%c * 2.0 - 1.0;\n", dst_param.reg_name, dst_param.mask_str[1],
-                    dst_param.reg_name, dst_param.mask_str[1]);
-                }
-            }
+        case CHANNEL_SOURCE_X:
+            strcat(arguments, reg_name);
+            strcat(arguments, ".x");
             break;
 
-        case WINED3DFMT_X8L8V8U8:
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
-                /* Red and blue are the signed channels, fix them up; Blue(=L) is correct already,
-                 * and a(X) is always 1.0
-                 */
-                mask = shader_glsl_add_dst_param(arg, arg->dst, WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);
-                mask_size = shader_glsl_get_write_mask_size(mask);
-                if(mask_size >= 2) {
-                    shader_addline(arg->buffer, "%s.%c%c = %s.%c%c * 2.0 - 1.0;\n",
-                                   dst_param.reg_name, dst_param.mask_str[1], dst_param.mask_str[2],
-                                   dst_param.reg_name, dst_param.mask_str[1], dst_param.mask_str[2]);
-                } else if(mask_size == 1) {
-                    shader_addline(arg->buffer, "%s.%c = %s.%c * 2.0 - 1.0;\n",
-                                   dst_param.reg_name, dst_param.mask_str[1],
-                                   dst_param.reg_name, dst_param.mask_str[1]);
-                }
-            }
+        case CHANNEL_SOURCE_Y:
+            strcat(arguments, reg_name);
+            strcat(arguments, ".y");
             break;
 
-        case WINED3DFMT_L6V5U5:
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
-                mask = shader_glsl_add_dst_param(arg, arg->dst, WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);
-                mask_size = shader_glsl_get_write_mask_size(mask);
-                shader_glsl_add_dst_param(arg, arg->dst, WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_2, &dst_param2);
-                if(mask_size >= 3) {
-                    /* Swap y and z (U and L), and do a sign conversion on x and the new y(V and U) */
-                    shader_addline(arg->buffer, "tmp0.g = %s.%c;\n",
-                                   dst_param.reg_name, dst_param.mask_str[2]);
-                    shader_addline(arg->buffer, "%s.%c%c = %s.%c%c * 2.0 - 1.0;\n",
-                                   dst_param.reg_name, dst_param.mask_str[2], dst_param.mask_str[1],
-                                   dst_param2.reg_name, dst_param.mask_str[1], dst_param.mask_str[3]);
-                    shader_addline(arg->buffer, "%s.%c = tmp0.g;\n", dst_param.reg_name,
-                                   dst_param.mask_str[3]);
-                } else if(mask_size == 2) {
-                    /* This is bad: We have VL, but we need VU */
-                    FIXME("2 components sampled from a converted L6V5U5 texture\n");
-                } else {
-                    shader_addline(arg->buffer, "%s.%c = %s.%c * 2.0 - 1.0;\n",
-                                   dst_param.reg_name, dst_param.mask_str[1],
-                                   dst_param2.reg_name, dst_param.mask_str[1]);
-                }
-            }
-            break;
-
-        case WINED3DFMT_Q8W8V8U8:
-            if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
-                /* Correct the sign in all channels. The writemask just applies as-is, no
-                 * need for checking the mask size
-                 */
-                shader_glsl_add_dst_param(arg, arg->dst,
-                                          WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 |
-                                          WINED3DSP_WRITEMASK_2 | WINED3DSP_WRITEMASK_3,
-                                          &dst_param);
-                shader_addline(arg->buffer, "%s%s = %s%s * 2.0 - 1.0;\n", dst_param.reg_name, dst_param.mask_str,
-                               dst_param.reg_name, dst_param.mask_str);
-            }
+        case CHANNEL_SOURCE_Z:
+            strcat(arguments, reg_name);
+            strcat(arguments, ".z");
             break;
 
-        case WINED3DFMT_ATI2N:
-            /* GL_ATI_texture_compression_3dc returns the two channels as luminance-alpha,
-             * which means the first one is replicated across .rgb, and the 2nd one is in
-             * .a. We need the 2nd in .g
-             *
-             * GL_EXT_texture_compression_rgtc returns the values in .rg, however, they
-             * are swapped compared to d3d. So swap red and green.
-             */
-            mask = shader_glsl_add_dst_param(arg, arg->dst, WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1, &dst_param);
-            mask_size = shader_glsl_get_write_mask_size(mask);
-            if(GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {
-                if(mask_size >= 2) {
-                    shader_addline(arg->buffer, "%s.%c%c = %s.%c%c;\n",
-                                dst_param.reg_name, dst_param.mask_str[1],
-                                                    dst_param.mask_str[2],
-                                dst_param.reg_name, dst_param.mask_str[2],
-                                                    dst_param.mask_str[1]);
-                } else {
-                    FIXME("%u components sampled from a converted ATI2N texture\n", mask_size);
-                }
-            } else {
-                if(mask_size == 4) {
-                    /* Swap y and z (U and L), and do a sign conversion on x and the new y(V and U) */
-                    shader_addline(arg->buffer, "%s.%c = %s.%c;\n",
-                                dst_param.reg_name, dst_param.mask_str[2],
-                                dst_param.reg_name, dst_param.mask_str[4]);
-                } else if(mask_size == 1) {
-                    /* Nothing to do */
-                } else {
-                    FIXME("%u components sampled from a converted ATI2N texture\n", mask_size);
-                    /* This is bad: We have .r[gb], but we need .ra */
-                }
-            }
+        case CHANNEL_SOURCE_W:
+            strcat(arguments, reg_name);
+            strcat(arguments, ".w");
             break;
 
-            /* stupid compiler */
         default:
+            FIXME("Unhandled channel source %#x\n", channel_source);
+            strcat(arguments, "undefined");
             break;
     }
+
+    if (sign_fixup) strcat(arguments, " * 2.0 - 1.0");
+}
+
+static void shader_glsl_color_correction(const struct SHADER_OPCODE_ARG *arg, struct color_fixup_desc fixup)
+{
+    unsigned int mask_size, remaining;
+    glsl_dst_param_t dst_param;
+    char arguments[256];
+    DWORD mask;
+    BOOL dummy;
+
+    mask = 0;
+    if (fixup.x_sign_fixup || fixup.x_source != CHANNEL_SOURCE_X) mask |= WINED3DSP_WRITEMASK_0;
+    if (fixup.y_sign_fixup || fixup.y_source != CHANNEL_SOURCE_Y) mask |= WINED3DSP_WRITEMASK_1;
+    if (fixup.z_sign_fixup || fixup.z_source != CHANNEL_SOURCE_Z) mask |= WINED3DSP_WRITEMASK_2;
+    if (fixup.w_sign_fixup || fixup.w_source != CHANNEL_SOURCE_W) mask |= WINED3DSP_WRITEMASK_3;
+    mask &= arg->dst;
+
+    if (!mask) return; /* Nothing to do */
+
+    if (is_yuv_fixup(fixup))
+    {
+        enum yuv_fixup yuv_fixup = get_yuv_fixup(fixup);
+        FIXME("YUV fixup (%#x) not supported\n", yuv_fixup);
+        return;
+    }
+
+    mask_size = shader_glsl_get_write_mask_size(mask);
+
+    dst_param.mask_str[0] = '\0';
+    shader_glsl_get_write_mask(mask, dst_param.mask_str);
+
+    dst_param.reg_name[0] = '\0';
+    shader_glsl_get_register_name(arg->dst, arg->dst_addr, dst_param.reg_name, &dummy, arg);
+
+    arguments[0] = '\0';
+    remaining = mask_size;
+    if (mask & WINED3DSP_WRITEMASK_0)
+    {
+        shader_glsl_append_fixup_arg(arguments, dst_param.reg_name, fixup.x_sign_fixup, fixup.x_source);
+        if (--remaining) strcat(arguments, ", ");
+    }
+    if (mask & WINED3DSP_WRITEMASK_1)
+    {
+        shader_glsl_append_fixup_arg(arguments, dst_param.reg_name, fixup.y_sign_fixup, fixup.y_source);
+        if (--remaining) strcat(arguments, ", ");
+    }
+    if (mask & WINED3DSP_WRITEMASK_2)
+    {
+        shader_glsl_append_fixup_arg(arguments, dst_param.reg_name, fixup.z_sign_fixup, fixup.z_source);
+        if (--remaining) strcat(arguments, ", ");
+    }
+    if (mask & WINED3DSP_WRITEMASK_3)
+    {
+        shader_glsl_append_fixup_arg(arguments, dst_param.reg_name, fixup.w_sign_fixup, fixup.w_source);
+        if (--remaining) strcat(arguments, ", ");
+    }
+
+    if (mask_size > 1)
+    {
+        shader_addline(arg->buffer, "%s%s = vec%u(%s);\n",
+                dst_param.reg_name, dst_param.mask_str, mask_size, arguments);
+    }
+    else
+    {
+        shader_addline(arg->buffer, "%s%s = %s;\n", dst_param.reg_name, dst_param.mask_str, arguments);
+    }
 }
 
 /*****************************************************************************
@@ -1426,7 +1278,8 @@ static void shader_glsl_color_correction(SHADER_OPCODE_ARG* arg) {
  ****************************************************************************/
 
 /* Generate GLSL arithmetic functions (dst = src1 + src2) */
-static void shader_glsl_arith(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_arith(const SHADER_OPCODE_ARG *arg)
+{
     CONST SHADER_OPCODE* curOpcode = arg->opcode;
     SHADER_BUFFER* buffer = arg->buffer;
     glsl_src_param_t src0_param;
@@ -1452,7 +1305,8 @@ static void shader_glsl_arith(SHADER_OPCODE_ARG* arg) {
 }
 
 /* Process the WINED3DSIO_MOV opcode using GLSL (dst = src) */
-static void shader_glsl_mov(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_mov(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
     SHADER_BUFFER* buffer = arg->buffer;
     glsl_src_param_t src0_param;
@@ -1487,7 +1341,8 @@ static void shader_glsl_mov(SHADER_OPCODE_ARG* arg) {
 }
 
 /* Process the dot product operators DP3 and DP4 in GLSL (dst = dot(src0, src1)) */
-static void shader_glsl_dot(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_dot(const SHADER_OPCODE_ARG *arg)
+{
     CONST SHADER_OPCODE* curOpcode = arg->opcode;
     SHADER_BUFFER* buffer = arg->buffer;
     glsl_src_param_t src0_param;
@@ -1517,7 +1372,8 @@ static void shader_glsl_dot(SHADER_OPCODE_ARG* arg) {
 
 /* Note that this instruction has some restrictions. The destination write mask
  * can't contain the w component, and the source swizzles have to be .xyzw */
-static void shader_glsl_cross(SHADER_OPCODE_ARG *arg) {
+static void shader_glsl_cross(const SHADER_OPCODE_ARG *arg)
+{
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
@@ -1533,7 +1389,8 @@ static void shader_glsl_cross(SHADER_OPCODE_ARG *arg) {
 /* Process the WINED3DSIO_POW instruction in GLSL (dst = |src0|^src1)
  * Src0 and src1 are scalars. Note that D3D uses the absolute of src0, while
  * GLSL uses the value as-is. */
-static void shader_glsl_pow(SHADER_OPCODE_ARG *arg) {
+static void shader_glsl_pow(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER *buffer = arg->buffer;
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
@@ -1556,7 +1413,8 @@ static void shader_glsl_pow(SHADER_OPCODE_ARG *arg) {
 /* Process the WINED3DSIO_LOG instruction in GLSL (dst = log2(|src0|))
  * Src0 is a scalar. Note that D3D uses the absolute of src0, while
  * GLSL uses the value as-is. */
-static void shader_glsl_log(SHADER_OPCODE_ARG *arg) {
+static void shader_glsl_log(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER *buffer = arg->buffer;
     glsl_src_param_t src0_param;
     DWORD dst_write_mask;
@@ -1575,7 +1433,8 @@ static void shader_glsl_log(SHADER_OPCODE_ARG *arg) {
 }
 
 /* Map the opcode 1-to-1 to the GL code (arg->dst = instruction(src0, src1, ...) */
-static void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_map2gl(const SHADER_OPCODE_ARG *arg)
+{
     CONST SHADER_OPCODE* curOpcode = arg->opcode;
     SHADER_BUFFER* buffer = arg->buffer;
     glsl_src_param_t src_param;
@@ -1626,7 +1485,8 @@ static void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg) {
  * For 2.0 shaders, just do this (honoring writemask and swizzle):
  *   dst = 2^src;    (partial precision is allowed, but optional)
  */
-static void shader_glsl_expp(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_expp(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)arg->shader;
     glsl_src_param_t src_param;
 
@@ -1659,7 +1519,8 @@ static void shader_glsl_expp(SHADER_OPCODE_ARG* arg) {
 }
 
 /** Process the RCP (reciprocal or inverse) opcode in GLSL (dst = 1 / src) */
-static void shader_glsl_rcp(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_rcp(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src_param;
     DWORD write_mask;
     unsigned int mask_size;
@@ -1675,7 +1536,8 @@ static void shader_glsl_rcp(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void shader_glsl_rsq(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_rsq(const SHADER_OPCODE_ARG *arg)
+{
     SHADER_BUFFER* buffer = arg->buffer;
     glsl_src_param_t src_param;
     DWORD write_mask;
@@ -1694,7 +1556,8 @@ static void shader_glsl_rsq(SHADER_OPCODE_ARG* arg) {
 }
 
 /** Process signed comparison opcodes in GLSL. */
-static void shader_glsl_compare(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_compare(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
     DWORD write_mask;
@@ -1741,7 +1604,8 @@ static void shader_glsl_compare(SHADER_OPCODE_ARG* arg) {
 }
 
 /** Process CMP instruction in GLSL (dst = src0 >= 0.0 ? src1 : src2), per channel */
-static void shader_glsl_cmp(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_cmp(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
     glsl_src_param_t src2_param;
@@ -1817,7 +1681,8 @@ static void shader_glsl_cmp(SHADER_OPCODE_ARG* arg) {
 /** Process the CND opcode in GLSL (dst = (src0 > 0.5) ? src1 : src2) */
 /* For ps 1.1-1.3, only a single component of src0 is used. For ps 1.4
  * the compare is done per component of src0. */
-static void shader_glsl_cnd(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_cnd(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
@@ -1863,7 +1728,8 @@ static void shader_glsl_cnd(SHADER_OPCODE_ARG* arg) {
 }
 
 /** GLSL code generation for WINED3DSIO_MAD: Multiply the first 2 opcodes, then add the last */
-static void shader_glsl_mad(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_mad(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
     glsl_src_param_t src2_param;
@@ -1879,7 +1745,11 @@ static void shader_glsl_mad(SHADER_OPCODE_ARG* arg) {
 
 /** Handles transforming all WINED3DSIO_M?x? opcodes for 
     Vertex shaders to GLSL codes */
-static void shader_glsl_mnxn(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_mnxn(const SHADER_OPCODE_ARG *arg)
+{
+    IWineD3DBaseShaderImpl *shader = (IWineD3DBaseShaderImpl *)arg->shader;
+    const SHADER_OPCODE *opcode_table = shader->baseShader.shader_ins;
+    DWORD shader_version = shader->baseShader.hex_version;
     int i;
     int nComponents = 0;
     SHADER_OPCODE_ARG tmpArg;
@@ -1897,23 +1767,23 @@ static void shader_glsl_mnxn(SHADER_OPCODE_ARG* arg) {
     switch(arg->opcode->opcode) {
         case WINED3DSIO_M4x4:
             nComponents = 4;
-            tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP4);
+            tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
             break;
         case WINED3DSIO_M4x3:
             nComponents = 3;
-            tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP4);
+            tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP4);
             break;
         case WINED3DSIO_M3x4:
             nComponents = 4;
-            tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP3);
+            tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
             break;
         case WINED3DSIO_M3x3:
             nComponents = 3;
-            tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP3);
+            tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
             break;
         case WINED3DSIO_M3x2:
             nComponents = 2;
-            tmpArg.opcode = shader_get_opcode(arg->shader, WINED3DSIO_DP3);
+            tmpArg.opcode = shader_get_opcode(opcode_table, shader_version, WINED3DSIO_DP3);
             break;
         default:
             break;
@@ -1932,7 +1802,8 @@ static void shader_glsl_mnxn(SHADER_OPCODE_ARG* arg) {
     blend factor.  Equation:  (dst = src2 + src0 * (src1 - src2))
     This is equivalent to mix(src2, src1, src0);
 */
-static void shader_glsl_lrp(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_lrp(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
     glsl_src_param_t src2_param;
@@ -1954,7 +1825,8 @@ static void shader_glsl_lrp(SHADER_OPCODE_ARG* arg) {
  * dst.z = (src0.x > 0) ? ((src0.y > 0) ? pow(src0.y, src.w) : 0) : 0
  *                                        where src.w is clamped at +- 128
  */
-static void shader_glsl_lit(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_lit(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
     glsl_src_param_t src3_param;
@@ -1998,7 +1870,8 @@ static void shader_glsl_lit(SHADER_OPCODE_ARG* arg) {
  * dst.z = src0.z
  * dst.w = src1.w
  */
-static void shader_glsl_dst(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_dst(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0y_param;
     glsl_src_param_t src0z_param;
     glsl_src_param_t src1y_param;
@@ -2026,7 +1899,8 @@ static void shader_glsl_dst(SHADER_OPCODE_ARG* arg) {
  * dst.z = dst.z
  * dst.w = dst.w
  */
-static void shader_glsl_sincos(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_sincos(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     DWORD write_mask;
 
@@ -2058,13 +1932,14 @@ static void shader_glsl_sincos(SHADER_OPCODE_ARG* arg) {
  *  Need to use a temporary variable for this operation.
  */
 /* FIXME: I don't think nested loops will work correctly this way. */
-static void shader_glsl_loop(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_loop(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src1_param;
     IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
     DWORD regtype = shader_get_regtype(arg->src[1]);
     DWORD reg = arg->src[1] & WINED3DSP_REGNUM_MASK;
     const DWORD *control_values = NULL;
-    local_constant *constant;
+    const local_constant *constant;
 
     shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], WINED3DSP_WRITEMASK_ALL, &src1_param);
 
@@ -2110,7 +1985,8 @@ static void shader_glsl_loop(SHADER_OPCODE_ARG* arg) {
     shader->baseShader.cur_loop_regno++;
 }
 
-static void shader_glsl_end(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_end(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
 
     shader_addline(arg->buffer, "}\n");
@@ -2124,7 +2000,8 @@ static void shader_glsl_end(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void shader_glsl_rep(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_rep(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DBaseShaderImpl* shader = (IWineD3DBaseShaderImpl*) arg->shader;
     glsl_src_param_t src0_param;
 
@@ -2135,14 +2012,16 @@ static void shader_glsl_rep(SHADER_OPCODE_ARG* arg) {
     shader->baseShader.cur_loop_depth++;
 }
 
-static void shader_glsl_if(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_if(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
 
     shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], WINED3DSP_WRITEMASK_0, &src0_param);
     shader_addline(arg->buffer, "if (%s) {\n", src0_param.param_str);
 }
 
-static void shader_glsl_ifc(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_ifc(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
 
@@ -2153,16 +2032,19 @@ static void shader_glsl_ifc(SHADER_OPCODE_ARG* arg) {
             src0_param.param_str, shader_get_comp_op(arg->opcode_token), src1_param.param_str);
 }
 
-static void shader_glsl_else(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_else(const SHADER_OPCODE_ARG *arg)
+{
     shader_addline(arg->buffer, "} else {\n");
 }
 
-static void shader_glsl_break(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_break(const SHADER_OPCODE_ARG *arg)
+{
     shader_addline(arg->buffer, "break;\n");
 }
 
 /* FIXME: According to MSDN the compare is done per component. */
-static void shader_glsl_breakc(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_breakc(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
 
@@ -2173,19 +2055,22 @@ static void shader_glsl_breakc(SHADER_OPCODE_ARG* arg) {
             src0_param.param_str, shader_get_comp_op(arg->opcode_token), src1_param.param_str);
 }
 
-static void shader_glsl_label(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_label(const SHADER_OPCODE_ARG *arg)
+{
 
     DWORD snum = (arg->src[0]) & WINED3DSP_REGNUM_MASK;
     shader_addline(arg->buffer, "}\n");
     shader_addline(arg->buffer, "void subroutine%u () {\n",  snum);
 }
 
-static void shader_glsl_call(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_call(const SHADER_OPCODE_ARG *arg)
+{
     DWORD snum = (arg->src[0]) & WINED3DSP_REGNUM_MASK;
     shader_addline(arg->buffer, "subroutine%u();\n", snum);
 }
 
-static void shader_glsl_callnz(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_callnz(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src1_param;
 
     DWORD snum = (arg->src[0]) & WINED3DSP_REGNUM_MASK;
@@ -2196,7 +2081,8 @@ static void shader_glsl_callnz(SHADER_OPCODE_ARG* arg) {
 /*********************************************
  * Pixel Shader Specific Code begins here
  ********************************************/
-static void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_tex(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     DWORD hex_version = This->baseShader.hex_version;
@@ -2295,7 +2181,8 @@ static void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void shader_glsl_texldl(SHADER_OPCODE_ARG* arg) {
+static void shader_glsl_texldl(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*)arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     glsl_sample_function_t sample_function;
@@ -2330,8 +2217,8 @@ static void shader_glsl_texldl(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_glsl_texcoord(const SHADER_OPCODE_ARG *arg)
+{
     /* FIXME: Make this work for more than just 2D textures */
     
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
@@ -2382,7 +2269,8 @@ static void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg) {
 /** Process the WINED3DSIO_TEXDP3TEX instruction in GLSL:
  * Take a 3-component dot product of the TexCoord[dstreg] and src,
  * then perform a 1D texture lookup from stage dstregnum, place into dst. */
-static void pshader_glsl_texdp3tex(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texdp3tex(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     char dst_mask[6];
     glsl_sample_function_t sample_function;
@@ -2424,7 +2312,8 @@ static void pshader_glsl_texdp3tex(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXDP3 instruction in GLSL:
  * Take a 3-component dot product of the TexCoord[dstreg] and src. */
-static void pshader_glsl_texdp3(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texdp3(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     DWORD dstreg = arg->dst & WINED3DSP_REGNUM_MASK;
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
@@ -2444,7 +2333,8 @@ static void pshader_glsl_texdp3(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXDEPTH instruction in GLSL:
  * Calculate the depth as dst.x / dst.y   */
-static void pshader_glsl_texdepth(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texdepth(const SHADER_OPCODE_ARG *arg)
+{
     glsl_dst_param_t dst_param;
 
     shader_glsl_add_dst_param(arg, arg->dst, 0, &dst_param);
@@ -2463,7 +2353,8 @@ static void pshader_glsl_texdepth(SHADER_OPCODE_ARG* arg) {
  * Calculate tmp0.y = TexCoord[dstreg] . src.xyz;  (tmp0.x has already been calculated)
  * depth = (tmp0.y == 0.0) ? 1.0 : tmp0.x / tmp0.y
  */
-static void pshader_glsl_texm3x2depth(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texm3x2depth(const SHADER_OPCODE_ARG *arg)
+{
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     DWORD dstreg = arg->dst & WINED3DSP_REGNUM_MASK;
     glsl_src_param_t src0_param;
@@ -2476,7 +2367,8 @@ static void pshader_glsl_texm3x2depth(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXM3X2PAD instruction in GLSL
  * Calculate the 1st of a 2-row matrix multiplication. */
-static void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texm3x2pad(const SHADER_OPCODE_ARG *arg)
+{
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
     SHADER_BUFFER* buffer = arg->buffer;
@@ -2488,8 +2380,8 @@ static void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXM3X3PAD instruction in GLSL
  * Calculate the 1st or 2nd row of a 3-row matrix multiplication. */
-static void pshader_glsl_texm3x3pad(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_glsl_texm3x3pad(const SHADER_OPCODE_ARG* arg)
+{
     IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
@@ -2502,7 +2394,8 @@ static void pshader_glsl_texm3x3pad(SHADER_OPCODE_ARG* arg) {
     current_state->texcoord_w[current_state->current_row++] = reg;
 }
 
-static void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texm3x2tex(const SHADER_OPCODE_ARG *arg)
+{
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
     SHADER_BUFFER* buffer = arg->buffer;
@@ -2521,7 +2414,8 @@ static void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXM3X3TEX instruction in GLSL
  * Perform the 3rd row of a 3x3 matrix multiply, then sample the texture using the calculated coordinates */
-static void pshader_glsl_texm3x3tex(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texm3x3tex(const SHADER_OPCODE_ARG *arg)
+{
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     glsl_src_param_t src0_param;
     char dst_mask[6];
@@ -2547,7 +2441,8 @@ static void pshader_glsl_texm3x3tex(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXM3X3 instruction in GLSL
  * Perform the 3rd row of a 3x3 matrix multiply */
-static void pshader_glsl_texm3x3(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texm3x3(const SHADER_OPCODE_ARG *arg)
+{
     DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     glsl_src_param_t src0_param;
     char dst_mask[6];
@@ -2566,8 +2461,8 @@ static void pshader_glsl_texm3x3(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXM3X3SPEC instruction in GLSL 
  * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */
-static void pshader_glsl_texm3x3spec(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_glsl_texm3x3spec(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
     DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
     glsl_src_param_t src0_param;
@@ -2600,8 +2495,8 @@ static void pshader_glsl_texm3x3spec(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXM3X3VSPEC instruction in GLSL 
  * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */
-static void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_glsl_texm3x3vspec(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* shader = (IWineD3DPixelShaderImpl*) arg->shader;
     DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
     SHADER_BUFFER* buffer = arg->buffer;
@@ -2637,7 +2532,8 @@ static void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
  * Apply a fake bump map transform.
  * texbem is pshader <= 1.3 only, this saves a few version checks
  */
-static void pshader_glsl_texbem(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texbem(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     char dst_swizzle[6];
@@ -2692,7 +2588,8 @@ static void pshader_glsl_texbem(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void pshader_glsl_bem(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_bem(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param, src1_param;
     DWORD sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
 
@@ -2706,8 +2603,8 @@ static void pshader_glsl_bem(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXREG2AR instruction in GLSL
  * Sample 2D texture at dst using the alpha & red (wx) components of src as texture coordinates */
-static void pshader_glsl_texreg2ar(SHADER_OPCODE_ARG* arg) {
-
+static void pshader_glsl_texreg2ar(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     DWORD sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
     char dst_mask[6];
@@ -2721,7 +2618,8 @@ static void pshader_glsl_texreg2ar(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXREG2GB instruction in GLSL
  * Sample 2D texture at dst using the green & blue (yz) components of src as texture coordinates */
-static void pshader_glsl_texreg2gb(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texreg2gb(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     DWORD sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
     char dst_mask[6];
@@ -2735,7 +2633,8 @@ static void pshader_glsl_texreg2gb(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXREG2RGB instruction in GLSL
  * Sample texture at dst using the rgb (xyz) components of src as texture coordinates */
-static void pshader_glsl_texreg2rgb(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texreg2rgb(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     char dst_mask[6];
     DWORD sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
@@ -2753,7 +2652,8 @@ static void pshader_glsl_texreg2rgb(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_TEXKILL instruction in GLSL.
  * If any of the first 3 components are < 0, discard this pixel */
-static void pshader_glsl_texkill(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_texkill(const SHADER_OPCODE_ARG *arg)
+{
     IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
     DWORD hex_version = This->baseShader.hex_version;
     glsl_dst_param_t dst_param;
@@ -2774,7 +2674,8 @@ static void pshader_glsl_texkill(SHADER_OPCODE_ARG* arg) {
 
 /** Process the WINED3DSIO_DP2ADD instruction in GLSL.
  * dst = dot2(src0, src1) + src2 */
-static void pshader_glsl_dp2add(SHADER_OPCODE_ARG* arg) {
+static void pshader_glsl_dp2add(const SHADER_OPCODE_ARG *arg)
+{
     glsl_src_param_t src0_param;
     glsl_src_param_t src1_param;
     glsl_src_param_t src2_param;
@@ -2795,11 +2696,9 @@ static void pshader_glsl_dp2add(SHADER_OPCODE_ARG* arg) {
     }
 }
 
-static void pshader_glsl_input_pack(
-   SHADER_BUFFER* buffer,
-   semantic* semantics_in,
-   IWineD3DPixelShader *iface) {
-
+static void pshader_glsl_input_pack(SHADER_BUFFER* buffer, const struct semantic* semantics_in,
+        IWineD3DPixelShader *iface, enum vertexprocessing_mode vertexprocessing)
+{
    unsigned int i;
    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface;
 
@@ -2819,7 +2718,7 @@ static void pshader_glsl_input_pack(
        switch(usage) {
 
            case WINED3DDECLUSAGE_TEXCOORD:
-               if(usage_idx < 8 && This->vertexprocessing == pretransformed) {
+               if(usage_idx < 8 && vertexprocessing == pretransformed) {
                    shader_addline(buffer, "IN[%u]%s = gl_TexCoord[%u]%s;\n",
                                   This->input_reg_map[i], reg_mask, usage_idx, reg_mask);
                } else {
@@ -2857,26 +2756,31 @@ static void add_glsl_program_entry(struct shader_glsl_priv *priv, struct glsl_sh
     key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t));
     key->vshader = entry->vshader;
     key->pshader = entry->pshader;
+    key->ps_args = entry->ps_args;
 
     hash_table_put(priv->glsl_program_lookup, key, entry);
 }
 
 static struct glsl_shader_prog_link *get_glsl_program_entry(struct shader_glsl_priv *priv,
-        GLhandleARB vshader, GLhandleARB pshader) {
+        GLhandleARB vshader, IWineD3DPixelShader *pshader, struct ps_compile_args *ps_args) {
     glsl_program_key_t key;
 
     key.vshader = vshader;
     key.pshader = pshader;
+    key.ps_args = *ps_args;
 
     return (struct glsl_shader_prog_link *)hash_table_get(priv->glsl_program_lookup, &key);
 }
 
-static void delete_glsl_program_entry(struct shader_glsl_priv *priv, WineD3D_GL_Info *gl_info, struct glsl_shader_prog_link *entry) {
+static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const WineD3D_GL_Info *gl_info,
+        struct glsl_shader_prog_link *entry)
+{
     glsl_program_key_t *key;
 
     key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t));
     key->vshader = entry->vshader;
     key->pshader = entry->pshader;
+    key->ps_args = entry->ps_args;
     hash_table_remove(priv->glsl_program_lookup, key);
 
     GL_EXTCALL(glDeleteObjectARB(entry->programId));
@@ -2887,7 +2791,9 @@ static void delete_glsl_program_entry(struct shader_glsl_priv *priv, WineD3D_GL_
     HeapFree(GetProcessHeap(), 0, entry);
 }
 
-static void handle_ps3_input(SHADER_BUFFER *buffer, semantic *semantics_in, semantic *semantics_out, WineD3D_GL_Info *gl_info, DWORD *map) {
+static void handle_ps3_input(SHADER_BUFFER *buffer, const struct semantic *semantics_in,
+        const struct semantic *semantics_out, const WineD3D_GL_Info *gl_info, const DWORD *map)
+{
     unsigned int i, j;
     DWORD usage_token, usage_token_out;
     DWORD register_token, register_token_out;
@@ -3036,8 +2942,8 @@ static void handle_ps3_input(SHADER_BUFFER *buffer, semantic *semantics_in, sema
 }
 
 static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexshader,
-        IWineD3DPixelShader *pixelshader,
-        WineD3D_GL_Info *gl_info) {
+        IWineD3DPixelShader *pixelshader, const WineD3D_GL_Info *gl_info)
+{
     GLhandleARB ret = 0;
     IWineD3DVertexShaderImpl *vs = (IWineD3DVertexShaderImpl *) vertexshader;
     IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) pixelshader;
@@ -3050,7 +2956,7 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs
     DWORD register_token;
     DWORD usage, usage_idx, writemask;
     char reg_mask[6];
-    semantic *semantics_out, *semantics_in;
+    const struct semantic *semantics_out, *semantics_in;
 
     buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
     buffer.bsize = 0;
@@ -3191,14 +3097,16 @@ static GLhandleARB generate_param_reorder_function(IWineD3DVertexShader *vertexs
     return ret;
 }
 
-static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, WineD3D_GL_Info *gl_info, GLhandleARB programId, char prefix) {
-    local_constant* lconst;
+static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, const WineD3D_GL_Info *gl_info,
+        GLhandleARB programId, char prefix)
+{
+    const local_constant *lconst;
     GLuint tmp_loc;
-    float *value;
+    const float *value;
     char glsl_name[8];
 
     LIST_FOR_EACH_ENTRY(lconst, &shader->baseShader.constantsF, local_constant, entry) {
-        value = (float *) lconst->value;
+        value = (const float *)lconst->value;
         snprintf(glsl_name, sizeof(glsl_name), "%cLC%u", prefix, lconst->idx);
         tmp_loc = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name));
         GL_EXTCALL(glUniform4fvARB(tmp_loc, 1, value));
@@ -3217,7 +3125,7 @@ static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, WineD3D_GL_
 static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) {
     IWineD3DDeviceImpl *This               = (IWineD3DDeviceImpl *)iface;
     struct shader_glsl_priv *priv          = (struct shader_glsl_priv *)This->shader_priv;
-    WineD3D_GL_Info *gl_info               = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info         = &This->adapter->gl_info;
     IWineD3DPixelShader  *pshader          = This->stateBlock->pixelShader;
     IWineD3DVertexShader *vshader          = This->stateBlock->vertexShader;
     struct glsl_shader_prog_link *entry    = NULL;
@@ -3225,10 +3133,22 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
     GLhandleARB reorder_shader_id          = 0;
     int i;
     char glsl_name[8];
+    GLhandleARB vshader_id, pshader_id;
+    struct ps_compile_args compile_args;
 
-    GLhandleARB vshader_id = use_vs ? ((IWineD3DBaseShaderImpl*)vshader)->baseShader.prgId : 0;
-    GLhandleARB pshader_id = use_ps ? ((IWineD3DBaseShaderImpl*)pshader)->baseShader.prgId : 0;
-    entry = get_glsl_program_entry(priv, vshader_id, pshader_id);
+    if(use_vs) {
+        IWineD3DVertexShaderImpl_CompileShader(vshader);
+        vshader_id = ((IWineD3DVertexShaderImpl*)vshader)->prgId;
+    } else {
+        vshader_id = 0;
+    }
+    if(use_ps) {
+        find_ps_compile_args((IWineD3DPixelShaderImpl*)This->stateBlock->pixelShader, This->stateBlock, &compile_args);
+    } else {
+        /* FIXME: Do we really have to spend CPU cycles to generate a few zeroed bytes? */
+        memset(&compile_args, 0, sizeof(compile_args));
+    }
+    entry = get_glsl_program_entry(priv, vshader_id, pshader, &compile_args);
     if (entry) {
         priv->glsl_program = entry;
         return;
@@ -3242,7 +3162,8 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
     entry = HeapAlloc(GetProcessHeap(), 0, sizeof(struct glsl_shader_prog_link));
     entry->programId = programId;
     entry->vshader = vshader_id;
-    entry->pshader = pshader_id;
+    entry->pshader = pshader;
+    entry->ps_args = compile_args;
     /* Add the hash table entry */
     add_glsl_program_entry(priv, entry);
 
@@ -3287,6 +3208,12 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
         list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry);
     }
 
+    if(use_ps) {
+        pshader_id = find_gl_pshader((IWineD3DPixelShaderImpl *) pshader, &compile_args);
+    } else {
+        pshader_id = 0;
+    }
+
     /* Attach GLSL pshader */
     if (pshader_id) {
         TRACE("Attaching GLSL shader object %u to program %u\n", pshader_id, programId);
@@ -3334,8 +3261,6 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
 
 
     entry->posFixup_location = GL_EXTCALL(glGetUniformLocationARB(programId, "posFixup"));
-    entry->srgb_comparison_location = GL_EXTCALL(glGetUniformLocationARB(programId, "srgb_comparison"));
-    entry->srgb_mul_low_location = GL_EXTCALL(glGetUniformLocationARB(programId, "srgb_mul_low"));
     entry->ycorrection_location = GL_EXTCALL(glGetUniformLocationARB(programId, "ycorrection"));
     checkGLcall("Find glsl program uniform locations");
 
@@ -3380,7 +3305,8 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
     }
 }
 
-static GLhandleARB create_glsl_blt_shader(WineD3D_GL_Info *gl_info, enum tex_types tex_type) {
+static GLhandleARB create_glsl_blt_shader(const WineD3D_GL_Info *gl_info, enum tex_types tex_type)
+{
     GLhandleARB program_id;
     GLhandleARB vshader_id, pshader_id;
     const char *blt_vshader[] = {
@@ -3454,7 +3380,7 @@ static GLhandleARB create_glsl_blt_shader(WineD3D_GL_Info *gl_info, enum tex_typ
 static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     struct shader_glsl_priv *priv = (struct shader_glsl_priv *)This->shader_priv;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
     GLhandleARB program_id = 0;
     GLenum old_vertex_color_clamp, current_vertex_color_clamp;
 
@@ -3482,7 +3408,7 @@ static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
 
 static void shader_glsl_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
     struct shader_glsl_priv *priv = (struct shader_glsl_priv *) This->shader_priv;
     GLhandleARB *blt_program = &priv->depth_blt_program[tex_type];
 
@@ -3499,7 +3425,7 @@ static void shader_glsl_select_depth_blt(IWineD3DDevice *iface, enum tex_types t
 
 static void shader_glsl_deselect_depth_blt(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
     struct shader_glsl_priv *priv = (struct shader_glsl_priv *) This->shader_priv;
     GLhandleARB program_id;
 
@@ -3512,23 +3438,32 @@ static void shader_glsl_deselect_depth_blt(IWineD3DDevice *iface) {
 
 static void shader_glsl_cleanup(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
     GL_EXTCALL(glUseProgramObjectARB(0));
 }
 
 static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
-    struct list *linked_programs;
+    const struct list *linked_programs;
     IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) iface;
     IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)This->baseShader.device;
     struct shader_glsl_priv *priv = (struct shader_glsl_priv *)device->shader_priv;
-    WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &device->adapter->gl_info;
+    IWineD3DPixelShaderImpl *ps = NULL;
+    IWineD3DVertexShaderImpl *vs = NULL;
 
     /* Note: Do not use QueryInterface here to find out which shader type this is because this code
      * can be called from IWineD3DBaseShader::Release
      */
     char pshader = shader_is_pshader_version(This->baseShader.hex_version);
 
-    if(This->baseShader.prgId == 0) return;
+    if(pshader) {
+        ps = (IWineD3DPixelShaderImpl *) This;
+        if(ps->num_gl_shaders == 0) return;
+    } else {
+        vs = (IWineD3DVertexShaderImpl *) This;
+        if(vs->prgId == 0) return;
+    }
+
     linked_programs = &This->baseShader.linked_programs;
 
     TRACE("Deleting linked programs\n");
@@ -3546,17 +3481,35 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
         }
     }
 
-    TRACE("Deleting shader object %u\n", This->baseShader.prgId);
-    GL_EXTCALL(glDeleteObjectARB(This->baseShader.prgId));
-    checkGLcall("glDeleteObjectARB");
-    This->baseShader.prgId = 0;
-    This->baseShader.is_compiled = FALSE;
+    if(pshader) {
+        UINT i;
+
+        ENTER_GL();
+        for(i = 0; i < ps->num_gl_shaders; i++) {
+            TRACE("deleting pshader %u\n", ps->gl_shaders[i].prgId);
+            GL_EXTCALL(glDeleteObjectARB(ps->gl_shaders[i].prgId));
+            checkGLcall("glDeleteObjectARB");
+        }
+        LEAVE_GL();
+        HeapFree(GetProcessHeap(), 0, ps->gl_shaders);
+        ps->gl_shaders = NULL;
+        ps->num_gl_shaders = 0;
+    } else {
+        TRACE("Deleting shader object %u\n", vs->prgId);
+        ENTER_GL();
+        GL_EXTCALL(glDeleteObjectARB(vs->prgId));
+        checkGLcall("glDeleteObjectARB");
+        LEAVE_GL();
+        vs->prgId = 0;
+        vs->baseShader.is_compiled = FALSE;
+    }
 }
 
-static unsigned int glsl_program_key_hash(void *key) {
-    glsl_program_key_t *k = (glsl_program_key_t *)key;
+static unsigned int glsl_program_key_hash(const void *key)
+{
+    const glsl_program_key_t *k = (const glsl_program_key_t *)key;
 
-    unsigned int hash = k->vshader | k->pshader << 16;
+    unsigned int hash = k->vshader | ((DWORD_PTR) k->pshader) << 16;
     hash += ~(hash << 15);
     hash ^=  (hash >> 10);
     hash +=  (hash << 3);
@@ -3567,11 +3520,13 @@ static unsigned int glsl_program_key_hash(void *key) {
     return hash;
 }
 
-static BOOL glsl_program_key_compare(void *keya, void *keyb) {
-    glsl_program_key_t *ka = (glsl_program_key_t *)keya;
-    glsl_program_key_t *kb = (glsl_program_key_t *)keyb;
+static BOOL glsl_program_key_compare(const void *keya, const void *keyb)
+{
+    const glsl_program_key_t *ka = (const glsl_program_key_t *)keya;
+    const glsl_program_key_t *kb = (const glsl_program_key_t *)keyb;
 
-    return ka->vshader == kb->vshader && ka->pshader == kb->pshader;
+    return ka->vshader == kb->vshader && ka->pshader == kb->pshader &&
+           (memcmp(&ka->ps_args, &kb->ps_args, sizeof(kb->ps_args)) == 0);
 }
 
 static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) {
@@ -3584,7 +3539,7 @@ static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) {
 
 static void shader_glsl_free(IWineD3DDevice *iface) {
     IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
-    WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
     struct shader_glsl_priv *priv = (struct shader_glsl_priv *)This->shader_priv;
     int i;
 
@@ -3607,14 +3562,14 @@ static BOOL shader_glsl_dirty_const(IWineD3DDevice *iface) {
     return FALSE;
 }
 
-static void shader_glsl_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
+static GLuint shader_glsl_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
     IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
-    shader_reg_maps* reg_maps = &This->baseShader.reg_maps;
+    const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
     CONST DWORD *function = This->baseShader.function;
     const char *fragcolor;
-    WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
 
-    /* Create the hw GLSL shader object and assign it as the baseShader.prgId */
+    /* Create the hw GLSL shader object and assign it as the shader->prgId */
     GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB));
 
     shader_addline(buffer, "#version 120\n");
@@ -3636,13 +3591,9 @@ static void shader_glsl_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFF
     if (This->baseShader.hex_version >= WINED3DPS_VERSION(3,0)) {
 
         if(((IWineD3DDeviceImpl *) This->baseShader.device)->strided_streams.u.s.position_transformed) {
-            This->vertexprocessing = pretransformed;
-            pshader_glsl_input_pack(buffer, This->semantics_in, iface);
+            pshader_glsl_input_pack(buffer, This->semantics_in, iface, pretransformed);
         } else if(!use_vs((IWineD3DDeviceImpl *) This->baseShader.device)) {
-            This->vertexprocessing = fixedfunction;
-            pshader_glsl_input_pack(buffer, This->semantics_in, iface);
-        } else {
-            This->vertexprocessing = vertexshader;
+            pshader_glsl_input_pack(buffer, This->semantics_in, iface, fixedfunction);
         }
     }
 
@@ -3663,7 +3614,7 @@ static void shader_glsl_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFF
     } else {
         fragcolor = "gl_FragColor";
     }
-    if(This->srgb_enabled) {
+    if(((IWineD3DDeviceImpl *)This->baseShader.device)->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE]) {
         shader_addline(buffer, "tmp0.xyz = pow(%s.xyz, vec3(%f, %f, %f)) * vec3(%f, %f, %f) - vec3(%f, %f, %f);\n",
                         fragcolor, srgb_pow, srgb_pow, srgb_pow, srgb_mul_high, srgb_mul_high, srgb_mul_high,
                         srgb_sub_high, srgb_sub_high, srgb_sub_high);
@@ -3692,16 +3643,16 @@ static void shader_glsl_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFF
     print_glsl_info_log(&GLINFO_LOCATION, shader_obj);
 
     /* Store the shader object */
-    This->baseShader.prgId = shader_obj;
+    return shader_obj;
 }
 
 static void shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer) {
     IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
-    shader_reg_maps* reg_maps = &This->baseShader.reg_maps;
+    const struct shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
     CONST DWORD *function = This->baseShader.function;
-    WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
+    const WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
 
-    /* Create the hw GLSL shader program and assign it as the baseShader.prgId */
+    /* Create the hw GLSL shader program and assign it as the shader->prgId */
     GLhandleARB shader_obj = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB));
 
     shader_addline(buffer, "#version 120\n");
@@ -3749,10 +3700,11 @@ static void shader_glsl_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUF
     print_glsl_info_log(&GLINFO_LOCATION, shader_obj);
 
     /* Store the shader object */
-    This->baseShader.prgId = shader_obj;
+    This->prgId = shader_obj;
 }
 
-static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) {
+static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps)
+{
     /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati
      * models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support using
      * vs_nv_version which is based on NV_vertex_program.
@@ -3800,21 +3752,23 @@ static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_inf
     TRACE_(d3d_caps)("Hardware pixel shader version %d.%d enabled (GLSL)\n", (pCaps->PixelShaderVersion >> 8) & 0xff, pCaps->PixelShaderVersion & 0xff);
 }
 
-static BOOL shader_glsl_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt));
-    switch(fmt) {
-        case WINED3DFMT_V8U8:
-        case WINED3DFMT_V16U16:
-        case WINED3DFMT_X8L8V8U8:
-        case WINED3DFMT_L6V5U5:
-        case WINED3DFMT_Q8W8V8U8:
-        case WINED3DFMT_ATI2N:
-            TRACE("[OK]\n");
-            return TRUE;
-        default:
-            TRACE("[FAILED\n");
-            return FALSE;
+static BOOL shader_glsl_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
+    }
+
+    /* We support everything except YUV conversions. */
+    if (!is_yuv_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
     }
+
+    TRACE("[FAILED]\n");
+    return FALSE;
 }
 
 static const SHADER_HANDLER shader_glsl_instruction_handler_table[WINED3DSIH_TABLE_SIZE] =
@@ -3919,5 +3873,5 @@ const shader_backend_t glsl_shader_backend = {
     shader_glsl_generate_pshader,
     shader_glsl_generate_vshader,
     shader_glsl_get_caps,
-    shader_glsl_conv_supported,
+    shader_glsl_color_fixup_supported,
 };
index 79423a1..0737892 100644 (file)
@@ -74,7 +74,7 @@ static ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface)
             LEAVE_GL();
         }
 
-        IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
+        resource_cleanup((IWineD3DResource *)iface);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -84,31 +84,31 @@ static ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface)
    IWineD3DIndexBuffer IWineD3DResource parts follow
    **************************************************** */
 static HRESULT WINAPI IWineD3DIndexBufferImpl_GetDevice(IWineD3DIndexBuffer *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    return resource_get_device((IWineD3DResource *)iface, ppDevice);
 }
 
 static HRESULT WINAPI IWineD3DIndexBufferImpl_SetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
 }
 
 static HRESULT WINAPI IWineD3DIndexBufferImpl_GetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
 }
 
 static HRESULT WINAPI IWineD3DIndexBufferImpl_FreePrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
+    return resource_free_private_data((IWineD3DResource *)iface, refguid);
 }
 
 static DWORD WINAPI IWineD3DIndexBufferImpl_SetPriority(IWineD3DIndexBuffer *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
+    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
 }
 
 static DWORD WINAPI IWineD3DIndexBufferImpl_GetPriority(IWineD3DIndexBuffer *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
+    return resource_get_priority((IWineD3DResource *)iface);
 }
 
 static void WINAPI IWineD3DIndexBufferImpl_PreLoad(IWineD3DIndexBuffer *iface) {
-    IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
+    FIXME("iface %p stub!\n", iface);
 }
 
 static void WINAPI IWineD3DIndexBufferImpl_UnLoad(IWineD3DIndexBuffer *iface) {
@@ -133,11 +133,11 @@ static void WINAPI IWineD3DIndexBufferImpl_UnLoad(IWineD3DIndexBuffer *iface) {
 }
 
 static WINED3DRESOURCETYPE WINAPI IWineD3DIndexBufferImpl_GetType(IWineD3DIndexBuffer *iface) {
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
+    return resource_get_type((IWineD3DResource *)iface);
 }
 
 static HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUnknown **pParent) {
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
+    return resource_get_parent((IWineD3DResource *)iface, pParent);
 }
 
 /* ******************************************************
index 29c4e98..77f5365 100644 (file)
@@ -29,7 +29,7 @@
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 
 #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
-void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
+static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     BOOL bumpmap = FALSE;
 
     if(stage > 0 && (stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE ||
@@ -548,7 +548,7 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
     }
 }
 
-void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
+static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     DWORD sampler = state - STATE_SAMPLER(0);
     DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler];
 
@@ -610,7 +610,8 @@ static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
     }
 }
 
-static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {
+static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps)
+{
     pCaps->TextureOpCaps =  WINED3DTEXOPCAPS_ADD                        |
                             WINED3DTEXOPCAPS_ADDSIGNED                  |
                             WINED3DTEXOPCAPS_ADDSIGNED2X                |
@@ -672,12 +673,26 @@ static void nvrc_fragment_free(IWineD3DDevice *iface) {}
  * register combiners extension(Pre-GF3).
  */
 
-static BOOL nvts_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking shader format support for format %s: [FAILED]\n", debug_d3dformat(fmt));
+static BOOL nvts_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
+    }
+
+    /* We only support identity conversions. */
+    if (is_identity_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
+    }
+
+    TRACE("[FAILED]\n");
     return FALSE;
 }
 
-const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
+static const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, 0                               },
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, 0                               },
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),        { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          nvrc_colorop        }, 0                               },
@@ -809,7 +824,7 @@ const struct fragment_pipeline nvts_fragment_pipeline = {
     nvrc_fragment_get_caps,
     nvrc_fragment_alloc,
     nvrc_fragment_free,
-    nvts_conv_supported,
+    nvts_color_fixup_supported,
     nvrc_fragmentstate_template,
     FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
 };
@@ -819,7 +834,7 @@ const struct fragment_pipeline nvrc_fragment_pipeline = {
     nvrc_fragment_get_caps,
     nvrc_fragment_alloc,
     nvrc_fragment_free,
-    nvts_conv_supported,
+    nvts_color_fixup_supported,
     nvrc_fragmentstate_template,
     FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
 };
index ff98333..8f6e37a 100644 (file)
@@ -105,7 +105,8 @@ static HRESULT  WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW
     return WINED3D_OK;
 }
 
-static HRESULT  WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt)
+static HRESULT  WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
+        DWORD Flags, DWORD Start, DWORD Count, const PALETTEENTRY *PalEnt)
 {
     IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
     IWineD3DResourceImpl *res;
index 246b58a..0557d86 100644 (file)
@@ -272,32 +272,16 @@ static void pshader_set_limits(
 
 /** Generate a pixel shader string using either GL_FRAGMENT_PROGRAM_ARB
     or GLSL and send it to the card */
-static inline VOID IWineD3DPixelShaderImpl_GenerateShader(
-    IWineD3DPixelShader *iface) {
-    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
+static inline GLuint IWineD3DPixelShaderImpl_GenerateShader(
+    IWineD3DPixelShaderImpl *This) {
     SHADER_BUFFER buffer;
 
-#if 0 /* FIXME: Use the buffer that is held by the device, this is ok since fixups will be skipped for software shaders
-        it also requires entering a critical section but cuts down the runtime footprint of wined3d and any memory fragmentation that may occur... */
-    if (This->device->fixupVertexBufferSize < SHADER_PGMSIZE) {
-        HeapFree(GetProcessHeap(), 0, This->fixupVertexBuffer);
-        This->fixupVertexBuffer = HeapAlloc(GetProcessHeap() , 0, SHADER_PGMSIZE);
-        This->fixupVertexBufferSize = PGMSIZE;
-        This->fixupVertexBuffer[0] = 0;
-    }
-    buffer.buffer = This->device->fixupVertexBuffer;
-#else
-    buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE); 
-#endif
+    buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
     buffer.bsize = 0;
     buffer.lineNo = 0;
     buffer.newline = TRUE;
 
-    ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_pshader(iface, &buffer);
-
-#if 1 /* if were using the data buffer of device then we don't need to free it */
-  HeapFree(GetProcessHeap(), 0, buffer.buffer);
-#endif
+    return ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_pshader((IWineD3DPixelShader *) This, &buffer);
 }
 
 static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *iface, CONST DWORD *pFunction) {
@@ -384,109 +368,49 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
     return WINED3D_OK;
 }
 
-static HRESULT WINAPI IWineD3DPixelShaderImpl_CompileShader(IWineD3DPixelShader *iface) {
-
-    IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface;
-    IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
+static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps_compile_args *args)
+{
     CONST DWORD *function = This->baseShader.function;
-    UINT i, sampler;
-    IWineD3DBaseTextureImpl *texture;
+    HRESULT hr;
+    GLuint retval;
 
-    TRACE("(%p) : function %p\n", iface, function);
-
-    /* We're already compiled, but check if any of the hardcoded stateblock assumptions
-     * changed.
-     */
-    if (This->baseShader.is_compiled) {
-        char srgbenabled = deviceImpl->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE] ? 1 : 0;
-        for(i = 0; i < This->baseShader.num_sampled_samplers; i++) {
-            sampler = This->baseShader.sampled_samplers[i];
-            texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler];
-            if(texture && texture->baseTexture.shader_conversion_group != This->baseShader.sampled_format[sampler]) {
-                WARN("Recompiling shader %p due to format change on sampler %d\n", This, sampler);
-                WARN("Old format group %s, new is %s\n",
-                     debug_d3dformat(This->baseShader.sampled_format[sampler]),
-                     debug_d3dformat(texture->baseTexture.shader_conversion_group));
-                goto recompile;
-            }
-        }
+    TRACE("(%p) : function %p\n", This, function);
 
-        /* TODO: Check projected textures */
-        /* TODO: Check texture types(2D, Cube, 3D) */
+    hr = IWineD3DPixelShader_UpdateSamplers((IWineD3DPixelShader *) This);
+    if(FAILED(hr)) {
+        ERR("Failed to update sampler information\n");
+        return 0;
+    }
 
-        if(srgbenabled != This->srgb_enabled && This->srgb_mode_hardcoded) {
-            WARN("Recompiling shader because srgb correction is different and hardcoded\n");
-            goto recompile;
-        }
-        if(This->baseShader.reg_maps.vpos && !This->vpos_uniform) {
-            if(This->render_offscreen != deviceImpl->render_offscreen ||
-               This->height != ((IWineD3DSurfaceImpl *) deviceImpl->render_targets[0])->currentDesc.Height) {
-                WARN("Recompiling shader because vpos is used, hard compiled and changed\n");
-                goto recompile;
-            }
-        }
-        if(This->baseShader.reg_maps.usesdsy && !This->vpos_uniform) {
-            if(This->render_offscreen ? 0 : 1 != deviceImpl->render_offscreen ? 0 : 1) {
-                WARN("Recompiling shader because dsy is used, hard compiled and render_offscreen changed\n");
-                goto recompile;
-            }
-        }
-        if(This->baseShader.hex_version >= WINED3DPS_VERSION(3,0)) {
-            if(((IWineD3DDeviceImpl *) This->baseShader.device)->strided_streams.u.s.position_transformed) {
-                if(This->vertexprocessing != pretransformed) {
-                    WARN("Recompiling shader because pretransformed vertices are provided, which wasn't the case before\n");
-                    goto recompile;
-                }
-            } else if(!use_vs((IWineD3DDeviceImpl *) This->baseShader.device) &&
-                       This->vertexprocessing != fixedfunction) {
-                WARN("Recompiling shader because fixed function vp is in use, which wasn't the case before\n");
-                goto recompile;
-            } else if(This->vertexprocessing != vertexshader) {
-                WARN("Recompiling shader because vertex shaders are in use, which wasn't the case before\n");
-                goto recompile;
-            }
-        }
+    /* Reset fields tracking stateblock values being hardcoded in the shader */
+    This->baseShader.num_sampled_samplers = 0;
 
-        return WINED3D_OK;
+    /* Generate the HW shader */
+    TRACE("(%p) : Generating hardware program\n", This);
+    retval = IWineD3DPixelShaderImpl_GenerateShader(This);
 
-        recompile:
-        if(This->baseShader.recompile_count > 50) {
-            FIXME("Shader %p recompiled more than 50 times\n", This);
-        } else {
-            This->baseShader.recompile_count++;
-        }
+    This->baseShader.is_compiled = TRUE;
 
-        deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface);
-    }
+    return retval;
+}
 
-    /* We don't need to compile */
-    if (!function) {
-        This->baseShader.is_compiled = TRUE;
-        return WINED3D_OK;
-    }
+static HRESULT WINAPI IWineD3DPixelShaderImpl_UpdateSamplers(IWineD3DPixelShader *iface) {
+    IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface;
 
     if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1) {
+        IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
         shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
         HRESULT hr;
 
         /* Second pass: figure out which registers are used, what the semantics are, etc.. */
         memset(reg_maps, 0, sizeof(shader_reg_maps));
         hr = shader_get_registers_used((IWineD3DBaseShader*)This, reg_maps,
-            This->semantics_in, NULL, This->baseShader.function, deviceImpl->stateBlock);
-        if (FAILED(hr)) return hr;
+                                        This->semantics_in, NULL, This->baseShader.function, deviceImpl->stateBlock);
+        return hr;
         /* FIXME: validate reg_maps against OpenGL */
+    } else {
+        return WINED3D_OK;
     }
-
-    /* Reset fields tracking stateblock values being hardcoded in the shader */
-    This->baseShader.num_sampled_samplers = 0;
-
-    /* Generate the HW shader */
-    TRACE("(%p) : Generating hardware program\n", This);
-    IWineD3DPixelShaderImpl_GenerateShader(iface);
-
-    This->baseShader.is_compiled = TRUE;
-
-    return WINED3D_OK;
 }
 
 const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
@@ -499,8 +423,70 @@ const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
     IWineD3DPixelShaderImpl_GetParent,
     /*** IWineD3DBaseShader methods ***/
     IWineD3DPixelShaderImpl_SetFunction,
-    IWineD3DPixelShaderImpl_CompileShader,
     /*** IWineD3DPixelShader methods ***/
+    IWineD3DPixelShaderImpl_UpdateSamplers,
     IWineD3DPixelShaderImpl_GetDevice,
     IWineD3DPixelShaderImpl_GetFunction
 };
+
+void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args) {
+    UINT i, sampler;
+    IWineD3DBaseTextureImpl *tex;
+
+    args->srgb_correction = stateblock->renderState[WINED3DRS_SRGBWRITEENABLE] ? 1 : 0;
+
+    memset(args->color_fixup, 0, sizeof(args->color_fixup));
+    for(i = 0; i < shader->baseShader.num_sampled_samplers; i++) {
+        sampler = shader->baseShader.sampled_samplers[i];
+        tex = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler];
+        if(!tex) {
+            args->color_fixup[sampler] = COLOR_FIXUP_IDENTITY;
+            continue;
+        }
+        args->color_fixup[sampler] = tex->baseTexture.shader_color_fixup;
+    }
+    if(shader->baseShader.hex_version >= WINED3DPS_VERSION(3,0)) {
+        if(((IWineD3DDeviceImpl *) shader->baseShader.device)->strided_streams.u.s.position_transformed) {
+            args->vp_mode = pretransformed;
+        } else if(use_vs((IWineD3DDeviceImpl *) shader->baseShader.device)) {
+            args->vp_mode = vertexshader;
+        } else {
+            args->vp_mode = fixedfunction;
+        }
+    } else {
+        args->vp_mode = vertexshader;
+    }
+}
+
+GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args)
+{
+    UINT i;
+    struct ps_compiled_shader *old_array;
+
+    /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
+     * so a linear search is more performant than a hashmap
+     */
+    for(i = 0; i < shader->num_gl_shaders; i++) {
+        if(memcmp(&shader->gl_shaders[i].args, args, sizeof(*args)) == 0) {
+            return shader->gl_shaders[i].prgId;
+        }
+    }
+
+    TRACE("No matching GL shader found, compiling a new shader\n");
+    old_array = shader->gl_shaders;
+    if(old_array) {
+        shader->gl_shaders = HeapReAlloc(GetProcessHeap(), 0, old_array,
+                                         (shader->num_gl_shaders + 1) * sizeof(*shader->gl_shaders));
+    } else {
+        shader->gl_shaders = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader->gl_shaders));
+    }
+
+    if(!shader->gl_shaders) {
+        ERR("Out of memory\n");
+        return 0;
+    }
+
+    shader->gl_shaders[shader->num_gl_shaders].args = *args;
+    shader->gl_shaders[shader->num_gl_shaders].prgId = pixelshader_compile(shader, args);
+    return shader->gl_shaders[shader->num_gl_shaders++].prgId;
+}
index c75e09d..efcac7b 100644 (file)
 WINE_DEFAULT_DEBUG_CHANNEL(d3d);
 #define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
 
-/* IWineD3DResource IUnknown parts follow: */
-HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, LPVOID *ppobj)
+void resource_cleanup(IWineD3DResource *iface)
 {
-    IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
-    TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
-    if (IsEqualGUID(riid, &IID_IUnknown)
-        || IsEqualGUID(riid, &IID_IWineD3DBase)
-        || IsEqualGUID(riid, &IID_IWineD3DResource)) {
-        IUnknown_AddRef(iface);
-        *ppobj = This;
-        return S_OK;
-    }
-    *ppobj = NULL;
-    return E_NOINTERFACE;
-}
-
-ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface) {
-    IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
-    ULONG ref = InterlockedIncrement(&This->resource.ref);
-    TRACE("(%p) : AddRef increasing from %d\n", This, ref - 1);
-    return ref; 
-}
-
-ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface) {
-    IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
-    ULONG ref = InterlockedDecrement(&This->resource.ref);
-    TRACE("(%p) : Releasing from %d\n", This, ref + 1);
-    if (ref == 0) {
-        IWineD3DResourceImpl_CleanUp(iface);
-        HeapFree(GetProcessHeap(), 0, This);
-    }
-    return ref;
-}
-
-/* class static (not in vtable) */
-void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     struct list *e1, *e2;
     PrivateData *data;
@@ -76,7 +42,7 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
 
     LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData) {
         data = LIST_ENTRY(e1, PrivateData, entry);
-        hr = IWineD3DResourceImpl_FreePrivateData(iface, &data->tag);
+        hr = resource_free_private_data(iface, &data->tag);
         if(hr != WINED3D_OK) {
             ERR("Failed to free private data when destroying resource %p, hr = %08x\n", This, hr);
         }
@@ -92,8 +58,8 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
     return;
 }
 
-/* IWineD3DResource Interface follows: */
-HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice** ppDevice) {
+HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice** ppDevice)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     TRACE("(%p) : returning %p\n", This, This->resource.wineD3DDevice);
     *ppDevice = (IWineD3DDevice *) This->resource.wineD3DDevice;
@@ -101,8 +67,7 @@ HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DD
     return WINED3D_OK;
 }
 
-static PrivateData* IWineD3DResourceImpl_FindPrivateData(IWineD3DResourceImpl *This,
-                    REFGUID tag)
+static PrivateData* resource_find_private_data(IWineD3DResourceImpl *This, REFGUID tag)
 {
     PrivateData *data;
     struct list *entry;
@@ -120,21 +85,21 @@ static PrivateData* IWineD3DResourceImpl_FindPrivateData(IWineD3DResourceImpl *T
     return NULL;
 }
 
-HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
+HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
+        const void *pData, DWORD SizeOfData, DWORD Flags)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     PrivateData *data;
 
     TRACE("(%p) : %s %p %d %d\n", This, debugstr_guid(refguid), pData, SizeOfData, Flags);
-    IWineD3DResourceImpl_FreePrivateData(iface, refguid);
+    resource_free_private_data(iface, refguid);
 
     data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
     if (NULL == data) return E_OUTOFMEMORY;
 
     data->tag = *refguid;
     data->flags = Flags;
-#if 0
-        (*data)->uniquenessValue = This->uniquenessValue;
-#endif
+
     if (Flags & WINED3DSPD_IUNKNOWN) {
         if(SizeOfData != sizeof(IUnknown *)) {
             WARN("IUnknown data with size %d, returning WINED3DERR_INVALIDCALL\n", SizeOfData);
@@ -160,20 +125,15 @@ HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFG
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
+HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID refguid, void *pData, DWORD *pSizeOfData)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     PrivateData *data;
 
     TRACE("(%p) : %p %p %p\n", This, refguid, pData, pSizeOfData);
-    data = IWineD3DResourceImpl_FindPrivateData(This, refguid);
+    data = resource_find_private_data(This, refguid);
     if (data == NULL) return WINED3DERR_NOTFOUND;
 
-
-#if 0 /* This may not be right. */
-    if (((*data)->flags & WINED3DSPD_VOLATILE)
-        && (*data)->uniquenessValue != This->uniquenessValue)
-        return DDERR_EXPIRED;
-#endif
     if (*pSizeOfData < data->size) {
         *pSizeOfData = data->size;
         return WINED3DERR_MOREDATA;
@@ -195,12 +155,13 @@ HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFG
 
     return WINED3D_OK;
 }
-HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid) {
+HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID refguid)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     PrivateData *data;
 
     TRACE("(%p) : %s\n", This, debugstr_guid(refguid));
-    data = IWineD3DResourceImpl_FindPrivateData(This, refguid);
+    data = resource_find_private_data(This, refguid);
     if (data == NULL) return WINED3DERR_NOTFOUND;
 
     if (data->flags & WINED3DSPD_IUNKNOWN)
@@ -217,7 +178,8 @@ HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REF
     return WINED3D_OK;
 }
 
-DWORD    WINAPI        IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew) {
+DWORD resource_set_priority(IWineD3DResource *iface, DWORD PriorityNew)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     DWORD PriorityOld = This->resource.priority;
     This->resource.priority = PriorityNew;
@@ -225,30 +187,22 @@ DWORD    WINAPI        IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface,
     return PriorityOld;
 }
 
-DWORD    WINAPI        IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface) {
+DWORD resource_get_priority(IWineD3DResource *iface)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     TRACE("(%p) : returning %d\n", This, This->resource.priority );
     return This->resource.priority;
 }
 
-/* Preloading of resources is not supported yet */
-void     WINAPI        IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface) {
-    IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
-    FIXME("(%p) : stub\n", This);
-}
-
-void     WINAPI        IWineD3DResourceImpl_UnLoad(IWineD3DResource *iface) {
-    IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
-    FIXME("(%p) : stub\n", This);
-}
-
-WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface) {
+WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     TRACE("(%p) : returning %d\n", This, This->resource.resourceType);
     return This->resource.resourceType;
 }
 
-HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent) {
+HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **pParent)
+{
     IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
     IUnknown_AddRef(This->resource.parent);
     *pParent = This->resource.parent;
@@ -262,22 +216,3 @@ void dumpResources(struct list *list) {
         FIXME("Leftover resource %p with type %d,%s\n", resource, IWineD3DResource_GetType((IWineD3DResource *) resource), debug_d3dresourcetype(IWineD3DResource_GetType((IWineD3DResource *) resource)));
     }
 }
-
-static const IWineD3DResourceVtbl IWineD3DResource_Vtbl =
-{
-    /* IUnknown */
-    IWineD3DResourceImpl_QueryInterface,
-    IWineD3DResourceImpl_AddRef,
-    IWineD3DResourceImpl_Release,
-    /* IWineD3DResource */
-    IWineD3DResourceImpl_GetParent,
-    IWineD3DResourceImpl_GetDevice,
-    IWineD3DResourceImpl_SetPrivateData,
-    IWineD3DResourceImpl_GetPrivateData,
-    IWineD3DResourceImpl_FreePrivateData,
-    IWineD3DResourceImpl_SetPriority,
-    IWineD3DResourceImpl_GetPriority,
-    IWineD3DResourceImpl_PreLoad,
-    IWineD3DResourceImpl_UnLoad,
-    IWineD3DResourceImpl_GetType
-};
index b9d28d4..0da9842 100644 (file)
@@ -244,7 +244,7 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
     if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE]      ||
         stateblock->renderState[WINED3DRS_EDGEANTIALIAS]         ||
         stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
-        const GlPixelFormatDesc *glDesc;
+        const struct GlPixelFormatDesc *glDesc;
         getFormatDescEntry(target->resource.format, &GLINFO_LOCATION, &glDesc);
 
         /* Disable blending in all cases even without pixelshaders. With blending on we could face a big performance penalty.
@@ -702,7 +702,7 @@ state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
             checkGLcall("glFinalCombinerInputNV()");
         }
     } else {
-        float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+        const GLfloat black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
 
         /* for the case of enabled lighting: */
         glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
@@ -1224,7 +1224,7 @@ static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock, Wi
 static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
     GLenum Parm = 0;
-    WineDirect3DStridedData *diffuse = &device->strided_streams.u.s.diffuse;
+    const WineDirect3DStridedData *diffuse = &device->strided_streams.u.s.diffuse;
     BOOL isDiffuseSupplied;
 
     /* Depends on the decoded vertex declaration to read the existence of diffuse data.
@@ -1323,7 +1323,7 @@ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
                 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*)&device->updateStateBlock->material.Specular);
                 checkGLcall("glMaterialfv");
             } else {
-                float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
+                const GLfloat black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
                 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
                 checkGLcall("glMaterialfv");
             }
@@ -1566,10 +1566,10 @@ static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, Win
     if(stateblock->renderState[WINED3DRS_LASTPIXEL]) {
         TRACE("Last Pixel Drawing Enabled\n");
     } else {
-        static BOOL first = TRUE;
-        if(first) {
+        static BOOL warned;
+        if (!warned) {
             FIXME("Last Pixel Drawing Disabled, not handled yet\n");
-            first = FALSE;
+            warned = TRUE;
         } else {
             TRACE("Last Pixel Drawing Disabled, not handled yet\n");
         }
@@ -3119,8 +3119,9 @@ static void unloadTexCoords(IWineD3DStateBlockImpl *stateblock) {
     }
 }
 
-static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd, GLint *curVBO) {
-    UINT *offset = stateblock->streamOffset;
+static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, const WineDirect3DVertexStridedData *sd, GLint *curVBO)
+{
+    const UINT *offset = stateblock->streamOffset;
     unsigned int mapped_stage = 0;
     unsigned int textureNo = 0;
 
@@ -3174,6 +3175,10 @@ static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertex
 static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
     DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
+    const GLfloat s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
+    const GLfloat t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
+    const GLfloat r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
+    const GLfloat q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
 
     if (mapped_stage == -1) {
         TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage);
@@ -3223,10 +3228,6 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
          * equates roughly to EYE_LINEAR
          */
         {
-            float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
-            float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
-            float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
-            float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
             TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
 
             glMatrixMode(GL_MODELVIEW);
@@ -3257,10 +3258,6 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
     case WINED3DTSS_TCI_CAMERASPACENORMAL:
         {
             if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
-                float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
-                float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
-                float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
-                float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
                 TRACE("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane\n");
 
                 glMatrixMode(GL_MODELVIEW);
@@ -3291,10 +3288,6 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
     case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
         {
             if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
-            float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
-            float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
-            float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
-            float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
             TRACE("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane\n");
 
             glMatrixMode(GL_MODELVIEW);
@@ -3480,7 +3473,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
     }
 }
 
-void apply_pshader_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
+static void apply_pshader_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
 
     if (use_ps(device)) {
@@ -3518,9 +3511,6 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DC
             * if a different texture was bound. I don't have to do anything.
             */
         }
-
-        /* Compile and bind the shader */
-        IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
     } else {
         /* Disabled the pixel shader - color ops weren't applied
          * while it was enabled, so re-apply them.
@@ -3637,12 +3627,12 @@ static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateblock, W
      */
     if(stateblock->wineD3DDevice->view_ident) {
         glLoadMatrixf(&stateblock->transforms[WINED3DTS_WORLDMATRIX(matrix)].u.m[0][0]);
-        checkGLcall("glLoadMatrixf")
+        checkGLcall("glLoadMatrixf");
     } else {
         glLoadMatrixf(&stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
-        checkGLcall("glLoadMatrixf")
+        checkGLcall("glLoadMatrixf");
         glMultMatrixf(&stateblock->transforms[WINED3DTS_WORLDMATRIX(matrix)].u.m[0][0]);
-        checkGLcall("glMultMatrixf")
+        checkGLcall("glMultMatrixf");
     }
 }
 
@@ -3716,7 +3706,7 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
      * NOTE2: Apparently texture transforms do NOT need reapplying
      */
 
-    PLIGHTINFOEL *light = NULL;
+    const PLIGHTINFOEL *light = NULL;
 
     glMatrixMode(GL_MODELVIEW);
     checkGLcall("glMatrixMode(GL_MODELVIEW)");
@@ -3907,10 +3897,27 @@ static inline void unloadVertexData(IWineD3DStateBlockImpl *stateblock) {
     unloadTexCoords(stateblock);
 }
 
+static inline void unload_numbered_array(IWineD3DStateBlockImpl *stateblock, WineD3DContext *context, int i)
+{
+    GL_EXTCALL(glDisableVertexAttribArrayARB(i));
+    checkGLcall("glDisableVertexAttribArrayARB(reg)");
+    /* Some Windows drivers(NV GF 7) use the latest value that was used when drawing with the now
+     * deactivated stream disabled, some other drivers(ATI, NV GF 8) set the undefined values to 0x00.
+     * Let's set them to 0x00 to avoid hitting some undefined aspects of OpenGL. All that is really
+     * important here is the glDisableVertexAttribArrayARB call above. The test shows that the refrast
+     * keeps dereferencing the pointers, which would cause crashes in some games like Half Life 2: Episode Two.
+     */
+    GL_EXTCALL(glVertexAttrib4NubARB(i, 0, 0, 0, 0));
+    checkGLcall("glVertexAttrib4NubARB(i, 0, 0, 0, 0)");
+
+    context->numbered_array_mask &= ~(1 << i);
+}
+
 /* This should match any arrays loaded in loadNumberedArrays
  * TODO: Only load / unload arrays if we have to.
  */
-static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) {
+static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineD3DContext *context)
+{
     /* disable any attribs (this is the same for both GLSL and ARB modes) */
     GLint maxAttribs = 16;
     int i;
@@ -3921,23 +3928,16 @@ static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) {
     if (glGetError() != GL_NO_ERROR)
         maxAttribs = 16;
     for (i = 0; i < maxAttribs; ++i) {
-        GL_EXTCALL(glDisableVertexAttribArrayARB(i));
-        checkGLcall("glDisableVertexAttribArrayARB(reg)");
-        /* Some Windows drivers(NV GF 7) use the latest value that was used when drawing with the now
-         * deactivated stream disabled, some other drivers(ATI, NV GF 8) set the undefined values to 0x00.
-         * Let's set them to 0x00 to avoid hitting some undefined aspects of OpenGL. All that is really
-         * important here is the glDisableVertexAttribArrayARB call above. The test shows that the refrast
-         * keeps dereferencing the pointers, which would cause crashes in some games like Half Life 2: Episode Two.
-         */
-        GL_EXTCALL(glVertexAttrib4NubARB(i, 0, 0, 0, 0));
-        checkGLcall("glVertexAttrib4NubARB(i, 0, 0, 0, 0)");
+        unload_numbered_array(stateblock, context, i);
     }
 }
 
-static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *strided) {
+static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
+        const WineDirect3DVertexStridedData *strided, WineD3DContext *context)
+{
     GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
     int i;
-    UINT *offset = stateblock->streamOffset;
+    const UINT *offset = stateblock->streamOffset;
     IWineD3DVertexBufferImpl *vb;
     DWORD_PTR shift_index;
 
@@ -3945,13 +3945,15 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
     stateblock->wineD3DDevice->instancedDraw = FALSE;
 
     for (i = 0; i < MAX_ATTRIBS; i++) {
-
-        if (!strided->u.input[i].lpData && !strided->u.input[i].VBO)
+        if (!strided->u.input[i].VBO && !strided->u.input[i].lpData)
+        {
+            if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i);
             continue;
+        }
 
         /* Do not load instance data. It will be specified using glTexCoord by drawprim */
         if(stateblock->streamFlags[strided->u.input[i].streamNo] & WINED3DSTREAMSOURCE_INSTANCEDATA) {
-            GL_EXTCALL(glDisableVertexAttribArrayARB(i));
+            if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i);
             stateblock->wineD3DDevice->instancedDraw = TRUE;
             continue;
         }
@@ -3996,31 +3998,37 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
                                 strided->u.input[i].lpData +
                                 stateblock->loadBaseVertexIndex * strided->u.input[i].dwStride +
                                 offset[strided->u.input[i].streamNo]) );
-                }
-            GL_EXTCALL(glEnableVertexAttribArrayARB(i));
+            }
+
+            if (!(context->numbered_array_mask & (1 << i)))
+            {
+                GL_EXTCALL(glEnableVertexAttribArrayARB(i));
+                context->numbered_array_mask |= (1 << i);
+            }
         } else {
             /* Stride = 0 means always the same values. glVertexAttribPointerARB doesn't do that. Instead disable the pointer and
              * set up the attribute statically. But we have to figure out the system memory address.
              */
-            BYTE *ptr = strided->u.input[i].lpData + offset[strided->u.input[i].streamNo];
+            const BYTE *ptr = strided->u.input[i].lpData + offset[strided->u.input[i].streamNo];
             if(strided->u.input[i].VBO) {
                 vb = (IWineD3DVertexBufferImpl *) stateblock->streamSource[strided->u.input[i].streamNo];
                 ptr += (long) vb->resource.allocatedMemory;
             }
-            GL_EXTCALL(glDisableVertexAttribArrayARB(i));
+
+            if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i);
 
             switch(strided->u.input[i].dwType) {
                 case WINED3DDECLTYPE_FLOAT1:
-                    GL_EXTCALL(glVertexAttrib1fvARB(i, (float *) ptr));
+                    GL_EXTCALL(glVertexAttrib1fvARB(i, (const GLfloat *)ptr));
                     break;
                 case WINED3DDECLTYPE_FLOAT2:
-                    GL_EXTCALL(glVertexAttrib2fvARB(i, (float *) ptr));
+                    GL_EXTCALL(glVertexAttrib2fvARB(i, (const GLfloat *)ptr));
                     break;
                 case WINED3DDECLTYPE_FLOAT3:
-                    GL_EXTCALL(glVertexAttrib3fvARB(i, (float *) ptr));
+                    GL_EXTCALL(glVertexAttrib3fvARB(i, (const GLfloat *)ptr));
                     break;
                 case WINED3DDECLTYPE_FLOAT4:
-                    GL_EXTCALL(glVertexAttrib4fvARB(i, (float *) ptr));
+                    GL_EXTCALL(glVertexAttrib4fvARB(i, (const GLfloat *)ptr));
                     break;
 
                 case WINED3DDECLTYPE_UBYTE4:
@@ -4032,38 +4040,38 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
                     break;
 
                 case WINED3DDECLTYPE_SHORT2:
-                    GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr));
+                    GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr));
                     break;
                 case WINED3DDECLTYPE_SHORT4:
-                    GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr));
+                    GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr));
                     break;
 
                 case WINED3DDECLTYPE_SHORT2N:
                 {
-                    GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1};
+                    const GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
                     GL_EXTCALL(glVertexAttrib4NsvARB(i, s));
                     break;
                 }
                 case WINED3DDECLTYPE_USHORT2N:
                 {
-                    GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1};
+                    const GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
                     GL_EXTCALL(glVertexAttrib4NusvARB(i, s));
                     break;
                 }
                 case WINED3DDECLTYPE_SHORT4N:
-                    GL_EXTCALL(glVertexAttrib4NsvARB(i, (GLshort *) ptr));
+                    GL_EXTCALL(glVertexAttrib4NsvARB(i, (const GLshort *)ptr));
                     break;
                 case WINED3DDECLTYPE_USHORT4N:
-                    GL_EXTCALL(glVertexAttrib4NusvARB(i, (GLushort *) ptr));
+                    GL_EXTCALL(glVertexAttrib4NusvARB(i, (const GLushort *)ptr));
                     break;
 
                 case WINED3DDECLTYPE_UDEC3:
                     FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
-                    /*glVertexAttrib3usvARB(i, (GLushort *) ptr); Does not exist */
+                    /*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
                     break;
                 case WINED3DDECLTYPE_DEC3N:
                     FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
-                    /*glVertexAttrib3NusvARB(i, (GLushort *) ptr); Does not exist */
+                    /*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
                     break;
 
                 case WINED3DDECLTYPE_FLOAT16_2:
@@ -4088,8 +4096,9 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
 }
 
 /* Used from 2 different functions, and too big to justify making it inlined */
-static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd) {
-    UINT *offset = stateblock->streamOffset;
+static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const WineDirect3DVertexStridedData *sd)
+{
+    const UINT *offset = stateblock->streamOffset;
     GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
 
     TRACE("Using fast vertex array code\n");
@@ -4130,10 +4139,11 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVerte
             checkGLcall("glWeightPointerARB");
 
             if((sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO)){
-                static BOOL showfixme = TRUE;
-                if(showfixme){
+                static BOOL warned;
+                if (!warned)
+                {
                     FIXME("blendMatrixIndices support\n");
-                    showfixme = FALSE;
+                    warned = TRUE;
                 }
             }
         } else {
@@ -4271,9 +4281,9 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVerte
                                                    WINED3D_ATR_GLTYPE(sd->u.s.specular.dwType),
                                                    sd->u.s.specular.dwStride,
                                                    sd->u.s.specular.lpData + stateblock->loadBaseVertexIndex * sd->u.s.specular.dwStride + offset[sd->u.s.specular.streamNo]);
-            vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
+            checkGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
             glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
-            vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
+            checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
         } else {
 
         /* Missing specular color is not critical, no warnings */
@@ -4295,9 +4305,8 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVerte
     loadTexCoords(stateblock, sd, &curVBO);
 }
 
-static inline void drawPrimitiveTraceDataLocations(
-    WineDirect3DVertexStridedData *dataLocations) {
-
+static inline void drawPrimitiveTraceDataLocations(const WineDirect3DVertexStridedData *dataLocations)
+{
     /* Dump out what parts we have supplied */
     TRACE("Strided Data:\n");
     TRACE_STRIDED((dataLocations), position);
@@ -4332,6 +4341,8 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCo
     BOOL fixup = FALSE;
     WineDirect3DVertexStridedData *dataLocations = &device->strided_streams;
     BOOL useVertexShaderFunction;
+    BOOL load_numbered = FALSE;
+    BOOL load_named = FALSE;
 
     if (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader &&
         ((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) {
@@ -4365,41 +4376,51 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCo
         useVertexShaderFunction = FALSE;
     }
 
-    /* Unload the old arrays before loading the new ones to get old junk out */
-    if(context->numberedArraysLoaded) {
-        unloadNumberedArrays(stateblock);
-        context->numberedArraysLoaded = FALSE;
-    }
-    if(context->namedArraysLoaded) {
-        unloadVertexData(stateblock);
-        context->namedArraysLoaded = FALSE;
-    }
-
     if(useVertexShaderFunction) {
         if(((IWineD3DVertexDeclarationImpl *) stateblock->vertexDecl)->half_float_conv_needed && !fixup) {
             TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n");
             device->useDrawStridedSlow = TRUE;
-            context->numberedArraysLoaded = FALSE;
         } else {
-            TRACE("Loading numbered arrays\n");
-            loadNumberedArrays(stateblock, dataLocations);
+            load_numbered = TRUE;
             device->useDrawStridedSlow = FALSE;
-            context->numberedArraysLoaded = TRUE;
         }
     } else if (fixup ||
                (dataLocations->u.s.pSize.lpData == NULL &&
                 dataLocations->u.s.diffuse.lpData == NULL &&
                 dataLocations->u.s.specular.lpData == NULL)) {
         /* Load the vertex data using named arrays */
-        TRACE("Loading vertex data\n");
-        loadVertexData(stateblock, dataLocations);
+        load_named = TRUE;
         device->useDrawStridedSlow = FALSE;
-        context->namedArraysLoaded = TRUE;
     } else {
         TRACE("Not loading vertex data\n");
         device->useDrawStridedSlow = TRUE;
     }
 
+    if (context->numberedArraysLoaded && !load_numbered)
+    {
+        unloadNumberedArrays(stateblock, context);
+        context->numberedArraysLoaded = FALSE;
+        context->numbered_array_mask = 0;
+    }
+    else if (context->namedArraysLoaded)
+    {
+        unloadVertexData(stateblock);
+        context->namedArraysLoaded = FALSE;
+    }
+
+    if (load_numbered)
+    {
+        TRACE("Loading numbered arrays\n");
+        loadNumberedArrays(stateblock, dataLocations, context);
+        context->numberedArraysLoaded = TRUE;
+    }
+    else if (load_named)
+    {
+        TRACE("Loading vertex data\n");
+        loadVertexData(stateblock, dataLocations);
+        context->namedArraysLoaded = TRUE;
+    }
+
 /* Generate some fixme's if unsupported functionality is being used */
 #define BUFFER_OR_DATA(_attribute) dataLocations->u.s._attribute.lpData
     /* TODO: Either support missing functionality in fixupVertices or by creating a shader to replace the pipeline. */
@@ -4511,11 +4532,6 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, W
             state_normalize(STATE_RENDER(WINED3DRS_NORMALIZENORMALS), stateblock, context);
         }
     } else {
-        /* We compile the shader here because we need the vertex declaration
-         * in order to determine if we need to do any swizzling for D3DCOLOR
-         * registers. If the shader is already compiled this call will do nothing. */
-        IWineD3DVertexShader_CompileShader(stateblock->vertexShader);
-
         if(!context->last_was_vshader) {
             int i;
             static BOOL warned = FALSE;
@@ -4610,7 +4626,7 @@ static void viewport_vertexpart(DWORD state, IWineD3DStateBlockImpl *stateblock,
 
 static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
     UINT Index = state - STATE_ACTIVELIGHT(0);
-    PLIGHTINFOEL *lightInfo = stateblock->activeLights[Index];
+    const PLIGHTINFOEL *lightInfo = stateblock->activeLights[Index];
 
     if(!lightInfo) {
         glDisable(GL_LIGHT0 + Index);
@@ -5445,7 +5461,8 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = {
 #define GLINFO_LOCATION (*gl_info)
 static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { }
 
-static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {
+static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps)
+{
     pCaps->TextureOpCaps =  WINED3DTEXOPCAPS_ADD         |
                             WINED3DTEXOPCAPS_ADDSIGNED   |
                             WINED3DTEXOPCAPS_ADDSIGNED2X |
@@ -5483,8 +5500,22 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_in
 
 static HRESULT ffp_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
 static void ffp_fragment_free(IWineD3DDevice *iface) {}
-static BOOL ffp_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking shader format support for format %s: [FAILED]\n", debug_d3dformat(fmt));
+static BOOL ffp_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
+    }
+
+    /* We only support identity conversions. */
+    if (is_identity_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
+    }
+
+    TRACE("[FAILED]\n");
     return FALSE;
 }
 
@@ -5493,12 +5524,13 @@ const struct fragment_pipeline ffp_fragment_pipeline = {
     ffp_fragment_get_caps,
     ffp_fragment_alloc,
     ffp_fragment_free,
-    ffp_conv_supported,
+    ffp_color_fixup_supported,
     ffp_fragmentstate_template,
     FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
 };
 
-static int num_handlers(APPLYSTATEFUNC *funcs) {
+static unsigned int num_handlers(const APPLYSTATEFUNC *funcs)
+{
     unsigned int i;
     for(i = 0; funcs[i]; i++);
     return i;
@@ -5515,12 +5547,10 @@ static void multistate_apply_3(DWORD state, IWineD3DStateBlockImpl *stateblock,
     stateblock->wineD3DDevice->multistate_funcs[state][2](state, stateblock, context);
 }
 
-void compile_state_table(struct StateEntry *StateTable,
-                         APPLYSTATEFUNC **dev_multistate_funcs,
-                         WineD3D_GL_Info *gl_info,
-                         const struct StateEntryTemplate *vertex,
-                         const struct fragment_pipeline *fragment,
-                         const struct StateEntryTemplate *misc) {
+void compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
+        const WineD3D_GL_Info *gl_info, const struct StateEntryTemplate *vertex,
+        const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc)
+{
     unsigned int i, type, handlers;
     APPLYSTATEFUNC multistate_funcs[STATE_HIGHEST + 1][3];
     const struct StateEntryTemplate *cur;
index 0d99134..3faa5a0 100644 (file)
@@ -63,11 +63,8 @@ HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) {
 }
 
 /** Copy all members of one stateblock to another */
-void stateblock_savedstates_copy(
-    IWineD3DStateBlock* iface,
-    SAVEDSTATES* dest,
-    SAVEDSTATES* source) {
-    
+static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *dest, const SAVEDSTATES *source)
+{
     IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
     unsigned bsize = sizeof(BOOL);
 
@@ -90,10 +87,10 @@ void stateblock_savedstates_copy(
     memcpy(dest->textureState, source->textureState, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
     memcpy(dest->samplerState, source->samplerState, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
     memcpy(dest->clipplane, source->clipplane, bsize * MAX_CLIPPLANES);
-    memcpy(dest->pixelShaderConstantsB, source->pixelShaderConstantsB, bsize * MAX_CONST_B);
-    memcpy(dest->pixelShaderConstantsI, source->pixelShaderConstantsI, bsize * MAX_CONST_I);
-    memcpy(dest->vertexShaderConstantsB, source->vertexShaderConstantsB, bsize * MAX_CONST_B);
-    memcpy(dest->vertexShaderConstantsI, source->vertexShaderConstantsI, bsize * MAX_CONST_I);
+    dest->pixelShaderConstantsB = source->pixelShaderConstantsB;
+    dest->pixelShaderConstantsI = source->pixelShaderConstantsI;
+    dest->vertexShaderConstantsB = source->vertexShaderConstantsB;
+    dest->vertexShaderConstantsI = source->vertexShaderConstantsI;
 
     /* Dynamically sized arrays */
     memcpy(dest->pixelShaderConstantsF, source->pixelShaderConstantsF, bsize * GL_LIMITS(pshader_constantsF));
@@ -128,10 +125,10 @@ void stateblock_savedstates_set(
     memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
     memset(states->samplerState, value, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
     memset(states->clipplane, value, bsize * MAX_CLIPPLANES);
-    memset(states->pixelShaderConstantsB, value, bsize * MAX_CONST_B);
-    memset(states->pixelShaderConstantsI, value, bsize * MAX_CONST_I);
-    memset(states->vertexShaderConstantsB, value, bsize * MAX_CONST_B);
-    memset(states->vertexShaderConstantsI, value, bsize * MAX_CONST_I);
+    states->pixelShaderConstantsB = value ? 0xffff : 0;
+    states->pixelShaderConstantsI = value ? 0xffff : 0;
+    states->vertexShaderConstantsB = value ? 0xffff : 0;
+    states->vertexShaderConstantsI = value ? 0xffff : 0;
 
     /* Dynamically sized arrays */
     memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF));
@@ -710,7 +707,7 @@ static inline void apply_lights(IWineD3DDevice *pDevice, IWineD3DStateBlockImpl
         struct list *e;
 
         LIST_FOR_EACH(e, &This->lightMap[i]) {
-            PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry);
+            const PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry);
 
             if(light->changed) {
                 IWineD3DDevice_SetLight(pDevice, light->OriginalIndex, &light->OriginalParms);
index 1849b83..0191403 100644 (file)
 #include "wined3d_private.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
+WINE_DECLARE_DEBUG_CHANNEL(d3d);
 #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
 
-HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf);
 static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey);
 static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert);
-static inline void clear_unused_channels(IWineD3DSurfaceImpl *This);
 static void surface_remove_pbo(IWineD3DSurfaceImpl *This);
 
 void surface_force_reload(IWineD3DSurface *iface)
@@ -210,8 +209,9 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
         LEAVE_GL();
 
         if (This->Flags & SFLAG_NONPOW2) {
-            LPBYTE src_data, dst_data;
-            int y;
+            const BYTE *src_data;
+            BYTE *dst_data;
+            UINT y;
             /*
              * Some games (e.g. warhammer 40k) don't work properly with the odd pitches, preventing
              * the surface pitch from being used to box non-power2 textures. Instead we have to use a hack to
@@ -346,7 +346,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi
  * activating the right context and binding the correct texture. */
 static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type) {
     BOOL enable_client_storage = FALSE;
-    BYTE *mem = NULL;
+    const BYTE *mem = NULL;
 
     if(This->heightscale != 1.0 && This->heightscale != 0.0) height *= This->heightscale;
 
@@ -443,7 +443,7 @@ void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int wi
     }
 
     if (!renderbuffer) {
-        const GlPixelFormatDesc *glDesc;
+        const struct GlPixelFormatDesc *glDesc;
         getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
 
         GL_EXTCALL(glGenRenderbuffersEXT(1, &renderbuffer));
@@ -480,7 +480,8 @@ GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchai
     return GL_BACK;
 }
 
-ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
+static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     ULONG ref = InterlockedDecrement(&This->resource.ref);
     TRACE("(%p) : Releasing from %d\n", This, ref + 1);
@@ -527,7 +528,7 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
 
         HeapFree(GetProcessHeap(), 0, This->palette9);
 
-        IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
+        resource_cleanup((IWineD3DResource *)iface);
 
         if(This->overlay_dest) {
             list_remove(&This->overlay_entry);
@@ -544,7 +545,8 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
    IWineD3DSurface IWineD3DResource parts follow
    **************************************************** */
 
-void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
+static void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface)
+{
     /* TODO: check for locks */
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     IWineD3DBaseTexture *baseTexture = NULL;
@@ -674,22 +676,13 @@ static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
    IWineD3DSurface IWineD3DSurface parts follow
    ****************************************************** */
 
-void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
+static void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     TRACE("(%p) : returning %p\n", This, &This->glDescription);
     *glDescription = &This->glDescription;
 }
 
-/* TODO: think about moving this down to resource? */
-const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface) {
-    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
-    /* This should only be called for sysmem textures, it may be a good idea to extend this to all pools at some point in the future  */
-    if (This->resource.pool != WINED3DPOOL_SYSTEMMEM) {
-        FIXME(" (%p)Attempting to get system memory for a non-system memory texture\n", iface);
-    }
-    return (CONST void*)(This->resource.allocatedMemory);
-}
-
 /* Read the framebuffer back into the surface */
 static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, void *dest, UINT pitch) {
     IWineD3DSwapChainImpl *swapchain;
@@ -803,7 +796,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
                  local_rect.right - local_rect.left,
                  local_rect.bottom - local_rect.top,
                  fmt, type, mem);
-    vcheckGLcall("glReadPixels");
+    checkGLcall("glReadPixels");
 
     if(This->Flags & SFLAG_PBO) {
         GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
@@ -864,7 +857,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
      * In case of P8 render targets, the index is stored in the alpha component so no conversion is needed.
      */
     if((This->resource.format == WINED3DFMT_P8) && !primary_render_target_is_p8(myDevice)) {
-        PALETTEENTRY *pal = NULL;
+        const PALETTEENTRY *pal = NULL;
         DWORD width = pitch / 3;
         int x, y, c;
 
@@ -879,9 +872,9 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
         for(y = local_rect.top; y < local_rect.bottom; y++) {
             for(x = local_rect.left; x < local_rect.right; x++) {
                 /*                      start              lines            pixels      */
-                BYTE *blue =  mem + y * pitch + x * (sizeof(BYTE) * 3);
-                BYTE *green = blue  + 1;
-                BYTE *red =   green + 1;
+                const BYTE *blue = mem + y * pitch + x * (sizeof(BYTE) * 3);
+                const BYTE *green = blue  + 1;
+                const BYTE *red = green + 1;
 
                 for(c = 0; c < 256; c++) {
                     if(*red   == pal[c].peRed   &&
@@ -951,8 +944,6 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This)
                                  This->pow2Height, format, type);
     }
 
-    clear_unused_channels(This);
-
     ENTER_GL();
     /* If !SrcIsUpsideDown we should flip the surface.
      * This can be done using glCopyTexSubImage2D but this
@@ -968,7 +959,7 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This)
     checkGLcall("glCopyTexSubImage2D");
 
     glReadBuffer(prevRead);
-    vcheckGLcall("glReadBuffer");
+    checkGLcall("glReadBuffer");
 
     LEAVE_GL();
     TRACE("Updated target %d\n", This->glDescription.target);
@@ -1216,18 +1207,18 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
     }
 
     glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
-    vcheckGLcall("glIntegerv");
+    checkGLcall("glIntegerv");
     glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]);
-    vcheckGLcall("glIntegerv");
+    checkGLcall("glIntegerv");
     glPixelZoom(1.0, -1.0);
-    vcheckGLcall("glPixelZoom");
+    checkGLcall("glPixelZoom");
 
     /* If not fullscreen, we need to skip a number of bytes to find the next row of data */
     glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes);
     glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width);
 
     glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1);
-    vcheckGLcall("glRasterPos2f");
+    checkGLcall("glRasterPos2f");
 
     /* Some drivers(radeon dri, others?) don't like exceptions during
      * glDrawPixels. If the surface is a DIB section, it might be in GDIMode
@@ -1270,14 +1261,14 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
     }
 
     glPixelZoom(1.0,1.0);
-    vcheckGLcall("glPixelZoom");
+    checkGLcall("glPixelZoom");
 
     glRasterPos3iv(&prev_rasterpos[0]);
-    vcheckGLcall("glRasterPos3iv");
+    checkGLcall("glRasterPos3iv");
 
     /* Reset to previous pack row length */
     glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes);
-    vcheckGLcall("glPixelStorei GL_UNPACK_ROW_LENGTH");
+    checkGLcall("glPixelStorei GL_UNPACK_ROW_LENGTH");
 
     if(!swapchain) {
         glDrawBuffer(myDevice->offscreenBuffer);
@@ -1405,7 +1396,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     WINED3DLOCKED_RECT lock;
     HRESULT hr;
@@ -1470,7 +1462,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
         /* GetDC on palettized formats is unsupported in D3D9, and the method is missing in
             D3D8, so this should only be used for DX <=7 surfaces (with non-device palettes) */
         unsigned int n;
-        PALETTEENTRY *pal = NULL;
+        const PALETTEENTRY *pal = NULL;
 
         if(This->palette) {
             pal = This->palette->palents;
@@ -1501,7 +1493,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
 
     TRACE("(%p)->(%p)\n",This,hDC);
@@ -1533,7 +1526,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
 
 HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) {
     BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT);
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
 
@@ -1707,38 +1700,6 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
             *target_bpp = 2;
             break;
 
-        case WINED3DFMT_R32F:
-            /* Can be loaded in theory with fmt=GL_RED, type=GL_FLOAT, but this fails. The reason
-             * is that D3D expects the undefined green, blue and alpha channels to return 1.0
-             * when sampling, but OpenGL sets green and blue to 0.0 instead. Thus we have to inject
-             * 1.0 instead.
-             *
-             * The alpha channel defaults to 1.0 in opengl, so nothing has to be done about it.
-             */
-            *convert = CONVERT_R32F;
-            *format = GL_RGB;
-            *internal = GL_RGB32F_ARB;
-            *type = GL_FLOAT;
-            *target_bpp = 12;
-            break;
-
-        case WINED3DFMT_R16F:
-            /* Similar to R32F */
-            *convert = CONVERT_R16F;
-            *format = GL_RGB;
-            *internal = GL_RGB16F_ARB;
-            *type = GL_HALF_FLOAT_ARB;
-            *target_bpp = 6;
-            break;
-
-        case WINED3DFMT_G16R16:
-            *convert = CONVERT_G16R16;
-            *format = GL_RGB;
-            *internal = GL_RGB16_EXT;
-            *type = GL_UNSIGNED_SHORT;
-            *target_bpp = 6;
-            break;
-
         default:
             break;
     }
@@ -1746,8 +1707,11 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
     return WINED3D_OK;
 }
 
-HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This) {
-    BYTE *source, *dest;
+static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width,
+        UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This)
+{
+    const BYTE *source;
+    BYTE *dest;
     TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert,This);
 
     switch (convert) {
@@ -1798,13 +1762,13 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
                      on the same surface and disables color keying in such a case
             */
             unsigned int x, y;
-            WORD *Source;
+            const WORD *Source;
             WORD *Dest;
 
             TRACE("Color keyed 565\n");
 
             for (y = 0; y < height; y++) {
-                Source = (WORD *) (src + y * pitch);
+                Source = (const WORD *)(src + y * pitch);
                 Dest = (WORD *) (dst + y * outpitch);
                 for (x = 0; x < width; x++ ) {
                     WORD color = *Source++;
@@ -1823,11 +1787,11 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         {
             /* Converting X1R5G5B5 format to R5G5B5A1 to emulate color-keying. */
             unsigned int x, y;
-            WORD *Source;
+            const WORD *Source;
             WORD *Dest;
             TRACE("Color keyed 5551\n");
             for (y = 0; y < height; y++) {
-                Source = (WORD *) (src + y * pitch);
+                Source = (const WORD *)(src + y * pitch);
                 Dest = (WORD *) (dst + y * outpitch);
                 for (x = 0; x < width; x++ ) {
                     WORD color = *Source++;
@@ -1845,6 +1809,29 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         }
         break;
 
+        case CONVERT_CK_RGB24:
+        {
+            /* Converting R8G8B8 format to R8G8B8A8 with color-keying. */
+            unsigned int x, y;
+            for (y = 0; y < height; y++)
+            {
+                source = src + pitch * y;
+                dest = dst + outpitch * y;
+                for (x = 0; x < width; x++) {
+                    DWORD color = ((DWORD)source[0] << 16) + ((DWORD)source[1] << 8) + (DWORD)source[2] ;
+                    DWORD dstcolor = color << 8;
+                    if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
+                        (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
+                        dstcolor |= 0xff;
+                    }
+                    *(DWORD*)dest = dstcolor;
+                    source += 3;
+                    dest += 4;
+                }
+            }
+        }
+        break;
+
         case CONVERT_RGB32_888:
         {
             /* Converting X8R8G8B8 format to R8G8B8A8 with color-keying. */
@@ -1854,7 +1841,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
                 source = src + pitch * y;
                 dest = dst + outpitch * y;
                 for (x = 0; x < width; x++) {
-                    DWORD color = 0xffffff & *(DWORD*)source;
+                    DWORD color = 0xffffff & *(const DWORD*)source;
                     DWORD dstcolor = color << 8;
                     if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
                         (color > This->SrcBltCKey.dwColorSpaceHighValue)) {
@@ -1871,10 +1858,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         case CONVERT_V8U8:
         {
             unsigned int x, y;
-            short *Source;
+            const short *Source;
             unsigned char *Dest;
             for(y = 0; y < height; y++) {
-                Source = (short *) (src + y * pitch);
+                Source = (const short *)(src + y * pitch);
                 Dest = dst + y * outpitch;
                 for (x = 0; x < width; x++ ) {
                     long color = (*Source++);
@@ -1890,10 +1877,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         case CONVERT_V16U16:
         {
             unsigned int x, y;
-            DWORD *Source;
+            const DWORD *Source;
             unsigned short *Dest;
             for(y = 0; y < height; y++) {
-                Source = (DWORD *) (src + y * pitch);
+                Source = (const DWORD *)(src + y * pitch);
                 Dest = (unsigned short *) (dst + y * outpitch);
                 for (x = 0; x < width; x++ ) {
                     DWORD color = (*Source++);
@@ -1909,10 +1896,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         case CONVERT_Q8W8V8U8:
         {
             unsigned int x, y;
-            DWORD *Source;
+            const DWORD *Source;
             unsigned char *Dest;
             for(y = 0; y < height; y++) {
-                Source = (DWORD *) (src + y * pitch);
+                Source = (const DWORD *)(src + y * pitch);
                 Dest = dst + y * outpitch;
                 for (x = 0; x < width; x++ ) {
                     long color = (*Source++);
@@ -1929,7 +1916,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         case CONVERT_L6V5U5:
         {
             unsigned int x, y;
-            WORD *Source;
+            const WORD *Source;
             unsigned char *Dest;
 
             if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -1938,7 +1925,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
                  * loaded
                  */
                 for(y = 0; y < height; y++) {
-                    Source = (WORD *) (src + y * pitch);
+                    Source = (const WORD *)(src + y * pitch);
                     Dest = dst + y * outpitch;
                     for (x = 0; x < width; x++ ) {
                         short color = (*Source++);
@@ -1963,7 +1950,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
             } else {
                 for(y = 0; y < height; y++) {
                     unsigned short *Dest_s = (unsigned short *) (dst + y * outpitch);
-                    Source = (WORD *) (src + y * pitch);
+                    Source = (const WORD *)(src + y * pitch);
                     for (x = 0; x < width; x++ ) {
                         short color = (*Source++);
                         unsigned char l = ((color >> 10) & 0xfc);
@@ -1983,7 +1970,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         case CONVERT_X8L8V8U8:
         {
             unsigned int x, y;
-            DWORD *Source;
+            const DWORD *Source;
             unsigned char *Dest;
 
             if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -1991,7 +1978,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
                  * without further modification after converting the surface.
                  */
                 for(y = 0; y < height; y++) {
-                    Source = (DWORD *) (src + y * pitch);
+                    Source = (const DWORD *)(src + y * pitch);
                     Dest = dst + y * outpitch;
                     for (x = 0; x < width; x++ ) {
                         long color = (*Source++);
@@ -2008,7 +1995,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
                  * standard fixed function pipeline anyway).
                  */
                 for(y = 0; y < height; y++) {
-                    Source = (DWORD *) (src + y * pitch);
+                    Source = (const DWORD *)(src + y * pitch);
                     Dest = dst + y * outpitch;
                     for (x = 0; x < width; x++ ) {
                         long color = (*Source++);
@@ -2025,7 +2012,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
         case CONVERT_A4L4:
         {
             unsigned int x, y;
-            unsigned char *Source;
+            const unsigned char *Source;
             unsigned char *Dest;
             for(y = 0; y < height; y++) {
                 Source = src + y * pitch;
@@ -2040,66 +2027,6 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
             break;
         }
 
-        case CONVERT_R32F:
-        {
-            unsigned int x, y;
-            float *Source;
-            float *Dest;
-            for(y = 0; y < height; y++) {
-                Source = (float *) (src + y * pitch);
-                Dest = (float *) (dst + y * outpitch);
-                for (x = 0; x < width; x++ ) {
-                    float color = (*Source++);
-                    Dest[0] = color;
-                    Dest[1] = 1.0;
-                    Dest[2] = 1.0;
-                    Dest += 3;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_R16F:
-        {
-            unsigned int x, y;
-            WORD *Source;
-            WORD *Dest;
-            WORD one = 0x3c00;
-            for(y = 0; y < height; y++) {
-                Source = (WORD *) (src + y * pitch);
-                Dest = (WORD *) (dst + y * outpitch);
-                for (x = 0; x < width; x++ ) {
-                    WORD color = (*Source++);
-                    Dest[0] = color;
-                    Dest[1] = one;
-                    Dest[2] = one;
-                    Dest += 3;
-                }
-            }
-            break;
-        }
-
-        case CONVERT_G16R16:
-        {
-            unsigned int x, y;
-            WORD *Source;
-            WORD *Dest;
-
-            for(y = 0; y < height; y++) {
-                Source = (WORD *) (src + y * pitch);
-                Dest = (WORD *) (dst + y * outpitch);
-                for (x = 0; x < width; x++ ) {
-                    WORD green = (*Source++);
-                    WORD red = (*Source++);
-                    Dest[0] = green;
-                    Dest[1] = red;
-                    Dest[2] = 0xffff;
-                    Dest += 3;
-                }
-            }
-            break;
-        }
-
         default:
             ERR("Unsupported conversation type %d\n", convert);
     }
@@ -2111,7 +2038,7 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     BOOL index_in_alpha = FALSE;
     int dxVersion = ( (IWineD3DImpl *) device->wineD3D)->dxVersion;
-    int i;
+    unsigned int i;
 
     /* Old games like StarCraft, C&C, Red Alert and others use P8 render targets.
     * Reading back the RGB output each lockrect (each frame as they lock the whole screen)
@@ -2165,15 +2092,6 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
     }
 }
 
-const char *fragment_palette_conversion =
-    "!!ARBfp1.0\n"
-    "TEMP index;\n"
-    "PARAM constants = { 0.996, 0.00195, 0, 0 };\n" /* { 255/256, 0.5/255*255/256, 0, 0 } */
-    "TEX index, fragment.texcoord[0], texture[0], 2D;\n" /* The alpha-component contains the palette index */
-    "MAD index.a, index.a, constants.x, constants.y;\n" /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
-    "TEX result.color, index.a, texture[1], 1D;\n" /* use the alpha-component as a index in the palette to get the final color */
-    "END";
-
 /* This function is used in case of 8bit paletted textures to upload the palette.
    It supports GL_EXT_paletted_texture and GL_ARB_fragment_program, support for other
    extensions like ATI_fragment_shaders is possible.
@@ -2200,6 +2118,19 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve
         /* Create the fragment program if we don't have it */
         if(!device->paletteConversionShader)
         {
+            const char *fragment_palette_conversion =
+                "!!ARBfp1.0\n"
+                "TEMP index;\n"
+                /* { 255/256, 0.5/255*255/256, 0, 0 } */
+                "PARAM constants = { 0.996, 0.00195, 0, 0 };\n"
+                /* The alpha-component contains the palette index */
+                "TEX index, fragment.texcoord[0], texture[0], 2D;\n"
+                /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
+                "MAD index.a, index.a, constants.x, constants.y;\n"
+                /* Use the alpha-component as an index in the palette to get the final color */
+                "TEX result.color, index.a, texture[1], 1D;\n"
+                "END";
+
             glEnable(GL_FRAGMENT_PROGRAM_ARB);
             GL_EXTCALL(glGenProgramsARB(1, &device->paletteConversionShader));
             GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader));
@@ -2247,41 +2178,6 @@ BOOL palette9_changed(IWineD3DSurfaceImpl *This) {
     return TRUE;
 }
 
-static inline void clear_unused_channels(IWineD3DSurfaceImpl *This) {
-    GLboolean oldwrite[4];
-
-    /* Some formats have only some color channels, and the others are 1.0.
-     * since our rendering renders to all channels, and those pixel formats
-     * are emulated by using a full texture with the other channels set to 1.0
-     * manually, clear the unused channels.
-     *
-     * This could be done with hacking colorwriteenable to mask the colors,
-     * but before drawing the buffer would have to be cleared too, so there's
-     * no gain in that
-     */
-    switch(This->resource.format) {
-        case WINED3DFMT_R16F:
-        case WINED3DFMT_R32F:
-            TRACE("R16F or R32F format, clearing green, blue and alpha to 1.0\n");
-            /* Do not activate a context, the correct drawable is active already
-             * though just the read buffer is set, make sure to have the correct draw
-             * buffer too
-             */
-            glDrawBuffer(This->resource.wineD3DDevice->offscreenBuffer);
-            glDisable(GL_SCISSOR_TEST);
-            glGetBooleanv(GL_COLOR_WRITEMASK, oldwrite);
-            glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
-            glClearColor(0.0, 1.0, 1.0, 1.0);
-            glClear(GL_COLOR_BUFFER_BIT);
-            glColorMask(oldwrite[0], oldwrite[1], oldwrite[2], oldwrite[3]);
-            if(!This->resource.wineD3DDevice->render_offscreen) glDrawBuffer(GL_BACK);
-            checkGLcall("Unused channel clear\n");
-            break;
-
-        default: break;
-    }
-}
-
 static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
 
@@ -2407,14 +2303,14 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface) {
 
 #include <errno.h>
 #include <stdio.h>
-HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename)
+{
     FILE* f = NULL;
-    UINT i, y;
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     char *allocatedMemory;
-    char *textureRow;
+    const char *textureRow;
     IWineD3DSwapChain *swapChain = NULL;
-    int width, height;
+    int width, height, i, y;
     GLuint tmpTexture = 0;
     DWORD color;
     /*FIXME:
@@ -2458,9 +2354,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
                         NULL);
 
         glGetIntegerv(GL_READ_BUFFER, &prevRead);
-        vcheckGLcall("glGetIntegerv");
+        checkGLcall("glGetIntegerv");
         glReadBuffer(swapChain ? GL_BACK : This->resource.wineD3DDevice->offscreenBuffer);
-        vcheckGLcall("glReadBuffer");
+        checkGLcall("glReadBuffer");
         glCopyTexImage2D(GL_TEXTURE_2D,
                             0,
                             GL_RGBA,
@@ -2528,7 +2424,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
         textureRow = allocatedMemory;
     for (y = 0 ; y < height; y++) {
         for (i = 0; i < width;  i++) {
-            color = *((DWORD*)textureRow);
+            color = *((const DWORD*)textureRow);
             fputc((color >> 16) & 0xFF, f); /* B */
             fputc((color >>  8) & 0xFF, f); /* G */
             fputc((color >>  0) & 0xFF, f); /* R */
@@ -2553,7 +2449,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
 /**
  *   Slightly inefficient way to handle multiple dirty rects but it works :)
  */
-HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     IWineD3DBaseTexture *baseTexture = NULL;
 
@@ -2583,10 +2480,10 @@ HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RE
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     HRESULT hr;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
 
     TRACE("(%p) : Calling base function first\n", This);
@@ -2604,7 +2501,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORM
     return hr;
 }
 
-HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
 
     if(This->Flags & (SFLAG_LOCKED | SFLAG_DCINUSE)) {
@@ -2797,7 +2694,10 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DS
 /* Does a direct frame buffer -> texture copy. Stretching is done
  * with single pixel copy calls
  */
-static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface, IWineD3DSwapChainImpl *swapchain, WINED3DRECT *srect, WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) {
+static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
+        IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect,
+        BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
+{
     IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
     float xrel, yrel;
     UINT row;
@@ -2875,13 +2775,16 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
             }
         }
     }
-    vcheckGLcall("glCopyTexSubImage2D");
+    checkGLcall("glCopyTexSubImage2D");
 
     LEAVE_GL();
 }
 
 /* Uses the hardware to stretch and flip the image */
-static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface, IWineD3DSwapChainImpl *swapchain, WINED3DRECT *srect, WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) {
+static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
+        IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect,
+        BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
+{
     GLuint src, backup = 0;
     IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
     IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
@@ -2957,7 +2860,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
                     magLookup[Filter - WINED3DTEXF_NONE]);
     checkGLcall("glTexParameteri");
     glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER,
-                    minMipLookup[Filter][WINED3DTEXF_NONE]);
+                    minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
     checkGLcall("glTexParameteri");
 
     if(!swapchain || (IWineD3DSurface *) Src == swapchain->backBuffer[0]) {
@@ -3117,7 +3020,10 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
 }
 
 /* Not called from the VTable */
-static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) {
+static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const RECT *DestRect,
+        IWineD3DSurface *SrcSurface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx,
+        WINED3DTEXTUREFILTERTYPE Filter)
+{
     WINED3DRECT rect;
     IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
     IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL;
@@ -3494,7 +3400,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
                         magLookup[Filter - WINED3DTEXF_NONE]);
         checkGLcall("glTexParameteri");
         glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER,
-                        minMipLookup[Filter][WINED3DTEXF_NONE]);
+                        minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
         checkGLcall("glTexParameteri");
         glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP);
         glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP);
@@ -3648,7 +3554,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
     return WINED3DERR_INVALIDCALL;
 }
 
-static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx)
+static HRESULT IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, const RECT *DestRect,
+        IWineD3DSurface *SrcSurface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx)
 {
     IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
     float depth;
@@ -3675,7 +3582,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *
 
         return IWineD3DDevice_Clear((IWineD3DDevice *) myDevice,
                                     DestRect == NULL ? 0 : 1,
-                                    (WINED3DRECT *) DestRect,
+                                    (const WINED3DRECT *)DestRect,
                                     WINED3DCLEAR_ZBUFFER,
                                     0x00000000,
                                     depth,
@@ -3686,7 +3593,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *
     return WINED3DERR_INVALIDCALL;
 }
 
-static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
+        const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
     IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
@@ -3725,7 +3633,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *Dest
     return IWineD3DBaseSurfaceImpl_Blt(iface, DestRect, SrcSurface, SrcRect, Flags, DDBltFx, Filter);
 }
 
-HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
+        IWineD3DSurface *Source, const RECT *rsrc, DWORD trans)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     IWineD3DSurfaceImpl *srcImpl = (IWineD3DSurfaceImpl *) Source;
     IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
@@ -3785,7 +3695,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, D
     return IWineD3DBaseSurfaceImpl_BltFast(iface, dstx, dsty, Source, rsrc, trans);
 }
 
-HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     RGBQUAD col[256];
     IWineD3DPaletteImpl *pal = This->palette;
@@ -3849,7 +3760,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
     /** Check against the maximum texture sizes supported by the video card **/
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     unsigned int pow2Width, pow2Height;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
 
     getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
     /* Setup some glformat defaults */
@@ -4674,7 +4585,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) {
+static HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     IWineD3DSwapChain *swapchain = NULL;
 
@@ -4772,7 +4684,7 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
     IWineD3DSurfaceImpl_SaveSnapshot,
     IWineD3DSurfaceImpl_SetContainer,
     IWineD3DSurfaceImpl_GetGlDesc,
-    IWineD3DSurfaceImpl_GetData,
+    IWineD3DBaseSurfaceImpl_GetData,
     IWineD3DSurfaceImpl_SetFormat,
     IWineD3DSurfaceImpl_PrivateSetup,
     IWineD3DSurfaceImpl_ModifyLocation,
@@ -4806,8 +4718,22 @@ static void ffp_blit_unset(IWineD3DDevice *iface) {
     }
 }
 
-static BOOL ffp_blit_conv_supported(WINED3DFORMAT fmt) {
-    TRACE("Checking blit format support for format %s: [FAILED]\n", debug_d3dformat(fmt));
+static BOOL ffp_blit_color_fixup_supported(struct color_fixup_desc fixup)
+{
+    if (TRACE_ON(d3d_surface) && TRACE_ON(d3d))
+    {
+        TRACE("Checking support for fixup:\n");
+        dump_color_fixup_desc(fixup);
+    }
+
+    /* We only support identity conversions. */
+    if (is_identity_fixup(fixup))
+    {
+        TRACE("[OK]\n");
+        return TRUE;
+    }
+
+    TRACE("[FAILED]\n");
     return FALSE;
 }
 
@@ -4816,5 +4742,5 @@ const struct blit_shader ffp_blit =  {
     ffp_blit_free,
     ffp_blit_set,
     ffp_blit_unset,
-    ffp_blit_conv_supported
+    ffp_blit_color_fixup_supported
 };
index e683e92..2710a8f 100644 (file)
@@ -119,37 +119,37 @@ ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) {
    IWineD3DSurface IWineD3DResource parts follow
    **************************************************** */
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    return resource_get_device((IWineD3DResource *)iface, ppDevice);
 }
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
 }
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
 }
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
+    return resource_free_private_data((IWineD3DResource *)iface, refguid);
 }
 
 DWORD   WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
+    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
 }
 
 DWORD   WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
+    return resource_get_priority((IWineD3DResource *)iface);
 }
 
 WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) {
     TRACE("(%p) : calling resourceimpl_GetType\n", iface);
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
+    return resource_get_type((IWineD3DResource *)iface);
 }
 
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) {
     TRACE("(%p) : calling resourceimpl_GetParent\n", iface);
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
+    return resource_get_parent((IWineD3DResource *)iface, pParent);
 }
 
 /* ******************************************************
@@ -269,7 +269,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD
     else return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey) {
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
 
@@ -418,7 +419,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *ifac
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX) {
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
+        IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX)
+{
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     IWineD3DSurfaceImpl *Dst = (IWineD3DSurfaceImpl *) DstSurface;
     TRACE("(%p)->(%p, %p, %p, %08x, %p)\n", This, SrcRect, Dst, DstRect, Flags, FX);
@@ -682,14 +685,16 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) {
     return WINED3D_OK;
 }
 
-void convert_r32f_r16f(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h) {
+static void convert_r32f_r16f(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
+                              unsigned int w, unsigned int h)
+{
     unsigned int x, y;
-    float *src_f;
+    const float *src_f;
     unsigned short *dst_s;
 
     TRACE("Converting %dx%d pixels, pitches %d %d\n", w, h, pitch_in, pitch_out);
     for(y = 0; y < h; y++) {
-        src_f = (float *) (src + y * pitch_in);
+        src_f = (const float *)(src + y * pitch_in);
         dst_s = (unsigned short *) (dst + y * pitch_out);
         for(x = 0; x < w; x++) {
             dst_s[x] = float_32_to_16(src_f + x);
@@ -699,14 +704,16 @@ void convert_r32f_r16f(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, un
 
 struct d3dfmt_convertor_desc {
     WINED3DFORMAT from, to;
-    void (*convert)(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
+    void (*convert)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
 };
 
-struct d3dfmt_convertor_desc convertors[] = {
+static const struct d3dfmt_convertor_desc convertors[] =
+{
     {WINED3DFMT_R32F,       WINED3DFMT_R16F,        convert_r32f_r16f},
 };
 
-static inline struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to) {
+static inline const struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to)
+{
     unsigned int i;
     for(i = 0; i < (sizeof(convertors) / sizeof(convertors[0])); i++) {
         if(convertors[i].from == from && convertors[i].to == to) {
@@ -727,9 +734,9 @@ static inline struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, W
  *  fmt: Requested destination format
  *
  *****************************************************************************/
-IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source, WINED3DFORMAT to_fmt) {
+static IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source, WINED3DFORMAT to_fmt) {
     IWineD3DSurface *ret = NULL;
-    struct d3dfmt_convertor_desc *conv;
+    const struct d3dfmt_convertor_desc *conv;
     WINED3DLOCKED_RECT lock_src, lock_dst;
     HRESULT hr;
 
@@ -862,14 +869,8 @@ static HRESULT
  *  SrcSurface: Source surface, can be NULL
  *  SrcRect: Source rectangle
  *****************************************************************************/
-HRESULT WINAPI
-IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
-                            RECT *DestRect,
-                            IWineD3DSurface *SrcSurface,
-                            RECT *SrcRect,
-                            DWORD Flags,
-                            WINEDDBLTFX *DDBltFx,
-                            WINED3DTEXTUREFILTERTYPE Filter)
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
+        const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
@@ -880,7 +881,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
     int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
     int x, y;
     const StaticPixelFormatDesc *sEntry, *dEntry;
-    LPBYTE dbuf, sbuf;
+    const BYTE *sbuf;
+    BYTE *dbuf;
     TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
 
     if (TRACE_ON(d3d_surface))
@@ -1171,7 +1173,7 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
     /* Now the 'with source' blits */
     if (Src)
     {
-        LPBYTE sbase;
+        const BYTE *sbase;
         int sx, xinc, sy, yinc;
 
         if (!dstwidth || !dstheight) /* hmm... stupid program ? */
@@ -1250,7 +1252,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
                     else
                     {
 #define STRETCH_ROW(type) { \
-                        type *s = (type *) sbuf, *d = (type *) dbuf; \
+                        const type *s = (const type *)sbuf; \
+                        type *d = (type *)dbuf; \
                         for (x = sx = 0; x < dstwidth; x++, sx += xinc) \
                         d[x] = s[sx >> 16]; \
                         break; }
@@ -1262,7 +1265,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
                                             case 4: STRETCH_ROW(DWORD)
                             case 3:
                             {
-                                LPBYTE s,d = dbuf;
+                                const BYTE *s;
+                                BYTE *d = dbuf;
                                 for (x = sx = 0; x < dstwidth; x++, sx+= xinc)
                                 {
                                     DWORD pixel;
@@ -1416,9 +1420,10 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
             }
 
 #define COPY_COLORKEY_FX(type) { \
-            type *s, *d = (type *) dbuf, *dx, tmp; \
+            const type *s; \
+            type *d = (type *)dbuf, *dx, tmp; \
             for (y = sy = 0; y < dstheight; y++, sy += yinc) { \
-            s = (type*)(sbase + (sy >> 16) * slock.Pitch); \
+            s = (const type*)(sbase + (sy >> 16) * slock.Pitch); \
             dx = d; \
             for (x = sx = 0; x < dstwidth; x++, sx += xinc) { \
             tmp = s[sx >> 16]; \
@@ -1438,7 +1443,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
                                 case 4: COPY_COLORKEY_FX(DWORD)
                 case 3:
                 {
-                    LPBYTE s,d = dbuf, dx;
+                    const BYTE *s;
+                    BYTE *d = dbuf, *dx;
                     for (y = sy = 0; y < dstheight; y++, sy += yinc)
                     {
                         sbuf = sbase + (sy >> 16) * slock.Pitch;
@@ -1504,13 +1510,8 @@ release:
  *  WINED3D_OK on success
  *
  *****************************************************************************/
-HRESULT WINAPI
-IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
-                                DWORD dstx,
-                                DWORD dsty,
-                                IWineD3DSurface *Source,
-                                RECT *rsrc,
-                                DWORD trans)
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
+        IWineD3DSurface *Source, const RECT *rsrc, DWORD trans)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) Source;
@@ -1520,7 +1521,8 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
     HRESULT             ret = WINED3D_OK;
     RECT                rsrc2;
     RECT                lock_src, lock_dst, lock_union;
-    BYTE                *sbuf, *dbuf;
+    const BYTE          *sbuf;
+    BYTE                *dbuf;
     const StaticPixelFormatDesc *sEntry, *dEntry;
 
     if (TRACE_ON(d3d_surface))
@@ -1548,11 +1550,11 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
     if (!rsrc)
     {
         WARN("rsrc is NULL!\n");
+        rsrc2.left = 0;
+        rsrc2.top = 0;
+        rsrc2.right = Src->currentDesc.Width;
+        rsrc2.bottom = Src->currentDesc.Height;
         rsrc = &rsrc2;
-        rsrc->left = 0;
-        rsrc->top = 0;
-        rsrc->right = Src->currentDesc.Width;
-        rsrc->bottom = Src->currentDesc.Height;
     }
 
     /* Check source rect for validity. Copied from normal Blt. Fixes Baldur's Gate.*/
@@ -1670,15 +1672,15 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
         }
 
 #define COPYBOX_COLORKEY(type) { \
-        type *d, *s, tmp; \
-        s = (type *) sbuf; \
-        d = (type *) dbuf; \
+        const type *s = (const type *)sbuf; \
+        type *d = (type *)dbuf; \
+        type tmp; \
         for (y = 0; y < h; y++) { \
         for (x = 0; x < w; x++) { \
         tmp = s[x]; \
         if (tmp < keylow || tmp > keyhigh) d[x] = tmp; \
     } \
-        s = (type *)((BYTE *)s + slock.Pitch); \
+        s = (const type *)((const BYTE *)s + slock.Pitch); \
         d = (type *)((BYTE *)d + dlock.Pitch); \
     } \
         break; \
@@ -1690,7 +1692,8 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
                             case 4: COPYBOX_COLORKEY(DWORD)
             case 3:
             {
-                BYTE *d, *s;
+                const BYTE *s;
+                BYTE *d;
                 DWORD tmp;
                 s = sbuf;
                 d = dbuf;
@@ -1826,3 +1829,17 @@ void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface) {
     ERR("Should not be called on base texture\n");
     return;
 }
+
+/* TODO: think about moving this down to resource? */
+const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface)
+{
+    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
+
+    /* This should only be called for sysmem textures, it may be a good idea
+     * to extend this to all pools at some point in the future  */
+    if (This->resource.pool != WINED3DPOOL_SYSTEMMEM)
+    {
+        FIXME("(%p) Attempting to get system memory for a non-system memory texture\n", iface);
+    }
+    return This->resource.allocatedMemory;
+}
index a17c007..d062458 100644 (file)
@@ -42,7 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
  * to destroy all the GL things.
  *
  *****************************************************************************/
-ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
+static ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     ULONG ref = InterlockedDecrement(&This->resource.ref);
     TRACE("(%p) : Releasing from %d\n", This, ref + 1);
@@ -62,7 +62,7 @@ ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
 
         HeapFree(GetProcessHeap(), 0, This->palette9);
 
-        IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
+        resource_cleanup((IWineD3DResource *)iface);
 
         if(This->overlay_dest) {
             list_remove(&This->overlay_entry);
@@ -245,7 +245,7 @@ IWineGDISurfaceImpl_Flip(IWineD3DSurface *iface,
  *  D3DERR_INVALIDCALL
  *
  *****************************************************************************/
-HRESULT WINAPI
+static HRESULT WINAPI
 IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode)
 {
     ERR("Unsupported on X11 surfaces\n");
@@ -280,7 +280,7 @@ static int get_shift(DWORD color_mask) {
 }
 
 
-HRESULT WINAPI
+static HRESULT WINAPI
 IWineGDISurfaceImpl_SaveSnapshot(IWineD3DSurface *iface,
 const char* filename)
 {
@@ -288,7 +288,7 @@ const char* filename)
     UINT y = 0, x = 0;
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     static char *output = NULL;
-    static int size = 0;
+    static UINT size = 0;
     const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(This->resource.format, NULL, NULL);
 
     if (This->pow2Width > size) {
@@ -340,7 +340,7 @@ const char* filename)
         alpha_shift = get_shift(formatEntry->alphaMask);
 
         for (y = 0; y < This->pow2Height; y++) {
-            unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
+            const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
             for (x = 0; x < This->pow2Width; x++) {        
                 unsigned int color;
                 unsigned int comp;
@@ -366,7 +366,7 @@ const char* filename)
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
+static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     WINED3DLOCKED_RECT lock;
     HRESULT hr;
@@ -405,7 +405,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
     if(This->resource.format == WINED3DFMT_P8 ||
        This->resource.format == WINED3DFMT_A8P8) {
         unsigned int n;
-        PALETTEENTRY *pal = NULL;
+        const PALETTEENTRY *pal = NULL;
 
         if(This->palette) {
             pal = This->palette->palents;
@@ -436,7 +436,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
+static HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
 
     TRACE("(%p)->(%p)\n",This,hDC);
@@ -457,7 +457,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
+static HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     RGBQUAD col[256];
     IWineD3DPaletteImpl *pal = This->palette;
@@ -507,7 +507,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
  *  The return values of called methods on failure
  *
  *****************************************************************************/
-HRESULT WINAPI
+static HRESULT WINAPI
 IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
 {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
@@ -534,13 +534,13 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
     return WINED3D_OK;
 }
 
-void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
+static void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     FIXME("(%p) : Should not be called on a GDI surface\n", This);
     *glDescription = NULL;
 }
 
-HRESULT WINAPI IWineGDISurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
+static HRESULT WINAPI IWineGDISurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
     /* GDI surface data can only be in one location, the system memory dib section. So they are
      * always clean by definition.
      */
@@ -548,7 +548,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RE
     return WINED3D_OK;
 }
 
-HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
+static HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
     IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
 
     /* Render targets depend on their hdc, and we can't create an hdc on a user pointer */
@@ -679,7 +679,7 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
     IWineGDISurfaceImpl_SaveSnapshot,
     IWineD3DBaseSurfaceImpl_SetContainer,
     IWineGDISurfaceImpl_GetGlDesc,
-    IWineD3DSurfaceImpl_GetData,
+    IWineD3DBaseSurfaceImpl_GetData,
     IWineD3DBaseSurfaceImpl_SetFormat,
     IWineGDISurfaceImpl_PrivateSetup,
     IWineGDISurfaceImpl_ModifyLocation,
index 6f4393a..d1a6520 100644 (file)
@@ -39,7 +39,7 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
 static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderTarget) {
     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
     WINED3DDISPLAYMODE mode;
-    int i;
+    unsigned int i;
 
     TRACE("Destroying swapchain %p\n", iface);
 
@@ -54,7 +54,7 @@ static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
     }
 
     if(This->backBuffer) {
-        int i;
+        UINT i;
         for(i = 0; i < This->presentParms.BackBufferCount; i++) {
             IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
             if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
@@ -138,7 +138,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
         IWineD3DSurface_BltFast(This->backBuffer[0], 0, 0, This->wineD3DDevice->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY);
     }
 
-    if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
+    if (pSourceRect || pDestRect) FIXME("Unhandled present rects %s/%s\n", wine_dbgstr_rect(pSourceRect), wine_dbgstr_rect(pDestRect));
     /* TODO: If only source rect or dest rect are supplied then clip the window to match */
     TRACE("presetting HDC %p\n", This->context[0]->hdc);
 
index 363331c..7272c95 100644 (file)
@@ -122,13 +122,14 @@ HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface,
 
 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
-    static BOOL showFixmes = TRUE;
+    static BOOL warned;
     pRasterStatus->InVBlank = TRUE;
     pRasterStatus->ScanLine = 0;
     /* No openGL equivalent */
-    if(showFixmes) {
+    if (!warned)
+    {
         FIXME("(%p) : stub (once)\n", This);
-        showFixmes = FALSE;
+        warned = TRUE;
     }
     return WINED3D_OK;
 }
index f634e50..5968201 100644 (file)
@@ -44,7 +44,7 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
     }
 
     if(This->backBuffer) {
-        int i;
+        UINT i;
         for(i = 0; i < This->presentParms.BackBufferCount; i++) {
             IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
             if(D3DCB_DestroyRenderback(This->backBuffer[i]) > 0) {
@@ -80,7 +80,8 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
  *  rc: Rectangle to copy
  *
  *****************************************************************************/
-void x11_copy_to_screen(IWineD3DSwapChainImpl *This, LPRECT rc) {
+void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc)
+{
     IWineD3DSurfaceImpl *front = (IWineD3DSurfaceImpl *) This->frontBuffer;
 
     if(front->resource.usage & WINED3DUSAGE_RENDERTARGET) {
@@ -238,18 +239,6 @@ static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CO
     return WINED3D_OK;
 }
 
-/* FIXME: This should not be needed, the base version is OK */
-HRESULT WINAPI IWineGDIBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
-    IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
-    IWineD3DDeviceImpl *device = This->wineD3DDevice;
-
-    pMode->Width = device->ddraw_width;
-    pMode->Height = device->ddraw_height;
-    pMode->Format = device->ddraw_format;
-    pMode->RefreshRate = 0;
-    return WINED3D_OK;
-}
-
 const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl =
 {
     /* IUnknown */
index 98aea92..71fb455 100644 (file)
@@ -69,27 +69,27 @@ static ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
    IWineD3DTexture IWineD3DResource parts follow
    **************************************************** */
 static HRESULT WINAPI IWineD3DTextureImpl_GetDevice(IWineD3DTexture *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    return resource_get_device((IWineD3DResource *)iface, ppDevice);
 }
 
 static HRESULT WINAPI IWineD3DTextureImpl_SetPrivateData(IWineD3DTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
 }
 
 static HRESULT WINAPI IWineD3DTextureImpl_GetPrivateData(IWineD3DTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
 }
 
 static HRESULT WINAPI IWineD3DTextureImpl_FreePrivateData(IWineD3DTexture *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
+    return resource_free_private_data((IWineD3DResource *)iface, refguid);
 }
 
 static DWORD WINAPI IWineD3DTextureImpl_SetPriority(IWineD3DTexture *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
+    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
 }
 
 static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
+    return resource_get_priority((IWineD3DResource *)iface);
 }
 
 static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
@@ -165,51 +165,51 @@ static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
         surface_set_texture_name(This->surfaces[i], 0);
     }
 
-    IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface);
+    basetexture_unload((IWineD3DBaseTexture *)iface);
 }
 
 static WINED3DRESOURCETYPE WINAPI IWineD3DTextureImpl_GetType(IWineD3DTexture *iface) {
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
+    return resource_get_type((IWineD3DResource *)iface);
 }
 
 static HRESULT WINAPI IWineD3DTextureImpl_GetParent(IWineD3DTexture *iface, IUnknown **pParent) {
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
+    return resource_get_parent((IWineD3DResource *)iface, pParent);
 }
 
 /* ******************************************************
    IWineD3DTexture IWineD3DBaseTexture parts follow
    ****************************************************** */
 static DWORD WINAPI IWineD3DTextureImpl_SetLOD(IWineD3DTexture *iface, DWORD LODNew) {
-    return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew);
+    return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
 }
 
 static DWORD WINAPI IWineD3DTextureImpl_GetLOD(IWineD3DTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface);
+    return basetexture_get_lod((IWineD3DBaseTexture *)iface);
 }
 
 static DWORD WINAPI IWineD3DTextureImpl_GetLevelCount(IWineD3DTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface);
+    return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
 }
 
 static HRESULT WINAPI IWineD3DTextureImpl_SetAutoGenFilterType(IWineD3DTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
-  return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType);
+  return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
 }
 
 static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DTextureImpl_GetAutoGenFilterType(IWineD3DTexture *iface) {
-  return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface);
+  return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
 }
 
 static void WINAPI IWineD3DTextureImpl_GenerateMipSubLevels(IWineD3DTexture *iface) {
-    IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface);
+    basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
 }
 
 /* Internal function, No d3d mapping */
 static BOOL WINAPI IWineD3DTextureImpl_SetDirty(IWineD3DTexture *iface, BOOL dirty) {
-    return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty);
+    return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
 }
 
 static BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface);
+    return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
 }
 
 static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
@@ -219,7 +219,7 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
 
     TRACE("(%p) : relay to BaseTexture\n", This);
 
-    hr = IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
+    hr = basetexture_bind((IWineD3DBaseTexture *)iface);
     if (set_gl_texture_desc && SUCCEEDED(hr)) {
         UINT i;
         for (i = 0; i < This->baseTexture.levels; ++i) {
@@ -270,7 +270,7 @@ static void WINAPI IWineD3DTextureImpl_ApplyStateChanges(IWineD3DTexture *iface,
                                                    const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
                                                    const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
     TRACE("(%p) : relay to BaseTexture\n", iface);
-    IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
+    basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
 }
 
 /* *******************************************
@@ -291,7 +291,7 @@ static void WINAPI IWineD3DTextureImpl_Destroy(IWineD3DTexture *iface, D3DCB_DES
         }
     }
     TRACE("(%p) : cleaning up base texture\n", This);
-    IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
+    basetexture_cleanup((IWineD3DBaseTexture *)iface);
     /* free the object */
     HeapFree(GetProcessHeap(), 0, This);
 }
index b49072f..fd4f4ee 100644 (file)
@@ -318,7 +318,7 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
         gl_info->gl_formats[dst].glGammaInternal = gl_formats_template[src].glGammaInternal;
         gl_info->gl_formats[dst].glFormat        = gl_formats_template[src].glFormat;
         gl_info->gl_formats[dst].glType          = gl_formats_template[src].glType;
-        gl_info->gl_formats[dst].conversion_group= WINED3DFMT_UNKNOWN;
+        gl_info->gl_formats[dst].color_fixup     = COLOR_FIXUP_IDENTITY;
         gl_info->gl_formats[dst].Flags           = gl_formats_template[src].Flags;
         gl_info->gl_formats[dst].heightscale     = 1.0;
 
@@ -363,29 +363,52 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
         }
     }
 
+    dst = getFmtIdx(WINED3DFMT_R16F);
+    gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+            0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
+
+    dst = getFmtIdx(WINED3DFMT_R32F);
+    gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+            0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
+
+    dst = getFmtIdx(WINED3DFMT_G16R16);
+    gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+            0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
+
+    dst = getFmtIdx(WINED3DFMT_G16R16F);
+    gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+            0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
+
+    dst = getFmtIdx(WINED3DFMT_G32R32F);
+    gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+            0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
+
     /* V8U8 is supported natively by GL_ATI_envmap_bumpmap and GL_NV_texture_shader.
      * V16U16 is only supported by GL_NV_texture_shader. The formats need fixup if
-     * their extensions are not available.
+     * their extensions are not available. GL_ATI_envmap_bumpmap is not used because
+     * the only driver that implements it(fglrx) has a buggy implementation.
      *
-     * In theory, V8U8 and V16U16 need a fixup of the undefined blue channel. OpenGL
-     * returns 0.0 when sampling from it, DirectX 1.0. This is disabled until we find
-     * an application that needs this because it causes performance problems due to
-     * shader recompiling in some games.
+     * V8U8 and V16U16 need a fixup of the undefined blue channel. OpenGL
+     * returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
+     * conversion for this format.
      */
-    if(!GL_SUPPORT(NV_TEXTURE_SHADER2)) {
-        /* signed -> unsigned fixup */
+    if (!GL_SUPPORT(NV_TEXTURE_SHADER))
+    {
         dst = getFmtIdx(WINED3DFMT_V8U8);
-        gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
         dst = getFmtIdx(WINED3DFMT_V16U16);
-        gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
-    } else {
-        /* Blue = 1.0 fixup, disabled for now */
-        if(0) {
-            dst = getFmtIdx(WINED3DFMT_V8U8);
-            gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
-            dst = getFmtIdx(WINED3DFMT_V16U16);
-            gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
-        }
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
+    }
+    else
+    {
+        dst = getFmtIdx(WINED3DFMT_V8U8);
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
+        dst = getFmtIdx(WINED3DFMT_V16U16);
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
     }
 
     if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -393,11 +416,14 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
          * with each other
          */
         dst = getFmtIdx(WINED3DFMT_L6V5U5);
-        gl_info->gl_formats[dst].conversion_group = WINED3DFMT_L6V5U5;
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE);
         dst = getFmtIdx(WINED3DFMT_X8L8V8U8);
-        gl_info->gl_formats[dst].conversion_group = WINED3DFMT_X8L8V8U8;
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W);
         dst = getFmtIdx(WINED3DFMT_Q8W8V8U8);
-        gl_info->gl_formats[dst].conversion_group = WINED3DFMT_Q8W8V8U8;
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 1, CHANNEL_SOURCE_Z, 1, CHANNEL_SOURCE_W);
     } else {
         /* If GL_NV_texture_shader is supported, WINED3DFMT_L6V5U5 and WINED3DFMT_X8L8V8U8
          * are converted at surface loading time, but they do not need any modification in
@@ -410,12 +436,14 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
         dst = getFmtIdx(WINED3DFMT_ATI2N);
         gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
         gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
-        gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N;
+        gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
+                0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
     } else if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) {
         dst = getFmtIdx(WINED3DFMT_ATI2N);
         gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
         gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
-        gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N;
+        gl_info->gl_formats[dst].color_fixup= create_color_fixup_desc(
+                0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
     }
 
     if(!GL_SUPPORT(APPLE_YCBCR_422)) {
@@ -424,19 +452,19 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
         gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
         gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
         gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
-        gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YUY2;
+        gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YUY2);
 
         dst = getFmtIdx(WINED3DFMT_UYVY);
         gl_info->gl_formats[dst].glInternal = GL_LUMINANCE_ALPHA;
         gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
         gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
         gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
-        gl_info->gl_formats[dst].conversion_group = WINED3DFMT_UYVY;
+        gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_UYVY);
     }
 
     dst = getFmtIdx(WINED3DFMT_YV12);
     gl_info->gl_formats[dst].heightscale = 1.5;
-    gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YV12;
+    gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12);
 
     return TRUE;
 }
@@ -476,7 +504,8 @@ void init_type_lookup(WineD3D_GL_Info *gl_info) {
 
 #define GLINFO_LOCATION This->adapter->gl_info
 
-const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, WineD3D_GL_Info *gl_info, const GlPixelFormatDesc **glDesc)
+const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const WineD3D_GL_Info *gl_info,
+        const struct GlPixelFormatDesc **glDesc)
 {
     int idx = getFmtIdx(fmt);
 
@@ -491,7 +520,7 @@ const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, WineD3D_GL_In
              * all gl caps check return "unsupported" than catching the lack of gl all over the code. ANSI C requires
              * static variables to be initialized to 0.
              */
-            static const GlPixelFormatDesc dummyFmt;
+            static const struct GlPixelFormatDesc dummyFmt;
             *glDesc = &dummyFmt;
         } else {
             *glDesc = &gl_info->gl_formats[idx];
@@ -1125,6 +1154,55 @@ const char *debug_d3ddegree(WINED3DDEGREETYPE degree) {
     }
 }
 
+const char *debug_fixup_channel_source(enum fixup_channel_source source)
+{
+    switch(source)
+    {
+#define WINED3D_TO_STR(x) case x: return #x
+        WINED3D_TO_STR(CHANNEL_SOURCE_ZERO);
+        WINED3D_TO_STR(CHANNEL_SOURCE_ONE);
+        WINED3D_TO_STR(CHANNEL_SOURCE_X);
+        WINED3D_TO_STR(CHANNEL_SOURCE_Y);
+        WINED3D_TO_STR(CHANNEL_SOURCE_Z);
+        WINED3D_TO_STR(CHANNEL_SOURCE_W);
+        WINED3D_TO_STR(CHANNEL_SOURCE_YUV0);
+        WINED3D_TO_STR(CHANNEL_SOURCE_YUV1);
+#undef WINED3D_TO_STR
+        default:
+            FIXME("Unrecognized fixup_channel_source %#x\n", source);
+            return "unrecognized";
+    }
+}
+
+const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup)
+{
+    switch(yuv_fixup)
+    {
+#define WINED3D_TO_STR(x) case x: return #x
+        WINED3D_TO_STR(YUV_FIXUP_YUY2);
+        WINED3D_TO_STR(YUV_FIXUP_UYVY);
+        WINED3D_TO_STR(YUV_FIXUP_YV12);
+#undef WINED3D_TO_STR
+        default:
+            FIXME("Unrecognized YUV fixup %#x\n", yuv_fixup);
+            return "unrecognized";
+    }
+}
+
+void dump_color_fixup_desc(struct color_fixup_desc fixup)
+{
+    if (is_yuv_fixup(fixup))
+    {
+        TRACE("\tYUV: %s\n", debug_yuv_fixup(get_yuv_fixup(fixup)));
+        return;
+    }
+
+    TRACE("\tX: %s%s\n", debug_fixup_channel_source(fixup.x_source), fixup.x_sign_fixup ? ", SIGN_FIXUP" : "");
+    TRACE("\tY: %s%s\n", debug_fixup_channel_source(fixup.y_source), fixup.y_sign_fixup ? ", SIGN_FIXUP" : "");
+    TRACE("\tZ: %s%s\n", debug_fixup_channel_source(fixup.z_source), fixup.z_sign_fixup ? ", SIGN_FIXUP" : "");
+    TRACE("\tW: %s%s\n", debug_fixup_channel_source(fixup.w_source), fixup.w_sign_fixup ? ", SIGN_FIXUP" : "");
+}
+
 /*****************************************************************************
  * Useful functions mapping GL <-> D3D values
  */
@@ -1633,7 +1711,8 @@ void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *val
     HeapFree(GetProcessHeap(), 0, table);
 }
 
-static inline struct hash_table_entry_t *hash_table_get_by_idx(struct hash_table_t *table, void *key, unsigned int idx)
+static inline struct hash_table_entry_t *hash_table_get_by_idx(const struct hash_table_t *table, const void *key,
+        unsigned int idx)
 {
     struct hash_table_entry_t *entry;
 
@@ -1781,7 +1860,7 @@ void hash_table_remove(struct hash_table_t *table, void *key)
     hash_table_put(table, key, NULL);
 }
 
-void *hash_table_get(struct hash_table_t *table, void *key)
+void *hash_table_get(const struct hash_table_t *table, const void *key)
 {
     unsigned int idx;
     struct hash_table_entry_t *entry;
@@ -1838,7 +1917,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
             settings->op[i].aop = WINED3DTOP_DISABLE;
             settings->op[i].carg0 = settings->op[i].carg1 = settings->op[i].carg2 = ARG_UNUSED;
             settings->op[i].aarg0 = settings->op[i].aarg1 = settings->op[i].aarg2 = ARG_UNUSED;
-            settings->op[i].color_correction = WINED3DFMT_UNKNOWN;
+            settings->op[i].color_correction = COLOR_FIXUP_IDENTITY;
             settings->op[i].dst = resultreg;
             settings->op[i].tex_type = tex_1d;
             settings->op[i].projected = proj_none;
@@ -1848,7 +1927,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
 
         texture = (IWineD3DBaseTextureImpl *) stateblock->textures[i];
         if(texture) {
-            settings->op[i].color_correction = texture->baseTexture.shader_conversion_group;
+            settings->op[i].color_correction = texture->baseTexture.shader_color_fixup;
             if(ignore_textype) {
                 settings->op[i].tex_type = tex_1d;
             } else {
@@ -1871,7 +1950,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
                 }
             }
         } else {
-            settings->op[i].color_correction = WINED3DFMT_UNKNOWN;
+            settings->op[i].color_correction = COLOR_FIXUP_IDENTITY;
             settings->op[i].tex_type = tex_1d;
         }
 
@@ -2013,9 +2092,11 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
 }
 #undef GLINFO_LOCATION
 
-struct ffp_frag_desc *find_ffp_frag_shader(struct hash_table_t *fragment_shaders, struct ffp_frag_settings *settings)
+const struct ffp_frag_desc *find_ffp_frag_shader(const struct hash_table_t *fragment_shaders,
+        const struct ffp_frag_settings *settings)
 {
-    return (struct ffp_frag_desc *)hash_table_get(fragment_shaders, settings);}
+    return (const struct ffp_frag_desc *)hash_table_get(fragment_shaders, settings);
+}
 
 void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *desc) {
     struct ffp_frag_settings *key = HeapAlloc(GetProcessHeap(), 0, sizeof(*key));
@@ -2121,10 +2202,11 @@ void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
 }
 #undef GLINFO_LOCATION
 
-unsigned int ffp_frag_program_key_hash(void *key) {
-    struct ffp_frag_settings *k = (struct ffp_frag_settings *)key;
+unsigned int ffp_frag_program_key_hash(const void *key)
+{
+    const struct ffp_frag_settings *k = (const struct ffp_frag_settings *)key;
     unsigned int hash = 0, i;
-    DWORD *blob;
+    const DWORD *blob;
 
     /* This takes the texture op settings of stage 0 and 1 into account.
      * how exactly depends on the memory laybout of the compiler, but it
@@ -2133,7 +2215,7 @@ unsigned int ffp_frag_program_key_hash(void *key) {
      * the ffp setup has distinct stage 0 and 1 settings.
      */
     for(i = 0; i < 2; i++) {
-        blob = (DWORD *) &k->op[i];
+        blob = (const DWORD *)&k->op[i];
         hash ^= blob[0] ^ blob[1];
     }
 
@@ -2147,9 +2229,10 @@ unsigned int ffp_frag_program_key_hash(void *key) {
     return hash;
 }
 
-BOOL ffp_frag_program_key_compare(void *keya, void *keyb) {
-    struct ffp_frag_settings *ka = (struct ffp_frag_settings *)keya;
-    struct ffp_frag_settings *kb = (struct ffp_frag_settings *)keyb;
+BOOL ffp_frag_program_key_compare(const void *keya, const void *keyb)
+{
+    const struct ffp_frag_settings *ka = (const struct ffp_frag_settings *)keya;
+    const struct ffp_frag_settings *kb = (const struct ffp_frag_settings *)keyb;
 
     return memcmp(ka, kb, sizeof(*ka)) == 0;
 }
index 5f687ff..5964033 100644 (file)
@@ -72,7 +72,7 @@ static ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface
             LEAVE_GL();
         }
 
-        IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
+        resource_cleanup((IWineD3DResource *)iface);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -82,27 +82,27 @@ static ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface
    IWineD3DVertexBuffer IWineD3DResource parts follow
    **************************************************** */
 static HRESULT WINAPI IWineD3DVertexBufferImpl_GetDevice(IWineD3DVertexBuffer *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    return resource_get_device((IWineD3DResource *)iface, ppDevice);
 }
 
 static HRESULT WINAPI IWineD3DVertexBufferImpl_SetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
 }
 
 static HRESULT WINAPI IWineD3DVertexBufferImpl_GetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
 }
 
 static HRESULT WINAPI IWineD3DVertexBufferImpl_FreePrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
+    return resource_free_private_data((IWineD3DResource *)iface, refguid);
 }
 
 static DWORD    WINAPI IWineD3DVertexBufferImpl_SetPriority(IWineD3DVertexBuffer *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
+    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
 }
 
 static DWORD    WINAPI IWineD3DVertexBufferImpl_GetPriority(IWineD3DVertexBuffer *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
+    return resource_get_priority((IWineD3DResource *)iface);
 }
 
 static inline void fixup_d3dcolor(DWORD *pos) {
@@ -143,7 +143,8 @@ static inline void fixup_transformed_pos(float *p) {
     p[3] = w;
 }
 
-DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, WineDirect3DVertexStridedData *strided, DWORD stride) {
+static DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, const WineDirect3DVertexStridedData *strided, DWORD stride)
+{
     DWORD *ret, i, shift, j, type;
     DWORD orig_type_size;
 
@@ -279,7 +280,7 @@ static inline BOOL check_attribute(IWineD3DVertexBufferImpl *This, const WineDir
     return ret;
 }
 
-inline BOOL WINAPI IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *This)
+static inline BOOL IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *This)
 {
     IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     BOOL ret = FALSE;
@@ -622,7 +623,7 @@ static void     WINAPI IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer *if
                     case CONV_FLOAT16_2:
                     {
                         float *out = (float *) (&data[This->conv_stride * i + j + This->conv_shift[j]]);
-                        WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]);
+                        const WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]);
 
                         out[1] = float_16_to_32(in + 1);
                         out[0] = float_16_to_32(in + 0);
@@ -703,11 +704,11 @@ static void WINAPI IWineD3DVertexBufferImpl_UnLoad(IWineD3DVertexBuffer *iface)
 }
 
 static WINED3DRESOURCETYPE WINAPI IWineD3DVertexBufferImpl_GetType(IWineD3DVertexBuffer *iface) {
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
+    return resource_get_type((IWineD3DResource *)iface);
 }
 
 static HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, IUnknown **pParent) {
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
+    return resource_get_parent((IWineD3DResource *)iface, pParent);
 }
 
 /* ******************************************************
@@ -743,7 +744,7 @@ static HRESULT  WINAPI IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer *iface
     /* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
     return WINED3D_OK;
 }
-HRESULT  WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
+static HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
     IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *) iface;
     LONG lockcount;
     TRACE("(%p)\n", This);
@@ -796,7 +797,8 @@ const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl =
     IWineD3DVertexBufferImpl_GetDesc
 };
 
-BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo) {
+const BYTE* IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo)
+{
     IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
 
     *vbo = This->vbo;
@@ -806,15 +808,11 @@ BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWO
             This->Flags &= ~VBFLAG_CREATEVBO;
             if(This->vbo) {
                 *vbo = This->vbo;
-                return (BYTE *) iOffset;
+                return (const BYTE *)iOffset;
             }
         }
         return This->resource.allocatedMemory + iOffset;
     } else {
-        return (BYTE *) iOffset;
+        return (const BYTE *)iOffset;
     }
 }
-
-HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface) {
-  return WINED3D_OK;
-}
index 05c6d6d..0f246f9 100644 (file)
@@ -316,11 +316,9 @@ static inline void find_swizzled_attribs(IWineD3DVertexDeclaration *declaration,
 }
 /** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB
     or GLSL and send it to the card */
-static VOID IWineD3DVertexShaderImpl_GenerateShader(
-    IWineD3DVertexShader *iface,
-    shader_reg_maps* reg_maps,
-    CONST DWORD *pFunction) {
-
+static void IWineD3DVertexShaderImpl_GenerateShader(IWineD3DVertexShader *iface,
+        const struct shader_reg_maps* reg_maps, const DWORD *pFunction)
+{
     IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
     IWineD3DVertexDeclaration *decl = ((IWineD3DDeviceImpl *) This->baseShader.device)->stateBlock->vertexDecl;
     SHADER_BUFFER buffer;
@@ -485,7 +483,7 @@ static void WINAPI IWineD3DVertexShaderImpl_FakeSemantics(IWineD3DVertexShader *
 
     int i;
     for (i = 0; i < vdecl->declarationWNumElements - 1; ++i) {
-        WINED3DVERTEXELEMENT* element = vdecl->pDeclarationWine + i;
+        const WINED3DVERTEXELEMENT *element = vdecl->pDeclarationWine + i;
         vshader_set_input(This, element->Reg, element->Usage, element->UsageIndex);
     }
 }
@@ -563,7 +561,7 @@ static inline BOOL swizzled_attribs_differ(IWineD3DVertexShaderImpl *This, IWine
     return FALSE;
 }
 
-static HRESULT WINAPI IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) {
+HRESULT IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) {
     IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
     IWineD3DVertexDeclarationImpl *vdecl;
     CONST DWORD *function = This->baseShader.function;
@@ -626,7 +624,6 @@ const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
     IWineD3DVertexShaderImpl_GetParent,
     /*** IWineD3DBaseShader methods ***/
     IWineD3DVertexShaderImpl_SetFunction,
-    IWineD3DVertexShaderImpl_CompileShader,
     /*** IWineD3DVertexShader methods ***/
     IWineD3DVertexShaderImpl_GetDevice,
     IWineD3DVertexShaderImpl_GetFunction,
index 8faef0c..6700bb4 100644 (file)
@@ -94,7 +94,7 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
     TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
     ref = InterlockedDecrement(&This->resource.ref);
     if (ref == 0) {
-        IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
+        resource_cleanup((IWineD3DResource *)iface);
         HeapFree(GetProcessHeap(), 0, This);
     }
     return ref;
@@ -104,35 +104,35 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
    IWineD3DVolume IWineD3DResource parts follow
    **************************************************** */
 static HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) {
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
+    return resource_get_parent((IWineD3DResource *)iface, pParent);
 }
 
 static HRESULT WINAPI IWineD3DVolumeImpl_GetDevice(IWineD3DVolume *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    return resource_get_device((IWineD3DResource *)iface, ppDevice);
 }
 
 static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
 }
 
 static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID  refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
 }
 
 static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
+    return resource_free_private_data((IWineD3DResource *)iface, refguid);
 }
 
 static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
+    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
 }
 
 static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
+    return resource_get_priority((IWineD3DResource *)iface);
 }
 
 static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
-    IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
+    FIXME("iface %p stub!\n", iface);
 }
 
 static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) {
@@ -143,7 +143,7 @@ static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) {
 }
 
 static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) {
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
+    return resource_get_type((IWineD3DResource *)iface);
 }
 
 /* *******************************************
@@ -310,7 +310,7 @@ static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWi
 static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) {
     IWineD3DVolumeImpl *This     = (IWineD3DVolumeImpl *)iface;
     WINED3DFORMAT format = This->resource.format;
-    const GlPixelFormatDesc *glDesc;
+    const struct GlPixelFormatDesc *glDesc;
     getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
 
     TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(format), format);
index 53275e1..9da4c95 100644 (file)
@@ -67,27 +67,27 @@ static ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *ifa
    IWineD3DVolumeTexture IWineD3DResource parts follow
    **************************************************** */
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetDevice(IWineD3DVolumeTexture *iface, IWineD3DDevice** ppDevice) {
-    return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
+    return resource_get_device((IWineD3DResource *)iface, ppDevice);
 }
 
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
-    return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
+    return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
 }
 
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
-    return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
+    return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
 }
 
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_FreePrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid) {
-    return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
+    return resource_free_private_data((IWineD3DResource *)iface, refguid);
 }
 
 static DWORD WINAPI IWineD3DVolumeTextureImpl_SetPriority(IWineD3DVolumeTexture *iface, DWORD PriorityNew) {
-    return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
+    return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
 }
 
 static DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture *iface) {
-    return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
+    return resource_get_priority((IWineD3DResource *)iface);
 }
 
 static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
@@ -145,57 +145,57 @@ static void WINAPI IWineD3DVolumeTextureImpl_UnLoad(IWineD3DVolumeTexture *iface
         IWineD3DVolume_UnLoad(This->volumes[i]);
     }
 
-    IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface);
+    basetexture_unload((IWineD3DBaseTexture *)iface);
 }
 
 static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeTextureImpl_GetType(IWineD3DVolumeTexture *iface) {
-    return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
+    return resource_get_type((IWineD3DResource *)iface);
 }
 
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetParent(IWineD3DVolumeTexture *iface, IUnknown **pParent) {
-    return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
+    return resource_get_parent((IWineD3DResource *)iface, pParent);
 }
 
 /* ******************************************************
    IWineD3DVolumeTexture IWineD3DBaseTexture parts follow
    ****************************************************** */
 static DWORD WINAPI IWineD3DVolumeTextureImpl_SetLOD(IWineD3DVolumeTexture *iface, DWORD LODNew) {
-    return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew);
+    return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
 }
 
 static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLOD(IWineD3DVolumeTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface);
+    return basetexture_get_lod((IWineD3DBaseTexture *)iface);
 }
 
 static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLevelCount(IWineD3DVolumeTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface);
+    return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
 }
 
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetAutoGenFilterType(IWineD3DVolumeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
-  return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType);
+  return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
 }
 
 static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DVolumeTextureImpl_GetAutoGenFilterType(IWineD3DVolumeTexture *iface) {
-  return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface);
+  return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
 }
 
 static void WINAPI IWineD3DVolumeTextureImpl_GenerateMipSubLevels(IWineD3DVolumeTexture *iface) {
-    IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface);
+    basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
 }
 
 /* Internal function, No d3d mapping */
 static BOOL WINAPI IWineD3DVolumeTextureImpl_SetDirty(IWineD3DVolumeTexture *iface, BOOL dirty) {
-    return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty);
+    return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
 }
 
 static BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface) {
-    return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface);
+    return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
 }
 
 static HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface) {
     IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
     TRACE("(%p) : relay to BaseTexture\n", This);
-    return IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
+    return basetexture_bind((IWineD3DBaseTexture *)iface);
 }
 
 static UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) {
@@ -216,7 +216,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_ApplyStateChanges(IWineD3DVolumeTex
                                                         const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
     IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
     TRACE("(%p) : nothing to do, passing to base texture\n", This);
-    IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
+    basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
 }
 
 
@@ -234,7 +234,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_Destroy(IWineD3DVolumeTexture *ifac
             D3DCB_DestroyVolume(This->volumes[i]);
         }
     }
-    IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
+    basetexture_cleanup((IWineD3DBaseTexture *)iface);
     HeapFree(GetProcessHeap(), 0, This);
 }
 
diff --git a/reactos/dll/directx/wine/wined3d/wined3d.idl b/reactos/dll/directx/wine/wined3d/wined3d.idl
new file mode 100644 (file)
index 0000000..abb0d3b
--- /dev/null
@@ -0,0 +1,3429 @@
+/*
+ * Copyright 2002-2003 The wine-d3d team
+ * Copyright 2002-2003 Jason Edmeades
+ * Copyright 2002-2003 Raphael Junqueira
+ * Copyright 2005 Oliver Stieber
+ * Copyright 2006 Stefan Dösinger
+ * Copyright 2006 Stefan Dösinger for CodeWeavers
+ * Copyright 2007 Henri Verbeet
+ * Copyright 2008 Henri Verbeet for CodeWeavers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+import "unknwn.idl";
+
+cpp_quote("#if 0")
+typedef HANDLE HMONITOR;
+
+typedef struct _RGNDATAHEADER
+{
+    DWORD dwSize;
+    DWORD iType;
+    DWORD nCount;
+    DWORD nRgnSize;
+    RECT rcBound;
+} RGNDATAHEADER;
+
+typedef struct _RGNDATA
+{
+    RGNDATAHEADER rdh;
+    char Buffer[1];
+} RGNDATA;
+cpp_quote("#endif")
+
+cpp_quote("#define WINED3D_OK                                  S_OK")
+
+const UINT _FACWINED3D = 0x876;
+cpp_quote("#define MAKE_WINED3DSTATUS(code)                    MAKE_HRESULT(0, _FACWINED3D, code)")
+cpp_quote("#define WINED3DOK_NOAUTOGEN                         MAKE_WINED3DSTATUS(2159)")
+
+cpp_quote("#define MAKE_WINED3DHRESULT(code)                   MAKE_HRESULT(1, _FACWINED3D, code)")
+cpp_quote("#define WINED3DERR_WRONGTEXTUREFORMAT               MAKE_WINED3DHRESULT(2072)")
+cpp_quote("#define WINED3DERR_UNSUPPORTEDCOLOROPERATION        MAKE_WINED3DHRESULT(2073)")
+cpp_quote("#define WINED3DERR_UNSUPPORTEDCOLORARG              MAKE_WINED3DHRESULT(2074)")
+cpp_quote("#define WINED3DERR_UNSUPPORTEDALPHAOPERATION        MAKE_WINED3DHRESULT(2075)")
+cpp_quote("#define WINED3DERR_UNSUPPORTEDALPHAARG              MAKE_WINED3DHRESULT(2076)")
+cpp_quote("#define WINED3DERR_TOOMANYOPERATIONS                MAKE_WINED3DHRESULT(2077)")
+cpp_quote("#define WINED3DERR_CONFLICTINGTEXTUREFILTER         MAKE_WINED3DHRESULT(2078)")
+cpp_quote("#define WINED3DERR_UNSUPPORTEDFACTORVALUE           MAKE_WINED3DHRESULT(2079)")
+cpp_quote("#define WINED3DERR_CONFLICTINGRENDERSTATE           MAKE_WINED3DHRESULT(2081)")
+cpp_quote("#define WINED3DERR_UNSUPPORTEDTEXTUREFILTER         MAKE_WINED3DHRESULT(2082)")
+cpp_quote("#define WINED3DERR_CONFLICTINGTEXTUREPALETTE        MAKE_WINED3DHRESULT(2086)")
+cpp_quote("#define WINED3DERR_DRIVERINTERNALERROR              MAKE_WINED3DHRESULT(2087)")
+cpp_quote("#define WINED3DERR_NOTFOUND                         MAKE_WINED3DHRESULT(2150)")
+cpp_quote("#define WINED3DERR_MOREDATA                         MAKE_WINED3DHRESULT(2151)")
+cpp_quote("#define WINED3DERR_DEVICELOST                       MAKE_WINED3DHRESULT(2152)")
+cpp_quote("#define WINED3DERR_DEVICENOTRESET                   MAKE_WINED3DHRESULT(2153)")
+cpp_quote("#define WINED3DERR_NOTAVAILABLE                     MAKE_WINED3DHRESULT(2154)")
+cpp_quote("#define WINED3DERR_OUTOFVIDEOMEMORY                 MAKE_WINED3DHRESULT(380)")
+cpp_quote("#define WINED3DERR_INVALIDDEVICE                    MAKE_WINED3DHRESULT(2155)")
+cpp_quote("#define WINED3DERR_INVALIDCALL                      MAKE_WINED3DHRESULT(2156)")
+cpp_quote("#define WINED3DERR_DRIVERINVALIDCALL                MAKE_WINED3DHRESULT(2157)")
+cpp_quote("#define WINED3DERR_WASSTILLDRAWING                  MAKE_WINED3DHRESULT(540)")
+cpp_quote("#define WINEDDERR_NOTAOVERLAYSURFACE                MAKE_WINED3DHRESULT(580)")
+cpp_quote("#define WINEDDERR_NODC                              MAKE_WINED3DHRESULT(586)")
+cpp_quote("#define WINEDDERR_DCALREADYCREATED                  MAKE_WINED3DHRESULT(620)")
+cpp_quote("#define WINEDDERR_NOTFLIPPABLE                      MAKE_WINED3DHRESULT(582)")
+cpp_quote("#define WINEDDERR_SURFACEBUSY                       MAKE_WINED3DHRESULT(430)")
+cpp_quote("#define WINEDDERR_INVALIDRECT                       MAKE_WINED3DHRESULT(150)")
+cpp_quote("#define WINEDDERR_NOCLIPLIST                        MAKE_WINED3DHRESULT(205)")
+cpp_quote("#define WINEDDERR_OVERLAYNOTVISIBLE                 MAKE_WINED3DHRESULT(577)")
+
+typedef DWORD WINED3DCOLOR;
+
+typedef enum _WINED3DLIGHTTYPE
+{
+    WINED3DLIGHT_POINT                      = 1,
+    WINED3DLIGHT_SPOT                       = 2,
+    WINED3DLIGHT_DIRECTIONAL                = 3,
+    WINED3DLIGHT_PARALLELPOINT              = 4, /* D3D7 */
+    WINED3DLIGHT_GLSPOT                     = 5, /* D3D7 */
+    WINED3DLIGHT_FORCE_DWORD                = 0x7fffffff
+} WINED3DLIGHTTYPE;
+
+typedef enum _WINED3DPRIMITIVETYPE
+{
+    WINED3DPT_POINTLIST                     = 1,
+    WINED3DPT_LINELIST                      = 2,
+    WINED3DPT_LINESTRIP                     = 3,
+    WINED3DPT_TRIANGLELIST                  = 4,
+    WINED3DPT_TRIANGLESTRIP                 = 5,
+    WINED3DPT_TRIANGLEFAN                   = 6,
+    WINED3DPT_FORCE_DWORD                   = 0x7fffffff
+} WINED3DPRIMITIVETYPE;
+
+typedef enum _WINED3DDEVTYPE
+{
+    WINED3DDEVTYPE_HAL                      = 1,
+    WINED3DDEVTYPE_REF                      = 2,
+    WINED3DDEVTYPE_SW                       = 3,
+    WINED3DDEVTYPE_NULLREF                  = 4,
+    WINED3DDEVTYPE_FORCE_DWORD              = 0xffffffff
+} WINED3DDEVTYPE;
+
+typedef enum _WINED3DDEGREETYPE
+{
+    WINED3DDEGREE_LINEAR                    = 1,
+    WINED3DDEGREE_QUADRATIC                 = 2,
+    WINED3DDEGREE_CUBIC                     = 3,
+    WINED3DDEGREE_QUINTIC                   = 5,
+    WINED3DDEGREE_FORCE_DWORD               = 0x7fffffff
+} WINED3DDEGREETYPE;
+
+typedef enum _WINED3DFORMAT
+{
+    WINED3DFMT_UNKNOWN                      = 0,
+    WINED3DFMT_R8G8B8                       = 20,
+    WINED3DFMT_A8R8G8B8                     = 21,
+    WINED3DFMT_X8R8G8B8                     = 22,
+    WINED3DFMT_R5G6B5                       = 23,
+    WINED3DFMT_X1R5G5B5                     = 24,
+    WINED3DFMT_A1R5G5B5                     = 25,
+    WINED3DFMT_A4R4G4B4                     = 26,
+    WINED3DFMT_R3G3B2                       = 27,
+    WINED3DFMT_A8                           = 28,
+    WINED3DFMT_A8R3G3B2                     = 29,
+    WINED3DFMT_X4R4G4B4                     = 30,
+    WINED3DFMT_A2B10G10R10                  = 31,
+    WINED3DFMT_A8B8G8R8                     = 32,
+    WINED3DFMT_X8B8G8R8                     = 33,
+    WINED3DFMT_G16R16                       = 34,
+    WINED3DFMT_A2R10G10B10                  = 35,
+    WINED3DFMT_A16B16G16R16                 = 36,
+    WINED3DFMT_A8P8                         = 40,
+    WINED3DFMT_P8                           = 41,
+    WINED3DFMT_L8                           = 50,
+    WINED3DFMT_A8L8                         = 51,
+    WINED3DFMT_A4L4                         = 52,
+    WINED3DFMT_V8U8                         = 60,
+    WINED3DFMT_L6V5U5                       = 61,
+    WINED3DFMT_X8L8V8U8                     = 62,
+    WINED3DFMT_Q8W8V8U8                     = 63,
+    WINED3DFMT_V16U16                       = 64,
+    WINED3DFMT_W11V11U10                    = 65,
+    WINED3DFMT_A2W10V10U10                  = 67,
+    WINED3DFMT_D16_LOCKABLE                 = 70,
+    WINED3DFMT_D32                          = 71,
+    WINED3DFMT_D15S1                        = 73,
+    WINED3DFMT_D24S8                        = 75,
+    WINED3DFMT_D24X8                        = 77,
+    WINED3DFMT_D24X4S4                      = 79,
+    WINED3DFMT_D16                          = 80,
+    WINED3DFMT_L16                          = 81,
+    WINED3DFMT_D32F_LOCKABLE                = 82,
+    WINED3DFMT_D24FS8                       = 83,
+    WINED3DFMT_VERTEXDATA                   = 100,
+    WINED3DFMT_INDEX16                      = 101,
+    WINED3DFMT_INDEX32                      = 102,
+    WINED3DFMT_Q16W16V16U16                 = 110,
+    WINED3DFMT_R16F                         = 111,
+    WINED3DFMT_G16R16F                      = 112,
+    WINED3DFMT_A16B16G16R16F                = 113,
+    WINED3DFMT_R32F                         = 114,
+    WINED3DFMT_G32R32F                      = 115,
+    WINED3DFMT_A32B32G32R32F                = 116,
+    WINED3DFMT_CxV8U8                       = 117,
+    WINED3DFMT_FORCE_DWORD                  = 0xffffffff
+} WINED3DFORMAT;
+cpp_quote("#define WINEMAKEFOURCC(ch0, ch1, ch2, ch3) \\")
+cpp_quote("        ((DWORD)(BYTE)(ch0) | ((DWORD)(BYTE)(ch1) << 8) | \\")
+cpp_quote("        ((DWORD)(BYTE)(ch2) << 16) | ((DWORD)(BYTE)(ch3) << 24 ))")
+cpp_quote("#define WINED3DFMT_UYVY         WINEMAKEFOURCC('U', 'Y', 'V', 'Y')")
+cpp_quote("#define WINED3DFMT_YUY2         WINEMAKEFOURCC('Y', 'U', 'Y', '2')")
+cpp_quote("#define WINED3DFMT_YV12         WINEMAKEFOURCC('Y', 'V', '1', '2')")
+cpp_quote("#define WINED3DFMT_DXT1         WINEMAKEFOURCC('D', 'X', 'T', '1')")
+cpp_quote("#define WINED3DFMT_DXT2         WINEMAKEFOURCC('D', 'X', 'T', '2')")
+cpp_quote("#define WINED3DFMT_DXT3         WINEMAKEFOURCC('D', 'X', 'T', '3')")
+cpp_quote("#define WINED3DFMT_DXT4         WINEMAKEFOURCC('D', 'X', 'T', '4')")
+cpp_quote("#define WINED3DFMT_DXT5         WINEMAKEFOURCC('D', 'X', 'T', '5')")
+cpp_quote("#define WINED3DFMT_MULTI2_ARGB8 WINEMAKEFOURCC('M', 'E', 'T', '1')")
+cpp_quote("#define WINED3DFMT_G8R8_G8B8    WINEMAKEFOURCC('G', 'R', 'G', 'B')")
+cpp_quote("#define WINED3DFMT_R8G8_B8G8    WINEMAKEFOURCC('R', 'G', 'B', 'G')")
+/* Vendor specific formats */
+cpp_quote("#define WINED3DFMT_ATI2N        WINEMAKEFOURCC('A', 'T', 'I', '2')")
+cpp_quote("#define WINED3DFMT_NVHU         WINEMAKEFOURCC('N', 'V', 'H', 'U')")
+cpp_quote("#define WINED3DFMT_NVHS         WINEMAKEFOURCC('N', 'V', 'H', 'S')")
+
+typedef enum _WINED3DRENDERSTATETYPE
+{
+    WINED3DRS_TEXTUREHANDLE                 = 1, /* d3d7 */
+    WINED3DRS_ANTIALIAS                     = 2, /* d3d7 */
+    WINED3DRS_TEXTUREADDRESS                = 3, /* d3d7 */
+    WINED3DRS_TEXTUREPERSPECTIVE            = 4, /* d3d7 */
+    WINED3DRS_WRAPU                         = 5, /* d3d7 */
+    WINED3DRS_WRAPV                         = 6, /* d3d7 */
+    WINED3DRS_ZENABLE                       = 7,
+    WINED3DRS_FILLMODE                      = 8,
+    WINED3DRS_SHADEMODE                     = 9,
+    WINED3DRS_LINEPATTERN                   = 10, /* d3d7, d3d8 */
+    WINED3DRS_MONOENABLE                    = 11, /* d3d7 */
+    WINED3DRS_ROP2                          = 12, /* d3d7 */
+    WINED3DRS_PLANEMASK                     = 13, /* d3d7 */
+    WINED3DRS_ZWRITEENABLE                  = 14,
+    WINED3DRS_ALPHATESTENABLE               = 15,
+    WINED3DRS_LASTPIXEL                     = 16,
+    WINED3DRS_TEXTUREMAG                    = 17, /* d3d7 */
+    WINED3DRS_TEXTUREMIN                    = 18, /* d3d7 */
+    WINED3DRS_SRCBLEND                      = 19,
+    WINED3DRS_DESTBLEND                     = 20,
+    WINED3DRS_TEXTUREMAPBLEND               = 21, /* d3d7 */
+    WINED3DRS_CULLMODE                      = 22,
+    WINED3DRS_ZFUNC                         = 23,
+    WINED3DRS_ALPHAREF                      = 24,
+    WINED3DRS_ALPHAFUNC                     = 25,
+    WINED3DRS_DITHERENABLE                  = 26,
+    WINED3DRS_ALPHABLENDENABLE              = 27,
+    WINED3DRS_FOGENABLE                     = 28,
+    WINED3DRS_SPECULARENABLE                = 29,
+    WINED3DRS_ZVISIBLE                      = 30, /* d3d7, d3d8 */
+    WINED3DRS_SUBPIXEL                      = 31, /* d3d7 */
+    WINED3DRS_SUBPIXELX                     = 32, /* d3d7 */
+    WINED3DRS_STIPPLEDALPHA                 = 33, /* d3d7 */
+    WINED3DRS_FOGCOLOR                      = 34,
+    WINED3DRS_FOGTABLEMODE                  = 35,
+    WINED3DRS_FOGSTART                      = 36,
+    WINED3DRS_FOGEND                        = 37,
+    WINED3DRS_FOGDENSITY                    = 38,
+    WINED3DRS_STIPPLEENABLE                 = 39, /* d3d7 */
+    WINED3DRS_EDGEANTIALIAS                 = 40, /* d3d7, d3d8 */
+    WINED3DRS_COLORKEYENABLE                = 41, /* d3d7 */
+    WINED3DRS_BORDERCOLOR                   = 43, /* d3d7 */
+    WINED3DRS_TEXTUREADDRESSU               = 44, /* d3d7 */
+    WINED3DRS_TEXTUREADDRESSV               = 45, /* d3d7 */
+    WINED3DRS_MIPMAPLODBIAS                 = 46, /* d3d7 */
+    WINED3DRS_ZBIAS                         = 47, /* d3d7, d3d8 */
+    WINED3DRS_RANGEFOGENABLE                = 48,
+    WINED3DRS_ANISOTROPY                    = 49, /* d3d7 */
+    WINED3DRS_FLUSHBATCH                    = 50, /* d3d7 */
+    WINED3DRS_TRANSLUCENTSORTINDEPENDENT    = 51, /* d3d7 */
+    WINED3DRS_STENCILENABLE                 = 52,
+    WINED3DRS_STENCILFAIL                   = 53,
+    WINED3DRS_STENCILZFAIL                  = 54,
+    WINED3DRS_STENCILPASS                   = 55,
+    WINED3DRS_STENCILFUNC                   = 56,
+    WINED3DRS_STENCILREF                    = 57,
+    WINED3DRS_STENCILMASK                   = 58,
+    WINED3DRS_STENCILWRITEMASK              = 59,
+    WINED3DRS_TEXTUREFACTOR                 = 60,
+    WINED3DRS_STIPPLEPATTERN00              = 64,
+    WINED3DRS_STIPPLEPATTERN01              = 65,
+    WINED3DRS_STIPPLEPATTERN02              = 66,
+    WINED3DRS_STIPPLEPATTERN03              = 67,
+    WINED3DRS_STIPPLEPATTERN04              = 68,
+    WINED3DRS_STIPPLEPATTERN05              = 69,
+    WINED3DRS_STIPPLEPATTERN06              = 70,
+    WINED3DRS_STIPPLEPATTERN07              = 71,
+    WINED3DRS_STIPPLEPATTERN08              = 72,
+    WINED3DRS_STIPPLEPATTERN09              = 73,
+    WINED3DRS_STIPPLEPATTERN10              = 74,
+    WINED3DRS_STIPPLEPATTERN11              = 75,
+    WINED3DRS_STIPPLEPATTERN12              = 76,
+    WINED3DRS_STIPPLEPATTERN13              = 77,
+    WINED3DRS_STIPPLEPATTERN14              = 78,
+    WINED3DRS_STIPPLEPATTERN15              = 79,
+    WINED3DRS_STIPPLEPATTERN16              = 80,
+    WINED3DRS_STIPPLEPATTERN17              = 81,
+    WINED3DRS_STIPPLEPATTERN18              = 82,
+    WINED3DRS_STIPPLEPATTERN19              = 83,
+    WINED3DRS_STIPPLEPATTERN20              = 84,
+    WINED3DRS_STIPPLEPATTERN21              = 85,
+    WINED3DRS_STIPPLEPATTERN22              = 86,
+    WINED3DRS_STIPPLEPATTERN23              = 87,
+    WINED3DRS_STIPPLEPATTERN24              = 88,
+    WINED3DRS_STIPPLEPATTERN25              = 89,
+    WINED3DRS_STIPPLEPATTERN26              = 90,
+    WINED3DRS_STIPPLEPATTERN27              = 91,
+    WINED3DRS_STIPPLEPATTERN28              = 92,
+    WINED3DRS_STIPPLEPATTERN29              = 93,
+    WINED3DRS_STIPPLEPATTERN30              = 94,
+    WINED3DRS_STIPPLEPATTERN31              = 95,
+    WINED3DRS_WRAP0                         = 128,
+    WINED3DRS_WRAP1                         = 129,
+    WINED3DRS_WRAP2                         = 130,
+    WINED3DRS_WRAP3                         = 131,
+    WINED3DRS_WRAP4                         = 132,
+    WINED3DRS_WRAP5                         = 133,
+    WINED3DRS_WRAP6                         = 134,
+    WINED3DRS_WRAP7                         = 135,
+    WINED3DRS_CLIPPING                      = 136,
+    WINED3DRS_LIGHTING                      = 137,
+    WINED3DRS_EXTENTS                       = 138, /* d3d7 */
+    WINED3DRS_AMBIENT                       = 139,
+    WINED3DRS_FOGVERTEXMODE                 = 140,
+    WINED3DRS_COLORVERTEX                   = 141,
+    WINED3DRS_LOCALVIEWER                   = 142,
+    WINED3DRS_NORMALIZENORMALS              = 143,
+    WINED3DRS_COLORKEYBLENDENABLE           = 144, /* d3d7 */
+    WINED3DRS_DIFFUSEMATERIALSOURCE         = 145,
+    WINED3DRS_SPECULARMATERIALSOURCE        = 146,
+    WINED3DRS_AMBIENTMATERIALSOURCE         = 147,
+    WINED3DRS_EMISSIVEMATERIALSOURCE        = 148,
+    WINED3DRS_VERTEXBLEND                   = 151,
+    WINED3DRS_CLIPPLANEENABLE               = 152,
+    WINED3DRS_SOFTWAREVERTEXPROCESSING      = 153, /* d3d8 */
+    WINED3DRS_POINTSIZE                     = 154,
+    WINED3DRS_POINTSIZE_MIN                 = 155,
+    WINED3DRS_POINTSPRITEENABLE             = 156,
+    WINED3DRS_POINTSCALEENABLE              = 157,
+    WINED3DRS_POINTSCALE_A                  = 158,
+    WINED3DRS_POINTSCALE_B                  = 159,
+    WINED3DRS_POINTSCALE_C                  = 160,
+    WINED3DRS_MULTISAMPLEANTIALIAS          = 161,
+    WINED3DRS_MULTISAMPLEMASK               = 162,
+    WINED3DRS_PATCHEDGESTYLE                = 163,
+    WINED3DRS_PATCHSEGMENTS                 = 164, /* d3d8 */
+    WINED3DRS_DEBUGMONITORTOKEN             = 165,
+    WINED3DRS_POINTSIZE_MAX                 = 166,
+    WINED3DRS_INDEXEDVERTEXBLENDENABLE      = 167,
+    WINED3DRS_COLORWRITEENABLE              = 168,
+    WINED3DRS_TWEENFACTOR                   = 170,
+    WINED3DRS_BLENDOP                       = 171,
+    WINED3DRS_POSITIONORDER                 = 172,
+    WINED3DRS_NORMALORDER                   = 173,
+    WINED3DRS_POSITIONDEGREE                = 172,
+    WINED3DRS_NORMALDEGREE                  = 173,
+    WINED3DRS_SCISSORTESTENABLE             = 174,
+    WINED3DRS_SLOPESCALEDEPTHBIAS           = 175,
+    WINED3DRS_ANTIALIASEDLINEENABLE         = 176,
+    WINED3DRS_MINTESSELLATIONLEVEL          = 178,
+    WINED3DRS_MAXTESSELLATIONLEVEL          = 179,
+    WINED3DRS_ADAPTIVETESS_X                = 180,
+    WINED3DRS_ADAPTIVETESS_Y                = 181,
+    WINED3DRS_ADAPTIVETESS_Z                = 182,
+    WINED3DRS_ADAPTIVETESS_W                = 183,
+    WINED3DRS_ENABLEADAPTIVETESSELLATION    = 184,
+    WINED3DRS_TWOSIDEDSTENCILMODE           = 185,
+    WINED3DRS_CCW_STENCILFAIL               = 186,
+    WINED3DRS_CCW_STENCILZFAIL              = 187,
+    WINED3DRS_CCW_STENCILPASS               = 188,
+    WINED3DRS_CCW_STENCILFUNC               = 189,
+    WINED3DRS_COLORWRITEENABLE1             = 190,
+    WINED3DRS_COLORWRITEENABLE2             = 191,
+    WINED3DRS_COLORWRITEENABLE3             = 192,
+    WINED3DRS_BLENDFACTOR                   = 193,
+    WINED3DRS_SRGBWRITEENABLE               = 194,
+    WINED3DRS_DEPTHBIAS                     = 195,
+    WINED3DRS_WRAP8                         = 198,
+    WINED3DRS_WRAP9                         = 199,
+    WINED3DRS_WRAP10                        = 200,
+    WINED3DRS_WRAP11                        = 201,
+    WINED3DRS_WRAP12                        = 202,
+    WINED3DRS_WRAP13                        = 203,
+    WINED3DRS_WRAP14                        = 204,
+    WINED3DRS_WRAP15                        = 205,
+    WINED3DRS_SEPARATEALPHABLENDENABLE      = 206,
+    WINED3DRS_SRCBLENDALPHA                 = 207,
+    WINED3DRS_DESTBLENDALPHA                = 208,
+    WINED3DRS_BLENDOPALPHA                  = 209,
+    WINED3DRS_FORCE_DWORD                   = 0x7fffffff
+} WINED3DRENDERSTATETYPE;
+const UINT WINEHIGHEST_RENDER_STATE         = WINED3DRS_BLENDOPALPHA;
+
+typedef enum _WINED3DBLEND
+{
+    WINED3DBLEND_ZERO                       =  1,
+    WINED3DBLEND_ONE                        =  2,
+    WINED3DBLEND_SRCCOLOR                   =  3,
+    WINED3DBLEND_INVSRCCOLOR                =  4,
+    WINED3DBLEND_SRCALPHA                   =  5,
+    WINED3DBLEND_INVSRCALPHA                =  6,
+    WINED3DBLEND_DESTALPHA                  =  7,
+    WINED3DBLEND_INVDESTALPHA               =  8,
+    WINED3DBLEND_DESTCOLOR                  =  9,
+    WINED3DBLEND_INVDESTCOLOR               = 10,
+    WINED3DBLEND_SRCALPHASAT                = 11,
+    WINED3DBLEND_BOTHSRCALPHA               = 12,
+    WINED3DBLEND_BOTHINVSRCALPHA            = 13,
+    WINED3DBLEND_BLENDFACTOR                = 14,
+    WINED3DBLEND_INVBLENDFACTOR             = 15,
+    WINED3DBLEND_FORCE_DWORD                = 0x7fffffff
+} WINED3DBLEND;
+
+typedef enum _WINED3DBLENDOP
+{
+    WINED3DBLENDOP_ADD                      = 1,
+    WINED3DBLENDOP_SUBTRACT                 = 2,
+    WINED3DBLENDOP_REVSUBTRACT              = 3,
+    WINED3DBLENDOP_MIN                      = 4,
+    WINED3DBLENDOP_MAX                      = 5,
+    WINED3DBLENDOP_FORCE_DWORD              = 0x7fffffff
+} WINED3DBLENDOP;
+
+typedef enum _WINED3DVERTEXBLENDFLAGS
+{
+    WINED3DVBF_DISABLE                      = 0,
+    WINED3DVBF_1WEIGHTS                     = 1,
+    WINED3DVBF_2WEIGHTS                     = 2,
+    WINED3DVBF_3WEIGHTS                     = 3,
+    WINED3DVBF_TWEENING                     = 255,
+    WINED3DVBF_0WEIGHTS                     = 256
+} WINED3DVERTEXBLENDFLAGS;
+
+typedef enum _WINED3DCMPFUNC
+{
+    WINED3DCMP_NEVER                        = 1,
+    WINED3DCMP_LESS                         = 2,
+    WINED3DCMP_EQUAL                        = 3,
+    WINED3DCMP_LESSEQUAL                    = 4,
+    WINED3DCMP_GREATER                      = 5,
+    WINED3DCMP_NOTEQUAL                     = 6,
+    WINED3DCMP_GREATEREQUAL                 = 7,
+    WINED3DCMP_ALWAYS                       = 8,
+    WINED3DCMP_FORCE_DWORD                  = 0x7fffffff
+} WINED3DCMPFUNC;
+
+typedef enum _WINED3DZBUFFERTYPE
+{
+    WINED3DZB_FALSE                         = 0,
+    WINED3DZB_TRUE                          = 1,
+    WINED3DZB_USEW                          = 2,
+    WINED3DZB_FORCE_DWORD                   = 0x7fffffff
+} WINED3DZBUFFERTYPE;
+
+typedef enum _WINED3DFOGMODE
+{
+    WINED3DFOG_NONE                         = 0,
+    WINED3DFOG_EXP                          = 1,
+    WINED3DFOG_EXP2                         = 2,
+    WINED3DFOG_LINEAR                       = 3,
+    WINED3DFOG_FORCE_DWORD                  = 0x7fffffff
+} WINED3DFOGMODE;
+
+typedef enum _WINED3DSHADEMODE
+{
+    WINED3DSHADE_FLAT                       = 1,
+    WINED3DSHADE_GOURAUD                    = 2,
+    WINED3DSHADE_PHONG                      = 3,
+    WINED3DSHADE_FORCE_DWORD                = 0x7fffffff
+} WINED3DSHADEMODE;
+
+typedef enum _WINED3DFILLMODE
+{
+    WINED3DFILL_POINT                       = 1,
+    WINED3DFILL_WIREFRAME                   = 2,
+    WINED3DFILL_SOLID                       = 3,
+    WINED3DFILL_FORCE_DWORD                 = 0x7fffffff
+} WINED3DFILLMODE;
+
+typedef enum _WINED3DCULL
+{
+    WINED3DCULL_NONE                        = 1,
+    WINED3DCULL_CW                          = 2,
+    WINED3DCULL_CCW                         = 3,
+    WINED3DCULL_FORCE_DWORD                 = 0x7fffffff
+} WINED3DCULL;
+
+typedef enum _WINED3DSTENCILOP
+{
+    WINED3DSTENCILOP_KEEP                   = 1,
+    WINED3DSTENCILOP_ZERO                   = 2,
+    WINED3DSTENCILOP_REPLACE                = 3,
+    WINED3DSTENCILOP_INCRSAT                = 4,
+    WINED3DSTENCILOP_DECRSAT                = 5,
+    WINED3DSTENCILOP_INVERT                 = 6,
+    WINED3DSTENCILOP_INCR                   = 7,
+    WINED3DSTENCILOP_DECR                   = 8,
+    WINED3DSTENCILOP_FORCE_DWORD            = 0x7fffffff
+} WINED3DSTENCILOP;
+
+typedef enum _WINED3DMATERIALCOLORSOURCE
+{
+    WINED3DMCS_MATERIAL                     = 0,
+    WINED3DMCS_COLOR1                       = 1,
+    WINED3DMCS_COLOR2                       = 2,
+    WINED3DMCS_FORCE_DWORD                  = 0x7fffffff
+} WINED3DMATERIALCOLORSOURCE;
+
+typedef enum _WINED3DPATCHEDGESTYLE
+{
+    WINED3DPATCHEDGE_DISCRETE               = 0,
+    WINED3DPATCHEDGE_CONTINUOUS             = 1,
+    WINED3DPATCHEDGE_FORCE_DWORD            = 0x7fffffff
+} WINED3DPATCHEDGESTYLE;
+
+typedef enum _WINED3DBACKBUFFER_TYPE
+{
+    WINED3DBACKBUFFER_TYPE_MONO             = 0,
+    WINED3DBACKBUFFER_TYPE_LEFT             = 1,
+    WINED3DBACKBUFFER_TYPE_RIGHT            = 2,
+    WINED3DBACKBUFFER_TYPE_FORCE_DWORD      = 0x7fffffff
+} WINED3DBACKBUFFER_TYPE;
+
+typedef enum _WINED3DSWAPEFFECT
+{
+    WINED3DSWAPEFFECT_DISCARD               = 1,
+    WINED3DSWAPEFFECT_FLIP                  = 2,
+    WINED3DSWAPEFFECT_COPY                  = 3,
+    WINED3DSWAPEFFECT_COPY_VSYNC            = 4,
+    WINED3DSWAPEFFECT_FORCE_DWORD           = 0xffffffff
+} WINED3DSWAPEFFECT;
+
+typedef enum _WINED3DSAMPLERSTATETYPE
+{
+    WINED3DSAMP_ADDRESSU                    = 1,
+    WINED3DSAMP_ADDRESSV                    = 2,
+    WINED3DSAMP_ADDRESSW                    = 3,
+    WINED3DSAMP_BORDERCOLOR                 = 4,
+    WINED3DSAMP_MAGFILTER                   = 5,
+    WINED3DSAMP_MINFILTER                   = 6,
+    WINED3DSAMP_MIPFILTER                   = 7,
+    WINED3DSAMP_MIPMAPLODBIAS               = 8,
+    WINED3DSAMP_MAXMIPLEVEL                 = 9,
+    WINED3DSAMP_MAXANISOTROPY               = 10,
+    WINED3DSAMP_SRGBTEXTURE                 = 11,
+    WINED3DSAMP_ELEMENTINDEX                = 12,
+    WINED3DSAMP_DMAPOFFSET                  = 13,
+    WINED3DSAMP_FORCE_DWORD                 = 0x7fffffff,
+} WINED3DSAMPLERSTATETYPE;
+const UINT WINED3D_HIGHEST_SAMPLER_STATE    = WINED3DSAMP_DMAPOFFSET;
+
+typedef enum _WINED3DMULTISAMPLE_TYPE
+{
+    WINED3DMULTISAMPLE_NONE                 = 0,
+    WINED3DMULTISAMPLE_NONMASKABLE          = 1,
+    WINED3DMULTISAMPLE_2_SAMPLES            = 2,
+    WINED3DMULTISAMPLE_3_SAMPLES            = 3,
+    WINED3DMULTISAMPLE_4_SAMPLES            = 4,
+    WINED3DMULTISAMPLE_5_SAMPLES            = 5,
+    WINED3DMULTISAMPLE_6_SAMPLES            = 6,
+    WINED3DMULTISAMPLE_7_SAMPLES            = 7,
+    WINED3DMULTISAMPLE_8_SAMPLES            = 8,
+    WINED3DMULTISAMPLE_9_SAMPLES            = 9,
+    WINED3DMULTISAMPLE_10_SAMPLES           = 10,
+    WINED3DMULTISAMPLE_11_SAMPLES           = 11,
+    WINED3DMULTISAMPLE_12_SAMPLES           = 12,
+    WINED3DMULTISAMPLE_13_SAMPLES           = 13,
+    WINED3DMULTISAMPLE_14_SAMPLES           = 14,
+    WINED3DMULTISAMPLE_15_SAMPLES           = 15,
+    WINED3DMULTISAMPLE_16_SAMPLES           = 16,
+    WINED3DMULTISAMPLE_FORCE_DWORD          = 0xffffffff
+} WINED3DMULTISAMPLE_TYPE;
+
+typedef enum _WINED3DTEXTURESTAGESTATETYPE
+{
+    WINED3DTSS_COLOROP                      = 1,
+    WINED3DTSS_COLORARG1                    = 2,
+    WINED3DTSS_COLORARG2                    = 3,
+    WINED3DTSS_ALPHAOP                      = 4,
+    WINED3DTSS_ALPHAARG1                    = 5,
+    WINED3DTSS_ALPHAARG2                    = 6,
+    WINED3DTSS_BUMPENVMAT00                 = 7,
+    WINED3DTSS_BUMPENVMAT01                 = 8,
+    WINED3DTSS_BUMPENVMAT10                 = 9,
+    WINED3DTSS_BUMPENVMAT11                 = 10,
+    WINED3DTSS_TEXCOORDINDEX                = 11,
+    WINED3DTSS_ADDRESS                      = 12,
+    WINED3DTSS_ADDRESSU                     = 13,
+    WINED3DTSS_ADDRESSV                     = 14,
+    WINED3DTSS_BORDERCOLOR                  = 15,
+    WINED3DTSS_MAGFILTER                    = 16,
+    WINED3DTSS_MINFILTER                    = 17,
+    WINED3DTSS_MIPFILTER                    = 18,
+    WINED3DTSS_MIPMAPLODBIAS                = 19,
+    WINED3DTSS_MAXMIPLEVEL                  = 20,
+    WINED3DTSS_MAXANISOTROPY                = 21,
+    WINED3DTSS_BUMPENVLSCALE                = 22,
+    WINED3DTSS_BUMPENVLOFFSET               = 23,
+    WINED3DTSS_TEXTURETRANSFORMFLAGS        = 24,
+    WINED3DTSS_ADDRESSW                     = 25,
+    WINED3DTSS_COLORARG0                    = 26,
+    WINED3DTSS_ALPHAARG0                    = 27,
+    WINED3DTSS_RESULTARG                    = 28,
+    WINED3DTSS_CONSTANT                     = 32,
+    WINED3DTSS_FORCE_DWORD                  = 0x7fffffff
+} WINED3DTEXTURESTAGESTATETYPE;
+const UINT WINED3D_HIGHEST_TEXTURE_STATE    = WINED3DTSS_CONSTANT;
+
+typedef enum _WINED3DTEXTURETRANSFORMFLAGS
+{
+    WINED3DTTFF_DISABLE                     = 0,
+    WINED3DTTFF_COUNT1                      = 1,
+    WINED3DTTFF_COUNT2                      = 2,
+    WINED3DTTFF_COUNT3                      = 3,
+    WINED3DTTFF_COUNT4                      = 4,
+    WINED3DTTFF_PROJECTED                   = 256,
+    WINED3DTTFF_FORCE_DWORD                 = 0x7fffffff
+} WINED3DTEXTURETRANSFORMFLAGS;
+
+typedef enum _WINED3DTEXTUREOP
+{
+    WINED3DTOP_DISABLE                      = 1,
+    WINED3DTOP_SELECTARG1                   = 2,
+    WINED3DTOP_SELECTARG2                   = 3,
+    WINED3DTOP_MODULATE                     = 4,
+    WINED3DTOP_MODULATE2X                   = 5,
+    WINED3DTOP_MODULATE4X                   = 6,
+    WINED3DTOP_ADD                          = 7,
+    WINED3DTOP_ADDSIGNED                    = 8,
+    WINED3DTOP_ADDSIGNED2X                  = 9,
+    WINED3DTOP_SUBTRACT                     = 10,
+    WINED3DTOP_ADDSMOOTH                    = 11,
+    WINED3DTOP_BLENDDIFFUSEALPHA            = 12,
+    WINED3DTOP_BLENDTEXTUREALPHA            = 13,
+    WINED3DTOP_BLENDFACTORALPHA             = 14,
+    WINED3DTOP_BLENDTEXTUREALPHAPM          = 15,
+    WINED3DTOP_BLENDCURRENTALPHA            = 16,
+    WINED3DTOP_PREMODULATE                  = 17,
+    WINED3DTOP_MODULATEALPHA_ADDCOLOR       = 18,
+    WINED3DTOP_MODULATECOLOR_ADDALPHA       = 19,
+    WINED3DTOP_MODULATEINVALPHA_ADDCOLOR    = 20,
+    WINED3DTOP_MODULATEINVCOLOR_ADDALPHA    = 21,
+    WINED3DTOP_BUMPENVMAP                   = 22,
+    WINED3DTOP_BUMPENVMAPLUMINANCE          = 23,
+    WINED3DTOP_DOTPRODUCT3                  = 24,
+    WINED3DTOP_MULTIPLYADD                  = 25,
+    WINED3DTOP_LERP                         = 26,
+    WINED3DTOP_FORCE_DWORD                  = 0x7fffffff,
+} WINED3DTEXTUREOP;
+
+typedef enum _WINED3DTEXTUREADDRESS
+{
+    WINED3DTADDRESS_WRAP                    = 1,
+    WINED3DTADDRESS_MIRROR                  = 2,
+    WINED3DTADDRESS_CLAMP                   = 3,
+    WINED3DTADDRESS_BORDER                  = 4,
+    WINED3DTADDRESS_MIRRORONCE              = 5,
+    WINED3DTADDRESS_FORCE_DWORD             = 0x7fffffff
+} WINED3DTEXTUREADDRESS;
+
+typedef enum _WINED3DTRANSFORMSTATETYPE
+{
+    WINED3DTS_VIEW                          = 2,
+    WINED3DTS_PROJECTION                    = 3,
+    WINED3DTS_TEXTURE0                      = 16,
+    WINED3DTS_TEXTURE1                      = 17,
+    WINED3DTS_TEXTURE2                      = 18,
+    WINED3DTS_TEXTURE3                      = 19,
+    WINED3DTS_TEXTURE4                      = 20,
+    WINED3DTS_TEXTURE5                      = 21,
+    WINED3DTS_TEXTURE6                      = 22,
+    WINED3DTS_TEXTURE7                      = 23,
+    WINED3DTS_FORCE_DWORD                   = 0x7fffffff
+} WINED3DTRANSFORMSTATETYPE;
+cpp_quote("#define WINED3DTS_WORLD  WINED3DTS_WORLDMATRIX(0)")
+cpp_quote("#define WINED3DTS_WORLD1 WINED3DTS_WORLDMATRIX(1)")
+cpp_quote("#define WINED3DTS_WORLD2 WINED3DTS_WORLDMATRIX(2)")
+cpp_quote("#define WINED3DTS_WORLD3 WINED3DTS_WORLDMATRIX(3)")
+cpp_quote("#define WINED3DTS_WORLDMATRIX(index) (WINED3DTRANSFORMSTATETYPE)(index + 256)")
+
+typedef enum _WINED3DBASISTYPE
+{
+    WINED3DBASIS_BEZIER                     = 0,
+    WINED3DBASIS_BSPLINE                    = 1,
+    WINED3DBASIS_INTERPOLATE                = 2,
+    WINED3DBASIS_FORCE_DWORD                = 0x7fffffff
+} WINED3DBASISTYPE;
+
+typedef enum _WINED3DCUBEMAP_FACES
+{
+    WINED3DCUBEMAP_FACE_POSITIVE_X          = 0,
+    WINED3DCUBEMAP_FACE_NEGATIVE_X          = 1,
+    WINED3DCUBEMAP_FACE_POSITIVE_Y          = 2,
+    WINED3DCUBEMAP_FACE_NEGATIVE_Y          = 3,
+    WINED3DCUBEMAP_FACE_POSITIVE_Z          = 4,
+    WINED3DCUBEMAP_FACE_NEGATIVE_Z          = 5,
+    WINED3DCUBEMAP_FACE_FORCE_DWORD         = 0xffffffff
+} WINED3DCUBEMAP_FACES;
+
+typedef enum _WINED3DTEXTUREFILTERTYPE
+{
+    WINED3DTEXF_NONE                        = 0,
+    WINED3DTEXF_POINT                       = 1,
+    WINED3DTEXF_LINEAR                      = 2,
+    WINED3DTEXF_ANISOTROPIC                 = 3,
+    WINED3DTEXF_FLATCUBIC                   = 4,
+    WINED3DTEXF_GAUSSIANCUBIC               = 5,
+    WINED3DTEXF_PYRAMIDALQUAD               = 6,
+    WINED3DTEXF_GAUSSIANQUAD                = 7,
+    WINED3DTEXF_FORCE_DWORD                 = 0x7fffffff
+} WINED3DTEXTUREFILTERTYPE;
+
+typedef enum _WINED3DRESOURCETYPE
+{
+    WINED3DRTYPE_SURFACE                    = 1,
+    WINED3DRTYPE_VOLUME                     = 2,
+    WINED3DRTYPE_TEXTURE                    = 3,
+    WINED3DRTYPE_VOLUMETEXTURE              = 4,
+    WINED3DRTYPE_CUBETEXTURE                = 5,
+    WINED3DRTYPE_VERTEXBUFFER               = 6,
+    WINED3DRTYPE_INDEXBUFFER                = 7,
+    WINED3DRTYPE_FORCE_DWORD                = 0x7fffffff
+} WINED3DRESOURCETYPE;
+const UINT WINED3DRTYPECOUNT                = WINED3DRTYPE_INDEXBUFFER + 1;
+
+typedef enum _WINED3DPOOL
+{
+    WINED3DPOOL_DEFAULT                     = 0,
+    WINED3DPOOL_MANAGED                     = 1,
+    WINED3DPOOL_SYSTEMMEM                   = 2,
+    WINED3DPOOL_SCRATCH                     = 3,
+    WINED3DPOOL_FORCE_DWORD                 = 0x7fffffff
+} WINED3DPOOL;
+
+typedef enum _WINED3DQUERYTYPE
+{
+    WINED3DQUERYTYPE_VCACHE                 = 4,
+    WINED3DQUERYTYPE_RESOURCEMANAGER        = 5,
+    WINED3DQUERYTYPE_VERTEXSTATS            = 6,
+    WINED3DQUERYTYPE_EVENT                  = 8,
+    WINED3DQUERYTYPE_OCCLUSION              = 9,
+    WINED3DQUERYTYPE_TIMESTAMP              = 10,
+    WINED3DQUERYTYPE_TIMESTAMPDISJOINT      = 11,
+    WINED3DQUERYTYPE_TIMESTAMPFREQ          = 12,
+    WINED3DQUERYTYPE_PIPELINETIMINGS        = 13,
+    WINED3DQUERYTYPE_INTERFACETIMINGS       = 14,
+    WINED3DQUERYTYPE_VERTEXTIMINGS          = 15,
+    WINED3DQUERYTYPE_PIXELTIMINGS           = 16,
+    WINED3DQUERYTYPE_BANDWIDTHTIMINGS       = 17,
+    WINED3DQUERYTYPE_CACHEUTILIZATION       = 18
+} WINED3DQUERYTYPE;
+
+const UINT WINED3DISSUE_BEGIN               = (1 << 1);
+const UINT WINED3DISSUE_END                 = (1 << 0);
+const UINT WINED3DGETDATA_FLUSH             = (1 << 0);
+
+typedef enum _WINED3DSTATEBLOCKTYPE
+{
+    WINED3DSBT_INIT                         = 0,
+    WINED3DSBT_ALL                          = 1,
+    WINED3DSBT_PIXELSTATE                   = 2,
+    WINED3DSBT_VERTEXSTATE                  = 3,
+    WINED3DSBT_RECORDED                     = 4, /* WineD3D private */
+    WINED3DSBT_FORCE_DWORD                  = 0xffffffff
+} WINED3DSTATEBLOCKTYPE;
+
+typedef enum _WINED3DDECLMETHOD
+{
+    WINED3DDECLMETHOD_DEFAULT               = 0,
+    WINED3DDECLMETHOD_PARTIALU              = 1,
+    WINED3DDECLMETHOD_PARTIALV              = 2,
+    WINED3DDECLMETHOD_CROSSUV               = 3,
+    WINED3DDECLMETHOD_UV                    = 4,
+    WINED3DDECLMETHOD_LOOKUP                = 5,
+    WINED3DDECLMETHOD_LOOKUPPRESAMPLED      = 6
+} WINED3DDECLMETHOD;
+
+typedef enum _WINED3DDECLTYPE
+{
+    WINED3DDECLTYPE_FLOAT1                  = 0,
+    WINED3DDECLTYPE_FLOAT2                  = 1,
+    WINED3DDECLTYPE_FLOAT3                  = 2,
+    WINED3DDECLTYPE_FLOAT4                  = 3,
+    WINED3DDECLTYPE_D3DCOLOR                = 4,
+    WINED3DDECLTYPE_UBYTE4                  = 5,
+    WINED3DDECLTYPE_SHORT2                  = 6,
+    WINED3DDECLTYPE_SHORT4                  = 7,
+    /* VS 2.0 */
+    WINED3DDECLTYPE_UBYTE4N                 = 8,
+    WINED3DDECLTYPE_SHORT2N                 = 9,
+    WINED3DDECLTYPE_SHORT4N                 = 10,
+    WINED3DDECLTYPE_USHORT2N                = 11,
+    WINED3DDECLTYPE_USHORT4N                = 12,
+    WINED3DDECLTYPE_UDEC3                   = 13,
+    WINED3DDECLTYPE_DEC3N                   = 14,
+    WINED3DDECLTYPE_FLOAT16_2               = 15,
+    WINED3DDECLTYPE_FLOAT16_4               = 16,
+    WINED3DDECLTYPE_UNUSED                  = 17,
+} WINED3DDECLTYPE;
+cpp_quote("#define WINED3DDECL_END() {0xFF, 0, WINED3DDECLTYPE_UNUSED, 0, 0, 0, -1}")
+
+typedef enum _WINED3DDECLUSAGE
+{
+    WINED3DDECLUSAGE_POSITION               = 0,
+    WINED3DDECLUSAGE_BLENDWEIGHT            = 1,
+    WINED3DDECLUSAGE_BLENDINDICES           = 2,
+    WINED3DDECLUSAGE_NORMAL                 = 3,
+    WINED3DDECLUSAGE_PSIZE                  = 4,
+    WINED3DDECLUSAGE_TEXCOORD               = 5,
+    WINED3DDECLUSAGE_TANGENT                = 6,
+    WINED3DDECLUSAGE_BINORMAL               = 7,
+    WINED3DDECLUSAGE_TESSFACTOR             = 8,
+    WINED3DDECLUSAGE_POSITIONT              = 9,
+    WINED3DDECLUSAGE_COLOR                  = 10,
+    WINED3DDECLUSAGE_FOG                    = 11,
+    WINED3DDECLUSAGE_DEPTH                  = 12,
+    WINED3DDECLUSAGE_SAMPLE                 = 13
+} WINED3DDECLUSAGE;
+
+typedef enum _WINED3DSURFTYPE
+{
+    SURFACE_UNKNOWN                         = 0,    /* Default / Unknown surface type */
+    SURFACE_OPENGL,                                 /* OpenGL surface: Renders using libGL, needed for 3D */
+    SURFACE_GDI,                                    /* User surface. No 3D, DirectDraw rendering with GDI */
+} WINED3DSURFTYPE;
+
+const UINT WINED3DCOLORWRITEENABLE_RED                          = (1<<0);
+const UINT WINED3DCOLORWRITEENABLE_GREEN                        = (1<<1);
+const UINT WINED3DCOLORWRITEENABLE_BLUE                         = (1<<2);
+const UINT WINED3DCOLORWRITEENABLE_ALPHA                        = (1<<3);
+
+const UINT WINED3DADAPTER_DEFAULT                               = 0;
+const UINT WINED3DENUM_NO_WHQL_LEVEL                            = 2;
+const UINT WINED3DPRESENT_BACK_BUFFER_MAX                       = 3;
+
+const UINT WINED3DTSS_TCI_PASSTHRU                              = 0x00000;
+const UINT WINED3DTSS_TCI_CAMERASPACENORMAL                     = 0x10000;
+const UINT WINED3DTSS_TCI_CAMERASPACEPOSITION                   = 0x20000;
+const UINT WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR           = 0x30000;
+const UINT WINED3DTSS_TCI_SPHEREMAP                             = 0x40000;
+
+const UINT WINED3DTA_SELECTMASK                                 = 0x0000000f;
+const UINT WINED3DTA_DIFFUSE                                    = 0x00000000;
+const UINT WINED3DTA_CURRENT                                    = 0x00000001;
+const UINT WINED3DTA_TEXTURE                                    = 0x00000002;
+const UINT WINED3DTA_TFACTOR                                    = 0x00000003;
+const UINT WINED3DTA_SPECULAR                                   = 0x00000004;
+const UINT WINED3DTA_TEMP                                       = 0x00000005;
+const UINT WINED3DTA_CONSTANT                                   = 0x00000006;
+const UINT WINED3DTA_COMPLEMENT                                 = 0x00000010;
+const UINT WINED3DTA_ALPHAREPLICATE                             = 0x00000020;
+
+const UINT WINED3DPRESENTFLAG_LOCKABLE_BACKBUFFER               = 0x00000001;
+const UINT WINED3DPRESENTFLAG_DISCARD_DEPTHSTENCIL              = 0x00000002;
+const UINT WINED3DPRESENTFLAG_DEVICECLIP                        = 0x00000004;
+const UINT WINED3DPRESENTFLAG_VIDEO                             = 0x00000010;
+const UINT WINED3DPRESENTFLAG_NOAUTOROTATE                      = 0x00000020;
+const UINT WINED3DPRESENTFLAG_UNPRUNEDMODE                      = 0x00000040;
+
+const UINT WINED3DDP_MAXTEXCOORD                                = 8;
+
+const UINT WINED3DUSAGE_RENDERTARGET                            = 0x00000001;
+const UINT WINED3DUSAGE_DEPTHSTENCIL                            = 0x00000002;
+const UINT WINED3DUSAGE_WRITEONLY                               = 0x00000008;
+const UINT WINED3DUSAGE_SOFTWAREPROCESSING                      = 0x00000010;
+const UINT WINED3DUSAGE_DONOTCLIP                               = 0x00000020;
+const UINT WINED3DUSAGE_POINTS                                  = 0x00000040;
+const UINT WINED3DUSAGE_RTPATCHES                               = 0x00000080;
+const UINT WINED3DUSAGE_NPATCHES                                = 0x00000100;
+const UINT WINED3DUSAGE_DYNAMIC                                 = 0x00000200;
+const UINT WINED3DUSAGE_AUTOGENMIPMAP                           = 0x00000400;
+const UINT WINED3DUSAGE_DMAP                                    = 0x00004000;
+const UINT WINED3DUSAGE_MASK                                    = 0x00004fff;
+const UINT WINED3DUSAGE_OVERLAY                                 = 0x80000000;
+
+const UINT WINED3DUSAGE_QUERY_LEGACYBUMPMAP                     = 0x00008000;
+const UINT WINED3DUSAGE_QUERY_FILTER                            = 0x00020000;
+const UINT WINED3DUSAGE_QUERY_POSTPIXELSHADER_BLENDING          = 0x00080000;
+const UINT WINED3DUSAGE_QUERY_SRGBREAD                          = 0x00010000;
+const UINT WINED3DUSAGE_QUERY_SRGBWRITE                         = 0x00040000;
+const UINT WINED3DUSAGE_QUERY_VERTEXTEXTURE                     = 0x00100000;
+const UINT WINED3DUSAGE_QUERY_WRAPANDMIP                        = 0x00200000;
+const UINT WINED3DUSAGE_QUERY_MASK                              = 0x003f8000;
+
+const UINT WINED3DLOCK_READONLY                                 = 0x0010;
+const UINT WINED3DLOCK_NOSYSLOCK                                = 0x0800;
+const UINT WINED3DLOCK_NOOVERWRITE                              = 0x1000;
+const UINT WINED3DLOCK_DISCARD                                  = 0x2000;
+const UINT WINED3DLOCK_DONOTWAIT                                = 0x4000;
+const UINT WINED3DLOCK_NO_DIRTY_UPDATE                          = 0x8000;
+
+const UINT WINED3DPRESENT_RATE_DEFAULT                          = 0x000000000;
+
+const UINT WINED3DPRESENT_INTERVAL_DEFAULT                      = 0x00000000;
+const UINT WINED3DPRESENT_INTERVAL_ONE                          = 0x00000001;
+const UINT WINED3DPRESENT_INTERVAL_TWO                          = 0x00000002;
+const UINT WINED3DPRESENT_INTERVAL_THREE                        = 0x00000004;
+const UINT WINED3DPRESENT_INTERVAL_FOUR                         = 0x00000008;
+const UINT WINED3DPRESENT_INTERVAL_IMMEDIATE                    = 0x80000000;
+
+const UINT WINED3DMAXUSERCLIPPLANES                             = 32;
+const UINT WINED3DCLIPPLANE0                                    = (1 << 0);
+const UINT WINED3DCLIPPLANE1                                    = (1 << 1);
+const UINT WINED3DCLIPPLANE2                                    = (1 << 2);
+const UINT WINED3DCLIPPLANE3                                    = (1 << 3);
+const UINT WINED3DCLIPPLANE4                                    = (1 << 4);
+const UINT WINED3DCLIPPLANE5                                    = (1 << 5);
+
+/* FVF (Flexible Vertex Format) codes */
+const UINT WINED3DFVF_RESERVED0                                 = 0x0001;
+const UINT WINED3DFVF_POSITION_MASK                             = 0x000e;
+const UINT WINED3DFVF_XYZ                                       = 0x0002;
+const UINT WINED3DFVF_XYZRHW                                    = 0x0004;
+const UINT WINED3DFVF_XYZB1                                     = 0x0006;
+const UINT WINED3DFVF_XYZB2                                     = 0x0008;
+const UINT WINED3DFVF_XYZB3                                     = 0x000a;
+const UINT WINED3DFVF_XYZB4                                     = 0x000c;
+const UINT WINED3DFVF_XYZB5                                     = 0x000e;
+const UINT WINED3DFVF_XYZW                                      = 0x4002;
+const UINT WINED3DFVF_NORMAL                                    = 0x0010;
+const UINT WINED3DFVF_PSIZE                                     = 0x0020;
+const UINT WINED3DFVF_DIFFUSE                                   = 0x0040;
+const UINT WINED3DFVF_SPECULAR                                  = 0x0080;
+const UINT WINED3DFVF_TEXCOUNT_MASK                             = 0x0f00;
+const UINT WINED3DFVF_TEXCOUNT_SHIFT                            = 8;
+const UINT WINED3DFVF_TEX0                                      = 0x0000;
+const UINT WINED3DFVF_TEX1                                      = 0x0100;
+const UINT WINED3DFVF_TEX2                                      = 0x0200;
+const UINT WINED3DFVF_TEX3                                      = 0x0300;
+const UINT WINED3DFVF_TEX4                                      = 0x0400;
+const UINT WINED3DFVF_TEX5                                      = 0x0500;
+const UINT WINED3DFVF_TEX6                                      = 0x0600;
+const UINT WINED3DFVF_TEX7                                      = 0x0700;
+const UINT WINED3DFVF_TEX8                                      = 0x0800;
+const UINT WINED3DFVF_LASTBETA_UBYTE4                           = 0x1000;
+const UINT WINED3DFVF_LASTBETA_D3DCOLOR                         = 0x8000;
+const UINT WINED3DFVF_RESERVED2                                 = 0x6000;
+
+const UINT WINED3DFVF_TEXTUREFORMAT1                            = 3;
+const UINT WINED3DFVF_TEXTUREFORMAT2                            = 0;
+const UINT WINED3DFVF_TEXTUREFORMAT3                            = 1;
+const UINT WINED3DFVF_TEXTUREFORMAT4                            = 2;
+cpp_quote("#define WINED3DFVF_TEXCOORDSIZE1(CoordIndex) (WINED3DFVF_TEXTUREFORMAT1 << (CoordIndex*2 + 16))")
+cpp_quote("#define WINED3DFVF_TEXCOORDSIZE2(CoordIndex) (WINED3DFVF_TEXTUREFORMAT2)")
+cpp_quote("#define WINED3DFVF_TEXCOORDSIZE3(CoordIndex) (WINED3DFVF_TEXTUREFORMAT3 << (CoordIndex*2 + 16))")
+cpp_quote("#define WINED3DFVF_TEXCOORDSIZE4(CoordIndex) (WINED3DFVF_TEXTUREFORMAT4 << (CoordIndex*2 + 16))")
+
+/* Clear flags */
+const UINT WINED3DCLEAR_TARGET                                  = 0x00000001;
+const UINT WINED3DCLEAR_ZBUFFER                                 = 0x00000002;
+const UINT WINED3DCLEAR_STENCIL                                 = 0x00000004;
+
+/* Stream source flags */
+const UINT WINED3DSTREAMSOURCE_INDEXEDDATA                      = (1 << 30);
+const UINT WINED3DSTREAMSOURCE_INSTANCEDATA                     = (2 << 30);
+
+/* SetPrivateData flags */
+const UINT WINED3DSPD_IUNKNOWN                                  = 0x00000001;
+
+/* IWineD3D::CreateDevice behaviour flags */
+const UINT WINED3DCREATE_FPU_PRESERVE                           = 0x00000002;
+const UINT WINED3DCREATE_PUREDEVICE                             = 0x00000010;
+const UINT WINED3DCREATE_SOFTWARE_VERTEXPROCESSING              = 0x00000020;
+const UINT WINED3DCREATE_HARDWARE_VERTEXPROCESSING              = 0x00000040;
+const UINT WINED3DCREATE_MIXED_VERTEXPROCESSING                 = 0x00000080;
+const UINT WINED3DCREATE_DISABLE_DRIVER_MANAGEMENT              = 0x00000100;
+const UINT WINED3DCREATE_ADAPTERGROUP_DEVICE                    = 0x00000200;
+
+/* VTF defines */
+const UINT WINED3DDMAPSAMPLER                                   = 0x100;
+const UINT WINED3DVERTEXTEXTURESAMPLER0                         = (WINED3DDMAPSAMPLER + 1);
+const UINT WINED3DVERTEXTEXTURESAMPLER1                         = (WINED3DDMAPSAMPLER + 2);
+const UINT WINED3DVERTEXTEXTURESAMPLER2                         = (WINED3DDMAPSAMPLER + 3);
+const UINT WINED3DVERTEXTEXTURESAMPLER3                         = (WINED3DDMAPSAMPLER + 4);
+
+const UINT WINED3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD        = 0x00000020;
+const UINT WINED3DCAPS3_LINEAR_TO_SRGB_PRESENTATION             = 0x00000080;
+const UINT WINED3DCAPS3_COPY_TO_VIDMEM                          = 0x00000100;
+const UINT WINED3DCAPS3_COPY_TO_SYSTEMMEM                       = 0x00000200;
+const UINT WINED3DCAPS3_RESERVED                                = 0x8000001f;
+
+const UINT WINED3DDEVCAPS2_STREAMOFFSET                         = 0x00000001;
+const UINT WINED3DDEVCAPS2_DMAPNPATCH                           = 0x00000002;
+const UINT WINED3DDEVCAPS2_ADAPTIVETESSRTPATCH                  = 0x00000004;
+const UINT WINED3DDEVCAPS2_ADAPTIVETESSNPATCH                   = 0x00000008;
+const UINT WINED3DDEVCAPS2_CAN_STRETCHRECT_FROM_TEXTURES        = 0x00000010;
+const UINT WINED3DDEVCAPS2_PRESAMPLEDDMAPNPATCH                 = 0x00000020;
+const UINT WINED3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET   = 0x00000040;
+
+const UINT WINED3DDTCAPS_UBYTE4                                 = 0x00000001;
+const UINT WINED3DDTCAPS_UBYTE4N                                = 0x00000002;
+const UINT WINED3DDTCAPS_SHORT2N                                = 0x00000004;
+const UINT WINED3DDTCAPS_SHORT4N                                = 0x00000008;
+const UINT WINED3DDTCAPS_USHORT2N                               = 0x00000010;
+const UINT WINED3DDTCAPS_USHORT4N                               = 0x00000020;
+const UINT WINED3DDTCAPS_UDEC3                                  = 0x00000040;
+const UINT WINED3DDTCAPS_DEC3N                                  = 0x00000080;
+const UINT WINED3DDTCAPS_FLOAT16_2                              = 0x00000100;
+const UINT WINED3DDTCAPS_FLOAT16_4                              = 0x00000200;
+
+const UINT WINED3DFVFCAPS_TEXCOORDCOUNTMASK                     = 0x0000ffff;
+const UINT WINED3DFVFCAPS_DONOTSTRIPELEMENTS                    = 0x00080000;
+const UINT WINED3DFVFCAPS_PSIZE                                 = 0x00100000;
+
+const UINT WINED3DLINECAPS_TEXTURE                              = 0x00000001;
+const UINT WINED3DLINECAPS_ZTEST                                = 0x00000002;
+const UINT WINED3DLINECAPS_BLEND                                = 0x00000004;
+const UINT WINED3DLINECAPS_ALPHACMP                             = 0x00000008;
+const UINT WINED3DLINECAPS_FOG                                  = 0x00000010;
+const UINT WINED3DLINECAPS_ANTIALIAS                            = 0x00000020;
+
+const UINT WINED3DMAX30SHADERINSTRUCTIONS                       = 32768;
+const UINT WINED3DMIN30SHADERINSTRUCTIONS                       = 512;
+
+const UINT WINED3DPBLENDCAPS_ZERO                               = 0x00000001;
+const UINT WINED3DPBLENDCAPS_ONE                                = 0x00000002;
+const UINT WINED3DPBLENDCAPS_SRCCOLOR                           = 0x00000004;
+const UINT WINED3DPBLENDCAPS_INVSRCCOLOR                        = 0x00000008;
+const UINT WINED3DPBLENDCAPS_SRCALPHA                           = 0x00000010;
+const UINT WINED3DPBLENDCAPS_INVSRCALPHA                        = 0x00000020;
+const UINT WINED3DPBLENDCAPS_DESTALPHA                          = 0x00000040;
+const UINT WINED3DPBLENDCAPS_INVDESTALPHA                       = 0x00000080;
+const UINT WINED3DPBLENDCAPS_DESTCOLOR                          = 0x00000100;
+const UINT WINED3DPBLENDCAPS_INVDESTCOLOR                       = 0x00000200;
+const UINT WINED3DPBLENDCAPS_SRCALPHASAT                        = 0x00000400;
+const UINT WINED3DPBLENDCAPS_BOTHSRCALPHA                       = 0x00000800;
+const UINT WINED3DPBLENDCAPS_BOTHINVSRCALPHA                    = 0x00001000;
+const UINT WINED3DPBLENDCAPS_BLENDFACTOR                        = 0x00002000;
+
+const UINT WINED3DPCMPCAPS_NEVER                                = 0x00000001;
+const UINT WINED3DPCMPCAPS_LESS                                 = 0x00000002;
+const UINT WINED3DPCMPCAPS_EQUAL                                = 0x00000004;
+const UINT WINED3DPCMPCAPS_LESSEQUAL                            = 0x00000008;
+const UINT WINED3DPCMPCAPS_GREATER                              = 0x00000010;
+const UINT WINED3DPCMPCAPS_NOTEQUAL                             = 0x00000020;
+const UINT WINED3DPCMPCAPS_GREATEREQUAL                         = 0x00000040;
+const UINT WINED3DPCMPCAPS_ALWAYS                               = 0x00000080;
+
+const UINT WINED3DPMISCCAPS_MASKZ                               = 0x00000002;
+const UINT WINED3DPMISCCAPS_LINEPATTERNREP                      = 0x00000004;
+const UINT WINED3DPMISCCAPS_CULLNONE                            = 0x00000010;
+const UINT WINED3DPMISCCAPS_CULLCW                              = 0x00000020;
+const UINT WINED3DPMISCCAPS_CULLCCW                             = 0x00000040;
+const UINT WINED3DPMISCCAPS_COLORWRITEENABLE                    = 0x00000080;
+const UINT WINED3DPMISCCAPS_CLIPPLANESCALEDPOINTS               = 0x00000100;
+const UINT WINED3DPMISCCAPS_CLIPTLVERTS                         = 0x00000200;
+const UINT WINED3DPMISCCAPS_TSSARGTEMP                          = 0x00000400;
+const UINT WINED3DPMISCCAPS_BLENDOP                             = 0x00000800;
+const UINT WINED3DPMISCCAPS_NULLREFERENCE                       = 0x00001000;
+const UINT WINED3DPMISCCAPS_INDEPENDENTWRITEMASKS               = 0x00004000;
+const UINT WINED3DPMISCCAPS_PERSTAGECONSTANT                    = 0x00008000;
+const UINT WINED3DPMISCCAPS_FOGANDSPECULARALPHA                 = 0x00010000;
+const UINT WINED3DPMISCCAPS_SEPARATEALPHABLEND                  = 0x00020000;
+const UINT WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS             = 0x00040000;
+const UINT WINED3DPMISCCAPS_MRTPOSTPIXELSHADERBLENDING          = 0x00080000;
+const UINT WINED3DPMISCCAPS_FOGVERTEXCLAMPED                    = 0x00100000;
+
+const UINT WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH              = 24;
+const UINT WINED3DPS20_MIN_DYNAMICFLOWCONTROLDEPTH              = 0;
+const UINT WINED3DPS20_MAX_NUMTEMPS                             = 32;
+const UINT WINED3DPS20_MIN_NUMTEMPS                             = 12;
+const UINT WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH               = 4;
+const UINT WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH               = 0;
+const UINT WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS                  = 512;
+const UINT WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS                  = 96;
+
+const UINT WINED3DPS20CAPS_ARBITRARYSWIZZLE                     = 0x00000001;
+const UINT WINED3DPS20CAPS_GRADIENTINSTRUCTIONS                 = 0x00000002;
+const UINT WINED3DPS20CAPS_PREDICATION                          = 0x00000004;
+const UINT WINED3DPS20CAPS_NODEPENDENTREADLIMIT                 = 0x00000008;
+const UINT WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT                = 0x00000010;
+
+const UINT WINED3DPTADDRESSCAPS_WRAP                            = 0x00000001;
+const UINT WINED3DPTADDRESSCAPS_MIRROR                          = 0x00000002;
+const UINT WINED3DPTADDRESSCAPS_CLAMP                           = 0x00000004;
+const UINT WINED3DPTADDRESSCAPS_BORDER                          = 0x00000008;
+const UINT WINED3DPTADDRESSCAPS_INDEPENDENTUV                   = 0x00000010;
+const UINT WINED3DPTADDRESSCAPS_MIRRORONCE                      = 0x00000020;
+
+const UINT WINED3DSTENCILCAPS_KEEP                              = 0x00000001;
+const UINT WINED3DSTENCILCAPS_ZERO                              = 0x00000002;
+const UINT WINED3DSTENCILCAPS_REPLACE                           = 0x00000004;
+const UINT WINED3DSTENCILCAPS_INCRSAT                           = 0x00000008;
+const UINT WINED3DSTENCILCAPS_DECRSAT                           = 0x00000010;
+const UINT WINED3DSTENCILCAPS_INVERT                            = 0x00000020;
+const UINT WINED3DSTENCILCAPS_INCR                              = 0x00000040;
+const UINT WINED3DSTENCILCAPS_DECR                              = 0x00000080;
+const UINT WINED3DSTENCILCAPS_TWOSIDED                          = 0x00000100;
+
+const UINT WINED3DTEXOPCAPS_DISABLE                             = 0x00000001;
+const UINT WINED3DTEXOPCAPS_SELECTARG1                          = 0x00000002;
+const UINT WINED3DTEXOPCAPS_SELECTARG2                          = 0x00000004;
+const UINT WINED3DTEXOPCAPS_MODULATE                            = 0x00000008;
+const UINT WINED3DTEXOPCAPS_MODULATE2X                          = 0x00000010;
+const UINT WINED3DTEXOPCAPS_MODULATE4X                          = 0x00000020;
+const UINT WINED3DTEXOPCAPS_ADD                                 = 0x00000040;
+const UINT WINED3DTEXOPCAPS_ADDSIGNED                           = 0x00000080;
+const UINT WINED3DTEXOPCAPS_ADDSIGNED2X                         = 0x00000100;
+const UINT WINED3DTEXOPCAPS_SUBTRACT                            = 0x00000200;
+const UINT WINED3DTEXOPCAPS_ADDSMOOTH                           = 0x00000400;
+const UINT WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA                   = 0x00000800;
+const UINT WINED3DTEXOPCAPS_BLENDTEXTUREALPHA                   = 0x00001000;
+const UINT WINED3DTEXOPCAPS_BLENDFACTORALPHA                    = 0x00002000;
+const UINT WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM                 = 0x00004000;
+const UINT WINED3DTEXOPCAPS_BLENDCURRENTALPHA                   = 0x00008000;
+const UINT WINED3DTEXOPCAPS_PREMODULATE                         = 0x00010000;
+const UINT WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR              = 0x00020000;
+const UINT WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA              = 0x00040000;
+const UINT WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR           = 0x00080000;
+const UINT WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA           = 0x00100000;
+const UINT WINED3DTEXOPCAPS_BUMPENVMAP                          = 0x00200000;
+const UINT WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE                 = 0x00400000;
+const UINT WINED3DTEXOPCAPS_DOTPRODUCT3                         = 0x00800000;
+const UINT WINED3DTEXOPCAPS_MULTIPLYADD                         = 0x01000000;
+const UINT WINED3DTEXOPCAPS_LERP                                = 0x02000000;
+
+const UINT WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH              = 24;
+const UINT WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH              = 0;
+const UINT WINED3DVS20_MAX_NUMTEMPS                             = 32;
+const UINT WINED3DVS20_MIN_NUMTEMPS                             = 12;
+const UINT WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH               = 4;
+const UINT WINED3DVS20_MIN_STATICFLOWCONTROLDEPTH               = 1;
+
+const UINT WINED3DVS20CAPS_PREDICATION                          = 0x00000001;
+
+const UINT WINED3DCAPS2_NO2DDURING3DSCENE                       = 0x00000002;
+const UINT WINED3DCAPS2_FULLSCREENGAMMA                         = 0x00020000;
+const UINT WINED3DCAPS2_CANRENDERWINDOWED                       = 0x00080000;
+const UINT WINED3DCAPS2_CANCALIBRATEGAMMA                       = 0x00100000;
+const UINT WINED3DCAPS2_RESERVED                                = 0x02000000;
+const UINT WINED3DCAPS2_CANMANAGERESOURCE                       = 0x10000000;
+const UINT WINED3DCAPS2_DYNAMICTEXTURES                         = 0x20000000;
+const UINT WINED3DCAPS2_CANAUTOGENMIPMAP                        = 0x40000000;
+
+const UINT WINED3DPRASTERCAPS_DITHER                            = 0x00000001;
+const UINT WINED3DPRASTERCAPS_ROP2                              = 0x00000002;
+const UINT WINED3DPRASTERCAPS_XOR                               = 0x00000004;
+const UINT WINED3DPRASTERCAPS_PAT                               = 0x00000008;
+const UINT WINED3DPRASTERCAPS_ZTEST                             = 0x00000010;
+const UINT WINED3DPRASTERCAPS_SUBPIXEL                          = 0x00000020;
+const UINT WINED3DPRASTERCAPS_SUBPIXELX                         = 0x00000040;
+const UINT WINED3DPRASTERCAPS_FOGVERTEX                         = 0x00000080;
+const UINT WINED3DPRASTERCAPS_FOGTABLE                          = 0x00000100;
+const UINT WINED3DPRASTERCAPS_STIPPLE                           = 0x00000200;
+const UINT WINED3DPRASTERCAPS_ANTIALIASSORTDEPENDENT            = 0x00000400;
+const UINT WINED3DPRASTERCAPS_ANTIALIASSORTINDEPENDENT          = 0x00000800;
+const UINT WINED3DPRASTERCAPS_ANTIALIASEDGES                    = 0x00001000;
+const UINT WINED3DPRASTERCAPS_MIPMAPLODBIAS                     = 0x00002000;
+const UINT WINED3DPRASTERCAPS_ZBIAS                             = 0x00004000;
+const UINT WINED3DPRASTERCAPS_ZBUFFERLESSHSR                    = 0x00008000;
+const UINT WINED3DPRASTERCAPS_FOGRANGE                          = 0x00010000;
+const UINT WINED3DPRASTERCAPS_ANISOTROPY                        = 0x00020000;
+const UINT WINED3DPRASTERCAPS_WBUFFER                           = 0x00040000;
+const UINT WINED3DPRASTERCAPS_TRANSLUCENTSORTINDEPENDENT        = 0x00080000;
+const UINT WINED3DPRASTERCAPS_WFOG                              = 0x00100000;
+const UINT WINED3DPRASTERCAPS_ZFOG                              = 0x00200000;
+const UINT WINED3DPRASTERCAPS_COLORPERSPECTIVE                  = 0x00400000;
+const UINT WINED3DPRASTERCAPS_SCISSORTEST                       = 0x01000000;
+const UINT WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS               = 0x02000000;
+const UINT WINED3DPRASTERCAPS_DEPTHBIAS                         = 0x04000000;
+const UINT WINED3DPRASTERCAPS_MULTISAMPLE_TOGGLE                = 0x08000000;
+
+const UINT WINED3DPSHADECAPS_COLORFLATMONO                      = 0x00000001;
+const UINT WINED3DPSHADECAPS_COLORFLATRGB                       = 0x00000002;
+const UINT WINED3DPSHADECAPS_COLORGOURAUDMONO                   = 0x00000004;
+const UINT WINED3DPSHADECAPS_COLORGOURAUDRGB                    = 0x00000008;
+const UINT WINED3DPSHADECAPS_COLORPHONGMONO                     = 0x00000010;
+const UINT WINED3DPSHADECAPS_COLORPHONGRGB                      = 0x00000020;
+const UINT WINED3DPSHADECAPS_SPECULARFLATMONO                   = 0x00000040;
+const UINT WINED3DPSHADECAPS_SPECULARFLATRGB                    = 0x00000080;
+const UINT WINED3DPSHADECAPS_SPECULARGOURAUDMONO                = 0x00000100;
+const UINT WINED3DPSHADECAPS_SPECULARGOURAUDRGB                 = 0x00000200;
+const UINT WINED3DPSHADECAPS_SPECULARPHONGMONO                  = 0x00000400;
+const UINT WINED3DPSHADECAPS_SPECULARPHONGRGB                   = 0x00000800;
+const UINT WINED3DPSHADECAPS_ALPHAFLATBLEND                     = 0x00001000;
+const UINT WINED3DPSHADECAPS_ALPHAFLATSTIPPLED                  = 0x00002000;
+const UINT WINED3DPSHADECAPS_ALPHAGOURAUDBLEND                  = 0x00004000;
+const UINT WINED3DPSHADECAPS_ALPHAGOURAUDSTIPPLED               = 0x00008000;
+const UINT WINED3DPSHADECAPS_ALPHAPHONGBLEND                    = 0x00010000;
+const UINT WINED3DPSHADECAPS_ALPHAPHONGSTIPPLED                 = 0x00020000;
+const UINT WINED3DPSHADECAPS_FOGFLAT                            = 0x00040000;
+const UINT WINED3DPSHADECAPS_FOGGOURAUD                         = 0x00080000;
+const UINT WINED3DPSHADECAPS_FOGPHONG                           = 0x00100000;
+
+const UINT WINED3DPTEXTURECAPS_PERSPECTIVE                      = 0x00000001;
+const UINT WINED3DPTEXTURECAPS_POW2                             = 0x00000002;
+const UINT WINED3DPTEXTURECAPS_ALPHA                            = 0x00000004;
+const UINT WINED3DPTEXTURECAPS_TRANSPARENCY                     = 0x00000008;
+const UINT WINED3DPTEXTURECAPS_BORDER                           = 0x00000010;
+const UINT WINED3DPTEXTURECAPS_SQUAREONLY                       = 0x00000020;
+const UINT WINED3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE         = 0x00000040;
+const UINT WINED3DPTEXTURECAPS_ALPHAPALETTE                     = 0x00000080;
+const UINT WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL               = 0x00000100;
+const UINT WINED3DPTEXTURECAPS_PROJECTED                        = 0x00000400;
+const UINT WINED3DPTEXTURECAPS_CUBEMAP                          = 0x00000800;
+const UINT WINED3DPTEXTURECAPS_COLORKEYBLEND                    = 0x00001000;
+const UINT WINED3DPTEXTURECAPS_VOLUMEMAP                        = 0x00002000;
+const UINT WINED3DPTEXTURECAPS_MIPMAP                           = 0x00004000;
+const UINT WINED3DPTEXTURECAPS_MIPVOLUMEMAP                     = 0x00008000;
+const UINT WINED3DPTEXTURECAPS_MIPCUBEMAP                       = 0x00010000;
+const UINT WINED3DPTEXTURECAPS_CUBEMAP_POW2                     = 0x00020000;
+const UINT WINED3DPTEXTURECAPS_VOLUMEMAP_POW2                   = 0x00040000;
+const UINT WINED3DPTEXTURECAPS_NOPROJECTEDBUMPENV               = 0x00200000;
+
+const UINT WINED3DPTFILTERCAPS_NEAREST                          = 0x00000001;
+const UINT WINED3DPTFILTERCAPS_LINEAR                           = 0x00000002;
+const UINT WINED3DPTFILTERCAPS_MIPNEAREST                       = 0x00000004;
+const UINT WINED3DPTFILTERCAPS_MIPLINEAR                        = 0x00000008;
+const UINT WINED3DPTFILTERCAPS_LINEARMIPNEAREST                 = 0x00000010;
+const UINT WINED3DPTFILTERCAPS_LINEARMIPLINEAR                  = 0x00000020;
+const UINT WINED3DPTFILTERCAPS_MINFPOINT                        = 0x00000100;
+const UINT WINED3DPTFILTERCAPS_MINFLINEAR                       = 0x00000200;
+const UINT WINED3DPTFILTERCAPS_MINFANISOTROPIC                  = 0x00000400;
+const UINT WINED3DPTFILTERCAPS_MIPFPOINT                        = 0x00010000;
+const UINT WINED3DPTFILTERCAPS_MIPFLINEAR                       = 0x00020000;
+const UINT WINED3DPTFILTERCAPS_MAGFPOINT                        = 0x01000000;
+const UINT WINED3DPTFILTERCAPS_MAGFLINEAR                       = 0x02000000;
+const UINT WINED3DPTFILTERCAPS_MAGFANISOTROPIC                  = 0x04000000;
+const UINT WINED3DPTFILTERCAPS_MAGFPYRAMIDALQUAD                = 0x08000000;
+const UINT WINED3DPTFILTERCAPS_MAGFGAUSSIANQUAD                 = 0x10000000;
+
+const UINT WINED3DVTXPCAPS_TEXGEN                               = 0x00000001;
+const UINT WINED3DVTXPCAPS_MATERIALSOURCE7                      = 0x00000002;
+const UINT WINED3DVTXPCAPS_VERTEXFOG                            = 0x00000004;
+const UINT WINED3DVTXPCAPS_DIRECTIONALLIGHTS                    = 0x00000008;
+const UINT WINED3DVTXPCAPS_POSITIONALLIGHTS                     = 0x00000010;
+const UINT WINED3DVTXPCAPS_LOCALVIEWER                          = 0x00000020;
+const UINT WINED3DVTXPCAPS_TWEENING                             = 0x00000040;
+const UINT WINED3DVTXPCAPS_TEXGEN_SPHEREMAP                     = 0x00000100;
+const UINT WINED3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER             = 0x00000200;
+
+const UINT WINED3DCURSORCAPS_COLOR                              = 0x00000001;
+const UINT WINED3DCURSORCAPS_LOWRES                             = 0x00000002;
+
+const UINT WINED3DDEVCAPS_FLOATTLVERTEX                         = 0x00000001;
+const UINT WINED3DDEVCAPS_SORTINCREASINGZ                       = 0x00000002;
+const UINT WINED3DDEVCAPS_SORTDECREASINGZ                       = 0X00000004;
+const UINT WINED3DDEVCAPS_SORTEXACT                             = 0x00000008;
+const UINT WINED3DDEVCAPS_EXECUTESYSTEMMEMORY                   = 0x00000010;
+const UINT WINED3DDEVCAPS_EXECUTEVIDEOMEMORY                    = 0x00000020;
+const UINT WINED3DDEVCAPS_TLVERTEXSYSTEMMEMORY                  = 0x00000040;
+const UINT WINED3DDEVCAPS_TLVERTEXVIDEOMEMORY                   = 0x00000080;
+const UINT WINED3DDEVCAPS_TEXTURESYSTEMMEMORY                   = 0x00000100;
+const UINT WINED3DDEVCAPS_TEXTUREVIDEOMEMORY                    = 0x00000200;
+const UINT WINED3DDEVCAPS_DRAWPRIMTLVERTEX                      = 0x00000400;
+const UINT WINED3DDEVCAPS_CANRENDERAFTERFLIP                    = 0x00000800;
+const UINT WINED3DDEVCAPS_TEXTURENONLOCALVIDMEM                 = 0x00001000;
+const UINT WINED3DDEVCAPS_DRAWPRIMITIVES2                       = 0x00002000;
+const UINT WINED3DDEVCAPS_SEPARATETEXTUREMEMORIES               = 0x00004000;
+const UINT WINED3DDEVCAPS_DRAWPRIMITIVES2EX                     = 0x00008000;
+const UINT WINED3DDEVCAPS_HWTRANSFORMANDLIGHT                   = 0x00010000;
+const UINT WINED3DDEVCAPS_CANBLTSYSTONONLOCAL                   = 0x00020000;
+const UINT WINED3DDEVCAPS_HWRASTERIZATION                       = 0x00080000;
+const UINT WINED3DDEVCAPS_PUREDEVICE                            = 0x00100000;
+const UINT WINED3DDEVCAPS_QUINTICRTPATCHES                      = 0x00200000;
+const UINT WINED3DDEVCAPS_RTPATCHES                             = 0x00400000;
+const UINT WINED3DDEVCAPS_RTPATCHHANDLEZERO                     = 0x00800000;
+const UINT WINED3DDEVCAPS_NPATCHES                              = 0x01000000;
+
+/* dwDDFX */
+/* arithmetic stretching along y axis */
+const UINT WINEDDBLTFX_ARITHSTRETCHY                            = 0x00000001;
+/* mirror on y axis */
+const UINT WINEDDBLTFX_MIRRORLEFTRIGHT                          = 0x00000002;
+/* mirror on x axis */
+const UINT WINEDDBLTFX_MIRRORUPDOWN                             = 0x00000004;
+/* do not tear */
+const UINT WINEDDBLTFX_NOTEARING                                = 0x00000008;
+/* 180 degrees clockwise rotation */
+const UINT WINEDDBLTFX_ROTATE180                                = 0x00000010;
+/* 270 degrees clockwise rotation */
+const UINT WINEDDBLTFX_ROTATE270                                = 0x00000020;
+/* 90 degrees clockwise rotation */
+const UINT WINEDDBLTFX_ROTATE90                                 = 0x00000040;
+/* dwZBufferLow and dwZBufferHigh specify limits to the copied Z values */
+const UINT WINEDDBLTFX_ZBUFFERRANGE                             = 0x00000080;
+/* add dwZBufferBaseDest to every source z value before compare */
+const UINT WINEDDBLTFX_ZBUFFERBASEDEST                          = 0x00000100;
+
+/* dwFlags for Blt* */
+const UINT WINEDDBLT_ALPHADEST                                  = 0x00000001;
+const UINT WINEDDBLT_ALPHADESTCONSTOVERRIDE                     = 0x00000002;
+const UINT WINEDDBLT_ALPHADESTNEG                               = 0x00000004;
+const UINT WINEDDBLT_ALPHADESTSURFACEOVERRIDE                   = 0x00000008;
+const UINT WINEDDBLT_ALPHAEDGEBLEND                             = 0x00000010;
+const UINT WINEDDBLT_ALPHASRC                                   = 0x00000020;
+const UINT WINEDDBLT_ALPHASRCCONSTOVERRIDE                      = 0x00000040;
+const UINT WINEDDBLT_ALPHASRCNEG                                = 0x00000080;
+const UINT WINEDDBLT_ALPHASRCSURFACEOVERRIDE                    = 0x00000100;
+const UINT WINEDDBLT_ASYNC                                      = 0x00000200;
+const UINT WINEDDBLT_COLORFILL                                  = 0x00000400;
+const UINT WINEDDBLT_DDFX                                       = 0x00000800;
+const UINT WINEDDBLT_DDROPS                                     = 0x00001000;
+const UINT WINEDDBLT_KEYDEST                                    = 0x00002000;
+const UINT WINEDDBLT_KEYDESTOVERRIDE                            = 0x00004000;
+const UINT WINEDDBLT_KEYSRC                                     = 0x00008000;
+const UINT WINEDDBLT_KEYSRCOVERRIDE                             = 0x00010000;
+const UINT WINEDDBLT_ROP                                        = 0x00020000;
+const UINT WINEDDBLT_ROTATIONANGLE                              = 0x00040000;
+const UINT WINEDDBLT_ZBUFFER                                    = 0x00080000;
+const UINT WINEDDBLT_ZBUFFERDESTCONSTOVERRIDE                   = 0x00100000;
+const UINT WINEDDBLT_ZBUFFERDESTOVERRIDE                        = 0x00200000;
+const UINT WINEDDBLT_ZBUFFERSRCCONSTOVERRIDE                    = 0x00400000;
+const UINT WINEDDBLT_ZBUFFERSRCOVERRIDE                         = 0x00800000;
+const UINT WINEDDBLT_WAIT                                       = 0x01000000;
+const UINT WINEDDBLT_DEPTHFILL                                  = 0x02000000;
+const UINT WINEDDBLT_DONOTWAIT                                  = 0x08000000;
+
+/* dwTrans for BltFast */
+const UINT WINEDDBLTFAST_NOCOLORKEY                             = 0x00000000;
+const UINT WINEDDBLTFAST_SRCCOLORKEY                            = 0x00000001;
+const UINT WINEDDBLTFAST_DESTCOLORKEY                           = 0x00000002;
+const UINT WINEDDBLTFAST_WAIT                                   = 0x00000010;
+const UINT WINEDDBLTFAST_DONOTWAIT                              = 0x00000020;
+
+/* DDSURFACEDESC.dwFlags */
+const UINT WINEDDSD_CAPS                                        = 0x00000001;
+const UINT WINEDDSD_HEIGHT                                      = 0x00000002;
+const UINT WINEDDSD_WIDTH                                       = 0x00000004;
+const UINT WINEDDSD_PITCH                                       = 0x00000008;
+const UINT WINEDDSD_BACKBUFFERCOUNT                             = 0x00000020;
+const UINT WINEDDSD_ZBUFFERBITDEPTH                             = 0x00000040;
+const UINT WINEDDSD_ALPHABITDEPTH                               = 0x00000080;
+const UINT WINEDDSD_LPSURFACE                                   = 0x00000800;
+const UINT WINEDDSD_PIXELFORMAT                                 = 0x00001000;
+const UINT WINEDDSD_CKDESTOVERLAY                               = 0x00002000;
+const UINT WINEDDSD_CKDESTBLT                                   = 0x00004000;
+const UINT WINEDDSD_CKSRCOVERLAY                                = 0x00008000;
+const UINT WINEDDSD_CKSRCBLT                                    = 0x00010000;
+const UINT WINEDDSD_MIPMAPCOUNT                                 = 0x00020000;
+const UINT WINEDDSD_REFRESHRATE                                 = 0x00040000;
+const UINT WINEDDSD_LINEARSIZE                                  = 0x00080000;
+const UINT WINEDDSD_TEXTURESTAGE                                = 0x00100000;
+const UINT WINEDDSD_FVF                                         = 0x00200000;
+const UINT WINEDDSD_SRCVBHANDLE                                 = 0x00400000;
+const UINT WINEDDSD_ALL                                         = 0x007ff9ee;
+
+/* Set/Get Colour Key Flags */
+const UINT WINEDDCKEY_COLORSPACE                                = 0x00000001; /* Struct is single colour space */
+const UINT WINEDDCKEY_DESTBLT                                   = 0x00000002; /* To be used as dest for blt */
+const UINT WINEDDCKEY_DESTOVERLAY                               = 0x00000004; /* To be used as dest for CK overlays */
+const UINT WINEDDCKEY_SRCBLT                                    = 0x00000008; /* To be used as src for blt */
+const UINT WINEDDCKEY_SRCOVERLAY                                = 0x00000010; /* To be used as src for CK overlays */
+
+/* dwFlags for GetBltStatus */
+const UINT WINEDDGBS_CANBLT                                     = 0x00000001;
+const UINT WINEDDGBS_ISBLTDONE                                  = 0x00000002;
+
+/* dwFlags for GetFlipStatus */
+const UINT WINEDDGFS_CANFLIP                                    = 0x00000001;
+const UINT WINEDDGFS_ISFLIPDONE                                 = 0x00000002;
+
+/* dwFlags for Flip */
+const UINT WINEDDFLIP_WAIT                                      = 0x00000001;
+const UINT WINEDDFLIP_EVEN                                      = 0x00000002; /* only valid for overlay */
+const UINT WINEDDFLIP_ODD                                       = 0x00000004; /* only valid for overlay */
+const UINT WINEDDFLIP_NOVSYNC                                   = 0x00000008;
+const UINT WINEDDFLIP_STEREO                                    = 0x00000010;
+const UINT WINEDDFLIP_DONOTWAIT                                 = 0x00000020;
+const UINT WINEDDFLIP_INTERVAL2                                 = 0x02000000;
+const UINT WINEDDFLIP_INTERVAL3                                 = 0x03000000;
+const UINT WINEDDFLIP_INTERVAL4                                 = 0x04000000;
+
+const UINT WINEDDOVER_ALPHADEST                                 = 0x00000001;
+const UINT WINEDDOVER_ALPHADESTCONSTOVERRIDE                    = 0x00000002;
+const UINT WINEDDOVER_ALPHADESTNEG                              = 0x00000004;
+const UINT WINEDDOVER_ALPHADESTSURFACEOVERRIDE                  = 0x00000008;
+const UINT WINEDDOVER_ALPHAEDGEBLEND                            = 0x00000010;
+const UINT WINEDDOVER_ALPHASRC                                  = 0x00000020;
+const UINT WINEDDOVER_ALPHASRCCONSTOVERRIDE                     = 0x00000040;
+const UINT WINEDDOVER_ALPHASRCNEG                               = 0x00000080;
+const UINT WINEDDOVER_ALPHASRCSURFACEOVERRIDE                   = 0x00000100;
+const UINT WINEDDOVER_HIDE                                      = 0x00000200;
+const UINT WINEDDOVER_KEYDEST                                   = 0x00000400;
+const UINT WINEDDOVER_KEYDESTOVERRIDE                           = 0x00000800;
+const UINT WINEDDOVER_KEYSRC                                    = 0x00001000;
+const UINT WINEDDOVER_KEYSRCOVERRIDE                            = 0x00002000;
+const UINT WINEDDOVER_SHOW                                      = 0x00004000;
+const UINT WINEDDOVER_ADDDIRTYRECT                              = 0x00008000;
+const UINT WINEDDOVER_REFRESHDIRTYRECTS                         = 0x00010000;
+const UINT WINEDDOVER_REFRESHALL                                = 0x00020000;
+const UINT WINEDDOVER_DDFX                                      = 0x00080000;
+const UINT WINEDDOVER_AUTOFLIP                                  = 0x00100000;
+const UINT WINEDDOVER_BOB                                       = 0x00200000;
+const UINT WINEDDOVER_OVERRIDEBOBWEAVE                          = 0x00400000;
+const UINT WINEDDOVER_INTERLEAVED                               = 0x00800000;
+
+/* DirectDraw Caps */
+const UINT WINEDDSCAPS_RESERVED1                                = 0x00000001;
+const UINT WINEDDSCAPS_ALPHA                                    = 0x00000002;
+const UINT WINEDDSCAPS_BACKBUFFER                               = 0x00000004;
+const UINT WINEDDSCAPS_COMPLEX                                  = 0x00000008;
+const UINT WINEDDSCAPS_FLIP                                     = 0x00000010;
+const UINT WINEDDSCAPS_FRONTBUFFER                              = 0x00000020;
+const UINT WINEDDSCAPS_OFFSCREENPLAIN                           = 0x00000040;
+const UINT WINEDDSCAPS_OVERLAY                                  = 0x00000080;
+const UINT WINEDDSCAPS_PALETTE                                  = 0x00000100;
+const UINT WINEDDSCAPS_PRIMARYSURFACE                           = 0x00000200;
+const UINT WINEDDSCAPS_PRIMARYSURFACELEFT                       = 0x00000400;
+const UINT WINEDDSCAPS_SYSTEMMEMORY                             = 0x00000800;
+const UINT WINEDDSCAPS_TEXTURE                                  = 0x00001000;
+const UINT WINEDDSCAPS_3DDEVICE                                 = 0x00002000;
+const UINT WINEDDSCAPS_VIDEOMEMORY                              = 0x00004000;
+const UINT WINEDDSCAPS_VISIBLE                                  = 0x00008000;
+const UINT WINEDDSCAPS_WRITEONLY                                = 0x00010000;
+const UINT WINEDDSCAPS_ZBUFFER                                  = 0x00020000;
+const UINT WINEDDSCAPS_OWNDC                                    = 0x00040000;
+const UINT WINEDDSCAPS_LIVEVIDEO                                = 0x00080000;
+const UINT WINEDDSCAPS_HWCODEC                                  = 0x00100000;
+const UINT WINEDDSCAPS_MODEX                                    = 0x00200000;
+const UINT WINEDDSCAPS_MIPMAP                                   = 0x00400000;
+const UINT WINEDDSCAPS_RESERVED2                                = 0x00800000;
+const UINT WINEDDSCAPS_ALLOCONLOAD                              = 0x04000000;
+const UINT WINEDDSCAPS_VIDEOPORT                                = 0x08000000;
+const UINT WINEDDSCAPS_LOCALVIDMEM                              = 0x10000000;
+const UINT WINEDDSCAPS_NONLOCALVIDMEM                           = 0x20000000;
+const UINT WINEDDSCAPS_STANDARDVGAMODE                          = 0x40000000;
+const UINT WINEDDSCAPS_OPTIMIZED                                = 0x80000000;
+
+const UINT WINEDDCKEYCAPS_DESTBLT                               = 0x00000001;
+const UINT WINEDDCKEYCAPS_DESTBLTCLRSPACE                       = 0x00000002;
+const UINT WINEDDCKEYCAPS_DESTBLTCLRSPACEYUV                    = 0x00000004;
+const UINT WINEDDCKEYCAPS_DESTBLTYUV                            = 0x00000008;
+const UINT WINEDDCKEYCAPS_DESTOVERLAY                           = 0x00000010;
+const UINT WINEDDCKEYCAPS_DESTOVERLAYCLRSPACE                   = 0x00000020;
+const UINT WINEDDCKEYCAPS_DESTOVERLAYCLRSPACEYUV                = 0x00000040;
+const UINT WINEDDCKEYCAPS_DESTOVERLAYONEACTIVE                  = 0x00000080;
+const UINT WINEDDCKEYCAPS_DESTOVERLAYYUV                        = 0x00000100;
+const UINT WINEDDCKEYCAPS_SRCBLT                                = 0x00000200;
+const UINT WINEDDCKEYCAPS_SRCBLTCLRSPACE                        = 0x00000400;
+const UINT WINEDDCKEYCAPS_SRCBLTCLRSPACEYUV                     = 0x00000800;
+const UINT WINEDDCKEYCAPS_SRCBLTYUV                             = 0x00001000;
+const UINT WINEDDCKEYCAPS_SRCOVERLAY                            = 0x00002000;
+const UINT WINEDDCKEYCAPS_SRCOVERLAYCLRSPACE                    = 0x00004000;
+const UINT WINEDDCKEYCAPS_SRCOVERLAYCLRSPACEYUV                 = 0x00008000;
+const UINT WINEDDCKEYCAPS_SRCOVERLAYONEACTIVE                   = 0x00010000;
+const UINT WINEDDCKEYCAPS_SRCOVERLAYYUV                         = 0x00020000;
+const UINT WINEDDCKEYCAPS_NOCOSTOVERLAY                         = 0x00040000;
+
+const UINT WINEDDFXCAPS_BLTALPHA                                = 0x00000001;
+const UINT WINEDDFXCAPS_OVERLAYALPHA                            = 0x00000004;
+const UINT WINEDDFXCAPS_BLTARITHSTRETCHYN                       = 0x00000010;
+const UINT WINEDDFXCAPS_BLTARITHSTRETCHY                        = 0x00000020;
+const UINT WINEDDFXCAPS_BLTMIRRORLEFTRIGHT                      = 0x00000040;
+const UINT WINEDDFXCAPS_BLTMIRRORUPDOWN                         = 0x00000080;
+const UINT WINEDDFXCAPS_BLTROTATION                             = 0x00000100;
+const UINT WINEDDFXCAPS_BLTROTATION90                           = 0x00000200;
+const UINT WINEDDFXCAPS_BLTSHRINKX                              = 0x00000400;
+const UINT WINEDDFXCAPS_BLTSHRINKXN                             = 0x00000800;
+const UINT WINEDDFXCAPS_BLTSHRINKY                              = 0x00001000;
+const UINT WINEDDFXCAPS_BLTSHRINKYN                             = 0x00002000;
+const UINT WINEDDFXCAPS_BLTSTRETCHX                             = 0x00004000;
+const UINT WINEDDFXCAPS_BLTSTRETCHXN                            = 0x00008000;
+const UINT WINEDDFXCAPS_BLTSTRETCHY                             = 0x00010000;
+const UINT WINEDDFXCAPS_BLTSTRETCHYN                            = 0x00020000;
+const UINT WINEDDFXCAPS_OVERLAYARITHSTRETCHY                    = 0x00040000;
+const UINT WINEDDFXCAPS_OVERLAYARITHSTRETCHYN                   = 0x00000008;
+const UINT WINEDDFXCAPS_OVERLAYSHRINKX                          = 0x00080000;
+const UINT WINEDDFXCAPS_OVERLAYSHRINKXN                         = 0x00100000;
+const UINT WINEDDFXCAPS_OVERLAYSHRINKY                          = 0x00200000;
+const UINT WINEDDFXCAPS_OVERLAYSHRINKYN                         = 0x00400000;
+const UINT WINEDDFXCAPS_OVERLAYSTRETCHX                         = 0x00800000;
+const UINT WINEDDFXCAPS_OVERLAYSTRETCHXN                        = 0x01000000;
+const UINT WINEDDFXCAPS_OVERLAYSTRETCHY                         = 0x02000000;
+const UINT WINEDDFXCAPS_OVERLAYSTRETCHYN                        = 0x04000000;
+const UINT WINEDDFXCAPS_OVERLAYMIRRORLEFTRIGHT                  = 0x08000000;
+const UINT WINEDDFXCAPS_OVERLAYMIRRORUPDOWN                     = 0x10000000;
+
+const UINT WINEDDCAPS_3D                                        = 0x00000001;
+const UINT WINEDDCAPS_ALIGNBOUNDARYDEST                         = 0x00000002;
+const UINT WINEDDCAPS_ALIGNSIZEDEST                             = 0x00000004;
+const UINT WINEDDCAPS_ALIGNBOUNDARYSRC                          = 0x00000008;
+const UINT WINEDDCAPS_ALIGNSIZESRC                              = 0x00000010;
+const UINT WINEDDCAPS_ALIGNSTRIDE                               = 0x00000020;
+const UINT WINEDDCAPS_BLT                                       = 0x00000040;
+const UINT WINEDDCAPS_BLTQUEUE                                  = 0x00000080;
+const UINT WINEDDCAPS_BLTFOURCC                                 = 0x00000100;
+const UINT WINEDDCAPS_BLTSTRETCH                                = 0x00000200;
+const UINT WINEDDCAPS_GDI                                       = 0x00000400;
+const UINT WINEDDCAPS_OVERLAY                                   = 0x00000800;
+const UINT WINEDDCAPS_OVERLAYCANTCLIP                           = 0x00001000;
+const UINT WINEDDCAPS_OVERLAYFOURCC                             = 0x00002000;
+const UINT WINEDDCAPS_OVERLAYSTRETCH                            = 0x00004000;
+const UINT WINEDDCAPS_PALETTE                                   = 0x00008000;
+const UINT WINEDDCAPS_PALETTEVSYNC                              = 0x00010000;
+const UINT WINEDDCAPS_READSCANLINE                              = 0x00020000;
+const UINT WINEDDCAPS_STEREOVIEW                                = 0x00040000;
+const UINT WINEDDCAPS_VBI                                       = 0x00080000;
+const UINT WINEDDCAPS_ZBLTS                                     = 0x00100000;
+const UINT WINEDDCAPS_ZOVERLAYS                                 = 0x00200000;
+const UINT WINEDDCAPS_COLORKEY                                  = 0x00400000;
+const UINT WINEDDCAPS_ALPHA                                     = 0x00800000;
+const UINT WINEDDCAPS_COLORKEYHWASSIST                          = 0x01000000;
+const UINT WINEDDCAPS_NOHARDWARE                                = 0x02000000;
+const UINT WINEDDCAPS_BLTCOLORFILL                              = 0x04000000;
+const UINT WINEDDCAPS_BANKSWITCHED                              = 0x08000000;
+const UINT WINEDDCAPS_BLTDEPTHFILL                              = 0x10000000;
+const UINT WINEDDCAPS_CANCLIP                                   = 0x20000000;
+const UINT WINEDDCAPS_CANCLIPSTRETCHED                          = 0x40000000;
+const UINT WINEDDCAPS_CANBLTSYSMEM                              = 0x80000000;
+
+const UINT WINEDDCAPS2_CERTIFIED                                = 0x00000001;
+const UINT WINEDDCAPS2_NO2DDURING3DSCENE                        = 0x00000002;
+const UINT WINEDDCAPS2_VIDEOPORT                                = 0x00000004;
+const UINT WINEDDCAPS2_AUTOFLIPOVERLAY                          = 0x00000008;
+const UINT WINEDDCAPS2_CANBOBINTERLEAVED                        = 0x00000010;
+const UINT WINEDDCAPS2_CANBOBNONINTERLEAVED                     = 0x00000020;
+const UINT WINEDDCAPS2_COLORCONTROLOVERLAY                      = 0x00000040;
+const UINT WINEDDCAPS2_COLORCONTROLPRIMARY                      = 0x00000080;
+const UINT WINEDDCAPS2_CANDROPZ16BIT                            = 0x00000100;
+const UINT WINEDDCAPS2_NONLOCALVIDMEM                           = 0x00000200;
+const UINT WINEDDCAPS2_NONLOCALVIDMEMCAPS                       = 0x00000400;
+const UINT WINEDDCAPS2_NOPAGELOCKREQUIRED                       = 0x00000800;
+const UINT WINEDDCAPS2_WIDESURFACES                             = 0x00001000;
+const UINT WINEDDCAPS2_CANFLIPODDEVEN                           = 0x00002000;
+const UINT WINEDDCAPS2_CANBOBHARDWARE                           = 0x00004000;
+const UINT WINEDDCAPS2_COPYFOURCC                               = 0x00008000;
+const UINT WINEDDCAPS2_PRIMARYGAMMA                             = 0x00020000;
+const UINT WINEDDCAPS2_CANRENDERWINDOWED                        = 0x00080000;
+const UINT WINEDDCAPS2_CANCALIBRATEGAMMA                        = 0x00100000;
+const UINT WINEDDCAPS2_FLIPINTERVAL                             = 0x00200000;
+const UINT WINEDDCAPS2_FLIPNOVSYNC                              = 0x00400000;
+const UINT WINEDDCAPS2_CANMANAGETEXTURE                         = 0x00800000;
+const UINT WINEDDCAPS2_TEXMANINNONLOCALVIDMEM                   = 0x01000000;
+const UINT WINEDDCAPS2_STEREO                                   = 0x02000000;
+const UINT WINEDDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL              = 0x04000000;
+
+/* DDCAPS.d */
+const UINT WINEDDPCAPS_4BIT                                     = 0x00000001;
+const UINT WINEDDPCAPS_8BITENTRIES                              = 0x00000002;
+const UINT WINEDDPCAPS_8BIT                                     = 0x00000004;
+const UINT WINEDDPCAPS_INITIALIZE                               = 0x00000008;
+const UINT WINEDDPCAPS_PRIMARYSURFACE                           = 0x00000010;
+const UINT WINEDDPCAPS_PRIMARYSURFACELEFT                       = 0x00000020;
+const UINT WINEDDPCAPS_ALLOW256                                 = 0x00000040;
+const UINT WINEDDPCAPS_VSYNC                                    = 0x00000080;
+const UINT WINEDDPCAPS_1BIT                                     = 0x00000100;
+const UINT WINEDDPCAPS_2BIT                                     = 0x00000200;
+const UINT WINEDDPCAPS_ALPHA                                    = 0x00000400;
+
+typedef struct _WINED3DDISPLAYMODE
+{
+    UINT Width;
+    UINT Height;
+    UINT RefreshRate;
+    WINED3DFORMAT Format;
+} WINED3DDISPLAYMODE;
+
+typedef struct _WINED3DCOLORVALUE
+{
+    float r;
+    float g;
+    float b;
+    float a;
+} WINED3DCOLORVALUE;
+
+typedef struct _WINED3DVECTOR
+{
+    float x;
+    float y;
+    float z;
+} WINED3DVECTOR;
+
+typedef struct _WINED3DMATRIX
+{
+    union
+    {
+        struct
+        {
+            float _11, _12, _13, _14;
+            float _21, _22, _23, _24;
+            float _31, _32, _33, _34;
+            float _41, _42, _43, _44;
+        } DUMMYSTRUCTNAME;
+        float m[4][4];
+    } DUMMYUNIONNAME;
+} WINED3DMATRIX;
+
+typedef struct _WINED3DRECT
+{
+    LONG x1;
+    LONG y1;
+    LONG x2;
+    LONG y2;
+} WINED3DRECT;
+
+typedef struct _WINED3DLIGHT
+{
+    WINED3DLIGHTTYPE Type;
+    WINED3DCOLORVALUE Diffuse;
+    WINED3DCOLORVALUE Specular;
+    WINED3DCOLORVALUE Ambient;
+    WINED3DVECTOR Position;
+    WINED3DVECTOR Direction;
+    float Range;
+    float Falloff;
+    float Attenuation0;
+    float Attenuation1;
+    float Attenuation2;
+    float Theta;
+    float Phi;
+} WINED3DLIGHT;
+
+typedef struct _WINED3DMATERIAL
+{
+    WINED3DCOLORVALUE Diffuse;
+    WINED3DCOLORVALUE Ambient;
+    WINED3DCOLORVALUE Specular;
+    WINED3DCOLORVALUE Emissive;
+    float Power;
+} WINED3DMATERIAL;
+
+typedef struct _WINED3DVIEWPORT
+{
+    DWORD X;
+    DWORD Y;
+    DWORD Width;
+    DWORD Height;
+    float MinZ;
+    float MaxZ;
+} WINED3DVIEWPORT;
+
+typedef struct _WINED3DGAMMARAMP
+{
+    WORD red[256];
+    WORD green[256];
+    WORD blue[256];
+} WINED3DGAMMARAMP;
+
+typedef struct _WINED3DLINEPATTERN
+{
+    WORD wRepeatFactor;
+    WORD wLinePattern;
+} WINED3DLINEPATTERN;
+
+typedef struct _WINEDD3DRECTPATCH_INFO
+{
+    UINT StartVertexOffsetWidth;
+    UINT StartVertexOffsetHeight;
+    UINT Width;
+    UINT Height;
+    UINT Stride;
+    WINED3DBASISTYPE Basis;
+    WINED3DDEGREETYPE Degree;
+} WINED3DRECTPATCH_INFO;
+
+typedef struct _WINED3DTRIPATCH_INFO
+{
+    UINT StartVertexOffset;
+    UINT NumVertices;
+    WINED3DBASISTYPE Basis;
+    WINED3DDEGREETYPE Degree;
+} WINED3DTRIPATCH_INFO;
+
+typedef struct _WINED3DADAPTER_IDENTIFIER
+{
+    char *Driver;
+    char *Description;
+    char *DeviceName;
+    LARGE_INTEGER *DriverVersion;
+    DWORD *VendorId;
+    DWORD *DeviceId;
+    DWORD *SubSysId;
+    DWORD *Revision;
+    GUID *DeviceIdentifier;
+    DWORD *WHQLLevel;
+} WINED3DADAPTER_IDENTIFIER;
+
+typedef struct _WINED3DPRESENT_PARAMETERS
+{
+    UINT BackBufferWidth;
+    UINT BackBufferHeight;
+    WINED3DFORMAT BackBufferFormat;
+    UINT BackBufferCount;
+    WINED3DMULTISAMPLE_TYPE MultiSampleType;
+    DWORD MultiSampleQuality;
+    WINED3DSWAPEFFECT SwapEffect;
+    HWND hDeviceWindow;
+    BOOL Windowed;
+    BOOL EnableAutoDepthStencil;
+    WINED3DFORMAT AutoDepthStencilFormat;
+    DWORD Flags;
+    UINT FullScreen_RefreshRateInHz;
+    UINT PresentationInterval;
+    BOOL AutoRestoreDisplayMode;
+} WINED3DPRESENT_PARAMETERS;
+
+typedef struct _WINED3DSURFACE_DESC
+{
+    WINED3DFORMAT *Format;
+    WINED3DRESOURCETYPE *Type;
+    DWORD *Usage;
+    WINED3DPOOL *Pool;
+    UINT *Size;
+    WINED3DMULTISAMPLE_TYPE *MultiSampleType;
+    DWORD *MultiSampleQuality;
+    UINT *Width;
+    UINT *Height;
+} WINED3DSURFACE_DESC;
+
+typedef struct _WINED3DVOLUME_DESC
+{
+    WINED3DFORMAT *Format;
+    WINED3DRESOURCETYPE *Type;
+    DWORD *Usage;
+    WINED3DPOOL *Pool;
+    UINT *Size;
+    UINT *Width;
+    UINT *Height;
+    UINT *Depth;
+} WINED3DVOLUME_DESC;
+
+typedef struct _WINED3DCLIPSTATUS
+{
+   DWORD ClipUnion;
+   DWORD ClipIntersection;
+} WINED3DCLIPSTATUS;
+
+typedef struct _WINED3DVERTEXELEMENT
+{
+  WORD Stream;
+  WORD Offset;
+  BYTE Type;
+  BYTE Method;
+  BYTE Usage;
+  BYTE UsageIndex;
+  int Reg; /* DirectX 8 */
+} WINED3DVERTEXELEMENT, *LPWINED3DVERTEXELEMENT;
+
+typedef struct _WINED3DDEVICE_CREATION_PARAMETERS
+{
+    UINT AdapterOrdinal;
+    WINED3DDEVTYPE DeviceType;
+    HWND hFocusWindow;
+    DWORD BehaviorFlags;
+} WINED3DDEVICE_CREATION_PARAMETERS;
+
+typedef struct _WINED3DDEVINFO_BANDWIDTHTIMINGS
+{
+    float MaxBandwidthUtilized;
+    float FrontEndUploadMemoryUtilizedPercent;
+    float VertexRateUtilizedPercent;
+    float TriangleSetupRateUtilizedPercent;
+    float FillRateUtilizedPercent;
+} WINED3DDEVINFO_BANDWIDTHTIMINGS;
+
+typedef struct _WINED3DDEVINFO_CACHEUTILIZATION
+{
+    float TextureCacheHitRate;
+    float PostTransformVertexCacheHitRate;
+} WINED3DDEVINFO_CACHEUTILIZATION;
+
+typedef struct _WINED3DDEVINFO_INTERFACETIMINGS
+{
+    float WaitingForGPUToUseApplicationResourceTimePercent;
+    float WaitingForGPUToAcceptMoreCommandsTimePercent;
+    float WaitingForGPUToStayWithinLatencyTimePercent;
+    float WaitingForGPUExclusiveResourceTimePercent;
+    float WaitingForGPUOtherTimePercent;
+} WINED3DDEVINFO_INTERFACETIMINGS;
+
+typedef struct _WINED3DDEVINFO_PIPELINETIMINGS
+{
+    float VertexProcessingTimePercent;
+    float PixelProcessingTimePercent;
+    float OtherGPUProcessingTimePercent;
+    float GPUIdleTimePercent;
+} WINED3DDEVINFO_PIPELINETIMINGS;
+
+typedef struct _WINED3DDEVINFO_STAGETIMINGS
+{
+    float MemoryProcessingPercent;
+    float ComputationProcessingPercent;
+} WINED3DDEVINFO_STAGETIMINGS;
+
+typedef struct _WINED3DRASTER_STATUS
+{
+    BOOL InVBlank;
+    UINT ScanLine;
+} WINED3DRASTER_STATUS;
+
+typedef struct WINED3DRESOURCESTATS
+{
+    BOOL bThrashing;
+    DWORD ApproxBytesDownloaded;
+    DWORD NumEvicts;
+    DWORD NumVidCreates;
+    DWORD LastPri;
+    DWORD NumUsed;
+    DWORD NumUsedInVidMem;
+    DWORD WorkingSet;
+    DWORD WorkingSetBytes;
+    DWORD TotalManaged;
+    DWORD TotalBytes;
+} WINED3DRESOURCESTATS;
+
+typedef struct _WINED3DDEVINFO_RESOURCEMANAGER
+{
+    WINED3DRESOURCESTATS stats[WINED3DRTYPECOUNT];
+} WINED3DDEVINFO_RESOURCEMANAGER;
+
+typedef struct _WINED3DDEVINFO_VERTEXSTATS
+{
+    DWORD NumRenderedTriangles;
+    DWORD NumExtraClippingTriangles;
+} WINED3DDEVINFO_VERTEXSTATS;
+
+typedef struct _WINED3DLOCKED_RECT
+{
+    INT Pitch;
+    void *pBits;
+} WINED3DLOCKED_RECT;
+
+typedef struct _WINED3DLOCKED_BOX
+{
+    INT RowPitch;
+    INT SlicePitch;
+    void *pBits;
+} WINED3DLOCKED_BOX;
+
+typedef struct _WINED3DBOX
+{
+    UINT Left;
+    UINT Top;
+    UINT Right;
+    UINT Bottom;
+    UINT Front;
+    UINT Back;
+} WINED3DBOX;
+
+/*Vertex cache optimization hints.*/
+typedef struct WINED3DDEVINFO_VCACHE
+{
+    DWORD Pattern;      /* Must be a 4 char code FOURCC (e.g. CACH) */
+    DWORD OptMethod;    /* 0 to get the longest  strips, 1 vertex cache */
+    DWORD CacheSize;    /* Cache size to use (only valid if OptMethod==1) */
+    DWORD MagicNumber;  /* Internal for deciding when to restart strips,
+                           non user modifiable (only valid if OptMethod==1) */
+} WINED3DDEVINFO_VCACHE;
+
+typedef struct _WINED3DVERTEXBUFFER_DESC
+{
+    WINED3DFORMAT Format;
+    WINED3DRESOURCETYPE Type;
+    DWORD Usage;
+    WINED3DPOOL Pool;
+    UINT Size;
+    DWORD FVF;
+} WINED3DVERTEXBUFFER_DESC;
+
+typedef struct _WINED3DINDEXBUFFER_DESC
+{
+    WINED3DFORMAT Format;
+    WINED3DRESOURCETYPE Type;
+    DWORD Usage;
+    WINED3DPOOL Pool;
+    UINT Size;
+} WINED3DINDEXBUFFER_DESC;
+
+typedef struct glDescriptor
+{
+    UINT textureName;
+    int level;
+    int /*GLenum*/ target;
+    int /*GLenum*/ glFormat;
+    int /*GLenum*/ glFormatInternal;
+    int /*GLenum*/ glType;
+} glDescriptor;
+
+typedef struct WineDirect3DStridedData
+{
+    const BYTE *lpData; /* Pointer to start of data */
+    DWORD dwStride;     /* Stride between occurrences of this data */
+    DWORD dwType;       /* Type (as in D3DVSDT_TYPE) */
+    int VBO;            /* Vertex buffer object this data is in */
+    UINT streamNo;      /* D3D stream number */
+} WineDirect3DStridedData;
+
+typedef struct WineDirect3DVertexStridedData
+{
+    /*
+     * IMPORTANT:
+     * This structure can be accessed in two ways: Named access, and array
+     * access. Please note that named access is only valid with the fixed
+     * function vertex pipeline, and the arrays are only valid with the
+     * programmable vertex pipeline(vertex shaders).
+     */
+    union
+    {
+        struct
+        {
+            /* Do not add or reorder fields here,
+             * so this can be indexed as an array */
+            WineDirect3DStridedData position;
+            WineDirect3DStridedData blendWeights;
+            WineDirect3DStridedData blendMatrixIndices;
+            WineDirect3DStridedData normal;
+            WineDirect3DStridedData pSize;
+            WineDirect3DStridedData diffuse;
+            WineDirect3DStridedData specular;
+            WineDirect3DStridedData texCoords[WINED3DDP_MAXTEXCOORD];
+            WineDirect3DStridedData position2;  /* tween data */
+            WineDirect3DStridedData normal2;    /* tween data */
+            WineDirect3DStridedData tangent;
+            WineDirect3DStridedData binormal;
+            WineDirect3DStridedData tessFactor;
+            WineDirect3DStridedData fog;
+            WineDirect3DStridedData depth;
+            WineDirect3DStridedData sample;
+
+            /* Add fields here */
+            BOOL position_transformed;
+        } s;
+        WineDirect3DStridedData input[16];  /* Indexed by constants in D3DVSDE_REGISTER */
+    } u;
+} WineDirect3DVertexStridedData;
+
+typedef struct _WINED3DVSHADERCAPS2_0
+{
+    DWORD Caps;
+    INT DynamicFlowControlDepth;
+    INT NumTemps;
+    INT StaticFlowControlDepth;
+} WINED3DVSHADERCAPS2_0;
+
+typedef struct _WINED3DPSHADERCAPS2_0
+{
+    DWORD Caps;
+    INT DynamicFlowControlDepth;
+    INT NumTemps;
+    INT StaticFlowControlDepth;
+    INT NumInstructionSlots;
+} WINED3DPSHADERCAPS2_0;
+
+typedef struct _WINEDDCAPS
+{
+    DWORD Caps;
+    DWORD Caps2;
+    DWORD CKeyCaps;
+    DWORD FXCaps;
+    DWORD FXAlphaCaps;
+    DWORD PalCaps;
+    DWORD SVCaps;
+    DWORD SVBCaps;
+    DWORD SVBCKeyCaps;
+    DWORD SVBFXCaps;
+    DWORD VSBCaps;
+    DWORD VSBCKeyCaps;
+    DWORD VSBFXCaps;
+    DWORD SSBCaps;
+    DWORD SSBCKeyCaps;
+    DWORD SSBFXCaps;
+    DWORD ddsCaps;
+    DWORD StrideAlign;
+} WINEDDCAPS;
+
+typedef struct _WINED3DCAPS
+{
+    WINED3DDEVTYPE DeviceType;
+    UINT AdapterOrdinal;
+
+    DWORD Caps;
+    DWORD Caps2;
+    DWORD Caps3;
+    DWORD PresentationIntervals;
+
+    DWORD CursorCaps;
+    DWORD DevCaps;
+    DWORD PrimitiveMiscCaps;
+    DWORD RasterCaps;
+    DWORD ZCmpCaps;
+    DWORD SrcBlendCaps;
+    DWORD DestBlendCaps;
+    DWORD AlphaCmpCaps;
+    DWORD ShadeCaps;
+    DWORD TextureCaps;
+    DWORD TextureFilterCaps;
+    DWORD CubeTextureFilterCaps;
+    DWORD VolumeTextureFilterCaps;
+    DWORD TextureAddressCaps;
+    DWORD VolumeTextureAddressCaps;
+    DWORD LineCaps;
+
+    DWORD MaxTextureWidth;
+    DWORD MaxTextureHeight;
+    DWORD MaxVolumeExtent;
+    DWORD MaxTextureRepeat;
+    DWORD MaxTextureAspectRatio;
+    DWORD MaxAnisotropy;
+    float MaxVertexW;
+
+    float GuardBandLeft;
+    float GuardBandTop;
+    float GuardBandRight;
+    float GuardBandBottom;
+
+    float ExtentsAdjust;
+    DWORD StencilCaps;
+
+    DWORD FVFCaps;
+    DWORD TextureOpCaps;
+    DWORD MaxTextureBlendStages;
+    DWORD MaxSimultaneousTextures;
+
+    DWORD VertexProcessingCaps;
+    DWORD MaxActiveLights;
+    DWORD MaxUserClipPlanes;
+    DWORD MaxVertexBlendMatrices;
+    DWORD MaxVertexBlendMatrixIndex;
+
+    float MaxPointSize;
+
+    DWORD MaxPrimitiveCount;
+    DWORD MaxVertexIndex;
+    DWORD MaxStreams;
+    DWORD MaxStreamStride;
+
+    DWORD VertexShaderVersion;
+    DWORD MaxVertexShaderConst;
+
+    DWORD PixelShaderVersion;
+    float PixelShader1xMaxValue;
+
+    /* DX 9 */
+    DWORD DevCaps2;
+
+    float MaxNpatchTessellationLevel;
+    DWORD Reserved5; /* undocumented */
+
+    UINT MasterAdapterOrdinal;
+    UINT AdapterOrdinalInGroup;
+    UINT NumberOfAdaptersInGroup;
+    DWORD DeclTypes;
+    DWORD NumSimultaneousRTs;
+    DWORD StretchRectFilterCaps;
+    WINED3DVSHADERCAPS2_0 VS20Caps;
+    WINED3DPSHADERCAPS2_0 PS20Caps;
+    DWORD VertexTextureFilterCaps;
+    DWORD MaxVShaderInstructionsExecuted;
+    DWORD MaxPShaderInstructionsExecuted;
+    DWORD MaxVertexShader30InstructionSlots;
+    DWORD MaxPixelShader30InstructionSlots;
+    DWORD Reserved2; /* Not in the microsoft headers but documented */
+    DWORD Reserved3;
+
+    WINEDDCAPS DirectDrawCaps;
+} WINED3DCAPS;
+
+/* DirectDraw types */
+
+typedef struct _WINEDDCOLORKEY
+{
+    DWORD dwColorSpaceLowValue;     /* low boundary of color space that is to
+                                     * be treated as Color Key, inclusive */
+    DWORD dwColorSpaceHighValue;    /* high boundary of color space that is
+                                     * to be treated as Color Key, inclusive */
+} WINEDDCOLORKEY,*LPWINEDDCOLORKEY;
+
+typedef struct _WINEDDBLTFX
+{
+    DWORD dwSize;                                   /* size of structure */
+    DWORD dwDDFX;                                   /* FX operations */
+    DWORD dwROP;                                    /* Win32 raster operations */
+    DWORD dwDDROP;                                  /* Raster operations new for DirectDraw */
+    DWORD dwRotationAngle;                          /* Rotation angle for blt */
+    DWORD dwZBufferOpCode;                          /* ZBuffer compares */
+    DWORD dwZBufferLow;                             /* Low limit of Z buffer */
+    DWORD dwZBufferHigh;                            /* High limit of Z buffer */
+    DWORD dwZBufferBaseDest;                        /* Destination base value */
+    DWORD dwZDestConstBitDepth;                     /* Bit depth used to specify Z constant for destination */
+    union
+    {
+        DWORD dwZDestConst;                         /* Constant to use as Z buffer for dest */
+        struct IWineD3DSurface *lpDDSZBufferDest;   /* Surface to use as Z buffer for dest */
+    } DUMMYUNIONNAME1;
+    DWORD dwZSrcConstBitDepth;                      /* Bit depth used to specify Z constant for source */
+    union
+    {
+        DWORD dwZSrcConst;                          /* Constant to use as Z buffer for src */
+        struct IWineD3DSurface *lpDDSZBufferSrc;    /* Surface to use as Z buffer for src */
+    } DUMMYUNIONNAME2;
+    DWORD dwAlphaEdgeBlendBitDepth;                 /* Bit depth used to specify constant for alpha edge blend */
+    DWORD dwAlphaEdgeBlend;                         /* Alpha for edge blending */
+    DWORD dwReserved;
+    DWORD dwAlphaDestConstBitDepth;                 /* Bit depth used to specify alpha constant for destination */
+    union
+    {
+        DWORD dwAlphaDestConst;                     /* Constant to use as Alpha Channel */
+        struct IWineD3DSurface *lpDDSAlphaDest;     /* Surface to use as Alpha Channel */
+    } DUMMYUNIONNAME3;
+    DWORD dwAlphaSrcConstBitDepth;                  /* Bit depth used to specify alpha constant for source */
+    union
+    {
+        DWORD dwAlphaSrcConst;                      /* Constant to use as Alpha Channel */
+        struct IWineD3DSurface *lpDDSAlphaSrc;      /* Surface to use as Alpha Channel */
+    } DUMMYUNIONNAME4;
+    union
+    {
+        DWORD dwFillColor;                          /* color in RGB or Palettized */
+        DWORD dwFillDepth;                          /* depth value for z-buffer */
+        DWORD dwFillPixel;                          /* pixel val for RGBA or RGBZ */
+        struct IWineD3DSurface *lpDDSPattern;       /* Surface to use as pattern */
+    } DUMMYUNIONNAME5;
+    WINEDDCOLORKEY ddckDestColorkey;                /* DestColorkey override */
+    WINEDDCOLORKEY ddckSrcColorkey;                 /* SrcColorkey override */
+} WINEDDBLTFX,*LPWINEDDBLTFX;
+
+typedef struct _WINEDDOVERLAYFX
+{
+    DWORD dwSize;                                   /* size of structure */
+    DWORD dwAlphaEdgeBlendBitDepth;                 /* Bit depth used to specify constant for alpha edge blend */
+    DWORD dwAlphaEdgeBlend;                         /* Constant to use as alpha for edge blend */
+    DWORD dwReserved;
+    DWORD dwAlphaDestConstBitDepth;                 /* Bit depth used to specify alpha constant for destination */
+    union
+    {
+        DWORD dwAlphaDestConst;                     /* Constant to use as alpha channel for dest */
+        struct IWineD3DSurface *lpDDSAlphaDest;     /* Surface to use as alpha channel for dest */
+    } DUMMYUNIONNAME1;
+    DWORD dwAlphaSrcConstBitDepth;                  /* Bit depth used to specify alpha constant for source */
+    union
+    {
+        DWORD dwAlphaSrcConst;                      /* Constant to use as alpha channel for src */
+        struct IWineD3DSurface *lpDDSAlphaSrc;      /* Surface to use as alpha channel for src */
+    } DUMMYUNIONNAME2;
+    WINEDDCOLORKEY dckDestColorkey;                 /* DestColorkey override */
+    WINEDDCOLORKEY dckSrcColorkey;                  /* SrcColorkey override */
+    DWORD dwDDFX;                                   /* Overlay FX */
+    DWORD dwFlags;                                  /* flags */
+} WINEDDOVERLAYFX;
+
+interface IWineD3DResource;
+interface IWineD3DSurface;
+interface IWineD3DVolume;
+interface IWineD3DSwapChain;
+interface IWineD3DDevice;
+
+typedef HRESULT (*D3DCB_CREATESURFACEFN)(IUnknown *pDevice, IUnknown *pSuperior, UINT Width,
+        UINT Height, WINED3DFORMAT Format, DWORD Usage, WINED3DPOOL Pool, UINT Level, WINED3DCUBEMAP_FACES Face,
+        IWineD3DSurface **ppSurface, HANDLE *pSharedHandle);
+typedef HRESULT (*D3DCB_CREATERENDERTARGETFN)(IUnknown *pDevice, IUnknown *pSuperior, UINT Width,
+        UINT Height, WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,
+        BOOL Lockable, IWineD3DSurface **ppSurface, HANDLE *pSharedHandle);
+typedef HRESULT (*D3DCB_CREATEDEPTHSTENCILSURFACEFN)(IUnknown *pDevice, IUnknown *pSuperior, UINT Width,
+        UINT Height, WINED3DFORMAT Format, WINED3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,
+        BOOL Discard, IWineD3DSurface **ppSurface, HANDLE *pSharedHandle);
+typedef ULONG (*D3DCB_DESTROYSURFACEFN)(IWineD3DSurface *pSurface);
+typedef HRESULT (*D3DCB_CREATEVOLUMEFN)(IUnknown *pDevice, IUnknown *pSuperior, UINT Width,
+        UINT Height, UINT Depth, WINED3DFORMAT Format, WINED3DPOOL Pool, DWORD Usage,
+        IWineD3DVolume **ppVolume, HANDLE *pSharedHandle);
+typedef ULONG (*D3DCB_DESTROYVOLUMEFN)(IWineD3DVolume *pVolume);
+typedef HRESULT (*D3DCB_CREATESWAPCHAIN)(IUnknown *pDevice, WINED3DPRESENT_PARAMETERS *pPresentationParameters,
+        IWineD3DSwapChain **pSwapChain);
+typedef ULONG (*D3DCB_DESTROYSWAPCHAINFN)(IWineD3DSwapChain *pSwapChain);
+typedef HRESULT (*D3DCB_ENUMRESOURCES)(IWineD3DResource *resource, void *pData);
+
+[
+    object,
+    local,
+    uuid(46799311-8e0e-40ce-b2ec-ddb99f18fcb4)
+]
+interface IWineD3DBase : IUnknown
+{
+    HRESULT GetParent(
+        [out] IUnknown **parent
+    );
+}
+
+[
+    object,
+    local,
+    uuid(108f9c44-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3D : IWineD3DBase
+{
+    UINT GetAdapterCount(
+    );
+    HRESULT RegisterSoftwareDevice(
+        [in] void *pInitializeFunction
+    );
+    HMONITOR GetAdapterMonitor(
+        [in] UINT adapter_idx
+    );
+    UINT GetAdapterModeCount(
+        [in] UINT adapter_idx,
+        [in] WINED3DFORMAT format
+    );
+    HRESULT EnumAdapterModes(
+        [in] UINT adapter_idx,
+        [in] UINT mode_idx,
+        [in] WINED3DFORMAT format,
+        [out] WINED3DDISPLAYMODE *mode
+    );
+    HRESULT GetAdapterDisplayMode(
+        [in] UINT adapter_idx,
+        [out] WINED3DDISPLAYMODE *mode
+    );
+    HRESULT GetAdapterIdentifier(
+        [in] UINT adapter_idx,
+        [in] DWORD flags,
+        [out] WINED3DADAPTER_IDENTIFIER *identifier
+    );
+    HRESULT CheckDeviceMultiSampleType(
+        [in] UINT adapter_idx,
+        [in] WINED3DDEVTYPE device_type,
+        [in] WINED3DFORMAT surface_format,
+        [in] BOOL windowed,
+        [in] WINED3DMULTISAMPLE_TYPE multisample_type,
+        [out] DWORD *quality_levels
+    );
+    HRESULT CheckDepthStencilMatch(
+        [in] UINT adapter_idx,
+        [in] WINED3DDEVTYPE device_type,
+        [in] WINED3DFORMAT adapter_format,
+        [in] WINED3DFORMAT render_target_format,
+        [in] WINED3DFORMAT depth_stencil_format
+    );
+    HRESULT CheckDeviceType(
+        [in] UINT adapter_idx,
+        [in] WINED3DDEVTYPE device_type,
+        [in] WINED3DFORMAT display_format,
+        [in] WINED3DFORMAT backbuffer_format,
+        [in] BOOL windowed
+    );
+    HRESULT CheckDeviceFormat(
+        [in] UINT adaper_idx,
+        [in] WINED3DDEVTYPE device_type,
+        [in] WINED3DFORMAT adapter_format,
+        [in] DWORD usage,
+        [in] WINED3DRESOURCETYPE resource_type,
+        [in] WINED3DFORMAT check_format,
+        [in] WINED3DSURFTYPE surface_type
+    );
+    HRESULT CheckDeviceFormatConversion(
+        [in] UINT adapter_idx,
+        [in] WINED3DDEVTYPE device_type,
+        [in] WINED3DFORMAT source_format,
+        [in] WINED3DFORMAT target_format
+    );
+    HRESULT GetDeviceCaps(
+        [in] UINT adapter_idx,
+        [in] WINED3DDEVTYPE device_type,
+        [out] WINED3DCAPS *caps
+    );
+    HRESULT CreateDevice(
+        [in] UINT adapter_idx,
+        [in] WINED3DDEVTYPE device_type,
+        [in] HWND focus_window,
+        [in] DWORD behaviour_flags,
+        [out] IWineD3DDevice **device,
+        [in] IUnknown *parent
+    );
+}
+
+[
+    object,
+    local,
+    uuid(1f3bfb34-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DResource : IWineD3DBase
+{
+    HRESULT GetDevice(
+        [out] IWineD3DDevice **device
+    );
+    HRESULT SetPrivateData(
+        [in] REFGUID guid,
+        [in] const void *data,
+        [in] DWORD data_size,
+        [in] DWORD flags
+    );
+    HRESULT GetPrivateData(
+        [in] REFGUID guid,
+        [out] void *data,
+        [in, out] DWORD *data_size
+    );
+    HRESULT FreePrivateData(
+        [in] REFGUID guid
+    );
+    DWORD SetPriority(
+        [in] DWORD new_priority
+    );
+    DWORD GetPriority(
+    );
+    void PreLoad(
+    );
+    void UnLoad(
+    );
+    WINED3DRESOURCETYPE GetType(
+    );
+}
+
+[
+    object,
+    local,
+    uuid(217f671e-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DVertexBuffer : IWineD3DResource
+{
+    HRESULT Lock(
+        [in] UINT offset,
+        [in] UINT size,
+        [out] BYTE **data,
+        [in] DWORD flags
+    );
+    HRESULT Unlock(
+    );
+    HRESULT GetDesc(
+        [out] WINED3DVERTEXBUFFER_DESC *desc
+    );
+}
+
+[
+    object,
+    local,
+    uuid(3a02a54e-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DIndexBuffer : IWineD3DResource
+{
+    HRESULT Lock(
+        [in] UINT offset,
+        [in] UINT size,
+        [out] BYTE **data,
+        [in] DWORD flags
+    );
+    HRESULT Unlock(
+    );
+    HRESULT GetDesc(
+        [out] WINED3DINDEXBUFFER_DESC *desc
+    );
+}
+
+[
+    object,
+    local,
+    uuid(f756720c-32b9-4439-b5a3-1d6c97037d9e)
+]
+interface IWineD3DPalette : IWineD3DBase
+{
+    HRESULT GetEntries(
+        [in] DWORD flags,
+        [in] DWORD start,
+        [in] DWORD count,
+        [out] PALETTEENTRY *entries
+    );
+    HRESULT GetCaps(
+        [out] DWORD *caps
+    );
+    HRESULT SetEntries(
+        [in] DWORD flags,
+        [in] DWORD start,
+        [in] DWORD count,
+        [in] const PALETTEENTRY *entries
+    );
+}
+
+[
+    object,
+    local,
+    uuid(8f2bceb1-d338-488c-ab7f-0ec980bf5d2d)
+]
+interface IWineD3DClipper : IWineD3DBase
+{
+    HRESULT GetClipList(
+        [in] const RECT *rect,
+        [out] RGNDATA *clip_list,
+        [in, out] DWORD *clip_list_size
+    );
+    HRESULT GetHWnd(
+        [out] HWND *hwnd
+    );
+    HRESULT IsClipListChanged(
+        [out] BOOL *changed
+    );
+    HRESULT SetClipList(
+        [in] const RGNDATA *clip_list,
+        [in] DWORD flags
+    );
+    HRESULT SetHWnd(
+        [in] DWORD flags,
+        [in] HWND hwnd
+    );
+}
+
+[
+    object,
+    local,
+    uuid(37cd5526-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DSurface : IWineD3DResource
+{
+    HRESULT GetContainer(
+        [in] REFIID riid,
+        [out] void **container
+    );
+    HRESULT GetDesc(
+        [out] WINED3DSURFACE_DESC *desc
+    );
+    HRESULT LockRect(
+        [out] WINED3DLOCKED_RECT *locked_rect,
+        [in] const RECT *rect,
+        [in] DWORD flags
+    );
+    HRESULT UnlockRect(
+    );
+    HRESULT GetDC(
+        [out] HDC *dc
+    );
+    HRESULT ReleaseDC(
+        [in] HDC dc
+    );
+    HRESULT Flip(
+        [in] IWineD3DSurface *override,
+        [in] DWORD flags
+    );
+    HRESULT Blt(
+        [in] const RECT *dst_rect,
+        [in] IWineD3DSurface *src_surface,
+        [in] const RECT *src_rect,
+        [in] DWORD flags,
+        [in] const WINEDDBLTFX *blt_fx,
+        [in] WINED3DTEXTUREFILTERTYPE filter
+    );
+    HRESULT GetBltStatus(
+        [in] DWORD flags
+    );
+    HRESULT GetFlipStatus(
+        [in] DWORD flags
+    );
+    HRESULT IsLost(
+    );
+    HRESULT Restore(
+    );
+    HRESULT BltFast(
+        [in] DWORD dst_x,
+        [in] DWORD dst_y,
+        [in] IWineD3DSurface *src_surface,
+        [in] const RECT *src_rect,
+        [in] DWORD trans
+    );
+    HRESULT GetPalette(
+        [out] IWineD3DPalette **palette
+    );
+    HRESULT SetPalette(
+        [in] IWineD3DPalette *palette
+    );
+    HRESULT RealizePalette(
+    );
+    HRESULT SetColorKey(
+        [in] DWORD flags,
+        [in] const WINEDDCOLORKEY *color_key
+    );
+    DWORD GetPitch(
+    );
+    HRESULT SetMem(
+        [in] void *mem
+    );
+    HRESULT SetOverlayPosition(
+        [in] LONG x,
+        [in] LONG y
+    );
+    HRESULT GetOverlayPosition(
+        [out] LONG *x,
+        [out] LONG *y
+    );
+    HRESULT UpdateOverlayZOrder(
+        [in] DWORD flags,
+        [in] IWineD3DSurface *ref
+    );
+    HRESULT UpdateOverlay(
+        [in] const RECT *src_rect,
+        [in] IWineD3DSurface *dst_surface,
+        [in] const RECT *dst_rect,
+        [in] DWORD flags,
+        [in] const WINEDDOVERLAYFX *fx
+    );
+    HRESULT SetClipper(
+        [in] IWineD3DClipper *clipper
+    );
+    HRESULT GetClipper(
+        [out] IWineD3DClipper **clipper
+    );
+    HRESULT AddDirtyRect(
+        [in] const RECT *dirty_rect
+    );
+    HRESULT LoadTexture(
+        [in] BOOL srgb_mode
+    );
+    void BindTexture(
+    );
+    HRESULT SaveSnapshot(
+        [in] const char *filename
+    );
+    HRESULT SetContainer(
+        [in] IWineD3DBase *container
+    );
+    void GetGlDesc(
+        [out] glDescriptor **desc
+    );
+    const void *GetData(
+    );
+    HRESULT SetFormat(
+        [in] WINED3DFORMAT format
+    );
+    HRESULT PrivateSetup(
+    );
+    void ModifyLocation(
+        [in] DWORD location,
+        [in] BOOL persistent
+    );
+    HRESULT LoadLocation(
+        [in] DWORD location,
+        [in] const RECT *rect
+    );
+    WINED3DSURFTYPE GetImplType(
+    );
+    HRESULT DrawOverlay(
+    );
+}
+
+[
+    object,
+    local,
+    uuid(24769ed8-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DVolume : IWineD3DResource
+{
+    HRESULT GetContainer(
+        [in] REFIID riid,
+        [out] void **container
+    );
+    HRESULT GetDesc(
+        [out] WINED3DVOLUME_DESC *desc
+    );
+    HRESULT LockBox(
+        [out] WINED3DLOCKED_BOX *locked_box,
+        [in] const WINED3DBOX *box,
+        [in] DWORD flags
+    );
+    HRESULT UnlockBox(
+    );
+    HRESULT AddDirtyBox(
+        [in] const WINED3DBOX *dirty_box
+    );
+    HRESULT CleanDirtyBox(
+    );
+    HRESULT LoadTexture(
+        [in] int gl_level,
+        [in] BOOL srgb_mode
+    );
+    HRESULT SetContainer(
+        [in] IWineD3DBase *container
+    );
+}
+
+[
+    object,
+    local,
+    uuid(3c2aebf6-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DBaseTexture : IWineD3DResource
+{
+    DWORD SetLOD(
+        [in] DWORD new_lod
+    );
+    DWORD GetLOD(
+    );
+    DWORD GetLevelCount(
+    );
+    HRESULT SetAutoGenFilterType(
+        WINED3DTEXTUREFILTERTYPE filter_type
+    );
+    WINED3DTEXTUREFILTERTYPE GetAutoGenFilterType(
+    );
+    void GenerateMipSubLevels(
+    );
+    BOOL SetDirty(
+        BOOL dirty
+    );
+    BOOL GetDirty(
+    );
+    HRESULT BindTexture(
+    );
+    UINT GetTextureDimensions(
+    );
+    BOOL IsCondNP2(
+    );
+    void ApplyStateChanges(
+        const DWORD texture_states[WINED3D_HIGHEST_TEXTURE_STATE + 1],
+        const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]
+    );
+}
+
+[
+    object,
+    local,
+    uuid(3e72cc1c-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DTexture : IWineD3DBaseTexture
+{
+    void Destroy(
+        [in] D3DCB_DESTROYSURFACEFN destroy_surface_callback
+    );
+    HRESULT GetLevelDesc(
+        [in] UINT level,
+        [out] WINED3DSURFACE_DESC *desc
+    );
+    HRESULT GetSurfaceLevel(
+        [in] UINT level,
+        [out] IWineD3DSurface **surface
+    );
+    HRESULT LockRect(
+        [in] UINT level,
+        [out] WINED3DLOCKED_RECT *locked_rect,
+        [in] const RECT *rect,
+        [in] DWORD flags
+    );
+    HRESULT UnlockRect(
+        [in] UINT level
+    );
+    HRESULT AddDirtyRect(
+        [in] const RECT *dirty_rect
+    );
+}
+
+[
+    object,
+    local,
+    uuid(41752900-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DCubeTexture : IWineD3DBaseTexture
+{
+    void Destroy(
+        [in] D3DCB_DESTROYSURFACEFN destroy_surface_callback
+    );
+    HRESULT GetLevelDesc(
+        [in] UINT level,
+        [out] WINED3DSURFACE_DESC *desc
+    );
+    HRESULT GetCubeMapSurface(
+        [in] WINED3DCUBEMAP_FACES face,
+        [in] UINT level,
+        [out] IWineD3DSurface **surface
+    );
+    HRESULT LockRect(
+        [in] WINED3DCUBEMAP_FACES face,
+        [in] UINT level,
+        [out] WINED3DLOCKED_RECT *locked_rect,
+        [in] const RECT *rect,
+        [in] DWORD flags
+    );
+    HRESULT UnlockRect(
+        [in] WINED3DCUBEMAP_FACES face,
+        [in] UINT level
+    );
+    HRESULT AddDirtyRect(
+        [in] WINED3DCUBEMAP_FACES face,
+        [in] const RECT *dirty_rect
+    );
+}
+
+[
+    object,
+    local,
+    uuid(7b39470c-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DVolumeTexture : IWineD3DBaseTexture
+{
+    void Destroy(
+        [in] D3DCB_DESTROYVOLUMEFN destroy_volume_callback
+    );
+    HRESULT GetLevelDesc(
+        [in] UINT level,
+        [out] WINED3DVOLUME_DESC *desc
+    );
+    HRESULT GetVolumeLevel(
+        [in] UINT level,
+        [out] IWineD3DVolume **volume
+    );
+    HRESULT LockBox(
+        [in] UINT level,
+        [out] WINED3DLOCKED_BOX *locked_box,
+        [in] const WINED3DBOX *box,
+        [in] DWORD flags
+    );
+    HRESULT UnlockBox(
+        [in] UINT level
+    );
+    HRESULT AddDirtyBox(
+        [in] const WINED3DBOX *dirty_box
+    );
+}
+
+[
+    object,
+    local,
+    uuid(7cd55be6-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DVertexDeclaration : IWineD3DBase
+{
+    HRESULT GetDevice(
+        [out] IWineD3DDevice **device
+    );
+    HRESULT GetDeclaration(
+        [out] WINED3DVERTEXELEMENT *elements,
+        [out] UINT *element_count
+    );
+    HRESULT SetDeclaration(
+        [in] const WINED3DVERTEXELEMENT *elements,
+        [in] UINT element_count
+    );
+}
+
+[
+    object,
+    local,
+    uuid(83b073ce-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DStateBlock : IWineD3DBase
+{
+    HRESULT GetDevice(
+        [out] IWineD3DDevice **device
+    );
+    HRESULT Capture(
+    );
+    HRESULT Apply(
+    );
+    HRESULT InitStartupStateBlock(
+    );
+}
+
+[
+    object,
+    local,
+    uuid(905ddbac-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DQuery : IWineD3DBase
+{
+    HRESULT GetDevice(
+        [out] IWineD3DDevice **device
+    );
+    HRESULT GetData(
+        [out] void *data,
+        [in] DWORD data_size,
+        [in] DWORD flags
+    );
+    DWORD GetDataSize(
+    );
+    WINED3DQUERYTYPE GetType(
+    );
+    HRESULT Issue(
+        DWORD flags
+    );
+}
+
+[
+    object,
+    local,
+    uuid(34d01b10-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DSwapChain : IWineD3DBase
+{
+    void Destroy(
+        [in] D3DCB_DESTROYSURFACEFN destroy_surface_callback
+    );
+    HRESULT GetDevice(
+        [out] IWineD3DDevice **device
+    );
+    HRESULT Present(
+        [in] const RECT *src_rect,
+        [in] const RECT *dst_rect,
+        [in] HWND dst_window_override,
+        [in] const RGNDATA *dirty_region,
+        [in] DWORD flags
+    );
+    HRESULT SetDestWindowOverride(
+        [in] HWND window
+    );
+    HRESULT GetFrontBufferData(
+        [in] IWineD3DSurface *dst_surface
+    );
+    HRESULT GetBackBuffer(
+        [in] UINT backbuffer_idx,
+        [in] WINED3DBACKBUFFER_TYPE backbuffer_type,
+        [out] IWineD3DSurface **backbuffer
+    );
+    HRESULT GetRasterStatus(
+        [out] WINED3DRASTER_STATUS *raster_status
+    );
+    HRESULT GetDisplayMode(
+        [out] WINED3DDISPLAYMODE *mode
+    );
+    HRESULT GetPresentParameters(
+        [out] WINED3DPRESENT_PARAMETERS *present_parameters
+    );
+    HRESULT SetGammaRamp(
+        [in] DWORD flags,
+        [in] const WINED3DGAMMARAMP *ramp
+    );
+    HRESULT GetGammaRamp(
+        [out] WINED3DGAMMARAMP *ramp
+    );
+}
+
+[
+    object,
+    local,
+    uuid(eac93065-a4df-446f-86a1-9ef2bca40a3c)
+]
+interface IWineD3DBaseShader : IWineD3DBase
+{
+    HRESULT SetFunction(
+        [in] const DWORD *function
+    );
+}
+
+[
+    object,
+    local,
+    uuid(7f7a2b60-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DVertexShader : IWineD3DBaseShader
+{
+    HRESULT GetDevice(
+        [out] IWineD3DDevice **device
+    );
+    HRESULT GetFunction(
+        [out] void *data,
+        [in, out] UINT *data_size
+    );
+    void FakeSemantics(
+        [in] IWineD3DVertexDeclaration *vertex_declaration
+    );
+    HRESULT SetLocalConstantsF(
+        [in] UINT start_idx,
+        [in] const float *src_data,
+        [in] UINT vector4f_count
+    );
+}
+
+[
+    object,
+    local,
+    uuid(818503da-6f30-11d9-c687-00046142c14f)
+]
+interface IWineD3DPixelShader : IWineD3DBaseShader
+{
+    HRESULT UpdateSamplers(
+    );
+    HRESULT GetDevice(
+        [out] IWineD3DDevice **device
+    );
+    HRESULT GetFunction(
+        [out] void *data,
+        [in, out] UINT *data_size
+    );
+}
+
+[
+    object,
+    local,
+    uuid(6d10a2ce-09d0-4a53-a427-11388f9f8ca5)
+]
+interface IWineD3DDevice : IWineD3DBase
+{
+    HRESULT CreateVertexBuffer(
+        [in] UINT length,
+        [in] DWORD usage,
+        [in] DWORD fvf,
+        [in] WINED3DPOOL pool,
+        [out] IWineD3DVertexBuffer **vertex_buffer,
+        [in] HANDLE *shared_handle,
+        [in] IUnknown *parent
+    );
+    HRESULT CreateIndexBuffer(
+        [in] UINT length,
+        [in] DWORD usage,
+        [in] WINED3DFORMAT format,
+        [in] WINED3DPOOL pool,
+        [out] IWineD3DIndexBuffer **index_buffer,
+        [in] HANDLE *shared_handle,
+        [in] IUnknown *parent
+    );
+    HRESULT CreateStateBlock(
+        [in] WINED3DSTATEBLOCKTYPE type,
+        [out] IWineD3DStateBlock **stateblock,
+        [in] IUnknown *parent
+    );
+    HRESULT CreateSurface(
+        [in] UINT width,
+        [in] UINT height,
+        [in] WINED3DFORMAT format,
+        [in] BOOL lockable,
+        [in] BOOL discard,
+        [in] UINT level,
+        [out] IWineD3DSurface **surface,
+        [in] WINED3DRESOURCETYPE resource_type,
+        [in] DWORD usage,
+        [in] WINED3DPOOL pool,
+        [in] WINED3DMULTISAMPLE_TYPE multisample_type,
+        [in] DWORD multisample_quality,
+        [in] HANDLE *shared_handle,
+        [in] WINED3DSURFTYPE surface_type,
+        [in] IUnknown *parent
+    );
+    HRESULT CreateTexture(
+        [in] UINT width,
+        [in] UINT height,
+        [in] UINT levels,
+        [in] DWORD usage,
+        [in] WINED3DFORMAT format,
+        [in] WINED3DPOOL pool,
+        [out] IWineD3DTexture **texture,
+        [in] HANDLE *shared_handle,
+        [in] IUnknown *parent,
+        [in] D3DCB_CREATESURFACEFN create_surface_callback
+    );
+    HRESULT CreateVolumeTexture(
+        [in] UINT width,
+        [in] UINT height,
+        [in] UINT depth,
+        [in] UINT levels,
+        [in] DWORD usage,
+        [in] WINED3DFORMAT format,
+        [in] WINED3DPOOL pool,
+        [out] IWineD3DVolumeTexture **texture,
+        [in] HANDLE *shared_handle,
+        [in] IUnknown *parent,
+        [in] D3DCB_CREATEVOLUMEFN create_volume_callback
+    );
+    HRESULT CreateVolume(
+        [in] UINT width,
+        [in] UINT height,
+        [in] UINT depth,
+        [in] DWORD usage,
+        [in] WINED3DFORMAT format,
+        [in] WINED3DPOOL pool,
+        [out] IWineD3DVolume **volume,
+        [in] HANDLE *shared_handle,
+        [in] IUnknown *parent
+    );
+    HRESULT CreateCubeTexture(
+        [in] UINT edge_length,
+        [in] UINT levels,
+        [in] DWORD usage,
+        [in] WINED3DFORMAT format,
+        [in] WINED3DPOOL pool,
+        [out] IWineD3DCubeTexture **texture,
+        [in] HANDLE *shared_handle,
+        [in] IUnknown *parent,
+        [in] D3DCB_CREATESURFACEFN create_surface_callback
+    );
+    HRESULT CreateQuery(
+        [in] WINED3DQUERYTYPE type,
+        [out] IWineD3DQuery **query,
+        [in] IUnknown *parent
+    );
+    HRESULT CreateSwapChain(
+        [in] WINED3DPRESENT_PARAMETERS *present_parameters,
+        [out] IWineD3DSwapChain **swapchain,
+        [in] IUnknown *parent,
+        [in] D3DCB_CREATERENDERTARGETFN create_render_target_callback,
+        [in] D3DCB_CREATEDEPTHSTENCILSURFACEFN create_depth_stencil_callback,
+        [in] WINED3DSURFTYPE surface_type
+    );
+    HRESULT CreateVertexDeclaration(
+        [out] IWineD3DVertexDeclaration **declaration,
+        [in] IUnknown *parent,
+        [in] const WINED3DVERTEXELEMENT *elements,
+        [in] UINT element_count
+    );
+    HRESULT CreateVertexDeclarationFromFVF(
+        [out] IWineD3DVertexDeclaration **declaration,
+        [in] IUnknown *parent,
+        [in] DWORD fvf
+    );
+    HRESULT CreateVertexShader(
+        [in] IWineD3DVertexDeclaration *declaration,
+        [in] const DWORD *function,
+        [out] IWineD3DVertexShader **shader,
+        [in] IUnknown *parent
+    );
+    HRESULT CreatePixelShader(
+        [in] const DWORD *function,
+        [out] IWineD3DPixelShader **shader,
+        [in] IUnknown *parent
+    );
+    HRESULT CreatePalette(
+        [in] DWORD flags,
+        [in] const PALETTEENTRY *palette_entry,
+        [out] IWineD3DPalette **palette,
+        [in] IUnknown *parent
+    );
+    HRESULT Init3D(
+        [in] WINED3DPRESENT_PARAMETERS *present_parameters,
+        [in] D3DCB_CREATESWAPCHAIN create_swapchain_callback
+    );
+    HRESULT InitGDI(
+        [in] WINED3DPRESENT_PARAMETERS *present_parameters,
+        [in] D3DCB_CREATESWAPCHAIN create_swapchain_callback
+    );
+    HRESULT Uninit3D(
+        [in] D3DCB_DESTROYSURFACEFN destroy_surface_callback,
+        [in] D3DCB_DESTROYSWAPCHAINFN destroy_swapchain_callback
+    );
+    HRESULT UninitGDI(
+        [in] D3DCB_DESTROYSWAPCHAINFN destroy_swapchain_callback
+    );
+    void SetMultithreaded(
+    );
+    HRESULT EvictManagedResources(
+    );
+    UINT GetAvailableTextureMem(
+    );
+    HRESULT GetBackBuffer(
+        [in] UINT swapchain_idx,
+        [in] UINT backbuffer_idx,
+        [in] WINED3DBACKBUFFER_TYPE backbuffer_type,
+        [out] IWineD3DSurface **backbuffer
+    );
+    HRESULT GetCreationParameters(
+        [out] WINED3DDEVICE_CREATION_PARAMETERS *creation_parameters
+    );
+    HRESULT GetDeviceCaps(
+        [out] WINED3DCAPS *caps
+    );
+    HRESULT GetDirect3D(
+        [out] IWineD3D** d3d
+    );
+    HRESULT GetDisplayMode(
+        [in] UINT swapchain_idx,
+        [out] WINED3DDISPLAYMODE *mode
+    );
+    HRESULT SetDisplayMode(
+        [in] UINT swapchain_idx,
+        [in] const WINED3DDISPLAYMODE *mode
+    );
+    UINT GetNumberOfSwapChains(
+    );
+    HRESULT GetRasterStatus(
+        [in] UINT swapchain_idx,
+        [out] WINED3DRASTER_STATUS *raster_status
+    );
+    HRESULT GetSwapChain(
+        [in] UINT swapchain_idx,
+        [out] IWineD3DSwapChain **swapchain
+    );
+    HRESULT Reset(
+        [in] WINED3DPRESENT_PARAMETERS *present_parameters
+    );
+    HRESULT SetDialogBoxMode(
+        [in] BOOL enable_dialogs
+    );
+    HRESULT SetCursorProperties(
+        [in] UINT x_hotspot,
+        [in] UINT y_hotspot,
+        [in] IWineD3DSurface *cursor_surface
+    );
+    void SetCursorPosition(
+        [in] int x_screen_space,
+        [in] int y_screen_space,
+        [in] DWORD flags
+    );
+    BOOL ShowCursor(
+        [in] BOOL show
+    );
+    HRESULT TestCooperativeLevel(
+    );
+    HRESULT SetClipPlane(
+        [in] DWORD plane_idx,
+        [in] const float *plane
+    );
+    HRESULT GetClipPlane(
+        [in] DWORD plane_idx,
+        [out] float *plane
+    );
+    HRESULT SetClipStatus(
+        [in] const WINED3DCLIPSTATUS *clip_status
+    );
+    HRESULT GetClipStatus(
+        [out] WINED3DCLIPSTATUS *clip_status
+    );
+    HRESULT SetCurrentTexturePalette(
+        [in] UINT palette_number
+    );
+    HRESULT GetCurrentTexturePalette(
+        [out] UINT *palette_number
+    );
+    HRESULT SetDepthStencilSurface(
+        [in] IWineD3DSurface *depth_stencil
+    );
+    HRESULT GetDepthStencilSurface(
+        [out] IWineD3DSurface **depth_stencil
+    );
+    HRESULT SetFVF(
+        [in] DWORD fvf
+    );
+    HRESULT GetFVF(
+        [out] DWORD *fvf
+    );
+    void SetGammaRamp(
+        [in] UINT swapchain_idx,
+        [in] DWORD flags,
+        [in] const WINED3DGAMMARAMP *ramp
+    );
+    void GetGammaRamp(
+        [in] UINT swapchain_idx,
+        [out] WINED3DGAMMARAMP *ramp
+    );
+    HRESULT SetIndices(
+        [in] IWineD3DIndexBuffer *index_buffer
+    );
+    HRESULT GetIndices(
+        [out] IWineD3DIndexBuffer **index_buffer
+    );
+    HRESULT SetBaseVertexIndex(
+        [in] INT base_index
+    );
+    HRESULT GetBaseVertexIndex(
+        [out] INT *base_index
+    );
+    HRESULT SetLight(
+        [in] DWORD light_idx,
+        [in] const WINED3DLIGHT *light
+    );
+    HRESULT GetLight(
+        [in] DWORD light_idx,
+        [out] WINED3DLIGHT *light
+    );
+    HRESULT SetLightEnable(
+        [in] DWORD light_idx,
+        [in] BOOL enable
+    );
+    HRESULT GetLightEnable(
+        [in] DWORD light_idx,
+        [out] BOOL *enable
+    );
+    HRESULT SetMaterial(
+        [in] const WINED3DMATERIAL *material
+    );
+    HRESULT GetMaterial(
+        [out] WINED3DMATERIAL *material
+    );
+    HRESULT SetNPatchMode(
+        [in] float segments
+    );
+    float GetNPatchMode(
+    );
+    HRESULT SetPaletteEntries(
+        [in] UINT palette_number,
+        [in] const PALETTEENTRY *entries
+    );
+    HRESULT GetPaletteEntries(
+        [in] UINT palette_number,
+        [out] PALETTEENTRY *entries
+    );
+    HRESULT SetPixelShader(
+        [in] IWineD3DPixelShader *shader
+    );
+    HRESULT GetPixelShader(
+        [out] IWineD3DPixelShader **shader
+    );
+    HRESULT SetPixelShaderConstantB(
+        [in] UINT start_register,
+        [in] const BOOL *constants,
+        [in] UINT bool_count
+    );
+    HRESULT GetPixelShaderConstantB(
+        [in] UINT start_register,
+        [out] BOOL *constants,
+        [in] UINT bool_count
+    );
+    HRESULT SetPixelShaderConstantI(
+        [in] UINT start_register,
+        [in] const int *constants,
+        [in] UINT vector4i_count
+    );
+    HRESULT GetPixelShaderConstantI(
+        [in] UINT start_register,
+        [out] int *constants,
+        [in] UINT vector4i_count
+    );
+    HRESULT SetPixelShaderConstantF(
+        [in] UINT start_register,
+        [in] const float *constants,
+        [in] UINT vector4f_count
+    );
+    HRESULT GetPixelShaderConstantF(
+        [in] UINT start_register,
+        [out] float *constants,
+        [in] UINT vector4f_count
+    );
+    HRESULT SetRenderState(
+        [in] WINED3DRENDERSTATETYPE state,
+        [in] DWORD value
+    );
+    HRESULT GetRenderState(
+        [in] WINED3DRENDERSTATETYPE state,
+        [out] DWORD *value
+    );
+    HRESULT SetRenderTarget(
+        [in] DWORD render_target_idx,
+        [in] IWineD3DSurface *render_target
+    );
+    HRESULT GetRenderTarget(
+        [in] DWORD render_target_idx,
+        [out] IWineD3DSurface **render_target
+    );
+    HRESULT SetFrontBackBuffers(
+        [in] IWineD3DSurface *front,
+        [in] IWineD3DSurface *back
+    );
+    HRESULT SetSamplerState(
+        [in] DWORD sampler_idx,
+        [in] WINED3DSAMPLERSTATETYPE state,
+        [in] DWORD value
+    );
+    HRESULT GetSamplerState(
+        [in] DWORD sampler_idx,
+        [in] WINED3DSAMPLERSTATETYPE state,
+        [out] DWORD *value
+    );
+    HRESULT SetScissorRect(
+        [in] const RECT *rect
+    );
+    HRESULT GetScissorRect(
+        [out] RECT *rect
+    );
+    HRESULT SetSoftwareVertexProcessing(
+        [in] BOOL software
+    );
+    BOOL GetSoftwareVertexProcessing(
+    );
+    HRESULT SetStreamSource(
+        [in] UINT stream_idx,
+        [in] IWineD3DVertexBuffer *vertex_buffer,
+        [in] UINT offset,
+        [in] UINT stride
+    );
+    HRESULT GetStreamSource(
+        [in] UINT stream_idx,
+        [out] IWineD3DVertexBuffer **vertex_buffer,
+        [out] UINT *offset,
+        [out] UINT *stride
+    );
+    HRESULT SetStreamSourceFreq(
+        [in] UINT stream_idx,
+        [in] UINT divider
+    );
+    HRESULT GetStreamSourceFreq(
+        [in] UINT stream_idx,
+        [out] UINT *divider
+    );
+    HRESULT SetTexture(
+        [in] DWORD stage,
+        [in] IWineD3DBaseTexture *texture
+    );
+    HRESULT GetTexture(
+        [in] DWORD stage,
+        [out] IWineD3DBaseTexture **texture
+    );
+    HRESULT SetTextureStageState(
+        [in] DWORD stage,
+        [in] WINED3DTEXTURESTAGESTATETYPE state,
+        [in] DWORD value
+    );
+    HRESULT GetTextureStageState(
+        [in] DWORD stage,
+        [in] WINED3DTEXTURESTAGESTATETYPE state,
+        [out] DWORD *value
+    );
+    HRESULT SetTransform(
+        [in] WINED3DTRANSFORMSTATETYPE state,
+        [in] const WINED3DMATRIX *matrix
+    );
+    HRESULT GetTransform(
+        [in] WINED3DTRANSFORMSTATETYPE state,
+        [out] WINED3DMATRIX *matrix
+    );
+    HRESULT SetVertexDeclaration(
+        [in] IWineD3DVertexDeclaration *declaration
+    );
+    HRESULT GetVertexDeclaration(
+        [out] IWineD3DVertexDeclaration **declaration
+    );
+    HRESULT SetVertexShader(
+        [in] IWineD3DVertexShader *shader
+    );
+    HRESULT GetVertexShader(
+        [out] IWineD3DVertexShader **shader
+    );
+    HRESULT SetVertexShaderConstantB(
+        [in] UINT start_register,
+        [in] const BOOL *constants,
+        [in] UINT bool_count
+    );
+    HRESULT GetVertexShaderConstantB(
+        [in] UINT start_register,
+        [out] BOOL *constants,
+        [in] UINT bool_count
+    );
+    HRESULT SetVertexShaderConstantI(
+        [in] UINT start_register,
+        [in] const int *constants,
+        [in] UINT vector4i_count
+    );
+    HRESULT GetVertexShaderConstantI(
+        [in] UINT start_register,
+        [out] int *constants,
+        [in] UINT vector4i_count
+    );
+    HRESULT SetVertexShaderConstantF(
+        [in] UINT start_register,
+        [in] const float *constants,
+        [in] UINT vector4f_count
+    );
+    HRESULT GetVertexShaderConstantF(
+        [in] UINT start_register,
+        [out] float *constants,
+        [in] UINT vector4f_count
+    );
+    HRESULT SetViewport(
+        [in] const WINED3DVIEWPORT *viewport
+    );
+    HRESULT GetViewport(
+        [out] WINED3DVIEWPORT *viewport
+    );
+    HRESULT MultiplyTransform(
+        [in] WINED3DTRANSFORMSTATETYPE state,
+        [in] const WINED3DMATRIX *matrix
+    );
+    HRESULT ValidateDevice(
+        [out] DWORD *num_passes
+    );
+    HRESULT ProcessVertices(
+        [in] UINT src_start_idx,
+        [in] UINT dst_idx,
+        [in] UINT vertex_count,
+        [in] IWineD3DVertexBuffer *dest_buffer,
+        [in] IWineD3DVertexDeclaration *declaration,
+        [in] DWORD flags
+    );
+    HRESULT BeginStateBlock(
+    );
+    HRESULT EndStateBlock(
+        [out] IWineD3DStateBlock **stateblock
+    );
+    HRESULT BeginScene(
+    );
+    HRESULT EndScene(
+    );
+    HRESULT Present(
+        [in] const RECT *src_rect,
+        [in] const RECT *dst_rect,
+        [in] HWND dst_window_override,
+        [in] const RGNDATA *dirty_region
+    );
+    HRESULT Clear(
+        [in] DWORD rect_count,
+        [in] const WINED3DRECT *rects,
+        [in] DWORD flags,
+        [in] WINED3DCOLOR color,
+        [in] float z,
+        [in] DWORD stencil
+    );
+    HRESULT DrawPrimitive(
+        [in] WINED3DPRIMITIVETYPE primitive_type,
+        [in] UINT start_vertex,
+        [in] UINT primitive_count
+    );
+    HRESULT DrawIndexedPrimitive(
+        [in] WINED3DPRIMITIVETYPE primitive_type,
+        [in] UINT min_vertex_idx,
+        [in] UINT vertex_count,
+        [in] UINT start_idx,
+        [in] UINT primitive_count
+    );
+    HRESULT DrawPrimitiveUP(
+        [in] WINED3DPRIMITIVETYPE primitive_type,
+        [in] UINT primitive_count,
+        [in] const void *stream_data,
+        [in] UINT stream_stride
+    );
+    HRESULT DrawIndexedPrimitiveUP(
+        [in] WINED3DPRIMITIVETYPE primitive_type,
+        [in] UINT min_vertex_idx,
+        [in] UINT vertex_count,
+        [in] UINT primitive_count,
+        [in] const void *index_data,
+        [in] WINED3DFORMAT index_data_format,
+        [in] const void *stream_data,
+        [in] UINT stream_stride
+    );
+    HRESULT DrawPrimitiveStrided(
+        [in] WINED3DPRIMITIVETYPE primitive_type,
+        [in] UINT primitive_count,
+        [in] const WineDirect3DVertexStridedData *strided_data
+    );
+    HRESULT DrawIndexedPrimitiveStrided(
+        [in] WINED3DPRIMITIVETYPE primitive_type,
+        [in] UINT primitive_count,
+        [in] const WineDirect3DVertexStridedData *strided_data,
+        [in] UINT vertex_count,
+        [in] const void *index_data,
+        [in] WINED3DFORMAT index_data_format
+    );
+    HRESULT DrawRectPatch(
+        [in] UINT handle,
+        [in] const float *num_segs,
+        [in] const WINED3DRECTPATCH_INFO *rect_patch_info
+    );
+    HRESULT DrawTriPatch(
+        [in] UINT handle,
+        [in] const float *num_segs,
+        [in] const WINED3DTRIPATCH_INFO *tri_patch_info
+    );
+    HRESULT DeletePatch(
+        [in] UINT handle
+    );
+    HRESULT ColorFill(
+        [in] IWineD3DSurface *surface,
+        [in] const WINED3DRECT *rect,
+        [in] WINED3DCOLOR color
+    );
+    HRESULT UpdateTexture(
+        [in] IWineD3DBaseTexture *src_texture,
+        [in] IWineD3DBaseTexture *dst_texture
+    );
+    HRESULT UpdateSurface(
+        [in] IWineD3DSurface *src_surface,
+        [in] const RECT *src_rect,
+        [in] IWineD3DSurface *dst_surface,
+        [in] const POINT *dst_point
+    );
+    HRESULT GetFrontBufferData(
+        [in] UINT swapchain_idx,
+        [in] IWineD3DSurface *dst_surface
+    );
+    void ResourceReleased(
+        [in] IWineD3DResource *resource
+    );
+    HRESULT EnumResources(
+        [in] D3DCB_ENUMRESOURCES callback,
+        [in] void *data
+    );
+}
+
+IWineD3D *WineDirect3DCreate(UINT dxVersion, IUnknown *parent);
+IWineD3DClipper *WineDirect3DCreateClipper(IUnknown *parent);
index ac97225..5fe0140 100644 (file)
@@ -4,6 +4,7 @@
        <importlibrary definition="wined3d.def" />
        <include base="wined3d">.</include>
        <include base="ReactOS">include/reactos/wine</include>
+       <include base="wined3d" root="intermediate">.</include>
        <define name="__WINESRC__" />
        <define name="USE_WIN32_OPENGL" />
 
@@ -49,4 +50,8 @@
        <file>volumetexture.c</file>
        <file>wined3d_main.c</file>
        <file>version.rc</file>
+       <dependency>wined3d_header</dependency>
 </module>
+<module name="wined3d_header" type="idlheader" allowwarnings="true">
+       <file>wined3d.idl</file>
+</module>
\ No newline at end of file
diff --git a/reactos/dll/directx/wine/wined3d/wined3d_gl.h b/reactos/dll/directx/wine/wined3d/wined3d_gl.h
new file mode 100644 (file)
index 0000000..f92adc6
--- /dev/null
@@ -0,0 +1,3892 @@
+/*
+ * Direct3D wine OpenGL include file
+ *
+ * Copyright 2002-2003 The wine-d3d team
+ * Copyright 2002-2004 Jason Edmeades
+ *                     Raphael Junqueira
+ * Copyright 2007 Roderick Colenbrander
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ *
+ * Most OpenGL 1.0/1.1/1.2/1.3 constants/types come from the Mesa-project:
+ * Copyright (C) 1999-2006  Brian Paul
+ *
+ * From the Mesa-license:
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __WINE_WINED3D_GL_H
+#define __WINE_WINED3D_GL_H
+
+#ifdef USE_WIN32_OPENGL
+#define WINE_GLAPI __stdcall
+#else
+#define WINE_GLAPI
+#endif
+
+/****************************************************
+ * OpenGL 1.0/1.1/1.2/1.3
+ *     types, #defines and function pointers
+ ****************************************************/
+
+/* Types */
+typedef unsigned int    GLbitfield;
+typedef unsigned char   GLboolean;
+typedef signed char     GLbyte;
+typedef unsigned char   GLubyte;
+typedef short           GLshort;
+typedef unsigned short  GLushort;
+typedef int             GLint;
+typedef unsigned int    GLuint;
+typedef unsigned int    GLenum;
+typedef float           GLfloat;
+typedef int             GLsizei;
+typedef float           GLclampf;
+typedef double          GLdouble;
+typedef double          GLclampd;
+typedef void            GLvoid;
+
+/* Booleans */
+#define GL_FALSE                                0x0
+#define GL_TRUE                                 0x1
+
+/* Data types */
+#define GL_BYTE                                 0x1400
+#define GL_UNSIGNED_BYTE                        0x1401
+#define GL_SHORT                                0x1402
+#define GL_UNSIGNED_SHORT                       0x1403
+#define GL_INT                                  0x1404
+#define GL_UNSIGNED_INT                         0x1405
+#define GL_FLOAT                                0x1406
+#define GL_DOUBLE                               0x140A
+#define GL_2_BYTES                              0x1407
+#define GL_3_BYTES                              0x1408
+#define GL_4_BYTES                              0x1409
+
+/* Errors */
+#define GL_NO_ERROR                             0x0
+#define GL_INVALID_VALUE                        0x0501
+#define GL_INVALID_ENUM                         0x0500
+#define GL_INVALID_OPERATION                    0x0502
+#define GL_STACK_OVERFLOW                       0x0503
+#define GL_STACK_UNDERFLOW                      0x0504
+#define GL_OUT_OF_MEMORY                        0x0505
+
+/* Utility */
+#define GL_VENDOR                               0x1F00
+#define GL_RENDERER                             0x1F01
+#define GL_VERSION                              0x1F02
+#define GL_EXTENSIONS                           0x1F03
+
+/* Accumulation buffer */
+#define GL_ACCUM_RED_BITS                       0x0D58
+#define GL_ACCUM_GREEN_BITS                     0x0D59
+#define GL_ACCUM_BLUE_BITS                      0x0D5A
+#define GL_ACCUM_ALPHA_BITS                     0x0D5B
+#define GL_ACCUM_CLEAR_VALUE                    0x0B80
+#define GL_ACCUM                                0x0100
+#define GL_ADD                                  0x0104
+#define GL_LOAD                                 0x0101
+#define GL_MULT                                 0x0103
+#define GL_RETURN                               0x0102
+
+/* Alpha testing */
+#define GL_ALPHA_TEST                           0x0BC0
+#define GL_ALPHA_TEST_REF                       0x0BC2
+#define GL_ALPHA_TEST_FUNC                      0x0BC1
+
+/* Blending */
+#define GL_BLEND                                0x0BE2
+#define GL_BLEND_SRC                            0x0BE1
+#define GL_BLEND_DST                            0x0BE0
+#define GL_ZERO                                 0x0
+#define GL_ONE                                  0x1
+#define GL_SRC_COLOR                            0x0300
+#define GL_ONE_MINUS_SRC_COLOR                  0x0301
+#define GL_SRC_ALPHA                            0x0302
+#define GL_ONE_MINUS_SRC_ALPHA                  0x0303
+#define GL_DST_ALPHA                            0x0304
+#define GL_ONE_MINUS_DST_ALPHA                  0x0305
+#define GL_DST_COLOR                            0x0306
+#define GL_ONE_MINUS_DST_COLOR                  0x0307
+#define GL_SRC_ALPHA_SATURATE                   0x0308
+#define GL_CONSTANT_COLOR                       0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR             0x8002
+#define GL_CONSTANT_ALPHA                       0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA             0x8004
+
+/* Buffers, Pixel Drawing/Reading */
+#define GL_NONE                                 0x0
+#define GL_FRONT_LEFT                           0x0400
+#define GL_FRONT_RIGHT                          0x0401
+#define GL_BACK_LEFT                            0x0402
+#define GL_BACK_RIGHT                           0x0403
+#define GL_FRONT                                0x0404
+#define GL_BACK                                 0x0405
+#define GL_LEFT                                 0x0406
+#define GL_RIGHT                                0x0407
+#define GL_FRONT_AND_BACK                       0x0408
+#define GL_AUX0                                 0x0409
+#define GL_AUX1                                 0x040A
+#define GL_AUX2                                 0x040B
+#define GL_AUX3                                 0x040C
+#define GL_COLOR_INDEX                          0x1900
+#define GL_RED                                  0x1903
+#define GL_GREEN                                0x1904
+#define GL_BLUE                                 0x1905
+#define GL_ALPHA                                0x1906
+#define GL_LUMINANCE                            0x1909
+#define GL_LUMINANCE_ALPHA                      0x190A
+#define GL_ALPHA_BITS                           0x0D55
+#define GL_RED_BITS                             0x0D52
+#define GL_GREEN_BITS                           0x0D53
+#define GL_BLUE_BITS                            0x0D54
+#define GL_INDEX_BITS                           0x0D51
+#define GL_SUBPIXEL_BITS                        0x0D50
+#define GL_AUX_BUFFERS                          0x0C00
+#define GL_READ_BUFFER                          0x0C02
+#define GL_DRAW_BUFFER                          0x0C01
+#define GL_DOUBLEBUFFER                         0x0C32
+#define GL_STEREO                               0x0C33
+#define GL_BITMAP                               0x1A00
+#define GL_COLOR                                0x1800
+#define GL_DEPTH                                0x1801
+#define GL_STENCIL                              0x1802
+#define GL_DITHER                               0x0BD0
+#define GL_RGB                                  0x1907
+#define GL_RGBA                                 0x1908
+
+/* Clipping */
+#define GL_CLIP_PLANE0                          0x3000
+#define GL_CLIP_PLANE1                          0x3001
+#define GL_CLIP_PLANE2                          0x3002
+#define GL_CLIP_PLANE3                          0x3003
+#define GL_CLIP_PLANE4                          0x3004
+#define GL_CLIP_PLANE5                          0x3005
+
+/* Depth buffer */
+#define GL_NEVER                                0x0200
+#define GL_LESS                                 0x0201
+#define GL_EQUAL                                0x0202
+#define GL_LEQUAL                               0x0203
+#define GL_GREATER                              0x0204
+#define GL_NOTEQUAL                             0x0205
+#define GL_GEQUAL                               0x0206
+#define GL_ALWAYS                               0x0207
+#define GL_DEPTH_TEST                           0x0B71
+#define GL_DEPTH_BITS                           0x0D56
+#define GL_DEPTH_CLEAR_VALUE                    0x0B73
+#define GL_DEPTH_FUNC                           0x0B74
+#define GL_DEPTH_RANGE                          0x0B70
+#define GL_DEPTH_WRITEMASK                      0x0B72
+#define GL_DEPTH_COMPONENT                      0x1902
+
+/* Evaluators */
+#define GL_AUTO_NORMAL                          0x0D80
+#define GL_MAP1_COLOR_4                         0x0D90
+#define GL_MAP1_GRID_DOMAIN                     0x0DD0
+#define GL_MAP1_GRID_SEGMENTS                   0x0DD1
+#define GL_MAP1_INDEX                           0x0D91
+#define GL_MAP1_NORMAL                          0x0D92
+#define GL_MAP1_TEXTURE_COORD_1                 0x0D93
+#define GL_MAP1_TEXTURE_COORD_2                 0x0D94
+#define GL_MAP1_TEXTURE_COORD_3                 0x0D95
+#define GL_MAP1_TEXTURE_COORD_4                 0x0D96
+#define GL_MAP1_VERTEX_3                        0x0D97
+#define GL_MAP1_VERTEX_4                        0x0D98
+#define GL_MAP2_COLOR_4                         0x0DB0
+#define GL_MAP2_GRID_DOMAIN                     0x0DD2
+#define GL_MAP2_GRID_SEGMENTS                   0x0DD3
+#define GL_MAP2_INDEX                           0x0DB1
+#define GL_MAP2_NORMAL                          0x0DB2
+#define GL_MAP2_TEXTURE_COORD_1                 0x0DB3
+#define GL_MAP2_TEXTURE_COORD_2                 0x0DB4
+#define GL_MAP2_TEXTURE_COORD_3                 0x0DB5
+#define GL_MAP2_TEXTURE_COORD_4                 0x0DB6
+#define GL_MAP2_VERTEX_3                        0x0DB7
+#define GL_MAP2_VERTEX_4                        0x0DB8
+#define GL_COEFF                                0x0A00
+#define GL_DOMAIN                               0x0A02
+#define GL_ORDER                                0x0A01
+
+/* Feedback */
+#define GL_2D                                   0x0600
+#define GL_3D                                   0x0601
+#define GL_3D_COLOR                             0x0602
+#define GL_3D_COLOR_TEXTURE                     0x0603
+#define GL_4D_COLOR_TEXTURE                     0x0604
+#define GL_POINT_TOKEN                          0x0701
+#define GL_LINE_TOKEN                           0x0702
+#define GL_LINE_RESET_TOKEN                     0x0707
+#define GL_POLYGON_TOKEN                        0x0703
+#define GL_BITMAP_TOKEN                         0x0704
+#define GL_DRAW_PIXEL_TOKEN                     0x0705
+#define GL_COPY_PIXEL_TOKEN                     0x0706
+#define GL_PASS_THROUGH_TOKEN                   0x0700
+#define GL_FEEDBACK_BUFFER_POINTER              0x0DF0
+#define GL_FEEDBACK_BUFFER_SIZE                 0x0DF1
+#define GL_FEEDBACK_BUFFER_TYPE                 0x0DF2
+
+/* Fog */
+#define GL_FOG                                  0x0B60
+#define GL_FOG_MODE                             0x0B65
+#define GL_FOG_DENSITY                          0x0B62
+#define GL_FOG_COLOR                            0x0B66
+#define GL_FOG_INDEX                            0x0B61
+#define GL_FOG_START                            0x0B63
+#define GL_FOG_END                              0x0B64
+#define GL_LINEAR                               0x2601
+#define GL_EXP                                  0x0800
+#define GL_EXP2                                 0x0801
+
+/* Gets */
+#define GL_ATTRIB_STACK_DEPTH                   0x0BB0
+#define GL_CLIENT_ATTRIB_STACK_DEPTH            0x0BB1
+#define GL_COLOR_CLEAR_VALUE                    0x0C22
+#define GL_COLOR_WRITEMASK                      0x0C23
+#define GL_CURRENT_INDEX                        0x0B01
+#define GL_CURRENT_COLOR                        0x0B00
+#define GL_CURRENT_NORMAL                       0x0B02
+#define GL_CURRENT_RASTER_COLOR                 0x0B04
+#define GL_CURRENT_RASTER_DISTANCE              0x0B09
+#define GL_CURRENT_RASTER_INDEX                 0x0B05
+#define GL_CURRENT_RASTER_POSITION              0x0B07
+#define GL_CURRENT_RASTER_TEXTURE_COORDS        0x0B06
+#define GL_CURRENT_RASTER_POSITION_VALID        0x0B08
+#define GL_CURRENT_TEXTURE_COORDS               0x0B03
+#define GL_INDEX_CLEAR_VALUE                    0x0C20
+#define GL_INDEX_MODE                           0x0C30
+#define GL_INDEX_WRITEMASK                      0x0C21
+#define GL_MODELVIEW_MATRIX                     0x0BA6
+#define GL_MODELVIEW_STACK_DEPTH                0x0BA3
+#define GL_NAME_STACK_DEPTH                     0x0D70
+#define GL_PROJECTION_MATRIX                    0x0BA7
+#define GL_PROJECTION_STACK_DEPTH               0x0BA4
+#define GL_RENDER_MODE                          0x0C40
+#define GL_RGBA_MODE                            0x0C31
+#define GL_TEXTURE_MATRIX                       0x0BA8
+#define GL_TEXTURE_STACK_DEPTH                  0x0BA5
+#define GL_VIEWPORT                             0x0BA2
+
+/* Hints */
+#define GL_FOG_HINT                             0x0C54
+#define GL_LINE_SMOOTH_HINT                     0x0C52
+#define GL_PERSPECTIVE_CORRECTION_HINT          0x0C50
+#define GL_POINT_SMOOTH_HINT                    0x0C51
+#define GL_POLYGON_SMOOTH_HINT                  0x0C53
+#define GL_DONT_CARE                            0x1100
+#define GL_FASTEST                              0x1101
+#define GL_NICEST                               0x1102
+
+/* Implementation limits */
+#define GL_MAX_LIST_NESTING                     0x0B31
+#define GL_MAX_ATTRIB_STACK_DEPTH               0x0D35
+#define GL_MAX_MODELVIEW_STACK_DEPTH            0x0D36
+#define GL_MAX_NAME_STACK_DEPTH                 0x0D37
+#define GL_MAX_PROJECTION_STACK_DEPTH           0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH              0x0D39
+#define GL_MAX_EVAL_ORDER                       0x0D30
+#define GL_MAX_LIGHTS                           0x0D31
+#define GL_MAX_CLIP_PLANES                      0x0D32
+#define GL_MAX_TEXTURE_SIZE                     0x0D33
+#define GL_MAX_PIXEL_MAP_TABLE                  0x0D34
+#define GL_MAX_VIEWPORT_DIMS                    0x0D3A
+#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH        0x0D3B
+
+/* Lighting */
+#define GL_LIGHTING                             0x0B50
+#define GL_LIGHT0                               0x4000
+#define GL_LIGHT1                               0x4001
+#define GL_LIGHT2                               0x4002
+#define GL_LIGHT3                               0x4003
+#define GL_LIGHT4                               0x4004
+#define GL_LIGHT5                               0x4005
+#define GL_LIGHT6                               0x4006
+#define GL_LIGHT7                               0x4007
+#define GL_SPOT_EXPONENT                        0x1205
+#define GL_SPOT_CUTOFF                          0x1206
+#define GL_CONSTANT_ATTENUATION                 0x1207
+#define GL_LINEAR_ATTENUATION                   0x1208
+#define GL_QUADRATIC_ATTENUATION                0x1209
+#define GL_AMBIENT                              0x1200
+#define GL_DIFFUSE                              0x1201
+#define GL_SPECULAR                             0x1202
+#define GL_SHININESS                            0x1601
+#define GL_EMISSION                             0x1600
+#define GL_POSITION                             0x1203
+#define GL_SPOT_DIRECTION                       0x1204
+#define GL_AMBIENT_AND_DIFFUSE                  0x1602
+#define GL_COLOR_INDEXES                        0x1603
+#define GL_LIGHT_MODEL_TWO_SIDE                 0x0B52
+#define GL_LIGHT_MODEL_LOCAL_VIEWER             0x0B51
+#define GL_LIGHT_MODEL_AMBIENT                  0x0B53
+#define GL_FRONT_AND_BACK                       0x0408
+#define GL_SHADE_MODEL                          0x0B54
+#define GL_FLAT                                 0x1D00
+#define GL_SMOOTH                               0x1D01
+#define GL_COLOR_MATERIAL                       0x0B57
+#define GL_COLOR_MATERIAL_FACE                  0x0B55
+#define GL_COLOR_MATERIAL_PARAMETER             0x0B56
+#define GL_NORMALIZE                            0x0BA1
+
+/* Lines */
+#define GL_LINE_SMOOTH                          0x0B20
+#define GL_LINE_STIPPLE                         0x0B24
+#define GL_LINE_STIPPLE_PATTERN                 0x0B25
+#define GL_LINE_STIPPLE_REPEAT                  0x0B26
+#define GL_LINE_WIDTH                           0x0B21
+#define GL_LINE_WIDTH_GRANULARITY               0x0B23
+#define GL_LINE_WIDTH_RANGE                     0x0B22
+
+/* Logic Ops */
+#define GL_LOGIC_OP                             0x0BF1
+#define GL_INDEX_LOGIC_OP                       0x0BF1
+#define GL_COLOR_LOGIC_OP                       0x0BF2
+#define GL_LOGIC_OP_MODE                        0x0BF0
+#define GL_CLEAR                                0x1500
+#define GL_SET                                  0x150F
+#define GL_COPY                                 0x1503
+#define GL_COPY_INVERTED                        0x150C
+#define GL_NOOP                                 0x1505
+#define GL_INVERT                               0x150A
+#define GL_AND                                  0x1501
+#define GL_NAND                                 0x150E
+#define GL_OR                                   0x1507
+#define GL_NOR                                  0x1508
+#define GL_XOR                                  0x1506
+#define GL_EQUIV                                0x1509
+#define GL_AND_REVERSE                          0x1502
+#define GL_AND_INVERTED                         0x1504
+#define GL_OR_REVERSE                           0x150B
+#define GL_OR_INVERTED                          0x150D
+
+/* Matrix Mode */
+#define GL_MATRIX_MODE                          0x0BA0
+#define GL_MODELVIEW                            0x1700
+#define GL_PROJECTION                           0x1701
+#define GL_TEXTURE                              0x1702
+
+/* Pixel Mode / Transfer */
+#define GL_MAP_COLOR                            0x0D10
+#define GL_MAP_STENCIL                          0x0D11
+#define GL_INDEX_SHIFT                          0x0D12
+#define GL_INDEX_OFFSET                         0x0D13
+#define GL_RED_SCALE                            0x0D14
+#define GL_RED_BIAS                             0x0D15
+#define GL_GREEN_SCALE                          0x0D18
+#define GL_GREEN_BIAS                           0x0D19
+#define GL_BLUE_SCALE                           0x0D1A
+#define GL_BLUE_BIAS                            0x0D1B
+#define GL_ALPHA_SCALE                          0x0D1C
+#define GL_ALPHA_BIAS                           0x0D1D
+#define GL_DEPTH_SCALE                          0x0D1E
+#define GL_DEPTH_BIAS                           0x0D1F
+#define GL_PIXEL_MAP_S_TO_S_SIZE                0x0CB1
+#define GL_PIXEL_MAP_I_TO_I_SIZE                0x0CB0
+#define GL_PIXEL_MAP_I_TO_R_SIZE                0x0CB2
+#define GL_PIXEL_MAP_I_TO_G_SIZE                0x0CB3
+#define GL_PIXEL_MAP_I_TO_B_SIZE                0x0CB4
+#define GL_PIXEL_MAP_I_TO_A_SIZE                0x0CB5
+#define GL_PIXEL_MAP_R_TO_R_SIZE                0x0CB6
+#define GL_PIXEL_MAP_G_TO_G_SIZE                0x0CB7
+#define GL_PIXEL_MAP_B_TO_B_SIZE                0x0CB8
+#define GL_PIXEL_MAP_A_TO_A_SIZE                0x0CB9
+#define GL_PIXEL_MAP_S_TO_S                     0x0C71
+#define GL_PIXEL_MAP_I_TO_I                     0x0C70
+#define GL_PIXEL_MAP_I_TO_R                     0x0C72
+#define GL_PIXEL_MAP_I_TO_G                     0x0C73
+#define GL_PIXEL_MAP_I_TO_B                     0x0C74
+#define GL_PIXEL_MAP_I_TO_A                     0x0C75
+#define GL_PIXEL_MAP_R_TO_R                     0x0C76
+#define GL_PIXEL_MAP_G_TO_G                     0x0C77
+#define GL_PIXEL_MAP_B_TO_B                     0x0C78
+#define GL_PIXEL_MAP_A_TO_A                     0x0C79
+#define GL_PACK_ALIGNMENT                       0x0D05
+#define GL_PACK_LSB_FIRST                       0x0D01
+#define GL_PACK_ROW_LENGTH                      0x0D02
+#define GL_PACK_SKIP_PIXELS                     0x0D04
+#define GL_PACK_SKIP_ROWS                       0x0D03
+#define GL_PACK_SWAP_BYTES                      0x0D00
+#define GL_UNPACK_ALIGNMENT                     0x0CF5
+#define GL_UNPACK_LSB_FIRST                     0x0CF1
+#define GL_UNPACK_ROW_LENGTH                    0x0CF2
+#define GL_UNPACK_SKIP_PIXELS                   0x0CF4
+#define GL_UNPACK_SKIP_ROWS                     0x0CF3
+#define GL_UNPACK_SWAP_BYTES                    0x0CF0
+#define GL_ZOOM_X                               0x0D16
+#define GL_ZOOM_Y                               0x0D17
+
+/* Points */
+#define GL_POINT_SMOOTH                         0x0B10
+#define GL_POINT_SIZE                           0x0B11
+#define GL_POINT_SIZE_GRANULARITY               0x0B13
+#define GL_POINT_SIZE_RANGE                     0x0B12
+
+/* Polygons */
+#define GL_POINT                                0x1B00
+#define GL_LINE                                 0x1B01
+#define GL_FILL                                 0x1B02
+#define GL_CW                                   0x0900
+#define GL_CCW                                  0x0901
+#define GL_FRONT                                0x0404
+#define GL_BACK                                 0x0405
+#define GL_POLYGON_MODE                         0x0B40
+#define GL_POLYGON_SMOOTH                       0x0B41
+#define GL_POLYGON_STIPPLE                      0x0B42
+#define GL_EDGE_FLAG                            0x0B43
+#define GL_CULL_FACE                            0x0B44
+#define GL_CULL_FACE_MODE                       0x0B45
+#define GL_FRONT_FACE                           0x0B46
+#define GL_POLYGON_OFFSET_FACTOR                0x8038
+#define GL_POLYGON_OFFSET_UNITS                 0x2A00
+#define GL_POLYGON_OFFSET_POINT                 0x2A01
+#define GL_POLYGON_OFFSET_LINE                  0x2A02
+#define GL_POLYGON_OFFSET_FILL                  0x8037
+
+/* Primitives */
+#define GL_POINTS                               0x0000
+#define GL_LINES                                0x0001
+#define GL_LINE_LOOP                            0x0002
+#define GL_LINE_STRIP                           0x0003
+#define GL_TRIANGLES                            0x0004
+#define GL_TRIANGLE_STRIP                       0x0005
+#define GL_TRIANGLE_FAN                         0x0006
+#define GL_QUADS                                0x0007
+#define GL_QUAD_STRIP                           0x0008
+#define GL_POLYGON                              0x0009
+
+/* Push/Pop bits */
+#define GL_CURRENT_BIT                          0x00000001
+#define GL_POINT_BIT                            0x00000002
+#define GL_LINE_BIT                             0x00000004
+#define GL_POLYGON_BIT                          0x00000008
+#define GL_POLYGON_STIPPLE_BIT                  0x00000010
+#define GL_PIXEL_MODE_BIT                       0x00000020
+#define GL_LIGHTING_BIT                         0x00000040
+#define GL_FOG_BIT                              0x00000080
+#define GL_DEPTH_BUFFER_BIT                     0x00000100
+#define GL_ACCUM_BUFFER_BIT                     0x00000200
+#define GL_STENCIL_BUFFER_BIT                   0x00000400
+#define GL_VIEWPORT_BIT                         0x00000800
+#define GL_TRANSFORM_BIT                        0x00001000
+#define GL_ENABLE_BIT                           0x00002000
+#define GL_COLOR_BUFFER_BIT                     0x00004000
+#define GL_HINT_BIT                             0x00008000
+#define GL_EVAL_BIT                             0x00010000
+#define GL_LIST_BIT                             0x00020000
+#define GL_TEXTURE_BIT                          0x00040000
+#define GL_SCISSOR_BIT                          0x00080000
+#define GL_ALL_ATTRIB_BITS                      0x000FFFFF
+
+/* Render Mode */
+#define GL_FEEDBACK                             0x1C01
+#define GL_RENDER                               0x1C00
+#define GL_SELECT                               0x1C02
+
+/* Scissor box */
+#define GL_SCISSOR_TEST                         0x0C11
+#define GL_SCISSOR_BOX                          0x0C10
+
+/* Stencil */
+#define GL_STENCIL_TEST                         0x0B90
+#define GL_STENCIL_WRITEMASK                    0x0B98
+#define GL_STENCIL_BITS                         0x0D57
+#define GL_STENCIL_FUNC                         0x0B92
+#define GL_STENCIL_VALUE_MASK                   0x0B93
+#define GL_STENCIL_REF                          0x0B97
+#define GL_STENCIL_FAIL                         0x0B94
+#define GL_STENCIL_PASS_DEPTH_PASS              0x0B96
+#define GL_STENCIL_PASS_DEPTH_FAIL              0x0B95
+#define GL_STENCIL_CLEAR_VALUE                  0x0B91
+#define GL_STENCIL_INDEX                        0x1901
+#define GL_KEEP                                 0x1E00
+#define GL_REPLACE                              0x1E01
+#define GL_INCR                                 0x1E02
+#define GL_DECR                                 0x1E03
+
+/* Texture mapping */
+#define GL_TEXTURE_ENV                          0x2300
+#define GL_TEXTURE_ENV_MODE                     0x2200
+#define GL_TEXTURE_1D                           0x0DE0
+#define GL_TEXTURE_2D                           0x0DE1
+#define GL_TEXTURE_WRAP_S                       0x2802
+#define GL_TEXTURE_WRAP_T                       0x2803
+#define GL_TEXTURE_MAG_FILTER                   0x2800
+#define GL_TEXTURE_MIN_FILTER                   0x2801
+#define GL_TEXTURE_ENV_COLOR                    0x2201
+#define GL_TEXTURE_GEN_S                        0x0C60
+#define GL_TEXTURE_GEN_T                        0x0C61
+#define GL_TEXTURE_GEN_MODE                     0x2500
+#define GL_TEXTURE_BORDER_COLOR                 0x1004
+#define GL_TEXTURE_WIDTH                        0x1000
+#define GL_TEXTURE_HEIGHT                       0x1001
+#define GL_TEXTURE_BORDER                       0x1005
+#define GL_TEXTURE_COMPONENTS                   0x1003
+#define GL_TEXTURE_RED_SIZE                     0x805C
+#define GL_TEXTURE_GREEN_SIZE                   0x805D
+#define GL_TEXTURE_BLUE_SIZE                    0x805E
+#define GL_TEXTURE_ALPHA_SIZE                   0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE               0x8060
+#define GL_TEXTURE_INTENSITY_SIZE               0x8061
+#define GL_NEAREST_MIPMAP_NEAREST               0x2700
+#define GL_NEAREST_MIPMAP_LINEAR                0x2702
+#define GL_LINEAR_MIPMAP_NEAREST                0x2701
+#define GL_LINEAR_MIPMAP_LINEAR                 0x2703
+#define GL_OBJECT_LINEAR                        0x2401
+#define GL_OBJECT_PLANE                         0x2501
+#define GL_EYE_LINEAR                           0x2400
+#define GL_EYE_PLANE                            0x2502
+#define GL_SPHERE_MAP                           0x2402
+#define GL_DECAL                                0x2101
+#define GL_MODULATE                             0x2100
+#define GL_NEAREST                              0x2600
+#define GL_REPEAT                               0x2901
+#define GL_CLAMP                                0x2900
+#define GL_S                                    0x2000
+#define GL_T                                    0x2001
+#define GL_R                                    0x2002
+#define GL_Q                                    0x2003
+#define GL_TEXTURE_GEN_R                        0x0C62
+#define GL_TEXTURE_GEN_Q                        0x0C63
+
+/* Vertex Arrays */
+#define GL_VERTEX_ARRAY                         0x8074
+#define GL_NORMAL_ARRAY                         0x8075
+#define GL_COLOR_ARRAY                          0x8076
+#define GL_INDEX_ARRAY                          0x8077
+#define GL_TEXTURE_COORD_ARRAY                  0x8078
+#define GL_EDGE_FLAG_ARRAY                      0x8079
+#define GL_VERTEX_ARRAY_SIZE                    0x807A
+#define GL_VERTEX_ARRAY_TYPE                    0x807B
+#define GL_VERTEX_ARRAY_STRIDE                  0x807C
+#define GL_NORMAL_ARRAY_TYPE                    0x807E
+#define GL_NORMAL_ARRAY_STRIDE                  0x807F
+#define GL_COLOR_ARRAY_SIZE                     0x8081
+#define GL_COLOR_ARRAY_TYPE                     0x8082
+#define GL_COLOR_ARRAY_STRIDE                   0x8083
+#define GL_INDEX_ARRAY_TYPE                     0x8085
+#define GL_INDEX_ARRAY_STRIDE                   0x8086
+#define GL_TEXTURE_COORD_ARRAY_SIZE             0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE             0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE           0x808A
+#define GL_EDGE_FLAG_ARRAY_STRIDE               0x808C
+#define GL_VERTEX_ARRAY_POINTER                 0x808E
+#define GL_NORMAL_ARRAY_POINTER                 0x808F
+#define GL_COLOR_ARRAY_POINTER                  0x8090
+#define GL_INDEX_ARRAY_POINTER                  0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER          0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER              0x8093
+#define GL_V2F                                  0x2A20
+#define GL_V3F                                  0x2A21
+#define GL_C4UB_V2F                             0x2A22
+#define GL_C4UB_V3F                             0x2A23
+#define GL_C3F_V3F                              0x2A24
+#define GL_N3F_V3F                              0x2A25
+#define GL_C4F_N3F_V3F                          0x2A26
+#define GL_T2F_V3F                              0x2A27
+#define GL_T4F_V4F                              0x2A28
+#define GL_T2F_C4UB_V3F                         0x2A29
+#define GL_T2F_C3F_V3F                          0x2A2A
+#define GL_T2F_N3F_V3F                          0x2A2B
+#define GL_T2F_C4F_N3F_V3F                      0x2A2C
+#define GL_T4F_C4F_N3F_V4F                      0x2A2D
+
+/* OpenGL 1.1 */
+#define GL_PROXY_TEXTURE_1D                     0x8063
+#define GL_PROXY_TEXTURE_2D                     0x8064
+#define GL_TEXTURE_PRIORITY                     0x8066
+#define GL_TEXTURE_RESIDENT                     0x8067
+#define GL_TEXTURE_BINDING_1D                   0x8068
+#define GL_TEXTURE_BINDING_2D                   0x8069
+#define GL_TEXTURE_INTERNAL_FORMAT              0x1003
+#define GL_ALPHA4                               0x803B
+#define GL_ALPHA8                               0x803C
+#define GL_ALPHA12                              0x803D
+#define GL_ALPHA16                              0x803E
+#define GL_LUMINANCE4                           0x803F
+#define GL_LUMINANCE8                           0x8040
+#define GL_LUMINANCE12                          0x8041
+#define GL_LUMINANCE16                          0x8042
+#define GL_LUMINANCE4_ALPHA4                    0x8043
+#define GL_LUMINANCE6_ALPHA2                    0x8044
+#define GL_LUMINANCE8_ALPHA8                    0x8045
+#define GL_LUMINANCE12_ALPHA4                   0x8046
+#define GL_LUMINANCE12_ALPHA12                  0x8047
+#define GL_LUMINANCE16_ALPHA16                  0x8048
+#define GL_INTENSITY                            0x8049
+#define GL_INTENSITY4                           0x804A
+#define GL_INTENSITY8                           0x804B
+#define GL_INTENSITY12                          0x804C
+#define GL_INTENSITY16                          0x804D
+#define GL_R3_G3_B2                             0x2A10
+#define GL_RGB4                                 0x804F
+#define GL_RGB5                                 0x8050
+#define GL_RGB8                                 0x8051
+#define GL_RGB10                                0x8052
+#define GL_RGB12                                0x8053
+#define GL_RGB16                                0x8054
+#define GL_RGBA2                                0x8055
+#define GL_RGBA4                                0x8056
+#define GL_RGB5_A1                              0x8057
+#define GL_RGBA8                                0x8058
+#define GL_RGB10_A2                             0x8059
+#define GL_RGBA12                               0x805A
+#define GL_RGBA16                               0x805B
+#define GL_CLIENT_PIXEL_STORE_BIT               0x00000001
+#define GL_CLIENT_VERTEX_ARRAY_BIT              0x00000002
+#define GL_ALL_CLIENT_ATTRIB_BITS               0xFFFFFFFF
+#define GL_CLIENT_ALL_ATTRIB_BITS               0xFFFFFFFF
+
+/* OpenGL 1.2 constants */
+#define GL_PACK_SKIP_IMAGES               0x806B
+#define GL_PACK_IMAGE_HEIGHT              0x806C
+#define GL_UNPACK_SKIP_IMAGES             0x806D
+#define GL_UNPACK_IMAGE_HEIGHT            0x806E
+#define GL_TEXTURE_3D                     0x806F
+#define GL_PROXY_TEXTURE_3D               0x8070
+#define GL_TEXTURE_DEPTH                  0x8071
+#define GL_TEXTURE_WRAP_R                 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE            0x8073
+#define GL_BGR                            0x80E0
+#define GL_BGRA                           0x80E1
+#define GL_UNSIGNED_BYTE_3_3_2            0x8032
+#define GL_UNSIGNED_BYTE_2_3_3_REV        0x8362
+#define GL_UNSIGNED_SHORT_5_6_5           0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV       0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4         0x8033
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV     0x8365
+#define GL_UNSIGNED_SHORT_5_5_5_1         0x8034
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV     0x8366
+#define GL_UNSIGNED_INT_8_8_8_8           0x8035
+#define GL_UNSIGNED_INT_8_8_8_8_REV       0x8367
+#define GL_UNSIGNED_INT_10_10_10_2        0x8036
+#define GL_UNSIGNED_INT_2_10_10_10_REV    0x8368
+#define GL_RESCALE_NORMAL                 0x803A
+#define GL_TEXTURE_BINDING_3D             0x806A
+#define GL_LIGHT_MODEL_COLOR_CONTROL      0x81F8
+#define GL_SINGLE_COLOR                   0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR        0x81FA
+#define GL_CLAMP_TO_EDGE                  0x812F
+#define GL_TEXTURE_MIN_LOD                0x813A
+#define GL_TEXTURE_MAX_LOD                0x813B
+#define GL_TEXTURE_BASE_LEVEL             0x813C
+#define GL_TEXTURE_MAX_LEVEL              0x813D
+#define GL_MAX_ELEMENTS_VERTICES          0x80E8
+#define GL_MAX_ELEMENTS_INDICES           0x80E9
+#define GL_ALIASED_POINT_SIZE_RANGE       0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE       0x846E
+
+/* OpenGL 1.3 constants */
+#define GL_ACTIVE_TEXTURE                 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE          0x84E1
+#define GL_MAX_TEXTURE_UNITS              0x84E2
+#define GL_TEXTURE0                       0x84C0
+#define GL_TEXTURE1                       0x84C1
+#define GL_TEXTURE2                       0x84C2
+#define GL_TEXTURE3                       0x84C3
+#define GL_TEXTURE4                       0x84C4
+#define GL_TEXTURE5                       0x84C5
+#define GL_TEXTURE6                       0x84C6
+#define GL_TEXTURE7                       0x84C7
+#define GL_TEXTURE8                       0x84C8
+#define GL_TEXTURE9                       0x84C9
+#define GL_TEXTURE10                      0x84CA
+#define GL_TEXTURE11                      0x84CB
+#define GL_TEXTURE12                      0x84CC
+#define GL_TEXTURE13                      0x84CD
+#define GL_TEXTURE14                      0x84CE
+#define GL_TEXTURE15                      0x84CF
+#define GL_TEXTURE16                      0x84D0
+#define GL_TEXTURE17                      0x84D1
+#define GL_TEXTURE18                      0x84D2
+#define GL_TEXTURE19                      0x84D3
+#define GL_TEXTURE20                      0x84D4
+#define GL_TEXTURE21                      0x84D5
+#define GL_TEXTURE22                      0x84D6
+#define GL_TEXTURE23                      0x84D7
+#define GL_TEXTURE24                      0x84D8
+#define GL_TEXTURE25                      0x84D9
+#define GL_TEXTURE26                      0x84DA
+#define GL_TEXTURE27                      0x84DB
+#define GL_TEXTURE28                      0x84DC
+#define GL_TEXTURE29                      0x84DD
+#define GL_TEXTURE30                      0x84DE
+#define GL_TEXTURE31                      0x84DF
+#define GL_NORMAL_MAP                     0x8511
+#define GL_REFLECTION_MAP                 0x8512
+#define GL_TEXTURE_CUBE_MAP               0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP       0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X    0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X    0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y    0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y    0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z    0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z    0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP         0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE      0x851C
+#define GL_COMBINE                        0x8570
+#define GL_COMBINE_RGB                    0x8571
+#define GL_COMBINE_ALPHA                  0x8572
+#define GL_RGB_SCALE                      0x8573
+#define GL_ADD_SIGNED                     0x8574
+#define GL_INTERPOLATE                    0x8575
+#define GL_CONSTANT                       0x8576
+#define GL_PRIMARY_COLOR                  0x8577
+#define GL_PREVIOUS                       0x8578
+#define GL_SOURCE0_RGB                    0x8580
+#define GL_SOURCE1_RGB                    0x8581
+#define GL_SOURCE2_RGB                    0x8582
+#define GL_SOURCE0_ALPHA                  0x8588
+#define GL_SOURCE1_ALPHA                  0x8589
+#define GL_SOURCE2_ALPHA                  0x858A
+#define GL_OPERAND0_RGB                   0x8590
+#define GL_OPERAND1_RGB                   0x8591
+#define GL_OPERAND2_RGB                   0x8592
+#define GL_OPERAND0_ALPHA                 0x8598
+#define GL_OPERAND1_ALPHA                 0x8599
+#define GL_OPERAND2_ALPHA                 0x859A
+#define GL_SUBTRACT                       0x84E7
+#define GL_TRANSPOSE_MODELVIEW_MATRIX     0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX    0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX       0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX         0x84E6
+#define GL_COMPRESSED_ALPHA               0x84E9
+#define GL_COMPRESSED_LUMINANCE           0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA     0x84EB
+#define GL_COMPRESSED_INTENSITY           0x84EC
+#define GL_COMPRESSED_RGB                 0x84ED
+#define GL_COMPRESSED_RGBA                0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT       0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE  0x86A0
+#define GL_TEXTURE_COMPRESSED             0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS     0x86A3
+#define GL_DOT3_RGB                       0x86AE
+#define GL_DOT3_RGBA                      0x86AF
+#define GL_CLAMP_TO_BORDER                0x812D
+#define GL_MULTISAMPLE                    0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE       0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE            0x809F
+#define GL_SAMPLE_COVERAGE                0x80A0
+#define GL_SAMPLE_BUFFERS                 0x80A8
+#define GL_SAMPLES                        0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE          0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT         0x80AB
+#define GL_MULTISAMPLE_BIT                0x20000000
+
+void (WINE_GLAPI *glAccum) (GLenum op, GLfloat value);
+void (WINE_GLAPI *glAlphaFunc) (GLenum func, GLclampf ref);
+GLboolean (WINE_GLAPI *glAreTexturesResident) (GLsizei n, const GLuint* textures, GLboolean* residences);
+void (WINE_GLAPI *glArrayElement) (GLint i);
+void (WINE_GLAPI *glBegin) (GLenum mode);
+void (WINE_GLAPI *glBindTexture) (GLenum target, GLuint texture);
+void (WINE_GLAPI *glBitmap) (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte* bitmap);
+void (WINE_GLAPI *glBlendFunc) (GLenum sfactor, GLenum dfactor);
+void (WINE_GLAPI *glCallList) (GLuint list);
+void (WINE_GLAPI *glCallLists) (GLsizei n, GLenum type, const GLvoid* lists);
+void (WINE_GLAPI *glClear) (GLbitfield mask);
+void (WINE_GLAPI *glClearAccum) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+void (WINE_GLAPI *glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+void (WINE_GLAPI *glClearDepth) (GLclampd depth);
+void (WINE_GLAPI *glClearIndex) (GLfloat c);
+void (WINE_GLAPI *glClearStencil) (GLint s);
+void (WINE_GLAPI *glClipPlane) (GLenum plane, const GLdouble* equation);
+void (WINE_GLAPI *glColor3b) (GLbyte red, GLbyte green, GLbyte blue);
+void (WINE_GLAPI *glColor3bv) (const GLbyte* v);
+void (WINE_GLAPI *glColor3d) (GLdouble red, GLdouble green, GLdouble blue);
+void (WINE_GLAPI *glColor3dv) (const GLdouble* v);
+void (WINE_GLAPI *glColor3f) (GLfloat red, GLfloat green, GLfloat blue);
+void (WINE_GLAPI *glColor3fv) (const GLfloat* v);
+void (WINE_GLAPI *glColor3i) (GLint red, GLint green, GLint blue);
+void (WINE_GLAPI *glColor3iv) (const GLint* v);
+void (WINE_GLAPI *glColor3s) (GLshort red, GLshort green, GLshort blue);
+void (WINE_GLAPI *glColor3sv) (const GLshort* v);
+void (WINE_GLAPI *glColor3ub) (GLubyte red, GLubyte green, GLubyte blue);
+void (WINE_GLAPI *glColor3ubv) (const GLubyte* v);
+void (WINE_GLAPI *glColor3ui) (GLuint red, GLuint green, GLuint blue);
+void (WINE_GLAPI *glColor3uiv) (const GLuint* v);
+void (WINE_GLAPI *glColor3us) (GLushort red, GLushort green, GLushort blue);
+void (WINE_GLAPI *glColor3usv) (const GLushort* v);
+void (WINE_GLAPI *glColor4b) (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
+void (WINE_GLAPI *glColor4bv) (const GLbyte* v);
+void (WINE_GLAPI *glColor4d) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
+void (WINE_GLAPI *glColor4dv) (const GLdouble* v);
+void (WINE_GLAPI *glColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+void (WINE_GLAPI *glColor4fv) (const GLfloat* v);
+void (WINE_GLAPI *glColor4i) (GLint red, GLint green, GLint blue, GLint alpha);
+void (WINE_GLAPI *glColor4iv) (const GLint* v);
+void (WINE_GLAPI *glColor4s) (GLshort red, GLshort green, GLshort blue, GLshort alpha);
+void (WINE_GLAPI *glColor4sv) (const GLshort* v);
+void (WINE_GLAPI *glColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+void (WINE_GLAPI *glColor4ubv) (const GLubyte* v);
+void (WINE_GLAPI *glColor4ui) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
+void (WINE_GLAPI *glColor4uiv) (const GLuint* v);
+void (WINE_GLAPI *glColor4us) (GLushort red, GLushort green, GLushort blue, GLushort alpha);
+void (WINE_GLAPI *glColor4usv) (const GLushort* v);
+void (WINE_GLAPI *glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+void (WINE_GLAPI *glColorMaterial) (GLenum face, GLenum mode);
+void (WINE_GLAPI *glColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+void (WINE_GLAPI *glCopyPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
+void (WINE_GLAPI *glCopyTexImage1D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+void (WINE_GLAPI *glCopyTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+void (WINE_GLAPI *glCopyTexSubImage1D) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+void (WINE_GLAPI *glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+void (WINE_GLAPI *glCullFace) (GLenum mode);
+void (WINE_GLAPI *glDeleteLists) (GLuint list, GLsizei range);
+void (WINE_GLAPI *glDeleteTextures) (GLsizei n, const GLuint* textures);
+void (WINE_GLAPI *glDepthFunc) (GLenum func);
+void (WINE_GLAPI *glDepthMask) (GLboolean flag);
+void (WINE_GLAPI *glDepthRange) (GLclampd nearParam, GLclampd farParam);
+void (WINE_GLAPI *glDisable) (GLenum cap);
+void (WINE_GLAPI *glDisableClientState) (GLenum array);
+void (WINE_GLAPI *glDrawArrays) (GLenum mode, GLint first, GLsizei count);
+void (WINE_GLAPI *glDrawBuffer) (GLenum mode);
+void (WINE_GLAPI *glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
+void (WINE_GLAPI *glDrawPixels) (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+void (WINE_GLAPI *glEdgeFlag) (GLboolean flag);
+void (WINE_GLAPI *glEdgeFlagPointer) (GLsizei stride, const GLvoid* pointer);
+void (WINE_GLAPI *glEdgeFlagv) (const GLboolean* flag);
+void (WINE_GLAPI *glEnable) (GLenum cap);
+void (WINE_GLAPI *glEnableClientState) (GLenum array);
+void (WINE_GLAPI *glEnd) ();
+void (WINE_GLAPI *glEndList) ();
+void (WINE_GLAPI *glEvalCoord1d) (GLdouble u);
+void (WINE_GLAPI *glEvalCoord1dv) (const GLdouble* u);
+void (WINE_GLAPI *glEvalCoord1f) (GLfloat u);
+void (WINE_GLAPI *glEvalCoord1fv) (const GLfloat* u);
+void (WINE_GLAPI *glEvalCoord2d) (GLdouble u, GLdouble v);
+void (WINE_GLAPI *glEvalCoord2dv) (const GLdouble* u);
+void (WINE_GLAPI *glEvalCoord2f) (GLfloat u, GLfloat v);
+void (WINE_GLAPI *glEvalCoord2fv) (const GLfloat* u);
+void (WINE_GLAPI *glEvalMesh1) (GLenum mode, GLint i1, GLint i2);
+void (WINE_GLAPI *glEvalMesh2) (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
+void (WINE_GLAPI *glEvalPoint1) (GLint i);
+void (WINE_GLAPI *glEvalPoint2) (GLint i, GLint j);
+void (WINE_GLAPI *glFeedbackBuffer) (GLsizei size, GLenum type, GLfloat* buffer);
+void (WINE_GLAPI *glFogf) (GLenum pname, GLfloat param);
+void (WINE_GLAPI *glFogfv) (GLenum pname, const GLfloat* params);
+void (WINE_GLAPI *glFogi) (GLenum pname, GLint param);
+void (WINE_GLAPI *glFogiv) (GLenum pname, const GLint* params);
+void (WINE_GLAPI *glFrontFace) (GLenum mode);
+void (WINE_GLAPI *glFrustum) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+GLuint (WINE_GLAPI *glGenLists) (GLsizei range);
+void (WINE_GLAPI *glGenTextures) (GLsizei n, GLuint* textures);
+void (WINE_GLAPI *glGetBooleanv) (GLenum pname, GLboolean* params);
+void (WINE_GLAPI *glGetClipPlane) (GLenum plane, GLdouble* equation);
+void (WINE_GLAPI *glGetDoublev) (GLenum pname, GLdouble* params);
+GLenum (WINE_GLAPI *glGetError) ();
+void (WINE_GLAPI *glGetFloatv) (GLenum pname, GLfloat* params);
+void (WINE_GLAPI *glGetIntegerv) (GLenum pname, GLint* params);
+void (WINE_GLAPI *glGetLightfv) (GLenum light, GLenum pname, GLfloat* params);
+void (WINE_GLAPI *glGetLightiv) (GLenum light, GLenum pname, GLint* params);
+void (WINE_GLAPI *glGetMapdv) (GLenum target, GLenum query, GLdouble* v);
+void (WINE_GLAPI *glGetMapfv) (GLenum target, GLenum query, GLfloat* v);
+void (WINE_GLAPI *glGetMapiv) (GLenum target, GLenum query, GLint* v);
+void (WINE_GLAPI *glGetMaterialfv) (GLenum face, GLenum pname, GLfloat* params);
+void (WINE_GLAPI *glGetMaterialiv) (GLenum face, GLenum pname, GLint* params);
+void (WINE_GLAPI *glGetPixelMapfv) (GLenum map, GLfloat* values);
+void (WINE_GLAPI *glGetPixelMapuiv) (GLenum map, GLuint* values);
+void (WINE_GLAPI *glGetPixelMapusv) (GLenum map, GLushort* values);
+void (WINE_GLAPI *glGetPointerv) (GLenum pname, GLvoid** params);
+void (WINE_GLAPI *glGetPolygonStipple) (GLubyte* mask);
+const GLubyte * (WINE_GLAPI *glGetString) (GLenum name);
+void (WINE_GLAPI *glGetTexEnvfv) (GLenum target, GLenum pname, GLfloat* params);
+void (WINE_GLAPI *glGetTexEnviv) (GLenum target, GLenum pname, GLint* params);
+void (WINE_GLAPI *glGetTexGendv) (GLenum coord, GLenum pname, GLdouble* params);
+void (WINE_GLAPI *glGetTexGenfv) (GLenum coord, GLenum pname, GLfloat* params);
+void (WINE_GLAPI *glGetTexGeniv) (GLenum coord, GLenum pname, GLint* params);
+void (WINE_GLAPI *glGetTexImage) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels);
+void (WINE_GLAPI *glGetTexLevelParameterfv) (GLenum target, GLint level, GLenum pname, GLfloat* params);
+void (WINE_GLAPI *glGetTexLevelParameteriv) (GLenum target, GLint level, GLenum pname, GLint* params);
+void (WINE_GLAPI *glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat* params);
+void (WINE_GLAPI *glGetTexParameteriv) (GLenum target, GLenum pname, GLint* params);
+void (WINE_GLAPI *glHint) (GLenum target, GLenum mode);
+void (WINE_GLAPI *glIndexMask) (GLuint mask);
+void (WINE_GLAPI *glIndexPointer) (GLenum type, GLsizei stride, const GLvoid* pointer);
+void (WINE_GLAPI *glIndexd) (GLdouble c);
+void (WINE_GLAPI *glIndexdv) (const GLdouble* c);
+void (WINE_GLAPI *glIndexf) (GLfloat c);
+void (WINE_GLAPI *glIndexfv) (const GLfloat* c);
+void (WINE_GLAPI *glIndexi) (GLint c);
+void (WINE_GLAPI *glIndexiv) (const GLint* c);
+void (WINE_GLAPI *glIndexs) (GLshort c);
+void (WINE_GLAPI *glIndexsv) (const GLshort* c);
+void (WINE_GLAPI *glIndexub) (GLubyte c);
+void (WINE_GLAPI *glIndexubv) (const GLubyte* c);
+void (WINE_GLAPI *glInitNames) ();
+void (WINE_GLAPI *glInterleavedArrays) (GLenum format, GLsizei stride, const GLvoid* pointer);
+GLboolean (WINE_GLAPI *glIsEnabled) (GLenum cap);
+GLboolean (WINE_GLAPI *glIsList) (GLuint list);
+GLboolean (WINE_GLAPI *glIsTexture) (GLuint texture);
+void (WINE_GLAPI *glLightModelf) (GLenum pname, GLfloat param);
+void (WINE_GLAPI *glLightModelfv) (GLenum pname, const GLfloat* params);
+void (WINE_GLAPI *glLightModeli) (GLenum pname, GLint param);
+void (WINE_GLAPI *glLightModeliv) (GLenum pname, const GLint* params);
+void (WINE_GLAPI *glLightf) (GLenum light, GLenum pname, GLfloat param);
+void (WINE_GLAPI *glLightfv) (GLenum light, GLenum pname, const GLfloat* params);
+void (WINE_GLAPI *glLighti) (GLenum light, GLenum pname, GLint param);
+void (WINE_GLAPI *glLightiv) (GLenum light, GLenum pname, const GLint* params);
+void (WINE_GLAPI *glLineStipple) (GLint factor, GLushort pattern);
+void (WINE_GLAPI *glLineWidth) (GLfloat width);
+void (WINE_GLAPI *glListBase) (GLuint base);
+void (WINE_GLAPI *glLoadIdentity) ();
+void (WINE_GLAPI *glLoadMatrixd) (const GLdouble* m);
+void (WINE_GLAPI *glLoadMatrixf) (const GLfloat* m);
+void (WINE_GLAPI *glLoadName) (GLuint name);
+void (WINE_GLAPI *glLogicOp) (GLenum opcode);
+void (WINE_GLAPI *glMap1d) (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points);
+void (WINE_GLAPI *glMap1f) (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points);
+void (WINE_GLAPI *glMap2d) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble* points);
+void (WINE_GLAPI *glMap2f) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat* points);
+void (WINE_GLAPI *glMapGrid1d) (GLint un, GLdouble u1, GLdouble u2);
+void (WINE_GLAPI *glMapGrid1f) (GLint un, GLfloat u1, GLfloat u2);
+void (WINE_GLAPI *glMapGrid2d) (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
+void (WINE_GLAPI *glMapGrid2f) (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
+void (WINE_GLAPI *glMaterialf) (GLenum face, GLenum pname, GLfloat param);
+void (WINE_GLAPI *glMaterialfv) (GLenum face, GLenum pname, const GLfloat* params);
+void (WINE_GLAPI *glMateriali) (GLenum face, GLenum pname, GLint param);
+void (WINE_GLAPI *glMaterialiv) (GLenum face, GLenum pname, const GLint* params);
+void (WINE_GLAPI *glMatrixMode) (GLenum mode);
+void (WINE_GLAPI *glMultMatrixd) (const GLdouble* m);
+void (WINE_GLAPI *glMultMatrixf) (const GLfloat* m);
+void (WINE_GLAPI *glNewList) (GLuint list, GLenum mode);
+void (WINE_GLAPI *glNormal3b) (GLbyte nx, GLbyte ny, GLbyte nz);
+void (WINE_GLAPI *glNormal3bv) (const GLbyte* v);
+void (WINE_GLAPI *glNormal3d) (GLdouble nx, GLdouble ny, GLdouble nz);
+void (WINE_GLAPI *glNormal3dv) (const GLdouble* v);
+void (WINE_GLAPI *glNormal3f) (GLfloat nx, GLfloat ny, GLfloat nz);
+void (WINE_GLAPI *glNormal3fv) (const GLfloat* v);
+void (WINE_GLAPI *glNormal3i) (GLint nx, GLint ny, GLint nz);
+void (WINE_GLAPI *glNormal3iv) (const GLint* v);
+void (WINE_GLAPI *glNormal3s) (GLshort nx, GLshort ny, GLshort nz);
+void (WINE_GLAPI *glNormal3sv) (const GLshort* v);
+void (WINE_GLAPI *glNormalPointer) (GLenum type, GLsizei stride, const GLvoid* pointer);
+void (WINE_GLAPI *glOrtho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+void (WINE_GLAPI *glPassThrough) (GLfloat token);
+void (WINE_GLAPI *glPixelMapfv) (GLenum map, GLint mapsize, const GLfloat* values);
+void (WINE_GLAPI *glPixelMapuiv) (GLenum map, GLint mapsize, const GLuint* values);
+void (WINE_GLAPI *glPixelMapusv) (GLenum map, GLint mapsize, const GLushort* values);
+void (WINE_GLAPI *glPixelStoref) (GLenum pname, GLfloat param);
+void (WINE_GLAPI *glPixelStorei) (GLenum pname, GLint param);
+void (WINE_GLAPI *glPixelTransferf) (GLenum pname, GLfloat param);
+void (WINE_GLAPI *glPixelTransferi) (GLenum pname, GLint param);
+void (WINE_GLAPI *glPixelZoom) (GLfloat xfactor, GLfloat yfactor);
+void (WINE_GLAPI *glPointSize) (GLfloat size);
+void (WINE_GLAPI *glPolygonMode) (GLenum face, GLenum mode);
+void (WINE_GLAPI *glPolygonOffset) (GLfloat factor, GLfloat units);
+void (WINE_GLAPI *glPolygonStipple) (const GLubyte* mask);
+void (WINE_GLAPI *glPopAttrib) ();
+void (WINE_GLAPI *glPopClientAttrib) ();
+void (WINE_GLAPI *glPopMatrix) ();
+void (WINE_GLAPI *glPopName) ();
+void (WINE_GLAPI *glPrioritizeTextures) (GLsizei n, const GLuint* textures, const GLclampf* priorities);
+void (WINE_GLAPI *glPushAttrib) (GLbitfield mask);
+void (WINE_GLAPI *glPushClientAttrib) (GLbitfield mask);
+void (WINE_GLAPI *glPushMatrix) ();
+void (WINE_GLAPI *glPushName) (GLuint name);
+void (WINE_GLAPI *glRasterPos2d) (GLdouble x, GLdouble y);
+void (WINE_GLAPI *glRasterPos2dv) (const GLdouble* v);
+void (WINE_GLAPI *glRasterPos2f) (GLfloat x, GLfloat y);
+void (WINE_GLAPI *glRasterPos2fv) (const GLfloat* v);
+void (WINE_GLAPI *glRasterPos2i) (GLint x, GLint y);
+void (WINE_GLAPI *glRasterPos2iv) (const GLint* v);
+void (WINE_GLAPI *glRasterPos2s) (GLshort x, GLshort y);
+void (WINE_GLAPI *glRasterPos2sv) (const GLshort* v);
+void (WINE_GLAPI *glRasterPos3d) (GLdouble x, GLdouble y, GLdouble z);
+void (WINE_GLAPI *glRasterPos3dv) (const GLdouble* v);
+void (WINE_GLAPI *glRasterPos3f) (GLfloat x, GLfloat y, GLfloat z);
+void (WINE_GLAPI *glRasterPos3fv) (const GLfloat* v);
+void (WINE_GLAPI *glRasterPos3i) (GLint x, GLint y, GLint z);
+void (WINE_GLAPI *glRasterPos3iv) (const GLint* v);
+void (WINE_GLAPI *glRasterPos3s) (GLshort x, GLshort y, GLshort z);
+void (WINE_GLAPI *glRasterPos3sv) (const GLshort* v);
+void (WINE_GLAPI *glRasterPos4d) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+void (WINE_GLAPI *glRasterPos4dv) (const GLdouble* v);
+void (WINE_GLAPI *glRasterPos4f) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+void (WINE_GLAPI *glRasterPos4fv) (const GLfloat* v);
+void (WINE_GLAPI *glRasterPos4i) (GLint x, GLint y, GLint z, GLint w);
+void (WINE_GLAPI *glRasterPos4iv) (const GLint* v);
+void (WINE_GLAPI *glRasterPos4s) (GLshort x, GLshort y, GLshort z, GLshort w);
+void (WINE_GLAPI *glRasterPos4sv) (const GLshort* v);
+void (WINE_GLAPI *glReadBuffer) (GLenum mode);
+void (WINE_GLAPI *glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
+void (WINE_GLAPI *glRectd) (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
+void (WINE_GLAPI *glRectdv) (const GLdouble* v1, const GLdouble* v2);
+void (WINE_GLAPI *glRectf) (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
+void (WINE_GLAPI *glRectfv) (const GLfloat* v1, const GLfloat* v2);
+void (WINE_GLAPI *glRecti) (GLint x1, GLint y1, GLint x2, GLint y2);
+void (WINE_GLAPI *glRectiv) (const GLint* v1, const GLint* v2);
+void (WINE_GLAPI *glRects) (GLshort x1, GLshort y1, GLshort x2, GLshort y2);
+void (WINE_GLAPI *glRectsv) (const GLshort* v1, const GLshort* v2);
+GLint (WINE_GLAPI *glRenderMode) (GLenum mode);
+void (WINE_GLAPI *glRotated) (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+void (WINE_GLAPI *glRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+void (WINE_GLAPI *glScaled) (GLdouble x, GLdouble y, GLdouble z);
+void (WINE_GLAPI *glScalef) (GLfloat x, GLfloat y, GLfloat z);
+void (WINE_GLAPI *glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
+void (WINE_GLAPI *glSelectBuffer) (GLsizei size, GLuint* buffer);
+void (WINE_GLAPI *glShadeModel) (GLenum mode);
+void (WINE_GLAPI *glStencilFunc) (GLenum func, GLint ref, GLuint mask);
+void (WINE_GLAPI *glStencilMask) (GLuint mask);
+void (WINE_GLAPI *glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass);
+void (WINE_GLAPI *glTexCoord1d) (GLdouble s);
+void (WINE_GLAPI *glTexCoord1dv) (const GLdouble* v);
+void (WINE_GLAPI *glTexCoord1f) (GLfloat s);
+void (WINE_GLAPI *glTexCoord1fv) (const GLfloat* v);
+void (WINE_GLAPI *glTexCoord1i) (GLint s);
+void (WINE_GLAPI *glTexCoord1iv) (const GLint* v);
+void (WINE_GLAPI *glTexCoord1s) (GLshort s);
+void (WINE_GLAPI *glTexCoord1sv) (const GLshort* v);
+void (WINE_GLAPI *glTexCoord2d) (GLdouble s, GLdouble t);
+void (WINE_GLAPI *glTexCoord2dv) (const GLdouble* v);
+void (WINE_GLAPI *glTexCoord2f) (GLfloat s, GLfloat t);
+void (WINE_GLAPI *glTexCoord2fv) (const GLfloat* v);
+void (WINE_GLAPI *glTexCoord2i) (GLint s, GLint t);
+void (WINE_GLAPI *glTexCoord2iv) (const GLint* v);
+void (WINE_GLAPI *glTexCoord2s) (GLshort s, GLshort t);
+void (WINE_GLAPI *glTexCoord2sv) (const GLshort* v);
+void (WINE_GLAPI *glTexCoord3d) (GLdouble s, GLdouble t, GLdouble r);
+void (WINE_GLAPI *glTexCoord3dv) (const GLdouble* v);
+void (WINE_GLAPI *glTexCoord3f) (GLfloat s, GLfloat t, GLfloat r);
+void (WINE_GLAPI *glTexCoord3fv) (const GLfloat* v);
+void (WINE_GLAPI *glTexCoord3i) (GLint s, GLint t, GLint r);
+void (WINE_GLAPI *glTexCoord3iv) (const GLint* v);
+void (WINE_GLAPI *glTexCoord3s) (GLshort s, GLshort t, GLshort r);
+void (WINE_GLAPI *glTexCoord3sv) (const GLshort* v);
+void (WINE_GLAPI *glTexCoord4d) (GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+void (WINE_GLAPI *glTexCoord4dv) (const GLdouble* v);
+void (WINE_GLAPI *glTexCoord4f) (GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+void (WINE_GLAPI *glTexCoord4fv) (const GLfloat* v);
+void (WINE_GLAPI *glTexCoord4i) (GLint s, GLint t, GLint r, GLint q);
+void (WINE_GLAPI *glTexCoord4iv) (const GLint* v);
+void (WINE_GLAPI *glTexCoord4s) (GLshort s, GLshort t, GLshort r, GLshort q);
+void (WINE_GLAPI *glTexCoord4sv) (const GLshort* v);
+void (WINE_GLAPI *glTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+void (WINE_GLAPI *glTexEnvf) (GLenum target, GLenum pname, GLfloat param);
+void (WINE_GLAPI *glTexEnvfv) (GLenum target, GLenum pname, const GLfloat* params);
+void (WINE_GLAPI *glTexEnvi) (GLenum target, GLenum pname, GLint param);
+void (WINE_GLAPI *glTexEnviv) (GLenum target, GLenum pname, const GLint* params);
+void (WINE_GLAPI *glTexGend) (GLenum coord, GLenum pname, GLdouble param);
+void (WINE_GLAPI *glTexGendv) (GLenum coord, GLenum pname, const GLdouble* params);
+void (WINE_GLAPI *glTexGenf) (GLenum coord, GLenum pname, GLfloat param);
+void (WINE_GLAPI *glTexGenfv) (GLenum coord, GLenum pname, const GLfloat* params);
+void (WINE_GLAPI *glTexGeni) (GLenum coord, GLenum pname, GLint param);
+void (WINE_GLAPI *glTexGeniv) (GLenum coord, GLenum pname, const GLint* params);
+void (WINE_GLAPI *glTexImage1D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+void (WINE_GLAPI *glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
+void (WINE_GLAPI *glTexParameterf) (GLenum target, GLenum pname, GLfloat param);
+void (WINE_GLAPI *glTexParameterfv) (GLenum target, GLenum pname, const GLfloat* params);
+void (WINE_GLAPI *glTexParameteri) (GLenum target, GLenum pname, GLint param);
+void (WINE_GLAPI *glTexParameteriv) (GLenum target, GLenum pname, const GLint* params);
+void (WINE_GLAPI *glTexSubImage1D) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid* pixels);
+void (WINE_GLAPI *glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
+void (WINE_GLAPI *glTranslated) (GLdouble x, GLdouble y, GLdouble z);
+void (WINE_GLAPI *glTranslatef) (GLfloat x, GLfloat y, GLfloat z);
+void (WINE_GLAPI *glVertex2d) (GLdouble x, GLdouble y);
+void (WINE_GLAPI *glVertex2dv) (const GLdouble* v);
+void (WINE_GLAPI *glVertex2f) (GLfloat x, GLfloat y);
+void (WINE_GLAPI *glVertex2fv) (const GLfloat* v);
+void (WINE_GLAPI *glVertex2i) (GLint x, GLint y);
+void (WINE_GLAPI *glVertex2iv) (const GLint* v);
+void (WINE_GLAPI *glVertex2s) (GLshort x, GLshort y);
+void (WINE_GLAPI *glVertex2sv) (const GLshort* v);
+void (WINE_GLAPI *glVertex3d) (GLdouble x, GLdouble y, GLdouble z);
+void (WINE_GLAPI *glVertex3dv) (const GLdouble* v);
+void (WINE_GLAPI *glVertex3f) (GLfloat x, GLfloat y, GLfloat z);
+void (WINE_GLAPI *glVertex3fv) (const GLfloat* v);
+void (WINE_GLAPI *glVertex3i) (GLint x, GLint y, GLint z);
+void (WINE_GLAPI *glVertex3iv) (const GLint* v);
+void (WINE_GLAPI *glVertex3s) (GLshort x, GLshort y, GLshort z);
+void (WINE_GLAPI *glVertex3sv) (const GLshort* v);
+void (WINE_GLAPI *glVertex4d) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+void (WINE_GLAPI *glVertex4dv) (const GLdouble* v);
+void (WINE_GLAPI *glVertex4f) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+void (WINE_GLAPI *glVertex4fv) (const GLfloat* v);
+void (WINE_GLAPI *glVertex4i) (GLint x, GLint y, GLint z, GLint w);
+void (WINE_GLAPI *glVertex4iv) (const GLint* v);
+void (WINE_GLAPI *glVertex4s) (GLshort x, GLshort y, GLshort z, GLshort w);
+void (WINE_GLAPI *glVertex4sv) (const GLshort* v);
+void (WINE_GLAPI *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
+void (WINE_GLAPI *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
+void (WINE_GLAPI *glPointParameterfv) (GLenum pname, const GLfloat *params);
+
+/* glFinish and glFlush are always loaded from opengl32.dll, thus they always have
+ * __stdcall calling convention
+ */
+void (__stdcall  *glFinish) ();
+void (__stdcall  *glFlush) ();
+
+/* WGL functions */
+HGLRC   (WINAPI *pwglCreateContext)(HDC);
+BOOL    (WINAPI *pwglDeleteContext)(HGLRC);
+HGLRC   (WINAPI *pwglGetCurrentContext)(void);
+HDC     (WINAPI *pwglGetCurrentDC)(void);
+PROC    (WINAPI *pwglGetProcAddress)(LPCSTR);
+BOOL    (WINAPI *pwglMakeCurrent)(HDC,HGLRC);
+BOOL    (WINAPI *pwglShareLists)(HGLRC,HGLRC);
+
+#define GL_FUNCS_GEN \
+    USE_GL_FUNC(glAccum) \
+    USE_GL_FUNC(glAlphaFunc) \
+    USE_GL_FUNC(glAreTexturesResident) \
+    USE_GL_FUNC(glArrayElement) \
+    USE_GL_FUNC(glBegin) \
+    USE_GL_FUNC(glBindTexture) \
+    USE_GL_FUNC(glBitmap) \
+    USE_GL_FUNC(glBlendFunc) \
+    USE_GL_FUNC(glCallList) \
+    USE_GL_FUNC(glCallLists) \
+    USE_GL_FUNC(glClear) \
+    USE_GL_FUNC(glClearAccum) \
+    USE_GL_FUNC(glClearColor) \
+    USE_GL_FUNC(glClearDepth) \
+    USE_GL_FUNC(glClearIndex) \
+    USE_GL_FUNC(glClearStencil) \
+    USE_GL_FUNC(glClipPlane) \
+    USE_GL_FUNC(glColor3b) \
+    USE_GL_FUNC(glColor3bv) \
+    USE_GL_FUNC(glColor3d) \
+    USE_GL_FUNC(glColor3dv) \
+    USE_GL_FUNC(glColor3f) \
+    USE_GL_FUNC(glColor3fv) \
+    USE_GL_FUNC(glColor3i) \
+    USE_GL_FUNC(glColor3iv) \
+    USE_GL_FUNC(glColor3s) \
+    USE_GL_FUNC(glColor3sv) \
+    USE_GL_FUNC(glColor3ub) \
+    USE_GL_FUNC(glColor3ubv) \
+    USE_GL_FUNC(glColor3ui) \
+    USE_GL_FUNC(glColor3uiv) \
+    USE_GL_FUNC(glColor3us) \
+    USE_GL_FUNC(glColor3usv) \
+    USE_GL_FUNC(glColor4b) \
+    USE_GL_FUNC(glColor4bv) \
+    USE_GL_FUNC(glColor4d) \
+    USE_GL_FUNC(glColor4dv) \
+    USE_GL_FUNC(glColor4f) \
+    USE_GL_FUNC(glColor4fv) \
+    USE_GL_FUNC(glColor4i) \
+    USE_GL_FUNC(glColor4iv) \
+    USE_GL_FUNC(glColor4s) \
+    USE_GL_FUNC(glColor4sv) \
+    USE_GL_FUNC(glColor4ub) \
+    USE_GL_FUNC(glColor4ubv) \
+    USE_GL_FUNC(glColor4ui) \
+    USE_GL_FUNC(glColor4uiv) \
+    USE_GL_FUNC(glColor4us) \
+    USE_GL_FUNC(glColor4usv) \
+    USE_GL_FUNC(glColorMask) \
+    USE_GL_FUNC(glColorMaterial) \
+    USE_GL_FUNC(glColorPointer) \
+    USE_GL_FUNC(glCopyPixels) \
+    USE_GL_FUNC(glCopyTexImage1D) \
+    USE_GL_FUNC(glCopyTexImage2D) \
+    USE_GL_FUNC(glCopyTexSubImage1D) \
+    USE_GL_FUNC(glCopyTexSubImage2D) \
+    USE_GL_FUNC(glCullFace) \
+    USE_GL_FUNC(glDeleteLists) \
+    USE_GL_FUNC(glDeleteTextures) \
+    USE_GL_FUNC(glDepthFunc) \
+    USE_GL_FUNC(glDepthMask) \
+    USE_GL_FUNC(glDepthRange) \
+    USE_GL_FUNC(glDisable) \
+    USE_GL_FUNC(glDisableClientState) \
+    USE_GL_FUNC(glDrawArrays) \
+    USE_GL_FUNC(glDrawBuffer) \
+    USE_GL_FUNC(glDrawElements) \
+    USE_GL_FUNC(glDrawPixels) \
+    USE_GL_FUNC(glEdgeFlag) \
+    USE_GL_FUNC(glEdgeFlagPointer) \
+    USE_GL_FUNC(glEdgeFlagv) \
+    USE_GL_FUNC(glEnable) \
+    USE_GL_FUNC(glEnableClientState) \
+    USE_GL_FUNC(glEnd) \
+    USE_GL_FUNC(glEndList) \
+    USE_GL_FUNC(glEvalCoord1d) \
+    USE_GL_FUNC(glEvalCoord1dv) \
+    USE_GL_FUNC(glEvalCoord1f) \
+    USE_GL_FUNC(glEvalCoord1fv) \
+    USE_GL_FUNC(glEvalCoord2d) \
+    USE_GL_FUNC(glEvalCoord2dv) \
+    USE_GL_FUNC(glEvalCoord2f) \
+    USE_GL_FUNC(glEvalCoord2fv) \
+    USE_GL_FUNC(glEvalMesh1) \
+    USE_GL_FUNC(glEvalMesh2) \
+    USE_GL_FUNC(glEvalPoint1) \
+    USE_GL_FUNC(glEvalPoint2) \
+    USE_GL_FUNC(glFeedbackBuffer) \
+    USE_GL_FUNC(glFogf) \
+    USE_GL_FUNC(glFogfv) \
+    USE_GL_FUNC(glFogi) \
+    USE_GL_FUNC(glFogiv) \
+    USE_GL_FUNC(glFrontFace) \
+    USE_GL_FUNC(glFrustum) \
+    USE_GL_FUNC(glGenLists) \
+    USE_GL_FUNC(glGenTextures) \
+    USE_GL_FUNC(glGetBooleanv) \
+    USE_GL_FUNC(glGetClipPlane) \
+    USE_GL_FUNC(glGetDoublev) \
+    USE_GL_FUNC(glGetError) \
+    USE_GL_FUNC(glGetFloatv) \
+    USE_GL_FUNC(glGetIntegerv) \
+    USE_GL_FUNC(glGetLightfv) \
+    USE_GL_FUNC(glGetLightiv) \
+    USE_GL_FUNC(glGetMapdv) \
+    USE_GL_FUNC(glGetMapfv) \
+    USE_GL_FUNC(glGetMapiv) \
+    USE_GL_FUNC(glGetMaterialfv) \
+    USE_GL_FUNC(glGetMaterialiv) \
+    USE_GL_FUNC(glGetPixelMapfv) \
+    USE_GL_FUNC(glGetPixelMapuiv) \
+    USE_GL_FUNC(glGetPixelMapusv) \
+    USE_GL_FUNC(glGetPointerv) \
+    USE_GL_FUNC(glGetPolygonStipple) \
+    USE_GL_FUNC(glGetString) \
+    USE_GL_FUNC(glGetTexEnvfv) \
+    USE_GL_FUNC(glGetTexEnviv) \
+    USE_GL_FUNC(glGetTexGendv) \
+    USE_GL_FUNC(glGetTexGenfv) \
+    USE_GL_FUNC(glGetTexGeniv) \
+    USE_GL_FUNC(glGetTexImage) \
+    USE_GL_FUNC(glGetTexLevelParameterfv) \
+    USE_GL_FUNC(glGetTexLevelParameteriv) \
+    USE_GL_FUNC(glGetTexParameterfv) \
+    USE_GL_FUNC(glGetTexParameteriv) \
+    USE_GL_FUNC(glHint) \
+    USE_GL_FUNC(glIndexMask) \
+    USE_GL_FUNC(glIndexPointer) \
+    USE_GL_FUNC(glIndexd) \
+    USE_GL_FUNC(glIndexdv) \
+    USE_GL_FUNC(glIndexf) \
+    USE_GL_FUNC(glIndexfv) \
+    USE_GL_FUNC(glIndexi) \
+    USE_GL_FUNC(glIndexiv) \
+    USE_GL_FUNC(glIndexs) \
+    USE_GL_FUNC(glIndexsv) \
+    USE_GL_FUNC(glIndexub) \
+    USE_GL_FUNC(glIndexubv) \
+    USE_GL_FUNC(glInitNames) \
+    USE_GL_FUNC(glInterleavedArrays) \
+    USE_GL_FUNC(glIsEnabled) \
+    USE_GL_FUNC(glIsList) \
+    USE_GL_FUNC(glIsTexture) \
+    USE_GL_FUNC(glLightModelf) \
+    USE_GL_FUNC(glLightModelfv) \
+    USE_GL_FUNC(glLightModeli) \
+    USE_GL_FUNC(glLightModeliv) \
+    USE_GL_FUNC(glLightf) \
+    USE_GL_FUNC(glLightfv) \
+    USE_GL_FUNC(glLighti) \
+    USE_GL_FUNC(glLightiv) \
+    USE_GL_FUNC(glLineStipple) \
+    USE_GL_FUNC(glLineWidth) \
+    USE_GL_FUNC(glListBase) \
+    USE_GL_FUNC(glLoadIdentity) \
+    USE_GL_FUNC(glLoadMatrixd) \
+    USE_GL_FUNC(glLoadMatrixf) \
+    USE_GL_FUNC(glLoadName) \
+    USE_GL_FUNC(glLogicOp) \
+    USE_GL_FUNC(glMap1d) \
+    USE_GL_FUNC(glMap1f) \
+    USE_GL_FUNC(glMap2d) \
+    USE_GL_FUNC(glMap2f) \
+    USE_GL_FUNC(glMapGrid1d) \
+    USE_GL_FUNC(glMapGrid1f) \
+    USE_GL_FUNC(glMapGrid2d) \
+    USE_GL_FUNC(glMapGrid2f) \
+    USE_GL_FUNC(glMaterialf) \
+    USE_GL_FUNC(glMaterialfv) \
+    USE_GL_FUNC(glMateriali) \
+    USE_GL_FUNC(glMaterialiv) \
+    USE_GL_FUNC(glMatrixMode) \
+    USE_GL_FUNC(glMultMatrixd) \
+    USE_GL_FUNC(glMultMatrixf) \
+    USE_GL_FUNC(glNewList) \
+    USE_GL_FUNC(glNormal3b) \
+    USE_GL_FUNC(glNormal3bv) \
+    USE_GL_FUNC(glNormal3d) \
+    USE_GL_FUNC(glNormal3dv) \
+    USE_GL_FUNC(glNormal3f) \
+    USE_GL_FUNC(glNormal3fv) \
+    USE_GL_FUNC(glNormal3i) \
+    USE_GL_FUNC(glNormal3iv) \
+    USE_GL_FUNC(glNormal3s) \
+    USE_GL_FUNC(glNormal3sv) \
+    USE_GL_FUNC(glNormalPointer) \
+    USE_GL_FUNC(glOrtho) \
+    USE_GL_FUNC(glPassThrough) \
+    USE_GL_FUNC(glPixelMapfv) \
+    USE_GL_FUNC(glPixelMapuiv) \
+    USE_GL_FUNC(glPixelMapusv) \
+    USE_GL_FUNC(glPixelStoref) \
+    USE_GL_FUNC(glPixelStorei) \
+    USE_GL_FUNC(glPixelTransferf) \
+    USE_GL_FUNC(glPixelTransferi) \
+    USE_GL_FUNC(glPixelZoom) \
+    USE_GL_FUNC(glPointSize) \
+    USE_GL_FUNC(glPolygonMode) \
+    USE_GL_FUNC(glPolygonOffset) \
+    USE_GL_FUNC(glPolygonStipple) \
+    USE_GL_FUNC(glPopAttrib) \
+    USE_GL_FUNC(glPopClientAttrib) \
+    USE_GL_FUNC(glPopMatrix) \
+    USE_GL_FUNC(glPopName) \
+    USE_GL_FUNC(glPrioritizeTextures) \
+    USE_GL_FUNC(glPushAttrib) \
+    USE_GL_FUNC(glPushClientAttrib) \
+    USE_GL_FUNC(glPushMatrix) \
+    USE_GL_FUNC(glPushName) \
+    USE_GL_FUNC(glRasterPos2d) \
+    USE_GL_FUNC(glRasterPos2dv) \
+    USE_GL_FUNC(glRasterPos2f) \
+    USE_GL_FUNC(glRasterPos2fv) \
+    USE_GL_FUNC(glRasterPos2i) \
+    USE_GL_FUNC(glRasterPos2iv) \
+    USE_GL_FUNC(glRasterPos2s) \
+    USE_GL_FUNC(glRasterPos2sv) \
+    USE_GL_FUNC(glRasterPos3d) \
+    USE_GL_FUNC(glRasterPos3dv) \
+    USE_GL_FUNC(glRasterPos3f) \
+    USE_GL_FUNC(glRasterPos3fv) \
+    USE_GL_FUNC(glRasterPos3i) \
+    USE_GL_FUNC(glRasterPos3iv) \
+    USE_GL_FUNC(glRasterPos3s) \
+    USE_GL_FUNC(glRasterPos3sv) \
+    USE_GL_FUNC(glRasterPos4d) \
+    USE_GL_FUNC(glRasterPos4dv) \
+    USE_GL_FUNC(glRasterPos4f) \
+    USE_GL_FUNC(glRasterPos4fv) \
+    USE_GL_FUNC(glRasterPos4i) \
+    USE_GL_FUNC(glRasterPos4iv) \
+    USE_GL_FUNC(glRasterPos4s) \
+    USE_GL_FUNC(glRasterPos4sv) \
+    USE_GL_FUNC(glReadBuffer) \
+    USE_GL_FUNC(glReadPixels) \
+    USE_GL_FUNC(glRectd) \
+    USE_GL_FUNC(glRectdv) \
+    USE_GL_FUNC(glRectf) \
+    USE_GL_FUNC(glRectfv) \
+    USE_GL_FUNC(glRecti) \
+    USE_GL_FUNC(glRectiv) \
+    USE_GL_FUNC(glRects) \
+    USE_GL_FUNC(glRectsv) \
+    USE_GL_FUNC(glRenderMode) \
+    USE_GL_FUNC(glRotated) \
+    USE_GL_FUNC(glRotatef) \
+    USE_GL_FUNC(glScaled) \
+    USE_GL_FUNC(glScalef) \
+    USE_GL_FUNC(glScissor) \
+    USE_GL_FUNC(glSelectBuffer) \
+    USE_GL_FUNC(glShadeModel) \
+    USE_GL_FUNC(glStencilFunc) \
+    USE_GL_FUNC(glStencilMask) \
+    USE_GL_FUNC(glStencilOp) \
+    USE_GL_FUNC(glTexCoord1d) \
+    USE_GL_FUNC(glTexCoord1dv) \
+    USE_GL_FUNC(glTexCoord1f) \
+    USE_GL_FUNC(glTexCoord1fv) \
+    USE_GL_FUNC(glTexCoord1i) \
+    USE_GL_FUNC(glTexCoord1iv) \
+    USE_GL_FUNC(glTexCoord1s) \
+    USE_GL_FUNC(glTexCoord1sv) \
+    USE_GL_FUNC(glTexCoord2d) \
+    USE_GL_FUNC(glTexCoord2dv) \
+    USE_GL_FUNC(glTexCoord2f) \
+    USE_GL_FUNC(glTexCoord2fv) \
+    USE_GL_FUNC(glTexCoord2i) \
+    USE_GL_FUNC(glTexCoord2iv) \
+    USE_GL_FUNC(glTexCoord2s) \
+    USE_GL_FUNC(glTexCoord2sv) \
+    USE_GL_FUNC(glTexCoord3d) \
+    USE_GL_FUNC(glTexCoord3dv) \
+    USE_GL_FUNC(glTexCoord3f) \
+    USE_GL_FUNC(glTexCoord3fv) \
+    USE_GL_FUNC(glTexCoord3i) \
+    USE_GL_FUNC(glTexCoord3iv) \
+    USE_GL_FUNC(glTexCoord3s) \
+    USE_GL_FUNC(glTexCoord3sv) \
+    USE_GL_FUNC(glTexCoord4d) \
+    USE_GL_FUNC(glTexCoord4dv) \
+    USE_GL_FUNC(glTexCoord4f) \
+    USE_GL_FUNC(glTexCoord4fv) \
+    USE_GL_FUNC(glTexCoord4i) \
+    USE_GL_FUNC(glTexCoord4iv) \
+    USE_GL_FUNC(glTexCoord4s) \
+    USE_GL_FUNC(glTexCoord4sv) \
+    USE_GL_FUNC(glTexCoordPointer) \
+    USE_GL_FUNC(glTexEnvf) \
+    USE_GL_FUNC(glTexEnvfv) \
+    USE_GL_FUNC(glTexEnvi) \
+    USE_GL_FUNC(glTexEnviv) \
+    USE_GL_FUNC(glTexGend) \
+    USE_GL_FUNC(glTexGendv) \
+    USE_GL_FUNC(glTexGenf) \
+    USE_GL_FUNC(glTexGenfv) \
+    USE_GL_FUNC(glTexGeni) \
+    USE_GL_FUNC(glTexGeniv) \
+    USE_GL_FUNC(glTexImage1D) \
+    USE_GL_FUNC(glTexImage2D) \
+    USE_GL_FUNC(glTexParameterf) \
+    USE_GL_FUNC(glTexParameterfv) \
+    USE_GL_FUNC(glTexParameteri) \
+    USE_GL_FUNC(glTexParameteriv) \
+    USE_GL_FUNC(glTexSubImage1D) \
+    USE_GL_FUNC(glTexSubImage2D) \
+    USE_GL_FUNC(glTranslated) \
+    USE_GL_FUNC(glTranslatef) \
+    USE_GL_FUNC(glVertex2d) \
+    USE_GL_FUNC(glVertex2dv) \
+    USE_GL_FUNC(glVertex2f) \
+    USE_GL_FUNC(glVertex2fv) \
+    USE_GL_FUNC(glVertex2i) \
+    USE_GL_FUNC(glVertex2iv) \
+    USE_GL_FUNC(glVertex2s) \
+    USE_GL_FUNC(glVertex2sv) \
+    USE_GL_FUNC(glVertex3d) \
+    USE_GL_FUNC(glVertex3dv) \
+    USE_GL_FUNC(glVertex3f) \
+    USE_GL_FUNC(glVertex3fv) \
+    USE_GL_FUNC(glVertex3i) \
+    USE_GL_FUNC(glVertex3iv) \
+    USE_GL_FUNC(glVertex3s) \
+    USE_GL_FUNC(glVertex3sv) \
+    USE_GL_FUNC(glVertex4d) \
+    USE_GL_FUNC(glVertex4dv) \
+    USE_GL_FUNC(glVertex4f) \
+    USE_GL_FUNC(glVertex4fv) \
+    USE_GL_FUNC(glVertex4i) \
+    USE_GL_FUNC(glVertex4iv) \
+    USE_GL_FUNC(glVertex4s) \
+    USE_GL_FUNC(glVertex4sv) \
+    USE_GL_FUNC(glVertexPointer) \
+    USE_GL_FUNC(glViewport) \
+    USE_GL_FUNC(glPointParameterfv) \
+
+#define WGL_FUNCS_GEN \
+    USE_WGL_FUNC(wglCreateContext) \
+    USE_WGL_FUNC(wglDeleteContext) \
+    USE_WGL_FUNC(wglGetCurrentContext) \
+    USE_WGL_FUNC(wglGetCurrentDC) \
+    USE_WGL_FUNC(wglGetProcAddress) \
+    USE_WGL_FUNC(wglMakeCurrent) \
+    USE_WGL_FUNC(wglShareLists)
+
+
+/****************************************************
+ * OpenGL Extensions (EXT and ARB)
+ *     #defines and functions pointer
+ ****************************************************/
+
+/* GL_ARB_color_buffer_float */
+#ifndef GL_ARB_color_buffer_float
+#define GL_RGBA_FLOAT_MODE_ARB            0x8820
+#define GL_CLAMP_VERTEX_COLOR_ARB         0x891A
+#define GL_CLAMP_FRAGMENT_COLOR_ARB       0x891B
+#define GL_CLAMP_READ_COLOR_ARB           0x891C
+#define GL_FIXED_ONLY_ARB                 0x891D
+#endif
+typedef void (WINE_GLAPI *PGLFNCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
+
+/* GL_ARB_depth_texture */
+#ifndef GL_ARB_depth_texture
+#define GL_ARB_depth_texture 1
+#define GL_DEPTH_COMPONENT16_ARB          0x81A5
+#define GL_DEPTH_COMPONENT24_ARB          0x81A6
+#define GL_DEPTH_COMPONENT32_ARB          0x81A7
+#define GL_TEXTURE_DEPTH_SIZE_ARB         0x884A
+#define GL_DEPTH_TEXTURE_MODE_ARB         0x884B
+#endif
+
+/* GL_ARB_draw_buffers */
+#ifndef GL_ARB_draw_buffers
+#define GL_ARB_draw_buffers 1
+#define GL_MAX_DRAW_BUFFERS_ARB           0x8824
+#define GL_DRAW_BUFFER0_ARB               0x8825
+#define GL_DRAW_BUFFER1_ARB               0x8826
+#define GL_DRAW_BUFFER2_ARB               0x8827
+#define GL_DRAW_BUFFER3_ARB               0x8828
+#define GL_DRAW_BUFFER4_ARB               0x8829
+#define GL_DRAW_BUFFER5_ARB               0x882A
+#define GL_DRAW_BUFFER6_ARB               0x882B
+#define GL_DRAW_BUFFER7_ARB               0x882C
+#define GL_DRAW_BUFFER8_ARB               0x882D
+#define GL_DRAW_BUFFER9_ARB               0x882E
+#define GL_DRAW_BUFFER10_ARB              0x882F
+#define GL_DRAW_BUFFER11_ARB              0x8830
+#define GL_DRAW_BUFFER12_ARB              0x8831
+#define GL_DRAW_BUFFER13_ARB              0x8832
+#define GL_DRAW_BUFFER14_ARB              0x8833
+#define GL_DRAW_BUFFER15_ARB              0x8834
+#endif
+typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
+
+/* GL_ARB_imaging */
+#ifndef GL_ARB_imaging
+#define GL_ARB_imaging 1
+#define GL_CONSTANT_COLOR                 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR       0x8002
+#define GL_CONSTANT_ALPHA                 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA       0x8004
+#define GL_BLEND_COLOR                    0x8005
+#define GL_FUNC_ADD                       0x8006
+#define GL_MIN                            0x8007
+#define GL_MAX                            0x8008
+#define GL_BLEND_EQUATION                 0x8009
+#define GL_FUNC_SUBTRACT                  0x800A
+#define GL_FUNC_REVERSE_SUBTRACT          0x800B
+#define GL_CONVOLUTION_1D                 0x8010
+#define GL_CONVOLUTION_2D                 0x8011
+#define GL_SEPARABLE_2D                   0x8012
+#define GL_CONVOLUTION_BORDER_MODE        0x8013
+#define GL_CONVOLUTION_FILTER_SCALE       0x8014
+#define GL_CONVOLUTION_FILTER_BIAS        0x8015
+#define GL_REDUCE                         0x8016
+#define GL_CONVOLUTION_FORMAT             0x8017
+#define GL_CONVOLUTION_WIDTH              0x8018
+#define GL_CONVOLUTION_HEIGHT             0x8019
+#define GL_MAX_CONVOLUTION_WIDTH          0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT         0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE     0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE   0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE    0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE   0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS      0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS    0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS     0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS    0x8023
+#define GL_HISTOGRAM                      0x8024
+#define GL_PROXY_HISTOGRAM                0x8025
+#define GL_HISTOGRAM_WIDTH                0x8026
+#define GL_HISTOGRAM_FORMAT               0x8027
+#define GL_HISTOGRAM_RED_SIZE             0x8028
+#define GL_HISTOGRAM_GREEN_SIZE           0x8029
+#define GL_HISTOGRAM_BLUE_SIZE            0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE           0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE       0x802C
+#define GL_HISTOGRAM_SINK                 0x802D
+#define GL_MINMAX                         0x802E
+#define GL_MINMAX_FORMAT                  0x802F
+#define GL_MINMAX_SINK                    0x8030
+#define GL_TABLE_TOO_LARGE                0x8031
+#define GL_COLOR_MATRIX                   0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH       0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH   0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE    0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE  0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE   0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE  0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS     0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS   0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS    0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS   0x80BB
+#define GL_COLOR_TABLE                    0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE   0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE  0x80D2
+#define GL_PROXY_COLOR_TABLE              0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE              0x80D6
+#define GL_COLOR_TABLE_BIAS               0x80D7
+#define GL_COLOR_TABLE_FORMAT             0x80D8
+#define GL_COLOR_TABLE_WIDTH              0x80D9
+#define GL_COLOR_TABLE_RED_SIZE           0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE         0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE          0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE         0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE     0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE     0x80DF
+#define GL_CONSTANT_BORDER                0x8151
+#define GL_REPLICATE_BORDER               0x8153
+#define GL_CONVOLUTION_BORDER_COLOR       0x8154
+#endif
+typedef void (WINE_GLAPI *PGLFNBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (WINE_GLAPI *PGLFNBLENDEQUATIONPROC) (GLenum mode);
+/* GL_ARB_multitexture */
+#ifndef GL_ARB_multitexture
+#define GL_ARB_multitexture 1
+#define GL_TEXTURE0_ARB                   0x84C0
+#define GL_TEXTURE1_ARB                   0x84C1
+#define GL_TEXTURE2_ARB                   0x84C2
+#define GL_TEXTURE3_ARB                   0x84C3
+#define GL_TEXTURE4_ARB                   0x84C4
+#define GL_TEXTURE5_ARB                   0x84C5
+#define GL_TEXTURE6_ARB                   0x84C6
+#define GL_TEXTURE7_ARB                   0x84C7
+#define GL_TEXTURE8_ARB                   0x84C8
+#define GL_TEXTURE9_ARB                   0x84C9
+#define GL_TEXTURE10_ARB                  0x84CA
+#define GL_TEXTURE11_ARB                  0x84CB
+#define GL_TEXTURE12_ARB                  0x84CC
+#define GL_TEXTURE13_ARB                  0x84CD
+#define GL_TEXTURE14_ARB                  0x84CE
+#define GL_TEXTURE15_ARB                  0x84CF
+#define GL_TEXTURE16_ARB                  0x84D0
+#define GL_TEXTURE17_ARB                  0x84D1
+#define GL_TEXTURE18_ARB                  0x84D2
+#define GL_TEXTURE19_ARB                  0x84D3
+#define GL_TEXTURE20_ARB                  0x84D4
+#define GL_TEXTURE21_ARB                  0x84D5
+#define GL_TEXTURE22_ARB                  0x84D6
+#define GL_TEXTURE23_ARB                  0x84D7
+#define GL_TEXTURE24_ARB                  0x84D8
+#define GL_TEXTURE25_ARB                  0x84D9
+#define GL_TEXTURE26_ARB                  0x84DA
+#define GL_TEXTURE27_ARB                  0x84DB
+#define GL_TEXTURE28_ARB                  0x84DC
+#define GL_TEXTURE29_ARB                  0x84DD
+#define GL_TEXTURE30_ARB                  0x84DE
+#define GL_TEXTURE31_ARB                  0x84DF
+#define GL_ACTIVE_TEXTURE_ARB             0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB      0x84E1
+#define GL_MAX_TEXTURE_UNITS_ARB          0x84E2
+#endif
+typedef void (WINE_GLAPI *WINED3D_PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (WINE_GLAPI *WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (WINE_GLAPI *WINED3D_PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+
+/* GL_ARB_texture_cube_map */
+#ifndef GL_ARB_texture_cube_map
+#define GL_ARB_texture_cube_map 1
+#define GL_NORMAL_MAP_ARB                   0x8511
+#define GL_REFLECTION_MAP_ARB               0x8512
+#define GL_TEXTURE_CUBE_MAP_ARB             0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARB     0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB  0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB  0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB  0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB  0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB  0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB  0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARB       0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB    0x851C
+#endif
+
+/* GL_ARB_point_parameters */
+#ifndef GL_ARB_point_parameters
+#define GL_ARB_point_parameters 1
+#define GL_POINT_SIZE_MIN_ARB             0x8126
+#define GL_POINT_SIZE_MAX_ARB             0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_ARB  0x8128
+#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129
+#endif
+typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
+typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
+/* GL_ARB_vertex_blend */
+#ifndef GL_ARB_vertex_blend
+#define GL_ARB_vertex_blend 1
+#define GL_MAX_VERTEX_UNITS_ARB           0x86A4
+#define GL_ACTIVE_VERTEX_UNITS_ARB        0x86A5
+#define GL_WEIGHT_SUM_UNITY_ARB           0x86A6
+#define GL_VERTEX_BLEND_ARB               0x86A7
+#define GL_CURRENT_WEIGHT_ARB             0x86A8
+#define GL_WEIGHT_ARRAY_TYPE_ARB          0x86A9
+#define GL_WEIGHT_ARRAY_STRIDE_ARB        0x86AA
+#define GL_WEIGHT_ARRAY_SIZE_ARB          0x86AB
+#define GL_WEIGHT_ARRAY_POINTER_ARB       0x86AC
+#define GL_WEIGHT_ARRAY_ARB               0x86AD
+#define GL_MODELVIEW0_ARB                 0x1700
+#define GL_MODELVIEW1_ARB                 0x850A
+#define GL_MODELVIEW2_ARB                 0x8722
+#define GL_MODELVIEW3_ARB                 0x8723
+#define GL_MODELVIEW4_ARB                 0x8724
+#define GL_MODELVIEW5_ARB                 0x8725
+#define GL_MODELVIEW6_ARB                 0x8726
+#define GL_MODELVIEW7_ARB                 0x8727
+#define GL_MODELVIEW8_ARB                 0x8728
+#define GL_MODELVIEW9_ARB                 0x8729
+#define GL_MODELVIEW10_ARB                0x872A
+#define GL_MODELVIEW11_ARB                0x872B
+#define GL_MODELVIEW12_ARB                0x872C
+#define GL_MODELVIEW13_ARB                0x872D
+#define GL_MODELVIEW14_ARB                0x872E
+#define GL_MODELVIEW15_ARB                0x872F
+#define GL_MODELVIEW16_ARB                0x8730
+#define GL_MODELVIEW17_ARB                0x8731
+#define GL_MODELVIEW18_ARB                0x8732
+#define GL_MODELVIEW19_ARB                0x8733
+#define GL_MODELVIEW20_ARB                0x8734
+#define GL_MODELVIEW21_ARB                0x8735
+#define GL_MODELVIEW22_ARB                0x8736
+#define GL_MODELVIEW23_ARB                0x8737
+#define GL_MODELVIEW24_ARB                0x8738
+#define GL_MODELVIEW25_ARB                0x8739
+#define GL_MODELVIEW26_ARB                0x873A
+#define GL_MODELVIEW27_ARB                0x873B
+#define GL_MODELVIEW28_ARB                0x873C
+#define GL_MODELVIEW29_ARB                0x873D
+#define GL_MODELVIEW30_ARB                0x873E
+#define GL_MODELVIEW31_ARB                0x873F
+#endif
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTPOINTERARB) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTBV) (GLint size, const GLbyte *weights);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTSV) (GLint size, const GLshort *weights);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTIV) (GLint size, const GLint *weights);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTFV) (GLint size, const GLfloat *weights);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTDV) (GLint size, const GLdouble *weights);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTUBV) (GLint size, const GLubyte *weights);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTUSV) (GLint size, const GLushort *weights);
+typedef void (WINE_GLAPI * PGLFNGLWEIGHTUIV) (GLint size, const GLuint *weights);
+typedef void (WINE_GLAPI * PGLFNGLVERTEXBLENDARB) (GLint count);
+/* GL_ARB_pixel_buffer_object */
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+#endif
+#define GL_PIXEL_PACK_BUFFER_ARB               0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_ARB             0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB       0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB     0x88EF
+/* GL_EXT_framebuffer_object */
+#ifndef GL_EXT_framebuffer_object
+#define GL_EXT_framebuffer_object 1
+#define GL_FRAMEBUFFER_EXT                     0x8D40
+#define GL_RENDERBUFFER_EXT                    0x8D41
+#define GL_STENCIL_INDEX1_EXT                  0x8D46
+#define GL_STENCIL_INDEX4_EXT                  0x8D47
+#define GL_STENCIL_INDEX8_EXT                  0x8D48
+#define GL_STENCIL_INDEX16_EXT                 0x8D49
+#define GL_RENDERBUFFER_WIDTH_EXT              0x8D42
+#define GL_RENDERBUFFER_HEIGHT_EXT             0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT    0x8D44
+#define GL_RENDERBUFFER_RED_SIZE_EXT           0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT         0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT          0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT         0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT         0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT       0x8D55
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT            0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT            0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT          0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT  0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT     0x8CD4
+#define GL_COLOR_ATTACHMENT0_EXT                0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT                0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT                0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT                0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT                0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT                0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT                0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT                0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT                0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT                0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT               0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT               0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT               0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT               0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT               0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT               0x8CEF
+#define GL_DEPTH_ATTACHMENT_EXT                 0x8D00
+#define GL_STENCIL_ATTACHMENT_EXT               0x8D20
+#define GL_FRAMEBUFFER_COMPLETE_EXT                          0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT             0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT     0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT             0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT                0x8CDA
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT            0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT            0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT                       0x8CDD
+#define GL_FRAMEBUFFER_BINDING_EXT             0x8CA6
+#define GL_RENDERBUFFER_BINDING_EXT            0x8CA7
+#define GL_MAX_COLOR_ATTACHMENTS_EXT           0x8CDF
+#define GL_MAX_RENDERBUFFER_SIZE_EXT           0x84E8
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT   0x0506
+
+#endif
+typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFEREXTPROC)(GLuint renderbuffer);
+typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFEREXTPROC)(GLenum target, GLuint renderbuffer);
+typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSEXTPROC)(GLsizei n, const GLuint *renderbuffers);
+typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSEXTPROC)(GLsizei n, GLuint *renderbuffers);
+typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEEXTPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC)(GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFEREXTPROC)(GLuint framebuffer);
+typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFEREXTPROC)(GLenum target, GLuint framebuffer);
+typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSEXTPROC)(GLsizei n, const GLuint *framebuffers);
+typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSEXTPROC)(GLsizei n, GLuint *framebuffers);
+typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)(GLenum target);
+typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPEXTPROC)(GLenum target);
+/* GL_EXT_framebuffer_blit */
+#ifndef GL_EXT_framebuffer_blit
+#define GL_EXT_framebuffer_blit 1
+#define GL_READ_FRAMEBUFFER_EXT                0x8CA8
+#define GL_DRAW_FRAMEBUFFER_EXT                0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_EXT        0x8CA6
+#define GL_READ_FRAMEBUFFER_BINDING_EXT        0x8CAA
+#endif
+typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+
+/* GL_EXT_framebuffer_multisample */
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_EXT_framebuffer_multisample 1
+#define GL_RENDERBUFFER_SAMPLES_EXT                 0x8cab
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT   0x8d56
+#define GL_MAX_SAMPLES_EXT                          0x8d57
+#endif
+typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+
+/* GL_EXT_secondary_color */
+#ifndef GL_EXT_secondary_color
+#define GL_EXT_secondary_color 1
+#define GL_COLOR_SUM_EXT                     0x8458
+#define GL_CURRENT_SECONDARY_COLOR_EXT       0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT    0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT    0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT  0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
+#define GL_SECONDARY_COLOR_ARRAY_EXT         0x845E
+#endif
+typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (WINE_GLAPI * PGLFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+/* GL_EXT_paletted_texture */
+#ifndef GL_EXT_paletted_texture
+#define GL_EXT_paletted_texture 1
+#define GL_COLOR_INDEX1_EXT               0x80E2
+#define GL_COLOR_INDEX2_EXT               0x80E3
+#define GL_COLOR_INDEX4_EXT               0x80E4
+#define GL_COLOR_INDEX8_EXT               0x80E5
+#define GL_COLOR_INDEX12_EXT              0x80E6
+#define GL_COLOR_INDEX16_EXT              0x80E7
+#define GL_TEXTURE_INDEX_SIZE_EXT         0x80ED
+#endif
+typedef void (WINE_GLAPI * PGLFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+/* GL_EXT_point_parameters */
+#ifndef GL_EXT_point_parameters
+#define GL_EXT_point_parameters 1
+#define GL_POINT_SIZE_MIN_EXT             0x8126
+#define GL_POINT_SIZE_MAX_EXT             0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT  0x8128
+#define GL_DISTANCE_ATTENUATION_EXT       0x8129
+#endif
+typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
+typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+/* GL_EXT_texture3D */
+#ifndef GL_EXT_texture3D
+#define GL_EXT_texture3D 1
+#define GL_PACK_SKIP_IMAGES_EXT           0x806B
+#define GL_PACK_IMAGE_HEIGHT_EXT          0x806C
+#define GL_UNPACK_SKIP_IMAGES_EXT         0x806D
+#define GL_UNPACK_IMAGE_HEIGHT_EXT        0x806E
+#define GL_TEXTURE_3D_EXT                 0x806F
+#define GL_PROXY_TEXTURE_3D_EXT           0x8070
+#define GL_TEXTURE_DEPTH_EXT              0x8071
+#define GL_TEXTURE_WRAP_R_EXT             0x8072
+#define GL_MAX_3D_TEXTURE_SIZE_EXT        0x8073
+#endif
+typedef void (WINE_GLAPI * PGLFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (WINE_GLAPI * PGLFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+/* GL_EXT_texture_env_combine */
+#ifndef GL_EXT_texture_env_combine
+#define GL_EXT_texture_env_combine 1
+#define GL_COMBINE_EXT                    0x8570
+#define GL_COMBINE_RGB_EXT                0x8571
+#define GL_COMBINE_ALPHA_EXT              0x8572
+#define GL_RGB_SCALE_EXT                  0x8573
+#define GL_ADD_SIGNED_EXT                 0x8574
+#define GL_INTERPOLATE_EXT                0x8575
+#define GL_SUBTRACT_EXT                   0x84E7
+#define GL_CONSTANT_EXT                   0x8576
+#define GL_PRIMARY_COLOR_EXT              0x8577
+#define GL_PREVIOUS_EXT                   0x8578
+#define GL_SOURCE0_RGB_EXT                0x8580
+#define GL_SOURCE1_RGB_EXT                0x8581
+#define GL_SOURCE2_RGB_EXT                0x8582
+#define GL_SOURCE3_RGB_EXT                0x8583
+#define GL_SOURCE4_RGB_EXT                0x8584
+#define GL_SOURCE5_RGB_EXT                0x8585
+#define GL_SOURCE6_RGB_EXT                0x8586
+#define GL_SOURCE7_RGB_EXT                0x8587
+#define GL_SOURCE0_ALPHA_EXT              0x8588
+#define GL_SOURCE1_ALPHA_EXT              0x8589
+#define GL_SOURCE2_ALPHA_EXT              0x858A
+#define GL_SOURCE3_ALPHA_EXT              0x858B
+#define GL_SOURCE4_ALPHA_EXT              0x858C
+#define GL_SOURCE5_ALPHA_EXT              0x858D
+#define GL_SOURCE6_ALPHA_EXT              0x858E
+#define GL_SOURCE7_ALPHA_EXT              0x858F
+#define GL_OPERAND0_RGB_EXT               0x8590
+#define GL_OPERAND1_RGB_EXT               0x8591
+#define GL_OPERAND2_RGB_EXT               0x8592
+#define GL_OPERAND3_RGB_EXT               0x8593
+#define GL_OPERAND4_RGB_EXT               0x8594
+#define GL_OPERAND5_RGB_EXT               0x8595
+#define GL_OPERAND6_RGB_EXT               0x8596
+#define GL_OPERAND7_RGB_EXT               0x8597
+#define GL_OPERAND0_ALPHA_EXT             0x8598
+#define GL_OPERAND1_ALPHA_EXT             0x8599
+#define GL_OPERAND2_ALPHA_EXT             0x859A
+#define GL_OPERAND3_ALPHA_EXT             0x859B
+#define GL_OPERAND4_ALPHA_EXT             0x859C
+#define GL_OPERAND5_ALPHA_EXT             0x859D
+#define GL_OPERAND6_ALPHA_EXT             0x859E
+#define GL_OPERAND7_ALPHA_EXT             0x859F
+#endif
+/* GL_EXT_texture_env_dot3 */
+#ifndef GL_EXT_texture_env_dot3
+#define GL_EXT_texture_env_dot3 1
+#define GL_DOT3_RGB_EXT                   0x8740
+#define GL_DOT3_RGBA_EXT                  0x8741
+#endif
+/* GL_EXT_texture_lod_bias */
+#ifndef GL_EXT_texture_lod_bias
+#define GL_EXT_texture_lod_bias 1
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT       0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT     0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT           0x8501
+#endif
+/* GL_ARB_texture_border_clamp */
+#ifndef GL_ARB_texture_border_clamp
+#define GL_ARB_texture_border_clamp 1
+#define GL_CLAMP_TO_BORDER_ARB            0x812D
+#endif
+/* GL_EXT_texture_filter_anisotropic */
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT     0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif
+/* GL_ARB_texture_mirrored_repeat (full support GL1.4) */
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
+#define GL_MIRRORED_REPEAT_ARB            0x8370
+#endif
+/* GL_ATI_texture_mirror_once */
+#ifndef GL_ATI_texture_mirror_once
+#define GL_ATI_texture_mirror_once 1
+#define GL_MIRROR_CLAMP_ATI               0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_ATI       0x8743
+#endif
+/* GL_ARB_texture_env_dot3 */
+#ifndef GL_ARB_texture_env_dot3
+#define GL_ARB_texture_env_dot3 1
+#define GL_DOT3_RGB_ARB                   0x86AE
+#define GL_DOT3_RGBA_ARB                  0x86AF
+#endif
+/* GL_EXT_texture_env_dot3 */
+#ifndef GL_EXT_texture_env_dot3
+#define GL_EXT_texture_env_dot3 1
+#define GL_DOT3_RGB_EXT                   0x8740
+#define GL_DOT3_RGBA_EXT                  0x8741
+#endif
+/* GL_EXT_texture_sRGB */
+#ifndef GL_EXT_texture_sRGB
+#define GL_EXT_texture_sRGB 1
+#define GL_SRGB_EXT                            0x8C40
+#define GL_SRGB8_EXT                           0x8C41
+#define GL_SRGB_ALPHA_EXT                      0x8C42
+#define GL_SRGB8_ALPHA8_EXT                    0x8C43
+#define GL_SLUMINANCE_ALPHA_EXT                0x8C44
+#define GL_SLUMINANCE8_ALPHA8_EXT              0x8C45
+#define GL_SLUMINANCE_EXT                      0x8C46
+#define GL_SLUMINANCE8_EXT                     0x8C47
+#define GL_COMPRESSED_SRGB_EXT                 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA_EXT           0x8C49
+#define GL_COMPRESSED_SLUMINANCE_EXT           0x8C4A
+#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT     0x8C4B
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT       0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
+#endif
+/* GL_ARB_texture_float */
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#define GL_RGBA32F_ARB                    0x8814
+#define GL_RGB32F_ARB                     0x8815
+#define GL_RGBA16F_ARB                    0x881A
+#define GL_RGB16F_ARB                     0x881B
+#endif
+/* GL_ARB_half_float_pixel */
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel
+#define GL_HALF_FLOAT_ARB                 0x140B
+#endif
+/* GL_ARB_vertex_program */
+#ifndef GL_ARB_vertex_program
+#define GL_ARB_vertex_program 1
+#define GL_VERTEX_PROGRAM_ARB             0x8620
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB  0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB    0x8643
+#define GL_COLOR_SUM_ARB                  0x8458
+#define GL_PROGRAM_FORMAT_ASCII_ARB       0x8875
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB   0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB   0x8625
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
+#define GL_CURRENT_VERTEX_ATTRIB_ARB      0x8626
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
+#define GL_PROGRAM_LENGTH_ARB             0x8627
+#define GL_PROGRAM_FORMAT_ARB             0x8876
+#define GL_PROGRAM_BINDING_ARB            0x8677
+#define GL_PROGRAM_INSTRUCTIONS_ARB       0x88A0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB   0x88A1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
+#define GL_PROGRAM_TEMPORARIES_ARB        0x88A4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB    0x88A5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
+#define GL_PROGRAM_PARAMETERS_ARB         0x88A8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB     0x88A9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB  0x88AA
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
+#define GL_PROGRAM_ATTRIBS_ARB            0x88AC
+#define GL_MAX_PROGRAM_ATTRIBS_ARB        0x88AD
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB     0x88AE
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB  0x88B0
+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
+#define GL_PROGRAM_STRING_ARB             0x8628
+#define GL_PROGRAM_ERROR_POSITION_ARB     0x864B
+#define GL_CURRENT_MATRIX_ARB             0x8641
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB   0x88B7
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
+#define GL_MAX_VERTEX_ATTRIBS_ARB         0x8869
+#define GL_MAX_PROGRAM_MATRICES_ARB       0x862F
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
+#define GL_PROGRAM_ERROR_STRING_ARB       0x8874
+#define GL_MATRIX0_ARB                    0x88C0
+#define GL_MATRIX1_ARB                    0x88C1
+#define GL_MATRIX2_ARB                    0x88C2
+#define GL_MATRIX3_ARB                    0x88C3
+#define GL_MATRIX4_ARB                    0x88C4
+#define GL_MATRIX5_ARB                    0x88C5
+#define GL_MATRIX6_ARB                    0x88C6
+#define GL_MATRIX7_ARB                    0x88C7
+#define GL_MATRIX8_ARB                    0x88C8
+#define GL_MATRIX9_ARB                    0x88C9
+#define GL_MATRIX10_ARB                   0x88CA
+#define GL_MATRIX11_ARB                   0x88CB
+#define GL_MATRIX12_ARB                   0x88CC
+#define GL_MATRIX13_ARB                   0x88CD
+#define GL_MATRIX14_ARB                   0x88CE
+#define GL_MATRIX15_ARB                   0x88CF
+#define GL_MATRIX16_ARB                   0x88D0
+#define GL_MATRIX17_ARB                   0x88D1
+#define GL_MATRIX18_ARB                   0x88D2
+#define GL_MATRIX19_ARB                   0x88D3
+#define GL_MATRIX20_ARB                   0x88D4
+#define GL_MATRIX21_ARB                   0x88D5
+#define GL_MATRIX22_ARB                   0x88D6
+#define GL_MATRIX23_ARB                   0x88D7
+#define GL_MATRIX24_ARB                   0x88D8
+#define GL_MATRIX25_ARB                   0x88D9
+#define GL_MATRIX26_ARB                   0x88DA
+#define GL_MATRIX27_ARB                   0x88DB
+#define GL_MATRIX28_ARB                   0x88DC
+#define GL_MATRIX29_ARB                   0x88DD
+#define GL_MATRIX30_ARB                   0x88DE
+#define GL_MATRIX31_ARB                   0x88DF
+#endif
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (WINE_GLAPI * PGLFNPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (WINE_GLAPI * PGLFNBINDPROGRAMARBPROC) (GLenum target, GLuint program);
+typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
+typedef void (WINE_GLAPI * PGLFNGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
+typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMARBPROC) (GLuint program);
+#ifndef GL_ARB_fragment_program
+#define GL_ARB_fragment_program 1
+#define GL_FRAGMENT_PROGRAM_ARB           0x8804
+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB   0x8805
+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB   0x8806
+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB   0x8807
+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
+#define GL_MAX_TEXTURE_COORDS_ARB         0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB    0x8872
+/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
+#endif
+/* GL_ARB_multisample */
+#ifndef GL_ARB_multisample
+#define GL_ARB_multisample 1
+#define GL_MULTISAMPLE_ARB                0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB   0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_ARB        0x809F
+#define GL_SAMPLE_COVERAGE_ARB            0x80A0
+#define GL_SAMPLE_BUFFERS_ARB             0x80A8
+#define GL_SAMPLES_ARB                    0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE_ARB      0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT_ARB     0x80AB
+#define GL_MULTISAMPLE_BIT_ARB            0x20000000
+#endif
+typedef void (WINE_GLAPI * WINED3D_PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);
+/* GL_ARB_vertex_buffer_object */
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_ARB_vertex_buffer_object 1
+#define GL_BUFFER_SIZE_ARB                0x8764
+#define GL_BUFFER_USAGE_ARB               0x8765
+#define GL_ARRAY_BUFFER_ARB               0x8892
+#define GL_ELEMENT_ARRAY_BUFFER_ARB       0x8893
+#define GL_ARRAY_BUFFER_BINDING_ARB       0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB  0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB  0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB   0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB   0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB   0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB       0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB  0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB          0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB   0x889F
+#define GL_READ_ONLY_ARB                  0x88B8
+#define GL_WRITE_ONLY_ARB                 0x88B9
+#define GL_READ_WRITE_ARB                 0x88BA
+#define GL_BUFFER_ACCESS_ARB              0x88BB
+#define GL_BUFFER_MAPPED_ARB              0x88BC
+#define GL_BUFFER_MAP_POINTER_ARB         0x88BD
+#define GL_STREAM_DRAW_ARB                0x88E0
+#define GL_STREAM_READ_ARB                0x88E1
+#define GL_STREAM_COPY_ARB                0x88E2
+#define GL_STATIC_DRAW_ARB                0x88E4
+#define GL_STATIC_READ_ARB                0x88E5
+#define GL_STATIC_COPY_ARB                0x88E6
+#define GL_DYNAMIC_DRAW_ARB               0x88E8
+#define GL_DYNAMIC_READ_ARB               0x88E9
+#define GL_DYNAMIC_COPY_ARB               0x88EA
+#endif
+typedef void (WINE_GLAPI * PGLFNBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
+typedef void (WINE_GLAPI * PGLFNDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
+typedef void (WINE_GLAPI * PGLFNGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (WINE_GLAPI * PGLFNISBUFFERARBPROC) (GLuint buffer);
+typedef void (WINE_GLAPI * PGLFNBUFFERDATAARBPROC) (GLenum target, ptrdiff_t size, const GLvoid *data, GLenum usage);
+typedef void (WINE_GLAPI * PGLFNBUFFERSUBDATAARBPROC) (GLenum target, ptrdiff_t offset, ptrdiff_t size, const GLvoid *data);
+typedef void (WINE_GLAPI * PGLFNGETBUFFERSUBDATAARBPROC) (GLenum target, ptrdiff_t offset, ptrdiff_t size, GLvoid *data);
+typedef GLvoid* (WINE_GLAPI * PGLFNMAPBUFFERARBPROC) (GLenum target, GLenum access);
+typedef GLboolean (WINE_GLAPI * PGLFNUNMAPBUFFERARBPROC) (GLenum target);
+typedef void (WINE_GLAPI * PGLFNGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
+/* GL_EXT_blend_equation_separate */
+typedef void (WINE_GLAPI * PGLFNBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+/* GL_EXT_blend_func_separate */
+#ifndef GL_EXT_blend_func_separate
+#define GL_BLEND_DST_RGB_EXT              0x80C8
+#define GL_BLEND_SRC_RGB_EXT              0x80C9
+#define GL_BLEND_DST_ALPHA_EXT            0x80CA
+#define GL_BLEND_SRC_ALPHA_EXT            0x80CB
+#endif
+typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
+/* GL_EXT_fog_coord */
+#ifndef GL_EXT_fog_coord
+#define GL_EXT_fog_coord 1
+#define GL_FOG_COORDINATE_SOURCE_EXT            0x8450
+#define GL_FOG_COORDINATE_EXT                   0x8451
+#define GL_FRAGMENT_DEPTH_EXT                   0x8452
+#define GL_CURRENT_FOG_COORDINATE_EXT           0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT        0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT      0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT     0x8456
+#define GL_FOG_COORDINATE_ARRAY_EXT             0x8457
+#endif /* GL_EXT_fog_coord */
+typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFEXTPROC) (GLfloat intesity);
+typedef void (WINE_GLAPI * PGLFNGLFOGCOORDFVEXTPROC) (GLfloat intesity);
+typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDEXTPROC) (GLfloat intesity);
+typedef void (WINE_GLAPI * PGLFNGLFOGCOORDDVEXTPROC) (GLfloat intesity);
+typedef void (WINE_GLAPI * PGLFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, GLvoid *data);
+/* GL_ARB_shader_objects (GLSL) */
+#ifndef GL_ARB_shader_objects
+#define GL_ARB_shader_objects 1
+typedef char GLcharARB;
+typedef unsigned int GLhandleARB;
+#define GL_PROGRAM_OBJECT_ARB                   0x8B40
+#define GL_OBJECT_TYPE_ARB                      0x8B4E
+#define GL_OBJECT_SUBTYPE_ARB                   0x8B4F
+#define GL_OBJECT_DELETE_STATUS_ARB             0x8B80
+#define GL_OBJECT_COMPILE_STATUS_ARB            0x8B81
+#define GL_OBJECT_LINK_STATUS_ARB               0x8B82
+#define GL_OBJECT_VALIDATE_STATUS_ARB           0x8B83
+#define GL_OBJECT_INFO_LOG_LENGTH_ARB           0x8B84
+#define GL_OBJECT_ATTACHED_OBJECTS_ARB          0x8B85
+#define GL_OBJECT_ACTIVE_UNIFORMS_ARB           0x8B86
+#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
+#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB      0x8B88
+#define GL_SHADER_OBJECT_ARB                    0x8B48
+#define GL_FLOAT_VEC2_ARB                       0x8B50
+#define GL_FLOAT_VEC3_ARB                       0x8B51
+#define GL_FLOAT_VEC4_ARB                       0x8B52
+#define GL_INT_VEC2_ARB                         0x8B53
+#define GL_INT_VEC3_ARB                         0x8B54
+#define GL_INT_VEC4_ARB                         0x8B55
+#define GL_BOOL_ARB                             0x8B56
+#define GL_BOOL_VEC2_ARB                        0x8B57
+#define GL_BOOL_VEC3_ARB                        0x8B58
+#define GL_BOOL_VEC4_ARB                        0x8B59
+#define GL_FLOAT_MAT2_ARB                       0x8B5A
+#define GL_FLOAT_MAT3_ARB                       0x8B5B
+#define GL_FLOAT_MAT4_ARB                       0x8B5C
+#define GL_SAMPLER_1D_ARB                       0x8B5D
+#define GL_SAMPLER_2D_ARB                       0x8B5E
+#define GL_SAMPLER_3D_ARB                       0x8B5F
+#define GL_SAMPLER_CUBE_ARB                     0x8B60
+#define GL_SAMPLER_1D_SHADOW_ARB                0x8B61
+#define GL_SAMPLER_2D_SHADOW_ARB                0x8B62
+#define GL_SAMPLER_2D_RECT_ARB                  0x8B63
+#define GL_SAMPELR_2D_RECT_SHADOW_ARB           0x8B64
+#endif
+#ifndef GL_ARB_shading_language_100
+#define GL_ARB_shading_language_100         1
+#define GL_SHADING_LANGUAGE_VERSION_ARB     0x8B8C
+#endif
+#ifndef GL_ARB_fragment_shader
+#define GL_ARB_fragment_shader 1
+#define GL_FRAGMENT_SHADER_ARB                  0x8B30
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB  0x8B49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB  0x8B8B
+#endif
+#ifndef GL_ARB_vertex_shader
+#define GL_ARB_vertex_shader 1
+#define GL_VERTEX_SHADER_ARB                        0x8B31
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB        0x8B4A
+#define GL_MAX_VARYING_FLOATS_ARB                   0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB       0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB     0x8B4D
+#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB             0x8B89
+#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB   0x8B8A
+#endif
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
+typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+typedef void (WINE_GLAPI * WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
+typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
+typedef void (WINE_GLAPI * WINED3D_PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+typedef void (WINE_GLAPI * WINED3D_PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
+typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
+typedef void (WINE_GLAPI * WINED3D_PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
+typedef void (WINE_GLAPI * WINED3D_PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (WINE_GLAPI * WINED3D_PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
+typedef void (WINE_GLAPI * WINED3D_PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
+typedef void (WINE_GLAPI * WINED3D_PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+typedef GLhandleARB (WINE_GLAPI * WINED3D_PFNGLGETHANDLEARBPROC) (GLenum pname);
+typedef void (WINE_GLAPI * WINED3D_PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+typedef void (WINE_GLAPI * WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
+typedef GLint (WINE_GLAPI * WINED3D_PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+/* GL_ARB_pixel_buffer_object */
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_ARB          0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_ARB        0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB  0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
+#endif
+/* GL_EXT_texture */
+#ifndef GL_EXT_texture
+#define GL_EXT_texture 1
+#define GL_ALPHA4_EXT                     0x803B
+#define GL_ALPHA8_EXT                     0x803C
+#define GL_ALPHA12_EXT                    0x803D
+#define GL_ALPHA16_EXT                    0x803E
+#define GL_LUMINANCE4_EXT                 0x803F
+#define GL_LUMINANCE8_EXT                 0x8040
+#define GL_LUMINANCE12_EXT                0x8041
+#define GL_LUMINANCE16_EXT                0x8042
+#define GL_LUMINANCE4_ALPHA4_EXT          0x8043
+#define GL_LUMINANCE6_ALPHA2_EXT          0x8044
+#define GL_LUMINANCE8_ALPHA8_EXT          0x8045
+#define GL_LUMINANCE12_ALPHA4_EXT         0x8046
+#define GL_LUMINANCE12_ALPHA12_EXT        0x8047
+#define GL_LUMINANCE16_ALPHA16_EXT        0x8048
+#define GL_INTENSITY_EXT                  0x8049
+#define GL_INTENSITY4_EXT                 0x804A
+#define GL_INTENSITY8_EXT                 0x804B
+#define GL_INTENSITY12_EXT                0x804C
+#define GL_INTENSITY16_EXT                0x804D
+#define GL_RGB2_EXT                       0x804E
+#define GL_RGB4_EXT                       0x804F
+#define GL_RGB5_EXT                       0x8050
+#define GL_RGB8_EXT                       0x8051
+#define GL_RGB10_EXT                      0x8052
+#define GL_RGB12_EXT                      0x8053
+#define GL_RGB16_EXT                      0x8054
+#define GL_RGBA2_EXT                      0x8055
+#define GL_RGBA4_EXT                      0x8056
+#define GL_RGB5_A1_EXT                    0x8057
+#define GL_RGBA8_EXT                      0x8058
+#define GL_RGB10_A2_EXT                   0x8059
+#define GL_RGBA12_EXT                     0x805A
+#define GL_RGBA16_EXT                     0x805B
+#define GL_TEXTURE_RED_SIZE_EXT           0x805C
+#define GL_TEXTURE_GREEN_SIZE_EXT         0x805D
+#define GL_TEXTURE_BLUE_SIZE_EXT          0x805E
+#define GL_TEXTURE_ALPHA_SIZE_EXT         0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE_EXT     0x8060
+#define GL_TEXTURE_INTENSITY_SIZE_EXT     0x8061
+#define GL_REPLACE_EXT                    0x8062
+#define GL_PROXY_TEXTURE_1D_EXT           0x8063
+#define GL_PROXY_TEXTURE_2D_EXT           0x8064
+#define GL_TEXTURE_TOO_LARGE_EXT          0x8065
+#endif
+/* GL_EXT_texture_compression_s3tc */
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_EXT_texture_compression_s3tc 1
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT   0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT  0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT  0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT  0x83F3
+#endif
+typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI * PGLFNCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (WINE_GLAPI * PGLFNGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);
+/* GL_EXT_stencil_wrap */
+#ifndef GL_EXT_stencil_wrap
+#define GL_EXT_stencil_wrap 1
+#define GL_INCR_WRAP_EXT                  0x8507
+#define GL_DECR_WRAP_EXT                  0x8508
+#endif
+
+/* GL_NV_half_float */
+#ifndef GL_NV_half_float
+#define GL_NV_half_float 1
+typedef unsigned short GLhalfNV;
+#define GL_HALF_FLOAT_NV                  0x140B
+#endif
+typedef void (WINE_GLAPI * PGLFNVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
+typedef void (WINE_GLAPI * PGLFNVERTEX2HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (WINE_GLAPI * PGLFNVERTEX3HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (WINE_GLAPI * PGLFNVERTEX4HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+typedef void (WINE_GLAPI * PGLFNNORMAL3HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (WINE_GLAPI * PGLFNCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+typedef void (WINE_GLAPI * PGLFNCOLOR4HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD1HNVPROC) (GLhalfNV s);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD1HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD2HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD3HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (WINE_GLAPI * PGLFNTEXCOORD4HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (WINE_GLAPI * PGLFNMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNFOGCOORDHNVPROC) (GLhalfNV fog);
+typedef void (WINE_GLAPI * PGLFNFOGCOORDHVNVPROC) (const GLhalfNV *fog);
+typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (WINE_GLAPI * PGLFNSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
+typedef void (WINE_GLAPI * PGLFNVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+
+/* GL_NV_fog_distance */
+#ifndef GL_NV_fog_distance
+#define GL_NV_fog_distance 1
+#define GL_FOG_DISTANCE_MODE_NV           0x855A
+#define GL_EYE_RADIAL_NV                  0x855B
+#define GL_EYE_PLANE_ABSOLUTE_NV          0x855C
+/* reuse GL_EYE_PLANE */
+#endif
+/* GL_NV_texgen_reflection */
+#ifndef GL_NV_texgen_reflection
+#define GL_NV_texgen_reflection 1
+#define GL_NORMAL_MAP_NV                  0x8511
+#define GL_REFLECTION_MAP_NV              0x8512
+#endif
+/* GL_NV_texture_env_combine4 */
+#ifndef GL_NV_texture_env_combine4
+#define GL_NV_texture_env_combine4 1
+#define GL_COMBINE4_NV                    0x8503
+#define GL_SOURCE3_RGB_NV                 0x8583
+#define GL_SOURCE3_ALPHA_NV               0x858B
+#define GL_OPERAND3_RGB_NV                0x8593
+#define GL_OPERAND3_ALPHA_NV              0x859B
+#endif
+/* GL_NV_register_combiners */
+#ifndef GL_NV_register_combiners
+#define GL_NV_register_combiners 1
+#define GL_REGISTER_COMBINERS_NV          0x8522
+#define GL_VARIABLE_A_NV                  0x8523
+#define GL_VARIABLE_B_NV                  0x8524
+#define GL_VARIABLE_C_NV                  0x8525
+#define GL_VARIABLE_D_NV                  0x8526
+#define GL_VARIABLE_E_NV                  0x8527
+#define GL_VARIABLE_F_NV                  0x8528
+#define GL_VARIABLE_G_NV                  0x8529
+#define GL_CONSTANT_COLOR0_NV             0x852A
+#define GL_CONSTANT_COLOR1_NV             0x852B
+#define GL_PRIMARY_COLOR_NV               0x852C
+#define GL_SECONDARY_COLOR_NV             0x852D
+#define GL_SPARE0_NV                      0x852E
+#define GL_SPARE1_NV                      0x852F
+#define GL_DISCARD_NV                     0x8530
+#define GL_E_TIMES_F_NV                   0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
+#define GL_UNSIGNED_IDENTITY_NV           0x8536
+#define GL_UNSIGNED_INVERT_NV             0x8537
+#define GL_EXPAND_NORMAL_NV               0x8538
+#define GL_EXPAND_NEGATE_NV               0x8539
+#define GL_HALF_BIAS_NORMAL_NV            0x853A
+#define GL_HALF_BIAS_NEGATE_NV            0x853B
+#define GL_SIGNED_IDENTITY_NV             0x853C
+#define GL_SIGNED_NEGATE_NV               0x853D
+#define GL_SCALE_BY_TWO_NV                0x853E
+#define GL_SCALE_BY_FOUR_NV               0x853F
+#define GL_SCALE_BY_ONE_HALF_NV           0x8540
+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV   0x8541
+#define GL_COMBINER_INPUT_NV              0x8542
+#define GL_COMBINER_MAPPING_NV            0x8543
+#define GL_COMBINER_COMPONENT_USAGE_NV    0x8544
+#define GL_COMBINER_AB_DOT_PRODUCT_NV     0x8545
+#define GL_COMBINER_CD_DOT_PRODUCT_NV     0x8546
+#define GL_COMBINER_MUX_SUM_NV            0x8547
+#define GL_COMBINER_SCALE_NV              0x8548
+#define GL_COMBINER_BIAS_NV               0x8549
+#define GL_COMBINER_AB_OUTPUT_NV          0x854A
+#define GL_COMBINER_CD_OUTPUT_NV          0x854B
+#define GL_COMBINER_SUM_OUTPUT_NV         0x854C
+#define GL_MAX_GENERAL_COMBINERS_NV       0x854D
+#define GL_NUM_GENERAL_COMBINERS_NV       0x854E
+#define GL_COLOR_SUM_CLAMP_NV             0x854F
+#define GL_COMBINER0_NV                   0x8550
+#define GL_COMBINER1_NV                   0x8551
+#define GL_COMBINER2_NV                   0x8552
+#define GL_COMBINER3_NV                   0x8553
+#define GL_COMBINER4_NV                   0x8554
+#define GL_COMBINER5_NV                   0x8555
+#define GL_COMBINER6_NV                   0x8556
+#define GL_COMBINER7_NV                   0x8557
+/* reuse GL_TEXTURE0_ARB */
+/* reuse GL_TEXTURE1_ARB */
+/* reuse GL_ZERO */
+/* reuse GL_NONE */
+/* reuse GL_FOG */
+#endif
+typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
+typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+typedef void (WINE_GLAPI * PGLFNCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (WINE_GLAPI * PGLFNCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (WINE_GLAPI * PGLFNCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+typedef void (WINE_GLAPI * PGLFNFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
+/* GL_NV_register_combiners2 */
+#ifndef GL_NV_register_combiners2
+#define GL_NV_register_combiners2 1
+#define GL_PER_STAGE_CONSTANTS_NV         0x8535
+#endif
+typedef void (WINE_GLAPI * PGLFNCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
+/* GL_NV_texture_shader */
+#ifndef GL_NV_texture_shader
+#define GL_NV_texture_shader 1
+#define GL_OFFSET_TEXTURE_RECTANGLE_NV    0x864C
+#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
+#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
+#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
+#define GL_UNSIGNED_INT_S8_S8_8_8_NV      0x86DA
+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV  0x86DB
+#define GL_DSDT_MAG_INTENSITY_NV          0x86DC
+#define GL_SHADER_CONSISTENT_NV           0x86DD
+#define GL_TEXTURE_SHADER_NV              0x86DE
+#define GL_SHADER_OPERATION_NV            0x86DF
+#define GL_CULL_MODES_NV                  0x86E0
+#define GL_OFFSET_TEXTURE_MATRIX_NV       0x86E1
+#define GL_OFFSET_TEXTURE_SCALE_NV        0x86E2
+#define GL_OFFSET_TEXTURE_BIAS_NV         0x86E3
+#define GL_OFFSET_TEXTURE_2D_MATRIX_NV    GL_OFFSET_TEXTURE_MATRIX_NV
+#define GL_OFFSET_TEXTURE_2D_SCALE_NV     GL_OFFSET_TEXTURE_SCALE_NV
+#define GL_OFFSET_TEXTURE_2D_BIAS_NV      GL_OFFSET_TEXTURE_BIAS_NV
+#define GL_PREVIOUS_TEXTURE_INPUT_NV      0x86E4
+#define GL_CONST_EYE_NV                   0x86E5
+#define GL_PASS_THROUGH_NV                0x86E6
+#define GL_CULL_FRAGMENT_NV               0x86E7
+#define GL_OFFSET_TEXTURE_2D_NV           0x86E8
+#define GL_DEPENDENT_AR_TEXTURE_2D_NV     0x86E9
+#define GL_DEPENDENT_GB_TEXTURE_2D_NV     0x86EA
+#define GL_DOT_PRODUCT_NV                 0x86EC
+#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV   0x86ED
+#define GL_DOT_PRODUCT_TEXTURE_2D_NV      0x86EE
+#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
+#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
+#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
+#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
+#define GL_HILO_NV                        0x86F4
+#define GL_DSDT_NV                        0x86F5
+#define GL_DSDT_MAG_NV                    0x86F6
+#define GL_DSDT_MAG_VIB_NV                0x86F7
+#define GL_HILO16_NV                      0x86F8
+#define GL_SIGNED_HILO_NV                 0x86F9
+#define GL_SIGNED_HILO16_NV               0x86FA
+#define GL_SIGNED_RGBA_NV                 0x86FB
+#define GL_SIGNED_RGBA8_NV                0x86FC
+#define GL_SIGNED_RGB_NV                  0x86FE
+#define GL_SIGNED_RGB8_NV                 0x86FF
+#define GL_SIGNED_LUMINANCE_NV            0x8701
+#define GL_SIGNED_LUMINANCE8_NV           0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV      0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV    0x8704
+#define GL_SIGNED_ALPHA_NV                0x8705
+#define GL_SIGNED_ALPHA8_NV               0x8706
+#define GL_SIGNED_INTENSITY_NV            0x8707
+#define GL_SIGNED_INTENSITY8_NV           0x8708
+#define GL_DSDT8_NV                       0x8709
+#define GL_DSDT8_MAG8_NV                  0x870A
+#define GL_DSDT8_MAG8_INTENSITY8_NV       0x870B
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV   0x870C
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
+#define GL_HI_SCALE_NV                    0x870E
+#define GL_LO_SCALE_NV                    0x870F
+#define GL_DS_SCALE_NV                    0x8710
+#define GL_DT_SCALE_NV                    0x8711
+#define GL_MAGNITUDE_SCALE_NV             0x8712
+#define GL_VIBRANCE_SCALE_NV              0x8713
+#define GL_HI_BIAS_NV                     0x8714
+#define GL_LO_BIAS_NV                     0x8715
+#define GL_DS_BIAS_NV                     0x8716
+#define GL_DT_BIAS_NV                     0x8717
+#define GL_MAGNITUDE_BIAS_NV              0x8718
+#define GL_VIBRANCE_BIAS_NV               0x8719
+#define GL_TEXTURE_BORDER_VALUES_NV       0x871A
+#define GL_TEXTURE_HI_SIZE_NV             0x871B
+#define GL_TEXTURE_LO_SIZE_NV             0x871C
+#define GL_TEXTURE_DS_SIZE_NV             0x871D
+#define GL_TEXTURE_DT_SIZE_NV             0x871E
+#define GL_TEXTURE_MAG_SIZE_NV            0x871F
+#endif
+/* GL_NV_texture_shader2 */
+#ifndef GL_NV_texture_shader2
+#define GL_NV_texture_shader2 1
+#define GL_DOT_PRODUCT_TEXTURE_3D_NV      0x86EF
+#endif
+/* GL_NV_texture_shader3 */
+#ifndef GL_NV_texture_shader3
+#define GL_NV_texture_shader3 1
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
+#define GL_OFFSET_HILO_TEXTURE_2D_NV      0x8854
+#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
+#define GL_DEPENDENT_HILO_TEXTURE_2D_NV   0x8858
+#define GL_DEPENDENT_RGB_TEXTURE_3D_NV    0x8859
+#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
+#define GL_DOT_PRODUCT_PASS_THROUGH_NV    0x885B
+#define GL_DOT_PRODUCT_TEXTURE_1D_NV      0x885C
+#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
+#define GL_HILO8_NV                       0x885E
+#define GL_SIGNED_HILO8_NV                0x885F
+#define GL_FORCE_BLUE_TO_ONE_NV           0x8860
+#endif
+/* GL_ATI_texture_env_combine3 */
+#ifndef GL_ATI_texture_env_combine3
+#define GL_ATI_texture_env_combine3 1
+#define GL_MODULATE_ADD_ATI               0x8744
+#define GL_MODULATE_SIGNED_ADD_ATI        0x8745
+#define GL_MODULATE_SUBTRACT_ATI          0x8746
+/* #define ONE */
+/* #define ZERO */
+#endif
+
+/**
+ * Point sprites
+ */
+/* GL_ARB_point_sprite */
+#ifndef GL_ARB_point_sprite
+#define GL_ARB_point_sprite 1
+#define GL_POINT_SPRITE_ARB               0x8861
+#define GL_COORD_REPLACE_ARB              0x8862
+#endif
+/**
+ * @TODO: GL_NV_point_sprite
+ */
+
+/**
+ * Occlusion Queries
+ */
+/* GL_ARB_occlusion_query */
+#ifndef GL_ARB_occlusion_query
+#define GL_ARB_occlusion_query 1
+#define GL_SAMPLES_PASSED_ARB                             0x8914
+#define GL_QUERY_COUNTER_BITS_ARB                         0x8864
+#define GL_CURRENT_QUERY_ARB                              0x8865
+#define GL_QUERY_RESULT_ARB                               0x8866
+#define GL_QUERY_RESULT_AVAILABLE_ARB                     0x8867
+#endif
+typedef void (WINE_GLAPI * PGLFNGENQUERIESARBPROC) (GLsizei n, GLuint *queries);
+typedef void (WINE_GLAPI * PGLFNDELETEQUERIESARBPROC) (GLsizei n, const GLuint *queries);
+typedef GLboolean (WINE_GLAPI * PGLFNISQUERYARBPROC) (GLuint query);
+typedef void (WINE_GLAPI * PGLFNBEGINQUERYARBPROC) (GLenum target, GLuint query);
+typedef void (WINE_GLAPI * PGLFNENDQUERYARBPROC) (GLenum target);
+typedef void (WINE_GLAPI * PGLFNGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTIVARBPROC) (GLuint query, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETQUERYOBJECTUIVARBPROC) (GLuint query, GLenum pname, GLuint *params);
+/* GL_HP_occlusion_test isn't complete, but it's constants are used by GL_NV_occlusion_query */
+#ifndef GL_HP_occlusion_test
+#define GL_HP_occlusion_test 1
+#define GL_OCCLUSION_TEST_HP                 0x8165
+#define GL_OCCLUSION_TEST_RESULT_HP          0x8165
+#endif
+/*  GL_NV_occlusion_query */
+#ifndef GL_NV_occlusion_query
+#define GL_NV_occlusion_query 1
+#define GL_PIXEL_COUNTER_BITS_NV          0x8864
+#define GL_CURRENT_OCCLUSION_QUERY_ID_NV  0x8865
+#define GL_PIXEL_COUNT_NV                 0x8866
+#define GL_PIXEL_COUNT_AVAILABLE_NV       0x8867
+#endif
+typedef void (WINE_GLAPI * PGLFNGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
+typedef void (WINE_GLAPI * PGLFNDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (WINE_GLAPI * PGLFNISOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (WINE_GLAPI * PGLFNBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (WINE_GLAPI * PGLFNENDOCCLUSIONQUERYNVPROC) (void);
+typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
+/* GL_EXT_stencil_two_side */
+#ifndef GL_EXT_stencil_two_side
+#define GL_EXT_stencil_two_side 1
+#define GL_STENCIL_TEST_TWO_SIDE_EXT      0x8910
+#define GL_ACTIVE_STENCIL_FACE_EXT        0x8911
+#endif
+typedef void (WINE_GLAPI * PGLFNACTIVESTENCILFACEEXTPROC) (GLenum face);
+/* GL_ATI_separate_stencil */
+#ifndef GL_ATI_separate_stencil
+#define GL_ATI_separate_stencil 1
+#define GL_STENCIL_BACK_FUNC_ATI          0x8800
+#define GL_STENCIL_BACK_FAIL_ATI          0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803
+#endif
+typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEATIPROC) (GLenum, GLenum, GLenum, GLenum);
+typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEATIPROC) (GLenum, GLenum, GLint, GLuint);
+/* GL_NV_fence */
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#define GL_ALL_COMPLETED_NV                 0x84F2
+#define GL_FENCE_STATUS_NV                  0x84F3
+#define GL_FENCE_CONDITION_NV               0x84F4
+#endif
+typedef void (WINE_GLAPI * PGLFNGENFENCESNVPROC) (GLsizei, GLuint *);
+typedef void (WINE_GLAPI * PGLFNDELETEFENCESNVPROC) (GLuint, const GLuint *);
+typedef void (WINE_GLAPI * PGLFNSETFENCENVPROC) (GLuint, GLenum);
+typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCENVPROC) (GLuint);
+typedef void (WINE_GLAPI * PGLFNFINISHFENCENVPROC) (GLuint);
+typedef GLboolean (WINE_GLAPI * PGLFNISFENCENVPROC) (GLuint);
+typedef void (WINE_GLAPI * PGLFNGETFENCEIVNVPROC) (GLuint, GLenum, GLint *);
+/* GL_APPLE_fence */
+#ifndef GL_APPLE_fence
+#define GL_APPLE_fence 1
+#define GL_DRAW_PIXELS_APPLE                0x8A0A
+#define GL_FENCE_APPLE                      0x84F3
+#endif
+typedef void (WINE_GLAPI * PGLFNGENFENCESAPPLEPROC) (GLsizei, GLuint *);
+typedef void (WINE_GLAPI * PGLFNDELETEFENCESAPPLEPROC) (GLuint, const GLuint *);
+typedef void (WINE_GLAPI * PGLFNSETFENCEAPPLEPROC) (GLuint);
+typedef GLboolean (WINE_GLAPI * PGLFNTESTFENCEAPPLEPROC) (GLuint);
+typedef void (WINE_GLAPI * PGLFNFINISHFENCEAPPLEPROC) (GLuint);
+typedef GLboolean (WINE_GLAPI * PGLFNISFENCEAPPLEPROC) (GLuint);
+typedef GLboolean (WINE_GLAPI * PGLFNTESTOBJECTAPPLEPROC) (GLenum, GLuint);
+typedef void (WINE_GLAPI * PGLFNFINISHOBJECTAPPLEPROC) (GLenum, GLuint);
+/* GL_APPLE_client_storage */
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 1
+#define GL_UNPACK_CLIENT_STORAGE_APPLE      0x85B2
+#endif
+/* GLX_SGI_video_sync */
+typedef int (WINE_GLAPI * PGLXFNGETVIDEOSYNCSGIPROC) (unsigned int *);
+typedef int (WINE_GLAPI * PGLXFNWAITVIDEOSYNCSGIPROC) (int, int, unsigned int *);
+
+/* GL_SGIS_generate_mipmap */
+#ifndef GLX_SGIS_generate_mipmap
+#define GL_GENERATE_MIPMAP_SGIS             0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS        0x8192
+#define GLX_SGIS_generate_mipmap
+#endif
+
+/* GL_NV_depth_clamp */
+#ifndef GL_NV_depth_clamp
+#define GL_DEPTH_CLAMP_NV                   0x864F
+#endif
+
+/* GL_APPLE_flush_render */
+typedef void (WINE_GLAPI * PGLFNFLUSHRENDERAPPLEPROC) (void);
+typedef void (WINE_GLAPI * PGLFNFINISHRENDERAPPLEPROC) (void);
+
+/* GL_APPLE_ycbcr_422 */
+#ifndef GL_APPLE_ycbcr_422
+#define GL_APPLE_ycbcr_422
+#define GL_YCBCR_422_APPLE                  0x85B9
+#define UNSIGNED_SHORT_8_8_APPLE            0x85BA
+#define UNSIGNED_SHORT_8_8_REV_APPLE        0x85BB
+#endif
+
+/* GL_ARB_texture_rectangle */
+#ifndef GL_ARB_texture_rectangle
+#define GL_ARB_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_ARB            0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_ARB    0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_ARB      0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB   0x84F8
+#define GL_SAMPLER_2D_RECT_ARB              0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB       0x8B64
+#endif
+
+/* GL_APPLE_float_pixels */
+#ifndef GL_APPLE_float_pixels
+#define GL_APPLE_float_pixels
+#define GL_HALF_APPLE                       0x140B
+#define GL_COLOR_FLOAT_APPLE                0x8A0F
+#define GL_RGBA_FLOAT32_APPLE               0x8814
+#define GL_RGB_FLOAT32_APPLE                0x8815
+#define GL_ALPHA_FLOAT32_APPLE              0x8816
+#define GL_INTENSITY_FLOAT32_APPLE          0x8817
+#define GL_LUMINANCE_FLOAT32_APPLE          0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE    0x8819
+#define GL_RGBA_FLOAT16_APPLE               0x881A
+#define GL_RGB_FLOAT16_APPLE                0x881B
+#define GL_ALPHA_FLOAT16_APPLE              0x881C
+#define GL_INTENSITY_FLOAT16_APPLE          0x881D
+#define GL_LUMINANCE_FLOAT16_APPLE          0x881E
+#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE    0x881F
+#endif
+
+/* GL_EXT_gpu_program_parameters */
+#ifndef GL_EXT_gpu_program_parameters
+#define GL_EXT_gpu_program_parameters
+typedef void (WINE_GLAPI * PGLFNPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params);
+typedef void (WINE_GLAPI * PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const float *params);
+#endif
+
+/* GL_NV_light_max_exponent */
+#ifndef GL_NV_light_max_exponent
+#define GL_NV_light_max_exponent
+#define GL_MAX_SHININESS_NV                 0x8504
+#define GL_MAX_SPOT_EXPONENT_NV             0x8505
+#endif
+
+/* GL_ATI_fragment_shader */
+#ifndef GL_ATI_fragment_shader
+#define GL_ATI_fragment_shader
+typedef GLuint (WINE_GLAPI *PGLFNGENFRAGMENTSHADERSATI) (GLuint range);
+typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI) (GLuint id);
+typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI) (GLuint id);
+typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI) ();
+typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI) ();
+typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI) (GLuint dst, GLuint coord, GLenum swizzle);
+typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI) (GLuint dst, GLuint interp, GLenum swizzle);
+typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMask,
+                                                     GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+                                                     GLuint arg1Mod);
+typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMask,
+                                                     GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+                                                     GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+                                                     GLuint arg2Mod);
+typedef void (WINE_GLAPI *PGLFNCOLORFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMask,
+                                                     GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+                                                     GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+                                                     GLuint arg2Mod, GLuint arg3, GLuint arg3Rep,
+                                                     GLuint arg3Mod);
+typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP1ATI) (GLenum op, GLuint dst, GLuint dstMod,
+                                                     GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP2ATI) (GLenum op, GLuint dst, GLuint dstMod,
+                                                     GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
+                                                     GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (WINE_GLAPI *PGLFNALPHAFRAGMENTOP3ATI) (GLenum op, GLuint dst, GLuint dstMod,
+                                                     GLuint arg1, GLuint arg1Rep, GLuint arg1Mod,
+                                                     GLuint arg2, GLuint arg2Rep, GLuint arg2Mod,
+                                                     GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (WINE_GLAPI *PGLFNSETFRAGMENTSHADERCONSTANTATI) (GLuint dst, const GLfloat *value);
+#define GL_FRAGMENT_SHADER_ATI              0x8920
+#define GL_REG_0_ATI                        0x8921
+#define GL_REG_1_ATI                        0x8922
+#define GL_REG_2_ATI                        0x8923
+#define GL_REG_3_ATI                        0x8924
+#define GL_REG_4_ATI                        0x8925
+#define GL_REG_5_ATI                        0x8926
+#define GL_CON_0_ATI                        0x8941
+#define GL_CON_1_ATI                        0x8942
+#define GL_CON_2_ATI                        0x8943
+#define GL_CON_3_ATI                        0x8944
+#define GL_CON_4_ATI                        0x8945
+#define GL_CON_5_ATI                        0x8946
+#define GL_CON_6_ATI                        0x8947
+#define GL_CON_7_ATI                        0x8948
+#define GL_MOV_ATI                          0x8961
+#define GL_ADD_ATI                          0x8963
+#define GL_MUL_ATI                          0x8964
+#define GL_SUB_ATI                          0x8965
+#define GL_DOT3_ATI                         0x8966
+#define GL_DOT4_ATI                         0x8967
+#define GL_MAD_ATI                          0x8968
+#define GL_LERP_ATI                         0x8969
+#define GL_CND_ATI                          0x896A
+#define GL_CND0_ATI                         0x896B
+#define GL_DOT2_ADD_ATI                     0x896C
+#define GL_SECONDARY_INTERPOLATOR_ATI       0x896D
+#define GL_SWIZZLE_STR_ATI                  0x8976
+#define GL_SWIZZLE_STQ_ATI                  0x8977
+#define GL_SWIZZLE_STR_DR_ATI               0x8978
+#define GL_SWIZZLE_STQ_DQ_ATI               0x8979
+#define GL_RED_BIT_ATI                      0x00000001
+#define GL_GREEN_BIT_ATI                    0x00000002
+#define GL_BLUE_BIT_ATI                     0x00000004
+#define GL_2X_BIT_ATI                       0x00000001
+#define GL_4X_BIT_ATI                       0x00000002
+#define GL_8X_BIT_ATI                       0x00000004
+#define GL_HALF_BIT_ATI                     0x00000008
+#define GL_QUARTER_BIT_ATI                  0x00000010
+#define GL_EIGHTH_BIT_ATI                   0x00000020
+#define GL_SATURATE_BIT_ATI                 0x00000040
+#define GL_2X_BIT_ATI                       0x00000001
+#define GL_COMP_BIT_ATI                     0x00000002
+#define GL_NEGATE_BIT_ATI                   0x00000004
+#define GL_BIAS_BIT_ATI                     0x00000008
+#endif
+/* GL_ATI_texture_compression_3dc */
+#ifndef GL_ATI_texture_compression_3dc
+#define GL_ATI_texture_compression_3dc
+#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837
+#endif
+/* GL_EXT_texture_compression_rgtc */
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_EXT_texture_compression_rgtc
+#define GL_COMPRESSED_RED_RGTC1_EXT                       0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT                0x8DBC
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT                 0x8DBD
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT          0x8DBE
+#endif
+
+/* GL_VERSION_2_0 */
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+#define GL_BLEND_EQUATION_RGB             GL_BLEND_EQUATION
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED    0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE       0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE     0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE       0x8625
+#define GL_CURRENT_VERTEX_ATTRIB          0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE      0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE        0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER    0x8645
+#define GL_STENCIL_BACK_FUNC              0x8800
+#define GL_STENCIL_BACK_FAIL              0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL   0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS   0x8803
+#define GL_MAX_DRAW_BUFFERS               0x8824
+#define GL_DRAW_BUFFER0                   0x8825
+#define GL_DRAW_BUFFER1                   0x8826
+#define GL_DRAW_BUFFER2                   0x8827
+#define GL_DRAW_BUFFER3                   0x8828
+#define GL_DRAW_BUFFER4                   0x8829
+#define GL_DRAW_BUFFER5                   0x882A
+#define GL_DRAW_BUFFER6                   0x882B
+#define GL_DRAW_BUFFER7                   0x882C
+#define GL_DRAW_BUFFER8                   0x882D
+#define GL_DRAW_BUFFER9                   0x882E
+#define GL_DRAW_BUFFER10                  0x882F
+#define GL_DRAW_BUFFER11                  0x8830
+#define GL_DRAW_BUFFER12                  0x8831
+#define GL_DRAW_BUFFER13                  0x8832
+#define GL_DRAW_BUFFER14                  0x8833
+#define GL_DRAW_BUFFER15                  0x8834
+#define GL_BLEND_EQUATION_ALPHA           0x883D
+#define GL_POINT_SPRITE                   0x8861
+#define GL_COORD_REPLACE                  0x8862
+#define GL_MAX_VERTEX_ATTRIBS             0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_COORDS             0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS        0x8872
+#define GL_FRAGMENT_SHADER                0x8B30
+#define GL_VERTEX_SHADER                  0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS  0x8B4A
+#define GL_MAX_VARYING_FLOATS             0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE                    0x8B4F
+#define GL_FLOAT_VEC2                     0x8B50
+#define GL_FLOAT_VEC3                     0x8B51
+#define GL_FLOAT_VEC4                     0x8B52
+#define GL_INT_VEC2                       0x8B53
+#define GL_INT_VEC3                       0x8B54
+#define GL_INT_VEC4                       0x8B55
+#define GL_BOOL                           0x8B56
+#define GL_BOOL_VEC2                      0x8B57
+#define GL_BOOL_VEC3                      0x8B58
+#define GL_BOOL_VEC4                      0x8B59
+#define GL_FLOAT_MAT2                     0x8B5A
+#define GL_FLOAT_MAT3                     0x8B5B
+#define GL_FLOAT_MAT4                     0x8B5C
+#define GL_SAMPLER_1D                     0x8B5D
+#define GL_SAMPLER_2D                     0x8B5E
+#define GL_SAMPLER_3D                     0x8B5F
+#define GL_SAMPLER_CUBE                   0x8B60
+#define GL_SAMPLER_1D_SHADOW              0x8B61
+#define GL_SAMPLER_2D_SHADOW              0x8B62
+#define GL_DELETE_STATUS                  0x8B80
+#define GL_COMPILE_STATUS                 0x8B81
+#define GL_LINK_STATUS                    0x8B82
+#define GL_VALIDATE_STATUS                0x8B83
+#define GL_INFO_LOG_LENGTH                0x8B84
+#define GL_ATTACHED_SHADERS               0x8B85
+#define GL_ACTIVE_UNIFORMS                0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH      0x8B87
+#define GL_SHADER_SOURCE_LENGTH           0x8B88
+#define GL_ACTIVE_ATTRIBUTES              0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH    0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION       0x8B8C
+#define GL_CURRENT_PROGRAM                0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN      0x8CA0
+#define GL_LOWER_LEFT                     0x8CA1
+#define GL_UPPER_LEFT                     0x8CA2
+#define GL_STENCIL_BACK_REF               0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK        0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK         0x8CA5
+typedef char GLchar;
+#endif
+typedef void (WINE_GLAPI * PGLFNBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
+typedef void (WINE_GLAPI * PGLFNDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
+typedef void (WINE_GLAPI * PGLFNSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (WINE_GLAPI * PGLFNSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+typedef void (WINE_GLAPI * PGLFNSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
+typedef void (WINE_GLAPI * PGLFNATTACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (WINE_GLAPI * PGLFNBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
+typedef void (WINE_GLAPI * PGLFNCOMPILESHADERPROC) (GLuint shader);
+typedef GLuint (WINE_GLAPI * PGLFNCREATEPROGRAMPROC) (void);
+typedef GLuint (WINE_GLAPI * PGLFNCREATESHADERPROC) (GLenum type);
+typedef void (WINE_GLAPI * PGLFNDELETEPROGRAMPROC) (GLuint program);
+typedef void (WINE_GLAPI * PGLFNDELETESHADERPROC) (GLuint shader);
+typedef void (WINE_GLAPI * PGLFNDETACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (WINE_GLAPI * PGLFNDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (WINE_GLAPI * PGLFNENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (WINE_GLAPI * PGLFNGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (WINE_GLAPI * PGLFNGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (WINE_GLAPI * PGLFNGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+typedef GLint (WINE_GLAPI * PGLFNGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (WINE_GLAPI * PGLFNGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (WINE_GLAPI * PGLFNGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef GLint (WINE_GLAPI * PGLFNGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (WINE_GLAPI * PGLFNGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (WINE_GLAPI * PGLFNGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (WINE_GLAPI * PGLFNISPROGRAMPROC) (GLuint program);
+typedef GLboolean (WINE_GLAPI * PGLFNISSHADERPROC) (GLuint shader);
+typedef void (WINE_GLAPI * PGLFNLINKPROGRAMPROC) (GLuint program);
+typedef void (WINE_GLAPI * PGLFNSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
+typedef void (WINE_GLAPI * PGLFNUSEPROGRAMPROC) (GLuint program);
+typedef void (WINE_GLAPI * PGLFNUNIFORM1FPROC) (GLint location, GLfloat v0);
+typedef void (WINE_GLAPI * PGLFNUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (WINE_GLAPI * PGLFNUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (WINE_GLAPI * PGLFNUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (WINE_GLAPI * PGLFNUNIFORM1IPROC) (GLint location, GLint v0);
+typedef void (WINE_GLAPI * PGLFNUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
+typedef void (WINE_GLAPI * PGLFNUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (WINE_GLAPI * PGLFNUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (WINE_GLAPI * PGLFNUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI * PGLFNUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (WINE_GLAPI * PGLFNVALIDATEPROGRAMPROC) (GLuint program);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
+typedef void (WINE_GLAPI * PGLFNVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+
+
+/****************************************************
+ * OpenGL Official Version
+ *  defines
+ ****************************************************/
+/* GL_VERSION_1_3 */
+#if !defined(GL_DOT3_RGBA)
+# define GL_DOT3_RGBA                     0x8741
+#endif
+#if !defined(GL_SUBTRACT)
+# define GL_SUBTRACT                      0x84E7
+#endif
+
+
+/****************************************************
+ * Enumerated types
+ ****************************************************/
+typedef enum _GL_Vendors {
+  VENDOR_WINE   = 0x0,
+  VENDOR_MESA   = 0x1,
+  VENDOR_ATI    = 0x1002,
+  VENDOR_NVIDIA = 0x10de,
+  VENDOR_INTEL  = 0x8086
+} GL_Vendors;
+
+typedef enum _GL_Cards {
+  CARD_WINE                       =    0x0,
+
+  CARD_ATI_RAGE_128PRO            = 0x5246,
+  CARD_ATI_RADEON_7200            = 0x5144,
+  CARD_ATI_RADEON_8500            = 0x514c,
+  CARD_ATI_RADEON_9500            = 0x4144,
+  CARD_ATI_RADEON_X700            = 0x5e4c,
+  CARD_ATI_RADEON_X1600           = 0x71c2,
+  CARD_ATI_RADEON_HD2300          = 0x7210,
+  CARD_ATI_RADEON_HD2600          = 0x9581,
+  CARD_ATI_RADEON_HD2900          = 0x9400,
+  CARD_ATI_RADEON_HD3200          = 0x9620,
+
+  CARD_NVIDIA_RIVA_128            = 0x0018,
+  CARD_NVIDIA_RIVA_TNT            = 0x0020,
+  CARD_NVIDIA_RIVA_TNT2           = 0x0028,
+  CARD_NVIDIA_GEFORCE             = 0x0100,
+  CARD_NVIDIA_GEFORCE2_MX         = 0x0110,
+  CARD_NVIDIA_GEFORCE2            = 0x0150,
+  CARD_NVIDIA_GEFORCE3            = 0x0200,
+  CARD_NVIDIA_GEFORCE4_MX         = 0x0170,
+  CARD_NVIDIA_GEFORCE4_TI4200     = 0x0253,
+  CARD_NVIDIA_GEFORCEFX_5200      = 0x0320,
+  CARD_NVIDIA_GEFORCEFX_5600      = 0x0312,
+  CARD_NVIDIA_GEFORCEFX_5800      = 0x0302,
+  CARD_NVIDIA_GEFORCE_6200        = 0x014f,
+  CARD_NVIDIA_GEFORCE_6600GT      = 0x0140,
+  CARD_NVIDIA_GEFORCE_6800        = 0x0041,
+  CARD_NVIDIA_GEFORCE_7400        = 0x01d8,
+  CARD_NVIDIA_GEFORCE_7300        = 0x01d7, /* GeForce Go 7300 */
+  CARD_NVIDIA_GEFORCE_7600        = 0x0391,
+  CARD_NVIDIA_GEFORCE_7800GT      = 0x0092,
+  CARD_NVIDIA_GEFORCE_8300GS      = 0x0423,
+  CARD_NVIDIA_GEFORCE_8600GT      = 0x0402,
+  CARD_NVIDIA_GEFORCE_8600MGT     = 0x0407,
+  CARD_NVIDIA_GEFORCE_8800GTS     = 0x0193,
+  CARD_NVIDIA_GEFORCE_9600GT      = 0x0622,
+  CARD_NVIDIA_GEFORCE_9800GT      = 0x0614,
+  CARD_NVIDIA_GEFORCE_GTX280      = 0x05e1,
+
+  CARD_INTEL_845G                 = 0x2562,
+  CARD_INTEL_I830G                = 0x3577,
+  CARD_INTEL_I855G                = 0x3582,
+  CARD_INTEL_I865G                = 0x2572,
+  CARD_INTEL_I915G                = 0x2582,
+  CARD_INTEL_I915GM               = 0x2592,
+  CARD_INTEL_I945GM               = 0x27a2, /* Same as GMA 950?? */
+} GL_Cards;
+
+#define WINE_DEFAULT_VIDMEM 64*1024*1024
+
+typedef enum _GL_VSVersion {
+  VS_VERSION_NOT_SUPPORTED = 0x0,
+  VS_VERSION_10 = 0x10,
+  VS_VERSION_11 = 0x11,
+  VS_VERSION_20 = 0x20,
+  VS_VERSION_30 = 0x30,
+  /*Force 32-bits*/
+  VS_VERSION_FORCE_DWORD = 0x7FFFFFFF
+} GL_VSVersion;
+
+typedef enum _GL_PSVersion {
+  PS_VERSION_NOT_SUPPORTED = 0x0,
+  PS_VERSION_10 = 0x10,
+  PS_VERSION_11 = 0x11,
+  PS_VERSION_12 = 0x12,
+  PS_VERSION_13 = 0x13,
+  PS_VERSION_14 = 0x14,
+  PS_VERSION_20 = 0x20,
+  PS_VERSION_30 = 0x30,
+  /*Force 32-bits*/
+  PS_VERSION_FORCE_DWORD = 0x7FFFFFFF
+} GL_PSVersion;
+
+#define MAKEDWORD_VERSION(maj, min)  ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF)
+
+/* OpenGL Supported Extensions (ARB and EXT) */
+typedef enum _GL_SupportedExt {
+  /* ARB */
+  ARB_COLOR_BUFFER_FLOAT,
+  ARB_DRAW_BUFFERS,
+  ARB_FRAGMENT_PROGRAM,
+  ARB_FRAGMENT_SHADER,
+  ARB_IMAGING,
+  ARB_MULTISAMPLE,
+  ARB_MULTITEXTURE,
+  ARB_OCCLUSION_QUERY,
+  ARB_POINT_PARAMETERS,
+  ARB_PIXEL_BUFFER_OBJECT,
+  ARB_POINT_SPRITE,
+  ARB_TEXTURE_COMPRESSION,
+  ARB_TEXTURE_CUBE_MAP,
+  ARB_TEXTURE_ENV_ADD,
+  ARB_TEXTURE_ENV_COMBINE,
+  ARB_TEXTURE_ENV_DOT3,
+  ARB_TEXTURE_FLOAT,
+  ARB_HALF_FLOAT_PIXEL,
+  ARB_TEXTURE_BORDER_CLAMP,
+  ARB_TEXTURE_MIRRORED_REPEAT,
+  ARB_TEXTURE_NON_POWER_OF_TWO,
+  ARB_TEXTURE_RECTANGLE,
+  ARB_VERTEX_PROGRAM,
+  ARB_VERTEX_BLEND,
+  ARB_VERTEX_BUFFER_OBJECT,
+  ARB_VERTEX_SHADER,
+  ARB_SHADER_OBJECTS,
+  /* EXT */
+  EXT_BLEND_COLOR,
+  EXT_BLEND_MINMAX,
+  EXT_BLEND_EQUATION_SEPARATE,
+  EXT_BLEND_FUNC_SEPARATE,
+  EXT_FOG_COORD,
+  EXT_FRAMEBUFFER_OBJECT,
+  EXT_FRAMEBUFFER_BLIT,
+  EXT_FRAMEBUFFER_MULTISAMPLE,
+  EXT_PALETTED_TEXTURE,
+  EXT_PIXEL_BUFFER_OBJECT,
+  EXT_POINT_PARAMETERS,
+  EXT_SECONDARY_COLOR,
+  EXT_STENCIL_TWO_SIDE,
+  EXT_STENCIL_WRAP,
+  EXT_TEXTURE3D,
+  EXT_TEXTURE_COMPRESSION_S3TC,
+  EXT_TEXTURE_COMPRESSION_RGTC,
+  EXT_TEXTURE_FILTER_ANISOTROPIC,
+  EXT_TEXTURE_LOD,
+  EXT_TEXTURE_LOD_BIAS,
+  EXT_TEXTURE_ENV_ADD,
+  EXT_TEXTURE_ENV_COMBINE,
+  EXT_TEXTURE_ENV_DOT3,
+  EXT_TEXTURE_SRGB,
+  EXT_GPU_PROGRAM_PARAMETERS,
+  /* NVIDIA */
+  NV_HALF_FLOAT,
+  NV_FOG_DISTANCE,
+  NV_FRAGMENT_PROGRAM,
+  NV_FRAGMENT_PROGRAM2,
+  NV_OCCLUSION_QUERY,
+  NV_REGISTER_COMBINERS,
+  NV_REGISTER_COMBINERS2,
+  NV_TEXGEN_REFLECTION,
+  NV_TEXTURE_ENV_COMBINE4,
+  NV_TEXTURE_SHADER,
+  NV_TEXTURE_SHADER2,
+  NV_TEXTURE_SHADER3,
+  NV_VERTEX_PROGRAM,
+  NV_VERTEX_PROGRAM1_1,
+  NV_VERTEX_PROGRAM2,
+  NV_VERTEX_PROGRAM3,
+  NV_FENCE,
+  NV_DEPTH_CLAMP,
+  NV_LIGHT_MAX_EXPONENT,
+  /* ATI */
+  ATI_SEPARATE_STENCIL,
+  ATI_TEXTURE_ENV_COMBINE3,
+  ATI_TEXTURE_MIRROR_ONCE,
+  EXT_VERTEX_SHADER,
+  ATI_FRAGMENT_SHADER,
+  ATI_TEXTURE_COMPRESSION_3DC,
+  /* APPLE */
+  APPLE_FENCE,
+  APPLE_CLIENT_STORAGE,
+  APPLE_FLUSH_RENDER,
+  APPLE_YCBCR_422,
+  APPLE_FLOAT_PIXELS,
+  /* SGI */
+  SGI_VIDEO_SYNC,
+  SGIS_GENERATE_MIPMAP,
+
+  /* Internally used */
+  WINE_NORMALIZED_TEXRECT,
+
+  /* WGL extensions */
+  WGL_ARB_PBUFFER,
+  WGL_WINE_PIXEL_FORMAT_PASSTHROUGH,
+
+  OPENGL_SUPPORTED_EXT_END
+} GL_SupportedExt;
+
+
+/****************************************************
+ * #Defines
+ ****************************************************/
+#define GL_EXT_FUNCS_GEN \
+    /** ARB Extensions **/ \
+    /* GL_ARB_color_buffer_float */ \
+    USE_GL_FUNC(PGLFNCLAMPCOLORARBPROC,                             glClampColorARB,                            ARB_COLOR_BUFFER_FLOAT, NULL )\
+    /* GL_ARB_draw_buffers */ \
+    USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC,                            glDrawBuffersARB,                           ARB_DRAW_BUFFERS,       NULL )\
+    /* GL_ARB_imaging, GL_EXT_blend_minmax */ \
+    USE_GL_FUNC(PGLFNBLENDCOLORPROC,                                glBlendColorEXT,                            EXT_BLEND_COLOR,        NULL )\
+    USE_GL_FUNC(PGLFNBLENDEQUATIONPROC,                             glBlendEquationEXT,                         EXT_BLEND_MINMAX,       NULL )\
+    /* GL_ARB_multisample */ \
+    USE_GL_FUNC(WINED3D_PFNGLSAMPLECOVERAGEARBPROC,                 glSampleCoverageARB,                        ARB_MULTISAMPLE,        NULL )\
+    /* GL_ARB_multitexture */ \
+    USE_GL_FUNC(WINED3D_PFNGLACTIVETEXTUREARBPROC,                  glActiveTextureARB,                         ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLCLIENTACTIVETEXTUREARBPROC,            glClientActiveTextureARB,                   ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FARBPROC,                glMultiTexCoord1fARB,                       ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD1FVARBPROC,               glMultiTexCoord1fvARB,                      ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FARBPROC,                glMultiTexCoord2fARB,                       ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2FVARBPROC,               glMultiTexCoord2fvARB,                      ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FARBPROC,                glMultiTexCoord3fARB,                       ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD3FVARBPROC,               glMultiTexCoord3fvARB,                      ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FARBPROC,                glMultiTexCoord4fARB,                       ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4FVARBPROC,               glMultiTexCoord4fvARB,                      ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD2SVARBPROC,               glMultiTexCoord2svARB,                      ARB_MULTITEXTURE,       NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLMULTITEXCOORD4SVARBPROC,               glMultiTexCoord4svARB,                      ARB_MULTITEXTURE,       NULL )\
+    /* GL_ARB_occlusion_query */ \
+    USE_GL_FUNC(PGLFNGENQUERIESARBPROC,                             glGenQueriesARB,                            ARB_OCCLUSION_QUERY,    NULL )\
+    USE_GL_FUNC(PGLFNDELETEQUERIESARBPROC,                          glDeleteQueriesARB,                         ARB_OCCLUSION_QUERY,    NULL )\
+    USE_GL_FUNC(PGLFNBEGINQUERYARBPROC,                             glBeginQueryARB,                            ARB_OCCLUSION_QUERY,    NULL )\
+    USE_GL_FUNC(PGLFNENDQUERYARBPROC,                               glEndQueryARB,                              ARB_OCCLUSION_QUERY,    NULL )\
+    USE_GL_FUNC(PGLFNGETQUERYOBJECTIVARBPROC,                       glGetQueryObjectivARB,                      ARB_OCCLUSION_QUERY,    NULL )\
+    USE_GL_FUNC(PGLFNGETQUERYOBJECTUIVARBPROC,                      glGetQueryObjectuivARB,                     ARB_OCCLUSION_QUERY,    NULL )\
+    /* GL_ARB_point_parameters */ \
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC,                      glPointParameterfARB,                       ARB_POINT_PARAMETERS,   NULL )\
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC,                     glPointParameterfvARB,                      ARB_POINT_PARAMETERS,   NULL )\
+    /* GL_ARB_texture_compression */ \
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC,                      glCompressedTexImage2DARB,                  ARB_TEXTURE_COMPRESSION,NULL )\
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE3DPROC,                      glCompressedTexImage3DARB,                  ARB_TEXTURE_COMPRESSION,NULL )\
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE2DPROC,                   glCompressedTexSubImage2DARB,               ARB_TEXTURE_COMPRESSION,NULL )\
+    USE_GL_FUNC(PGLFNCOMPRESSEDTEXSUBIMAGE3DPROC,                   glCompressedTexSubImage3DARB,               ARB_TEXTURE_COMPRESSION,NULL )\
+    USE_GL_FUNC(PGLFNGETCOMPRESSEDTEXIMAGEPROC,                     glGetCompressedTexImageARB,                 ARB_TEXTURE_COMPRESSION,NULL )\
+    /* GL_ARB_vertex_blend */ \
+    USE_GL_FUNC(PGLFNGLWEIGHTPOINTERARB,                            glWeightPointerARB,                         ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTBV,                                    glWeightbvARB,                              ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTSV,                                    glWeightsvARB,                              ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTIV,                                    glWeightivARB,                              ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTFV,                                    glWeightfvARB,                              ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTDV,                                    glWeightdvARB,                              ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTUBV,                                   glWeightubvARB,                             ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTUSV,                                   glWeightusvARB,                             ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLWEIGHTUIV,                                   glWeightuivARB,                             ARB_VERTEX_BLEND,       NULL )\
+    USE_GL_FUNC(PGLFNGLVERTEXBLENDARB,                              glVertexBlendARB,                           ARB_VERTEX_BLEND,       NULL )\
+    /* GL_ARB_vertex_buffer_object */ \
+    USE_GL_FUNC(PGLFNBINDBUFFERARBPROC,                             glBindBufferARB,                            ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNDELETEBUFFERSARBPROC,                          glDeleteBuffersARB,                         ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNGENBUFFERSARBPROC,                             glGenBuffersARB,                            ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNISBUFFERARBPROC,                               glIsBufferARB,                              ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNBUFFERDATAARBPROC,                             glBufferDataARB,                            ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNBUFFERSUBDATAARBPROC,                          glBufferSubDataARB,                         ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNGETBUFFERSUBDATAARBPROC,                       glGetBufferSubDataARB,                      ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNMAPBUFFERARBPROC,                              glMapBufferARB,                             ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNUNMAPBUFFERARBPROC,                            glUnmapBufferARB,                           ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNGETBUFFERPARAMETERIVARBPROC,                   glGetBufferParameterivARB,                  ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    USE_GL_FUNC(PGLFNGETBUFFERPOINTERVARBPROC,                      glGetBufferPointervARB,                     ARB_VERTEX_BUFFER_OBJECT,NULL)\
+    /** EXT Extensions **/ \
+    /* GL_EXT_blend_equation_separate */ \
+    USE_GL_FUNC(PGLFNBLENDFUNCSEPARATEEXTPROC,                      glBlendFuncSeparateEXT,                     EXT_BLEND_FUNC_SEPARATE, NULL)\
+    /* GL_EXT_blend_func_separate */ \
+    USE_GL_FUNC(PGLFNBLENDEQUATIONSEPARATEEXTPROC,                  glBlendEquationSeparateEXT,                 EXT_BLEND_EQUATION_SEPARATE, NULL)\
+    /* GL_EXT_fog_coord */ \
+    USE_GL_FUNC(PGLFNGLFOGCOORDFEXTPROC,                            glFogCoordfEXT,                             EXT_FOG_COORD,          NULL )\
+    USE_GL_FUNC(PGLFNGLFOGCOORDFVEXTPROC,                           glFogCoordfvEXT,                            EXT_FOG_COORD,          NULL )\
+    USE_GL_FUNC(PGLFNGLFOGCOORDDEXTPROC,                            glFogCoorddEXT,                             EXT_FOG_COORD,          NULL )\
+    USE_GL_FUNC(PGLFNGLFOGCOORDDVEXTPROC,                           glFogCoordvEXT,                             EXT_FOG_COORD,          NULL )\
+    USE_GL_FUNC(PGLFNGLFOGCOORDPOINTEREXTPROC,                      glFogCoordPointerEXT,                       EXT_FOG_COORD,          NULL )\
+    /* GL_EXT_framebuffer_object */ \
+    USE_GL_FUNC(PGLFNGLISRENDERBUFFEREXTPROC,                       glIsRenderbufferEXT,                        EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLBINDRENDERBUFFEREXTPROC,                     glBindRenderbufferEXT,                      EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSEXTPROC,                  glDeleteRenderbuffersEXT,                   EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSEXTPROC,                     glGenRenderbuffersEXT,                      EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEEXTPROC,                  glRenderbufferStorageEXT,                   EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLISFRAMEBUFFEREXTPROC,                        glIsFramebufferEXT,                         EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFEREXTPROC,                      glBindFramebufferEXT,                       EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSEXTPROC,                   glDeleteFramebuffersEXT,                    EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSEXTPROC,                      glGenFramebuffersEXT,                       EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSEXTPROC,               glCheckFramebufferStatusEXT,                EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DEXTPROC,                 glFramebufferTexture1DEXT,                  EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DEXTPROC,                 glFramebufferTexture2DEXT,                  EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DEXTPROC,                 glFramebufferTexture3DEXT,                  EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFEREXTPROC,              glFramebufferRenderbufferEXT,               EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLGENERATEMIPMAPEXTPROC,                       glGenerateMipmapEXT,                        EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVEXTPROC,           glGetRenderbufferParameterivEXT,            EXT_FRAMEBUFFER_OBJECT, NULL )\
+    USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC,  glGetFramebufferAttachmentParameterivEXT,   EXT_FRAMEBUFFER_OBJECT, NULL )\
+    /* GL_EXT_framebuffer_blit */ \
+    USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFEREXTPROC,                      glBlitFramebufferEXT,                       EXT_FRAMEBUFFER_BLIT,   NULL )\
+    /* GL_EXT_framebuffer_multisample */ \
+    USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC,         glRenderbufferStorageMultisampleEXT,        EXT_FRAMEBUFFER_MULTISAMPLE, NULL )\
+    /* GL_EXT_paletted_texture */ \
+    USE_GL_FUNC(PGLFNGLCOLORTABLEEXTPROC,                           glColorTableEXT,                            EXT_PALETTED_TEXTURE,   NULL )\
+    /* GL_EXT_point_parameters */ \
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC,                      glPointParameterfEXT,                       EXT_POINT_PARAMETERS,   NULL )\
+    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC,                     glPointParameterfvEXT,                      EXT_POINT_PARAMETERS,   NULL )\
+    /* GL_EXT_secondary_color */ \
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC,                    glSecondaryColor3ubEXT,                     EXT_SECONDARY_COLOR,    NULL )\
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FEXTPROC,                     glSecondaryColor3fEXT,                      EXT_SECONDARY_COLOR,    NULL )\
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3FVEXTPROC,                    glSecondaryColor3fvEXT,                     EXT_SECONDARY_COLOR,    NULL )\
+    USE_GL_FUNC(PGLFNGLSECONDARYCOLORPOINTEREXTPROC,                glSecondaryColorPointerEXT,                 EXT_SECONDARY_COLOR,    NULL )\
+    /* GL_EXT_texture3D */ \
+    USE_GL_FUNC(PGLFNGLTEXIMAGE3DEXTPROC,                           glTexImage3DEXT,                            EXT_TEXTURE3D,          glTexImage3D)\
+    USE_GL_FUNC(PGLFNGLTEXSUBIMAGE3DEXTPROC,                        glTexSubImage3DEXT,                         EXT_TEXTURE3D,          glTexSubImage3D)\
+    /* GL_ARB_vertex_program */ \
+    USE_GL_FUNC(PGLFNGENPROGRAMSARBPROC,                            glGenProgramsARB,                           ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNBINDPROGRAMARBPROC,                            glBindProgramARB,                           ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNPROGRAMSTRINGARBPROC,                          glProgramStringARB,                         ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNDELETEPROGRAMSARBPROC,                         glDeleteProgramsARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNPROGRAMENVPARAMETER4FVARBPROC,                 glProgramEnvParameter4fvARB,                ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETER4FVARBPROC,               glProgramLocalParameter4fvARB,                ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIBPOINTERARBPROC,                    glVertexAttribPointerARB,                   ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNENABLEVERTEXATTRIBARRAYARBPROC,                glEnableVertexAttribArrayARB,               ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNDISABLEVERTEXATTRIBARRAYARBPROC,               glDisableVertexAttribArrayARB,              ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1DARBPROC,                         glVertexAttrib1dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1DVARBPROC,                        glVertexAttrib1dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1FARBPROC,                         glVertexAttrib1fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1FVARBPROC,                        glVertexAttrib1fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1SARBPROC,                         glVertexAttrib1sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1SVARBPROC,                        glVertexAttrib1svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2DARBPROC,                         glVertexAttrib2dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2DVARBPROC,                        glVertexAttrib2dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2FARBPROC,                         glVertexAttrib2fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2FVARBPROC,                        glVertexAttrib2fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2SARBPROC,                         glVertexAttrib2sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2SVARBPROC,                        glVertexAttrib2svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3DARBPROC,                         glVertexAttrib3dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3DVARBPROC,                        glVertexAttrib3dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3FARBPROC,                         glVertexAttrib3fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3FVARBPROC,                        glVertexAttrib3fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3SARBPROC,                         glVertexAttrib3sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3SVARBPROC,                        glVertexAttrib3svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NBVARBPROC,                       glVertexAttrib4NbvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NIVARBPROC,                       glVertexAttrib4NivARB,                      ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NSVARBPROC,                       glVertexAttrib4NsvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBARBPROC,                       glVertexAttrib4NubARB,                      ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUBVARBPROC,                      glVertexAttrib4NubvARB,                     ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUIVARBPROC,                      glVertexAttrib4NuivARB,                     ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4NUSVARBPROC,                      glVertexAttrib4NusvARB,                     ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4BVARBPROC,                        glVertexAttrib4bvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4DARBPROC,                         glVertexAttrib4dARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4DVARBPROC,                        glVertexAttrib4dvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4FARBPROC,                         glVertexAttrib4fARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4FVARBPROC,                        glVertexAttrib4fvARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4IVARBPROC,                        glVertexAttrib4ivARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4SARBPROC,                         glVertexAttrib4sARB,                        ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4SVARBPROC,                        glVertexAttrib4svARB,                       ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4UBVARBPROC,                       glVertexAttrib4ubvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4UIVARBPROC,                       glVertexAttrib4uivARB,                      ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4USVARBPROC,                       glVertexAttrib4usvARB,                      ARB_VERTEX_PROGRAM,     NULL )\
+    USE_GL_FUNC(PGLFNGETPROGRAMIVARBPROC,                           glGetProgramivARB,                          ARB_VERTEX_PROGRAM,     NULL )\
+    /* GL_ARB_shader_objects */ \
+    USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERIVARBPROC,           glGetObjectParameterivARB,                  ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETOBJECTPARAMETERFVARBPROC,           glGetObjectParameterfvARB,                  ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMLOCATIONARBPROC,             glGetUniformLocationARB,                    ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETACTIVEUNIFORMARBPROC,               glGetActiveUniformARB,                      ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC,                      glUniform1iARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IARBPROC,                      glUniform2iARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IARBPROC,                      glUniform3iARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IARBPROC,                      glUniform4iARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IARBPROC,                      glUniform1fARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FARBPROC,                      glUniform2fARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FARBPROC,                      glUniform3fARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FARBPROC,                      glUniform4fARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1FVARBPROC,                     glUniform1fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2FVARBPROC,                     glUniform2fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3FVARBPROC,                     glUniform3fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4FVARBPROC,                     glUniform4fvARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM1IVARBPROC,                     glUniform1ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM2IVARBPROC,                     glUniform2ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM3IVARBPROC,                     glUniform3ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORM4IVARBPROC,                     glUniform4ivARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX2FVARBPROC,               glUniformMatrix2fvARB,                      ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX3FVARBPROC,               glUniformMatrix3fvARB,                      ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUNIFORMMATRIX4FVARBPROC,               glUniformMatrix4fvARB,                      ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMFVARBPROC,                   glGetUniform4fvARB,                         ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETUNIFORMIVARBPROC,                   glGetUniform4ivARB,                         ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETINFOLOGARBPROC,                     glGetInfoLogARB,                            ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLUSEPROGRAMOBJECTARBPROC,               glUseProgramObjectARB,                      ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLCREATESHADEROBJECTARBPROC,             glCreateShaderObjectARB,                    ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLSHADERSOURCEARBPROC,                   glShaderSourceARB,                          ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLCOMPILESHADERARBPROC,                  glCompileShaderARB,                         ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLCREATEPROGRAMOBJECTARBPROC,            glCreateProgramObjectARB,                   ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLATTACHOBJECTARBPROC,                   glAttachObjectARB,                          ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLLINKPROGRAMARBPROC,                    glLinkProgramARB,                           ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLDETACHOBJECTARBPROC,                   glDetachObjectARB,                          ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLDELETEOBJECTARBPROC,                   glDeleteObjectARB,                          ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLVALIDATEPROGRAMARBPROC,                glValidateProgramARB,                       ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETATTACHEDOBJECTSARBPROC,             glGetAttachedObjectsARB,                    ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETHANDLEARBPROC,                      glGetHandleARB,                             ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETSHADERSOURCEARBPROC,                glGetShaderSourceARB,                       ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLBINDATTRIBLOCATIONARBPROC,             glBindAttribLocationARB,                    ARB_SHADER_OBJECTS,     NULL )\
+    USE_GL_FUNC(WINED3D_PFNGLGETATTRIBLOCATIONARBPROC,              glGetAttribLocationARB,                     ARB_SHADER_OBJECTS,     NULL )\
+    /* GL_EXT_stencil_two_side */ \
+    USE_GL_FUNC(PGLFNACTIVESTENCILFACEEXTPROC,                      glActiveStencilFaceEXT,                     EXT_STENCIL_TWO_SIDE,   NULL )\
+    /* GL_ATI_separate_stencil */ \
+    USE_GL_FUNC(PGLFNSTENCILOPSEPARATEATIPROC,                      glStencilOpSeparateATI,                     ATI_SEPARATE_STENCIL,   NULL )\
+    USE_GL_FUNC(PGLFNSTENCILFUNCSEPARATEATIPROC,                    glStencilFuncSeparateATI,                   ATI_SEPARATE_STENCIL,   NULL )\
+    /* GL_NV_half_float */ \
+    USE_GL_FUNC(PGLFNVERTEX2HNVPROC,                                glVertex2hNV,                               NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEX2HVNVPROC,                               glVertex2hvNV,                              NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEX3HNVPROC,                                glVertex3hNV,                               NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEX3HVNVPROC,                               glVertex3hvNV,                              NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEX4HNVPROC,                                glVertex4hNV,                               NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEX4HVNVPROC,                               glVertex4hvNV,                              NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNNORMAL3HNVPROC,                                glNormal3hNV,                               NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNNORMAL3HVNVPROC,                               glNormal3hvNV,                              NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNCOLOR3HNVPROC,                                 glColor3hNV,                                NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNCOLOR3HVNVPROC,                                glColor3hvNV,                               NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNCOLOR4HNVPROC,                                 glColor4hNV,                                NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNCOLOR4HVNVPROC,                                glColor4hvNV,                               NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD1HNVPROC,                              glTexCoord1hNV,                             NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD1HVNVPROC,                             glTexCoord1hvNV,                            NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD2HNVPROC,                              glTexCoord2hNV,                             NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD2HVNVPROC,                             glTexCoord2hvNV,                            NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD3HNVPROC,                              glTexCoord3hNV,                             NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD3HVNVPROC,                             glTexCoord3hvNV,                            NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD4HNVPROC,                              glTexCoord4hNV,                             NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNTEXCOORD4HVNVPROC,                             glTexCoord4hvNV,                            NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD1HNVPROC,                         glMultiTexCoord1hNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD1HVNVPROC,                        glMultiTexCoord1hvNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD2HNVPROC,                         glMultiTexCoord2hNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD2HVNVPROC,                        glMultiTexCoord2hvNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD3HNVPROC,                         glMultiTexCoord3hNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD3HVNVPROC,                        glMultiTexCoord3hvNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD4HNVPROC,                         glMultiTexCoord4hNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNMULTITEXCOORD4HVNVPROC,                        glMultiTexCoord4hvNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNFOGCOORDHNVPROC,                               glFogCoordhNV,                              NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNFOGCOORDHVNVPROC,                              glFogCoordhvNV,                             NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNSECONDARYCOLOR3HNVPROC,                        glSecondaryColor3hNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNSECONDARYCOLOR3HVNVPROC,                       glSecondaryColor3hvNV,                      NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXWEIGHTHNVPROC,                           glVertexWeighthNV,                          NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXWEIGHTHVNVPROC,                          glVertexWeighthvNV,                         NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1HNVPROC,                          glVertexAttrib1hNV,                         NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB1HVNVPROC,                         glVertexAttrib1hvNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2HNVPROC,                          glVertexAttrib2hNV,                         NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB2HVNVPROC,                         glVertexAttrib2hvNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3HNVPROC,                          glVertexAttrib3hNV,                         NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB3HVNVPROC,                         glVertexAttrib3hvNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4HNVPROC,                          glVertexAttrib4hNV,                         NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIB4HVNVPROC,                         glVertexAttrib4hvNV,                        NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS1HVNVPROC,                        glVertexAttribs1hvNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS2HVNVPROC,                        glVertexAttribs2hvNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS3HVNVPROC,                        glVertexAttribs3hvNV,                       NV_HALF_FLOAT,          NULL )\
+    USE_GL_FUNC(PGLFNVERTEXATTRIBS4HVNVPROC,                        glVertexAttribs4hvNV,                       NV_HALF_FLOAT,          NULL )\
+    /* GL_NV_register_combiners */ \
+    USE_GL_FUNC(PGLFNCOMBINERINPUTNVPROC,                           glCombinerInputNV,                          NV_REGISTER_COMBINERS,  NULL )\
+    USE_GL_FUNC(PGLFNCOMBINEROUTPUTNVPROC,                          glCombinerOutputNV,                         NV_REGISTER_COMBINERS,  NULL )\
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERFNVPROC,                      glCombinerParameterfNV,                     NV_REGISTER_COMBINERS,  NULL )\
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERFVNVPROC,                     glCombinerParameterfvNV,                    NV_REGISTER_COMBINERS,  NULL )\
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERINVPROC,                      glCombinerParameteriNV,                     NV_REGISTER_COMBINERS,  NULL )\
+    USE_GL_FUNC(PGLFNCOMBINERPARAMETERIVNVPROC,                     glCombinerParameterivNV,                    NV_REGISTER_COMBINERS,  NULL )\
+    USE_GL_FUNC(PGLFNFINALCOMBINERINPUTNVPROC,                      glFinalCombinerInputNV,                     NV_REGISTER_COMBINERS,  NULL )\
+    /* GL_NV_fence */ \
+    USE_GL_FUNC(PGLFNGENFENCESNVPROC,                               glGenFencesNV,                              NV_FENCE,               NULL )\
+    USE_GL_FUNC(PGLFNDELETEFENCESNVPROC,                            glDeleteFencesNV,                           NV_FENCE,               NULL )\
+    USE_GL_FUNC(PGLFNSETFENCENVPROC,                                glSetFenceNV,                               NV_FENCE,               NULL )\
+    USE_GL_FUNC(PGLFNTESTFENCENVPROC,                               glTestFenceNV,                              NV_FENCE,               NULL )\
+    USE_GL_FUNC(PGLFNFINISHFENCENVPROC,                             glFinishFenceNV,                            NV_FENCE,               NULL )\
+    USE_GL_FUNC(PGLFNISFENCENVPROC,                                 glIsFenceNV,                                NV_FENCE,               NULL )\
+    USE_GL_FUNC(PGLFNGETFENCEIVNVPROC,                              glGetFenceivNV,                             NV_FENCE,               NULL )\
+    /* GL_APPLE_fence */ \
+    USE_GL_FUNC(PGLFNGENFENCESAPPLEPROC,                            glGenFencesAPPLE,                           APPLE_FENCE,            NULL )\
+    USE_GL_FUNC(PGLFNDELETEFENCESAPPLEPROC,                         glDeleteFencesAPPLE,                        APPLE_FENCE,            NULL )\
+    USE_GL_FUNC(PGLFNSETFENCEAPPLEPROC,                             glSetFenceAPPLE,                            APPLE_FENCE,            NULL )\
+    USE_GL_FUNC(PGLFNTESTFENCEAPPLEPROC,                            glTestFenceAPPLE,                           APPLE_FENCE,            NULL )\
+    USE_GL_FUNC(PGLFNFINISHFENCEAPPLEPROC,                          glFinishFenceAPPLE,                         APPLE_FENCE,            NULL )\
+    USE_GL_FUNC(PGLFNISFENCEAPPLEPROC,                              glIsFenceAPPLE,                             APPLE_FENCE,            NULL )\
+    USE_GL_FUNC(PGLFNTESTOBJECTAPPLEPROC,                           glTestObjectAPPLE,                          APPLE_FENCE,            NULL )\
+    USE_GL_FUNC(PGLFNFINISHOBJECTAPPLEPROC,                         glFinishObjectAPPLE,                        APPLE_FENCE,            NULL )\
+    /* GLX_SGI_video_sync */ \
+    USE_GL_FUNC(PGLXFNGETVIDEOSYNCSGIPROC,                          glXGetVideoSyncSGI,                         SGI_VIDEO_SYNC,         NULL )\
+    USE_GL_FUNC(PGLXFNWAITVIDEOSYNCSGIPROC,                         glXWaitVideoSyncSGI,                        SGI_VIDEO_SYNC,         NULL )\
+    /* GL_APPLE_flush_render */ \
+    USE_GL_FUNC(PGLFNFLUSHRENDERAPPLEPROC,                          glFlushRenderApple,                         APPLE_FLUSH_RENDER,     NULL )\
+    USE_GL_FUNC(PGLFNFINISHRENDERAPPLEPROC,                         glFinishRenderApple,                        APPLE_FLUSH_RENDER,     NULL )\
+    /* GL_EXT_gpu_program_parameters */ \
+    USE_GL_FUNC(PGLFNPROGRAMENVPARAMETERS4FVEXTPROC,                glProgramEnvParameters4fvEXT,            EXT_GPU_PROGRAM_PARAMETERS,NULL )\
+    USE_GL_FUNC(PGLFNPROGRAMLOCALPARAMETERS4FVEXTPROC,              glProgramLocalParameters4fvEXT,          EXT_GPU_PROGRAM_PARAMETERS,NULL )\
+    /* GL_ATI_fragment_shader */ \
+    USE_GL_FUNC(PGLFNGENFRAGMENTSHADERSATI,                         glGenFragmentShadersATI,                    ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNBINDFRAGMENTSHADERATI,                         glBindFragmentShaderATI,                    ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNDELETEFRAGMENTSHADERATI,                       glDeleteFragmentShaderATI,                  ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNBEGINFRAGMENTSHADERATI,                        glBeginFragmentShaderATI,                   ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNENDFRAGMENTSHADERATI,                          glEndFragmentShaderATI,                     ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNPASSTEXCOORDATI,                               glPassTexCoordATI,                          ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNSAMPLEMAPATI,                                  glSampleMapATI,                             ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP1ATI,                           glColorFragmentOp1ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP2ATI,                           glColorFragmentOp2ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNCOLORFRAGMENTOP3ATI,                           glColorFragmentOp3ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP1ATI,                           glAlphaFragmentOp1ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP2ATI,                           glAlphaFragmentOp2ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNALPHAFRAGMENTOP3ATI,                           glAlphaFragmentOp3ATI,                      ATI_FRAGMENT_SHADER,    NULL )\
+    USE_GL_FUNC(PGLFNSETFRAGMENTSHADERCONSTANTATI,                  glSetFragmentShaderConstantATI,             ATI_FRAGMENT_SHADER,    NULL )
+
+/****************************************************
+ * OpenGL WGL defines and functions pointer
+ ****************************************************/
+
+/* WGL_ARB_extensions_string */
+typedef const char * (WINAPI * WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
+/* WGL_ARB_multisample */
+#ifndef WGL_ARB_multisample
+#define WGL_SAMPLE_BUFFERS_ARB         0x2041
+#define WGL_SAMPLES_ARB                0x2042
+#endif
+/* WGL_ARB_pixel_format */
+#ifndef WGL_ARB_pixel_format
+#define WGL_ARB_pixel_format 1
+#define WGL_NUMBER_PIXEL_FORMATS_ARB   0x2000
+#define WGL_DRAW_TO_WINDOW_ARB         0x2001
+#define WGL_DRAW_TO_BITMAP_ARB         0x2002
+#define WGL_ACCELERATION_ARB           0x2003
+#define WGL_NEED_PALETTE_ARB           0x2004
+#define WGL_NEED_SYSTEM_PALETTE_ARB    0x2005
+#define WGL_SWAP_LAYER_BUFFERS_ARB     0x2006
+#define WGL_SWAP_METHOD_ARB            0x2007
+#define WGL_NUMBER_OVERLAYS_ARB        0x2008
+#define WGL_NUMBER_UNDERLAYS_ARB       0x2009
+#define WGL_TRANSPARENT_ARB            0x200A
+#define WGL_TRANSPARENT_RED_VALUE_ARB  0x2037
+#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
+#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
+#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
+#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
+#define WGL_SHARE_DEPTH_ARB            0x200C
+#define WGL_SHARE_STENCIL_ARB          0x200D
+#define WGL_SHARE_ACCUM_ARB            0x200E
+#define WGL_SUPPORT_GDI_ARB            0x200F
+#define WGL_SUPPORT_OPENGL_ARB         0x2010
+#define WGL_DOUBLE_BUFFER_ARB          0x2011
+#define WGL_STEREO_ARB                 0x2012
+#define WGL_PIXEL_TYPE_ARB             0x2013
+#define WGL_COLOR_BITS_ARB             0x2014
+#define WGL_RED_BITS_ARB               0x2015
+#define WGL_RED_SHIFT_ARB              0x2016
+#define WGL_GREEN_BITS_ARB             0x2017
+#define WGL_GREEN_SHIFT_ARB            0x2018
+#define WGL_BLUE_BITS_ARB              0x2019
+#define WGL_BLUE_SHIFT_ARB             0x201A
+#define WGL_ALPHA_BITS_ARB             0x201B
+#define WGL_ALPHA_SHIFT_ARB            0x201C
+#define WGL_ACCUM_BITS_ARB             0x201D
+#define WGL_ACCUM_RED_BITS_ARB         0x201E
+#define WGL_ACCUM_GREEN_BITS_ARB       0x201F
+#define WGL_ACCUM_BLUE_BITS_ARB        0x2020
+#define WGL_ACCUM_ALPHA_BITS_ARB       0x2021
+#define WGL_DEPTH_BITS_ARB             0x2022
+#define WGL_STENCIL_BITS_ARB           0x2023
+#define WGL_AUX_BUFFERS_ARB            0x2024
+#define WGL_NO_ACCELERATION_ARB        0x2025
+#define WGL_GENERIC_ACCELERATION_ARB   0x2026
+#define WGL_FULL_ACCELERATION_ARB      0x2027
+#define WGL_SWAP_EXCHANGE_ARB          0x2028
+#define WGL_SWAP_COPY_ARB              0x2029
+#define WGL_SWAP_UNDEFINED_ARB         0x202A
+#define WGL_TYPE_RGBA_ARB              0x202B
+#define WGL_TYPE_COLORINDEX_ARB        0x202C
+#endif
+typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
+typedef BOOL (WINAPI * WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
+typedef BOOL (WINAPI * WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
+/* WGL_ARB_make_current_read */
+typedef BOOL (WINAPI * WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
+typedef HDC (WINAPI * WINED3D_PFNWGLGETCURRENTREADDCARBPROC) (void);
+/* WGL_ARB_pbuffer */
+#ifndef WGL_ARB_pbuffer
+#define WGL_ARB_pbuffer 1
+#define WGL_DRAW_TO_PBUFFER_ARB        0x202D
+#define WGL_MAX_PBUFFER_PIXELS_ARB     0x202E
+#define WGL_MAX_PBUFFER_WIDTH_ARB      0x202F
+#define WGL_MAX_PBUFFER_HEIGHT_ARB     0x2030
+#define WGL_PBUFFER_LARGEST_ARB        0x2033
+#define WGL_PBUFFER_WIDTH_ARB          0x2034
+#define WGL_PBUFFER_HEIGHT_ARB         0x2035
+#define WGL_PBUFFER_LOST_ARB           0x2036
+#endif
+DECLARE_HANDLE(HPBUFFERARB);
+typedef HPBUFFERARB (WINAPI * WINED3D_PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
+typedef HDC (WINAPI * WINED3D_PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
+typedef int (WINAPI * WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
+typedef BOOL (WINAPI * WINED3D_PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
+typedef BOOL (WINAPI * WINED3D_PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
+#ifndef WGL_ARB_pixel_format_float
+#define WGL_ARB_pixel_format_float 1
+#define WGL_TYPE_RGBA_FLOAT_ARB        0x21A0
+#endif
+/* WGL_WINE_pixel_format_passthrough */
+typedef BOOL (WINAPI * WINED3D_PFNWGLSETPIXELFORMATWINE) (HDC hdc, int iPixelFormat, const PIXELFORMATDESCRIPTOR* ppfd);
+
+#define WGL_EXT_FUNCS_GEN \
+    USE_GL_FUNC(WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC, wglGetExtensionsStringARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLMAKECONTEXTCURRENTARBPROC, wglMakeContextCurrentARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLGETCURRENTREADDCARBPROC, wglGetCurrentReadDCARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB, 0, NULL) \
+    USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL)
+
+
+/****************************************************
+ * Structures
+ ****************************************************/
+
+typedef struct _WINED3DGLTYPE {
+    int         d3dType;
+    GLint       size;
+    GLenum      glType;
+    GLboolean   normalized;
+    int         typesize;
+} WINED3DGLTYPE;
+
+#define USE_GL_FUNC(type, pfn, ext, replace) type pfn;
+typedef struct _WineD3D_GL_Info {
+
+  DWORD  glx_version;
+  DWORD  gl_version;
+
+  GL_Vendors gl_vendor;
+  GL_Cards   gl_card;
+  UINT   vidmem;
+  DWORD  driver_version;
+  DWORD  driver_version_hipart;
+  CHAR   gl_renderer[255];
+  /**
+   * CAPS Constants
+   */
+  UINT   max_buffers;
+  UINT   max_lights;
+  UINT   max_textures;
+  UINT   max_texture_stages;
+  UINT   max_fragment_samplers;
+  UINT   max_vertex_samplers;
+  UINT   max_combined_samplers;
+  UINT   max_sampler_stages;
+  UINT   max_clipplanes;
+  UINT   max_texture_size;
+  UINT   max_texture3d_size;
+  float  max_pointsize, max_pointsizemin;
+  UINT   max_blends;
+  UINT   max_anisotropy;
+  UINT   max_glsl_varyings;
+  float  max_shininess;
+
+  unsigned max_vshader_constantsF;
+  unsigned max_pshader_constantsF;
+
+  unsigned vs_arb_constantsF;
+  unsigned vs_arb_max_instructions;
+  unsigned vs_arb_max_temps;
+  unsigned ps_arb_constantsF;
+  unsigned ps_arb_max_instructions;
+  unsigned ps_arb_max_temps;
+  unsigned vs_glsl_constantsF;
+  unsigned ps_glsl_constantsF;
+
+  GL_PSVersion ps_arb_version;
+  GL_PSVersion ps_nv_version;
+
+  GL_VSVersion vs_arb_version;
+  GL_VSVersion vs_nv_version;
+  GL_VSVersion vs_ati_version;
+
+  BOOL arb_vs_offset_limit;
+  BOOL set_texcoord_w;
+
+  BOOL supported[OPENGL_SUPPORTED_EXT_END + 1];
+
+  /** OpenGL EXT and ARB functions ptr */
+  GL_EXT_FUNCS_GEN
+  /** OpenGL WGL functions ptr */
+  WGL_EXT_FUNCS_GEN
+
+  struct GlPixelFormatDesc *gl_formats;
+
+  /* Vertex data types */
+  WINED3DGLTYPE glTypeLookup[WINED3DDECLTYPE_UNUSED];
+} WineD3D_GL_Info;
+#undef USE_GL_FUNC
+
+#endif /* __WINE_WINED3D_GL */
index fa1d028..ee8f07f 100644 (file)
@@ -43,6 +43,8 @@ wined3d_settings_t wined3d_settings =
     TRUE,           /* Use of GLSL enabled by default */
     ORM_BACKBUFFER, /* Use the backbuffer to do offscreen rendering */
     RTL_AUTO,       /* Automatically determine best locking method */
+    PCI_VENDOR_NONE,/* PCI Vendor ID */
+    PCI_DEVICE_NONE,/* PCI Device ID */
     0,              /* The default of memory is set in FillGLCaps */
     NULL,           /* No wine logo by default */
     FALSE           /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */
@@ -77,6 +79,15 @@ static inline DWORD get_config_key(HKEY defkey, HKEY appkey, const char* name, c
     return ERROR_FILE_NOT_FOUND;
 }
 
+static inline DWORD get_config_key_dword(HKEY defkey, HKEY appkey, const char* name, DWORD *data)
+{
+    DWORD type;
+    DWORD size = sizeof(DWORD);
+    if (0 != appkey && !RegQueryValueExA( appkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0;
+    if (0 != defkey && !RegQueryValueExA( defkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0;
+    return ERROR_FILE_NOT_FOUND;
+}
+
 static void wined3d_do_nothing(void)
 {
 }
@@ -92,7 +103,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
        DWORD size = sizeof(buffer);
        HKEY hkey = 0;
        HKEY appkey = 0;
-       DWORD len;
+       DWORD len, tmpvalue;
        WNDCLASSA wc;
 
        /* We need our own window class for a fake window which we use to retrieve GL capabilities */
@@ -238,6 +249,36 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
                     wined3d_settings.rendertargetlock_mode = RTL_TEXTEX;
                 }
             }
+            if ( !get_config_key_dword( hkey, appkey, "VideoPciDeviceID", &tmpvalue) )
+            {
+                int pci_device_id = tmpvalue;
+
+                /* A pci device id is 16-bit */
+                if(pci_device_id > 0xffff)
+                {
+                    ERR("Invalid value for VideoPciDeviceID. The value should be smaller or equal to 65535 or 0xffff\n");
+                }
+                else
+                {
+                    TRACE("Using PCI Device ID %04x\n", pci_device_id);
+                    wined3d_settings.pci_device_id = pci_device_id;
+                }
+            }
+            if ( !get_config_key_dword( hkey, appkey, "VideoPciVendorID", &tmpvalue) )
+            {
+                int pci_vendor_id = tmpvalue;
+
+                /* A pci device id is 16-bit */
+                if(pci_vendor_id > 0xffff)
+                {
+                    ERR("Invalid value for VideoPciVendorID. The value should be smaller or equal to 65535 or 0xffff\n");
+                }
+                else
+                {
+                    TRACE("Using PCI Vendor ID %04x\n", pci_vendor_id);
+                    wined3d_settings.pci_vendor_id = pci_vendor_id;
+                }
+            }
             if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) )
             {
                 int TmpVideoMemorySize = atoi(buffer);
index 100b324..038c760 100644 (file)
 #include "wine/debug.h"
 #include "wine/unicode.h"
 
+#include "objbase.h"
 #include "wined3d_private_types.h"
-#include "wine/wined3d_interface.h"
-#include "wine/wined3d_caps.h"
+#include "wined3d.h"
 #include "wined3d_gl.h"
 #include "wine/list.h"
 
+/* Texture format fixups */
+
+enum fixup_channel_source
+{
+    CHANNEL_SOURCE_ZERO = 0,
+    CHANNEL_SOURCE_ONE = 1,
+    CHANNEL_SOURCE_X = 2,
+    CHANNEL_SOURCE_Y = 3,
+    CHANNEL_SOURCE_Z = 4,
+    CHANNEL_SOURCE_W = 5,
+    CHANNEL_SOURCE_YUV0 = 6,
+    CHANNEL_SOURCE_YUV1 = 7,
+};
+
+enum yuv_fixup
+{
+    YUV_FIXUP_YUY2 = 0,
+    YUV_FIXUP_UYVY = 1,
+    YUV_FIXUP_YV12 = 2,
+};
+
+#include <pshpack2.h>
+struct color_fixup_desc
+{
+    unsigned x_sign_fixup : 1;
+    unsigned x_source : 3;
+    unsigned y_sign_fixup : 1;
+    unsigned y_source : 3;
+    unsigned z_sign_fixup : 1;
+    unsigned z_source : 3;
+    unsigned w_sign_fixup : 1;
+    unsigned w_source : 3;
+};
+#include <poppack.h>
+
+static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
+        {0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
+
+static inline struct color_fixup_desc create_color_fixup_desc(
+        int sign0, enum fixup_channel_source src0, int sign1, enum fixup_channel_source src1,
+        int sign2, enum fixup_channel_source src2, int sign3, enum fixup_channel_source src3)
+{
+    struct color_fixup_desc fixup =
+    {
+        sign0, src0,
+        sign1, src1,
+        sign2, src2,
+        sign3, src3,
+    };
+    return fixup;
+}
+
+static inline struct color_fixup_desc create_yuv_fixup_desc(enum yuv_fixup yuv_fixup)
+{
+    struct color_fixup_desc fixup =
+    {
+        0, yuv_fixup & (1 << 0) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
+        0, yuv_fixup & (1 << 1) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
+        0, yuv_fixup & (1 << 2) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
+        0, yuv_fixup & (1 << 3) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
+    };
+    return fixup;
+}
+
+static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
+{
+    return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
+}
+
+static inline BOOL is_yuv_fixup(struct color_fixup_desc fixup)
+{
+    return fixup.x_source == CHANNEL_SOURCE_YUV0 || fixup.x_source == CHANNEL_SOURCE_YUV1;
+}
+
+static inline enum yuv_fixup get_yuv_fixup(struct color_fixup_desc fixup)
+{
+    enum yuv_fixup yuv_fixup = 0;
+    if (fixup.x_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 0);
+    if (fixup.y_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 1);
+    if (fixup.z_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 2);
+    if (fixup.w_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 3);
+    return yuv_fixup;
+}
+
 /* Hash table functions */
-typedef unsigned int (hash_function_t)(void *key);
-typedef BOOL (compare_function_t)(void *keya, void *keyb);
+typedef unsigned int (hash_function_t)(const void *key);
+typedef BOOL (compare_function_t)(const void *keya, const void *keyb);
 
 #define  ceilf(x) (float)ceil((double)x)
 
@@ -71,7 +155,7 @@ struct hash_table_t {
 
 struct hash_table_t *hash_table_create(hash_function_t *hash_function, compare_function_t *compare_function);
 void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *value, void *cb), void *cb);
-void *hash_table_get(struct hash_table_t *table, void *key);
+void *hash_table_get(const struct hash_table_t *table, const void *key);
 void hash_table_put(struct hash_table_t *table, void *key, void *value);
 void hash_table_remove(struct hash_table_t *table, void *key);
 
@@ -109,17 +193,22 @@ typedef enum _WINELOOKUP {
     MAX_LOOKUPS          = 1
 } WINELOOKUP;
 
-extern int minLookup[MAX_LOOKUPS];
-extern int maxLookup[MAX_LOOKUPS];
+extern const int minLookup[MAX_LOOKUPS];
+extern const int maxLookup[MAX_LOOKUPS];
 extern DWORD *stateLookup[MAX_LOOKUPS];
 
-typedef DWORD magLookup_t[WINED3DTEXF_ANISOTROPIC + 1];
-extern magLookup_t magLookup;
-extern magLookup_t magLookup_noFilter;
+struct min_lookup
+{
+    GLenum mip[WINED3DTEXF_LINEAR + 1];
+};
+
+struct min_lookup minMipLookup[WINED3DTEXF_ANISOTROPIC + 1];
+const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1];
+GLenum magLookup[WINED3DTEXF_ANISOTROPIC + 1];
+const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1];
 
-typedef DWORD minMipLookup_t[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
-extern minMipLookup_t minMipLookup;
-extern minMipLookup_t minMipLookup_noFilter;
+extern const struct filter_lookup filter_lookup_nofilter;
+extern struct filter_lookup filter_lookup;
 
 void init_type_lookup(WineD3D_GL_Info *gl_info);
 #define WINED3D_ATR_TYPE(type)          GLINFO_LOCATION.glTypeLookup[type].d3dType
@@ -187,6 +276,9 @@ static inline float float_16_to_32(const unsigned short *in) {
 #define RTL_TEXDRAW    3
 #define RTL_TEXTEX     4
 
+#define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
+#define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
+
 /* NOTE: When adding fields to this structure, make sure to update the default
  * values in wined3d_main.c as well. */
 typedef struct wined3d_settings_s {
@@ -200,6 +292,8 @@ typedef struct wined3d_settings_s {
   BOOL glslRequested;
   int offscreen_rendering_mode;
   int rendertargetlock_mode;
+  unsigned short pci_vendor_id;
+  unsigned short pci_device_id;
 /* Memory tracking and object counting */
   unsigned int emulated_textureram;
   char *logo;
@@ -307,7 +401,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
     WINED3DSIH_TABLE_SIZE
 };
 
-typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
+typedef void (*SHADER_HANDLER)(const struct SHADER_OPCODE_ARG *);
 
 struct shader_caps {
     DWORD               VertexShaderVersion;
@@ -342,15 +436,15 @@ typedef struct {
     void (*shader_deselect_depth_blt)(IWineD3DDevice *iface);
     void (*shader_load_constants)(IWineD3DDevice *iface, char usePS, char useVS);
     void (*shader_cleanup)(IWineD3DDevice *iface);
-    void (*shader_color_correction)(struct SHADER_OPCODE_ARG *arg);
+    void (*shader_color_correction)(const struct SHADER_OPCODE_ARG *arg, struct color_fixup_desc fixup);
     void (*shader_destroy)(IWineD3DBaseShader *iface);
     HRESULT (*shader_alloc_private)(IWineD3DDevice *iface);
     void (*shader_free_private)(IWineD3DDevice *iface);
     BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface);
-    void (*shader_generate_pshader)(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer);
+    GLuint (*shader_generate_pshader)(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer);
     void (*shader_generate_vshader)(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer);
-    void (*shader_get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *caps);
-    BOOL (*shader_conv_supported)(WINED3DFORMAT conv);
+    void (*shader_get_caps)(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *caps);
+    BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
 } shader_backend_t;
 
 extern const shader_backend_t glsl_shader_backend;
@@ -394,11 +488,12 @@ extern int num_lock;
 #define D3DCOLOR_B(dw) (((float) (((dw) >>  0) & 0xFF)) / 255.0f)
 #define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
 
-#define D3DCOLORTOGLFLOAT4(dw, vec) \
+#define D3DCOLORTOGLFLOAT4(dw, vec) do { \
   (vec)[0] = D3DCOLOR_R(dw); \
   (vec)[1] = D3DCOLOR_G(dw); \
   (vec)[2] = D3DCOLOR_B(dw); \
-  (vec)[3] = D3DCOLOR_A(dw);
+  (vec)[3] = D3DCOLOR_A(dw); \
+} while(0)
 
 /* DirectX Device Limits */
 /* --------------------- */
@@ -412,8 +507,9 @@ extern int num_lock;
 
 /* Checking of API calls */
 /* --------------------- */
+#ifndef WINE_NO_DEBUG_MSGS
 #define checkGLcall(A)                                          \
-{                                                               \
+do {                                                            \
     GLint err = glGetError();                                   \
     if (err == GL_NO_ERROR) {                                   \
        TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__);    \
@@ -423,7 +519,10 @@ extern int num_lock;
             debug_glerror(err), err, A, __FILE__, __LINE__);    \
        err = glGetError();                                      \
     } while (err != GL_NO_ERROR);                               \
-} 
+} while(0)
+#else
+#define checkGLcall(A) do {} while(0)
+#endif
 
 /* Trace routines / diagnostics */
 /* ---------------------------- */
@@ -440,13 +539,13 @@ do {
 
 /* Macro to dump out the current state of the light chain */
 #define DUMP_LIGHT_CHAIN()                    \
-{                                             \
+do {                                          \
   PLIGHTINFOEL *el = This->stateBlock->lights;\
   while (el) {                                \
     TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
     el = el->next;                            \
   }                                           \
-}
+} while(0)
 
 /* Trace vector and strided data information */
 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
@@ -479,21 +578,6 @@ extern const float identity[16];
 # define VTRACE(A) 
 #endif
 
-/* Checking of per-vertex related GL calls */
-/* --------------------- */
-#define vcheckGLcall(A)                                         \
-{                                                               \
-    GLint err = glGetError();                                   \
-    if (err == GL_NO_ERROR) {                                   \
-       VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
-                                                                \
-    } else do {                                                 \
-        FIXME(">>>>>>>>>>>>>>>>> %s (%#x) from %s @ %s / %d\n", \
-            debug_glerror(err), err, A, __FILE__, __LINE__);    \
-       err = glGetError();                                      \
-    } while (err != GL_NO_ERROR);                               \
-}
-
 /* TODO: Confirm each of these works when wined3d move completed */
 #if 0 /* NOTE: Must be 0 in cvs */
   /* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
@@ -548,8 +632,8 @@ void primitiveDeclarationConvertToStridedData(
 
 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
 
-typedef void (WINE_GLAPI *glAttribFunc)(void *data);
-typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, void *data);
+typedef void (WINE_GLAPI *glAttribFunc)(const void *data);
+typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, const void *data);
 extern glAttribFunc position_funcs[WINED3DDECLTYPE_UNUSED];
 extern glAttribFunc diffuse_funcs[WINED3DDECLTYPE_UNUSED];
 extern glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED];
@@ -639,10 +723,10 @@ struct fragment_caps {
 
 struct fragment_pipeline {
     void (*enable_extension)(IWineD3DDevice *iface, BOOL enable);
-    void (*get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *caps);
+    void (*get_caps)(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *caps);
     HRESULT (*alloc_private)(IWineD3DDevice *iface);
     void (*free_private)(IWineD3DDevice *iface);
-    BOOL (*conv_supported)(WINED3DFORMAT conv);
+    BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
     const struct StateEntryTemplate *states;
     BOOL ffp_proj_control;
 };
@@ -656,12 +740,9 @@ extern const struct fragment_pipeline nvts_fragment_pipeline;
 extern const struct fragment_pipeline nvrc_fragment_pipeline;
 
 /* "Base" state table */
-void compile_state_table(struct StateEntry *StateTable,
-                         APPLYSTATEFUNC **dev_multistate_funcs,
-                         WineD3D_GL_Info *gl_info,
-                         const struct StateEntryTemplate *vertex,
-                         const struct fragment_pipeline *fragment,
-                         const struct StateEntryTemplate *misc);
+void compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
+        const WineD3D_GL_Info *gl_info, const struct StateEntryTemplate *vertex,
+        const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc);
 
 /* Shaders for color conversions in blits */
 struct blit_shader {
@@ -669,7 +750,7 @@ struct blit_shader {
     void (*free_private)(IWineD3DDevice *iface);
     HRESULT (*set_shader)(IWineD3DDevice *iface, WINED3DFORMAT fmt, GLenum textype, UINT width, UINT height);
     void (*unset_shader)(IWineD3DDevice *iface);
-    BOOL (*conv_supported)(WINED3DFORMAT conv);
+    BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
 };
 
 extern const struct blit_shader ffp_blit;
@@ -697,6 +778,7 @@ struct WineD3DContext {
     BOOL                    last_was_vshader;
     BOOL                    last_was_foggy_shader;
     BOOL                    namedArraysLoaded, numberedArraysLoaded;
+    DWORD                   numbered_array_mask;
     BOOL                    lastWasPow2Texture[MAX_TEXTURES];
     GLenum                  tracking_parm;     /* Which source is tracking current colour         */
     unsigned char           num_untracked_materials;
@@ -842,17 +924,24 @@ enum dst_arg
 /*****************************************************************************
  * Fixed function pipeline replacements
  */
+#define ARG_UNUSED          0x3f
 struct texture_stage_op
 {
-    unsigned                cop : 5, aop : 5;
-#define ARG_UNUSED          0x3f
-    unsigned                carg1 : 6, carg2 : 6, carg0 : 6;
+    unsigned                cop : 8;
+    unsigned                carg1 : 8;
+    unsigned                carg2 : 8;
+    unsigned                carg0 : 8;
+
+    unsigned                aop : 8;
+    unsigned                aarg1 : 8;
+    unsigned                aarg2 : 8;
+    unsigned                aarg0 : 8;
+
+    struct color_fixup_desc color_correction;
     unsigned                tex_type : 3;
-    unsigned                dst : 1;                        /* Total of 32 bits */
-    unsigned                aarg1 : 6, aarg2 : 6, aarg0 : 6;
+    unsigned                dst : 1;
     unsigned                projected : 2;
-    unsigned                padding : 12;                   /* Total of 64 bits */
-    WINED3DFORMAT           color_correction;
+    unsigned                padding : 10;
 };
 
 struct ffp_frag_settings {
@@ -873,10 +962,11 @@ struct ffp_frag_desc
 };
 
 void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings, BOOL ignore_textype);
-struct ffp_frag_desc *find_ffp_frag_shader(struct hash_table_t *fragment_shaders, struct ffp_frag_settings *settings);
+const struct ffp_frag_desc *find_ffp_frag_shader(const struct hash_table_t *fragment_shaders,
+        const struct ffp_frag_settings *settings);
 void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *desc);
-BOOL ffp_frag_program_key_compare(void *keya, void *keyb);
-unsigned int ffp_frag_program_key_hash(void *key);
+BOOL ffp_frag_program_key_compare(const void *keya, const void *keyb);
+unsigned int ffp_frag_program_key_hash(const void *key);
 
 /*****************************************************************************
  * IWineD3D implementation structure
@@ -1033,7 +1123,7 @@ struct IWineD3DDeviceImpl
 
     /* Stream source management */
     WineDirect3DVertexStridedData strided_streams;
-    WineDirect3DVertexStridedData *up_strided;
+    const WineDirect3DVertexStridedData *up_strided;
     BOOL                      useDrawStridedSlow;
     BOOL                      instancedDraw;
 
@@ -1072,7 +1162,6 @@ typedef struct PrivateData
 
     GUID tag;
     DWORD flags; /* DDSPD_* */
-    DWORD uniqueness_value;
 
     union
     {
@@ -1114,6 +1203,18 @@ typedef struct IWineD3DResourceImpl
     IWineD3DResourceClass   resource;
 } IWineD3DResourceImpl;
 
+void resource_cleanup(IWineD3DResource *iface);
+HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid);
+HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice **device);
+HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **parent);
+DWORD resource_get_priority(IWineD3DResource *iface);
+HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
+        void *data, DWORD *data_size);
+WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface);
+DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority);
+HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID guid,
+        const void *data, DWORD data_size, DWORD flags);
+
 /* Tests show that the start address of resources is 32 byte aligned */
 #define RESOURCE_ALIGNMENT 32
 
@@ -1213,20 +1314,20 @@ typedef enum winetexturestates {
  */
 typedef struct IWineD3DBaseTextureClass
 {
+    DWORD                   states[MAX_WINETEXTURESTATES];
     UINT                    levels;
     BOOL                    dirty;
     UINT                    textureName;
+    float                   pow2Matrix[16];
     UINT                    LOD;
     WINED3DTEXTUREFILTERTYPE filterType;
-    DWORD                   states[MAX_WINETEXTURESTATES];
     LONG                    bindCount;
     DWORD                   sampler;
     BOOL                    is_srgb;
     UINT                    srgb_mode_change_count;
-    WINED3DFORMAT           shader_conversion_group;
-    float                   pow2Matrix[16];
-    minMipLookup_t          *minMipLookup;
-    magLookup_t             *magLookup;
+    const struct min_lookup *minMipLookup;
+    const GLenum            *magLookup;
+    struct color_fixup_desc shader_color_fixup;
 } IWineD3DBaseTextureClass;
 
 typedef struct IWineD3DBaseTextureImpl
@@ -1238,6 +1339,21 @@ typedef struct IWineD3DBaseTextureImpl
 
 } IWineD3DBaseTextureImpl;
 
+void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
+        const DWORD texture_states[WINED3D_HIGHEST_TEXTURE_STATE + 1],
+        const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
+HRESULT basetexture_bind(IWineD3DBaseTexture *iface);
+void basetexture_cleanup(IWineD3DBaseTexture *iface);
+void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface);
+WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface);
+BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface);
+DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface);
+DWORD basetexture_get_lod(IWineD3DBaseTexture *iface);
+HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE filter_type);
+BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty);
+DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD new_lod);
+void basetexture_unload(IWineD3DBaseTexture *iface);
+
 /*****************************************************************************
  * IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
  */
@@ -1272,8 +1388,6 @@ typedef struct IWineD3DCubeTextureImpl
 
     /* IWineD3DCubeTexture */
     IWineD3DSurface          *surfaces[6][MAX_LEVELS];
-
-    UINT                      edgeLength;
 } IWineD3DCubeTextureImpl;
 
 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
@@ -1322,10 +1436,6 @@ typedef struct IWineD3DVolumeTextureImpl
 
     /* IWineD3DVolumeTexture */
     IWineD3DVolume           *volumes[MAX_LEVELS];
-
-    UINT                      width;
-    UINT                      height;
-    UINT                      depth;
 } IWineD3DVolumeTextureImpl;
 
 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
@@ -1468,24 +1578,26 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey);
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container);
 DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref);
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX);
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
+        IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
 HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface);
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter);
-HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans);
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
+        const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter);
+HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
+        IWineD3DSurface *Source, const RECT *rsrc, DWORD trans);
 HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
 void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface);
-
-const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
+const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface);
 
 void get_drawable_size_swapchain(IWineD3DSurfaceImpl *This, UINT *width, UINT *height);
 void get_drawable_size_backbuffer(IWineD3DSurfaceImpl *This, UINT *width, UINT *height);
@@ -1569,9 +1681,6 @@ typedef enum {
     CONVERT_Q8W8V8U8,
     CONVERT_V16U16,
     CONVERT_A4L4,
-    CONVERT_R32F,
-    CONVERT_R16F,
-    CONVERT_G16R16,
 } CONVERT_TYPES;
 
 HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode);
@@ -1634,12 +1743,12 @@ typedef struct SAVEDSTATES {
         BOOL                      clipplane[MAX_CLIPPLANES];
         BOOL                      vertexDecl;
         BOOL                      pixelShader;
-        BOOL                      pixelShaderConstantsB[MAX_CONST_B];
-        BOOL                      pixelShaderConstantsI[MAX_CONST_I];
+        WORD                      pixelShaderConstantsB;
+        WORD                      pixelShaderConstantsI;
         BOOL                     *pixelShaderConstantsF;
         BOOL                      vertexShader;
-        BOOL                      vertexShaderConstantsB[MAX_CONST_B];
-        BOOL                      vertexShaderConstantsI[MAX_CONST_I];
+        WORD                      vertexShaderConstantsB;
+        WORD                      vertexShaderConstantsI;
         BOOL                     *vertexShaderConstantsF;
         BOOL                      scissorRect;
 } SAVEDSTATES;
@@ -1767,11 +1876,6 @@ extern void stateblock_savedstates_set(
     SAVEDSTATES* states,
     BOOL value);
 
-extern void stateblock_savedstates_copy(
-    IWineD3DStateBlock* iface,
-    SAVEDSTATES* dest,
-    SAVEDSTATES* source);
-
 extern void stateblock_copy(
     IWineD3DStateBlock* destination,
     IWineD3DStateBlock* source);
@@ -1859,7 +1963,7 @@ typedef struct IWineD3DSwapChainImpl
 
 extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
 const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl;
-void x11_copy_to_screen(IWineD3DSwapChainImpl *This, LPRECT rc);
+void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc);
 
 HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, LPVOID *ppobj);
 ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface);
@@ -1901,6 +2005,9 @@ const char *debug_glerror(GLenum error);
 const char *debug_d3dbasis(WINED3DBASISTYPE basis);
 const char *debug_d3ddegree(WINED3DDEGREETYPE order);
 const char* debug_d3dtop(WINED3DTEXTUREOP d3dtop);
+const char *debug_fixup_channel_source(enum fixup_channel_source source);
+const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup);
+void dump_color_fixup_desc(struct color_fixup_desc fixup);
 
 /* Routines for GL <-> D3D values */
 GLenum StencilOp(DWORD op);
@@ -1933,56 +2040,9 @@ unsigned int count_bits(unsigned int mask);
  *
  * Note: Only require classes which are subclassed, ie resource, basetexture, 
  */
-    /*** IUnknown methods ***/
-    extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
-    extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
-    extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
-    /*** IWineD3DResource methods ***/
-    extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
-    extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
-    extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags);
-    extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID  refguid, void * pData, DWORD * pSizeOfData);
-    extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID  refguid);
-    extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD  PriorityNew);
-    extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
-    extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
-    extern void WINAPI IWineD3DResourceImpl_UnLoad(IWineD3DResource *iface);
-    extern WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
-    /*** class static members ***/
-    void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
-
-    /*** IUnknown methods ***/
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
-    extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
-    extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
-    /*** IWineD3DResource methods ***/
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid, CONST void * pData, DWORD  SizeOfData, DWORD  Flags);
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid, void * pData, DWORD * pSizeOfData);
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID  refguid);
-    extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD  PriorityNew);
-    extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
-    extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
-    extern void WINAPI IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface);
-    extern WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
-    /*** IWineD3DBaseTexture methods ***/
-    extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
-    extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
-    extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType);
-    extern WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
-    extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
-    extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
-    extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
-
-    extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
-    extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
-    extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
-    extern void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
-    /*** class static members ***/
-    void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
 
+    /* IWineD3DVertexBuffer */
+    extern const BYTE *IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
 
 /* TODO: Make this dynamic, based on shader limits ? */
 #define MAX_REG_ADDR 1
@@ -2060,7 +2120,7 @@ typedef struct SHADER_OPCODE {
 
 typedef struct SHADER_OPCODE_ARG {
     IWineD3DBaseShader* shader;
-    shader_reg_maps* reg_maps;
+    const shader_reg_maps *reg_maps;
     CONST SHADER_OPCODE* opcode;
     DWORD opcode_token;
     DWORD dst;
@@ -2104,9 +2164,7 @@ extern int shader_addline(
     SHADER_BUFFER* buffer,
     const char* fmt, ...) PRINTF_ATTR(2,3);
 
-extern const SHADER_OPCODE* shader_get_opcode(
-    IWineD3DBaseShader *iface, 
-    const DWORD code);
+const SHADER_OPCODE *shader_get_opcode(const SHADER_OPCODE *shader_ins, DWORD shader_version, DWORD code);
 
 /* Vertex shader utility functions */
 extern BOOL vshader_get_input(
@@ -2121,7 +2179,7 @@ extern BOOL vshader_input_is_color(
 extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object);
 
 /* GLSL helper functions */
-extern void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG *arg);
+extern void shader_glsl_add_instruction_modifiers(const SHADER_OPCODE_ARG *arg);
 
 /*****************************************************************************
  * IDirect3DBaseShader implementation structure
@@ -2135,7 +2193,6 @@ typedef struct IWineD3DBaseShaderClass
     CONST SHADER_OPCODE             *shader_ins;
     DWORD                          *function;
     UINT                            functionLength;
-    GLuint                          prgId;
     BOOL                            is_compiled;
     UINT                            cur_loop_depth, cur_loop_regno;
     BOOL                            load_local_constsF;
@@ -2152,12 +2209,6 @@ typedef struct IWineD3DBaseShaderClass
     struct list constantsI;
     shader_reg_maps reg_maps;
 
-    /* Pixel formats of sampled textures, for format conversion. This
-     * represents the formats found during compilation, it is not initialized
-     * on the first parser pass. It is needed to check if the shader
-     * needs recompilation to adjust the format conversion
-     */
-    WINED3DFORMAT       sampled_format[MAX_COMBINED_SAMPLERS];
     UINT                sampled_samplers[MAX_COMBINED_SAMPLERS];
     UINT                num_sampled_samplers;
 
@@ -2189,35 +2240,13 @@ extern HRESULT shader_get_registers_used(
     CONST DWORD* pToken,
     IWineD3DStateBlockImpl *stateBlock);
 
-extern void shader_generate_main(
-    IWineD3DBaseShader *iface,
-    SHADER_BUFFER* buffer,
-    shader_reg_maps* reg_maps,
-    CONST DWORD* pFunction);
-
-extern void shader_dump_ins_modifiers(
-    const DWORD output);
-
-extern void shader_dump_param(
-    IWineD3DBaseShader *iface,
-    const DWORD param,
-    const DWORD addr_token,
-    int input);
+extern void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
+        const shader_reg_maps *reg_maps, const DWORD *pFunction);
 
 extern void shader_trace_init(
     IWineD3DBaseShader *iface,
     const DWORD* pFunction);
 
-extern int shader_get_param(
-    IWineD3DBaseShader* iface,
-    const DWORD* pToken,
-    DWORD* param,
-    DWORD* addr_token);
-
-extern int shader_skip_unrecognized(
-    IWineD3DBaseShader* iface,
-    const DWORD* pToken);
-
 static inline int shader_get_regtype(const DWORD param) {
     return (((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT) |
             ((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2));
@@ -2227,8 +2256,6 @@ static inline int shader_get_writemask(const DWORD param) {
     return param & WINED3DSP_WRITEMASK_ALL;
 }
 
-extern unsigned int shader_get_float_offset(const DWORD reg);
-
 static inline BOOL shader_is_pshader_version(DWORD token) {
     return 0xFFFF0000 == (token & 0xFFFF0000);
 }
@@ -2302,6 +2329,9 @@ typedef struct IWineD3DVertexShaderImpl {
 
     DWORD                       usage;
 
+    /* The GL shader */
+    GLuint                          prgId;
+
     /* Vertex shader input and output semantics */
     semantic semantics_in [MAX_ATTRIBS];
     semantic semantics_out [MAX_REG_OUTPUT];
@@ -2317,6 +2347,7 @@ typedef struct IWineD3DVertexShaderImpl {
 } IWineD3DVertexShaderImpl;
 extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[];
 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
+HRESULT IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface);
 
 /*****************************************************************************
  * IDirect3DPixelShader implementation structure
@@ -2333,6 +2364,22 @@ struct stb_const_desc {
     UINT                    const_num;
 };
 
+/* Stateblock dependent parameters which have to be hardcoded
+ * into the shader code
+ */
+struct ps_compile_args {
+    struct color_fixup_desc     color_fixup[MAX_FRAGMENT_SAMPLERS];
+    BOOL                        srgb_correction;
+    enum vertexprocessing_mode  vp_mode;
+    /* Projected textures(ps 1.0-1.3) */
+    /* Texture types(2D, Cube, 3D) in ps 1.x */
+};
+
+struct ps_compiled_shader {
+    struct ps_compile_args      args;
+    GLuint                      prgId;
+};
+
 typedef struct IWineD3DPixelShaderImpl {
     /* IUnknown parts */
     const IWineD3DPixelShaderVtbl *lpVtbl;
@@ -2349,22 +2396,21 @@ typedef struct IWineD3DPixelShaderImpl {
     BOOL                  input_reg_used[MAX_REG_INPUT];
     int                         declared_in_count;
 
+    /* The GL shader */
+    struct ps_compiled_shader   *gl_shaders;
+    UINT                        num_gl_shaders;
+
     /* Some information about the shader behavior */
     struct stb_const_desc       bumpenvmatconst[MAX_TEXTURES];
     char                        numbumpenvmatconsts;
     struct stb_const_desc       luminanceconst[MAX_TEXTURES];
-    char                        srgb_enabled;
-    char                        srgb_mode_hardcoded;
-    UINT                        srgb_low_const;
-    UINT                        srgb_cmp_const;
     char                        vpos_uniform;
-    BOOL                        render_offscreen;
-    UINT                        height;
-    enum vertexprocessing_mode  vertexprocessing;
 } IWineD3DPixelShaderImpl;
 
 extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[];
 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
+GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args);
+void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args);
 
 /* sRGB correction constants */
 static const float srgb_cmp = 0.0031308;
@@ -2403,6 +2449,19 @@ extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
 /*****************************************************************************
  * Pixel format management
  */
+
+struct GlPixelFormatDesc
+{
+    GLint glInternal;
+    GLint glGammaInternal;
+    GLint rtInternal;
+    GLint glFormat;
+    GLint glType;
+    unsigned int Flags;
+    float heightscale;
+    struct color_fixup_desc color_fixup;
+};
+
 typedef struct {
     WINED3DFORMAT           format;
     DWORD                   alphaMask, redMask, greenMask, blueMask;
@@ -2412,8 +2471,7 @@ typedef struct {
 } StaticPixelFormatDesc;
 
 const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
-        WineD3D_GL_Info *gl_info,
-        const GlPixelFormatDesc **glDesc);
+        const WineD3D_GL_Info *gl_info, const struct GlPixelFormatDesc **glDesc);
 
 static inline BOOL use_vs(IWineD3DDeviceImpl *device) {
     return (device->vs_selected_mode != SHADER_NONE