Changeset 46757 in vbox for trunk/src/VBox/GuestHost/OpenGL/util
- Timestamp:
- Jun 24, 2013 2:30:18 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 86685
- Location:
- trunk/src/VBox/GuestHost/OpenGL/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/util/error.c
r41635 r46757 246 246 } 247 247 248 #ifdef DEBUG_misha 249 # undef crWarning 250 #endif 248 251 DECLEXPORT(void) crWarning(const char *format, ... ) 249 252 { … … 496 499 #else 497 500 if (!output 498 # ifndef DEBUG_misha499 501 || output==stderr 500 # endif501 502 ) 502 503 { … … 505 506 else 506 507 { 507 # ifndef DEBUG_misha508 508 LogRel(("%s\n", txt)); 509 # endif510 509 outputChromiumMessage(output, txt); 511 510 } -
trunk/src/VBox/GuestHost/OpenGL/util/vreg.cpp
r45627 r46757 17 17 */ 18 18 #include <cr_vreg.h> 19 #include <iprt/memcache.h>20 19 #include <iprt/err.h> 21 20 #include <iprt/assert.h> 22 21 #include <iprt/asm.h> 23 22 24 #ifndef IN_RING025 23 #include <cr_error.h> 26 24 #define WARN(_m) do { crWarning _m ; } while (0) 27 #else 28 # error port me! 29 #endif 30 31 #ifdef DEBUG_misha 32 //# define VBOXVDBG_VR_LAL_DISABLE 33 #endif 34 25 26 #ifndef IN_RING0 27 #include <iprt/memcache.h> 35 28 #ifndef VBOXVDBG_VR_LAL_DISABLE 36 static volatile int32_t g_cVBoxVrInits = 0;37 29 static RTMEMCACHE g_VBoxVrLookasideList; 38 #endif 39 40 static PVBOXVR_REG vboxVrRegCreate() 41 { 42 #ifndef VBOXVDBG_VR_LAL_DISABLE 43 PVBOXVR_REG pReg = (PVBOXVR_REG)RTMemCacheAlloc(g_VBoxVrLookasideList); 44 if (!pReg) 45 { 46 WARN(("ExAllocateFromLookasideListEx failed!")); 47 } 48 return pReg; 49 #else 50 return (PVBOXVR_REG)RTMemAlloc(sizeof (VBOXVR_REG)); 51 #endif 52 } 53 54 static void vboxVrRegTerm(PVBOXVR_REG pReg) 55 { 56 #ifndef VBOXVDBG_VR_LAL_DISABLE 57 RTMemCacheFree(g_VBoxVrLookasideList, pReg); 58 #else 59 RTMemFree(pReg); 60 #endif 61 } 62 63 VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList) 64 { 65 PVBOXVR_REG pReg, pRegNext; 66 67 RTListForEachSafe(&pList->ListHead, pReg, pRegNext, VBOXVR_REG, ListEntry) 68 { 69 vboxVrRegTerm(pReg); 70 } 71 VBoxVrListInit(pList); 72 } 73 74 #define VBOXVR_MEMTAG 'vDBV' 75 76 VBOXVREGDECL(int) VBoxVrInit() 77 { 78 int32_t cNewRefs = ASMAtomicIncS32(&g_cVBoxVrInits); 79 Assert(cNewRefs >= 1); 80 Assert(cNewRefs == 1); /* <- debugging */ 81 if (cNewRefs > 1) 82 return VINF_SUCCESS; 83 84 #ifndef VBOXVDBG_VR_LAL_DISABLE 85 int rc = RTMemCacheCreate(&g_VBoxVrLookasideList, sizeof (VBOXVR_REG), 30 #define vboxVrRegLaAlloc(_c) RTMemCacheAlloc((_c)) 31 #define vboxVrRegLaFree(_c, _e) RTMemCacheFree((_c), (_e)) 32 DECLINLINE(int) vboxVrLaCreate(RTMEMCACHE *pCache, size_t cbElement) 33 { 34 int rc = RTMemCacheCreate(pCache, cbElement, 86 35 0, /* size_t cbAlignment */ 87 36 UINT32_MAX, /* uint32_t cMaxObjects */ … … 93 42 if (!RT_SUCCESS(rc)) 94 43 { 44 WARN(("RTMemCacheCreate failed rc %d", rc)); 45 return rc; 46 } 47 return VINF_SUCCESS; 48 } 49 #define vboxVrLaDestroy(_c) RTMemCacheDestroy((_c)) 50 #endif 51 #else 52 # ifdef RT_OS_WINDOWS 53 # ifdef PAGE_SIZE 54 # undef PAGE_SIZE 55 # endif 56 # ifdef PAGE_SHIFT 57 # undef PAGE_SHIFT 58 # endif 59 # define VBOX_WITH_WORKAROUND_MISSING_PACK 60 # if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK) 61 # define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap 62 # define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap 63 # define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap 64 # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap 65 # define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap 66 # define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap 67 # define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap 68 # define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap 69 # pragma warning(disable : 4163) 70 # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK 71 # pragma warning(disable : 4103) 72 # endif 73 # include <ntddk.h> 74 # pragma warning(default : 4163) 75 # ifdef VBOX_WITH_WORKAROUND_MISSING_PACK 76 # pragma pack() 77 # pragma warning(default : 4103) 78 # endif 79 # undef _InterlockedExchange 80 # undef _InterlockedExchangeAdd 81 # undef _InterlockedCompareExchange 82 # undef _InterlockedAddLargeStatistic 83 # undef _interlockedbittestandset 84 # undef _interlockedbittestandreset 85 # undef _interlockedbittestandset64 86 # undef _interlockedbittestandreset64 87 # else 88 # include <ntddk.h> 89 # endif 90 #ifndef VBOXVDBG_VR_LAL_DISABLE 91 static LOOKASIDE_LIST_EX g_VBoxVrLookasideList; 92 #define vboxVrRegLaAlloc(_c) ExAllocateFromLookasideListEx(&(_c)) 93 #define vboxVrRegLaFree(_c, _e) ExFreeToLookasideListEx(&(_c), (_e)) 94 #define VBOXWDDMVR_MEMTAG 'vDBV' 95 DECLINLINE(int) vboxVrLaCreate(LOOKASIDE_LIST_EX *pCache, size_t cbElement) 96 { 97 NTSTATUS Status = ExInitializeLookasideListEx(pCache, 98 NULL, /* PALLOCATE_FUNCTION_EX Allocate */ 99 NULL, /* PFREE_FUNCTION_EX Free */ 100 NonPagedPool, 101 0, /* ULONG Flags */ 102 cbElement, 103 VBOXWDDMVR_MEMTAG, 104 0 /* USHORT Depth - reserved, must be null */ 105 ); 106 if (!NT_SUCCESS(Status)) 107 { 108 WARN(("ExInitializeLookasideListEx failed, Status (0x%x)", Status)); 109 return VERR_GENERAL_FAILURE; 110 } 111 112 return VINF_SUCCESS; 113 } 114 #define vboxVrLaDestroy(_c) ExDeleteLookasideListEx(&(_c)) 115 #endif 116 # else 117 # error "port me!" 118 # endif 119 #endif 120 121 #ifdef DEBUG_misha 122 //# define VBOXVDBG_VR_LAL_DISABLE 123 #endif 124 125 #ifndef VBOXVDBG_VR_LAL_DISABLE 126 static volatile int32_t g_cVBoxVrInits = 0; 127 #endif 128 129 static PVBOXVR_REG vboxVrRegCreate() 130 { 131 #ifndef VBOXVDBG_VR_LAL_DISABLE 132 PVBOXVR_REG pReg = (PVBOXVR_REG)vboxVrRegLaAlloc(g_VBoxVrLookasideList); 133 if (!pReg) 134 { 135 WARN(("ExAllocateFromLookasideListEx failed!")); 136 } 137 return pReg; 138 #else 139 return (PVBOXVR_REG)RTMemAlloc(sizeof (VBOXVR_REG)); 140 #endif 141 } 142 143 static void vboxVrRegTerm(PVBOXVR_REG pReg) 144 { 145 #ifndef VBOXVDBG_VR_LAL_DISABLE 146 vboxVrRegLaFree(g_VBoxVrLookasideList, pReg); 147 #else 148 RTMemFree(pReg); 149 #endif 150 } 151 152 VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList) 153 { 154 PVBOXVR_REG pReg, pRegNext; 155 156 RTListForEachSafe(&pList->ListHead, pReg, pRegNext, VBOXVR_REG, ListEntry) 157 { 158 vboxVrRegTerm(pReg); 159 } 160 VBoxVrListInit(pList); 161 } 162 163 #define VBOXVR_MEMTAG 'vDBV' 164 165 VBOXVREGDECL(int) VBoxVrInit() 166 { 167 int32_t cNewRefs = ASMAtomicIncS32(&g_cVBoxVrInits); 168 Assert(cNewRefs >= 1); 169 Assert(cNewRefs == 1); /* <- debugging */ 170 if (cNewRefs > 1) 171 return VINF_SUCCESS; 172 173 #ifndef VBOXVDBG_VR_LAL_DISABLE 174 int rc = vboxVrLaCreate(&g_VBoxVrLookasideList, sizeof (VBOXVR_REG)); 175 if (!RT_SUCCESS(rc)) 176 { 95 177 WARN(("ExInitializeLookasideListEx failed, rc (%d)", rc)); 96 178 return rc; … … 109 191 110 192 #ifndef VBOXVDBG_VR_LAL_DISABLE 111 RTMemCacheDestroy(g_VBoxVrLookasideList);193 vboxVrLaDestroy(g_VBoxVrLookasideList); 112 194 #endif 113 195 } … … 1542 1624 int rc = VBoxVrListRectsGet(&pCEntry->Vr, cRects, pEntry->paDstRects); 1543 1625 AssertRC(rc); 1544 if (pCompositor->StretchX >= 1. && pCompositor->StretchY >= 1. /* <- stretching can not zero some rects */ 1545 && !pEntry->Pos.x && !pEntry->Pos.y) 1626 if ( 1627 #ifndef IN_RING0 1628 pCompositor->StretchX >= 1. && pCompositor->StretchY >= 1. /* <- stretching can not zero some rects */ 1629 && 1630 #endif 1631 !pEntry->Pos.x && !pEntry->Pos.y 1632 ) 1546 1633 { 1547 1634 memcpy(pEntry->paSrcRects, pEntry->paDstRects, cRects * sizeof (*pEntry->paSrcRects)); … … 1551 1638 for (uint32_t i = 0; i < cRects; ++i) 1552 1639 { 1553 pEntry->paSrcRects[i].xLeft = (int32_t)((pEntry->paDstRects[i].xLeft - pEntry->Pos.x) * pCompositor->StretchX); 1554 pEntry->paSrcRects[i].yTop = (int32_t)((pEntry->paDstRects[i].yTop - pEntry->Pos.y) * pCompositor->StretchY); 1555 pEntry->paSrcRects[i].xRight = (int32_t)((pEntry->paDstRects[i].xRight - pEntry->Pos.x) * pCompositor->StretchX); 1556 pEntry->paSrcRects[i].yBottom = (int32_t)((pEntry->paDstRects[i].yBottom - pEntry->Pos.y) * pCompositor->StretchY); 1557 } 1558 1559 bool canZeroX = (pCompositor->StretchX < 1); 1560 bool canZeroY = (pCompositor->StretchY < 1); 1640 pEntry->paSrcRects[i].xLeft = (int32_t)((pEntry->paDstRects[i].xLeft - pEntry->Pos.x)); 1641 pEntry->paSrcRects[i].yTop = (int32_t)((pEntry->paDstRects[i].yTop - pEntry->Pos.y)); 1642 pEntry->paSrcRects[i].xRight = (int32_t)((pEntry->paDstRects[i].xRight - pEntry->Pos.x)); 1643 pEntry->paSrcRects[i].yBottom = (int32_t)((pEntry->paDstRects[i].yBottom - pEntry->Pos.y)); 1644 #ifndef IN_RING0 1645 if (pCompositor->StretchX != 1.) 1646 { 1647 pEntry->paSrcRects[i].xLeft = (int32_t)(pEntry->paSrcRects[i].xLeft * pCompositor->StretchX); 1648 pEntry->paSrcRects[i].xRight = (int32_t)(pEntry->paSrcRects[i].xRight * pCompositor->StretchX); 1649 } 1650 if (pCompositor->StretchY != 1.) 1651 { 1652 pEntry->paSrcRects[i].yTop = (int32_t)(pEntry->paSrcRects[i].yTop * pCompositor->StretchY); 1653 pEntry->paSrcRects[i].yBottom = (int32_t)(pEntry->paSrcRects[i].yBottom * pCompositor->StretchY); 1654 } 1655 #endif 1656 } 1657 1658 #ifndef IN_RING0 1659 bool canZeroX = (pCompositor->StretchX < 1.); 1660 bool canZeroY = (pCompositor->StretchY < 1.); 1561 1661 if (canZeroX && canZeroY) 1562 1662 { … … 1589 1689 } 1590 1690 } 1591 } 1592 1691 #endif 1692 } 1593 1693 pEntry->cRects = cRects; 1594 1694 pData->paDstRects += cRects; … … 1980 2080 { 1981 2081 memset(pCompositor, 0, sizeof (*pCompositor)); 2082 #ifndef IN_RING0 1982 2083 int rc = RTCritSectInit(&pCompositor->CritSect); 1983 if (RT_SUCCESS(rc)) 1984 { 1985 VBoxVrCompositorInit(&pCompositor->Compositor, NULL); 1986 pCompositor->StretchX = 1.0; 1987 pCompositor->StretchY = 1.0; 1988 return VINF_SUCCESS; 1989 } 1990 else 2084 if (!RT_SUCCESS(rc)) 1991 2085 { 1992 2086 WARN(("RTCritSectInit failed rc %d", rc)); 1993 } 1994 return rc; 2087 return rc; 2088 } 2089 #endif 2090 VBoxVrCompositorInit(&pCompositor->Compositor, NULL); 2091 #ifndef IN_RING0 2092 pCompositor->StretchX = 1.0; 2093 pCompositor->StretchY = 1.0; 2094 #endif 2095 return VINF_SUCCESS; 1995 2096 } 1996 2097 … … 2002 2103 if (pCompositor->paSrcRects) 2003 2104 RTMemFree(pCompositor->paSrcRects); 2004 2105 #ifndef IN_RING0 2005 2106 RTCritSectDelete(&pCompositor->CritSect); 2107 #endif 2006 2108 } 2007 2109 … … 2018 2120 VBoxVrCompositorVisit(&pCompositor->Compositor, crVrScrCompositorEntrySetAllChangedCb, (void*)fChanged); 2019 2121 } 2020 2122 #ifndef IN_RING0 2021 2123 VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY) 2022 2124 { … … 2026 2128 CrVrScrCompositorEntrySetAllChanged(pCompositor, true); 2027 2129 } 2028 2130 #endif 2029 2131 /* regions are valid until the next CrVrScrCompositor call */ 2030 2132 VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t *pcRegions, const RTRECT **ppaSrcRegions, const RTRECT **ppaDstRegions)
Note:
See TracChangeset
for help on using the changeset viewer.