VirtualBox

source: vbox/trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d.cpp@ 86838

Last change on this file since 86838 was 86838, checked in by vboxsync, 4 years ago

Devices/Graphics: A couple of new commands; a more generic handler for creating a surface; cleaned saved state data for a surface; increased saved state version; possibility to build DX11 backend. bugref:9830

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 38.6 KB
Line 
1/* $Id: DevVGA-SVGA3d.cpp 86838 2020-11-09 23:16:50Z vboxsync $ */
2/** @file
3 * DevSVGA3d - VMWare SVGA device, 3D parts - Common core code.
4 */
5
6/*
7 * Copyright (C) 2013-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_DEV_VMSVGA
23#include <VBox/vmm/pdmdev.h>
24#include <iprt/errcore.h>
25#include <VBox/log.h>
26
27#include <iprt/assert.h>
28#include <iprt/mem.h>
29
30#include <VBox/vmm/pgm.h> /* required by DevVGA.h */
31#include <VBoxVideo.h> /* required by DevVGA.h */
32
33/* should go BEFORE any other DevVGA include to make all DevVGA.h config defines be visible */
34#include "DevVGA.h"
35
36#include "DevVGA-SVGA.h"
37#include "DevVGA-SVGA3d.h"
38#define VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS
39#include "DevVGA-SVGA3d-internal.h"
40
41
42
43/**
44 * Implements the SVGA_3D_CMD_SURFACE_DEFINE_V2 and SVGA_3D_CMD_SURFACE_DEFINE
45 * commands (fifo).
46 *
47 * @returns VBox status code (currently ignored).
48 * @param pThisCC The VGA/VMSVGA state for ring-3.
49 * @param sid The ID of the surface to (re-)define.
50 * @param surfaceFlags .
51 * @param format .
52 * @param multisampleCount .
53 * @param autogenFilter .
54 * @param numMipLevels .
55 * @param pMipLevel0Size .
56 */
57int vmsvga3dSurfaceDefine(PVGASTATECC pThisCC, uint32_t sid, SVGA3dSurfaceFlags surfaceFlags, SVGA3dSurfaceFormat format,
58 uint32_t multisampleCount, SVGA3dTextureFilter autogenFilter,
59 uint32_t numMipLevels, SVGA3dSize const *pMipLevel0Size)
60{
61 PVMSVGA3DSURFACE pSurface;
62 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
63 AssertReturn(pState, VERR_INVALID_STATE);
64
65 LogFunc(("sid=%u surfaceFlags=%#x format=%s (%#x) multiSampleCount=%d autogenFilter=%d, numMipLevels=%d size=(%dx%dx%d)\n",
66 sid, surfaceFlags, vmsvgaLookupEnum((int)format, &g_SVGA3dSurfaceFormat2String), format, multisampleCount, autogenFilter,
67 numMipLevels, pMipLevel0Size->width, pMipLevel0Size->height, pMipLevel0Size->depth));
68
69 AssertReturn(sid < SVGA3D_MAX_SURFACE_IDS, VERR_INVALID_PARAMETER);
70 AssertReturn(numMipLevels >= 1, VERR_INVALID_PARAMETER);
71
72 if (sid >= pState->cSurfaces)
73 {
74 /* Grow the array. */
75 uint32_t cNew = RT_ALIGN(sid + 15, 16);
76 void *pvNew = RTMemRealloc(pState->papSurfaces, sizeof(pState->papSurfaces[0]) * cNew);
77 AssertReturn(pvNew, VERR_NO_MEMORY);
78 pState->papSurfaces = (PVMSVGA3DSURFACE *)pvNew;
79 while (pState->cSurfaces < cNew)
80 {
81 pSurface = (PVMSVGA3DSURFACE)RTMemAllocZ(sizeof(*pSurface));
82 AssertReturn(pSurface, VERR_NO_MEMORY);
83 pSurface->id = SVGA3D_INVALID_ID;
84 pState->papSurfaces[pState->cSurfaces++] = pSurface;
85 }
86 }
87 pSurface = pState->papSurfaces[sid];
88
89 /* If one already exists with this id, then destroy it now. */
90 if (pSurface->id != SVGA3D_INVALID_ID)
91 vmsvga3dSurfaceDestroy(pThisCC, sid);
92
93 RT_ZERO(*pSurface);
94 pSurface->id = sid;
95#ifdef VMSVGA3D_OPENGL
96 pSurface->idWeakContextAssociation = SVGA3D_INVALID_ID;
97 pSurface->oglId.buffer = OPENGL_INVALID_ID;
98#elif defined(VMSVGA3D_DX)
99 // pSurface->pBackendSurface = NULL;
100#else /* VMSVGA3D_DIRECT3D */
101 pSurface->idAssociatedContext = SVGA3D_INVALID_ID;
102 pSurface->hSharedObject = NULL;
103 pSurface->pSharedObjectTree = NULL;
104#endif
105
106 /** @todo This 'switch' and the sufraceFlags tweaks should not be necessary.
107 * The actual surface type will be figured out when the surface is actually used later.
108 * The backends code must be reviewed for unnecessary dependencies on the surfaceFlags value.
109 */
110 /* The surface type is sort of undefined now, even though the hints and format can help to clear that up.
111 * In some case we'll have to wait until the surface is used to create the D3D object.
112 */
113 switch (format)
114 {
115 case SVGA3D_Z_D32:
116 case SVGA3D_Z_D16:
117 case SVGA3D_Z_D24S8:
118 case SVGA3D_Z_D15S1:
119 case SVGA3D_Z_D24X8:
120 case SVGA3D_Z_DF16:
121 case SVGA3D_Z_DF24:
122 case SVGA3D_Z_D24S8_INT:
123 Assert(surfaceFlags & SVGA3D_SURFACE_HINT_DEPTHSTENCIL);
124 surfaceFlags |= SVGA3D_SURFACE_HINT_DEPTHSTENCIL;
125 break;
126
127 /* Texture compression formats */
128 case SVGA3D_DXT1:
129 case SVGA3D_DXT2:
130 case SVGA3D_DXT3:
131 case SVGA3D_DXT4:
132 case SVGA3D_DXT5:
133 /* Bump-map formats */
134 case SVGA3D_BUMPU8V8:
135 case SVGA3D_BUMPL6V5U5:
136 case SVGA3D_BUMPX8L8V8U8:
137 case SVGA3D_V8U8:
138 case SVGA3D_Q8W8V8U8:
139 case SVGA3D_CxV8U8:
140 case SVGA3D_X8L8V8U8:
141 case SVGA3D_A2W10V10U10:
142 case SVGA3D_V16U16:
143 /* Typical render target formats; we should allow render target buffers to be used as textures. */
144 case SVGA3D_X8R8G8B8:
145 case SVGA3D_A8R8G8B8:
146 case SVGA3D_R5G6B5:
147 case SVGA3D_X1R5G5B5:
148 case SVGA3D_A1R5G5B5:
149 case SVGA3D_A4R4G4B4:
150 Assert(surfaceFlags & (SVGA3D_SURFACE_HINT_TEXTURE | SVGA3D_SURFACE_SCREENTARGET));
151 surfaceFlags |= SVGA3D_SURFACE_HINT_TEXTURE;
152 break;
153
154 case SVGA3D_LUMINANCE8:
155 case SVGA3D_LUMINANCE4_ALPHA4:
156 case SVGA3D_LUMINANCE16:
157 case SVGA3D_LUMINANCE8_ALPHA8:
158 case SVGA3D_ARGB_S10E5: /* 16-bit floating-point ARGB */
159 case SVGA3D_ARGB_S23E8: /* 32-bit floating-point ARGB */
160 case SVGA3D_A2R10G10B10:
161 case SVGA3D_ALPHA8:
162 case SVGA3D_R_S10E5:
163 case SVGA3D_R_S23E8:
164 case SVGA3D_RG_S10E5:
165 case SVGA3D_RG_S23E8:
166 case SVGA3D_G16R16:
167 case SVGA3D_A16B16G16R16:
168 case SVGA3D_UYVY:
169 case SVGA3D_YUY2:
170 case SVGA3D_NV12:
171 case SVGA3D_AYUV:
172 case SVGA3D_ATI1:
173 case SVGA3D_ATI2:
174 break;
175
176 /*
177 * Any surface can be used as a buffer object, but SVGA3D_BUFFER is
178 * the most efficient format to use when creating new surfaces
179 * expressly for index or vertex data.
180 */
181 case SVGA3D_BUFFER:
182 break;
183
184 default:
185 break;
186 }
187
188 pSurface->surfaceFlags = surfaceFlags;
189 pSurface->format = format;
190 /* cFaces is 6 for a cubemaps and 1 otherwise. */
191 pSurface->cFaces = (uint32_t)((surfaceFlags & SVGA3D_SURFACE_CUBEMAP) ? 6 : 1);
192 pSurface->cLevels = numMipLevels;
193 pSurface->multiSampleCount = multisampleCount;
194 pSurface->autogenFilter = autogenFilter;
195 Assert(autogenFilter != SVGA3D_TEX_FILTER_FLATCUBIC);
196 Assert(autogenFilter != SVGA3D_TEX_FILTER_GAUSSIANCUBIC);
197 pSurface->paMipmapLevels = (PVMSVGA3DMIPMAPLEVEL)RTMemAllocZ(numMipLevels * pSurface->cFaces * sizeof(VMSVGA3DMIPMAPLEVEL));
198 AssertReturn(pSurface->paMipmapLevels, VERR_NO_MEMORY);
199
200 pSurface->cbBlock = vmsvga3dSurfaceFormatSize(format, &pSurface->cxBlock, &pSurface->cyBlock);
201 AssertReturn(pSurface->cbBlock, VERR_INVALID_PARAMETER);
202
203 /** @todo cbMemRemaining = value of SVGA_REG_MOB_MAX_SIZE */
204 uint32_t cbMemRemaining = SVGA3D_MAX_SURFACE_MEM_SIZE; /* Do not allow more than this for a surface. */
205 SVGA3dSize mipmapSize = *pMipLevel0Size;
206 for (uint32_t i = 0; i < numMipLevels; ++i)
207 {
208 for (uint32_t iFace = 0; iFace < pSurface->cFaces; ++iFace)
209 {
210 uint32_t const iMipmap = iFace * numMipLevels + i;
211 LogFunc(("[%d] face %d mip level %d (%d,%d,%d) cbBlock=%#x block %dx%d\n",
212 iMipmap, iFace, i, mipmapSize.width, mipmapSize.height, mipmapSize.depth,
213 pSurface->cbBlock, pSurface->cxBlock, pSurface->cyBlock));
214
215 uint32_t cBlocksX;
216 uint32_t cBlocksY;
217 if (RT_LIKELY(pSurface->cxBlock == 1 && pSurface->cyBlock == 1))
218 {
219 cBlocksX = mipmapSize.width;
220 cBlocksY = mipmapSize.height;
221 }
222 else
223 {
224 cBlocksX = mipmapSize.width / pSurface->cxBlock;
225 if (mipmapSize.width % pSurface->cxBlock)
226 ++cBlocksX;
227 cBlocksY = mipmapSize.height / pSurface->cyBlock;
228 if (mipmapSize.height % pSurface->cyBlock)
229 ++cBlocksY;
230 }
231
232 AssertReturn(cBlocksX > 0 && cBlocksY > 0 && mipmapSize.depth > 0, VERR_INVALID_PARAMETER);
233
234 const uint32_t cMaxBlocksX = cbMemRemaining / pSurface->cbBlock;
235 if (cBlocksX > cMaxBlocksX)
236 return VERR_INVALID_PARAMETER;
237 const uint32_t cbSurfacePitch = pSurface->cbBlock * cBlocksX;
238 LogFunc(("cbSurfacePitch=0x%x\n", cbSurfacePitch));
239
240 const uint32_t cMaxBlocksY = cbMemRemaining / cbSurfacePitch;
241 if (cBlocksY > cMaxBlocksY)
242 return VERR_INVALID_PARAMETER;
243 const uint32_t cbSurfacePlane = cbSurfacePitch * cBlocksY;
244
245 const uint32_t cMaxDepth = cbMemRemaining / cbSurfacePlane;
246 if (mipmapSize.depth > cMaxDepth)
247 return VERR_INVALID_PARAMETER;
248 const uint32_t cbSurface = cbSurfacePlane * mipmapSize.depth;
249
250 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[iMipmap];
251 pMipmapLevel->mipmapSize = mipmapSize;
252 pMipmapLevel->cBlocksX = cBlocksX;
253 pMipmapLevel->cBlocksY = cBlocksY;
254 pMipmapLevel->cBlocks = cBlocksX * cBlocksY * mipmapSize.depth;
255 pMipmapLevel->cbSurfacePitch = cbSurfacePitch;
256 pMipmapLevel->cbSurfacePlane = cbSurfacePlane;
257 pMipmapLevel->cbSurface = cbSurface;
258 pMipmapLevel->pSurfaceData = NULL;
259
260 cbMemRemaining -= cbSurface;
261 }
262
263 mipmapSize.width >>= 1;
264 if (mipmapSize.width == 0) mipmapSize.width = 1;
265 mipmapSize.height >>= 1;
266 if (mipmapSize.height == 0) mipmapSize.height = 1;
267 mipmapSize.depth >>= 1;
268 if (mipmapSize.depth == 0) mipmapSize.depth = 1;
269 }
270
271#ifdef VMSVGA3D_DIRECT3D
272 /* Translate the format and usage flags to D3D. */
273 pSurface->d3dfmtRequested = vmsvga3dSurfaceFormat2D3D(format);
274 pSurface->formatD3D = D3D9GetActualFormat(pState, pSurface->d3dfmtRequested);
275 pSurface->multiSampleTypeD3D= vmsvga3dMultipeSampleCount2D3D(multisampleCount);
276 pSurface->fUsageD3D = 0;
277 if (surfaceFlags & SVGA3D_SURFACE_HINT_DYNAMIC)
278 pSurface->fUsageD3D |= D3DUSAGE_DYNAMIC;
279 if (surfaceFlags & SVGA3D_SURFACE_HINT_RENDERTARGET)
280 pSurface->fUsageD3D |= D3DUSAGE_RENDERTARGET;
281 if (surfaceFlags & SVGA3D_SURFACE_HINT_DEPTHSTENCIL)
282 pSurface->fUsageD3D |= D3DUSAGE_DEPTHSTENCIL;
283 if (surfaceFlags & SVGA3D_SURFACE_HINT_WRITEONLY)
284 pSurface->fUsageD3D |= D3DUSAGE_WRITEONLY;
285 if (surfaceFlags & SVGA3D_SURFACE_AUTOGENMIPMAPS)
286 pSurface->fUsageD3D |= D3DUSAGE_AUTOGENMIPMAP;
287 pSurface->enmD3DResType = VMSVGA3D_D3DRESTYPE_NONE;
288 /* pSurface->u.pSurface = NULL; */
289 /* pSurface->bounce.pTexture = NULL; */
290 /* pSurface->emulated.pTexture = NULL; */
291#elif defined(VMSVGA3D_DX)
292 /* Nothing, because all backend specific data reside in pSurface->pBackendSurface. */
293#else
294 /* pSurface->fEmulated = false; */
295 /* pSurface->idEmulated = OPENGL_INVALID_ID; */
296 vmsvga3dSurfaceFormat2OGL(pSurface, format);
297#endif
298
299 LogFunc(("surface hint(s):%s%s%s%s%s%s\n",
300 (surfaceFlags & SVGA3D_SURFACE_HINT_INDEXBUFFER) ? " SVGA3D_SURFACE_HINT_INDEXBUFFER" : "",
301 (surfaceFlags & SVGA3D_SURFACE_HINT_VERTEXBUFFER) ? " SVGA3D_SURFACE_HINT_VERTEXBUFFER" : "",
302 (surfaceFlags & SVGA3D_SURFACE_HINT_TEXTURE) ? " SVGA3D_SURFACE_HINT_TEXTURE" : "",
303 (surfaceFlags & SVGA3D_SURFACE_HINT_DEPTHSTENCIL) ? " SVGA3D_SURFACE_HINT_DEPTHSTENCIL" : "",
304 (surfaceFlags & SVGA3D_SURFACE_HINT_RENDERTARGET) ? " SVGA3D_SURFACE_HINT_RENDERTARGET" : "",
305 (surfaceFlags & SVGA3D_SURFACE_CUBEMAP) ? " SVGA3D_SURFACE_CUBEMAP" : ""
306 ));
307
308 Assert(!VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface));
309
310 /* Allocate buffer to hold the surface data until we can move it into a D3D object */
311 for (uint32_t i = 0; i < numMipLevels * pSurface->cFaces; ++i)
312 {
313 PVMSVGA3DMIPMAPLEVEL pMipmapLevel = &pSurface->paMipmapLevels[i];
314 pMipmapLevel->pSurfaceData = RTMemAllocZ(pMipmapLevel->cbSurface);
315 AssertReturn(pMipmapLevel->pSurfaceData, VERR_NO_MEMORY);
316 }
317 return VINF_SUCCESS;
318}
319
320
321/**
322 * Implements the SVGA_3D_CMD_SURFACE_DESTROY command (fifo).
323 *
324 * @returns VBox status code (currently ignored).
325 * @param pThisCC The VGA/VMSVGA state for ring-3.
326 * @param sid The ID of the surface to destroy.
327 */
328int vmsvga3dSurfaceDestroy(PVGASTATECC pThisCC, uint32_t sid)
329{
330 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
331 AssertReturn(pState, VERR_NO_MEMORY);
332
333 PVMSVGA3DSURFACE pSurface;
334 int rc = vmsvga3dSurfaceFromSid(pState, sid, &pSurface);
335 AssertRCReturn(rc, rc);
336
337 LogFunc(("sid=%u\n", sid));
338
339 /* Check all contexts if this surface is used as a render target or active texture. */
340 for (uint32_t cid = 0; cid < pState->cContexts; cid++)
341 {
342 PVMSVGA3DCONTEXT pContext = pState->papContexts[cid];
343 if (pContext->id == cid)
344 {
345 for (uint32_t i = 0; i < RT_ELEMENTS(pContext->aSidActiveTextures); ++i)
346 if (pContext->aSidActiveTextures[i] == sid)
347 pContext->aSidActiveTextures[i] = SVGA3D_INVALID_ID;
348 for (uint32_t i = 0; i < RT_ELEMENTS(pContext->state.aRenderTargets); ++i)
349 if (pContext->state.aRenderTargets[i] == sid)
350 pContext->state.aRenderTargets[i] = SVGA3D_INVALID_ID;
351 }
352 }
353
354 vmsvga3dBackSurfaceDestroy(pState, pSurface);
355
356 if (pSurface->paMipmapLevels)
357 {
358 for (uint32_t i = 0; i < pSurface->cLevels * pSurface->cFaces; ++i)
359 RTMemFreeZ(pSurface->paMipmapLevels[i].pSurfaceData, pSurface->paMipmapLevels[i].cbSurface);
360 RTMemFree(pSurface->paMipmapLevels);
361 }
362
363 memset(pSurface, 0, sizeof(*pSurface));
364 pSurface->id = SVGA3D_INVALID_ID;
365
366 return VINF_SUCCESS;
367}
368
369
370/**
371 * Implements the SVGA_3D_CMD_SURFACE_STRETCHBLT command (fifo).
372 *
373 * @returns VBox status code (currently ignored).
374 * @param pThis The shared VGA/VMSVGA state.
375 * @param pThisCC The VGA/VMSVGA state for ring-3.
376 * @param pDstSfcImg
377 * @param pDstBox
378 * @param pSrcSfcImg
379 * @param pSrcBox
380 * @param enmMode
381 */
382int vmsvga3dSurfaceStretchBlt(PVGASTATE pThis, PVGASTATECC pThisCC, SVGA3dSurfaceImageId const *pDstSfcImg, SVGA3dBox const *pDstBox,
383 SVGA3dSurfaceImageId const *pSrcSfcImg, SVGA3dBox const *pSrcBox, SVGA3dStretchBltMode enmMode)
384{
385 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
386 AssertReturn(pState, VERR_NO_MEMORY);
387
388 int rc;
389
390 uint32_t const sidSrc = pSrcSfcImg->sid;
391 PVMSVGA3DSURFACE pSrcSurface;
392 rc = vmsvga3dSurfaceFromSid(pState, sidSrc, &pSrcSurface);
393 AssertRCReturn(rc, rc);
394
395 uint32_t const sidDst = pDstSfcImg->sid;
396 PVMSVGA3DSURFACE pDstSurface;
397 rc = vmsvga3dSurfaceFromSid(pState, sidDst, &pDstSurface);
398 AssertRCReturn(rc, rc);
399
400 AssertReturn(pSrcSfcImg->face < pSrcSurface->cFaces, VERR_INVALID_PARAMETER);
401 AssertReturn(pSrcSfcImg->mipmap < pSrcSurface->cLevels, VERR_INVALID_PARAMETER);
402 AssertReturn(pDstSfcImg->face < pDstSurface->cFaces, VERR_INVALID_PARAMETER);
403 AssertReturn(pDstSfcImg->mipmap < pDstSurface->cLevels, VERR_INVALID_PARAMETER);
404
405 PVMSVGA3DCONTEXT pContext;
406#ifdef VMSVGA3D_OPENGL
407 LogFunc(("src sid=%u (%d,%d)(%d,%d) dest sid=%u (%d,%d)(%d,%d) mode=%x\n",
408 sidSrc, pSrcBox->x, pSrcBox->y, pSrcBox->x + pSrcBox->w, pSrcBox->y + pSrcBox->h,
409 sidDst, pDstBox->x, pDstBox->y, pDstBox->x + pDstBox->w, pDstBox->y + pDstBox->h, enmMode));
410 pContext = &pState->SharedCtx;
411 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
412#else
413 LogFunc(("src sid=%u cid=%u (%d,%d)(%d,%d) dest sid=%u cid=%u (%d,%d)(%d,%d) mode=%x\n",
414 sidSrc, pSrcSurface->idAssociatedContext, pSrcBox->x, pSrcBox->y, pSrcBox->x + pSrcBox->w, pSrcBox->y + pSrcBox->h,
415 sidDst, pDstSurface->idAssociatedContext, pDstBox->x, pDstBox->y, pDstBox->x + pDstBox->w, pDstBox->y + pDstBox->h, enmMode));
416
417 uint32_t cid = pDstSurface->idAssociatedContext;
418 if (cid == SVGA3D_INVALID_ID)
419 cid = pSrcSurface->idAssociatedContext;
420
421 /* At least one of surfaces must be in hardware. */
422 AssertReturn(cid != SVGA3D_INVALID_ID, VERR_INVALID_PARAMETER);
423
424 rc = vmsvga3dContextFromCid(pState, cid, &pContext);
425 AssertRCReturn(rc, rc);
426#endif
427
428 if (!VMSVGA3DSURFACE_HAS_HW_SURFACE(pSrcSurface))
429 {
430 /* Unknown surface type; turn it into a texture, which can be used for other purposes too. */
431 LogFunc(("unknown src sid=%u type=%d format=%d -> create texture\n", sidSrc, pSrcSurface->surfaceFlags, pSrcSurface->format));
432 rc = vmsvga3dBackCreateTexture(pState, pContext, pContext->id, pSrcSurface);
433 AssertRCReturn(rc, rc);
434 }
435
436 if (!VMSVGA3DSURFACE_HAS_HW_SURFACE(pDstSurface))
437 {
438 /* Unknown surface type; turn it into a texture, which can be used for other purposes too. */
439 LogFunc(("unknown dest sid=%u type=%d format=%d -> create texture\n", sidDst, pDstSurface->surfaceFlags, pDstSurface->format));
440 rc = vmsvga3dBackCreateTexture(pState, pContext, pContext->id, pDstSurface);
441 AssertRCReturn(rc, rc);
442 }
443
444 PVMSVGA3DMIPMAPLEVEL pSrcMipmapLevel;
445 rc = vmsvga3dMipmapLevel(pSrcSurface, pSrcSfcImg->face, pSrcSfcImg->mipmap, &pSrcMipmapLevel);
446 AssertRCReturn(rc, rc);
447
448 PVMSVGA3DMIPMAPLEVEL pDstMipmapLevel;
449 rc = vmsvga3dMipmapLevel(pDstSurface, pDstSfcImg->face, pDstSfcImg->mipmap, &pDstMipmapLevel);
450 AssertRCReturn(rc, rc);
451
452 SVGA3dBox clipSrcBox = *pSrcBox;
453 SVGA3dBox clipDstBox = *pDstBox;
454 vmsvgaR3ClipBox(&pSrcMipmapLevel->mipmapSize, &clipSrcBox);
455 vmsvgaR3ClipBox(&pDstMipmapLevel->mipmapSize, &clipDstBox);
456
457 return vmsvga3dBackSurfaceStretchBlt(pThis, pState,
458 pDstSurface, pDstSfcImg->face, pDstSfcImg->mipmap, &clipDstBox,
459 pSrcSurface, pSrcSfcImg->face, pSrcSfcImg->mipmap, &clipSrcBox,
460 enmMode, pContext);
461}
462
463/**
464 * Implements the SVGA_3D_CMD_SURFACE_DMA command (fifo).
465 *
466 * @returns VBox status code (currently ignored).
467 * @param pThis The shared VGA/VMSVGA instance data.
468 * @param pThisCC The VGA/VMSVGA state for ring-3.
469 * @param guest .
470 * @param host .
471 * @param transfer .
472 * @param cCopyBoxes .
473 * @param paBoxes .
474 */
475int vmsvga3dSurfaceDMA(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAGuestImage guest, SVGA3dSurfaceImageId host,
476 SVGA3dTransferType transfer, uint32_t cCopyBoxes, SVGA3dCopyBox *paBoxes)
477{
478 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
479 AssertReturn(pState, VERR_NO_MEMORY);
480
481 PVMSVGA3DSURFACE pSurface;
482 int rc = vmsvga3dSurfaceFromSid(pState, host.sid, &pSurface);
483 AssertRCReturn(rc, rc);
484
485 LogFunc(("%sguestptr gmr=%x offset=%x pitch=%x host sid=%u face=%d mipmap=%d transfer=%s cCopyBoxes=%d\n",
486 (pSurface->surfaceFlags & SVGA3D_SURFACE_HINT_TEXTURE) ? "TEXTURE " : "",
487 guest.ptr.gmrId, guest.ptr.offset, guest.pitch,
488 host.sid, host.face, host.mipmap, (transfer == SVGA3D_WRITE_HOST_VRAM) ? "READ" : "WRITE", cCopyBoxes));
489
490 PVMSVGA3DMIPMAPLEVEL pMipLevel;
491 rc = vmsvga3dMipmapLevel(pSurface, host.face, host.mipmap, &pMipLevel);
492 AssertRCReturn(rc, rc);
493
494 PVMSVGA3DCONTEXT pContext = NULL;
495 if (!VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface))
496 {
497 /*
498 * Not realized in host hardware/library yet, we have to work with
499 * the copy of the data we've got in VMSVGA3DMIMAPLEVEL::pSurfaceData.
500 */
501 AssertReturn(pMipLevel->pSurfaceData, VERR_INTERNAL_ERROR);
502 }
503 else
504 {
505#ifdef VMSVGA3D_DIRECT3D
506 /* Flush the drawing pipeline for this surface as it could be used in a shared context. */
507 vmsvga3dSurfaceFlush(pSurface);
508#elif defined(VMSVGA3D_DX)
509 /** @todo */
510#else /* VMSVGA3D_OPENGL */
511 pContext = &pState->SharedCtx;
512 VMSVGA3D_SET_CURRENT_CONTEXT(pState, pContext);
513#endif
514 }
515
516 /* SVGA_3D_CMD_SURFACE_DMA:
517 * "define the 'source' in each copyBox as the guest image and the
518 * 'destination' as the host image, regardless of transfer direction."
519 */
520 for (uint32_t i = 0; i < cCopyBoxes; ++i)
521 {
522 Log(("Copy box (%s) %d (%d,%d,%d)(%d,%d,%d) dest (%d,%d)\n",
523 VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface) ? "hw" : "mem",
524 i, paBoxes[i].srcx, paBoxes[i].srcy, paBoxes[i].srcz, paBoxes[i].w, paBoxes[i].h, paBoxes[i].d, paBoxes[i].x, paBoxes[i].y));
525
526 /* Apparently we're supposed to clip it (gmr test sample) */
527
528 /* The copybox's "dest" is coords in the host surface. Verify them against the surface's mipmap size. */
529 SVGA3dBox hostBox;
530 hostBox.x = paBoxes[i].x;
531 hostBox.y = paBoxes[i].y;
532 hostBox.z = paBoxes[i].z;
533 hostBox.w = paBoxes[i].w;
534 hostBox.h = paBoxes[i].h;
535 hostBox.d = paBoxes[i].d;
536 vmsvgaR3ClipBox(&pMipLevel->mipmapSize, &hostBox);
537
538 if ( !hostBox.w
539 || !hostBox.h
540 || !hostBox.d)
541 {
542 Log(("Skip empty box\n"));
543 continue;
544 }
545 RT_UNTRUSTED_VALIDATED_FENCE();
546
547 /* Adjust the guest, i.e. "src", point.
548 * Do not try to verify them here because vmsvgaR3GmrTransfer takes care of this.
549 */
550 uint32_t const srcx = paBoxes[i].srcx + (hostBox.x - paBoxes[i].x);
551 uint32_t const srcy = paBoxes[i].srcy + (hostBox.y - paBoxes[i].y);
552 uint32_t const srcz = paBoxes[i].srcz + (hostBox.z - paBoxes[i].z);
553
554 /* Calculate offsets of the image blocks for the transfer. */
555 uint32_t u32HostBlockX;
556 uint32_t u32HostBlockY;
557 uint32_t u32GuestBlockX;
558 uint32_t u32GuestBlockY;
559 uint32_t cBlocksX;
560 uint32_t cBlocksY;
561 if (RT_LIKELY(pSurface->cxBlock == 1 && pSurface->cyBlock == 1))
562 {
563 u32HostBlockX = hostBox.x;
564 u32HostBlockY = hostBox.y;
565
566 u32GuestBlockX = srcx;
567 u32GuestBlockY = srcy;
568
569 cBlocksX = hostBox.w;
570 cBlocksY = hostBox.h;
571 }
572 else
573 {
574 /* Pixels to blocks. */
575 u32HostBlockX = hostBox.x / pSurface->cxBlock;
576 u32HostBlockY = hostBox.y / pSurface->cyBlock;
577 Assert(u32HostBlockX * pSurface->cxBlock == hostBox.x);
578 Assert(u32HostBlockY * pSurface->cyBlock == hostBox.y);
579
580 u32GuestBlockX = srcx / pSurface->cxBlock;
581 u32GuestBlockY = srcy / pSurface->cyBlock;
582 Assert(u32GuestBlockX * pSurface->cxBlock == srcx);
583 Assert(u32GuestBlockY * pSurface->cyBlock == srcy);
584
585 cBlocksX = (hostBox.w + pSurface->cxBlock - 1) / pSurface->cxBlock;
586 cBlocksY = (hostBox.h + pSurface->cyBlock - 1) / pSurface->cyBlock;
587 }
588
589 uint32_t cbGuestPitch = guest.pitch;
590 if (cbGuestPitch == 0)
591 {
592 /* Host must "assume image is tightly packed". Our surfaces are. */
593 cbGuestPitch = pMipLevel->cbSurfacePitch;
594 }
595 else
596 {
597 /* vmsvgaR3GmrTransfer will verify the value, just check it is sane. */
598 AssertReturn(cbGuestPitch <= SVGA3D_MAX_SURFACE_MEM_SIZE, VERR_INVALID_PARAMETER);
599 RT_UNTRUSTED_VALIDATED_FENCE();
600 }
601
602 /* srcx, srcy and srcz values are used to calculate the guest offset.
603 * The offset will be verified by vmsvgaR3GmrTransfer, so just check for overflows here.
604 */
605 AssertReturn(srcz < UINT32_MAX / pMipLevel->mipmapSize.height / cbGuestPitch, VERR_INVALID_PARAMETER);
606 AssertReturn(u32GuestBlockY < UINT32_MAX / cbGuestPitch, VERR_INVALID_PARAMETER);
607 AssertReturn(u32GuestBlockX < UINT32_MAX / pSurface->cbBlock, VERR_INVALID_PARAMETER);
608 RT_UNTRUSTED_VALIDATED_FENCE();
609
610 if ( !VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface)
611 || VMSVGA3DSURFACE_NEEDS_DATA(pSurface))
612 {
613 uint64_t uGuestOffset = u32GuestBlockX * pSurface->cbBlock +
614 u32GuestBlockY * cbGuestPitch +
615 srcz * pMipLevel->mipmapSize.height * cbGuestPitch;
616 AssertReturn(uGuestOffset < UINT32_MAX, VERR_INVALID_PARAMETER);
617
618 /* vmsvga3dSurfaceDefine verifies the surface dimensions and clipBox is within them. */
619 uint32_t uHostOffset = u32HostBlockX * pSurface->cbBlock +
620 u32HostBlockY * pMipLevel->cbSurfacePitch +
621 hostBox.z * pMipLevel->cbSurfacePlane;
622 AssertReturn(uHostOffset < pMipLevel->cbSurface, VERR_INTERNAL_ERROR);
623
624 for (uint32_t z = 0; z < hostBox.d; ++z)
625 {
626 rc = vmsvgaR3GmrTransfer(pThis,
627 pThisCC,
628 transfer,
629 (uint8_t *)pMipLevel->pSurfaceData,
630 pMipLevel->cbSurface,
631 uHostOffset,
632 (int32_t)pMipLevel->cbSurfacePitch,
633 guest.ptr,
634 (uint32_t)uGuestOffset,
635 cbGuestPitch,
636 cBlocksX * pSurface->cbBlock,
637 cBlocksY);
638 AssertRC(rc);
639
640 Log4(("first line [z=%d] (updated at offset 0x%x):\n%.*Rhxd\n",
641 z, uHostOffset, pMipLevel->cbSurfacePitch, pMipLevel->pSurfaceData));
642
643 uHostOffset += pMipLevel->cbSurfacePlane;
644 uGuestOffset += pMipLevel->mipmapSize.height * cbGuestPitch;
645 AssertReturn(uGuestOffset < UINT32_MAX, VERR_INVALID_PARAMETER);
646 }
647 }
648
649 if (VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface))
650 {
651 SVGA3dCopyBox clipBox;
652 clipBox.x = hostBox.x;
653 clipBox.y = hostBox.y;
654 clipBox.z = hostBox.z;
655 clipBox.w = hostBox.w;
656 clipBox.h = hostBox.h;
657 clipBox.d = hostBox.d;
658 clipBox.srcx = srcx;
659 clipBox.srcy = srcy;
660 clipBox.srcz = srcz;
661 rc = vmsvga3dBackSurfaceDMACopyBox(pThis, pThisCC, pState, pSurface, pMipLevel, host.face, host.mipmap,
662 guest.ptr, cbGuestPitch, transfer,
663 &clipBox, pContext, rc, i);
664 AssertRC(rc);
665 }
666 }
667
668 if (!VMSVGA3DSURFACE_HAS_HW_SURFACE(pSurface))
669 {
670 pMipLevel->fDirty = true;
671 pSurface->fDirty = true;
672 }
673
674 return rc;
675}
676
677static int vmsvga3dQueryWriteResult(PVGASTATE pThis, PVGASTATECC pThisCC, SVGAGuestPtr guestResult,
678 SVGA3dQueryState enmState, uint32_t u32Result)
679{
680 SVGA3dQueryResult queryResult;
681 queryResult.totalSize = sizeof(queryResult); /* Set by guest before query is ended. */
682 queryResult.state = enmState; /* Set by host or guest. See SVGA3dQueryState. */
683 queryResult.result32 = u32Result;
684
685 int rc = vmsvgaR3GmrTransfer(pThis, pThisCC, SVGA3D_READ_HOST_VRAM,
686 (uint8_t *)&queryResult, sizeof(queryResult), 0, sizeof(queryResult),
687 guestResult, 0, sizeof(queryResult), sizeof(queryResult), 1);
688 AssertRC(rc);
689 return rc;
690}
691
692int vmsvga3dQueryBegin(PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type)
693{
694 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
695 AssertReturn(pState, VERR_NO_MEMORY);
696
697 LogFunc(("cid=%u type=%d\n", cid, type));
698
699 PVMSVGA3DCONTEXT pContext;
700 int rc = vmsvga3dContextFromCid(pState, cid, &pContext);
701 AssertRCReturn(rc, rc);
702
703 if (type == SVGA3D_QUERYTYPE_OCCLUSION)
704 {
705 VMSVGA3DQUERY *p = &pContext->occlusion;
706 if (!VMSVGA3DQUERY_EXISTS(p))
707 {
708 /* Lazy creation of the query object. */
709 rc = vmsvga3dOcclusionQueryCreate(pState, pContext);
710 AssertRCReturn(rc, rc);
711 }
712
713 rc = vmsvga3dOcclusionQueryBegin(pState, pContext);
714 AssertRCReturn(rc, rc);
715
716 p->enmQueryState = VMSVGA3DQUERYSTATE_BUILDING;
717 p->u32QueryResult = 0;
718
719 return VINF_SUCCESS;
720 }
721
722 /* Nothing else for VGPU9. */
723 AssertFailedReturn(VERR_NOT_IMPLEMENTED);
724}
725
726int vmsvga3dQueryEnd(PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult)
727{
728 RT_NOREF(guestResult);
729 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
730 AssertReturn(pState, VERR_NO_MEMORY);
731
732 LogFunc(("cid=%u type=%d guestResult %d:0x%x\n", cid, type, guestResult.gmrId, guestResult.offset));
733
734 PVMSVGA3DCONTEXT pContext;
735 int rc = vmsvga3dContextFromCid(pState, cid, &pContext);
736 AssertRCReturn(rc, rc);
737
738 if (type == SVGA3D_QUERYTYPE_OCCLUSION)
739 {
740 VMSVGA3DQUERY *p = &pContext->occlusion;
741 Assert(p->enmQueryState == VMSVGA3DQUERYSTATE_BUILDING);
742 AssertMsgReturn(VMSVGA3DQUERY_EXISTS(p), ("Query is NULL\n"), VERR_INTERNAL_ERROR);
743
744 rc = vmsvga3dOcclusionQueryEnd(pState, pContext);
745 AssertRCReturn(rc, rc);
746
747 p->enmQueryState = VMSVGA3DQUERYSTATE_ISSUED;
748
749 /* Do not touch guestResult, because the guest will call WaitForQuery. */
750 return VINF_SUCCESS;
751 }
752
753 /* Nothing else for VGPU9. */
754 AssertFailedReturn(VERR_NOT_IMPLEMENTED);
755}
756
757int vmsvga3dQueryWait(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t cid, SVGA3dQueryType type, SVGAGuestPtr guestResult)
758{
759 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
760 AssertReturn(pState, VERR_NO_MEMORY);
761
762 LogFunc(("cid=%u type=%d guestResult GMR%d:0x%x\n", cid, type, guestResult.gmrId, guestResult.offset));
763
764 PVMSVGA3DCONTEXT pContext;
765 int rc = vmsvga3dContextFromCid(pState, cid, &pContext);
766 AssertRCReturn(rc, rc);
767
768 if (type == SVGA3D_QUERYTYPE_OCCLUSION)
769 {
770 VMSVGA3DQUERY *p = &pContext->occlusion;
771 if (VMSVGA3DQUERY_EXISTS(p))
772 {
773 if (p->enmQueryState == VMSVGA3DQUERYSTATE_ISSUED)
774 {
775 /* Only if not already in SIGNALED state,
776 * i.e. not a second read from the guest or after restoring saved state.
777 */
778 uint32_t u32Pixels = 0;
779 rc = vmsvga3dOcclusionQueryGetData(pState, pContext, &u32Pixels);
780 if (RT_SUCCESS(rc))
781 {
782 p->enmQueryState = VMSVGA3DQUERYSTATE_SIGNALED;
783 p->u32QueryResult += u32Pixels; /* += because it might contain partial result from saved state. */
784 }
785 }
786
787 if (RT_SUCCESS(rc))
788 {
789 /* Return data to the guest. */
790 vmsvga3dQueryWriteResult(pThis, pThisCC, guestResult, SVGA3D_QUERYSTATE_SUCCEEDED, p->u32QueryResult);
791 return VINF_SUCCESS;
792 }
793 }
794 else
795 {
796 AssertMsgFailed(("GetData Query is NULL\n"));
797 }
798
799 rc = VERR_INTERNAL_ERROR;
800 }
801 else
802 {
803 rc = VERR_NOT_IMPLEMENTED;
804 }
805
806 vmsvga3dQueryWriteResult(pThis, pThisCC, guestResult, SVGA3D_QUERYSTATE_FAILED, 0);
807 AssertFailedReturn(rc);
808}
809
810int vmsvga3dSurfaceBlitToScreen(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t idDstScreen, SVGASignedRect destRect,
811 SVGA3dSurfaceImageId srcImage, SVGASignedRect srcRect, uint32_t cRects, SVGASignedRect *pRect)
812{
813 /* Requires SVGA_FIFO_CAP_SCREEN_OBJECT support */
814 LogFunc(("dest=%d (%d,%d)(%d,%d) sid=%u (face=%d, mipmap=%d) (%d,%d)(%d,%d) cRects=%d\n",
815 idDstScreen, destRect.left, destRect.top, destRect.right, destRect.bottom, srcImage.sid, srcImage.face, srcImage.mipmap,
816 srcRect.left, srcRect.top, srcRect.right, srcRect.bottom, cRects));
817 for (uint32_t i = 0; i < cRects; i++)
818 {
819 LogFunc(("clipping rect %d (%d,%d)(%d,%d)\n", i, pRect[i].left, pRect[i].top, pRect[i].right, pRect[i].bottom));
820 }
821
822 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, idDstScreen);
823 AssertReturn(pScreen, VERR_INTERNAL_ERROR);
824
825 /* vmwgfx driver does not always initialize srcImage.mipmap and srcImage.face. They are assumed to be zero. */
826 SVGA3dSurfaceImageId src;
827 src.sid = srcImage.sid;
828 src.mipmap = 0;
829 src.face = 0;
830
831 if (pScreen->pHwScreen)
832 {
833 /* Use the backend accelerated method, if available. */
834 int rc = vmsvga3dBackSurfaceBlitToScreen(pThisCC, pScreen,
835 destRect, src, srcRect, cRects, pRect);
836 if (rc == VINF_SUCCESS)
837 {
838 return VINF_SUCCESS;
839 }
840 }
841
842 /** @todo scaling */
843 AssertReturn(destRect.right - destRect.left == srcRect.right - srcRect.left && destRect.bottom - destRect.top == srcRect.bottom - srcRect.top, VERR_INVALID_PARAMETER);
844
845 SVGA3dCopyBox box;
846 SVGAGuestImage dest;
847
848 box.srcz = 0;
849 box.z = 0;
850 box.d = 1;
851
852 dest.ptr.gmrId = SVGA_GMR_FRAMEBUFFER;
853 dest.ptr.offset = pScreen->offVRAM;
854 dest.pitch = pScreen->cbPitch;
855
856 if (cRects == 0)
857 {
858 /* easy case; no clipping */
859
860 /* SVGA_3D_CMD_SURFACE_DMA:
861 * 'define the "source" in each copyBox as the guest image and the
862 * "destination" as the host image, regardless of transfer direction.'
863 *
864 * Since the BlitToScreen operation transfers from a host surface to the guest VRAM,
865 * it must set the copyBox "source" to the guest destination coords and
866 * the copyBox "destination" to the host surface source coords.
867 */
868 /* Host image. */
869 box.x = srcRect.left;
870 box.y = srcRect.top;
871 box.w = srcRect.right - srcRect.left;
872 box.h = srcRect.bottom - srcRect.top;
873 /* Guest image. */
874 box.srcx = destRect.left;
875 box.srcy = destRect.top;
876
877 int rc = vmsvga3dSurfaceDMA(pThis, pThisCC, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box);
878 AssertRCReturn(rc, rc);
879
880 /* Update the guest image, which is at box.src. */
881 vmsvgaR3UpdateScreen(pThisCC, pScreen, box.srcx, box.srcy, box.w, box.h);
882 }
883 else
884 {
885 /** @todo merge into one SurfaceDMA call */
886 for (uint32_t i = 0; i < cRects; i++)
887 {
888 /* "The clip rectangle coordinates are measured
889 * relative to the top-left corner of destRect."
890 * Therefore they are relative to the top-left corner of srcRect as well.
891 */
892
893 /* Host image. See 'SVGA_3D_CMD_SURFACE_DMA:' comment in the 'if' branch. */
894 box.x = srcRect.left + pRect[i].left;
895 box.y = srcRect.top + pRect[i].top;
896 box.w = pRect[i].right - pRect[i].left;
897 box.h = pRect[i].bottom - pRect[i].top;
898 /* Guest image. The target screen memory is currently in the guest VRAM. */
899 box.srcx = destRect.left + pRect[i].left;
900 box.srcy = destRect.top + pRect[i].top;
901
902 int rc = vmsvga3dSurfaceDMA(pThis, pThisCC, dest, src, SVGA3D_READ_HOST_VRAM, 1, &box);
903 AssertRCReturn(rc, rc);
904
905 /* Update the guest image, which is at box.src. */
906 vmsvgaR3UpdateScreen(pThisCC, pScreen, box.srcx, box.srcy, box.w, box.h);
907 }
908 }
909
910 return VINF_SUCCESS;
911}
912
913int vmsvga3dCommandPresent(PVGASTATE pThis, PVGASTATECC pThisCC, uint32_t sid, uint32_t cRects, SVGA3dCopyRect *pRect)
914{
915 /* Deprecated according to svga3d_reg.h. */
916 PVMSVGA3DSTATE pState = pThisCC->svga.p3dState;
917 AssertReturn(pState, VERR_NO_MEMORY);
918
919 PVMSVGA3DSURFACE pSurface;
920 int rc = vmsvga3dSurfaceFromSid(pState, sid, &pSurface);
921 AssertRCReturn(rc, rc);
922
923 /** @todo Detect screen from coords? Or split rect to screens? */
924 VMSVGASCREENOBJECT *pScreen = vmsvgaR3GetScreenObject(pThisCC, 0);
925 AssertReturn(pScreen, VERR_INTERNAL_ERROR);
926
927 /* If there are no recangles specified, just grab a screenful. */
928 SVGA3dCopyRect DummyRect;
929 if (cRects != 0)
930 { /* likely */ }
931 else
932 {
933 /** @todo Find the usecase for this or check what the original device does.
934 * The original code was doing some scaling based on the surface
935 * size... */
936 AssertMsgFailed(("No rects to present. Who is doing that and what do they actually expect?\n"));
937 DummyRect.x = DummyRect.srcx = 0;
938 DummyRect.y = DummyRect.srcy = 0;
939 DummyRect.w = pScreen->cWidth;
940 DummyRect.h = pScreen->cHeight;
941 cRects = 1;
942 pRect = &DummyRect;
943 }
944
945 uint32_t i;
946 for (i = 0; i < cRects; ++i)
947 {
948 uint32_t idDstScreen = 0; /** @todo Use virtual coords: SVGA_ID_INVALID. */
949 SVGASignedRect destRect;
950 destRect.left = pRect[i].x;
951 destRect.top = pRect[i].y;
952 destRect.right = pRect[i].x + pRect[i].w;
953 destRect.bottom = pRect[i].y + pRect[i].h;
954
955 SVGA3dSurfaceImageId src;
956 src.sid = sid;
957 src.face = 0;
958 src.mipmap = 0;
959
960 SVGASignedRect srcRect;
961 srcRect.left = pRect[i].srcx;
962 srcRect.top = pRect[i].srcy;
963 srcRect.right = pRect[i].srcx + pRect[i].w;
964 srcRect.bottom = pRect[i].srcy + pRect[i].h;
965
966 /* Entire rect. */
967 rc = vmsvga3dSurfaceBlitToScreen(pThis, pThisCC, idDstScreen, destRect, src, srcRect, 0, NULL);
968 AssertRCReturn(rc, rc);
969 }
970
971 return VINF_SUCCESS;
972}
973
974int vmsvga3dDefineScreen(PVGASTATE pThis, PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen)
975{
976 if (pScreen->pHwScreen)
977 {
978 vmsvga3dBackDestroyScreen(pThisCC, pScreen);
979 }
980
981 int rc = vmsvga3dBackDefineScreen(pThis, pThisCC, pScreen);
982 if (RT_SUCCESS(rc))
983 {
984 LogRelMax(1, ("VMSVGA: using accelerated graphics output\n"));
985 }
986 return rc;
987}
988
989int vmsvga3dDestroyScreen(PVGASTATECC pThisCC, VMSVGASCREENOBJECT *pScreen)
990{
991 return vmsvga3dBackDestroyScreen(pThisCC, pScreen);
992}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette