Changeset 33306 in vbox
- Timestamp:
- Oct 21, 2010 12:52:37 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/VBoxCrHgsmi.h
r33119 r33306 48 48 VBOXCRHGSMI_DECL(HVBOXCRHGSMI_CLIENT) VBoxCrHgsmiQueryClient(); 49 49 50 VBOXCRHGSMI_DECL(void) VBoxCrHgsmiLog(char * szString); 51 50 52 RT_C_DECLS_END 51 53 -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxCrHgsmi.cpp
r33241 r33306 8 8 static uint32_t g_cVBoxCrHgsmiProvider = 0; 9 9 10 static VBOXDISPKMT_CALLBACKS g_VBoxCrHgsmiKmtCallbacks; 11 10 12 typedef VBOXWDDMDISP_DECL(int) FNVBOXDISPCRHGSMI_INIT(PVBOXCRHGSMI_CALLBACKS pCallbacks); 11 13 typedef FNVBOXDISPCRHGSMI_INIT *PFNVBOXDISPCRHGSMI_INIT; … … 23 25 VBOXCRHGSMI_DECL(int) VBoxCrHgsmiInit(PVBOXCRHGSMI_CALLBACKS pCallbacks) 24 26 { 27 static int bKmtCallbacksInited = 0; 28 if (!bKmtCallbacksInited) 29 { 30 HRESULT hr = vboxDispKmtCallbacksInit(&g_VBoxCrHgsmiKmtCallbacks); 31 Assert(hr == S_OK); 32 if (hr == S_OK) 33 bKmtCallbacksInited = 1; 34 else 35 bKmtCallbacksInited = -1; 36 } 37 38 Assert(bKmtCallbacksInited); 39 if (bKmtCallbacksInited < 0) 40 { 41 Assert(0); 42 return VERR_NOT_SUPPORTED; 43 } 44 25 45 g_VBoxCrHgsmiCallbacks = *pCallbacks; 26 46 if (!g_hVBoxCrHgsmiProvider) … … 77 97 { 78 98 hClient = g_pfnVBoxDispCrHgsmiQueryClient(); 79 #ifdef DEBUG_misha80 Assert(hClient);81 #endif99 //#ifdef DEBUG_misha 100 // Assert(hClient); 101 //#endif 82 102 if (hClient) 83 103 return hClient; … … 125 145 } 126 146 147 VBOXCRHGSMI_DECL(void) VBoxCrHgsmiLog(char * szString) 148 { 149 VBOXDISPKMT_ADAPTER Adapter; 150 HRESULT hr = vboxDispKmtOpenAdapter(&g_VBoxCrHgsmiKmtCallbacks, &Adapter); 151 Assert(hr == S_OK); 152 if (hr == S_OK) 153 { 154 uint32_t cbString = (uint32_t)strlen(szString) + 1; 155 uint32_t cbCmd = RT_OFFSETOF(VBOXDISPIFESCAPE_DBGPRINT, aStringBuf[cbString]); 156 PVBOXDISPIFESCAPE_DBGPRINT pCmd = (PVBOXDISPIFESCAPE_DBGPRINT)RTMemAllocZ(cbCmd); 157 Assert(pCmd); 158 if (pCmd) 159 { 160 pCmd->EscapeHdr.escapeCode = VBOXESC_DBGPRINT; 161 memcpy(pCmd->aStringBuf, szString, cbString); 162 163 D3DKMT_ESCAPE EscapeData = {0}; 164 EscapeData.hAdapter = Adapter.hAdapter; 165 //EscapeData.hDevice = NULL; 166 EscapeData.Type = D3DKMT_ESCAPE_DRIVERPRIVATE; 167 // EscapeData.Flags.HardwareAccess = 1; 168 EscapeData.pPrivateDriverData = pCmd; 169 EscapeData.PrivateDriverDataSize = cbCmd; 170 //EscapeData.hContext = NULL; 171 172 int Status = g_VBoxCrHgsmiKmtCallbacks.pfnD3DKMTEscape(&EscapeData); 173 Assert(!Status); 174 175 RTMemFree(pCmd); 176 } 177 hr = vboxDispKmtCloseAdapter(&Adapter); 178 Assert(hr == S_OK); 179 } 180 } 127 181 128 182 ///* to be used by injection thread and by ogl ICD driver for hgsmi initialization*/ -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.cpp
r33281 r33306 1699 1699 pSwapchain->pRenderTargetFbCopy->Release(); 1700 1700 pSwapchain->pRenderTargetFbCopy = NULL; 1701 pSwapchain->bRTFbCopyUpToDate = FALSE; 1701 1702 #endif 1702 1703 pSwapchain->pSwapChainIf->Release(); … … 2358 2359 pSwapchain->pSwapChainIf = pNewIf; 2359 2360 #ifndef VBOXWDDM_WITH_VISIBLE_FB 2361 pSwapchain->bRTFbCopyUpToDate = FALSE; 2360 2362 if (!pSwapchain->pRenderTargetFbCopy) 2361 2363 { … … 2462 2464 if (hr == S_OK) 2463 2465 { 2466 pSwapchain->bRTFbCopyUpToDate = FALSE; 2464 2467 vboxWddmSwapchainFlip(pSwapchain); 2465 2468 Assert(pSwapchain->fFlags.Value == 0); … … 6355 6358 pSrcSurfIf = pSrcSwapchain->pRenderTargetFbCopy; 6356 6359 Assert(pSrcSurfIf); 6357 hr = pSrcSwapchain->pSwapChainIf->GetFrontBufferData(pSrcSurfIf); 6358 Assert(hr == S_OK); 6359 if (hr == S_OK) 6360 if (!pSrcSwapchain->bRTFbCopyUpToDate) 6360 6361 { 6361 /* do pSrcSurfIf->AddRef since we do a Release in the following if (hr == S_OK) branch */ 6362 hr = pSrcSwapchain->pSwapChainIf->GetFrontBufferData(pSrcSurfIf); 6363 Assert(hr == S_OK); 6364 if (hr == S_OK) 6365 { 6366 /* do pSrcSurfIf->AddRef since we do a Release in the following if (hr == S_OK) branch */ 6367 pSrcSwapchain->bRTFbCopyUpToDate = TRUE; 6368 pSrcSurfIf->AddRef(); 6369 } 6370 } 6371 else 6372 { 6362 6373 pSrcSurfIf->AddRef(); 6363 6374 } -
trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/VBoxDispD3D.h
r33171 r33306 139 139 #ifndef VBOXWDDM_WITH_VISIBLE_FB 140 140 IDirect3DSurface9 *pRenderTargetFbCopy; 141 BOOL bRTFbCopyUpToDate; 141 142 #endif 142 143 IDirect3DSwapChain9 *pSwapChainIf; -
trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoWddm.cpp
r33252 r33306 983 983 Assert(Status == STATUS_SUCCESS); 984 984 985 if (context.data.bNotifyDpc) 986 pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle); 987 985 988 if (!vboxSHGSMIListIsEmpty(&context.data.CtlList)) 986 989 { … … 1003 1006 1004 1007 vboxVdmaDdiCmdHandleCompletedList(pDevExt, &pDevExt->DdiCmdQueue, &context.data.CompletedDdiCmdQueue); 1005 1006 if (context.data.bNotifyDpc)1007 pDevExt->u.primary.DxgkInterface.DxgkCbNotifyDpc(pDevExt->u.primary.DxgkInterface.DeviceHandle);1008 1008 1009 1009 // dfprintf(("<== "__FUNCTION__ ", context(0x%p)\n", MiniportDeviceContext)); … … 4245 4245 DXGKARG_RENDER *pRender) 4246 4246 { 4247 drprintf(("==> "__FUNCTION__ ", hContext(0x%x)\n", hContext));4247 // drprintf(("==> "__FUNCTION__ ", hContext(0x%x)\n", hContext)); 4248 4248 4249 4249 Assert(pRender->DmaBufferPrivateDataSize >= sizeof (VBOXWDDM_DMA_PRIVATEDATA_BASEHDR)); … … 4347 4347 } 4348 4348 4349 drprintf(("<== "__FUNCTION__ ", hContext(0x%x)\n", hContext));4349 // drprintf(("<== "__FUNCTION__ ", hContext(0x%x)\n", hContext)); 4350 4350 4351 4351 return Status; -
trunk/src/VBox/Additions/WINNT/Graphics/Wine/wined3d/surface.c
r33282 r33306 854 854 } 855 855 856 #ifdef VBOX_WITH_WDDM 857 static void surface_upload_data_rect(IWineD3DSurfaceImpl *This, const struct wined3d_gl_info *gl_info, 858 const struct wined3d_format_desc *format_desc, BOOL srgb, const GLvoid *data, RECT *pRect) 859 { 860 GLsizei width = pRect->right - pRect->left; 861 GLsizei height = pRect->bottom - pRect->top; 862 GLenum internal; 863 864 if (srgb) 865 { 866 internal = format_desc->glGammaInternal; 867 } 868 else if (This->resource.usage & WINED3DUSAGE_RENDERTARGET 869 && surface_is_offscreen((IWineD3DSurface *)This)) 870 { 871 internal = format_desc->rtInternal; 872 } 873 else 874 { 875 internal = format_desc->glInternal; 876 } 877 878 TRACE("This %p, internal %#x, width %d, height %d, format %#x, type %#x, data %p.\n", 879 This, internal, width, height, format_desc->glFormat, format_desc->glType, data); 880 TRACE("target %#x, level %u, resource size %u.\n", 881 This->texture_target, This->texture_level, This->resource.size); 882 883 if (format_desc->heightscale != 1.0f && format_desc->heightscale != 0.0f) height *= format_desc->heightscale; 884 885 ENTER_GL(); 886 887 if (This->Flags & SFLAG_PBO) 888 { 889 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo)); 890 checkGLcall("glBindBufferARB"); 891 892 TRACE("(%p) pbo: %#x, data: %p.\n", This, This->pbo, data); 893 data = NULL; 894 } 895 896 if (format_desc->Flags & WINED3DFMT_FLAG_COMPRESSED) 897 { 898 TRACE("Calling glCompressedTexSubImage2DARB.\n"); 899 900 GL_EXTCALL(glCompressedTexSubImage2DARB(This->texture_target, This->texture_level, 901 pRect->left, pRect->top, width, height, internal, This->resource.size, data)); 902 checkGLcall("glCompressedTexSubImage2DARB"); 903 } 904 else 905 { 906 TRACE("Calling glTexSubImage2D.\n"); 907 908 glTexSubImage2D(This->texture_target, This->texture_level, 909 pRect->left, pRect->top, width, height, format_desc->glFormat, format_desc->glType, data); 910 checkGLcall("glTexSubImage2D"); 911 } 912 913 if (This->Flags & SFLAG_PBO) 914 { 915 GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0)); 916 checkGLcall("glBindBufferARB"); 917 } 918 919 LEAVE_GL(); 920 921 if (gl_info->quirks & WINED3D_QUIRK_FBO_TEX_UPDATE) 922 { 923 IWineD3DDeviceImpl *device = This->resource.device; 924 unsigned int i; 925 926 for (i = 0; i < device->numContexts; ++i) 927 { 928 context_surface_update(device->contexts[i], This); 929 } 930 } 931 } 932 #endif 933 856 934 /* This call just allocates the texture, the caller is responsible for binding 857 935 * the correct texture. */ … … 3899 3977 } 3900 3978 3979 #ifdef VBOX_WITH_WDDM 3980 /* Not called from the VTable */ 3981 static HRESULT IWineD3DSurfaceImpl_BltSys2Vram(IWineD3DSurfaceImpl *This, const RECT *DestRect, 3982 IWineD3DSurface *SrcSurface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, 3983 WINED3DTEXTUREFILTERTYPE Filter) 3984 { 3985 IWineD3DDeviceImpl *myDevice = This->resource.device; 3986 const struct wined3d_gl_info *gl_info = &myDevice->adapter->gl_info; 3987 IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface; 3988 RECT dst_rect, src_rect; 3989 struct wined3d_format_desc desc; 3990 CONVERT_TYPES convert; 3991 struct wined3d_context *context = NULL; 3992 BYTE *mem; 3993 BYTE *updateMem; 3994 BOOL srgb; 3995 int srcWidth, srcPitch; 3996 3997 TRACE("(%p)->(%p,%p,%p,%08x,%p)\n", This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx); 3998 3999 if(This->Flags & SFLAG_INSYSMEM) { 4000 WARN("Destination has a SYSMEM location valid, rejecting gl blt\n"); 4001 return WINED3DERR_INVALIDCALL; 4002 } 4003 4004 if(!(This->Flags & SFLAG_INTEXTURE) 4005 && !(This->Flags & SFLAG_INSRGBTEX)) { 4006 WARN("Destination does NOT have a TEXTURE location valid, rejecting gl blt\n"); 4007 return WINED3DERR_INVALIDCALL; 4008 } 4009 4010 srgb = !(This->Flags & SFLAG_INTEXTURE); 4011 4012 if(!(Src->Flags & SFLAG_INSYSMEM)) { 4013 WARN("Source does NOT have a SYSMEM location valid, rejecting gl blt\n"); 4014 return WINED3DERR_INVALIDCALL; 4015 } 4016 4017 if(This->resource.format_desc != Src->resource.format_desc) { 4018 WARN("Src and Dest Formats NOT equal, rejecting gl blt\n"); 4019 return WINED3DERR_INVALIDCALL; 4020 } 4021 4022 /* No destination color keying supported */ 4023 if(Flags & (WINEDDBLT_KEYDEST | WINEDDBLT_KEYDESTOVERRIDE)) { 4024 /* Can we support that with glBlendFunc if blitting to the frame buffer? */ 4025 TRACE("Destination color key not supported in accelerated Blit, falling back to software\n"); 4026 return WINED3DERR_INVALIDCALL; 4027 } 4028 4029 surface_get_rect(This, DestRect, &dst_rect); 4030 surface_get_rect(Src, SrcRect, &src_rect); 4031 4032 if (src_rect.right - src_rect.left != dst_rect.right - dst_rect.left 4033 || src_rect.bottom - src_rect.top != dst_rect.bottom - dst_rect.top) 4034 { 4035 WARN("Stretching requested, rejecting gl blt\n"); 4036 return WINED3DERR_INVALIDCALL; 4037 } 4038 4039 d3dfmt_get_conv(Src, TRUE /* We need color keying */, TRUE /* We will use textures */, 4040 &desc, &convert); 4041 4042 if (desc.convert || convert != NO_CONVERSION) 4043 { 4044 WARN("TODO: test if conversion works, rejecting gl blt\n"); 4045 return WINED3DERR_INVALIDCALL; 4046 } 4047 4048 if (!myDevice->isInDraw) context = context_acquire(myDevice, NULL, CTXUSAGE_RESOURCELOAD); 4049 4050 surface_bind_and_dirtify(This, srgb); 4051 4052 if(This->CKeyFlags & WINEDDSD_CKSRCBLT) { 4053 This->Flags |= SFLAG_GLCKEY; 4054 This->glCKey = This->SrcBltCKey; 4055 } 4056 else This->Flags &= ~SFLAG_GLCKEY; 4057 4058 // /* The width is in 'length' not in bytes */ 4059 srcWidth = Src->currentDesc.Width; 4060 srcPitch = IWineD3DSurface_GetPitch(SrcSurface); 4061 4062 /* Don't use PBOs for converted surfaces. During PBO conversion we look at SFLAG_CONVERTED 4063 * but it isn't set (yet) in all cases it is getting called. */ 4064 if((convert != NO_CONVERSION) && (This->Flags & SFLAG_PBO)) { 4065 TRACE("Removing the pbo attached to surface %p\n", This); 4066 surface_remove_pbo(This, gl_info); 4067 } 4068 4069 if(desc.convert) { 4070 /* This code is entered for texture formats which need a fixup. */ 4071 int srcHeight = Src->currentDesc.Height; 4072 // int width = Src->currentDesc.Width; 4073 // int pitch = IWineD3DSurface_GetPitch(SrcSurface); 4074 4075 /* Stick to the alignment for the converted surface too, makes it easier to load the surface */ 4076 int outpitch = srcWidth * desc.conv_byte_count; 4077 outpitch = (outpitch + myDevice->surface_alignment - 1) & ~(myDevice->surface_alignment - 1); 4078 4079 mem = HeapAlloc(GetProcessHeap(), 0, outpitch * srcHeight); 4080 if(!mem) { 4081 ERR("Out of memory %d, %d!\n", outpitch, srcHeight); 4082 if (context) context_release(context); 4083 return WINED3DERR_OUTOFVIDEOMEMORY; 4084 } 4085 desc.convert(Src->resource.allocatedMemory, mem, srcPitch, srcWidth, srcHeight); 4086 } else if((convert != NO_CONVERSION) && Src->resource.allocatedMemory) { 4087 /* This code is only entered for color keying fixups */ 4088 int srcHeight = Src->currentDesc.Height; 4089 int outpitch; 4090 // int width = Src->currentDesc.Width; 4091 // int pitch = IWineD3DSurface_GetPitch(SrcSurface); 4092 4093 /* Stick to the alignment for the converted surface too, makes it easier to load the surface */ 4094 outpitch = srcWidth * desc.conv_byte_count; 4095 outpitch = (outpitch + myDevice->surface_alignment - 1) & ~(myDevice->surface_alignment - 1); 4096 4097 mem = HeapAlloc(GetProcessHeap(), 0, outpitch * srcHeight); 4098 if(!mem) { 4099 ERR("Out of memory %d, %d!\n", outpitch, srcHeight); 4100 if (context) context_release(context); 4101 return WINED3DERR_OUTOFVIDEOMEMORY; 4102 } 4103 d3dfmt_convert_surface(Src->resource.allocatedMemory, mem, srcPitch, srcWidth, srcHeight, outpitch, convert, Src); 4104 } else { 4105 mem = Src->resource.allocatedMemory; 4106 } 4107 4108 updateMem = mem + srcPitch * src_rect.top; 4109 4110 /* Make sure the correct pitch is used */ 4111 ENTER_GL(); 4112 glPixelStorei(GL_UNPACK_ROW_LENGTH, Src->currentDesc.Width); 4113 glPixelStorei(GL_UNPACK_SKIP_PIXELS, src_rect.left); 4114 LEAVE_GL(); 4115 4116 if (mem || (This->Flags & SFLAG_PBO)) 4117 surface_upload_data_rect(This, gl_info, &desc, srgb, updateMem, &dst_rect); 4118 4119 /* Restore the default pitch */ 4120 ENTER_GL(); 4121 glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0); 4122 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 4123 LEAVE_GL(); 4124 4125 if (context) context_release(context); 4126 4127 /* Don't delete PBO memory */ 4128 if((mem != Src->resource.allocatedMemory) && !(This->Flags & SFLAG_PBO)) 4129 HeapFree(GetProcessHeap(), 0, mem); 4130 //// 4131 4132 IWineD3DSurface_ModifyLocation((IWineD3DSurface *)This, srgb ? SFLAG_INSRGBTEX : SFLAG_INTEXTURE, TRUE); 4133 4134 return WINED3D_OK; 4135 } 4136 #endif 4137 3901 4138 static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface, 3902 4139 const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) { … … 3932 4169 if(IWineD3DSurfaceImpl_BltOverride(This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx, Filter) == WINED3D_OK) return WINED3D_OK; 3933 4170 } 4171 4172 #ifdef VBOX_WITH_WDDM 4173 if (IWineD3DSurfaceImpl_BltSys2Vram(This, DestRect, SrcSurface, SrcRect, Flags, DDBltFx, Filter) == WINED3D_OK) return WINED3D_OK; 4174 #endif 3934 4175 3935 4176 /* For the rest call the X11 surface implementation. -
trunk/src/VBox/Devices/Graphics/DevVGA_VDMA.cpp
r33216 r33306 524 524 void * pvDst; 525 525 int rc = VINF_SUCCESS; 526 uint32_t cbTransfer = pTransfer->cbTransferSize; 527 uint32_t cbTransfered = 0; 526 528 bool bSrcLocked = false; 527 529 bool bDstLocked = false; 528 if (pTransfer->fFlags & VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET) 529 { 530 pvSrc = pvRam + pTransfer->Src.offVramBuf; 531 } 532 else 533 { 534 RTGCPHYS phPage = pTransfer->Src.phBuf; 535 rc = PDMDevHlpPhysGCPhys2CCPtrReadOnly(pDevIns, phPage, 0, &pvSrc, &SrcLock); 536 AssertRC(rc); 530 do 531 { 532 uint32_t cbSubTransfer = cbTransfer; 533 if (pTransfer->fFlags & VBOXVDMACMD_DMA_BPB_TRANSFER_F_SRC_VRAMOFFSET) 534 { 535 pvSrc = pvRam + pTransfer->Src.offVramBuf + cbTransfered; 536 } 537 else 538 { 539 RTGCPHYS phPage = pTransfer->Src.phBuf; 540 phPage += cbTransfered; 541 rc = PDMDevHlpPhysGCPhys2CCPtrReadOnly(pDevIns, phPage, 0, &pvSrc, &SrcLock); 542 AssertRC(rc); 543 if (RT_SUCCESS(rc)) 544 { 545 bSrcLocked = true; 546 cbSubTransfer = RT_MIN(cbSubTransfer, 0x1000); 547 } 548 else 549 { 550 break; 551 } 552 } 553 554 if (pTransfer->fFlags & VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET) 555 { 556 pvDst = pvRam + pTransfer->Dst.offVramBuf + cbTransfered; 557 } 558 else 559 { 560 RTGCPHYS phPage = pTransfer->Dst.phBuf; 561 phPage += cbTransfered; 562 rc = PDMDevHlpPhysGCPhys2CCPtr(pDevIns, phPage, 0, &pvDst, &DstLock); 563 AssertRC(rc); 564 if (RT_SUCCESS(rc)) 565 { 566 bDstLocked = true; 567 cbSubTransfer = RT_MIN(cbSubTransfer, 0x1000); 568 } 569 else 570 { 571 break; 572 } 573 } 574 537 575 if (RT_SUCCESS(rc)) 538 576 { 539 bSrcLocked = true; 540 } 541 } 542 543 if (pTransfer->fFlags & VBOXVDMACMD_DMA_BPB_TRANSFER_F_DST_VRAMOFFSET) 544 { 545 pvDst = pvRam + pTransfer->Dst.offVramBuf; 546 } 547 else 548 { 549 RTGCPHYS phPage = pTransfer->Dst.phBuf; 550 rc = PDMDevHlpPhysGCPhys2CCPtr(pDevIns, phPage, 0, &pvDst, &DstLock); 551 AssertRC(rc); 552 if (RT_SUCCESS(rc)) 553 { 554 bDstLocked = true; 555 } 556 } 557 558 if (RT_SUCCESS(rc)) 559 { 560 memcpy(pvDst, pvSrc, pTransfer->cbTransferSize); 561 } 562 563 if (bSrcLocked) 564 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &SrcLock); 565 if (bDstLocked) 566 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &DstLock); 577 memcpy(pvDst, pvSrc, cbSubTransfer); 578 cbTransfer -= cbSubTransfer; 579 cbTransfered += cbSubTransfer; 580 } 581 else 582 { 583 cbTransfer = 0; /* to break */ 584 } 585 586 if (bSrcLocked) 587 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &SrcLock); 588 if (bDstLocked) 589 PDMDevHlpPhysReleasePageMappingLock(pDevIns, &DstLock); 590 } while (cbTransfer); 567 591 568 592 if (RT_SUCCESS(rc)) -
trunk/src/VBox/GuestHost/OpenGL/util/vboxhgsmi.c
r33241 r33306 60 60 #endif 61 61 62 #define VBOX_WITH_CRHGSMIPROFILE 63 #ifdef VBOX_WITH_CRHGSMIPROFILE 64 #include <iprt/time.h> 65 #include <stdio.h> 66 67 typedef struct VBOXCRHGSMIPROFILE 68 { 69 uint64_t cStartTime; 70 uint64_t cStepsTime; 71 uint64_t cSteps; 72 } VBOXCRHGSMIPROFILE, *PVBOXCRHGSMIPROFILE; 73 74 #define VBOXCRHGSMIPROFILE_GET_TIME_NANO() RTTimeNanoTS() 75 #define VBOXCRHGSMIPROFILE_GET_TIME_MILLI() RTTimeMilliTS() 76 77 /* 10 sec */ 78 #define VBOXCRHGSMIPROFILE_LOG_STEP_TIME (10000000000.) 79 80 DECLINLINE(void) vboxCrHgsmiProfileStart(PVBOXCRHGSMIPROFILE pProfile) 81 { 82 pProfile->cStepsTime = 0; 83 pProfile->cSteps = 0; 84 pProfile->cStartTime = VBOXCRHGSMIPROFILE_GET_TIME_NANO(); 85 } 86 87 DECLINLINE(void) vboxCrHgsmiProfileStep(PVBOXCRHGSMIPROFILE pProfile, uint64_t cStepTime) 88 { 89 pProfile->cStepsTime += cStepTime; 90 ++pProfile->cSteps; 91 } 92 93 typedef struct VBOXCRHGSMIPROFILE_SCOPE 94 { 95 uint64_t cStartTime; 96 // bool bDisable; 97 } VBOXCRHGSMIPROFILE_SCOPE, *PVBOXCRHGSMIPROFILE_SCOPE; 98 99 static VBOXCRHGSMIPROFILE g_VBoxProfile; 100 101 static void vboxCrHgsmiLog(char * szString, ...) 102 { 103 char szBuffer[4096] = {0}; 104 va_list pArgList; 105 va_start(pArgList, szString); 106 _vsnprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), szString, pArgList); 107 va_end(pArgList); 108 109 VBoxCrHgsmiLog(szBuffer); 110 } 111 112 DECLINLINE(void) vboxCrHgsmiProfileLog(PVBOXCRHGSMIPROFILE pProfile, uint64_t cTime) 113 { 114 uint64_t profileTime = cTime - pProfile->cStartTime; 115 double percent = ((double)100.0) * pProfile->cStepsTime / profileTime; 116 double cps = ((double)1000000000.) * pProfile->cSteps / profileTime; 117 vboxCrHgsmiLog("hgsmi: cps: %.1f, host %.1f%%\n", cps, percent); 118 } 119 120 DECLINLINE(void) vboxCrHgsmiProfileScopeEnter(PVBOXCRHGSMIPROFILE_SCOPE pScope) 121 { 122 // pScope->bDisable = false; 123 pScope->cStartTime = VBOXCRHGSMIPROFILE_GET_TIME_NANO(); 124 } 125 126 DECLINLINE(void) vboxCrHgsmiProfileScopeExit(PVBOXCRHGSMIPROFILE_SCOPE pScope) 127 { 128 // if (!pScope->bDisable) 129 { 130 uint64_t cTime = VBOXCRHGSMIPROFILE_GET_TIME_NANO(); 131 vboxCrHgsmiProfileStep(&g_VBoxProfile, cTime - pScope->cStartTime); 132 if (VBOXCRHGSMIPROFILE_LOG_STEP_TIME < cTime - g_VBoxProfile.cStartTime) 133 { 134 vboxCrHgsmiProfileLog(&g_VBoxProfile, cTime); 135 vboxCrHgsmiProfileStart(&g_VBoxProfile); 136 } 137 } 138 } 139 140 141 #define VBOXCRHGSMIPROFILE_INIT() vboxCrHgsmiProfileStart(&g_VBoxProfile) 142 #define VBOXCRHGSMIPROFILE_TERM() do {} while (0) 143 144 #define VBOXCRHGSMIPROFILE_FUNC_PROLOGUE() \ 145 VBOXCRHGSMIPROFILE_SCOPE __vboxCrHgsmiProfileScope; \ 146 vboxCrHgsmiProfileScopeEnter(&__vboxCrHgsmiProfileScope); 147 148 #define VBOXCRHGSMIPROFILE_FUNC_EPILOGUE() \ 149 vboxCrHgsmiProfileScopeExit(&__vboxCrHgsmiProfileScope); \ 150 151 152 #else 153 #define VBOXCRHGSMIPROFILE_INIT() do {} while (0) 154 #define VBOXCRHGSMIPROFILE_TERM() do {} while (0) 155 #define VBOXCRHGSMIPROFILE_FUNC_PROLOGUE() do {} while (0) 156 #define VBOXCRHGSMIPROFILE_FUNC_EPILOGUE() do {} while (0) 157 #endif 158 159 62 160 typedef struct { 63 161 int initialized; … … 443 541 static void *crVBoxHGSMIAlloc(CRConnection *conn) 444 542 { 445 PCRVBOXHGSMI_CLIENT pClient = _crVBoxHGSMIClientGet(); 446 void *pvBuf = _crVBoxHGSMIDoAlloc(pClient, conn->buffer_size); 543 PCRVBOXHGSMI_CLIENT pClient; 544 void *pvBuf; 545 546 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 547 548 pClient = _crVBoxHGSMIClientGet(); 549 pvBuf = _crVBoxHGSMIDoAlloc(pClient, conn->buffer_size); 447 550 Assert(pvBuf); 551 552 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 553 448 554 return pvBuf; 449 555 } … … 456 562 pSubm->fFlags.Value = 0; 457 563 pSubm->fFlags.bDoNotRetire = 1; 458 pSubm->fFlags.bDoNotSignalCompletion = 1; /* <- we do not need that actually since459 * in case we want completion,460 * we will block in _crVBoxHGSMICmdBufferGetRc (when locking the buffer)461 * which is needed for getting the result */564 // pSubm->fFlags.bDoNotSignalCompletion = 1; /* <- we do not need that actually since 565 // * in case we want completion, 566 // * we will block in _crVBoxHGSMICmdBufferGetRc (when locking the buffer) 567 // * which is needed for getting the result */ 462 568 } 463 569 … … 467 573 # error "Port Me!!" 468 574 #endif 575 576 DECLINLINE(void) _crVBoxHGSMIWaitCmd(PCRVBOXHGSMI_CLIENT pClient) 577 { 578 int rc = CRVBOXHGSMI_BUF_WAIT(pClient->pCmdBuffer); 579 Assert(rc == 0); 580 } 469 581 470 582 static void _crVBoxHGSMIWriteExact(CRConnection *conn, PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI_BUFFER pBuf, uint32_t offStart, unsigned int len) … … 506 618 if (RT_SUCCESS(rc)) 507 619 { 620 _crVBoxHGSMIWaitCmd(pClient); 508 621 /* @todo: do we need to wait for completion actually? 509 622 * NOTE: in case we do not need completion, … … 539 652 if (RT_SUCCESS(rc)) 540 653 { 654 _crVBoxHGSMIWaitCmd(pClient); 541 655 /* @todo: do we need to wait for completion actually? 542 656 * NOTE: in case we do not need completion, … … 556 670 static void crVBoxHGSMIWriteExact(CRConnection *conn, const void *buf, unsigned int len) 557 671 { 672 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 558 673 Assert(0); 559 674 … … 566 681 // _crVBoxHGSMIWriteExact(conn, pClient, pBuf, 0, len); 567 682 // _crVBoxHGSMIBufFree(pClient, pBuf); 683 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 568 684 } 569 685 … … 609 725 return; 610 726 } 727 728 _crVBoxHGSMIWaitCmd(pClient); 611 729 612 730 parms = (CRVBOXHGSMIREAD *)_crVBoxHGSMICmdBufferLockRo(pClient, sizeof (*parms)); … … 733 851 break; 734 852 } 853 854 _crVBoxHGSMIWaitCmd(pClient); 735 855 736 856 parms = (CRVBOXHGSMIWRITEREAD *)_crVBoxHGSMICmdBufferLockRo(pClient, sizeof (*parms)); … … 799 919 PVBOXUHGSMI_BUFFER pBuf; 800 920 921 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 922 801 923 if (!bufp) /* We're sending a user-allocated buffer. */ 802 924 { … … 811 933 _crVBoxHGSMIWriteReadExact(conn, pClient, (void*)start, 0, len, false); 812 934 #endif 935 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 813 936 return; 814 937 } … … 822 945 Assert(pBuf); 823 946 if (!pBuf) 947 { 948 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 824 949 return; 950 } 825 951 826 952 pClient = (PCRVBOXHGSMI_CLIENT)pBuf->pvUserData; … … 847 973 */ 848 974 *bufp = NULL; 975 976 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 849 977 } 850 978 … … 852 980 { 853 981 PCRVBOXHGSMI_CLIENT pClient; 854 PVBOXUHGSMI_BUFFER pBuf = _crVBoxHGSMIBufFromMemPtr(buf); 982 PVBOXUHGSMI_BUFFER pBuf; 983 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 984 pBuf = _crVBoxHGSMIBufFromMemPtr(buf); 855 985 Assert(pBuf); 856 986 Assert(0); 857 987 CRASSERT(0); 858 988 if (!pBuf) 989 { 990 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 859 991 return; 992 } 860 993 pClient = (PCRVBOXHGSMI_CLIENT)pBuf->pvUserData; 861 994 _crVBoxHGSMIReadExact(conn, pClient); 862 } 863 864 static void crVBoxHGSMIFree(CRConnection *conn, void *buf) 995 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 996 } 997 998 static void _crVBoxHGSMIFree(CRConnection *conn, void *buf) 865 999 { 866 1000 CRVBOXHGSMIBUFFER *hgsmi_buffer = (CRVBOXHGSMIBUFFER *) buf - 1; … … 888 1022 #endif 889 1023 } 1024 } 1025 static void crVBoxHGSMIFree(CRConnection *conn, void *buf) 1026 { 1027 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1028 _crVBoxHGSMIFree(conn, buf); 1029 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 890 1030 } 891 1031 … … 967 1107 && cached_type != CR_MESSAGE_GATHER) 968 1108 { 969 crVBoxHGSMIFree(conn, msg);1109 _crVBoxHGSMIFree(conn, msg); 970 1110 } 971 1111 } … … 973 1113 static void crVBoxHGSMIReceiveMessage(CRConnection *conn) 974 1114 { 975 PCRVBOXHGSMI_CLIENT pClient = _crVBoxHGSMIClientGet(); 1115 PCRVBOXHGSMI_CLIENT pClient; 1116 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1117 1118 pClient = _crVBoxHGSMIClientGet(); 976 1119 977 1120 Assert(pClient); … … 979 1122 980 1123 _crVBoxHGSMIReceiveMessage(conn, pClient); 1124 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 981 1125 } 982 1126 /* … … 985 1129 static void crVBoxHGSMIAccept( CRConnection *conn, const char *hostname, unsigned short port ) 986 1130 { 1131 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 987 1132 Assert(0); 988 1133 … … 991 1136 CRASSERT(FALSE); 992 1137 #endif 1138 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 993 1139 } 994 1140 … … 1038 1184 #ifdef RT_OS_WINDOWS 1039 1185 DWORD cbReturned; 1186 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1040 1187 1041 1188 if (g_crvboxhgsmi.hGuestDrv == INVALID_HANDLE_VALUE) … … 1055 1202 Assert(0); 1056 1203 crDebug("could not open VBox Guest Additions driver! rc = %d\n", GetLastError()); 1204 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1057 1205 return FALSE; 1058 1206 } 1059 1207 } 1060 1208 #else 1209 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1210 1061 1211 if (g_crvboxhgsmi.iGuestDrv == INVALID_HANDLE_VALUE) 1062 1212 { … … 1065 1215 { 1066 1216 crDebug("could not open Guest Additions kernel module! rc = %d\n", errno); 1217 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1067 1218 return FALSE; 1068 1219 } … … 1097 1248 if (info.result == VINF_SUCCESS) 1098 1249 { 1250 int rc; 1099 1251 conn->u32ClientID = info.u32ClientID; 1100 1252 crDebug("HGCM connect was successful: client id =0x%x\n", conn->u32ClientID); 1101 1253 1102 return crVBoxHGSMISetVersion(conn, CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR); 1254 rc = crVBoxHGSMISetVersion(conn, CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR); 1255 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1256 return rc; 1103 1257 } 1104 1258 else … … 1116 1270 #endif 1117 1271 } 1272 1273 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1118 1274 1119 1275 return FALSE; … … 1135 1291 int i; 1136 1292 #endif 1293 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1137 1294 1138 1295 if (conn->pHostBuffer) … … 1214 1371 # endif 1215 1372 } 1373 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1216 1374 #endif /* IN_GUEST */ 1217 1375 } … … 1219 1377 static void crVBoxHGSMIInstantReclaim(CRConnection *conn, CRMessage *mess) 1220 1378 { 1379 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1221 1380 Assert(0); 1222 1381 1223 crVBoxHGSMIFree(conn, mess);1382 _crVBoxHGSMIFree(conn, mess); 1224 1383 CRASSERT(FALSE); 1384 1385 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1225 1386 } 1226 1387 1227 1388 static void crVBoxHGSMIHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len ) 1228 1389 { 1390 VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); 1229 1391 Assert(0); 1230 1392 1231 1393 CRASSERT(FALSE); 1394 VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); 1232 1395 } 1233 1396 … … 1241 1404 pClient->pHgsmi = pHgsmi; 1242 1405 rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(1), 1243 VBOXUHGSMI_SYNCHOBJECT_TYPE_SEMAPHORE, NULL, 1406 VBOXUHGSMI_SYNCHOBJECT_TYPE_EVENT, 1407 NULL, 1244 1408 &pClient->pCmdBuffer); 1245 1409 AssertRC(rc); … … 1247 1411 { 1248 1412 rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(0x800000), 1249 VBOXUHGSMI_SYNCHOBJECT_TYPE_SEMAPHORE, NULL, 1413 VBOXUHGSMI_SYNCHOBJECT_TYPE_EVENT, 1414 NULL, 1250 1415 &pClient->pHGBuffer); 1251 1416 AssertRC(rc);
Note:
See TracChangeset
for help on using the changeset viewer.