VirtualBox

Ignore:
Timestamp:
Apr 19, 2010 3:27:01 PM (15 years ago)
Author:
vboxsync
Message:

crOpenGL: update to wine 1.1.43

File:
1 edited

Legend:

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

    r25949 r28475  
    124124        gl_filter = GL_LINEAR;
    125125
    126     if (gl_info->fbo_ops.glBlitFramebuffer)
     126    if (gl_info->fbo_ops.glBlitFramebuffer && is_identity_fixup(backbuffer->resource.format_desc->color_fixup))
    127127    {
    128128        ENTER_GL();
    129129        context_bind_fbo(context, GL_READ_FRAMEBUFFER, &context->src_fbo);
    130         context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, This->backBuffer[0]);
     130        context_attach_surface_fbo(context, GL_READ_FRAMEBUFFER, 0, backbuffer);
    131131        context_attach_depth_stencil_fbo(context, GL_READ_FRAMEBUFFER, NULL, FALSE);
    132132
     
    162162        }
    163163
     164        if (is_complex_fixup(backbuffer->resource.format_desc->color_fixup))
     165            gl_filter = GL_NEAREST;
     166
    164167        ENTER_GL();
    165168        context_bind_fbo(context2, GL_DRAW_FRAMEBUFFER, NULL);
     
    168171         * so there are no d3d texture settings to dirtify
    169172         */
    170         device->blitter->set_shader((IWineD3DDevice *) device, backbuffer->resource.format_desc,
    171                                     backbuffer->texture_target, backbuffer->pow2Width,
    172                                     backbuffer->pow2Height);
    173         glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    174         glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
     173        device->blitter->set_shader((IWineD3DDevice *) device, backbuffer);
     174        glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MIN_FILTER, gl_filter);
     175        glTexParameteri(backbuffer->texture_target, GL_TEXTURE_MAG_FILTER, gl_filter);
    175176
    176177        context_set_draw_buffer(context, GL_BACK);
     
    227228    int retval;
    228229
     230    IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride);
     231
    229232    context = context_acquire(This->device, This->backBuffer[0], CTXUSAGE_RESOURCELOAD);
     233    if (!context->valid)
     234    {
     235        context_release(context);
     236        WARN("Invalid context, skipping present.\n");
     237        return WINED3D_OK;
     238    }
    230239
    231240    /* Render the cursor onto the back buffer, using our nifty directdraw blitting code :-) */
     
    257266        cursor.currentDesc.Width = This->device->cursorWidth;
    258267        cursor.currentDesc.Height = This->device->cursorHeight;
    259         cursor.glRect.left = 0;
    260         cursor.glRect.top = 0;
    261         cursor.glRect.right = cursor.currentDesc.Width;
    262         cursor.glRect.bottom = cursor.currentDesc.Height;
    263268        /* The cursor must have pow2 sizes */
    264269        cursor.pow2Width = cursor.currentDesc.Width;
     
    282287    }
    283288
    284     TRACE("presetting HDC %p\n", This->context[0]->hdc);
    285 
    286     /* Don't call checkGLcall, as glGetError is not applicable here */
    287     if (hDestWindowOverride && This->win_handle != hDestWindowOverride) {
    288         IWineD3DSwapChain_SetDestWindowOverride(iface, hDestWindowOverride);
    289     }
     289    TRACE("Presenting HDC %p.\n", context->hdc);
    290290
    291291    render_to_fbo = This->render_to_fbo;
     
    353353    }
    354354
    355     SwapBuffers(This->context[0]->hdc); /* TODO: cycle through the swapchain buffers */
     355    if (This->num_contexts > 1) wglFinish();
     356    SwapBuffers(context->hdc); /* TODO: cycle through the swapchain buffers */
    356357
    357358    TRACE("SwapBuffers called, Starting new frame\n");
     
    526527}
    527528
    528 static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapChain *iface, HWND window) {
    529     IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
    530     WINED3DLOCKED_RECT r;
    531     BYTE *mem;
    532 
    533     if(window == This->win_handle) return WINED3D_OK;
    534 
    535     TRACE("Performing dest override of swapchain %p from window %p to %p\n", This, This->win_handle, window);
    536     if (This->context[0] == This->device->contexts[0])
    537     {
    538         /* The primary context 'owns' all the opengl resources. Destroying and recreating that context requires downloading
    539          * all opengl resources, deleting the gl resources, destroying all other contexts, then recreating all other contexts
    540          * and reload the resources
    541          */
    542         delete_opengl_contexts((IWineD3DDevice *)This->device, iface);
    543         This->win_handle = window;
    544         create_primary_opengl_context((IWineD3DDevice *)This->device, iface);
    545     }
    546     else
    547     {
    548         This->win_handle = window;
    549 
    550         /* The old back buffer has to be copied over to the new back buffer. A lockrect - switchcontext - unlockrect
    551          * would suffice in theory, but it is rather nasty and may cause troubles with future changes of the locking code
    552          * So lock read only, copy the surface out, then lock with the discard flag and write back
    553          */
    554         IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_READONLY);
    555         mem = HeapAlloc(GetProcessHeap(), 0, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
    556         memcpy(mem, r.pBits, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
    557         IWineD3DSurface_UnlockRect(This->backBuffer[0]);
    558 
    559         context_destroy(This->device, This->context[0]);
    560         This->context[0] = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
    561                 This->win_handle, FALSE /* pbuffer */, &This->presentParms);
    562         context_release(This->context[0]);
    563 
    564         IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_DISCARD);
    565         memcpy(r.pBits, mem, r.Pitch * ((IWineD3DSurfaceImpl *) This->backBuffer[0])->currentDesc.Height);
    566         HeapFree(GetProcessHeap(), 0, mem);
    567         IWineD3DSurface_UnlockRect(This->backBuffer[0]);
    568     }
     529static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapChain *iface, HWND window)
     530{
     531    IWineD3DSwapChainImpl *swapchain = (IWineD3DSwapChainImpl *)iface;
     532
     533    if (!window) window = swapchain->device_window;
     534    if (window == swapchain->win_handle) return WINED3D_OK;
     535
     536    TRACE("Setting swapchain %p window from %p to %p\n", swapchain, swapchain->win_handle, window);
     537    swapchain->win_handle = window;
     538
    569539    return WINED3D_OK;
    570540}
     
    611581{
    612582    IWineD3DDeviceImpl *device = swapchain->device;
    613     HWND window = swapchain->win_handle;
     583    HWND window = swapchain->device_window;
    614584    BOOL filter_messages;
    615585    LONG style, exstyle;
     
    645615{
    646616    IWineD3DDeviceImpl *device = swapchain->device;
    647     HWND window = swapchain->win_handle;
     617    HWND window = swapchain->device_window;
    648618    BOOL filter_messages;
    649619    LONG style, exstyle;
     
    683653{
    684654    const struct wined3d_adapter *adapter = device->adapter;
    685     const struct GlPixelFormatDesc *format_desc;
     655    const struct wined3d_format_desc *format_desc;
    686656    BOOL displaymode_set = FALSE;
    687657    WINED3DDISPLAYMODE mode;
     
    725695    swapchain->ref = 1;
    726696    swapchain->win_handle = window;
     697    swapchain->device_window = window;
    727698
    728699    if (!present_parameters->Windowed && window)
     
    828799    if (surface_type == SURFACE_OPENGL)
    829800    {
    830         swapchain->context[0] = context_create(device, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
    831                 window, FALSE /* pbuffer */, present_parameters);
     801        const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     802
     803        /* In WGL both color, depth and stencil are features of a pixel format. In case of D3D they are separate.
     804         * You are able to add a depth + stencil surface at a later stage when you need it.
     805         * In order to support this properly in WineD3D we need the ability to recreate the opengl context and
     806         * drawable when this is required. This is very tricky as we need to reapply ALL opengl states for the new
     807         * context, need torecreate shaders, textures and other resources.
     808         *
     809         * The context manager already takes care of the state problem and for the other tasks code from Reset
     810         * can be used. These changes are way to risky during the 1.0 code freeze which is taking place right now.
     811         * Likely a lot of other new bugs will be exposed. For that reason request a depth stencil surface all the
     812         * time. It can cause a slight performance hit but fixes a lot of regressions. A fixme reminds of that this
     813         * issue needs to be fixed. */
     814        if (!present_parameters->EnableAutoDepthStencil
     815                || swapchain->presentParms.AutoDepthStencilFormat != WINED3DFMT_D24_UNORM_S8_UINT)
     816        {
     817            FIXME("Add OpenGL context recreation support to context_validate_onscreen_formats\n");
     818        }
     819        swapchain->ds_format = getFormatDescEntry(WINED3DFMT_D24_UNORM_S8_UINT, gl_info);
     820        swapchain->context[0] = context_create(swapchain, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
     821                swapchain->ds_format);
    832822        if (!swapchain->context[0])
    833823        {
     
    923913    }
    924914
    925     if (swapchain->context && swapchain->context[0])
    926     {
    927         context_release(swapchain->context[0]);
    928         context_destroy(device, swapchain->context[0]);
     915    if (swapchain->context)
     916    {
     917        if (swapchain->context[0])
     918        {
     919            context_release(swapchain->context[0]);
     920            context_destroy(device, swapchain->context[0]);
     921            swapchain->num_contexts = 0;
     922        }
     923        HeapFree(GetProcessHeap(), 0, swapchain->context);
    929924    }
    930925
     
    942937    TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
    943938
    944     ctx = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
    945             This->context[0]->win_handle, FALSE /* pbuffer */, &This->presentParms);
    946     if (!ctx)
     939    if (!(ctx = context_create(This, (IWineD3DSurfaceImpl *)This->frontBuffer, This->ds_format)))
    947940    {
    948941        ERR("Failed to create a new context for the swapchain\n");
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