VirtualBox

Changeset 35822 in vbox for trunk/src/VBox/Additions


Ignore:
Timestamp:
Feb 2, 2011 1:23:37 PM (14 years ago)
Author:
vboxsync
Message:

wined3d: properly recreate shaders if multiply swapchains are used

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

Legend:

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

    r33656 r35822  
    191191    unsigned char                   numbumpenvmatconsts;
    192192    char                            num_int_consts;
     193    const struct wined3d_context    *context;
    193194};
    194195
     
    223224    char                            need_color_unclamp;
    224225    UINT                            pos_fixup;
     226    const struct wined3d_context    *context;
    225227};
    226228
     
    40664068
    40674069/* GL locking is done by the caller */
    4068 static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *shader, const struct arb_ps_compile_args *args)
     4070static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl *shader,
     4071    const struct arb_ps_compile_args *args, const struct wined3d_context *context)
    40694072{
    40704073    UINT i;
     
    41044107     */
    41054108    for(i = 0; i < shader_data->num_gl_shaders; i++) {
    4106         if(memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) {
     4109        if(shader_data->gl_shaders[i].context==context
     4110           && memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) {
    41074111            return &shader_data->gl_shaders[i];
    41084112        }
     
    41294133    }
    41304134
     4135    shader_data->gl_shaders[shader_data->num_gl_shaders].context = context;
    41314136    shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
    41324137
     
    41614166}
    41624167
    4163 static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl *shader, const struct arb_vs_compile_args *args)
     4168static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl *shader,
     4169    const struct arb_vs_compile_args *args, const struct wined3d_context *context)
    41644170{
    41654171    UINT i;
     
    41834189     */
    41844190    for(i = 0; i < shader_data->num_gl_shaders; i++) {
    4185         if (vs_args_equal(&shader_data->gl_shaders[i].args, args,
    4186                 use_map, gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]))
     4191        if (shader_data->gl_shaders[i].context==context
     4192            && vs_args_equal(&shader_data->gl_shaders[i].args, args,
     4193                             use_map, gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]))
    41874194        {
    41884195            return &shader_data->gl_shaders[i];
     
    42114218    }
    42124219
     4220    shader_data->gl_shaders[shader_data->num_gl_shaders].context = context;
    42134221    shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
    42144222
     
    43784386        TRACE("Using pixel shader %p\n", This->stateBlock->pixelShader);
    43794387        find_arb_ps_compile_args(ps, This->stateBlock, &compile_args);
    4380         compiled = find_arb_pshader(ps, &compile_args);
     4388        compiled = find_arb_pshader(ps, &compile_args, context);
    43814389        priv->current_fprogram_id = compiled->prgId;
    43824390        priv->compiled_fprog = compiled;
     
    44344442        TRACE("Using vertex shader %p\n", This->stateBlock->vertexShader);
    44354443        find_arb_vs_compile_args(vs, This->stateBlock, &compile_args);
    4436         compiled = find_arb_vshader(vs, &compile_args);
     4444        compiled = find_arb_vshader(vs, &compile_args, context);
    44374445        priv->current_vprogram_id = compiled->prgId;
    44384446        priv->compiled_vprog = compiled;
     
    45304538            for (i = 0; i < shader_data->num_gl_shaders; ++i)
    45314539            {
    4532                 GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId));
    4533                 checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))");
     4540                if (shader_data->gl_shaders[i].context==context_get_current())
     4541                {
     4542                    GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId));
     4543                    checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))");
     4544                }
     4545                else
     4546                {
     4547                    WARN("Attempting to delete fprog %u created in ctx %p from ctx %p\n",
     4548                         shader_data->gl_shaders[i].prgId, shader_data->gl_shaders[i].context, context_get_current());
     4549                }
    45344550            }
    45354551            LEAVE_GL();
     
    45564572            for (i = 0; i < shader_data->num_gl_shaders; ++i)
    45574573            {
    4558                 GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId));
    4559                 checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))");
     4574                if (shader_data->gl_shaders[i].context==context_get_current())
     4575                {
     4576                    GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId));
     4577                    checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))");
     4578                }
     4579                else
     4580                {
     4581                    WARN("Attempting to delete vprog %u created in ctx %p from ctx %p\n",
     4582                         shader_data->gl_shaders[i].prgId, shader_data->gl_shaders[i].context, context_get_current());
     4583                }
    45604584            }
    45614585            LEAVE_GL();
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/glsl_shader.c

    r35713 r35822  
    126126    struct ps_compile_args      ps_args;
    127127    UINT                        constant_version;
     128    const struct wined3d_context *context;
    128129#ifdef VBOX_WITH_WDDM
    129130    UINT                        inp2Fixup_info;
     
    145146
    146147typedef struct {
    147     IWineD3DVertexShader        *vshader;
    148     IWineD3DPixelShader         *pshader;
    149     struct ps_compile_args      ps_args;
    150     struct vs_compile_args      vs_args;
     148    IWineD3DVertexShader         *vshader;
     149    IWineD3DPixelShader          *pshader;
     150    struct ps_compile_args       ps_args;
     151    struct vs_compile_args       vs_args;
     152    const struct wined3d_context *context;
    151153} glsl_program_key_t;
    152154
     
    162164    struct ps_np2fixup_info         np2fixup;
    163165    GLhandleARB                     prgId;
     166    const struct wined3d_context    *context;
    164167};
    165168
     
    174177    struct vs_compile_args          args;
    175178    GLhandleARB                     prgId;
     179    const struct wined3d_context    *context;
    176180};
    177181
     
    36673671    key.vs_args = entry->vs_args;
    36683672    key.ps_args = entry->ps_args;
     3673    key.context = entry->context;
    36693674
    36703675    if (wine_rb_put(&priv->program_lookup, &key, &entry->program_lookup_entry) == -1)
     
    36763681static struct glsl_shader_prog_link *get_glsl_program_entry(struct shader_glsl_priv *priv,
    36773682        IWineD3DVertexShader *vshader, IWineD3DPixelShader *pshader, struct vs_compile_args *vs_args,
    3678         struct ps_compile_args *ps_args) {
     3683        struct ps_compile_args *ps_args, const struct wined3d_context *context) {
    36793684    struct wine_rb_entry *entry;
    36803685    glsl_program_key_t key;
     
    36843689    key.vs_args = *vs_args;
    36853690    key.ps_args = *ps_args;
     3691    key.context = context;
    36863692
    36873693    entry = wine_rb_get(&priv->program_lookup, &key);
     
    36993705    key.vs_args = entry->vs_args;
    37003706    key.ps_args = entry->ps_args;
     3707    key.context = entry->context;
    37013708    wine_rb_remove(&priv->program_lookup, &key);
    37023709
    3703     TRACE("deleting program %u\n", entry->programId);
    3704     GL_EXTCALL(glDeleteObjectARB(entry->programId));
    3705     checkGLcall("glDeleteObjectARB");
     3710    if (context_get_current() == entry->context)
     3711    {
     3712        TRACE("deleting program %u\n", entry->programId);
     3713        GL_EXTCALL(glDeleteObjectARB(entry->programId));
     3714        checkGLcall("glDeleteObjectARB");
     3715    }
     3716    else
     3717    {
     3718        WARN("Attempting to delete program %u created in ctx %p from ctx %p\n", entry->programId, entry->context, context_get_current());
     3719    }
     3720   
    37063721    if (entry->vshader) list_remove(&entry->vshader_entry);
    37073722    if (entry->pshader) list_remove(&entry->pshader_entry);
     
    42524267     */
    42534268    for(i = 0; i < shader_data->num_gl_shaders; i++) {
    4254         if(memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) {
     4269        if(shader_data->gl_shaders[i].context==context
     4270           && memcmp(&shader_data->gl_shaders[i].args, args, sizeof(*args)) == 0) {
    42554271            if(args->np2_fixup) {
    42564272#ifdef VBOX_WITH_WDDM
     
    42844300    }
    42854301
     4302    shader_data->gl_shaders[shader_data->num_gl_shaders].context = context;
    42864303    shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
    42874304
     
    43384355     */
    43394356    for(i = 0; i < shader_data->num_gl_shaders; i++) {
    4340         if(vs_args_equal(&shader_data->gl_shaders[i].args, args, use_map)) {
     4357        if(shader_data->gl_shaders[i].context==context
     4358           && vs_args_equal(&shader_data->gl_shaders[i].args, args, use_map)) {
    43414359            return shader_data->gl_shaders[i].prgId;
    43424360        }
     
    43644382    }
    43654383
     4384    shader_data->gl_shaders[shader_data->num_gl_shaders].context = context;
    43664385    shader_data->gl_shaders[shader_data->num_gl_shaders].args = *args;
    43674386
     
    44014420    if (pshader) find_ps_compile_args((IWineD3DPixelShaderImpl *)pshader, device->stateBlock, &ps_compile_args);
    44024421
    4403     entry = get_glsl_program_entry(priv, vshader, pshader, &vs_compile_args, &ps_compile_args);
     4422    entry = get_glsl_program_entry(priv, vshader, pshader, &vs_compile_args, &ps_compile_args, context);
    44044423    if (entry) {
    44054424        priv->glsl_program = entry;
     
    44134432    /* Create the entry */
    44144433    entry = HeapAlloc(GetProcessHeap(), 0, sizeof(struct glsl_shader_prog_link));
     4434    entry->context = context;
    44154435    entry->programId = programId;
    44164436    entry->vshader = vshader;
     
    48124832        ENTER_GL();
    48134833        for(i = 0; i < shader_data->num_gl_shaders; i++) {
    4814             TRACE("deleting pshader %u\n", shader_data->gl_shaders[i].prgId);
    4815             GL_EXTCALL(glDeleteObjectARB(shader_data->gl_shaders[i].prgId));
    4816             checkGLcall("glDeleteObjectARB");
     4834            if (shader_data->gl_shaders[i].context==context_get_current())
     4835            {
     4836                TRACE("deleting pshader %u\n", shader_data->gl_shaders[i].prgId);
     4837                GL_EXTCALL(glDeleteObjectARB(shader_data->gl_shaders[i].prgId));
     4838                checkGLcall("glDeleteObjectARB");
     4839            }
     4840            else
     4841            {
     4842                WARN("Attempting to delete pshader %u created in ctx %p from ctx %p\n",
     4843                     shader_data->gl_shaders[i].prgId, shader_data->gl_shaders[i].context, context_get_current());
     4844            }
    48174845        }
    48184846        LEAVE_GL();
     
    48264854        ENTER_GL();
    48274855        for(i = 0; i < shader_data->num_gl_shaders; i++) {
    4828             TRACE("deleting vshader %u\n", shader_data->gl_shaders[i].prgId);
    4829             GL_EXTCALL(glDeleteObjectARB(shader_data->gl_shaders[i].prgId));
    4830             checkGLcall("glDeleteObjectARB");
     4856            if (shader_data->gl_shaders[i].context==context_get_current())
     4857            {
     4858                TRACE("deleting vshader %u\n", shader_data->gl_shaders[i].prgId);
     4859                GL_EXTCALL(glDeleteObjectARB(shader_data->gl_shaders[i].prgId));
     4860                checkGLcall("glDeleteObjectARB");
     4861            }
     4862            else
     4863            {
     4864                WARN("Attempting to delete vshader %u created in ctx %p from ctx %p\n",
     4865                     shader_data->gl_shaders[i].prgId, shader_data->gl_shaders[i].context, context_get_current());
     4866            }
    48314867        }
    48324868        LEAVE_GL();
     
    48464882            const struct glsl_shader_prog_link, program_lookup_entry);
    48474883    int cmp;
     4884
     4885    if (k->context > prog->context) return 1;
     4886    else if (k->context < prog->context) return -1;
    48484887
    48494888    if (k->vshader > prog->vshader) return 1;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r35720 r35822  
    709709};
    710710
     711struct wined3d_context;
     712
    711713/* Stateblock dependent parameters which have to be hardcoded
    712714 * into the shader code
     
    736738    WORD                        swizzle_map;   /* MAX_ATTRIBS, 16 */
    737739};
    738 
    739 struct wined3d_context;
    740740
    741741typedef struct {
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