VBoxMPIf.h revision 2eed70acbc887ff6ba5bcc935cb50f46cf834b5a
/* $Id$ */
/** @file
* VBox WDDM Miniport driver
*
* Contains base definitions of constants & structures used
* to control & perform rendering,
* such as DMA commands types, allocation types, escape codes, etc.
* used by both miniport & display drivers.
*
* The latter uses these and only these defs to communicate with the former
* by posting appropriate requests via D3D RT Krnl Svc accessing callbacks.
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#ifndef ___VBoxMPIf_h___
#define ___VBoxMPIf_h___
#include <VBox/VBoxVideo.h>
#include "../../../../include/VBoxDisplay.h"
#include "../VBoxVideoTools.h"
#include <VBox/VBoxUhgsmi.h>
#include <VBox/VBoxGuest2.h>
/* One would increase this whenever definitions in this file are changed */
#define VBOXVIDEOIF_VERSION 13
#define VBOXWDDM_NODE_ID_SYSTEM 0
#define VBOXWDDM_NODE_ID_3D (VBOXWDDM_NODE_ID_SYSTEM)
#define VBOXWDDM_NODE_ID_3D_KMT (VBOXWDDM_NODE_ID_3D)
#define VBOXWDDM_ENGINE_ID_SYSTEM 0
#else
# define VBOXWDDM_ENGINE_ID_3D 0
#endif
#else
# define VBOXWDDM_ENGINE_ID_3D_KMT 0
#endif
#else
# define VBOXWDDM_ENGINE_ID_2D_VIDEO 0
#endif
/* create allocation func */
typedef enum
{
/* this one is win 7-specific and hence unused for now */
/* custom allocation types requested from user-mode d3d module will go here */
/* usage */
typedef enum
{
/* set for the allocation being primary */
typedef struct VBOXWDDM_SURFACE_DESC
{
typedef struct VBOXWDDM_ALLOCINFO
{
union
{
struct
{
};
struct
{
};
};
typedef struct VBOXWDDM_RC_DESC
{
typedef struct VBOXWDDMDISP_RESOURCE_FLAGS
{
union
{
struct
{
UINT Generic : 1; /* identifies this is a resource created with CreateResource, the VBOXWDDMDISP_RESOURCE::fRcFlags is valid */
};
};
typedef struct VBOXWDDM_RCINFO
{
// VBOXWDDM_ALLOCINFO aAllocInfos[1];
typedef struct VBOXWDDM_DMA_PRIVATEDATA_FLAFS
{
union
{
struct
{
};
};
typedef struct VBOXWDDM_DMA_PRIVATEDATA_BASEHDR
{
union
{
};
typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_SUBMIT_INFO
{
typedef struct VBOXWDDM_DMA_PRIVATEDATA_UM_CHROMIUM_CMD
{
#define VBOXVHWA_F_ENABLED 0x00000001
#define VBOXVHWA_F_CKEY_DST 0x00000002
#define VBOXVHWA_F_CKEY_SRC 0x00000004
#define VBOXVHWA_MAX_FORMATS 8
typedef struct VBOXVHWA_INFO
{
#define VBOXWDDM_OVERLAY_F_CKEY_DST 0x00000001
#define VBOXWDDM_OVERLAY_F_CKEY_DSTRANGE 0x00000002
#define VBOXWDDM_OVERLAY_F_CKEY_SRC 0x00000004
#define VBOXWDDM_OVERLAY_F_CKEY_SRCRANGE 0x00000008
#define VBOXWDDM_OVERLAY_F_BOB 0x00000010
#define VBOXWDDM_OVERLAY_F_INTERLEAVED 0x00000020
#define VBOXWDDM_OVERLAY_F_MIRROR_LR 0x00000040
#define VBOXWDDM_OVERLAY_F_MIRROR_UD 0x00000080
#define VBOXWDDM_OVERLAY_F_DEINTERLACED 0x00000100
typedef struct VBOXWDDM_OVERLAY_DESC
{
typedef struct VBOXWDDM_OVERLAY_INFO
{
typedef struct VBOXWDDM_OVERLAYFLIP_INFO
{
typedef enum
{
/* system-created context (for GDI rendering) */
/* context created by the D3D User-mode driver when crogl IS available */
/* context created by the D3D User-mode driver when crogl is NOT available or for ddraw overlay acceleration */
/* contexts created by the cromium HGSMI transport for HGSMI commands submission */
/* context created by the kernel->user communication mechanism for visible rects reporting, etc. */
typedef struct VBOXWDDM_CREATECONTEXT_INFO
{
/* interface version, i.e. 9 for d3d9, 8 for d3d8, etc. */
/* true if d3d false if ddraw */
/* we use uint64_t instead of HANDLE to ensure structure def is the same for both 32-bit and 64-bit
* since x64 kernel driver can be called by 32-bit UMD */
/* info to be passed to UMD notification to identify the context */
typedef uint64_t VBOXDISP_UMHANDLE;
typedef uint32_t VBOXDISP_KMHANDLE;
typedef struct VBOXWDDM_RECTS_FLAFS
{
union
{
struct
{
/* used only in conjunction with bSetVisibleRects.
* if set - VBOXWDDM_RECTS_INFO::aRects[0] contains view rectangle */
/* adds visible regions */
/* adds hidden regions */
/* hide entire window */
/* reserved */
};
};
typedef struct VBOXWDDM_RECTS_INFO
{
#define VBOXWDDM_RECTS_INFO_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXWDDM_RECTS_INFO, aRects[(_cRects)]))
typedef enum
{
/* command to be post to user mode */
/* control command processed in kernel mode */
VBOXVIDEOCM_CMD_DUMMY_32BIT = 0x7fffffff
typedef struct VBOXVIDEOCM_CMD_HDR
{
typedef struct VBOXVIDEOCM_CMD_RECTS
{
typedef struct VBOXVIDEOCM_CMD_RECTS_INTERNAL
{
union
{
};
typedef struct VBOXVIDEOCM_CMD_RECTS_HDR
{
#define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS(_cRects) (RT_OFFSETOF(VBOXVIDEOCM_CMD_RECTS_INTERNAL, Cmd.RectsInfo.aRects[(_cRects)]))
#define VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE(_pCmd) (VBOXVIDEOCM_CMD_RECTS_INTERNAL_SIZE4CRECTS((_pCmd)->cRects))
typedef struct VBOXWDDM_GETVBOXVIDEOCMCMD_HDR
{
typedef struct VBOXDISPIFESCAPE_GETVBOXVIDEOCMCMD
{
typedef struct VBOXDISPIFESCAPE_DBGPRINT
{
/* null-terminated string to DbgPrint including \0 */
char aStringBuf[1];
typedef enum
{
VBOXDISPIFESCAPE_DBGDUMPBUF_TYPE_DUMMY32BIT = 0x7fffffff
typedef struct VBOXDISPIFESCAPE_DBGDUMPBUF_FLAGS
{
union
{
struct
{
};
};
typedef struct VBOXDISPIFESCAPE_DBGDUMPBUF
{
char aBuf[1];
typedef struct VBOXSCREENLAYOUT_ELEMENT
{
typedef struct VBOXSCREENLAYOUT
{
typedef struct VBOXDISPIFESCAPE_SCREENLAYOUT
{
typedef struct VBOXSWAPCHAININFO
{
typedef struct VBOXDISPIFESCAPE_SWAPCHAININFO
{
typedef struct VBOXVIDEOCM_UM_ALLOC
{
typedef struct VBOXDISPIFESCAPE_UHGSMI_ALLOCATE
{
typedef struct VBOXDISPIFESCAPE_UHGSMI_DEALLOCATE
{
typedef struct VBOXWDDM_UHGSMI_BUFFER_UI_INFO_ESCAPE
{
typedef struct VBOXDISPIFESCAPE_UHGSMI_SUBMIT
{
typedef struct VBOXDISPIFESCAPE_SHRC_REF
{
typedef struct VBOXDISPIFESCAPE_CRHGSMICTLCON_CALL
{
/* query info func */
typedef struct VBOXWDDM_QI
{
} VBOXWDDM_QI;
/* submit cmd func */
{
switch (enmFormat)
{
case D3DDDIFMT_A8R8G8B8:
return D3DDDIFMT_X8R8G8B8;
case D3DDDIFMT_A1R5G5B5:
return D3DDDIFMT_X1R5G5B5;
case D3DDDIFMT_A4R4G4B4:
return D3DDDIFMT_X4R4G4B4;
case D3DDDIFMT_A8B8G8R8:
return D3DDDIFMT_X8B8G8R8;
default:
return enmFormat;
}
}
/* tooling */
{
switch (enmFormat)
{
case D3DDDIFMT_R8G8B8:
return 24;
case D3DDDIFMT_A8R8G8B8:
case D3DDDIFMT_X8R8G8B8:
return 32;
case D3DDDIFMT_R5G6B5:
case D3DDDIFMT_X1R5G5B5:
case D3DDDIFMT_A1R5G5B5:
case D3DDDIFMT_A4R4G4B4:
return 16;
case D3DDDIFMT_R3G3B2:
case D3DDDIFMT_A8:
return 8;
case D3DDDIFMT_A8R3G3B2:
case D3DDDIFMT_X4R4G4B4:
return 16;
case D3DDDIFMT_A2B10G10R10:
case D3DDDIFMT_A8B8G8R8:
case D3DDDIFMT_X8B8G8R8:
case D3DDDIFMT_G16R16:
case D3DDDIFMT_A2R10G10B10:
return 32;
case D3DDDIFMT_A16B16G16R16:
return 64;
case D3DDDIFMT_A8P8:
return 16;
case D3DDDIFMT_P8:
case D3DDDIFMT_L8:
return 8;
case D3DDDIFMT_L16:
case D3DDDIFMT_A8L8:
return 16;
case D3DDDIFMT_A4L4:
return 8;
case D3DDDIFMT_V8U8:
case D3DDDIFMT_L6V5U5:
return 16;
case D3DDDIFMT_X8L8V8U8:
case D3DDDIFMT_Q8W8V8U8:
case D3DDDIFMT_V16U16:
case D3DDDIFMT_W11V11U10:
case D3DDDIFMT_A2W10V10U10:
return 32;
case D3DDDIFMT_D16_LOCKABLE:
case D3DDDIFMT_D16:
case D3DDDIFMT_D15S1:
return 16;
case D3DDDIFMT_D32:
case D3DDDIFMT_D24S8:
case D3DDDIFMT_D24X8:
case D3DDDIFMT_D24X4S4:
case D3DDDIFMT_D24FS8:
case D3DDDIFMT_D32_LOCKABLE:
case D3DDDIFMT_D32F_LOCKABLE:
return 32;
case D3DDDIFMT_S8_LOCKABLE:
return 8;
case D3DDDIFMT_DXT1:
return 4;
case D3DDDIFMT_DXT2:
case D3DDDIFMT_DXT3:
case D3DDDIFMT_DXT4:
case D3DDDIFMT_DXT5:
case D3DDDIFMT_VERTEXDATA:
case D3DDDIFMT_INDEX16: /* <- yes, dx runtime treats it as such */
return 8;
case D3DDDIFMT_INDEX32:
return 8;
case D3DDDIFMT_R32F:
return 32;
default:
return 0;
}
}
{
/* assume that in case both four bytes are non-zero, this is a fourcc */
if ((uFormat & 0xff000000)
&& (uFormat & 0x00ff0000)
&& (uFormat & 0x0000ff00)
&& (uFormat & 0x000000ff)
)
return uFormat;
return 0;
}
{
switch (enmFormat)
{
/* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
* i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
* then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
case D3DDDIFMT_DXT1:
{
return Pitch;
}
case D3DDDIFMT_DXT2:
case D3DDDIFMT_DXT3:
case D3DDDIFMT_DXT4:
case D3DDDIFMT_DXT5:
{
return Pitch;
}
default:
{
/* the default is just to calculate the pitch from bpp */
/* pitch is now in bits, translate in bytes */
}
}
}
{
switch (enmFormat)
{
/* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
* i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
* then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
case D3DDDIFMT_DXT1:
{
return Pitch;
}
case D3DDDIFMT_DXT2:
case D3DDDIFMT_DXT3:
case D3DDDIFMT_DXT4:
case D3DDDIFMT_DXT5:
{
return Pitch;
}
default:
{
/* the default is just to calculate the pitch from bpp */
/* pitch is now in bits, translate in bytes */
return Pitch >> 3;
}
}
}
{
switch (enmFormat)
{
/* for the DXT* (aka compressed) formats each block is decompressed into 4 x 4 pixels,
* so packing is 4
*/
case D3DDDIFMT_DXT1:
case D3DDDIFMT_DXT2:
case D3DDDIFMT_DXT3:
case D3DDDIFMT_DXT4:
case D3DDDIFMT_DXT5:
return 4;
default:
return 1;
}
}
{
/* round it up */
}
{
/* round it up */
}
{
return vboxWddmCalcOffXru(w, enmFormat);
}
{
switch (enmFormat)
{
/* pitch for the DXT* (aka compressed) formats is the size in bytes of blocks that fill in an image width
* i.e. each block decompressed into 4 x 4 pixels, so we have ((Width + 3) / 4) blocks for Width.
* then each block has 64 bits (8 bytes) for DXT1 and 64+64 bits (16 bytes) for DXT2-DXT5, so.. : */
case D3DDDIFMT_DXT1:
{
}
case D3DDDIFMT_DXT2:
case D3DDDIFMT_DXT3:
case D3DDDIFMT_DXT4:
case D3DDDIFMT_DXT5:
{
}
default:
{
/* the default is just to calculate it from bpp */
}
}
}
{
}
{
}
{
}
{
if (y)
}
#define VBOXWDDM_TRAILARRAY_MAXELEMENTSU32(_t, _af) ((uint32_t)(((~(0UL)) - (uint32_t)RT_OFFSETOF(_t, _af[0])) / RT_SIZEOFMEMB(_t, _af[0])))
#endif /* #ifndef ___VBoxMPIf_h___ */