Move the GetDeviceCaps into the wined3d library and call from d3d9.

This commit is contained in:
Jason Edmeades 2004-10-06 00:05:29 +00:00 committed by Alexandre Julliard
parent 1e23cb7d33
commit b519893e41
6 changed files with 349 additions and 399 deletions

View File

@ -72,102 +72,6 @@ inline static Display *get_display( HDC hdc )
return display;
}
/**
* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
* ie there is no GL Context - Get a default rendering context to enable the
* function query some info from GL
*/
static
WineD3D_Context* WineD3DCreateFakeGLContext(void) {
static WineD3D_Context ctx = { NULL, NULL, NULL, 0, 0 };
WineD3D_Context* ret = NULL;
if (glXGetCurrentContext() == NULL) {
BOOL gotContext = FALSE;
BOOL created = FALSE;
XVisualInfo template;
HDC device_context;
Visual* visual;
BOOL failed = FALSE;
int num;
XWindowAttributes win_attr;
TRACE_(d3d_caps)("Creating Fake GL Context\n");
ctx.drawable = (Drawable) GetPropA(GetDesktopWindow(), "__wine_x11_whole_window");
/* Get the display */
device_context = GetDC(0);
ctx.display = get_display(device_context);
ReleaseDC(0, device_context);
/* Get the X visual */
ENTER_GL();
if (XGetWindowAttributes(ctx.display, ctx.drawable, &win_attr)) {
visual = win_attr.visual;
} else {
visual = DefaultVisual(ctx.display, DefaultScreen(ctx.display));
}
template.visualid = XVisualIDFromVisual(visual);
ctx.visInfo = XGetVisualInfo(ctx.display, VisualIDMask, &template, &num);
if (ctx.visInfo == NULL) {
LEAVE_GL();
WARN_(d3d_caps)("Error creating visual info for capabilities initialization\n");
failed = TRUE;
}
/* Create a GL context */
if (!failed) {
ctx.glCtx = glXCreateContext(ctx.display, ctx.visInfo, NULL, GL_TRUE);
if (ctx.glCtx == NULL) {
LEAVE_GL();
WARN_(d3d_caps)("Error creating default context for capabilities initialization\n");
failed = TRUE;
}
}
/* Make it the current GL context */
if (!failed && glXMakeCurrent(ctx.display, ctx.drawable, ctx.glCtx) == False) {
glXDestroyContext(ctx.display, ctx.glCtx);
LEAVE_GL();
WARN_(d3d_caps)("Error setting default context as current for capabilities initialization\n");
failed = TRUE;
}
/* It worked! Wow... */
if (!failed) {
gotContext = TRUE;
created = TRUE;
ret = &ctx;
} else {
ret = NULL;
}
} else {
if (ctx.ref > 0) ret = &ctx;
}
if (NULL != ret) ++ret->ref;
return ret;
}
static
void WineD3DReleaseFakeGLContext(WineD3D_Context* ctx) {
/* If we created a dummy context, throw it away */
if (NULL != ctx) {
--ctx->ref;
if (0 == ctx->ref) {
glXMakeCurrent(ctx->display, None, NULL);
glXDestroyContext(ctx->display, ctx->glCtx);
ctx->display = NULL;
ctx->glCtx = NULL;
LEAVE_GL();
}
}
}
/* IDirect3D IUnknown parts follow: */
HRESULT WINAPI IDirect3D8Impl_QueryInterface(LPDIRECT3D8 iface,REFIID riid,LPVOID *ppobj)
{
@ -282,296 +186,8 @@ HRESULT WINAPI IDirect3D8Impl_CheckDepthStencilMatch(LPDIRECT3D8 iface,
}
HRESULT WINAPI IDirect3D8Impl_GetDeviceCaps(LPDIRECT3D8 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS8* pCaps) {
BOOL gotContext = FALSE;
GLint gl_tex_size = 0;
WineD3D_Context* fake_ctx = NULL;
IDirect3D8Impl *This = (IDirect3D8Impl *)iface;
TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps);
if (Adapter >= IDirect3D8Impl_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL;
}
/* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
ie there is no GL Context - Get a default rendering context to enable the
function query some info from GL */
if (glXGetCurrentContext() == NULL) {
fake_ctx = WineD3DCreateFakeGLContext();
if (NULL != fake_ctx) gotContext = TRUE;
} else {
gotContext = TRUE;
}
if (gotContext == FALSE) {
FIXME_(d3d_caps)("GetDeviceCaps called but no GL Context - Returning dummy values\n");
gl_tex_size=65535;
pCaps->MaxTextureBlendStages = 2;
pCaps->MaxSimultaneousTextures = 2;
pCaps->MaxUserClipPlanes = 8;
pCaps->MaxActiveLights = 8;
pCaps->MaxVertexBlendMatrices = 0;
pCaps->MaxVertexBlendMatrixIndex = 1;
pCaps->MaxAnisotropy = 0;
pCaps->MaxPointSize = 255.0;
} else {
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_tex_size);
}
/* If we don't know the device settings, go query them now */
if (This->isGLInfoValid == FALSE) IDirect3D8Impl_FillGLCaps(iface, NULL);
pCaps->DeviceType = (DeviceType == D3DDEVTYPE_HAL) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF; /* Not quite true, but use h/w supported by opengl I suppose */
pCaps->AdapterOrdinal = Adapter;
pCaps->Caps = 0;
pCaps->Caps2 = D3DCAPS2_CANRENDERWINDOWED;
pCaps->Caps3 = D3DDEVCAPS_HWTRANSFORMANDLIGHT;
pCaps->PresentationIntervals = D3DPRESENT_INTERVAL_IMMEDIATE;
pCaps->CursorCaps = 0;
pCaps->DevCaps = D3DDEVCAPS_DRAWPRIMTLVERTEX |
D3DDEVCAPS_HWTRANSFORMANDLIGHT |
D3DDEVCAPS_PUREDEVICE;
pCaps->PrimitiveMiscCaps = D3DPMISCCAPS_CULLCCW |
D3DPMISCCAPS_CULLCW |
D3DPMISCCAPS_COLORWRITEENABLE |
D3DPMISCCAPS_CLIPTLVERTS |
D3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
D3DPMISCCAPS_MASKZ;
/*NOT: D3DPMISCCAPS_TSSARGTEMP*/
pCaps->RasterCaps = D3DPRASTERCAPS_DITHER |
D3DPRASTERCAPS_PAT |
D3DPRASTERCAPS_WFOG |
D3DPRASTERCAPS_ZFOG |
D3DPRASTERCAPS_FOGVERTEX |
D3DPRASTERCAPS_FOGTABLE |
D3DPRASTERCAPS_FOGRANGE;
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
pCaps->RasterCaps |= D3DPRASTERCAPS_ANISOTROPY;
}
/* FIXME Add:
D3DPRASTERCAPS_MIPMAPLODBIAS
D3DPRASTERCAPS_ZBIAS
D3DPRASTERCAPS_COLORPERSPECTIVE
D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
D3DPRASTERCAPS_ANTIALIASEDGES
D3DPRASTERCAPS_ZBUFFERLESSHSR
D3DPRASTERCAPS_WBUFFER */
pCaps->ZCmpCaps = D3DPCMPCAPS_ALWAYS |
D3DPCMPCAPS_EQUAL |
D3DPCMPCAPS_GREATER |
D3DPCMPCAPS_GREATEREQUAL |
D3DPCMPCAPS_LESS |
D3DPCMPCAPS_LESSEQUAL |
D3DPCMPCAPS_NEVER |
D3DPCMPCAPS_NOTEQUAL;
pCaps->SrcBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->DestBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->AlphaCmpCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB |
D3DPSHADECAPS_COLORGOURAUDRGB;
pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA |
D3DPTEXTURECAPS_ALPHAPALETTE |
D3DPTEXTURECAPS_POW2 |
D3DPTEXTURECAPS_VOLUMEMAP |
D3DPTEXTURECAPS_MIPMAP |
D3DPTEXTURECAPS_PROJECTED;
if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
pCaps->TextureCaps |= D3DPTEXTURECAPS_CUBEMAP |
D3DPTEXTURECAPS_MIPCUBEMAP |
D3DPTEXTURECAPS_CUBEMAP_POW2;
}
pCaps->TextureFilterCaps = D3DPTFILTERCAPS_MAGFLINEAR |
D3DPTFILTERCAPS_MAGFPOINT |
D3DPTFILTERCAPS_MINFLINEAR |
D3DPTFILTERCAPS_MINFPOINT |
D3DPTFILTERCAPS_MIPFLINEAR |
D3DPTFILTERCAPS_MIPFPOINT;
pCaps->CubeTextureFilterCaps = 0;
pCaps->VolumeTextureFilterCaps = 0;
pCaps->TextureAddressCaps = D3DPTADDRESSCAPS_BORDER |
D3DPTADDRESSCAPS_CLAMP |
D3DPTADDRESSCAPS_WRAP;
if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_BORDER;
}
if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRROR;
}
if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE;
}
pCaps->VolumeTextureAddressCaps = 0;
pCaps->LineCaps = D3DLINECAPS_TEXTURE |
D3DLINECAPS_ZTEST;
/* FIXME: Add
D3DLINECAPS_BLEND
D3DLINECAPS_ALPHACMP
D3DLINECAPS_FOG */
pCaps->MaxTextureWidth = gl_tex_size;
pCaps->MaxTextureHeight = gl_tex_size;
pCaps->MaxVolumeExtent = 0;
pCaps->MaxTextureRepeat = 32768;
pCaps->MaxTextureAspectRatio = 32768;
pCaps->MaxVertexW = 1.0;
pCaps->GuardBandLeft = 0;
pCaps->GuardBandTop = 0;
pCaps->GuardBandRight = 0;
pCaps->GuardBandBottom = 0;
pCaps->ExtentsAdjust = 0;
pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT |
D3DSTENCILCAPS_INCRSAT |
D3DSTENCILCAPS_INVERT |
D3DSTENCILCAPS_KEEP |
D3DSTENCILCAPS_REPLACE |
D3DSTENCILCAPS_ZERO;
if (GL_SUPPORT(EXT_STENCIL_WRAP)) {
pCaps->StencilCaps |= D3DSTENCILCAPS_DECR |
D3DSTENCILCAPS_INCR;
}
pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
pCaps->TextureOpCaps = D3DTEXOPCAPS_ADD |
D3DTEXOPCAPS_ADDSIGNED |
D3DTEXOPCAPS_ADDSIGNED2X |
D3DTEXOPCAPS_MODULATE |
D3DTEXOPCAPS_MODULATE2X |
D3DTEXOPCAPS_MODULATE4X |
D3DTEXOPCAPS_SELECTARG1 |
D3DTEXOPCAPS_SELECTARG2 |
D3DTEXOPCAPS_DISABLE;
#if defined(GL_VERSION_1_3)
pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3 |
D3DTEXOPCAPS_SUBTRACT;
#endif
if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE) ||
GL_SUPPORT(EXT_TEXTURE_ENV_COMBINE) ||
GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) {
pCaps->TextureOpCaps |= D3DTEXOPCAPS_BLENDDIFFUSEALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHA |
D3DTEXOPCAPS_BLENDFACTORALPHA |
D3DTEXOPCAPS_BLENDCURRENTALPHA |
D3DTEXOPCAPS_LERP;
}
if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) {
pCaps->TextureOpCaps |= D3DTEXOPCAPS_ADDSMOOTH |
D3DTEXOPCAPS_MULTIPLYADD |
D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHAPM;
}
#if 0
pCaps->TextureOpCaps |= D3DTEXOPCAPS_BUMPENVMAP;
/* FIXME: Add
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
D3DTEXOPCAPS_PREMODULATE */
#endif
if (gotContext) {
GLint gl_max;
GLfloat gl_float;
#if defined(GL_VERSION_1_3)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_max);
#else
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
#endif
TRACE_(d3d_caps)("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max);
pCaps->MaxTextureBlendStages = min(8, gl_max);
pCaps->MaxSimultaneousTextures = min(8, gl_max);
glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
pCaps->MaxUserClipPlanes = min(MAX_CLIPPLANES, gl_max);
TRACE_(d3d_caps)("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", pCaps->MaxUserClipPlanes);
glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
pCaps->MaxActiveLights = gl_max;
TRACE_(d3d_caps)("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps->MaxActiveLights);
if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
pCaps->MaxVertexBlendMatrices = gl_max;
pCaps->MaxVertexBlendMatrixIndex = 1;
} else {
pCaps->MaxVertexBlendMatrices = 0;
pCaps->MaxVertexBlendMatrixIndex = 1;
}
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
checkGLcall("glGetInterv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)");
pCaps->MaxAnisotropy = gl_max;
} else {
pCaps->MaxAnisotropy = 0;
}
glGetFloatv(GL_POINT_SIZE_RANGE, &gl_float);
pCaps->MaxPointSize = gl_float;
}
pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS |
D3DVTXPCAPS_MATERIALSOURCE7 |
D3DVTXPCAPS_POSITIONALLIGHTS |
D3DVTXPCAPS_LOCALVIEWER |
D3DVTXPCAPS_TEXGEN;
/* FIXME: Add
D3DVTXPCAPS_TWEENING */
pCaps->MaxPrimitiveCount = 0xFFFFFFFF;
pCaps->MaxVertexIndex = 0xFFFFFFFF;
pCaps->MaxStreams = MAX_STREAMS;
pCaps->MaxStreamStride = 1024;
if (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) || (vs_mode == VS_SW) || (DeviceType == D3DDEVTYPE_REF)) {
pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
if (This->gl_info.gl_vendor == VENDOR_MESA ||
This->gl_info.gl_vendor == VENDOR_WINE) {
pCaps->MaxVertexShaderConst = 95;
} else {
pCaps->MaxVertexShaderConst = D3D8_VSHADER_MAX_CONSTANTS;
}
} else {
pCaps->VertexShaderVersion = 0;
pCaps->MaxVertexShaderConst = 0;
}
if ((ps_mode == PS_HW) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && (DeviceType != D3DDEVTYPE_REF)) {
pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
pCaps->MaxPixelShaderValue = 1.0;
} else {
pCaps->PixelShaderVersion = 0;
pCaps->MaxPixelShaderValue = 0.0;
}
/* If we created a dummy context, throw it away */
WineD3DReleaseFakeGLContext(fake_ctx);
return D3D_OK;
return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (void *)pCaps);
}
HMONITOR WINAPI IDirect3D8Impl_GetAdapterMonitor(LPDIRECT3D8 iface, UINT Adapter) {

View File

@ -156,8 +156,7 @@ HRESULT WINAPI IDirect3D9Impl_CheckDeviceFormatConversion(LPDIRECT3D9 iface, U
HRESULT WINAPI IDirect3D9Impl_GetDeviceCaps(LPDIRECT3D9 iface, UINT Adapter, D3DDEVTYPE DeviceType, D3DCAPS9* pCaps) {
IDirect3D9Impl *This = (IDirect3D9Impl *)iface;
FIXME("(%p): stub\n", This);
return D3D_OK;
return IWineD3D_GetDeviceCaps(This->WineD3D, Adapter, DeviceType, (void *)pCaps);
}
HMONITOR WINAPI IDirect3D9Impl_GetAdapterMonitor(LPDIRECT3D9 iface, UINT Adapter) {

View File

@ -980,6 +980,332 @@ HRESULT WINAPI IWineD3DImpl_CheckDeviceFormatConversion(IWineD3D *iface, UINT
return D3D_OK;
}
/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
subset of a D3DCAPS9 structure. However, it has to come via a void *
as the d3d8 interface cannot import the d3d9 header */
HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, D3DDEVTYPE DeviceType, void* pCapsIn) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
BOOL gotContext = FALSE;
GLint gl_tex_size = 0;
WineD3D_Context *fake_ctx = NULL;
D3DCAPS9 *pCaps = (D3DCAPS9 *)pCapsIn;
TRACE_(d3d_caps)("(%p)->(Adptr:%d, DevType: %x, pCaps: %p)\n", This, Adapter, DeviceType, pCaps);
if (Adapter >= IWineD3D_GetAdapterCount(iface)) {
return D3DERR_INVALIDCALL;
}
/* Note: GL seems to trap if GetDeviceCaps is called before any HWND's created
ie there is no GL Context - Get a default rendering context to enable the
function query some info from GL */
if (glXGetCurrentContext() == NULL) {
fake_ctx = WineD3D_CreateFakeGLContext();
if (NULL != fake_ctx) gotContext = TRUE;
} else {
gotContext = TRUE;
}
if (gotContext == FALSE) {
FIXME_(d3d_caps)("GetDeviceCaps called but no GL Context - Returning dummy values\n");
gl_tex_size=65535;
pCaps->MaxTextureBlendStages = 2;
pCaps->MaxSimultaneousTextures = 2;
pCaps->MaxUserClipPlanes = 8;
pCaps->MaxActiveLights = 8;
pCaps->MaxVertexBlendMatrices = 0;
pCaps->MaxVertexBlendMatrixIndex = 1;
pCaps->MaxAnisotropy = 0;
pCaps->MaxPointSize = 255.0;
} else {
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_tex_size);
}
/* If we don't know the device settings, go query them now */
if (This->isGLInfoValid == FALSE) {
BOOL rc = IWineD3DImpl_FillGLCaps(&This->gl_info, NULL);
/* If we are running off a real context, save the values */
if ((rc == TRUE) && ((NULL != fake_ctx))) This->isGLInfoValid = TRUE;
}
/* ------------------------------------------------
The following fields apply to both d3d8 and d3d9
------------------------------------------------ */
pCaps->DeviceType = (DeviceType == D3DDEVTYPE_HAL) ? D3DDEVTYPE_HAL : D3DDEVTYPE_REF; /* Not quite true, but use h/w supported by opengl I suppose */
pCaps->AdapterOrdinal = Adapter;
pCaps->Caps = 0;
pCaps->Caps2 = D3DCAPS2_CANRENDERWINDOWED;
pCaps->Caps3 = D3DDEVCAPS_HWTRANSFORMANDLIGHT;
pCaps->PresentationIntervals = D3DPRESENT_INTERVAL_IMMEDIATE;
pCaps->CursorCaps = 0;
pCaps->DevCaps = D3DDEVCAPS_DRAWPRIMTLVERTEX |
D3DDEVCAPS_HWTRANSFORMANDLIGHT |
D3DDEVCAPS_PUREDEVICE;
pCaps->PrimitiveMiscCaps = D3DPMISCCAPS_CULLCCW |
D3DPMISCCAPS_CULLCW |
D3DPMISCCAPS_COLORWRITEENABLE |
D3DPMISCCAPS_CLIPTLVERTS |
D3DPMISCCAPS_CLIPPLANESCALEDPOINTS |
D3DPMISCCAPS_MASKZ;
/*NOT: D3DPMISCCAPS_TSSARGTEMP*/
pCaps->RasterCaps = D3DPRASTERCAPS_DITHER |
D3DPRASTERCAPS_PAT |
D3DPRASTERCAPS_WFOG |
D3DPRASTERCAPS_ZFOG |
D3DPRASTERCAPS_FOGVERTEX |
D3DPRASTERCAPS_FOGTABLE |
D3DPRASTERCAPS_FOGRANGE;
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
pCaps->RasterCaps |= D3DPRASTERCAPS_ANISOTROPY;
}
/* FIXME Add:
D3DPRASTERCAPS_MIPMAPLODBIAS
D3DPRASTERCAPS_ZBIAS
D3DPRASTERCAPS_COLORPERSPECTIVE
D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE
D3DPRASTERCAPS_ANTIALIASEDGES
D3DPRASTERCAPS_ZBUFFERLESSHSR
D3DPRASTERCAPS_WBUFFER */
pCaps->ZCmpCaps = D3DPCMPCAPS_ALWAYS |
D3DPCMPCAPS_EQUAL |
D3DPCMPCAPS_GREATER |
D3DPCMPCAPS_GREATEREQUAL |
D3DPCMPCAPS_LESS |
D3DPCMPCAPS_LESSEQUAL |
D3DPCMPCAPS_NEVER |
D3DPCMPCAPS_NOTEQUAL;
pCaps->SrcBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->DestBlendCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->AlphaCmpCaps = 0xFFFFFFFF; /*FIXME: Tidy up later */
pCaps->ShadeCaps = D3DPSHADECAPS_SPECULARGOURAUDRGB |
D3DPSHADECAPS_COLORGOURAUDRGB;
pCaps->TextureCaps = D3DPTEXTURECAPS_ALPHA |
D3DPTEXTURECAPS_ALPHAPALETTE |
D3DPTEXTURECAPS_POW2 |
D3DPTEXTURECAPS_VOLUMEMAP |
D3DPTEXTURECAPS_MIPMAP |
D3DPTEXTURECAPS_PROJECTED;
if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) {
pCaps->TextureCaps |= D3DPTEXTURECAPS_CUBEMAP |
D3DPTEXTURECAPS_MIPCUBEMAP |
D3DPTEXTURECAPS_CUBEMAP_POW2;
}
pCaps->TextureFilterCaps = D3DPTFILTERCAPS_MAGFLINEAR |
D3DPTFILTERCAPS_MAGFPOINT |
D3DPTFILTERCAPS_MINFLINEAR |
D3DPTFILTERCAPS_MINFPOINT |
D3DPTFILTERCAPS_MIPFLINEAR |
D3DPTFILTERCAPS_MIPFPOINT;
pCaps->CubeTextureFilterCaps = 0;
pCaps->VolumeTextureFilterCaps = 0;
pCaps->TextureAddressCaps = D3DPTADDRESSCAPS_BORDER |
D3DPTADDRESSCAPS_CLAMP |
D3DPTADDRESSCAPS_WRAP;
if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) {
pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_BORDER;
}
if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) {
pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRROR;
}
if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) {
pCaps->TextureAddressCaps |= D3DPTADDRESSCAPS_MIRRORONCE;
}
pCaps->VolumeTextureAddressCaps = 0;
pCaps->LineCaps = D3DLINECAPS_TEXTURE |
D3DLINECAPS_ZTEST;
/* FIXME: Add
D3DLINECAPS_BLEND
D3DLINECAPS_ALPHACMP
D3DLINECAPS_FOG */
pCaps->MaxTextureWidth = gl_tex_size;
pCaps->MaxTextureHeight = gl_tex_size;
pCaps->MaxVolumeExtent = 0;
pCaps->MaxTextureRepeat = 32768;
pCaps->MaxTextureAspectRatio = 32768;
pCaps->MaxVertexW = 1.0;
pCaps->GuardBandLeft = 0;
pCaps->GuardBandTop = 0;
pCaps->GuardBandRight = 0;
pCaps->GuardBandBottom = 0;
pCaps->ExtentsAdjust = 0;
pCaps->StencilCaps = D3DSTENCILCAPS_DECRSAT |
D3DSTENCILCAPS_INCRSAT |
D3DSTENCILCAPS_INVERT |
D3DSTENCILCAPS_KEEP |
D3DSTENCILCAPS_REPLACE |
D3DSTENCILCAPS_ZERO;
if (GL_SUPPORT(EXT_STENCIL_WRAP)) {
pCaps->StencilCaps |= D3DSTENCILCAPS_DECR |
D3DSTENCILCAPS_INCR;
}
pCaps->FVFCaps = D3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */
pCaps->TextureOpCaps = D3DTEXOPCAPS_ADD |
D3DTEXOPCAPS_ADDSIGNED |
D3DTEXOPCAPS_ADDSIGNED2X |
D3DTEXOPCAPS_MODULATE |
D3DTEXOPCAPS_MODULATE2X |
D3DTEXOPCAPS_MODULATE4X |
D3DTEXOPCAPS_SELECTARG1 |
D3DTEXOPCAPS_SELECTARG2 |
D3DTEXOPCAPS_DISABLE;
#if defined(GL_VERSION_1_3)
pCaps->TextureOpCaps |= D3DTEXOPCAPS_DOTPRODUCT3 |
D3DTEXOPCAPS_SUBTRACT;
#endif
if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE) ||
GL_SUPPORT(EXT_TEXTURE_ENV_COMBINE) ||
GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) {
pCaps->TextureOpCaps |= D3DTEXOPCAPS_BLENDDIFFUSEALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHA |
D3DTEXOPCAPS_BLENDFACTORALPHA |
D3DTEXOPCAPS_BLENDCURRENTALPHA |
D3DTEXOPCAPS_LERP;
}
if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) {
pCaps->TextureOpCaps |= D3DTEXOPCAPS_ADDSMOOTH |
D3DTEXOPCAPS_MULTIPLYADD |
D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
D3DTEXOPCAPS_BLENDTEXTUREALPHAPM;
}
#if 0
pCaps->TextureOpCaps |= D3DTEXOPCAPS_BUMPENVMAP;
/* FIXME: Add
D3DTEXOPCAPS_BUMPENVMAPLUMINANCE
D3DTEXOPCAPS_PREMODULATE */
#endif
if (gotContext) {
GLint gl_max;
GLfloat gl_float;
#if defined(GL_VERSION_1_3)
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_max);
#else
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_max);
#endif
TRACE_(d3d_caps)("GLCaps: GL_MAX_TEXTURE_UNITS_ARB=%d\n", gl_max);
pCaps->MaxTextureBlendStages = min(8, gl_max);
pCaps->MaxSimultaneousTextures = min(8, gl_max);
glGetIntegerv(GL_MAX_CLIP_PLANES, &gl_max);
pCaps->MaxUserClipPlanes = min(D3DMAXUSERCLIPPLANES, gl_max);
TRACE_(d3d_caps)("GLCaps: GL_MAX_CLIP_PLANES=%ld\n", pCaps->MaxUserClipPlanes);
glGetIntegerv(GL_MAX_LIGHTS, &gl_max);
pCaps->MaxActiveLights = gl_max;
TRACE_(d3d_caps)("GLCaps: GL_MAX_LIGHTS=%ld\n", pCaps->MaxActiveLights);
if (GL_SUPPORT(ARB_VERTEX_BLEND)) {
glGetIntegerv(GL_MAX_VERTEX_UNITS_ARB, &gl_max);
pCaps->MaxVertexBlendMatrices = gl_max;
pCaps->MaxVertexBlendMatrixIndex = 1;
} else {
pCaps->MaxVertexBlendMatrices = 0;
pCaps->MaxVertexBlendMatrixIndex = 1;
}
if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) {
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_max);
pCaps->MaxAnisotropy = gl_max;
} else {
pCaps->MaxAnisotropy = 0;
}
glGetFloatv(GL_POINT_SIZE_RANGE, &gl_float);
pCaps->MaxPointSize = gl_float;
}
pCaps->VertexProcessingCaps = D3DVTXPCAPS_DIRECTIONALLIGHTS |
D3DVTXPCAPS_MATERIALSOURCE7 |
D3DVTXPCAPS_POSITIONALLIGHTS |
D3DVTXPCAPS_LOCALVIEWER |
D3DVTXPCAPS_TEXGEN;
/* FIXME: Add
D3DVTXPCAPS_TWEENING */
pCaps->MaxPrimitiveCount = 0xFFFFFFFF;
pCaps->MaxVertexIndex = 0xFFFFFFFF;
pCaps->MaxStreams = MAX_STREAMS;
pCaps->MaxStreamStride = 1024;
if (((vs_mode == VS_HW) && GL_SUPPORT(ARB_VERTEX_PROGRAM)) || (vs_mode == VS_SW) || (DeviceType == D3DDEVTYPE_REF)) {
pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
if (This->gl_info.gl_vendor == VENDOR_MESA ||
This->gl_info.gl_vendor == VENDOR_WINE) {
pCaps->MaxVertexShaderConst = 95;
} else {
pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS;
}
} else {
pCaps->VertexShaderVersion = 0;
pCaps->MaxVertexShaderConst = 0;
}
if ((ps_mode == PS_HW) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && (DeviceType != D3DDEVTYPE_REF)) {
pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
pCaps->MaxPixelShaderValue = 1.0;
} else {
pCaps->PixelShaderVersion = 0;
pCaps->MaxPixelShaderValue = 0.0;
}
/* ------------------------------------------------
The following fields apply to d3d9 only
------------------------------------------------ */
if (This->dxVersion > 8) {
FIXME("Caps support for directx9 is non-existant at the moment!\n");
pCaps->DevCaps2 = 0;
pCaps->MaxNpatchTessellationLevel = 0;
pCaps->MasterAdapterOrdinal = 0;
pCaps->AdapterOrdinalInGroup = 0;
pCaps->NumberOfAdaptersInGroup = 1;
pCaps->DeclTypes = 0;
pCaps->NumSimultaneousRTs = 0;
pCaps->StretchRectFilterCaps = 0;
pCaps->VS20Caps.Caps = 0;
pCaps->PS20Caps.Caps = 0;
pCaps->VertexTextureFilterCaps = 0;
pCaps->MaxVShaderInstructionsExecuted = 0;
pCaps->MaxPShaderInstructionsExecuted = 0;
pCaps->MaxVertexShader30InstructionSlots = 0;
pCaps->MaxPixelShader30InstructionSlots = 0;
}
/* If we created a dummy context, throw it away */
if (NULL != fake_ctx) WineD3D_ReleaseFakeGLContext(fake_ctx);
return D3D_OK;
}
/**********************************************************
* IUnknown parts follows
**********************************************************/
@ -1023,5 +1349,7 @@ IWineD3DVtbl IWineD3D_Vtbl =
IWineD3DImpl_CheckDeviceMultiSampleType,
IWineD3DImpl_CheckDepthStencilMatch,
IWineD3DImpl_CheckDeviceType,
IWineD3DImpl_CheckDeviceFormat
IWineD3DImpl_CheckDeviceFormat,
IWineD3DImpl_CheckDeviceFormatConversion,
IWineD3DImpl_GetDeviceCaps
};

View File

@ -68,6 +68,13 @@ extern int num_lock;
*/
#define GL_SUPPORT(ExtName) (This->gl_info.supported[ExtName] != 0)
#define MAX_STREAMS 16 /* Maximum possible streams - used for fixed size arrays
See MaxStreams in MSDN under GetDeviceCaps */
#define WINED3D_VSHADER_MAX_CONSTANTS 96
/* Maximum number of constants provided to the shaders */
/*****************************************************************************
* IWineD3D implementation structure
*/

View File

@ -44,8 +44,6 @@
#undef APIENTRY
#define APIENTRY
#undef CALLBACK
#undef WINAPI
/****************************************************
* OpenGL Extensions (EXT and ARB)
@ -795,6 +793,15 @@ typedef enum _GL_SupportedExt {
USE_GL_FUNC(PGLXFNGLXMAKECONTEXTCURRENTPROC, glXMakeContextCurrent); \
USE_GL_FUNC(PGLXFNGLXCHOOSEFBCONFIGPROC, glXChooseFBConfig); \
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
/****************************************************
* Structures
****************************************************/
@ -840,15 +847,6 @@ typedef struct _WineD3D_GLContext {
DWORD ref;
} WineD3D_Context;
#undef APIENTRY
#undef CALLBACK
#undef WINAPI
/* Redefines the constants */
#define CALLBACK __stdcall
#define WINAPI __stdcall
#define APIENTRY WINAPI
#endif /* HAVE_OPENGL */
#endif /* __WINE_WINED3D_GL */

View File

@ -80,6 +80,7 @@ DECLARE_INTERFACE_(IWineD3D,IUnknown)
STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter, D3DDEVTYPE CheckType, D3DFORMAT DisplayFormat, D3DFORMAT BackBufferFormat, BOOL Windowed) PURE;
STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT AdapterFormat, DWORD Usage, D3DRESOURCETYPE RType, D3DFORMAT CheckFormat) PURE;
STDMETHOD(CheckDeviceFormatConversion)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, D3DFORMAT SourceFormat, D3DFORMAT TargetFormat) PURE;
STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter, D3DDEVTYPE DeviceType, void * pCaps) PURE;
};
#undef INTERFACE
@ -101,6 +102,7 @@ DECLARE_INTERFACE_(IWineD3D,IUnknown)
#define IWineD3D_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e)
#define IWineD3D_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f)
#define IWineD3D_CheckDeviceFormatConversion(p,a,b,c,d) (p)->lpVtbl->CheckDeviceFormatConversion(p,a,b,c,d)
#define IWineD3D_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c)
#endif
/* Define the main WineD3D entrypoint */