VirtualBox

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

Last change on this file since 46876 was 46757, checked in by vboxsync, 11 years ago

wddm/crOpenGL: r0-based visible regions handling, r0-based chromium commands submission debugged, more on new presentation mechanism, cleanup, etc.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.7 KB
Line 
1/* $Id: VBoxMPVdma.h 46757 2013-06-24 14:30:18Z 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#ifdef VBOXWDDM_RENDER_FROM_SHADOW
118NTSTATUS vboxVdmaHlpUpdatePrimary(PVBOXMP_DEVEXT pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, RECT* pRect);
119#endif
120
121#if 0
122typedef DECLCALLBACK(int) FNVBOXVDMASUBMIT(struct _DEVICE_EXTENSION* pDevExt, struct VBOXVDMAINFO * pInfo, HGSMIOFFSET offDr, PVOID pvContext);
123typedef FNVBOXVDMASUBMIT *PFNVBOXVDMASUBMIT;
124
125typedef struct VBOXVDMASUBMIT
126{
127 PFNVBOXVDMASUBMIT pfnSubmit;
128 PVOID pvContext;
129} VBOXVDMASUBMIT, *PVBOXVDMASUBMIT;
130#endif
131
132/* start */
133typedef enum
134{
135 VBOXVDMAPIPE_STATE_CLOSED = 0,
136 VBOXVDMAPIPE_STATE_CREATED = 1,
137 VBOXVDMAPIPE_STATE_OPENNED = 2,
138 VBOXVDMAPIPE_STATE_CLOSING = 3
139} VBOXVDMAPIPE_STATE;
140
141typedef struct VBOXVDMAPIPE
142{
143 KSPIN_LOCK SinchLock;
144 KEVENT Event;
145 LIST_ENTRY CmdListHead;
146 VBOXVDMAPIPE_STATE enmState;
147 /* true iff the other end needs Event notification */
148 bool bNeedNotify;
149} VBOXVDMAPIPE, *PVBOXVDMAPIPE;
150
151typedef struct VBOXVDMAPIPE_CMD_HDR
152{
153 LIST_ENTRY ListEntry;
154} VBOXVDMAPIPE_CMD_HDR, *PVBOXVDMAPIPE_CMD_HDR;
155
156#define VBOXVDMAPIPE_CMD_HDR_FROM_ENTRY(_pE) ( (PVBOXVDMAPIPE_CMD_HDR)((uint8_t *)(_pE) - RT_OFFSETOF(VBOXVDMAPIPE_CMD_HDR, ListEntry)) )
157
158typedef enum
159{
160 VBOXVDMAPIPE_CMD_TYPE_UNDEFINED = 0,
161 VBOXVDMAPIPE_CMD_TYPE_RECTSINFO,
162 VBOXVDMAPIPE_CMD_TYPE_DMACMD,
163 VBOXVDMAPIPE_CMD_TYPE_FINISH, /* ensures all previously submitted commands are completed */
164 VBOXVDMAPIPE_CMD_TYPE_CANCEL
165} VBOXVDMAPIPE_CMD_TYPE;
166
167typedef struct VBOXVDMAPIPE_CMD_DR
168{
169 VBOXVDMAPIPE_CMD_HDR PipeHdr;
170 VBOXVDMAPIPE_CMD_TYPE enmType;
171 volatile uint32_t cRefs;
172} VBOXVDMAPIPE_CMD_DR, *PVBOXVDMAPIPE_CMD_DR;
173
174#define VBOXVDMAPIPE_CMD_DR_FROM_ENTRY(_pE) ( (PVBOXVDMAPIPE_CMD_DR)VBOXVDMAPIPE_CMD_HDR_FROM_ENTRY(_pE) )
175
176typedef struct VBOXWDDM_DMA_ALLOCINFO
177{
178 PVBOXWDDM_ALLOCATION pAlloc;
179 VBOXVIDEOOFFSET offAlloc;
180 UINT segmentIdAlloc : 31;
181 UINT fWriteOp : 1;
182 D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId;
183} VBOXWDDM_DMA_ALLOCINFO, *PVBOXWDDM_DMA_ALLOCINFO;
184
185typedef struct VBOXVDMAPIPE_RECTS
186{
187 RECT ContextRect;
188 VBOXWDDM_RECTS_INFO UpdateRects;
189} VBOXVDMAPIPE_RECTS, *PVBOXVDMAPIPE_RECTS;
190
191typedef struct VBOXVDMAPIPE_CMD_RECTSINFO
192{
193 VBOXVDMAPIPE_CMD_DR Hdr;
194 PVBOXWDDM_CONTEXT pContext;
195 struct VBOXWDDM_SWAPCHAIN *pSwapchain;
196 VBOXVDMAPIPE_RECTS ContextsRects;
197} VBOXVDMAPIPE_CMD_RECTSINFO, *PVBOXVDMAPIPE_CMD_RECTSINFO;
198
199typedef struct VBOXVDMAPIPE_CMD_FINISH
200{
201 VBOXVDMAPIPE_CMD_DR Hdr;
202 PVBOXWDDM_CONTEXT pContext;
203 PKEVENT pEvent;
204} VBOXVDMAPIPE_CMD_FINISH, *PVBOXVDMAPIPE_CMD_FINISH;
205
206typedef struct VBOXVDMAPIPE_CMD_CANCEL
207{
208 VBOXVDMAPIPE_CMD_DR Hdr;
209 PVBOXWDDM_CONTEXT pContext;
210 PVBOXWDDM_SWAPCHAIN pSwapchain;
211 PKEVENT pEvent;
212} VBOXVDMAPIPE_CMD_CANCEL, *PVBOXVDMAPIPE_CMD_CANCEL;
213
214typedef struct VBOXVDMAPIPE_FLAGS_DMACMD
215{
216 union
217 {
218 struct
219 {
220 UINT fRealOp : 1;
221 UINT fVisibleRegions : 1;
222 UINT Reserved : 30;
223 };
224 UINT Value;
225 };
226} VBOXVDMAPIPE_FLAGS_DMACMD, *PVBOXVDMAPIPE_FLAGS_DMACMD;
227typedef struct VBOXVDMAPIPE_CMD_DMACMD
228{
229 VBOXVDMAPIPE_CMD_DR Hdr;
230#ifndef VBOX_WDDM_IRQ_COMPLETION
231 VBOXVDMADDI_CMD DdiCmd;
232#endif
233 PVBOXWDDM_CONTEXT pContext;
234 VBOXVDMACMD_TYPE enmCmd;
235 VBOXVDMAPIPE_FLAGS_DMACMD fFlags;
236} VBOXVDMAPIPE_CMD_DMACMD, *PVBOXVDMAPIPE_CMD_DMACMD;
237
238typedef struct VBOXVDMA_CLRFILL
239{
240 VBOXWDDM_DMA_ALLOCINFO Alloc;
241 UINT Color;
242 VBOXWDDM_RECTS_INFO Rects;
243} VBOXVDMA_CLRFILL, *PVBOXVDMA_CLRFILL;
244
245typedef struct VBOXVDMAPIPE_CMD_DMACMD_CLRFILL
246{
247 VBOXVDMAPIPE_CMD_DMACMD Hdr;
248 VBOXVDMA_CLRFILL ClrFill;
249} VBOXVDMAPIPE_CMD_DMACMD_CLRFILL, *PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL;
250
251typedef struct VBOXVDMA_BLT
252{
253 VBOXWDDM_DMA_ALLOCINFO SrcAlloc;
254 VBOXWDDM_DMA_ALLOCINFO DstAlloc;
255 RECT SrcRect;
256 VBOXVDMAPIPE_RECTS DstRects;
257} VBOXVDMA_BLT, *PVBOXVDMA_BLT;
258
259typedef struct VBOXVDMAPIPE_CMD_DMACMD_BLT
260{
261 VBOXVDMAPIPE_CMD_DMACMD Hdr;
262 VBOXVDMA_BLT Blt;
263} VBOXVDMAPIPE_CMD_DMACMD_BLT, *PVBOXVDMAPIPE_CMD_DMACMD_BLT;
264
265typedef struct VBOXVDMA_FLIP
266{
267 VBOXWDDM_DMA_ALLOCINFO Alloc;
268} VBOXVDMA_FLIP, *PVBOXVDMA_FLIP;
269
270typedef struct VBOXVDMAPIPE_CMD_DMACMD_FLIP
271{
272 VBOXVDMAPIPE_CMD_DMACMD Hdr;
273 VBOXVDMA_FLIP Flip;
274} VBOXVDMAPIPE_CMD_DMACMD_FLIP, *PVBOXVDMAPIPE_CMD_DMACMD_FLIP;
275
276typedef struct VBOXVDMA_SHADOW2PRIMARY
277{
278 VBOXWDDM_DMA_ALLOCINFO ShadowAlloc;
279 RECT SrcRect;
280 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
281} VBOXVDMA_SHADOW2PRIMARY, *PVBOXVDMA_SHADOW2PRIMARY;
282
283typedef struct VBOXVDMAGG
284{
285 VBOXVDMAPIPE CmdPipe;
286 PKTHREAD pThread;
287} VBOXVDMAGG, *PVBOXVDMAGG;
288
289/* DMA commands are currently submitted over HGSMI */
290typedef struct VBOXVDMAINFO
291{
292#ifdef VBOX_WITH_VDMA
293 VBOXSHGSMI CmdHeap;
294#endif
295 UINT uLastCompletedPagingBufferCmdFenceId;
296 BOOL fEnabled;
297} VBOXVDMAINFO, *PVBOXVDMAINFO;
298
299int vboxVdmaCreate (PVBOXMP_DEVEXT pDevExt, VBOXVDMAINFO *pInfo
300#ifdef VBOX_WITH_VDMA
301 , ULONG offBuffer, ULONG cbBuffer
302#endif
303#if 0
304 , PFNVBOXVDMASUBMIT pfnSubmit, PVOID pvContext
305#endif
306 );
307int vboxVdmaDisable(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
308int vboxVdmaEnable(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
309int vboxVdmaDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
310
311#ifdef VBOX_WITH_VDMA
312int vboxVdmaFlush(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
313DECLINLINE(HGSMIOFFSET) vboxVdmaCBufDrPtrOffset(const PVBOXVDMAINFO pInfo, const void* pvPtr)
314{
315 return VBoxSHGSMICommandPtrOffset(&pInfo->CmdHeap, pvPtr);
316}
317int vboxVdmaCBufDrSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
318int vboxVdmaCBufDrSubmitSynch(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
319struct VBOXVDMACBUF_DR* vboxVdmaCBufDrCreate(PVBOXVDMAINFO pInfo, uint32_t cbTrailingData);
320void vboxVdmaCBufDrFree(PVBOXVDMAINFO pInfo, struct VBOXVDMACBUF_DR* pDr);
321
322#define VBOXVDMACBUF_DR_DATA_OFFSET() (sizeof (VBOXVDMACBUF_DR))
323#define VBOXVDMACBUF_DR_SIZE(_cbData) (VBOXVDMACBUF_DR_DATA_OFFSET() + (_cbData))
324#define VBOXVDMACBUF_DR_DATA(_pDr) ( ((uint8_t*)(_pDr)) + VBOXVDMACBUF_DR_DATA_OFFSET() )
325
326AssertCompile(sizeof (VBOXVDMADDI_CMD) <= RT_SIZEOFMEMB(VBOXVDMACBUF_DR, aGuestData));
327#define VBOXVDMADDI_CMD_FROM_BUF_DR(_pDr) ((PVBOXVDMADDI_CMD)(_pDr)->aGuestData)
328#define VBOXVDMACBUF_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMACBUF_DR)(((uint8_t*)(_pCmd)) - RT_OFFSETOF(VBOXVDMACBUF_DR, aGuestData)))
329
330#endif
331
332NTSTATUS vboxVdmaPostHideSwapchain(PVBOXWDDM_SWAPCHAIN pSwapchain);
333
334NTSTATUS vboxVdmaGgCmdDmaNotifyCompleted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAPIPE_CMD_DMACMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
335NTSTATUS vboxVdmaGgCmdDmaNotifySubmitted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAPIPE_CMD_DMACMD pCmd);
336VOID vboxVdmaGgCmdDmaNotifyInit(PVBOXVDMAPIPE_CMD_DMACMD pCmd,
337 uint32_t u32NodeOrdinal, uint32_t u32FenceId,
338 PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete, PVOID pvComplete);
339
340NTSTATUS vboxVdmaGgDmaBltPerform(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_ALLOC_DATA * pSrcAlloc, RECT* pSrcRect,
341 struct VBOXWDDM_ALLOC_DATA *pDstAlloc, RECT* pDstRect);
342
343#define VBOXVDMAPIPE_CMD_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMAPIPE_CMD_DR)(((uint8_t*)(_pCmd)) - RT_OFFSETOF(VBOXVDMAPIPE_CMD_DR, DdiCmd)))
344
345NTSTATUS vboxVdmaProcessBltCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_BLT *pBlt, struct VBOXVDMAPIPE_FLAGS_DMACMD fBltFlags);
346NTSTATUS vboxVdmaProcessFlipCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_FLIP *pFlip, struct VBOXVDMAPIPE_FLAGS_DMACMD fFlags);
347NTSTATUS vboxVdmaProcessClrFillCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_CLRFILL *pCF, struct VBOXVDMAPIPE_FLAGS_DMACMD fFlags);
348
349#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