VirtualBox

Ignore:
Timestamp:
Aug 31, 2011 4:01:24 PM (13 years ago)
Author:
vboxsync
Message:

wddm/wine: fix image viewer rendering under Aero (workaround NVIDIA bugs with BlitFramebuffer)

File:
1 edited

Legend:

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

    r38565 r38588  
    31993199 * with single pixel copy calls
    32003200 */
    3201 static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
    3202         const RECT *src_rect, const RECT *dst_rect_in, WINED3DTEXTUREFILTERTYPE Filter, BOOL doit)
     3201static inline BOOL fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
     3202        const RECT *src_rect, const RECT *dst_rect_in, WINED3DTEXTUREFILTERTYPE Filter, BOOL fFastOnly)
    32033203{
    32043204    IWineD3DDeviceImpl *myDevice = This->resource.device;
     
    32083208    struct wined3d_context *context;
    32093209    BOOL upsidedown = FALSE;
     3210    BOOL isOffscreen = surface_is_offscreen(SrcSurface);
     3211    BOOL fNoStretching = TRUE;
    32103212    RECT dst_rect = *dst_rect_in;
    32113213
     
    32153217    if(dst_rect.top > dst_rect.bottom) {
    32163218        UINT tmp = dst_rect.bottom;
     3219#ifdef DEBUG_misha
     3220        ERR("validate this path!");
     3221#endif
    32173222        dst_rect.bottom = dst_rect.top;
    32183223        dst_rect.top = tmp;
     
    32203225    }
    32213226
     3227    if (isOffscreen)
     3228    {
     3229        upsidedown = !upsidedown;
     3230    }
     3231
     3232    xrel = (float) (src_rect->right - src_rect->left) / (float) (dst_rect.right - dst_rect.left);
     3233    yrel = (float) (src_rect->bottom - src_rect->top) / (float) (dst_rect.bottom - dst_rect.top);
     3234
     3235    if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
     3236    {
     3237        FIXME("Doing a pixel by pixel copy from the framebuffer to a texture, expect major performance issues\n");
     3238
     3239        if(Filter != WINED3DTEXF_NONE && Filter != WINED3DTEXF_POINT) {
     3240            ERR("Texture filtering not supported in direct blit\n");
     3241        }
     3242    }
     3243    else if ((Filter != WINED3DTEXF_NONE && Filter != WINED3DTEXF_POINT)
     3244            && ((yrel - 1.0f < -eps) || (yrel - 1.0f > eps)))
     3245    {
     3246        ERR("Texture filtering not supported in direct blit\n");
     3247    }
     3248
     3249    fNoStretching = !((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
     3250            && !((yrel - 1.0f < -eps) || (yrel - 1.0f > eps));
     3251
     3252    if (fFastOnly && (!upsidedown || !fNoStretching))
     3253    {
     3254        return FALSE;
     3255    }
     3256
    32223257    context = context_acquire(myDevice, SrcSurface, CTXUSAGE_BLIT);
    32233258    surface_internal_preload((IWineD3DSurface *) This, SRGB_RGB);
     
    32273262    glBindTexture(This->texture_target, This->texture_name);
    32283263    checkGLcall("glBindTexture");
    3229     if(surface_is_offscreen(SrcSurface)) {
     3264    if(isOffscreen) {
    32303265        TRACE("Reading from an offscreen target\n");
    3231         upsidedown = !upsidedown;
    32323266        glReadBuffer(myDevice->offscreenBuffer);
    32333267    }
     
    32383272    checkGLcall("glReadBuffer");
    32393273
    3240     xrel = (float) (src_rect->right - src_rect->left) / (float) (dst_rect.right - dst_rect.left);
    3241     yrel = (float) (src_rect->bottom - src_rect->top) / (float) (dst_rect.bottom - dst_rect.top);
    3242 
    3243     if ((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
    3244     {
    3245         FIXME("Doing a pixel by pixel copy from the framebuffer to a texture, expect major performance issues\n");
    3246 
    3247         if(Filter != WINED3DTEXF_NONE && Filter != WINED3DTEXF_POINT) {
    3248             ERR("Texture filtering not supported in direct blit\n");
    3249         }
    3250     }
    3251     else if ((Filter != WINED3DTEXF_NONE && Filter != WINED3DTEXF_POINT)
    3252             && ((yrel - 1.0f < -eps) || (yrel - 1.0f > eps)))
    3253     {
    3254         ERR("Texture filtering not supported in direct blit\n");
    3255     }
    3256 
    3257     if (upsidedown
    3258             && !((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
    3259             && !((yrel - 1.0f < -eps) || (yrel - 1.0f > eps)))
     3274    if (upsidedown && fNoStretching)
    32603275    {
    32613276        /* Upside down copy without stretching is nice, one glCopyTexSubImage call will do */
     
    32743289         */
    32753290
    3276         if (!((xrel - 1.0f < -eps) || (xrel - 1.0f > eps))
    3277             && !((yrel - 1.0f < -eps) || (yrel - 1.0f > eps)))
     3291        if (fNoStretching)
    32783292        {
    32793293            /* No stretching involved, so just pass negative height and let host side take care of inverting */
    32803294
    3281             if (doit)
    3282             {
    3283                 glCopyTexSubImage2D(This->texture_target, This->texture_level,
     3295            glCopyTexSubImage2D(This->texture_target, This->texture_level,
    32843296                    dst_rect.left /*xoffset */, dst_rect.top /* y offset */,
    32853297                    src_rect->left, Src->currentDesc.Height - src_rect->bottom,
    32863298                    dst_rect.right - dst_rect.left, -(dst_rect.bottom-dst_rect.top));
    3287             }
    32883299        }
    32893300        else
     
    33193330     */
    33203331    IWineD3DSurface_ModifyLocation((IWineD3DSurface *) This, SFLAG_INTEXTURE, TRUE);
     3332
     3333    return TRUE;
    33213334}
    33223335
     
    38073820           )
    38083821        {
    3809             stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
    3810                     (IWineD3DSurface *)This, &dst_rect, Filter);
     3822            /* blit framebuffer might be buggy for some GPUs, try if fb_copy_to_texture_direct can do it quickly */
     3823            if (!fb_copy_to_texture_direct(This, SrcSurface, &src_rect, &dst_rect, Filter, TRUE /* fals only */))
     3824            {
     3825                TRACE("fb_copy_to_texture_direct can not do it fast, use stretch_rect_fbo\n");
     3826                stretch_rect_fbo((IWineD3DDevice *)myDevice, SrcSurface, &src_rect,
     3827                        (IWineD3DSurface *)This, &dst_rect, Filter);
     3828            }
    38113829        } else if((!stretchx) || dst_rect.right - dst_rect.left > Src->currentDesc.Width ||
    38123830                                    dst_rect.bottom - dst_rect.top > Src->currentDesc.Height) {
    38133831            TRACE("No stretching in x direction, using direct framebuffer -> texture copy\n");
    3814             fb_copy_to_texture_direct(This, SrcSurface, &src_rect, &dst_rect, Filter, TRUE);
     3832            fb_copy_to_texture_direct(This, SrcSurface, &src_rect, &dst_rect, Filter, FALSE /* do it alwais */);
    38153833        } else {
    38163834            TRACE("Using hardware stretching to flip / stretch the texture\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