Changeset 57519 in vbox
- Timestamp:
- Aug 24, 2015 11:33:46 PM (9 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r57517 r57519 2842 2842 2843 2843 2844 /* If there are no recangles specified, just grab a viewport worth bits. */2844 /* Read the destination viewport specs in one go to try avoid some unnecessary update races. */ 2845 2845 VMSVGAVIEWPORT const DstViewport = pThis->svga.viewport; 2846 2846 ASMCompilerBarrier(); /* paranoia */ 2847 2847 Assert(DstViewport.yHighWC >= DstViewport.yLowWC); 2848 2848 2849 /* If there are no recangles specified, just grab a screenful. */ 2849 2850 SVGA3dCopyRect DummyRect; 2850 2851 if (cRects != 0) … … 2866 2867 } 2867 2868 2868 /* Blit the surface rectangle(s) to the back buffer. */ 2869 /* 2870 * Blit the surface rectangle(s) to the back buffer. 2871 */ 2869 2872 uint32_t const cxSurface = pSurface->pMipmapLevels[0].size.width; 2870 2873 uint32_t const cySurface = pSurface->pMipmapLevels[0].size.height; -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-win.cpp
r57358 r57519 2186 2186 pSurfaceD3D = pSurface->u.pSurface; 2187 2187 2188 /* Source surface different size? */ 2189 if (pSurface->pMipmapLevels[0].size.width != pThis->svga.uWidth || 2190 pSurface->pMipmapLevels[0].size.height != pThis->svga.uHeight) 2191 { 2192 float xMultiplier = (float)pSurface->pMipmapLevels[0].size.width / (float)pThis->svga.uWidth; 2193 float yMultiplier = (float)pSurface->pMipmapLevels[0].size.height / (float)pThis->svga.uHeight; 2194 2195 srcViewPort.x = (uint32_t)((float)pThis->svga.viewport.x * xMultiplier); 2196 srcViewPort.y = (uint32_t)((float)pThis->svga.viewport.y * yMultiplier); 2197 srcViewPort.cx = (uint32_t)((float)pThis->svga.viewport.cx * xMultiplier); 2198 srcViewPort.cy = (uint32_t)((float)pThis->svga.viewport.cy * yMultiplier); 2199 } 2188 /* Read the destination viewport specs in one go to try avoid some unnecessary update races. */ 2189 VMSVGAVIEWPORT const DstViewport = pThis->svga.viewport; 2190 ASMCompilerBarrier(); /* paranoia */ 2191 Assert(DstViewport.yHighWC >= DstViewport.yLowWC); 2192 2193 /* If there are no recangles specified, just grab a screenful. */ 2194 SVGA3dCopyRect DummyRect; 2195 if (cRects != 0) 2196 { /* likely */ } 2200 2197 else 2201 2198 { 2202 srcViewPort.x = pThis->svga.viewport.x; 2203 srcViewPort.y = pThis->svga.viewport.y; 2204 srcViewPort.cx = pThis->svga.viewport.cx; 2205 srcViewPort.cy = pThis->svga.viewport.cy; 2206 } 2207 2208 /* @note the viewport doesn't affect blitting. */ 2209 if (cRects == 0) 2210 { 2211 RECT rectDest, rectSrc; 2212 2213 rectSrc.left = srcViewPort.x; 2214 rectSrc.top = srcViewPort.y; 2215 rectSrc.right = rectSrc.left + srcViewPort.cx; 2216 rectSrc.bottom = rectSrc.top + srcViewPort.cy; 2217 rectDest.left = 0; 2218 rectDest.top = 0; 2219 rectDest.right = pThis->svga.viewport.cx; 2220 rectDest.bottom = pThis->svga.viewport.cy; 2221 hr = pContext->pDevice->StretchRect(pSurfaceD3D, &rectSrc, pBackBuffer, &rectDest, D3DTEXF_NONE); 2222 } 2223 else 2224 { 2225 for (uint32_t i = 0; i < cRects; i++) 2226 { 2227 RECT rectSrc; 2228 RECT rectDest; 2229 2230 if ( pRect[i].x + pRect[i].w <= pThis->svga.viewport.x 2231 || pThis->svga.viewport.x + pThis->svga.viewport.cx <= pRect[i].x 2232 || pRect[i].y + pRect[i].h <= pThis->svga.viewport.y 2233 || pThis->svga.viewport.y + pThis->svga.viewport.cy <= pRect[i].y) 2199 /** @todo Find the usecase for this or check what the original device does. 2200 * The original code was doing some scaling based on the surface 2201 * size... */ 2202 # ifdef DEBUG_bird 2203 AssertMsgFailed(("No rects to present. Who is doing that and what do they actually expect?\n")); 2204 # endif 2205 DummyRect.x = DummyRect.srcx = 0; 2206 DummyRect.y = DummyRect.srcy = 0; 2207 DummyRect.w = pThis->svga.uWidth; 2208 DummyRect.h = pThis->svga.uHeight; 2209 cRects = 1; 2210 pRect = &DummyRect; 2211 } 2212 2213 /* 2214 * Blit the surface rectangle(s) to the back buffer. 2215 */ 2216 uint32_t const cxSurface = pSurface->pMipmapLevels[0].size.width; 2217 uint32_t const cySurface = pSurface->pMipmapLevels[0].size.height; 2218 for (uint32_t i = 0; i < cRects; i++) 2219 { 2220 SVGA3dCopyRect ClippedRect = pRect[i]; 2221 2222 /* 2223 * Do some sanity checking and limit width and height, all so we 2224 * don't need to think about wrap-arounds below. 2225 */ 2226 if (RT_LIKELY( ClippedRect.w 2227 && ClippedRect.x < VMSVGA_MAX_X 2228 && ClippedRect.srcx < VMSVGA_MAX_X 2229 && ClippedRect.h 2230 && ClippedRect.y < VMSVGA_MAX_Y 2231 && ClippedRect.srcy < VMSVGA_MAX_Y 2232 )) 2233 { /* likely */ } 2234 else 2235 continue; 2236 2237 if (RT_LIKELY(ClippedRect.w < VMSVGA_MAX_Y)) 2238 { /* likely */ } 2239 else 2240 ClippedRect.w = VMSVGA_MAX_Y; 2241 if (RT_LIKELY(ClippedRect.w < VMSVGA_MAX_Y)) 2242 { /* likely */ } 2243 else 2244 ClippedRect.w = VMSVGA_MAX_Y; 2245 2246 /* 2247 * Source surface clipping (paranoia). Straight forward. 2248 */ 2249 if (RT_LIKELY(ClippedRect.srcx < cxSurface)) 2250 { /* likely */ } 2251 else 2252 continue; 2253 if (RT_LIKELY(ClippedRect.srcx + ClippedRect.w <= cxSurface)) 2254 { /* likely */ } 2255 else 2256 { 2257 AssertFailed(); /* remove if annoying. */ 2258 ClippedRect.w = cxSurface - ClippedRect.srcx; 2259 } 2260 2261 if (RT_LIKELY(ClippedRect.srcy < cySurface)) 2262 { /* likely */ } 2263 else 2264 continue; 2265 if (RT_LIKELY(ClippedRect.srcy + ClippedRect.h <= cySurface)) 2266 { /* likely */ } 2267 else 2268 { 2269 AssertFailed(); /* remove if annoying. */ 2270 ClippedRect.h = cySurface - ClippedRect.srcy; 2271 } 2272 2273 /* 2274 * Destination viewport clipping. 2275 * 2276 * This is very straight forward compared to OpenGL. There is no Y 2277 * inversion anywhere and all the coordinate systems are the same. 2278 */ 2279 /* X */ 2280 if (ClippedRect.x >= DstViewport.x) 2281 { 2282 if (ClippedRect.x + ClippedRect.w <= DstViewport.xRight) 2283 { /* typical */ } 2284 else if (ClippedRect.x < DstViewport.xRight) 2285 ClippedRect.w = DstViewport.xRight - ClippedRect.x; 2286 else 2287 continue; 2288 } 2289 else 2290 { 2291 uint32_t cxAdjust = DstViewport.x - ClippedRect.x; 2292 if (cxAdjust < ClippedRect.w) 2234 2293 { 2235 /* Intersection is empty; skip */ 2294 ClippedRect.w -= cxAdjust; 2295 ClippedRect.x += cxAdjust; 2296 ClippedRect.srcx += cxAdjust; 2297 } 2298 else 2236 2299 continue; 2300 2301 if (ClippedRect.x + ClippedRect.w <= DstViewport.xRight) 2302 { /* typical */ } 2303 else 2304 ClippedRect.w = DstViewport.xRight - ClippedRect.x; 2305 } 2306 2307 /* Y */ 2308 if (ClippedRect.y >= DstViewport.y) 2309 { 2310 if (ClippedRect.y + ClippedRect.h <= DstViewport.y + DstViewport.cy) 2311 { /* typical */ } 2312 else if (ClippedRect.x < DstViewport.y + DstViewport.cy) 2313 ClippedRect.h = DstViewport.y + DstViewport.cy - ClippedRect.y; 2314 else 2315 continue; 2316 } 2317 else 2318 { 2319 uint32_t cyAdjust = DstViewport.y - ClippedRect.y; 2320 if (cyAdjust < ClippedRect.h) 2321 { 2322 ClippedRect.h -= cyAdjust; 2323 ClippedRect.y += cyAdjust; 2324 ClippedRect.srcy += cyAdjust; 2237 2325 } 2238 2239 rectSrc.left = RT_MAX(pRect[i].srcx, srcViewPort.x); 2240 rectSrc.top = RT_MAX(pRect[i].srcy, srcViewPort.y); 2241 rectSrc.right = RT_MIN(pRect[i].srcx + pRect[i].w, srcViewPort.x + srcViewPort.cx); 2242 rectSrc.bottom = RT_MIN(pRect[i].srcy + pRect[i].h, srcViewPort.y + srcViewPort.cy); 2243 rectDest.left = RT_MAX(pRect[i].x, pThis->svga.viewport.x) - pThis->svga.viewport.x; 2244 rectDest.top = RT_MAX(pRect[i].y, pThis->svga.viewport.y) - pThis->svga.viewport.y; 2245 rectDest.right = RT_MIN(pRect[i].x + pRect[i].w, pThis->svga.viewport.x + pThis->svga.viewport.cx) - pThis->svga.viewport.x; 2246 rectDest.bottom = RT_MIN(pRect[i].y + pRect[i].h, pThis->svga.viewport.y + pThis->svga.viewport.cy) - pThis->svga.viewport.y; 2247 2248 hr = pContext->pDevice->StretchRect(pSurfaceD3D, &rectSrc, pBackBuffer, &rectDest, D3DTEXF_NONE); 2249 AssertBreak(hr == D3D_OK); 2250 } 2251 } 2326 else 2327 continue; 2328 2329 if (ClippedRect.y + ClippedRect.h <= DstViewport.y + DstViewport.cy) 2330 { /* typical */ } 2331 else 2332 ClippedRect.h = DstViewport.y + DstViewport.cy - ClippedRect.y; 2333 } 2334 2335 /* Calc source rectangle. */ 2336 RECT SrcRect; 2337 SrcRect.left = ClippedRect.srcx; 2338 SrcRect.right = ClippedRect.srcx + ClippedRect.w; 2339 SrcRect.top = ClippedRect.srcy; 2340 SrcRect.bottom = ClippedRect.srcy + ClippedRect.h; 2341 2342 /* Calc destination rectangle. */ 2343 RECT DstRect; 2344 DstRect.left = ClippedRect.x; 2345 DstRect.right = ClippedRect.x + ClippedRect.w; 2346 DstRect.top = ClippedRect.y; 2347 DstRect.bottom = ClippedRect.y + ClippedRect.h; 2348 2349 /* Adjust for viewport. */ 2350 DstRect.left -= DstViewport.x; 2351 DstRect.right -= DstViewport.x; 2352 DstRect.bottom -= DstViewport.y; 2353 DstRect.top -= DstViewport.y; 2354 2355 Log(("SrcRect: (%d,%d)(%d,%d) DstRect: (%d,%d)(%d,%d)\n", 2356 SrcRect.left, SrcRect.bottom, SrcRect.right, SrcRect.top, 2357 DstRect.left, DstRect.bottom, DstRect.right, DstRect.top)); 2358 hr = pContext->pDevice->StretchRect(pSurfaceD3D, &SrcRect, pBackBuffer, &DstRect, D3DTEXF_NONE); 2359 AssertBreak(hr == D3D_OK); 2360 } 2361 #endif 2252 2362 2253 2363 if (pSurface->flags & SVGA3D_SURFACE_HINT_TEXTURE)
Note:
See TracChangeset
for help on using the changeset viewer.