1 | /* $Id: VBoxMPVbva.cpp 96407 2022-08-22 17:43:14Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox WDDM Miniport driver
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2011-2022 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #include "VBoxMPWddm.h"
|
---|
29 | #include "common/VBoxMPCommon.h"
|
---|
30 |
|
---|
31 | /*
|
---|
32 | * Public hardware buffer methods.
|
---|
33 | */
|
---|
34 | int vboxVbvaEnable (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
|
---|
35 | {
|
---|
36 | if (VBoxVBVAEnable(&pVbva->Vbva, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx,
|
---|
37 | pVbva->Vbva.pVBVA, pVbva->srcId))
|
---|
38 | return VINF_SUCCESS;
|
---|
39 |
|
---|
40 | WARN(("VBoxVBVAEnable failed!"));
|
---|
41 | return VERR_GENERAL_FAILURE;
|
---|
42 | }
|
---|
43 |
|
---|
44 | int vboxVbvaDisable (PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
|
---|
45 | {
|
---|
46 | VBoxVBVADisable(&pVbva->Vbva, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx, pVbva->srcId);
|
---|
47 | return VINF_SUCCESS;
|
---|
48 | }
|
---|
49 |
|
---|
50 | int vboxVbvaCreate(PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva, ULONG offBuffer, ULONG cbBuffer, D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId)
|
---|
51 | {
|
---|
52 | memset(pVbva, 0, sizeof(VBOXVBVAINFO));
|
---|
53 |
|
---|
54 | KeInitializeSpinLock(&pVbva->Lock);
|
---|
55 |
|
---|
56 | int rc = VBoxMPCmnMapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt),
|
---|
57 | (void**)&pVbva->Vbva.pVBVA,
|
---|
58 | offBuffer,
|
---|
59 | cbBuffer);
|
---|
60 | if (RT_SUCCESS(rc))
|
---|
61 | {
|
---|
62 | Assert(pVbva->Vbva.pVBVA);
|
---|
63 | VBoxVBVASetupBufferContext(&pVbva->Vbva, offBuffer, cbBuffer);
|
---|
64 | pVbva->srcId = srcId;
|
---|
65 | }
|
---|
66 | else
|
---|
67 | {
|
---|
68 | WARN(("VBoxMPCmnMapAdapterMemory failed rc %d", rc));
|
---|
69 | }
|
---|
70 |
|
---|
71 |
|
---|
72 | return rc;
|
---|
73 | }
|
---|
74 |
|
---|
75 | int vboxVbvaDestroy(PVBOXMP_DEVEXT pDevExt, VBOXVBVAINFO *pVbva)
|
---|
76 | {
|
---|
77 | int rc = VINF_SUCCESS;
|
---|
78 | VBoxMPCmnUnmapAdapterMemory(VBoxCommonFromDeviceExt(pDevExt), (void**)&pVbva->Vbva.pVBVA);
|
---|
79 | memset(pVbva, 0, sizeof (VBOXVBVAINFO));
|
---|
80 | return rc;
|
---|
81 | }
|
---|
82 |
|
---|
83 | int vboxVbvaReportDirtyRect (PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_SOURCE pSrc, RECT *pRectOrig)
|
---|
84 | {
|
---|
85 | VBVACMDHDR hdr;
|
---|
86 |
|
---|
87 | RECT rect = *pRectOrig;
|
---|
88 |
|
---|
89 | // if (rect.left < 0) rect.left = 0;
|
---|
90 | // if (rect.top < 0) rect.top = 0;
|
---|
91 | // if (rect.right > (int)ppdev->cxScreen) rect.right = ppdev->cxScreen;
|
---|
92 | // if (rect.bottom > (int)ppdev->cyScreen) rect.bottom = ppdev->cyScreen;
|
---|
93 |
|
---|
94 | hdr.x = (int16_t)rect.left;
|
---|
95 | hdr.y = (int16_t)rect.top;
|
---|
96 | hdr.w = (uint16_t)(rect.right - rect.left);
|
---|
97 | hdr.h = (uint16_t)(rect.bottom - rect.top);
|
---|
98 |
|
---|
99 | hdr.x += (int16_t)pSrc->VScreenPos.x;
|
---|
100 | hdr.y += (int16_t)pSrc->VScreenPos.y;
|
---|
101 |
|
---|
102 | if (VBoxVBVAWrite(&pSrc->Vbva.Vbva, &VBoxCommonFromDeviceExt(pDevExt)->guestCtx, &hdr, sizeof(hdr)))
|
---|
103 | return VINF_SUCCESS;
|
---|
104 |
|
---|
105 | WARN(("VBoxVBVAWrite failed"));
|
---|
106 | return VERR_GENERAL_FAILURE;
|
---|
107 | }
|
---|