VirtualBox

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

Last change on this file since 50929 was 47566, checked in by vboxsync, 11 years ago

crOpenGL/wddm: TexPresent fixes, irq handling fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.4 KB
Line 
1/* $Id: VBoxMPVdma.h 47566 2013-08-06 22:20:23Z 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_CMD_DMACMD
215{
216 VBOXVDMAPIPE_CMD_DR Hdr;
217#ifndef VBOX_WDDM_IRQ_COMPLETION
218 VBOXVDMADDI_CMD DdiCmd;
219#endif
220 PVBOXWDDM_CONTEXT pContext;
221 VBOXVDMACMD_TYPE enmCmd;
222// VBOXVDMAPIPE_FLAGS_DMACMD fFlags;
223} VBOXVDMAPIPE_CMD_DMACMD, *PVBOXVDMAPIPE_CMD_DMACMD;
224
225typedef struct VBOXVDMA_CLRFILL
226{
227 VBOXWDDM_DMA_ALLOCINFO Alloc;
228 UINT Color;
229 VBOXWDDM_RECTS_INFO Rects;
230} VBOXVDMA_CLRFILL, *PVBOXVDMA_CLRFILL;
231
232typedef struct VBOXVDMAPIPE_CMD_DMACMD_CLRFILL
233{
234 VBOXVDMAPIPE_CMD_DMACMD Hdr;
235 VBOXVDMA_CLRFILL ClrFill;
236} VBOXVDMAPIPE_CMD_DMACMD_CLRFILL, *PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL;
237
238typedef struct VBOXVDMA_BLT
239{
240 VBOXWDDM_DMA_ALLOCINFO SrcAlloc;
241 VBOXWDDM_DMA_ALLOCINFO DstAlloc;
242 RECT SrcRect;
243 VBOXVDMAPIPE_RECTS DstRects;
244} VBOXVDMA_BLT, *PVBOXVDMA_BLT;
245
246typedef struct VBOXVDMAPIPE_CMD_DMACMD_BLT
247{
248 VBOXVDMAPIPE_CMD_DMACMD Hdr;
249 VBOXVDMA_BLT Blt;
250} VBOXVDMAPIPE_CMD_DMACMD_BLT, *PVBOXVDMAPIPE_CMD_DMACMD_BLT;
251
252typedef struct VBOXVDMA_FLIP
253{
254 VBOXWDDM_DMA_ALLOCINFO Alloc;
255} VBOXVDMA_FLIP, *PVBOXVDMA_FLIP;
256
257typedef struct VBOXVDMAPIPE_CMD_DMACMD_FLIP
258{
259 VBOXVDMAPIPE_CMD_DMACMD Hdr;
260 VBOXVDMA_FLIP Flip;
261} VBOXVDMAPIPE_CMD_DMACMD_FLIP, *PVBOXVDMAPIPE_CMD_DMACMD_FLIP;
262
263typedef struct VBOXVDMA_SHADOW2PRIMARY
264{
265 VBOXWDDM_DMA_ALLOCINFO ShadowAlloc;
266 RECT SrcRect;
267 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
268} VBOXVDMA_SHADOW2PRIMARY, *PVBOXVDMA_SHADOW2PRIMARY;
269
270typedef struct VBOXVDMAGG
271{
272 VBOXVDMAPIPE CmdPipe;
273 PKTHREAD pThread;
274} VBOXVDMAGG, *PVBOXVDMAGG;
275
276/* DMA commands are currently submitted over HGSMI */
277typedef struct VBOXVDMAINFO
278{
279#ifdef VBOX_WITH_VDMA
280 VBOXSHGSMI CmdHeap;
281#endif
282 UINT uLastCompletedPagingBufferCmdFenceId;
283 BOOL fEnabled;
284} VBOXVDMAINFO, *PVBOXVDMAINFO;
285
286int vboxVdmaCreate (PVBOXMP_DEVEXT pDevExt, VBOXVDMAINFO *pInfo
287#ifdef VBOX_WITH_VDMA
288 , ULONG offBuffer, ULONG cbBuffer
289#endif
290#if 0
291 , PFNVBOXVDMASUBMIT pfnSubmit, PVOID pvContext
292#endif
293 );
294int vboxVdmaDisable(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
295int vboxVdmaEnable(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
296int vboxVdmaDestroy(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
297
298#ifdef VBOX_WITH_VDMA
299int vboxVdmaFlush(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo);
300DECLINLINE(HGSMIOFFSET) vboxVdmaCBufDrPtrOffset(const PVBOXVDMAINFO pInfo, const void* pvPtr)
301{
302 return VBoxSHGSMICommandPtrOffset(&pInfo->CmdHeap, pvPtr);
303}
304int vboxVdmaCBufDrSubmit(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
305int vboxVdmaCBufDrSubmitSynch(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
306struct VBOXVDMACBUF_DR* vboxVdmaCBufDrCreate(PVBOXVDMAINFO pInfo, uint32_t cbTrailingData);
307void vboxVdmaCBufDrFree(PVBOXVDMAINFO pInfo, struct VBOXVDMACBUF_DR* pDr);
308
309#define VBOXVDMACBUF_DR_DATA_OFFSET() (sizeof (VBOXVDMACBUF_DR))
310#define VBOXVDMACBUF_DR_SIZE(_cbData) (VBOXVDMACBUF_DR_DATA_OFFSET() + (_cbData))
311#define VBOXVDMACBUF_DR_DATA(_pDr) ( ((uint8_t*)(_pDr)) + VBOXVDMACBUF_DR_DATA_OFFSET() )
312
313AssertCompile(sizeof (VBOXVDMADDI_CMD) <= RT_SIZEOFMEMB(VBOXVDMACBUF_DR, aGuestData));
314#define VBOXVDMADDI_CMD_FROM_BUF_DR(_pDr) ((PVBOXVDMADDI_CMD)(_pDr)->aGuestData)
315#define VBOXVDMACBUF_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMACBUF_DR)(((uint8_t*)(_pCmd)) - RT_OFFSETOF(VBOXVDMACBUF_DR, aGuestData)))
316
317#endif
318
319NTSTATUS vboxVdmaPostHideSwapchain(PVBOXWDDM_SWAPCHAIN pSwapchain);
320
321NTSTATUS vboxVdmaGgCmdDmaNotifyCompleted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAPIPE_CMD_DMACMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
322NTSTATUS vboxVdmaGgCmdDmaNotifySubmitted(PVBOXMP_DEVEXT pDevExt, PVBOXVDMAPIPE_CMD_DMACMD pCmd);
323VOID vboxVdmaGgCmdDmaNotifyInit(PVBOXVDMAPIPE_CMD_DMACMD pCmd,
324 uint32_t u32NodeOrdinal, uint32_t u32FenceId,
325 PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete, PVOID pvComplete);
326
327NTSTATUS vboxVdmaGgDmaBltPerform(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_ALLOC_DATA * pSrcAlloc, RECT* pSrcRect,
328 struct VBOXWDDM_ALLOC_DATA *pDstAlloc, RECT* pDstRect);
329
330#define VBOXVDMAPIPE_CMD_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMAPIPE_CMD_DR)(((uint8_t*)(_pCmd)) - RT_OFFSETOF(VBOXVDMAPIPE_CMD_DR, DdiCmd)))
331
332NTSTATUS vboxVdmaProcessBltCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_BLT *pBlt);
333NTSTATUS vboxVdmaProcessFlipCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_FLIP *pFlip);
334NTSTATUS vboxVdmaProcessClrFillCmd(PVBOXMP_DEVEXT pDevExt, struct VBOXWDDM_CONTEXT *pContext, struct VBOXWDDM_DMA_PRIVATEDATA_CLRFILL *pCF);
335
336NTSTATUS vboxVdmaTexPresentSetAlloc(PVBOXMP_DEVEXT pDevExt, PVBOXWDDM_ALLOCATION pRealFbAlloc);
337
338#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