VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/driver.h@ 20653

Last change on this file since 20653 was 20653, checked in by vboxsync, 16 years ago

video hw accel: fixes for basic ddraw op hanlding

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 14.6 KB
Line 
1/******************************Module*Header*******************************\
2*
3 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
4 *
5 * This file is part of VirtualBox Open Source Edition (OSE), as
6 * available from http://www.virtualbox.org. This file is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU
8 * General Public License (GPL) as published by the Free Software
9 * Foundation, in version 2 as it comes in the "COPYING" file of the
10 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
11 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
12 *
13 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
14 * Clara, CA 95054 USA or visit http://www.sun.com if you need
15 * additional information or have any questions.
16*/
17/*
18* Based in part on Microsoft DDK sample code
19*
20* *******************
21* * GDI SAMPLE CODE *
22* *******************
23*
24* Module Name: driver.h
25*
26* contains prototypes for the frame buffer driver.
27*
28* Copyright (c) 1992-1998 Microsoft Corporation
29\**************************************************************************/
30
31#include "stddef.h"
32#include <stdarg.h>
33#include "windef.h"
34#include "wingdi.h"
35#include "winddi.h"
36#include "devioctl.h"
37#include "ntddvdeo.h"
38#include "debug.h"
39
40#include "../Miniport/vboxioctl.h"
41
42#include <VBox/VBoxVideo.h>
43
44/* Forward declaration. */
45struct _PDEV;
46typedef struct _PDEV PDEV;
47typedef PDEV *PPDEV;
48
49typedef struct _VBOXDISPLAYINFO
50{
51 VBOXVIDEOINFOHDR hdrLink;
52 VBOXVIDEOINFOLINK link;
53 VBOXVIDEOINFOHDR hdrScreen;
54 VBOXVIDEOINFOSCREEN screen;
55 VBOXVIDEOINFOHDR hdrHostEvents;
56 VBOXVIDEOINFOHOSTEVENTS hostEvents;
57 VBOXVIDEOINFOHDR hdrEnd;
58} VBOXDISPLAYINFO;
59
60#include "vbvavrdp.h"
61#include "vrdpbmp.h"
62
63/* Saved screen bits information. */
64typedef struct _SSB
65{
66 ULONG ident; /* 1 based index in the stack = the handle returned by DrvSaveScreenBits (SS_SAVE) */
67 BYTE *pBuffer; /* Buffer where screen bits are saved. */
68} SSB;
69
70/* VRAM
71 * | | | | |
72 * 0+framebuffer+ddraw heap+VBVA buffer+displayinfo=cScreenSize
73 */
74typedef struct _VRAMLAYOUT
75{
76 ULONG cbVRAM;
77
78 ULONG offFrameBuffer;
79 ULONG cbFrameBuffer;
80
81 ULONG offDDRAWHeap; //@todo
82 ULONG cbDDRAWHeap;
83
84 ULONG offVBVABuffer;
85 ULONG cbVBVABuffer;
86
87 ULONG offDisplayInformation;
88 ULONG cbDisplayInformation;
89} VRAMLAYOUT;
90
91typedef struct
92{
93 PPDEV ppdev;
94} VBOXSURF, *PVBOXSURF;
95
96#ifdef VBOX_WITH_VIDEOHWACCEL
97typedef struct _VBOXVHWASURFDESC
98{
99 VBOXVHWA_SURFHANDLE hHostHandle;
100 volatile uint32_t cPendingBltsSrc;
101 volatile uint32_t cPendingBltsDst;
102 volatile uint32_t cPendingFlips;
103 uint32_t cBitsPerPixel;
104}VBOXVHWASURFDESC, *PVBOXVHWASURFDESC;
105
106typedef struct _VBOXVHWAINFO
107{
108 uint32_t caps;
109 uint32_t colorKeyCaps;
110 uint32_t stretchCaps;
111 uint32_t surfaceCaps;
112 uint32_t numOverlays;
113 uint32_t numFourCC;
114 HGSMIOFFSET FourCC;
115 BOOLEAN bVHWAEnabled;
116} VBOXVHWAINFO;
117#endif
118
119struct _PDEV
120{
121 HANDLE hDriver; // Handle to \Device\Screen
122 HDEV hdevEng; // Engine's handle to PDEV
123 HSURF hsurfScreenBitmap; // Engine's handle to VRAM screen bitmap surface
124 SURFOBJ *psoScreenBitmap; // VRAM screen bitmap surface
125 HSURF hsurfScreen; // Engine's handle to VRAM screen device surface
126 ULONG ulBitmapType;
127 HPALETTE hpalDefault; // Handle to the default palette for device.
128 PBYTE pjScreen; // This is pointer to base screen address
129 ULONG cxScreen; // Visible screen width
130 ULONG cyScreen; // Visible screen height
131 POINTL ptlOrg; // Where this display is anchored in
132 // the virtual desktop.
133 POINTL ptlDevOrg; // Device origin for DualView (0,0 for primary view).
134 ULONG ulMode; // Mode the mini-port driver is in.
135 LONG lDeltaScreen; // Distance from one scan to the next.
136
137 PVOID pOffscreenList; // linked list of DCI offscreen surfaces.
138 FLONG flRed; // For bitfields device, Red Mask
139 FLONG flGreen; // For bitfields device, Green Mask
140 FLONG flBlue; // For bitfields device, Blue Mask
141 ULONG cPaletteShift; // number of bits the 8-8-8 palette must
142 // be shifted by to fit in the hardware
143 // palette.
144 ULONG ulBitCount; // # of bits per pel 8,16,24,32 are only supported.
145 POINTL ptlHotSpot; // adjustment for pointer hot spot
146 VIDEO_POINTER_CAPABILITIES PointerCapabilities; // HW pointer abilities
147 PVIDEO_POINTER_ATTRIBUTES pPointerAttributes; // hardware pointer attributes
148 DWORD cjPointerAttributes; // Size of buffer allocated
149 BOOL fHwCursorActive; // Are we currently using the hw cursor
150 PALETTEENTRY *pPal; // If this is pal managed, this is the pal
151 BOOL bSupportDCI; // Does the miniport support DCI?
152 FLONG flHooks;
153
154#ifndef VBOX_WITH_HGSMI
155 VBVAENABLERESULT vbva;
156 uint32_t u32VRDPResetFlag;
157#endif /* !VBOX_WITH_HGSMI */
158 BOOL fHwBufferOverflow;
159 VBVARECORD *pRecord;
160 VRDPBC cache;
161
162 ULONG cSSB; // Number of active saved screen bits records in the following array.
163 SSB aSSB[4]; // LIFO type stack for saved screen areas.
164
165#ifndef VBOX_WITH_HGSMI
166 VBOXDISPLAYINFO *pInfo;
167 BOOLEAN bVBoxVideoSupported;
168#endif /* !VBOX_WITH_HGSMI */
169 ULONG iDevice;
170 VRAMLAYOUT layout;
171
172 PVBOXSURF pdsurfScreen;
173
174#ifdef VBOX_WITH_DDRAW
175 BOOL bDdExclusiveMode;
176 DWORD dwNewDDSurfaceOffset;
177 DWORD cHeaps;
178 VIDEOMEMORY* pvmList;
179 struct {
180 DWORD bLocked;
181 RECTL rArea;
182 } ddLock;
183#endif /* VBOX_WITH_DDRAW */
184
185#ifdef VBOX_WITH_HGSMI
186 BOOLEAN bHGSMISupported;
187 HGSMIHEAP hgsmiDisplayHeap;
188 VBVABUFFER *pVBVA; /* Pointer to the pjScreen + layout->offVBVABuffer. NULL if VBVA is not enabled. */
189
190 HVBOXVIDEOHGSMI hMpHGSMI; /* context handler passed to miniport HGSMI callbacks */
191 PFNVBOXVIDEOHGSMICOMPLETION pfnHGSMICommandComplete; /* called to complete the command we receive from the miniport */
192 PFNVBOXVIDEOHGSMICOMMANDS pfnHGSMIRequestCommands; /* called to requests the commands posted to us from the host */
193#endif /* VBOX_WITH_HGSMI */
194
195#ifdef VBOX_WITH_VIDEOHWACCEL
196 VBOXVHWAINFO vhwaInfo;
197#endif
198};
199
200#ifdef VBOX_WITH_OPENGL
201typedef struct
202{
203 DWORD dwVersion;
204 DWORD dwDriverVersion;
205 WCHAR szDriverName[256];
206} OPENGL_INFO, *POPENGL_INFO;
207#endif
208
209#ifndef VBOX_WITH_HGSMI
210/* The global semaphore handle for all driver instances. */
211extern HSEMAPHORE ghsemHwBuffer;
212#endif /* !VBOX_WITH_HGSMI */
213
214
215#ifdef VBOX_WITH_HGSMI
216#define VBE_DISPI_IOPORT_INDEX 0x01CE
217#define VBE_DISPI_IOPORT_DATA 0x01CF
218#define VBE_DISPI_INDEX_VBVA_GUEST 0xc
219#endif /* VBOX_WITH_HGSMI */
220
221extern BOOL g_bOnNT40;
222
223DWORD getAvailableModes(HANDLE, PVIDEO_MODE_INFORMATION *, DWORD *);
224BOOL bInitPDEV(PPDEV, PDEVMODEW, GDIINFO *, DEVINFO *);
225BOOL bInitSURF(PPDEV, BOOL);
226BOOL bInitPaletteInfo(PPDEV, DEVINFO *);
227BOOL bInitPointer(PPDEV, DEVINFO *);
228BOOL bInit256ColorPalette(PPDEV);
229BOOL bInitNotificationThread(PPDEV);
230VOID vStopNotificationThread (PPDEV);
231VOID vDisablePalette(PPDEV);
232VOID vDisableSURF(PPDEV);
233
234#define MAX_CLUT_SIZE (sizeof(VIDEO_CLUT) + (sizeof(ULONG) * 256))
235
236//
237// Determines the size of the DriverExtra information in the DEVMODE
238// structure passed to and from the display driver.
239//
240
241#define DRIVER_EXTRA_SIZE 0
242
243#define DLL_NAME L"VBoxDisp" // Name of the DLL in UNICODE
244#define STANDARD_DEBUG_PREFIX "VBOXDISP: " // All debug output is prefixed
245#define ALLOC_TAG 'bvDD' // Four byte tag (characters in
246 // reverse order) used for memory
247 // allocations
248
249// VBOX
250typedef struct _CLIPRECTS {
251 ULONG c;
252 RECTL arcl[64];
253} CLIPRECTS;
254
255typedef struct _VRDPCLIPRECTS
256{
257 RECTL rclDstOrig; /* Original bounding rectancle. */
258 RECTL rclDst; /* Bounding rectangle of all rects. */
259 CLIPRECTS rects; /* Rectangles to update. */
260} VRDPCLIPRECTS;
261
262
263BOOL vboxVbvaEnable (PPDEV ppdev);
264void vboxVbvaDisable (PPDEV ppdev);
265
266BOOL vboxHwBufferBeginUpdate (PPDEV ppdev);
267void vboxHwBufferEndUpdate (PPDEV ppdev);
268
269BOOL vboxWrite (PPDEV ppdev, const void *pv, uint32_t cb);
270
271BOOL vboxOrderSupported (PPDEV ppdev, unsigned code);
272
273void VBoxProcessDisplayInfo(PPDEV ppdev);
274void VBoxUpdateDisplayInfo (PPDEV ppdev);
275
276void drvLoadEng (void);
277
278#ifdef VBOX_WITH_HGSMI
279void vboxVBVAHostCommandComplete(PPDEV ppdev, VBVAHOSTCMD * pCmd);
280
281 #ifdef VBOX_WITH_VIDEOHWACCEL
282
283#define VBOXDD_CHECKFLAG(_v, _f) ((_v) & (_f)) == (_f)
284
285typedef DECLCALLBACK(void) FNVBOXVHWACMDCOMPLETION(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext);
286typedef FNVBOXVHWACMDCOMPLETION *PFNVBOXVHWACMDCOMPLETION;
287
288VBOXVHWACMD* vboxVHWACommandCreate (PPDEV ppdev, VBOXVHWACMD_TYPE enmCmd, VBOXVHWACMD_LENGTH cbCmd);
289void vboxVHWACommandFree (PPDEV ppdev, VBOXVHWACMD* pCmd);
290BOOL vboxVHWACommandSubmit (PPDEV ppdev, VBOXVHWACMD* pCmd);
291void vboxVHWACommandSubmitAsynch (PPDEV ppdev, VBOXVHWACMD* pCmd, PFNVBOXVHWACMDCOMPLETION pfnCompletion, void * pContext);
292void vboxVHWACommandSubmitAsynchByEvent (PPDEV ppdev, VBOXVHWACMD* pCmd, PEVENT pEvent);
293void vboxVHWACommandCheckHostCmds(PPDEV ppdev);
294
295int vboxVHWAInitHostInfo1(PPDEV ppdev);
296int vboxVHWAInitHostInfo2(PPDEV ppdev, DWORD *pFourCC);
297
298VBOXVHWACMD_QUERYINFO1* vboxVHWAQueryHostInfo1(PPDEV ppdev);
299void vboxVHWAFreeHostInfo1(PPDEV ppdev, VBOXVHWACMD_QUERYINFO1* pInfo);
300VBOXVHWACMD_QUERYINFO2* vboxVHWAQueryHostInfo2(PPDEV ppdev, uint32_t numFourCC);
301void vboxVHWAFreeHostInfo2(PPDEV ppdev, VBOXVHWACMD_QUERYINFO2* pInfo);
302
303void vboxVHWAInit();
304void vboxVHWATerm();
305uint32_t vboxVHWAUnsupportedDDCAPS(uint32_t caps);
306uint32_t vboxVHWAUnsupportedDDSCAPS(uint32_t caps);
307uint32_t vboxVHWAUnsupportedDDPFS(uint32_t caps);
308uint32_t vboxVHWASupportedDDCAPS(uint32_t caps);
309uint32_t vboxVHWASupportedDDSCAPS(uint32_t caps);
310uint32_t vboxVHWASupportedDDPFS(uint32_t caps);
311uint32_t vboxVHWAFromDDCAPS(uint32_t caps);
312uint32_t vboxVHWAToDDCAPS(uint32_t caps);
313uint32_t vboxVHWAFromDDSCAPS(uint32_t caps);
314uint32_t vboxVHWAToDDSCAPS(uint32_t caps);
315uint32_t vboxVHWAFromDDPFS(uint32_t caps);
316uint32_t vboxVHWAToDDPFS(uint32_t caps);
317void vboxVHWAFromDDPIXELFORMAT(VBOXVHWA_PIXELFORMAT *pVHWAFormat, DDPIXELFORMAT *pDdFormat);
318void vboxVHWAFromRECTL(VBOXVHWA_RECTL *pDst, RECTL *pSrc);
319PVBOXVHWASURFDESC vboxVHWASurfDescAlloc();
320void vboxVHWASurfDescFree(PVBOXVHWASURFDESC pDesc);
321
322int vboxVHWAEnable(PPDEV ppdev);
323int vboxVHWADisable(PPDEV ppdev);
324
325 #endif
326#endif
327
328BOOL bIsScreenSurface (SURFOBJ *pso);
329
330__inline SURFOBJ *getSurfObj (SURFOBJ *pso)
331{
332 if (pso)
333 {
334 PPDEV ppdev = (PPDEV)pso->dhpdev;
335
336 if (ppdev)
337 {
338 if (ppdev->psoScreenBitmap && pso->hsurf == ppdev->hsurfScreen)
339 {
340 /* Convert the device PSO to the bitmap PSO which can be passed to Eng*. */
341 pso = ppdev->psoScreenBitmap;
342 }
343 }
344 }
345
346 return pso;
347}
348
349#define CONV_SURF(_pso) getSurfObj (_pso)
350
351__inline int format2BytesPerPixel(const SURFOBJ *pso)
352{
353 switch (pso->iBitmapFormat)
354 {
355 case BMF_16BPP: return 2;
356 case BMF_24BPP: return 3;
357 case BMF_32BPP: return 4;
358 }
359
360 return 0;
361}
362
363#ifdef VBOX_VBVA_ADJUST_RECT
364void vrdpAdjustRect (SURFOBJ *pso, RECTL *prcl);
365BOOL vbvaFindChangedRect (SURFOBJ *psoDest, SURFOBJ *psoSrc, RECTL *prclDest, POINTL *pptlSrc);
366#endif /* VBOX_VBVA_ADJUST_RECT */
367
368void vrdpReportDirtyRect (PPDEV ppdev, RECTL *prcl);
369void vbvaReportDirtyRect (PPDEV ppdev, RECTL *prcl);
370
371#define VRDP_TEXT_MAX_GLYPH_SIZE 0x100
372#define VRDP_TEXT_MAX_GLYPHS 0xfe
373
374BOOL vboxReportText (PPDEV ppdev,
375 VRDPCLIPRECTS *pClipRects,
376 STROBJ *pstro,
377 FONTOBJ *pfo,
378 RECTL *prclOpaque,
379 ULONG ulForeRGB,
380 ULONG ulBackRGB
381 );
382
383BOOL vrdpReportOrderGeneric (PPDEV ppdev,
384 const VRDPCLIPRECTS *pClipRects,
385 const void *pvOrder,
386 unsigned cbOrder,
387 unsigned code);
388
389
390#include <iprt/assert.h>
391
392#define VBVA_ASSERT(expr) \
393 do { \
394 if (!(expr)) \
395 { \
396 AssertMsg1(#expr, __LINE__, __FILE__, __PRETTY_FUNCTION__); \
397 AssertMsg2("!!!\n"); \
398 } \
399 } while (0)
400
401#ifdef STAT_sunlover
402extern ULONG gStatCopyBitsOffscreenToScreen;
403extern ULONG gStatCopyBitsScreenToScreen;
404extern ULONG gStatBitBltOffscreenToScreen;
405extern ULONG gStatBitBltScreenToScreen;
406extern ULONG gStatUnchangedOffscreenToScreen;
407extern ULONG gStatUnchangedOffscreenToScreenCRC;
408extern ULONG gStatNonTransientEngineBitmaps;
409extern ULONG gStatTransientEngineBitmaps;
410extern ULONG gStatUnchangedBitmapsCRC;
411extern ULONG gStatUnchangedBitmapsDeviceCRC;
412extern ULONG gStatBitmapsCRC;
413extern ULONG gStatBitBltScreenPattern;
414extern ULONG gStatBitBltScreenSquare;
415extern ULONG gStatBitBltScreenPatternReported;
416extern ULONG gStatBitBltScreenSquareReported;
417extern ULONG gStatCopyBitsScreenSquare;
418
419extern ULONG gStatEnablePDEV;
420extern ULONG gStatCompletePDEV;
421extern ULONG gStatDisablePDEV;
422extern ULONG gStatEnableSurface;
423extern ULONG gStatDisableSurface;
424extern ULONG gStatAssertMode;
425extern ULONG gStatDisableDriver;
426extern ULONG gStatCreateDeviceBitmap;
427extern ULONG gStatDeleteDeviceBitmap;
428extern ULONG gStatDitherColor;
429extern ULONG gStatStrokePath;
430extern ULONG gStatFillPath;
431extern ULONG gStatStrokeAndFillPath;
432extern ULONG gStatPaint;
433extern ULONG gStatBitBlt;
434extern ULONG gStatCopyBits;
435extern ULONG gStatStretchBlt;
436extern ULONG gStatSetPalette;
437extern ULONG gStatTextOut;
438extern ULONG gStatSetPointerShape;
439extern ULONG gStatMovePointer;
440extern ULONG gStatLineTo;
441extern ULONG gStatSynchronize;
442extern ULONG gStatGetModes;
443extern ULONG gStatGradientFill;
444extern ULONG gStatStretchBltROP;
445extern ULONG gStatPlgBlt;
446extern ULONG gStatAlphaBlend;
447extern ULONG gStatTransparentBlt;
448
449void statPrint (void);
450
451#define STATDRVENTRY(a, b) do { if (bIsScreenSurface (b)) gStat##a++; } while (0)
452#define STATPRINT do { statPrint (); } while (0)
453#else
454#define STATDRVENTRY(a, b)
455#define STATPRINT
456#endif /* STAT_sunlover */
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