VirtualBox

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

Last change on this file since 33252 was 33216, checked in by vboxsync, 14 years ago

wddm/3d: chromium hgsmi fixes

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