VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPVdma.h@ 54957

Last change on this file since 54957 was 52329, checked in by vboxsync, 10 years ago

wddm/crOpenGL: prevent shared objects from being deleted till they can be used

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.0 KB
Line 
1/* $Id: VBoxMPVdma.h 52329 2014-08-08 18:34:02Z vboxsync $ */
2/** @file
3 * VBox WDDM Miniport driver
4 */
5
6/*
7 * Copyright (C) 2011-2012 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#ifndef ___VBoxMPVdma_h___
19#define ___VBoxMPVdma_h___
20
21#include <iprt/cdefs.h>
22#include <iprt/asm.h>
23#include <VBox/VBoxVideo.h>
24#include <VBox/HGSMI/HGSMI.h>
25
26typedef struct _VBOXMP_DEVEXT *PVBOXMP_DEVEXT;
27
28/* ddi dma command queue handling */
29typedef enum
30{
31 VBOXVDMADDI_STATE_UNCKNOWN = 0,
32 VBOXVDMADDI_STATE_NOT_DX_CMD,
33 VBOXVDMADDI_STATE_NOT_QUEUED,
34 VBOXVDMADDI_STATE_PENDING,
35 VBOXVDMADDI_STATE_SUBMITTED,
36 VBOXVDMADDI_STATE_COMPLETED
37} VBOXVDMADDI_STATE;
38
39typedef struct VBOXVDMADDI_CMD *PVBOXVDMADDI_CMD;
40typedef DECLCALLBACK(VOID) FNVBOXVDMADDICMDCOMPLETE_DPC(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
41typedef FNVBOXVDMADDICMDCOMPLETE_DPC *PFNVBOXVDMADDICMDCOMPLETE_DPC;
42
43typedef struct VBOXVDMADDI_CMD
44{
45 LIST_ENTRY QueueEntry;
46 VBOXVDMADDI_STATE enmState;
47 uint32_t u32NodeOrdinal;
48 uint32_t u32FenceId;
49 DXGK_INTERRUPT_TYPE enmComplType;
50 PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete;
51 PVOID pvComplete;
52} VBOXVDMADDI_CMD, *PVBOXVDMADDI_CMD;
53
54typedef struct VBOXVDMADDI_CMD_QUEUE
55{
56 volatile uint32_t cQueuedCmds;
57 LIST_ENTRY CmdQueue;
58} VBOXVDMADDI_CMD_QUEUE, *PVBOXVDMADDI_CMD_QUEUE;
59
60typedef struct VBOXVDMADDI_NODE
61{
62 VBOXVDMADDI_CMD_QUEUE CmdQueue;
63 UINT uLastCompletedFenceId;
64} VBOXVDMADDI_NODE, *PVBOXVDMADDI_NODE;
65
66VOID vboxVdmaDdiNodesInit(PVBOXMP_DEVEXT pDevExt);
67BOOLEAN vboxVdmaDdiCmdCompletedIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
68VOID vboxVdmaDdiCmdSubmittedIrq(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd);
69
70NTSTATUS vboxVdmaDdiCmdCompleted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
71NTSTATUS vboxVdmaDdiCmdSubmitted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd);
72
73DECLINLINE(VOID) vboxVdmaDdiCmdInit(PVBOXVDMADDI_CMD pCmd,
74 uint32_t u32NodeOrdinal, uint32_t u32FenceId,
75 PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete, PVOID pvComplete)
76{
77 pCmd->QueueEntry.Blink = NULL;
78 pCmd->QueueEntry.Flink = NULL;
79 pCmd->enmState = VBOXVDMADDI_STATE_NOT_QUEUED;
80 pCmd->u32NodeOrdinal = u32NodeOrdinal;
81 pCmd->u32FenceId = u32FenceId;
82 pCmd->pfnComplete = pfnComplete;
83 pCmd->pvComplete = pvComplete;
84}
85
86/* marks the command a submitted in a way that it is invisible for dx runtime,
87 * i.e. the dx runtime won't be notified about the command completion
88 * this is used to submit commands initiated by the driver, but not by the dx runtime */
89DECLINLINE(VOID) vboxVdmaDdiCmdSubmittedNotDx(PVBOXVDMADDI_CMD pCmd)
90{
91 Assert(pCmd->enmState == VBOXVDMADDI_STATE_NOT_QUEUED);
92 pCmd->enmState = VBOXVDMADDI_STATE_NOT_DX_CMD;
93}
94
95NTSTATUS vboxVdmaDdiCmdFenceComplete(PVBOXMP_DEVEXT pDevExt, uint32_t u32NodeOrdinal, uint32_t u32FenceId, DXGK_INTERRUPT_TYPE enmComplType);
96
97DECLCALLBACK(VOID) vboxVdmaDdiCmdCompletionCbFree(PVBOXMP_DEVEXT pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
98
99VOID vboxVdmaDdiCmdGetCompletedListIsr(PVBOXMP_DEVEXT pDevExt, LIST_ENTRY *pList);
100
101BOOLEAN vboxVdmaDdiCmdIsCompletedListEmptyIsr(PVBOXMP_DEVEXT pDevExt);
102
103#define VBOXVDMADDI_CMD_FROM_ENTRY(_pEntry) ((PVBOXVDMADDI_CMD)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVDMADDI_CMD, QueueEntry)))
104
105DECLINLINE(VOID) vboxVdmaDdiCmdHandleCompletedList(PVBOXMP_DEVEXT pDevExt, LIST_ENTRY *pList)
106{
107 LIST_ENTRY *pEntry = pList->Flink;
108 while (pEntry != pList)
109 {
110 PVBOXVDMADDI_CMD pCmd = VBOXVDMADDI_CMD_FROM_ENTRY(pEntry);
111 pEntry = pEntry->Flink;
112 if (pCmd->pfnComplete)
113 pCmd->pfnComplete(pDevExt, pCmd, pCmd->pvComplete);
114 }
115}
116
117#if 0
118typedef DECLCALLBACK(int) FNVBOXVDMASUBMIT(struct _DEVICE_EXTENSION* pDevExt, struct VBOXVDMAINFO * pInfo, HGSMIOFFSET offDr, PVOID pvContext);
119typedef FNVBOXVDMASUBMIT *PFNVBOXVDMASUBMIT;
120
121typedef struct VBOXVDMASUBMIT
122{
123 PFNVBOXVDMASUBMIT pfnSubmit;
124 PVOID pvContext;
125} VBOXVDMASUBMIT, *PVBOXVDMASUBMIT;
126#endif
127
128/* start */
129typedef enum
130{
131 VBOXVDMAPIPE_STATE_CLOSED = 0,
132 VBOXVDMAPIPE_STATE_CREATED = 1,
133 VBOXVDMAPIPE_STATE_OPENNED = 2,
134 VBOXVDMAPIPE_STATE_CLOSING = 3
135} VBOXVDMAPIPE_STATE;
136
137typedef struct VBOXVDMAPIPE
138{
139 KSPIN_LOCK SinchLock;
140 KEVENT Event;
141 LIST_ENTRY CmdListHead;
142 VBOXVDMAPIPE_STATE enmState;
143 /* true iff the other end needs Event notification */
144 bool bNeedNotify;
145} VBOXVDMAPIPE, *PVBOXVDMAPIPE;
146
147typedef struct VBOXVDMAPIPE_CMD_HDR
148{
149 LIST_ENTRY ListEntry;
150} VBOXVDMAPIPE_CMD_HDR, *PVBOXVDMAPIPE_CMD_HDR;
151
152#define VBOXVDMAPIPE_CMD_HDR_FROM_ENTRY(_pE) ( (PVBOXVDMAPIPE_CMD_HDR)((uint8_t *)(_pE) - RT_OFFSETOF(VBOXVDMAPIPE_CMD_HDR, ListEntry)) )
153
154typedef enum
155{
156 VBOXVDMAPIPE_CMD_TYPE_UNDEFINED = 0,
157 VBOXVDMAPIPE_CMD_TYPE_RECTSINFO,
158 VBOXVDMAPIPE_CMD_TYPE_DMACMD,
159 VBOXVDMAPIPE_CMD_TYPE_FINISH, /* ensures all previously submitted commands are completed */
160 VBOXVDMAPIPE_CMD_TYPE_CANCEL
161} VBOXVDMAPIPE_CMD_TYPE;
162
163typedef struct VBOXVDMAPIPE_CMD_DR
164{
165 VBOXVDMAPIPE_CMD_HDR PipeHdr;
166 VBOXVDMAPIPE_CMD_TYPE enmType;
167 volatile uint32_t cRefs;
168} VBOXVDMAPIPE_CMD_DR, *PVBOXVDMAPIPE_CMD_DR;
169
170#define VBOXVDMAPIPE_CMD_DR_FROM_ENTRY(_pE) ( (PVBOXVDMAPIPE_CMD_DR)VBOXVDMAPIPE_CMD_HDR_FROM_ENTRY(_pE) )
171
172typedef struct VBOXWDDM_DMA_ALLOCINFO
173{
174 PVBOXWDDM_ALLOCATION pAlloc;
175 VBOXVIDEOOFFSET offAlloc;
176 UINT segmentIdAlloc : 31;
177 UINT fWriteOp : 1;
178 D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId;
179} VBOXWDDM_DMA_ALLOCINFO, *PVBOXWDDM_DMA_ALLOCINFO;
180
181typedef struct VBOXVDMAPIPE_RECTS
182{
183 RECT ContextRect;
184 VBOXWDDM_RECTS_INFO UpdateRects;
185} VBOXVDMAPIPE_RECTS, *PVBOXVDMAPIPE_RECTS;
186
187typedef struct VBOXVDMAPIPE_CMD_RECTSINFO
188{
189 VBOXVDMAPIPE_CMD_DR Hdr;
190 PVBOXWDDM_CONTEXT pContext;
191 struct VBOXWDDM_SWAPCHAIN *pSwapchain;
192 VBOXVDMAPIPE_RECTS ContextsRects;
193} VBOXVDMAPIPE_CMD_RECTSINFO, *PVBOXVDMAPIPE_CMD_RECTSINFO;
194
195typedef struct VBOXVDMAPIPE_CMD_DMACMD
196{
197 VBOXVDMAPIPE_CMD_DR Hdr;
198#ifndef VBOX_WDDM_IRQ_COMPLETION
199 VBOXVDMADDI_CMD DdiCmd;
200#endif
201 PVBOXWDDM_CONTEXT pContext;
202 VBOXVDMACMD_TYPE enmCmd;
203// VBOXVDMAPIPE_FLAGS_DMACMD fFlags;
204} VBOXVDMAPIPE_CMD_DMACMD, *PVBOXVDMAPIPE_CMD_DMACMD;
205
206typedef struct VBOXVDMA_CLRFILL
207{
208 VBOXWDDM_DMA_ALLOCINFO Alloc;
209 UINT Color;
210 VBOXWDDM_RECTS_INFO Rects;
211} VBOXVDMA_CLRFILL, *PVBOXVDMA_CLRFILL;
212
213typedef struct VBOXVDMAPIPE_CMD_DMACMD_CLRFILL
214{
215 VBOXVDMAPIPE_CMD_DMACMD Hdr;
216 VBOXVDMA_CLRFILL ClrFill;
217} VBOXVDMAPIPE_CMD_DMACMD_CLRFILL, *PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL;
218
219typedef struct VBOXVDMA_BLT
220{
221 VBOXWDDM_DMA_ALLOCINFO SrcAlloc;
222 VBOXWDDM_DMA_ALLOCINFO DstAlloc;
223 RECT SrcRect;
224 VBOXVDMAPIPE_RECTS DstRects;
225} VBOXVDMA_BLT, *PVBOXVDMA_BLT;
226
227typedef struct VBOXVDMAPIPE_CMD_DMACMD_BLT
228{
229 VBOXVDMAPIPE_CMD_DMACMD Hdr;
230 VBOXVDMA_BLT Blt;
231} VBOXVDMAPIPE_CMD_DMACMD_BLT, *PVBOXVDMAPIPE_CMD_DMACMD_BLT;
232
233typedef struct VBOXVDMA_FLIP
234{
235 VBOXWDDM_DMA_ALLOCINFO Alloc;
236} VBOXVDMA_FLIP, *PVBOXVDMA_FLIP;
237
238typedef struct VBOXVDMAPIPE_CMD_DMACMD_FLIP
239{
240 VBOXVDMAPIPE_CMD_DMACMD Hdr;
241 VBOXVDMA_FLIP Flip;
242} VBOXVDMAPIPE_CMD_DMACMD_FLIP, *PVBOXVDMAPIPE_CMD_DMACMD_FLIP;
243
244typedef struct VBOXVDMA_SHADOW2PRIMARY
245{
246 VBOXWDDM_DMA_ALLOCINFO ShadowAlloc;
247 RECT SrcRect;
248 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
249} VBOXVDMA_SHADOW2PRIMARY, *PVBOXVDMA_SHADOW2PRIMARY;
250
251typedef struct VBOXVDMAGG
252{
253 VBOXVDMAPIPE CmdPipe;
254 PKTHREAD pThread;
255} VBOXVDMAGG, *PVBOXVDMAGG;
256
257/* DMA commands are currently submitted over HGSMI */
258typedef struct VBOXVDMAINFO
259{
260#ifdef VBOX_WITH_VDMA
261 VBOXSHGSMI CmdHeap;
262#endif
263 UINT uLastCompletedPagingBufferCmdFenceId;
264 BOOL fEnabled;
265} VBOXVDMAINFO, *PVBOXVDMAINFO;
266
267int vboxVdmaCreate (PVBOXMP_DEVEXT pDevExt, VBOXVDMAINFO *pInfo
268#ifdef VBOX_WITH_VDMA
269 , ULONG offBuffer, ULONG cbBuffer
270#endif
271#if 0
272 , PFNVBOXVDMASUBMIT pfnSubmit, PVOID pvContext
273#endif
274 );
275int vboxVdmaDisable(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
276int vboxVdmaEnable(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
277int vboxVdmaDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
278
279#ifdef VBOX_WITH_VDMA
280int vboxVdmaFlush(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
281DECLINLINE(HGSMIOFFSET) vboxVdmaCBufDrPtrOffset(const PVBOXVDMAINFO pInfo, const void* pvPtr)
282{
283 return VBoxSHGSMICommandPtrOffset(&pInfo->CmdHeap, pvPtr);
284}
285int vboxVdmaCBufDrSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
286int vboxVdmaCBufDrSubmitSynch(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
287struct VBOXVDMACBUF_DR* vboxVdmaCBufDrCreate(PVBOXVDMAINFO pInfo, uint32_t cbTrailingData);
288void vboxVdmaCBufDrFree(PVBOXVDMAINFO pInfo, struct VBOXVDMACBUF_DR* pDr);
289
290#define VBOXVDMACBUF_DR_DATA_OFFSET() (sizeof (VBOXVDMACBUF_DR))
291#define VBOXVDMACBUF_DR_SIZE(_cbData) (VBOXVDMACBUF_DR_DATA_OFFSET() + (_cbData))
292#define VBOXVDMACBUF_DR_DATA(_pDr) ( ((uint8_t*)(_pDr)) + VBOXVDMACBUF_DR_DATA_OFFSET() )
293
294AssertCompile(sizeof (VBOXVDMADDI_CMD) <= RT_SIZEOFMEMB(VBOXVDMACBUF_DR, aGuestData));
295#define VBOXVDMADDI_CMD_FROM_BUF_DR(_pDr) ((PVBOXVDMADDI_CMD)(_pDr)->aGuestData)
296#define VBOXVDMACBUF_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMACBUF_DR)(((uint8_t*)(_pCmd)) - RT_OFFSETOF(VBOXVDMACBUF_DR, aGuestData)))
297
298#endif
299#ifdef VBOX_WITH_CROGL
300NTSTATUS vboxVdmaPostHideSwapchain(PVBOXWDDM_SWAPCHAIN pSwapchain);
301#endif
302
303NTSTATUS vboxVdmaGgCmdDmaNotifyCompleted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAPIPE_CMD_DMACMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
304NTSTATUS vboxVdmaGgCmdDmaNotifySubmitted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAPIPE_CMD_DMACMD pCmd);
305VOID vboxVdmaGgCmdDmaNotifyInit(PVBOXVDMAPIPE_CMD_DMACMD pCmd,
306 uint32_t u32NodeOrdinal, uint32_t u32FenceId,
307 PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete, PVOID pvComplete);
308
309NTSTATUS vboxVdmaGgDmaBltPerform(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_ALLOC_DATA * pSrcAlloc, RECT* pSrcRect,
310 struct VBOXWDDM_ALLOC_DATA *pDstAlloc, RECT* pDstRect);
311
312#define VBOXVDMAPIPE_CMD_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMAPIPE_CMD_DR)(((uint8_t*)(_pCmd)) - RT_OFFSETOF(VBOXVDMAPIPE_CMD_DR, DdiCmd)))
313
314NTSTATUS vboxVdmaProcessBltCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_BLT *pBlt);
315NTSTATUS vboxVdmaProcessFlipCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_FLIP *pFlip);
316NTSTATUS vboxVdmaProcessClrFillCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_CLRFILL *pCF);
317#ifdef VBOX_WITH_CROGL
318NTSTATUS vboxVdmaTexPresentSetAlloc(PVBOXMP_DEVEXT pDevExt, const VBOXWDDM_ALLOC_DATA *pAllocData);
319NTSTATUS VBoxVdmaChromiumParameteriCRSubmit(PVBOXMP_DEVEXT pDevExt, uint32_t target, uint32_t value);
320#endif
321
322#endif /* #ifndef ___VBoxMPVdma_h___ */
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