VirtualBox

Changeset 39899 in vbox for trunk/src/VBox/Additions/WINNT


Ignore:
Timestamp:
Jan 27, 2012 3:46:44 PM (13 years ago)
Author:
vboxsync
Message:

wine/wddm: shared resource handling fixes, state fixes - working powershell_ise

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

Legend:

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

    r38982 r39899  
    266266}
    267267
     268void basetexture_state_init(IWineD3DBaseTexture *iface, struct gl_texture *gl_tex)
     269{
     270    /* Initialise the state of the texture object
     271    to the openGL defaults, not the directx defaults */
     272    gl_tex->states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_WRAP;
     273    gl_tex->states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_WRAP;
     274    gl_tex->states[WINED3DTEXSTA_ADDRESSW]      = WINED3DTADDRESS_WRAP;
     275    gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]   = 0;
     276    gl_tex->states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_LINEAR;
     277    gl_tex->states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
     278    gl_tex->states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
     279    gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL]   = 0;
     280    gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
     281    gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE]   = 0;
     282    gl_tex->states[WINED3DTEXSTA_ELEMENTINDEX]  = 0;
     283    gl_tex->states[WINED3DTEXSTA_DMAPOFFSET]    = 0;
     284    gl_tex->states[WINED3DTEXSTA_TSSADDRESSW]   = WINED3DTADDRESS_WRAP;
     285    IWineD3DBaseTexture_SetDirty(iface, TRUE);
     286}
     287
    268288/* Context activation is done by the caller. */
    269289HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc)
     
    291311        if (VBOXSHRC_IS_SHARED_OPENED(This))
    292312        {
     313            ERR("should not be here!");
    293314            gl_tex->name = (GLuint)VBOXSHRC_GET_SHAREHANDLE(This);
     315            TRACE("Assigned shared texture %d\n", gl_tex->name);
    294316        }
    295317        else
     
    298320            isNewTexture = TRUE;
    299321            glGenTextures(1, &gl_tex->name);
     322            checkGLcall("glGenTextures");
     323            TRACE("Generated texture %d\n", gl_tex->name);
    300324#ifdef VBOX_WITH_WDDM
    301325            if (VBOXSHRC_IS_SHARED(This))
     
    305329#endif
    306330        }
    307         checkGLcall("glGenTextures");
    308         TRACE("Generated texture %d\n", gl_tex->name);
    309331#ifndef VBOX_WITH_WDDM
    310332        if (This->resource.pool == WINED3DPOOL_DEFAULT) {
     
    321343        /* Initialise the state of the texture object
    322344        to the openGL defaults, not the directx defaults */
    323         gl_tex->states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_WRAP;
    324         gl_tex->states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_WRAP;
    325         gl_tex->states[WINED3DTEXSTA_ADDRESSW]      = WINED3DTADDRESS_WRAP;
    326         gl_tex->states[WINED3DTEXSTA_BORDERCOLOR]   = 0;
    327         gl_tex->states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_LINEAR;
    328         gl_tex->states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT; /* GL_NEAREST_MIPMAP_LINEAR */
    329         gl_tex->states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_LINEAR; /* GL_NEAREST_MIPMAP_LINEAR */
    330         gl_tex->states[WINED3DTEXSTA_MAXMIPLEVEL]   = 0;
    331         gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] = 1;
    332         gl_tex->states[WINED3DTEXSTA_SRGBTEXTURE]   = 0;
    333         gl_tex->states[WINED3DTEXSTA_ELEMENTINDEX]  = 0;
    334         gl_tex->states[WINED3DTEXSTA_DMAPOFFSET]    = 0;
    335         gl_tex->states[WINED3DTEXSTA_TSSADDRESSW]   = WINED3DTADDRESS_WRAP;
    336         IWineD3DBaseTexture_SetDirty(iface, TRUE);
     345        basetexture_state_init(iface, gl_tex);
    337346
    338347        if(isNewTexture
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/context.c

    r39869 r39899  
    26492649
    26502650        case CTXUSAGE_BLIT:
    2651         case CTXUSAGE_BLIT_LIGHT:
    26522651            if (wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
    26532652                if (!context->render_offscreen) context_validate_onscreen_formats(device, context);
     
    26832682    switch(usage) {
    26842683        case CTXUSAGE_RESOURCELOAD:
    2685         case CTXUSAGE_BLIT_LIGHT:
    26862684            /* This does not require any special states to be set up */
    26872685            break;
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c

    r39649 r39899  
    532532        if (!VBOXSHRC_IS_SHARED_OPENED(surface))
    533533        {
     534            struct wined3d_context * context;
     535
    534536            Assert(!(*shared_handle));
    535537            *shared_handle = VBOXSHRC_GET_SHAREHANDLE(surface);
     538
     539            Assert(!device->isInDraw);
     540
     541            /* flush to ensure the texture is allocated before it is used by another
     542             * process opening it */
     543            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
     544            if (context->valid)
     545            {
     546                wglFlush();
     547            }
     548            else
     549            {
     550                ERR("invalid context!");
     551            }
     552            context_release(context);
    536553        }
    537554        else
     
    9901007    GLenum internal;
    9911008
     1009#ifdef VBOX_WITH_WDDM
     1010    if (VBOXSHRC_IS_SHARED_OPENED(This))
     1011    {
     1012        ERR("trying to allocate shared openned resource!!, ignoring..\n");
     1013        return;
     1014    }
     1015#endif
     1016
    9921017    if (srgb)
    9931018    {
     
    10351060    }
    10361061
    1037 #ifdef VBOX_WITH_WDDM
    1038     if (!VBOXSHRC_IS_SHARED_OPENED(This))
    1039 #endif
    1040     {
    1041         if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED && mem)
    1042         {
    1043             GL_EXTCALL(glCompressedTexImage2DARB(This->texture_target, This->texture_level,
    1044                     internal, width, height, 0, This->resource.size, mem));
    1045         }
    1046         else
    1047         {
    1048             glTexImage2D(This->texture_target, This->texture_level,
    1049                     internal, width, height, 0, format_desc->glFormat, format_desc->glType, mem);
    1050             checkGLcall("glTexImage2D");
    1051         }
     1062    if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED && mem)
     1063    {
     1064        GL_EXTCALL(glCompressedTexImage2DARB(This->texture_target, This->texture_level,
     1065                internal, width, height, 0, This->resource.size, mem));
     1066    }
     1067    else
     1068    {
     1069        glTexImage2D(This->texture_target, This->texture_level,
     1070                internal, width, height, 0, format_desc->glFormat, format_desc->glType, mem);
     1071        checkGLcall("glTexImage2D");
    10521072    }
    10531073
     
    18031823    IWineD3DDeviceImpl *device = This->resource.device;
    18041824    const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
    1805     struct wined3d_context * context = NULL;
    1806     if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
    1807 
    1808     surface_prepare_texture(This, gl_info, FALSE);
    1809     /* no need to bind it here */
    1810 //    surface_bind_and_dirtify(This, FALSE);
    1811 
    1812     if (context) context_release(context);
     1825    DWORD alloc_flag = SFLAG_ALLOCATED;
     1826    CONVERT_TYPES convert;
     1827    struct wined3d_format_desc desc;
     1828    IWineD3DBaseTexture *baseTexture = NULL;
     1829
     1830    d3dfmt_get_conv(This, TRUE, TRUE, &desc, &convert);
     1831    if(convert != NO_CONVERSION) This->Flags |= SFLAG_CONVERTED;
     1832    else This->Flags &= ~SFLAG_CONVERTED;
     1833
     1834    if (IWineD3DSurface_GetContainer((IWineD3DSurface*)This, &IID_IWineD3DBaseTexture, (void **)&baseTexture) == WINED3D_OK) {
     1835        IWineD3DTextureImpl* pTex = (IWineD3DTextureImpl*)baseTexture;
     1836        if (!pTex->baseTexture.texture_rgb.name)
     1837        {
     1838            pTex->baseTexture.texture_rgb.name = (GLuint)VBOXSHRC_GET_SHAREHANDLE(pTex);
     1839            /* @todo: this is not entirely correct: need to share this state among all instances of the given shared resource */
     1840            texture_state_init((IWineD3DTexture*)baseTexture, &pTex->baseTexture.texture_rgb);
     1841        }
     1842        IWineD3DBaseTexture_Release(baseTexture);
     1843    }
     1844    This->Flags |= alloc_flag;
     1845
     1846    This->texture_name = (GLuint)VBOXSHRC_GET_SHAREHANDLE(This);
    18131847
    18141848    IWineD3DSurface_ModifyLocation((IWineD3DSurface*)This, SFLAG_INTEXTURE, TRUE);
     
    28562890                if (VBOXSHRC_IS_SHARED_OPENED(This))
    28572891                {
     2892                    ERR("should not be here!");
    28582893                    *name = (GLuint)VBOXSHRC_GET_SHAREHANDLE(This);
    28592894                }
     
    28622897                {
    28632898                    glGenTextures(1, name);
     2899                    checkGLcall("glGenTextures");
     2900                    TRACE("Surface %p given name %d\n", This, *name);
     2901
     2902                    glBindTexture(This->texture_target, *name);
     2903                    checkGLcall("glBindTexture");
     2904                    glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
     2905                    checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
     2906                    glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     2907                    checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)");
     2908                    glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
     2909                    checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE)");
     2910                    glTexParameteri(This->texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
     2911                    checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
     2912                    glTexParameteri(This->texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
     2913                    checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
    28642914#ifdef VBOX_WITH_WDDM
    28652915                    if (VBOXSHRC_IS_SHARED(This))
     
    28692919#endif
    28702920                }
    2871                 checkGLcall("glGenTextures");
    2872                 TRACE("Surface %p given name %d\n", This, *name);
    2873 
    2874                 glBindTexture(This->texture_target, *name);
    2875                 checkGLcall("glBindTexture");
    2876                 glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    2877                 checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE)");
    2878                 glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    2879                 checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)");
    2880                 glTexParameteri(This->texture_target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
    2881                 checkGLcall("glTexParameteri(dimension, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE)");
    2882                 glTexParameteri(This->texture_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    2883                 checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MIN_FILTER, GL_NEAREST)");
    2884                 glTexParameteri(This->texture_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    2885                 checkGLcall("glTexParameteri(dimension, GL_TEXTURE_MAG_FILTER, GL_NEAREST)");
    28862921            }
    28872922            /* This is where we should be reducing the amount of GLMemoryUsed */
     
    33063341    }
    33073342
    3308     context = context_acquire(myDevice, SrcSurface,
    3309 #ifdef VBOX_WITH_WDDM
    3310             CTXUSAGE_BLIT_LIGHT
    3311 #else
    3312             CTXUSAGE_BLIT
    3313 #endif
    3314             );
     3343    context = context_acquire(myDevice, SrcSurface, CTXUSAGE_BLIT);
    33153344
    33163345    surface_internal_preload((IWineD3DSurface *) This, SRGB_RGB);
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/texture.c

    r38982 r39899  
    473473};
    474474
     475void texture_state_init(IWineD3DTexture *iface, struct gl_texture *gl_tex)
     476{
     477    basetexture_state_init((IWineD3DBaseTexture*)iface, gl_tex);
     478    if(IWineD3DBaseTexture_IsCondNP2(iface)) {
     479        gl_tex->states[WINED3DTEXSTA_ADDRESSU]      = WINED3DTADDRESS_CLAMP;
     480        gl_tex->states[WINED3DTEXSTA_ADDRESSV]      = WINED3DTADDRESS_CLAMP;
     481        gl_tex->states[WINED3DTEXSTA_MAGFILTER]     = WINED3DTEXF_POINT;
     482        gl_tex->states[WINED3DTEXSTA_MINFILTER]     = WINED3DTEXF_POINT;
     483        gl_tex->states[WINED3DTEXSTA_MIPFILTER]     = WINED3DTEXF_NONE;
     484    }
     485}
     486
    475487HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
    476488        IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
     
    687699        }
    688700#endif
     701
     702        if (!VBOXSHRC_IS_SHARED_OPENED(texture))
     703        {
     704            struct wined3d_context * context;
     705
     706            Assert(!device->isInDraw);
     707
     708            /* flush to ensure the texture is allocated before it is used by another
     709             * process opening it */
     710            context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD);
     711            if (context->valid)
     712            {
     713                wglFlush();
     714            }
     715            else
     716            {
     717                ERR("invalid context!");
     718            }
     719            context_release(context);
     720        }
    689721    }
    690722    else
  • trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/wined3d_private.h

    r39602 r39899  
    12661266    CTXUSAGE_BLIT               = 3,    /* OpenGL states are set up 3D drawing */
    12671267    CTXUSAGE_CLEAR              = 4,    /* Drawable and states are set up for clearing */
    1268     CTXUSAGE_BLIT_LIGHT         = 5,    /* OpenGL states are set up 3D drawing */
    12691268} ContextUsage;
    12701269
     
    19871986        const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1],
    19881987        const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
     1988void basetexture_state_init(IWineD3DBaseTexture *iface, struct gl_texture *gl_tex);
    19891989HRESULT basetexture_bind(IWineD3DBaseTexture *iface, BOOL srgb, BOOL *set_surface_desc) DECLSPEC_HIDDEN;
    19901990void basetexture_cleanup(IWineD3DBaseTexture *iface) DECLSPEC_HIDDEN;
     
    20252025} IWineD3DTextureImpl;
    20262026
     2027void texture_state_init(IWineD3DTexture *iface, struct gl_texture *gl_tex);
    20272028HRESULT texture_init(IWineD3DTextureImpl *texture, UINT width, UINT height, UINT levels,
    20282029        IWineD3DDeviceImpl *device, DWORD usage, WINED3DFORMAT format, WINED3DPOOL pool,
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