📄 directx.c
字号:
{
case WINED3DFMT_UNKNOWN:
/* This is D3D8. Do not enumerate P8 here */
if (DevModeW.dmBitsPerPel == 32 ||
DevModeW.dmBitsPerPel == 16) i++;
break;
case WINED3DFMT_X8R8G8B8:
if (DevModeW.dmBitsPerPel == 32) i++;
break;
case WINED3DFMT_R5G6B5:
if (DevModeW.dmBitsPerPel == 16) i++;
break;
case WINED3DFMT_P8:
if (DevModeW.dmBitsPerPel == 8) i++;
break;
default:
/* Modes that don't match what we support can get an early-out */
TRACE_(d3d_caps)("Searching for %s, returning D3DERR_INVALIDCALL\n", debug_d3dformat(Format));
return WINED3DERR_INVALIDCALL;
}
}
if (i == 0) {
TRACE_(d3d_caps)("No modes found for format (%x - %s)\n", Format, debug_d3dformat(Format));
return WINED3DERR_INVALIDCALL;
}
ModeIdx = j - 1;
/* Now get the display mode via the calculated index */
if (EnumDisplaySettingsExW(NULL, ModeIdx, &DevModeW, 0)) {
pMode->Width = DevModeW.dmPelsWidth;
pMode->Height = DevModeW.dmPelsHeight;
pMode->RefreshRate = WINED3DADAPTER_DEFAULT;
if (DevModeW.dmFields & DM_DISPLAYFREQUENCY)
pMode->RefreshRate = DevModeW.dmDisplayFrequency;
if (Format == WINED3DFMT_UNKNOWN)
{
switch (DevModeW.dmBitsPerPel)
{
case 8:
pMode->Format = WINED3DFMT_P8;
break;
case 16:
pMode->Format = WINED3DFMT_R5G6B5;
break;
case 32:
pMode->Format = WINED3DFMT_X8R8G8B8;
break;
default:
pMode->Format = WINED3DFMT_UNKNOWN;
ERR("Unhandled bit depth (%u) in mode list!\n", DevModeW.dmBitsPerPel);
}
} else {
pMode->Format = Format;
}
} else {
TRACE_(d3d_caps)("Requested mode out of range %d\n", Mode);
return WINED3DERR_INVALIDCALL;
}
TRACE_(d3d_caps)("W %d H %d rr %d fmt (%x - %s) bpp %u\n", pMode->Width, pMode->Height,
pMode->RefreshRate, pMode->Format, debug_d3dformat(pMode->Format),
DevModeW.dmBitsPerPel);
} else if (DEBUG_SINGLE_MODE) {
/* Return one setting of the format requested */
if (Mode > 0) return WINED3DERR_INVALIDCALL;
pMode->Width = 800;
pMode->Height = 600;
pMode->RefreshRate = 60;
pMode->Format = (Format == WINED3DFMT_UNKNOWN) ? WINED3DFMT_X8R8G8B8 : Format;
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT Adapter, WINED3DDISPLAYMODE* pMode) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d, pMode: %p)\n", This, Adapter, pMode);
if (NULL == pMode ||
Adapter >= IWineD3D_GetAdapterCount(iface)) {
return WINED3DERR_INVALIDCALL;
}
if (Adapter == 0) { /* Display */
int bpp = 0;
DEVMODEW DevModeW;
ZeroMemory(&DevModeW, sizeof(DevModeW));
DevModeW.dmSize = sizeof(DevModeW);
EnumDisplaySettingsExW(NULL, ENUM_CURRENT_SETTINGS, &DevModeW, 0);
pMode->Width = DevModeW.dmPelsWidth;
pMode->Height = DevModeW.dmPelsHeight;
bpp = DevModeW.dmBitsPerPel;
pMode->RefreshRate = WINED3DADAPTER_DEFAULT;
if (DevModeW.dmFields&DM_DISPLAYFREQUENCY)
{
pMode->RefreshRate = DevModeW.dmDisplayFrequency;
}
switch (bpp) {
case 8: pMode->Format = WINED3DFMT_R3G3B2; break;
case 16: pMode->Format = WINED3DFMT_R5G6B5; break;
case 24: pMode->Format = WINED3DFMT_X8R8G8B8; break; /* Robots needs 24bit to be X8R8G8B8 */
case 32: pMode->Format = WINED3DFMT_X8R8G8B8; break; /* EVE online and the Fur demo need 32bit AdapterDisplatMode to return X8R8G8B8 */
default: pMode->Format = WINED3DFMT_UNKNOWN;
}
} else {
FIXME_(d3d_caps)("Adapter not primary display\n");
}
TRACE_(d3d_caps)("returning w:%d, h:%d, ref:%d, fmt:%s\n", pMode->Width,
pMode->Height, pMode->RefreshRate, debug_d3dformat(pMode->Format));
return WINED3D_OK;
}
/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER,
and fields being inserted in the middle, a new structure is used in place */
static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter, DWORD Flags,
WINED3DADAPTER_IDENTIFIER* pIdentifier) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p}->(Adapter: %d, Flags: %x, pId=%p)\n", This, Adapter, Flags, pIdentifier);
if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
return WINED3DERR_INVALIDCALL;
}
/* Return the information requested */
TRACE_(d3d_caps)("device/Vendor Name and Version detection using FillGLCaps\n");
strcpy(pIdentifier->Driver, Adapters[Adapter].driver);
strcpy(pIdentifier->Description, Adapters[Adapter].description);
/* Note dx8 doesn't supply a DeviceName */
if (NULL != pIdentifier->DeviceName) strcpy(pIdentifier->DeviceName, "\\\\.\\DISPLAY"); /* FIXME: May depend on desktop? */
/* Current Windows drivers have versions like 6.14.... (some older have an earlier version) */
pIdentifier->DriverVersion->u.HighPart = MAKEDWORD_VERSION(6, 14);
pIdentifier->DriverVersion->u.LowPart = Adapters[Adapter].gl_info.gl_driver_version;
*(pIdentifier->VendorId) = Adapters[Adapter].gl_info.gl_vendor;
*(pIdentifier->DeviceId) = Adapters[Adapter].gl_info.gl_card;
*(pIdentifier->SubSysId) = 0;
*(pIdentifier->Revision) = 0;
/*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
if (Flags & WINED3DENUM_NO_WHQL_LEVEL) {
*(pIdentifier->WHQLLevel) = 0;
} else {
*(pIdentifier->WHQLLevel) = 1;
}
return WINED3D_OK;
}
static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(const WineD3D_PixelFormat *cfg, WINED3DFORMAT Format) {
short redSize, greenSize, blueSize, alphaSize, colorBits;
if(!cfg)
return FALSE;
if(!getColorBits(Format, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(Format));
return FALSE;
}
if(cfg->redSize < redSize)
return FALSE;
if(cfg->greenSize < greenSize)
return FALSE;
if(cfg->blueSize < blueSize)
return FALSE;
if(cfg->alphaSize < alphaSize)
return FALSE;
return TRUE;
}
static BOOL IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(const WineD3D_PixelFormat *cfg, WINED3DFORMAT Format) {
short depthSize, stencilSize;
if(!cfg)
return FALSE;
if(!getDepthStencilBits(Format, &depthSize, &stencilSize)) {
ERR("Unable to check compatibility for Format=%s\n", debug_d3dformat(Format));
return FALSE;
}
if(cfg->depthSize < depthSize)
return FALSE;
if(cfg->stencilSize < stencilSize)
return FALSE;
return TRUE;
}
static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
WINED3DFORMAT AdapterFormat,
WINED3DFORMAT RenderTargetFormat,
WINED3DFORMAT DepthStencilFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
int nCfgs;
WineD3D_PixelFormat *cfgs;
int it;
WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
This, Adapter,
DeviceType, debug_d3ddevicetype(DeviceType),
AdapterFormat, debug_d3dformat(AdapterFormat),
RenderTargetFormat, debug_d3dformat(RenderTargetFormat),
DepthStencilFormat, debug_d3dformat(DepthStencilFormat));
if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
TRACE("(%p) Failed: Atapter (%u) higher than supported adapters (%u) returning WINED3DERR_INVALIDCALL\n", This, Adapter, IWineD3D_GetAdapterCount(iface));
return WINED3DERR_INVALIDCALL;
}
cfgs = Adapters[Adapter].cfgs;
nCfgs = Adapters[Adapter].nCfgs;
for (it = 0; it < nCfgs; ++it) {
if (IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&cfgs[it], RenderTargetFormat)) {
if (IWineD3DImpl_IsPixelFormatCompatibleWithDepthFmt(&cfgs[it], DepthStencilFormat)) {
TRACE_(d3d_caps)("(%p) : Formats matched\n", This);
return WINED3D_OK;
}
}
}
WARN_(d3d_caps)("unsupported format pair: %s and %s\n", debug_d3dformat(RenderTargetFormat), debug_d3dformat(DepthStencilFormat));
return WINED3DERR_NOTAVAILABLE;
}
static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
WINED3DFORMAT SurfaceFormat,
BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
This,
Adapter,
DeviceType, debug_d3ddevicetype(DeviceType),
SurfaceFormat, debug_d3dformat(SurfaceFormat),
Windowed,
MultiSampleType,
pQualityLevels);
if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
return WINED3DERR_INVALIDCALL;
}
/* TODO: Store in Adapter structure */
if (pQualityLevels != NULL) {
static int s_single_shot = 0;
if (!s_single_shot) {
FIXME("Quality levels unsupported at present\n");
s_single_shot = 1;
}
*pQualityLevels = 1; /* Guess at a value! */
}
if (WINED3DMULTISAMPLE_NONE == MultiSampleType) return WINED3D_OK;
return WINED3DERR_NOTAVAILABLE;
}
static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE CheckType,
WINED3DFORMAT DisplayFormat, WINED3DFORMAT BackBufferFormat, BOOL Windowed) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
int nCfgs = 0;
WineD3D_PixelFormat *cfgs;
int it;
HRESULT hr = WINED3DERR_NOTAVAILABLE;
TRACE_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, CheckType:(%x,%s), DispFmt:(%x,%s), BackBuf:(%x,%s), Win?%d): stub\n",
This,
Adapter,
CheckType, debug_d3ddevicetype(CheckType),
DisplayFormat, debug_d3dformat(DisplayFormat),
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -