VirtualBox

Changeset 57790 in vbox for trunk


Ignore:
Timestamp:
Sep 16, 2015 5:09:28 PM (9 years ago)
Author:
vboxsync
Message:

VMSVGA3d: Turns out I'm blitting to the wrong end (Y direction) of the nsview framebuffer. Missed some [NSOpenGLContext update] calls when the parent view got resized, so it sometimes worked, but not all the time. After calling update, the visible part of the framebuffer is the bottom half, not the top half as I though and as seems to be the case on the other plaforms.

Location:
trunk/src/VBox/Devices/Graphics
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA.cpp

    r57517 r57790  
    535535#endif
    536536
     537#ifdef IN_RING3
    537538/**
    538539 * @interface_method_impl{PDMIDISPLAYPORT::pfnSetViewport}
     
    543544
    544545    Log(("vmsvgaPortSetViewPort: screen %d (%d,%d)(%d,%d)\n", uScreenId, x, y, cx, cy));
     546    VMSVGAVIEWPORT const OldViewport = pThis->svga.viewport;
    545547
    546548    if (x < pThis->svga.uWidth)
     
    570572        pThis->svga.viewport.yHighWC = 0;
    571573    }
     574
     575# ifdef VBOX_WITH_VMSVGA3D
     576    /*
     577     * Now inform the 3D backend.
     578     */
     579    if (pThis->svga.f3DEnabled)
     580        vmsvga3dUpdateHostScreenViewport(pThis, uScreenId, &OldViewport);
     581# endif
    572582}
     583#endif /* IN_RING3 */
    573584
    574585/**
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.h

    r57154 r57790  
    4343VMSVGA3DCOCOA_DECL(void) vmsvga3dCocoaViewSetPosition(NativeNSViewRef pView, NativeNSViewRef pParentView, int x, int y);
    4444VMSVGA3DCOCOA_DECL(void) vmsvga3dCocoaViewSetSize(NativeNSViewRef pView, int w, int h);
     45VMSVGA3DCOCOA_DECL(void) vmsvga3dCocoaViewUpdateViewport(NativeNSViewRef pView);
    4546VMSVGA3DCOCOA_DECL(void) vmsvga3dCocoaViewMakeCurrentContext(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
    4647VMSVGA3DCOCOA_DECL(void) vmsvga3dCocoaSwapBuffers(NativeNSViewRef pView, NativeNSOpenGLContextRef pCtx);
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-cocoa.m

    r57372 r57790  
    118118- (void)vboxSetPos:(NSPoint)pos;
    119119- (void)vboxSetSize:(NSSize)size;
     120- (void)vboxScheduleCtxUpdate;
    120121- (void)vboxReshapePerform;
    121122- (void)vboxReshape;
    122 #if 0 // doesn't work or isn't needed :/
    123 - (void)vboxFrameDidChange;
     123- (void)vboxBoundsDidChange:(NSNotification *)pNotification;
     124- (void)vboxFrameDidChange:(NSNotification *)pNotification;
     125- (void)vboxFrameDidChangeGlobal:(NSNotification *)pNotification;
    124126- (BOOL)postsFrameChangedNotifications;
    125 #endif
    126127- (void)vboxRemoveFromSuperviewAndHide;
    127128- (void)vboxUpdateCtxIfNecessary;
     
    251252                [pFmt release];
    252253
    253 #if 0 // doesn't work or isn't needed :/
    254                 /*
    255                  * Get notifications when we're moved...
    256                  */
    257                 if (pParams->pParentView)
    258                 {
    259                     [[NSNotificationCenter defaultCenter] addObserver:self
    260                                                              selector:@selector(vboxFrameDidChange)
    261                                                                  name:NSViewFrameDidChangeNotification
    262                                                                object:self];
    263                 }
    264 #endif
    265 
    266254                LogFlow(("OvlView createViewAndContext: returns successfully\n"));
    267255                return;
     
    300288        //self.autoresizingMask = NSViewMinXMargin | NSViewMaxXMargin | NSViewMinYMargin | NSViewMaxYMargin;
    301289        self.autoresizingMask = NSViewNotSizable;
     290
     291        /*
     292         * Get notifications when we're moved or resized and when we're moved
     293         * to a different screen or GPU or when the GL context simply needs updating.
     294         */
     295        if (pParentView)
     296        {
     297            [[NSNotificationCenter defaultCenter] addObserver:self
     298                                                     selector:@selector(vboxBoundsDidChange:)
     299                                                         name:NSViewBoundsDidChangeNotification
     300                                                       object:self];
     301            [[NSNotificationCenter defaultCenter] addObserver:self
     302                                                     selector:@selector(vboxFrameDidChange:)
     303                                                         name:NSViewFrameDidChangeNotification
     304                                                       object:self];
     305            //[[NSNotificationCenter defaultCenter] addObserver:self
     306            //                                         selector:@selector(vboxFrameDidChange:)
     307            //                                             name:NSViewDidUpdateTrackingAreasNotification
     308            //                                           object:self];
     309            [[NSNotificationCenter defaultCenter] addObserver:self
     310                                                     selector:@selector(vboxFrameDidChangeGlobal:)
     311                                                         name:NSViewGlobalFrameDidChangeNotification
     312                                                       object:self];
     313        }
    302314    }
    303315    LogFlow(("OvlView(%p) initWithFrameAndFormat: returns %p\n", (void *)self, (void *)self));
     
    345357}
    346358
     359- (void)vboxScheduleCtxUpdate
     360{
     361    m_fUpdateCtx = true;
     362}
    347363
    348364- (void)vboxUpdateCtxIfNecessary
     
    454470}
    455471
    456 #if 0 // doesn't work or isn't needed :/
    457 - (void)vboxFrameDidChange
     472/**
     473 * This is called when the bounds change.
     474 * 
     475 * We indicate that the FIFO thread must update the GL context.
     476 */
     477- (void)vboxBoundsDidChange:(NSNotification *)pNotification
     478{
     479    LogFlow(("OvlView(%p) vboxBoundsDidChange:\n", (void *)self));
     480    self->m_fUpdateCtx = true;
     481}
     482
     483/**
     484 * This is called when the frame changes size or position.
     485 * 
     486 * We indicate that the FIFO thread must update the GL context.
     487 */
     488- (void)vboxFrameDidChange:(NSNotification *)pNotification
    458489{
    459490    LogFlow(("OvlView(%p) vboxFrameDidChange:\n", (void *)self));
    460 }
    461 
     491    self->m_fUpdateCtx = true;
     492}
     493
     494/**
     495 * This is called when moved to different screen/GPU or/and when the GL context
     496 * needs updating.
     497 * 
     498 * We indicate that the FIFO thread must update the GL context.
     499 */
     500- (void)vboxFrameDidChangeGlobal:(NSNotification *)pNotification
     501{
     502    LogFlow(("OvlView(%p) vboxFrameDidChangeGlobal:\n", (void *)self));
     503    self->m_fUpdateCtx = true;
     504}
     505
     506/** This enables the vboxFrameDidChange notification. */
    462507- (BOOL)postsFrameChangedNotifications
    463508{
     
    465510    return YES;
    466511}
    467 #endif
    468512
    469513/**
     
    493537            LogFlow(("OvlView(%p) vboxRemoveFromSuperviewAndHide: calling setHidden\n", (void *)self));
    494538            [self setHidden:YES];
    495 #if 0 /* doesn't work, or isn't really needed (scroll bar mess). */
    496539            LogFlow(("OvlView(%p) vboxRemoveFromSuperviewAndHide: calling setHidden\n", (void *)self));
    497540            [[NSNotificationCenter defaultCenter] removeObserver:self];
    498 #endif
    499541        }
    500542        else
     
    798840
    799841
     842VMSVGA3DCOCOA_DECL(void) vmsvga3dCocoaViewUpdateViewport(NativeNSViewRef pView)
     843{
     844    LogFlow(("vmsvga3dCocoaViewSetSize: pView=%p\n", (void *)pView));
     845    NSAutoreleasePool *pPool = [[NSAutoreleasePool alloc] init];
     846    VMSVGA3DOverlayView *pOverlayView = (VMSVGA3DOverlayView *)pView;
     847
     848    /* Possible that we don't actually need to do this (i.e. this API), but right now I'm
     849       leaving it to be sure things actually work right when scrolling. */
     850    [pOverlayView vboxScheduleCtxUpdate];
     851
     852    [pPool release];
     853    LogFlow(("vmsvga3dCocoaViewSetSize: returns\n"));
     854}
     855
     856
    800857VMSVGA3DCOCOA_DECL(void) vmsvga3dCocoaViewSetSize(NativeNSViewRef pView, int cx, int cy)
    801858{
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp

    r57519 r57790  
    10781078
    10791079    return VINF_SUCCESS;
     1080}
     1081
     1082
     1083void vmsvga3dUpdateHostScreenViewport(PVGASTATE pThis, uint32_t idScreen, VMSVGAVIEWPORT const *pOldViewport)
     1084{
     1085    /** @todo Move the visible framebuffer content here, don't wait for the guest to
     1086     *        redraw it. */
     1087
     1088#ifdef RT_OS_DARWIN
     1089    PVMSVGA3DSTATE pState = pThis->svga.p3dState;
     1090    if (   pState
     1091        && idScreen == 0
     1092        && pState->SharedCtx.id == VMSVGA3D_SHARED_CTX_ID)
     1093    {
     1094        vmsvga3dCocoaViewUpdateViewport(pState->SharedCtx.cocoaView);
     1095    }
     1096#else
     1097    NOREF(pThis); NOREF(idScreen);
     1098#endif
    10801099}
    10811100
     
    29953014         *   => Copy = { .yDst = 2, .ySrc = 5, .cy = 2 }
    29963015         *
     3016         * Update: On darwin, it turns out that when we call [NSOpenGLContext updates]
     3017         *         when the view is resized, moved and otherwise messed with,
     3018         *         the visible part of the framebuffer is actually the bottom
     3019         *         one.  It's easy to adjust for this, just have to adjust the
     3020         *         destination rectangle such that yBottom is zero.
    29973021         */
    29983022        /* X - no inversion, so kind of simple. */
     
    30563080            {
    30573081                /* adjustment #2 */
    3058                 uint32_t cyAdjust = ClippedRect.y + ClippedRect.h - DstViewport.yHighWC;
     3082                cyAdjust = ClippedRect.y + ClippedRect.h - DstViewport.yHighWC;
    30593083                ClippedRect.srcy += cyAdjust;
    30603084                ClippedRect.h    -= cyAdjust;
     
    30793103        DstRect.xLeft   -= DstViewport.x;
    30803104        DstRect.xRight  -= DstViewport.x;
     3105# ifdef RT_OS_DARWIN /* We actually seeing the bottom of the FB, not the top as on windows and X11. */
     3106        DstRect.yTop    -= DstRect.yBottom;
     3107        DstRect.yBottom  = 0;
     3108# else
    30813109        DstRect.yBottom += DstViewport.y;
    30823110        DstRect.yTop    += DstViewport.y;
     3111# endif
    30833112
    30843113        Log(("SrcRect: (%d,%d)(%d,%d) DstRect: (%d,%d)(%d,%d)\n",
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp

    r57520 r57790  
    324324}
    325325
     326void vmsvga3dUpdateHostScreenViewport(PVGASTATE pThis, uint32_t idScreen, VMSVGAVIEWPORT const *pOldViewport)
     327{
     328    /** @todo Scroll the screen content without requiring the guest to redraw. */
     329    NOREF(pThis); NOREF(idScreen); NOREF(pOldViewport);
     330}
    326331
    327332static uint32_t vmsvga3dGetSurfaceFormatSupport(PVMSVGA3DSTATE pState3D, uint32_t idx3dCaps, D3DFORMAT format)
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.h

    r57151 r57790  
    5656int vmsvga3dTerminate(PVGASTATE pThis);
    5757int vmsvga3dReset(PVGASTATE pThis);
     58void vmsvga3dUpdateHostScreenViewport(PVGASTATE pThis, uint32_t idScreen, VMSVGAVIEWPORT const *pOldViewport);
    5859int vmsvga3dQueryCaps(PVGASTATE pThis, uint32_t idx3dCaps, uint32_t *pu32Val);
    5960
  • trunk/src/VBox/Devices/Graphics/VBoxSVGA3DObjC.def

    r57154 r57790  
    2424    vmsvga3dCocoaViewSetPosition
    2525    vmsvga3dCocoaViewSetSize
     26    vmsvga3dCocoaViewUpdateViewport
    2627    vmsvga3dCocoaViewMakeCurrentContext
    2728    vmsvga3dCocoaSwapBuffers
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