VirtualBox

Ignore:
Timestamp:
Nov 20, 2013 5:53:55 PM (11 years ago)
Author:
vboxsync
Message:

wddm: more on new comand mechanism, guest side almost done, some cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c

    r49088 r49591  
    196196    CR_VBOXHGCM_MEMORY,
    197197    CR_VBOXHGCM_MEMORY_BIG
    198 #ifdef RT_OS_WINDOWS
    199     ,CR_VBOXHGCM_DDRAW_SURFACE
    200 #endif
    201198#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST)
    202199    ,CR_VBOXHGCM_UHGSMI_BUFFER
     
    221218#endif
    222219    };
    223 #ifdef RT_OS_WINDOWS
    224     LPDIRECTDRAWSURFACE  pDDS;
    225 #endif
    226220} CRVBOXHGCMBUFFER;
    227221
     
    706700                        (unsigned int)sizeof(CRVBOXHGCMBUFFER) + conn->buffer_size);
    707701
    708 #if defined(IN_GUEST) && defined(RT_OS_WINDOWS)
    709         /* Try to start DDRAW on guest side */
    710         if (!g_crvboxhgcm.pDirectDraw && 0)
    711         {
    712             HRESULT hr;
    713 
    714             hr = DirectDrawCreate(NULL, &g_crvboxhgcm.pDirectDraw, NULL);
    715             if (hr != DD_OK)
    716             {
    717                 crWarning("Failed to create DirectDraw interface (%x)\n", hr);
    718                 g_crvboxhgcm.pDirectDraw = NULL;
    719             }
    720             else
    721             {
    722                 hr = IDirectDraw_SetCooperativeLevel(g_crvboxhgcm.pDirectDraw, NULL, DDSCL_NORMAL);
    723                 if (hr != DD_OK)
    724                 {
    725                     crWarning("Failed to SetCooperativeLevel (%x)\n", hr);
    726                     IDirectDraw_Release(g_crvboxhgcm.pDirectDraw);
    727                     g_crvboxhgcm.pDirectDraw = NULL;
    728                 }
    729                 crDebug("Created DirectDraw and set CooperativeLevel successfully\n");
    730             }
    731         }
    732 
    733         /* Try to allocate buffer via DDRAW */
    734         if (g_crvboxhgcm.pDirectDraw)
    735         {
    736             DDSURFACEDESC       ddsd;
    737             HRESULT             hr;
    738             LPDIRECTDRAWSURFACE lpDDS;
    739 
    740             memset(&ddsd, 0, sizeof(ddsd));
    741             ddsd.dwSize  = sizeof(ddsd);
    742 
    743             /* @todo DDSCAPS_VIDEOMEMORY ain't working for some reason
    744              * also, it would be better to request dwLinearSize but it fails too
    745              * ddsd.dwLinearSize = sizeof(CRVBOXHGCMBUFFER) + conn->buffer_size;
    746              */
    747 
    748             ddsd.dwFlags = DDSD_CAPS | DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT;
    749             ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
    750             /* use 1 byte per pixel format */
    751             ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
    752             ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
    753             ddsd.ddpfPixelFormat.dwRGBBitCount = 8;
    754             ddsd.ddpfPixelFormat.dwRBitMask = 0xFF;
    755             ddsd.ddpfPixelFormat.dwGBitMask = 0;
    756             ddsd.ddpfPixelFormat.dwBBitMask = 0;
    757             /* request given buffer size, rounded to 1k */
    758             ddsd.dwWidth = 1024;
    759             ddsd.dwHeight = (sizeof(CRVBOXHGCMBUFFER) + conn->buffer_size + ddsd.dwWidth-1)/ddsd.dwWidth;
    760 
    761             hr = IDirectDraw_CreateSurface(g_crvboxhgcm.pDirectDraw, &ddsd, &lpDDS, NULL);
    762             if (hr != DD_OK)
    763             {
    764                 crWarning("Failed to create DirectDraw surface (%x)\n", hr);
    765             }
    766             else
    767             {
    768                 crDebug("Created DirectDraw surface (%x)\n", lpDDS);
    769 
    770                 hr = IDirectDrawSurface_Lock(lpDDS, NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR, NULL);
    771                 if (hr != DD_OK)
    772                 {
    773                     crWarning("Failed to lock DirectDraw surface (%x)\n", hr);
    774                     IDirectDrawSurface_Release(lpDDS);
    775                 }
    776                 else
    777                 {
    778                     uint32_t cbLocked;
    779                     cbLocked = (ddsd.dwFlags & DDSD_LINEARSIZE) ? ddsd.dwLinearSize : ddsd.lPitch*ddsd.dwHeight;
    780 
    781                     crDebug("Locked %d bytes DirectDraw surface\n", cbLocked);
    782 
    783                     buf = (CRVBOXHGCMBUFFER *) ddsd.lpSurface;
    784                     CRASSERT(buf);
    785                     buf->magic = CR_VBOXHGCM_BUFFER_MAGIC;
    786                     buf->kind  = CR_VBOXHGCM_DDRAW_SURFACE;
    787                     buf->allocated = cbLocked;
    788                     buf->pDDS = lpDDS;
    789                 }
    790             }
    791         }
    792 #endif
    793 
    794702        /* We're either on host side, or we failed to allocate DDRAW buffer */
    795703        if (!buf)
     
    801709            buf->kind  = CR_VBOXHGCM_MEMORY;
    802710            buf->allocated = conn->buffer_size;
    803 #ifdef RT_OS_WINDOWS
    804             buf->pDDS = NULL;
    805 #endif
    806711        }
    807712    }
     
    945850    parms.hdr.cParms      = SHCRGL_CPARMS_WRITE_READ;
    946851
    947     //if (bufferKind != CR_VBOXHGCM_DDRAW_SURFACE)
    948     {
    949         parms.pBuffer.type                   = VMMDevHGCMParmType_LinAddr_In;
    950         parms.pBuffer.u.Pointer.size         = len;
    951         parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf;
    952     }
    953     /*else ///@todo it fails badly, have to check why. bird: This fails because buf isn't a physical address?
    954     {
    955         parms.pBuffer.type                 = VMMDevHGCMParmType_PhysAddr;
    956         parms.pBuffer.u.Pointer.size       = len;
    957         parms.pBuffer.u.Pointer.u.physAddr = (uintptr_t) buf;
    958     }*/
     852    parms.pBuffer.type                   = VMMDevHGCMParmType_LinAddr_In;
     853    parms.pBuffer.u.Pointer.size         = len;
     854    parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf;
    959855
    960856    CRASSERT(!conn->pBuffer); //make sure there's no data to process
     
    12031099    {
    12041100        case CR_VBOXHGCM_MEMORY:
    1205 #ifdef RT_OS_WINDOWS
    1206         case CR_VBOXHGCM_DDRAW_SURFACE:
    1207 #endif
    12081101#ifdef CHROMIUM_THREADSAFE
    12091102            crLockMutex(&g_crvboxhgcm.mutex);
     
    12841177    {
    12851178        /* we should NEVER have redir_ptr disabled with HGSMI command now */
    1286         CRASSERT(!conn->CmdData.pCmd);
     1179        CRASSERT(!conn->CmdData.pvCmd);
    12871180        if ( len <= conn->buffer_size )
    12881181        {
     
    12991192            hgcm_buffer->kind      = CR_VBOXHGCM_MEMORY_BIG;
    13001193            hgcm_buffer->allocated = sizeof(CRVBOXHGCMBUFFER) + len;
    1301 # ifdef RT_OS_WINDOWS
    1302             hgcm_buffer->pDDS      = NULL;
    1303 # endif
    13041194        }
    13051195
     
    24212311void crVBoxHGCMBufferFree(void *data)
    24222312{
    2423 #ifdef RT_OS_WINDOWS
    2424     LPDIRECTDRAWSURFACE lpDDS;
    2425 #endif
    24262313    CRVBOXHGCMBUFFER *hgcm_buffer = (CRVBOXHGCMBUFFER *) data;
    24272314
     
    24332320            crFree( hgcm_buffer );
    24342321            break;
    2435 #ifdef RT_OS_WINDOWS
    2436         case CR_VBOXHGCM_DDRAW_SURFACE:
    2437             lpDDS = hgcm_buffer->pDDS;
    2438             CRASSERT(lpDDS);
    2439             IDirectDrawSurface_Unlock(lpDDS, NULL);
    2440             IDirectDrawSurface_Release(lpDDS);
    2441             crDebug("DDraw surface freed (%x)\n", lpDDS);
    2442             break;
    2443 #endif
    24442322        case CR_VBOXHGCM_MEMORY_BIG:
    24452323            crFree( hgcm_buffer );
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