VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Miniport/wddm/VBoxVideoVdma.h@ 33890

Last change on this file since 33890 was 33530, checked in by vboxsync, 14 years ago

wddm/3d: chromium hgsmi: better alloc/submit engine

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.2 KB
Line 
1/*
2 * Copyright (C) 2010 Oracle Corporation
3 *
4 * This file is part of VirtualBox Open Source Edition (OSE), as
5 * available from http://www.virtualbox.org. This file is free software;
6 * you can redistribute it and/or modify it under the terms of the GNU
7 * General Public License (GPL) as published by the Free Software
8 * Foundation, in version 2 as it comes in the "COPYING" file of the
9 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
10 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
11 */
12#ifndef ___VBoxVideoVdma_h___
13#define ___VBoxVideoVdma_h___
14
15#include <iprt/cdefs.h>
16#include <iprt/asm.h>
17#include <VBox/VBoxVideo.h>
18#include "../VBoxVideo.h"
19
20/* ddi dma command queue handling */
21typedef enum
22{
23 VBOXVDMADDI_STATE_UNCKNOWN = 0,
24 VBOXVDMADDI_STATE_NOT_DX_CMD,
25 VBOXVDMADDI_STATE_NOT_QUEUED,
26 VBOXVDMADDI_STATE_PENDING,
27 VBOXVDMADDI_STATE_SUBMITTED,
28 VBOXVDMADDI_STATE_COMPLETED
29} VBOXVDMADDI_STATE;
30
31typedef struct VBOXVDMADDI_CMD *PVBOXVDMADDI_CMD;
32typedef DECLCALLBACK(VOID) FNVBOXVDMADDICMDCOMPLETE_DPC(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
33typedef FNVBOXVDMADDICMDCOMPLETE_DPC *PFNVBOXVDMADDICMDCOMPLETE_DPC;
34
35typedef struct VBOXVDMADDI_CMD
36{
37 LIST_ENTRY QueueEntry;
38 VBOXVDMADDI_STATE enmState;
39 uint32_t u32FenceId;
40 DXGK_INTERRUPT_TYPE enmComplType;
41 PVBOXWDDM_CONTEXT pContext;
42 PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete;
43 PVOID pvComplete;
44} VBOXVDMADDI_CMD, *PVBOXVDMADDI_CMD;
45
46typedef struct VBOXVDMADDI_CMD_QUEUE
47{
48 volatile uint32_t cQueuedCmds;
49 LIST_ENTRY CmdQueue;
50 LIST_ENTRY DpcCmdQueue;
51} VBOXVDMADDI_CMD_QUEUE, *PVBOXVDMADDI_CMD_QUEUE;
52
53VOID vboxVdmaDdiQueueInit(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD_QUEUE pQueue);
54BOOLEAN vboxVdmaDdiCmdCompletedIrq(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD_QUEUE pQueue, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
55VOID vboxVdmaDdiCmdSubmittedIrq(PVBOXVDMADDI_CMD_QUEUE pQueue, PVBOXVDMADDI_CMD pCmd);
56
57NTSTATUS vboxVdmaDdiCmdCompleted(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD_QUEUE pQueue, PVBOXVDMADDI_CMD pCmd, DXGK_INTERRUPT_TYPE enmComplType);
58NTSTATUS vboxVdmaDdiCmdSubmitted(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD_QUEUE pQueue, PVBOXVDMADDI_CMD pCmd);
59
60DECLINLINE(VOID) vboxVdmaDdiCmdInit(PVBOXVDMADDI_CMD pCmd,
61 uint32_t u32FenceId, PVBOXWDDM_CONTEXT pContext,
62 PFNVBOXVDMADDICMDCOMPLETE_DPC pfnComplete, PVOID pvComplete)
63{
64 pCmd->QueueEntry.Blink = NULL;
65 pCmd->QueueEntry.Flink = NULL;
66 pCmd->enmState = VBOXVDMADDI_STATE_NOT_QUEUED;
67 pCmd->u32FenceId = u32FenceId;
68 pCmd->pContext = pContext;
69 pCmd->pfnComplete = pfnComplete;
70 pCmd->pvComplete = pvComplete;
71}
72
73DECLINLINE(VOID) vboxVdmaDdiCmdSubmittedNotDx(PVBOXVDMADDI_CMD pCmd)
74{
75 Assert(pCmd->enmState == VBOXVDMADDI_STATE_NOT_QUEUED);
76 pCmd->enmState = VBOXVDMADDI_STATE_NOT_DX_CMD;
77}
78
79NTSTATUS vboxVdmaDdiCmdFenceComplete(PDEVICE_EXTENSION pDevExt, PVBOXWDDM_CONTEXT pContext, uint32_t u32FenceId, DXGK_INTERRUPT_TYPE enmComplType);
80
81DECLCALLBACK(VOID) vboxVdmaDdiCmdCompletionCbFree(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
82
83DECLINLINE(VOID) vboxVdmaDdiCmdGetCompletedListIsr(PVBOXVDMADDI_CMD_QUEUE pQueue, LIST_ENTRY *pList)
84{
85 vboxVideoLeDetach(&pQueue->DpcCmdQueue, pList);
86}
87
88DECLINLINE(BOOLEAN) vboxVdmaDdiCmdIsCompletedListEmptyIsr(PVBOXVDMADDI_CMD_QUEUE pQueue)
89{
90 return IsListEmpty(&pQueue->DpcCmdQueue);
91}
92
93#define VBOXVDMADDI_CMD_FROM_ENTRY(_pEntry) ((PVBOXVDMADDI_CMD)(((uint8_t*)(_pEntry)) - RT_OFFSETOF(VBOXVDMADDI_CMD, QueueEntry)))
94
95DECLINLINE(VOID) vboxVdmaDdiCmdHandleCompletedList(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD_QUEUE pQueue, LIST_ENTRY *pList)
96{
97 LIST_ENTRY *pEntry = pList->Flink;
98 while (pEntry != pList)
99 {
100 PVBOXVDMADDI_CMD pCmd = VBOXVDMADDI_CMD_FROM_ENTRY(pEntry);
101 pEntry = pEntry->Flink;
102 if (pCmd->pfnComplete)
103 pCmd->pfnComplete(pDevExt, pCmd, pCmd->pvComplete);
104 }
105}
106
107#ifdef VBOXWDDM_RENDER_FROM_SHADOW
108NTSTATUS vboxVdmaHlpUpdatePrimary(PDEVICE_EXTENSION pDevExt, D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId, RECT* pRect);
109#endif
110
111#if 0
112typedef DECLCALLBACK(int) FNVBOXVDMASUBMIT(struct _DEVICE_EXTENSION* pDevExt, struct VBOXVDMAINFO * pInfo, HGSMIOFFSET offDr, PVOID pvContext);
113typedef FNVBOXVDMASUBMIT *PFNVBOXVDMASUBMIT;
114
115typedef struct VBOXVDMASUBMIT
116{
117 PFNVBOXVDMASUBMIT pfnSubmit;
118 PVOID pvContext;
119} VBOXVDMASUBMIT, *PVBOXVDMASUBMIT;
120#endif
121
122/* start */
123typedef enum
124{
125 VBOXVDMAPIPE_STATE_CLOSED = 0,
126 VBOXVDMAPIPE_STATE_CREATED = 1,
127 VBOXVDMAPIPE_STATE_OPENNED = 2,
128 VBOXVDMAPIPE_STATE_CLOSING = 3
129} VBOXVDMAPIPE_STATE;
130
131typedef struct VBOXVDMAPIPE
132{
133 KSPIN_LOCK SinchLock;
134 KEVENT Event;
135 LIST_ENTRY CmdListHead;
136 VBOXVDMAPIPE_STATE enmState;
137 /* true iff the other end needs Event notification */
138 bool bNeedNotify;
139} VBOXVDMAPIPE, *PVBOXVDMAPIPE;
140
141typedef struct VBOXVDMAPIPE_CMD_HDR
142{
143 LIST_ENTRY ListEntry;
144} VBOXVDMAPIPE_CMD_HDR, *PVBOXVDMAPIPE_CMD_HDR;
145
146#define VBOXVDMAPIPE_CMD_HDR_FROM_ENTRY(_pE) ( (PVBOXVDMAPIPE_CMD_HDR)((uint8_t *)(_pE) - RT_OFFSETOF(VBOXVDMAPIPE_CMD_HDR, ListEntry)) )
147
148typedef enum
149{
150 VBOXVDMAPIPE_CMD_TYPE_UNDEFINED = 0,
151 VBOXVDMAPIPE_CMD_TYPE_RECTSINFO,
152 VBOXVDMAPIPE_CMD_TYPE_DMACMD
153} VBOXVDMAPIPE_CMD_TYPE;
154
155typedef struct VBOXVDMAPIPE_CMD_DR
156{
157 VBOXVDMAPIPE_CMD_HDR PipeHdr;
158 VBOXVDMAPIPE_CMD_TYPE enmType;
159} VBOXVDMAPIPE_CMD_DR, *PVBOXVDMAPIPE_CMD_DR;
160
161#define VBOXVDMAPIPE_CMD_DR_FROM_ENTRY(_pE) ( (PVBOXVDMAPIPE_CMD_DR)VBOXVDMAPIPE_CMD_HDR_FROM_ENTRY(_pE) )
162
163typedef struct VBOXWDDM_DMA_ALLOCINFO
164{
165 PVBOXWDDM_ALLOCATION pAlloc;
166 VBOXVIDEOOFFSET offAlloc;
167 UINT segmentIdAlloc;
168 D3DDDI_VIDEO_PRESENT_SOURCE_ID srcId;
169} VBOXWDDM_DMA_ALLOCINFO, *PVBOXWDDM_DMA_ALLOCINFO;
170
171typedef struct VBOXVDMAPIPE_RECTS
172{
173 RECT ContextRect;
174 VBOXWDDM_RECTS_INFO UpdateRects;
175} VBOXVDMAPIPE_RECTS, *PVBOXVDMAPIPE_RECTS;
176
177typedef struct VBOXVDMAPIPE_CMD_RECTSINFO
178{
179 VBOXVDMAPIPE_CMD_DR Hdr;
180 VBOXVDMADDI_CMD DdiCmd;
181 struct VBOXWDDM_SWAPCHAIN *pSwapchain;
182 VBOXVDMAPIPE_RECTS ContextsRects;
183} VBOXVDMAPIPE_CMD_RECTSINFO, *PVBOXVDMAPIPE_CMD_RECTSINFO;
184
185typedef struct VBOXVDMAPIPE_FLAGS_DMACMD
186{
187 union
188 {
189 struct
190 {
191 UINT b2DRelated : 1;
192 UINT b3DRelated : 1;
193 UINT bDecVBVAUnlock : 1;
194 UINT Reserved : 29;
195 };
196 UINT Value;
197 };
198} VBOXVDMAPIPE_FLAGS_DMACMD, *PVBOXVDMAPIPE_FLAGS_DMACMD;
199typedef struct VBOXVDMAPIPE_CMD_DMACMD
200{
201 VBOXVDMAPIPE_CMD_DR Hdr;
202 VBOXVDMADDI_CMD DdiCmd;
203 PDEVICE_EXTENSION pDevExt;
204 VBOXVDMACMD_TYPE enmCmd;
205 VBOXVDMAPIPE_FLAGS_DMACMD fFlags;
206} VBOXVDMAPIPE_CMD_DMACMD, *PVBOXVDMAPIPE_CMD_DMACMD;
207
208typedef struct VBOXVDMA_CLRFILL
209{
210 VBOXWDDM_DMA_ALLOCINFO Alloc;
211 UINT Color;
212 VBOXWDDM_RECTS_INFO Rects;
213} VBOXVDMA_CLRFILL, *PVBOXVDMA_CLRFILL;
214
215typedef struct VBOXVDMAPIPE_CMD_DMACMD_CLRFILL
216{
217 VBOXVDMAPIPE_CMD_DMACMD Hdr;
218 VBOXVDMA_CLRFILL ClrFill;
219} VBOXVDMAPIPE_CMD_DMACMD_CLRFILL, *PVBOXVDMAPIPE_CMD_DMACMD_CLRFILL;
220
221typedef struct VBOXVDMA_BLT
222{
223 VBOXWDDM_DMA_ALLOCINFO SrcAlloc;
224 VBOXWDDM_DMA_ALLOCINFO DstAlloc;
225 RECT SrcRect;
226 VBOXVDMAPIPE_RECTS DstRects;
227} VBOXVDMA_BLT, *PVBOXVDMA_BLT;
228
229typedef struct VBOXVDMAPIPE_CMD_DMACMD_BLT
230{
231 VBOXVDMAPIPE_CMD_DMACMD Hdr;
232 VBOXVDMA_BLT Blt;
233} VBOXVDMAPIPE_CMD_DMACMD_BLT, *PVBOXVDMAPIPE_CMD_DMACMD_BLT;
234
235typedef struct VBOXVDMA_FLIP
236{
237 VBOXWDDM_DMA_ALLOCINFO Alloc;
238} VBOXVDMA_FLIP, *PVBOXVDMA_FLIP;
239
240typedef struct VBOXVDMAPIPE_CMD_DMACMD_FLIP
241{
242 VBOXVDMAPIPE_CMD_DMACMD Hdr;
243 VBOXVDMA_FLIP Flip;
244} VBOXVDMAPIPE_CMD_DMACMD_FLIP, *PVBOXVDMAPIPE_CMD_DMACMD_FLIP;
245
246typedef struct VBOXVDMA_SHADOW2PRIMARY
247{
248 VBOXWDDM_DMA_ALLOCINFO ShadowAlloc;
249 RECT SrcRect;
250 D3DDDI_VIDEO_PRESENT_SOURCE_ID VidPnSourceId;
251} VBOXVDMA_SHADOW2PRIMARY, *PVBOXVDMA_SHADOW2PRIMARY;
252
253typedef struct VBOXVDMAGG
254{
255 VBOXVDMAPIPE CmdPipe;
256 PKTHREAD pThread;
257} VBOXVDMAGG, *PVBOXVDMAGG;
258
259/* DMA commands are currently submitted over HGSMI */
260typedef struct VBOXVDMAINFO
261{
262#ifdef VBOX_WITH_VDMA
263 KSPIN_LOCK HeapLock;
264 HGSMIHEAP CmdHeap;
265#endif
266 UINT uLastCompletedPagingBufferCmdFenceId;
267 BOOL fEnabled;
268 /* dma-related commands list processed on the guest w/o host part involvement (guest-guest commands) */
269 VBOXVDMAGG DmaGg;
270} VBOXVDMAINFO, *PVBOXVDMAINFO;
271
272int vboxVdmaCreate (struct _DEVICE_EXTENSION* pDevExt, VBOXVDMAINFO *pInfo
273#ifdef VBOX_WITH_VDMA
274 , ULONG offBuffer, ULONG cbBuffer
275#endif
276#if 0
277 , PFNVBOXVDMASUBMIT pfnSubmit, PVOID pvContext
278#endif
279 );
280int vboxVdmaDisable (struct _DEVICE_EXTENSION* pDevExt, PVBOXVDMAINFO pInfo);
281int vboxVdmaEnable (struct _DEVICE_EXTENSION* pDevExt, PVBOXVDMAINFO pInfo);
282int vboxVdmaDestroy (struct _DEVICE_EXTENSION* pDevExt, PVBOXVDMAINFO pInfo);
283
284#ifdef VBOX_WITH_VDMA
285int vboxVdmaFlush (struct _DEVICE_EXTENSION* pDevExt, PVBOXVDMAINFO pInfo);
286int vboxVdmaCBufDrSubmit (struct _DEVICE_EXTENSION* pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
287int vboxVdmaCBufDrSubmitSynch (PDEVICE_EXTENSION pDevExt, PVBOXVDMAINFO pInfo, PVBOXVDMACBUF_DR pDr);
288struct VBOXVDMACBUF_DR* vboxVdmaCBufDrCreate (PVBOXVDMAINFO pInfo, uint32_t cbTrailingData);
289void vboxVdmaCBufDrFree (PVBOXVDMAINFO pInfo, struct VBOXVDMACBUF_DR* pDr);
290
291#define VBOXVDMACBUF_DR_DATA_OFFSET() (sizeof (VBOXVDMACBUF_DR))
292#define VBOXVDMACBUF_DR_SIZE(_cbData) (VBOXVDMACBUF_DR_DATA_OFFSET() + (_cbData))
293#define VBOXVDMACBUF_DR_DATA(_pDr) ( ((uint8_t*)(_pDr)) + VBOXVDMACBUF_DR_DATA_OFFSET() )
294
295AssertCompile(sizeof (VBOXVDMADDI_CMD) <= RT_SIZEOFMEMB(VBOXVDMACBUF_DR, aGuestData));
296#define VBOXVDMADDI_CMD_FROM_BUF_DR(_pDr) ((PVBOXVDMADDI_CMD)(_pDr)->aGuestData)
297#define VBOXVDMACBUF_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMACBUF_DR)(((uint_8*)(_pCmd)) - RT_OFFSETOF(VBOXVDMACBUF_DR, aGuestData)))
298
299#endif
300NTSTATUS vboxVdmaGgCmdSubmit(PVBOXVDMAGG pVdma, PVBOXVDMAPIPE_CMD_DR pCmd);
301PVBOXVDMAPIPE_CMD_DR vboxVdmaGgCmdCreate(PVBOXVDMAGG pVdma, VBOXVDMAPIPE_CMD_TYPE enmType, uint32_t cbCmd);
302void vboxVdmaGgCmdDestroy(PVBOXVDMAPIPE_CMD_DR pDr);
303
304#define VBOXVDMAPIPE_CMD_DR_FROM_DDI_CMD(_pCmd) ((PVBOXVDMAPIPE_CMD_DR)(((uint8_t*)(_pCmd)) - RT_OFFSETOF(VBOXVDMAPIPE_CMD_DR, DdiCmd)))
305DECLCALLBACK(VOID) vboxVdmaGgDdiCmdDestroy(PDEVICE_EXTENSION pDevExt, PVBOXVDMADDI_CMD pCmd, PVOID pvContext);
306#endif /* #ifndef ___VBoxVideoVdma_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