Changeset 49591 in vbox for trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
- Timestamp:
- Nov 20, 2013 5:53:55 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
r49088 r49591 196 196 CR_VBOXHGCM_MEMORY, 197 197 CR_VBOXHGCM_MEMORY_BIG 198 #ifdef RT_OS_WINDOWS199 ,CR_VBOXHGCM_DDRAW_SURFACE200 #endif201 198 #if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) 202 199 ,CR_VBOXHGCM_UHGSMI_BUFFER … … 221 218 #endif 222 219 }; 223 #ifdef RT_OS_WINDOWS224 LPDIRECTDRAWSURFACE pDDS;225 #endif226 220 } CRVBOXHGCMBUFFER; 227 221 … … 706 700 (unsigned int)sizeof(CRVBOXHGCMBUFFER) + conn->buffer_size); 707 701 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 else721 {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 reason744 * also, it would be better to request dwLinearSize but it fails too745 * 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 else767 {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 else777 {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 #endif793 794 702 /* We're either on host side, or we failed to allocate DDRAW buffer */ 795 703 if (!buf) … … 801 709 buf->kind = CR_VBOXHGCM_MEMORY; 802 710 buf->allocated = conn->buffer_size; 803 #ifdef RT_OS_WINDOWS804 buf->pDDS = NULL;805 #endif806 711 } 807 712 } … … 945 850 parms.hdr.cParms = SHCRGL_CPARMS_WRITE_READ; 946 851 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; 959 855 960 856 CRASSERT(!conn->pBuffer); //make sure there's no data to process … … 1203 1099 { 1204 1100 case CR_VBOXHGCM_MEMORY: 1205 #ifdef RT_OS_WINDOWS1206 case CR_VBOXHGCM_DDRAW_SURFACE:1207 #endif1208 1101 #ifdef CHROMIUM_THREADSAFE 1209 1102 crLockMutex(&g_crvboxhgcm.mutex); … … 1284 1177 { 1285 1178 /* we should NEVER have redir_ptr disabled with HGSMI command now */ 1286 CRASSERT(!conn->CmdData.p Cmd);1179 CRASSERT(!conn->CmdData.pvCmd); 1287 1180 if ( len <= conn->buffer_size ) 1288 1181 { … … 1299 1192 hgcm_buffer->kind = CR_VBOXHGCM_MEMORY_BIG; 1300 1193 hgcm_buffer->allocated = sizeof(CRVBOXHGCMBUFFER) + len; 1301 # ifdef RT_OS_WINDOWS1302 hgcm_buffer->pDDS = NULL;1303 # endif1304 1194 } 1305 1195 … … 2421 2311 void crVBoxHGCMBufferFree(void *data) 2422 2312 { 2423 #ifdef RT_OS_WINDOWS2424 LPDIRECTDRAWSURFACE lpDDS;2425 #endif2426 2313 CRVBOXHGCMBUFFER *hgcm_buffer = (CRVBOXHGCMBUFFER *) data; 2427 2314 … … 2433 2320 crFree( hgcm_buffer ); 2434 2321 break; 2435 #ifdef RT_OS_WINDOWS2436 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 #endif2444 2322 case CR_VBOXHGCM_MEMORY_BIG: 2445 2323 crFree( hgcm_buffer );
Note:
See TracChangeset
for help on using the changeset viewer.