VirtualBox

Ignore:
Timestamp:
Oct 6, 2009 6:07:06 AM (15 years ago)
Author:
vboxsync
Message:

crOpenGL: update to wine 1.1.30

Location:
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d
Files:
33 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/arb_program_shader.c

    r22496 r23571  
    101101/* ARB_program_shader private data */
    102102
    103 struct loop_control
    104 {
    105     unsigned int count;
    106     unsigned int start;
    107     int step;
    108 };
    109 
    110103struct control_frame
    111104{
     
    125118        unsigned int                ifc_no;
    126119    };
    127     struct loop_control            loop_control;
     120    struct wined3d_shader_loop_control loop_control;
    128121    BOOL                            had_else;
    129122};
     
    142135{
    143136    struct ps_compile_args          super;
    144     DWORD                           bools; /* WORD is enough, use DWORD for alignment */
     137    WORD                            bools;
     138    WORD                            clip;  /* only a boolean, use a WORD for alignment */
    145139    unsigned char                   loop_ctrl[MAX_CONST_I][3];
    146140};
     
    282276 ********************************************************/
    283277
    284 /**
    285  * Loads floating point constants into the currently set ARB_vertex/fragment_program.
     278/* Loads floating point constants into the currently set ARB_vertex/fragment_program.
    286279 * When constant_list == NULL, it will load all the constants.
    287  * 
     280 *
    288281 * @target_type should be either GL_VERTEX_PROGRAM_ARB (for vertex shaders)
    289282 *  or GL_FRAGMENT_PROGRAM_ARB (for pixel shaders)
     
    294287{
    295288    local_constant* lconst;
    296     DWORD i = 0, j;
     289    DWORD i, j;
    297290    unsigned int ret;
    298291
    299     if (TRACE_ON(d3d_shader)) {
     292    if (TRACE_ON(d3d_constants))
     293    {
    300294        for(i = 0; i < max_constants; i++) {
    301295            if(!dirty_consts[i]) continue;
     
    305299        }
    306300    }
     301
     302    i = 0;
     303
    307304    /* In 1.X pixel shaders constants are implicitly clamped in the range [-1;1] */
    308305    if (target_type == GL_FRAGMENT_PROGRAM_ARB && This->baseShader.reg_maps.shader_version.major == 1)
     
    546543/**
    547544 * Loads the app-supplied constants into the currently set ARB_[vertex/fragment]_programs.
    548  * 
    549  * We only support float constants in ARB at the moment, so don't 
     545 *
     546 * We only support float constants in ARB at the moment, so don't
    550547 * worry about the Integers or Booleans
    551548 */
     
    632629    unsigned max_constantsF;
    633630    const local_constant *lconst;
     631    DWORD map;
    634632
    635633    /* In pixel shaders, all private constants are program local, we don't need anything
     
    675673    }
    676674
    677     for(i = 0; i < This->baseShader.limits.temporary; i++) {
    678         if (reg_maps->temporary[i])
    679             shader_addline(buffer, "TEMP R%u;\n", i);
    680     }
    681 
    682     for (i = 0; i < This->baseShader.limits.address; i++) {
    683         if (reg_maps->address[i])
    684             shader_addline(buffer, "ADDRESS A%d;\n", i);
    685     }
    686 
    687     if(pshader && reg_maps->shader_version.major == 1 && reg_maps->shader_version.minor <= 3) {
    688         for(i = 0; i < This->baseShader.limits.texcoord; i++) {
    689             if (reg_maps->texcoord[i] && pshader)
    690                 shader_addline(buffer,"TEMP T%u;\n", i);
     675    for (i = 0, map = reg_maps->temporary; map; map >>= 1, ++i)
     676    {
     677        if (map & 1) shader_addline(buffer, "TEMP R%u;\n", i);
     678    }
     679
     680    for (i = 0, map = reg_maps->address; map; map >>= 1, ++i)
     681    {
     682        if (map & 1) shader_addline(buffer, "ADDRESS A%u;\n", i);
     683    }
     684
     685    if (pshader && reg_maps->shader_version.major == 1 && reg_maps->shader_version.minor <= 3)
     686    {
     687        for (i = 0, map = reg_maps->texcoord; map; map >>= 1, ++i)
     688        {
     689            if (map & 1) shader_addline(buffer, "TEMP T%u;\n", i);
    691690        }
    692691    }
     
    12621261    if (flags & TEX_DERIV)
    12631262    {
    1264         if(flags & TEX_PROJ) FIXME("Projected texture sampling with custom derivates\n");
    1265         if(flags & TEX_BIAS) FIXME("Biased texture sampling with custom derivates\n");
     1263        if(flags & TEX_PROJ) FIXME("Projected texture sampling with custom derivatives\n");
     1264        if(flags & TEX_BIAS) FIXME("Biased texture sampling with custom derivatives\n");
    12661265        shader_addline(buffer, "TXD%s %s, %s, %s, %s, texture[%u], %s;\n", mod, dst_str, coord_reg,
    12671266                       dsx, dsy,sampler_idx, tex_type);
     
    20382037    char dst_str[50];
    20392038    char src0_name[50];
    2040     char dst_reg[8];
     2039    char dst_reg[50];
    20412040    BOOL is_color;
    20422041
     
    20812080    char src0_name[50];
    20822081    char src1_name[50];
    2083     char dst_reg[8];
     2082    char dst_reg[50];
    20842083    BOOL is_color;
    20852084
     
    30103009{
    30113010    GLuint program_id = 0;
     3011    GLint pos;
     3012
    30123013    const char *blt_vprogram =
    30133014        "!!ARBvp1.0\n"
     
    30203021    GL_EXTCALL(glGenProgramsARB(1, &program_id));
    30213022    GL_EXTCALL(glBindProgramARB(GL_VERTEX_PROGRAM_ARB, program_id));
    3022     GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(blt_vprogram), blt_vprogram));
    3023 
    3024     if (glGetError() == GL_INVALID_OPERATION) {
    3025         GLint pos;
    3026         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     3023    GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
     3024            strlen(blt_vprogram), blt_vprogram));
     3025    checkGLcall("glProgramStringARB()");
     3026
     3027    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     3028    if (pos != -1)
     3029    {
    30273030        FIXME("Vertex program error at position %d: %s\n", pos,
    30283031            debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
    30293032    }
     3033    else
     3034    {
     3035        GLint native;
     3036
     3037        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &native));
     3038        checkGLcall("glGetProgramivARB()");
     3039        if (!native) WARN("Program exceeds native resource limits.\n");
     3040    }
    30303041
    30313042    return program_id;
     
    30363047{
    30373048    GLuint program_id = 0;
     3049    GLint pos;
     3050
    30383051    static const char * const blt_fprograms[tex_type_count] =
    30393052    {
     
    30703083    GL_EXTCALL(glGenProgramsARB(1, &program_id));
    30713084    GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, program_id));
    3072     GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(blt_fprograms[tex_type]), blt_fprograms[tex_type]));
    3073 
    3074     if (glGetError() == GL_INVALID_OPERATION) {
    3075         GLint pos;
    3076         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     3085    GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
     3086            strlen(blt_fprograms[tex_type]), blt_fprograms[tex_type]));
     3087    checkGLcall("glProgramStringARB()");
     3088
     3089    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     3090    if (pos != -1)
     3091    {
    30773092        FIXME("Fragment program error at position %d: %s\n", pos,
    30783093            debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
     3094    }
     3095    else
     3096    {
     3097        GLint native;
     3098
     3099        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &native));
     3100        checkGLcall("glGetProgramivARB()");
     3101        if (!native) WARN("Program exceeds native resource limits.\n");
    30793102    }
    30803103
     
    32293252    BOOL dcl_tmp = args->super.srgb_correction, dcl_td = FALSE;
    32303253    BOOL want_nv_prog = FALSE;
    3231     struct arb_pshader_private *shader_priv = This->backend_priv;
     3254    struct arb_pshader_private *shader_priv = This->baseShader.backend_data;
     3255    GLint errPos;
     3256    DWORD map;
    32323257
    32333258    char srgbtmp[4][4];
    32343259    unsigned int i, found = 0;
    32353260
    3236     for(i = 0; i < This->baseShader.limits.temporary; i++) {
    3237 
    3238         /* Don't overwrite the color source */
    3239         if(This->color0_mov && i == This->color0_reg) continue;
    3240         else if(reg_maps->shader_version.major < 2 && i == 0) continue;
    3241 
    3242         if(reg_maps->temporary[i]) {
    3243             sprintf(srgbtmp[found], "R%u", i);
    3244             found++;
    3245             if(found == 4) break;
    3246         }
     3261    for (i = 0, map = reg_maps->temporary; map; map >>= 1, ++i)
     3262    {
     3263        if (!(map & 1)
     3264                || (This->color0_mov && i == This->color0_reg)
     3265                || (reg_maps->shader_version.major < 2 && i == 0))
     3266            continue;
     3267
     3268        sprintf(srgbtmp[found], "R%u", i);
     3269        ++found;
     3270        if (found == 4) break;
    32473271    }
    32483272
     
    33753399            lconst_map, NULL, &priv_ctx);
    33763400
    3377     for(i = 0; i < (sizeof(reg_maps->bumpmat) / sizeof(reg_maps->bumpmat[0])); i++) {
    3378         if(!reg_maps->bumpmat[i]) continue;
     3401    for (i = 0, map = reg_maps->bumpmat; map; map >>= 1, ++i)
     3402    {
     3403        if (!(map & 1)) continue;
    33793404
    33803405        cur = compiled->numbumpenvmatconsts;
     
    33983423        compiled->numbumpenvmatconsts = cur + 1;
    33993424
    3400         if(!reg_maps->luminanceparams[i]) continue;
     3425        if (!(reg_maps->luminanceparams & (1 << i))) continue;
    34013426
    34023427        compiled->luminanceconst[cur].const_num = next_local++;
     
    34863511    }
    34873512
    3488     if(shader_priv->clipplane_emulation)
    3489     {
    3490         shader_addline(buffer, "KIL fragment.texcoord[%u];\n", shader_priv->clipplane_emulation - 1);
     3513    if (shader_priv->clipplane_emulation != ~0U && args->clip)
     3514    {
     3515        shader_addline(buffer, "KIL fragment.texcoord[%u];\n", shader_priv->clipplane_emulation);
    34913516    }
    34923517
     
    35123537    GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
    35133538               buffer->bsize, buffer->buffer));
    3514 
    3515     if (glGetError() == GL_INVALID_OPERATION) {
    3516         GLint errPos;
    3517         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
     3539    checkGLcall("glProgramStringARB()");
     3540
     3541    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
     3542    if (errPos != -1)
     3543    {
    35183544        FIXME("HW PixelShader Error at position %d: %s\n",
    35193545              errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
    35203546        retval = 0;
     3547    }
     3548    else
     3549    {
     3550        GLint native;
     3551
     3552        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &native));
     3553        checkGLcall("glGetProgramivARB()");
     3554        if (!native) WARN("Program exceeds native resource limits.\n");
    35213555    }
    35223556
     
    37963830    struct shader_arb_ctx_priv priv_ctx;
    37973831    unsigned int i;
     3832    GLint errPos;
    37983833
    37993834    memset(&priv_ctx, 0, sizeof(priv_ctx));
     
    39053940    GL_EXTCALL(glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
    39063941               buffer->bsize, buffer->buffer));
    3907 
    3908     if (glGetError() == GL_INVALID_OPERATION) {
    3909         GLint errPos;
    3910         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
     3942    checkGLcall("glProgramStringARB()");
     3943
     3944    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos);
     3945    if (errPos != -1)
     3946    {
    39113947        FIXME("HW VertexShader Error at position %d: %s\n",
    39123948              errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
    39133949        ret = -1;
    3914     } else {
     3950    }
     3951    else
     3952    {
     3953        GLint native;
     3954
     3955        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &native));
     3956        checkGLcall("glGetProgramivARB()");
     3957        if (!native) WARN("Program exceeds native resource limits.\n");
     3958
    39153959        /* Load immediate constants */
    39163960        if(lconst_map) {
     
    39243968
    39253969    return ret;
    3926 }
    3927 
    3928 static void find_clip_texcoord(IWineD3DPixelShaderImpl *ps)
    3929 {
    3930     struct arb_pshader_private *shader_priv = ps->backend_priv;
    3931     int i;
    3932     const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)ps->baseShader.device)->adapter->gl_info;
    3933 
    3934     /* See if we can use fragment.texcoord[7] for clipplane emulation
    3935      *
    3936      * Don't do this if it is not supported, or fragment.texcoord[7] is used
    3937      */
    3938     if(ps->baseShader.reg_maps.shader_version.major < 3)
    3939     {
    3940         for(i = GL_LIMITS(texture_stages); i > 0; i--)
    3941         {
    3942             if(!ps->baseShader.reg_maps.texcoord[i - 1])
    3943             {
    3944                 shader_priv->clipplane_emulation = i;
    3945                 return;
    3946             }
    3947         }
    3948         WARN("Did not find a free clip reg(2.0)\n");
    3949     }
    3950     else
    3951     {
    3952         for(i = GL_LIMITS(texture_stages); i > 0; i--)
    3953         {
    3954             if(!(ps->baseShader.reg_maps.input_registers & (1 << (i - 1))))
    3955             {
    3956                 shader_priv->clipplane_emulation = i;
    3957                 return;
    3958             }
    3959         }
    3960         WARN("Did not find a free clip reg(3.0)\n");
    3961     }
    39623970}
    39633971
     
    39723980    GLuint ret;
    39733981
    3974     if(!shader->backend_priv) {
     3982    if (!shader->baseShader.backend_data)
     3983    {
    39753984        IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) shader->baseShader.device;
     3985        const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    39763986        struct shader_arb_priv *priv = device->shader_priv;
    39773987
    3978         shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
    3979         shader_data = shader->backend_priv;
     3988        shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
     3989        shader_data = shader->baseShader.backend_data;
    39803990        shader_data->clamp_consts = shader->baseShader.reg_maps.shader_version.major == 1;
    39813991
     
    39863996        TRACE("Shader got assigned input signature index %u\n", shader_data->input_signature_idx);
    39873997
    3988         if(!device->vs_clipping) find_clip_texcoord(shader);
    3989     }
    3990     shader_data = shader->backend_priv;
     3998        if (!device->vs_clipping)
     3999            shader_data->clipplane_emulation = shader_find_free_input_register(&shader->baseShader.reg_maps,
     4000                    GL_LIMITS(texture_stages) - 1);
     4001        else
     4002            shader_data->clipplane_emulation = ~0U;
     4003    }
     4004    shader_data = shader->baseShader.backend_data;
    39914005
    39924006    /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
     
    40624076    const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)shader->baseShader.device)->adapter->gl_info;
    40634077
    4064     if(!shader->backend_priv) {
    4065         shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
    4066     }
    4067     shader_data = shader->backend_priv;
     4078    if (!shader->baseShader.backend_data)
     4079    {
     4080        shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
     4081    }
     4082    shader_data = shader->baseShader.backend_data;
    40684083
    40694084    /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
     
    41304145    }
    41314146
     4147    /* Only enable the clip plane emulation KIL if at least one clipplane is enabled. The KIL instruction
     4148     * is quite expensive because it forces the driver to disable early Z discards. It is cheaper to
     4149     * duplicate the shader than have a no-op KIL instruction in every shader
     4150     */
     4151    if((!((IWineD3DDeviceImpl *) shader->baseShader.device)->vs_clipping) && use_vs(stateblock) &&
     4152       stateblock->renderState[WINED3DRS_CLIPPING] && stateblock->renderState[WINED3DRS_CLIPPLANEENABLE])
     4153    {
     4154        args->clip = 1;
     4155    }
     4156    else
     4157    {
     4158        args->clip = 0;
     4159    }
     4160
    41324161    /* Skip if unused or local, or supported natively */
    41334162    int_skip = ~shader->baseShader.reg_maps.integer_constants | shader->baseShader.reg_maps.local_int_consts;
     
    41684197    {
    41694198        IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) stateblock->pixelShader;
    4170         struct arb_pshader_private *shader_priv = ps->backend_priv;
     4199        struct arb_pshader_private *shader_priv = ps->baseShader.backend_data;
    41714200        args->ps_signature = shader_priv->input_signature_idx;
    41724201
    4173         args->boolclip.clip_control[0] = shader_priv->clipplane_emulation;
     4202        args->boolclip.clip_control[0] = shader_priv->clipplane_emulation + 1;
    41744203    }
    41754204    else
     
    42644293         * a 1.x and newer shader, reload the first 8 constants
    42654294         */
    4266         if(priv->last_ps_const_clamped != ((struct arb_pshader_private *) ps->backend_priv)->clamp_consts)
    4267         {
    4268             priv->last_ps_const_clamped = ((struct arb_pshader_private *) ps->backend_priv)->clamp_consts;
     4295        if(priv->last_ps_const_clamped != ((struct arb_pshader_private *)ps->baseShader.backend_data)->clamp_consts)
     4296        {
     4297            priv->last_ps_const_clamped = ((struct arb_pshader_private *)ps->baseShader.backend_data)->clamp_consts;
    42694298            This->highest_dirty_ps_const = max(This->highest_dirty_ps_const, 8);
    42704299            for(i = 0; i < 8; i++)
     
    43824411    {
    43834412        IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface;
    4384         struct arb_pshader_private *shader_data = This->backend_priv;
     4413        struct arb_pshader_private *shader_data = This->baseShader.backend_data;
    43854414        UINT i;
    43864415
     
    43974426        HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
    43984427        HeapFree(GetProcessHeap(), 0, shader_data);
    4399         This->backend_priv = NULL;
     4428        This->baseShader.backend_data = NULL;
    44004429    } else {
    44014430        IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *) iface;
    4402         struct arb_vshader_private *shader_data = This->backend_priv;
     4431        struct arb_vshader_private *shader_data = This->baseShader.backend_data;
    44034432        UINT i;
    44044433
     
    44154444        HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
    44164445        HeapFree(GetProcessHeap(), 0, shader_data);
    4417         This->backend_priv = NULL;
     4446        This->baseShader.backend_data = NULL;
    44184447    }
    44194448}
     
    44254454}
    44264455
    4427 struct wine_rb_functions sig_tree_functions =
     4456static const struct wine_rb_functions sig_tree_functions =
    44284457{
    44294458    wined3d_rb_alloc,
     
    46964725
    46974726static void get_loop_control_const(const struct wined3d_shader_instruction *ins,
    4698         IWineD3DBaseShaderImpl *This, UINT idx, struct loop_control *loop_control)
     4727        IWineD3DBaseShaderImpl *This, UINT idx, struct wined3d_shader_loop_control *loop_control)
    46994728{
    47004729    struct shader_arb_ctx_priv *priv = ins->ctx->backend_data;
     
    52395268    if (use_ps(stateblock))
    52405269    {
    5241         if(stage != 0 &&
    5242            ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.bumpmat[stage]) {
     5270        if (stage != 0
     5271                && (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.bumpmat & (1 << stage)))
     5272        {
    52435273            /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
    52445274             * anyway
     
    52755305    if (use_ps(stateblock))
    52765306    {
    5277         if(stage != 0 &&
    5278            ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.luminanceparams[stage]) {
     5307        if (stage != 0
     5308                && (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.luminanceparams & (1 << stage)))
     5309        {
    52795310            /* The pixel shader has to know the luminance offset. Do a constants update if it
    52805311             * isn't scheduled anyway
     
    55305561    BOOL op_equal;
    55315562    const char *final_combiner_src = "ret";
     5563    GLint pos;
    55325564
    55335565    /* Find out which textures are read */
     
    57635795    GL_EXTCALL(glGenProgramsARB(1, &ret));
    57645796    GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, ret));
    5765     GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(buffer.buffer), buffer.buffer));
    5766 
    5767     if (glGetError() == GL_INVALID_OPERATION) {
    5768         GLint pos;
    5769         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     5797    GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
     5798            strlen(buffer.buffer), buffer.buffer));
     5799    checkGLcall("glProgramStringARB()");
     5800
     5801    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     5802    if (pos != -1)
     5803    {
    57705804        FIXME("Fragment program error at position %d: %s\n", pos,
    57715805              debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
    57725806    }
     5807    else
     5808    {
     5809        GLint native;
     5810
     5811        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &native));
     5812        checkGLcall("glGetProgramivARB()");
     5813        if (!native) WARN("Program exceeds native resource limits.\n");
     5814    }
     5815
    57735816    shader_buffer_free(&buffer);
    57745817    return ret;
     
    63496392    char luminance_component;
    63506393    struct arbfp_blit_priv *priv = device->blit_priv;
     6394    GLint pos;
    63516395
    63526396    /* Shader header */
     
    64516495
    64526496    ENTER_GL();
    6453     GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(buffer.buffer), buffer.buffer));
    6454 
    6455     if (glGetError() == GL_INVALID_OPERATION) {
    6456         GLint pos;
    6457         glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     6497    GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
     6498            strlen(buffer.buffer), buffer.buffer));
     6499    checkGLcall("glProgramStringARB()");
     6500
     6501    glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
     6502    if (pos != -1)
     6503    {
    64586504        FIXME("Fragment program error at position %d: %s\n", pos,
    64596505              debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)));
    64606506    }
     6507    else
     6508    {
     6509        GLint native;
     6510
     6511        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB, &native));
     6512        checkGLcall("glGetProgramivARB()");
     6513        if (!native) WARN("Program exceeds native resource limits.\n");
     6514    }
     6515
    64616516    shader_buffer_free(&buffer);
    64626517    LEAVE_GL();
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/baseshader.c

    r22496 r23571  
    217217}
    218218
    219 void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDevice *device)
     219void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
     220        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    220221{
    221222    shader->ref = 1;
    222     shader->device = device;
     223    shader->device = (IWineD3DDevice *)device;
     224    shader->parent = parent;
     225    shader->parent_ops = parent_ops;
    223226    list_init(&shader->linked_programs);
     227    list_add_head(&device->shaders, &shader->shader_list_entry);
    224228}
    225229
     
    268272    {
    269273        case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
    270             if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord[reg->idx] = 1;
    271             else reg_maps->address[reg->idx] = 1;
     274            if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx;
     275            else reg_maps->address |= 1 << reg->idx;
    272276            break;
    273277
    274278        case WINED3DSPR_TEMP:
    275             reg_maps->temporary[reg->idx] = 1;
     279            reg_maps->temporary |= 1 << reg->idx;
    276280            break;
    277281
     
    610614
    611615            fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
    612             reg_maps->labels[src.reg.idx] = 1;
     616            reg_maps->labels |= 1 << src.reg.idx;
    613617        }
    614618        /* Set texture, address, temporary registers */
     
    697701                            || ins.handler_idx == WINED3DSIH_TEXBEML)
    698702                    {
    699                         reg_maps->bumpmat[sampler_code] = TRUE;
     703                        reg_maps->bumpmat |= 1 << dst_param.reg.idx;
    700704                        if (ins.handler_idx == WINED3DSIH_TEXBEML)
    701705                        {
    702                             reg_maps->luminanceparams[sampler_code] = TRUE;
     706                            reg_maps->luminanceparams |= 1 << dst_param.reg.idx;
    703707                        }
    704708                    }
     
    706710                else if (ins.handler_idx == WINED3DSIH_BEM)
    707711                {
    708                     reg_maps->bumpmat[dst_param.reg.idx] = TRUE;
     712                    reg_maps->bumpmat |= 1 << dst_param.reg.idx;
    709713                }
    710714            }
     
    778782
    779783    return WINED3D_OK;
     784}
     785
     786unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max)
     787{
     788    DWORD map = 1 << max;
     789    map |= map - 1;
     790    map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
     791
     792    return wined3d_log2i(map);
    780793}
    781794
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/basetexture.c

    r22496 r23571  
    66 * Copyright 2005 Oliver Stieber
    77 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     8 * Copyright 2009 Henri Verbeet for CodeWeavers
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    3940HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
    4041        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
    41         WINED3DPOOL pool, IUnknown *parent)
     42        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    4243{
    4344    HRESULT hr;
    4445
    45     hr = resource_init((IWineD3DResource *)texture, resource_type, device, size, usage, format_desc, pool, parent);
     46    hr = resource_init((IWineD3DResource *)texture, resource_type, device,
     47            size, usage, format_desc, pool, parent, parent_ops);
    4648    if (FAILED(hr))
    4749    {
     
    5355    texture->baseTexture.filterType = (usage & WINED3DUSAGE_AUTOGENMIPMAP) ? WINED3DTEXF_LINEAR : WINED3DTEXF_NONE;
    5456    texture->baseTexture.LOD = 0;
    55     texture->baseTexture.dirty = TRUE;
    56     texture->baseTexture.srgbDirty = TRUE;
     57    texture->baseTexture.texture_rgb.dirty = TRUE;
     58    texture->baseTexture.texture_srgb.dirty = TRUE;
    5759    texture->baseTexture.is_srgb = FALSE;
    5860    texture->baseTexture.pow2Matrix_identity = TRUE;
     
    7880}
    7981
     82/* A GL context is provided by the caller */
     83static void gltexture_delete(struct gl_texture *tex)
     84{
     85    ENTER_GL();
     86    glDeleteTextures(1, &tex->name);
     87    LEAVE_GL();
     88    tex->name = 0;
     89}
     90
    8091void basetexture_unload(IWineD3DBaseTexture *iface)
    8192{
     
    8394    IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
    8495
    85     if(This->baseTexture.textureName) {
     96    if(This->baseTexture.texture_rgb.name ||
     97       This->baseTexture.texture_srgb.name) {
    8698        ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
    87         ENTER_GL();
    88         glDeleteTextures(1, &This->baseTexture.textureName);
    89         This->baseTexture.textureName = 0;
    90         LEAVE_GL();
    91     }
    92 
    93     if(This->baseTexture.srgbTextureName) {
    94         ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
    95         ENTER_GL();
    96         glDeleteTextures(1, &This->baseTexture.srgbTextureName);
    97         This->baseTexture.srgbTextureName = 0;
    98         LEAVE_GL();
    99     }
    100     This->baseTexture.dirty = TRUE;
    101     This->baseTexture.srgbDirty = TRUE;
    102 }
    103 
    104 /* There is no OpenGL equivalent of setLOD, getLOD. All they do anyway is prioritize texture loading
    105  * so just pretend that they work unless something really needs a failure. */
     99    }
     100
     101    if(This->baseTexture.texture_rgb.name) {
     102        gltexture_delete(&This->baseTexture.texture_rgb);
     103    }
     104    if(This->baseTexture.texture_srgb.name) {
     105        gltexture_delete(&This->baseTexture.texture_srgb);
     106    }
     107    This->baseTexture.texture_rgb.dirty = TRUE;
     108    This->baseTexture.texture_srgb.dirty = TRUE;
     109}
     110
    106111DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
    107112{
    108113    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
    109 
     114    DWORD old = This->baseTexture.LOD;
     115
     116    /* The d3d9:texture test shows that SetLOD is ignored on non-managed
     117     * textures. The call always returns 0, and GetLOD always returns 0
     118     */
    110119    if (This->resource.pool != WINED3DPOOL_MANAGED) {
    111         return  WINED3DERR_INVALIDCALL;
     120        TRACE("Ignoring SetLOD on %s texture, returning 0\n", debug_d3dpool(This->resource.pool));
     121        return 0;
    112122    }
    113123
    114124    if(LODNew >= This->baseTexture.levels)
    115125        LODNew = This->baseTexture.levels - 1;
    116      This->baseTexture.LOD = LODNew;
    117 
    118     TRACE("(%p) : set bogus LOD to %d\n", This, This->baseTexture.LOD);
    119 
    120     return This->baseTexture.LOD;
     126
     127    if(This->baseTexture.LOD != LODNew) {
     128        This->baseTexture.LOD = LODNew;
     129
     130        This->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
     131        This->baseTexture.texture_srgb.states[WINED3DTEXSTA_MAXMIPLEVEL] = ~0U;
     132        if(This->baseTexture.bindCount) {
     133            IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(This->baseTexture.sampler));
     134        }
     135    }
     136
     137    TRACE("(%p) : set LOD to %d\n", This, This->baseTexture.LOD);
     138
     139    return old;
    121140}
    122141
     
    124143{
    125144    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
    126 
    127     if (This->resource.pool != WINED3DPOOL_MANAGED) {
    128         return  WINED3DERR_INVALIDCALL;
    129     }
    130145
    131146    TRACE("(%p) : returning %d\n", This, This->baseTexture.LOD);
     
    158173      ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
    159174      ENTER_GL();
    160       glBindTexture(textureDimensions, This->baseTexture.textureName);
     175      glBindTexture(textureDimensions, This->baseTexture.texture_rgb.name);
    161176      checkGLcall("glBindTexture");
    162177      switch(FilterType) {
     
    205220    BOOL old;
    206221    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
    207     old = This->baseTexture.dirty || This->baseTexture.srgbDirty;
    208     This->baseTexture.dirty = dirty;
    209     This->baseTexture.srgbDirty = dirty;
     222    old = This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
     223    This->baseTexture.texture_rgb.dirty = dirty;
     224    This->baseTexture.texture_srgb.dirty = dirty;
    210225    return old;
    211226}
     
    214229{
    215230    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
    216     return This->baseTexture.dirty || This->baseTexture.srgbDirty;
     231    return This->baseTexture.texture_rgb.dirty || This->baseTexture.texture_srgb.dirty;
    217232}
    218233
     
    224239    UINT textureDimensions;
    225240    BOOL isNewTexture = FALSE;
    226     GLuint *texture;
    227     DWORD *states;
     241    struct gl_texture *gl_tex;
    228242    TRACE("(%p) : About to bind texture\n", This);
    229243
    230244    This->baseTexture.is_srgb = srgb; /* SRGB mode cache for PreLoad calls outside drawprim */
    231245    if(srgb) {
    232         texture = &This->baseTexture.srgbTextureName;
    233         states = This->baseTexture.srgbstates;
     246        gl_tex = &This->baseTexture.texture_srgb;
    234247    } else {
    235         texture = &This->baseTexture.textureName;
    236         states = This->baseTexture.states;
     248        gl_tex = &This->baseTexture.texture_rgb;
    237249    }
    238250
     
    240252    ENTER_GL();
    241253    /* Generate a texture name if we don't already have one */
    242     if (*texture == 0) {
     254    if (gl_tex->name == 0) {
    243255        *set_surface_desc = TRUE;
    244         glGenTextures(1, texture);
     256        glGenTextures(1, &gl_tex->name);
    245257        checkGLcall("glGenTextures");
    246         TRACE("Generated texture %d\n", *texture);
     258        TRACE("Generated texture %d\n", gl_tex->name);
    247259        if (This->resource.pool == WINED3DPOOL_DEFAULT) {
    248260            /* Tell opengl to try and keep this texture in video ram (well mostly) */
    249261            GLclampf tmp;
    250262            tmp = 0.9f;
    251             glPrioritizeTextures(1, texture, &tmp);
     263            glPrioritizeTextures(1, &gl_tex->name, &tmp);
    252264
    253265        }
    254266        /* Initialise the state of the texture object
    255267        to the openGL defaults, not the directx defaults */
    256         states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_WRAP;
    257         states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_WRAP;
    258         states[WINED3DTEXSTA_ADDRESSW]      = WINED3DTADDRESS_WRAP;
    259         states[WINED3DTEXSTA_BORDERCOLOR]   = 0;
    260         states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_LINEAR;
    261         states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
    262         states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
    263         states[WINED3DTEXSTA_MAXMIPLEVEL]   = 0;
    264         states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
    265         states[WINED3DTEXSTA_SRGBTEXTURE]   = 0;
    266         states[WINED3DTEXSTA_ELEMENTINDEX]  = 0;
    267         states[WINED3DTEXSTA_DMAPOFFSET]    = 0;
    268         states[WINED3DTEXSTA_TSSADDRESSW]   = WINED3DTADDRESS_WRAP;
     268        gl_tex->states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_WRAP;
     269        gl_tex->states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_WRAP;
     270        gl_tex->states[WINED3DTEXSTA_ADDRESSW]      = WINED3DTADDRESS_WRAP;
     271        gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]   = 0;
     272        gl_tex->states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_LINEAR;
     273        gl_tex->states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
     274        gl_tex->states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
     275        gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL]   = 0;
     276        gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
     277        gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE]   = 0;
     278        gl_tex->states[WINED3DTEXSTA_ELEMENTINDEX]  = 0;
     279        gl_tex->states[WINED3DTEXSTA_DMAPOFFSET]    = 0;
     280        gl_tex->states[WINED3DTEXSTA_TSSADDRESSW]   = WINED3DTADDRESS_WRAP;
    269281        IWineD3DBaseTexture_SetDirty(iface, TRUE);
    270282        isNewTexture = TRUE;
     
    274286             * in all, and the run-time path free from additional checks
    275287             */
    276             glBindTexture(textureDimensions, *texture);
     288            glBindTexture(textureDimensions, gl_tex->name);
    277289            checkGLcall("glBindTexture");
    278290            glTexParameteri(textureDimensions, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
     
    284296
    285297    /* Bind the texture */
    286     if (*texture != 0) {
    287         glBindTexture(textureDimensions, *texture);
     298    if (gl_tex->name != 0) {
     299        glBindTexture(textureDimensions, gl_tex->name);
    288300        checkGLcall("glBindTexture");
    289301        if (isNewTexture) {
     
    348360{
    349361    IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
    350     DWORD state, *states;
     362    DWORD state;
    351363    GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
    352364    BOOL cond_np2 = IWineD3DBaseTexture_IsCondNP2(iface);
    353365    DWORD aniso;
     366    struct gl_texture *gl_tex;
    354367
    355368    TRACE("iface %p, textureStates %p, samplerStates %p\n", iface, textureStates, samplerStates);
    356369
    357370    if(This->baseTexture.is_srgb) {
    358         states = This->baseTexture.srgbstates;
     371        gl_tex = &This->baseTexture.texture_srgb;
    359372    } else {
    360         states = This->baseTexture.states;
     373        gl_tex = &This->baseTexture.texture_rgb;
    361374    }
    362375
    363376    /* This function relies on the correct texture being bound and loaded. */
    364377
    365     if(samplerStates[WINED3DSAMP_ADDRESSU]      != states[WINED3DTEXSTA_ADDRESSU]) {
     378    if(samplerStates[WINED3DSAMP_ADDRESSU]      != gl_tex->states[WINED3DTEXSTA_ADDRESSU]) {
    366379        state = samplerStates[WINED3DSAMP_ADDRESSU];
    367380        apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_S, cond_np2);
    368         states[WINED3DTEXSTA_ADDRESSU] = state;
    369     }
    370 
    371     if(samplerStates[WINED3DSAMP_ADDRESSV]      != states[WINED3DTEXSTA_ADDRESSV]) {
     381        gl_tex->states[WINED3DTEXSTA_ADDRESSU] = state;
     382    }
     383
     384    if(samplerStates[WINED3DSAMP_ADDRESSV]      != gl_tex->states[WINED3DTEXSTA_ADDRESSV]) {
    372385        state = samplerStates[WINED3DSAMP_ADDRESSV];
    373386        apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_T, cond_np2);
    374         states[WINED3DTEXSTA_ADDRESSV] = state;
    375     }
    376 
    377     if(samplerStates[WINED3DSAMP_ADDRESSW]      != states[WINED3DTEXSTA_ADDRESSW]) {
     387        gl_tex->states[WINED3DTEXSTA_ADDRESSV] = state;
     388    }
     389
     390    if(samplerStates[WINED3DSAMP_ADDRESSW]      != gl_tex->states[WINED3DTEXSTA_ADDRESSW]) {
    378391        state = samplerStates[WINED3DSAMP_ADDRESSW];
    379392        apply_wrap(textureDimensions, state, GL_TEXTURE_WRAP_R, cond_np2);
    380         states[WINED3DTEXSTA_ADDRESSW] = state;
    381     }
    382 
    383     if(samplerStates[WINED3DSAMP_BORDERCOLOR]   != states[WINED3DTEXSTA_BORDERCOLOR]) {
     393        gl_tex->states[WINED3DTEXSTA_ADDRESSW] = state;
     394    }
     395
     396    if(samplerStates[WINED3DSAMP_BORDERCOLOR]   != gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]) {
    384397        float col[4];
    385398
     
    389402        glTexParameterfv(textureDimensions, GL_TEXTURE_BORDER_COLOR, &col[0]);
    390403        checkGLcall("glTexParameteri(..., GL_TEXTURE_BORDER_COLOR, ...)");
    391         states[WINED3DTEXSTA_BORDERCOLOR] = state;
    392     }
    393 
    394     if(samplerStates[WINED3DSAMP_MAGFILTER]     != states[WINED3DTEXSTA_MAGFILTER]) {
     404        gl_tex->states[WINED3DTEXSTA_BORDERCOLOR] = state;
     405    }
     406
     407    if(samplerStates[WINED3DSAMP_MAGFILTER]     != gl_tex->states[WINED3DTEXSTA_MAGFILTER]) {
    395408        GLint glValue;
    396409        state = samplerStates[WINED3DSAMP_MAGFILTER];
     
    404417        glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
    405418
    406         states[WINED3DTEXSTA_MAGFILTER] = state;
    407     }
    408 
    409     if((samplerStates[WINED3DSAMP_MINFILTER]     != states[WINED3DTEXSTA_MINFILTER] ||
    410         samplerStates[WINED3DSAMP_MIPFILTER]     != states[WINED3DTEXSTA_MIPFILTER] ||
    411         samplerStates[WINED3DSAMP_MAXMIPLEVEL]   != states[WINED3DTEXSTA_MAXMIPLEVEL])) {
     419        gl_tex->states[WINED3DTEXSTA_MAGFILTER] = state;
     420    }
     421
     422    if((samplerStates[WINED3DSAMP_MINFILTER]     != gl_tex->states[WINED3DTEXSTA_MINFILTER] ||
     423        samplerStates[WINED3DSAMP_MIPFILTER]     != gl_tex->states[WINED3DTEXSTA_MIPFILTER] ||
     424        samplerStates[WINED3DSAMP_MAXMIPLEVEL]   != gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL])) {
    412425        GLint glValue;
    413426
    414         states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
    415         states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
    416         states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
    417 
    418         if (states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
    419                 || states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
     427        gl_tex->states[WINED3DTEXSTA_MIPFILTER] = samplerStates[WINED3DSAMP_MIPFILTER];
     428        gl_tex->states[WINED3DTEXSTA_MINFILTER] = samplerStates[WINED3DSAMP_MINFILTER];
     429        gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] = samplerStates[WINED3DSAMP_MAXMIPLEVEL];
     430
     431        if (gl_tex->states[WINED3DTEXSTA_MINFILTER] > WINED3DTEXF_ANISOTROPIC
     432            || gl_tex->states[WINED3DTEXSTA_MIPFILTER] > WINED3DTEXF_ANISOTROPIC)
    420433        {
    421434
    422435            FIXME("Unrecognized or unsupported D3DSAMP_MINFILTER value %d D3DSAMP_MIPFILTER value %d\n",
    423                   states[WINED3DTEXSTA_MINFILTER],
    424                   states[WINED3DTEXSTA_MIPFILTER]);
     436                  gl_tex->states[WINED3DTEXSTA_MINFILTER],
     437                  gl_tex->states[WINED3DTEXSTA_MIPFILTER]);
    425438        }
    426439        glValue = wined3d_gl_min_mip_filter(This->baseTexture.minMipLookup,
     
    435448
    436449        if(!cond_np2) {
    437             if(states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
    438                 glValue = 0;
    439             } else if(states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
     450            if(gl_tex->states[WINED3DTEXSTA_MIPFILTER] == WINED3DTEXF_NONE) {
     451                glValue = This->baseTexture.LOD;
     452            } else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] >= This->baseTexture.levels) {
    440453                glValue = This->baseTexture.levels - 1;
     454            } else if(gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL] < This->baseTexture.LOD) {
     455                /* baseTexture.LOD is already clamped in the setter */
     456                glValue = This->baseTexture.LOD;
    441457            } else {
    442                 glValue = states[WINED3DTEXSTA_MAXMIPLEVEL];
     458                glValue = gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL];
    443459            }
     460            /* Note that D3DSAMP_MAXMIPLEVEL specifies the biggest mipmap(default 0), while
     461             * GL_TEXTURE_MAX_LEVEL specifies the smallest mimap used(default 1000).
     462             * So D3DSAMP_MAXMIPLEVEL is the same as GL_TEXTURE_BASE_LEVEL.
     463             */
    444464            glTexParameteri(textureDimensions, GL_TEXTURE_BASE_LEVEL, glValue);
    445465        }
    446466    }
    447467
    448     if ((states[WINED3DSAMP_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
    449             && states[WINED3DSAMP_MINFILTER] != WINED3DTEXF_ANISOTROPIC
    450             && states[WINED3DSAMP_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
     468    if ((gl_tex->states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_ANISOTROPIC
     469         && gl_tex->states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_ANISOTROPIC
     470         && gl_tex->states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_ANISOTROPIC)
    451471            || cond_np2)
    452472    {
     
    458478    }
    459479
    460     if (states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
     480    if (gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] != aniso)
    461481    {
    462482        if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC))
     
    469489            WARN("Anisotropic filtering not supported.\n");
    470490        }
    471         states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
    472     }
    473 }
     491        gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = aniso;
     492    }
     493}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/buffer.c

    r22496 r23571  
    208208}
    209209
    210 static BOOL buffer_check_attribute(struct wined3d_buffer *This,
    211         const struct wined3d_stream_info_element *attrib, const BOOL check_d3dcolor, const BOOL is_ffp_position,
    212         const BOOL is_ffp_color, DWORD *stride_this_run, BOOL *float16_used)
    213 {
     210static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct wined3d_stream_info *si,
     211        UINT attrib_idx, const BOOL check_d3dcolor, const BOOL is_ffp_position, const BOOL is_ffp_color,
     212        DWORD *stride_this_run, BOOL *float16_used)
     213{
     214    const struct wined3d_stream_info_element *attrib = &si->elements[attrib_idx];
    214215    BOOL ret = FALSE;
    215216    WINED3DFORMAT format;
     
    218219     * there, on nonexistent attribs the vbo is 0.
    219220     */
    220     if (attrib->buffer_object != This->buffer_object) return FALSE;
     221    if (!(si->use_map & (1 << attrib_idx))
     222            || attrib->buffer_object != This->buffer_object)
     223        return FALSE;
    221224
    222225    format = attrib->format_desc->format;
     
    230233        *float16_used = TRUE;
    231234    }
    232     else if (check_d3dcolor && format == WINED3DFMT_A8R8G8B8)
     235    else if (check_d3dcolor && format == WINED3DFMT_B8G8R8A8_UNORM)
    233236    {
    234237        ret = buffer_process_converted_attribute(This, CONV_D3DCOLOR, attrib, stride_this_run);
    235238
    236         if (!is_ffp_color) FIXME("Test for non-color fixed function WINED3DFMT_A8R8G8B8 format\n");
     239        if (!is_ffp_color) FIXME("Test for non-color fixed function WINED3DFMT_B8G8R8A8_UNORM format\n");
    237240    }
    238241    else if (is_ffp_position && format == WINED3DFMT_R32G32B32A32_FLOAT)
     
    265268        WINED3DFORMAT format;
    266269
    267         if (strided->elements[i].buffer_object != This->buffer_object) continue;
     270        if (!(strided->use_map & (1 << i)) || strided->elements[i].buffer_object != This->buffer_object) continue;
    268271
    269272        format = strided->elements[i].format_desc->format;
     
    316319{
    317320    IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     321    const struct wined3d_stream_info *si = &device->strided_streams;
    318322    UINT stride_this_run = 0;
    319323    BOOL float16_used = FALSE;
     
    403407        for (i = 0; i < MAX_ATTRIBS; ++i)
    404408        {
    405             ret = buffer_check_attribute(This, &device->strided_streams.elements[i],
    406                     FALSE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
     409            ret = buffer_check_attribute(This, si, i, FALSE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    407410        }
    408411
     
    413416        {
    414417            HeapFree(GetProcessHeap(), 0, This->conversion_shift);
    415             This->conversion_shift = find_conversion_shift(This, &device->strided_streams, This->stride);
     418            This->conversion_shift = find_conversion_shift(This, si, This->stride);
    416419        }
    417420    }
     
    423426         */
    424427        BOOL support_d3dcolor = GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA);
    425         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_POSITION],
     428        ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION,
    426429                TRUE, TRUE,  FALSE, &stride_this_run, &float16_used) || ret;
    427         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_NORMAL],
     430        ret = buffer_check_attribute(This, si, WINED3D_FFP_NORMAL,
    428431                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    429         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_DIFFUSE],
     432        ret = buffer_check_attribute(This, si, WINED3D_FFP_DIFFUSE,
    430433                !support_d3dcolor, FALSE, TRUE,  &stride_this_run, &float16_used) || ret;
    431         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_SPECULAR],
     434        ret = buffer_check_attribute(This, si, WINED3D_FFP_SPECULAR,
    432435                !support_d3dcolor, FALSE, TRUE,  &stride_this_run, &float16_used) || ret;
    433         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD0],
     436        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD0,
    434437                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    435         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD1],
     438        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD1,
    436439                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    437         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD2],
     440        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD2,
    438441                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    439         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD3],
     442        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD3,
    440443                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    441         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD4],
     444        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD4,
    442445                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    443         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD5],
     446        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD5,
    444447                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    445         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD6],
     448        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD6,
    446449                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    447         ret = buffer_check_attribute(This, &device->strided_streams.elements[WINED3D_FFP_TEXCOORD7],
     450        ret = buffer_check_attribute(This, si, WINED3D_FFP_TEXCOORD7,
    448451                TRUE, FALSE, FALSE, &stride_this_run, &float16_used) || ret;
    449452
     
    642645        buffer_UnLoad(iface);
    643646        resource_cleanup((IWineD3DResource *)iface);
     647        This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
    644648        HeapFree(GetProcessHeap(), 0, This);
    645649    }
     
    10421046}
    10431047
    1044 const struct IWineD3DBufferVtbl wined3d_buffer_vtbl =
     1048static const struct IWineD3DBufferVtbl wined3d_buffer_vtbl =
    10451049{
    10461050    /* IUnknown methods */
     
    10651069    buffer_GetDesc,
    10661070};
     1071
     1072HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
     1073        UINT size, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, GLenum bind_hint,
     1074        const char *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     1075{
     1076    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, &device->adapter->gl_info);
     1077    HRESULT hr;
     1078
     1079    if (!size)
     1080    {
     1081        WARN("Size 0 requested, returning WINED3DERR_INVALIDCALL\n");
     1082        return WINED3DERR_INVALIDCALL;
     1083    }
     1084
     1085    buffer->vtbl = &wined3d_buffer_vtbl;
     1086
     1087    hr = resource_init((IWineD3DResource *)buffer, WINED3DRTYPE_BUFFER,
     1088            device, size, usage, format_desc, pool, parent, parent_ops);
     1089    if (FAILED(hr))
     1090    {
     1091        WARN("Failed to initialize resource, hr %#x\n", hr);
     1092        return hr;
     1093    }
     1094    buffer->buffer_type_hint = bind_hint;
     1095
     1096    TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n", buffer->resource.size, buffer->resource.usage,
     1097            debug_d3dformat(buffer->resource.format_desc->format), buffer->resource.allocatedMemory, buffer);
     1098
     1099    if (data)
     1100    {
     1101        BYTE *ptr;
     1102
     1103        hr = IWineD3DBuffer_Map((IWineD3DBuffer *)buffer, 0, size, &ptr, 0);
     1104        if (FAILED(hr))
     1105        {
     1106            ERR("Failed to map buffer, hr %#x\n", hr);
     1107            buffer_UnLoad((IWineD3DBuffer *)buffer);
     1108            resource_cleanup((IWineD3DResource *)buffer);
     1109            return hr;
     1110        }
     1111
     1112        memcpy(ptr, data, size);
     1113
     1114        hr = IWineD3DBuffer_Unmap((IWineD3DBuffer *)buffer);
     1115        if (FAILED(hr))
     1116        {
     1117            ERR("Failed to unmap buffer, hr %#x\n", hr);
     1118            buffer_UnLoad((IWineD3DBuffer *)buffer);
     1119            resource_cleanup((IWineD3DResource *)buffer);
     1120            return hr;
     1121        }
     1122    }
     1123
     1124    return WINED3D_OK;
     1125}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c

    r22596 r23571  
    5858        if (!*fbo)
    5959        {
    60             GL_EXTCALL(glGenFramebuffersEXT(1, fbo));
    61             checkGLcall("glGenFramebuffersEXT()");
     60            gl_info->fbo_ops.glGenFramebuffers(1, fbo);
     61            checkGLcall("glGenFramebuffers()");
    6262            TRACE("Created FBO %u.\n", *fbo);
    6363        }
     
    6767    switch (target)
    6868    {
    69         case GL_READ_FRAMEBUFFER_EXT:
     69        case GL_READ_FRAMEBUFFER:
    7070            if (context->fbo_read_binding == f) return;
    7171            context->fbo_read_binding = f;
    7272            break;
    7373
    74         case GL_DRAW_FRAMEBUFFER_EXT:
     74        case GL_DRAW_FRAMEBUFFER:
    7575            if (context->fbo_draw_binding == f) return;
    7676            context->fbo_draw_binding = f;
    7777            break;
    7878
    79         case GL_FRAMEBUFFER_EXT:
     79        case GL_FRAMEBUFFER:
    8080            if (context->fbo_read_binding == f
    8181                    && context->fbo_draw_binding == f) return;
     
    8989    }
    9090
    91     GL_EXTCALL(glBindFramebufferEXT(target, f));
     91    gl_info->fbo_ops.glBindFramebuffer(target, f);
    9292    checkGLcall("glBindFramebuffer()");
    9393}
     
    100100    for (i = 0; i < GL_LIMITS(buffers); ++i)
    101101    {
    102         GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT + i, GL_TEXTURE_2D, 0, 0));
     102        gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, 0, 0);
    103103        checkGLcall("glFramebufferTexture2D()");
    104104    }
    105     GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
     105    gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
    106106    checkGLcall("glFramebufferTexture2D()");
    107107
    108     GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
     108    gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
    109109    checkGLcall("glFramebufferTexture2D()");
    110110}
     
    115115    const struct wined3d_gl_info *gl_info = context->gl_info;
    116116
    117     context_bind_fbo(context, GL_FRAMEBUFFER_EXT, fbo);
     117    context_bind_fbo(context, GL_FRAMEBUFFER, fbo);
    118118    context_clean_fbo_attachments(gl_info);
    119     context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL);
    120 
    121     GL_EXTCALL(glDeleteFramebuffersEXT(1, fbo));
     119    context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
     120
     121    gl_info->fbo_ops.glDeleteFramebuffers(1, fbo);
    122122    checkGLcall("glDeleteFramebuffers()");
    123123}
     
    135135    if (SUCCEEDED(IWineD3DSurface_GetContainer(surface, &IID_IWineD3DBaseTexture, (void **)&texture_impl)))
    136136    {
    137         if (texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_POINT
    138             || texture_impl->baseTexture.states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_NONE)
    139         {
    140             texture_impl->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
    141             texture_impl->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
     137        if (texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] != WINED3DTEXF_POINT
     138            || texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] != WINED3DTEXF_NONE)
     139        {
     140            texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
     141            texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
    142142            update_minfilter = TRUE;
    143143        }
    144144
    145         if (texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_POINT)
    146         {
    147             texture_impl->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
     145        if (texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] != WINED3DTEXF_POINT)
     146        {
     147            texture_impl->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
    148148            update_magfilter = TRUE;
    149149        }
     
    204204            if (format_flags & WINED3DFMT_FLAG_DEPTH)
    205205            {
    206                 GL_EXTCALL(glFramebufferRenderbufferEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT,
    207                         GL_RENDERBUFFER_EXT, depth_stencil_impl->current_renderbuffer->id));
    208                 checkGLcall("glFramebufferRenderbufferEXT()");
     206                gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_DEPTH_ATTACHMENT,
     207                        GL_RENDERBUFFER, depth_stencil_impl->current_renderbuffer->id);
     208                checkGLcall("glFramebufferRenderbuffer()");
    209209            }
    210210
    211211            if (format_flags & WINED3DFMT_FLAG_STENCIL)
    212212            {
    213                 GL_EXTCALL(glFramebufferRenderbufferEXT(fbo_target, GL_STENCIL_ATTACHMENT_EXT,
    214                         GL_RENDERBUFFER_EXT, depth_stencil_impl->current_renderbuffer->id));
    215                 checkGLcall("glFramebufferRenderbufferEXT()");
     213                gl_info->fbo_ops.glFramebufferRenderbuffer(fbo_target, GL_STENCIL_ATTACHMENT,
     214                        GL_RENDERBUFFER, depth_stencil_impl->current_renderbuffer->id);
     215                checkGLcall("glFramebufferRenderbuffer()");
    216216            }
    217217        }
     
    222222            if (format_flags & WINED3DFMT_FLAG_DEPTH)
    223223            {
    224                 GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT,
     224                gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_DEPTH_ATTACHMENT,
    225225                        depth_stencil_impl->texture_target, depth_stencil_impl->texture_name,
    226                         depth_stencil_impl->texture_level));
    227                 checkGLcall("glFramebufferTexture2DEXT()");
     226                        depth_stencil_impl->texture_level);
     227                checkGLcall("glFramebufferTexture2D()");
    228228            }
    229229
    230230            if (format_flags & WINED3DFMT_FLAG_STENCIL)
    231231            {
    232                 GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_STENCIL_ATTACHMENT_EXT,
     232                gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_STENCIL_ATTACHMENT,
    233233                        depth_stencil_impl->texture_target, depth_stencil_impl->texture_name,
    234                         depth_stencil_impl->texture_level));
    235                 checkGLcall("glFramebufferTexture2DEXT()");
     234                        depth_stencil_impl->texture_level);
     235                checkGLcall("glFramebufferTexture2D()");
    236236            }
    237237        }
     
    239239        if (!(format_flags & WINED3DFMT_FLAG_DEPTH))
    240240        {
    241             GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
    242             checkGLcall("glFramebufferTexture2DEXT()");
     241            gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
     242            checkGLcall("glFramebufferTexture2D()");
    243243        }
    244244
    245245        if (!(format_flags & WINED3DFMT_FLAG_STENCIL))
    246246        {
    247             GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
    248             checkGLcall("glFramebufferTexture2DEXT()");
     247            gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
     248            checkGLcall("glFramebufferTexture2D()");
    249249        }
    250250    }
    251251    else
    252252    {
    253         GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
    254         checkGLcall("glFramebufferTexture2DEXT()");
    255 
    256         GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0));
    257         checkGLcall("glFramebufferTexture2DEXT()");
     253        gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
     254        checkGLcall("glFramebufferTexture2D()");
     255
     256        gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
     257        checkGLcall("glFramebufferTexture2D()");
    258258    }
    259259}
     
    272272        context_apply_attachment_filter_states(surface, TRUE);
    273273
    274         GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_COLOR_ATTACHMENT0_EXT + idx, surface_impl->texture_target,
    275                 surface_impl->texture_name, surface_impl->texture_level));
    276         checkGLcall("glFramebufferTexture2DEXT()");
    277     } else {
    278         GL_EXTCALL(glFramebufferTexture2DEXT(fbo_target, GL_COLOR_ATTACHMENT0_EXT + idx, GL_TEXTURE_2D, 0, 0));
    279         checkGLcall("glFramebufferTexture2DEXT()");
     274        gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx, surface_impl->texture_target,
     275                surface_impl->texture_name, surface_impl->texture_level);
     276        checkGLcall("glFramebufferTexture2D()");
     277    }
     278    else
     279    {
     280        gl_info->fbo_ops.glFramebufferTexture2D(fbo_target, GL_COLOR_ATTACHMENT0 + idx, GL_TEXTURE_2D, 0, 0);
     281        checkGLcall("glFramebufferTexture2D()");
    280282    }
    281283}
     
    287289    GLenum status;
    288290
    289     status = GL_EXTCALL(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
    290     if (status == GL_FRAMEBUFFER_COMPLETE_EXT)
     291    status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
     292    if (status == GL_FRAMEBUFFER_COMPLETE)
    291293    {
    292294        TRACE("FBO complete\n");
     
    295297        unsigned int i;
    296298        FIXME("FBO status %s (%#x)\n", debug_fbostatus(status), status);
    297 
    298299
    299300        if (context->current_fbo)
     
    308309                            i, attachment, debug_d3dformat(attachment->resource.format_desc->format),
    309310                            attachment->pow2Width, attachment->pow2Height);
    310        
    311311                }
    312312            }
     
    344344    const struct wined3d_gl_info *gl_info = context->gl_info;
    345345
    346     context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &entry->id);
     346    context_bind_fbo(context, GL_FRAMEBUFFER, &entry->id);
    347347    context_clean_fbo_attachments(gl_info);
    348348
     
    409409    unsigned int i;
    410410
    411     context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &entry->id);
     411    context_bind_fbo(context, GL_FRAMEBUFFER, &entry->id);
    412412
    413413    if (!entry->attached)
     
    417417        {
    418418            IWineD3DSurface *render_target = device->render_targets[i];
    419             context_attach_surface_fbo(context, GL_FRAMEBUFFER_EXT, i, render_target);
     419            context_attach_surface_fbo(context, GL_FRAMEBUFFER, i, render_target);
    420420        }
    421421
     
    428428            surface_set_compatible_renderbuffer(device->stencilBufferTarget, w, h);
    429429        }
    430         context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER_EXT, device->stencilBufferTarget, TRUE);
     430        context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, device->stencilBufferTarget, TRUE);
    431431
    432432        entry->attached = TRUE;
     
    444444    {
    445445        if (device->render_targets[i])
    446             device->draw_buffers[i] = GL_COLOR_ATTACHMENT0_EXT + i;
     446            device->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i;
    447447        else
    448448            device->draw_buffers[i] = GL_NONE;
     
    459459    } else {
    460460        context->current_fbo = NULL;
    461         context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL);
     461        context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
    462462    }
    463463
     
    690690        }
    691691
    692         GL_EXTCALL(glDeleteQueriesARB(context->free_occlusion_query_count, context->free_occlusion_queries));
     692        if (GL_SUPPORT(ARB_OCCLUSION_QUERY))
     693            GL_EXTCALL(glDeleteQueriesARB(context->free_occlusion_query_count, context->free_occlusion_queries));
    693694
    694695        if (GL_SUPPORT(APPLE_FENCE))
     
    771772        if (!pwglMakeCurrent(ctx->hdc, ctx->glCtx))
    772773        {
    773             ERR("Failed to make GL context %p current on device context %p.\n", ctx->glCtx, ctx->hdc);
     774            DWORD err = GetLastError();
     775            ERR("Failed to make GL context %p current on device context %p, last error %#x.\n",
     776                    ctx->glCtx, ctx->hdc, err);
     777            TlsSetValue(wined3d_context_tls_idx, NULL);
    774778            return FALSE;
    775779        }
    776780        ctx->current = 1;
    777781    }
    778     else
     782    else if(pwglGetCurrentContext())
    779783    {
    780784        TRACE("Clearing current D3D context.\n");
    781785        if (!pwglMakeCurrent(NULL, NULL))
    782786        {
    783             ERR("Failed to clear current GL context.\n");
    784             /*In case of failure, wglMakeCurrent makes current GLRC not current anyway.*/
     787            DWORD err = GetLastError();
     788            ERR("Failed to clear current GL context, last error %#x.\n", err);
    785789            TlsSetValue(wined3d_context_tls_idx, NULL);
    786790            return FALSE;
     
    810814    BYTE shift;
    811815
    812     if(!rep || isStateDirty(context, rep)) return;
     816    if (isStateDirty(context, rep)) return;
    813817
    814818    context->dirtyArray[context->numDirtyEntries++] = rep;
     
    867871     */
    868872    for(state = 0; state <= STATE_HIGHEST; state++) {
    869         Context_MarkStateDirty(This->contexts[This->numContexts], state, This->StateTable);
     873        if (This->StateTable[state].representative)
     874            Context_MarkStateDirty(This->contexts[This->numContexts], state, This->StateTable);
    870875    }
    871876
     
    930935     * time. It can cause a slight performance hit but fixes a lot of regressions. A fixme reminds of that this
    931936     * issue needs to be fixed. */
    932     if (ds_format_desc->format != WINED3DFMT_D24S8)
     937    if (ds_format_desc->format != WINED3DFMT_S8_UINT_D24_UNORM)
    933938    {
    934939        FIXME("Add OpenGL context recreation support to SetDepthStencilSurface\n");
    935         ds_format_desc = getFormatDescEntry(WINED3DFMT_D24S8, &This->adapter->gl_info);
     940        ds_format_desc = getFormatDescEntry(WINED3DFMT_S8_UINT_D24_UNORM, &This->adapter->gl_info);
    936941    }
    937942
     
    11451150            auxBuffers = TRUE;
    11461151
    1147             if (color_format_desc->format == WINED3DFMT_X4R4G4B4)
    1148                 color_format_desc = getFormatDescEntry(WINED3DFMT_A4R4G4B4, &This->adapter->gl_info);
    1149             else if (color_format_desc->format == WINED3DFMT_X8R8G8B8)
    1150                 color_format_desc = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &This->adapter->gl_info);
     1152            if (color_format_desc->format == WINED3DFMT_B4G4R4X4_UNORM)
     1153                color_format_desc = getFormatDescEntry(WINED3DFMT_B4G4R4A4_UNORM, &This->adapter->gl_info);
     1154            else if (color_format_desc->format == WINED3DFMT_B8G8R8X8_UNORM)
     1155                color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info);
    11511156        }
    11521157
     
    11551160         * The conversion (ab)uses the alpha component for storing the palette index. For this reason we require
    11561161         * a format with 8bit alpha, so request A8R8G8B8. */
    1157         if (color_format_desc->format == WINED3DFMT_P8)
    1158             color_format_desc = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &This->adapter->gl_info);
     1162        if (color_format_desc->format == WINED3DFMT_P8_UINT)
     1163            color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info);
    11591164
    11601165        /* Retrieve the depth stencil format from the present parameters.
     
    13741379        checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)");
    13751380    }
     1381
     1382    if (GL_SUPPORT(ARB_PROVOKING_VERTEX))
     1383    {
     1384        GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION));
     1385    }
     1386    else if (GL_SUPPORT(EXT_PROVOKING_VERTEX))
     1387    {
     1388        GL_EXTCALL(glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT));
     1389    }
     1390
    13761391    LEAVE_GL();
    13771392
     
    15241539static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context *context, UINT width, UINT height)
    15251540{
    1526     int i, sampler;
     1541    int i;
    15271542    const struct StateEntry *StateTable = This->StateTable;
    15281543    const struct wined3d_gl_info *gl_info = context->gl_info;
     1544    DWORD sampler;
    15291545
    15301546    TRACE("Setting up context %p for blitting\n", context);
     
    15891605        checkGLcall("glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);");
    15901606
    1591         if (sampler != -1) {
     1607        if (sampler != WINED3D_UNMAPPED_STAGE)
     1608        {
    15921609            if (sampler < MAX_TEXTURES) {
    15931610                Context_MarkStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP), StateTable);
     
    16281645    }
    16291646
    1630     if (sampler != -1) {
     1647    if (sampler != WINED3D_UNMAPPED_STAGE)
     1648    {
    16311649        if (sampler < MAX_TEXTURES) {
    16321650            Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_TEXTURE0 + sampler), StateTable);
     
    18561874    if (context->render_offscreen != old_render_offscreen)
    18571875    {
    1858         Context_MarkStateDirty(context, WINED3DTS_PROJECTION, StateTable);
     1876        Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
    18591877        Context_MarkStateDirty(context, STATE_VDECL, StateTable);
    18601878        Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
     
    19641982                }
    19651983            } else {
    1966                 glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
     1984                glDrawBuffer(GL_COLOR_ATTACHMENT0);
    19671985                checkGLcall("glDrawBuffer()");
    19681986            }
     
    20462064                    FIXME("Activating for CTXUSAGE_BLIT for an offscreen target with ORM_FBO. This should be avoided.\n");
    20472065                    ENTER_GL();
    2048                     context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->dst_fbo);
    2049                     context_attach_surface_fbo(context, GL_FRAMEBUFFER_EXT, 0, target);
    2050                     context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER_EXT, NULL, FALSE);
     2066                    context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
     2067                    context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, target);
     2068                    context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, NULL, FALSE);
    20512069                    LEAVE_GL();
    20522070                } else {
    20532071                    ENTER_GL();
    2054                     context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL);
     2072                    context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
    20552073                    LEAVE_GL();
    20562074                }
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/cubetexture.c

    r22496 r23571  
    66 * Copyright 2005 Oliver Stieber
    77 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     8 * Copyright 2009 Henri Verbeet for CodeWeavers
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    6566            break;
    6667    }
    67     dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
     68    dirty = srgb_mode ? &This->baseTexture.texture_srgb.dirty : &This->baseTexture.texture_rgb.dirty;
    6869
    6970    TRACE("(%p) : About to load texture: dirtified(%u).\n", This, *dirty);
     
    7980    }
    8081
    81     if (This->resource.format_desc->format == WINED3DFMT_P8
    82             || This->resource.format_desc->format == WINED3DFMT_A8P8)
     82    if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
     83            || This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
    8384    {
    8485        for (i = 0; i < This->baseTexture.levels; ++i)
     
    120121}
    121122
    122 static void cubetexture_cleanup(IWineD3DCubeTextureImpl *This, D3DCB_DESTROYSURFACEFN surface_destroy_cb)
     123static void cubetexture_cleanup(IWineD3DCubeTextureImpl *This)
    123124{
    124125    unsigned int i, j;
     
    140141                surface_set_texture_target(surface, 0);
    141142                IWineD3DSurface_SetContainer(surface, NULL);
    142                 surface_destroy_cb(surface);
     143                IWineD3DSurface_Release(surface);
    143144            }
    144145        }
    145146    }
    146147    basetexture_cleanup((IWineD3DBaseTexture *)This);
    147 }
    148 
    149 HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
    150         IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
    151 {
    152     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    153     const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
    154     UINT pow2_edge_length;
    155     unsigned int i, j;
    156     UINT tmp_w;
    157     HRESULT hr;
    158 
    159     /* TODO: It should only be possible to create textures for formats
    160      * that are reported as supported. */
    161     if (WINED3DFMT_UNKNOWN >= format)
    162     {
    163         WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
    164         return WINED3DERR_INVALIDCALL;
    165     }
    166 
    167     if (!GL_SUPPORT(ARB_TEXTURE_CUBE_MAP) && pool != WINED3DPOOL_SCRATCH)
    168     {
    169         WARN("(%p) : Tried to create not supported cube texture.\n", texture);
    170         return WINED3DERR_INVALIDCALL;
    171     }
    172 
    173     /* Calculate levels for mip mapping */
    174     if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
    175     {
    176         if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
    177         {
    178             WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
    179             return WINED3DERR_INVALIDCALL;
    180         }
    181 
    182         if (levels > 1)
    183         {
    184             WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
    185             return WINED3DERR_INVALIDCALL;
    186         }
    187 
    188         levels = 1;
    189     }
    190     else if (!levels)
    191     {
    192         levels = wined3d_log2i(edge_length) + 1;
    193         TRACE("Calculated levels = %u.\n", levels);
    194     }
    195 
    196     hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
    197             WINED3DRTYPE_CUBETEXTURE, device, 0, usage, format_desc, pool, parent);
    198     if (FAILED(hr))
    199     {
    200         WARN("Failed to initialize basetexture, returning %#x\n", hr);
    201         return hr;
    202     }
    203 
    204     /* Find the nearest pow2 match. */
    205     pow2_edge_length = 1;
    206     while (pow2_edge_length < edge_length) pow2_edge_length <<= 1;
    207 
    208     if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || (edge_length == pow2_edge_length))
    209     {
    210         /* Precalculated scaling for 'faked' non power of two texture coords. */
    211         texture->baseTexture.pow2Matrix[0] = 1.0f;
    212         texture->baseTexture.pow2Matrix[5] = 1.0f;
    213         texture->baseTexture.pow2Matrix[10] = 1.0f;
    214         texture->baseTexture.pow2Matrix[15] = 1.0f;
    215     }
    216     else
    217     {
    218         /* Precalculated scaling for 'faked' non power of two texture coords. */
    219         texture->baseTexture.pow2Matrix[0] = ((float)edge_length) / ((float)pow2_edge_length);
    220         texture->baseTexture.pow2Matrix[5] = ((float)edge_length) / ((float)pow2_edge_length);
    221         texture->baseTexture.pow2Matrix[10] = ((float)edge_length) / ((float)pow2_edge_length);
    222         texture->baseTexture.pow2Matrix[15] = 1.0f;
    223         texture->baseTexture.pow2Matrix_identity = FALSE;
    224     }
    225 
    226     /* Generate all the surfaces. */
    227     tmp_w = edge_length;
    228     for (i = 0; i < texture->baseTexture.levels; ++i)
    229     {
    230         /* Create the 6 faces. */
    231         for (j = 0; j < 6; ++j)
    232         {
    233             static const GLenum cube_targets[6] =
    234             {
    235                 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
    236                 GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
    237                 GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
    238                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
    239                 GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
    240                 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
    241             };
    242 
    243             hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
    244                     format, usage, pool, i /* Level */, j, &texture->surfaces[j][i]);
    245             if (FAILED(hr))
    246             {
    247                 FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
    248                 texture->surfaces[j][i] = NULL;
    249                 cubetexture_cleanup(texture, D3DCB_DefaultDestroySurface);
    250                 return hr;
    251             }
    252 
    253             IWineD3DSurface_SetContainer(texture->surfaces[j][i], (IWineD3DBase *)texture);
    254             TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[j][i]);
    255             surface_set_texture_target(texture->surfaces[j][i], cube_targets[j]);
    256         }
    257         tmp_w = max(1, tmp_w >> 1);
    258     }
    259     texture->baseTexture.internal_preload = cubetexture_internal_preload;
    260 
    261     return WINED3D_OK;
    262148}
    263149
     
    298184    TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
    299185    ref = InterlockedDecrement(&This->resource.ref);
    300     if (ref == 0) {
    301         IWineD3DCubeTexture_Destroy(iface, D3DCB_DefaultDestroySurface);
     186    if (!ref)
     187    {
     188        cubetexture_cleanup(This);
     189        This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
     190        HeapFree(GetProcessHeap(), 0, This);
    302191    }
    303192    return ref;
     
    414303            for (j = WINED3DCUBEMAP_FACE_POSITIVE_X; j <= WINED3DCUBEMAP_FACE_NEGATIVE_Z; ++j) {
    415304                if(This->baseTexture.is_srgb) {
    416                     surface_set_texture_name(This->surfaces[j][i], This->baseTexture.srgbTextureName, TRUE);
     305                    surface_set_texture_name(This->surfaces[j][i], This->baseTexture.texture_srgb.name, TRUE);
    417306                } else {
    418                     surface_set_texture_name(This->surfaces[j][i], This->baseTexture.textureName, FALSE);
     307                    surface_set_texture_name(This->surfaces[j][i], This->baseTexture.texture_rgb.name, FALSE);
    419308                }
    420309            }
     
    442331   IWineD3DCubeTexture IWineD3DCubeTexture parts follow
    443332   ******************************************* */
    444 static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroySurface) {
    445     IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
    446 
    447     cubetexture_cleanup(This, D3DCB_DestroySurface);
    448     /* finally delete the object */
    449     HeapFree(GetProcessHeap(), 0, This);
    450 }
    451 
    452333static HRESULT WINAPI IWineD3DCubeTextureImpl_GetLevelDesc(IWineD3DCubeTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
    453334    IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
     
    516397    HRESULT hr = WINED3DERR_INVALIDCALL;
    517398    IWineD3DCubeTextureImpl *This = (IWineD3DCubeTextureImpl *)iface;
    518     This->baseTexture.dirty = TRUE;
    519     This->baseTexture.srgbDirty = TRUE;
     399    This->baseTexture.texture_rgb.dirty = TRUE;
     400    This->baseTexture.texture_srgb.dirty = TRUE;
    520401    TRACE("(%p) : dirtyfication of faceType(%d) Level (0)\n", This, FaceType);
    521402    if (FaceType <= WINED3DCUBEMAP_FACE_NEGATIVE_Z) {
     
    528409}
    529410
    530 
    531 const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
     411static const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl =
    532412{
    533413    /* IUnknown */
     
    559439    IWineD3DCubeTextureImpl_IsCondNP2,
    560440    /* IWineD3DCubeTexture */
    561     IWineD3DCubeTextureImpl_Destroy,
    562441    IWineD3DCubeTextureImpl_GetLevelDesc,
    563442    IWineD3DCubeTextureImpl_GetCubeMapSurface,
     
    566445    IWineD3DCubeTextureImpl_AddDirtyRect
    567446};
     447
     448HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
     449        IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
     450        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     451{
     452    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     453    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
     454    UINT pow2_edge_length;
     455    unsigned int i, j;
     456    UINT tmp_w;
     457    HRESULT hr;
     458
     459    /* TODO: It should only be possible to create textures for formats
     460     * that are reported as supported. */
     461    if (WINED3DFMT_UNKNOWN >= format)
     462    {
     463        WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
     464        return WINED3DERR_INVALIDCALL;
     465    }
     466
     467    if (!gl_info->supported[ARB_TEXTURE_CUBE_MAP] && pool != WINED3DPOOL_SCRATCH)
     468    {
     469        WARN("(%p) : Tried to create not supported cube texture.\n", texture);
     470        return WINED3DERR_INVALIDCALL;
     471    }
     472
     473    /* Calculate levels for mip mapping */
     474    if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
     475    {
     476        if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
     477        {
     478            WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
     479            return WINED3DERR_INVALIDCALL;
     480        }
     481
     482        if (levels > 1)
     483        {
     484            WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
     485            return WINED3DERR_INVALIDCALL;
     486        }
     487
     488        levels = 1;
     489    }
     490    else if (!levels)
     491    {
     492        levels = wined3d_log2i(edge_length) + 1;
     493        TRACE("Calculated levels = %u.\n", levels);
     494    }
     495
     496    texture->lpVtbl = &IWineD3DCubeTexture_Vtbl;
     497
     498    hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_CUBETEXTURE,
     499            device, 0, usage, format_desc, pool, parent, parent_ops);
     500    if (FAILED(hr))
     501    {
     502        WARN("Failed to initialize basetexture, returning %#x\n", hr);
     503        return hr;
     504    }
     505
     506    /* Find the nearest pow2 match. */
     507    pow2_edge_length = 1;
     508    while (pow2_edge_length < edge_length) pow2_edge_length <<= 1;
     509
     510    if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || (edge_length == pow2_edge_length))
     511    {
     512        /* Precalculated scaling for 'faked' non power of two texture coords. */
     513        texture->baseTexture.pow2Matrix[0] = 1.0f;
     514        texture->baseTexture.pow2Matrix[5] = 1.0f;
     515        texture->baseTexture.pow2Matrix[10] = 1.0f;
     516        texture->baseTexture.pow2Matrix[15] = 1.0f;
     517    }
     518    else
     519    {
     520        /* Precalculated scaling for 'faked' non power of two texture coords. */
     521        texture->baseTexture.pow2Matrix[0] = ((float)edge_length) / ((float)pow2_edge_length);
     522        texture->baseTexture.pow2Matrix[5] = ((float)edge_length) / ((float)pow2_edge_length);
     523        texture->baseTexture.pow2Matrix[10] = ((float)edge_length) / ((float)pow2_edge_length);
     524        texture->baseTexture.pow2Matrix[15] = 1.0f;
     525        texture->baseTexture.pow2Matrix_identity = FALSE;
     526    }
     527
     528    /* Generate all the surfaces. */
     529    tmp_w = edge_length;
     530    for (i = 0; i < texture->baseTexture.levels; ++i)
     531    {
     532        /* Create the 6 faces. */
     533        for (j = 0; j < 6; ++j)
     534        {
     535            static const GLenum cube_targets[6] =
     536            {
     537                GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
     538                GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
     539                GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
     540                GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
     541                GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
     542                GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB,
     543            };
     544
     545            hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_w,
     546                    format, usage, pool, i /* Level */, j, &texture->surfaces[j][i]);
     547            if (FAILED(hr))
     548            {
     549                FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
     550                texture->surfaces[j][i] = NULL;
     551                cubetexture_cleanup(texture);
     552                return hr;
     553            }
     554
     555            IWineD3DSurface_SetContainer(texture->surfaces[j][i], (IWineD3DBase *)texture);
     556            TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[j][i]);
     557            surface_set_texture_target(texture->surfaces[j][i], cube_targets[j]);
     558        }
     559        tmp_w = max(1, tmp_w >> 1);
     560    }
     561    texture->baseTexture.internal_preload = cubetexture_internal_preload;
     562
     563    return WINED3D_OK;
     564}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/device.c

    r22496 r23571  
    1010 * Copyright 2006-2008 Henri Verbeet
    1111 * Copyright 2007 Andrew Riedi
     12 * Copyright 2009 Henri Verbeet for CodeWeavers
    1213 *
    1314 * This library is free software; you can redistribute it and/or
     
    192193    unsigned int i;
    193194
    194     memset(stream_info, 0, sizeof(*stream_info));
     195    stream_info->use_map = 0;
     196    stream_info->swizzle_map = 0;
    195197
    196198    /* Check for transformed vertices, disable vertex shader if present. */
     
    306308            stream_info->elements[idx].buffer_object = buffer_object;
    307309
    308             if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && element->format_desc->format == WINED3DFMT_A8R8G8B8)
     310            if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM)
    309311            {
    310312                stream_info->swizzle_map |= 1 << idx;
     
    368370        if (!stream_info->elements[i].format_desc) continue;
    369371
    370         if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && stream_info->elements[i].format_desc->format == WINED3DFMT_A8R8G8B8)
     372        if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA)
     373                && stream_info->elements[i].format_desc->format == WINED3DFMT_B8G8R8A8_UNORM)
    371374        {
    372375            stream_info->swizzle_map |= 1 << i;
     
    450453}
    451454
    452 static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface,
    453         struct wined3d_buffer_desc *desc, const void *data, IUnknown *parent, IWineD3DBuffer **buffer)
     455static HRESULT WINAPI IWineD3DDeviceImpl_CreateBuffer(IWineD3DDevice *iface, struct wined3d_buffer_desc *desc,
     456        const void *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops, IWineD3DBuffer **buffer)
    454457{
    455458    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    456     const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info);
    457459    struct wined3d_buffer *object;
    458460    HRESULT hr;
     
    467469    }
    468470
    469     object->vtbl = &wined3d_buffer_vtbl;
    470     object->desc = *desc;
    471 
    472471    FIXME("Ignoring access flags (pool)\n");
    473472
    474     hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, desc->byte_width,
    475             desc->usage, format_desc, WINED3DPOOL_MANAGED, parent);
     473    hr = buffer_init(object, This, desc->byte_width, desc->usage, WINED3DFMT_UNKNOWN,
     474            WINED3DPOOL_MANAGED, GL_ARRAY_BUFFER_ARB, data, parent, parent_ops);
    476475    if (FAILED(hr))
    477476    {
    478         WARN("Failed to initialize resource, returning %#x\n", hr);
     477        WARN("Failed to initialize buffer, hr %#x.\n", hr);
    479478        HeapFree(GetProcessHeap(), 0, object);
    480479        return hr;
    481480    }
    482     object->buffer_type_hint = GL_ARRAY_BUFFER_ARB;
    483 
    484     TRACE("Created resource %p\n", object);
    485 
    486     TRACE("size %#x, usage=%#x, format %s, memory @ %p, iface @ %p\n", object->resource.size, object->resource.usage,
    487             debug_d3dformat(object->resource.format_desc->format), object->resource.allocatedMemory, object);
    488 
    489     if (data)
    490     {
    491         BYTE *ptr;
    492 
    493         hr = IWineD3DBuffer_Map((IWineD3DBuffer *)object, 0, desc->byte_width, &ptr, 0);
    494         if (FAILED(hr))
    495         {
    496             ERR("Failed to map buffer, hr %#x\n", hr);
    497             IWineD3DBuffer_Release((IWineD3DBuffer *)object);
    498             return hr;
    499         }
    500 
    501         memcpy(ptr, data, desc->byte_width);
    502 
    503         hr = IWineD3DBuffer_Unmap((IWineD3DBuffer *)object);
    504         if (FAILED(hr))
    505         {
    506             ERR("Failed to unmap buffer, hr %#x\n", hr);
    507             IWineD3DBuffer_Release((IWineD3DBuffer *)object);
    508             return hr;
    509         }
    510     }
     481    object->desc = *desc;
     482
     483    TRACE("Created buffer %p.\n", object);
    511484
    512485    *buffer = (IWineD3DBuffer *)object;
     
    515488}
    516489
    517 static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT Size, DWORD Usage,
    518         DWORD FVF, WINED3DPOOL Pool, IWineD3DBuffer **ppVertexBuffer, IUnknown *parent)
     490static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *iface, UINT Size,
     491        DWORD Usage, DWORD FVF, WINED3DPOOL Pool, IWineD3DBuffer **ppVertexBuffer,
     492        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    519493{
    520494    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    521     /* Dummy format for now */
    522     const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_VERTEXDATA, &This->adapter->gl_info);
    523495    struct wined3d_buffer *object;
    524496    int dxVersion = ( (IWineD3DImpl *) This->wineD3D)->dxVersion;
     
    526498    BOOL conv;
    527499
    528     if(Size == 0) {
    529         WARN("Size 0 requested, returning WINED3DERR_INVALIDCALL\n");
    530         *ppVertexBuffer = NULL;
    531         return WINED3DERR_INVALIDCALL;
    532     } else if(Pool == WINED3DPOOL_SCRATCH) {
     500    if (Pool == WINED3DPOOL_SCRATCH)
     501    {
    533502        /* The d3d9 testsuit shows that this is not allowed. It doesn't make much sense
    534503         * anyway, SCRATCH vertex buffers aren't usable anywhere
     
    547516    }
    548517
    549     object->vtbl = &wined3d_buffer_vtbl;
    550     hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, Size, Usage, format_desc, Pool, parent);
     518    hr = buffer_init(object, This, Size, Usage, WINED3DFMT_VERTEXDATA,
     519            Pool, GL_ARRAY_BUFFER_ARB, NULL, parent, parent_ops);
    551520    if (FAILED(hr))
    552521    {
    553         WARN("Failed to initialize resource, returning %#x\n", hr);
     522        WARN("Failed to initialize buffer, hr %#x.\n", hr);
    554523        HeapFree(GetProcessHeap(), 0, object);
    555         *ppVertexBuffer = NULL;
    556524        return hr;
    557525    }
    558     object->buffer_type_hint = GL_ARRAY_BUFFER_ARB;
    559 
    560     TRACE("(%p) : Created resource %p\n", This, object);
    561 
    562     TRACE("(%p) : Size=%d, Usage=0x%08x, FVF=%x, Pool=%d - Memory@%p, Iface@%p\n", This, Size, Usage, FVF, Pool, object->resource.allocatedMemory, object);
     526
     527    TRACE("Created buffer %p.\n", object);
     528    TRACE("FVF %#x, Pool %#x.\n", FVF, Pool);
    563529    *ppVertexBuffer = (IWineD3DBuffer *)object;
    564530
     
    594560
    595561static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface,
    596         UINT Length, DWORD Usage, WINED3DPOOL Pool, IWineD3DBuffer **ppIndexBuffer, IUnknown *parent)
     562        UINT Length, DWORD Usage, WINED3DPOOL Pool, IWineD3DBuffer **ppIndexBuffer,
     563        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    597564{
    598565    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    599     const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info);
    600566    struct wined3d_buffer *object;
    601567    HRESULT hr;
     
    612578    }
    613579
    614     object->vtbl = &wined3d_buffer_vtbl;
    615     hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_BUFFER, This, Length, Usage, format_desc, Pool, parent);
     580    hr = buffer_init(object, This, Length, Usage, WINED3DFMT_UNKNOWN,
     581            Pool, GL_ELEMENT_ARRAY_BUFFER_ARB, NULL, parent, parent_ops);
    616582    if (FAILED(hr))
    617583    {
    618         WARN("Failed to initialize resource, returning %#x\n", hr);
     584        WARN("Failed to initialize buffer, hr %#x\n", hr);
    619585        HeapFree(GetProcessHeap(), 0, object);
    620         *ppIndexBuffer = NULL;
    621586        return hr;
    622587    }
    623     object->buffer_type_hint = GL_ELEMENT_ARRAY_BUFFER_ARB;
    624 
    625     TRACE("(%p) : Created resource %p\n", This, object);
     588
     589    TRACE("Created buffer %p.\n", object);
    626590
    627591    if(Pool != WINED3DPOOL_SYSTEMMEM && !(Usage & WINED3DUSAGE_DYNAMIC) && GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) {
     
    629593    }
    630594
    631     TRACE("(%p) : Len=%d, Use=%x, Pool=%d - Memory@%p, Iface@%p\n", This, Length, Usage,
    632             Pool, object, object->resource.allocatedMemory);
    633595    *ppIndexBuffer = (IWineD3DBuffer *) object;
    634596
     
    909871        WINED3DFORMAT Format, BOOL Lockable, BOOL Discard, UINT Level, IWineD3DSurface **ppSurface,
    910872        DWORD Usage, WINED3DPOOL Pool, WINED3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality,
    911         WINED3DSURFTYPE Impl, IUnknown *parent)
     873        WINED3DSURFTYPE Impl, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    912874{
    913875    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     
    932894
    933895    hr = surface_init(object, Impl, This->surface_alignment, Width, Height, Level, Lockable,
    934             Discard, MultiSample, MultisampleQuality, This, Usage, Format, Pool, parent);
     896            Discard, MultiSample, MultisampleQuality, This, Usage, Format, Pool, parent, parent_ops);
    935897    if (FAILED(hr))
    936898    {
     
    972934
    973935static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface,
    974         UINT Width, UINT Height, UINT Levels, DWORD Usage, WINED3DFORMAT Format,
    975         WINED3DPOOL Pool, IWineD3DTexture **ppTexture, IUnknown *parent)
     936        UINT Width, UINT Height, UINT Levels, DWORD Usage, WINED3DFORMAT Format, WINED3DPOOL Pool,
     937        IWineD3DTexture **ppTexture, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    976938{
    977939    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     
    991953    }
    992954
    993     object->lpVtbl = &IWineD3DTexture_Vtbl;
    994 
    995     hr = texture_init(object, Width, Height, Levels, This, Usage, Format, Pool, parent);
     955    hr = texture_init(object, Width, Height, Levels, This, Usage, Format, Pool, parent, parent_ops);
    996956    if (FAILED(hr))
    997957    {
     
    1010970
    1011971static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *iface,
    1012         UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, WINED3DFORMAT Format,
    1013         WINED3DPOOL Pool, IWineD3DVolumeTexture **ppVolumeTexture, IUnknown *parent)
     972        UINT Width, UINT Height, UINT Depth, UINT Levels, DWORD Usage, WINED3DFORMAT Format, WINED3DPOOL Pool,
     973        IWineD3DVolumeTexture **ppVolumeTexture, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    1014974{
    1015975    IWineD3DDeviceImpl        *This = (IWineD3DDeviceImpl *)iface;
     
    1028988    }
    1029989
    1030     object->lpVtbl = &IWineD3DVolumeTexture_Vtbl;
    1031     hr = volumetexture_init(object, Width, Height, Depth, Levels, This, Usage, Format, Pool, parent);
     990    hr = volumetexture_init(object, Width, Height, Depth, Levels, This, Usage, Format, Pool, parent, parent_ops);
    1032991    if (FAILED(hr))
    1033992    {
     
    10441003}
    10451004
    1046 static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface,
    1047         UINT Width, UINT Height, UINT Depth, DWORD Usage, WINED3DFORMAT Format,
    1048         WINED3DPOOL Pool, IWineD3DVolume **ppVolume, IUnknown *parent)
     1005static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolume(IWineD3DDevice *iface, UINT Width, UINT Height,
     1006        UINT Depth, DWORD Usage, WINED3DFORMAT Format, WINED3DPOOL Pool, IWineD3DVolume **ppVolume,
     1007        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    10491008{
    1050     IWineD3DDeviceImpl        *This = (IWineD3DDeviceImpl *)iface;
    1051     IWineD3DVolumeImpl        *object; /** NOTE: impl ref allowed since this is a create function **/
    1052     const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(Format, &GLINFO_LOCATION);
     1009    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     1010    IWineD3DVolumeImpl *object;
    10531011    HRESULT hr;
    10541012
    1055     if(!GL_SUPPORT(EXT_TEXTURE3D)) {
    1056         WARN("(%p) : Volume cannot be created - no volume texture support\n", This);
    1057         return WINED3DERR_INVALIDCALL;
    1058     }
     1013    TRACE("(%p) : W(%d) H(%d) D(%d), Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
     1014          Depth, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
    10591015
    10601016    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
     
    10661022    }
    10671023
    1068     object->lpVtbl = &IWineD3DVolume_Vtbl;
    1069     hr = resource_init((IWineD3DResource *)object, WINED3DRTYPE_VOLUME, This,
    1070             Width * Height * Depth * format_desc->byte_count, Usage, format_desc, Pool, parent);
     1024    hr = volume_init(object, This, Width, Height, Depth, Usage, Format, Pool, parent, parent_ops);
    10711025    if (FAILED(hr))
    10721026    {
    1073         WARN("Failed to initialize resource, returning %#x\n", hr);
     1027        WARN("Failed to initialize volume, returning %#x.\n", hr);
    10741028        HeapFree(GetProcessHeap(), 0, object);
    1075         *ppVolume = NULL;
    10761029        return hr;
    10771030    }
    10781031
    1079     TRACE("(%p) : Created resource %p\n", This, object);
    1080 
     1032    TRACE("(%p) : Created volume %p.\n", This, object);
    10811033    *ppVolume = (IWineD3DVolume *)object;
    10821034
    1083     TRACE("(%p) : W(%d) H(%d) D(%d), Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
    1084           Depth, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
    1085 
    1086     object->currentDesc.Width   = Width;
    1087     object->currentDesc.Height  = Height;
    1088     object->currentDesc.Depth   = Depth;
    1089 
    1090     /** Note: Volume textures cannot be dxtn, hence no need to check here **/
    1091     object->lockable            = TRUE;
    1092     object->locked              = FALSE;
    1093     memset(&object->lockedBox, 0, sizeof(WINED3DBOX));
    1094     object->dirty               = TRUE;
    1095 
    1096     volume_add_dirty_box((IWineD3DVolume *)object, NULL);
    1097 
    1098     return WINED3D_OK;
    1099 }
    1100 
    1101 static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface,
    1102         UINT EdgeLength, UINT Levels, DWORD Usage, WINED3DFORMAT Format,
    1103         WINED3DPOOL Pool, IWineD3DCubeTexture **ppCubeTexture, IUnknown *parent)
     1035    return WINED3D_OK;
     1036}
     1037
     1038static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface, UINT EdgeLength, UINT Levels,
     1039        DWORD Usage, WINED3DFORMAT Format, WINED3DPOOL Pool, IWineD3DCubeTexture **ppCubeTexture,
     1040        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    11041041{
    11051042    IWineD3DDeviceImpl      *This = (IWineD3DDeviceImpl *)iface;
     
    11151052    }
    11161053
    1117     object->lpVtbl = &IWineD3DCubeTexture_Vtbl;
    1118     hr = cubetexture_init(object, EdgeLength, Levels, This, Usage, Format, Pool, parent);
     1054    hr = cubetexture_init(object, EdgeLength, Levels, This, Usage, Format, Pool, parent, parent_ops);
    11191055    if (FAILED(hr))
    11201056    {
     
    13511287    IWineD3DSwapChainImpl  *object; /** NOTE: impl ref allowed since this is a create function **/
    13521288    HRESULT                 hr;
    1353     IUnknown               *bufferParent;
    13541289    BOOL                    displaymode_set = FALSE;
    13551290    WINED3DDISPLAYMODE      Mode;
     
    16121547        UINT i;
    16131548        for(i = 0; i < object->presentParms.BackBufferCount; i++) {
    1614             if(object->backBuffer[i]) {
    1615                 IWineD3DSurface_GetParent(object->backBuffer[i], &bufferParent);
    1616                 IUnknown_Release(bufferParent); /* once for the get parent */
    1617                 if (IUnknown_Release(bufferParent) > 0) {
    1618                     FIXME("(%p) Something's still holding the back buffer\n",This);
    1619                 }
    1620             }
     1549            if (object->backBuffer[i]) IWineD3DSurface_Release(object->backBuffer[i]);
    16211550        }
    16221551        HeapFree(GetProcessHeap(), 0, object->backBuffer);
     
    16251554    if(object->context && object->context[0])
    16261555        DestroyContext(This, object->context[0]);
    1627     if(object->frontBuffer) {
    1628         IWineD3DSurface_GetParent(object->frontBuffer, &bufferParent);
    1629         IUnknown_Release(bufferParent); /* once for the get parent */
    1630         if (IUnknown_Release(bufferParent) > 0) {
    1631             FIXME("(%p) Something's still holding the front buffer\n",This);
    1632         }
    1633     }
     1556    if (object->frontBuffer) IWineD3DSurface_Release(object->frontBuffer);
    16341557    HeapFree(GetProcessHeap(), 0, object);
    16351558    return hr;
     
    16601583}
    16611584
    1662 /*****
    1663  * Vertex Declaration
    1664  *****/
    1665 static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppVertexDeclaration,
    1666         IUnknown *parent, const WINED3DVERTEXELEMENT *elements, UINT element_count) {
    1667     IWineD3DDeviceImpl            *This   = (IWineD3DDeviceImpl *)iface;
     1585static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclaration(IWineD3DDevice *iface,
     1586        IWineD3DVertexDeclaration **declaration, IUnknown *parent, const struct wined3d_parent_ops *parent_ops,
     1587        const WINED3DVERTEXELEMENT *elements, UINT element_count)
     1588{
     1589    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    16681590    IWineD3DVertexDeclarationImpl *object = NULL;
    1669     HRESULT hr = WINED3D_OK;
    1670 
    1671     TRACE("(%p) : directXVersion %u, elements %p, element_count %d, ppDecl=%p\n",
    1672             This, ((IWineD3DImpl *)This->wineD3D)->dxVersion, elements, element_count, ppVertexDeclaration);
     1591    HRESULT hr;
     1592
     1593    TRACE("iface %p, declaration %p, parent %p, elements %p, element_count %u.\n",
     1594            iface, declaration, parent, elements, element_count);
    16731595
    16741596    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
    16751597    if(!object)
    16761598    {
    1677         ERR("Out of memory\n");
    1678         *ppVertexDeclaration = NULL;
    1679         return WINED3DERR_OUTOFVIDEOMEMORY;
    1680     }
    1681 
    1682     object->lpVtbl = &IWineD3DVertexDeclaration_Vtbl;
    1683     object->wineD3DDevice = This;
    1684     object->parent = parent;
    1685     object->ref = 1;
    1686 
    1687     *ppVertexDeclaration = (IWineD3DVertexDeclaration *)object;
    1688 
    1689     hr = vertexdeclaration_init(object, elements, element_count);
    1690 
    1691     if(FAILED(hr)) {
    1692         IWineD3DVertexDeclaration_Release((IWineD3DVertexDeclaration *)object);
    1693         *ppVertexDeclaration = NULL;
    1694     }
    1695 
    1696     return hr;
     1599        ERR("Failed to allocate vertex declaration memory.\n");
     1600        return E_OUTOFMEMORY;
     1601    }
     1602
     1603    hr = vertexdeclaration_init(object, This, elements, element_count, parent, parent_ops);
     1604    if (FAILED(hr))
     1605    {
     1606        WARN("Failed to initialize vertex declaration, hr %#x.\n", hr);
     1607        HeapFree(GetProcessHeap(), 0, object);
     1608        return hr;
     1609    }
     1610
     1611    TRACE("Created verrtex declaration %p.\n", object);
     1612    *declaration = (IWineD3DVertexDeclaration *)object;
     1613
     1614    return WINED3D_OK;
    16971615}
    16981616
     
    17481666    if (has_blend && (num_blends > 0)) {
    17491667        if (((fvf & WINED3DFVF_XYZB5) == WINED3DFVF_XYZB2) && (fvf & WINED3DFVF_LASTBETA_D3DCOLOR))
    1750             elements[idx].format = WINED3DFMT_A8R8G8B8;
     1668            elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
    17511669        else {
    17521670            switch(num_blends) {
     
    17681686            elements[idx].format = WINED3DFMT_R8G8B8A8_UINT;
    17691687        else if (fvf & WINED3DFVF_LASTBETA_D3DCOLOR)
    1770             elements[idx].format = WINED3DFMT_A8R8G8B8;
     1688            elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
    17711689        else
    17721690            elements[idx].format = WINED3DFMT_R32_FLOAT;
     
    17881706    }
    17891707    if (has_diffuse) {
    1790         elements[idx].format = WINED3DFMT_A8R8G8B8;
     1708        elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
    17911709        elements[idx].usage = WINED3DDECLUSAGE_COLOR;
    17921710        elements[idx].usage_idx = 0;
     
    17941712    }
    17951713    if (has_specular) {
    1796         elements[idx].format = WINED3DFMT_A8R8G8B8;
     1714        elements[idx].format = WINED3DFMT_B8G8R8A8_UNORM;
    17971715        elements[idx].usage = WINED3DDECLUSAGE_COLOR;
    17981716        elements[idx].usage_idx = 1;
     
    18341752}
    18351753
    1836 static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3DDevice* iface, IWineD3DVertexDeclaration** ppVertexDeclaration, IUnknown *Parent, DWORD Fvf) {
    1837     WINED3DVERTEXELEMENT* elements = NULL;
     1754static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexDeclarationFromFVF(IWineD3DDevice *iface,
     1755        IWineD3DVertexDeclaration **declaration, IUnknown *parent,
     1756        const struct wined3d_parent_ops *parent_ops, DWORD fvf)
     1757{
    18381758    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     1759    WINED3DVERTEXELEMENT *elements;
    18391760    unsigned int size;
    18401761    DWORD hr;
    18411762
    1842     size = ConvertFvfToDeclaration(This, Fvf, &elements);
    1843     if (size == ~0U) return WINED3DERR_OUTOFVIDEOMEMORY;
    1844 
    1845     hr = IWineD3DDevice_CreateVertexDeclaration(iface, ppVertexDeclaration, Parent, elements, size);
     1763    TRACE("iface %p, declaration %p, parent %p, fvf %#x.\n", iface, declaration, parent, fvf);
     1764
     1765    size = ConvertFvfToDeclaration(This, fvf, &elements);
     1766    if (size == ~0U) return E_OUTOFMEMORY;
     1767
     1768    hr = IWineD3DDevice_CreateVertexDeclaration(iface, declaration, parent, parent_ops, elements, size);
    18461769    HeapFree(GetProcessHeap(), 0, elements);
    1847     if (hr != S_OK) return hr;
    1848 
    1849     return WINED3D_OK;
     1770    return hr;
    18501771}
    18511772
    18521773static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *iface,
    18531774        const DWORD *pFunction, const struct wined3d_shader_signature *output_signature,
    1854         IWineD3DVertexShader **ppVertexShader, IUnknown *parent)
     1775        IWineD3DVertexShader **ppVertexShader, IUnknown *parent,
     1776        const struct wined3d_parent_ops *parent_ops)
    18551777{
    1856     IWineD3DDeviceImpl       *This = (IWineD3DDeviceImpl *)iface;
    1857     IWineD3DVertexShaderImpl *object;  /* NOTE: impl usage is ok, this is a create */
    1858     HRESULT hr = WINED3D_OK;
    1859 
    1860     if (!pFunction) return WINED3DERR_INVALIDCALL;
     1778    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     1779    IWineD3DVertexShaderImpl *object;
     1780    HRESULT hr;
    18611781
    18621782    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
    18631783    if (!object)
    18641784    {
    1865         ERR("Out of memory\n");
    1866         *ppVertexShader = NULL;
    1867         return WINED3DERR_OUTOFVIDEOMEMORY;
    1868     }
    1869 
    1870     object->lpVtbl = &IWineD3DVertexShader_Vtbl;
    1871     object->parent = parent;
    1872     shader_init(&object->baseShader, iface);
    1873     list_add_head(&This->shaders, &object->baseShader.shader_list_entry);
    1874     *ppVertexShader = (IWineD3DVertexShader *)object;
    1875 
    1876     TRACE("(%p) : Created vertex shader %p\n", This, *ppVertexShader);
    1877 
    1878     hr = IWineD3DVertexShader_SetFunction(*ppVertexShader, pFunction, output_signature);
     1785        ERR("Failed to allocate shader memory.\n");
     1786        return E_OUTOFMEMORY;
     1787    }
     1788
     1789    hr = vertexshader_init(object, This, pFunction, output_signature, parent, parent_ops);
    18791790    if (FAILED(hr))
    18801791    {
    1881         WARN("(%p) : Failed to set function, returning %#x\n", iface, hr);
    1882         IWineD3DVertexShader_Release(*ppVertexShader);
    1883         *ppVertexShader = NULL;
     1792        WARN("Failed to initialize vertex shader, hr %#x.\n", hr);
     1793        HeapFree(GetProcessHeap(), 0, object);
    18841794        return hr;
    18851795    }
    18861796
    1887     return hr;
     1797    TRACE("Created vertex shader %p.\n", object);
     1798    *ppVertexShader = (IWineD3DVertexShader *)object;
     1799
     1800    return WINED3D_OK;
    18881801}
    18891802
    18901803static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface,
    18911804        const DWORD *pFunction, const struct wined3d_shader_signature *output_signature,
    1892         IWineD3DPixelShader **ppPixelShader, IUnknown *parent)
     1805        IWineD3DPixelShader **ppPixelShader, IUnknown *parent,
     1806        const struct wined3d_parent_ops *parent_ops)
    18931807{
    18941808    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    1895     IWineD3DPixelShaderImpl *object; /* NOTE: impl allowed, this is a create */
    1896     HRESULT hr = WINED3D_OK;
    1897 
    1898     if (!pFunction) return WINED3DERR_INVALIDCALL;
     1809    IWineD3DPixelShaderImpl *object;
     1810    HRESULT hr;
    18991811
    19001812    object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
    19011813    if (!object)
    19021814    {
    1903         ERR("Out of memory\n");
    1904         *ppPixelShader = NULL;
    1905         return WINED3DERR_OUTOFVIDEOMEMORY;
    1906     }
    1907 
    1908     object->lpVtbl = &IWineD3DPixelShader_Vtbl;
    1909     object->parent = parent;
    1910     shader_init(&object->baseShader, iface);
    1911     list_add_head(&This->shaders, &object->baseShader.shader_list_entry);
    1912     *ppPixelShader = (IWineD3DPixelShader *)object;
    1913 
    1914     TRACE("(%p) : Created pixel shader %p\n", This, *ppPixelShader);
    1915 
    1916     hr = IWineD3DPixelShader_SetFunction(*ppPixelShader, pFunction, output_signature);
     1815        ERR("Failed to allocate shader memory.\n");
     1816        return E_OUTOFMEMORY;
     1817    }
     1818
     1819    hr = pixelshader_init(object, This, pFunction, output_signature, parent, parent_ops);
    19171820    if (FAILED(hr))
    19181821    {
    1919         WARN("(%p) : Failed to set function, returning %#x\n", iface, hr);
    1920         IWineD3DPixelShader_Release(*ppPixelShader);
    1921         *ppPixelShader = NULL;
     1822        WARN("Failed to initialize pixel shader, hr %#x.\n", hr);
     1823        HeapFree(GetProcessHeap(), 0, object);
    19221824        return hr;
    19231825    }
    19241826
    1925     return hr;
     1827    TRACE("Created pixel shader %p.\n", object);
     1828    *ppPixelShader = (IWineD3DPixelShader *)object;
     1829
     1830    return WINED3D_OK;
    19261831}
    19271832
     
    19901895    }
    19911896
    1992     hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *) This, bm.bmWidth, bm.bmHeight, WINED3DFMT_R5G6B5, TRUE,
    1993             FALSE, 0, &This->logo_surface, 0, WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL, NULL);
     1897    hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *)This, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
     1898            FALSE, 0, &This->logo_surface, 0, WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL,
     1899            NULL, &wined3d_null_parent_ops);
    19941900    if(FAILED(hr)) {
    19951901        ERR("Wine logo requested, but failed to create surface\n");
     
    21232029            This->rev_tex_unit_map[state] = state;
    21242030        } else {
    2125             This->texUnitMap[state] = -1;
    2126             This->rev_tex_unit_map[state] = -1;
     2031            This->texUnitMap[state] = WINED3D_UNMAPPED_STAGE;
     2032            This->rev_tex_unit_map[state] = WINED3D_UNMAPPED_STAGE;
    21272033        }
    21282034    }
     
    22952201}
    22962202
    2297 static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyDepthStencilSurface, D3DCB_DESTROYSWAPCHAINFN D3DCB_DestroySwapChain) {
     2203static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
     2204        D3DCB_DESTROYSWAPCHAINFN D3DCB_DestroySwapChain)
     2205{
    22982206    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     2207    const struct wined3d_context *context;
     2208    const struct wined3d_gl_info *gl_info;
    22992209    int sampler;
    23002210    UINT i;
     
    23062216     * it was created. Thus make sure a context is active for the glDelete* calls
    23072217     */
    2308     ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
     2218    context = ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
     2219    gl_info = context->gl_info;
    23092220
    23102221    if(This->logo_surface) IWineD3DSurface_Release(This->logo_surface);
     
    23602271    if (This->depth_blt_rb) {
    23612272        ENTER_GL();
    2362         GL_EXTCALL(glDeleteRenderbuffersEXT(1, &This->depth_blt_rb));
     2273        gl_info->fbo_ops.glDeleteRenderbuffers(1, &This->depth_blt_rb);
    23632274        LEAVE_GL();
    23642275        This->depth_blt_rb = 0;
     
    24072318
    24082319    if (This->auto_depth_stencil_buffer) {
    2409         if(D3DCB_DestroyDepthStencilSurface(This->auto_depth_stencil_buffer) > 0) {
     2320        if (IWineD3DSurface_Release(This->auto_depth_stencil_buffer) > 0)
     2321        {
    24102322            FIXME("(%p) Something's still holding the auto depth stencil buffer\n", This);
    24112323        }
     
    31633075 * Get / Set Indices
    31643076 *****/
    3165 static HRESULT WINAPI IWineD3DDeviceImpl_SetIndices(IWineD3DDevice *iface, IWineD3DBuffer* pIndexData, WINED3DFORMAT fmt) {
    3166     IWineD3DDeviceImpl  *This = (IWineD3DDeviceImpl *)iface;
     3077static HRESULT WINAPI IWineD3DDeviceImpl_SetIndexBuffer(IWineD3DDevice *iface,
     3078        IWineD3DBuffer *pIndexData, WINED3DFORMAT fmt)
     3079{
     3080    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    31673081    IWineD3DBuffer *oldIdxs;
    31683082
     
    31973111}
    31983112
    3199 static HRESULT WINAPI IWineD3DDeviceImpl_GetIndices(IWineD3DDevice *iface, IWineD3DBuffer** ppIndexData) {
     3113static HRESULT WINAPI IWineD3DDeviceImpl_GetIndexBuffer(IWineD3DDevice *iface, IWineD3DBuffer **ppIndexData)
     3114{
    32003115    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    32013116
     
    36453560}
    36463561
    3647 static void device_map_stage(IWineD3DDeviceImpl *This, int stage, int unit) {
    3648     int i = This->rev_tex_unit_map[unit];
    3649     int j = This->texUnitMap[stage];
     3562static void device_map_stage(IWineD3DDeviceImpl *This, DWORD stage, DWORD unit)
     3563{
     3564    DWORD i = This->rev_tex_unit_map[unit];
     3565    DWORD j = This->texUnitMap[stage];
    36503566
    36513567    This->texUnitMap[stage] = unit;
    3652     if (i != -1 && i != stage) {
    3653         This->texUnitMap[i] = -1;
     3568    if (i != WINED3D_UNMAPPED_STAGE && i != stage)
     3569    {
     3570        This->texUnitMap[i] = WINED3D_UNMAPPED_STAGE;
    36543571    }
    36553572
    36563573    This->rev_tex_unit_map[unit] = stage;
    3657     if (j != -1 && j != unit) {
    3658         This->rev_tex_unit_map[j] = -1;
     3574    if (j != WINED3D_UNMAPPED_STAGE && j != unit)
     3575    {
     3576        This->rev_tex_unit_map[j] = WINED3D_UNMAPPED_STAGE;
    36593577    }
    36603578}
     
    37503668
    37513669static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshader_sampler_tokens,
    3752         const DWORD *vshader_sampler_tokens, int unit)
     3670        const DWORD *vshader_sampler_tokens, DWORD unit)
    37533671{
    3754     int current_mapping = This->rev_tex_unit_map[unit];
    3755 
    3756     if (current_mapping == -1) {
    3757         /* Not currently used */
    3758         return TRUE;
    3759     }
     3672    DWORD current_mapping = This->rev_tex_unit_map[unit];
     3673
     3674    /* Not currently used */
     3675    if (current_mapping == WINED3D_UNMAPPED_STAGE) return TRUE;
    37603676
    37613677    if (current_mapping < MAX_FRAGMENT_SAMPLERS) {
     
    37723688
    37733689    /* Used by a vertex sampler */
    3774     return !vshader_sampler_tokens[current_mapping];
     3690    return !vshader_sampler_tokens[current_mapping - MAX_FRAGMENT_SAMPLERS];
    37753691}
    37763692
     
    37793695            ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.sampler_type;
    37803696    const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_type = NULL;
    3781     int start = GL_LIMITS(combined_samplers) - 1;
     3697    int start = min(MAX_COMBINED_SAMPLERS, GL_LIMITS(combined_samplers)) - 1;
    37823698    int i;
    37833699
     
    37913707
    37923708    for (i = 0; i < MAX_VERTEX_SAMPLERS; ++i) {
    3793         int vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
     3709        DWORD vsampler_idx = i + MAX_FRAGMENT_SAMPLERS;
    37943710        if (vshader_sampler_type[i])
    37953711        {
     
    40453961    DWORD numTextures;
    40463962
    4047     if (stream_info->elements[WINED3D_FFP_NORMAL].data)
     3963    if (stream_info->use_map & (1 << WINED3D_FFP_NORMAL))
    40483964    {
    40493965        WARN(" lighting state not saved yet... Some strange stuff may happen !\n");
    40503966    }
    40513967
    4052     if (!stream_info->elements[WINED3D_FFP_POSITION].data)
     3968    if (!(stream_info->use_map & (1 << WINED3D_FFP_POSITION)))
    40533969    {
    40543970        ERR("Source has no position mask\n");
     
    41864102            if( !doClip ||
    41874103                ( (-rhw -eps < x) && (-rhw -eps < y) && ( -eps < z) &&
    4188                   (x <= rhw + eps) && (y <= rhw + eps ) && (z <= rhw + eps) && 
     4104                  (x <= rhw + eps) && (y <= rhw + eps ) && (z <= rhw + eps) &&
    41894105                  ( rhw > eps ) ) ) {
    41904106
     
    42834199            const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_DIFFUSE];
    42844200            const DWORD *color_d = (const DWORD *)(element->data + i * element->stride);
    4285             if(!color_d) {
     4201            if (!(stream_info->use_map & (1 << WINED3D_FFP_DIFFUSE)))
     4202            {
    42864203                static BOOL warned = FALSE;
    42874204
     
    43104227        }
    43114228
    4312         if (DestFVF & WINED3DFVF_SPECULAR) {
     4229        if (DestFVF & WINED3DFVF_SPECULAR)
     4230        {
    43134231            /* What's the color value in the feedback buffer? */
    43144232            const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_SPECULAR];
    43154233            const DWORD *color_s = (const DWORD *)(element->data + i * element->stride);
    4316             if(!color_s) {
     4234            if (!(stream_info->use_map & (1 << WINED3D_FFP_SPECULAR)))
     4235            {
    43174236                static BOOL warned = FALSE;
    43184237
     
    43444263            const struct wined3d_stream_info_element *element = &stream_info->elements[WINED3D_FFP_TEXCOORD0 + tex_index];
    43454264            const float *tex_coord = (const float *)(element->data + i * element->stride);
    4346             if(!tex_coord) {
     4265            if (!(stream_info->use_map & (1 << (WINED3D_FFP_TEXCOORD0 + tex_index))))
     4266            {
    43474267                ERR("No source texture, but destination requests one\n");
    43484268                dest_ptr+=GET_TEXCOORD_SIZE_FROM_FVF(DestFVF, tex_index) * sizeof(float);
     
    44064326        for (i = 0; i < (sizeof(stream_info.elements) / sizeof(*stream_info.elements)); ++i)
    44074327        {
    4408             struct wined3d_stream_info_element *e = &stream_info.elements[i];
     4328            struct wined3d_stream_info_element *e;
     4329
     4330            if (!(stream_info.use_map & (1 << i))) continue;
     4331
     4332            e = &stream_info.elements[i];
    44094333            if (e->buffer_object)
    44104334            {
     
    48564780    ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
    48574781    /* We only have to do this if we need to read the, swapbuffers performs a flush for us */
    4858     glFlush();
     4782    wglFlush();
    48594783    /* No checkGLcall here to avoid locking the lock just for checking a call that hardly ever
    48604784     * fails
     
    50694993    if (SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface *)target, &IID_IWineD3DSwapChain, (void **)&swapchain))) {
    50704994        if (target == (IWineD3DSurfaceImpl*) swapchain->frontBuffer) {
    5071             glFlush();
     4995            wglFlush();
    50724996        }
    50734997        IWineD3DSwapChain_Release((IWineD3DSwapChain *) swapchain);
     
    51435067    }
    51445068    /* Account for the loading offset due to index buffers. Instead of reloading all sources correct it with the startvertex parameter */
    5145     drawPrimitive(iface, vertex_count, 0/* NumVertices */, StartVertex /* start_idx */,
    5146                   0 /* indxSize */, NULL /* indxData */, 0 /* minIndex */);
    5147     return WINED3D_OK;
    5148 }
    5149 
    5150 static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface,
    5151         UINT minIndex, UINT NumVertices, UINT startIndex, UINT index_count)
     5069    drawPrimitive(iface, vertex_count, StartVertex /* start_idx */, 0 /* indxSize */, NULL /* indxData */);
     5070    return WINED3D_OK;
     5071}
     5072
     5073static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitive(IWineD3DDevice *iface, UINT startIndex, UINT index_count)
    51525074{
    51535075    IWineD3DDeviceImpl  *This = (IWineD3DDeviceImpl *)iface;
     
    51775099    vbo = ((struct wined3d_buffer *) pIB)->buffer_object;
    51785100
    5179     TRACE("(%p) : min %u, vertex count %u, startIdx %u, index count %u\n",
    5180             This, minIndex, NumVertices, startIndex, index_count);
     5101    TRACE("(%p) : startIndex %u, index count %u.\n", This, startIndex, index_count);
    51815102
    51825103    if (This->stateBlock->IndexFmt == WINED3DFMT_R16_UINT) {
     
    51915112    }
    51925113
    5193     drawPrimitive(iface, index_count, NumVertices, startIndex, idxStride,
    5194             vbo ? NULL : ((struct wined3d_buffer *) pIB)->resource.allocatedMemory, minIndex);
     5114    drawPrimitive(iface, index_count, startIndex, idxStride,
     5115            vbo ? NULL : ((struct wined3d_buffer *)pIB)->resource.allocatedMemory);
    51955116
    51965117    return WINED3D_OK;
     
    52235144    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_STREAMSRC);
    52245145
    5225     drawPrimitive(iface, vertex_count, 0 /* NumVertices */, 0 /* start_idx */,
    5226             0 /* indxSize*/, NULL /* indxData */, 0 /* indxMin */);
     5146    drawPrimitive(iface, vertex_count, 0 /* start_idx */, 0 /* indxSize*/, NULL /* indxData */);
    52275147
    52285148    /* MSDN specifies stream zero settings must be set to NULL */
     
    52365156}
    52375157
    5238 static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface, UINT MinVertexIndex,
    5239         UINT NumVertices, UINT index_count, const void *pIndexData, WINED3DFORMAT IndexDataFormat,
     5158static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *iface,
     5159        UINT index_count, const void *pIndexData, WINED3DFORMAT IndexDataFormat,
    52405160        const void *pVertexStreamZeroData, UINT VertexStreamZeroStride)
    52415161{
     
    52455165    IWineD3DBuffer *ib;
    52465166
    5247     TRACE("(%p) : MinVtxIdx %u, NumVIdx %u, index count %u, pidxdata %p, IdxFmt %u, pVtxdata %p, stride=%u\n",
    5248             This, MinVertexIndex, NumVertices, index_count, pIndexData,
    5249             IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
     5167    TRACE("(%p) : index count %u, pidxdata %p, IdxFmt %u, pVtxdata %p, stride=%u.\n",
     5168            This, index_count, pIndexData, IndexDataFormat, pVertexStreamZeroData, VertexStreamZeroStride);
    52505169
    52515170    if(!This->stateBlock->vertexDecl) {
     
    52755194    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_INDEXBUFFER);
    52765195
    5277     drawPrimitive(iface, index_count, NumVertices, 0 /* start_idx */,
    5278             idxStride, pIndexData, MinVertexIndex);
     5196    drawPrimitive(iface, index_count, 0 /* start_idx */, idxStride, pIndexData);
    52795197
    52805198    /* MSDN specifies stream zero settings and index buffer must be set to NULL */
     
    53065224    This->stateBlock->baseVertexIndex = 0;
    53075225    This->up_strided = DrawPrimStrideData;
    5308     drawPrimitive(iface, vertex_count, 0, 0, 0, NULL, 0);
     5226    drawPrimitive(iface, vertex_count, 0, 0, NULL);
    53095227    This->up_strided = NULL;
    53105228    return WINED3D_OK;
     
    53275245    This->stateBlock->baseVertexIndex = 0;
    53285246    This->up_strided = DrawPrimStrideData;
    5329     drawPrimitive(iface, vertex_count, 0 /* numindices */, 0 /* start_idx */, idxSize, pIndexData, 0 /* minindex */);
     5247    drawPrimitive(iface, 0 /* numindices */, 0 /* start_idx */, idxSize, pIndexData);
    53305248    This->up_strided = NULL;
    53315249    return WINED3D_OK;
     
    55505468    int i;
    55515469
    5552     for (i = 0; i < MAX_COMBINED_SAMPLERS; i++) {
    5553             IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl*)device->stateBlock->textures[i];
    5554             if (texture && (texture->resource.format_desc->format == WINED3DFMT_P8
    5555                     || texture->resource.format_desc->format == WINED3DFMT_A8P8))
    5556             {
    5557                 IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(i));
    5558             }
    5559         }
     5470    for (i = 0; i < MAX_COMBINED_SAMPLERS; ++i)
     5471    {
     5472        IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl*)device->stateBlock->textures[i];
     5473        if (texture && (texture->resource.format_desc->format == WINED3DFMT_P8_UINT
     5474                || texture->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM))
     5475        {
     5476            IWineD3DDeviceImpl_MarkStateDirty(device, STATE_SAMPLER(i));
     5477        }
     5478    }
    55605479}
    55615480
     
    57415660    const struct GlPixelFormatDesc *src_format_desc, *dst_format_desc;
    57425661    GLenum dummy;
    5743     int sampler;
     5662    DWORD sampler;
    57445663    int bpp;
    57455664    CONVERT_TYPES convert = NO_CONVERSION;
     
    58815800    IWineD3DSurface_ModifyLocation(pDestinationSurface, SFLAG_INTEXTURE, TRUE);
    58825801    sampler = This->rev_tex_unit_map[0];
    5883     if (sampler != -1) {
     5802    if (sampler != WINED3D_UNMAPPED_STAGE)
     5803    {
    58845804        IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
    58855805    }
     
    60345954        context = ActivateContext(This, surface, CTXUSAGE_RESOURCELOAD);
    60355955        ENTER_GL();
    6036         context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL);
     5956        context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
    60375957        buffer = surface_get_gl_buffer(surface, swapchain);
    60385958        glDrawBuffer(buffer);
     
    60435963        context = ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
    60445964        ENTER_GL();
    6045         context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->dst_fbo);
    6046         context_attach_surface_fbo(context, GL_FRAMEBUFFER_EXT, 0, surface);
    6047         context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER_EXT, NULL, FALSE);
     5965        context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
     5966        context_attach_surface_fbo(context, GL_FRAMEBUFFER, 0, surface);
     5967        context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, NULL, FALSE);
    60485968    }
    60495969
     
    60866006    DWORD ret;
    60876007
    6088     if(destfmt == WINED3DFMT_A8R8G8B8 || destfmt == WINED3DFMT_X8R8G8B8 ||
    6089        destfmt == WINED3DFMT_R8G8B8)
     6008    if (destfmt == WINED3DFMT_B8G8R8A8_UNORM
     6009            || destfmt == WINED3DFMT_B8G8R8X8_UNORM
     6010            || destfmt == WINED3DFMT_B8G8R8_UNORM)
    60906011        return color;
    60916012
     
    60996020    switch(destfmt)
    61006021    {
    6101         case WINED3DFMT_R5G6B5:
     6022        case WINED3DFMT_B5G6R5_UNORM:
    61026023            if(r == 0xff && g == 0xff && b == 0xff) return 0xffff;
    61036024            r = (r * 32) / 256;
     
    61106031            return ret;
    61116032
    6112         case WINED3DFMT_X1R5G5B5:
    6113         case WINED3DFMT_A1R5G5B5:
     6033        case WINED3DFMT_B5G5R5X1_UNORM:
     6034        case WINED3DFMT_B5G5R5A1_UNORM:
    61146035            a = (a *  2) / 256;
    61156036            r = (r * 32) / 256;
     
    61276048            return a;
    61286049
    6129         case WINED3DFMT_X4R4G4B4:
    6130         case WINED3DFMT_A4R4G4B4:
     6050        case WINED3DFMT_B4G4R4X4_UNORM:
     6051        case WINED3DFMT_B4G4R4A4_UNORM:
    61316052            a = (a * 16) / 256;
    61326053            r = (r * 16) / 256;
     
    61406061            return ret;
    61416062
    6142         case WINED3DFMT_R3G3B2:
     6063        case WINED3DFMT_B2G3R3_UNORM:
    61436064            r = (r * 8) / 256;
    61446065            g = (g * 8) / 256;
     
    61506071            return ret;
    61516072
    6152         case WINED3DFMT_X8B8G8R8:
     6073        case WINED3DFMT_R8G8B8X8_UNORM:
    61536074        case WINED3DFMT_R8G8B8A8_UNORM:
    61546075            ret  = a << 24;
     
    61596080            return ret;
    61606081
    6161         case WINED3DFMT_A2R10G10B10:
     6082        case WINED3DFMT_B10G10R10A2_UNORM:
    61626083            a = (a *    4) / 256;
    61636084            r = (r * 1024) / 256;
     
    64026323    GLbitfield mask = GL_COLOR_BUFFER_BIT; /* TODO: Support blitting depth/stencil surfaces */
    64036324    IWineD3DSwapChain *src_swapchain, *dst_swapchain;
     6325    const struct wined3d_gl_info *gl_info;
    64046326    struct wined3d_context *context;
    64056327    GLenum gl_filter;
     
    64316353    else if (dst_swapchain) context = ActivateContext(This, dst_surface, CTXUSAGE_RESOURCELOAD);
    64326354    else context = ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
     6355
     6356    gl_info = context->gl_info;
    64336357
    64346358    if (src_swapchain) {
     
    64556379
    64566380        ENTER_GL();
    6457         context_bind_fbo(context, GL_READ_FRAMEBUFFER_EXT, NULL);
     6381        context_bind_fbo(context, GL_READ_FRAMEBUFFER, NULL);
    64586382        glReadBuffer(buffer);
    64596383        checkGLcall("glReadBuffer()");
     
    64616385        TRACE("Source surface %p is offscreen\n", src_surface);
    64626386        ENTER_GL();
    6463         context_bind_fbo(context, GL_READ_FRAMEBUFFER_EXT, &context->src_fbo);
    6464         context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER_EXT, 0, src_surface);
    6465         glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
     6387        context_bind_fbo(context, GL_READ_FRAMEBUFFER, &context->src_fbo);
     6388        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, src_surface);
     6389        glReadBuffer(GL_COLOR_ATTACHMENT0);
    64666390        checkGLcall("glReadBuffer()");
    6467         context_attach_depth_stencil_fbo(context, GL_READ_FRAMEBUFFER_EXT, NULL, FALSE);
     6391        context_attach_depth_stencil_fbo(context, GL_READ_FRAMEBUFFER, NULL, FALSE);
    64686392    }
    64696393    LEAVE_GL();
     
    64946418
    64956419        ENTER_GL();
    6496         context_bind_fbo(context, GL_DRAW_FRAMEBUFFER_EXT, NULL);
     6420        context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, NULL);
    64976421        glDrawBuffer(buffer);
    64986422        checkGLcall("glDrawBuffer()");
     
    65016425
    65026426        ENTER_GL();
    6503         context_bind_fbo(context, GL_DRAW_FRAMEBUFFER_EXT, &context->dst_fbo);
    6504         context_attach_surface_fbo(context, GL_DRAW_FRAMEBUFFER_EXT, 0, dst_surface);
    6505         glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
     6427        context_bind_fbo(context, GL_DRAW_FRAMEBUFFER, &context->dst_fbo);
     6428        context_attach_surface_fbo(context, GL_DRAW_FRAMEBUFFER, 0, dst_surface);
     6429        glDrawBuffer(GL_COLOR_ATTACHMENT0);
    65066430        checkGLcall("glDrawBuffer()");
    6507         context_attach_depth_stencil_fbo(context, GL_DRAW_FRAMEBUFFER_EXT, NULL, FALSE);
     6431        context_attach_depth_stencil_fbo(context, GL_DRAW_FRAMEBUFFER, NULL, FALSE);
    65086432    }
    65096433    glDisable(GL_SCISSOR_TEST);
     
    65116435
    65126436    if (flip) {
    6513         GL_EXTCALL(glBlitFramebufferEXT(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
    6514                 dst_rect->x1, dst_rect->y2, dst_rect->x2, dst_rect->y1, mask, gl_filter));
     6437        gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
     6438                dst_rect->x1, dst_rect->y2, dst_rect->x2, dst_rect->y1, mask, gl_filter);
    65156439        checkGLcall("glBlitFramebuffer()");
    65166440    } else {
    6517         GL_EXTCALL(glBlitFramebufferEXT(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
    6518                 dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2, mask, gl_filter));
     6441        gl_info->fbo_ops.glBlitFramebuffer(src_rect->x1, src_rect->y1, src_rect->x2, src_rect->y2,
     6442                dst_rect->x1, dst_rect->y1, dst_rect->x2, dst_rect->y2, mask, gl_filter);
    65196443        checkGLcall("glBlitFramebuffer()");
    65206444    }
     
    65756499        viewport.MinZ   = 0.0f;
    65766500        IWineD3DDeviceImpl_SetViewport(iface, &viewport);
    6577         /* Make sure the viewport state is dirty, because the render_offscreen thing affects it.
    6578          * SetViewport may catch NOP viewport changes, which would occur when switching between equally sized targets
    6579          */
    6580         IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
    65816501    }
    65826502    return WINED3D_OK;
     
    66566576
    66576577        /* MSDN: Cursor must be A8R8G8B8 */
    6658         if (WINED3DFMT_A8R8G8B8 != pSur->resource.format_desc->format)
     6578        if (pSur->resource.format_desc->format != WINED3DFMT_B8G8R8A8_UNORM)
    66596579        {
    66606580            ERR("(%p) : surface(%p) has an invalid format\n", This, pCursorBitmap);
     
    66826602            if (SUCCEEDED(IWineD3DSurface_LockRect(pCursorBitmap, &rect, NULL, WINED3DLOCK_READONLY)))
    66836603            {
    6684                 const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &GLINFO_LOCATION);
     6604                const struct GlPixelFormatDesc *glDesc =
     6605                        getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &GLINFO_LOCATION);
    66856606                char *mem, *bits = rect.pBits;
    66866607                GLint intfmt = glDesc->glInternal;
     
    66906611                INT width = This->cursorWidth;
    66916612                INT bpp = glDesc->byte_count;
    6692                 INT i, sampler;
     6613                DWORD sampler;
     6614                INT i;
    66936615
    66946616                /* Reformat the texture memory (pitch and width can be
     
    67126634                checkGLcall("glActiveTextureARB");
    67136635                sampler = This->rev_tex_unit_map[0];
    6714                 if (sampler != -1) {
     6636                if (sampler != WINED3D_UNMAPPED_STAGE)
     6637                {
    67156638                    IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(sampler));
    67166639                }
     
    69626885    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
    69636886    IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *) swapchain_iface;
     6887    const struct wined3d_context *context;
     6888    const struct wined3d_gl_info *gl_info;
    69646889    UINT i;
    69656890    IWineD3DBaseShaderImpl *shader;
    69666891
    6967     ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
     6892    context = ActivateContext(This, NULL, CTXUSAGE_RESOURCELOAD);
     6893    gl_info = context->gl_info;
    69686894
    69696895    IWineD3DDevice_EnumResources(iface, reset_unload_resources, NULL);
     
    69786904    }
    69796905    if (This->depth_blt_rb) {
    6980         GL_EXTCALL(glDeleteRenderbuffersEXT(1, &This->depth_blt_rb));
     6906        gl_info->fbo_ops.glDeleteRenderbuffers(1, &This->depth_blt_rb);
    69816907        This->depth_blt_rb = 0;
    69826908        This->depth_blt_rb_w = 0;
     
    71417067        IWineD3DDevice_SetDepthStencilSurface(iface, NULL);
    71427068
     7069    TRACE("Resetting stateblock\n");
     7070    IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock);
     7071    IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
     7072
    71437073    delete_opengl_contexts(iface, (IWineD3DSwapChain *) swapchain);
    71447074
     
    72147144        This->exStyle = exStyle;
    72157145    }
    7216 
    7217     TRACE("Resetting stateblock\n");
    7218     IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->updateStateBlock);
    7219     IWineD3DStateBlock_Release((IWineD3DStateBlock *)This->stateBlock);
    72207146
    72217147    /* Note: No parent needed for initial internal stateblock */
     
    74847410    IWineD3DDeviceImpl_SetGammaRamp,
    74857411    IWineD3DDeviceImpl_GetGammaRamp,
    7486     IWineD3DDeviceImpl_SetIndices,
    7487     IWineD3DDeviceImpl_GetIndices,
     7412    IWineD3DDeviceImpl_SetIndexBuffer,
     7413    IWineD3DDeviceImpl_GetIndexBuffer,
    74887414    IWineD3DDeviceImpl_SetBaseVertexIndex,
    74897415    IWineD3DDeviceImpl_GetBaseVertexIndex,
     
    76967622    UINT i;
    76977623
    7698     if(!rep) return;
    76997624    for(i = 0; i < This->numContexts; i++) {
    77007625        context = This->contexts[i];
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/directx.c

    r22496 r23571  
    77 * Copyright 2005 Oliver Stieber
    88 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     9 * Copyright 2009 Henri Verbeet for CodeWeavers
    910 *
    1011 * This library is free software; you can redistribute it and/or
     
    6667    {"GL_ARB_color_buffer_float",           ARB_COLOR_BUFFER_FLOAT,         0                           },
    6768    {"GL_ARB_depth_buffer_float",           ARB_DEPTH_BUFFER_FLOAT,         0                           },
     69    {"GL_ARB_depth_clamp",                  ARB_DEPTH_CLAMP,                0                           },
    6870    {"GL_ARB_depth_texture",                ARB_DEPTH_TEXTURE,              0                           },
    6971    {"GL_ARB_draw_buffers",                 ARB_DRAW_BUFFERS,               0                           },
    7072    {"GL_ARB_fragment_program",             ARB_FRAGMENT_PROGRAM,           0                           },
    7173    {"GL_ARB_fragment_shader",              ARB_FRAGMENT_SHADER,            0                           },
     74    {"GL_ARB_framebuffer_object",           ARB_FRAMEBUFFER_OBJECT,         0                           },
    7275    {"GL_ARB_geometry_shader4",             ARB_GEOMETRY_SHADER4,           0                           },
    7376    {"GL_ARB_half_float_pixel",             ARB_HALF_FLOAT_PIXEL,           0                           },
     
    7982    {"GL_ARB_point_parameters",             ARB_POINT_PARAMETERS,           0                           },
    8083    {"GL_ARB_point_sprite",                 ARB_POINT_SPRITE,               0                           },
     84    {"GL_ARB_provoking_vertex",             ARB_PROVOKING_VERTEX,           0                           },
    8185    {"GL_ARB_texture_border_clamp",         ARB_TEXTURE_BORDER_CLAMP,       0                           },
    8286    {"GL_ARB_texture_compression",          ARB_TEXTURE_COMPRESSION,        0                           },
     
    110114    {"GL_EXT_paletted_texture",             EXT_PALETTED_TEXTURE,           0                           },
    111115    {"GL_EXT_point_parameters",             EXT_POINT_PARAMETERS,           0                           },
     116    {"GL_EXT_provoking_vertex",             EXT_PROVOKING_VERTEX,           0                           },
    112117    {"GL_EXT_secondary_color",              EXT_SECONDARY_COLOR,            0                           },
    113118    {"GL_EXT_stencil_two_side",             EXT_STENCIL_TWO_SIDE,           0                           },
     
    194199};
    195200
     201const struct min_lookup minMipLookup_noMip[] =
     202{
     203    /* NONE         POINT                       LINEAR */
     204    {{GL_NEAREST,   GL_NEAREST,                 GL_NEAREST}},               /* NONE */
     205    {{GL_NEAREST,   GL_NEAREST,                 GL_NEAREST}},               /* POINT */
     206    {{GL_LINEAR,    GL_LINEAR,                  GL_LINEAR }},               /* LINEAR */
     207};
     208
    196209const GLenum magLookup[] =
    197210{
     
    376389}
    377390
    378 /* Set the shader type for this device, depending on the given capabilities,
    379  * the device type, and the user preferences in wined3d_settings */
    380 
    381 static void select_shader_mode(const struct wined3d_gl_info *gl_info,
    382         WINED3DDEVTYPE DeviceType, int *ps_selected, int *vs_selected)
     391/* Set the shader type for this device, depending on the given capabilities
     392 * and the user preferences in wined3d_settings. */
     393static void select_shader_mode(const struct wined3d_gl_info *gl_info, int *ps_selected, int *vs_selected)
    383394{
    384395    if (wined3d_settings.vs_mode == VS_NONE) {
     
    388399         * wrong. This combined with the fact that glsl won't offer more features or performance, use ARB
    389400         * shaders only on this card. */
    390         if(gl_info->vs_nv_version && gl_info->vs_nv_version < VS_VERSION_20)
     401        if (gl_info->supported[NV_VERTEX_PROGRAM] && !gl_info->supported[NV_VERTEX_PROGRAM2])
    391402            *vs_selected = SHADER_ARB;
    392403        else
     
    528539            && gl_info->supported[APPLE_YCBCR_422])
    529540    {
    530         TRACE_(d3d_caps)("GL_APPLE_fence, GL_APPLE_client_storage, GL_APPLE_flush_render and GL_ycbcr_422 are supported.\n");
    531         TRACE_(d3d_caps)("Activating MacOS fixups.\n");
    532541        return TRUE;
    533542    }
    534543    else
    535544    {
    536         TRACE_(d3d_caps)("Apple extensions are not supported.\n");
    537         TRACE_(d3d_caps)("Not activating MacOS fixups.\n");
    538545        return FALSE;
    539546    }
     
    585592
    586593    GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
    587     glFinish(); /* just to be sure */
     594    wglFinish(); /* just to be sure */
    588595
    589596    memset(check, 0, sizeof(check));
     
    793800};
    794801
    795 struct driver_quirk quirk_table[] =
     802static const struct driver_quirk quirk_table[] =
    796803{
    797804    {
     
    936943    test_pbo_functionality(gl_info);
    937944
    938     /* Fixup the driver version */
     945    /* Fixup the driver version we'll report to the app. */
     946    gl_info->driver_version        = MAKEDWORD_VERSION(8, 6); /* Nvidia RIVA TNT, arbitrary */
     947    gl_info->driver_version_hipart = MAKEDWORD_VERSION(7, 1);
    939948    for (i = 0; i < (sizeof(driver_version_table) / sizeof(driver_version_table[0])); ++i)
    940949    {
     
    953962        }
    954963    }
     964    TRACE_(d3d_caps)("Reporting (fake) driver version 0x%08X-0x%08X.\n",
     965            gl_info->driver_version_hipart, gl_info->driver_version);
     966}
     967
     968static DWORD wined3d_parse_gl_version(const char *gl_version)
     969{
     970    const char *ptr = gl_version;
     971    int major, minor;
     972
     973    major = atoi(ptr);
     974    if (major <= 0) ERR_(d3d_caps)("Invalid opengl major version: %d.\n", major);
     975
     976    while (isdigit(*ptr)) ++ptr;
     977    if (*ptr++ != '.') ERR_(d3d_caps)("Invalid opengl version string: %s.\n", debugstr_a(gl_version));
     978
     979    minor = atoi(ptr);
     980
     981    TRACE_(d3d_caps)("Found OpenGL version: %d.%d.\n", major, minor);
     982
     983    return MAKEDWORD_VERSION(major, minor);
     984}
     985
     986static GL_Vendors wined3d_guess_vendor(const char *gl_vendor, const char *gl_renderer)
     987{
     988    if (strstr(gl_vendor, "NVIDIA"))
     989        return VENDOR_NVIDIA;
     990
     991    if (strstr(gl_vendor, "ATI"))
     992        return VENDOR_ATI;
     993
     994    if (strstr(gl_vendor, "Intel(R)")
     995            || strstr(gl_renderer, "Intel(R)")
     996            || strstr(gl_vendor, "Intel Inc."))
     997        return VENDOR_INTEL;
     998
     999    if (strstr(gl_vendor, "Mesa")
     1000            || strstr(gl_vendor, "DRI R300 Project")
     1001            || strstr(gl_vendor, "Tungsten Graphics, Inc"))
     1002        return VENDOR_MESA;
     1003
     1004    FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Returning VENDOR_WINE.\n", debugstr_a(gl_vendor));
     1005
     1006    return VENDOR_WINE;
     1007}
     1008
     1009static GL_Cards wined3d_guess_card(const struct wined3d_gl_info *gl_info, const char *gl_renderer,
     1010        GL_Vendors *vendor, unsigned int *vidmem)
     1011{
     1012    /* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of
     1013     * different GPUs with roughly the same features. In most cases GPUs from a
     1014     * certain family differ in clockspeeds, the amount of video memory and the
     1015     * number of shader pipelines.
     1016     *
     1017     * A Direct3D device object contains the PCI id (vendor + device) of the
     1018     * videocard which is used for rendering. Various applications use this
     1019     * information to get a rough estimation of the features of the card and
     1020     * some might use it for enabling 3d effects only on certain types of
     1021     * videocards. In some cases games might even use it to work around bugs
     1022     * which happen on certain videocards/driver combinations. The problem is
     1023     * that OpenGL only exposes a rendering string containing the name of the
     1024     * videocard and not the PCI id.
     1025     *
     1026     * Various games depend on the PCI id, so somehow we need to provide one.
     1027     * A simple option is to parse the renderer string and translate this to
     1028     * the right PCI id. This is a lot of work because there are more than 200
     1029     * GPUs just for Nvidia. Various cards share the same renderer string, so
     1030     * the amount of code might be 'small' but there are quite a number of
     1031     * exceptions which would make this a pain to maintain. Another way would
     1032     * be to query the PCI id from the operating system (assuming this is the
     1033     * videocard which is used for rendering which is not always the case).
     1034     * This would work but it is not very portable. Second it would not work
     1035     * well in, let's say, a remote X situation in which the amount of 3d
     1036     * features which can be used is limited.
     1037     *
     1038     * As said most games only use the PCI id to get an indication of the
     1039     * capabilities of the card. It doesn't really matter if the given id is
     1040     * the correct one if we return the id of a card with similar 3d features.
     1041     *
     1042     * The code below checks the OpenGL capabilities of a videocard and matches
     1043     * that to a certain level of Direct3D functionality. Once a card passes
     1044     * the Direct3D9 check, we know that the card (in case of Nvidia) is at
     1045     * least a GeforceFX. To give a better estimate we do a basic check on the
     1046     * renderer string but if that won't pass we return a default card. This
     1047     * way is better than maintaining a full card database as even without a
     1048     * full database we can return a card with similar features. Second the
     1049     * size of the database can be made quite small because when you know what
     1050     * type of 3d functionality a card has, you know to which GPU family the
     1051     * GPU must belong. Because of this you only have to check a small part of
     1052     * the renderer string to distinguishes between different models from that
     1053     * family.
     1054     *
     1055     * The code also selects a default amount of video memory which we will
     1056     * use for an estimation of the amount of free texture memory. In case of
     1057     * real D3D the amount of texture memory includes video memory and system
     1058     * memory (to be specific AGP memory or in case of PCIE TurboCache /
     1059     * HyperMemory). We don't know how much system memory can be addressed by
     1060     * the system but we can make a reasonable estimation about the amount of
     1061     * video memory. If the value is slightly wrong it doesn't matter as we
     1062     * didn't include AGP-like memory which makes the amount of addressable
     1063     * memory higher and second OpenGL isn't that critical it moves to system
     1064     * memory behind our backs if really needed. Note that the amount of video
     1065     * memory can be overruled using a registry setting. */
     1066
     1067    switch (*vendor)
     1068    {
     1069        case VENDOR_NVIDIA:
     1070            /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
     1071             * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
     1072             */
     1073            if (WINE_D3D9_CAPABLE(gl_info) && gl_info->supported[NV_VERTEX_PROGRAM3])
     1074            {
     1075                /* Geforce 200 - highend */
     1076                if (strstr(gl_renderer, "GTX 280")
     1077                        || strstr(gl_renderer, "GTX 285")
     1078                        || strstr(gl_renderer, "GTX 295"))
     1079                {
     1080                    *vidmem = 1024;
     1081                    return CARD_NVIDIA_GEFORCE_GTX280;
     1082                }
     1083
     1084                /* Geforce 200 - midend high */
     1085                if (strstr(gl_renderer, "GTX 275"))
     1086                {
     1087                    *vidmem = 896;
     1088                    return CARD_NVIDIA_GEFORCE_GTX275;
     1089                }
     1090
     1091                /* Geforce 200 - midend */
     1092                if (strstr(gl_renderer, "GTX 260"))
     1093                {
     1094                    *vidmem = 1024;
     1095                    return CARD_NVIDIA_GEFORCE_GTX260;
     1096                }
     1097
     1098                /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
     1099                if (strstr(gl_renderer, "9800")
     1100                        || strstr(gl_renderer, "GTS 150")
     1101                        || strstr(gl_renderer, "GTS 250"))
     1102                {
     1103                    *vidmem = 512;
     1104                    return CARD_NVIDIA_GEFORCE_9800GT;
     1105                }
     1106
     1107                /* Geforce9 - midend */
     1108                if (strstr(gl_renderer, "9600"))
     1109                {
     1110                    *vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
     1111                    return CARD_NVIDIA_GEFORCE_9600GT;
     1112                }
     1113
     1114                /* Geforce9 - midend low / Geforce 200 - low */
     1115                if (strstr(gl_renderer, "9500")
     1116                        || strstr(gl_renderer, "GT 120")
     1117                        || strstr(gl_renderer, "GT 130"))
     1118                {
     1119                    *vidmem = 256; /* The 9500GT has 256-1024MB */
     1120                    return CARD_NVIDIA_GEFORCE_9500GT;
     1121                }
     1122
     1123                /* Geforce9 - lowend */
     1124                if (strstr(gl_renderer, "9400"))
     1125                {
     1126                    *vidmem = 256; /* The 9400GT has 256-1024MB */
     1127                    return CARD_NVIDIA_GEFORCE_9400GT;
     1128                }
     1129
     1130                /* Geforce9 - lowend low */
     1131                if (strstr(gl_renderer, "9100")
     1132                        || strstr(gl_renderer, "9200")
     1133                        || strstr(gl_renderer, "9300")
     1134                        || strstr(gl_renderer, "G 100"))
     1135                {
     1136                    *vidmem = 256; /* The 9100-9300 cards have 256MB */
     1137                    return CARD_NVIDIA_GEFORCE_9200;
     1138                }
     1139
     1140                /* Geforce8 - highend */
     1141                if (strstr(gl_renderer, "8800"))
     1142                {
     1143                    *vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
     1144                    return CARD_NVIDIA_GEFORCE_8800GTS;
     1145                }
     1146
     1147                /* Geforce8 - midend mobile */
     1148                if (strstr(gl_renderer, "8600 M"))
     1149                {
     1150                    *vidmem = 512;
     1151                    return CARD_NVIDIA_GEFORCE_8600MGT;
     1152                }
     1153
     1154                /* Geforce8 - midend */
     1155                if (strstr(gl_renderer, "8600")
     1156                        || strstr(gl_renderer, "8700"))
     1157                {
     1158                    *vidmem = 256;
     1159                    return CARD_NVIDIA_GEFORCE_8600GT;
     1160                }
     1161
     1162                /* Geforce8 - lowend */
     1163                if (strstr(gl_renderer, "8300")
     1164                        || strstr(gl_renderer, "8400")
     1165                        || strstr(gl_renderer, "8500"))
     1166                {
     1167                    *vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */
     1168                    return CARD_NVIDIA_GEFORCE_8300GS;
     1169                }
     1170
     1171                /* Geforce7 - highend */
     1172                if (strstr(gl_renderer, "7800")
     1173                        || strstr(gl_renderer, "7900")
     1174                        || strstr(gl_renderer, "7950")
     1175                        || strstr(gl_renderer, "Quadro FX 4")
     1176                        || strstr(gl_renderer, "Quadro FX 5"))
     1177                {
     1178                    *vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
     1179                    return CARD_NVIDIA_GEFORCE_7800GT;
     1180                }
     1181
     1182                /* Geforce7 midend */
     1183                if (strstr(gl_renderer, "7600")
     1184                        || strstr(gl_renderer, "7700"))
     1185                {
     1186                    *vidmem = 256; /* The 7600 uses 256-512MB */
     1187                    return CARD_NVIDIA_GEFORCE_7600;
     1188                }
     1189
     1190                /* Geforce7 lower medium */
     1191                if (strstr(gl_renderer, "7400"))
     1192                {
     1193                    *vidmem = 256; /* The 7400 uses 256-512MB */
     1194                    return CARD_NVIDIA_GEFORCE_7400;
     1195                }
     1196
     1197                /* Geforce7 lowend */
     1198                if (strstr(gl_renderer, "7300"))
     1199                {
     1200                    *vidmem = 256; /* Mac Pros with this card have 256 MB */
     1201                    return CARD_NVIDIA_GEFORCE_7300;
     1202                }
     1203
     1204                /* Geforce6 highend */
     1205                if (strstr(gl_renderer, "6800"))
     1206                {
     1207                    *vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
     1208                    return CARD_NVIDIA_GEFORCE_6800;
     1209                }
     1210
     1211                /* Geforce6 - midend */
     1212                if (strstr(gl_renderer, "6600")
     1213                        || strstr(gl_renderer, "6610")
     1214                        || strstr(gl_renderer, "6700"))
     1215                {
     1216                    *vidmem = 128; /* A 6600GT has 128-256MB */
     1217                    return CARD_NVIDIA_GEFORCE_6600GT;
     1218                }
     1219
     1220                /* Geforce6/7 lowend */
     1221                *vidmem = 64; /* */
     1222                return CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
     1223            }
     1224
     1225            if (WINE_D3D9_CAPABLE(gl_info))
     1226            {
     1227                /* GeforceFX - highend */
     1228                if (strstr(gl_renderer, "5800")
     1229                        || strstr(gl_renderer, "5900")
     1230                        || strstr(gl_renderer, "5950")
     1231                        || strstr(gl_renderer, "Quadro FX"))
     1232                {
     1233                    *vidmem = 256; /* 5800-5900 cards use 256MB */
     1234                    return CARD_NVIDIA_GEFORCEFX_5800;
     1235                }
     1236
     1237                /* GeforceFX - midend */
     1238                if (strstr(gl_renderer, "5600")
     1239                        || strstr(gl_renderer, "5650")
     1240                        || strstr(gl_renderer, "5700")
     1241                        || strstr(gl_renderer, "5750"))
     1242                {
     1243                    *vidmem = 128; /* A 5600 uses 128-256MB */
     1244                    return CARD_NVIDIA_GEFORCEFX_5600;
     1245                }
     1246
     1247                /* GeforceFX - lowend */
     1248                *vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
     1249                return CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
     1250            }
     1251
     1252            if (WINE_D3D8_CAPABLE(gl_info))
     1253            {
     1254                if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
     1255                {
     1256                    *vidmem = 64; /* Geforce4 Ti cards have 64-128MB */
     1257                    return CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
     1258                }
     1259
     1260                *vidmem = 64; /* Geforce3 cards have 64-128MB */
     1261                return CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
     1262            }
     1263
     1264            if (WINE_D3D7_CAPABLE(gl_info))
     1265            {
     1266                if (strstr(gl_renderer, "GeForce4 MX"))
     1267                {
     1268                    /* Most Geforce4MX GPUs have at least 64MB of memory, some
     1269                     * early models had 32MB but most have 64MB or even 128MB. */
     1270                    *vidmem = 64;
     1271                    return CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
     1272                }
     1273
     1274                if (strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
     1275                {
     1276                    *vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */
     1277                    return CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
     1278                }
     1279
     1280                if (strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
     1281                {
     1282                    *vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */
     1283                    return CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
     1284                }
     1285
     1286                /* Most Geforce1 cards have 32MB, there are also some rare 16
     1287                 * and 64MB (Dell) models. */
     1288                *vidmem = 32;
     1289                return CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
     1290            }
     1291
     1292            if (strstr(gl_renderer, "TNT2"))
     1293            {
     1294                *vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
     1295                return CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
     1296            }
     1297
     1298            *vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */
     1299            return CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
     1300
     1301        case VENDOR_ATI:
     1302            /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
     1303             *
     1304             * Beware: renderer string do not match exact card model,
     1305             * eg HD 4800 is returned for multiple cards, even for RV790 based ones. */
     1306            if (WINE_D3D9_CAPABLE(gl_info))
     1307            {
     1308                /* Radeon R7xx HD4800 - highend */
     1309                if (strstr(gl_renderer, "HD 4800")          /* Radeon RV7xx HD48xx generic renderer string */
     1310                        || strstr(gl_renderer, "HD 4830")   /* Radeon RV770 */
     1311                        || strstr(gl_renderer, "HD 4850")   /* Radeon RV770 */
     1312                        || strstr(gl_renderer, "HD 4870")   /* Radeon RV770 */
     1313                        || strstr(gl_renderer, "HD 4890"))  /* Radeon RV790 */
     1314                {
     1315                    *vidmem = 512; /* note: HD4890 cards use 1024MB */
     1316                    return CARD_ATI_RADEON_HD4800;
     1317                }
     1318
     1319                /* Radeon R740 HD4700 - midend */
     1320                if (strstr(gl_renderer, "HD 4700")          /* Radeon RV770 */
     1321                        || strstr(gl_renderer, "HD 4770"))  /* Radeon RV740 */
     1322                {
     1323                    *vidmem = 512;
     1324                    return CARD_ATI_RADEON_HD4700;
     1325                }
     1326
     1327                /* Radeon R730 HD4600 - midend */
     1328                if (strstr(gl_renderer, "HD 4600")          /* Radeon RV730 */
     1329                        || strstr(gl_renderer, "HD 4650")   /* Radeon RV730 */
     1330                        || strstr(gl_renderer, "HD 4670"))  /* Radeon RV730 */
     1331                {
     1332                    *vidmem = 512;
     1333                    return CARD_ATI_RADEON_HD4600;
     1334                }
     1335
     1336                /* Radeon R710 HD4500/HD4350 - lowend */
     1337                if (strstr(gl_renderer, "HD 4350")          /* Radeon RV710 */
     1338                        || strstr(gl_renderer, "HD 4550"))  /* Radeon RV710 */
     1339                {
     1340                    *vidmem = 256;
     1341                    return CARD_ATI_RADEON_HD4350;
     1342                }
     1343
     1344                /* Radeon R6xx HD2900/HD3800 - highend */
     1345                if (strstr(gl_renderer, "HD 2900")
     1346                        || strstr(gl_renderer, "HD 3870")
     1347                        || strstr(gl_renderer, "HD 3850"))
     1348                {
     1349                    *vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
     1350                    return CARD_ATI_RADEON_HD2900;
     1351                }
     1352
     1353                /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
     1354                if (strstr(gl_renderer, "HD 2600")
     1355                        || strstr(gl_renderer, "HD 3830")
     1356                        || strstr(gl_renderer, "HD 3690")
     1357                        || strstr(gl_renderer, "HD 3650"))
     1358                {
     1359                    *vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
     1360                    return CARD_ATI_RADEON_HD2600;
     1361                }
     1362
     1363                /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
     1364                if (strstr(gl_renderer, "HD 2300")
     1365                        || strstr(gl_renderer, "HD 2400")
     1366                        || strstr(gl_renderer, "HD 3470")
     1367                        || strstr(gl_renderer, "HD 3450")
     1368                        || strstr(gl_renderer, "HD 3430")
     1369                        || strstr(gl_renderer, "HD 3400"))
     1370                {
     1371                    *vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */
     1372                    return CARD_ATI_RADEON_HD2300;
     1373                }
     1374
     1375                /* Radeon R6xx/R7xx integrated */
     1376                if (strstr(gl_renderer, "HD 3100")
     1377                        || strstr(gl_renderer, "HD 3200")
     1378                        || strstr(gl_renderer, "HD 3300"))
     1379                {
     1380                    *vidmem = 128; /* 128MB */
     1381                    return CARD_ATI_RADEON_HD3200;
     1382                }
     1383
     1384                /* Radeon R5xx */
     1385                if (strstr(gl_renderer, "X1600")
     1386                        || strstr(gl_renderer, "X1650")
     1387                        || strstr(gl_renderer, "X1800")
     1388                        || strstr(gl_renderer, "X1900")
     1389                        || strstr(gl_renderer, "X1950"))
     1390                {
     1391                    *vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
     1392                    return CARD_ATI_RADEON_X1600;
     1393                }
     1394
     1395                /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
     1396                if (strstr(gl_renderer, "X700")
     1397                        || strstr(gl_renderer, "X800")
     1398                        || strstr(gl_renderer, "X850")
     1399                        || strstr(gl_renderer, "X1300")
     1400                        || strstr(gl_renderer, "X1400")
     1401                        || strstr(gl_renderer, "X1450")
     1402                        || strstr(gl_renderer, "X1550"))
     1403                {
     1404                    *vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
     1405                    return CARD_ATI_RADEON_X700;
     1406                }
     1407
     1408                /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
     1409                if (strstr(gl_renderer, "Radeon Xpress"))
     1410                {
     1411                    *vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
     1412                    return CARD_ATI_RADEON_XPRESS_200M;
     1413                }
     1414
     1415                /* Radeon R3xx */
     1416                *vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
     1417                return CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
     1418            }
     1419
     1420            if (WINE_D3D8_CAPABLE(gl_info))
     1421            {
     1422                *vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
     1423                return CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
     1424            }
     1425
     1426            if (WINE_D3D7_CAPABLE(gl_info))
     1427            {
     1428                *vidmem = 32; /* There are models with up to 64MB */
     1429                return CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
     1430            }
     1431
     1432            *vidmem = 16; /* There are 16-32MB models */
     1433            return CARD_ATI_RAGE_128PRO;
     1434
     1435        case VENDOR_INTEL:
     1436            if (strstr(gl_renderer, "X3100"))
     1437            {
     1438                /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */
     1439                *vidmem = 128;
     1440                return CARD_INTEL_X3100;
     1441            }
     1442
     1443            if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM"))
     1444            {
     1445                /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
     1446                *vidmem = 64;
     1447                return CARD_INTEL_I945GM;
     1448            }
     1449
     1450            if (strstr(gl_renderer, "915GM")) return CARD_INTEL_I915GM;
     1451            if (strstr(gl_renderer, "915G")) return CARD_INTEL_I915G;
     1452            if (strstr(gl_renderer, "865G")) return CARD_INTEL_I865G;
     1453            if (strstr(gl_renderer, "855G")) return CARD_INTEL_I855G;
     1454            if (strstr(gl_renderer, "830G")) return CARD_INTEL_I830G;
     1455            return CARD_INTEL_I915G;
     1456
     1457        case VENDOR_MESA:
     1458        case VENDOR_WINE:
     1459        default:
     1460            /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
     1461             * for Nvidia was because the hardware and drivers they make are of good quality. This makes
     1462             * them a good generic choice. */
     1463            *vendor = VENDOR_NVIDIA;
     1464            if (WINE_D3D9_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCEFX_5600;
     1465            if (WINE_D3D8_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE3;
     1466            if (WINE_D3D7_CAPABLE(gl_info)) return CARD_NVIDIA_GEFORCE;
     1467            if (WINE_D3D6_CAPABLE(gl_info)) return CARD_NVIDIA_RIVA_TNT;
     1468            return CARD_NVIDIA_RIVA_128;
     1469    }
    9551470}
    9561471
     
    9611476    const char *WGL_Extensions   = NULL;
    9621477    const char *gl_string        = NULL;
    963     const char *gl_string_cursor = NULL;
    9641478    GLint       gl_max;
    9651479    GLfloat     gl_floatv[2];
    966     int         major = 1, minor = 0;
    9671480    unsigned    i;
    9681481    HDC         hdc;
     
    9771490
    9781491    gl_string = (const char *)glGetString(GL_RENDERER);
    979     TRACE_(d3d_caps)("GL_RENDERER: %s.\n", gl_string);
     1492    TRACE_(d3d_caps)("GL_RENDERER: %s.\n", debugstr_a(gl_string));
    9801493    if (!gl_string)
    9811494    {
     1495        LEAVE_GL();
    9821496        ERR_(d3d_caps)("Received a NULL GL_RENDERER.\n");
    9831497        return FALSE;
     
    9881502    if (!gl_renderer)
    9891503    {
     1504        LEAVE_GL();
    9901505        ERR_(d3d_caps)("Failed to allocate gl_renderer memory.\n");
    9911506        return FALSE;
     
    9941509
    9951510    gl_string = (const char *)glGetString(GL_VENDOR);
    996     TRACE_(d3d_caps)("GL_VENDOR: %s.\n", gl_string);
     1511    TRACE_(d3d_caps)("GL_VENDOR: %s.\n", debugstr_a(gl_string));
    9971512    if (!gl_string)
    9981513    {
     1514        LEAVE_GL();
    9991515        ERR_(d3d_caps)("Received a NULL GL_VENDOR.\n");
    10001516        HeapFree(GetProcessHeap(), 0, gl_renderer);
    10011517        return FALSE;
    10021518    }
    1003 
    1004     /* Fill in the GL vendor */
    1005     if (strstr(gl_string, "NVIDIA"))
    1006     {
    1007         gl_info->gl_vendor = VENDOR_NVIDIA;
    1008     }
    1009     else if (strstr(gl_string, "ATI"))
    1010     {
    1011         gl_info->gl_vendor = VENDOR_ATI;
    1012     }
    1013     else if (strstr(gl_string, "Intel(R)")
    1014             || strstr(gl_renderer, "Intel(R)")
    1015             || strstr(gl_string, "Intel Inc."))
    1016     {
    1017         gl_info->gl_vendor = VENDOR_INTEL;
    1018     }
    1019     else if (strstr(gl_string, "Mesa"))
    1020     {
    1021         gl_info->gl_vendor = VENDOR_MESA;
    1022     }
    1023     else
    1024     {
    1025         FIXME_(d3d_caps)("Received unrecognized GL_VENDOR %s. Setting VENDOR_WINE.\n", gl_string);
    1026         gl_info->gl_vendor = VENDOR_WINE;
    1027     }
     1519    gl_info->gl_vendor = wined3d_guess_vendor(gl_string, gl_renderer);
    10281520    TRACE_(d3d_caps)("found GL_VENDOR (%s)->(0x%04x)\n", debugstr_a(gl_string), gl_info->gl_vendor);
    10291521
    10301522    /* Parse the GL_VERSION field into major and minor information */
    10311523    gl_string = (const char *)glGetString(GL_VERSION);
    1032     TRACE_(d3d_caps)("GL_VERSION: %s.\n", gl_string);
     1524    TRACE_(d3d_caps)("GL_VERSION: %s.\n", debugstr_a(gl_string));
    10331525    if (!gl_string)
    10341526    {
     1527        LEAVE_GL();
    10351528        ERR_(d3d_caps)("Received a NULL GL_VERSION.\n");
    10361529        HeapFree(GetProcessHeap(), 0, gl_renderer);
    10371530        return FALSE;
    10381531    }
    1039 
    1040     /* First, parse the generic opengl version. This is supposed not to be
    1041      * convoluted with driver specific information. */
    1042     gl_string_cursor = gl_string;
    1043 
    1044     major = atoi(gl_string_cursor);
    1045     if (major <= 0) ERR_(d3d_caps)("Invalid opengl major version: %d.\n", major);
    1046     while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0') ++gl_string_cursor;
    1047     if (*gl_string_cursor++ != '.') ERR_(d3d_caps)("Invalid opengl version string: %s.\n", debugstr_a(gl_string));
    1048 
    1049     minor = atoi(gl_string_cursor);
    1050     TRACE_(d3d_caps)("Found OpenGL version: %d.%d.\n", major, minor);
    1051     gl_version = MAKEDWORD_VERSION(major, minor);
    1052 
    1053     /* Now parse the driver specific string which we'll report to the app. */
    1054     switch (gl_info->gl_vendor)
    1055     {
    1056         case VENDOR_NVIDIA:
    1057             gl_string_cursor = strstr(gl_string, "NVIDIA");
    1058             if (!gl_string_cursor)
    1059             {
    1060                 ERR_(d3d_caps)("Invalid nVidia version string: %s.\n", debugstr_a(gl_string));
    1061                 break;
    1062             }
    1063 
    1064             gl_string_cursor = strstr(gl_string_cursor, " ");
    1065             if (!gl_string_cursor)
    1066             {
    1067                 ERR_(d3d_caps)("Invalid nVidia version string: %s.\n", debugstr_a(gl_string));
    1068                 break;
    1069             }
    1070 
    1071             while (*gl_string_cursor == ' ') ++gl_string_cursor;
    1072 
    1073             if (!*gl_string_cursor)
    1074             {
    1075                 ERR_(d3d_caps)("Invalid nVidia version string: %s.\n", debugstr_a(gl_string));
    1076                 break;
    1077             }
    1078 
    1079             major = atoi(gl_string_cursor);
    1080             while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0') ++gl_string_cursor;
    1081 
    1082             if (*gl_string_cursor++ != '.')
    1083             {
    1084                 ERR_(d3d_caps)("Invalid nVidia version string: %s.\n", debugstr_a(gl_string));
    1085                 break;
    1086             }
    1087 
    1088             minor = atoi(gl_string_cursor);
    1089             minor = major * 100 + minor;
    1090             major = 10;
    1091             break;
    1092 
    1093         case VENDOR_ATI:
    1094             major = minor = 0;
    1095             gl_string_cursor = strchr(gl_string, '-');
    1096             if (gl_string_cursor)
    1097             {
    1098                 ++gl_string_cursor;
    1099 
    1100                 /* Check if version number is of the form x.y.z. */
    1101                 if (*gl_string_cursor < '0' || *gl_string_cursor > '9'
    1102                         || gl_string_cursor[1] != '.'
    1103                         || gl_string_cursor[2] < '0' || gl_string_cursor[2] > '9'
    1104                         || gl_string_cursor[3] != '.'
    1105                         || gl_string_cursor[4] < '0' || gl_string_cursor[4] > '9')
    1106                     /* Mark version number as malformed. */
    1107                     gl_string_cursor = 0;
    1108             }
    1109 
    1110             if (!gl_string_cursor)
    1111             {
    1112                 WARN_(d3d_caps)("malformed GL_VERSION (%s).\n", debugstr_a(gl_string));
    1113             }
    1114             else
    1115             {
    1116                 major = *gl_string_cursor - '0';
    1117                 minor = (gl_string_cursor[2] - '0') * 256 + (gl_string_cursor[4] - '0');
    1118             }
    1119             break;
    1120 
    1121         case VENDOR_INTEL:
    1122             /* Apple and Mesa version strings look differently, but both provide intel drivers. */
    1123             if (strstr(gl_string, "APPLE"))
    1124             {
    1125                 /* [0-9]+.[0-9]+ APPLE-[0-9]+.[0.9]+.[0.9]+
    1126                  * We only need the first part, and use the APPLE as identification
    1127                  * "1.2 APPLE-1.4.56". */
    1128                 gl_string_cursor = gl_string;
    1129                 major = atoi(gl_string_cursor);
    1130                 while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0') ++gl_string_cursor;
    1131 
    1132                 if (*gl_string_cursor++ != '.')
    1133                 {
    1134                     ERR_(d3d_caps)("Invalid MacOS-Intel version string: %s.\n", debugstr_a(gl_string));
    1135                     break;
    1136                 }
    1137 
    1138                 minor = atoi(gl_string_cursor);
    1139                 break;
    1140             }
    1141             /* Fallthrough */
    1142 
    1143         case VENDOR_MESA:
    1144             gl_string_cursor = strstr(gl_string, "Mesa");
    1145             gl_string_cursor = strstr(gl_string_cursor, " ");
    1146             while (*gl_string_cursor && ' ' == *gl_string_cursor) ++gl_string_cursor;
    1147             if (*gl_string_cursor)
    1148             {
    1149                 char tmp[16];
    1150                 int cursor = 0;
    1151 
    1152                 while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0')
    1153                 {
    1154                     tmp[cursor++] = *gl_string_cursor;
    1155                     ++gl_string_cursor;
    1156                 }
    1157                 tmp[cursor] = 0;
    1158                 major = atoi(tmp);
    1159 
    1160                 if (*gl_string_cursor != '.') WARN_(d3d_caps)("malformed GL_VERSION (%s).\n", debugstr_a(gl_string));
    1161                 ++gl_string_cursor;
    1162 
    1163                 cursor = 0;
    1164                 while (*gl_string_cursor <= '9' && *gl_string_cursor >= '0')
    1165                 {
    1166                     tmp[cursor++] = *gl_string_cursor;
    1167                     ++gl_string_cursor;
    1168                 }
    1169                 tmp[cursor] = 0;
    1170                 minor = atoi(tmp);
    1171             }
    1172             break;
    1173 
    1174         default:
    1175             major = 0;
    1176             minor = 9;
    1177             break;
    1178     }
    1179 
    1180     gl_info->driver_version = MAKEDWORD_VERSION(major, minor);
    1181     TRACE_(d3d_caps)("found driver version (%s)->%i.%i->(0x%08x).\n",
    1182             debugstr_a(gl_string), major, minor, gl_info->driver_version);
    1183     /* Current Windows drivers have versions like 6.14.... (some older have an earlier version). */
    1184     gl_info->driver_version_hipart = MAKEDWORD_VERSION(6, 14);
     1532    gl_version = wined3d_parse_gl_version(gl_string);
    11851533
    11861534    /*
     
    11961544    gl_info->max_combined_samplers = gl_info->max_fragment_samplers + gl_info->max_vertex_samplers;
    11971545    gl_info->max_sampler_stages = 1;
    1198     gl_info->ps_arb_version = PS_VERSION_NOT_SUPPORTED;
    11991546    gl_info->ps_arb_max_temps = 0;
    12001547    gl_info->ps_arb_max_instructions = 0;
    1201     gl_info->vs_arb_version = VS_VERSION_NOT_SUPPORTED;
    12021548    gl_info->vs_arb_max_temps = 0;
    12031549    gl_info->vs_arb_max_instructions = 0;
    1204     gl_info->vs_nv_version  = VS_VERSION_NOT_SUPPORTED;
    1205     gl_info->vs_ati_version = VS_VERSION_NOT_SUPPORTED;
    12061550    gl_info->vs_glsl_constantsF = 0;
    12071551    gl_info->ps_glsl_constantsF = 0;
     
    12321576    if (!GL_Extensions)
    12331577    {
     1578        LEAVE_GL();
    12341579        ERR_(d3d_caps)("Received a NULL GL_EXTENSIONS.\n");
    12351580        HeapFree(GetProcessHeap(), 0, gl_renderer);
     
    12371582    }
    12381583
     1584    LEAVE_GL();
     1585
    12391586    TRACE_(d3d_caps)("GL_Extensions reported:\n");
    12401587
     
    12551602        memcpy(current_ext, start, len);
    12561603        current_ext[len] = '\0';
    1257         TRACE_(d3d_caps)("- %s\n", current_ext);
     1604        TRACE_(d3d_caps)("- %s\n", debugstr_a(current_ext));
    12581605
    12591606        for (i = 0; i < (sizeof(EXTENSION_MAP) / sizeof(*EXTENSION_MAP)); ++i)
     
    12671614        }
    12681615    }
    1269 
    1270     LEAVE_GL();
    12711616
    12721617    /* Now work out what GL support this card really has */
     
    13341679        TRACE_(d3d_caps)(" IMPLIED: NVIDIA (NV) Texture Gen Reflection support.\n");
    13351680        gl_info->supported[NV_TEXGEN_REFLECTION] = TRUE;
     1681    }
     1682    if (!gl_info->supported[ARB_DEPTH_CLAMP] && gl_info->supported[NV_DEPTH_CLAMP])
     1683    {
     1684        TRACE_(d3d_caps)(" IMPLIED: ARB_depth_clamp support (by NV_depth_clamp).\n");
     1685        gl_info->supported[ARB_DEPTH_CLAMP] = TRUE;
    13361686    }
    13371687    if (gl_info->supported[NV_TEXTURE_SHADER2])
     
    14421792    if (gl_info->supported[ARB_FRAGMENT_PROGRAM])
    14431793    {
    1444         gl_info->ps_arb_version = PS_VERSION_11;
    14451794        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
    14461795        gl_info->ps_arb_constantsF = gl_max;
     
    14521801        gl_info->ps_arb_max_instructions = gl_max;
    14531802        TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM native instructions: %d.\n", gl_info->ps_arb_max_instructions);
     1803        GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, &gl_max));
     1804        gl_info->ps_arb_max_local_constants = gl_max;
     1805        TRACE_(d3d_caps)("Max ARB_FRAGMENT_PROGRAM local parameters: %d.\n", gl_info->ps_arb_max_instructions);
    14541806    }
    14551807    if (gl_info->supported[ARB_VERTEX_PROGRAM])
    14561808    {
    1457         gl_info->vs_arb_version = VS_VERSION_11;
    14581809        GL_EXTCALL(glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
    14591810        gl_info->vs_arb_constantsF = gl_max;
     
    14821833        gl_info->max_glsl_varyings = gl_max;
    14831834        TRACE_(d3d_caps)("Max GLSL varyings: %u (%u 4 component varyings).\n", gl_max, gl_max / 4);
    1484     }
    1485     if (gl_info->supported[EXT_VERTEX_SHADER])
    1486     {
    1487         gl_info->vs_ati_version = VS_VERSION_11;
    1488     }
    1489     if (gl_info->supported[NV_VERTEX_PROGRAM3])
    1490     {
    1491         gl_info->vs_nv_version = VS_VERSION_30;
    1492     }
    1493     else if (gl_info->supported[NV_VERTEX_PROGRAM2])
    1494     {
    1495         gl_info->vs_nv_version = VS_VERSION_20;
    1496     }
    1497     else if (gl_info->supported[NV_VERTEX_PROGRAM1_1])
    1498     {
    1499         gl_info->vs_nv_version = VS_VERSION_11;
    1500     }
    1501     else if (gl_info->supported[NV_VERTEX_PROGRAM])
    1502     {
    1503         gl_info->vs_nv_version = VS_VERSION_10;
    1504     }
    1505     if (gl_info->supported[NV_FRAGMENT_PROGRAM2])
    1506     {
    1507         gl_info->ps_nv_version = PS_VERSION_30;
    1508     }
    1509     else if (gl_info->supported[NV_FRAGMENT_PROGRAM])
    1510     {
    1511         gl_info->ps_nv_version = PS_VERSION_20;
    15121835    }
    15131836    if (gl_info->supported[NV_LIGHT_MAX_EXPONENT])
     
    15541877    checkGLcall("extension detection");
    15551878
     1879    LEAVE_GL();
     1880
    15561881    /* In some cases the number of texture stages can be larger than the number
    15571882     * of samplers. The GF4 for example can use only 2 samplers (no fragment
     
    15591884    gl_info->max_sampler_stages = max(gl_info->max_fragment_samplers, gl_info->max_texture_stages);
    15601885
    1561     /* We can only use ORM_FBO when the hardware supports it. */
    1562     if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && !gl_info->supported[EXT_FRAMEBUFFER_OBJECT]) {
    1563         WARN_(d3d_caps)("GL_EXT_framebuffer_object not supported, falling back to backbuffer offscreen rendering mode.\n");
    1564         wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
     1886    if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT])
     1887    {
     1888        gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbuffer;
     1889        gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbuffer;
     1890        gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffers;
     1891        gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffers;
     1892        gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorage;
     1893        gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisample;
     1894        gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameteriv;
     1895        gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebuffer;
     1896        gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebuffer;
     1897        gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffers;
     1898        gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffers;
     1899        gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatus;
     1900        gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1D;
     1901        gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2D;
     1902        gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3D;
     1903        gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbuffer;
     1904        gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameteriv;
     1905        gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebuffer;
     1906        gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmap;
     1907    }
     1908    else
     1909    {
     1910        if (gl_info->supported[EXT_FRAMEBUFFER_OBJECT])
     1911        {
     1912            gl_info->fbo_ops.glIsRenderbuffer = gl_info->glIsRenderbufferEXT;
     1913            gl_info->fbo_ops.glBindRenderbuffer = gl_info->glBindRenderbufferEXT;
     1914            gl_info->fbo_ops.glDeleteRenderbuffers = gl_info->glDeleteRenderbuffersEXT;
     1915            gl_info->fbo_ops.glGenRenderbuffers = gl_info->glGenRenderbuffersEXT;
     1916            gl_info->fbo_ops.glRenderbufferStorage = gl_info->glRenderbufferStorageEXT;
     1917            gl_info->fbo_ops.glGetRenderbufferParameteriv = gl_info->glGetRenderbufferParameterivEXT;
     1918            gl_info->fbo_ops.glIsFramebuffer = gl_info->glIsFramebufferEXT;
     1919            gl_info->fbo_ops.glBindFramebuffer = gl_info->glBindFramebufferEXT;
     1920            gl_info->fbo_ops.glDeleteFramebuffers = gl_info->glDeleteFramebuffersEXT;
     1921            gl_info->fbo_ops.glGenFramebuffers = gl_info->glGenFramebuffersEXT;
     1922            gl_info->fbo_ops.glCheckFramebufferStatus = gl_info->glCheckFramebufferStatusEXT;
     1923            gl_info->fbo_ops.glFramebufferTexture1D = gl_info->glFramebufferTexture1DEXT;
     1924            gl_info->fbo_ops.glFramebufferTexture2D = gl_info->glFramebufferTexture2DEXT;
     1925            gl_info->fbo_ops.glFramebufferTexture3D = gl_info->glFramebufferTexture3DEXT;
     1926            gl_info->fbo_ops.glFramebufferRenderbuffer = gl_info->glFramebufferRenderbufferEXT;
     1927            gl_info->fbo_ops.glGetFramebufferAttachmentParameteriv = gl_info->glGetFramebufferAttachmentParameterivEXT;
     1928            gl_info->fbo_ops.glGenerateMipmap = gl_info->glGenerateMipmapEXT;
     1929        }
     1930        else if (wined3d_settings.offscreen_rendering_mode == ORM_FBO)
     1931        {
     1932            WARN_(d3d_caps)("Framebuffer objects not supported, falling back to backbuffer offscreen rendering mode.\n");
     1933            wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
     1934        }
     1935        if (gl_info->supported[EXT_FRAMEBUFFER_BLIT])
     1936        {
     1937            gl_info->fbo_ops.glBlitFramebuffer = gl_info->glBlitFramebufferEXT;
     1938        }
     1939        if (gl_info->supported[EXT_FRAMEBUFFER_MULTISAMPLE])
     1940        {
     1941            gl_info->fbo_ops.glRenderbufferStorageMultisample = gl_info->glRenderbufferStorageMultisampleEXT;
     1942        }
    15651943    }
    15661944
     
    15701948    }
    15711949
    1572     /* Below is a list of Nvidia and ATI GPUs. Both vendors have dozens of different GPUs with roughly the same
    1573      * features. In most cases GPUs from a certain family differ in clockspeeds, the amount of video memory and
    1574      * in case of the latest videocards in the number of pixel/vertex pipelines.
    1575      *
    1576      * A Direct3D device object contains the PCI id (vendor + device) of the videocard which is used for
    1577      * rendering. Various games use this information to get a rough estimation of the features of the card
    1578      * and some might use it for enabling 3d effects only on certain types of videocards. In some cases
    1579      * games might even use it to work around bugs which happen on certain videocards/driver combinations.
    1580      * The problem is that OpenGL only exposes a rendering string containing the name of the videocard and
    1581      * not the PCI id.
    1582      *
    1583      * Various games depend on the PCI id, so somehow we need to provide one. A simple option is to parse
    1584      * the renderer string and translate this to the right PCI id. This is a lot of work because there are more
    1585      * than 200 GPUs just for Nvidia. Various cards share the same renderer string, so the amount of code might
    1586      * be 'small' but there are quite a number of exceptions which would make this a pain to maintain.
    1587      * Another way would be to query the PCI id from the operating system (assuming this is the videocard which
    1588      * is used for rendering which is not always the case). This would work but it is not very portable. Second
    1589      * it would not work well in, let's say, a remote X situation in which the amount of 3d features which can be used
    1590      * is limited.
    1591      *
    1592      * As said most games only use the PCI id to get an indication of the capabilities of the card.
    1593      * It doesn't really matter if the given id is the correct one if we return the id of a card with
    1594      * similar 3d features.
    1595      *
    1596      * The code below checks the OpenGL capabilities of a videocard and matches that to a certain level of
    1597      * Direct3D functionality. Once a card passes the Direct3D9 check, we know that the card (in case of Nvidia)
    1598      * is at least a GeforceFX. To give a better estimate we do a basic check on the renderer string but if that
    1599      * won't pass we return a default card. This way is better than maintaining a full card database as even
    1600      * without a full database we can return a card with similar features. Second the size of the database
    1601      * can be made quite small because when you know what type of 3d functionality a card has, you know to which
    1602      * GPU family the GPU must belong. Because of this you only have to check a small part of the renderer string
    1603      * to distinguishes between different models from that family.
    1604      *
    1605      * The code also selects a default amount of video memory which we will use for an estimation of the amount
    1606      * of free texture memory. In case of real D3D the amount of texture memory includes video memory and system
    1607      * memory (to be specific AGP memory or in case of PCIE TurboCache/HyperMemory). We don't know how much
    1608      * system memory can be addressed by the system but we can make a reasonable estimation about the amount of
    1609      * video memory. If the value is slightly wrong it doesn't matter as we didn't include AGP-like memory which
    1610      * makes the amount of addressable memory higher and second OpenGL isn't that critical it moves to system
    1611      * memory behind our backs if really needed.
    1612      * Note that the amount of video memory can be overruled using a registry setting.
    1613      */
    1614     switch (gl_info->gl_vendor) {
    1615         case VENDOR_NVIDIA:
    1616             /* Both the GeforceFX, 6xxx and 7xxx series support D3D9. The last two types have more
    1617              * shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
    1618              */
    1619             if(WINE_D3D9_CAPABLE(gl_info) && (gl_info->vs_nv_version == VS_VERSION_30)) {
    1620                 /* Geforce 200 - highend */
    1621                 if (strstr(gl_renderer, "GTX 280")
    1622                         || strstr(gl_renderer, "GTX 285")
    1623                         || strstr(gl_renderer, "GTX 295"))
    1624                 {
    1625                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_GTX280;
    1626                     vidmem = 1024;
    1627                 }
    1628                 /* Geforce 200 - midend high */
    1629                 else if (strstr(gl_renderer, "GTX 275"))
    1630                 {
    1631                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_GTX275;
    1632                     vidmem = 896;
    1633                 }
    1634                 /* Geforce 200 - midend */
    1635                 else if (strstr(gl_renderer, "GTX 260"))
    1636                 {
    1637                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_GTX260;
    1638                     vidmem = 1024;
    1639                 }
    1640                 /* Geforce9 - highend / Geforce 200 - midend (GTS 150/250 are based on the same core) */
    1641                 else if (strstr(gl_renderer, "9800")
    1642                         || strstr(gl_renderer, "GTS 150")
    1643                         || strstr(gl_renderer, "GTS 250"))
    1644                 {
    1645                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_9800GT;
    1646                     vidmem = 512;
    1647                 }
    1648                 /* Geforce9 - midend */
    1649                 else if (strstr(gl_renderer, "9600"))
    1650                 {
    1651                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_9600GT;
    1652                     vidmem = 384; /* The 9600GSO has 384MB, the 9600GT has 512-1024MB */
    1653                 }
    1654                 /* Geforce9 - midend low / Geforce 200 - low*/
    1655                 else if (strstr(gl_renderer, "9500")
    1656                         || strstr(gl_renderer, "GT 120")
    1657                         || strstr(gl_renderer, "GT 130"))
    1658                 {
    1659                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_9500GT;
    1660                     vidmem = 256; /* The 9500GT has 256-1024MB */
    1661                 }
    1662                 /* Geforce9 - lowend */
    1663                 else if (strstr(gl_renderer, "9400"))
    1664                 {
    1665                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_9400GT;
    1666                     vidmem = 256; /* The 9400GT has 256-1024MB */
    1667                 }
    1668                 /* Geforce9 - lowend low */
    1669                 else if (strstr(gl_renderer, "9100")
    1670                         || strstr(gl_renderer, "9200")
    1671                         || strstr(gl_renderer, "9300")
    1672                         || strstr(gl_renderer, "G 100"))
    1673                 {
    1674                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_9200;
    1675                     vidmem = 256; /* The 9100-9300 cards have 256MB */
    1676                 }
    1677                 /* Geforce8 - highend */
    1678                 else if (strstr(gl_renderer, "8800"))
    1679                 {
    1680                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_8800GTS;
    1681                     vidmem = 320; /* The 8800GTS uses 320MB, a 8800GTX can have 768MB */
    1682                 }
    1683                 /* Geforce8 - midend mobile */
    1684                 else if (strstr(gl_renderer, "8600 M"))
    1685                 {
    1686                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_8600MGT;
    1687                     vidmem = 512;
    1688                 }
    1689                 /* Geforce8 - midend */
    1690                 else if (strstr(gl_renderer, "8600")
    1691                         || strstr(gl_renderer, "8700"))
    1692                 {
    1693                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_8600GT;
    1694                     vidmem = 256;
    1695                 }
    1696                 /* Geforce8 - lowend */
    1697                 else if (strstr(gl_renderer, "8300")
    1698                         || strstr(gl_renderer, "8400")
    1699                         || strstr(gl_renderer, "8500"))
    1700                 {
    1701                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_8300GS;
    1702                     vidmem = 128; /* 128-256MB for a 8300, 256-512MB for a 8400 */
    1703                 }
    1704                 /* Geforce7 - highend */
    1705                 else if (strstr(gl_renderer, "7800")
    1706                         || strstr(gl_renderer, "7900")
    1707                         || strstr(gl_renderer, "7950")
    1708                         || strstr(gl_renderer, "Quadro FX 4")
    1709                         || strstr(gl_renderer, "Quadro FX 5"))
    1710                 {
    1711                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_7800GT;
    1712                     vidmem = 256; /* A 7800GT uses 256MB while highend 7900 cards can use 512MB */
    1713                 }
    1714                 /* Geforce7 midend */
    1715                 else if (strstr(gl_renderer, "7600")
    1716                         || strstr(gl_renderer, "7700"))
    1717                 {
    1718                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_7600;
    1719                     vidmem = 256; /* The 7600 uses 256-512MB */
    1720                 /* Geforce7 lower medium */
    1721                 }
    1722                 else if (strstr(gl_renderer, "7400"))
    1723                 {
    1724                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_7400;
    1725                     vidmem = 256; /* The 7400 uses 256-512MB */
    1726                 }
    1727                 /* Geforce7 lowend */
    1728                 else if (strstr(gl_renderer, "7300"))
    1729                 {
    1730                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_7300;
    1731                     vidmem = 256; /* Mac Pros with this card have 256 MB */
    1732                 }
    1733                 /* Geforce6 highend */
    1734                 else if (strstr(gl_renderer, "6800"))
    1735                 {
    1736                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_6800;
    1737                     vidmem = 128; /* The 6800 uses 128-256MB, the 7600 uses 256-512MB */
    1738                 }
    1739                 /* Geforce6 - midend */
    1740                 else if (strstr(gl_renderer, "6600")
    1741                         || strstr(gl_renderer, "6610")
    1742                         || strstr(gl_renderer, "6700"))
    1743                 {
    1744                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_6600GT;
    1745                     vidmem = 128; /* A 6600GT has 128-256MB */
    1746                 }
    1747                 /* Geforce6/7 lowend */
    1748                 else {
    1749                     gl_info->gl_card = CARD_NVIDIA_GEFORCE_6200; /* Geforce 6100/6150/6200/7300/7400/7500 */
    1750                     vidmem = 64; /* */
    1751                 }
    1752             } else if(WINE_D3D9_CAPABLE(gl_info)) {
    1753                 /* GeforceFX - highend */
    1754                 if (strstr(gl_renderer, "5800")
    1755                         || strstr(gl_renderer, "5900")
    1756                         || strstr(gl_renderer, "5950")
    1757                         || strstr(gl_renderer, "Quadro FX"))
    1758                 {
    1759                     gl_info->gl_card = CARD_NVIDIA_GEFORCEFX_5800;
    1760                     vidmem = 256; /* 5800-5900 cards use 256MB */
    1761                 }
    1762                 /* GeforceFX - midend */
    1763                 else if (strstr(gl_renderer, "5600")
    1764                         || strstr(gl_renderer, "5650")
    1765                         || strstr(gl_renderer, "5700")
    1766                         || strstr(gl_renderer, "5750"))
    1767                 {
    1768                     gl_info->gl_card = CARD_NVIDIA_GEFORCEFX_5600;
    1769                     vidmem = 128; /* A 5600 uses 128-256MB */
    1770                 }
    1771                 /* GeforceFX - lowend */
    1772                 else {
    1773                     gl_info->gl_card = CARD_NVIDIA_GEFORCEFX_5200; /* GeforceFX 5100/5200/5250/5300/5500 */
    1774                     vidmem = 64; /* Normal FX5200 cards use 64-256MB; laptop (non-standard) can have less */
    1775                 }
    1776             } else if(WINE_D3D8_CAPABLE(gl_info)) {
    1777                 if (strstr(gl_renderer, "GeForce4 Ti") || strstr(gl_renderer, "Quadro4"))
    1778                 {
    1779                     gl_info->gl_card = CARD_NVIDIA_GEFORCE4_TI4200; /* Geforce4 Ti4200/Ti4400/Ti4600/Ti4800, Quadro4 */
    1780                     vidmem = 64; /* Geforce4 Ti cards have 64-128MB */
    1781                 }
    1782                 else
    1783                 {
    1784                     gl_info->gl_card = CARD_NVIDIA_GEFORCE3; /* Geforce3 standard/Ti200/Ti500, Quadro DCC */
    1785                     vidmem = 64; /* Geforce3 cards have 64-128MB */
    1786                 }
    1787             } else if(WINE_D3D7_CAPABLE(gl_info)) {
    1788                 if (strstr(gl_renderer, "GeForce4 MX"))
    1789                 {
    1790                     gl_info->gl_card = CARD_NVIDIA_GEFORCE4_MX; /* MX420/MX440/MX460/MX4000 */
    1791                     vidmem = 64; /* Most Geforce4MX GPUs have at least 64MB of memory, some early models had 32MB but most have 64MB or even 128MB */
    1792                 }
    1793                 else if(strstr(gl_renderer, "GeForce2 MX") || strstr(gl_renderer, "Quadro2 MXR"))
    1794                 {
    1795                     gl_info->gl_card = CARD_NVIDIA_GEFORCE2_MX; /* Geforce2 standard/MX100/MX200/MX400, Quadro2 MXR */
    1796                     vidmem = 32; /* Geforce2MX GPUs have 32-64MB of video memory */
    1797                 }
    1798                 else if(strstr(gl_renderer, "GeForce2") || strstr(gl_renderer, "Quadro2"))
    1799                 {
    1800                     gl_info->gl_card = CARD_NVIDIA_GEFORCE2; /* Geforce2 GTS/Pro/Ti/Ultra, Quadro2 */
    1801                     vidmem = 32; /* Geforce2 GPUs have 32-64MB of video memory */
    1802                 }
    1803                 else
    1804                 {
    1805                     gl_info->gl_card = CARD_NVIDIA_GEFORCE; /* Geforce 256/DDR, Quadro */
    1806                     vidmem = 32; /* Most Geforce1 cards have 32MB, there are also some rare 16 and 64MB (Dell) models */
    1807                 }
    1808             } else {
    1809                 if (strstr(gl_renderer, "TNT2"))
    1810                 {
    1811                     gl_info->gl_card = CARD_NVIDIA_RIVA_TNT2; /* Riva TNT2 standard/M64/Pro/Ultra */
    1812                     vidmem = 32; /* Most TNT2 boards have 32MB, though there are 16MB boards too */
    1813                 }
    1814                 else
    1815                 {
    1816                     gl_info->gl_card = CARD_NVIDIA_RIVA_TNT; /* Riva TNT, Vanta */
    1817                     vidmem = 16; /* Most TNT boards have 16MB, some rare models have 8MB */
    1818                 }
    1819             }
    1820             break;
    1821         case VENDOR_ATI:
    1822             /* See http://developer.amd.com/drivers/pc_vendor_id/Pages/default.aspx
    1823              *
    1824              * beware: renderer string do not match exact card model,
    1825              * eg HD 4800 is returned for multiple card, even for RV790 based one
    1826              */
    1827             if(WINE_D3D9_CAPABLE(gl_info)) {
    1828                 /* Radeon R7xx HD4800 - highend */
    1829                 if (strstr(gl_renderer, "HD 4800")          /* Radeon RV7xx HD48xx generic renderer string */
    1830                         || strstr(gl_renderer, "HD 4830")   /* Radeon RV770 */
    1831                         || strstr(gl_renderer, "HD 4850")   /* Radeon RV770 */
    1832                         || strstr(gl_renderer, "HD 4870")   /* Radeon RV770 */
    1833                         || strstr(gl_renderer, "HD 4890"))  /* Radeon RV790 */
    1834                 {
    1835                     gl_info->gl_card = CARD_ATI_RADEON_HD4800;
    1836                     vidmem = 512; /* note: HD4890 cards use 1024MB */
    1837                 }
    1838                 /* Radeon R740 HD4700 - midend */
    1839                 else if (strstr(gl_renderer, "HD 4700")     /* Radeon RV770 */
    1840                         || strstr(gl_renderer, "HD 4770"))  /* Radeon RV740 */
    1841                 {
    1842                     gl_info->gl_card = CARD_ATI_RADEON_HD4700;
    1843                     vidmem = 512;
    1844                 }
    1845                 /* Radeon R730 HD4600 - midend */
    1846                 else if (strstr(gl_renderer, "HD 4600")     /* Radeon RV730 */
    1847                         || strstr(gl_renderer, "HD 4650")   /* Radeon RV730 */
    1848                         || strstr(gl_renderer, "HD 4670"))  /* Radeon RV730 */
    1849                 {
    1850                     gl_info->gl_card = CARD_ATI_RADEON_HD4600;
    1851                     vidmem = 512;
    1852                 }
    1853                 /* Radeon R710 HD4500/HD4350 - lowend */
    1854                 else if (strstr(gl_renderer, "HD 4350")     /* Radeon RV710 */
    1855                         || strstr(gl_renderer, "HD 4550"))  /* Radeon RV710 */
    1856                 {
    1857                     gl_info->gl_card = CARD_ATI_RADEON_HD4350;
    1858                     vidmem = 256;
    1859                 }
    1860                 /* Radeon R6xx HD2900/HD3800 - highend */
    1861                 else if (strstr(gl_renderer, "HD 2900")
    1862                         || strstr(gl_renderer, "HD 3870")
    1863                         || strstr(gl_renderer, "HD 3850"))
    1864                 {
    1865                     gl_info->gl_card = CARD_ATI_RADEON_HD2900;
    1866                     vidmem = 512; /* HD2900/HD3800 uses 256-1024MB */
    1867                 }
    1868                 /* Radeon R6xx HD2600/HD3600 - midend; HD3830 is China-only midend */
    1869                 else if (strstr(gl_renderer, "HD 2600")
    1870                         || strstr(gl_renderer, "HD 3830")
    1871                         || strstr(gl_renderer, "HD 3690")
    1872                         || strstr(gl_renderer, "HD 3650"))
    1873                 {
    1874                     gl_info->gl_card = CARD_ATI_RADEON_HD2600;
    1875                     vidmem = 256; /* HD2600/HD3600 uses 256-512MB */
    1876                 }
    1877                 /* Radeon R6xx HD2300/HD2400/HD3400 - lowend */
    1878                 else if (strstr(gl_renderer, "HD 2300")
    1879                         || strstr(gl_renderer, "HD 2400")
    1880                         || strstr(gl_renderer, "HD 3470")
    1881                         || strstr(gl_renderer, "HD 3450")
    1882                         || strstr(gl_renderer, "HD 3430")
    1883                         || strstr(gl_renderer, "HD 3400"))
    1884                 {
    1885                     gl_info->gl_card = CARD_ATI_RADEON_HD2300;
    1886                     vidmem = 128; /* HD2300 uses at least 128MB, HD2400 uses 256MB */
    1887                 }
    1888                 /* Radeon R6xx/R7xx integrated */
    1889                 else if (strstr(gl_renderer, "HD 3100")
    1890                         || strstr(gl_renderer, "HD 3200")
    1891                         || strstr(gl_renderer, "HD 3300"))
    1892                 {
    1893                     gl_info->gl_card = CARD_ATI_RADEON_HD3200;
    1894                     vidmem = 128; /* 128MB */
    1895                 }
    1896                 /* Radeon R5xx */
    1897                 else if (strstr(gl_renderer, "X1600")
    1898                         || strstr(gl_renderer, "X1650")
    1899                         || strstr(gl_renderer, "X1800")
    1900                         || strstr(gl_renderer, "X1900")
    1901                         || strstr(gl_renderer, "X1950"))
    1902                 {
    1903                     gl_info->gl_card = CARD_ATI_RADEON_X1600;
    1904                     vidmem = 128; /* X1600 uses 128-256MB, >=X1800 uses 256MB */
    1905                 }
    1906                 /* Radeon R4xx + X1300/X1400/X1450/X1550/X2300 (lowend R5xx) */
    1907                 else if(strstr(gl_renderer, "X700")
    1908                         || strstr(gl_renderer, "X800")
    1909                         || strstr(gl_renderer, "X850")
    1910                         || strstr(gl_renderer, "X1300")
    1911                         || strstr(gl_renderer, "X1400")
    1912                         || strstr(gl_renderer, "X1450")
    1913                         || strstr(gl_renderer, "X1550"))
    1914                 {
    1915                     gl_info->gl_card = CARD_ATI_RADEON_X700;
    1916                     vidmem = 128; /* x700/x8*0 use 128-256MB, >=x1300 128-512MB */
    1917                 }
    1918                 /* Radeon Xpress Series - onboard, DX9b, Shader 2.0, 300-400MHz */
    1919                 else if(strstr(gl_renderer, "Radeon Xpress"))
    1920                 {
    1921                     gl_info->gl_card = CARD_ATI_RADEON_XPRESS_200M;
    1922                     vidmem = 64; /* Shared RAM, BIOS configurable, 64-256M */
    1923                 }
    1924                 /* Radeon R3xx */
    1925                 else {
    1926                     gl_info->gl_card = CARD_ATI_RADEON_9500; /* Radeon 9500/9550/9600/9700/9800/X300/X550/X600 */
    1927                     vidmem = 64; /* Radeon 9500 uses 64MB, higher models use up to 256MB */
    1928                 }
    1929             } else if(WINE_D3D8_CAPABLE(gl_info)) {
    1930                 gl_info->gl_card = CARD_ATI_RADEON_8500; /* Radeon 8500/9000/9100/9200/9300 */
    1931                 vidmem = 64; /* 8500/9000 cards use mostly 64MB, though there are 32MB and 128MB models */
    1932             } else if(WINE_D3D7_CAPABLE(gl_info)) {
    1933                 gl_info->gl_card = CARD_ATI_RADEON_7200; /* Radeon 7000/7100/7200/7500 */
    1934                 vidmem = 32; /* There are models with up to 64MB */
    1935             } else {
    1936                 gl_info->gl_card = CARD_ATI_RAGE_128PRO;
    1937                 vidmem = 16; /* There are 16-32MB models */
    1938             }
    1939             break;
    1940         case VENDOR_INTEL:
    1941             if(strstr(gl_renderer, "X3100"))
    1942             {
    1943                 /* MacOS calls the card GMA X3100, Google findings also suggest the name GM965 */
    1944                 gl_info->gl_card = CARD_INTEL_X3100;
    1945                 vidmem = 128;
    1946             }
    1947             else if (strstr(gl_renderer, "GMA 950") || strstr(gl_renderer, "945GM"))
    1948             {
    1949                 /* MacOS calls the card GMA 950, but everywhere else the PCI ID is named 945GM */
    1950                 gl_info->gl_card = CARD_INTEL_I945GM;
    1951                 vidmem = 64;
    1952             }
    1953             else if (strstr(gl_renderer, "915GM"))
    1954             {
    1955                 gl_info->gl_card = CARD_INTEL_I915GM;
    1956             }
    1957             else if (strstr(gl_renderer, "915G"))
    1958             {
    1959                 gl_info->gl_card = CARD_INTEL_I915G;
    1960             }
    1961             else if (strstr(gl_renderer, "865G"))
    1962             {
    1963                 gl_info->gl_card = CARD_INTEL_I865G;
    1964             }
    1965             else if (strstr(gl_renderer, "855G"))
    1966             {
    1967                 gl_info->gl_card = CARD_INTEL_I855G;
    1968             }
    1969             else if (strstr(gl_renderer, "830G"))
    1970             {
    1971                 gl_info->gl_card = CARD_INTEL_I830G;
    1972             } else {
    1973                 gl_info->gl_card = CARD_INTEL_I915G;
    1974             }
    1975             break;
    1976         case VENDOR_MESA:
    1977         case VENDOR_WINE:
    1978         default:
    1979             /* Default to generic Nvidia hardware based on the supported OpenGL extensions. The choice
    1980              * for Nvidia was because the hardware and drivers they make are of good quality. This makes
    1981              * them a good generic choice.
    1982              */
    1983             gl_info->gl_vendor = VENDOR_NVIDIA;
    1984             if(WINE_D3D9_CAPABLE(gl_info))
    1985                 gl_info->gl_card = CARD_NVIDIA_GEFORCEFX_5600;
    1986             else if(WINE_D3D8_CAPABLE(gl_info))
    1987                 gl_info->gl_card = CARD_NVIDIA_GEFORCE3;
    1988             else if(WINE_D3D7_CAPABLE(gl_info))
    1989                 gl_info->gl_card = CARD_NVIDIA_GEFORCE;
    1990             else if(WINE_D3D6_CAPABLE(gl_info))
    1991                 gl_info->gl_card = CARD_NVIDIA_RIVA_TNT;
    1992             else
    1993                 gl_info->gl_card = CARD_NVIDIA_RIVA_128;
    1994     }
     1950    gl_info->gl_card = wined3d_guess_card(gl_info, gl_renderer, &gl_info->gl_vendor, &vidmem);
    19951951    TRACE_(d3d_caps)("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", gl_info->gl_vendor, gl_info->gl_card);
    19961952
     
    20442000                memcpy(ThisExtn, Start, len);
    20452001                ThisExtn[len] = '\0';
    2046                 TRACE_(d3d_caps)("- %s\n", ThisExtn);
     2002                TRACE_(d3d_caps)("- %s\n", debugstr_a(ThisExtn));
    20472003
    20482004                if (!strcmp(ThisExtn, "WGL_ARB_pbuffer")) {
     
    20612017        }
    20622018    }
    2063     LEAVE_GL();
    20642019
    20652020    fixup_extensions(gl_info, gl_renderer);
     
    21312086                    break;
    21322087
    2133                 case WINED3DFMT_X8R8G8B8:
     2088                case WINED3DFMT_B8G8R8X8_UNORM:
    21342089                    if (mode.dmBitsPerPel == 32) ++i;
    21352090                    break;
    21362091
    2137                 case WINED3DFMT_R5G6B5:
     2092                case WINED3DFMT_B5G6R5_UNORM:
    21382093                    if (mode.dmBitsPerPel == 16) ++i;
    21392094                    break;
    21402095
    2141                 case WINED3DFMT_P8:
     2096                case WINED3DFMT_P8_UINT:
    21422097                    if (mode.dmBitsPerPel == 8) ++i;
    21432098                    break;
     
    21912146                        DevModeW.dmBitsPerPel == 16) i++;
    21922147                    break;
    2193                 case WINED3DFMT_X8R8G8B8:
     2148                case WINED3DFMT_B8G8R8X8_UNORM:
    21942149                    if (DevModeW.dmBitsPerPel == 32) i++;
    21952150                    break;
    2196                 case WINED3DFMT_R5G6B5:
     2151                case WINED3DFMT_B5G6R5_UNORM:
    21972152                    if (DevModeW.dmBitsPerPel == 16) i++;
    21982153                    break;
    2199                 case WINED3DFMT_P8:
     2154                case WINED3DFMT_P8_UINT:
    22002155                    if (DevModeW.dmBitsPerPel == 8) i++;
    22012156                    break;
     
    22172172            pMode->Width        = DevModeW.dmPelsWidth;
    22182173            pMode->Height       = DevModeW.dmPelsHeight;
    2219             pMode->RefreshRate  = WINED3DADAPTER_DEFAULT;
     2174            pMode->RefreshRate  = DEFAULT_REFRESH_RATE;
    22202175            if (DevModeW.dmFields & DM_DISPLAYFREQUENCY)
    22212176                pMode->RefreshRate = DevModeW.dmDisplayFrequency;
     
    22642219        pMode->Height       = DevModeW.dmPelsHeight;
    22652220        bpp                 = DevModeW.dmBitsPerPel;
    2266         pMode->RefreshRate  = WINED3DADAPTER_DEFAULT;
     2221        pMode->RefreshRate  = DEFAULT_REFRESH_RATE;
    22672222        if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
    22682223        {
     
    24222377    }
    24232378
    2424     if ((format_desc->format == WINED3DFMT_D16_LOCKABLE) || (format_desc->format == WINED3DFMT_D32F_LOCKABLE))
     2379    if ((format_desc->format == WINED3DFMT_D16_LOCKABLE) || (format_desc->format == WINED3DFMT_D32_FLOAT))
    24252380        lockable = TRUE;
    24262381
     
    24832438}
    24842439
    2485 static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
    2486                                                        WINED3DFORMAT SurfaceFormat,
    2487                                                        BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD*   pQualityLevels) {
    2488 
     2440static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
     2441        WINED3DFORMAT SurfaceFormat, BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD *pQualityLevels)
     2442{
    24892443    IWineD3DImpl *This = (IWineD3DImpl *)iface;
    24902444    const struct GlPixelFormatDesc *glDesc;
     
    26062560
    26072561    /* There are only 4 display formats */
    2608     if(!((DisplayFormat == WINED3DFMT_R5G6B5) ||
    2609          (DisplayFormat == WINED3DFMT_X1R5G5B5) ||
    2610          (DisplayFormat == WINED3DFMT_X8R8G8B8) ||
    2611          (DisplayFormat == WINED3DFMT_A2R10G10B10)))
     2562    if (!(DisplayFormat == WINED3DFMT_B5G6R5_UNORM
     2563            || DisplayFormat == WINED3DFMT_B5G5R5X1_UNORM
     2564            || DisplayFormat == WINED3DFMT_B8G8R8X8_UNORM
     2565            || DisplayFormat == WINED3DFMT_B10G10R10A2_UNORM))
    26122566    {
    26132567        TRACE_(d3d_caps)("Format %s unsupported as display format\n", debug_d3dformat(DisplayFormat));
     
    26292583
    26302584    /* In FULLSCREEN mode R5G6B5 can only be mixed with backbuffer format R5G6B5 */
    2631     if( (DisplayFormat == WINED3DFMT_R5G6B5) && (BackBufferFormat != WINED3DFMT_R5G6B5) ) {
     2585    if (DisplayFormat == WINED3DFMT_B5G6R5_UNORM && BackBufferFormat != WINED3DFMT_B5G6R5_UNORM)
     2586    {
    26322587        TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
    26332588        return WINED3DERR_NOTAVAILABLE;
     
    26352590
    26362591    /* In FULLSCREEN mode X1R5G5B5 can only be mixed with backbuffer format *1R5G5B5 */
    2637     if( (DisplayFormat == WINED3DFMT_X1R5G5B5) && !((BackBufferFormat == WINED3DFMT_X1R5G5B5) || (BackBufferFormat == WINED3DFMT_A1R5G5B5)) ) {
     2592    if (DisplayFormat == WINED3DFMT_B5G5R5X1_UNORM
     2593            && !(BackBufferFormat == WINED3DFMT_B5G5R5X1_UNORM || BackBufferFormat == WINED3DFMT_B5G5R5A1_UNORM))
     2594    {
    26382595        TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
    26392596        return WINED3DERR_NOTAVAILABLE;
     
    26412598
    26422599    /* In FULLSCREEN mode X8R8G8B8 can only be mixed with backbuffer format *8R8G8B8 */
    2643     if( (DisplayFormat == WINED3DFMT_X8R8G8B8) && !((BackBufferFormat == WINED3DFMT_X8R8G8B8) || (BackBufferFormat == WINED3DFMT_A8R8G8B8)) ) {
     2600    if (DisplayFormat == WINED3DFMT_B8G8R8X8_UNORM
     2601            && !(BackBufferFormat == WINED3DFMT_B8G8R8X8_UNORM || BackBufferFormat == WINED3DFMT_B8G8R8A8_UNORM))
     2602    {
    26442603        TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
    26452604        return WINED3DERR_NOTAVAILABLE;
     
    26472606
    26482607    /* A2R10G10B10 is only allowed in fullscreen mode and it can only be mixed with backbuffer format A2R10G10B10 */
    2649     if( (DisplayFormat == WINED3DFMT_A2R10G10B10) && ((BackBufferFormat != WINED3DFMT_A2R10G10B10) || Windowed)) {
     2608    if (DisplayFormat == WINED3DFMT_B10G10R10A2_UNORM
     2609            && (BackBufferFormat != WINED3DFMT_B10G10R10A2_UNORM || Windowed))
     2610    {
    26502611        TRACE_(d3d_caps)("Unsupported display/backbuffer format combination %s/%s\n", debug_d3dformat(DisplayFormat), debug_d3dformat(BackBufferFormat));
    26512612        return WINED3DERR_NOTAVAILABLE;
     
    26712632        case WINED3DFMT_R8G8_SNORM:
    26722633        case WINED3DFMT_R16G16_SNORM:
    2673         case WINED3DFMT_L6V5U5:
    2674         case WINED3DFMT_X8L8V8U8:
     2634        case WINED3DFMT_R5G5_SNORM_L6_UNORM:
     2635        case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
    26752636        case WINED3DFMT_R8G8B8A8_SNORM:
    26762637            /* Ask the fixed function pipeline implementation if it can deal
     
    27962757    switch (format_desc->format)
    27972758    {
    2798         case WINED3DFMT_A8R8G8B8:
    2799         case WINED3DFMT_X8R8G8B8:
    2800         case WINED3DFMT_A4R4G4B4:
    2801         case WINED3DFMT_L8:
    2802         case WINED3DFMT_A8L8:
     2759        case WINED3DFMT_B8G8R8A8_UNORM:
     2760        case WINED3DFMT_B8G8R8X8_UNORM:
     2761        case WINED3DFMT_B4G4R4A4_UNORM:
     2762        case WINED3DFMT_L8_UNORM:
     2763        case WINED3DFMT_L8A8_UNORM:
    28032764        case WINED3DFMT_DXT1:
    28042765        case WINED3DFMT_DXT2:
     
    28222783     * doing the color fixup in shaders.
    28232784     * Note Windows drivers (at least on the Geforce 8800) also offer this on R5G6B5. */
    2824     if ((format_desc->format == WINED3DFMT_X8R8G8B8) || (format_desc->format == WINED3DFMT_A8R8G8B8))
     2785    if ((format_desc->format == WINED3DFMT_B8G8R8X8_UNORM) || (format_desc->format == WINED3DFMT_B8G8R8A8_UNORM))
    28252786    {
    28262787        int vs_selected_mode;
    28272788        int ps_selected_mode;
    2828         select_shader_mode(&adapter->gl_info, DeviceType, &ps_selected_mode, &vs_selected_mode);
     2789        select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
    28292790
    28302791        if((ps_selected_mode == SHADER_ARB) || (ps_selected_mode == SHADER_GLSL)) {
     
    28752836         *  supported: RGB(A) formats
    28762837         */
    2877         case WINED3DFMT_R8G8B8: /* Enable for dx7, blacklisted for 8 and 9 above */
    2878         case WINED3DFMT_A8R8G8B8:
    2879         case WINED3DFMT_X8R8G8B8:
    2880         case WINED3DFMT_R5G6B5:
    2881         case WINED3DFMT_X1R5G5B5:
    2882         case WINED3DFMT_A1R5G5B5:
    2883         case WINED3DFMT_A4R4G4B4:
     2838        case WINED3DFMT_B8G8R8_UNORM: /* Enable for dx7, blacklisted for 8 and 9 above */
     2839        case WINED3DFMT_B8G8R8A8_UNORM:
     2840        case WINED3DFMT_B8G8R8X8_UNORM:
     2841        case WINED3DFMT_B5G6R5_UNORM:
     2842        case WINED3DFMT_B5G5R5X1_UNORM:
     2843        case WINED3DFMT_B5G5R5A1_UNORM:
     2844        case WINED3DFMT_B4G4R4A4_UNORM:
    28842845        case WINED3DFMT_A8_UNORM:
    2885         case WINED3DFMT_X4R4G4B4:
     2846        case WINED3DFMT_B4G4R4X4_UNORM:
    28862847        case WINED3DFMT_R8G8B8A8_UNORM:
    2887         case WINED3DFMT_X8B8G8R8:
    2888         case WINED3DFMT_A2R10G10B10:
     2848        case WINED3DFMT_R8G8B8X8_UNORM:
     2849        case WINED3DFMT_B10G10R10A2_UNORM:
    28892850        case WINED3DFMT_R10G10B10A2_UNORM:
    28902851        case WINED3DFMT_R16G16_UNORM:
    2891         case WINED3DFMT_R16G16B16A16_UNORM:
    28922852            TRACE_(d3d_caps)("[OK]\n");
    28932853            return TRUE;
    28942854
    2895         case WINED3DFMT_R3G3B2:
     2855        case WINED3DFMT_B2G3R3_UNORM:
    28962856            TRACE_(d3d_caps)("[FAILED] - Not supported on Windows\n");
    28972857            return FALSE;
     
    29002860         *  supported: Palettized
    29012861         */
    2902         case WINED3DFMT_P8:
     2862        case WINED3DFMT_P8_UINT:
    29032863            TRACE_(d3d_caps)("[OK]\n");
    29042864            return TRUE;
    2905         /* No Windows driver offers A8P8, so don't offer it either */
    2906         case WINED3DFMT_A8P8:
     2865        /* No Windows driver offers WINED3DFMT_P8_UINT_A8_UNORM, so don't offer it either */
     2866        case WINED3DFMT_P8_UINT_A8_UNORM:
    29072867            return FALSE;
    29082868
     
    29102870         *  Supported: (Alpha)-Luminance
    29112871         */
    2912         case WINED3DFMT_L8:
    2913         case WINED3DFMT_A8L8:
    2914         case WINED3DFMT_L16:
     2872        case WINED3DFMT_L8_UNORM:
     2873        case WINED3DFMT_L8A8_UNORM:
     2874        case WINED3DFMT_L16_UNORM:
    29152875            TRACE_(d3d_caps)("[OK]\n");
    29162876            return TRUE;
    29172877
    29182878        /* Not supported on Windows, thus disabled */
    2919         case WINED3DFMT_A4L4:
     2879        case WINED3DFMT_L4A4_UNORM:
    29202880            TRACE_(d3d_caps)("[FAILED] - not supported on windows\n");
    29212881            return FALSE;
     
    29262886        case WINED3DFMT_D16_LOCKABLE:
    29272887        case WINED3DFMT_D16_UNORM:
    2928         case WINED3DFMT_D15S1:
    2929         case WINED3DFMT_D24X8:
    2930         case WINED3DFMT_D24X4S4:
    2931         case WINED3DFMT_D24S8:
    2932         case WINED3DFMT_D24FS8:
    2933         case WINED3DFMT_D32:
    2934         case WINED3DFMT_D32F_LOCKABLE:
     2888        case WINED3DFMT_S1_UINT_D15_UNORM:
     2889        case WINED3DFMT_X8D24_UNORM:
     2890        case WINED3DFMT_S4X4_UINT_D24_UNORM:
     2891        case WINED3DFMT_S8_UINT_D24_UNORM:
     2892        case WINED3DFMT_S8_UINT_D24_FLOAT:
     2893        case WINED3DFMT_D32_UNORM:
     2894        case WINED3DFMT_D32_FLOAT:
    29352895            return TRUE;
    29362896
     
    29402900         */
    29412901        case WINED3DFMT_R8G8_SNORM:
    2942         case WINED3DFMT_X8L8V8U8:
    2943         case WINED3DFMT_L6V5U5:
     2902        case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
     2903        case WINED3DFMT_R5G5_SNORM_L6_UNORM:
    29442904        case WINED3DFMT_R8G8B8A8_SNORM:
    29452905        case WINED3DFMT_R16G16_SNORM:
     
    29762936        case WINED3DFMT_R32_UINT:
    29772937        case WINED3DFMT_R16G16B16A16_SNORM:
    2978         case WINED3DFMT_A2W10V10U10:
    2979         case WINED3DFMT_W11V11U10:
     2938        case WINED3DFMT_R10G10B10_SNORM_A2_UNORM:
     2939        case WINED3DFMT_R10G11B11_SNORM:
    29802940            TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
    29812941            return FALSE;
    29822942
    29832943        /*****
    2984          *  WINED3DFMT_CxV8U8: Not supported right now
     2944         *  WINED3DFMT_R8G8_SNORM_Cx: Not supported right now
    29852945         */
    2986         case WINED3DFMT_CxV8U8:
     2946        case WINED3DFMT_R8G8_SNORM_Cx:
    29872947            TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
    29882948            return FALSE;
     
    30022962
    30032963            /* Not supported */
    3004         case WINED3DFMT_A8R3G3B2:
     2964        case WINED3DFMT_R16G16B16A16_UNORM:
     2965        case WINED3DFMT_B2G3R3A8_UNORM:
    30052966            TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
    30062967            return FALSE;
     
    31003061        switch(check_format_desc->format)
    31013062        {
    3102             case WINED3DFMT_R8G8B8:
    3103             case WINED3DFMT_A8R8G8B8:
    3104             case WINED3DFMT_X8R8G8B8:
    3105             case WINED3DFMT_R5G6B5:
    3106             case WINED3DFMT_X1R5G5B5:
    3107             case WINED3DFMT_A1R5G5B5:
    3108             case WINED3DFMT_A4R4G4B4:
    3109             case WINED3DFMT_R3G3B2:
     3063            case WINED3DFMT_B8G8R8_UNORM:
     3064            case WINED3DFMT_B8G8R8A8_UNORM:
     3065            case WINED3DFMT_B8G8R8X8_UNORM:
     3066            case WINED3DFMT_B5G6R5_UNORM:
     3067            case WINED3DFMT_B5G5R5X1_UNORM:
     3068            case WINED3DFMT_B5G5R5A1_UNORM:
     3069            case WINED3DFMT_B4G4R4A4_UNORM:
     3070            case WINED3DFMT_B2G3R3_UNORM:
    31103071            case WINED3DFMT_A8_UNORM:
    3111             case WINED3DFMT_A8R3G3B2:
    3112             case WINED3DFMT_X4R4G4B4:
     3072            case WINED3DFMT_B2G3R3A8_UNORM:
     3073            case WINED3DFMT_B4G4R4X4_UNORM:
    31133074            case WINED3DFMT_R10G10B10A2_UNORM:
    31143075            case WINED3DFMT_R8G8B8A8_UNORM:
    3115             case WINED3DFMT_X8B8G8R8:
     3076            case WINED3DFMT_R8G8B8X8_UNORM:
    31163077            case WINED3DFMT_R16G16_UNORM:
    3117             case WINED3DFMT_A2R10G10B10:
     3078            case WINED3DFMT_B10G10R10A2_UNORM:
    31183079            case WINED3DFMT_R16G16B16A16_UNORM:
    3119             case WINED3DFMT_P8:
     3080            case WINED3DFMT_P8_UINT:
    31203081                TRACE_(d3d_caps)("[OK]\n");
    31213082                return TRUE;
     
    31703131}
    31713132
    3172 static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, 
     3133static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
    31733134        WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat,
    3174         WINED3DSURFTYPE SurfaceType) {
     3135        WINED3DSURFTYPE SurfaceType)
     3136{
    31753137    IWineD3DImpl *This = (IWineD3DImpl *)iface;
    31763138    struct WineD3DAdapter *adapter = &This->adapters[Adapter];
     
    36063568         */
    36073569        switch(CheckFormat) {
    3608             case WINED3DFMT_P8:
    3609             case WINED3DFMT_A4L4:
     3570            case WINED3DFMT_P8_UINT:
     3571            case WINED3DFMT_L4A4_UNORM:
    36103572            case WINED3DFMT_R32_FLOAT:
    36113573            case WINED3DFMT_R16_FLOAT:
    3612             case WINED3DFMT_X8L8V8U8:
    3613             case WINED3DFMT_L6V5U5:
     3574            case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
     3575            case WINED3DFMT_R5G5_SNORM_L6_UNORM:
    36143576            case WINED3DFMT_R16G16_UNORM:
    36153577                TRACE_(d3d_caps)("[FAILED] - No converted formats on volumes\n");
     
    36863648    int ps_selected_mode;
    36873649
    3688     select_shader_mode(&adapter->gl_info, DeviceType, &ps_selected_mode, &vs_selected_mode);
     3650    select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
    36893651    if (vs_selected_mode == SHADER_GLSL || ps_selected_mode == SHADER_GLSL) {
    36903652        ret = &glsl_shader_backend;
     
    37043666    int ps_selected_mode;
    37053667
    3706     select_shader_mode(&adapter->gl_info, DeviceType, &ps_selected_mode, &vs_selected_mode);
     3668    select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
    37073669    if((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {
    37083670        return &arbfp_fragment_pipeline;
     
    37243686    int ps_selected_mode;
    37253687
    3726     select_shader_mode(&adapter->gl_info, DeviceType, &ps_selected_mode, &vs_selected_mode);
     3688    select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
    37273689    if((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) {
    37283690        return &arbfp_blit;
     
    37543716    }
    37553717
    3756     select_shader_mode(&adapter->gl_info, DeviceType, &ps_selected_mode, &vs_selected_mode);
     3718    select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
    37573719
    37583720    /* This function should *not* be modifying GL caps
     
    40764038
    40774039
     4040    /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
    40784041    pCaps->VertexProcessingCaps = WINED3DVTXPCAPS_DIRECTIONALLIGHTS |
    40794042                                  WINED3DVTXPCAPS_MATERIALSOURCE7   |
     
    40824045                                  WINED3DVTXPCAPS_VERTEXFOG         |
    40834046                                  WINED3DVTXPCAPS_TEXGEN;
    4084                                   /* FIXME: Add
    4085                                      D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */
    40864047
    40874048    pCaps->MaxPrimitiveCount   = 0xFFFFF; /* For now set 2^20-1 which is used by most >=Geforce3/Radeon8500 cards */
     
    43734334    object->devType                      = DeviceType;
    43744335
    4375     select_shader_mode(&adapter->gl_info, DeviceType,
    4376             &object->ps_selected_mode, &object->vs_selected_mode);
     4336    select_shader_mode(&adapter->gl_info, &object->ps_selected_mode, &object->vs_selected_mode);
    43774337    object->shader_backend = select_shader_backend(adapter, DeviceType);
    43784338
     
    44254385    *pParent = This->parent;
    44264386    return WINED3D_OK;
    4427 }
    4428 
    4429 ULONG WINAPI D3DCB_DefaultDestroySurface(IWineD3DSurface *pSurface) {
    4430     IUnknown* surfaceParent;
    4431     TRACE("(%p) call back\n", pSurface);
    4432 
    4433     /* Now, release the parent, which will take care of cleaning up the surface for us */
    4434     IWineD3DSurface_GetParent(pSurface, &surfaceParent);
    4435     IUnknown_Release(surfaceParent);
    4436     return IUnknown_Release(surfaceParent);
    44374387}
    44384388
     
    46724622     */
    46734623#ifdef USE_WIN32_OPENGL
    4674     glFinish = (void*)GetProcAddress(mod_gl, "glFinish");
    4675     glFlush = (void*)GetProcAddress(mod_gl, "glFlush");
     4624    wglFinish = (void*)GetProcAddress(mod_gl, "glFinish");
     4625    wglFlush = (void*)GetProcAddress(mod_gl, "glFlush");
    46764626#else
    4677     glFinish = (void*)pwglGetProcAddress("wglFinish");
    4678     glFlush = (void*)pwglGetProcAddress("wglFlush");
     4627    wglFinish = (void*)pwglGetProcAddress("wglFinish");
     4628    wglFlush = (void*)pwglGetProcAddress("wglFlush");
    46794629#endif
    46804630
     
    48824832        WineD3D_ReleaseFakeGLContext(&fake_gl_ctx);
    48834833
    4884         select_shader_mode(&adapter->gl_info, WINED3DDEVTYPE_HAL, &ps_selected_mode, &vs_selected_mode);
     4834        select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode);
    48854835        select_shader_max_constants(ps_selected_mode, vs_selected_mode, &adapter->gl_info);
    48864836        fillGLAttribFuncs(&adapter->gl_info);
     
    49414891    IWineD3DImpl_CreateDevice
    49424892};
     4893
     4894static void STDMETHODCALLTYPE wined3d_null_wined3d_object_destroyed(void *parent) {}
     4895
     4896const struct wined3d_parent_ops wined3d_null_parent_ops =
     4897{
     4898    wined3d_null_wined3d_object_destroyed,
     4899};
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/drawprim.c

    r22496 r23571  
    88 * Copyright 2006, 2008 Henri Verbeet
    99 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     10 * Copyright 2009 Henri Verbeet for CodeWeavers
    1011 *
    1112 * This library is free software; you can redistribute it and/or
     
    4647/* GL locking is done by the caller */
    4748static void drawStridedFast(IWineD3DDevice *iface, GLenum primitive_type,
    48         UINT min_vertex_idx, UINT max_vertex_idx, UINT count, UINT idx_size,
    49         const void *idx_data, UINT start_idx)
     49        UINT count, UINT idx_size, const void *idx_data, UINT start_idx)
    5050{
    5151    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
     
    5353    if (idx_size)
    5454    {
    55         TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, primitive_type, count, min_vertex_idx);
    56 
    57 #if 1
     55        TRACE("(%p) : glElements(%x, %d, ...)\n", This, primitive_type, count);
     56
    5857        glDrawElements(primitive_type, count,
    5958                idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
    6059                (const char *)idx_data + (idx_size * start_idx));
    6160        checkGLcall("glDrawElements");
    62 #else
    63         glDrawRangeElements(primitive_type, min_vertex_idx, max_vertex_idx, count,
    64                 idx_size == 2 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_INT,
    65                 (const char *)idx_data + (idx_size * start_idx));
    66         checkGLcall("glDrawRangeElements");
    67 #endif
    6861    }
    6962    else
     
    8477static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context *context,
    8578        const struct wined3d_stream_info *si, UINT NumVertexes, GLenum glPrimType,
    86         const void *idxData, UINT idxSize, UINT minIndex, UINT startIdx)
     79        const void *idxData, UINT idxSize, UINT startIdx)
    8780{
    8881    unsigned int               textureNo    = 0;
     
    125118    glBegin(glPrimType);
    126119
    127     element = &si->elements[WINED3D_FFP_POSITION];
    128     if (element->data) position = element->data + streamOffset[element->stream_idx];
    129 
    130     element = &si->elements[WINED3D_FFP_NORMAL];
    131     if (element->data) normal = element->data + streamOffset[element->stream_idx];
    132     else glNormal3f(0, 0, 0);
    133 
    134     element = &si->elements[WINED3D_FFP_DIFFUSE];
    135     if (element->data) diffuse = element->data + streamOffset[element->stream_idx];
    136     else glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
     120    if (si->use_map & (1 << WINED3D_FFP_POSITION))
     121    {
     122        element = &si->elements[WINED3D_FFP_POSITION];
     123        position = element->data + streamOffset[element->stream_idx];
     124    }
     125
     126    if (si->use_map & (1 << WINED3D_FFP_NORMAL))
     127    {
     128        element = &si->elements[WINED3D_FFP_NORMAL];
     129        normal = element->data + streamOffset[element->stream_idx];
     130    }
     131    else
     132    {
     133        glNormal3f(0, 0, 0);
     134    }
     135
    137136    num_untracked_materials = context->num_untracked_materials;
    138     if (num_untracked_materials && element->format_desc->format != WINED3DFMT_A8R8G8B8)
    139         FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->format_desc->format));
    140 
    141     element = &si->elements[WINED3D_FFP_SPECULAR];
    142     if (element->data)
    143     {
     137    if (si->use_map & (1 << WINED3D_FFP_DIFFUSE))
     138    {
     139        element = &si->elements[WINED3D_FFP_DIFFUSE];
     140        diffuse = element->data + streamOffset[element->stream_idx];
     141
     142        if (num_untracked_materials && element->format_desc->format != WINED3DFMT_B8G8R8A8_UNORM)
     143            FIXME("Implement diffuse color tracking from %s\n", debug_d3dformat(element->format_desc->format));
     144    }
     145    else
     146    {
     147        glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
     148    }
     149
     150    if (si->use_map & (1 << WINED3D_FFP_SPECULAR))
     151    {
     152        element = &si->elements[WINED3D_FFP_SPECULAR];
    144153        specular = element->data + streamOffset[element->stream_idx];
    145154
     
    152161            if (GL_SUPPORT(EXT_FOG_COORD))
    153162            {
    154                 if (element->format_desc->format == WINED3DFMT_A8R8G8B8) specular_fog = TRUE;
     163                if (element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) specular_fog = TRUE;
    155164                else FIXME("Implement fog coordinates from %s\n", debug_d3dformat(element->format_desc->format));
    156165            }
     
    176185    {
    177186        int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
    178         int texture_idx = This->texUnitMap[textureNo];
     187        DWORD texture_idx = This->texUnitMap[textureNo];
    179188
    180189        if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0)
     
    186195        if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;
    187196
    188         if (texture_idx == -1) continue;
     197        if (texture_idx == WINED3D_UNMAPPED_STAGE) continue;
    189198
    190199        if (coordIdx > 7)
     
    199208        }
    200209
    201         element = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
    202         if (element->data)
    203         {
     210        if (si->use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx)))
     211        {
     212            element = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
    204213            texCoords[coordIdx] = element->data + streamOffset[element->stream_idx];
    205214            tex_mask |= (1 << textureNo);
     
    244253            int coord_idx;
    245254            const void *ptr;
    246             int texture_idx;
     255            DWORD texture_idx;
    247256
    248257            if (!(tmp_tex_mask & 1)) continue;
     
    335344            GL_EXTCALL(glVertexAttrib4ubvARB(index, ptr));
    336345            break;
    337         case WINED3DFMT_A8R8G8B8:
     346        case WINED3DFMT_B8G8R8A8_UNORM:
    338347            if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
    339348            {
     
    419428/* GL locking is done by the caller */
    420429static void drawStridedSlowVs(IWineD3DDevice *iface, const struct wined3d_stream_info *si, UINT numberOfVertices,
    421         GLenum glPrimitiveType, const void *idxData, UINT idxSize, UINT minIndex, UINT startIdx)
     430        GLenum glPrimitiveType, const void *idxData, UINT idxSize, UINT startIdx)
    422431{
    423432    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
     
    463472        }
    464473
    465         for(i = MAX_ATTRIBS - 1; i >= 0; i--) {
    466             if(!si->elements[i].data) continue;
     474        for (i = MAX_ATTRIBS - 1; i >= 0; i--)
     475        {
     476            if (!(si->use_map & (1 << i))) continue;
    467477
    468478            ptr = si->elements[i].data +
     
    480490/* GL locking is done by the caller */
    481491static inline void drawStridedInstanced(IWineD3DDevice *iface, const struct wined3d_stream_info *si,
    482         UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, UINT idxSize, UINT minIndex,
     492        UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, UINT idxSize,
    483493        UINT startIdx)
    484494{
     
    500510    }
    501511
    502     TRACE("(%p) : glElements(%x, %d, %d, ...)\n", This, glPrimitiveType, numberOfVertices, minIndex);
     512    TRACE("(%p) : glElements(%x, %d, ...)\n", This, glPrimitiveType, numberOfVertices);
    503513
    504514    /* First, figure out how many instances we have to draw */
     
    518528    for (i = 0; i < sizeof(si->elements) / sizeof(*si->elements); ++i)
    519529    {
     530        if (!(si->use_map & (1 << i))) continue;
     531
    520532        if (stateblock->streamFlags[si->elements[i].stream_idx] & WINED3DSTREAMSOURCE_INSTANCEDATA)
    521533        {
     
    554566    for (i = 0; i < (sizeof(s->elements) / sizeof(*s->elements)); ++i)
    555567    {
    556         struct wined3d_stream_info_element *e = &s->elements[i];
     568        struct wined3d_stream_info_element *e;
     569
     570        if (!(s->use_map & (1 << i))) continue;
     571
     572        e = &s->elements[i];
    557573        if (e->buffer_object)
    558574        {
     
    565581
    566582/* Routine common to the draw primitive and draw indexed primitive routines */
    567 void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertices,
    568         UINT StartIdx, UINT idxSize, const void *idxData, UINT minIndex)
     583void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT idxSize, const void *idxData)
    569584{
    570585
     
    616631        const struct wined3d_stream_info *stream_info = &This->strided_streams;
    617632        struct wined3d_stream_info stridedlcl;
    618 
    619         if (!numberOfVertices) numberOfVertices = index_count;
    620633
    621634        if (!use_vs(This->stateBlock))
     
    666679                    TRACE("Using immediate mode with vertex shaders for half float emulation\n");
    667680                }
    668                 drawStridedSlowVs(iface, stream_info, index_count, glPrimType, idxData, idxSize, minIndex, StartIdx);
     681                drawStridedSlowVs(iface, stream_info, index_count, glPrimType, idxData, idxSize, StartIdx);
    669682            } else {
    670683                drawStridedSlow(iface, context, stream_info, index_count,
    671                         glPrimType, idxData, idxSize, minIndex, StartIdx);
     684                        glPrimType, idxData, idxSize, StartIdx);
    672685            }
    673686        } else if(This->instancedDraw) {
    674687            /* Instancing emulation with mixing immediate mode and arrays */
    675688            drawStridedInstanced(iface, &This->strided_streams, index_count,
    676                     glPrimType, idxData, idxSize, minIndex, StartIdx);
     689                    glPrimType, idxData, idxSize, StartIdx);
    677690        } else {
    678             drawStridedFast(iface, glPrimType, minIndex, minIndex + numberOfVertices - 1,
    679                     index_count, idxSize, idxData, StartIdx);
     691            drawStridedFast(iface, glPrimType, index_count, idxSize, idxData, StartIdx);
    680692        }
    681693    }
     
    689701    {
    690702        static long int primCounter = 0;
    691         /* NOTE: set primCounter to the value reported by drawprim 
     703        /* NOTE: set primCounter to the value reported by drawprim
    692704           before you want to to write frame makeup to /tmp */
    693705        if (primCounter >= 0) {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c

    r22496 r23571  
    22 * GLSL pixel and vertex shader implementation
    33 *
    4  * Copyright 2006 Jason Green 
     4 * Copyright 2006 Jason Green
    55 * Copyright 2006-2007 Henri Verbeet
    66 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     
    198198    {
    199199        "Vertex shader was successfully compiled to run on hardware.\n",    /* fglrx          */
    200         "Fragment shader was successfully compiled to run on hardware.\n",  /* fglrx          */
     200        "Fragment shader was successfully compiled to run on hardware.\n",  /* fglrx, with \n */
     201        "Fragment shader was successfully compiled to run on hardware.",    /* fglrx, no \n   */
    201202        "Fragment shader(s) linked, vertex shader(s) linked. \n ",          /* fglrx, with \n */
    202203        "Fragment shader(s) linked, vertex shader(s) linked.",              /* fglrx, no \n   */
    203204        "Vertex shader(s) linked, no fragment shader(s) defined. \n ",      /* fglrx, with \n */
    204205        "Vertex shader(s) linked, no fragment shader(s) defined.",          /* fglrx, no \n   */
    205         "Fragment shader was successfully compiled to run on hardware.\n"
     206        "Fragment shader(s) linked, no vertex shader(s) defined. \n ",      /* fglrx, with \n */
    206207        "Fragment shader(s) linked, no vertex shader(s) defined.",          /* fglrx, no \n   */
    207         "Fragment shader(s) linked, no vertex shader(s) defined. \n ",      /* fglrx, with \n */
    208208    };
    209209
     
    825825    unsigned int i, extra_constants_needed = 0;
    826826    const local_constant *lconst;
     827    DWORD map;
    827828
    828829    /* There are some minor differences between pixel and vertex shaders */
     
    831832
    832833    /* Prototype the subroutines */
    833     for (i = 0; i < This->baseShader.limits.label; i++) {
    834         if (reg_maps->labels[i])
    835             shader_addline(buffer, "void subroutine%u();\n", i);
     834    for (i = 0, map = reg_maps->labels; map; map >>= 1, ++i)
     835    {
     836        if (map & 1) shader_addline(buffer, "void subroutine%u();\n", i);
    836837    }
    837838
     
    909910        }
    910911    } else {
    911         for(i = 0; i < (sizeof(reg_maps->bumpmat) / sizeof(reg_maps->bumpmat[0])); i++) {
    912             if(!reg_maps->bumpmat[i]) {
    913                 continue;
    914             }
     912        for (i = 0, map = reg_maps->bumpmat; map; map >>= 1, ++i)
     913        {
     914            if (!(map & 1)) continue;
    915915
    916916            shader_addline(buffer, "uniform mat2 bumpenvmat%d;\n", i);
    917917
    918             if(reg_maps->luminanceparams) {
     918            if (reg_maps->luminanceparams & (1 << i))
     919            {
    919920                shader_addline(buffer, "uniform float luminancescale%d;\n", i);
    920921                shader_addline(buffer, "uniform float luminanceoffset%d;\n", i);
     
    950951    }
    951952
    952     /* Declare texture samplers */ 
     953    /* Declare texture samplers */
    953954    for (i = 0; i < This->baseShader.limits.sampler; i++) {
    954955        if (reg_maps->sampler_type[i])
     
    984985     * This is NOT done inside the loop that declares the texture samplers since the NP2 fixup code
    985986     * is currently only used for the GeforceFX series and when forcing the ARB_npot extension off.
    986      * Modern cards just skip the code anyway, so put it inside a seperate loop. */
     987     * Modern cards just skip the code anyway, so put it inside a separate loop. */
    987988    if (pshader && ps_args->np2_fixup) {
    988989
     
    10131014
    10141015    /* Declare address variables */
    1015     for (i = 0; i < This->baseShader.limits.address; i++) {
    1016         if (reg_maps->address[i])
    1017             shader_addline(buffer, "ivec4 A%d;\n", i);
     1016    for (i = 0, map = reg_maps->address; map; map >>= 1, ++i)
     1017    {
     1018        if (map & 1) shader_addline(buffer, "ivec4 A%u;\n", i);
    10181019    }
    10191020
    10201021    /* Declare texture coordinate temporaries and initialize them */
    1021     for (i = 0; i < This->baseShader.limits.texcoord; i++) {
    1022         if (reg_maps->texcoord[i])
    1023             shader_addline(buffer, "vec4 T%u = gl_TexCoord[%u];\n", i, i);
     1022    for (i = 0, map = reg_maps->texcoord; map; map >>= 1, ++i)
     1023    {
     1024        if (map & 1) shader_addline(buffer, "vec4 T%u = gl_TexCoord[%u];\n", i, i);
    10241025    }
    10251026
     
    10471048
    10481049    /* Declare temporary variables */
    1049     for(i = 0; i < This->baseShader.limits.temporary; i++) {
    1050         if (reg_maps->temporary[i])
    1051             shader_addline(buffer, "vec4 R%u;\n", i);
     1050    for (i = 0, map = reg_maps->temporary; map; map >>= 1, ++i)
     1051    {
     1052        if (map & 1) shader_addline(buffer, "vec4 R%u;\n", i);
    10521053    }
    10531054
     
    10551056    if (reg_maps->shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
    10561057    {
    1057         WORD map = reg_maps->input_registers;
    1058 
    1059         for (i = 0; map; map >>= 1, ++i)
     1058        for (i = 0, map = reg_maps->input_registers; map; map >>= 1, ++i)
    10601059        {
    1061             if (!(map & 1)) continue;
    1062 
    1063             shader_addline(buffer, "attribute vec4 attrib%i;\n", i);
     1060            if (map & 1) shader_addline(buffer, "attribute vec4 attrib%i;\n", i);
    10641061        }
    10651062    }
     
    11181115/** Used for opcode modifiers - They multiply the result by the specified amount */
    11191116static const char * const shift_glsl_tab[] = {
    1120     "",           /*  0 (none) */ 
    1121     "2.0 * ",     /*  1 (x2)   */ 
    1122     "4.0 * ",     /*  2 (x4)   */ 
    1123     "8.0 * ",     /*  3 (x8)   */ 
    1124     "16.0 * ",    /*  4 (x16)  */ 
    1125     "32.0 * ",    /*  5 (x32)  */ 
    1126     "",           /*  6 (x64)  */ 
    1127     "",           /*  7 (x128) */ 
    1128     "",           /*  8 (d256) */ 
    1129     "",           /*  9 (d128) */ 
    1130     "",           /* 10 (d64)  */ 
    1131     "",           /* 11 (d32)  */ 
    1132     "0.0625 * ",  /* 12 (d16)  */ 
    1133     "0.125 * ",   /* 13 (d8)   */ 
    1134     "0.25 * ",    /* 14 (d4)   */ 
    1135     "0.5 * "      /* 15 (d2)   */ 
     1117    "",           /*  0 (none) */
     1118    "2.0 * ",     /*  1 (x2)   */
     1119    "4.0 * ",     /*  2 (x4)   */
     1120    "8.0 * ",     /*  3 (x8)   */
     1121    "16.0 * ",    /*  4 (x16)  */
     1122    "32.0 * ",    /*  5 (x32)  */
     1123    "",           /*  6 (x64)  */
     1124    "",           /*  7 (x128) */
     1125    "",           /*  8 (d256) */
     1126    "",           /*  9 (d128) */
     1127    "",           /* 10 (d64)  */
     1128    "",           /* 11 (d32)  */
     1129    "0.0625 * ",  /* 12 (d16)  */
     1130    "0.125 * ",   /* 13 (d8)   */
     1131    "0.25 * ",    /* 14 (d4)   */
     1132    "0.5 * "      /* 15 (d2)   */
    11361133};
    11371134
     
    17911788
    17921789/*****************************************************************************
    1793  *
    17941790 * Begin processing individual instruction opcodes
    1795  *
    17961791 ****************************************************************************/
    17971792
     
    22782273}
    22792274
    2280 /** Handles transforming all WINED3DSIO_M?x? opcodes for
    2281     Vertex shaders to GLSL codes */
     2275/* Handles transforming all WINED3DSIO_M?x? opcodes for
     2276   Vertex shaders to GLSL codes */
    22822277static void shader_glsl_mnxn(const struct wined3d_shader_instruction *ins)
    22832278{
     
    23352330
    23362331/**
    2337     The LRP instruction performs a component-wise linear interpolation 
     2332    The LRP instruction performs a component-wise linear interpolation
    23382333    between the second and third operands using the first operand as the
    23392334    blend factor.  Equation:  (dst = src2 + src0 * (src1 - src2))
     
    24322427 * VS 2.0 requires that specific cosine and sine constants be passed to this instruction so the hardware
    24332428 * can handle it.  But, these functions are built-in for GLSL, so we can just ignore the last 2 params.
    2434  * 
     2429 *
    24352430 * dst.x = cos(src0.?)
    24362431 * dst.y = sin(src0.?)
     
    24962491    }
    24972492
    2498     if(control_values) {
    2499         if(control_values[2] > 0) {
    2500             shader_addline(ins->ctx->buffer, "for (aL%u = %d; aL%u < (%d * %d + %d); aL%u += %d) {\n",
    2501                     shader->baseShader.cur_loop_depth, control_values[1],
    2502                     shader->baseShader.cur_loop_depth, control_values[0], control_values[2], control_values[1],
    2503                     shader->baseShader.cur_loop_depth, control_values[2]);
    2504         } else if(control_values[2] == 0) {
    2505             shader_addline(ins->ctx->buffer, "for (aL%u = %d, tmpInt%u = 0; tmpInt%u < %d; tmpInt%u++) {\n",
    2506                     shader->baseShader.cur_loop_depth, control_values[1], shader->baseShader.cur_loop_depth,
    2507                     shader->baseShader.cur_loop_depth, control_values[0],
     2493    if (control_values)
     2494    {
     2495        struct wined3d_shader_loop_control loop_control;
     2496        loop_control.count = control_values[0];
     2497        loop_control.start = control_values[1];
     2498        loop_control.step = (int)control_values[2];
     2499
     2500        if (loop_control.step > 0)
     2501        {
     2502            shader_addline(ins->ctx->buffer, "for (aL%u = %u; aL%u < (%u * %d + %u); aL%u += %d) {\n",
     2503                    shader->baseShader.cur_loop_depth, loop_control.start,
     2504                    shader->baseShader.cur_loop_depth, loop_control.count, loop_control.step, loop_control.start,
     2505                    shader->baseShader.cur_loop_depth, loop_control.step);
     2506        }
     2507        else if (loop_control.step < 0)
     2508        {
     2509            shader_addline(ins->ctx->buffer, "for (aL%u = %u; aL%u > (%u * %d + %u); aL%u += %d) {\n",
     2510                    shader->baseShader.cur_loop_depth, loop_control.start,
     2511                    shader->baseShader.cur_loop_depth, loop_control.count, loop_control.step, loop_control.start,
     2512                    shader->baseShader.cur_loop_depth, loop_control.step);
     2513        }
     2514        else
     2515        {
     2516            shader_addline(ins->ctx->buffer, "for (aL%u = %u, tmpInt%u = 0; tmpInt%u < %u; tmpInt%u++) {\n",
     2517                    shader->baseShader.cur_loop_depth, loop_control.start, shader->baseShader.cur_loop_depth,
     2518                    shader->baseShader.cur_loop_depth, loop_control.count,
    25082519                    shader->baseShader.cur_loop_depth);
    2509         } else {
    2510             shader_addline(ins->ctx->buffer, "for (aL%u = %d; aL%u > (%d * %d + %d); aL%u += %d) {\n",
    2511                     shader->baseShader.cur_loop_depth, control_values[1],
    2512                     shader->baseShader.cur_loop_depth, control_values[0], control_values[2], control_values[1],
    2513                     shader->baseShader.cur_loop_depth, control_values[2]);
    25142520        }
    25152521    } else {
     
    26482654 * Pixel Shader Specific Code begins here
    26492655 ********************************************/
    2650 static void pshader_glsl_tex(const struct wined3d_shader_instruction *ins)
     2656static void shader_glsl_tex(const struct wined3d_shader_instruction *ins)
    26512657{
    26522658    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
     
    27512757    if(!GL_SUPPORT(ARB_SHADER_TEXTURE_LOD)) {
    27522758        FIXME("texldd used, but not supported by hardware. Falling back to regular tex\n");
    2753         return pshader_glsl_tex(ins);
     2759        return shader_glsl_tex(ins);
    27542760    }
    27552761
     
    27742780    IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)ins->ctx->shader;
    27752781    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
     2782    const struct wined3d_gl_info *gl_info = &deviceImpl->adapter->gl_info;
    27762783    glsl_sample_function_t sample_function;
    27772784    glsl_src_param_t coord_param, lod_param;
     
    27922799    shader_glsl_add_src_param(ins, &ins->src[0], WINED3DSP_WRITEMASK_3, &lod_param);
    27932800
    2794     if (shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type))
     2801    if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD]
     2802            && shader_is_pshader_version(ins->ctx->reg_maps->shader_version.type))
    27952803    {
    27962804        /* The GLSL spec claims the Lod sampling functions are only supported in vertex shaders.
     
    28022810}
    28032811
    2804 static void pshader_glsl_texcoord(const struct wined3d_shader_instruction *ins)
     2812static void shader_glsl_texcoord(const struct wined3d_shader_instruction *ins)
    28052813{
    28062814    /* FIXME: Make this work for more than just 2D textures */
     
    28512859 * Take a 3-component dot product of the TexCoord[dstreg] and src,
    28522860 * then perform a 1D texture lookup from stage dstregnum, place into dst. */
    2853 static void pshader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins)
     2861static void shader_glsl_texdp3tex(const struct wined3d_shader_instruction *ins)
    28542862{
    28552863    glsl_src_param_t src0_param;
     
    28952903/** Process the WINED3DSIO_TEXDP3 instruction in GLSL:
    28962904 * Take a 3-component dot product of the TexCoord[dstreg] and src. */
    2897 static void pshader_glsl_texdp3(const struct wined3d_shader_instruction *ins)
     2905static void shader_glsl_texdp3(const struct wined3d_shader_instruction *ins)
    28982906{
    28992907    glsl_src_param_t src0_param;
     
    29162924/** Process the WINED3DSIO_TEXDEPTH instruction in GLSL:
    29172925 * Calculate the depth as dst.x / dst.y   */
    2918 static void pshader_glsl_texdepth(const struct wined3d_shader_instruction *ins)
     2926static void shader_glsl_texdepth(const struct wined3d_shader_instruction *ins)
    29192927{
    29202928    glsl_dst_param_t dst_param;
     
    29372945 * depth = (tmp0.y == 0.0) ? 1.0 : tmp0.x / tmp0.y
    29382946 */
    2939 static void pshader_glsl_texm3x2depth(const struct wined3d_shader_instruction *ins)
     2947static void shader_glsl_texm3x2depth(const struct wined3d_shader_instruction *ins)
    29402948{
    29412949    DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     
    29512959/** Process the WINED3DSIO_TEXM3X2PAD instruction in GLSL
    29522960 * Calculate the 1st of a 2-row matrix multiplication. */
    2953 static void pshader_glsl_texm3x2pad(const struct wined3d_shader_instruction *ins)
     2961static void shader_glsl_texm3x2pad(const struct wined3d_shader_instruction *ins)
    29542962{
    29552963    DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     
    29642972/** Process the WINED3DSIO_TEXM3X3PAD instruction in GLSL
    29652973 * Calculate the 1st or 2nd row of a 3-row matrix multiplication. */
    2966 static void pshader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins)
     2974static void shader_glsl_texm3x3pad(const struct wined3d_shader_instruction *ins)
    29672975{
    29682976    IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
     
    29782986}
    29792987
    2980 static void pshader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins)
     2988static void shader_glsl_texm3x2tex(const struct wined3d_shader_instruction *ins)
    29812989{
    29822990    DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     
    29983006/** Process the WINED3DSIO_TEXM3X3TEX instruction in GLSL
    29993007 * Perform the 3rd row of a 3x3 matrix multiply, then sample the texture using the calculated coordinates */
    3000 static void pshader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins)
     3008static void shader_glsl_texm3x3tex(const struct wined3d_shader_instruction *ins)
    30013009{
    30023010    DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     
    30223030/** Process the WINED3DSIO_TEXM3X3 instruction in GLSL
    30233031 * Perform the 3rd row of a 3x3 matrix multiply */
    3024 static void pshader_glsl_texm3x3(const struct wined3d_shader_instruction *ins)
     3032static void shader_glsl_texm3x3(const struct wined3d_shader_instruction *ins)
    30253033{
    30263034    DWORD src_mask = WINED3DSP_WRITEMASK_0 | WINED3DSP_WRITEMASK_1 | WINED3DSP_WRITEMASK_2;
     
    30403048}
    30413049
    3042 /** Process the WINED3DSIO_TEXM3X3SPEC instruction in GLSL
     3050/* Process the WINED3DSIO_TEXM3X3SPEC instruction in GLSL
    30433051 * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */
    3044 static void pshader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins)
     3052static void shader_glsl_texm3x3spec(const struct wined3d_shader_instruction *ins)
    30453053{
    30463054    IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
     
    30713079}
    30723080
    3073 /** Process the WINED3DSIO_TEXM3X3VSPEC instruction in GLSL
     3081/* Process the WINED3DSIO_TEXM3X3VSPEC instruction in GLSL
    30743082 * Perform the final texture lookup based on the previous 2 3x3 matrix multiplies */
    3075 static void pshader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *ins)
     3083static void shader_glsl_texm3x3vspec(const struct wined3d_shader_instruction *ins)
    30763084{
    30773085    IWineD3DPixelShaderImpl *shader = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
     
    31073115 * texbem is pshader <= 1.3 only, this saves a few version checks
    31083116 */
    3109 static void pshader_glsl_texbem(const struct wined3d_shader_instruction *ins)
     3117static void shader_glsl_texbem(const struct wined3d_shader_instruction *ins)
    31103118{
    31113119    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)ins->ctx->shader;
     
    31663174}
    31673175
    3168 static void pshader_glsl_bem(const struct wined3d_shader_instruction *ins)
     3176static void shader_glsl_bem(const struct wined3d_shader_instruction *ins)
    31693177{
    31703178    glsl_src_param_t src0_param, src1_param;
     
    31813189/** Process the WINED3DSIO_TEXREG2AR instruction in GLSL
    31823190 * Sample 2D texture at dst using the alpha & red (wx) components of src as texture coordinates */
    3183 static void pshader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins)
     3191static void shader_glsl_texreg2ar(const struct wined3d_shader_instruction *ins)
    31843192{
    31853193    glsl_src_param_t src0_param;
     
    31973205/** Process the WINED3DSIO_TEXREG2GB instruction in GLSL
    31983206 * Sample 2D texture at dst using the green & blue (yz) components of src as texture coordinates */
    3199 static void pshader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins)
     3207static void shader_glsl_texreg2gb(const struct wined3d_shader_instruction *ins)
    32003208{
    32013209    glsl_src_param_t src0_param;
     
    32133221/** Process the WINED3DSIO_TEXREG2RGB instruction in GLSL
    32143222 * Sample texture at dst using the rgb (xyz) components of src as texture coordinates */
    3215 static void pshader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins)
     3223static void shader_glsl_texreg2rgb(const struct wined3d_shader_instruction *ins)
    32163224{
    32173225    glsl_src_param_t src0_param;
     
    32303238/** Process the WINED3DSIO_TEXKILL instruction in GLSL.
    32313239 * If any of the first 3 components are < 0, discard this pixel */
    3232 static void pshader_glsl_texkill(const struct wined3d_shader_instruction *ins)
     3240static void shader_glsl_texkill(const struct wined3d_shader_instruction *ins)
    32333241{
    32343242    glsl_dst_param_t dst_param;
     
    32513259/** Process the WINED3DSIO_DP2ADD instruction in GLSL.
    32523260 * dst = dot2(src0, src1) + src2 */
    3253 static void pshader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
     3261static void shader_glsl_dp2add(const struct wined3d_shader_instruction *ins)
    32543262{
    32553263    glsl_src_param_t src0_param;
     
    32753283}
    32763284
    3277 static void pshader_glsl_input_pack(IWineD3DPixelShader *iface, struct wined3d_shader_buffer *buffer,
     3285static void shader_glsl_input_pack(IWineD3DPixelShader *iface, struct wined3d_shader_buffer *buffer,
    32783286        const struct wined3d_shader_signature_element *input_signature, const struct shader_reg_maps *reg_maps,
    32793287        enum vertexprocessing_mode vertexprocessing)
     
    37403748    if (reg_maps->shader_version.major >= 3 && args->vp_mode != vertexshader)
    37413749    {
    3742         pshader_glsl_input_pack((IWineD3DPixelShader *) This, buffer, This->input_signature, reg_maps, args->vp_mode);
     3750        shader_glsl_input_pack((IWineD3DPixelShader *) This, buffer, This->input_signature, reg_maps, args->vp_mode);
    37433751    }
    37443752
     
    38833891    GLhandleARB ret;
    38843892
    3885     if(!shader->backend_priv) {
    3886         shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
    3887     }
    3888     shader_data = shader->backend_priv;
     3893    if (!shader->baseShader.backend_data)
     3894    {
     3895        shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
     3896        if (!shader->baseShader.backend_data)
     3897        {
     3898            ERR("Failed to allocate backend data.\n");
     3899            return 0;
     3900        }
     3901    }
     3902    shader_data = shader->baseShader.backend_data;
    38893903
    38903904    /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
     
    39523966    GLhandleARB ret;
    39533967
    3954     if(!shader->backend_priv) {
    3955         shader->backend_priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
    3956     }
    3957     shader_data = shader->backend_priv;
     3968    if (!shader->baseShader.backend_data)
     3969    {
     3970        shader->baseShader.backend_data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*shader_data));
     3971        if (!shader->baseShader.backend_data)
     3972        {
     3973            ERR("Failed to allocate backend data.\n");
     3974            return 0;
     3975        }
     3976    }
     3977    shader_data = shader->baseShader.backend_data;
    39583978
    39593979    /* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
     
    43544374        struct glsl_pshader_private *shader_data;
    43554375        ps = (IWineD3DPixelShaderImpl *) This;
    4356         shader_data = ps->backend_priv;
     4376        shader_data = ps->baseShader.backend_data;
    43574377        if(!shader_data || shader_data->num_gl_shaders == 0)
    43584378        {
    43594379            HeapFree(GetProcessHeap(), 0, shader_data);
    4360             ps->backend_priv = NULL;
     4380            ps->baseShader.backend_data = NULL;
    43614381            return;
    43624382        }
     
    43744394        struct glsl_vshader_private *shader_data;
    43754395        vs = (IWineD3DVertexShaderImpl *) This;
    4376         shader_data = vs->backend_priv;
     4396        shader_data = vs->baseShader.backend_data;
    43774397        if(!shader_data || shader_data->num_gl_shaders == 0)
    43784398        {
    43794399            HeapFree(GetProcessHeap(), 0, shader_data);
    4380             vs->backend_priv = NULL;
     4400            vs->baseShader.backend_data = NULL;
    43814401            return;
    43824402        }
     
    44144434    if(pshader) {
    44154435        UINT i;
    4416         struct glsl_pshader_private *shader_data = ps->backend_priv;
     4436        struct glsl_pshader_private *shader_data = ps->baseShader.backend_data;
    44174437
    44184438        ENTER_GL();
     
    44254445        HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
    44264446        HeapFree(GetProcessHeap(), 0, shader_data);
    4427         ps->backend_priv = NULL;
     4447        ps->baseShader.backend_data = NULL;
    44284448    } else {
    44294449        UINT i;
    4430         struct glsl_vshader_private *shader_data = vs->backend_priv;
     4450        struct glsl_vshader_private *shader_data = vs->baseShader.backend_data;
    44314451
    44324452        ENTER_GL();
     
    44394459        HeapFree(GetProcessHeap(), 0, shader_data->gl_shaders);
    44404460        HeapFree(GetProcessHeap(), 0, shader_data);
    4441         vs->backend_priv = NULL;
     4461        vs->baseShader.backend_data = NULL;
    44424462    }
    44434463}
     
    45804600{
    45814601    /* Nvidia Geforce6/7 or Ati R4xx/R5xx cards with GLSL support, support VS 3.0 but older Nvidia/Ati
    4582      * models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support using
    4583      * vs_nv_version which is based on NV_vertex_program.
     4602     * models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support based
     4603     * on the version of NV_vertex_program.
    45844604     * For Ati cards there's no way using glsl (it abstracts the lowlevel info away) and also not
    45854605     * using ARB_vertex_program. It is safe to assume that when a card supports pixel shader 2.0 it
     
    45874607     * of native instructions, so use that here. For more info see the pixel shader versioning code below.
    45884608     */
    4589     if((GLINFO_LOCATION.vs_nv_version == VS_VERSION_20) || (GLINFO_LOCATION.ps_arb_max_instructions <= 512))
     4609    if ((gl_info->supported[NV_VERTEX_PROGRAM2] && !gl_info->supported[NV_VERTEX_PROGRAM3])
     4610            || gl_info->ps_arb_max_instructions <= 512)
    45904611        pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
    45914612    else
     
    46054626     * NOTE: ps3.0 hardware requires 512 or more instructions but ati and nvidia offer 'enough' (1024 vs 4096) on their most basic ps3.0 hardware.
    46064627     */
    4607     if((GLINFO_LOCATION.ps_nv_version == PS_VERSION_20) || (GLINFO_LOCATION.ps_arb_max_instructions <= 512))
     4628    if ((gl_info->supported[NV_FRAGMENT_PROGRAM] && !gl_info->supported[NV_FRAGMENT_PROGRAM2])
     4629            || (gl_info->ps_arb_max_instructions <= 512))
    46084630        pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
    46094631    else
     
    46534675    /* WINED3DSIH_ABS           */ shader_glsl_map2gl,
    46544676    /* WINED3DSIH_ADD           */ shader_glsl_arith,
    4655     /* WINED3DSIH_BEM           */ pshader_glsl_bem,
     4677    /* WINED3DSIH_BEM           */ shader_glsl_bem,
    46564678    /* WINED3DSIH_BREAK         */ shader_glsl_break,
    46574679    /* WINED3DSIH_BREAKC        */ shader_glsl_breakc,
     
    46664688    /* WINED3DSIH_DEFB          */ NULL,
    46674689    /* WINED3DSIH_DEFI          */ NULL,
    4668     /* WINED3DSIH_DP2ADD        */ pshader_glsl_dp2add,
     4690    /* WINED3DSIH_DP2ADD        */ shader_glsl_dp2add,
    46694691    /* WINED3DSIH_DP3           */ shader_glsl_dot,
    46704692    /* WINED3DSIH_DP4           */ shader_glsl_dot,
     
    47124734    /* WINED3DSIH_SLT           */ shader_glsl_compare,
    47134735    /* WINED3DSIH_SUB           */ shader_glsl_arith,
    4714     /* WINED3DSIH_TEX           */ pshader_glsl_tex,
    4715     /* WINED3DSIH_TEXBEM        */ pshader_glsl_texbem,
    4716     /* WINED3DSIH_TEXBEML       */ pshader_glsl_texbem,
    4717     /* WINED3DSIH_TEXCOORD      */ pshader_glsl_texcoord,
    4718     /* WINED3DSIH_TEXDEPTH      */ pshader_glsl_texdepth,
    4719     /* WINED3DSIH_TEXDP3        */ pshader_glsl_texdp3,
    4720     /* WINED3DSIH_TEXDP3TEX     */ pshader_glsl_texdp3tex,
    4721     /* WINED3DSIH_TEXKILL       */ pshader_glsl_texkill,
     4736    /* WINED3DSIH_TEX           */ shader_glsl_tex,
     4737    /* WINED3DSIH_TEXBEM        */ shader_glsl_texbem,
     4738    /* WINED3DSIH_TEXBEML       */ shader_glsl_texbem,
     4739    /* WINED3DSIH_TEXCOORD      */ shader_glsl_texcoord,
     4740    /* WINED3DSIH_TEXDEPTH      */ shader_glsl_texdepth,
     4741    /* WINED3DSIH_TEXDP3        */ shader_glsl_texdp3,
     4742    /* WINED3DSIH_TEXDP3TEX     */ shader_glsl_texdp3tex,
     4743    /* WINED3DSIH_TEXKILL       */ shader_glsl_texkill,
    47224744    /* WINED3DSIH_TEXLDD        */ shader_glsl_texldd,
    47234745    /* WINED3DSIH_TEXLDL        */ shader_glsl_texldl,
    4724     /* WINED3DSIH_TEXM3x2DEPTH  */ pshader_glsl_texm3x2depth,
    4725     /* WINED3DSIH_TEXM3x2PAD    */ pshader_glsl_texm3x2pad,
    4726     /* WINED3DSIH_TEXM3x2TEX    */ pshader_glsl_texm3x2tex,
    4727     /* WINED3DSIH_TEXM3x3       */ pshader_glsl_texm3x3,
     4746    /* WINED3DSIH_TEXM3x2DEPTH  */ shader_glsl_texm3x2depth,
     4747    /* WINED3DSIH_TEXM3x2PAD    */ shader_glsl_texm3x2pad,
     4748    /* WINED3DSIH_TEXM3x2TEX    */ shader_glsl_texm3x2tex,
     4749    /* WINED3DSIH_TEXM3x3       */ shader_glsl_texm3x3,
    47284750    /* WINED3DSIH_TEXM3x3DIFF   */ NULL,
    4729     /* WINED3DSIH_TEXM3x3PAD    */ pshader_glsl_texm3x3pad,
    4730     /* WINED3DSIH_TEXM3x3SPEC   */ pshader_glsl_texm3x3spec,
    4731     /* WINED3DSIH_TEXM3x3TEX    */ pshader_glsl_texm3x3tex,
    4732     /* WINED3DSIH_TEXM3x3VSPEC  */ pshader_glsl_texm3x3vspec,
    4733     /* WINED3DSIH_TEXREG2AR     */ pshader_glsl_texreg2ar,
    4734     /* WINED3DSIH_TEXREG2GB     */ pshader_glsl_texreg2gb,
    4735     /* WINED3DSIH_TEXREG2RGB    */ pshader_glsl_texreg2rgb,
     4751    /* WINED3DSIH_TEXM3x3PAD    */ shader_glsl_texm3x3pad,
     4752    /* WINED3DSIH_TEXM3x3SPEC   */ shader_glsl_texm3x3spec,
     4753    /* WINED3DSIH_TEXM3x3TEX    */ shader_glsl_texm3x3tex,
     4754    /* WINED3DSIH_TEXM3x3VSPEC  */ shader_glsl_texm3x3vspec,
     4755    /* WINED3DSIH_TEXREG2AR     */ shader_glsl_texreg2ar,
     4756    /* WINED3DSIH_TEXREG2GB     */ shader_glsl_texreg2gb,
     4757    /* WINED3DSIH_TEXREG2RGB    */ shader_glsl_texreg2rgb,
    47364758};
    47374759
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/pixelshader.c

    r22496 r23571  
    88 * Copyright 2006 Ivan Gyurdiev
    99 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     10 * Copyright 2009 Henri Verbeet for CodeWeavers
    1011 *
    1112 * This library is free software; you can redistribute it and/or
     
    8182    {
    8283        shader_cleanup((IWineD3DBaseShader *)iface);
     84        This->baseShader.parent_ops->wined3d_object_destroyed(This->baseShader.parent);
    8385        HeapFree(GetProcessHeap(), 0, This);
    8486    }
     
    9496    IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
    9597
    96     *parent = This->parent;
     98    *parent = This->baseShader.parent;
    9799    IUnknown_AddRef(*parent);
    98100    TRACE("(%p) : returning %p\n", This, *parent);
     
    218220}
    219221
    220 static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *iface,
    221         const DWORD *pFunction, const struct wined3d_shader_signature *output_signature)
     222static HRESULT pixelshader_set_function(IWineD3DPixelShaderImpl *shader,
     223        const DWORD *byte_code, const struct wined3d_shader_signature *output_signature)
    222224{
    223     IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface;
     225    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
     226    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    224227    unsigned int i, highest_reg_used = 0, num_regs_used = 0;
    225     shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
     228    shader_reg_maps *reg_maps = &shader->baseShader.reg_maps;
    226229    const struct wined3d_shader_frontend *fe;
    227230    HRESULT hr;
    228231
    229     TRACE("(%p) : pFunction %p\n", iface, pFunction);
    230 
    231     fe = shader_select_frontend(*pFunction);
     232    TRACE("shader %p, byte_code %p, output_signature %p.\n", shader, byte_code, output_signature);
     233
     234    fe = shader_select_frontend(*byte_code);
    232235    if (!fe)
    233236    {
     
    235238        return WINED3DERR_INVALIDCALL;
    236239    }
    237     This->baseShader.frontend = fe;
    238     This->baseShader.frontend_data = fe->shader_init(pFunction, output_signature);
    239     if (!This->baseShader.frontend_data)
     240    shader->baseShader.frontend = fe;
     241    shader->baseShader.frontend_data = fe->shader_init(byte_code, output_signature);
     242    if (!shader->baseShader.frontend_data)
    240243    {
    241244        FIXME("Failed to initialize frontend.\n");
     
    244247
    245248    /* First pass: trace shader */
    246     if (TRACE_ON(d3d_shader)) shader_trace_init(fe, This->baseShader.frontend_data, pFunction);
     249    if (TRACE_ON(d3d_shader)) shader_trace_init(fe, shader->baseShader.frontend_data, byte_code);
    247250
    248251    /* Initialize immediate constant lists */
    249     list_init(&This->baseShader.constantsF);
    250     list_init(&This->baseShader.constantsB);
    251     list_init(&This->baseShader.constantsI);
     252    list_init(&shader->baseShader.constantsF);
     253    list_init(&shader->baseShader.constantsB);
     254    list_init(&shader->baseShader.constantsI);
    252255
    253256    /* Second pass: figure out which registers are used, what the semantics are, etc.. */
    254     hr = shader_get_registers_used((IWineD3DBaseShader *)This, fe,
    255             reg_maps, NULL, This->input_signature, NULL,
    256             pFunction, GL_LIMITS(pshader_constantsF));
     257    hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe,
     258            reg_maps, NULL, shader->input_signature, NULL,
     259            byte_code, gl_info->max_pshader_constantsF);
    257260    if (FAILED(hr)) return hr;
    258261
    259     pshader_set_limits(This);
     262    pshader_set_limits(shader);
    260263
    261264    for (i = 0; i < MAX_REG_INPUT; ++i)
    262265    {
    263         if (This->input_reg_used[i])
     266        if (shader->input_reg_used[i])
    264267        {
    265268            ++num_regs_used;
     
    270273    /* Don't do any register mapping magic if it is not needed, or if we can't
    271274     * achieve anything anyway */
    272     if (highest_reg_used < (GL_LIMITS(glsl_varyings) / 4)
    273             || num_regs_used > (GL_LIMITS(glsl_varyings) / 4))
    274     {
    275         if (num_regs_used > (GL_LIMITS(glsl_varyings) / 4))
     275    if (highest_reg_used < (gl_info->max_glsl_varyings / 4)
     276            || num_regs_used > (gl_info->max_glsl_varyings / 4))
     277    {
     278        if (num_regs_used > (gl_info->max_glsl_varyings / 4))
    276279        {
    277280            /* This happens with relative addressing. The input mapper function
     
    283286        for (i = 0; i < MAX_REG_INPUT; ++i)
    284287        {
    285             This->input_reg_map[i] = i;
    286         }
    287 
    288         This->declared_in_count = highest_reg_used + 1;
     288            shader->input_reg_map[i] = i;
     289        }
     290
     291        shader->declared_in_count = highest_reg_used + 1;
    289292    }
    290293    else
    291294    {
    292         This->declared_in_count = 0;
     295        shader->declared_in_count = 0;
    293296        for (i = 0; i < MAX_REG_INPUT; ++i)
    294297        {
    295             if (This->input_reg_used[i]) This->input_reg_map[i] = This->declared_in_count++;
    296             else This->input_reg_map[i] = ~0U;
    297         }
    298     }
    299 
    300     This->baseShader.load_local_constsF = FALSE;
    301 
    302     TRACE("(%p) : Copying the function\n", This);
    303 
    304     This->baseShader.function = HeapAlloc(GetProcessHeap(), 0, This->baseShader.functionLength);
    305     if (!This->baseShader.function) return E_OUTOFMEMORY;
    306     memcpy(This->baseShader.function, pFunction, This->baseShader.functionLength);
     298            if (shader->input_reg_used[i]) shader->input_reg_map[i] = shader->declared_in_count++;
     299            else shader->input_reg_map[i] = ~0U;
     300        }
     301    }
     302
     303    shader->baseShader.load_local_constsF = FALSE;
     304
     305    TRACE("(%p) : Copying byte code.\n", shader);
     306
     307    shader->baseShader.function = HeapAlloc(GetProcessHeap(), 0, shader->baseShader.functionLength);
     308    if (!shader->baseShader.function) return E_OUTOFMEMORY;
     309    memcpy(shader->baseShader.function, byte_code, shader->baseShader.functionLength);
    307310
    308311    return WINED3D_OK;
     
    353356}
    354357
    355 const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
     358static const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
    356359{
    357360    /*** IUnknown methods ***/
     
    362365    IWineD3DPixelShaderImpl_GetParent,
    363366    /*** IWineD3DBaseShader methods ***/
    364     IWineD3DPixelShaderImpl_SetFunction,
    365     /*** IWineD3DPixelShader methods ***/
    366367    IWineD3DPixelShaderImpl_GetDevice,
    367368    IWineD3DPixelShaderImpl_GetFunction
     369    /*** IWineD3DPixelShader methods ***/
    368370};
    369371
     
    431433    }
    432434}
     435
     436HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
     437        const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
     438        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     439{
     440    HRESULT hr;
     441
     442    if (!byte_code) return WINED3DERR_INVALIDCALL;
     443
     444    shader->lpVtbl = &IWineD3DPixelShader_Vtbl;
     445    shader_init(&shader->baseShader, device, parent, parent_ops);
     446
     447    hr = pixelshader_set_function(shader, byte_code, output_signature);
     448    if (FAILED(hr))
     449    {
     450        WARN("Failed to set function, hr %#x.\n", hr);
     451        shader_cleanup((IWineD3DBaseShader *)shader);
     452        return hr;
     453    }
     454
     455    return WINED3D_OK;
     456}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/query.c

    r22496 r23571  
    356356    if (!pData || !dwSize) return S_OK;
    357357
     358    if (!query->context)
     359    {
     360        ERR("Query not started, returning TRUE.\n");
     361        *data = TRUE;
     362
     363        return S_OK;
     364    }
     365
    358366    if (query->context->tid != GetCurrentThreadId())
    359367    {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/resource.c

    r20612 r23571  
    66 * Copyright 2004 Christian Costa
    77 * Copyright 2005 Oliver Stieber
     8 * Copyright 2009 Henri Verbeet for CodeWeavers
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    3839HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
    3940        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
    40         WINED3DPOOL pool, IUnknown *parent)
     41        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    4142{
    4243    struct IWineD3DResourceClass *resource = &((IWineD3DResourceImpl *)iface)->resource;
     
    5152    resource->size = size;
    5253    resource->priority = 0;
     54    resource->parent_ops = parent_ops;
    5355    list_init(&resource->privateData);
    5456
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/shader_sm4.c

    r22496 r23571  
    6363    WINED3D_SM4_OP_EXP      = 0x19,
    6464    WINED3D_SM4_OP_LOG      = 0x2f,
     65    WINED3D_SM4_OP_MIN      = 0x33,
     66    WINED3D_SM4_OP_MAX      = 0x34,
    6567    WINED3D_SM4_OP_MOV      = 0x36,
    6668    WINED3D_SM4_OP_MUL      = 0x38,
     
    114116    {WINED3D_SM4_OP_EXP,    WINED3DSIH_EXP,         1,  1},
    115117    {WINED3D_SM4_OP_LOG,    WINED3DSIH_LOG,         1,  1},
     118    {WINED3D_SM4_OP_MIN,    WINED3DSIH_MIN,         1,  2},
     119    {WINED3D_SM4_OP_MAX,    WINED3DSIH_MAX,         1,  2},
    116120    {WINED3D_SM4_OP_MOV,    WINED3DSIH_MOV,         1,  1},
    117121    {WINED3D_SM4_OP_MUL,    WINED3DSIH_MUL,         1,  2},
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/state.c

    r22496 r23571  
    99 * Copyright 2006 Henri Verbeet
    1010 * Copyright 2006-2008 Stefan Dösinger for CodeWeavers
     11 * Copyright 2009 Henri Verbeet for CodeWeavers
    1112 *
    1213 * This library is free software; you can redistribute it and/or
     
    4445WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
    4546
    46 #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
     47#define GLINFO_LOCATION (*context->gl_info)
    4748
    4849/* GL locking for state handlers is done by the caller. */
     
    6667static void state_undefined(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
    6768{
    68     /* Print a WARN, this allows the stateblock code to loop over all states to generate a display
    69      * list without causing confusing terminal output. Deliberately no special debug name here
    70      * because its undefined.
    71      */
    72     WARN("undefined state %d\n", state);
     69    ERR("Undefined state.\n");
    7370}
    7471
     
    578575        enable  = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
    579576        disable = ~stateblock->renderState[WINED3DRS_CLIPPLANEENABLE];
    580         if(GL_SUPPORT(NV_DEPTH_CLAMP)) {
    581             glDisable(GL_DEPTH_CLAMP_NV);
    582             checkGLcall("glDisable(GL_DEPTH_CLAMP_NV)");
     577        if (GL_SUPPORT(ARB_DEPTH_CLAMP))
     578        {
     579            glDisable(GL_DEPTH_CLAMP);
     580            checkGLcall("glDisable(GL_DEPTH_CLAMP)");
    583581        }
    584582    } else {
    585583        disable = 0xffffffff;
    586584        enable  = 0x00;
    587         if(GL_SUPPORT(NV_DEPTH_CLAMP)) {
    588             glEnable(GL_DEPTH_CLAMP_NV);
    589             checkGLcall("glEnable(GL_DEPTH_CLAMP_NV)");
     585        if (GL_SUPPORT(ARB_DEPTH_CLAMP))
     586        {
     587            glEnable(GL_DEPTH_CLAMP);
     588            checkGLcall("glEnable(GL_DEPTH_CLAMP)");
    590589        }
    591590    }
     
    785784}
    786785
    787 static void
    788 renderstate_stencil_twosided(IWineD3DStateBlockImpl *stateblock, GLint face, GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass ) {
     786static void renderstate_stencil_twosided(struct wined3d_context *context, GLint face,
     787        GLint func, GLint ref, GLuint mask, GLint stencilFail, GLint depthFail, GLint stencilPass)
     788{
    789789    glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
    790790    checkGLcall("glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)");
     
    852852             * to set it back
    853853             */
    854             renderstate_stencil_twosided(stateblock, GL_BACK, func_ccw, ref, mask,
    855                                         stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
    856             renderstate_stencil_twosided(stateblock, GL_FRONT, func, ref, mask,
    857                                         stencilFail, depthFail, stencilPass);
     854            renderstate_stencil_twosided(context, GL_BACK,
     855                    func_ccw, ref, mask, stencilFail_ccw, depthFail_ccw, stencilPass_ccw);
     856            renderstate_stencil_twosided(context, GL_FRONT,
     857                    func, ref, mask, stencilFail, depthFail, stencilPass);
    858858        } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL)) {
    859859            GL_EXTCALL(glStencilFuncSeparateATI(func, func_ccw, ref, mask));
     
    11911191    IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
    11921192    GLenum Parm = 0;
    1193     const struct wined3d_stream_info_element *diffuse = &device->strided_streams.elements[WINED3D_FFP_DIFFUSE];
    1194     BOOL isDiffuseSupplied;
    11951193
    11961194    /* Depends on the decoded vertex declaration to read the existence of diffuse data.
     
    12021200    }
    12031201
    1204     isDiffuseSupplied = diffuse->data || diffuse->buffer_object;
    1205 
    12061202    context->num_untracked_materials = 0;
    1207     if (isDiffuseSupplied && stateblock->renderState[WINED3DRS_COLORVERTEX]) {
     1203    if ((device->strided_streams.use_map & (1 << WINED3D_FFP_DIFFUSE))
     1204            && stateblock->renderState[WINED3DRS_COLORVERTEX])
     1205    {
    12081206        TRACE("diff %d, amb %d, emis %d, spec %d\n",
    12091207              stateblock->renderState[WINED3DRS_DIFFUSEMATERIALSOURCE],
     
    13601358     */
    13611359    if (stateblock->renderState[WINED3DRS_NORMALIZENORMALS]
    1362             && (stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_NORMAL].data
    1363             || stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_NORMAL].buffer_object))
     1360            && (stateblock->wineD3DDevice->strided_streams.use_map & (1 << WINED3D_FFP_NORMAL)))
    13641361    {
    13651362        glEnable(GL_NORMALIZE);
     
    15041501}
    15051502
     1503static void state_debug_monitor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
     1504{
     1505    WARN("token: %#x\n", stateblock->renderState[WINED3DRS_DEBUGMONITORTOKEN]);
     1506}
     1507
    15061508static void state_colorwrite(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
    15071509{
     
    18521854}
    18531855
     1856static void state_swvp(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
     1857{
     1858    if (stateblock->renderState[WINED3DRS_SOFTWAREVERTEXPROCESSING])
     1859    {
     1860        FIXME("Software vertex processing not implemented.\n");
     1861    }
     1862}
     1863
    18541864/* Set texture operations up - The following avoids lots of ifdefs in this routine!*/
    18551865#if defined (GL_VERSION_1_3)
     
    19001910
    19011911/* Setup the texture operations texture stage states */
    1902 static void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3)
     1912static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *iface,
     1913        BOOL isAlpha, int Stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3)
    19031914{
    19041915    GLenum src1, src2, src3;
     
    19111922    BOOL Handled = FALSE;
    19121923    IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
    1913     IWineD3DStateBlockImpl *stateblock = This->stateBlock; /* for GLINFO_LOCATION */
    19141924
    19151925    TRACE("Alpha?(%d), Stage:%d Op(%s), a1(%d), a2(%d), a3(%d)\n", isAlpha, Stage, debug_d3dtop(op), arg1, arg2, arg3);
     
    29772987    }
    29782988
    2979     set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
     2989    set_tex_op(context, (IWineD3DDevice *)stateblock->wineD3DDevice, FALSE, stage,
    29802990                stateblock->textureState[stage][WINED3DTSS_COLOROP],
    29812991                stateblock->textureState[stage][WINED3DTSS_COLORARG1],
     
    30793089                         stateblock->textureState[stage][WINED3DTSS_RESULTARG]);
    30803090    } else {
    3081         set_tex_op((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage,
     3091        set_tex_op(context, (IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage,
    30823092                    op, arg1, arg2, arg0);
    30833093    }
     
    31103120    set_texture_matrix(&stateblock->transforms[WINED3DTS_TEXTURE0 + texUnit].u.m[0][0],
    31113121            stateblock->textureState[texUnit][WINED3DTSS_TEXTURETRANSFORMFLAGS], generated, context->last_was_rhw,
    3112             stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].stride
     3122            stateblock->wineD3DDevice->strided_streams.use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx))
    31133123            ? stateblock->wineD3DDevice->strided_streams.elements[WINED3D_FFP_TEXCOORD0 + coordIdx].format_desc->format
    31143124            : WINED3DFMT_UNKNOWN,
     
    31303140}
    31313141
    3132 static void unloadTexCoords(IWineD3DStateBlockImpl *stateblock) {
     3142static void unloadTexCoords(const struct wined3d_context *context)
     3143{
    31333144    unsigned int texture_idx;
    31343145
     
    31393150}
    31403151
    3141 static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, const struct wined3d_stream_info *si, GLuint *curVBO)
     3152static void loadTexCoords(const struct wined3d_context *context, IWineD3DStateBlockImpl *stateblock,
     3153        const struct wined3d_stream_info *si, GLuint *curVBO)
    31423154{
    31433155    const UINT *offset = stateblock->streamOffset;
     
    31473159    for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
    31483160        int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
    3149         const struct wined3d_stream_info_element *e;
    31503161
    31513162        mapped_stage = stateblock->wineD3DDevice->texUnitMap[textureNo];
    31523163        if (mapped_stage == WINED3D_UNMAPPED_STAGE) continue;
    31533164
    3154         e = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
    3155         if (coordIdx < MAX_TEXTURES && (e->data || e->buffer_object))
     3165        if (coordIdx < MAX_TEXTURES && (si->use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx))))
    31563166        {
     3167            const struct wined3d_stream_info_element *e = &si->elements[WINED3D_FFP_TEXCOORD0 + coordIdx];
     3168
    31573169            TRACE("Setting up texture %u, idx %d, cordindx %u, data %p\n",
    31583170                    textureNo, mapped_stage, coordIdx, e->data);
     
    33553367        GLuint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? ~0U : 0;
    33563368
    3357         unloadTexCoords(stateblock);
    3358         loadTexCoords(stateblock, &stateblock->wineD3DDevice->strided_streams, &curVBO);
     3369        unloadTexCoords(context);
     3370        loadTexCoords(context, stateblock, &stateblock->wineD3DDevice->strided_streams, &curVBO);
    33593371    }
    33603372}
     
    33793391    DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
    33803392
    3381     if(stateblock->pixelShader && stage != 0 &&
    3382        ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.luminanceparams[stage]) {
     3393    if (stateblock->pixelShader && stage != 0
     3394            && (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.luminanceparams & (1 << stage)))
     3395    {
    33833396        /* The pixel shader has to know the luminance scale. Do a constants update if it
    33843397         * isn't scheduled anyway
     
    35403553{
    35413554    DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
    3542     if(stateblock->pixelShader && stage != 0 &&
    3543        ((IWineD3DPixelShaderImpl *) stateblock->pixelShader)->baseShader.reg_maps.bumpmat[stage]) {
     3555    if (stateblock->pixelShader && stage != 0
     3556            && (((IWineD3DPixelShaderImpl *)stateblock->pixelShader)->baseShader.reg_maps.bumpmat & (1 << stage)))
     3557    {
    35443558        /* The pixel shader has to know the bump env matrix. Do a constants update if it isn't scheduled
    35453559         * anyway
     
    38423856
    38433857        /* Window Coord 0 is the middle of the first pixel, so translate by 1/2 pixels */
    3844         glTranslatef(0.5f, 0.5f, 0.0f);
    3845         checkGLcall("glTranslatef(0.5f, 0.5f, 0.0f)");
     3858        glTranslatef(63.0f / 128.0f, 63.0f / 128.0f, 0.0f);
     3859        checkGLcall("glTranslatef(63.0f / 128.0f, 63.0f / 128.0f, 0.0f)");
     3860
    38463861        /* D3D texture coordinates are flipped compared to OpenGL ones, so
    38473862         * render everything upside down when rendering offscreen. */
     
    38893904         */
    38903905
     3906        /* Translate by slightly less than a half pixel to force a top-left
     3907         * filling convention. We want the difference to be large enough that
     3908         * it doesn't get lost due to rounding inside the driver, but small
     3909         * enough to prevent it from interfering with any anti-aliasing. */
     3910        GLfloat xoffset = (63.0f / 64.0f) / stateblock->viewport.Width;
     3911        GLfloat yoffset = -(63.0f / 64.0f) / stateblock->viewport.Height;
     3912
    38913913        if (context->render_offscreen)
    38923914        {
    38933915            /* D3D texture coordinates are flipped compared to OpenGL ones, so
    38943916             * render everything upside down when rendering offscreen. */
    3895             glTranslatef(1.0f / stateblock->viewport.Width, 1.0f / stateblock->viewport.Height, -1.0f);
    3896             checkGLcall("glTranslatef(1.0f / width, 1.0f / height, -1.0f)");
     3917            glTranslatef(xoffset, -yoffset, -1.0f);
     3918            checkGLcall("glTranslatef(xoffset, -yoffset, -1.0f)");
    38973919            glScalef(1.0f, -1.0f, 2.0f);
    38983920        } else {
    3899             glTranslatef(1.0f / stateblock->viewport.Width, -1.0f / stateblock->viewport.Height, -1.0f);
    3900             checkGLcall("glTranslatef(1.0f / width, -1.0f / height, -1.0f)");
     3921            glTranslatef(xoffset, yoffset, -1.0f);
     3922            checkGLcall("glTranslatef(xoffset, yoffset, -1.0f)");
    39013923            glScalef(1.0f, 1.0f, 2.0f);
    39023924        }
     
    39123934 * TODO: Only load / unload arrays if we have to.
    39133935 */
    3914 static inline void unloadVertexData(IWineD3DStateBlockImpl *stateblock) {
     3936static inline void unloadVertexData(const struct wined3d_context *context)
     3937{
    39153938    glDisableClientState(GL_VERTEX_ARRAY);
    39163939    glDisableClientState(GL_NORMAL_ARRAY);
     
    39223945        glDisableClientState(GL_WEIGHT_ARRAY_ARB);
    39233946    }
    3924     unloadTexCoords(stateblock);
     3947    unloadTexCoords(context);
    39253948}
    39263949
     
    40564079                    GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr));
    40574080                    break;
    4058                 case WINED3DFMT_A8R8G8B8:
     4081                case WINED3DFMT_B8G8R8A8_UNORM:
    40594082                    if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
    40604083                    {
     
    41274150
    41284151/* Used from 2 different functions, and too big to justify making it inlined */
    4129 static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const struct wined3d_stream_info *si)
     4152static void loadVertexData(const struct wined3d_context *context, IWineD3DStateBlockImpl *stateblock,
     4153        const struct wined3d_stream_info *si)
    41304154{
    41314155    const UINT *offset = stateblock->streamOffset;
     
    41394163
    41404164    /* Blend Data ---------------------------------------------- */
    4141     e = &si->elements[WINED3D_FFP_BLENDWEIGHT];
    4142     if (e->data || e->buffer_object
    4143             || si->elements[WINED3D_FFP_BLENDINDICES].data
    4144             || si->elements[WINED3D_FFP_BLENDINDICES].buffer_object)
     4165    if ((si->use_map & (1 << WINED3D_FFP_BLENDWEIGHT))
     4166            || si->use_map & (1 << WINED3D_FFP_BLENDINDICES))
    41454167    {
     4168        e = &si->elements[WINED3D_FFP_BLENDWEIGHT];
     4169
    41464170        if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
    41474171            TRACE("Blend %d %p %d\n", e->format_desc->component_count,
     
    41704194            checkGLcall("glWeightPointerARB");
    41714195
    4172             if (si->elements[WINED3D_FFP_BLENDINDICES].data
    4173                     || (si->elements[WINED3D_FFP_BLENDINDICES].buffer_object))
     4196            if (si->use_map & (1 << WINED3D_FFP_BLENDINDICES))
    41744197            {
    41754198                static BOOL warned;
     
    41954218
    41964219    /* Point Size ----------------------------------------------*/
    4197     e = &si->elements[WINED3D_FFP_PSIZE];
    4198     if (e->data || e->buffer_object)
     4220    if (si->use_map & (1 << WINED3D_FFP_PSIZE))
    41994221    {
    42004222        /* no such functionality in the fixed function GL pipeline */
     
    42044226
    42054227    /* Vertex Pointers -----------------------------------------*/
    4206     e = &si->elements[WINED3D_FFP_POSITION];
    4207     if (e->data || e->buffer_object)
     4228    if (si->use_map & (1 << WINED3D_FFP_POSITION))
    42084229    {
    42094230        VTRACE(("glVertexPointer(%d, GL_FLOAT, %d, %p)\n", e->stride, e->size, e->data));
    42104231
     4232        e = &si->elements[WINED3D_FFP_POSITION];
    42114233        if (curVBO != e->buffer_object)
    42124234        {
     
    42384260
    42394261    /* Normals -------------------------------------------------*/
    4240     e = &si->elements[WINED3D_FFP_NORMAL];
    4241     if (e->data || e->buffer_object)
     4262    if (si->use_map & (1 << WINED3D_FFP_NORMAL))
    42424263    {
    42434264        VTRACE(("glNormalPointer(GL_FLOAT, %d, %p)\n", e->stride, e->data));
     4265
     4266        e = &si->elements[WINED3D_FFP_NORMAL];
    42444267        if (curVBO != e->buffer_object)
    42454268        {
     
    42684291    /* , or the user doesn't care and wants the speed advantage   */
    42694292
    4270     e = &si->elements[WINED3D_FFP_DIFFUSE];
    4271     if (e->data || e->buffer_object)
     4293    if (si->use_map & (1 << WINED3D_FFP_DIFFUSE))
    42724294    {
    42734295        VTRACE(("glColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e->stride, e->data));
    42744296
     4297        e = &si->elements[WINED3D_FFP_DIFFUSE];
    42754298        if (curVBO != e->buffer_object)
    42764299        {
     
    42924315
    42934316    /* Specular Colour ------------------------------------------*/
    4294     e = &si->elements[WINED3D_FFP_SPECULAR];
    4295     if (e->data || e->buffer_object)
     4317    if (si->use_map & (1 << WINED3D_FFP_SPECULAR))
    42964318    {
    42974319        TRACE("setting specular colour\n");
    42984320        VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e->stride, e->data));
    42994321
     4322        e = &si->elements[WINED3D_FFP_SPECULAR];
    43004323        if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
    43014324            GLenum type = e->format_desc->gl_vtx_type;
     
    43584381
    43594382    /* Texture coords -------------------------------------------*/
    4360     loadTexCoords(stateblock, si, &curVBO);
     4383    loadTexCoords(context, stateblock, si, &curVBO);
    43614384}
    43624385
     
    44244447        }
    44254448    }
    4426     else if (fixup || (!dataLocations->elements[WINED3D_FFP_PSIZE].data
    4427             && !dataLocations->position_transformed
    4428             && (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA)
    4429             || (!dataLocations->elements[WINED3D_FFP_DIFFUSE].data
    4430             && !dataLocations->elements[WINED3D_FFP_SPECULAR].data))))
     4449    else
    44314450    {
    4432         /* Load the vertex data using named arrays */
    4433         load_named = TRUE;
    4434         device->useDrawStridedSlow = FALSE;
    4435     } else {
    4436         TRACE("Not loading vertex data\n");
    4437         device->useDrawStridedSlow = TRUE;
     4451        WORD slow_mask = (1 << WINED3D_FFP_PSIZE);
     4452        slow_mask |= -!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR));
     4453
     4454        if (fixup || (!dataLocations->position_transformed
     4455                && !(dataLocations->use_map & slow_mask)))
     4456        {
     4457            /* Load the vertex data using named arrays */
     4458            load_named = TRUE;
     4459            device->useDrawStridedSlow = FALSE;
     4460        }
     4461        else
     4462        {
     4463            TRACE("Not loading vertex data\n");
     4464            device->useDrawStridedSlow = TRUE;
     4465        }
    44384466    }
    44394467
     
    44464474    else if (context->namedArraysLoaded)
    44474475    {
    4448         unloadVertexData(stateblock);
     4476        unloadVertexData(context);
    44494477        context->namedArraysLoaded = FALSE;
    44504478    }
     
    44594487    {
    44604488        TRACE("Loading vertex data\n");
    4461         loadVertexData(stateblock, dataLocations);
     4489        loadVertexData(context, stateblock, dataLocations);
    44624490        context->namedArraysLoaded = TRUE;
    44634491    }
     
    45014529         * TODO: Move to the viewport state
    45024530         */
    4503         if (useVertexShaderFunction) {
     4531        if (useVertexShaderFunction)
     4532        {
     4533            GLfloat yoffset = -(63.0f / 64.0f) / stateblock->viewport.Height;
    45044534            device->posFixup[1] = context->render_offscreen ? -1.0f : 1.0f;
    4505             device->posFixup[3] = -device->posFixup[1] / stateblock->viewport.Height;
     4535            device->posFixup[3] = device->posFixup[1] * yoffset;
    45064536        }
    45074537    }
     
    46484678static void viewport_vertexpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context)
    46494679{
    4650     stateblock->wineD3DDevice->posFixup[2] = 1.0f / stateblock->viewport.Width;
    4651     stateblock->wineD3DDevice->posFixup[3] = -stateblock->wineD3DDevice->posFixup[1] / stateblock->viewport.Height;
     4680    GLfloat yoffset = -(63.0f / 64.0f) / stateblock->viewport.Height;
     4681
     4682    stateblock->wineD3DDevice->posFixup[2] = (63.0f / 64.0f) / stateblock->viewport.Width;
     4683    stateblock->wineD3DDevice->posFixup[3] = stateblock->wineD3DDevice->posFixup[1] * yoffset;
     4684
    46524685    if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
    46534686        transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock, context);
     
    49514984    { STATE_RENDER(WINED3DRS_EXTENTS),                    { STATE_RENDER(WINED3DRS_EXTENTS),                    state_extents       }, WINED3D_GL_EXT_NONE             },
    49524985    { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE),        { STATE_RENDER(WINED3DRS_COLORKEYBLENDENABLE),        state_ckeyblend     }, WINED3D_GL_EXT_NONE             },
     4986    { STATE_RENDER(WINED3DRS_SOFTWAREVERTEXPROCESSING),   { STATE_RENDER(WINED3DRS_SOFTWAREVERTEXPROCESSING),   state_swvp          }, WINED3D_GL_EXT_NONE             },
    49534987    { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE),             { STATE_RENDER(WINED3DRS_PATCHEDGESTYLE),             state_patchedgestyle}, WINED3D_GL_EXT_NONE             },
    49544988    { STATE_RENDER(WINED3DRS_PATCHSEGMENTS),              { STATE_RENDER(WINED3DRS_PATCHSEGMENTS),              state_patchsegments }, WINED3D_GL_EXT_NONE             },
     
    49654999    { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS),       { STATE_RENDER(WINED3DRS_MULTISAMPLEANTIALIAS),       state_msaa_w        }, WINED3D_GL_EXT_NONE             },
    49665000    { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK),            { STATE_RENDER(WINED3DRS_MULTISAMPLEMASK),            state_multisampmask }, WINED3D_GL_EXT_NONE             },
     5001    { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN),          { STATE_RENDER(WINED3DRS_DEBUGMONITORTOKEN),          state_debug_monitor }, WINED3D_GL_EXT_NONE             },
    49675002    { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           { STATE_RENDER(WINED3DRS_COLORWRITEENABLE),           state_colorwrite    }, WINED3D_GL_EXT_NONE             },
    49685003    { STATE_RENDER(WINED3DRS_BLENDOP),                    { STATE_RENDER(WINED3DRS_BLENDOP),                    state_blendop       }, EXT_BLEND_MINMAX                },
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/stateblock.c

    r22496 r23571  
    4141 **************************************/
    4242
    43 /** Allocates the correct amount of space for pixel and vertex shader constants,
     43/* Allocates the correct amount of space for pixel and vertex shader constants,
    4444 * along with their set/changed flags on the given stateblock object
    4545 */
    46 HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) {
    47    
     46HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object)
     47{
    4848    IWineD3DStateBlockImpl *This = object;
    4949
     
    123123
    124124/** Set all members of a stateblock savedstate to the given value */
    125 void stateblock_savedstates_set(
    126     IWineD3DStateBlock* iface,
    127     SAVEDSTATES* states,
    128     BOOL value) {
    129    
     125void stateblock_savedstates_set(IWineD3DStateBlock *iface, SAVEDSTATES *states, BOOL value)
     126{
    130127    IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
    131128    unsigned bsize = sizeof(BOOL);
     
    238235    memcpy(Dest->pixelShaderConstantB, This->pixelShaderConstantB, sizeof(BOOL) * MAX_CONST_B);
    239236    memcpy(Dest->pixelShaderConstantI, This->pixelShaderConstantI, sizeof(INT) * MAX_CONST_I * 4);
    240    
     237
    241238    memcpy(Dest->streamStride, This->streamStride, sizeof(UINT) * MAX_STREAMS);
    242239    memcpy(Dest->streamOffset, This->streamOffset, sizeof(UINT) * MAX_STREAMS);
     
    855852        }
    856853
    857         if (This->changed.indices) {
    858             IWineD3DDevice_SetIndices(pDevice, This->pIndexData, This->IndexFmt);
     854        if (This->changed.indices)
     855        {
     856            IWineD3DDevice_SetIndexBuffer(pDevice, This->pIndexData, This->IndexFmt);
    859857            IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
    860858        }
     
    10381036        }
    10391037        This->wineD3DDevice->updateStateBlock->gl_primitive_type = This->gl_primitive_type;
    1040         IWineD3DDevice_SetIndices(pDevice, This->pIndexData, This->IndexFmt);
     1038        IWineD3DDevice_SetIndexBuffer(pDevice, This->pIndexData, This->IndexFmt);
    10411039        IWineD3DDevice_SetBaseVertexIndex(pDevice, This->baseVertexIndex);
    10421040        IWineD3DDevice_SetVertexDeclaration(pDevice, This->vertexDecl);
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c

    r22496 r23571  
    1111 * Copyright 2007-2008 Henri Verbeet
    1212 * Copyright 2006-2008 Roderick Colenbrander
     13 * Copyright 2009 Henri Verbeet for CodeWeavers
    1314 *
    1415 * This library is free software; you can redistribute it and/or
     
    7980    LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry)
    8081    {
    81         GL_EXTCALL(glDeleteRenderbuffersEXT(1, &entry->id));
     82        gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
    8283        HeapFree(GetProcessHeap(), 0, entry);
    8384    }
     
    132133        UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
    133134        UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
    134         WINED3DPOOL pool, IUnknown *parent)
     135        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
    135136{
    136137    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     
    169170
    170171    hr = resource_init((IWineD3DResource *)surface, WINED3DRTYPE_SURFACE,
    171             device, resource_size, usage, format_desc, pool, parent);
     172            device, resource_size, usage, format_desc, pool, parent, parent_ops);
    172173    if (FAILED(hr))
    173174    {
     
    311312/* Context activation is done by the caller. */
    312313static void surface_bind_and_dirtify(IWineD3DSurfaceImpl *This, BOOL srgb) {
    313     int active_sampler;
     314    DWORD active_sampler;
    314315
    315316    /* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
     
    330331    active_sampler = This->resource.wineD3DDevice->rev_tex_unit_map[active_texture - GL_TEXTURE0_ARB];
    331332
    332     if (active_sampler != -1) {
     333    if (active_sampler != WINED3D_UNMAPPED_STAGE)
     334    {
    333335        IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));
    334336    }
     
    342344        IWineD3DSurfaceImpl* render_target = (IWineD3DSurfaceImpl*)device->render_targets[0];
    343345        if ((render_target->resource.usage & WINED3DUSAGE_RENDERTARGET)
    344                 && (render_target->resource.format_desc->format == WINED3DFMT_P8))
     346                && (render_target->resource.format_desc->format == WINED3DFMT_P8_UINT))
    345347            return TRUE;
    346348    }
     
    359361
    360362    /* Only support read back of converted P8 surfaces */
    361     if (This->Flags & SFLAG_CONVERTED && format_desc->format != WINED3DFMT_P8)
     363    if (This->Flags & SFLAG_CONVERTED && format_desc->format != WINED3DFMT_P8_UINT)
    362364    {
    363365        FIXME("Read back converted textures unsupported, format=%s\n", debug_d3dformat(format_desc->format));
     
    378380            checkGLcall("glBindBufferARB");
    379381            GL_EXTCALL(glGetCompressedTexImageARB(This->texture_target, This->texture_level, NULL));
    380             checkGLcall("glGetCompressedTexImageARB()");
     382            checkGLcall("glGetCompressedTexImageARB");
    381383            GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
    382384            checkGLcall("glBindBufferARB");
     
    386388            GL_EXTCALL(glGetCompressedTexImageARB(This->texture_target,
    387389                    This->texture_level, This->resource.allocatedMemory));
    388             checkGLcall("glGetCompressedTexImageARB()");
     390            checkGLcall("glGetCompressedTexImageARB");
    389391        }
    390392
     
    398400
    399401        /* In case of P8 the index is stored in the alpha component if the primary render target uses P8 */
    400         if (format_desc->format == WINED3DFMT_P8 && primary_render_target_is_p8(This->resource.wineD3DDevice))
     402        if (format_desc->format == WINED3DFMT_P8_UINT && primary_render_target_is_p8(This->resource.wineD3DDevice))
    401403        {
    402404            format = GL_ALPHA;
     
    422424
    423425            glGetTexImage(This->texture_target, This->texture_level, format, type, NULL);
    424             checkGLcall("glGetTexImage()");
     426            checkGLcall("glGetTexImage");
    425427
    426428            GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
     
    428430        } else {
    429431            glGetTexImage(This->texture_target, This->texture_level, format, type, mem);
    430             checkGLcall("glGetTexImage()");
     432            checkGLcall("glGetTexImage");
    431433        }
    432434        LEAVE_GL();
     
    618620void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int width, unsigned int height) {
    619621    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
     622    const struct wined3d_gl_info *gl_info = &This->resource.wineD3DDevice->adapter->gl_info;
    620623    renderbuffer_entry_t *entry;
    621624    GLuint renderbuffer = 0;
     
    629632
    630633    /* Remove any renderbuffer set if the sizes match */
    631     if (width == src_width && height == src_height) {
     634    if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT]
     635            || (width == src_width && height == src_height))
     636    {
    632637        This->current_renderbuffer = NULL;
    633638        return;
     
    644649
    645650    if (!renderbuffer) {
    646         GL_EXTCALL(glGenRenderbuffersEXT(1, &renderbuffer));
    647         GL_EXTCALL(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, renderbuffer));
    648         GL_EXTCALL(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT,
    649                 This->resource.format_desc->glInternal, width, height));
     651        gl_info->fbo_ops.glGenRenderbuffers(1, &renderbuffer);
     652        gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
     653        gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER,
     654                This->resource.format_desc->glInternal, width, height);
    650655
    651656        entry = HeapAlloc(GetProcessHeap(), 0, sizeof(renderbuffer_entry_t));
     
    736741    {
    737742        surface_cleanup(This);
     743        This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
    738744
    739745        TRACE("(%p) Released.\n", This);
     
    768774        }
    769775
    770         if (This->resource.format_desc->format == WINED3DFMT_P8
    771                 || This->resource.format_desc->format == WINED3DFMT_A8P8)
     776        if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
     777                || This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
    772778        {
    773779            if(palette9_changed(This)) {
     
    806812    ENTER_GL();
    807813    GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
    808     checkGLcall("glBindBuffer(GL_PIXEL_UNPACK_BUFFER, This->pbo)");
     814    checkGLcall("glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, This->pbo)");
    809815    GL_EXTCALL(glGetBufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0, This->resource.size, This->resource.allocatedMemory));
    810     checkGLcall("glGetBufferSubData");
     816    checkGLcall("glGetBufferSubDataARB");
    811817    GL_EXTCALL(glDeleteBuffersARB(1, &This->pbo));
    812     checkGLcall("glDeleteBuffers");
     818    checkGLcall("glDeleteBuffersARB");
    813819    LEAVE_GL();
    814820
     
    821827    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
    822828    IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     829    const struct wined3d_context *context;
     830    const struct wined3d_gl_info *gl_info;
    823831    renderbuffer_entry_t *entry, *entry2;
    824832    TRACE("(%p)\n", iface);
     
    851859    This->Flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
    852860
    853     ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
     861    context = ActivateContext(device, NULL, CTXUSAGE_RESOURCELOAD);
     862    gl_info = context->gl_info;
    854863
    855864    /* Destroy PBOs, but load them into real sysmem before */
     
    864873    LIST_FOR_EACH_ENTRY_SAFE(entry, entry2, &This->renderbuffers, renderbuffer_entry_t, entry) {
    865874        ENTER_GL();
    866         GL_EXTCALL(glDeleteRenderbuffersEXT(1, &entry->id));
     875        gl_info->fbo_ops.glDeleteRenderbuffers(1, &entry->id);
    867876        LEAVE_GL();
    868877        list_remove(&entry->entry);
     
    961970    switch(This->resource.format_desc->format)
    962971    {
    963         case WINED3DFMT_P8:
     972        case WINED3DFMT_P8_UINT:
    964973        {
    965974            if(primary_render_target_is_p8(myDevice)) {
     
    10111020    /* Save old pixel store pack state */
    10121021    glGetIntegerv(GL_PACK_ROW_LENGTH, &rowLen);
    1013     checkGLcall("glIntegerv");
     1022    checkGLcall("glGetIntegerv");
    10141023    glGetIntegerv(GL_PACK_SKIP_PIXELS, &skipPix);
    1015     checkGLcall("glIntegerv");
     1024    checkGLcall("glGetIntegerv");
    10161025    glGetIntegerv(GL_PACK_SKIP_ROWS, &skipRow);
    1017     checkGLcall("glIntegerv");
     1026    checkGLcall("glGetIntegerv");
    10181027
    10191028    /* Setup pixel store pack state -- to glReadPixels into the correct place */
     
    10671076        if(!row) {
    10681077            ERR("Out of memory\n");
    1069             if (This->resource.format_desc->format == WINED3DFMT_P8) HeapFree(GetProcessHeap(), 0, mem);
     1078            if (This->resource.format_desc->format == WINED3DFMT_P8_UINT) HeapFree(GetProcessHeap(), 0, mem);
    10701079            LEAVE_GL();
    10711080            return;
     
    10971106     * In case of P8 render targets, the index is stored in the alpha component so no conversion is needed.
    10981107     */
    1099     if ((This->resource.format_desc->format == WINED3DFMT_P8) && !primary_render_target_is_p8(myDevice))
     1108    if (This->resource.format_desc->format == WINED3DFMT_P8_UINT && !primary_render_target_is_p8(myDevice))
    11001109    {
    11011110        const PALETTEENTRY *pal = NULL;
     
    13941403
    13951404    glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
    1396     checkGLcall("glIntegerv");
     1405    checkGLcall("glGetIntegerv");
    13971406    glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]);
    1398     checkGLcall("glIntegerv");
     1407    checkGLcall("glGetIntegerv");
    13991408    glPixelZoom(1.0f, -1.0f);
    14001409    checkGLcall("glPixelZoom");
     
    14051414
    14061415    glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1);
    1407     checkGLcall("glRasterPos2f");
     1416    checkGLcall("glRasterPos3i");
    14081417
    14091418    /* Some drivers(radeon dri, others?) don't like exceptions during
     
    14551464    /* Reset to previous pack row length */
    14561465    glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes);
    1457     checkGLcall("glPixelStorei GL_UNPACK_ROW_LENGTH");
     1466    checkGLcall("glPixelStorei(GL_UNPACK_ROW_LENGTH)");
    14581467
    14591468    if(!swapchain) {
     
    15251534        switch(wined3d_settings.rendertargetlock_mode) {
    15261535            case RTL_READTEX:
    1527             case RTL_TEXTEX:
    15281536                IWineD3DSurface_LoadLocation(iface, SFLAG_INTEXTURE, NULL /* partial texture loading not supported yet */);
    15291537                /* drop through */
    15301538
    1531             case RTL_AUTO:
    15321539            case RTL_READDRAW:
    1533             case RTL_TEXDRAW:
    15341540                IWineD3DSurface_LoadLocation(iface, SFLAG_INDRAWABLE, fullsurface ? NULL : &This->dirtyRect);
    15351541                break;
     
    16011607        return WINED3DERR_INVALIDCALL;
    16021608
    1603     /* According to Direct3D9 docs, only these formats are supported */
    1604     if (((IWineD3DImpl *)This->resource.wineD3DDevice->wineD3D)->dxVersion > 7) {
    1605         if (This->resource.format_desc->format != WINED3DFMT_R5G6B5
    1606                 && This->resource.format_desc->format != WINED3DFMT_X1R5G5B5
    1607                 && This->resource.format_desc->format != WINED3DFMT_R8G8B8
    1608                 && This->resource.format_desc->format != WINED3DFMT_X8R8G8B8)
    1609             return WINED3DERR_INVALIDCALL;
    1610     }
    1611 
    16121609    memset(&lock, 0, sizeof(lock)); /* To be sure */
    16131610
    16141611    /* Create a DIB section if there isn't a hdc yet */
    16151612    if(!This->hDC) {
    1616         IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
     1613        hr = IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
     1614        if(FAILED(hr)) return WINED3DERR_INVALIDCALL;
    16171615        if(This->Flags & SFLAG_CLIENT) {
    16181616            surface_internal_preload(iface, SRGB_RGB);
     
    16411639    }
    16421640
    1643     if (This->resource.format_desc->format == WINED3DFMT_P8
    1644             || This->resource.format_desc->format == WINED3DFMT_A8P8)
     1641    if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
     1642            || This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
    16451643    {
    16461644        /* GetDC on palettized formats is unsupported in D3D9, and the method is missing in
     
    17341732    switch(This->resource.format_desc->format)
    17351733    {
    1736         case WINED3DFMT_P8:
     1734        case WINED3DFMT_P8_UINT:
    17371735            /* ****************
    17381736                Paletted Texture
     
    17691767            break;
    17701768
    1771         case WINED3DFMT_R3G3B2:
     1769        case WINED3DFMT_B2G3R3_UNORM:
    17721770            /* **********************
    17731771                GL_UNSIGNED_BYTE_3_3_2
     
    17801778            break;
    17811779
    1782         case WINED3DFMT_R5G6B5:
     1780        case WINED3DFMT_B5G6R5_UNORM:
    17831781            if (colorkey_active) {
    17841782                *convert = CONVERT_CK_565;
     
    17891787            break;
    17901788
    1791         case WINED3DFMT_X1R5G5B5:
     1789        case WINED3DFMT_B5G5R5X1_UNORM:
    17921790            if (colorkey_active) {
    17931791                *convert = CONVERT_CK_5551;
     
    17981796            break;
    17991797
    1800         case WINED3DFMT_R8G8B8:
     1798        case WINED3DFMT_B8G8R8_UNORM:
    18011799            if (colorkey_active) {
    18021800                *convert = CONVERT_CK_RGB24;
     
    18081806            break;
    18091807
    1810         case WINED3DFMT_X8R8G8B8:
     1808        case WINED3DFMT_B8G8R8X8_UNORM:
    18111809            if (colorkey_active) {
    18121810                *convert = CONVERT_RGB32_888;
     
    18251823            break;
    18261824
    1827         case WINED3DFMT_L6V5U5:
     1825        case WINED3DFMT_R5G5_SNORM_L6_UNORM:
    18281826            *convert = CONVERT_L6V5U5;
    18291827            if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
     
    18381836            break;
    18391837
    1840         case WINED3DFMT_X8L8V8U8:
     1838        case WINED3DFMT_R8G8_SNORM_L8X8_UNORM:
    18411839            *convert = CONVERT_X8L8V8U8;
    18421840            *target_bpp = 4;
     
    18701868            break;
    18711869
    1872         case WINED3DFMT_A4L4:
    1873             /* A4L4 exists as an internal gl format, but for some reason there is not
     1870        case WINED3DFMT_L4A4_UNORM:
     1871            /* WINED3DFMT_L4A4_UNORM exists as an internal gl format, but for some reason there is not
    18741872             * format+type combination to load it. Thus convert it to A8L8, then load it
    18751873             * with A4L4 internal, but A8L8 format+type
     
    19021900            break;
    19031901
    1904         case WINED3DFMT_D15S1:
    1905             if (GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
     1902        case WINED3DFMT_S1_UINT_D15_UNORM:
     1903            if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT)
     1904                    || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
    19061905            {
    19071906                *convert = CONVERT_D15S1;
     
    19101909            break;
    19111910
    1912         case WINED3DFMT_D24X4S4:
    1913             if (GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
     1911        case WINED3DFMT_S4X4_UINT_D24_UNORM:
     1912            if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT)
     1913                    || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
    19141914            {
    19151915                *convert = CONVERT_D24X4S4;
     
    19171917            break;
    19181918
    1919         case WINED3DFMT_D24FS8:
     1919        case WINED3DFMT_S8_UINT_D24_FLOAT:
    19201920            if (GL_SUPPORT(ARB_DEPTH_BUFFER_FLOAT))
    19211921            {
     
    25172517    IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
    25182518
    2519     if (This->palette || (This->resource.format_desc->format != WINED3DFMT_P8
    2520             && This->resource.format_desc->format != WINED3DFMT_A8P8))
     2519    if (This->palette || (This->resource.format_desc->format != WINED3DFMT_P8_UINT
     2520            && This->resource.format_desc->format != WINED3DFMT_P8_UINT_A8_UNORM))
    25212521    {
    25222522        /* If a ddraw-style palette is attached assume no d3d9 palette change.
     
    27422742    FIXME("Saving texture level %d width %d height %d\n", This->texture_level, width, height);
    27432743    glGetTexImage(GL_TEXTURE_2D, This->texture_level, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, allocatedMemory);
    2744     checkGLcall("glTexImage2D");
     2744    checkGLcall("glGetTexImage");
    27452745    if (tmpTexture) {
    27462746        glBindTexture(GL_TEXTURE_2D, 0);
     
    29852985
    29862986    if(override) {
    2987         /* DDraw sets this for the X11 surfaces, so don't confuse the user 
     2987        /* DDraw sets this for the X11 surfaces, so don't confuse the user
    29882988         * FIXME("(%p) Target override is not supported by now\n", This);
    29892989         * Additionally, it isn't really possible to support triple-buffering
     
    31083108
    31093109    LEAVE_GL();
     3110
     3111    /* The texture is now most up to date - If the surface is a render target and has a drawable, this
     3112     * path is never entered
     3113     */
     3114    IWineD3DSurface_ModifyLocation((IWineD3DSurface *) This, SFLAG_INTEXTURE, TRUE);
    31103115}
    31113116
     
    33553360
    33563361    LEAVE_GL();
     3362
     3363    /* The texture is now most up to date - If the surface is a render target and has a drawable, this
     3364     * path is never entered
     3365     */
     3366    IWineD3DSurface_ModifyLocation((IWineD3DSurface *) This, SFLAG_INTEXTURE, TRUE);
    33573367}
    33583368
     
    35773587        /* When blitting from a render target a texture, the texture isn't required to have a palette.
    35783588         * In this case grab the palette from the render target. */
    3579         if ((This->resource.format_desc->format == WINED3DFMT_P8) && (This->palette == NULL))
     3589        if (This->resource.format_desc->format == WINED3DFMT_P8_UINT && !This->palette)
    35803590        {
    35813591            paletteOverride = TRUE;
     
    35993609         * backends.
    36003610         */
    3601         if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && GL_SUPPORT(EXT_FRAMEBUFFER_BLIT)
     3611        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
     3612                && myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
    36023613                && surface_can_stretch_rect(Src, This))
    36033614        {
     
    36243635            This->Flags &= ~SFLAG_INSYSMEM;
    36253636        }
    3626         /* The texture is now most up to date - If the surface is a render target and has a drawable, this
    3627          * path is never entered
    3628          */
    3629         IWineD3DSurface_ModifyLocation((IWineD3DSurface *) This, SFLAG_INTEXTURE, TRUE);
    36303637
    36313638        return WINED3D_OK;
     
    36563663         * code further down the road retrieves the palette from the surface, so
    36573664         * it must have a palette set. */
    3658         if ((Src->resource.format_desc->format == WINED3DFMT_P8) && (Src->palette == NULL))
     3665        if (Src->resource.format_desc->format == WINED3DFMT_P8_UINT && !Src->palette)
    36593666        {
    36603667            paletteOverride = TRUE;
     
    36633670        }
    36643671
    3665         if (wined3d_settings.offscreen_rendering_mode == ORM_FBO && GL_SUPPORT(EXT_FRAMEBUFFER_BLIT)
     3672        if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
     3673                && myDevice->adapter->gl_info.fbo_ops.glBlitFramebuffer
    36663674                && !(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE))
    36673675                && surface_can_stretch_rect(Src, This))
     
    37683776        if(Flags & (WINEDDBLT_KEYSRC | WINEDDBLT_KEYSRCOVERRIDE)) {
    37693777            glEnable(GL_ALPHA_TEST);
    3770             checkGLcall("glEnable GL_ALPHA_TEST");
     3778            checkGLcall("glEnable(GL_ALPHA_TEST)");
    37713779
    37723780            /* When the primary render target uses P8, the alpha component contains the palette index.
     
    37803788        } else {
    37813789            glDisable(GL_ALPHA_TEST);
    3782             checkGLcall("glDisable GL_ALPHA_TEST");
     3790            checkGLcall("glDisable(GL_ALPHA_TEST)");
    37833791        }
    37843792
     
    38263834        /* Flush in case the drawable is used by multiple GL contexts */
    38273835        if(dstSwapchain && (This == (IWineD3DSurfaceImpl *) dstSwapchain->frontBuffer || dstSwapchain->num_contexts >= 2))
    3828             glFlush();
     3836            wglFlush();
    38293837
    38303838        /* TODO: If the surface is locked often, perform the Blt in software on the memory instead */
     
    38553863             * 'clear' expect it in ARGB format => we need to do some conversion :-)
    38563864             */
    3857             if (This->resource.format_desc->format == WINED3DFMT_P8)
     3865            if (This->resource.format_desc->format == WINED3DFMT_P8_UINT)
    38583866            {
    38593867                DWORD alpha;
     
    38713879                }
    38723880            }
    3873             else if (This->resource.format_desc->format == WINED3DFMT_R5G6B5)
     3881            else if (This->resource.format_desc->format == WINED3DFMT_B5G6R5_UNORM)
    38743882            {
    38753883                if (DDBltFx->u5.dwFillColor == 0xFFFF) {
     
    38823890                }
    38833891            }
    3884             else if ((This->resource.format_desc->format == WINED3DFMT_R8G8B8)
    3885                     || (This->resource.format_desc->format == WINED3DFMT_X8R8G8B8))
     3892            else if (This->resource.format_desc->format == WINED3DFMT_B8G8R8_UNORM
     3893                    || This->resource.format_desc->format == WINED3DFMT_B8G8R8X8_UNORM)
    38863894            {
    38873895                color = 0xFF000000 | DDBltFx->u5.dwFillColor;
    38883896            }
    3889             else if (This->resource.format_desc->format == WINED3DFMT_A8R8G8B8)
     3897            else if (This->resource.format_desc->format == WINED3DFMT_B8G8R8A8_UNORM)
    38903898            {
    38913899                color = DDBltFx->u5.dwFillColor;
     
    39203928                depth = (float) DDBltFx->u5.dwFillDepth / (float) 0x0000ffff;
    39213929                break;
    3922             case WINED3DFMT_D15S1:
     3930            case WINED3DFMT_S1_UINT_D15_UNORM:
    39233931                depth = (float) DDBltFx->u5.dwFillDepth / (float) 0x0000fffe;
    39243932                break;
    3925             case WINED3DFMT_D24S8:
    3926             case WINED3DFMT_D24X8:
     3933            case WINED3DFMT_S8_UINT_D24_UNORM:
     3934            case WINED3DFMT_X8D24_UNORM:
    39273935                depth = (float) DDBltFx->u5.dwFillDepth / (float) 0x00ffffff;
    39283936                break;
    3929             case WINED3DFMT_D32:
     3937            case WINED3DFMT_D32_UNORM:
    39303938                depth = (float) DDBltFx->u5.dwFillDepth / (float) 0xffffffff;
    39313939                break;
     
    40604068    if (!pal) return WINED3D_OK;
    40614069
    4062     if (This->resource.format_desc->format == WINED3DFMT_P8
    4063             || This->resource.format_desc->format == WINED3DFMT_A8P8)
     4070    if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
     4071            || This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
    40644072    {
    40654073        int bpp;
     
    40684076
    40694077        /* Check if we are using a RTL mode which uses texturing for uploads */
    4070         BOOL use_texture = (wined3d_settings.rendertargetlock_mode == RTL_READTEX || wined3d_settings.rendertargetlock_mode == RTL_TEXTEX);
     4078        BOOL use_texture = (wined3d_settings.rendertargetlock_mode == RTL_READTEX);
    40714079
    40724080        /* Check if we have hardware palette conversion if we have convert is set to NO_CONVERSION */
     
    41734181           doesn't work in combination with ARB_TEXTURE_RECTANGLE.
    41744182        */
    4175         if(This->Flags & SFLAG_NONPOW2 && GL_SUPPORT(ARB_TEXTURE_RECTANGLE)
    4176                 && !((This->resource.format_desc->format == WINED3DFMT_P8) && GL_SUPPORT(EXT_PALETTED_TEXTURE)
    4177                 && (wined3d_settings.rendertargetlock_mode == RTL_READTEX
    4178                 || wined3d_settings.rendertargetlock_mode == RTL_TEXTEX)))
     4183        if (This->Flags & SFLAG_NONPOW2 && GL_SUPPORT(ARB_TEXTURE_RECTANGLE)
     4184                && !(This->resource.format_desc->format == WINED3DFMT_P8_UINT && GL_SUPPORT(EXT_PALETTED_TEXTURE)
     4185                && wined3d_settings.rendertargetlock_mode == RTL_READTEX))
    41794186        {
    41804187            This->texture_target = GL_TEXTURE_RECTANGLE_ARB;
     
    43614368    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
    43624369    IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
     4370    const struct wined3d_gl_info *gl_info = context->gl_info;
    43634371
    43644372    TRACE("(%p) New location %#x\n", This, location);
     
    43924400            /* Note that we use depth_blt here as well, rather than glCopyTexImage2D
    43934401             * directly on the FBO texture. That's because we need to flip. */
    4394             context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL);
     4402            context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
    43954403            if (This->texture_target == GL_TEXTURE_RECTANGLE_ARB)
    43964404            {
     
    44144422            /* Setup the destination */
    44154423            if (!device->depth_blt_rb) {
    4416                 GL_EXTCALL(glGenRenderbuffersEXT(1, &device->depth_blt_rb));
     4424                gl_info->fbo_ops.glGenRenderbuffers(1, &device->depth_blt_rb);
    44174425                checkGLcall("glGenRenderbuffersEXT");
    44184426            }
    44194427            if (device->depth_blt_rb_w != This->currentDesc.Width
    44204428                    || device->depth_blt_rb_h != This->currentDesc.Height) {
    4421                 GL_EXTCALL(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, device->depth_blt_rb));
     4429                gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, device->depth_blt_rb);
    44224430                checkGLcall("glBindRenderbufferEXT");
    4423                 GL_EXTCALL(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA8, This->currentDesc.Width, This->currentDesc.Height));
     4431                gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8,
     4432                        This->currentDesc.Width, This->currentDesc.Height);
    44244433                checkGLcall("glRenderbufferStorageEXT");
    44254434                device->depth_blt_rb_w = This->currentDesc.Width;
     
    44274436            }
    44284437
    4429             context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->dst_fbo);
    4430             GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, device->depth_blt_rb));
     4438            context_bind_fbo(context, GL_FRAMEBUFFER, &context->dst_fbo);
     4439            gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER,
     4440                    GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, device->depth_blt_rb);
    44314441            checkGLcall("glFramebufferRenderbufferEXT");
    4432             context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER_EXT, iface, FALSE);
     4442            context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, iface, FALSE);
    44334443
    44344444            /* Do the actual blit */
     
    44364446            checkGLcall("depth_blt");
    44374447
    4438             if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->current_fbo->id);
    4439             else context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL);
     4448            if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER, &context->current_fbo->id);
     4449            else context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
    44404450
    44414451            LEAVE_GL();
     
    44494459            ENTER_GL();
    44504460
    4451             context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL);
     4461            context_bind_fbo(context, GL_FRAMEBUFFER, NULL);
    44524462            surface_depth_blt(This, This->texture_name, This->currentDesc.Width,
    44534463                    This->currentDesc.Height, This->texture_target);
    44544464            checkGLcall("depth_blt");
    44554465
    4456             if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->current_fbo->id);
     4466            if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER, &context->current_fbo->id);
    44574467
    44584468            LEAVE_GL();
     
    46554665    checkGLcall("glEnable(bind_target)");
    46564666    glBindTexture(bind_target, This->texture_name);
    4657     checkGLcall("bind_target, This->texture_name)");
     4667    checkGLcall("glBindTexture(bind_target, This->texture_name)");
    46584668    glTexParameteri(bind_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    46594669    checkGLcall("glTexParameteri");
     
    46934703        if(((IWineD3DSwapChainImpl*)swapchain)->frontBuffer == (IWineD3DSurface*)This ||
    46944704           ((IWineD3DSwapChainImpl*)swapchain)->num_contexts >= 2)
    4695             glFlush();
     4705            wglFlush();
    46964706
    46974707        IWineD3DSwapChain_Release(swapchain);
     
    47024712        if(SUCCEEDED(IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DBaseTexture, (void **) &texture)))
    47034713        {
    4704             ((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
    4705             ((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
    4706             ((IWineD3DBaseTextureImpl *) texture)->baseTexture.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
     4714            ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MAGFILTER] = WINED3DTEXF_POINT;
     4715            ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MINFILTER] = WINED3DTEXF_POINT;
     4716            ((IWineD3DBaseTextureImpl *) texture)->baseTexture.texture_rgb.states[WINED3DTEXSTA_MIPFILTER] = WINED3DTEXF_NONE;
    47074717            IWineD3DBaseTexture_Release(texture);
    47084718        }
     
    48514861                }
    48524862            } else {
    4853                 if((This->Flags & SFLAG_LOCATIONS) == SFLAG_INSRGBTEX) {
     4863                if((This->Flags & (SFLAG_INSRGBTEX | SFLAG_INSYSMEM)) == SFLAG_INSRGBTEX) {
    48544864                    /* Performance warning ... */
    48554865                    FIXME("%p: Downloading srgb texture to reload it as rgb\n", This);
    48564866                    IWineD3DSurfaceImpl_LoadLocation(iface, SFLAG_INSYSMEM, rect);
    48574867                }
     4868            }
     4869            if(!(This->Flags & SFLAG_INSYSMEM)) {
     4870                /* Should not happen */
     4871                ERR("Trying to load a texture from sysmem, but SFLAG_INSYSMEM is not set\n");
     4872                /* Lets hope we get it from somewhere... */
     4873                IWineD3DSurfaceImpl_LoadLocation(iface, SFLAG_INSYSMEM, rect);
    48584874            }
    48594875
     
    48944910                This->Flags |= SFLAG_CONVERTED;
    48954911            }
    4896             else if ((This->resource.format_desc->format == WINED3DFMT_P8)
     4912            else if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
    48974913                    && (GL_SUPPORT(EXT_PALETTED_TEXTURE) || GL_SUPPORT(ARB_FRAGMENT_PROGRAM)))
    48984914            {
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_base.c

    r21731 r23571  
    1111 * Copyright 2007 Henri Verbeet
    1212 * Copyright 2006-2007 Roderick Colenbrander
     13 * Copyright 2009 Henri Verbeet for CodeWeavers
    1314 *
    1415 * This library is free software; you can redistribute it and/or
     
    552553    UINT usage;
    553554
     555    if(!(format_desc->Flags & WINED3DFMT_FLAG_GETDC))
     556    {
     557        WARN("Cannot use GetDC on a %s surface\n", debug_d3dformat(format_desc->format));
     558        return WINED3DERR_INVALIDCALL;
     559    }
     560
    554561    switch (format_desc->byte_count)
    555562    {
     
    602609    switch (This->resource.format_desc->format)
    603610    {
    604         case WINED3DFMT_R8G8B8:
     611        case WINED3DFMT_B8G8R8_UNORM:
    605612            usage = DIB_RGB_COLORS;
    606613            b_info->bmiHeader.biCompression = BI_RGB;
    607614            break;
    608615
    609         case WINED3DFMT_X1R5G5B5:
    610         case WINED3DFMT_A1R5G5B5:
    611         case WINED3DFMT_A4R4G4B4:
    612         case WINED3DFMT_X4R4G4B4:
    613         case WINED3DFMT_R3G3B2:
    614         case WINED3DFMT_A8R3G3B2:
     616        case WINED3DFMT_B5G5R5X1_UNORM:
     617        case WINED3DFMT_B5G5R5A1_UNORM:
     618        case WINED3DFMT_B4G4R4A4_UNORM:
     619        case WINED3DFMT_B4G4R4X4_UNORM:
     620        case WINED3DFMT_B2G3R3_UNORM:
     621        case WINED3DFMT_B2G3R3A8_UNORM:
    615622        case WINED3DFMT_R10G10B10A2_UNORM:
    616623        case WINED3DFMT_R8G8B8A8_UNORM:
    617         case WINED3DFMT_X8B8G8R8:
    618         case WINED3DFMT_A2R10G10B10:
    619         case WINED3DFMT_R5G6B5:
     624        case WINED3DFMT_R8G8B8X8_UNORM:
     625        case WINED3DFMT_B10G10R10A2_UNORM:
     626        case WINED3DFMT_B5G6R5_UNORM:
    620627        case WINED3DFMT_R16G16B16A16_UNORM:
    621628            usage = 0;
     
    760767static const struct d3dfmt_convertor_desc convertors[] =
    761768{
    762     {WINED3DFMT_R32_FLOAT,  WINED3DFMT_R16_FLOAT,   convert_r32_float_r16_float},
    763     {WINED3DFMT_R5G6B5,     WINED3DFMT_X8R8G8B8,    convert_r5g6b5_x8r8g8b8},
    764     {WINED3DFMT_A8R8G8B8,   WINED3DFMT_X8R8G8B8,    convert_a8r8g8b8_x8r8g8b8},
     769    {WINED3DFMT_R32_FLOAT,      WINED3DFMT_R16_FLOAT,       convert_r32_float_r16_float},
     770    {WINED3DFMT_B5G6R5_UNORM,   WINED3DFMT_B8G8R8X8_UNORM,  convert_r5g6b5_x8r8g8b8},
     771    {WINED3DFMT_B8G8R8A8_UNORM, WINED3DFMT_B8G8R8X8_UNORM,  convert_a8r8g8b8_x8r8g8b8},
    765772};
    766773
     
    803810            source->currentDesc.Height, to_fmt, TRUE /* lockable */, TRUE /* discard  */, 0 /* level */, &ret,
    804811            0 /* usage */, WINED3DPOOL_SCRATCH, WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */,
    805             0 /* MultiSampleQuality */, IWineD3DSurface_GetImplType((IWineD3DSurface *) source), NULL /* parent */);
     812            0 /* MultiSampleQuality */, IWineD3DSurface_GetImplType((IWineD3DSurface *) source),
     813            NULL /* parent */, &wined3d_null_parent_ops);
    806814    if(!ret) {
    807815        ERR("Failed to create a destination surface for conversion\n");
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface_gdi.c

    r21731 r23571  
    323323    fprintf(f, "P6\n%d %d\n255\n", This->pow2Width, This->pow2Height);
    324324
    325     if (This->resource.format_desc->format == WINED3DFMT_P8)
     325    if (This->resource.format_desc->format == WINED3DFMT_P8_UINT)
    326326    {
    327327        unsigned char table[256][3];
     
    393393
    394394    TRACE("(%p)->(%p)\n",This,pHDC);
     395
     396    if(!(This->Flags & SFLAG_DIBSECTION))
     397    {
     398        WARN("DC not supported on this surface\n");
     399        return WINED3DERR_INVALIDCALL;
     400    }
    395401
    396402    if(This->Flags & SFLAG_USERPTR) {
     
    422428    }
    423429
    424     if (This->resource.format_desc->format == WINED3DFMT_P8
    425             || This->resource.format_desc->format == WINED3DFMT_A8P8)
     430    if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
     431            || This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
    426432    {
    427433        unsigned int n;
     
    535541{
    536542    IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
     543    HRESULT hr;
    537544
    538545    if(This->resource.usage & WINED3DUSAGE_OVERLAY)
     
    541548        return WINED3DERR_INVALIDCALL;
    542549    }
     550
    543551    /* Sysmem textures have memory already allocated -
    544552     * release it, this avoids an unnecessary memcpy
    545553     */
    546     HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
    547     This->resource.allocatedMemory = NULL;
    548     This->resource.heapMemory = NULL;
     554    hr = IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
     555    if(SUCCEEDED(hr))
     556    {
     557        HeapFree(GetProcessHeap(), 0, This->resource.heapMemory);
     558        This->resource.heapMemory = NULL;
     559        This->resource.allocatedMemory = This->dib.bitmap_data;
     560    }
    549561
    550562    /* We don't mind the nonpow2 stuff in GDI */
    551563    This->pow2Width = This->currentDesc.Width;
    552564    This->pow2Height = This->currentDesc.Height;
    553 
    554     IWineD3DBaseSurfaceImpl_CreateDIBSection(iface);
    555     This->resource.allocatedMemory = This->dib.bitmap_data;
    556565
    557566    return WINED3D_OK;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain.c

    r22496 r23571  
    4646
    4747/*IWineD3DSwapChain parts follow: */
    48 static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderTarget) {
     48static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface)
     49{
    4950    IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
    5051    WINED3DDISPLAYMODE mode;
     
    5556    IWineD3DSwapChain_SetGammaRamp(iface, 0, &This->orig_gamma);
    5657
    57     /* release the ref to the front and back buffer parents */
    58     if(This->frontBuffer) {
     58    /* Release the swapchain's draw buffers. Make sure This->backBuffer[0] is
     59     * the last buffer to be destroyed, FindContext() depends on that. */
     60    if (This->frontBuffer)
     61    {
    5962        IWineD3DSurface_SetContainer(This->frontBuffer, 0);
    60         if(D3DCB_DestroyRenderTarget(This->frontBuffer) > 0) {
    61             FIXME("(%p) Something's still holding the front buffer\n",This);
    62         }
    63     }
    64 
    65     if(This->backBuffer) {
    66         UINT i;
    67         for(i = 0; i < This->presentParms.BackBufferCount; i++) {
     63        if (IWineD3DSurface_Release(This->frontBuffer))
     64        {
     65            WARN("(%p) Something's still holding the front buffer (%p).\n",
     66                    This, This->frontBuffer);
     67        }
     68        This->frontBuffer = NULL;
     69    }
     70
     71    if (This->backBuffer)
     72    {
     73        UINT i = This->presentParms.BackBufferCount;
     74
     75        while (i--)
     76        {
    6877            IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
    69             if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
    70                 FIXME("(%p) Something's still holding the back buffer\n",This);
    71             }
     78            if (IWineD3DSurface_Release(This->backBuffer[i]))
     79                WARN("(%p) Something's still holding back buffer %u (%p).\n",
     80                        This, i, This->backBuffer[i]);
    7281        }
    7382        HeapFree(GetProcessHeap(), 0, This->backBuffer);
     83        This->backBuffer = NULL;
    7484    }
    7585
     
    120130        cursor.resource.wineD3DDevice = This->wineD3DDevice;
    121131        cursor.resource.pool = WINED3DPOOL_SCRATCH;
    122         cursor.resource.format_desc = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &This->wineD3DDevice->adapter->gl_info);
     132        cursor.resource.format_desc =
     133                getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->wineD3DDevice->adapter->gl_info);
    123134        cursor.resource.resourceType = WINED3DRTYPE_SURFACE;
    124135        cursor.texture_name = This->wineD3DDevice->cursorTexture;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain_base.c

    r16477 r23571  
    6969    TRACE("(%p) : ReleaseRef to %d\n", This, refCount);
    7070    if (refCount == 0) {
    71         IWineD3DSwapChain_Destroy(iface, D3DCB_DefaultDestroySurface);
     71        IWineD3DSwapChain_Destroy(iface);
    7272    }
    7373    return refCount;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/swapchain_gdi.c

    r16477 r23571  
    3737WINE_DECLARE_DEBUG_CHANNEL(fps);
    3838
    39 static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderback) {
     39static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface)
     40{
    4041    IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
    4142    WINED3DDISPLAYMODE mode;
     
    4849    if(This->frontBuffer) {
    4950        IWineD3DSurface_SetContainer(This->frontBuffer, 0);
    50         if(D3DCB_DestroyRenderback(This->frontBuffer) > 0) {
    51             FIXME("(%p) Something's still holding the front buffer\n",This);
     51        if (IWineD3DSurface_Release(This->frontBuffer) > 0)
     52        {
     53            WARN("(%p) Something's still holding the front buffer\n",This);
    5254        }
    5355    }
     
    5759        for(i = 0; i < This->presentParms.BackBufferCount; i++) {
    5860            IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
    59             if(D3DCB_DestroyRenderback(This->backBuffer[i]) > 0) {
    60                 FIXME("(%p) Something's still holding the back buffer\n",This);
     61            if (IWineD3DSurface_Release(This->backBuffer[i]) > 0)
     62            {
     63                WARN("(%p) Something's still holding the back buffer\n",This);
    6164            }
    6265        }
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c

    r22496 r23571  
    66 * Copyright 2005 Oliver Stieber
    77 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     8 * Copyright 2009 Henri Verbeet for CodeWeavers
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    6768            break;
    6869    }
    69     dirty = srgb_mode ? &This->baseTexture.srgbDirty : &This->baseTexture.dirty;
     70    dirty = srgb_mode ? &This->baseTexture.texture_srgb.dirty : &This->baseTexture.texture_rgb.dirty;
    7071
    7172    if (!device->isInDraw)
     
    7677    }
    7778
    78     if (This->resource.format_desc->format == WINED3DFMT_P8
    79             || This->resource.format_desc->format == WINED3DFMT_A8P8)
     79    if (This->resource.format_desc->format == WINED3DFMT_P8_UINT
     80            || This->resource.format_desc->format == WINED3DFMT_P8_UINT_A8_UNORM)
    8081    {
    8182        for (i = 0; i < This->baseTexture.levels; ++i)
     
    110111}
    111112
    112 static void texture_cleanup(IWineD3DTextureImpl *This, D3DCB_DESTROYSURFACEFN surface_destroy_cb)
     113static void texture_cleanup(IWineD3DTextureImpl *This)
    113114{
    114115    unsigned int i;
     
    126127            surface_set_texture_target(This->surfaces[i], 0);
    127128            IWineD3DSurface_SetContainer(This->surfaces[i], 0);
    128             surface_destroy_cb(This->surfaces[i]);
     129            IWineD3DSurface_Release(This->surfaces[i]);
    129130        }
    130131    }
     
    132133    TRACE("(%p) : Cleaning up base texture\n", This);
    133134    basetexture_cleanup((IWineD3DBaseTexture *)This);
    134 }
    135 
    136 HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
    137         IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
    138 {
    139     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    140     const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
    141     UINT pow2_width, pow2_height;
    142     UINT tmp_w, tmp_h;
    143     unsigned int i;
    144     HRESULT hr;
    145 
    146     /* TODO: It should only be possible to create textures for formats
    147      * that are reported as supported. */
    148     if (WINED3DFMT_UNKNOWN >= format)
    149     {
    150         WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
    151         return WINED3DERR_INVALIDCALL;
    152     }
    153 
    154     /* Non-power2 support. */
    155     if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO))
    156     {
    157         pow2_width = width;
    158         pow2_height = height;
    159     }
    160     else
    161     {
    162         /* Find the nearest pow2 match. */
    163         pow2_width = pow2_height = 1;
    164         while (pow2_width < width) pow2_width <<= 1;
    165         while (pow2_height < height) pow2_height <<= 1;
    166 
    167         if (pow2_width != width || pow2_height != height)
    168         {
    169             if (levels > 1)
    170             {
    171                 WARN("Attempted to create a mipmapped np2 texture without unconditional np2 support.\n");
    172                 return WINED3DERR_INVALIDCALL;
    173             }
    174             levels = 1;
    175         }
    176     }
    177 
    178     /* Calculate levels for mip mapping. */
    179     if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
    180     {
    181         if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
    182         {
    183             WARN("No mipmap generation support, returning WINED3DERR_INVALIDCALL.\n");
    184             return WINED3DERR_INVALIDCALL;
    185         }
    186 
    187         if (levels > 1)
    188         {
    189             WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning WINED3DERR_INVALIDCALL.\n");
    190             return WINED3DERR_INVALIDCALL;
    191         }
    192 
    193         levels = 1;
    194     }
    195     else if (!levels)
    196     {
    197         levels = wined3d_log2i(max(width, height)) + 1;
    198         TRACE("Calculated levels = %u.\n", levels);
    199     }
    200 
    201     hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
    202             WINED3DRTYPE_TEXTURE, device, 0, usage, format_desc, pool, parent);
    203     if (FAILED(hr))
    204     {
    205         WARN("Failed to initialize basetexture, returning %#x.\n", hr);
    206         return hr;
    207     }
    208 
    209     /* Precalculated scaling for 'faked' non power of two texture coords.
    210      * Second also don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
    211      * is used in combination with texture uploads (RTL_READTEX/RTL_TEXTEX). The reason is that EXT_PALETTED_TEXTURE
    212      * doesn't work in combination with ARB_TEXTURE_RECTANGLE. */
    213     if (GL_SUPPORT(WINE_NORMALIZED_TEXRECT) && (width != pow2_width || height != pow2_height))
    214     {
    215         texture->baseTexture.pow2Matrix[0] = 1.0f;
    216         texture->baseTexture.pow2Matrix[5] = 1.0f;
    217         texture->baseTexture.pow2Matrix[10] = 1.0f;
    218         texture->baseTexture.pow2Matrix[15] = 1.0f;
    219         texture->target = GL_TEXTURE_2D;
    220         texture->cond_np2 = TRUE;
    221         texture->baseTexture.minMipLookup = minMipLookup_noFilter;
    222     }
    223     else if (GL_SUPPORT(ARB_TEXTURE_RECTANGLE) && (width != pow2_width || height != pow2_height)
    224             && !((format_desc->format == WINED3DFMT_P8) && GL_SUPPORT(EXT_PALETTED_TEXTURE)
    225             && (wined3d_settings.rendertargetlock_mode == RTL_READTEX
    226             || wined3d_settings.rendertargetlock_mode == RTL_TEXTEX)))
    227     {
    228         if ((width != 1) || (height != 1)) texture->baseTexture.pow2Matrix_identity = FALSE;
    229 
    230         texture->baseTexture.pow2Matrix[0] = (float)width;
    231         texture->baseTexture.pow2Matrix[5] = (float)height;
    232         texture->baseTexture.pow2Matrix[10] = 1.0f;
    233         texture->baseTexture.pow2Matrix[15] = 1.0f;
    234         texture->target = GL_TEXTURE_RECTANGLE_ARB;
    235         texture->cond_np2 = TRUE;
    236         texture->baseTexture.minMipLookup = minMipLookup_noFilter;
    237     }
    238     else
    239     {
    240         if ((width != pow2_width) || (height != pow2_height))
    241         {
    242             texture->baseTexture.pow2Matrix_identity = FALSE;
    243             texture->baseTexture.pow2Matrix[0] = (((float)width) / ((float)pow2_width));
    244             texture->baseTexture.pow2Matrix[5] = (((float)height) / ((float)pow2_height));
    245         }
    246         else
    247         {
    248             texture->baseTexture.pow2Matrix[0] = 1.0f;
    249             texture->baseTexture.pow2Matrix[5] = 1.0f;
    250         }
    251 
    252         texture->baseTexture.pow2Matrix[10] = 1.0f;
    253         texture->baseTexture.pow2Matrix[15] = 1.0f;
    254         texture->target = GL_TEXTURE_2D;
    255         texture->cond_np2 = FALSE;
    256     }
    257     TRACE("xf(%f) yf(%f)\n", texture->baseTexture.pow2Matrix[0], texture->baseTexture.pow2Matrix[5]);
    258 
    259     /* Generate all the surfaces. */
    260     tmp_w = width;
    261     tmp_h = height;
    262     for (i = 0; i < texture->baseTexture.levels; ++i)
    263     {
    264         /* Use the callback to create the texture surface. */
    265         hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h, format_desc->format,
    266                 usage, pool, i, WINED3DCUBEMAP_FACE_POSITIVE_X, &texture->surfaces[i]);
    267         if (FAILED(hr) || ((IWineD3DSurfaceImpl *)texture->surfaces[i])->Flags & SFLAG_OVERSIZE)
    268         {
    269             FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
    270             texture->surfaces[i] = NULL;
    271             texture_cleanup(texture, D3DCB_DefaultDestroySurface);
    272             return hr;
    273         }
    274 
    275         IWineD3DSurface_SetContainer(texture->surfaces[i], (IWineD3DBase *)texture);
    276         TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[i]);
    277         surface_set_texture_target(texture->surfaces[i], texture->target);
    278         /* Calculate the next mipmap level. */
    279         tmp_w = max(1, tmp_w >> 1);
    280         tmp_h = max(1, tmp_h >> 1);
    281     }
    282     texture->baseTexture.internal_preload = texture_internal_preload;
    283 
    284     return WINED3D_OK;
    285135}
    286136
     
    321171    TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
    322172    ref = InterlockedDecrement(&This->resource.ref);
    323     if (ref == 0) {
    324         IWineD3DTexture_Destroy(iface, D3DCB_DefaultDestroySurface);
     173    if (!ref)
     174    {
     175        texture_cleanup(This);
     176        This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
     177        HeapFree(GetProcessHeap(), 0, This);
    325178    }
    326179    return ref;
     
    432285    if (set_gl_texture_desc && SUCCEEDED(hr)) {
    433286        UINT i;
     287        struct gl_texture *gl_tex;
     288
     289        if(This->baseTexture.is_srgb) {
     290            gl_tex = &This->baseTexture.texture_srgb;
     291        } else {
     292            gl_tex = &This->baseTexture.texture_rgb;
     293        }
     294
    434295        for (i = 0; i < This->baseTexture.levels; ++i) {
    435             if(This->baseTexture.is_srgb) {
    436                 surface_set_texture_name(This->surfaces[i], This->baseTexture.srgbTextureName, TRUE);
    437             } else {
    438                 surface_set_texture_name(This->surfaces[i], This->baseTexture.textureName, FALSE);
    439             }
     296            surface_set_texture_name(This->surfaces[i], gl_tex->name, This->baseTexture.is_srgb);
    440297        }
    441298        /* Conditinal non power of two textures use a different clamping default. If we're using the GL_WINE_normalized_texrect
     
    455312            checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
    456313            LEAVE_GL();
    457             This->baseTexture.states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_CLAMP;
    458             This->baseTexture.states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_CLAMP;
    459             This->baseTexture.states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_POINT;
    460             This->baseTexture.states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT;
    461             This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_NONE;
     314            gl_tex->states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_CLAMP;
     315            gl_tex->states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_CLAMP;
     316            gl_tex->states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_POINT;
     317            gl_tex->states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT;
     318            gl_tex->states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_NONE;
    462319        }
    463320    }
     
    483340   IWineD3DTexture IWineD3DTexture parts follow
    484341   ******************************************* */
    485 static void WINAPI IWineD3DTextureImpl_Destroy(IWineD3DTexture *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroySurface) {
    486     IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
    487 
    488     texture_cleanup(This, D3DCB_DestroySurface);
    489     /* free the object */
    490     HeapFree(GetProcessHeap(), 0, This);
    491 }
    492 
    493342static HRESULT WINAPI IWineD3DTextureImpl_GetLevelDesc(IWineD3DTexture *iface, UINT Level, WINED3DSURFACE_DESC* pDesc) {
    494343    IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
     
    553402static HRESULT WINAPI IWineD3DTextureImpl_AddDirtyRect(IWineD3DTexture *iface, CONST RECT* pDirtyRect) {
    554403    IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
    555     This->baseTexture.dirty = TRUE;
    556     This->baseTexture.srgbDirty = TRUE;
     404    This->baseTexture.texture_rgb.dirty = TRUE;
     405    This->baseTexture.texture_srgb.dirty = TRUE;
    557406    TRACE("(%p) : dirtyfication of surface Level (0)\n", This);
    558407    surface_add_dirty_rect(This->surfaces[0], pDirtyRect);
     
    561410}
    562411
    563 const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
     412static const IWineD3DTextureVtbl IWineD3DTexture_Vtbl =
    564413{
    565414    /* IUnknown */
     
    591440    IWineD3DTextureImpl_IsCondNP2,
    592441    /* IWineD3DTexture */
    593     IWineD3DTextureImpl_Destroy,
    594442    IWineD3DTextureImpl_GetLevelDesc,
    595443    IWineD3DTextureImpl_GetSurfaceLevel,
     
    598446    IWineD3DTextureImpl_AddDirtyRect
    599447};
     448
     449HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
     450        IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
     451        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     452{
     453    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     454    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
     455    UINT pow2_width, pow2_height;
     456    UINT tmp_w, tmp_h;
     457    unsigned int i;
     458    HRESULT hr;
     459
     460    /* TODO: It should only be possible to create textures for formats
     461     * that are reported as supported. */
     462    if (WINED3DFMT_UNKNOWN >= format)
     463    {
     464        WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
     465        return WINED3DERR_INVALIDCALL;
     466    }
     467
     468    /* Non-power2 support. */
     469    if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO])
     470    {
     471        pow2_width = width;
     472        pow2_height = height;
     473    }
     474    else
     475    {
     476        /* Find the nearest pow2 match. */
     477        pow2_width = pow2_height = 1;
     478        while (pow2_width < width) pow2_width <<= 1;
     479        while (pow2_height < height) pow2_height <<= 1;
     480
     481        if (pow2_width != width || pow2_height != height)
     482        {
     483            if (levels > 1)
     484            {
     485                WARN("Attempted to create a mipmapped np2 texture without unconditional np2 support.\n");
     486                return WINED3DERR_INVALIDCALL;
     487            }
     488            levels = 1;
     489        }
     490    }
     491
     492    /* Calculate levels for mip mapping. */
     493    if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
     494    {
     495        if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
     496        {
     497            WARN("No mipmap generation support, returning WINED3DERR_INVALIDCALL.\n");
     498            return WINED3DERR_INVALIDCALL;
     499        }
     500
     501        if (levels > 1)
     502        {
     503            WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning WINED3DERR_INVALIDCALL.\n");
     504            return WINED3DERR_INVALIDCALL;
     505        }
     506
     507        levels = 1;
     508    }
     509    else if (!levels)
     510    {
     511        levels = wined3d_log2i(max(width, height)) + 1;
     512        TRACE("Calculated levels = %u.\n", levels);
     513    }
     514
     515    texture->lpVtbl = &IWineD3DTexture_Vtbl;
     516
     517    hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_TEXTURE,
     518            device, 0, usage, format_desc, pool, parent, parent_ops);
     519    if (FAILED(hr))
     520    {
     521        WARN("Failed to initialize basetexture, returning %#x.\n", hr);
     522        return hr;
     523    }
     524
     525    /* Precalculated scaling for 'faked' non power of two texture coords.
     526     * Second also don't use ARB_TEXTURE_RECTANGLE in case the surface format is P8 and EXT_PALETTED_TEXTURE
     527     * is used in combination with texture uploads (RTL_READTEX). The reason is that EXT_PALETTED_TEXTURE
     528     * doesn't work in combination with ARB_TEXTURE_RECTANGLE. */
     529    if (gl_info->supported[WINE_NORMALIZED_TEXRECT] && (width != pow2_width || height != pow2_height))
     530    {
     531        texture->baseTexture.pow2Matrix[0] = 1.0f;
     532        texture->baseTexture.pow2Matrix[5] = 1.0f;
     533        texture->baseTexture.pow2Matrix[10] = 1.0f;
     534        texture->baseTexture.pow2Matrix[15] = 1.0f;
     535        texture->target = GL_TEXTURE_2D;
     536        texture->cond_np2 = TRUE;
     537        texture->baseTexture.minMipLookup = minMipLookup_noFilter;
     538    }
     539    else if (gl_info->supported[ARB_TEXTURE_RECTANGLE] && (width != pow2_width || height != pow2_height)
     540            && !(format_desc->format == WINED3DFMT_P8_UINT && gl_info->supported[EXT_PALETTED_TEXTURE]
     541            && wined3d_settings.rendertargetlock_mode == RTL_READTEX))
     542    {
     543        if ((width != 1) || (height != 1)) texture->baseTexture.pow2Matrix_identity = FALSE;
     544
     545        texture->baseTexture.pow2Matrix[0] = (float)width;
     546        texture->baseTexture.pow2Matrix[5] = (float)height;
     547        texture->baseTexture.pow2Matrix[10] = 1.0f;
     548        texture->baseTexture.pow2Matrix[15] = 1.0f;
     549        texture->target = GL_TEXTURE_RECTANGLE_ARB;
     550        texture->cond_np2 = TRUE;
     551
     552        if(texture->resource.format_desc->Flags & WINED3DFMT_FLAG_FILTERING)
     553        {
     554            texture->baseTexture.minMipLookup = minMipLookup_noMip;
     555        }
     556        else
     557        {
     558            texture->baseTexture.minMipLookup = minMipLookup_noFilter;
     559        }
     560    }
     561    else
     562    {
     563        if ((width != pow2_width) || (height != pow2_height))
     564        {
     565            texture->baseTexture.pow2Matrix_identity = FALSE;
     566            texture->baseTexture.pow2Matrix[0] = (((float)width) / ((float)pow2_width));
     567            texture->baseTexture.pow2Matrix[5] = (((float)height) / ((float)pow2_height));
     568        }
     569        else
     570        {
     571            texture->baseTexture.pow2Matrix[0] = 1.0f;
     572            texture->baseTexture.pow2Matrix[5] = 1.0f;
     573        }
     574
     575        texture->baseTexture.pow2Matrix[10] = 1.0f;
     576        texture->baseTexture.pow2Matrix[15] = 1.0f;
     577        texture->target = GL_TEXTURE_2D;
     578        texture->cond_np2 = FALSE;
     579    }
     580    TRACE("xf(%f) yf(%f)\n", texture->baseTexture.pow2Matrix[0], texture->baseTexture.pow2Matrix[5]);
     581
     582    /* Generate all the surfaces. */
     583    tmp_w = width;
     584    tmp_h = height;
     585    for (i = 0; i < texture->baseTexture.levels; ++i)
     586    {
     587        /* Use the callback to create the texture surface. */
     588        hr = IWineD3DDeviceParent_CreateSurface(device->device_parent, parent, tmp_w, tmp_h, format_desc->format,
     589                usage, pool, i, WINED3DCUBEMAP_FACE_POSITIVE_X, &texture->surfaces[i]);
     590        if (FAILED(hr) || ((IWineD3DSurfaceImpl *)texture->surfaces[i])->Flags & SFLAG_OVERSIZE)
     591        {
     592            FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
     593            texture->surfaces[i] = NULL;
     594            texture_cleanup(texture);
     595            return hr;
     596        }
     597
     598        IWineD3DSurface_SetContainer(texture->surfaces[i], (IWineD3DBase *)texture);
     599        TRACE("Created surface level %u @ %p.\n", i, texture->surfaces[i]);
     600        surface_set_texture_target(texture->surfaces[i], texture->target);
     601        /* Calculate the next mipmap level. */
     602        tmp_w = max(1, tmp_w >> 1);
     603        tmp_h = max(1, tmp_h >> 1);
     604    }
     605    texture->baseTexture.internal_preload = texture_internal_preload;
     606
     607    return WINED3D_OK;
     608}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/utils.c

    r22496 r23571  
    88 * Copyright 2006-2008 Henri Verbeet
    99 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     10 * Copyright 2009 Henri Verbeet for CodeWeavers
    1011 *
    1112 * This library is free software; you can redistribute it and/or
     
    5960static const struct StaticPixelFormatDesc formats[] =
    6061{
    61   /* WINED3DFORMAT               alphamask    redmask    greenmask    bluemask     bpp    depth  stencil  isFourcc */
    62     {WINED3DFMT_UNKNOWN,            0x0,        0x0,        0x0,        0x0,        0,      0,      0,      FALSE},
    63     /* FourCC formats, kept here to have WINED3DFMT_R8G8B8(=20) at position 20 */
    64     {WINED3DFMT_UYVY,               0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
    65     {WINED3DFMT_YUY2,               0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
    66     {WINED3DFMT_YV12,               0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
    67     {WINED3DFMT_DXT1,               0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
    68     {WINED3DFMT_DXT2,               0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
    69     {WINED3DFMT_DXT3,               0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
    70     {WINED3DFMT_DXT4,               0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
    71     {WINED3DFMT_DXT5,               0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
    72     {WINED3DFMT_MULTI2_ARGB8,       0x0,        0x0,        0x0,        0x0,        1/*?*/, 0,      0,      TRUE },
    73     {WINED3DFMT_G8R8_G8B8,          0x0,        0x0,        0x0,        0x0,        1/*?*/, 0,      0,      TRUE },
    74     {WINED3DFMT_R8G8_B8G8,          0x0,        0x0,        0x0,        0x0,        1/*?*/, 0,      0,      TRUE },
     62  /* WINED3DFORMAT                   alphamask    redmask    greenmask    bluemask     bpp    depth  stencil isFourcc */
     63    {WINED3DFMT_UNKNOWN,                0x0,        0x0,        0x0,        0x0,        0,      0,      0,      FALSE},
     64    /* FourCC formats */
     65    {WINED3DFMT_UYVY,                   0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
     66    {WINED3DFMT_YUY2,                   0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
     67    {WINED3DFMT_YV12,                   0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
     68    {WINED3DFMT_DXT1,                   0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
     69    {WINED3DFMT_DXT2,                   0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
     70    {WINED3DFMT_DXT3,                   0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
     71    {WINED3DFMT_DXT4,                   0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
     72    {WINED3DFMT_DXT5,                   0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
     73    {WINED3DFMT_MULTI2_ARGB8,           0x0,        0x0,        0x0,        0x0,        1/*?*/, 0,      0,      TRUE },
     74    {WINED3DFMT_G8R8_G8B8,              0x0,        0x0,        0x0,        0x0,        1/*?*/, 0,      0,      TRUE },
     75    {WINED3DFMT_R8G8_B8G8,              0x0,        0x0,        0x0,        0x0,        1/*?*/, 0,      0,      TRUE },
    7576    /* IEEE formats */
    76     {WINED3DFMT_R32_FLOAT,          0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    77     {WINED3DFMT_R32G32_FLOAT,       0x0,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
    78     {WINED3DFMT_R32G32B32_FLOAT,    0x0,        0x0,        0x0,        0x0,        12,     0,      0,      FALSE},
    79     {WINED3DFMT_R32G32B32A32_FLOAT, 0x1,        0x0,        0x0,        0x0,        16,     0,      0,      FALSE},
     77    {WINED3DFMT_R32_FLOAT,              0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     78    {WINED3DFMT_R32G32_FLOAT,           0x0,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
     79    {WINED3DFMT_R32G32B32_FLOAT,        0x0,        0x0,        0x0,        0x0,        12,     0,      0,      FALSE},
     80    {WINED3DFMT_R32G32B32A32_FLOAT,     0x1,        0x0,        0x0,        0x0,        16,     0,      0,      FALSE},
    8081    /* Hmm? */
    81     {WINED3DFMT_CxV8U8,             0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
     82    {WINED3DFMT_R8G8_SNORM_Cx,          0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
    8283    /* Float */
    83     {WINED3DFMT_R16_FLOAT,          0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
    84     {WINED3DFMT_R16G16_FLOAT,       0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    85     {WINED3DFMT_R16G16_SINT,        0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    86     {WINED3DFMT_R16G16B16A16_FLOAT, 0x1,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
    87     {WINED3DFMT_R16G16B16A16_SINT,  0x1,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
     84    {WINED3DFMT_R16_FLOAT,              0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
     85    {WINED3DFMT_R16G16_FLOAT,           0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     86    {WINED3DFMT_R16G16_SINT,            0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     87    {WINED3DFMT_R16G16B16A16_FLOAT,     0x1,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
     88    {WINED3DFMT_R16G16B16A16_SINT,      0x1,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
    8889    /* Palettized formats */
    89     {WINED3DFMT_A8P8,               0x0000ff00, 0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
    90     {WINED3DFMT_P8,                 0x0,        0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
     90    {WINED3DFMT_P8_UINT_A8_UNORM,       0x0000ff00, 0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
     91    {WINED3DFMT_P8_UINT,                0x0,        0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
    9192    /* Standard ARGB formats. */
    92     {WINED3DFMT_R8G8B8,             0x0,        0x00ff0000, 0x0000ff00, 0x000000ff, 3,      0,      0,      FALSE},
    93     {WINED3DFMT_A8R8G8B8,           0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff, 4,      0,      0,      FALSE},
    94     {WINED3DFMT_X8R8G8B8,           0x0,        0x00ff0000, 0x0000ff00, 0x000000ff, 4,      0,      0,      FALSE},
    95     {WINED3DFMT_R5G6B5,             0x0,        0x0000f800, 0x000007e0, 0x0000001f, 2,      0,      0,      FALSE},
    96     {WINED3DFMT_X1R5G5B5,           0x0,        0x00007c00, 0x000003e0, 0x0000001f, 2,      0,      0,      FALSE},
    97     {WINED3DFMT_A1R5G5B5,           0x00008000, 0x00007c00, 0x000003e0, 0x0000001f, 2,      0,      0,      FALSE},
    98     {WINED3DFMT_A4R4G4B4,           0x0000f000, 0x00000f00, 0x000000f0, 0x0000000f, 2,      0,      0,      FALSE},
    99     {WINED3DFMT_R3G3B2,             0x0,        0x000000e0, 0x0000001c, 0x00000003, 1,      0,      0,      FALSE},
    100     {WINED3DFMT_A8_UNORM,           0x000000ff, 0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
    101     {WINED3DFMT_A8R3G3B2,           0x0000ff00, 0x000000e0, 0x0000001c, 0x00000003, 2,      0,      0,      FALSE},
    102     {WINED3DFMT_X4R4G4B4,           0x0,        0x00000f00, 0x000000f0, 0x0000000f, 2,      0,      0,      FALSE},
    103     {WINED3DFMT_R10G10B10A2_UNORM,  0xc0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4,      0,      0,      FALSE},
    104     {WINED3DFMT_R10G10B10A2_UINT,   0xc0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4,      0,      0,      FALSE},
    105     {WINED3DFMT_R10G10B10A2_SNORM,  0xc0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4,      0,      0,      FALSE},
    106     {WINED3DFMT_R8G8B8A8_UNORM,     0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4,      0,      0,      FALSE},
    107     {WINED3DFMT_R8G8B8A8_UINT,      0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4,      0,      0,      FALSE},
    108     {WINED3DFMT_X8B8G8R8,           0x0,        0x000000ff, 0x0000ff00, 0x00ff0000, 4,      0,      0,      FALSE},
    109     {WINED3DFMT_R16G16_UNORM,       0x0,        0x0000ffff, 0xffff0000, 0x0,        4,      0,      0,      FALSE},
    110     {WINED3DFMT_A2R10G10B10,        0xc0000000, 0x3ff00000, 0x000ffc00, 0x000003ff, 4,      0,      0,      FALSE},
    111     {WINED3DFMT_R16G16B16A16_UNORM, 0x1,        0x0000ffff, 0xffff0000, 0x0,        8,      0,      0,      FALSE},
     93    {WINED3DFMT_B8G8R8_UNORM,           0x0,        0x00ff0000, 0x0000ff00, 0x000000ff, 3,      0,      0,      FALSE},
     94    {WINED3DFMT_B8G8R8A8_UNORM,         0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff, 4,      0,      0,      FALSE},
     95    {WINED3DFMT_B8G8R8X8_UNORM,         0x0,        0x00ff0000, 0x0000ff00, 0x000000ff, 4,      0,      0,      FALSE},
     96    {WINED3DFMT_B5G6R5_UNORM,           0x0,        0x0000f800, 0x000007e0, 0x0000001f, 2,      0,      0,      FALSE},
     97    {WINED3DFMT_B5G5R5X1_UNORM,         0x0,        0x00007c00, 0x000003e0, 0x0000001f, 2,      0,      0,      FALSE},
     98    {WINED3DFMT_B5G5R5A1_UNORM,         0x00008000, 0x00007c00, 0x000003e0, 0x0000001f, 2,      0,      0,      FALSE},
     99    {WINED3DFMT_B4G4R4A4_UNORM,         0x0000f000, 0x00000f00, 0x000000f0, 0x0000000f, 2,      0,      0,      FALSE},
     100    {WINED3DFMT_B2G3R3_UNORM,           0x0,        0x000000e0, 0x0000001c, 0x00000003, 1,      0,      0,      FALSE},
     101    {WINED3DFMT_A8_UNORM,               0x000000ff, 0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
     102    {WINED3DFMT_B2G3R3A8_UNORM,         0x0000ff00, 0x000000e0, 0x0000001c, 0x00000003, 2,      0,      0,      FALSE},
     103    {WINED3DFMT_B4G4R4X4_UNORM,         0x0,        0x00000f00, 0x000000f0, 0x0000000f, 2,      0,      0,      FALSE},
     104    {WINED3DFMT_R10G10B10A2_UNORM,      0xc0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4,      0,      0,      FALSE},
     105    {WINED3DFMT_R10G10B10A2_UINT,       0xc0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4,      0,      0,      FALSE},
     106    {WINED3DFMT_R10G10B10A2_SNORM,      0xc0000000, 0x000003ff, 0x000ffc00, 0x3ff00000, 4,      0,      0,      FALSE},
     107    {WINED3DFMT_R8G8B8A8_UNORM,         0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4,      0,      0,      FALSE},
     108    {WINED3DFMT_R8G8B8A8_UINT,          0xff000000, 0x000000ff, 0x0000ff00, 0x00ff0000, 4,      0,      0,      FALSE},
     109    {WINED3DFMT_R8G8B8X8_UNORM,         0x0,        0x000000ff, 0x0000ff00, 0x00ff0000, 4,      0,      0,      FALSE},
     110    {WINED3DFMT_R16G16_UNORM,           0x0,        0x0000ffff, 0xffff0000, 0x0,        4,      0,      0,      FALSE},
     111    {WINED3DFMT_B10G10R10A2_UNORM,      0xc0000000, 0x3ff00000, 0x000ffc00, 0x000003ff, 4,      0,      0,      FALSE},
     112    {WINED3DFMT_R16G16B16A16_UNORM,     0x1,        0x0000ffff, 0xffff0000, 0x0,        8,      0,      0,      FALSE},
    112113    /* Luminance */
    113     {WINED3DFMT_L8,                 0x0,        0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
    114     {WINED3DFMT_A8L8,               0x0000ff00, 0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
    115     {WINED3DFMT_A4L4,               0x000000f0, 0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
     114    {WINED3DFMT_L8_UNORM,               0x0,        0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
     115    {WINED3DFMT_L8A8_UNORM,             0x0000ff00, 0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
     116    {WINED3DFMT_L4A4_UNORM,             0x000000f0, 0x0,        0x0,        0x0,        1,      0,      0,      FALSE},
     117    {WINED3DFMT_L16_UNORM,              0x0,        0x0,        0x0,        0x0,        2,      16,     0,      FALSE},
    116118    /* Bump mapping stuff */
    117     {WINED3DFMT_R8G8_SNORM,         0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
    118     {WINED3DFMT_L6V5U5,             0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
    119     {WINED3DFMT_X8L8V8U8,           0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    120     {WINED3DFMT_R8G8B8A8_SNORM,     0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    121     {WINED3DFMT_R16G16_SNORM,       0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    122     {WINED3DFMT_W11V11U10,          0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    123     {WINED3DFMT_A2W10V10U10,        0xb0000000, 0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     119    {WINED3DFMT_R8G8_SNORM,             0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
     120    {WINED3DFMT_R5G5_SNORM_L6_UNORM,    0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
     121    {WINED3DFMT_R8G8_SNORM_L8X8_UNORM,  0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     122    {WINED3DFMT_R8G8B8A8_SNORM,         0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     123    {WINED3DFMT_R16G16_SNORM,           0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     124    {WINED3DFMT_R10G11B11_SNORM,        0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     125    {WINED3DFMT_R10G10B10_SNORM_A2_UNORM,0xb0000000,0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    124126    /* Depth stencil formats */
    125     {WINED3DFMT_D16_LOCKABLE,       0x0,        0x0,        0x0,        0x0,        2,      16,     0,      FALSE},
    126     {WINED3DFMT_D32,                0x0,        0x0,        0x0,        0x0,        4,      32,     0,      FALSE},
    127     {WINED3DFMT_D15S1,              0x0,        0x0,        0x0,        0x0,        2,      15,     1,      FALSE},
    128     {WINED3DFMT_D24S8,              0x0,        0x0,        0x0,        0x0,        4,      24,     8,      FALSE},
    129     {WINED3DFMT_D24X8,              0x0,        0x0,        0x0,        0x0,        4,      24,     0,      FALSE},
    130     {WINED3DFMT_D24X4S4,            0x0,        0x0,        0x0,        0x0,        4,      24,     4,      FALSE},
    131     {WINED3DFMT_D16_UNORM,          0x0,        0x0,        0x0,        0x0,        2,      16,     0,      FALSE},
    132     {WINED3DFMT_L16,                0x0,        0x0,        0x0,        0x0,        2,      16,     0,      FALSE},
    133     {WINED3DFMT_D32F_LOCKABLE,      0x0,        0x0,        0x0,        0x0,        4,      32,     0,      FALSE},
    134     {WINED3DFMT_D24FS8,             0x0,        0x0,        0x0,        0x0,        4,      24,     8,      FALSE},
    135     /* Is this a vertex buffer? */
    136     {WINED3DFMT_VERTEXDATA,         0x0,        0x0,        0x0,        0x0,        0,      0,      0,      FALSE},
    137     {WINED3DFMT_R16_UINT,           0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
    138     {WINED3DFMT_R32_UINT,           0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
    139     {WINED3DFMT_R16G16B16A16_SNORM, 0x0,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
     127    {WINED3DFMT_D16_LOCKABLE,           0x0,        0x0,        0x0,        0x0,        2,      16,     0,      FALSE},
     128    {WINED3DFMT_D32_UNORM,              0x0,        0x0,        0x0,        0x0,        4,      32,     0,      FALSE},
     129    {WINED3DFMT_S1_UINT_D15_UNORM,      0x0,        0x0,        0x0,        0x0,        2,      15,     1,      FALSE},
     130    {WINED3DFMT_S8_UINT_D24_UNORM,      0x0,        0x0,        0x0,        0x0,        4,      24,     8,      FALSE},
     131    {WINED3DFMT_X8D24_UNORM,            0x0,        0x0,        0x0,        0x0,        4,      24,     0,      FALSE},
     132    {WINED3DFMT_S4X4_UINT_D24_UNORM,    0x0,        0x0,        0x0,        0x0,        4,      24,     4,      FALSE},
     133    {WINED3DFMT_D16_UNORM,              0x0,        0x0,        0x0,        0x0,        2,      16,     0,      FALSE},
     134    {WINED3DFMT_D32_FLOAT,              0x0,        0x0,        0x0,        0x0,        4,      32,     0,      FALSE},
     135    {WINED3DFMT_S8_UINT_D24_FLOAT,      0x0,        0x0,        0x0,        0x0,        4,      24,     8,      FALSE},
     136    {WINED3DFMT_VERTEXDATA,             0x0,        0x0,        0x0,        0x0,        0,      0,      0,      FALSE},
     137    {WINED3DFMT_R16_UINT,               0x0,        0x0,        0x0,        0x0,        2,      0,      0,      FALSE},
     138    {WINED3DFMT_R32_UINT,               0x0,        0x0,        0x0,        0x0,        4,      0,      0,      FALSE},
     139    {WINED3DFMT_R16G16B16A16_SNORM,     0x0,        0x0,        0x0,        0x0,        8,      0,      0,      FALSE},
    140140    /* Vendor-specific formats */
    141     {WINED3DFMT_ATI2N,              0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
    142     {WINED3DFMT_NVHU,               0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
    143     {WINED3DFMT_NVHS,               0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
     141    {WINED3DFMT_ATI2N,                  0x0,        0x0,        0x0,        0x0,        1,      0,      0,      TRUE },
     142    {WINED3DFMT_NVHU,                   0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
     143    {WINED3DFMT_NVHS,                   0x0,        0x0,        0x0,        0x0,        2,      0,      0,      TRUE },
    144144};
    145145
     
    179179    {WINED3DFMT_R32G32B32_FLOAT,    WINED3D_FFP_EMIT_FLOAT3,    3, GL_FLOAT,          3, GL_FALSE, sizeof(float)},
    180180    {WINED3DFMT_R32G32B32A32_FLOAT, WINED3D_FFP_EMIT_FLOAT4,    4, GL_FLOAT,          4, GL_FALSE, sizeof(float)},
    181     {WINED3DFMT_A8R8G8B8,           WINED3D_FFP_EMIT_D3DCOLOR,  4, GL_UNSIGNED_BYTE,  4, GL_TRUE,  sizeof(BYTE)},
     181    {WINED3DFMT_B8G8R8A8_UNORM,     WINED3D_FFP_EMIT_D3DCOLOR,  4, GL_UNSIGNED_BYTE,  4, GL_TRUE,  sizeof(BYTE)},
    182182    {WINED3DFMT_R8G8B8A8_UINT,      WINED3D_FFP_EMIT_UBYTE4,    4, GL_UNSIGNED_BYTE,  4, GL_FALSE, sizeof(BYTE)},
    183183    {WINED3DFMT_R16G16_SINT,        WINED3D_FFP_EMIT_SHORT2,    2, GL_SHORT,          2, GL_FALSE, sizeof(short int)},
     
    208208 */
    209209static const GlPixelFormatDescTemplate gl_formats_template[] = {
    210     /* WINED3DFORMAT                internal                          srgbInternal                            rtInternal
    211             format                  type
     210    /* WINED3DFORMAT                    internal                          srgbInternal                       rtInternal
     211            format                      type
    212212            flags
    213213            extension */
     
    219219     * endian machine
    220220     */
    221     {WINED3DFMT_UYVY,               GL_LUMINANCE_ALPHA,               GL_LUMINANCE_ALPHA,                     0,
    222             GL_LUMINANCE_ALPHA,     GL_UNSIGNED_BYTE,
     221    {WINED3DFMT_UYVY,                   GL_LUMINANCE_ALPHA,               GL_LUMINANCE_ALPHA,                     0,
     222            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
    223223            WINED3DFMT_FLAG_FILTERING,
    224224            WINED3D_GL_EXT_NONE},
    225     {WINED3DFMT_UYVY,               GL_RGB,                           GL_RGB,                                 0,
    226             GL_YCBCR_422_APPLE,     UNSIGNED_SHORT_8_8_APPLE,
     225    {WINED3DFMT_UYVY,                   GL_RGB,                           GL_RGB,                                 0,
     226            GL_YCBCR_422_APPLE,         UNSIGNED_SHORT_8_8_APPLE,
    227227            WINED3DFMT_FLAG_FILTERING,
    228228            APPLE_YCBCR_422},
    229     {WINED3DFMT_YUY2,               GL_LUMINANCE_ALPHA,               GL_LUMINANCE_ALPHA,                     0,
    230             GL_LUMINANCE_ALPHA,     GL_UNSIGNED_BYTE,
     229    {WINED3DFMT_YUY2,                   GL_LUMINANCE_ALPHA,               GL_LUMINANCE_ALPHA,                     0,
     230            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
    231231            WINED3DFMT_FLAG_FILTERING,
    232232            WINED3D_GL_EXT_NONE},
    233     {WINED3DFMT_YUY2,               GL_RGB,                           GL_RGB,                                 0,
    234             GL_YCBCR_422_APPLE, UNSIGNED_SHORT_8_8_REV_APPLE,
     233    {WINED3DFMT_YUY2,                   GL_RGB,                           GL_RGB,                                 0,
     234            GL_YCBCR_422_APPLE,         UNSIGNED_SHORT_8_8_REV_APPLE,
    235235            WINED3DFMT_FLAG_FILTERING,
    236236            APPLE_YCBCR_422},
    237     {WINED3DFMT_YV12,               GL_ALPHA,                         GL_ALPHA,                               0,
    238             GL_ALPHA,               GL_UNSIGNED_BYTE,
     237    {WINED3DFMT_YV12,                   GL_ALPHA,                         GL_ALPHA,                               0,
     238            GL_ALPHA,                   GL_UNSIGNED_BYTE,
    239239            WINED3DFMT_FLAG_FILTERING,
    240240            WINED3D_GL_EXT_NONE},
    241     {WINED3DFMT_DXT1,               GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0,
    242             GL_RGBA,                GL_UNSIGNED_BYTE,
     241    {WINED3DFMT_DXT1,                   GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0,
     242            GL_RGBA,                    GL_UNSIGNED_BYTE,
    243243            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    244244            EXT_TEXTURE_COMPRESSION_S3TC},
    245     {WINED3DFMT_DXT2,               GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
    246             GL_RGBA,                GL_UNSIGNED_BYTE,
     245    {WINED3DFMT_DXT2,                   GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
     246            GL_RGBA,                    GL_UNSIGNED_BYTE,
    247247            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    248248            EXT_TEXTURE_COMPRESSION_S3TC},
    249     {WINED3DFMT_DXT3,               GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
    250             GL_RGBA,                GL_UNSIGNED_BYTE,
     249    {WINED3DFMT_DXT3,                   GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
     250            GL_RGBA,                    GL_UNSIGNED_BYTE,
    251251            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    252252            EXT_TEXTURE_COMPRESSION_S3TC},
    253     {WINED3DFMT_DXT4,               GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
    254             GL_RGBA,                GL_UNSIGNED_BYTE,
     253    {WINED3DFMT_DXT4,                   GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
     254            GL_RGBA,                    GL_UNSIGNED_BYTE,
    255255            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    256256            EXT_TEXTURE_COMPRESSION_S3TC},
    257     {WINED3DFMT_DXT5,               GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
    258             GL_RGBA,                GL_UNSIGNED_BYTE,
     257    {WINED3DFMT_DXT5,                   GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
     258            GL_RGBA,                    GL_UNSIGNED_BYTE,
    259259            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    260260            EXT_TEXTURE_COMPRESSION_S3TC},
    261261    /* IEEE formats */
    262     {WINED3DFMT_R32_FLOAT,          GL_RGB32F_ARB,                    GL_RGB32F_ARB,                          0,
    263             GL_RED,                 GL_FLOAT,
     262    {WINED3DFMT_R32_FLOAT,              GL_RGB32F_ARB,                    GL_RGB32F_ARB,                          0,
     263            GL_RED,                     GL_FLOAT,
    264264            WINED3DFMT_FLAG_RENDERTARGET,
    265265            ARB_TEXTURE_FLOAT},
    266     {WINED3DFMT_R32_FLOAT,          GL_R32F,                          GL_R32F,                                0,
    267             GL_RED,                 GL_FLOAT,
     266    {WINED3DFMT_R32_FLOAT,              GL_R32F,                          GL_R32F,                                0,
     267            GL_RED,                     GL_FLOAT,
    268268            WINED3DFMT_FLAG_RENDERTARGET,
    269269            ARB_TEXTURE_RG},
    270     {WINED3DFMT_R32G32_FLOAT,       GL_RGB32F_ARB,                    GL_RGB32F_ARB,                          0,
    271             GL_RGB,                 GL_FLOAT,
     270    {WINED3DFMT_R32G32_FLOAT,           GL_RGB32F_ARB,                    GL_RGB32F_ARB,                          0,
     271            GL_RGB,                     GL_FLOAT,
    272272            WINED3DFMT_FLAG_RENDERTARGET,
    273273            ARB_TEXTURE_FLOAT},
    274     {WINED3DFMT_R32G32_FLOAT,       GL_RG32F,                         GL_RG32F,                               0,
    275             GL_RG,                  GL_FLOAT,
     274    {WINED3DFMT_R32G32_FLOAT,           GL_RG32F,                         GL_RG32F,                               0,
     275            GL_RG,                      GL_FLOAT,
    276276            WINED3DFMT_FLAG_RENDERTARGET,
    277277            ARB_TEXTURE_RG},
    278     {WINED3DFMT_R32G32B32A32_FLOAT, GL_RGBA32F_ARB,                   GL_RGBA32F_ARB,                         0,
    279             GL_RGBA,                GL_FLOAT,
     278    {WINED3DFMT_R32G32B32A32_FLOAT,     GL_RGBA32F_ARB,                   GL_RGBA32F_ARB,                         0,
     279            GL_RGBA,                    GL_FLOAT,
    280280            WINED3DFMT_FLAG_RENDERTARGET,
    281281            ARB_TEXTURE_FLOAT},
    282282    /* Float */
    283     {WINED3DFMT_R16_FLOAT,          GL_RGB16F_ARB,                    GL_RGB16F_ARB,                          0,
    284             GL_RED,                 GL_HALF_FLOAT_ARB,
     283    {WINED3DFMT_R16_FLOAT,              GL_RGB16F_ARB,                    GL_RGB16F_ARB,                          0,
     284            GL_RED,                     GL_HALF_FLOAT_ARB,
    285285            WINED3DFMT_FLAG_RENDERTARGET,
    286286            ARB_TEXTURE_FLOAT},
    287     {WINED3DFMT_R16_FLOAT,          GL_R16F,                          GL_R16F,                                0,
    288             GL_RED,                 GL_HALF_FLOAT_ARB,
     287    {WINED3DFMT_R16_FLOAT,              GL_R16F,                          GL_R16F,                                0,
     288            GL_RED,                     GL_HALF_FLOAT_ARB,
    289289            WINED3DFMT_FLAG_RENDERTARGET,
    290290            ARB_TEXTURE_RG},
    291     {WINED3DFMT_R16G16_FLOAT,       GL_RGB16F_ARB,                    GL_RGB16F_ARB,                          0,
    292             GL_RGB,                 GL_HALF_FLOAT_ARB,
     291    {WINED3DFMT_R16G16_FLOAT,           GL_RGB16F_ARB,                    GL_RGB16F_ARB,                          0,
     292            GL_RGB,                     GL_HALF_FLOAT_ARB,
    293293            WINED3DFMT_FLAG_RENDERTARGET,
    294294            ARB_TEXTURE_FLOAT},
    295     {WINED3DFMT_R16G16_FLOAT,       GL_RG16F,                         GL_RG16F,                               0,
    296             GL_RG,                  GL_HALF_FLOAT_ARB,
     295    {WINED3DFMT_R16G16_FLOAT,           GL_RG16F,                         GL_RG16F,                               0,
     296            GL_RG,                      GL_HALF_FLOAT_ARB,
    297297            WINED3DFMT_FLAG_RENDERTARGET,
    298298            ARB_TEXTURE_RG},
    299     {WINED3DFMT_R16G16B16A16_FLOAT, GL_RGBA16F_ARB,                   GL_RGBA16F_ARB,                         0,
    300             GL_RGBA,                GL_HALF_FLOAT_ARB,
     299    {WINED3DFMT_R16G16B16A16_FLOAT,     GL_RGBA16F_ARB,                   GL_RGBA16F_ARB,                         0,
     300            GL_RGBA,                    GL_HALF_FLOAT_ARB,
    301301            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_RENDERTARGET,
    302302            ARB_TEXTURE_FLOAT},
    303303    /* Palettized formats */
    304     {WINED3DFMT_P8,                 GL_RGBA,                          GL_RGBA,                                0,
    305             GL_RGBA,                GL_UNSIGNED_BYTE,
    306             0,
     304    {WINED3DFMT_P8_UINT,                GL_RGBA,                          GL_RGBA,                                0,
     305            GL_RGBA,                    GL_UNSIGNED_BYTE,
     306            WINED3DFMT_FLAG_GETDC,
    307307            ARB_FRAGMENT_PROGRAM},
    308     {WINED3DFMT_P8,                 GL_COLOR_INDEX8_EXT,              GL_COLOR_INDEX8_EXT,                    0,
    309             GL_COLOR_INDEX,         GL_UNSIGNED_BYTE,
    310             0,
     308    {WINED3DFMT_P8_UINT,                GL_COLOR_INDEX8_EXT,              GL_COLOR_INDEX8_EXT,                    0,
     309            GL_COLOR_INDEX,             GL_UNSIGNED_BYTE,
     310            WINED3DFMT_FLAG_GETDC,
    311311            EXT_PALETTED_TEXTURE},
    312312    /* Standard ARGB formats */
    313     {WINED3DFMT_R8G8B8,             GL_RGB8,                          GL_RGB8,                                0,
    314             GL_BGR,                 GL_UNSIGNED_BYTE,
    315             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
     313    {WINED3DFMT_B8G8R8_UNORM,           GL_RGB8,                          GL_RGB8,                                0,
     314            GL_BGR,                     GL_UNSIGNED_BYTE,
     315            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET |
     316            WINED3DFMT_FLAG_GETDC,
    316317            WINED3D_GL_EXT_NONE},
    317     {WINED3DFMT_A8R8G8B8,           GL_RGBA8,                         GL_SRGB8_ALPHA8_EXT,                    0,
    318             GL_BGRA,                GL_UNSIGNED_INT_8_8_8_8_REV,
    319             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
     318    {WINED3DFMT_B8G8R8A8_UNORM,         GL_RGBA8,                         GL_SRGB8_ALPHA8_EXT,                    0,
     319            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
     320            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET |
     321            WINED3DFMT_FLAG_GETDC,
    320322            WINED3D_GL_EXT_NONE},
    321     {WINED3DFMT_X8R8G8B8,           GL_RGB8,                          GL_SRGB8_EXT,                           0,
    322             GL_BGRA,                GL_UNSIGNED_INT_8_8_8_8_REV,
    323             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
     323    {WINED3DFMT_B8G8R8X8_UNORM,         GL_RGB8,                          GL_SRGB8_EXT,                           0,
     324            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
     325            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET |
     326            WINED3DFMT_FLAG_GETDC,
    324327            WINED3D_GL_EXT_NONE},
    325     {WINED3DFMT_R5G6B5,             GL_RGB5,                          GL_RGB5,                                GL_RGB8,
    326             GL_RGB,                 GL_UNSIGNED_SHORT_5_6_5,
    327             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
     328    {WINED3DFMT_B5G6R5_UNORM,           GL_RGB5,                          GL_RGB5,                          GL_RGB8,
     329            GL_RGB,                     GL_UNSIGNED_SHORT_5_6_5,
     330            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET |
     331            WINED3DFMT_FLAG_GETDC,
    328332            WINED3D_GL_EXT_NONE},
    329     {WINED3DFMT_X1R5G5B5,           GL_RGB5,                          GL_RGB5_A1,                             0,
    330             GL_BGRA,                GL_UNSIGNED_SHORT_1_5_5_5_REV,
     333    {WINED3DFMT_B5G5R5X1_UNORM,         GL_RGB5,                          GL_RGB5_A1,                             0,
     334            GL_BGRA,                    GL_UNSIGNED_SHORT_1_5_5_5_REV,
     335            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING |
     336            WINED3DFMT_FLAG_GETDC,
     337            WINED3D_GL_EXT_NONE},
     338    {WINED3DFMT_B5G5R5A1_UNORM,         GL_RGB5_A1,                       GL_RGB5_A1,                             0,
     339            GL_BGRA,                    GL_UNSIGNED_SHORT_1_5_5_5_REV,
     340            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING |
     341            WINED3DFMT_FLAG_GETDC,
     342            WINED3D_GL_EXT_NONE},
     343    {WINED3DFMT_B4G4R4A4_UNORM,         GL_RGBA4,                         GL_SRGB8_ALPHA8_EXT,                    0,
     344            GL_BGRA,                    GL_UNSIGNED_SHORT_4_4_4_4_REV,
     345            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING |
     346            WINED3DFMT_FLAG_GETDC,
     347            WINED3D_GL_EXT_NONE},
     348    {WINED3DFMT_B2G3R3_UNORM,           GL_R3_G3_B2,                      GL_R3_G3_B2,                            0,
     349            GL_RGB,                     GL_UNSIGNED_BYTE_3_3_2,
     350            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING,
     351            WINED3D_GL_EXT_NONE},
     352    {WINED3DFMT_A8_UNORM,               GL_ALPHA8,                        GL_ALPHA8,                              0,
     353            GL_ALPHA,                   GL_UNSIGNED_BYTE,
     354            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING,
     355            WINED3D_GL_EXT_NONE},
     356    {WINED3DFMT_B4G4R4X4_UNORM,         GL_RGB4,                          GL_RGB4,                                0,
     357            GL_BGRA,                    GL_UNSIGNED_SHORT_4_4_4_4_REV,
     358            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_GETDC,
     359            WINED3D_GL_EXT_NONE},
     360    {WINED3DFMT_R10G10B10A2_UNORM,      GL_RGB10_A2,                      GL_RGB10_A2,                            0,
     361            GL_RGBA,                    GL_UNSIGNED_INT_2_10_10_10_REV,
    331362            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    332363            WINED3D_GL_EXT_NONE},
    333     {WINED3DFMT_A1R5G5B5,           GL_RGB5_A1,                       GL_RGB5_A1,                             0,
    334             GL_BGRA,                GL_UNSIGNED_SHORT_1_5_5_5_REV,
     364    {WINED3DFMT_R8G8B8A8_UNORM,         GL_RGBA8,                         GL_RGBA8,                               0,
     365            GL_RGBA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
     366            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_GETDC,
     367            WINED3D_GL_EXT_NONE},
     368    {WINED3DFMT_R8G8B8X8_UNORM,         GL_RGB8,                          GL_RGB8,                                0,
     369            GL_RGBA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
     370            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_GETDC,
     371            WINED3D_GL_EXT_NONE},
     372    {WINED3DFMT_R16G16_UNORM,           GL_RGB16_EXT,                     GL_RGB16_EXT,               GL_RGBA16_EXT,
     373            GL_RGB,                     GL_UNSIGNED_SHORT,
    335374            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    336375            WINED3D_GL_EXT_NONE},
    337     {WINED3DFMT_A4R4G4B4,           GL_RGBA4,                         GL_SRGB8_ALPHA8_EXT,                    0,
    338             GL_BGRA,                GL_UNSIGNED_SHORT_4_4_4_4_REV,
     376    {WINED3DFMT_B10G10R10A2_UNORM,      GL_RGB10_A2,                      GL_RGB10_A2,                            0,
     377            GL_BGRA,                    GL_UNSIGNED_INT_2_10_10_10_REV,
    339378            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    340379            WINED3D_GL_EXT_NONE},
    341     {WINED3DFMT_R3G3B2,             GL_R3_G3_B2,                      GL_R3_G3_B2,                            0,
    342             GL_RGB,                 GL_UNSIGNED_BYTE_3_3_2,
    343             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING,
    344             WINED3D_GL_EXT_NONE},
    345     {WINED3DFMT_A8_UNORM,           GL_ALPHA8,                        GL_ALPHA8,                              0,
    346             GL_ALPHA,               GL_UNSIGNED_BYTE,
    347             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING,
    348             WINED3D_GL_EXT_NONE},
    349     {WINED3DFMT_X4R4G4B4,           GL_RGB4,                          GL_RGB4,                                0,
    350             GL_BGRA,                GL_UNSIGNED_SHORT_4_4_4_4_REV,
    351             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    352             WINED3D_GL_EXT_NONE},
    353     {WINED3DFMT_R10G10B10A2_UNORM,  GL_RGB10_A2,                      GL_RGB10_A2,                            0,
    354             GL_RGBA,                GL_UNSIGNED_INT_2_10_10_10_REV,
    355             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    356             WINED3D_GL_EXT_NONE},
    357     {WINED3DFMT_R8G8B8A8_UNORM,     GL_RGBA8,                         GL_RGBA8,                               0,
    358             GL_RGBA,                GL_UNSIGNED_INT_8_8_8_8_REV,
    359             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    360             WINED3D_GL_EXT_NONE},
    361     {WINED3DFMT_X8B8G8R8,           GL_RGB8,                          GL_RGB8,                                0,
    362             GL_RGBA,                GL_UNSIGNED_INT_8_8_8_8_REV,
    363             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    364             WINED3D_GL_EXT_NONE},
    365     {WINED3DFMT_R16G16_UNORM,       GL_RGB16_EXT,                     GL_RGB16_EXT,                           GL_RGBA16_EXT,
    366             GL_RGB,                 GL_UNSIGNED_SHORT,
    367             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    368             WINED3D_GL_EXT_NONE},
    369     {WINED3DFMT_A2R10G10B10,        GL_RGB10_A2,                      GL_RGB10_A2,                            0,
    370             GL_BGRA,                GL_UNSIGNED_INT_2_10_10_10_REV,
    371             WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    372             WINED3D_GL_EXT_NONE},
    373     {WINED3DFMT_R16G16B16A16_UNORM, GL_RGBA16_EXT,                    GL_RGBA16_EXT,                          0,
    374             GL_RGBA,                GL_UNSIGNED_SHORT,
     380    {WINED3DFMT_R16G16B16A16_UNORM,     GL_RGBA16_EXT,                    GL_RGBA16_EXT,                          0,
     381            GL_RGBA,                    GL_UNSIGNED_SHORT,
    375382            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_RENDERTARGET,
    376383            WINED3D_GL_EXT_NONE},
    377384    /* Luminance */
    378     {WINED3DFMT_L8               GL_LUMINANCE8,                    GL_SLUMINANCE8_EXT,                     0,
    379             GL_LUMINANCE,           GL_UNSIGNED_BYTE,
     385    {WINED3DFMT_L8_UNORM,               GL_LUMINANCE8,                    GL_SLUMINANCE8_EXT,                     0,
     386            GL_LUMINANCE,               GL_UNSIGNED_BYTE,
    380387            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    381388            WINED3D_GL_EXT_NONE},
    382     {WINED3DFMT_A8L8,               GL_LUMINANCE8_ALPHA8,             GL_SLUMINANCE8_ALPHA8_EXT,              0,
    383             GL_LUMINANCE_ALPHA,     GL_UNSIGNED_BYTE,
     389    {WINED3DFMT_L8A8_UNORM,             GL_LUMINANCE8_ALPHA8,             GL_SLUMINANCE8_ALPHA8_EXT,              0,
     390            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
    384391            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    385392            WINED3D_GL_EXT_NONE},
    386     {WINED3DFMT_A4L4,               GL_LUMINANCE4_ALPHA4,             GL_LUMINANCE4_ALPHA4,                   0,
    387             GL_LUMINANCE_ALPHA,     GL_UNSIGNED_BYTE,
     393    {WINED3DFMT_L4A4_UNORM,             GL_LUMINANCE4_ALPHA4,             GL_LUMINANCE4_ALPHA4,                   0,
     394            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
    388395            0,
    389396            WINED3D_GL_EXT_NONE},
    390397    /* Bump mapping stuff */
    391     {WINED3DFMT_R8G8_SNORM,         GL_RGB8,                          GL_RGB8,                                0,
    392             GL_BGR,                 GL_UNSIGNED_BYTE,
     398    {WINED3DFMT_R8G8_SNORM,             GL_RGB8,                          GL_RGB8,                                0,
     399            GL_BGR,                     GL_UNSIGNED_BYTE,
    393400            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    394401            WINED3D_GL_EXT_NONE},
    395     {WINED3DFMT_R8G8_SNORM,         GL_DSDT8_NV,                      GL_DSDT8_NV,                            0,
    396             GL_DSDT_NV,             GL_BYTE,
     402    {WINED3DFMT_R8G8_SNORM,             GL_DSDT8_NV,                      GL_DSDT8_NV,                            0,
     403            GL_DSDT_NV,                 GL_BYTE,
    397404            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    398405            NV_TEXTURE_SHADER},
    399     {WINED3DFMT_L6V5U5,             GL_RGB5,                          GL_RGB5,                                0,
    400             GL_RGB,                 GL_UNSIGNED_SHORT_5_6_5,
     406    {WINED3DFMT_R5G5_SNORM_L6_UNORM,    GL_RGB5,                          GL_RGB5,                                0,
     407            GL_RGB,                     GL_UNSIGNED_SHORT_5_6_5,
    401408            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    402409            WINED3D_GL_EXT_NONE},
    403     {WINED3DFMT_L6V5U5,             GL_DSDT8_MAG8_NV,                 GL_DSDT8_MAG8_NV,                       0,
    404             GL_DSDT_MAG_NV,         GL_BYTE,
     410    {WINED3DFMT_R5G5_SNORM_L6_UNORM,    GL_DSDT8_MAG8_NV,                 GL_DSDT8_MAG8_NV,                       0,
     411            GL_DSDT_MAG_NV,             GL_BYTE,
    405412            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    406413            NV_TEXTURE_SHADER},
    407     {WINED3DFMT_X8L8V8U8,           GL_RGB8,                          GL_RGB8,                                0,
    408             GL_BGRA,                GL_UNSIGNED_INT_8_8_8_8_REV,
     414    {WINED3DFMT_R8G8_SNORM_L8X8_UNORM,  GL_RGB8,                          GL_RGB8,                                0,
     415            GL_BGRA,                    GL_UNSIGNED_INT_8_8_8_8_REV,
    409416            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    410417            WINED3D_GL_EXT_NONE},
    411     {WINED3DFMT_X8L8V8U8,           GL_DSDT8_MAG8_INTENSITY8_NV,      GL_DSDT8_MAG8_INTENSITY8_NV,            0,
    412             GL_DSDT_MAG_VIB_NV,     GL_UNSIGNED_INT_8_8_S8_S8_REV_NV,
     418    {WINED3DFMT_R8G8_SNORM_L8X8_UNORM,  GL_DSDT8_MAG8_INTENSITY8_NV,      GL_DSDT8_MAG8_INTENSITY8_NV,            0,
     419            GL_DSDT_MAG_VIB_NV,         GL_UNSIGNED_INT_8_8_S8_S8_REV_NV,
    413420            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    414421            NV_TEXTURE_SHADER},
    415     {WINED3DFMT_R8G8B8A8_SNORM,     GL_RGBA8,                         GL_RGBA8,                               0,
    416             GL_BGRA,                GL_UNSIGNED_BYTE,
     422    {WINED3DFMT_R8G8B8A8_SNORM,         GL_RGBA8,                         GL_RGBA8,                               0,
     423            GL_BGRA,                    GL_UNSIGNED_BYTE,
    417424            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    418425            WINED3D_GL_EXT_NONE},
    419     {WINED3DFMT_R8G8B8A8_SNORM,     GL_SIGNED_RGBA8_NV,               GL_SIGNED_RGBA8_NV,                     0,
    420             GL_RGBA,                GL_BYTE,
     426    {WINED3DFMT_R8G8B8A8_SNORM,         GL_SIGNED_RGBA8_NV,               GL_SIGNED_RGBA8_NV,                     0,
     427            GL_RGBA,                    GL_BYTE,
    421428            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    422429            NV_TEXTURE_SHADER},
    423     {WINED3DFMT_R16G16_SNORM,       GL_RGB16_EXT,                     GL_RGB16_EXT,                           0,
    424             GL_BGR,                 GL_UNSIGNED_SHORT,
     430    {WINED3DFMT_R16G16_SNORM,           GL_RGB16_EXT,                     GL_RGB16_EXT,                           0,
     431            GL_BGR,                     GL_UNSIGNED_SHORT,
    425432            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    426433            WINED3D_GL_EXT_NONE},
    427     {WINED3DFMT_R16G16_SNORM,       GL_SIGNED_HILO16_NV,              GL_SIGNED_HILO16_NV,                    0,
    428             GL_HILO_NV,             GL_SHORT,
     434    {WINED3DFMT_R16G16_SNORM,           GL_SIGNED_HILO16_NV,              GL_SIGNED_HILO16_NV,                    0,
     435            GL_HILO_NV,                 GL_SHORT,
    429436            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    430437            NV_TEXTURE_SHADER},
    431438    /* Depth stencil formats */
    432     {WINED3DFMT_D16_LOCKABLE,       GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
    433             GL_DEPTH_COMPONENT,     GL_UNSIGNED_SHORT,
     439    {WINED3DFMT_D16_LOCKABLE,           GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
     440            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,
    434441            WINED3DFMT_FLAG_DEPTH,
    435442            ARB_DEPTH_TEXTURE},
    436     {WINED3DFMT_D32              GL_DEPTH_COMPONENT32_ARB,         GL_DEPTH_COMPONENT32_ARB,               0,
    437             GL_DEPTH_COMPONENT,     GL_UNSIGNED_INT,
     443    {WINED3DFMT_D32_UNORM,              GL_DEPTH_COMPONENT32_ARB,         GL_DEPTH_COMPONENT32_ARB,               0,
     444            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
    438445            WINED3DFMT_FLAG_DEPTH,
    439446            ARB_DEPTH_TEXTURE},
    440     {WINED3DFMT_D15S1,              GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
    441             GL_DEPTH_COMPONENT,     GL_UNSIGNED_SHORT,
     447    {WINED3DFMT_S1_UINT_D15_UNORM,      GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
     448            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,
    442449            WINED3DFMT_FLAG_DEPTH,
    443450            ARB_DEPTH_TEXTURE},
    444     {WINED3DFMT_D15S1,              GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
    445             GL_DEPTH_STENCIL_EXT,   GL_UNSIGNED_INT_24_8_EXT,
     451    {WINED3DFMT_S1_UINT_D15_UNORM,      GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
     452            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,
    446453            WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
    447454            EXT_PACKED_DEPTH_STENCIL},
    448     {WINED3DFMT_D24S8,              GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
    449             GL_DEPTH_COMPONENT,     GL_UNSIGNED_INT,
     455    {WINED3DFMT_S1_UINT_D15_UNORM,      GL_DEPTH24_STENCIL8,              GL_DEPTH24_STENCIL8,                    0,
     456            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,
     457            WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
     458            ARB_FRAMEBUFFER_OBJECT},
     459    {WINED3DFMT_S8_UINT_D24_UNORM,      GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
     460            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
    450461            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH,
    451462            ARB_DEPTH_TEXTURE},
    452     {WINED3DFMT_D24S8,              GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
    453             GL_DEPTH_STENCIL_EXT,   GL_UNSIGNED_INT_24_8_EXT,
     463    {WINED3DFMT_S8_UINT_D24_UNORM,      GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
     464            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,
    454465            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
    455466            EXT_PACKED_DEPTH_STENCIL},
    456     {WINED3DFMT_D24X8,              GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
    457             GL_DEPTH_COMPONENT,     GL_UNSIGNED_INT,
     467    {WINED3DFMT_S8_UINT_D24_UNORM,      GL_DEPTH24_STENCIL8,              GL_DEPTH24_STENCIL8,                    0,
     468            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,
     469            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
     470            ARB_FRAMEBUFFER_OBJECT},
     471    {WINED3DFMT_X8D24_UNORM,            GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
     472            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
    458473            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH,
    459474            ARB_DEPTH_TEXTURE},
    460     {WINED3DFMT_D24X4S4,            GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
    461             GL_DEPTH_COMPONENT,     GL_UNSIGNED_INT,
     475    {WINED3DFMT_S4X4_UINT_D24_UNORM,    GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
     476            GL_DEPTH_COMPONENT,         GL_UNSIGNED_INT,
    462477            WINED3DFMT_FLAG_DEPTH,
    463478            ARB_DEPTH_TEXTURE},
    464     {WINED3DFMT_D24X4S4,            GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
    465             GL_DEPTH_STENCIL_EXT,   GL_UNSIGNED_INT_24_8_EXT,
     479    {WINED3DFMT_S4X4_UINT_D24_UNORM,    GL_DEPTH24_STENCIL8_EXT,          GL_DEPTH24_STENCIL8_EXT,                0,
     480            GL_DEPTH_STENCIL_EXT,       GL_UNSIGNED_INT_24_8_EXT,
    466481            WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
    467482            EXT_PACKED_DEPTH_STENCIL},
    468     {WINED3DFMT_D16_UNORM,          GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
    469             GL_DEPTH_COMPONENT,     GL_UNSIGNED_SHORT,
     483    {WINED3DFMT_S4X4_UINT_D24_UNORM,    GL_DEPTH24_STENCIL8,              GL_DEPTH24_STENCIL8,                    0,
     484            GL_DEPTH_STENCIL,           GL_UNSIGNED_INT_24_8,
     485            WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
     486            ARB_FRAMEBUFFER_OBJECT},
     487    {WINED3DFMT_D16_UNORM,              GL_DEPTH_COMPONENT24_ARB,         GL_DEPTH_COMPONENT24_ARB,               0,
     488            GL_DEPTH_COMPONENT,         GL_UNSIGNED_SHORT,
    470489            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_DEPTH,
    471490            ARB_DEPTH_TEXTURE},
    472     {WINED3DFMT_L16              GL_LUMINANCE16_EXT,               GL_LUMINANCE16_EXT,                     0,
    473             GL_LUMINANCE,           GL_UNSIGNED_SHORT,
     491    {WINED3DFMT_L16_UNORM,              GL_LUMINANCE16_EXT,               GL_LUMINANCE16_EXT,                     0,
     492            GL_LUMINANCE,               GL_UNSIGNED_SHORT,
    474493            WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING,
    475494            WINED3D_GL_EXT_NONE},
    476     {WINED3DFMT_D32F_LOCKABLE,      GL_DEPTH_COMPONENT32F,            GL_DEPTH_COMPONENT32F,                  0,
    477             GL_DEPTH_COMPONENT,     GL_FLOAT,
     495    {WINED3DFMT_D32_FLOAT,              GL_DEPTH_COMPONENT32F,            GL_DEPTH_COMPONENT32F,                  0,
     496            GL_DEPTH_COMPONENT,         GL_FLOAT,
    478497            WINED3DFMT_FLAG_DEPTH,
    479498            ARB_DEPTH_BUFFER_FLOAT},
    480     {WINED3DFMT_D24FS8,             GL_DEPTH32F_STENCIL8,             GL_DEPTH32F_STENCIL8,                   0,
    481             GL_DEPTH_STENCIL_EXT,   GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
     499    {WINED3DFMT_S8_UINT_D24_FLOAT,      GL_DEPTH32F_STENCIL8,             GL_DEPTH32F_STENCIL8,                   0,
     500            GL_DEPTH_STENCIL,           GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
    482501            WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL,
    483502            ARB_DEPTH_BUFFER_FLOAT},
    484503    /* Vendor-specific formats */
    485     {WINED3DFMT_ATI2N,              GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0,
    486             GL_LUMINANCE_ALPHA,     GL_UNSIGNED_BYTE,
     504    {WINED3DFMT_ATI2N,                  GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0,
     505            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
    487506            0,
    488507            ATI_TEXTURE_COMPRESSION_3DC},
    489     {WINED3DFMT_ATI2N,              GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_COMPRESSED_RED_GREEN_RGTC2_EXT,     0,
    490             GL_LUMINANCE_ALPHA,     GL_UNSIGNED_BYTE,
     508    {WINED3DFMT_ATI2N,                  GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_COMPRESSED_RED_GREEN_RGTC2_EXT,     0,
     509            GL_LUMINANCE_ALPHA,         GL_UNSIGNED_BYTE,
    491510            0,
    492511            EXT_TEXTURE_COMPRESSION_RGTC},
     
    590609    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    591610
    592     GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0));
    593 
    594     status = GL_EXTCALL(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
     611    gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
     612
     613    status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
    595614    checkGLcall("Framebuffer format check");
    596615
    597     if (status == GL_FRAMEBUFFER_COMPLETE_EXT)
     616    if (status == GL_FRAMEBUFFER_COMPLETE)
    598617    {
    599618        TRACE("Format %s is supported as FBO color attachment\n", debug_d3dformat(format_desc->format));
     
    624643            while(glGetError());
    625644
    626             GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0));
     645            gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
    627646
    628647            glTexImage2D(GL_TEXTURE_2D, 0, format_desc->rtInternal, 16, 16, 0,
     
    631650            glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    632651
    633             GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tex, 0));
    634 
    635             status = GL_EXTCALL(glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT));
     652            gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, 0);
     653
     654            status = gl_info->fbo_ops.glCheckFramebufferStatus(GL_FRAMEBUFFER);
    636655            checkGLcall("Framebuffer format check");
    637656
    638             if (status == GL_FRAMEBUFFER_COMPLETE_EXT)
     657            if (status == GL_FRAMEBUFFER_COMPLETE)
    639658            {
    640659                TRACE("Format %s rtInternal format is supported as FBO color attachment\n",
     
    650669    }
    651670
    652     if (status == GL_FRAMEBUFFER_COMPLETE_EXT && format_desc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)
     671    if (status == GL_FRAMEBUFFER_COMPLETE && format_desc->Flags & WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING)
    653672    {
    654673        GLuint rb;
    655674
    656         if (GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
     675        if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT)
     676                || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
    657677        {
    658             GL_EXTCALL(glGenRenderbuffersEXT(1, &rb));
    659             GL_EXTCALL(glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb));
    660             GL_EXTCALL(glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH24_STENCIL8_EXT, 16, 16));
    661             GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    662                     GL_RENDERBUFFER_EXT, rb));
    663             GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
    664                     GL_RENDERBUFFER_EXT, rb));
     678            gl_info->fbo_ops.glGenRenderbuffers(1, &rb);
     679            gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, rb);
     680            gl_info->fbo_ops.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 16, 16);
     681            gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rb);
     682            gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb);
    665683            checkGLcall("RB attachment");
    666684        }
     
    668686        glEnable(GL_BLEND);
    669687        glClear(GL_COLOR_BUFFER_BIT);
    670         if (glGetError() == GL_INVALID_FRAMEBUFFER_OPERATION_EXT)
     688        if (glGetError() == GL_INVALID_FRAMEBUFFER_OPERATION)
    671689        {
    672690            while(glGetError());
     
    675693        }
    676694
    677         if (GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
     695        if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT)
     696                || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL))
    678697        {
    679             GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
    680                     GL_RENDERBUFFER_EXT, 0));
    681             GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
    682                     GL_RENDERBUFFER_EXT, 0));
    683             GL_EXTCALL(glDeleteRenderbuffersEXT(1, &rb));
     698            gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
     699            gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0);
     700            gl_info->fbo_ops.glDeleteRenderbuffers(1, &rb);
    684701            checkGLcall("RB cleanup");
    685702        }
     
    701718        ENTER_GL();
    702719
    703         GL_EXTCALL(glGenFramebuffersEXT(1, &fbo));
    704         GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo));
     720        gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
     721        gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
    705722
    706723        LEAVE_GL();
     
    742759        ENTER_GL();
    743760
    744         GL_EXTCALL(glDeleteFramebuffersEXT(1, &fbo));
     761        gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
    745762
    746763        LEAVE_GL();
     
    833850    glEnable(GL_TEXTURE_2D);
    834851
    835     GL_EXTCALL(glGenFramebuffersEXT(1, &fbo));
    836     GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo));
    837     GL_EXTCALL(glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, buffer, 0));
    838     glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
     852    gl_info->fbo_ops.glGenFramebuffers(1, &fbo);
     853    gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, fbo);
     854    gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, buffer, 0);
     855    glDrawBuffer(GL_COLOR_ATTACHMENT0);
    839856
    840857    glViewport(0, 0, 16, 1);
     
    876893    }
    877894
    878     GL_EXTCALL(glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0));
    879     GL_EXTCALL(glDeleteFramebuffersEXT(1, &fbo));
     895    gl_info->fbo_ops.glBindFramebuffer(GL_FRAMEBUFFER, 0);
     896    gl_info->fbo_ops.glDeleteFramebuffers(1, &fbo);
    880897    glDeleteTextures(1, &tex);
    881898    glDeleteTextures(1, &buffer);
     
    10071024         * with each other
    10081025         */
    1009         idx = getFmtIdx(WINED3DFMT_L6V5U5);
     1026        idx = getFmtIdx(WINED3DFMT_R5G5_SNORM_L6_UNORM);
    10101027        gl_info->gl_formats[idx].color_fixup = create_color_fixup_desc(
    10111028                1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE);
    1012         idx = getFmtIdx(WINED3DFMT_X8L8V8U8);
     1029        idx = getFmtIdx(WINED3DFMT_R8G8_SNORM_L8X8_UNORM);
    10131030        gl_info->gl_formats[idx].color_fixup = create_color_fixup_desc(
    10141031                1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W);
     
    10541071    if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA))
    10551072    {
    1056         idx = getFmtIdx(WINED3DFMT_A8R8G8B8);
     1073        idx = getFmtIdx(WINED3DFMT_B8G8R8A8_UNORM);
    10571074        gl_info->gl_formats[idx].gl_vtx_format = GL_BGRA;
    10581075    }
     
    11551172#define FMT_TO_STR(fmt) case fmt: return #fmt
    11561173    FMT_TO_STR(WINED3DFMT_UNKNOWN);
    1157     FMT_TO_STR(WINED3DFMT_R8G8B8);
    1158     FMT_TO_STR(WINED3DFMT_A8R8G8B8);
    1159     FMT_TO_STR(WINED3DFMT_X8R8G8B8);
    1160     FMT_TO_STR(WINED3DFMT_R5G6B5);
    1161     FMT_TO_STR(WINED3DFMT_X1R5G5B5);
    1162     FMT_TO_STR(WINED3DFMT_A1R5G5B5);
    1163     FMT_TO_STR(WINED3DFMT_A4R4G4B4);
    1164     FMT_TO_STR(WINED3DFMT_R3G3B2);
    1165     FMT_TO_STR(WINED3DFMT_A8R3G3B2);
    1166     FMT_TO_STR(WINED3DFMT_X4R4G4B4);
    1167     FMT_TO_STR(WINED3DFMT_X8B8G8R8);
    1168     FMT_TO_STR(WINED3DFMT_A2R10G10B10);
    1169     FMT_TO_STR(WINED3DFMT_A8P8);
    1170     FMT_TO_STR(WINED3DFMT_P8);
    1171     FMT_TO_STR(WINED3DFMT_L8);
    1172     FMT_TO_STR(WINED3DFMT_A8L8);
    1173     FMT_TO_STR(WINED3DFMT_A4L4);
    1174     FMT_TO_STR(WINED3DFMT_L6V5U5);
    1175     FMT_TO_STR(WINED3DFMT_X8L8V8U8);
    1176     FMT_TO_STR(WINED3DFMT_W11V11U10);
    1177     FMT_TO_STR(WINED3DFMT_A2W10V10U10);
     1174    FMT_TO_STR(WINED3DFMT_B8G8R8_UNORM);
     1175    FMT_TO_STR(WINED3DFMT_B5G5R5X1_UNORM);
     1176    FMT_TO_STR(WINED3DFMT_B4G4R4A4_UNORM);
     1177    FMT_TO_STR(WINED3DFMT_B2G3R3_UNORM);
     1178    FMT_TO_STR(WINED3DFMT_B2G3R3A8_UNORM);
     1179    FMT_TO_STR(WINED3DFMT_B4G4R4X4_UNORM);
     1180    FMT_TO_STR(WINED3DFMT_R8G8B8X8_UNORM);
     1181    FMT_TO_STR(WINED3DFMT_B10G10R10A2_UNORM);
     1182    FMT_TO_STR(WINED3DFMT_P8_UINT_A8_UNORM);
     1183    FMT_TO_STR(WINED3DFMT_P8_UINT);
     1184    FMT_TO_STR(WINED3DFMT_L8_UNORM);
     1185    FMT_TO_STR(WINED3DFMT_L8A8_UNORM);
     1186    FMT_TO_STR(WINED3DFMT_L4A4_UNORM);
     1187    FMT_TO_STR(WINED3DFMT_R5G5_SNORM_L6_UNORM);
     1188    FMT_TO_STR(WINED3DFMT_R8G8_SNORM_L8X8_UNORM);
     1189    FMT_TO_STR(WINED3DFMT_R10G11B11_SNORM);
     1190    FMT_TO_STR(WINED3DFMT_R10G10B10_SNORM_A2_UNORM);
    11781191    FMT_TO_STR(WINED3DFMT_UYVY);
    11791192    FMT_TO_STR(WINED3DFMT_YUY2);
     
    11881201    FMT_TO_STR(WINED3DFMT_R8G8_B8G8);
    11891202    FMT_TO_STR(WINED3DFMT_D16_LOCKABLE);
    1190     FMT_TO_STR(WINED3DFMT_D32);
    1191     FMT_TO_STR(WINED3DFMT_D15S1);
    1192     FMT_TO_STR(WINED3DFMT_D24S8);
    1193     FMT_TO_STR(WINED3DFMT_D24X8);
    1194     FMT_TO_STR(WINED3DFMT_D24X4S4);
    1195     FMT_TO_STR(WINED3DFMT_L16);
    1196     FMT_TO_STR(WINED3DFMT_D32F_LOCKABLE);
    1197     FMT_TO_STR(WINED3DFMT_D24FS8);
     1203    FMT_TO_STR(WINED3DFMT_D32_UNORM);
     1204    FMT_TO_STR(WINED3DFMT_S1_UINT_D15_UNORM);
     1205    FMT_TO_STR(WINED3DFMT_S8_UINT_D24_UNORM);
     1206    FMT_TO_STR(WINED3DFMT_X8D24_UNORM);
     1207    FMT_TO_STR(WINED3DFMT_S4X4_UINT_D24_UNORM);
     1208    FMT_TO_STR(WINED3DFMT_L16_UNORM);
     1209    FMT_TO_STR(WINED3DFMT_S8_UINT_D24_FLOAT);
    11981210    FMT_TO_STR(WINED3DFMT_VERTEXDATA);
    1199     FMT_TO_STR(WINED3DFMT_CxV8U8);
     1211    FMT_TO_STR(WINED3DFMT_R8G8_SNORM_Cx);
    12001212    FMT_TO_STR(WINED3DFMT_ATI2N);
    12011213    FMT_TO_STR(WINED3DFMT_NVHU);
     
    17651777    switch(status) {
    17661778#define FBOSTATUS_TO_STR(u) case u: return #u
    1767         FBOSTATUS_TO_STR(GL_FRAMEBUFFER_COMPLETE_EXT);
    1768         FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT);
    1769         FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT);
     1779        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_COMPLETE);
     1780        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT);
     1781        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT);
    17701782        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT);
    17711783        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT);
    1772         FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT);
    1773         FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT);
    1774         FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT);
    1775         FBOSTATUS_TO_STR(GL_FRAMEBUFFER_UNSUPPORTED_EXT);
     1784        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER);
     1785        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER);
     1786        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE);
     1787        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_UNSUPPORTED);
     1788        FBOSTATUS_TO_STR(GL_FRAMEBUFFER_UNDEFINED);
    17761789#undef FBOSTATUS_TO_STR
    17771790        default:
     
    17911804        GLERROR_TO_STR(GL_STACK_UNDERFLOW);
    17921805        GLERROR_TO_STR(GL_OUT_OF_MEMORY);
    1793         GLERROR_TO_STR(GL_INVALID_FRAMEBUFFER_OPERATION_EXT);
     1806        GLERROR_TO_STR(GL_INVALID_FRAMEBUFFER_OPERATION);
    17941807#undef GLERROR_TO_STR
    17951808        default:
     
    20442057    switch(format_desc->format)
    20452058    {
    2046         case WINED3DFMT_X8R8G8B8:
    2047         case WINED3DFMT_R8G8B8:
    2048         case WINED3DFMT_A8R8G8B8:
     2059        case WINED3DFMT_B8G8R8X8_UNORM:
     2060        case WINED3DFMT_B8G8R8_UNORM:
     2061        case WINED3DFMT_B8G8R8A8_UNORM:
    20492062        case WINED3DFMT_R8G8B8A8_UNORM:
    2050         case WINED3DFMT_A2R10G10B10:
    2051         case WINED3DFMT_X1R5G5B5:
    2052         case WINED3DFMT_A1R5G5B5:
    2053         case WINED3DFMT_R5G6B5:
    2054         case WINED3DFMT_X4R4G4B4:
    2055         case WINED3DFMT_A4R4G4B4:
    2056         case WINED3DFMT_R3G3B2:
    2057         case WINED3DFMT_A8P8:
    2058         case WINED3DFMT_P8:
     2063        case WINED3DFMT_B10G10R10A2_UNORM:
     2064        case WINED3DFMT_B5G5R5X1_UNORM:
     2065        case WINED3DFMT_B5G5R5A1_UNORM:
     2066        case WINED3DFMT_B5G6R5_UNORM:
     2067        case WINED3DFMT_B4G4R4X4_UNORM:
     2068        case WINED3DFMT_B4G4R4A4_UNORM:
     2069        case WINED3DFMT_B2G3R3_UNORM:
     2070        case WINED3DFMT_P8_UINT_A8_UNORM:
     2071        case WINED3DFMT_P8_UINT:
    20592072            break;
    20602073        default:
     
    20822095        case WINED3DFMT_D16_LOCKABLE:
    20832096        case WINED3DFMT_D16_UNORM:
    2084         case WINED3DFMT_D15S1:
    2085         case WINED3DFMT_D24X8:
    2086         case WINED3DFMT_D24X4S4:
    2087         case WINED3DFMT_D24S8:
    2088         case WINED3DFMT_D24FS8:
    2089         case WINED3DFMT_D32:
    2090         case WINED3DFMT_D32F_LOCKABLE:
     2097        case WINED3DFMT_S1_UINT_D15_UNORM:
     2098        case WINED3DFMT_X8D24_UNORM:
     2099        case WINED3DFMT_S4X4_UINT_D24_UNORM:
     2100        case WINED3DFMT_S8_UINT_D24_UNORM:
     2101        case WINED3DFMT_S8_UINT_D24_FLOAT:
     2102        case WINED3DFMT_D32_UNORM:
     2103        case WINED3DFMT_D32_FLOAT:
    20912104            break;
    20922105        default:
     
    21062119WINED3DFORMAT pixelformat_for_depth(DWORD depth) {
    21072120    switch(depth) {
    2108         case 8:  return WINED3DFMT_P8;
    2109         case 15: return WINED3DFMT_X1R5G5B5;
    2110         case 16: return WINED3DFMT_R5G6B5;
    2111         case 24: return WINED3DFMT_X8R8G8B8; /* Robots needs 24bit to be X8R8G8B8 */
    2112         case 32: return WINED3DFMT_X8R8G8B8; /* EVE online and the Fur demo need 32bit AdapterDisplayMode to return X8R8G8B8 */
     2121        case 8:  return WINED3DFMT_P8_UINT;
     2122        case 15: return WINED3DFMT_B5G5R5X1_UNORM;
     2123        case 16: return WINED3DFMT_B5G6R5_UNORM;
     2124        case 24: return WINED3DFMT_B8G8R8X8_UNORM; /* Robots needs 24bit to be WINED3DFMT_B8G8R8X8_UNORM */
     2125        case 32: return WINED3DFMT_B8G8R8X8_UNORM; /* EVE online and the Fur demo need 32bit AdapterDisplayMode to return WINED3DFMT_B8G8R8X8_UNORM */
    21132126        default: return WINED3DFMT_UNKNOWN;
    21142127    }
     
    25432556        settings->sRGB_write = 0;
    25442557    }
    2545     if(device->vs_clipping || !use_vs(stateblock)) {
     2558    if(device->vs_clipping || !use_vs(stateblock) || !stateblock->renderState[WINED3DRS_CLIPPING] ||
     2559       !stateblock->renderState[WINED3DRS_CLIPPLANEENABLE]) {
    25462560        /* No need to emulate clipplanes if GL supports native vertex shader clipping or if
    2547          * the fixed function vertex pipeline is used(which always supports clipplanes)
     2561         * the fixed function vertex pipeline is used(which always supports clipplanes), or
     2562         * if no clipplane is enabled
    25482563         */
    25492564        settings->emul_clipplanes = 0;
     
    27022717UINT wined3d_log2i(UINT32 x)
    27032718{
    2704     static const BYTE l[] =
    2705     {
    2706         0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
    2707         4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
    2708         5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    2709         5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
    2710         6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
    2711         6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
    2712         6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
    2713         6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
    2714         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    2715         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    2716         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    2717         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    2718         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    2719         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    2720         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    2721         7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2719    static const UINT l[] =
     2720    {
     2721        ~0U, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
     2722          4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
     2723          5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     2724          5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
     2725          6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
     2726          6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
     2727          6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
     2728          6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
     2729          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2730          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2731          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2732          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2733          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2734          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2735          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
     2736          7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
    27222737    };
    27232738    UINT32 i;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vertexdeclaration.c

    r19678 r23571  
    66 * Copyright 2004 Christian Costa
    77 * Copyright 2005 Oliver Stieber
     8 * Copyright 2009 Henri Verbeet for CodeWeavers
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    8485
    8586        HeapFree(GetProcessHeap(), 0, This->elements);
     87        This->parent_ops->wined3d_object_destroyed(This->parent);
    8688        HeapFree(GetProcessHeap(), 0, This);
    8789    }
     
    139141                case WINED3DFMT_R32G32B32_FLOAT:
    140142                case WINED3DFMT_R32G32B32A32_FLOAT:
    141                 case WINED3DFMT_A8R8G8B8:
     143                case WINED3DFMT_B8G8R8A8_UNORM:
    142144                case WINED3DFMT_R8G8B8A8_UINT:
    143145                case WINED3DFMT_R16G16_SINT:
     
    183185                case WINED3DFMT_R32G32B32_FLOAT:
    184186                case WINED3DFMT_R32G32B32A32_FLOAT:
    185                 case WINED3DFMT_A8R8G8B8:
     187                case WINED3DFMT_B8G8R8A8_UNORM:
    186188                case WINED3DFMT_R8G8B8A8_UINT:
    187189                case WINED3DFMT_R16G16B16A16_SINT:
     
    200202}
    201203
    202 HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *This,
    203         const WINED3DVERTEXELEMENT *elements, UINT element_count)
    204 {
    205     HRESULT hr = WINED3D_OK;
    206     unsigned int i;
    207     char isPreLoaded[MAX_STREAMS];
    208 
    209     TRACE("(%p) : d3d version %d\n", This, ((IWineD3DImpl *)This->wineD3DDevice->wineD3D)->dxVersion);
    210     memset(isPreLoaded, 0, sizeof(isPreLoaded));
    211 
    212     if (TRACE_ON(d3d_decl)) {
    213         for (i = 0; i < element_count; ++i) {
    214             dump_wined3dvertexelement(elements+i);
    215         }
    216     }
    217 
    218     This->element_count = element_count;
    219     This->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*This->elements) * element_count);
    220     if (!This->elements)
    221     {
    222         ERR("Memory allocation failed\n");
    223         return WINED3DERR_OUTOFVIDEOMEMORY;
    224     }
    225 
    226     /* Do some static analysis on the elements to make reading the declaration more comfortable
    227      * for the drawing code
    228      */
    229     This->num_streams = 0;
    230     This->position_transformed = FALSE;
    231     for (i = 0; i < element_count; ++i) {
    232         struct wined3d_vertex_declaration_element *e = &This->elements[i];
    233 
    234         e->format_desc = getFormatDescEntry(elements[i].format, &This->wineD3DDevice->adapter->gl_info);
    235         e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
    236         e->input_slot = elements[i].input_slot;
    237         e->offset = elements[i].offset;
    238         e->output_slot = elements[i].output_slot;
    239         e->method = elements[i].method;
    240         e->usage = elements[i].usage;
    241         e->usage_idx = elements[i].usage_idx;
    242 
    243         if (e->usage == WINED3DDECLUSAGE_POSITIONT) This->position_transformed = TRUE;
    244 
    245         /* Find the Streams used in the declaration. The vertex buffers have to be loaded
    246          * when drawing, but filter tesselation pseudo streams
    247          */
    248         if (e->input_slot >= MAX_STREAMS) continue;
    249 
    250         if (!e->format_desc->gl_vtx_format)
    251         {
    252             FIXME("The application tries to use an unsupported format (%s), returning E_FAIL\n",
    253                     debug_d3dformat(elements[i].format));
    254             /* The caller will release the vdecl, which will free This->elements */
    255             return E_FAIL;
    256         }
    257 
    258         if (e->offset & 0x3)
    259         {
    260             WARN("Declaration element %u is not 4 byte aligned(%u), returning E_FAIL\n", i, e->offset);
    261             return E_FAIL;
    262         }
    263 
    264         if (!isPreLoaded[e->input_slot])
    265         {
    266             This->streams[This->num_streams] = e->input_slot;
    267             This->num_streams++;
    268             isPreLoaded[e->input_slot] = 1;
    269         }
    270 
    271         if (elements[i].format == WINED3DFMT_R16G16_FLOAT || elements[i].format == WINED3DFMT_R16G16B16A16_FLOAT)
    272         {
    273             if (!GL_SUPPORT(ARB_HALF_FLOAT_VERTEX)) This->half_float_conv_needed = TRUE;
    274         }
    275     }
    276 
    277     TRACE("Returning\n");
    278     return hr;
    279 }
    280 
    281 const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl =
     204static const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl =
    282205{
    283206    /* IUnknown */
     
    289212    IWineD3DVertexDeclarationImpl_GetDevice,
    290213};
     214
     215HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
     216        const WINED3DVERTEXELEMENT *elements, UINT element_count,
     217        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     218{
     219    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     220    WORD preloaded = 0; /* MAX_STREAMS, 16 */
     221    unsigned int i;
     222
     223    if (TRACE_ON(d3d_decl))
     224    {
     225        for (i = 0; i < element_count; ++i)
     226        {
     227            dump_wined3dvertexelement(elements + i);
     228        }
     229    }
     230
     231    declaration->lpVtbl = &IWineD3DVertexDeclaration_Vtbl;
     232    declaration->ref = 1;
     233    declaration->parent = parent;
     234    declaration->parent_ops = parent_ops;
     235    declaration->wineD3DDevice = device;
     236    declaration->elements = HeapAlloc(GetProcessHeap(), 0, sizeof(*declaration->elements) * element_count);
     237    if (!declaration->elements)
     238    {
     239        ERR("Failed to allocate elements memory.\n");
     240        return E_OUTOFMEMORY;
     241    }
     242    declaration->element_count = element_count;
     243
     244    /* Do some static analysis on the elements to make reading the
     245     * declaration more comfortable for the drawing code. */
     246    for (i = 0; i < element_count; ++i)
     247    {
     248        struct wined3d_vertex_declaration_element *e = &declaration->elements[i];
     249
     250        e->format_desc = getFormatDescEntry(elements[i].format, gl_info);
     251        e->ffp_valid = declaration_element_valid_ffp(&elements[i]);
     252        e->input_slot = elements[i].input_slot;
     253        e->offset = elements[i].offset;
     254        e->output_slot = elements[i].output_slot;
     255        e->method = elements[i].method;
     256        e->usage = elements[i].usage;
     257        e->usage_idx = elements[i].usage_idx;
     258
     259        if (e->usage == WINED3DDECLUSAGE_POSITIONT) declaration->position_transformed = TRUE;
     260
     261        /* Find the streams used in the declaration. The vertex buffers have
     262         * to be loaded when drawing, but filter tesselation pseudo streams. */
     263        if (e->input_slot >= MAX_STREAMS) continue;
     264
     265        if (!e->format_desc->gl_vtx_format)
     266        {
     267            FIXME("The application tries to use an unsupported format (%s), returning E_FAIL.\n",
     268                    debug_d3dformat(elements[i].format));
     269            HeapFree(GetProcessHeap(), 0, declaration->elements);
     270            return E_FAIL;
     271        }
     272
     273        if (e->offset & 0x3)
     274        {
     275            WARN("Declaration element %u is not 4 byte aligned(%u), returning E_FAIL.\n", i, e->offset);
     276            HeapFree(GetProcessHeap(), 0, declaration->elements);
     277            return E_FAIL;
     278        }
     279
     280        if (!(preloaded & (1 << e->input_slot)))
     281        {
     282            declaration->streams[declaration->num_streams] = e->input_slot;
     283            ++declaration->num_streams;
     284            preloaded |= 1 << e->input_slot;
     285        }
     286
     287        if (elements[i].format == WINED3DFMT_R16G16_FLOAT || elements[i].format == WINED3DFMT_R16G16B16A16_FLOAT)
     288        {
     289            if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX]) declaration->half_float_conv_needed = TRUE;
     290        }
     291    }
     292
     293    return WINED3D_OK;
     294}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/vertexshader.c

    r21731 r23571  
    88 * Copyright 2006 Ivan Gyurdiev
    99 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     10 * Copyright 2009 Henri Verbeet for CodeWeavers
    1011 *
    1112 * This library is free software; you can redistribute it and/or
     
    184185    {
    185186        shader_cleanup((IWineD3DBaseShader *)iface);
     187        This->baseShader.parent_ops->wined3d_object_destroyed(This->baseShader.parent);
    186188        HeapFree(GetProcessHeap(), 0, This);
    187189    }
     
    196198static HRESULT WINAPI IWineD3DVertexShaderImpl_GetParent(IWineD3DVertexShader *iface, IUnknown** parent){
    197199    IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
    198    
    199     *parent = This->parent;
     200
     201    *parent = This->baseShader.parent;
    200202    IUnknown_AddRef(*parent);
    201203    TRACE("(%p) : returning %p\n", This, *parent);
     
    232234}
    233235
    234 /* Note that for vertex shaders CompileShader isn't called until the
    235  * shader is first used. The reason for this is that we need the vertex
    236  * declaration the shader will be used with in order to determine if
    237  * the data in a register is of type D3DCOLOR, and needs swizzling. */
    238 static HRESULT WINAPI IWineD3DVertexShaderImpl_SetFunction(IWineD3DVertexShader *iface,
    239         const DWORD *pFunction, const struct wined3d_shader_signature *output_signature)
    240 {
    241     IWineD3DVertexShaderImpl *This =(IWineD3DVertexShaderImpl *)iface;
    242     IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl *) This->baseShader.device;
     236static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader,
     237        const DWORD *byte_code, const struct wined3d_shader_signature *output_signature)
     238{
     239    IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)shader->baseShader.device;
     240    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    243241    const struct wined3d_shader_frontend *fe;
    244242    unsigned int i;
    245243    HRESULT hr;
    246     shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
    247 
    248     TRACE("(%p) : pFunction %p\n", iface, pFunction);
    249 
    250     fe = shader_select_frontend(*pFunction);
     244    shader_reg_maps *reg_maps = &shader->baseShader.reg_maps;
     245
     246    TRACE("shader %p, byte_code %p, output_signature %p.\n", shader, byte_code, output_signature);
     247
     248    fe = shader_select_frontend(*byte_code);
    251249    if (!fe)
    252250    {
     
    254252        return WINED3DERR_INVALIDCALL;
    255253    }
    256     This->baseShader.frontend = fe;
    257     This->baseShader.frontend_data = fe->shader_init(pFunction, output_signature);
    258     if (!This->baseShader.frontend_data)
     254    shader->baseShader.frontend = fe;
     255    shader->baseShader.frontend_data = fe->shader_init(byte_code, output_signature);
     256    if (!shader->baseShader.frontend_data)
    259257    {
    260258        FIXME("Failed to initialize frontend.\n");
     
    263261
    264262    /* First pass: trace shader */
    265     if (TRACE_ON(d3d_shader)) shader_trace_init(fe, This->baseShader.frontend_data, pFunction);
     263    if (TRACE_ON(d3d_shader)) shader_trace_init(fe, shader->baseShader.frontend_data, byte_code);
    266264
    267265    /* Initialize immediate constant lists */
    268     list_init(&This->baseShader.constantsF);
    269     list_init(&This->baseShader.constantsB);
    270     list_init(&This->baseShader.constantsI);
     266    list_init(&shader->baseShader.constantsF);
     267    list_init(&shader->baseShader.constantsB);
     268    list_init(&shader->baseShader.constantsI);
    271269
    272270    /* Second pass: figure out registers used, semantics, etc.. */
    273     This->min_rel_offset = GL_LIMITS(vshader_constantsF);
    274     This->max_rel_offset = 0;
    275     hr = shader_get_registers_used((IWineD3DBaseShader*) This, fe,
    276             reg_maps, This->attributes, NULL, This->output_signature,
    277             pFunction, GL_LIMITS(vshader_constantsF));
     271    shader->min_rel_offset = gl_info->max_vshader_constantsF;
     272    shader->max_rel_offset = 0;
     273    hr = shader_get_registers_used((IWineD3DBaseShader *)shader, fe,
     274            reg_maps, shader->attributes, NULL, shader->output_signature,
     275            byte_code, gl_info->max_vshader_constantsF);
    278276    if (hr != WINED3D_OK) return hr;
    279277
     
    284282            struct wined3d_shader_signature_element *e = &output_signature->elements[i];
    285283            reg_maps->output_registers |= 1 << e->register_idx;
    286             This->output_signature[e->register_idx] = *e;
    287         }
    288     }
    289 
    290     vshader_set_limits(This);
    291 
    292     if (deviceImpl->vs_selected_mode == SHADER_ARB
    293             && ((GLINFO_LOCATION).quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT)
    294             && This->min_rel_offset <= This->max_rel_offset)
    295     {
    296         if(This->max_rel_offset - This->min_rel_offset > 127) {
     284            shader->output_signature[e->register_idx] = *e;
     285        }
     286    }
     287
     288    vshader_set_limits(shader);
     289
     290    if (device->vs_selected_mode == SHADER_ARB
     291            && (gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT)
     292            && shader->min_rel_offset <= shader->max_rel_offset)
     293    {
     294        if (shader->max_rel_offset - shader->min_rel_offset > 127)
     295        {
    297296            FIXME("The difference between the minimum and maximum relative offset is > 127\n");
    298297            FIXME("Which this OpenGL implementation does not support. Try using GLSL\n");
    299             FIXME("Min: %d, Max: %d\n", This->min_rel_offset, This->max_rel_offset);
    300         } else if(This->max_rel_offset - This->min_rel_offset > 63) {
    301             This->rel_offset = This->min_rel_offset + 63;
    302         } else if(This->max_rel_offset > 63) {
    303             This->rel_offset = This->min_rel_offset;
    304         } else {
    305             This->rel_offset = 0;
    306         }
    307     }
    308     This->baseShader.load_local_constsF = This->baseShader.reg_maps.usesrelconstF && !list_empty(&This->baseShader.constantsF);
     298            FIXME("Min: %d, Max: %d\n", shader->min_rel_offset, shader->max_rel_offset);
     299        }
     300        else if (shader->max_rel_offset - shader->min_rel_offset > 63)
     301        {
     302            shader->rel_offset = shader->min_rel_offset + 63;
     303        }
     304        else if (shader->max_rel_offset > 63)
     305        {
     306            shader->rel_offset = shader->min_rel_offset;
     307        }
     308        else
     309        {
     310            shader->rel_offset = 0;
     311        }
     312    }
     313    shader->baseShader.load_local_constsF = shader->baseShader.reg_maps.usesrelconstF
     314            && !list_empty(&shader->baseShader.constantsF);
    309315
    310316    /* copy the function ... because it will certainly be released by application */
    311     This->baseShader.function = HeapAlloc(GetProcessHeap(), 0, This->baseShader.functionLength);
    312     if (!This->baseShader.function) return E_OUTOFMEMORY;
    313     memcpy(This->baseShader.function, pFunction, This->baseShader.functionLength);
     317    shader->baseShader.function = HeapAlloc(GetProcessHeap(), 0, shader->baseShader.functionLength);
     318    if (!shader->baseShader.function) return E_OUTOFMEMORY;
     319    memcpy(shader->baseShader.function, byte_code, shader->baseShader.functionLength);
    314320
    315321    return WINED3D_OK;
     
    342348}
    343349
    344 const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
     350static const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
    345351{
    346352    /*** IUnknown methods ***/
     
    351357    IWineD3DVertexShaderImpl_GetParent,
    352358    /*** IWineD3DBaseShader methods ***/
    353     IWineD3DVertexShaderImpl_SetFunction,
    354     /*** IWineD3DVertexShader methods ***/
    355359    IWineD3DVertexShaderImpl_GetDevice,
    356360    IWineD3DVertexShaderImpl_GetFunction,
     361    /*** IWineD3DVertexShader methods ***/
    357362    IWIneD3DVertexShaderImpl_SetLocalConstantsF
    358363};
     
    362367    args->swizzle_map = ((IWineD3DDeviceImpl *)shader->baseShader.device)->strided_streams.swizzle_map;
    363368}
     369
     370HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device,
     371        const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
     372        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     373{
     374    HRESULT hr;
     375
     376    if (!byte_code) return WINED3DERR_INVALIDCALL;
     377
     378    shader->lpVtbl = &IWineD3DVertexShader_Vtbl;
     379    shader_init(&shader->baseShader, device, parent, parent_ops);
     380
     381    hr = vertexshader_set_function(shader, byte_code, output_signature);
     382    if (FAILED(hr))
     383    {
     384        WARN("Failed to set function, hr %#x.\n", hr);
     385        shader_cleanup((IWineD3DBaseShader *)shader);
     386        return hr;
     387    }
     388
     389    return WINED3D_OK;
     390}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volume.c

    r21731 r23571  
    55 * Copyright 2002-2005 Raphael Junqueira
    66 * Copyright 2005 Oliver Stieber
     7 * Copyright 2009 Henri Verbeet for CodeWeavers
    78 *
    89 * This library is free software; you can redistribute it and/or
     
    4041    IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
    4142    IWineD3DVolumeTexture *texture;
    42     int active_sampler;
     43    DWORD active_sampler;
    4344
    4445    /* We don't need a specific texture unit, but after binding the texture the current unit is dirty.
     
    6364    }
    6465
    65     if (active_sampler != -1) {
     66    if (active_sampler != WINED3D_UNMAPPED_STAGE)
     67    {
    6668        IWineD3DDeviceImpl_MarkStateDirty(This->resource.wineD3DDevice, STATE_SAMPLER(active_sampler));
    6769    }
     
    131133    if (ref == 0) {
    132134        resource_cleanup((IWineD3DResource *)iface);
     135        This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
    133136        HeapFree(GetProcessHeap(), 0, This);
    134137    }
     
    273276        if (containerType == WINED3DRTYPE_VOLUMETEXTURE) {
    274277          IWineD3DBaseTextureImpl* pTexture = (IWineD3DBaseTextureImpl*) cont;
    275           pTexture->baseTexture.dirty = TRUE;
     278          pTexture->baseTexture.texture_rgb.dirty = TRUE;
     279          pTexture->baseTexture.texture_srgb.dirty = TRUE;
    276280        } else {
    277281          FIXME("Set dirty on container type %d\n", containerType);
     
    355359}
    356360
    357 const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
     361static const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl =
    358362{
    359363    /* IUnknown */
     
    381385    IWineD3DVolumeImpl_SetContainer
    382386};
     387
     388HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
     389        UINT height, UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
     390        IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     391{
     392    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     393    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
     394    HRESULT hr;
     395
     396    if (!gl_info->supported[EXT_TEXTURE3D])
     397    {
     398        WARN("Volume cannot be created - no volume texture support.\n");
     399        return WINED3DERR_INVALIDCALL;
     400    }
     401
     402    volume->lpVtbl = &IWineD3DVolume_Vtbl;
     403
     404    hr = resource_init((IWineD3DResource *)volume, WINED3DRTYPE_VOLUME, device,
     405            width * height * depth * format_desc->byte_count, usage, format_desc, pool, parent, parent_ops);
     406    if (FAILED(hr))
     407    {
     408        WARN("Failed to initialize resource, returning %#x.\n", hr);
     409        return hr;
     410    }
     411
     412    volume->currentDesc.Width = width;
     413    volume->currentDesc.Height = height;
     414    volume->currentDesc.Depth = depth;
     415    volume->lockable = TRUE;
     416    volume->locked = FALSE;
     417    memset(&volume->lockedBox, 0, sizeof(volume->lockedBox));
     418    volume->dirty = TRUE;
     419
     420    volume_add_dirty_box((IWineD3DVolume *)volume, NULL);
     421
     422    return WINED3D_OK;
     423}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/volumetexture.c

    r22496 r23571  
    55 * Copyright 2002-2005 Raphael Junqueira
    66 * Copyright 2005 Oliver Stieber
     7 * Copyright 2009 Henri Verbeet for CodeWeavers
    78 *
    89 * This library is free software; you can redistribute it and/or
     
    6263    /* If the texture is marked dirty or the srgb sampler setting has changed
    6364     * since the last load then reload the volumes. */
    64     if (This->baseTexture.dirty)
     65    if (This->baseTexture.texture_rgb.dirty)
    6566    {
    6667        for (i = 0; i < This->baseTexture.levels; ++i)
     
    8384
    8485    /* No longer dirty */
    85     This->baseTexture.dirty = FALSE;
    86 }
    87 
    88 static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This, D3DCB_DESTROYVOLUMEFN volume_destroy_cb)
     86    This->baseTexture.texture_rgb.dirty = FALSE;
     87}
     88
     89static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This)
    8990{
    9091    unsigned int i;
     
    100101            /* Cleanup the container. */
    101102            IWineD3DVolume_SetContainer(volume, NULL);
    102             volume_destroy_cb(volume);
     103            IWineD3DVolume_Release(volume);
    103104        }
    104105    }
    105106    basetexture_cleanup((IWineD3DBaseTexture *)This);
    106 }
    107 
    108 HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height, UINT depth, UINT levels,
    109         IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent)
    110 {
    111     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    112     const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
    113     UINT tmp_w, tmp_h, tmp_d;
    114     unsigned int i;
    115     HRESULT hr;
    116 
    117     /* TODO: It should only be possible to create textures for formats
    118      * that are reported as supported. */
    119     if (WINED3DFMT_UNKNOWN >= format)
    120     {
    121         WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
    122         return WINED3DERR_INVALIDCALL;
    123     }
    124 
    125     if (!GL_SUPPORT(EXT_TEXTURE3D))
    126     {
    127         WARN("(%p) : Texture cannot be created - no volume texture support.\n", texture);
    128         return WINED3DERR_INVALIDCALL;
    129     }
    130 
    131     /* Calculate levels for mip mapping. */
    132     if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
    133     {
    134         if (!GL_SUPPORT(SGIS_GENERATE_MIPMAP))
    135         {
    136             WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
    137             return WINED3DERR_INVALIDCALL;
    138         }
    139 
    140         if (levels > 1)
    141         {
    142             WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
    143             return WINED3DERR_INVALIDCALL;
    144         }
    145 
    146         levels = 1;
    147     }
    148     else if (!levels)
    149     {
    150         levels = wined3d_log2i(max(max(width, height), depth)) + 1;
    151         TRACE("Calculated levels = %u.\n", levels);
    152     }
    153 
    154     hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels,
    155             WINED3DRTYPE_VOLUMETEXTURE, device, 0, usage, format_desc, pool, parent);
    156     if (FAILED(hr))
    157     {
    158         WARN("Failed to initialize basetexture, returning %#x.\n", hr);
    159         return hr;
    160     }
    161 
    162     /* Is NP2 support for volumes needed? */
    163     texture->baseTexture.pow2Matrix[0] = 1.0f;
    164     texture->baseTexture.pow2Matrix[5] = 1.0f;
    165     texture->baseTexture.pow2Matrix[10] = 1.0f;
    166     texture->baseTexture.pow2Matrix[15] = 1.0f;
    167 
    168     /* Generate all the surfaces. */
    169     tmp_w = width;
    170     tmp_h = height;
    171     tmp_d = depth;
    172 
    173     for (i = 0; i < texture->baseTexture.levels; ++i)
    174     {
    175         /* Create the volume. */
    176         hr = IWineD3DDeviceParent_CreateVolume(device->device_parent, parent,
    177                 tmp_w, tmp_h, tmp_d, format, pool, usage, &texture->volumes[i]);
    178         if (FAILED(hr))
    179         {
    180             ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
    181             texture->volumes[i] = NULL;
    182             volumetexture_cleanup(texture, D3DCB_DefaultDestroyVolume);
    183             return hr;
    184         }
    185 
    186         /* Set its container to this texture. */
    187         IWineD3DVolume_SetContainer(texture->volumes[i], (IWineD3DBase *)texture);
    188 
    189         /* Calculate the next mipmap level. */
    190         tmp_w = max(1, tmp_w >> 1);
    191         tmp_h = max(1, tmp_h >> 1);
    192         tmp_d = max(1, tmp_d >> 1);
    193     }
    194     texture->baseTexture.internal_preload = volumetexture_internal_preload;
    195 
    196     return WINED3D_OK;
    197107}
    198108
     
    233143    TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
    234144    ref = InterlockedDecrement(&This->resource.ref);
    235     if (ref == 0) {
    236         IWineD3DVolumeTexture_Destroy(iface, D3DCB_DefaultDestroyVolume);
     145    if (!ref)
     146    {
     147        volumetexture_cleanup(This);
     148        This->resource.parent_ops->wined3d_object_destroyed(This->resource.parent);
     149        HeapFree(GetProcessHeap(), 0, This);
    237150    }
    238151    return ref;
     
    354267   IWineD3DVolumeTexture IWineD3DVolumeTexture parts follow
    355268   ******************************************* */
    356 static void WINAPI IWineD3DVolumeTextureImpl_Destroy(IWineD3DVolumeTexture *iface, D3DCB_DESTROYVOLUMEFN D3DCB_DestroyVolume) {
    357     IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
    358 
    359     volumetexture_cleanup(This, D3DCB_DestroyVolume);
    360 
    361     HeapFree(GetProcessHeap(), 0, This);
    362 }
    363 
    364269static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetLevelDesc(IWineD3DVolumeTexture *iface, UINT Level,WINED3DVOLUME_DESC *pDesc) {
    365270    IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
     
    417322static HRESULT WINAPI IWineD3DVolumeTextureImpl_AddDirtyBox(IWineD3DVolumeTexture *iface, CONST WINED3DBOX* pDirtyBox) {
    418323    IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
    419     This->baseTexture.dirty = TRUE;
     324    This->baseTexture.texture_rgb.dirty = TRUE;
     325    This->baseTexture.texture_srgb.dirty = TRUE;
    420326    TRACE("(%p) : dirtyfication of volume Level (0)\n", This);
    421327    volume_add_dirty_box(This->volumes[0], pDirtyBox);
     
    424330}
    425331
    426 const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =
     332static const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl =
    427333{
    428334    /* IUnknown */
     
    455361    IWineD3DVolumeTextureImpl_IsCondNP2,
    456362    /* volume texture */
    457     IWineD3DVolumeTextureImpl_Destroy,
    458363    IWineD3DVolumeTextureImpl_GetLevelDesc,
    459364    IWineD3DVolumeTextureImpl_GetVolumeLevel,
     
    462367    IWineD3DVolumeTextureImpl_AddDirtyBox
    463368};
     369
     370HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height,
     371        UINT depth, UINT levels, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
     372        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
     373{
     374    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     375    const struct GlPixelFormatDesc *format_desc = getFormatDescEntry(format, gl_info);
     376    UINT tmp_w, tmp_h, tmp_d;
     377    unsigned int i;
     378    HRESULT hr;
     379
     380    /* TODO: It should only be possible to create textures for formats
     381     * that are reported as supported. */
     382    if (WINED3DFMT_UNKNOWN >= format)
     383    {
     384        WARN("(%p) : Texture cannot be created with a format of WINED3DFMT_UNKNOWN.\n", texture);
     385        return WINED3DERR_INVALIDCALL;
     386    }
     387
     388    if (!gl_info->supported[EXT_TEXTURE3D])
     389    {
     390        WARN("(%p) : Texture cannot be created - no volume texture support.\n", texture);
     391        return WINED3DERR_INVALIDCALL;
     392    }
     393
     394    /* Calculate levels for mip mapping. */
     395    if (usage & WINED3DUSAGE_AUTOGENMIPMAP)
     396    {
     397        if (!gl_info->supported[SGIS_GENERATE_MIPMAP])
     398        {
     399            WARN("No mipmap generation support, returning D3DERR_INVALIDCALL.\n");
     400            return WINED3DERR_INVALIDCALL;
     401        }
     402
     403        if (levels > 1)
     404        {
     405            WARN("D3DUSAGE_AUTOGENMIPMAP is set, and level count > 1, returning D3DERR_INVALIDCALL.\n");
     406            return WINED3DERR_INVALIDCALL;
     407        }
     408
     409        levels = 1;
     410    }
     411    else if (!levels)
     412    {
     413        levels = wined3d_log2i(max(max(width, height), depth)) + 1;
     414        TRACE("Calculated levels = %u.\n", levels);
     415    }
     416
     417    texture->lpVtbl = &IWineD3DVolumeTexture_Vtbl;
     418
     419    hr = basetexture_init((IWineD3DBaseTextureImpl *)texture, levels, WINED3DRTYPE_VOLUMETEXTURE,
     420            device, 0, usage, format_desc, pool, parent, parent_ops);
     421    if (FAILED(hr))
     422    {
     423        WARN("Failed to initialize basetexture, returning %#x.\n", hr);
     424        return hr;
     425    }
     426
     427    /* Is NP2 support for volumes needed? */
     428    texture->baseTexture.pow2Matrix[0] = 1.0f;
     429    texture->baseTexture.pow2Matrix[5] = 1.0f;
     430    texture->baseTexture.pow2Matrix[10] = 1.0f;
     431    texture->baseTexture.pow2Matrix[15] = 1.0f;
     432
     433    /* Generate all the surfaces. */
     434    tmp_w = width;
     435    tmp_h = height;
     436    tmp_d = depth;
     437
     438    for (i = 0; i < texture->baseTexture.levels; ++i)
     439    {
     440        /* Create the volume. */
     441        hr = IWineD3DDeviceParent_CreateVolume(device->device_parent, parent,
     442                tmp_w, tmp_h, tmp_d, format, pool, usage, &texture->volumes[i]);
     443        if (FAILED(hr))
     444        {
     445            ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
     446            texture->volumes[i] = NULL;
     447            volumetexture_cleanup(texture);
     448            return hr;
     449        }
     450
     451        /* Set its container to this texture. */
     452        IWineD3DVolume_SetContainer(texture->volumes[i], (IWineD3DBase *)texture);
     453
     454        /* Calculate the next mipmap level. */
     455        tmp_w = max(1, tmp_w >> 1);
     456        tmp_h = max(1, tmp_h >> 1);
     457        tmp_d = max(1, tmp_d >> 1);
     458    }
     459    texture->baseTexture.internal_preload = volumetexture_internal_preload;
     460
     461    return WINED3D_OK;
     462}
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d.def

    r16410 r23571  
    44
    55EXPORTS
    6 ;  WineDirect3DCreate@8 @1
    7 ;  WineDirect3DCreateClipper@4 @2
    8 ;  WineDirect3DCreate@8 = WineDirect3DCreate
    9 ;  WineDirect3DCreateClipper@4 = WineDirect3DCreateClipper
    106  WineDirect3DCreate
    117  WineDirect3DCreateClipper
     8  wined3d_mutex_lock
     9  wined3d_mutex_unlock
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d.spec

    r16410 r23571  
    11@ stdcall WineDirect3DCreate(long ptr)
    22@ stdcall WineDirect3DCreateClipper(ptr)
     3@ stdcall wined3d_mutex_lock()
     4@ stdcall wined3d_mutex_unlock()
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_gl.h

    r21731 r23571  
    812812#define GL_MULTISAMPLE_BIT                0x20000000
    813813
    814 void (WINE_GLAPI *glAccum) (GLenum op, GLfloat value);
    815 void (WINE_GLAPI *glAlphaFunc) (GLenum func, GLclampf ref);
    816 GLboolean (WINE_GLAPI *glAreTexturesResident) (GLsizei n, const GLuint* textures, GLboolean* residences);
    817 void (WINE_GLAPI *glArrayElement) (GLint i);
    818 void (WINE_GLAPI *glBegin) (GLenum mode);
    819 void (WINE_GLAPI *glBindTexture) (GLenum target, GLuint texture);
    820 void (WINE_GLAPI *glBitmap) (GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte* bitmap);
    821 void (WINE_GLAPI *glBlendFunc) (GLenum sfactor, GLenum dfactor);
    822 void (WINE_GLAPI *glCallList) (GLuint list);
    823 void (WINE_GLAPI *glCallLists) (GLsizei n, GLenum type, const GLvoid* lists);
    824 void (WINE_GLAPI *glClear) (GLbitfield mask);
    825 void (WINE_GLAPI *glClearAccum) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
    826 void (WINE_GLAPI *glClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
    827 void (WINE_GLAPI *glClearDepth) (GLclampd depth);
    828 void (WINE_GLAPI *glClearIndex) (GLfloat c);
    829 void (WINE_GLAPI *glClearStencil) (GLint s);
    830 void (WINE_GLAPI *glClipPlane) (GLenum plane, const GLdouble* equation);
    831 void (WINE_GLAPI *glColor3b) (GLbyte red, GLbyte green, GLbyte blue);
    832 void (WINE_GLAPI *glColor3bv) (const GLbyte* v);
    833 void (WINE_GLAPI *glColor3d) (GLdouble red, GLdouble green, GLdouble blue);
    834 void (WINE_GLAPI *glColor3dv) (const GLdouble* v);
    835 void (WINE_GLAPI *glColor3f) (GLfloat red, GLfloat green, GLfloat blue);
    836 void (WINE_GLAPI *glColor3fv) (const GLfloat* v);
    837 void (WINE_GLAPI *glColor3i) (GLint red, GLint green, GLint blue);
    838 void (WINE_GLAPI *glColor3iv) (const GLint* v);
    839 void (WINE_GLAPI *glColor3s) (GLshort red, GLshort green, GLshort blue);
    840 void (WINE_GLAPI *glColor3sv) (const GLshort* v);
    841 void (WINE_GLAPI *glColor3ub) (GLubyte red, GLubyte green, GLubyte blue);
    842 void (WINE_GLAPI *glColor3ubv) (const GLubyte* v);
    843 void (WINE_GLAPI *glColor3ui) (GLuint red, GLuint green, GLuint blue);
    844 void (WINE_GLAPI *glColor3uiv) (const GLuint* v);
    845 void (WINE_GLAPI *glColor3us) (GLushort red, GLushort green, GLushort blue);
    846 void (WINE_GLAPI *glColor3usv) (const GLushort* v);
    847 void (WINE_GLAPI *glColor4b) (GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
    848 void (WINE_GLAPI *glColor4bv) (const GLbyte* v);
    849 void (WINE_GLAPI *glColor4d) (GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
    850 void (WINE_GLAPI *glColor4dv) (const GLdouble* v);
    851 void (WINE_GLAPI *glColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
    852 void (WINE_GLAPI *glColor4fv) (const GLfloat* v);
    853 void (WINE_GLAPI *glColor4i) (GLint red, GLint green, GLint blue, GLint alpha);
    854 void (WINE_GLAPI *glColor4iv) (const GLint* v);
    855 void (WINE_GLAPI *glColor4s) (GLshort red, GLshort green, GLshort blue, GLshort alpha);
    856 void (WINE_GLAPI *glColor4sv) (const GLshort* v);
    857 void (WINE_GLAPI *glColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
    858 void (WINE_GLAPI *glColor4ubv) (const GLubyte* v);
    859 void (WINE_GLAPI *glColor4ui) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
    860 void (WINE_GLAPI *glColor4uiv) (const GLuint* v);
    861 void (WINE_GLAPI *glColor4us) (GLushort red, GLushort green, GLushort blue, GLushort alpha);
    862 void (WINE_GLAPI *glColor4usv) (const GLushort* v);
    863 void (WINE_GLAPI *glColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
    864 void (WINE_GLAPI *glColorMaterial) (GLenum face, GLenum mode);
    865 void (WINE_GLAPI *glColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
    866 void (WINE_GLAPI *glCopyPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
    867 void (WINE_GLAPI *glCopyTexImage1D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
    868 void (WINE_GLAPI *glCopyTexImage2D) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
    869 void (WINE_GLAPI *glCopyTexSubImage1D) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
    870 void (WINE_GLAPI *glCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
    871 void (WINE_GLAPI *glCullFace) (GLenum mode);
    872 void (WINE_GLAPI *glDeleteLists) (GLuint list, GLsizei range);
    873 void (WINE_GLAPI *glDeleteTextures) (GLsizei n, const GLuint* textures);
    874 void (WINE_GLAPI *glDepthFunc) (GLenum func);
    875 void (WINE_GLAPI *glDepthMask) (GLboolean flag);
    876 void (WINE_GLAPI *glDepthRange) (GLclampd nearParam, GLclampd farParam);
    877 void (WINE_GLAPI *glDisable) (GLenum cap);
    878 void (WINE_GLAPI *glDisableWINE) (GLenum cap);
    879 void (WINE_GLAPI *glDisableClientState) (GLenum array);
    880 void (WINE_GLAPI *glDrawArrays) (GLenum mode, GLint first, GLsizei count);
    881 void (WINE_GLAPI *glDrawBuffer) (GLenum mode);
    882 void (WINE_GLAPI *glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
    883 void (WINE_GLAPI *glDrawPixels) (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
    884 void (WINE_GLAPI *glEdgeFlag) (GLboolean flag);
    885 void (WINE_GLAPI *glEdgeFlagPointer) (GLsizei stride, const GLvoid* pointer);
    886 void (WINE_GLAPI *glEdgeFlagv) (const GLboolean* flag);
    887 void (WINE_GLAPI *glEnable) (GLenum cap);
    888 void (WINE_GLAPI *glEnableWINE) (GLenum cap);
    889 void (WINE_GLAPI *glEnableClientState) (GLenum array);
    890 void (WINE_GLAPI *glEnd) ();
    891 void (WINE_GLAPI *glEndList) ();
    892 void (WINE_GLAPI *glEvalCoord1d) (GLdouble u);
    893 void (WINE_GLAPI *glEvalCoord1dv) (const GLdouble* u);
    894 void (WINE_GLAPI *glEvalCoord1f) (GLfloat u);
    895 void (WINE_GLAPI *glEvalCoord1fv) (const GLfloat* u);
    896 void (WINE_GLAPI *glEvalCoord2d) (GLdouble u, GLdouble v);
    897 void (WINE_GLAPI *glEvalCoord2dv) (const GLdouble* u);
    898 void (WINE_GLAPI *glEvalCoord2f) (GLfloat u, GLfloat v);
    899 void (WINE_GLAPI *glEvalCoord2fv) (const GLfloat* u);
    900 void (WINE_GLAPI *glEvalMesh1) (GLenum mode, GLint i1, GLint i2);
    901 void (WINE_GLAPI *glEvalMesh2) (GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
    902 void (WINE_GLAPI *glEvalPoint1) (GLint i);
    903 void (WINE_GLAPI *glEvalPoint2) (GLint i, GLint j);
    904 void (WINE_GLAPI *glFeedbackBuffer) (GLsizei size, GLenum type, GLfloat* buffer);
    905 void (WINE_GLAPI *glFogf) (GLenum pname, GLfloat param);
    906 void (WINE_GLAPI *glFogfv) (GLenum pname, const GLfloat* params);
    907 void (WINE_GLAPI *glFogi) (GLenum pname, GLint param);
    908 void (WINE_GLAPI *glFogiv) (GLenum pname, const GLint* params);
    909 void (WINE_GLAPI *glFrontFace) (GLenum mode);
    910 void (WINE_GLAPI *glFrustum) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
    911 GLuint (WINE_GLAPI *glGenLists) (GLsizei range);
    912 void (WINE_GLAPI *glGenTextures) (GLsizei n, GLuint* textures);
    913 void (WINE_GLAPI *glGetBooleanv) (GLenum pname, GLboolean* params);
    914 void (WINE_GLAPI *glGetClipPlane) (GLenum plane, GLdouble* equation);
    915 void (WINE_GLAPI *glGetDoublev) (GLenum pname, GLdouble* params);
    916 GLenum (WINE_GLAPI *glGetError) ();
    917 void (WINE_GLAPI *glGetFloatv) (GLenum pname, GLfloat* params);
    918 void (WINE_GLAPI *glGetIntegerv) (GLenum pname, GLint* params);
    919 void (WINE_GLAPI *glGetLightfv) (GLenum light, GLenum pname, GLfloat* params);
    920 void (WINE_GLAPI *glGetLightiv) (GLenum light, GLenum pname, GLint* params);
    921 void (WINE_GLAPI *glGetMapdv) (GLenum target, GLenum query, GLdouble* v);
    922 void (WINE_GLAPI *glGetMapfv) (GLenum target, GLenum query, GLfloat* v);
    923 void (WINE_GLAPI *glGetMapiv) (GLenum target, GLenum query, GLint* v);
    924 void (WINE_GLAPI *glGetMaterialfv) (GLenum face, GLenum pname, GLfloat* params);
    925 void (WINE_GLAPI *glGetMaterialiv) (GLenum face, GLenum pname, GLint* params);
    926 void (WINE_GLAPI *glGetPixelMapfv) (GLenum map, GLfloat* values);
    927 void (WINE_GLAPI *glGetPixelMapuiv) (GLenum map, GLuint* values);
    928 void (WINE_GLAPI *glGetPixelMapusv) (GLenum map, GLushort* values);
    929 void (WINE_GLAPI *glGetPointerv) (GLenum pname, GLvoid** params);
    930 void (WINE_GLAPI *glGetPolygonStipple) (GLubyte* mask);
    931 const GLubyte * (WINE_GLAPI *glGetString) (GLenum name);
    932 void (WINE_GLAPI *glGetTexEnvfv) (GLenum target, GLenum pname, GLfloat* params);
    933 void (WINE_GLAPI *glGetTexEnviv) (GLenum target, GLenum pname, GLint* params);
    934 void (WINE_GLAPI *glGetTexGendv) (GLenum coord, GLenum pname, GLdouble* params);
    935 void (WINE_GLAPI *glGetTexGenfv) (GLenum coord, GLenum pname, GLfloat* params);
    936 void (WINE_GLAPI *glGetTexGeniv) (GLenum coord, GLenum pname, GLint* params);
    937 void (WINE_GLAPI *glGetTexImage) (GLenum target, GLint level, GLenum format, GLenum type, GLvoid* pixels);
    938 void (WINE_GLAPI *glGetTexLevelParameterfv) (GLenum target, GLint level, GLenum pname, GLfloat* params);
    939 void (WINE_GLAPI *glGetTexLevelParameteriv) (GLenum target, GLint level, GLenum pname, GLint* params);
    940 void (WINE_GLAPI *glGetTexParameterfv) (GLenum target, GLenum pname, GLfloat* params);
    941 void (WINE_GLAPI *glGetTexParameteriv) (GLenum target, GLenum pname, GLint* params);
    942 void (WINE_GLAPI *glHint) (GLenum target, GLenum mode);
    943 void (WINE_GLAPI *glIndexMask) (GLuint mask);
    944 void (WINE_GLAPI *glIndexPointer) (GLenum type, GLsizei stride, const GLvoid* pointer);
    945 void (WINE_GLAPI *glIndexd) (GLdouble c);
    946 void (WINE_GLAPI *glIndexdv) (const GLdouble* c);
    947 void (WINE_GLAPI *glIndexf) (GLfloat c);
    948 void (WINE_GLAPI *glIndexfv) (const GLfloat* c);
    949 void (WINE_GLAPI *glIndexi) (GLint c);
    950 void (WINE_GLAPI *glIndexiv) (const GLint* c);
    951 void (WINE_GLAPI *glIndexs) (GLshort c);
    952 void (WINE_GLAPI *glIndexsv) (const GLshort* c);
    953 void (WINE_GLAPI *glIndexub) (GLubyte c);
    954 void (WINE_GLAPI *glIndexubv) (const GLubyte* c);
    955 void (WINE_GLAPI *glInitNames) ();
    956 void (WINE_GLAPI *glInterleavedArrays) (GLenum format, GLsizei stride, const GLvoid* pointer);
    957 GLboolean (WINE_GLAPI *glIsEnabled) (GLenum cap);
    958 GLboolean (WINE_GLAPI *glIsList) (GLuint list);
    959 GLboolean (WINE_GLAPI *glIsTexture) (GLuint texture);
    960 void (WINE_GLAPI *glLightModelf) (GLenum pname, GLfloat param);
    961 void (WINE_GLAPI *glLightModelfv) (GLenum pname, const GLfloat* params);
    962 void (WINE_GLAPI *glLightModeli) (GLenum pname, GLint param);
    963 void (WINE_GLAPI *glLightModeliv) (GLenum pname, const GLint* params);
    964 void (WINE_GLAPI *glLightf) (GLenum light, GLenum pname, GLfloat param);
    965 void (WINE_GLAPI *glLightfv) (GLenum light, GLenum pname, const GLfloat* params);
    966 void (WINE_GLAPI *glLighti) (GLenum light, GLenum pname, GLint param);
    967 void (WINE_GLAPI *glLightiv) (GLenum light, GLenum pname, const GLint* params);
    968 void (WINE_GLAPI *glLineStipple) (GLint factor, GLushort pattern);
    969 void (WINE_GLAPI *glLineWidth) (GLfloat width);
    970 void (WINE_GLAPI *glListBase) (GLuint base);
    971 void (WINE_GLAPI *glLoadIdentity) ();
    972 void (WINE_GLAPI *glLoadMatrixd) (const GLdouble* m);
    973 void (WINE_GLAPI *glLoadMatrixf) (const GLfloat* m);
    974 void (WINE_GLAPI *glLoadName) (GLuint name);
    975 void (WINE_GLAPI *glLogicOp) (GLenum opcode);
    976 void (WINE_GLAPI *glMap1d) (GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble* points);
    977 void (WINE_GLAPI *glMap1f) (GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat* points);
    978 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);
    979 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);
    980 void (WINE_GLAPI *glMapGrid1d) (GLint un, GLdouble u1, GLdouble u2);
    981 void (WINE_GLAPI *glMapGrid1f) (GLint un, GLfloat u1, GLfloat u2);
    982 void (WINE_GLAPI *glMapGrid2d) (GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
    983 void (WINE_GLAPI *glMapGrid2f) (GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
    984 void (WINE_GLAPI *glMaterialf) (GLenum face, GLenum pname, GLfloat param);
    985 void (WINE_GLAPI *glMaterialfv) (GLenum face, GLenum pname, const GLfloat* params);
    986 void (WINE_GLAPI *glMateriali) (GLenum face, GLenum pname, GLint param);
    987 void (WINE_GLAPI *glMaterialiv) (GLenum face, GLenum pname, const GLint* params);
    988 void (WINE_GLAPI *glMatrixMode) (GLenum mode);
    989 void (WINE_GLAPI *glMultMatrixd) (const GLdouble* m);
    990 void (WINE_GLAPI *glMultMatrixf) (const GLfloat* m);
    991 void (WINE_GLAPI *glNewList) (GLuint list, GLenum mode);
    992 void (WINE_GLAPI *glNormal3b) (GLbyte nx, GLbyte ny, GLbyte nz);
    993 void (WINE_GLAPI *glNormal3bv) (const GLbyte* v);
    994 void (WINE_GLAPI *glNormal3d) (GLdouble nx, GLdouble ny, GLdouble nz);
    995 void (WINE_GLAPI *glNormal3dv) (const GLdouble* v);
    996 void (WINE_GLAPI *glNormal3f) (GLfloat nx, GLfloat ny, GLfloat nz);
    997 void (WINE_GLAPI *glNormal3fv) (const GLfloat* v);
    998 void (WINE_GLAPI *glNormal3i) (GLint nx, GLint ny, GLint nz);
    999 void (WINE_GLAPI *glNormal3iv) (const GLint* v);
    1000 void (WINE_GLAPI *glNormal3s) (GLshort nx, GLshort ny, GLshort nz);
    1001 void (WINE_GLAPI *glNormal3sv) (const GLshort* v);
    1002 void (WINE_GLAPI *glNormalPointer) (GLenum type, GLsizei stride, const GLvoid* pointer);
    1003 void (WINE_GLAPI *glOrtho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
    1004 void (WINE_GLAPI *glPassThrough) (GLfloat token);
    1005 void (WINE_GLAPI *glPixelMapfv) (GLenum map, GLint mapsize, const GLfloat* values);
    1006 void (WINE_GLAPI *glPixelMapuiv) (GLenum map, GLint mapsize, const GLuint* values);
    1007 void (WINE_GLAPI *glPixelMapusv) (GLenum map, GLint mapsize, const GLushort* values);
    1008 void (WINE_GLAPI *glPixelStoref) (GLenum pname, GLfloat param);
    1009 void (WINE_GLAPI *glPixelStorei) (GLenum pname, GLint param);
    1010 void (WINE_GLAPI *glPixelTransferf) (GLenum pname, GLfloat param);
    1011 void (WINE_GLAPI *glPixelTransferi) (GLenum pname, GLint param);
    1012 void (WINE_GLAPI *glPixelZoom) (GLfloat xfactor, GLfloat yfactor);
    1013 void (WINE_GLAPI *glPointSize) (GLfloat size);
    1014 void (WINE_GLAPI *glPolygonMode) (GLenum face, GLenum mode);
    1015 void (WINE_GLAPI *glPolygonOffset) (GLfloat factor, GLfloat units);
    1016 void (WINE_GLAPI *glPolygonStipple) (const GLubyte* mask);
    1017 void (WINE_GLAPI *glPopAttrib) ();
    1018 void (WINE_GLAPI *glPopClientAttrib) ();
    1019 void (WINE_GLAPI *glPopMatrix) ();
    1020 void (WINE_GLAPI *glPopName) ();
    1021 void (WINE_GLAPI *glPrioritizeTextures) (GLsizei n, const GLuint* textures, const GLclampf* priorities);
    1022 void (WINE_GLAPI *glPushAttrib) (GLbitfield mask);
    1023 void (WINE_GLAPI *glPushClientAttrib) (GLbitfield mask);
    1024 void (WINE_GLAPI *glPushMatrix) ();
    1025 void (WINE_GLAPI *glPushName) (GLuint name);
    1026 void (WINE_GLAPI *glRasterPos2d) (GLdouble x, GLdouble y);
    1027 void (WINE_GLAPI *glRasterPos2dv) (const GLdouble* v);
    1028 void (WINE_GLAPI *glRasterPos2f) (GLfloat x, GLfloat y);
    1029 void (WINE_GLAPI *glRasterPos2fv) (const GLfloat* v);
    1030 void (WINE_GLAPI *glRasterPos2i) (GLint x, GLint y);
    1031 void (WINE_GLAPI *glRasterPos2iv) (const GLint* v);
    1032 void (WINE_GLAPI *glRasterPos2s) (GLshort x, GLshort y);
    1033 void (WINE_GLAPI *glRasterPos2sv) (const GLshort* v);
    1034 void (WINE_GLAPI *glRasterPos3d) (GLdouble x, GLdouble y, GLdouble z);
    1035 void (WINE_GLAPI *glRasterPos3dv) (const GLdouble* v);
    1036 void (WINE_GLAPI *glRasterPos3f) (GLfloat x, GLfloat y, GLfloat z);
    1037 void (WINE_GLAPI *glRasterPos3fv) (const GLfloat* v);
    1038 void (WINE_GLAPI *glRasterPos3i) (GLint x, GLint y, GLint z);
    1039 void (WINE_GLAPI *glRasterPos3iv) (const GLint* v);
    1040 void (WINE_GLAPI *glRasterPos3s) (GLshort x, GLshort y, GLshort z);
    1041 void (WINE_GLAPI *glRasterPos3sv) (const GLshort* v);
    1042 void (WINE_GLAPI *glRasterPos4d) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
    1043 void (WINE_GLAPI *glRasterPos4dv) (const GLdouble* v);
    1044 void (WINE_GLAPI *glRasterPos4f) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    1045 void (WINE_GLAPI *glRasterPos4fv) (const GLfloat* v);
    1046 void (WINE_GLAPI *glRasterPos4i) (GLint x, GLint y, GLint z, GLint w);
    1047 void (WINE_GLAPI *glRasterPos4iv) (const GLint* v);
    1048 void (WINE_GLAPI *glRasterPos4s) (GLshort x, GLshort y, GLshort z, GLshort w);
    1049 void (WINE_GLAPI *glRasterPos4sv) (const GLshort* v);
    1050 void (WINE_GLAPI *glReadBuffer) (GLenum mode);
    1051 void (WINE_GLAPI *glReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
    1052 void (WINE_GLAPI *glRectd) (GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
    1053 void (WINE_GLAPI *glRectdv) (const GLdouble* v1, const GLdouble* v2);
    1054 void (WINE_GLAPI *glRectf) (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
    1055 void (WINE_GLAPI *glRectfv) (const GLfloat* v1, const GLfloat* v2);
    1056 void (WINE_GLAPI *glRecti) (GLint x1, GLint y1, GLint x2, GLint y2);
    1057 void (WINE_GLAPI *glRectiv) (const GLint* v1, const GLint* v2);
    1058 void (WINE_GLAPI *glRects) (GLshort x1, GLshort y1, GLshort x2, GLshort y2);
    1059 void (WINE_GLAPI *glRectsv) (const GLshort* v1, const GLshort* v2);
    1060 GLint (WINE_GLAPI *glRenderMode) (GLenum mode);
    1061 void (WINE_GLAPI *glRotated) (GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
    1062 void (WINE_GLAPI *glRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
    1063 void (WINE_GLAPI *glScaled) (GLdouble x, GLdouble y, GLdouble z);
    1064 void (WINE_GLAPI *glScalef) (GLfloat x, GLfloat y, GLfloat z);
    1065 void (WINE_GLAPI *glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
    1066 void (WINE_GLAPI *glSelectBuffer) (GLsizei size, GLuint* buffer);
    1067 void (WINE_GLAPI *glShadeModel) (GLenum mode);
    1068 void (WINE_GLAPI *glStencilFunc) (GLenum func, GLint ref, GLuint mask);
    1069 void (WINE_GLAPI *glStencilMask) (GLuint mask);
    1070 void (WINE_GLAPI *glStencilOp) (GLenum fail, GLenum zfail, GLenum zpass);
    1071 void (WINE_GLAPI *glTexCoord1d) (GLdouble s);
    1072 void (WINE_GLAPI *glTexCoord1dv) (const GLdouble* v);
    1073 void (WINE_GLAPI *glTexCoord1f) (GLfloat s);
    1074 void (WINE_GLAPI *glTexCoord1fv) (const GLfloat* v);
    1075 void (WINE_GLAPI *glTexCoord1i) (GLint s);
    1076 void (WINE_GLAPI *glTexCoord1iv) (const GLint* v);
    1077 void (WINE_GLAPI *glTexCoord1s) (GLshort s);
    1078 void (WINE_GLAPI *glTexCoord1sv) (const GLshort* v);
    1079 void (WINE_GLAPI *glTexCoord2d) (GLdouble s, GLdouble t);
    1080 void (WINE_GLAPI *glTexCoord2dv) (const GLdouble* v);
    1081 void (WINE_GLAPI *glTexCoord2f) (GLfloat s, GLfloat t);
    1082 void (WINE_GLAPI *glTexCoord2fv) (const GLfloat* v);
    1083 void (WINE_GLAPI *glTexCoord2i) (GLint s, GLint t);
    1084 void (WINE_GLAPI *glTexCoord2iv) (const GLint* v);
    1085 void (WINE_GLAPI *glTexCoord2s) (GLshort s, GLshort t);
    1086 void (WINE_GLAPI *glTexCoord2sv) (const GLshort* v);
    1087 void (WINE_GLAPI *glTexCoord3d) (GLdouble s, GLdouble t, GLdouble r);
    1088 void (WINE_GLAPI *glTexCoord3dv) (const GLdouble* v);
    1089 void (WINE_GLAPI *glTexCoord3f) (GLfloat s, GLfloat t, GLfloat r);
    1090 void (WINE_GLAPI *glTexCoord3fv) (const GLfloat* v);
    1091 void (WINE_GLAPI *glTexCoord3i) (GLint s, GLint t, GLint r);
    1092 void (WINE_GLAPI *glTexCoord3iv) (const GLint* v);
    1093 void (WINE_GLAPI *glTexCoord3s) (GLshort s, GLshort t, GLshort r);
    1094 void (WINE_GLAPI *glTexCoord3sv) (const GLshort* v);
    1095 void (WINE_GLAPI *glTexCoord4d) (GLdouble s, GLdouble t, GLdouble r, GLdouble q);
    1096 void (WINE_GLAPI *glTexCoord4dv) (const GLdouble* v);
    1097 void (WINE_GLAPI *glTexCoord4f) (GLfloat s, GLfloat t, GLfloat r, GLfloat q);
    1098 void (WINE_GLAPI *glTexCoord4fv) (const GLfloat* v);
    1099 void (WINE_GLAPI *glTexCoord4i) (GLint s, GLint t, GLint r, GLint q);
    1100 void (WINE_GLAPI *glTexCoord4iv) (const GLint* v);
    1101 void (WINE_GLAPI *glTexCoord4s) (GLshort s, GLshort t, GLshort r, GLshort q);
    1102 void (WINE_GLAPI *glTexCoord4sv) (const GLshort* v);
    1103 void (WINE_GLAPI *glTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
    1104 void (WINE_GLAPI *glTexEnvf) (GLenum target, GLenum pname, GLfloat param);
    1105 void (WINE_GLAPI *glTexEnvfv) (GLenum target, GLenum pname, const GLfloat* params);
    1106 void (WINE_GLAPI *glTexEnvi) (GLenum target, GLenum pname, GLint param);
    1107 void (WINE_GLAPI *glTexEnviv) (GLenum target, GLenum pname, const GLint* params);
    1108 void (WINE_GLAPI *glTexGend) (GLenum coord, GLenum pname, GLdouble param);
    1109 void (WINE_GLAPI *glTexGendv) (GLenum coord, GLenum pname, const GLdouble* params);
    1110 void (WINE_GLAPI *glTexGenf) (GLenum coord, GLenum pname, GLfloat param);
    1111 void (WINE_GLAPI *glTexGenfv) (GLenum coord, GLenum pname, const GLfloat* params);
    1112 void (WINE_GLAPI *glTexGeni) (GLenum coord, GLenum pname, GLint param);
    1113 void (WINE_GLAPI *glTexGeniv) (GLenum coord, GLenum pname, const GLint* params);
    1114 void (WINE_GLAPI *glTexImage1D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
    1115 void (WINE_GLAPI *glTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
    1116 void (WINE_GLAPI *glTexParameterf) (GLenum target, GLenum pname, GLfloat param);
    1117 void (WINE_GLAPI *glTexParameterfv) (GLenum target, GLenum pname, const GLfloat* params);
    1118 void (WINE_GLAPI *glTexParameteri) (GLenum target, GLenum pname, GLint param);
    1119 void (WINE_GLAPI *glTexParameteriv) (GLenum target, GLenum pname, const GLint* params);
    1120 void (WINE_GLAPI *glTexSubImage1D) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid* pixels);
    1121 void (WINE_GLAPI *glTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
    1122 void (WINE_GLAPI *glTranslated) (GLdouble x, GLdouble y, GLdouble z);
    1123 void (WINE_GLAPI *glTranslatef) (GLfloat x, GLfloat y, GLfloat z);
    1124 void (WINE_GLAPI *glVertex2d) (GLdouble x, GLdouble y);
    1125 void (WINE_GLAPI *glVertex2dv) (const GLdouble* v);
    1126 void (WINE_GLAPI *glVertex2f) (GLfloat x, GLfloat y);
    1127 void (WINE_GLAPI *glVertex2fv) (const GLfloat* v);
    1128 void (WINE_GLAPI *glVertex2i) (GLint x, GLint y);
    1129 void (WINE_GLAPI *glVertex2iv) (const GLint* v);
    1130 void (WINE_GLAPI *glVertex2s) (GLshort x, GLshort y);
    1131 void (WINE_GLAPI *glVertex2sv) (const GLshort* v);
    1132 void (WINE_GLAPI *glVertex3d) (GLdouble x, GLdouble y, GLdouble z);
    1133 void (WINE_GLAPI *glVertex3dv) (const GLdouble* v);
    1134 void (WINE_GLAPI *glVertex3f) (GLfloat x, GLfloat y, GLfloat z);
    1135 void (WINE_GLAPI *glVertex3fv) (const GLfloat* v);
    1136 void (WINE_GLAPI *glVertex3i) (GLint x, GLint y, GLint z);
    1137 void (WINE_GLAPI *glVertex3iv) (const GLint* v);
    1138 void (WINE_GLAPI *glVertex3s) (GLshort x, GLshort y, GLshort z);
    1139 void (WINE_GLAPI *glVertex3sv) (const GLshort* v);
    1140 void (WINE_GLAPI *glVertex4d) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
    1141 void (WINE_GLAPI *glVertex4dv) (const GLdouble* v);
    1142 void (WINE_GLAPI *glVertex4f) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
    1143 void (WINE_GLAPI *glVertex4fv) (const GLfloat* v);
    1144 void (WINE_GLAPI *glVertex4i) (GLint x, GLint y, GLint z, GLint w);
    1145 void (WINE_GLAPI *glVertex4iv) (const GLint* v);
    1146 void (WINE_GLAPI *glVertex4s) (GLshort x, GLshort y, GLshort z, GLshort w);
    1147 void (WINE_GLAPI *glVertex4sv) (const GLshort* v);
    1148 void (WINE_GLAPI *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid* pointer);
    1149 void (WINE_GLAPI *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
    1150 void (WINE_GLAPI *glPointParameterfv) (GLenum pname, const GLfloat *params);
     814void (WINE_GLAPI *glAccum)(GLenum op, GLfloat value) DECLSPEC_HIDDEN;
     815void (WINE_GLAPI *glAlphaFunc)(GLenum func, GLclampf ref) DECLSPEC_HIDDEN;
     816GLboolean (WINE_GLAPI *glAreTexturesResident)(GLsizei n, const GLuint *textures, GLboolean *residences) DECLSPEC_HIDDEN;
     817void (WINE_GLAPI *glArrayElement)(GLint i) DECLSPEC_HIDDEN;
     818void (WINE_GLAPI *glBegin)(GLenum mode) DECLSPEC_HIDDEN;
     819void (WINE_GLAPI *glBindTexture)(GLenum target, GLuint texture) DECLSPEC_HIDDEN;
     820void (WINE_GLAPI *glBitmap)(GLsizei width, GLsizei height, GLfloat xorig,
     821        GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bitmap) DECLSPEC_HIDDEN;
     822void (WINE_GLAPI *glBlendFunc)(GLenum sfactor, GLenum dfactor) DECLSPEC_HIDDEN;
     823void (WINE_GLAPI *glCallList)(GLuint list) DECLSPEC_HIDDEN;
     824void (WINE_GLAPI *glCallLists)(GLsizei n, GLenum type, const GLvoid *lists) DECLSPEC_HIDDEN;
     825void (WINE_GLAPI *glClear)(GLbitfield mask) DECLSPEC_HIDDEN;
     826void (WINE_GLAPI *glClearAccum)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DECLSPEC_HIDDEN;
     827void (WINE_GLAPI *glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) DECLSPEC_HIDDEN;
     828void (WINE_GLAPI *glClearDepth)(GLclampd depth) DECLSPEC_HIDDEN;
     829void (WINE_GLAPI *glClearIndex)(GLfloat c) DECLSPEC_HIDDEN;
     830void (WINE_GLAPI *glClearStencil)(GLint s) DECLSPEC_HIDDEN;
     831void (WINE_GLAPI *glClipPlane)(GLenum plane, const GLdouble *equation) DECLSPEC_HIDDEN;
     832void (WINE_GLAPI *glColor3b)(GLbyte red, GLbyte green, GLbyte blue) DECLSPEC_HIDDEN;
     833void (WINE_GLAPI *glColor3bv)(const GLbyte *v) DECLSPEC_HIDDEN;
     834void (WINE_GLAPI *glColor3d)(GLdouble red, GLdouble green, GLdouble blue) DECLSPEC_HIDDEN;
     835void (WINE_GLAPI *glColor3dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     836void (WINE_GLAPI *glColor3f)(GLfloat red, GLfloat green, GLfloat blue) DECLSPEC_HIDDEN;
     837void (WINE_GLAPI *glColor3fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     838void (WINE_GLAPI *glColor3i)(GLint red, GLint green, GLint blue) DECLSPEC_HIDDEN;
     839void (WINE_GLAPI *glColor3iv)(const GLint *v) DECLSPEC_HIDDEN;
     840void (WINE_GLAPI *glColor3s)(GLshort red, GLshort green, GLshort blue) DECLSPEC_HIDDEN;
     841void (WINE_GLAPI *glColor3sv)(const GLshort *v) DECLSPEC_HIDDEN;
     842void (WINE_GLAPI *glColor3ub)(GLubyte red, GLubyte green, GLubyte blue) DECLSPEC_HIDDEN;
     843void (WINE_GLAPI *glColor3ubv)(const GLubyte *v) DECLSPEC_HIDDEN;
     844void (WINE_GLAPI *glColor3ui)(GLuint red, GLuint green, GLuint blue) DECLSPEC_HIDDEN;
     845void (WINE_GLAPI *glColor3uiv)(const GLuint *v) DECLSPEC_HIDDEN;
     846void (WINE_GLAPI *glColor3us)(GLushort red, GLushort green, GLushort blue) DECLSPEC_HIDDEN;
     847void (WINE_GLAPI *glColor3usv)(const GLushort *v) DECLSPEC_HIDDEN;
     848void (WINE_GLAPI *glColor4b)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) DECLSPEC_HIDDEN;
     849void (WINE_GLAPI *glColor4bv)(const GLbyte *v) DECLSPEC_HIDDEN;
     850void (WINE_GLAPI *glColor4d)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) DECLSPEC_HIDDEN;
     851void (WINE_GLAPI *glColor4dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     852void (WINE_GLAPI *glColor4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) DECLSPEC_HIDDEN;
     853void (WINE_GLAPI *glColor4fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     854void (WINE_GLAPI *glColor4i)(GLint red, GLint green, GLint blue, GLint alpha) DECLSPEC_HIDDEN;
     855void (WINE_GLAPI *glColor4iv)(const GLint *v) DECLSPEC_HIDDEN;
     856void (WINE_GLAPI *glColor4s)(GLshort red, GLshort green, GLshort blue, GLshort alpha) DECLSPEC_HIDDEN;
     857void (WINE_GLAPI *glColor4sv)(const GLshort *v) DECLSPEC_HIDDEN;
     858void (WINE_GLAPI *glColor4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) DECLSPEC_HIDDEN;
     859void (WINE_GLAPI *glColor4ubv)(const GLubyte *v) DECLSPEC_HIDDEN;
     860void (WINE_GLAPI *glColor4ui)(GLuint red, GLuint green, GLuint blue, GLuint alpha) DECLSPEC_HIDDEN;
     861void (WINE_GLAPI *glColor4uiv)(const GLuint *v) DECLSPEC_HIDDEN;
     862void (WINE_GLAPI *glColor4us)(GLushort red, GLushort green, GLushort blue, GLushort alpha) DECLSPEC_HIDDEN;
     863void (WINE_GLAPI *glColor4usv)(const GLushort *v) DECLSPEC_HIDDEN;
     864void (WINE_GLAPI *glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) DECLSPEC_HIDDEN;
     865void (WINE_GLAPI *glColorMaterial)(GLenum face, GLenum mode) DECLSPEC_HIDDEN;
     866void (WINE_GLAPI *glColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) DECLSPEC_HIDDEN;
     867void (WINE_GLAPI *glCopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type) DECLSPEC_HIDDEN;
     868void (WINE_GLAPI *glCopyTexImage1D)(GLenum target, GLint level,
     869        GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) DECLSPEC_HIDDEN;
     870void (WINE_GLAPI *glCopyTexImage2D)(GLenum target, GLint level,
     871        GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) DECLSPEC_HIDDEN;
     872void (WINE_GLAPI *glCopyTexSubImage1D)(GLenum target, GLint level,
     873        GLint xoffset, GLint x, GLint y, GLsizei width) DECLSPEC_HIDDEN;
     874void (WINE_GLAPI *glCopyTexSubImage2D)(GLenum target, GLint level,
     875        GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) DECLSPEC_HIDDEN;
     876void (WINE_GLAPI *glCullFace)(GLenum mode) DECLSPEC_HIDDEN;
     877void (WINE_GLAPI *glDeleteLists)(GLuint list, GLsizei range) DECLSPEC_HIDDEN;
     878void (WINE_GLAPI *glDeleteTextures)(GLsizei n, const GLuint *textures) DECLSPEC_HIDDEN;
     879void (WINE_GLAPI *glDepthFunc)(GLenum func) DECLSPEC_HIDDEN;
     880void (WINE_GLAPI *glDepthMask)(GLboolean flag) DECLSPEC_HIDDEN;
     881void (WINE_GLAPI *glDepthRange)(GLclampd nearParam, GLclampd farParam) DECLSPEC_HIDDEN;
     882void (WINE_GLAPI *glDisable)(GLenum cap) DECLSPEC_HIDDEN;
     883void (WINE_GLAPI *glDisableWINE)(GLenum cap) DECLSPEC_HIDDEN;
     884void (WINE_GLAPI *glDisableClientState)(GLenum array) DECLSPEC_HIDDEN;
     885void (WINE_GLAPI *glDrawArrays)(GLenum mode, GLint first, GLsizei count) DECLSPEC_HIDDEN;
     886void (WINE_GLAPI *glDrawBuffer)(GLenum mode) DECLSPEC_HIDDEN;
     887void (WINE_GLAPI *glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) DECLSPEC_HIDDEN;
     888void (WINE_GLAPI *glDrawPixels)(GLsizei width, GLsizei height, GLenum format,
     889        GLenum type, const GLvoid *pixels) DECLSPEC_HIDDEN;
     890void (WINE_GLAPI *glEdgeFlag)(GLboolean flag) DECLSPEC_HIDDEN;
     891void (WINE_GLAPI *glEdgeFlagPointer)(GLsizei stride, const GLvoid *pointer) DECLSPEC_HIDDEN;
     892void (WINE_GLAPI *glEdgeFlagv)(const GLboolean *flag) DECLSPEC_HIDDEN;
     893void (WINE_GLAPI *glEnable)(GLenum cap) DECLSPEC_HIDDEN;
     894void (WINE_GLAPI *glEnableWINE)(GLenum cap) DECLSPEC_HIDDEN;
     895void (WINE_GLAPI *glEnableClientState)(GLenum array) DECLSPEC_HIDDEN;
     896void (WINE_GLAPI *glEnd)(void) DECLSPEC_HIDDEN;
     897void (WINE_GLAPI *glEndList)(void) DECLSPEC_HIDDEN;
     898void (WINE_GLAPI *glEvalCoord1d)(GLdouble u) DECLSPEC_HIDDEN;
     899void (WINE_GLAPI *glEvalCoord1dv)(const GLdouble *u) DECLSPEC_HIDDEN;
     900void (WINE_GLAPI *glEvalCoord1f)(GLfloat u) DECLSPEC_HIDDEN;
     901void (WINE_GLAPI *glEvalCoord1fv)(const GLfloat *u) DECLSPEC_HIDDEN;
     902void (WINE_GLAPI *glEvalCoord2d)(GLdouble u, GLdouble v) DECLSPEC_HIDDEN;
     903void (WINE_GLAPI *glEvalCoord2dv)(const GLdouble *u) DECLSPEC_HIDDEN;
     904void (WINE_GLAPI *glEvalCoord2f)(GLfloat u, GLfloat v) DECLSPEC_HIDDEN;
     905void (WINE_GLAPI *glEvalCoord2fv)(const GLfloat *u) DECLSPEC_HIDDEN;
     906void (WINE_GLAPI *glEvalMesh1)(GLenum mode, GLint i1, GLint i2) DECLSPEC_HIDDEN;
     907void (WINE_GLAPI *glEvalMesh2)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) DECLSPEC_HIDDEN;
     908void (WINE_GLAPI *glEvalPoint1)(GLint i) DECLSPEC_HIDDEN;
     909void (WINE_GLAPI *glEvalPoint2)(GLint i, GLint j) DECLSPEC_HIDDEN;
     910void (WINE_GLAPI *glFeedbackBuffer)(GLsizei size, GLenum type, GLfloat *buffer) DECLSPEC_HIDDEN;
     911void (WINE_GLAPI *glFogf)(GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     912void (WINE_GLAPI *glFogfv)(GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
     913void (WINE_GLAPI *glFogi)(GLenum pname, GLint param) DECLSPEC_HIDDEN;
     914void (WINE_GLAPI *glFogiv)(GLenum pname, const GLint *params) DECLSPEC_HIDDEN;
     915void (WINE_GLAPI *glFrontFace)(GLenum mode) DECLSPEC_HIDDEN;
     916void (WINE_GLAPI *glFrustum)(GLdouble left, GLdouble right, GLdouble bottom,
     917        GLdouble top, GLdouble zNear, GLdouble zFar) DECLSPEC_HIDDEN;
     918GLuint (WINE_GLAPI *glGenLists)(GLsizei range) DECLSPEC_HIDDEN;
     919void (WINE_GLAPI *glGenTextures)(GLsizei n, GLuint *textures) DECLSPEC_HIDDEN;
     920void (WINE_GLAPI *glGetBooleanv)(GLenum pname, GLboolean *params) DECLSPEC_HIDDEN;
     921void (WINE_GLAPI *glGetClipPlane)(GLenum plane, GLdouble *equation) DECLSPEC_HIDDEN;
     922void (WINE_GLAPI *glGetDoublev)(GLenum pname, GLdouble *params) DECLSPEC_HIDDEN;
     923GLenum (WINE_GLAPI *glGetError)(void) DECLSPEC_HIDDEN;
     924void (WINE_GLAPI *glGetFloatv)(GLenum pname, GLfloat *params) DECLSPEC_HIDDEN;
     925void (WINE_GLAPI *glGetIntegerv)(GLenum pname, GLint *params) DECLSPEC_HIDDEN;
     926void (WINE_GLAPI *glGetLightfv)(GLenum light, GLenum pname, GLfloat *params) DECLSPEC_HIDDEN;
     927void (WINE_GLAPI *glGetLightiv)(GLenum light, GLenum pname, GLint *params) DECLSPEC_HIDDEN;
     928void (WINE_GLAPI *glGetMapdv)(GLenum target, GLenum query, GLdouble *v) DECLSPEC_HIDDEN;
     929void (WINE_GLAPI *glGetMapfv)(GLenum target, GLenum query, GLfloat *v) DECLSPEC_HIDDEN;
     930void (WINE_GLAPI *glGetMapiv)(GLenum target, GLenum query, GLint *v) DECLSPEC_HIDDEN;
     931void (WINE_GLAPI *glGetMaterialfv)(GLenum face, GLenum pname, GLfloat *params) DECLSPEC_HIDDEN;
     932void (WINE_GLAPI *glGetMaterialiv)(GLenum face, GLenum pname, GLint *params) DECLSPEC_HIDDEN;
     933void (WINE_GLAPI *glGetPixelMapfv)(GLenum map, GLfloat *values) DECLSPEC_HIDDEN;
     934void (WINE_GLAPI *glGetPixelMapuiv)(GLenum map, GLuint *values) DECLSPEC_HIDDEN;
     935void (WINE_GLAPI *glGetPixelMapusv)(GLenum map, GLushort *values) DECLSPEC_HIDDEN;
     936void (WINE_GLAPI *glGetPointerv)(GLenum pname, GLvoid **params) DECLSPEC_HIDDEN;
     937void (WINE_GLAPI *glGetPolygonStipple)(GLubyte *mask) DECLSPEC_HIDDEN;
     938const GLubyte * (WINE_GLAPI *glGetString)(GLenum name) DECLSPEC_HIDDEN;
     939void (WINE_GLAPI *glGetTexEnvfv)(GLenum target, GLenum pname, GLfloat *params) DECLSPEC_HIDDEN;
     940void (WINE_GLAPI *glGetTexEnviv)(GLenum target, GLenum pname, GLint *params) DECLSPEC_HIDDEN;
     941void (WINE_GLAPI *glGetTexGendv)(GLenum coord, GLenum pname, GLdouble *params) DECLSPEC_HIDDEN;
     942void (WINE_GLAPI *glGetTexGenfv)(GLenum coord, GLenum pname, GLfloat *params) DECLSPEC_HIDDEN;
     943void (WINE_GLAPI *glGetTexGeniv)(GLenum coord, GLenum pname, GLint *params) DECLSPEC_HIDDEN;
     944void (WINE_GLAPI *glGetTexImage)(GLenum target, GLint level, GLenum format,
     945        GLenum type, GLvoid *pixels) DECLSPEC_HIDDEN;
     946void (WINE_GLAPI *glGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat *params) DECLSPEC_HIDDEN;
     947void (WINE_GLAPI *glGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint *params) DECLSPEC_HIDDEN;
     948void (WINE_GLAPI *glGetTexParameterfv)(GLenum target, GLenum pname, GLfloat *params) DECLSPEC_HIDDEN;
     949void (WINE_GLAPI *glGetTexParameteriv)(GLenum target, GLenum pname, GLint *params) DECLSPEC_HIDDEN;
     950void (WINE_GLAPI *glHint)(GLenum target, GLenum mode) DECLSPEC_HIDDEN;
     951void (WINE_GLAPI *glIndexMask)(GLuint mask) DECLSPEC_HIDDEN;
     952void (WINE_GLAPI *glIndexPointer)(GLenum type, GLsizei stride, const GLvoid *pointer) DECLSPEC_HIDDEN;
     953void (WINE_GLAPI *glIndexd)(GLdouble c) DECLSPEC_HIDDEN;
     954void (WINE_GLAPI *glIndexdv)(const GLdouble *c) DECLSPEC_HIDDEN;
     955void (WINE_GLAPI *glIndexf)(GLfloat c) DECLSPEC_HIDDEN;
     956void (WINE_GLAPI *glIndexfv)(const GLfloat *c) DECLSPEC_HIDDEN;
     957void (WINE_GLAPI *glIndexi)(GLint c) DECLSPEC_HIDDEN;
     958void (WINE_GLAPI *glIndexiv)(const GLint *c) DECLSPEC_HIDDEN;
     959void (WINE_GLAPI *glIndexs)(GLshort c) DECLSPEC_HIDDEN;
     960void (WINE_GLAPI *glIndexsv)(const GLshort *c) DECLSPEC_HIDDEN;
     961void (WINE_GLAPI *glIndexub)(GLubyte c) DECLSPEC_HIDDEN;
     962void (WINE_GLAPI *glIndexubv)(const GLubyte *c) DECLSPEC_HIDDEN;
     963void (WINE_GLAPI *glInitNames)(void) DECLSPEC_HIDDEN;
     964void (WINE_GLAPI *glInterleavedArrays)(GLenum format, GLsizei stride, const GLvoid *pointer) DECLSPEC_HIDDEN;
     965GLboolean (WINE_GLAPI *glIsEnabled)(GLenum cap) DECLSPEC_HIDDEN;
     966GLboolean (WINE_GLAPI *glIsList)(GLuint list) DECLSPEC_HIDDEN;
     967GLboolean (WINE_GLAPI *glIsTexture)(GLuint texture) DECLSPEC_HIDDEN;
     968void (WINE_GLAPI *glLightModelf)(GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     969void (WINE_GLAPI *glLightModelfv)(GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
     970void (WINE_GLAPI *glLightModeli)(GLenum pname, GLint param) DECLSPEC_HIDDEN;
     971void (WINE_GLAPI *glLightModeliv)(GLenum pname, const GLint *params) DECLSPEC_HIDDEN;
     972void (WINE_GLAPI *glLightf)(GLenum light, GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     973void (WINE_GLAPI *glLightfv)(GLenum light, GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
     974void (WINE_GLAPI *glLighti)(GLenum light, GLenum pname, GLint param) DECLSPEC_HIDDEN;
     975void (WINE_GLAPI *glLightiv)(GLenum light, GLenum pname, const GLint *params) DECLSPEC_HIDDEN;
     976void (WINE_GLAPI *glLineStipple)(GLint factor, GLushort pattern) DECLSPEC_HIDDEN;
     977void (WINE_GLAPI *glLineWidth)(GLfloat width) DECLSPEC_HIDDEN;
     978void (WINE_GLAPI *glListBase)(GLuint base) DECLSPEC_HIDDEN;
     979void (WINE_GLAPI *glLoadIdentity)(void) DECLSPEC_HIDDEN;
     980void (WINE_GLAPI *glLoadMatrixd)(const GLdouble *m) DECLSPEC_HIDDEN;
     981void (WINE_GLAPI *glLoadMatrixf)(const GLfloat *m) DECLSPEC_HIDDEN;
     982void (WINE_GLAPI *glLoadName)(GLuint name) DECLSPEC_HIDDEN;
     983void (WINE_GLAPI *glLogicOp)(GLenum opcode) DECLSPEC_HIDDEN;
     984void (WINE_GLAPI *glMap1d)(GLenum target, GLdouble u1, GLdouble u2,
     985        GLint stride, GLint order, const GLdouble *points) DECLSPEC_HIDDEN;
     986void (WINE_GLAPI *glMap1f)(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
     987        GLint order, const GLfloat *points) DECLSPEC_HIDDEN;
     988void (WINE_GLAPI *glMap2d)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
     989        GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points) DECLSPEC_HIDDEN;
     990void (WINE_GLAPI *glMap2f)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
     991        GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points) DECLSPEC_HIDDEN;
     992void (WINE_GLAPI *glMapGrid1d)(GLint un, GLdouble u1, GLdouble u2) DECLSPEC_HIDDEN;
     993void (WINE_GLAPI *glMapGrid1f)(GLint un, GLfloat u1, GLfloat u2) DECLSPEC_HIDDEN;
     994void (WINE_GLAPI *glMapGrid2d)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2) DECLSPEC_HIDDEN;
     995void (WINE_GLAPI *glMapGrid2f)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2) DECLSPEC_HIDDEN;
     996void (WINE_GLAPI *glMaterialf)(GLenum face, GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     997void (WINE_GLAPI *glMaterialfv)(GLenum face, GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
     998void (WINE_GLAPI *glMateriali)(GLenum face, GLenum pname, GLint param) DECLSPEC_HIDDEN;
     999void (WINE_GLAPI *glMaterialiv)(GLenum face, GLenum pname, const GLint *params) DECLSPEC_HIDDEN;
     1000void (WINE_GLAPI *glMatrixMode)(GLenum mode) DECLSPEC_HIDDEN;
     1001void (WINE_GLAPI *glMultMatrixd)(const GLdouble *m) DECLSPEC_HIDDEN;
     1002void (WINE_GLAPI *glMultMatrixf)(const GLfloat *m) DECLSPEC_HIDDEN;
     1003void (WINE_GLAPI *glNewList)(GLuint list, GLenum mode) DECLSPEC_HIDDEN;
     1004void (WINE_GLAPI *glNormal3b)(GLbyte nx, GLbyte ny, GLbyte nz) DECLSPEC_HIDDEN;
     1005void (WINE_GLAPI *glNormal3bv)(const GLbyte *v) DECLSPEC_HIDDEN;
     1006void (WINE_GLAPI *glNormal3d)(GLdouble nx, GLdouble ny, GLdouble nz) DECLSPEC_HIDDEN;
     1007void (WINE_GLAPI *glNormal3dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1008void (WINE_GLAPI *glNormal3f)(GLfloat nx, GLfloat ny, GLfloat nz) DECLSPEC_HIDDEN;
     1009void (WINE_GLAPI *glNormal3fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1010void (WINE_GLAPI *glNormal3i)(GLint nx, GLint ny, GLint nz) DECLSPEC_HIDDEN;
     1011void (WINE_GLAPI *glNormal3iv)(const GLint *v) DECLSPEC_HIDDEN;
     1012void (WINE_GLAPI *glNormal3s)(GLshort nx, GLshort ny, GLshort nz) DECLSPEC_HIDDEN;
     1013void (WINE_GLAPI *glNormal3sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1014void (WINE_GLAPI *glNormalPointer)(GLenum type, GLsizei stride, const GLvoid *pointer) DECLSPEC_HIDDEN;
     1015void (WINE_GLAPI *glOrtho)(GLdouble left, GLdouble right, GLdouble bottom,
     1016        GLdouble top, GLdouble zNear, GLdouble zFar) DECLSPEC_HIDDEN;
     1017void (WINE_GLAPI *glPassThrough)(GLfloat token) DECLSPEC_HIDDEN;
     1018void (WINE_GLAPI *glPixelMapfv)(GLenum map, GLint mapsize, const GLfloat *values) DECLSPEC_HIDDEN;
     1019void (WINE_GLAPI *glPixelMapuiv)(GLenum map, GLint mapsize, const GLuint *values) DECLSPEC_HIDDEN;
     1020void (WINE_GLAPI *glPixelMapusv)(GLenum map, GLint mapsize, const GLushort *values) DECLSPEC_HIDDEN;
     1021void (WINE_GLAPI *glPixelStoref)(GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     1022void (WINE_GLAPI *glPixelStorei)(GLenum pname, GLint param) DECLSPEC_HIDDEN;
     1023void (WINE_GLAPI *glPixelTransferf)(GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     1024void (WINE_GLAPI *glPixelTransferi)(GLenum pname, GLint param) DECLSPEC_HIDDEN;
     1025void (WINE_GLAPI *glPixelZoom)(GLfloat xfactor, GLfloat yfactor) DECLSPEC_HIDDEN;
     1026void (WINE_GLAPI *glPointSize)(GLfloat size) DECLSPEC_HIDDEN;
     1027void (WINE_GLAPI *glPolygonMode)(GLenum face, GLenum mode) DECLSPEC_HIDDEN;
     1028void (WINE_GLAPI *glPolygonOffset)(GLfloat factor, GLfloat units) DECLSPEC_HIDDEN;
     1029void (WINE_GLAPI *glPolygonStipple)(const GLubyte *mask) DECLSPEC_HIDDEN;
     1030void (WINE_GLAPI *glPopAttrib)(void) DECLSPEC_HIDDEN;
     1031void (WINE_GLAPI *glPopClientAttrib)(void) DECLSPEC_HIDDEN;
     1032void (WINE_GLAPI *glPopMatrix)(void) DECLSPEC_HIDDEN;
     1033void (WINE_GLAPI *glPopName)(void) DECLSPEC_HIDDEN;
     1034void (WINE_GLAPI *glPrioritizeTextures)(GLsizei n, const GLuint *textures, const GLclampf *priorities) DECLSPEC_HIDDEN;
     1035void (WINE_GLAPI *glPushAttrib)(GLbitfield mask) DECLSPEC_HIDDEN;
     1036void (WINE_GLAPI *glPushClientAttrib)(GLbitfield mask) DECLSPEC_HIDDEN;
     1037void (WINE_GLAPI *glPushMatrix)(void) DECLSPEC_HIDDEN;
     1038void (WINE_GLAPI *glPushName)(GLuint name) DECLSPEC_HIDDEN;
     1039void (WINE_GLAPI *glRasterPos2d)(GLdouble x, GLdouble y) DECLSPEC_HIDDEN;
     1040void (WINE_GLAPI *glRasterPos2dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1041void (WINE_GLAPI *glRasterPos2f)(GLfloat x, GLfloat y) DECLSPEC_HIDDEN;
     1042void (WINE_GLAPI *glRasterPos2fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1043void (WINE_GLAPI *glRasterPos2i)(GLint x, GLint y) DECLSPEC_HIDDEN;
     1044void (WINE_GLAPI *glRasterPos2iv)(const GLint *v) DECLSPEC_HIDDEN;
     1045void (WINE_GLAPI *glRasterPos2s)(GLshort x, GLshort y) DECLSPEC_HIDDEN;
     1046void (WINE_GLAPI *glRasterPos2sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1047void (WINE_GLAPI *glRasterPos3d)(GLdouble x, GLdouble y, GLdouble z) DECLSPEC_HIDDEN;
     1048void (WINE_GLAPI *glRasterPos3dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1049void (WINE_GLAPI *glRasterPos3f)(GLfloat x, GLfloat y, GLfloat z) DECLSPEC_HIDDEN;
     1050void (WINE_GLAPI *glRasterPos3fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1051void (WINE_GLAPI *glRasterPos3i)(GLint x, GLint y, GLint z) DECLSPEC_HIDDEN;
     1052void (WINE_GLAPI *glRasterPos3iv)(const GLint *v) DECLSPEC_HIDDEN;
     1053void (WINE_GLAPI *glRasterPos3s)(GLshort x, GLshort y, GLshort z) DECLSPEC_HIDDEN;
     1054void (WINE_GLAPI *glRasterPos3sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1055void (WINE_GLAPI *glRasterPos4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w) DECLSPEC_HIDDEN;
     1056void (WINE_GLAPI *glRasterPos4dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1057void (WINE_GLAPI *glRasterPos4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) DECLSPEC_HIDDEN;
     1058void (WINE_GLAPI *glRasterPos4fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1059void (WINE_GLAPI *glRasterPos4i)(GLint x, GLint y, GLint z, GLint w) DECLSPEC_HIDDEN;
     1060void (WINE_GLAPI *glRasterPos4iv)(const GLint *v) DECLSPEC_HIDDEN;
     1061void (WINE_GLAPI *glRasterPos4s)(GLshort x, GLshort y, GLshort z, GLshort w) DECLSPEC_HIDDEN;
     1062void (WINE_GLAPI *glRasterPos4sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1063void (WINE_GLAPI *glReadBuffer)(GLenum mode) DECLSPEC_HIDDEN;
     1064void (WINE_GLAPI *glReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height,
     1065        GLenum format, GLenum type, GLvoid *pixels) DECLSPEC_HIDDEN;
     1066void (WINE_GLAPI *glRectd)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2) DECLSPEC_HIDDEN;
     1067void (WINE_GLAPI *glRectdv)(const GLdouble *v1, const GLdouble *v2) DECLSPEC_HIDDEN;
     1068void (WINE_GLAPI *glRectf)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) DECLSPEC_HIDDEN;
     1069void (WINE_GLAPI *glRectfv)(const GLfloat *v1, const GLfloat *v2) DECLSPEC_HIDDEN;
     1070void (WINE_GLAPI *glRecti)(GLint x1, GLint y1, GLint x2, GLint y2) DECLSPEC_HIDDEN;
     1071void (WINE_GLAPI *glRectiv)(const GLint *v1, const GLint *v2) DECLSPEC_HIDDEN;
     1072void (WINE_GLAPI *glRects)(GLshort x1, GLshort y1, GLshort x2, GLshort y2) DECLSPEC_HIDDEN;
     1073void (WINE_GLAPI *glRectsv)(const GLshort *v1, const GLshort *v2) DECLSPEC_HIDDEN;
     1074GLint (WINE_GLAPI *glRenderMode)(GLenum mode) DECLSPEC_HIDDEN;
     1075void (WINE_GLAPI *glRotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z) DECLSPEC_HIDDEN;
     1076void (WINE_GLAPI *glRotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) DECLSPEC_HIDDEN;
     1077void (WINE_GLAPI *glScaled)(GLdouble x, GLdouble y, GLdouble z) DECLSPEC_HIDDEN;
     1078void (WINE_GLAPI *glScalef)(GLfloat x, GLfloat y, GLfloat z) DECLSPEC_HIDDEN;
     1079void (WINE_GLAPI *glScissor)(GLint x, GLint y, GLsizei width, GLsizei height) DECLSPEC_HIDDEN;
     1080void (WINE_GLAPI *glSelectBuffer)(GLsizei size, GLuint *buffer) DECLSPEC_HIDDEN;
     1081void (WINE_GLAPI *glShadeModel)(GLenum mode) DECLSPEC_HIDDEN;
     1082void (WINE_GLAPI *glStencilFunc)(GLenum func, GLint ref, GLuint mask) DECLSPEC_HIDDEN;
     1083void (WINE_GLAPI *glStencilMask)(GLuint mask) DECLSPEC_HIDDEN;
     1084void (WINE_GLAPI *glStencilOp)(GLenum fail, GLenum zfail, GLenum zpass) DECLSPEC_HIDDEN;
     1085void (WINE_GLAPI *glTexCoord1d)(GLdouble s) DECLSPEC_HIDDEN;
     1086void (WINE_GLAPI *glTexCoord1dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1087void (WINE_GLAPI *glTexCoord1f)(GLfloat s) DECLSPEC_HIDDEN;
     1088void (WINE_GLAPI *glTexCoord1fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1089void (WINE_GLAPI *glTexCoord1i)(GLint s) DECLSPEC_HIDDEN;
     1090void (WINE_GLAPI *glTexCoord1iv)(const GLint *v) DECLSPEC_HIDDEN;
     1091void (WINE_GLAPI *glTexCoord1s)(GLshort s) DECLSPEC_HIDDEN;
     1092void (WINE_GLAPI *glTexCoord1sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1093void (WINE_GLAPI *glTexCoord2d)(GLdouble s, GLdouble t) DECLSPEC_HIDDEN;
     1094void (WINE_GLAPI *glTexCoord2dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1095void (WINE_GLAPI *glTexCoord2f)(GLfloat s, GLfloat t) DECLSPEC_HIDDEN;
     1096void (WINE_GLAPI *glTexCoord2fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1097void (WINE_GLAPI *glTexCoord2i)(GLint s, GLint t) DECLSPEC_HIDDEN;
     1098void (WINE_GLAPI *glTexCoord2iv)(const GLint *v) DECLSPEC_HIDDEN;
     1099void (WINE_GLAPI *glTexCoord2s)(GLshort s, GLshort t) DECLSPEC_HIDDEN;
     1100void (WINE_GLAPI *glTexCoord2sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1101void (WINE_GLAPI *glTexCoord3d)(GLdouble s, GLdouble t, GLdouble r) DECLSPEC_HIDDEN;
     1102void (WINE_GLAPI *glTexCoord3dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1103void (WINE_GLAPI *glTexCoord3f)(GLfloat s, GLfloat t, GLfloat r) DECLSPEC_HIDDEN;
     1104void (WINE_GLAPI *glTexCoord3fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1105void (WINE_GLAPI *glTexCoord3i)(GLint s, GLint t, GLint r) DECLSPEC_HIDDEN;
     1106void (WINE_GLAPI *glTexCoord3iv)(const GLint *v) DECLSPEC_HIDDEN;
     1107void (WINE_GLAPI *glTexCoord3s)(GLshort s, GLshort t, GLshort r) DECLSPEC_HIDDEN;
     1108void (WINE_GLAPI *glTexCoord3sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1109void (WINE_GLAPI *glTexCoord4d)(GLdouble s, GLdouble t, GLdouble r, GLdouble q) DECLSPEC_HIDDEN;
     1110void (WINE_GLAPI *glTexCoord4dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1111void (WINE_GLAPI *glTexCoord4f)(GLfloat s, GLfloat t, GLfloat r, GLfloat q) DECLSPEC_HIDDEN;
     1112void (WINE_GLAPI *glTexCoord4fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1113void (WINE_GLAPI *glTexCoord4i)(GLint s, GLint t, GLint r, GLint q) DECLSPEC_HIDDEN;
     1114void (WINE_GLAPI *glTexCoord4iv)(const GLint *v) DECLSPEC_HIDDEN;
     1115void (WINE_GLAPI *glTexCoord4s)(GLshort s, GLshort t, GLshort r, GLshort q) DECLSPEC_HIDDEN;
     1116void (WINE_GLAPI *glTexCoord4sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1117void (WINE_GLAPI *glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) DECLSPEC_HIDDEN;
     1118void (WINE_GLAPI *glTexEnvf)(GLenum target, GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     1119void (WINE_GLAPI *glTexEnvfv)(GLenum target, GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
     1120void (WINE_GLAPI *glTexEnvi)(GLenum target, GLenum pname, GLint param) DECLSPEC_HIDDEN;
     1121void (WINE_GLAPI *glTexEnviv)(GLenum target, GLenum pname, const GLint *params) DECLSPEC_HIDDEN;
     1122void (WINE_GLAPI *glTexGend)(GLenum coord, GLenum pname, GLdouble param) DECLSPEC_HIDDEN;
     1123void (WINE_GLAPI *glTexGendv)(GLenum coord, GLenum pname, const GLdouble *params) DECLSPEC_HIDDEN;
     1124void (WINE_GLAPI *glTexGenf)(GLenum coord, GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     1125void (WINE_GLAPI *glTexGenfv)(GLenum coord, GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
     1126void (WINE_GLAPI *glTexGeni)(GLenum coord, GLenum pname, GLint param) DECLSPEC_HIDDEN;
     1127void (WINE_GLAPI *glTexGeniv)(GLenum coord, GLenum pname, const GLint *params) DECLSPEC_HIDDEN;
     1128void (WINE_GLAPI *glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width,
     1129        GLint border, GLenum format, GLenum type, const GLvoid *pixels) DECLSPEC_HIDDEN;
     1130void (WINE_GLAPI *glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width,
     1131        GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) DECLSPEC_HIDDEN;
     1132void (WINE_GLAPI *glTexParameterf)(GLenum target, GLenum pname, GLfloat param) DECLSPEC_HIDDEN;
     1133void (WINE_GLAPI *glTexParameterfv)(GLenum target, GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
     1134void (WINE_GLAPI *glTexParameteri)(GLenum target, GLenum pname, GLint param) DECLSPEC_HIDDEN;
     1135void (WINE_GLAPI *glTexParameteriv)(GLenum target, GLenum pname, const GLint *params) DECLSPEC_HIDDEN;
     1136void (WINE_GLAPI *glTexSubImage1D)(GLenum target, GLint level, GLint xoffset,
     1137        GLsizei width, GLenum format, GLenum type, const GLvoid *pixels) DECLSPEC_HIDDEN;
     1138void (WINE_GLAPI *glTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset,
     1139        GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) DECLSPEC_HIDDEN;
     1140void (WINE_GLAPI *glTranslated)(GLdouble x, GLdouble y, GLdouble z) DECLSPEC_HIDDEN;
     1141void (WINE_GLAPI *glTranslatef)(GLfloat x, GLfloat y, GLfloat z) DECLSPEC_HIDDEN;
     1142void (WINE_GLAPI *glVertex2d)(GLdouble x, GLdouble y) DECLSPEC_HIDDEN;
     1143void (WINE_GLAPI *glVertex2dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1144void (WINE_GLAPI *glVertex2f)(GLfloat x, GLfloat y) DECLSPEC_HIDDEN;
     1145void (WINE_GLAPI *glVertex2fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1146void (WINE_GLAPI *glVertex2i)(GLint x, GLint y) DECLSPEC_HIDDEN;
     1147void (WINE_GLAPI *glVertex2iv)(const GLint *v) DECLSPEC_HIDDEN;
     1148void (WINE_GLAPI *glVertex2s)(GLshort x, GLshort y) DECLSPEC_HIDDEN;
     1149void (WINE_GLAPI *glVertex2sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1150void (WINE_GLAPI *glVertex3d)(GLdouble x, GLdouble y, GLdouble z) DECLSPEC_HIDDEN;
     1151void (WINE_GLAPI *glVertex3dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1152void (WINE_GLAPI *glVertex3f)(GLfloat x, GLfloat y, GLfloat z) DECLSPEC_HIDDEN;
     1153void (WINE_GLAPI *glVertex3fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1154void (WINE_GLAPI *glVertex3i)(GLint x, GLint y, GLint z) DECLSPEC_HIDDEN;
     1155void (WINE_GLAPI *glVertex3iv)(const GLint *v) DECLSPEC_HIDDEN;
     1156void (WINE_GLAPI *glVertex3s)(GLshort x, GLshort y, GLshort z) DECLSPEC_HIDDEN;
     1157void (WINE_GLAPI *glVertex3sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1158void (WINE_GLAPI *glVertex4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w) DECLSPEC_HIDDEN;
     1159void (WINE_GLAPI *glVertex4dv)(const GLdouble *v) DECLSPEC_HIDDEN;
     1160void (WINE_GLAPI *glVertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w) DECLSPEC_HIDDEN;
     1161void (WINE_GLAPI *glVertex4fv)(const GLfloat *v) DECLSPEC_HIDDEN;
     1162void (WINE_GLAPI *glVertex4i)(GLint x, GLint y, GLint z, GLint w) DECLSPEC_HIDDEN;
     1163void (WINE_GLAPI *glVertex4iv)(const GLint *v) DECLSPEC_HIDDEN;
     1164void (WINE_GLAPI *glVertex4s)(GLshort x, GLshort y, GLshort z, GLshort w) DECLSPEC_HIDDEN;
     1165void (WINE_GLAPI *glVertex4sv)(const GLshort *v) DECLSPEC_HIDDEN;
     1166void (WINE_GLAPI *glVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) DECLSPEC_HIDDEN;
     1167void (WINE_GLAPI *glViewport)(GLint x, GLint y, GLsizei width, GLsizei height) DECLSPEC_HIDDEN;
     1168void (WINE_GLAPI *glPointParameterfv)(GLenum pname, const GLfloat *params) DECLSPEC_HIDDEN;
    11511169
    11521170/* glFinish and glFlush are always loaded from opengl32.dll, thus they always have
    1153  * __stdcall calling convention
     1171 * __stdcall calling convention.
     1172 *
     1173 * They are wgl functions and must not be called inside the gl lock, give them a
     1174 * name that makes this clear
    11541175 */
    1155 void (__stdcall  *glFinish) ();
    1156 void (__stdcall  *glFlush) ();
     1176void (__stdcall *wglFinish)(void) DECLSPEC_HIDDEN;
     1177void (__stdcall *wglFlush)(void) DECLSPEC_HIDDEN;
    11571178
    11581179/* WGL functions */
    1159 HGLRC   (WINAPI *pwglCreateContext)(HDC);
    1160 BOOL    (WINAPI *pwglDeleteContext)(HGLRC);
    1161 HGLRC   (WINAPI *pwglGetCurrentContext)(void);
    1162 HDC     (WINAPI *pwglGetCurrentDC)(void);
    1163 PROC    (WINAPI *pwglGetProcAddress)(LPCSTR);
    1164 BOOL    (WINAPI *pwglMakeCurrent)(HDC,HGLRC);
    1165 BOOL    (WINAPI *pwglShareLists)(HGLRC,HGLRC);
     1180HGLRC (WINAPI *pwglCreateContext)(HDC) DECLSPEC_HIDDEN;
     1181BOOL (WINAPI *pwglDeleteContext)(HGLRC) DECLSPEC_HIDDEN;
     1182HGLRC (WINAPI *pwglGetCurrentContext)(void) DECLSPEC_HIDDEN;
     1183HDC (WINAPI *pwglGetCurrentDC)(void) DECLSPEC_HIDDEN;
     1184PROC (WINAPI *pwglGetProcAddress)(LPCSTR) DECLSPEC_HIDDEN;
     1185BOOL (WINAPI *pwglMakeCurrent)(HDC, HGLRC) DECLSPEC_HIDDEN;
     1186BOOL (WINAPI *pwglShareLists)(HGLRC, HGLRC) DECLSPEC_HIDDEN;
    11661187
    11671188#define GL_FUNCS_GEN \
     
    15351556#endif
    15361557
     1558/* GL_ARB_depth_clamp */
     1559#ifndef GL_ARB_depth_clamp
     1560#define GL_ARB_depth_clamp 1
     1561#define GL_DEPTH_CLAMP                    0x864f
     1562#endif
     1563
    15371564/* GL_ARB_depth_texture */
    15381565#ifndef GL_ARB_depth_texture
     
    15671594#endif
    15681595typedef void (WINE_GLAPI *PGLFNDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
     1596
     1597/* GL_ARB_framebuffer_object */
     1598#ifndef GL_ARB_framebuffer_object
     1599#define GL_ARB_framebuffer_object 1
     1600#define GL_FRAMEBUFFER                                      0x8d40
     1601#define GL_READ_FRAMEBUFFER                                 0x8ca8
     1602#define GL_DRAW_FRAMEBUFFER                                 0x8ca9
     1603#define GL_RENDERBUFFER                                     0x8d41
     1604#define GL_STENCIL_INDEX1                                   0x8d46
     1605#define GL_STENCIL_INDEX4                                   0x8d47
     1606#define GL_STENCIL_INDEX8                                   0x8d48
     1607#define GL_STENCIL_INDEX16                                  0x8d49
     1608#define GL_RENDERBUFFER_WIDTH                               0x8d42
     1609#define GL_RENDERBUFFER_HEIGHT                              0x8d43
     1610#define GL_RENDERBUFFER_INTERNAL_FORMAT                     0x8d44
     1611#define GL_RENDERBUFFER_RED_SIZE                            0x8d50
     1612#define GL_RENDERBUFFER_GREEN_SIZE                          0x8d51
     1613#define GL_RENDERBUFFER_BLUE_SIZE                           0x8d52
     1614#define GL_RENDERBUFFER_ALPHA_SIZE                          0x8d53
     1615#define GL_RENDERBUFFER_DEPTH_SIZE                          0x8d54
     1616#define GL_RENDERBUFFER_STENCIL_SIZE                        0x8d55
     1617#define GL_RENDERBUFFER_SAMPLES                             0x8cab
     1618#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE               0x8cd0
     1619#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME               0x8cd1
     1620#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL             0x8cd2
     1621#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE     0x8cd3
     1622#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER             0x8cd4
     1623#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING            0x8210
     1624#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE            0x8211
     1625#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE                  0x8212
     1626#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE                0x8213
     1627#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE                 0x8214
     1628#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE                0x8215
     1629#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE                0x8216
     1630#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE              0x8217
     1631#define GL_SRGB                                             0x8c40
     1632#define GL_UNSIGNED_NORMALIZED                              0x8c17
     1633#define GL_FRAMEBUFFER_DEFAULT                              0x8218
     1634#define GL_INDEX                                            0x8222
     1635#define GL_COLOR_ATTACHMENT0                                0x8ce0
     1636#define GL_COLOR_ATTACHMENT1                                0x8ce1
     1637#define GL_COLOR_ATTACHMENT2                                0x8ce2
     1638#define GL_COLOR_ATTACHMENT3                                0x8ce3
     1639#define GL_COLOR_ATTACHMENT4                                0x8ce4
     1640#define GL_COLOR_ATTACHMENT5                                0x8ce5
     1641#define GL_COLOR_ATTACHMENT6                                0x8ce6
     1642#define GL_COLOR_ATTACHMENT7                                0x8ce7
     1643#define GL_COLOR_ATTACHMENT8                                0x8ce8
     1644#define GL_COLOR_ATTACHMENT9                                0x8ce9
     1645#define GL_COLOR_ATTACHMENT10                               0x8cea
     1646#define GL_COLOR_ATTACHMENT11                               0x8ceb
     1647#define GL_COLOR_ATTACHMENT12                               0x8cec
     1648#define GL_COLOR_ATTACHMENT13                               0x8ced
     1649#define GL_COLOR_ATTACHMENT14                               0x8cee
     1650#define GL_COLOR_ATTACHMENT15                               0x8cef
     1651#define GL_DEPTH_ATTACHMENT                                 0x8d00
     1652#define GL_STENCIL_ATTACHMENT                               0x8d20
     1653#define GL_DEPTH_STENCIL_ATTACHMENT                         0x821a
     1654#define GL_MAX_SAMPLES                                      0x8d57
     1655#define GL_FRAMEBUFFER_COMPLETE                             0x8cd5
     1656#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT                0x8cd6
     1657#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT        0x8cd7
     1658#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER               0x8cdb
     1659#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER               0x8cdc
     1660#define GL_FRAMEBUFFER_UNSUPPORTED                          0x8cdd
     1661#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE               0x8d56
     1662#define GL_FRAMEBUFFER_UNDEFINED                            0x8219
     1663#define GL_FRAMEBUFFER_BINDING                              0x8ca6
     1664#define GL_DRAW_FRAMEBUFFER_BINDING                         0x8ca6
     1665#define GL_READ_FRAMEBUFFER_BINDING                         0x8caa
     1666#define GL_RENDERBUFFER_BINDING                             0x8ca7
     1667#define GL_MAX_COLOR_ATTACHMENTS                            0x8cdf
     1668#define GL_MAX_RENDERBUFFER_SIZE                            0x84e8
     1669#define GL_INVALID_FRAMEBUFFER_OPERATION                    0x0506
     1670#define GL_DEPTH_STENCIL                                    0x84f9
     1671#define GL_UNSIGNED_INT_24_8                                0x84fa
     1672#define GL_DEPTH24_STENCIL8                                 0x88f0
     1673#define GL_TEXTURE_STENCIL_SIZE                             0x88f1
     1674#endif
     1675typedef GLboolean (WINE_GLAPI * PGLFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
     1676typedef void (WINE_GLAPI * PGLFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
     1677typedef void (WINE_GLAPI * PGLFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers);
     1678typedef void (WINE_GLAPI * PGLFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers);
     1679typedef void (WINE_GLAPI * PGLFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat,
     1680        GLsizei width, GLsizei height);
     1681typedef void (WINE_GLAPI * PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples,
     1682        GLenum internalformat, GLsizei width, GLsizei height);
     1683typedef void (WINE_GLAPI * PGLFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params);
     1684typedef GLboolean (WINE_GLAPI * PGLFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
     1685typedef void (WINE_GLAPI * PGLFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
     1686typedef void (WINE_GLAPI * PGLFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers);
     1687typedef void (WINE_GLAPI * PGLFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers);
     1688typedef GLenum (WINE_GLAPI * PGLFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
     1689typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment,
     1690        GLenum textarget, GLuint texture, GLint level);
     1691typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment,
     1692        GLenum textarget, GLuint texture, GLint level);
     1693typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment,
     1694        GLenum textarget, GLuint texture, GLint level, GLint layer);
     1695typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment,
     1696        GLuint texture, GLint level, GLint layer);
     1697typedef void (WINE_GLAPI * PGLFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment,
     1698        GLenum renderbuffertarget, GLuint renderbuffer);
     1699typedef void (WINE_GLAPI * PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment,
     1700        GLenum pname, GLint *params);
     1701typedef void (WINE_GLAPI * PGLFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
     1702        GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
     1703typedef void (WINE_GLAPI * PGLFNGLGENERATEMIPMAPPROC)(GLenum target);
    15691704
    15701705/* GL_ARB_geometry_shader4 */
     
    17591894typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
    17601895typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
     1896
     1897/* GL_ARB_provoking_vertex */
     1898#ifndef GL_ARB_provoking_vertex
     1899#define GL_ARB_provoking_vertex 1
     1900#define GL_FIRST_VERTEX_CONVENTION                      0x8e4d
     1901#define GL_LAST_VERTEX_CONVENTION                       0x8e4e
     1902#define GL_PROVOKING_VERTEX                             0x8e4f
     1903#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION     0x8e4c
     1904#endif
     1905typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXPROC)(GLenum mode);
     1906
    17611907/* GL_ARB_vertex_blend */
    17621908#ifndef GL_ARB_vertex_blend
     
    19622108typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
    19632109typedef void (WINE_GLAPI * PGLFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
     2110
     2111/* GL_EXT_provoking_vertex */
     2112#ifndef GL_EXT_provoking_vertex
     2113#define GL_EXT_provoking_vertex 1
     2114#define GL_FIRST_VERTEX_CONVENTION_EXT                      0x8e4d
     2115#define GL_LAST_VERTEX_CONVENTION_EXT                       0x8e4e
     2116#define GL_PROVOKING_VERTEX_EXT                             0x8e4f
     2117#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT     0x8e4c
     2118#endif
     2119typedef void (WINE_GLAPI * PGLFNGLPROVOKINGVERTEXEXTPROC)(GLenum mode);
     2120
    19642121/* GL_EXT_texture3D */
    19652122#ifndef GL_EXT_texture3D
     
    30213178typedef void (WINE_GLAPI *PGLFNBINDFRAGMENTSHADERATI) (GLuint id);
    30223179typedef void (WINE_GLAPI *PGLFNDELETEFRAGMENTSHADERATI) (GLuint id);
    3023 typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI) ();
    3024 typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI) ();
     3180typedef void (WINE_GLAPI *PGLFNBEGINFRAGMENTSHADERATI) (void);
     3181typedef void (WINE_GLAPI *PGLFNENDFRAGMENTSHADERATI) (void);
    30253182typedef void (WINE_GLAPI *PGLFNPASSTEXCOORDATI) (GLuint dst, GLuint coord, GLenum swizzle);
    30263183typedef void (WINE_GLAPI *PGLFNSAMPLEMAPATI) (GLuint dst, GLuint interp, GLenum swizzle);
     
    33933550#define WINE_DEFAULT_VIDMEM 64*1024*1024
    33943551
    3395 typedef enum _GL_VSVersion {
    3396   VS_VERSION_NOT_SUPPORTED = 0x0,
    3397   VS_VERSION_10 = 0x10,
    3398   VS_VERSION_11 = 0x11,
    3399   VS_VERSION_20 = 0x20,
    3400   VS_VERSION_30 = 0x30,
    3401   /*Force 32-bits*/
    3402   VS_VERSION_FORCE_DWORD = 0x7FFFFFFF
    3403 } GL_VSVersion;
    3404 
    3405 typedef enum _GL_PSVersion {
    3406   PS_VERSION_NOT_SUPPORTED = 0x0,
    3407   PS_VERSION_10 = 0x10,
    3408   PS_VERSION_11 = 0x11,
    3409   PS_VERSION_12 = 0x12,
    3410   PS_VERSION_13 = 0x13,
    3411   PS_VERSION_14 = 0x14,
    3412   PS_VERSION_20 = 0x20,
    3413   PS_VERSION_30 = 0x30,
    3414   /*Force 32-bits*/
    3415   PS_VERSION_FORCE_DWORD = 0x7FFFFFFF
    3416 } GL_PSVersion;
    3417 
    34183552#define MAKEDWORD_VERSION(maj, min)  ((maj & 0x0000FFFF) << 16) | (min & 0x0000FFFF)
    34193553
     
    34243558  ARB_COLOR_BUFFER_FLOAT,
    34253559  ARB_DEPTH_BUFFER_FLOAT,
     3560  ARB_DEPTH_CLAMP,
    34263561  ARB_DEPTH_TEXTURE,
    34273562  ARB_DRAW_BUFFERS,
    34283563  ARB_FRAGMENT_PROGRAM,
    34293564  ARB_FRAGMENT_SHADER,
     3565  ARB_FRAMEBUFFER_OBJECT,
    34303566  ARB_GEOMETRY_SHADER4,
    34313567  ARB_IMAGING,
     
    34343570  ARB_OCCLUSION_QUERY,
    34353571  ARB_POINT_PARAMETERS,
     3572  ARB_PROVOKING_VERTEX,
    34363573  ARB_PIXEL_BUFFER_OBJECT,
    34373574  ARB_POINT_SPRITE,
     
    34683605  EXT_PIXEL_BUFFER_OBJECT,
    34693606  EXT_POINT_PARAMETERS,
     3607  EXT_PROVOKING_VERTEX,
    34703608  EXT_SECONDARY_COLOR,
    34713609  EXT_STENCIL_TWO_SIDE,
     
    35443682    /* GL_ARB_draw_buffers */ \
    35453683    USE_GL_FUNC(PGLFNDRAWBUFFERSARBPROC,                            glDrawBuffersARB,                           ARB_DRAW_BUFFERS,       NULL )\
     3684    /* GL_ARB_framebuffer_object */ \
     3685    USE_GL_FUNC(PGLFNGLISRENDERBUFFERPROC,                          glIsRenderbuffer,                           ARB_FRAMEBUFFER_OBJECT, NULL )\
     3686    USE_GL_FUNC(PGLFNGLBINDRENDERBUFFERPROC,                        glBindRenderbuffer,                         ARB_FRAMEBUFFER_OBJECT, NULL )\
     3687    USE_GL_FUNC(PGLFNGLDELETERENDERBUFFERSPROC,                     glDeleteRenderbuffers,                      ARB_FRAMEBUFFER_OBJECT, NULL )\
     3688    USE_GL_FUNC(PGLFNGLGENRENDERBUFFERSPROC,                        glGenRenderbuffers,                         ARB_FRAMEBUFFER_OBJECT, NULL )\
     3689    USE_GL_FUNC(PGLFNGLRENDERBUFFERSTORAGEPROC,                     glRenderbufferStorage,                      ARB_FRAMEBUFFER_OBJECT, NULL )\
     3690    USE_GL_FUNC(PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC,            glRenderbufferStorageMultisample,           ARB_FRAMEBUFFER_OBJECT, NULL )\
     3691    USE_GL_FUNC(PGLFNGLGETRENDERBUFFERPARAMETERIVPROC,              glGetRenderbufferParameteriv,               ARB_FRAMEBUFFER_OBJECT, NULL )\
     3692    USE_GL_FUNC(PGLFNGLISFRAMEBUFFERPROC,                           glIsFramebuffer,                            ARB_FRAMEBUFFER_OBJECT, NULL )\
     3693    USE_GL_FUNC(PGLFNGLBINDFRAMEBUFFERPROC,                         glBindFramebuffer,                          ARB_FRAMEBUFFER_OBJECT, NULL )\
     3694    USE_GL_FUNC(PGLFNGLDELETEFRAMEBUFFERSPROC,                      glDeleteFramebuffers,                       ARB_FRAMEBUFFER_OBJECT, NULL )\
     3695    USE_GL_FUNC(PGLFNGLGENFRAMEBUFFERSPROC,                         glGenFramebuffers,                          ARB_FRAMEBUFFER_OBJECT, NULL )\
     3696    USE_GL_FUNC(PGLFNGLCHECKFRAMEBUFFERSTATUSPROC,                  glCheckFramebufferStatus,                   ARB_FRAMEBUFFER_OBJECT, NULL )\
     3697    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE1DPROC,                    glFramebufferTexture1D,                     ARB_FRAMEBUFFER_OBJECT, NULL )\
     3698    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE2DPROC,                    glFramebufferTexture2D,                     ARB_FRAMEBUFFER_OBJECT, NULL )\
     3699    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURE3DPROC,                    glFramebufferTexture3D,                     ARB_FRAMEBUFFER_OBJECT, NULL )\
     3700    USE_GL_FUNC(PGLFNGLFRAMEBUFFERTEXTURELAYERPROC,                 glFramebufferTextureLayer,                  ARB_FRAMEBUFFER_OBJECT, NULL )\
     3701    USE_GL_FUNC(PGLFNGLFRAMEBUFFERRENDERBUFFERPROC,                 glFramebufferRenderbuffer,                  ARB_FRAMEBUFFER_OBJECT, NULL )\
     3702    USE_GL_FUNC(PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC,     glGetFramebufferAttachmentParameteriv,      ARB_FRAMEBUFFER_OBJECT, NULL )\
     3703    USE_GL_FUNC(PGLFNGLBLITFRAMEBUFFERPROC,                         glBlitFramebuffer,                          ARB_FRAMEBUFFER_OBJECT, NULL )\
     3704    USE_GL_FUNC(PGLFNGLGENERATEMIPMAPPROC,                          glGenerateMipmap,                           ARB_FRAMEBUFFER_OBJECT, NULL )\
    35463705    /* GL_ARB_geometry_shader4 */ \
    35473706    USE_GL_FUNC(PGLFNPROGRAMPARAMETERIARBPROC,                      glProgramParameteriARB,                     ARB_GEOMETRY_SHADER4,   NULL ) \
     
    35773736    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFARBPROC,                      glPointParameterfARB,                       ARB_POINT_PARAMETERS,   NULL )\
    35783737    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVARBPROC,                     glPointParameterfvARB,                      ARB_POINT_PARAMETERS,   NULL )\
     3738    /* GL_ARB_provoking_vertex */ \
     3739    USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXPROC,                         glProvokingVertex,                          ARB_PROVOKING_VERTEX,   NULL)\
    35793740    /* GL_ARB_texture_compression */ \
    35803741    USE_GL_FUNC(PGLFNCOMPRESSEDTEXIMAGE2DPROC,                      glCompressedTexImage2DARB,                  ARB_TEXTURE_COMPRESSION,NULL )\
     
    36443805    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFEXTPROC,                      glPointParameterfEXT,                       EXT_POINT_PARAMETERS,   NULL )\
    36453806    USE_GL_FUNC(PGLFNGLPOINTPARAMETERFVEXTPROC,                     glPointParameterfvEXT,                      EXT_POINT_PARAMETERS,   NULL )\
     3807    /* GL_EXT_provoking_vertex */ \
     3808    USE_GL_FUNC(PGLFNGLPROVOKINGVERTEXEXTPROC,                      glProvokingVertexEXT,                       EXT_PROVOKING_VERTEX,   NULL)\
    36463809    /* GL_EXT_secondary_color */ \
    36473810    USE_GL_FUNC(PGLFNGLSECONDARYCOLOR3UBEXTPROC,                    glSecondaryColor3ubEXT,                     EXT_SECONDARY_COLOR,    NULL )\
     
    39584121 ****************************************************/
    39594122
     4123struct wined3d_fbo_ops
     4124{
     4125    PGLFNGLISRENDERBUFFERPROC                       glIsRenderbuffer;
     4126    PGLFNGLBINDRENDERBUFFERPROC                     glBindRenderbuffer;
     4127    PGLFNGLDELETERENDERBUFFERSPROC                  glDeleteRenderbuffers;
     4128    PGLFNGLGENRENDERBUFFERSPROC                     glGenRenderbuffers;
     4129    PGLFNGLRENDERBUFFERSTORAGEPROC                  glRenderbufferStorage;
     4130    PGLFNRENDERBUFFERSTORAGEMULTISAMPLEPROC         glRenderbufferStorageMultisample;
     4131    PGLFNGLGETRENDERBUFFERPARAMETERIVPROC           glGetRenderbufferParameteriv;
     4132    PGLFNGLISFRAMEBUFFERPROC                        glIsFramebuffer;
     4133    PGLFNGLBINDFRAMEBUFFERPROC                      glBindFramebuffer;
     4134    PGLFNGLDELETEFRAMEBUFFERSPROC                   glDeleteFramebuffers;
     4135    PGLFNGLGENFRAMEBUFFERSPROC                      glGenFramebuffers;
     4136    PGLFNGLCHECKFRAMEBUFFERSTATUSPROC               glCheckFramebufferStatus;
     4137    PGLFNGLFRAMEBUFFERTEXTURE1DPROC                 glFramebufferTexture1D;
     4138    PGLFNGLFRAMEBUFFERTEXTURE2DPROC                 glFramebufferTexture2D;
     4139    PGLFNGLFRAMEBUFFERTEXTURE3DPROC                 glFramebufferTexture3D;
     4140    PGLFNGLFRAMEBUFFERRENDERBUFFERPROC              glFramebufferRenderbuffer;
     4141    PGLFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC  glGetFramebufferAttachmentParameteriv;
     4142    PGLFNGLBLITFRAMEBUFFERPROC                      glBlitFramebuffer;
     4143    PGLFNGLGENERATEMIPMAPPROC                       glGenerateMipmap;
     4144};
     4145
    39604146#define USE_GL_FUNC(type, pfn, ext, replace) type pfn;
    39614147
     
    40004186    unsigned int ps_glsl_constantsF;
    40014187
    4002     GL_PSVersion ps_arb_version;
    4003     GL_PSVersion ps_nv_version;
    4004 
    4005     GL_VSVersion vs_arb_version;
    4006     GL_VSVersion vs_nv_version;
    4007     GL_VSVersion vs_ati_version;
    4008 
    40094188    DWORD reserved_glsl_constants;
    40104189
     
    40134192    BOOL supported[WINED3D_GL_EXT_COUNT];
    40144193
     4194    struct wined3d_fbo_ops fbo_ops;
    40154195    /* GL function pointers */
    40164196    GL_EXT_FUNCS_GEN
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_main.c

    r22496 r23571  
    66 * Copyright 2004      Jason Edmeades
    77 * Copyright 2007-2008 Stefan Dösinger for CodeWeavers
     8 * Copyright 2009 Henri Verbeet for CodeWeavers
    89 *
    910 * This library is free software; you can redistribute it and/or
     
    4243void (*CDECL wine_tsx11_unlock_ptr)(void) = NULL;
    4344
     45static CRITICAL_SECTION wined3d_cs;
     46static CRITICAL_SECTION_DEBUG wined3d_cs_debug =
     47{
     48    0, 0, &wined3d_cs,
     49    {&wined3d_cs_debug.ProcessLocksList,
     50    &wined3d_cs_debug.ProcessLocksList},
     51    0, 0, {(DWORD_PTR)(__FILE__ ": wined3d_cs")}
     52};
     53static CRITICAL_SECTION wined3d_cs = {&wined3d_cs_debug, -1, 0, 0, 0, 0};
    4454
    4555/* When updating default value here, make sure to update winecfg as well,
    4656 * where appropriate. */
    47 wined3d_settings_t wined3d_settings = 
     57wined3d_settings_t wined3d_settings =
    4858{
    4959    VS_HW,          /* Hardware by default */
    5060    PS_HW,          /* Hardware by default */
    51     VBO_HW,         /* Hardware by default */
    5261    TRUE,           /* Use of GLSL enabled by default */
    5362    ORM_FBO,        /* Use FBOs to do offscreen rendering */
    54     RTL_AUTO,       /* Automatically determine best locking method */
     63    RTL_READTEX,    /* Default render target locking method */
    5564    PCI_VENDOR_NONE,/* PCI Vendor ID */
    5665    PCI_DEVICE_NONE,/* PCI Device ID */
     
    206215            }
    207216        }
    208         if ( !get_config_key( hkey, appkey, "VertexBufferMode", buffer, size) )
    209         {
    210             if (!strcmp(buffer,"none"))
    211             {
    212                 TRACE("Disable Vertex Buffer Hardware support\n");
    213                 wined3d_settings.vbo_mode = VBO_NONE;
    214             }
    215             else if (!strcmp(buffer,"hardware"))
    216             {
    217                 TRACE("Allow Vertex Buffer Hardware support\n");
    218                 wined3d_settings.vbo_mode = VBO_HW;
    219             }
    220         }
    221217        if ( !get_config_key( hkey, appkey, "UseGLSL", buffer, size) )
    222218        {
     
    261257                TRACE("Using glReadPixels for render target reading and textures for writing\n");
    262258                wined3d_settings.rendertargetlock_mode = RTL_READTEX;
    263             }
    264             else if (!strcmp(buffer,"texdraw"))
    265             {
    266                 TRACE("Using textures for render target reading and glDrawPixels for writing\n");
    267                 wined3d_settings.rendertargetlock_mode = RTL_TEXDRAW;
    268             }
    269             else if (!strcmp(buffer,"textex"))
    270             {
    271                 TRACE("Reading render targets via textures and writing via textures\n");
    272                 wined3d_settings.rendertargetlock_mode = RTL_TEXTEX;
    273259            }
    274260        }
     
    318304        if ( !get_config_key( hkey, appkey, "WineLogo", buffer, size) )
    319305        {
    320             wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, strlen(buffer) + 1);
    321             if(wined3d_settings.logo) strcpy(wined3d_settings.logo, buffer);
     306            size_t len = strlen(buffer) + 1;
     307
     308            wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, len);
     309            if (!wined3d_settings.logo) ERR("Failed to allocate logo path memory.\n");
     310            else memcpy(wined3d_settings.logo, buffer, len);
    322311        }
    323312        if ( !get_config_key( hkey, appkey, "Multisampling", buffer, size) )
     
    334323    if (wined3d_settings.ps_mode == PS_NONE)
    335324        TRACE("Disable pixel shaders\n");
    336     if (wined3d_settings.vbo_mode == VBO_NONE)
    337         TRACE("Disable Vertex Buffer Hardware support\n");
    338325    if (wined3d_settings.glslRequested)
    339326        TRACE("If supported by your system, GL Shading Language will be used\n");
     
    361348}
    362349
     350void WINAPI wined3d_mutex_lock(void)
     351{
     352    EnterCriticalSection(&wined3d_cs);
     353}
     354
     355void WINAPI wined3d_mutex_unlock(void)
     356{
     357    LeaveCriticalSection(&wined3d_cs);
     358}
     359
    363360/* At process attach */
    364361BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r22496 r23571  
    143143}
    144144
    145 void *wined3d_rb_alloc(size_t size);
    146 void *wined3d_rb_realloc(void *ptr, size_t size);
    147 void wined3d_rb_free(void *ptr);
     145void *wined3d_rb_alloc(size_t size) DECLSPEC_HIDDEN;
     146void *wined3d_rb_realloc(void *ptr, size_t size) DECLSPEC_HIDDEN;
     147void wined3d_rb_free(void *ptr) DECLSPEC_HIDDEN;
    148148
    149149/* Device caps */
     
    165165#define NUM_SAVEDVERTEXSTATES_S    1
    166166
    167 extern const DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R];
    168 extern const DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T];
    169 extern const DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S];
    170 extern const DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R];
    171 extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T];
    172 extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S];
     167extern const DWORD SavedPixelStates_R[NUM_SAVEDPIXELSTATES_R] DECLSPEC_HIDDEN;
     168extern const DWORD SavedPixelStates_T[NUM_SAVEDPIXELSTATES_T] DECLSPEC_HIDDEN;
     169extern const DWORD SavedPixelStates_S[NUM_SAVEDPIXELSTATES_S] DECLSPEC_HIDDEN;
     170extern const DWORD SavedVertexStates_R[NUM_SAVEDVERTEXSTATES_R] DECLSPEC_HIDDEN;
     171extern const DWORD SavedVertexStates_T[NUM_SAVEDVERTEXSTATES_T] DECLSPEC_HIDDEN;
     172extern const DWORD SavedVertexStates_S[NUM_SAVEDVERTEXSTATES_S] DECLSPEC_HIDDEN;
    173173
    174174typedef enum _WINELOOKUP {
     
    177177} WINELOOKUP;
    178178
    179 extern const int minLookup[MAX_LOOKUPS];
    180 extern const int maxLookup[MAX_LOOKUPS];
    181 extern DWORD *stateLookup[MAX_LOOKUPS];
     179extern const int minLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
     180extern const int maxLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
     181extern DWORD *stateLookup[MAX_LOOKUPS] DECLSPEC_HIDDEN;
    182182
    183183struct min_lookup
     
    186186};
    187187
    188 const struct min_lookup minMipLookup[WINED3DTEXF_LINEAR + 1];
    189 const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_LINEAR + 1];
    190 const GLenum magLookup[WINED3DTEXF_LINEAR + 1];
    191 const GLenum magLookup_noFilter[WINED3DTEXF_LINEAR + 1];
     188const struct min_lookup minMipLookup[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
     189const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
     190const struct min_lookup minMipLookup_noMip[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
     191const GLenum magLookup[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
     192const GLenum magLookup_noFilter[WINED3DTEXF_LINEAR + 1] DECLSPEC_HIDDEN;
    192193
    193194static inline GLenum wined3d_gl_mag_filter(const GLenum mag_lookup[], WINED3DTEXTUREFILTERTYPE mag_filter)
     
    259260
    260261/**
    261  * Settings 
     262 * Settings
    262263 */
    263264#define VS_NONE    0
     
    284285
    285286#define RTL_DISABLE   -1
    286 #define RTL_AUTO       0
    287287#define RTL_READDRAW   1
    288288#define RTL_READTEX    2
    289 #define RTL_TEXDRAW    3
    290 #define RTL_TEXTEX     4
    291289
    292290#define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
     
    299297  int vs_mode;
    300298  int ps_mode;
    301   int vbo_mode;
    302299/* Ideally, we don't want the user to have to request GLSL.  If the hardware supports GLSL,
    303300    we should use it.  However, until it's fully implemented, we'll leave it as a registry
     
    314311} wined3d_settings_t;
    315312
    316 extern wined3d_settings_t wined3d_settings;
     313extern wined3d_settings_t wined3d_settings DECLSPEC_HIDDEN;
    317314
    318315typedef enum _WINED3DSAMPLER_TEXTURE_TYPE
     
    648645{
    649646    struct wined3d_shader_version shader_version;
    650     char texcoord[MAX_REG_TEXCRD];          /* pixel < 3.0 */
    651     char temporary[MAX_REG_TEMP];           /* pixel, vertex */
    652     char address[MAX_REG_ADDR];             /* vertex */
    653     char labels[MAX_LABELS];                /* pixel, vertex */
     647    BYTE texcoord;                          /* MAX_REG_TEXCRD, 8 */
     648    BYTE address;                           /* MAX_REG_ADDR, 1 */
     649    WORD labels;                            /* MAX_LABELS, 16 */
     650    DWORD temporary;                        /* MAX_REG_TEMP, 32 */
    654651    DWORD *constf;                          /* pixel, vertex */
    655652    DWORD texcoord_mask[MAX_REG_TEXCRD];    /* vertex < 3.0 */
     
    662659
    663660    WINED3DSAMPLER_TEXTURE_TYPE sampler_type[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
    664     BOOL bumpmat[MAX_TEXTURES], luminanceparams[MAX_TEXTURES];
    665 
    666     unsigned usesnrm        : 1;
    667     unsigned vpos           : 1;
    668     unsigned usesdsx        : 1;
    669     unsigned usesdsy        : 1;
    670     unsigned usestexldd     : 1;
    671     unsigned usesmova       : 1;
    672     unsigned usesfacing     : 1;
    673     unsigned usesrelconstF  : 1;
    674     unsigned fog            : 1;
    675     unsigned usestexldl     : 1;
    676     unsigned usesifc        : 1;
    677     unsigned usescall       : 1;
    678     unsigned padding        : 4;
     661    BYTE bumpmat;                           /* MAX_TEXTURES, 8 */
     662    BYTE luminanceparams;                   /* MAX_TEXTURES, 8 */
     663
     664    WORD usesnrm        : 1;
     665    WORD vpos           : 1;
     666    WORD usesdsx        : 1;
     667    WORD usesdsy        : 1;
     668    WORD usestexldd     : 1;
     669    WORD usesmova       : 1;
     670    WORD usesfacing     : 1;
     671    WORD usesrelconstF  : 1;
     672    WORD fog            : 1;
     673    WORD usestexldl     : 1;
     674    WORD usesifc        : 1;
     675    WORD usescall       : 1;
     676    WORD padding        : 4;
    679677
    680678    /* Whether or not loops are used in this shader, and nesting depth */
     
    742740    WINED3DDECLUSAGE usage;
    743741    UINT usage_idx;
     742};
     743
     744struct wined3d_shader_loop_control
     745{
     746    unsigned int count;
     747    unsigned int start;
     748    int step;
    744749};
    745750
     
    759764};
    760765
    761 extern const struct wined3d_shader_frontend sm1_shader_frontend;
    762 extern const struct wined3d_shader_frontend sm4_shader_frontend;
     766extern const struct wined3d_shader_frontend sm1_shader_frontend DECLSPEC_HIDDEN;
     767extern const struct wined3d_shader_frontend sm4_shader_frontend DECLSPEC_HIDDEN;
    763768
    764769typedef void (*SHADER_HANDLER)(const struct wined3d_shader_instruction *);
     
    854859} shader_backend_t;
    855860
    856 extern const shader_backend_t glsl_shader_backend;
    857 extern const shader_backend_t arb_program_shader_backend;
    858 extern const shader_backend_t none_shader_backend;
     861extern const shader_backend_t glsl_shader_backend DECLSPEC_HIDDEN;
     862extern const shader_backend_t arb_program_shader_backend DECLSPEC_HIDDEN;
     863extern const shader_backend_t none_shader_backend DECLSPEC_HIDDEN;
    859864
    860865/* X11 locking */
    861866
    862 extern void (* CDECL wine_tsx11_lock_ptr)(void);
    863 extern void (* CDECL wine_tsx11_unlock_ptr)(void);
     867extern void (* CDECL wine_tsx11_lock_ptr)(void) DECLSPEC_HIDDEN;
     868extern void (* CDECL wine_tsx11_unlock_ptr)(void) DECLSPEC_HIDDEN;
    864869
    865870/* As GLX relies on X, this is needed */
    866 extern int num_lock;
     871extern int num_lock DECLSPEC_HIDDEN;
    867872
    868873#if 0
     
    954959
    955960/* Trace vector and strided data information */
    956 #define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
    957 #define TRACE_STRIDED(si, name) TRACE( #name "=(data:%p, stride:%d, format:%#x, vbo %d, stream %u)\n", \
     961#define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w)
     962#define TRACE_STRIDED(si, name) do { if (si->use_map & (1 << name)) \
     963        TRACE( #name "=(data:%p, stride:%d, format:%#x, vbo %d, stream %u)\n", \
    958964        si->elements[name].data, si->elements[name].stride, si->elements[name].format_desc->format, \
    959         si->elements[name].buffer_object, si->elements[name].stream_idx);
     965        si->elements[name].buffer_object, si->elements[name].stream_idx); } while(0)
    960966
    961967/* Defines used for optimizations */
     
    972978
    973979/* Global variables */
    974 extern const float identity[16];
     980extern const float identity[16] DECLSPEC_HIDDEN;
    975981
    976982/*****************************************************************************
     
    981987#if 0 /* NOTE: Must be 0 in cvs */
    982988# define VTRACE(A) TRACE A
    983 #else 
    984 # define VTRACE(A) 
     989#else
     990# define VTRACE(A)
    985991#endif
    986992
     
    9951001# if 1 /* NOTE: Must be 1 in cvs, as this is mostly more useful than a trace from program start */
    9961002#  define SINGLE_FRAME_DEBUGGING
    997 # endif 
     1003# endif
    9981004  /* The following, when enabled, lets you see the makeup of the frame, by drawprimitive calls.
    999      It can only be enabled when FRAME_DEBUGGING is also enabled                               
    1000      The contents of the back buffer are written into /tmp/backbuffer_* after each primitive 
     1005     It can only be enabled when FRAME_DEBUGGING is also enabled
     1006     The contents of the back buffer are written into /tmp/backbuffer_* after each primitive
    10011007     array is drawn.                                                                            */
    1002 # if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */                                                                                       
     1008# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
    10031009#  define SHOW_FRAME_MAKEUP 1
    1004 # endif 
     1010# endif
    10051011  /* The following, when enabled, lets you see the makeup of the all the textures used during each
    10061012     of the drawprimitive calls. It can only be enabled when SHOW_FRAME_MAKEUP is also enabled.
    1007      The contents of the textures assigned to each stage are written into 
     1013     The contents of the textures assigned to each stage are written into
    10081014     /tmp/texture_*_<Stage>.ppm after each primitive array is drawn.                            */
    10091015# if 0 /* NOTE: Must be 0 in cvs, as this give a lot of ppm files when compiled in */
    10101016#  define SHOW_TEXTURE_MAKEUP 0
    1011 # endif 
     1017# endif
    10121018extern BOOL isOn;
    10131019extern BOOL isDumpingFrames;
     
    10781084
    10791085/* Routine common to the draw primitive and draw indexed primitive routines */
    1080 void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertices,
    1081         UINT start_idx, UINT idxBytes, const void *idxData, UINT minIndex);
    1082 DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
     1086void drawPrimitive(IWineD3DDevice *iface, UINT index_count,
     1087        UINT start_idx, UINT idxBytes, const void *idxData) DECLSPEC_HIDDEN;
     1088DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) DECLSPEC_HIDDEN;
    10831089
    10841090typedef void (WINE_GLAPI *glAttribFunc)(const void *data);
    10851091typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, const void *data);
    1086 extern glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT];
    1087 extern glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT];
    1088 extern glAttribFunc specular_func_3ubv;
    1089 extern glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT];
    1090 extern glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT];
    1091 extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT];
     1092extern glAttribFunc position_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
     1093extern glAttribFunc diffuse_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
     1094extern glAttribFunc specular_func_3ubv DECLSPEC_HIDDEN;
     1095extern glAttribFunc specular_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
     1096extern glAttribFunc normal_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
     1097extern glMultiTexCoordFunc multi_texcoord_funcs[WINED3D_FFP_EMIT_COUNT] DECLSPEC_HIDDEN;
    10921098
    10931099#define eps 1e-8
     
    12811287};
    12821288
    1283 extern const struct StateEntryTemplate misc_state_template[];
    1284 extern const struct StateEntryTemplate ffp_vertexstate_template[];
    1285 extern const struct fragment_pipeline ffp_fragment_pipeline;
    1286 extern const struct fragment_pipeline atifs_fragment_pipeline;
    1287 extern const struct fragment_pipeline arbfp_fragment_pipeline;
    1288 extern const struct fragment_pipeline nvts_fragment_pipeline;
    1289 extern const struct fragment_pipeline nvrc_fragment_pipeline;
     1289extern const struct StateEntryTemplate misc_state_template[] DECLSPEC_HIDDEN;
     1290extern const struct StateEntryTemplate ffp_vertexstate_template[] DECLSPEC_HIDDEN;
     1291extern const struct fragment_pipeline ffp_fragment_pipeline DECLSPEC_HIDDEN;
     1292extern const struct fragment_pipeline atifs_fragment_pipeline DECLSPEC_HIDDEN;
     1293extern const struct fragment_pipeline arbfp_fragment_pipeline DECLSPEC_HIDDEN;
     1294extern const struct fragment_pipeline nvts_fragment_pipeline DECLSPEC_HIDDEN;
     1295extern const struct fragment_pipeline nvrc_fragment_pipeline DECLSPEC_HIDDEN;
    12901296
    12911297/* "Base" state table */
    12921298HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
    12931299        const struct wined3d_gl_info *gl_info, const struct StateEntryTemplate *vertex,
    1294         const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc);
     1300        const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc) DECLSPEC_HIDDEN;
    12951301
    12961302/* Shaders for color conversions in blits */
     
    13051311};
    13061312
    1307 extern const struct blit_shader ffp_blit;
    1308 extern const struct blit_shader arbfp_blit;
     1313extern const struct blit_shader ffp_blit DECLSPEC_HIDDEN;
     1314extern const struct blit_shader arbfp_blit DECLSPEC_HIDDEN;
    13091315
    13101316typedef enum ContextUsage {
     
    13151321} ContextUsage;
    13161322
    1317 struct wined3d_context *ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurface *target, enum ContextUsage usage);
     1323struct wined3d_context *ActivateContext(IWineD3DDeviceImpl *This,
     1324        IWineD3DSurface *target, enum ContextUsage usage) DECLSPEC_HIDDEN;
    13181325struct wined3d_context *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win,
    1319         BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *pPresentParms);
    1320 void DestroyContext(IWineD3DDeviceImpl *This, struct wined3d_context *context);
    1321 void context_alloc_event_query(struct wined3d_context *context, struct wined3d_event_query *query);
    1322 void context_alloc_occlusion_query(struct wined3d_context *context, struct wined3d_occlusion_query *query);
    1323 void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource, WINED3DRESOURCETYPE type);
    1324 void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint *fbo);
     1326        BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *pPresentParms) DECLSPEC_HIDDEN;
     1327void DestroyContext(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
     1328void context_alloc_event_query(struct wined3d_context *context,
     1329        struct wined3d_event_query *query) DECLSPEC_HIDDEN;
     1330void context_alloc_occlusion_query(struct wined3d_context *context,
     1331        struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
     1332void context_resource_released(IWineD3DDevice *iface,
     1333        IWineD3DResource *resource, WINED3DRESOURCETYPE type) DECLSPEC_HIDDEN;
     1334void context_bind_fbo(struct wined3d_context *context, GLenum target, GLuint *fbo) DECLSPEC_HIDDEN;
    13251335void context_attach_depth_stencil_fbo(struct wined3d_context *context,
    1326         GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer);
     1336        GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
    13271337void context_attach_surface_fbo(const struct wined3d_context *context,
    1328         GLenum fbo_target, DWORD idx, IWineD3DSurface *surface);
    1329 void context_free_event_query(struct wined3d_event_query *query);
    1330 void context_free_occlusion_query(struct wined3d_occlusion_query *query);
    1331 struct wined3d_context *context_get_current(void);
    1332 DWORD context_get_tls_idx(void);
    1333 BOOL context_set_current(struct wined3d_context *ctx);
    1334 void context_set_tls_idx(DWORD idx);
    1335 
    1336 void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain);
    1337 HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain);
     1338        GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) DECLSPEC_HIDDEN;
     1339void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
     1340void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
     1341struct wined3d_context *context_get_current(void) DECLSPEC_HIDDEN;
     1342DWORD context_get_tls_idx(void) DECLSPEC_HIDDEN;
     1343BOOL context_set_current(struct wined3d_context *ctx) DECLSPEC_HIDDEN;
     1344void context_set_tls_idx(DWORD idx) DECLSPEC_HIDDEN;
     1345
     1346void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
     1347HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
    13381348
    13391349/* Macros for doing basic GPU detection based on opengl capabilities */
     
    13441354
    13451355/* Default callbacks for implicit object destruction */
    1346 extern ULONG WINAPI D3DCB_DefaultDestroySurface(IWineD3DSurface *pSurface);
    1347 
    1348 extern ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pSurface);
     1356extern ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pSurface) DECLSPEC_HIDDEN;
    13491357
    13501358/*****************************************************************************
     
    13701378
    13711379/* The default light parameters */
    1372 extern const WINED3DLIGHT WINED3D_default_light;
     1380extern const WINED3DLIGHT WINED3D_default_light DECLSPEC_HIDDEN;
    13731381
    13741382typedef struct WineD3D_PixelFormat
     
    14021410};
    14031411
    1404 extern BOOL initPixelFormats(struct wined3d_gl_info *gl_info);
    1405 BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info);
    1406 extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram);
    1407 extern void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info);
     1412extern BOOL initPixelFormats(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
     1413BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
     1414extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram) DECLSPEC_HIDDEN;
     1415extern void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
    14081416
    14091417/*****************************************************************************
     
    14211429};
    14221430
    1423 HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, struct WineD3DRectPatch *patch);
     1431HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, struct WineD3DRectPatch *patch) DECLSPEC_HIDDEN;
    14241432
    14251433enum projection_types
     
    14741482};
    14751483
    1476 extern const struct wine_rb_functions wined3d_ffp_frag_program_rb_functions;
    1477 
    1478 void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings, BOOL ignore_textype);
     1484extern const struct wine_rb_functions wined3d_ffp_frag_program_rb_functions DECLSPEC_HIDDEN;
     1485extern const struct wined3d_parent_ops wined3d_null_parent_ops DECLSPEC_HIDDEN;
     1486
     1487void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings,
     1488        BOOL ignore_textype) DECLSPEC_HIDDEN;
    14791489const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders,
    1480         const struct ffp_frag_settings *settings);
    1481 void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc);
     1490        const struct ffp_frag_settings *settings) DECLSPEC_HIDDEN;
     1491void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc) DECLSPEC_HIDDEN;
    14821492
    14831493/*****************************************************************************
     
    14981508} IWineD3DImpl;
    14991509
    1500 extern const IWineD3DVtbl IWineD3D_Vtbl;
    1501 
    1502 BOOL InitAdapters(IWineD3DImpl *This);
     1510extern const IWineD3DVtbl IWineD3D_Vtbl DECLSPEC_HIDDEN;
     1511
     1512BOOL InitAdapters(IWineD3DImpl *This) DECLSPEC_HIDDEN;
    15031513
    15041514/* A helper function that dumps a resource list */
    1505 void dumpResources(struct list *list);
     1515void dumpResources(struct list *list) DECLSPEC_HIDDEN;
    15061516
    15071517/*****************************************************************************
     
    16501660};
    16511661
    1652 extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl;
    1653 
    1654 void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource);
    1655 void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource);
     1662extern const IWineD3DDeviceVtbl IWineD3DDevice_Vtbl DECLSPEC_HIDDEN;
     1663
     1664void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
     1665void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
    16561666void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
    1657         BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup);
     1667        BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
    16581668void device_stream_info_from_strided(IWineD3DDeviceImpl *This,
    1659         const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info);
    1660 HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This,  IWineD3DSurfaceImpl *target, DWORD Count,
    1661                                         CONST WINED3DRECT* pRects, DWORD Flags, WINED3DCOLOR Color,
    1662                                         float Z, DWORD Stencil);
    1663 void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This);
    1664 void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state);
     1669        const struct WineDirect3DVertexStridedData *strided, struct wined3d_stream_info *stream_info) DECLSPEC_HIDDEN;
     1670HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, DWORD Count,
     1671        const WINED3DRECT *pRects, DWORD Flags, WINED3DCOLOR Color, float Z, DWORD Stencil) DECLSPEC_HIDDEN;
     1672void IWineD3DDeviceImpl_FindTexUnitMap(IWineD3DDeviceImpl *This) DECLSPEC_HIDDEN;
     1673void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) DECLSPEC_HIDDEN;
    16651674static inline BOOL isStateDirty(struct wined3d_context *context, DWORD state)
    16661675{
     
    17081717    struct list             privateData;
    17091718    struct list             resource_list_entry;
    1710 
     1719    const struct wined3d_parent_ops *parent_ops;
    17111720} IWineD3DResourceClass;
    17121721
     
    17181727} IWineD3DResourceImpl;
    17191728
    1720 void resource_cleanup(IWineD3DResource *iface);
    1721 HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid);
    1722 HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice **device);
    1723 HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **parent);
    1724 DWORD resource_get_priority(IWineD3DResource *iface);
     1729void resource_cleanup(IWineD3DResource *iface) DECLSPEC_HIDDEN;
     1730HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid) DECLSPEC_HIDDEN;
     1731HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice **device) DECLSPEC_HIDDEN;
     1732HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **parent) DECLSPEC_HIDDEN;
     1733DWORD resource_get_priority(IWineD3DResource *iface) DECLSPEC_HIDDEN;
    17251734HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
    1726         void *data, DWORD *data_size);
     1735        void *data, DWORD *data_size) DECLSPEC_HIDDEN;
    17271736HRESULT resource_init(IWineD3DResource *iface, WINED3DRESOURCETYPE resource_type,
    17281737        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
    1729         WINED3DPOOL pool, IUnknown *parent);
    1730 WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface);
    1731 DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority);
     1738        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
     1739WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface) DECLSPEC_HIDDEN;
     1740DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority) DECLSPEC_HIDDEN;
    17321741HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID guid,
    1733         const void *data, DWORD data_size, DWORD flags);
     1742        const void *data, DWORD data_size, DWORD flags) DECLSPEC_HIDDEN;
    17341743
    17351744/* Tests show that the start address of resources is 32 byte aligned */
     
    17651774};
    17661775
     1776struct gl_texture
     1777{
     1778    DWORD                   states[MAX_WINETEXTURESTATES];
     1779    BOOL                    dirty;
     1780    GLuint                  name;
     1781};
     1782
    17671783/*****************************************************************************
    17681784 * IWineD3DBaseTexture implementation structure (extends IWineD3DResourceImpl)
     
    17701786typedef struct IWineD3DBaseTextureClass
    17711787{
    1772     DWORD                   states[MAX_WINETEXTURESTATES];
    1773     DWORD                   srgbstates[MAX_WINETEXTURESTATES];
     1788    struct gl_texture       texture_rgb, texture_srgb;
    17741789    UINT                    levels;
    1775     BOOL                    dirty, srgbDirty;
    1776     UINT                    textureName, srgbTextureName;
    17771790    float                   pow2Matrix[16];
    17781791    UINT                    LOD;
     
    17871800} IWineD3DBaseTextureClass;
    17881801
    1789 void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb);
     1802void surface_internal_preload(IWineD3DSurface *iface, enum WINED3DSRGB srgb) DECLSPEC_HIDDEN;
    17901803
    17911804typedef struct IWineD3DBaseTextureImpl
     
    18001813void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
    18011814        const DWORD texture_states[WINED3D_HIGHEST_TEXTURE_STATE + 1],
    1802         const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
    1803 HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc);
    1804 void basetexture_cleanup(IWineD3DBaseTexture *iface);
    1805 void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface);
    1806 WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface);
    1807 BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface);
    1808 DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface);
    1809 DWORD basetexture_get_lod(IWineD3DBaseTexture *iface);
     1815        const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]) DECLSPEC_HIDDEN;
     1816HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc) DECLSPEC_HIDDEN;
     1817void basetexture_cleanup(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
     1818void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
     1819WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
     1820BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
     1821DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
     1822DWORD basetexture_get_lod(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
    18101823HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type,
    18111824        IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc,
    1812         WINED3DPOOL pool, IUnknown *parent);
    1813 HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE filter_type);
    1814 BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty);
    1815 DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD new_lod);
    1816 void basetexture_unload(IWineD3DBaseTexture *iface);
     1825        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
     1826HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface,
     1827        WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
     1828BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty) DECLSPEC_HIDDEN;
     1829DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD new_lod) DECLSPEC_HIDDEN;
     1830void basetexture_unload(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
    18171831
    18181832/*****************************************************************************
     
    18331847} IWineD3DTextureImpl;
    18341848
    1835 extern const IWineD3DTextureVtbl IWineD3DTexture_Vtbl;
    1836 
    18371849HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
    1838         IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent);
     1850        IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
     1851        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    18391852
    18401853/*****************************************************************************
     
    18521865} IWineD3DCubeTextureImpl;
    18531866
    1854 extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
    1855 
    18561867HRESULT cubetexture_init(IWineD3DCubeTextureImpl *texture, UINT edge_length, UINT levels,
    1857         IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent);
     1868        IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
     1869        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    18581870
    18591871typedef struct _WINED3DVOLUMET_DESC
     
    18831895} IWineD3DVolumeImpl;
    18841896
    1885 extern const IWineD3DVolumeVtbl IWineD3DVolume_Vtbl;
    1886 
    1887 void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box);
     1897void volume_add_dirty_box(IWineD3DVolume *iface, const WINED3DBOX *dirty_box) DECLSPEC_HIDDEN;
     1898HRESULT volume_init(IWineD3DVolumeImpl *volume, IWineD3DDeviceImpl *device, UINT width,
     1899        UINT height, UINT depth, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
     1900        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    18881901
    18891902/*****************************************************************************
     
    19011914} IWineD3DVolumeTextureImpl;
    19021915
    1903 extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
    1904 
    1905 HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height, UINT depth, UINT levels,
    1906         IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, IUnknown *parent);
     1916HRESULT volumetexture_init(IWineD3DVolumeTextureImpl *texture, UINT width, UINT height,
     1917        UINT depth, UINT levels, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
     1918        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    19071919
    19081920typedef struct _WINED3DSURFACET_DESC
     
    20202032};
    20212033
    2022 extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl;
    2023 extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl;
    2024 
    2025 UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc, UINT alignment, UINT width, UINT height);
    2026 void surface_gdi_cleanup(IWineD3DSurfaceImpl *This);
     2034extern const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl DECLSPEC_HIDDEN;
     2035extern const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl DECLSPEC_HIDDEN;
     2036
     2037UINT surface_calculate_size(const struct GlPixelFormatDesc *format_desc,
     2038        UINT alignment, UINT width, UINT height) DECLSPEC_HIDDEN;
     2039void surface_gdi_cleanup(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
    20272040HRESULT surface_init(IWineD3DSurfaceImpl *surface, WINED3DSURFTYPE surface_type, UINT alignment,
    20282041        UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
    20292042        UINT multisample_quality, IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format,
    2030         WINED3DPOOL pool, IUnknown *parent);
     2043        WINED3DPOOL pool, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    20312044
    20322045/* Predeclare the shared Surface functions */
    2033 HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface, REFIID riid, LPVOID *ppobj);
    2034 ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface);
    2035 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent);
    2036 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice);
    2037 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags);
    2038 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData);
    2039 HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid);
    2040 DWORD   WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew);
    2041 DWORD   WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface);
    2042 WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface);
    2043 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetContainer(IWineD3DSurface* iface, REFIID riid, void** ppContainer);
    2044 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc);
    2045 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags);
    2046 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags);
    2047 HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface);
    2048 HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface);
    2049 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal);
    2050 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
    2051 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey);
    2052 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container);
    2053 DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface);
    2054 HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface);
    2055 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y);
    2056 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y);
    2057 HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref);
     2046HRESULT WINAPI IWineD3DBaseSurfaceImpl_QueryInterface(IWineD3DSurface *iface,
     2047        REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
     2048ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2049HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) DECLSPEC_HIDDEN;
     2050HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice) DECLSPEC_HIDDEN;
     2051HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface,
     2052        REFGUID refguid, const void *pData, DWORD SizeOfData, DWORD Flags) DECLSPEC_HIDDEN;
     2053HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface,
     2054        REFGUID refguid, void *pData, DWORD *pSizeOfData) DECLSPEC_HIDDEN;
     2055HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) DECLSPEC_HIDDEN;
     2056DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) DECLSPEC_HIDDEN;
     2057DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2058WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2059HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetContainer(IWineD3DSurface* iface,
     2060        REFIID riid, void **ppContainer) DECLSPEC_HIDDEN;
     2061HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDesc(IWineD3DSurface *iface, WINED3DSURFACE_DESC *pDesc) DECLSPEC_HIDDEN;
     2062HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetBltStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
     2063HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetFlipStatus(IWineD3DSurface *iface, DWORD Flags) DECLSPEC_HIDDEN;
     2064HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2065HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2066HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal) DECLSPEC_HIDDEN;
     2067HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal) DECLSPEC_HIDDEN;
     2068HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface,
     2069        DWORD Flags, const WINEDDCOLORKEY *CKey) DECLSPEC_HIDDEN;
     2070HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) DECLSPEC_HIDDEN;
     2071DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2072HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2073HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y) DECLSPEC_HIDDEN;
     2074HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y) DECLSPEC_HIDDEN;
     2075HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface,
     2076        DWORD Flags, IWineD3DSurface *Ref) DECLSPEC_HIDDEN;
    20582077HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
    2059         IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX);
    2060 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper);
    2061 HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper);
    2062 HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
    2063 HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface);
     2078        IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX) DECLSPEC_HIDDEN;
     2079HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper) DECLSPEC_HIDDEN;
     2080HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper) DECLSPEC_HIDDEN;
     2081HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) DECLSPEC_HIDDEN;
     2082HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
    20642083HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
    2065         const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter);
     2084        const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) DECLSPEC_HIDDEN;
    20662085HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
    2067         IWineD3DSurface *Source, const RECT *rsrc, DWORD trans);
    2068 HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
    2069 void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb);
    2070 const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface);
    2071 
    2072 void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height);
    2073 void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height);
    2074 void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height);
    2075 void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height);
    2076 
    2077 void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back);
     2086        IWineD3DSurface *Source, const RECT *rsrc, DWORD trans) DECLSPEC_HIDDEN;
     2087HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT *pLockedRect,
     2088        const RECT *pRect, DWORD Flags) DECLSPEC_HIDDEN;
     2089void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface, BOOL srgb) DECLSPEC_HIDDEN;
     2090const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface) DECLSPEC_HIDDEN;
     2091
     2092void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
     2093void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
     2094void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
     2095void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
     2096
     2097void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) DECLSPEC_HIDDEN;
    20782098
    20792099/* Surface flags: */
     
    21312151#define SFLAG_DS_DISCARDED   SFLAG_DS_LOCATIONS
    21322152
    2133 BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]);
     2153BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) DECLSPEC_HIDDEN;
    21342154
    21352155typedef enum {
     
    21612181} CONVERT_TYPES;
    21622182
    2163 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);
    2164 
    2165 BOOL palette9_changed(IWineD3DSurfaceImpl *This);
     2183HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format,
     2184        GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) DECLSPEC_HIDDEN;
     2185
     2186BOOL palette9_changed(IWineD3DSurfaceImpl *This) DECLSPEC_HIDDEN;
    21662187
    21672188/*****************************************************************************
     
    21882209
    21892210    IUnknown                *parent;
     2211    const struct wined3d_parent_ops *parent_ops;
    21902212    IWineD3DDeviceImpl      *wineD3DDevice;
    21912213
     
    21992221} IWineD3DVertexDeclarationImpl;
    22002222
    2201 extern const IWineD3DVertexDeclarationVtbl IWineD3DVertexDeclaration_Vtbl;
    2202 
    2203 HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *This,
    2204         const WINED3DVERTEXELEMENT *elements, UINT element_count);
     2223HRESULT vertexdeclaration_init(IWineD3DVertexDeclarationImpl *declaration, IWineD3DDeviceImpl *device,
     2224        const WINED3DVERTEXELEMENT *elements, UINT element_count,
     2225        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    22052226
    22062227/*****************************************************************************
     
    23482369};
    23492370
    2350 extern void stateblock_savedstates_set(
    2351     IWineD3DStateBlock* iface,
    2352     SAVEDSTATES* states,
    2353     BOOL value);
    2354 
    2355 extern void stateblock_copy(
    2356     IWineD3DStateBlock* destination,
    2357     IWineD3DStateBlock* source);
    2358 
    2359 extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
     2371extern void stateblock_savedstates_set(IWineD3DStateBlock *iface, SAVEDSTATES *states, BOOL value) DECLSPEC_HIDDEN;
     2372extern void stateblock_copy(IWineD3DStateBlock *destination, IWineD3DStateBlock *source) DECLSPEC_HIDDEN;
     2373
     2374extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl DECLSPEC_HIDDEN;
    23602375
    23612376/* Direct3D terminology with little modifications. We do not have an issued state
     
    23752390    const IWineD3DQueryVtbl  *lpVtbl;
    23762391    LONG                      ref;     /* Note: Ref counting not required */
    2377    
     2392
    23782393    IUnknown                 *parent;
    23792394    /*TODO: replace with iface usage */
     
    23892404    /* TODO: Think about using a IUnknown instead of a void* */
    23902405    void                     *extendedData;
    2391    
    2392  
    23932406} IWineD3DQueryImpl;
    23942407
    2395 extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl;
    2396 extern const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl;
    2397 extern const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl;
     2408extern const IWineD3DQueryVtbl IWineD3DQuery_Vtbl DECLSPEC_HIDDEN;
     2409extern const IWineD3DQueryVtbl IWineD3DEventQuery_Vtbl DECLSPEC_HIDDEN;
     2410extern const IWineD3DQueryVtbl IWineD3DOcclusionQuery_Vtbl DECLSPEC_HIDDEN;
    23982411
    23992412/* IWineD3DBuffer */
     
    24432456};
    24442457
    2445 extern const IWineD3DBufferVtbl wined3d_buffer_vtbl;
    2446 const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object);
    2447 BYTE *buffer_get_sysmem(struct wined3d_buffer *This);
     2458const BYTE *buffer_get_memory(IWineD3DBuffer *iface, UINT offset, GLuint *buffer_object) DECLSPEC_HIDDEN;
     2459BYTE *buffer_get_sysmem(struct wined3d_buffer *This) DECLSPEC_HIDDEN;
     2460HRESULT buffer_init(struct wined3d_buffer *buffer, IWineD3DDeviceImpl *device,
     2461        UINT size, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool, GLenum bind_hint,
     2462        const char *data, IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    24482463
    24492464/* IWineD3DRendertargetView */
     
    24572472};
    24582473
    2459 extern const IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl;
     2474extern const IWineD3DRendertargetViewVtbl wined3d_rendertarget_view_vtbl DECLSPEC_HIDDEN;
    24602475
    24612476/*****************************************************************************
     
    24892504} IWineD3DSwapChainImpl;
    24902505
    2491 extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
    2492 const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl;
    2493 void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc);
    2494 
    2495 HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, LPVOID *ppobj);
    2496 ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface);
    2497 ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface);
    2498 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown ** ppParent);
    2499 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface, IWineD3DSurface *pDestSurface);
    2500 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer, WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer);
    2501 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus);
    2502 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode);
    2503 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface, IWineD3DDevice**ppDevice);
    2504 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters);
    2505 HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface, DWORD Flags, CONST WINED3DGAMMARAMP *pRamp);
    2506 HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface, WINED3DGAMMARAMP *pRamp);
    2507 
    2508 struct wined3d_context *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *iface);
     2506extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl DECLSPEC_HIDDEN;
     2507const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl DECLSPEC_HIDDEN;
     2508void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc) DECLSPEC_HIDDEN;
     2509
     2510HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface,
     2511        REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN;
     2512ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
     2513ULONG WINAPI IWineD3DBaseSwapChainImpl_Release(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
     2514HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetParent(IWineD3DSwapChain *iface, IUnknown **ppParent) DECLSPEC_HIDDEN;
     2515HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetFrontBufferData(IWineD3DSwapChain *iface,
     2516        IWineD3DSurface *pDestSurface) DECLSPEC_HIDDEN;
     2517HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface, UINT iBackBuffer,
     2518        WINED3DBACKBUFFER_TYPE Type, IWineD3DSurface **ppBackBuffer) DECLSPEC_HIDDEN;
     2519HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface,
     2520        WINED3DRASTER_STATUS *pRasterStatus) DECLSPEC_HIDDEN;
     2521HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface,
     2522        WINED3DDISPLAYMODE *pMode) DECLSPEC_HIDDEN;
     2523HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetDevice(IWineD3DSwapChain *iface,
     2524        IWineD3DDevice **ppDevice) DECLSPEC_HIDDEN;
     2525HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetPresentParameters(IWineD3DSwapChain *iface,
     2526        WINED3DPRESENT_PARAMETERS *pPresentationParameters) DECLSPEC_HIDDEN;
     2527HRESULT WINAPI IWineD3DBaseSwapChainImpl_SetGammaRamp(IWineD3DSwapChain *iface,
     2528        DWORD Flags, const WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
     2529HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
     2530        WINED3DGAMMARAMP *pRamp) DECLSPEC_HIDDEN;
     2531
     2532struct wined3d_context *IWineD3DSwapChainImpl_CreateContextForThread(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
     2533
     2534#define DEFAULT_REFRESH_RATE 0
    25092535
    25102536/*****************************************************************************
    2511  * Utility function prototypes 
     2537 * Utility function prototypes
    25122538 */
    25132539
    25142540/* Trace routines */
    2515 const char* debug_d3dformat(WINED3DFORMAT fmt);
    2516 const char* debug_d3ddevicetype(WINED3DDEVTYPE devtype);
    2517 const char* debug_d3dresourcetype(WINED3DRESOURCETYPE res);
    2518 const char* debug_d3dusage(DWORD usage);
    2519 const char* debug_d3dusagequery(DWORD usagequery);
    2520 const char* debug_d3ddeclmethod(WINED3DDECLMETHOD method);
    2521 const char* debug_d3ddeclusage(BYTE usage);
    2522 const char* debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType);
    2523 const char* debug_d3drenderstate(DWORD state);
    2524 const char* debug_d3dsamplerstate(DWORD state);
    2525 const char* debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type);
    2526 const char* debug_d3dtexturestate(DWORD state);
    2527 const char* debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype);
    2528 const char* debug_d3dpool(WINED3DPOOL pool);
    2529 const char *debug_fbostatus(GLenum status);
    2530 const char *debug_glerror(GLenum error);
    2531 const char *debug_d3dbasis(WINED3DBASISTYPE basis);
    2532 const char *debug_d3ddegree(WINED3DDEGREETYPE order);
    2533 const char* debug_d3dtop(WINED3DTEXTUREOP d3dtop);
    2534 void dump_color_fixup_desc(struct color_fixup_desc fixup);
    2535 const char *debug_surflocation(DWORD flag);
     2541const char *debug_d3dformat(WINED3DFORMAT fmt) DECLSPEC_HIDDEN;
     2542const char *debug_d3ddevicetype(WINED3DDEVTYPE devtype) DECLSPEC_HIDDEN;
     2543const char *debug_d3dresourcetype(WINED3DRESOURCETYPE res) DECLSPEC_HIDDEN;
     2544const char *debug_d3dusage(DWORD usage) DECLSPEC_HIDDEN;
     2545const char *debug_d3dusagequery(DWORD usagequery) DECLSPEC_HIDDEN;
     2546const char *debug_d3ddeclmethod(WINED3DDECLMETHOD method) DECLSPEC_HIDDEN;
     2547const char *debug_d3ddeclusage(BYTE usage) DECLSPEC_HIDDEN;
     2548const char *debug_d3dprimitivetype(WINED3DPRIMITIVETYPE PrimitiveType) DECLSPEC_HIDDEN;
     2549const char *debug_d3drenderstate(DWORD state) DECLSPEC_HIDDEN;
     2550const char *debug_d3dsamplerstate(DWORD state) DECLSPEC_HIDDEN;
     2551const char *debug_d3dtexturefiltertype(WINED3DTEXTUREFILTERTYPE filter_type) DECLSPEC_HIDDEN;
     2552const char *debug_d3dtexturestate(DWORD state) DECLSPEC_HIDDEN;
     2553const char *debug_d3dtstype(WINED3DTRANSFORMSTATETYPE tstype) DECLSPEC_HIDDEN;
     2554const char *debug_d3dpool(WINED3DPOOL pool) DECLSPEC_HIDDEN;
     2555const char *debug_fbostatus(GLenum status) DECLSPEC_HIDDEN;
     2556const char *debug_glerror(GLenum error) DECLSPEC_HIDDEN;
     2557const char *debug_d3dbasis(WINED3DBASISTYPE basis) DECLSPEC_HIDDEN;
     2558const char *debug_d3ddegree(WINED3DDEGREETYPE order) DECLSPEC_HIDDEN;
     2559const char *debug_d3dtop(WINED3DTEXTUREOP d3dtop) DECLSPEC_HIDDEN;
     2560void dump_color_fixup_desc(struct color_fixup_desc fixup) DECLSPEC_HIDDEN;
     2561const char *debug_surflocation(DWORD flag) DECLSPEC_HIDDEN;
    25362562
    25372563/* Routines for GL <-> D3D values */
    2538 GLenum StencilOp(DWORD op);
    2539 GLenum CompareFunc(DWORD func);
    2540 BOOL is_invalid_op(IWineD3DDeviceImpl *This, int stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3);
    2541 void   set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst);
    2542 void   set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, BOOL transformed, DWORD coordtype, BOOL ffp_can_disable_proj);
    2543 void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2544 void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2545 void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2546 void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2547 void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2548 void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2549 void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2550 void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context);
    2551 
    2552 void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect);
    2553 GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain);
    2554 void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *context, DWORD location);
    2555 void surface_modify_ds_location(IWineD3DSurface *iface, DWORD location);
    2556 void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int width, unsigned int height);
    2557 void surface_set_texture_name(IWineD3DSurface *iface, GLuint name, BOOL srgb_name);
    2558 void surface_set_texture_target(IWineD3DSurface *iface, GLenum target);
     2564GLenum StencilOp(DWORD op) DECLSPEC_HIDDEN;
     2565GLenum CompareFunc(DWORD func) DECLSPEC_HIDDEN;
     2566BOOL is_invalid_op(IWineD3DDeviceImpl *This, int stage, WINED3DTEXTUREOP op,
     2567        DWORD arg1, DWORD arg2, DWORD arg3) DECLSPEC_HIDDEN;
     2568void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op,
     2569        DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
     2570void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords,
     2571        BOOL transformed, DWORD coordtype, BOOL ffp_can_disable_proj) DECLSPEC_HIDDEN;
     2572void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock,
     2573        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2574void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock,
     2575        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2576void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock,
     2577        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2578void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock,
     2579        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2580void state_fogcolor(DWORD state, IWineD3DStateBlockImpl *stateblock,
     2581        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2582void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock,
     2583        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2584void state_fogstartend(DWORD state, IWineD3DStateBlockImpl *stateblock,
     2585        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2586void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock,
     2587        struct wined3d_context *context) DECLSPEC_HIDDEN;
     2588
     2589void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect) DECLSPEC_HIDDEN;
     2590GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain) DECLSPEC_HIDDEN;
     2591void surface_load_ds_location(IWineD3DSurface *iface, struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
     2592void surface_modify_ds_location(IWineD3DSurface *iface, DWORD location) DECLSPEC_HIDDEN;
     2593void surface_set_compatible_renderbuffer(IWineD3DSurface *iface,
     2594        unsigned int width, unsigned int height) DECLSPEC_HIDDEN;
     2595void surface_set_texture_name(IWineD3DSurface *iface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
     2596void surface_set_texture_target(IWineD3DSurface *iface, GLenum target) DECLSPEC_HIDDEN;
    25592597
    25602598BOOL getColorBits(const struct GlPixelFormatDesc *format_desc,
    2561         short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize);
    2562 BOOL getDepthStencilBits(const struct GlPixelFormatDesc *format_desc, short *depthSize, short *stencilSize);
     2599        short *redSize, short *greenSize, short *blueSize, short *alphaSize, short *totalSize) DECLSPEC_HIDDEN;
     2600BOOL getDepthStencilBits(const struct GlPixelFormatDesc *format_desc,
     2601        short *depthSize, short *stencilSize) DECLSPEC_HIDDEN;
    25632602
    25642603/* Math utils */
    2565 void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2);
    2566 UINT wined3d_log2i(UINT32 x);
    2567 unsigned int count_bits(unsigned int mask);
     2604void multiply_matrix(WINED3DMATRIX *dest, const WINED3DMATRIX *src1, const WINED3DMATRIX *src2) DECLSPEC_HIDDEN;
     2605UINT wined3d_log2i(UINT32 x) DECLSPEC_HIDDEN;
     2606unsigned int count_bits(unsigned int mask) DECLSPEC_HIDDEN;
    25682607
    25692608typedef struct local_constant {
     
    25872626} SHADER_LIMITS;
    25882627
    2589 /** Keeps track of details for TEX_M#x# shader opcodes which need to
    2590    maintain state information between multiple codes */
     2628/* Keeps track of details for TEX_M#x# shader opcodes which need to
     2629 * maintain state information between multiple codes */
    25912630typedef struct SHADER_PARSE_STATE {
    25922631    unsigned int current_row;
     
    26012640
    26022641/* Base Shader utility functions. */
    2603 int shader_addline(struct wined3d_shader_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3);
    2604 int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_list args);
     2642int shader_addline(struct wined3d_shader_buffer *buffer, const char *fmt, ...) PRINTF_ATTR(2,3) DECLSPEC_HIDDEN;
     2643int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *fmt, va_list args) DECLSPEC_HIDDEN;
    26052644
    26062645/* Vertex shader utility functions */
    2607 extern BOOL vshader_get_input(
    2608     IWineD3DVertexShader* iface,
    2609     BYTE usage_req, BYTE usage_idx_req,
    2610     unsigned int* regnum);
    2611 
    2612 extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object);
     2646extern BOOL vshader_get_input(IWineD3DVertexShader *iface,
     2647        BYTE usage_req, BYTE usage_idx_req, unsigned int *regnum) DECLSPEC_HIDDEN;
     2648
     2649extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) DECLSPEC_HIDDEN;
    26132650
    26142651/*****************************************************************************
     
    26262663    const struct wined3d_shader_frontend *frontend;
    26272664    void *frontend_data;
     2665    void *backend_data;
     2666
     2667    IUnknown *parent;
     2668    const struct wined3d_parent_ops *parent_ops;
    26282669
    26292670    /* Programs this shader is linked with */
     
    26502691} IWineD3DBaseShaderImpl;
    26512692
    2652 void shader_buffer_clear(struct wined3d_shader_buffer *buffer);
    2653 BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer);
    2654 void shader_buffer_free(struct wined3d_shader_buffer *buffer);
    2655 void shader_cleanup(IWineD3DBaseShader *iface);
     2693void shader_buffer_clear(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
     2694BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
     2695void shader_buffer_free(struct wined3d_shader_buffer *buffer) DECLSPEC_HIDDEN;
     2696void shader_cleanup(IWineD3DBaseShader *iface) DECLSPEC_HIDDEN;
    26562697void shader_dump_src_param(const struct wined3d_shader_src_param *param,
    2657         const struct wined3d_shader_version *shader_version);
     2698        const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
    26582699void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
    2659         const struct wined3d_shader_version *shader_version);
     2700        const struct wined3d_shader_version *shader_version) DECLSPEC_HIDDEN;
     2701unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max) DECLSPEC_HIDDEN;
    26602702void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
    2661         const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx);
     2703        const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx) DECLSPEC_HIDDEN;
    26622704HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
    26632705        struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes,
    26642706        struct wined3d_shader_signature_element *input_signature,
    2665         struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size);
    2666 void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDevice *device);
    2667 BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage);
    2668 const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token);
    2669 void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction);
     2707        struct wined3d_shader_signature_element *output_signature,
     2708        const DWORD *byte_code, DWORD constf_size) DECLSPEC_HIDDEN;
     2709void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
     2710        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
     2711BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage) DECLSPEC_HIDDEN;
     2712const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token) DECLSPEC_HIDDEN;
     2713void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction) DECLSPEC_HIDDEN;
    26702714
    26712715static inline BOOL shader_is_pshader_version(enum wined3d_shader_type type)
     
    27352779 */
    27362780typedef struct IWineD3DVertexShaderImpl {
    2737     /* IUnknown parts*/   
     2781    /* IUnknown parts */
    27382782    const IWineD3DVertexShaderVtbl *lpVtbl;
    27392783
    27402784    /* IWineD3DBaseShader */
    27412785    IWineD3DBaseShaderClass     baseShader;
    2742 
    2743     /* IWineD3DVertexShaderImpl */
    2744     IUnknown                    *parent;
    2745 
    2746     DWORD                       usage;
    2747 
    2748     /* The GL shader */
    2749     void                        *backend_priv;
    27502786
    27512787    /* Vertex shader input and output semantics */
     
    27552791    UINT                       min_rel_offset, max_rel_offset;
    27562792    UINT                       rel_offset;
    2757 
    2758     UINT                       recompile_count;
    27592793} IWineD3DVertexShaderImpl;
    2760 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
    2761 
    2762 void find_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct vs_compile_args *args);
     2794
     2795void find_vs_compile_args(IWineD3DVertexShaderImpl *shader, IWineD3DStateBlockImpl *stateblock,
     2796        struct vs_compile_args *args) DECLSPEC_HIDDEN;
     2797HRESULT vertexshader_init(IWineD3DVertexShaderImpl *shader, IWineD3DDeviceImpl *device,
     2798        const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
     2799        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
    27632800
    27642801/*****************************************************************************
     
    27902827    IWineD3DBaseShaderClass     baseShader;
    27912828
    2792     /* IWineD3DPixelShaderImpl */
    2793     IUnknown                   *parent;
    2794 
    27952829    /* Pixel shader input semantics */
    27962830    struct wined3d_shader_signature_element input_signature[MAX_REG_INPUT];
     
    27992833    unsigned int declared_in_count;
    28002834
    2801     /* The GL shader */
    2802     void                        *backend_priv;
    2803 
    28042835    /* Some information about the shader behavior */
    28052836    char                        vpos_uniform;
     
    28102841} IWineD3DPixelShaderImpl;
    28112842
    2812 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
    2813 void pixelshader_update_samplers(struct shader_reg_maps *reg_maps, IWineD3DBaseTexture * const *textures);
    2814 void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args);
     2843HRESULT pixelshader_init(IWineD3DPixelShaderImpl *shader, IWineD3DDeviceImpl *device,
     2844        const DWORD *byte_code, const struct wined3d_shader_signature *output_signature,
     2845        IUnknown *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN;
     2846void pixelshader_update_samplers(struct shader_reg_maps *reg_maps,
     2847        IWineD3DBaseTexture * const *textures) DECLSPEC_HIDDEN;
     2848void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock,
     2849        struct ps_compile_args *args) DECLSPEC_HIDDEN;
    28152850
    28162851/* sRGB correction constants */
     
    28422877};
    28432878
    2844 extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl;
    2845 DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags);
     2879extern const IWineD3DPaletteVtbl IWineD3DPalette_Vtbl DECLSPEC_HIDDEN;
     2880DWORD IWineD3DPaletteImpl_Size(DWORD dwFlags) DECLSPEC_HIDDEN;
    28462881
    28472882/* DirectDraw utility functions */
    2848 extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
     2883extern WINED3DFORMAT pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN;
    28492884
    28502885/*****************************************************************************
     
    28612896#define WINED3DFMT_FLAG_FBO_ATTACHABLE           0x40
    28622897#define WINED3DFMT_FLAG_COMPRESSED               0x80
     2898#define WINED3DFMT_FLAG_GETDC                    0x100
    28632899
    28642900struct GlPixelFormatDesc
     
    28942930};
    28952931
    2896 const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const struct wined3d_gl_info *gl_info);
     2932const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
     2933        const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
    28972934
    28982935static inline BOOL use_vs(IWineD3DStateBlockImpl *stateblock)
    28992936{
     2937    /* Check stateblock->vertexDecl to allow this to be used from
     2938     * IWineD3DDeviceImpl_FindTexUnitMap(). This is safe because
     2939     * stateblock->vertexShader implies a vertex declaration instead of ddraw
     2940     * style strided data. */
    29002941    return (stateblock->vertexShader
    2901             && !stateblock->wineD3DDevice->strided_streams.position_transformed
     2942            && !((IWineD3DVertexDeclarationImpl *)stateblock->vertexDecl)->position_transformed
    29022943            && stateblock->wineD3DDevice->vs_selected_mode != SHADER_NONE);
    29032944}
     
    29092950}
    29102951
    2911 void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED3DRECT *src_rect,
    2912         IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip);
     2952void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface,
     2953        WINED3DRECT *src_rect, IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect,
     2954        const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) DECLSPEC_HIDDEN;
    29132955
    29142956/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette