VBoxDispD3DIf.cpp revision 369424307f1564511c32c427be8d6864067fa422
/* $Id$ */
/** @file
* VBoxVideo Display D3D User mode dll
*/
/*
* Copyright (C) 2011-2012 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.
*/
#include "VBoxDispD3DIf.h"
#include "VBoxDispD3DCmn.h"
{
}
/**
* Loads a system DLL.
*
* @returns Module handle or NULL
* @param pszName The DLL name.
*/
{
{
return NULL;
}
return LoadLibraryA(szPath);
}
{
#ifdef VBOX_WDDM_WOW64
#else
#endif
{
return E_FAIL;
}
do
{
pD3D->pfnDirect3DCreate9Ex = (PFNVBOXDISPD3DCREATE9EX)GetProcAddress(pD3D->hD3DLib, "Direct3DCreate9Ex");
if (!pD3D->pfnDirect3DCreate9Ex)
{
WARN(("no Direct3DCreate9Ex"));
break;
}
pD3D->pfnVBoxWineExD3DDev9CreateTexture = (PFNVBOXWINEEXD3DDEV9_CREATETEXTURE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9CreateTexture");
{
WARN(("no VBoxWineExD3DDev9CreateTexture"));
break;
}
pD3D->pfnVBoxWineExD3DDev9CreateCubeTexture = (PFNVBOXWINEEXD3DDEV9_CREATECUBETEXTURE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9CreateCubeTexture");
{
WARN(("no VBoxWineExD3DDev9CreateCubeTexture"));
break;
}
pD3D->pfnVBoxWineExD3DDev9CreateVolumeTexture = (PFNVBOXWINEEXD3DDEV9_CREATEVOLUMETEXTURE)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9CreateVolumeTexture");
{
WARN(("no VBoxWineExD3DDev9CreateVolumeTexture"));
break;
}
pD3D->pfnVBoxWineExD3DDev9Flush = (PFNVBOXWINEEXD3DDEV9_FLUSH)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9Flush");
if (!pD3D->pfnVBoxWineExD3DDev9Flush)
{
WARN(("no VBoxWineExD3DDev9Flush"));
break;
}
pD3D->pfnVBoxWineExD3DDev9FlushToHost = (PFNVBOXWINEEXD3DDEV9_FLUSHTOHOST)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9FlushToHost");
{
WARN(("no VBoxWineExD3DDev9FlushToHost"));
break;
}
pD3D->pfnVBoxWineExD3DDev9Finish = (PFNVBOXWINEEXD3DDEV9_FINISH)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9Finish");
if (!pD3D->pfnVBoxWineExD3DDev9Finish)
{
WARN(("no VBoxWineExD3DDev9Finish"));
break;
}
pD3D->pfnVBoxWineExD3DDev9VolBlt = (PFNVBOXWINEEXD3DDEV9_VOLBLT)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9VolBlt");
if (!pD3D->pfnVBoxWineExD3DDev9VolBlt)
{
WARN(("no VBoxWineExD3DDev9VolBlt"));
break;
}
pD3D->pfnVBoxWineExD3DDev9VolTexBlt = (PFNVBOXWINEEXD3DDEV9_VOLTEXBLT)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9VolTexBlt");
{
WARN(("no VBoxWineExD3DDev9VolTexBlt"));
break;
}
pD3D->pfnVBoxWineExD3DDev9Term = (PFNVBOXWINEEXD3DDEV9_TERM)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9Term");
if (!pD3D->pfnVBoxWineExD3DDev9Term)
{
WARN(("no VBoxWineExD3DDev9Term"));
break;
}
pD3D->pfnVBoxWineExD3DSwapchain9Present = (PFNVBOXWINEEXD3DSWAPCHAIN9_PRESENT)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DSwapchain9Present");
{
WARN(("no VBoxWineExD3DSwapchain9Present"));
break;
}
pD3D->pfnVBoxWineExD3DSurf9GetHostId = (PFNVBOXWINEEXD3DSURF9_GETHOSTID)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DSurf9GetHostId");
{
WARN(("no VBoxWineExD3DSurf9GetHostId"));
break;
}
pD3D->pfnVBoxWineExD3DSurf9SyncToHost = (PFNVBOXWINEEXD3DSURF9_SYNCTOHOST)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DSurf9SyncToHost");
{
WARN(("no VBoxWineExD3DSurf9SyncToHost"));
break;
}
pD3D->pfnVBoxWineExD3DSwapchain9GetHostWinID = (PFNVBOXWINEEXD3DSWAPCHAIN9_GETHOSTWINID)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DSwapchain9GetHostWinID");
{
WARN(("no VBoxWineExD3DSwapchain9GetHostWinID"));
break;
}
pD3D->pfnVBoxWineExD3DDev9GetHostId = (PFNVBOXWINEEXD3DDEV9_GETHOSTID)GetProcAddress(pD3D->hD3DLib, "VBoxWineExD3DDev9GetHostId");
{
WARN(("no VBoxWineExD3DDev9GetHostId"));
break;
}
return S_OK;
} while (0);
return E_FAIL;
}
static FORMATOP gVBoxFormatOps3D[] = {
FORMATOP_SRGBWRITE|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_SRGBWRITE|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
{D3DDDIFMT_D16, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_D24S8, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_D24X8, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_X8D24, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_D32F_LOCKABLE, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
{D3DDDIFMT_S8D24, FORMATOP_TEXTURE|FORMATOP_ZSTENCIL|FORMATOP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
// Floating-point formats are not implemented in Chromium.
// {D3DDDIFMT_A16B16G16R16F,
// FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
// FORMATOP_SAME_FORMAT_RENDERTARGET|
// 0|
// FORMATOP_OFFSCREENPLAIN|
// 0|
// FORMATOP_VERTEXTEXTURE, 0, 0, 0},
//
// {D3DDDIFMT_A32B32G32R32F,
// FORMATOP_TEXTURE|FORMATOP_VOLUMETEXTURE|FORMATOP_CUBETEXTURE|FORMATOP_OFFSCREEN_RENDERTARGET|
// FORMATOP_SAME_FORMAT_RENDERTARGET|
// 0|
// FORMATOP_OFFSCREENPLAIN|
// 0|
// FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
0|
0|
FORMATOP_NOTEXCOORDWRAPNORMIP, 0, 0, 0},
0|
0|
0|
FORMATOP_NOTEXCOORDWRAPNORMIP, 0, 0, 0},
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
FORMATOP_OVERLAY, 0, 0, 0},
{D3DDDIFMT_BINARYBUFFER, FORMATOP_OFFSCREENPLAIN, 0, 0, 0},
0|
0|
FORMATOP_VERTEXTEXTURE, 0, 0, 0},
0|
FORMATOP_AUTOGENMIPMAP|FORMATOP_VERTEXTEXTURE, 0, 0, 0},
};
static FORMATOP gVBoxFormatOpsBase[] = {
{D3DDDIFMT_X8R8G8B8, FORMATOP_DISPLAYMODE, 0, 0, 0},
{D3DDDIFMT_R8G8B8, FORMATOP_DISPLAYMODE, 0, 0, 0},
{D3DDDIFMT_R5G6B5, FORMATOP_DISPLAYMODE, 0, 0, 0},
{D3DDDIFMT_P8, FORMATOP_DISPLAYMODE, 0, 0, 0},
};
static DDSURFACEDESC gVBoxSurfDescsBase[] = {
{
sizeof (DDSURFACEDESC), /* DWORD dwSize; */
0, /* DWORD dwHeight; */
0, /* DWORD dwWidth; */
{
0, /* Union */
/* LONG lPitch; */
/* DWORD dwLinearSize; */
},
0, /* DWORD dwBackBufferCount; */
{
0, /* Union */
/* DWORD dwMipMapCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwRefreshRate; */
},
0, /* DWORD dwAlphaBitDepth; */
0, /* DWORD dwReserved; */
NULL, /* LPVOID lpSurface; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestBlt; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcBlt; */
{
sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
DDPF_RGB, /* DWORD dwFlags; */
0, /* DWORD dwFourCC; */
{
32, /* union */
/* DWORD dwRGBBitCount; */
/* DWORD dwYUVBitCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwAlphaBitDepth; */
/* DWORD dwLuminanceBitCount; */
/* DWORD dwBumpBitCount; */
},
{
0xff0000, /* union */
/* DWORD dwRBitMask; */
/* DWORD dwYBitMask; */
/* DWORD dwStencilBitDepth; */
/* DWORD dwLuminanceBitMask; */
/* DWORD dwBumpDuBitMask; */
},
{
0xff00,
/* DWORD dwGBitMask; */
/* DWORD dwUBitMask; */
/* DWORD dwZBitMask; */
/* DWORD dwBumpDvBitMask; */
},
{
0xff,
/* DWORD dwBBitMask; */
/* DWORD dwVBitMask; */
/* DWORD dwStencilBitMask; */
/* DWORD dwBumpLuminanceBitMask; */
},
{
0,
/* DWORD dwRGBAlphaBitMask; */
/* DWORD dwYUVAlphaBitMask; */
/* DWORD dwLuminanceAlphaBitMask; */
/* DWORD dwRGBZBitMask; */
/* DWORD dwYUVZBitMask; */
},
}, /* DDPIXELFORMAT ddpfPixelFormat; */
{
| DDSCAPS_VISIBLE /* DWORD dwCaps; */
} /* DDSCAPS ddsCaps; */
},
{
sizeof (DDSURFACEDESC), /* DWORD dwSize; */
0, /* DWORD dwHeight; */
0, /* DWORD dwWidth; */
{
0, /* Union */
/* LONG lPitch; */
/* DWORD dwLinearSize; */
},
0, /* DWORD dwBackBufferCount; */
{
0, /* Union */
/* DWORD dwMipMapCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwRefreshRate; */
},
0, /* DWORD dwAlphaBitDepth; */
0, /* DWORD dwReserved; */
NULL, /* LPVOID lpSurface; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestBlt; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcBlt; */
{
sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
DDPF_RGB, /* DWORD dwFlags; */
0, /* DWORD dwFourCC; */
{
24, /* union */
/* DWORD dwRGBBitCount; */
/* DWORD dwYUVBitCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwAlphaBitDepth; */
/* DWORD dwLuminanceBitCount; */
/* DWORD dwBumpBitCount; */
},
{
0xff0000, /* union */
/* DWORD dwRBitMask; */
/* DWORD dwYBitMask; */
/* DWORD dwStencilBitDepth; */
/* DWORD dwLuminanceBitMask; */
/* DWORD dwBumpDuBitMask; */
},
{
0xff00,
/* DWORD dwGBitMask; */
/* DWORD dwUBitMask; */
/* DWORD dwZBitMask; */
/* DWORD dwBumpDvBitMask; */
},
{
0xff,
/* DWORD dwBBitMask; */
/* DWORD dwVBitMask; */
/* DWORD dwStencilBitMask; */
/* DWORD dwBumpLuminanceBitMask; */
},
{
0,
/* DWORD dwRGBAlphaBitMask; */
/* DWORD dwYUVAlphaBitMask; */
/* DWORD dwLuminanceAlphaBitMask; */
/* DWORD dwRGBZBitMask; */
/* DWORD dwYUVZBitMask; */
},
}, /* DDPIXELFORMAT ddpfPixelFormat; */
{
| DDSCAPS_VISIBLE /* DWORD dwCaps; */
} /* DDSCAPS ddsCaps; */
},
{
sizeof (DDSURFACEDESC), /* DWORD dwSize; */
0, /* DWORD dwHeight; */
0, /* DWORD dwWidth; */
{
0, /* Union */
/* LONG lPitch; */
/* DWORD dwLinearSize; */
},
0, /* DWORD dwBackBufferCount; */
{
0, /* Union */
/* DWORD dwMipMapCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwRefreshRate; */
},
0, /* DWORD dwAlphaBitDepth; */
0, /* DWORD dwReserved; */
NULL, /* LPVOID lpSurface; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKDestBlt; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcOverlay; */
{
0, /* DWORD dwColorSpaceLowValue; */
0, /* DWORD dwColorSpaceHighValue; */
}, /* DDCOLORKEY ddckCKSrcBlt; */
{
sizeof (DDPIXELFORMAT), /* DWORD dwSize; */
DDPF_RGB, /* DWORD dwFlags; */
0, /* DWORD dwFourCC; */
{
16, /* union */
/* DWORD dwRGBBitCount; */
/* DWORD dwYUVBitCount; */
/* DWORD dwZBufferBitDepth; */
/* DWORD dwAlphaBitDepth; */
/* DWORD dwLuminanceBitCount; */
/* DWORD dwBumpBitCount; */
},
{
0xf800, /* union */
/* DWORD dwRBitMask; */
/* DWORD dwYBitMask; */
/* DWORD dwStencilBitDepth; */
/* DWORD dwLuminanceBitMask; */
/* DWORD dwBumpDuBitMask; */
},
{
0x7e0,
/* DWORD dwGBitMask; */
/* DWORD dwUBitMask; */
/* DWORD dwZBitMask; */
/* DWORD dwBumpDvBitMask; */
},
{
0x1f,
/* DWORD dwBBitMask; */
/* DWORD dwVBitMask; */
/* DWORD dwStencilBitMask; */
/* DWORD dwBumpLuminanceBitMask; */
},
{
0,
/* DWORD dwRGBAlphaBitMask; */
/* DWORD dwYUVAlphaBitMask; */
/* DWORD dwLuminanceAlphaBitMask; */
/* DWORD dwRGBZBitMask; */
/* DWORD dwYUVZBitMask; */
},
}, /* DDPIXELFORMAT ddpfPixelFormat; */
{
| DDSCAPS_VISIBLE /* DWORD dwCaps; */
} /* DDSCAPS ddsCaps; */
},
};
#ifdef VBOX_WITH_VIDEOHWACCEL
{
}
{
}
HRESULT vboxSurfDescMerge(DDSURFACEDESC *paDescs, uint32_t *pcDescs, uint32_t cMaxDescs, DDSURFACEDESC *pDesc)
{
return E_INVALIDARG;
{
{
{
}
return S_OK;
}
}
{
++cDescs;
return VINF_SUCCESS;
}
return E_FAIL;
}
{
{
{
return S_OK;
}
}
{
++cOps;
return VINF_SUCCESS;
}
return E_FAIL;
}
{
/* just calc the max number of formats */
uint32_t cOverlayFormats = 0;
{
{
}
}
/* ensure the surf descs are 8 byte aligned */
if (pvBuf)
{
{
{
{
hr = vboxFormatOpsMerge((FORMATOP *)pAdapter->Formats.paFormstOps, &pAdapter->Formats.cFormstOps, cFormats, &fo);
{
}
}
}
}
{
{
{
if (fourcc)
{
hr = vboxSurfDescMerge((DDSURFACEDESC *)pAdapter->Formats.paSurfDescs, &pAdapter->Formats.cSurfDescs, cSurfDescs, &sd);
{
}
}
}
}
}
}
else
{
WARN(("RTMemAllocZ failed"));
return E_FAIL;
}
return S_OK;
}
{
}
#endif
static uint32_t g_cVBoxDispD3DGlobalOpens;
void vboxDispD3DGlobalLock()
{
}
void vboxDispD3DGlobalUnlock()
{
}
void VBoxDispD3DGlobalInit()
{
}
void VBoxDispD3DGlobalTerm()
{
}
{
}
{
{
return hr;
}
/* needed for Windows Media Player to work properly */
/*| D3DDEVCAPS_HWVERTEXBUFFER | D3DDEVCAPS_HWINDEXBUFFER | D3DDEVCAPS_SUBVOLUMELOCK */;
pCaps->RasterCaps |= D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_STIPPLE | D3DPRASTERCAPS_ZBIAS | D3DPRASTERCAPS_COLORPERSPECTIVE /* keep */;
/* workaround for wine not returning InstructionSlots correctly for shaders v3.0 */
{
}
#if defined(DEBUG)
{
}
{
}
else
{
WARN(("incorect shader caps!"));
}
#endif
return S_OK;
}
{
}
{
{
{
{
return S_OK;
}
else
{
}
}
else
{
}
}
else
{
}
return hr;
}
{
{
{
return hr;
}
}
return S_OK;
}
{
{
}
}