wined3d: Store the gl information in a per adapter structure and initialize it only once.

This commit is contained in:
Stefan Dösinger 2007-06-09 14:27:41 +02:00 committed by Alexandre Julliard
parent 6089fe8667
commit a460a2df43
22 changed files with 131 additions and 128 deletions

View File

@ -104,7 +104,7 @@ void shader_arb_load_constants(
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock; IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl*)deviceImpl->wineD3D)->gl_info; WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
if (useVertexShader) { if (useVertexShader) {
IWineD3DBaseShaderImpl* vshader = (IWineD3DBaseShaderImpl*) stateBlock->vertexShader; IWineD3DBaseShaderImpl* vshader = (IWineD3DBaseShaderImpl*) stateBlock->vertexShader;
@ -383,7 +383,7 @@ static void shader_hw_sample(SHADER_OPCODE_ARG* arg, DWORD sampler_idx, const ch
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader; IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler_idx]; IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler_idx];
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(((IWineD3DDeviceImpl *)(This->baseShader.device))->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
SHADER_BUFFER* buffer = arg->buffer; SHADER_BUFFER* buffer = arg->buffer;
DWORD sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK; DWORD sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
@ -1033,7 +1033,7 @@ static GLuint create_arb_blt_fragment_program(WineD3D_GL_Info *gl_info) {
static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) { static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
if (useVS) { if (useVS) {
TRACE("Using vertex shader\n"); TRACE("Using vertex shader\n");
@ -1074,7 +1074,7 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
static void shader_arb_select_depth_blt(IWineD3DDevice *iface) { static void shader_arb_select_depth_blt(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
static GLuint vprogram_id = 0; static GLuint vprogram_id = 0;
static GLuint fprogram_id = 0; static GLuint fprogram_id = 0;
@ -1089,7 +1089,7 @@ static void shader_arb_select_depth_blt(IWineD3DDevice *iface) {
static void shader_arb_cleanup(IWineD3DDevice *iface) { static void shader_arb_cleanup(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
if (GL_SUPPORT(ARB_VERTEX_PROGRAM)) glDisable(GL_VERTEX_PROGRAM_ARB); if (GL_SUPPORT(ARB_VERTEX_PROGRAM)) glDisable(GL_VERTEX_PROGRAM_ARB);
if (GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) glDisable(GL_FRAGMENT_PROGRAM_ARB); if (GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) glDisable(GL_FRAGMENT_PROGRAM_ARB);
} }

View File

@ -24,7 +24,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static const Wined3dTextureStateMap textureObjectSamplerStates[] = { static const Wined3dTextureStateMap textureObjectSamplerStates[] = {
{WINED3DSAMP_ADDRESSU, WINED3DSAMP_ADDRESSU}, {WINED3DSAMP_ADDRESSU, WINED3DSAMP_ADDRESSU},

View File

@ -27,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info #define GLINFO_LOCATION This->adapter->gl_info
/***************************************************************************** /*****************************************************************************
* Context_MarkStateDirty * Context_MarkStateDirty

View File

@ -24,7 +24,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static const GLenum cube_targets[6] = { static const GLenum cube_targets[6] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,

View File

@ -33,7 +33,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info #define GLINFO_LOCATION This->adapter->gl_info
/* Define the default light parameters as specified by MSDN */ /* Define the default light parameters as specified by MSDN */
const WINED3DLIGHT WINED3D_default_light = { const WINED3DLIGHT WINED3D_default_light = {
@ -1855,12 +1855,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPR
/* Set up some starting GL setup */ /* Set up some starting GL setup */
ENTER_GL(); ENTER_GL();
/*
* Initialize openGL extension related variables
* with Default values
*/
((IWineD3DImpl *) This->wineD3D)->isGLInfoValid = IWineD3DImpl_FillGLCaps(This->wineD3D, swapchain->context[0]->display);
/* Setup all the devices defaults */ /* Setup all the devices defaults */
IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *)This->stateBlock); IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *)This->stateBlock);
#if 0 #if 0

View File

@ -35,7 +35,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_caps); WINE_DECLARE_DEBUG_CHANNEL(d3d_caps);
#define GLINFO_LOCATION This->gl_info
/********************************************************** /**********************************************************
* Utility functions follow * Utility functions follow
@ -61,6 +60,10 @@ static inline Display *get_display( HDC hdc )
return display; return display;
} }
/* Adapters */
static int numAdapters = 0;
static struct WineD3DAdapter Adapters[1];
/* lookup tables */ /* lookup tables */
int minLookup[MAX_LOOKUPS]; int minLookup[MAX_LOOKUPS];
int maxLookup[MAX_LOOKUPS]; int maxLookup[MAX_LOOKUPS];
@ -314,10 +317,8 @@ static void select_shader_max_constants(
* IWineD3D parts follows * IWineD3D parts follows
**********************************************************/ **********************************************************/
BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) { #define GLINFO_LOCATION (*gl_info)
IWineD3DImpl *This = (IWineD3DImpl *)iface; BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display) {
WineD3D_GL_Info *gl_info = &This->gl_info;
const char *GL_Extensions = NULL; const char *GL_Extensions = NULL;
const char *GLX_Extensions = NULL; const char *GLX_Extensions = NULL;
const char *gl_string = NULL; const char *gl_string = NULL;
@ -1072,6 +1073,7 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) {
WineD3D_ReleaseFakeGLContext(); WineD3D_ReleaseFakeGLContext();
return return_value; return return_value;
} }
#undef GLINFO_LOCATION
/********************************************************** /**********************************************************
* IWineD3D implementation follows * IWineD3D implementation follows
@ -1080,9 +1082,8 @@ BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display) {
static UINT WINAPI IWineD3DImpl_GetAdapterCount (IWineD3D *iface) { static UINT WINAPI IWineD3DImpl_GetAdapterCount (IWineD3D *iface) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
/* FIXME: Set to one for now to imply the display */ TRACE_(d3d_caps)("(%p): Reporting %d adapters\n", This, numAdapters);
TRACE_(d3d_caps)("(%p): Mostly stub, only returns primary display\n", This); return numAdapters;
return 1;
} }
static HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice(IWineD3D *iface, void* pInitializeFunction) { static HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice(IWineD3D *iface, void* pInitializeFunction) {
@ -1093,14 +1094,13 @@ static HRESULT WINAPI IWineD3DImpl_RegisterSoftwareDevice(IWineD3D *iface, void
static HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter) { static HMONITOR WINAPI IWineD3DImpl_GetAdapterMonitor(IWineD3D *iface, UINT Adapter) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
POINT pt = { -1, -1 };
if (Adapter >= IWineD3DImpl_GetAdapterCount(iface)) { if (Adapter >= IWineD3DImpl_GetAdapterCount(iface)) {
return NULL; return NULL;
} }
FIXME_(d3d_caps)("(%p): returning the primary monitor for adapter %d\n", This, Adapter); TRACE_(d3d_caps)("(%p)->(%d)\n", This, Adapter);
return MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); return MonitorFromPoint(Adapters[Adapter].monitorPoint, MONITOR_DEFAULTTOPRIMARY);
} }
/* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes /* FIXME: GetAdapterModeCount and EnumAdapterModes currently only returns modes
@ -1115,6 +1115,7 @@ static UINT WINAPI IWineD3DImpl_GetAdapterModeCount(IWineD3D *iface, UINT Ad
return 0; return 0;
} }
/* TODO: Store modes per adapter and read it from the adapter structure */
if (Adapter == 0) { /* Display */ if (Adapter == 0) { /* Display */
int i = 0; int i = 0;
int j = 0; int j = 0;
@ -1170,6 +1171,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
/* TODO: Store modes per adapter and read it from the adapter structure */
if (Adapter == 0 && !DEBUG_SINGLE_MODE) { /* Display */ if (Adapter == 0 && !DEBUG_SINGLE_MODE) { /* Display */
DEVMODEW DevModeW; DEVMODEW DevModeW;
int ModeIdx = 0; int ModeIdx = 0;
@ -1300,18 +1302,6 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterDisplayMode(IWineD3D *iface, UINT A
return WINED3D_OK; return WINED3D_OK;
} }
static Display * WINAPI IWineD3DImpl_GetAdapterDisplay(IWineD3D *iface, UINT Adapter) {
Display *display;
HDC device_context;
/* only works with one adapter at the moment... */
/* Get the display */
device_context = GetDC(0);
display = get_display(device_context);
ReleaseDC(0, device_context);
return display;
}
/* NOTE: due to structure differences between dx8 and dx9 D3DADAPTER_IDENTIFIER, /* 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 */ 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, static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Adapter, DWORD Flags,
@ -1324,42 +1314,26 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Ad
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if (Adapter == 0) { /* Display - only device supported for now */ /* Return the information requested */
TRACE_(d3d_caps)("device/Vendor Name and Version detection using FillGLCaps\n");
strcpy(pIdentifier->Driver, "Display");
strcpy(pIdentifier->Description, "Direct3D HAL");
BOOL isGLInfoValid = This->isGLInfoValid; /* Note dx8 doesn't supply a DeviceName */
if (NULL != pIdentifier->DeviceName) strcpy(pIdentifier->DeviceName, "\\\\.\\DISPLAY"); /* FIXME: May depend on desktop? */
/* FillGLCaps updates gl_info, but we only want to store and /* Current Windows drivers have versions like 6.14.... (some older have an earlier version) */
reuse the values once we have a context which is valid. Values from pIdentifier->DriverVersion->u.HighPart = MAKEDWORD_VERSION(6, 14);
a temporary context may differ from the final ones */ pIdentifier->DriverVersion->u.LowPart = Adapters[Adapter].gl_info.gl_driver_version;
if (!isGLInfoValid) { *(pIdentifier->VendorId) = Adapters[Adapter].gl_info.gl_vendor;
/* If we don't know the device settings, go query them now */ *(pIdentifier->DeviceId) = Adapters[Adapter].gl_info.gl_card;
isGLInfoValid = IWineD3DImpl_FillGLCaps(iface, IWineD3DImpl_GetAdapterDisplay(iface, Adapter)); *(pIdentifier->SubSysId) = 0;
} *(pIdentifier->Revision) = 0;
/* Return the information requested */
TRACE_(d3d_caps)("device/Vendor Name and Version detection using FillGLCaps\n");
strcpy(pIdentifier->Driver, "Display");
strcpy(pIdentifier->Description, "Direct3D HAL");
/* 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 = This->gl_info.gl_driver_version;
*(pIdentifier->VendorId) = This->gl_info.gl_vendor;
*(pIdentifier->DeviceId) = This->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;
}
/*FIXME: memcpy(&pIdentifier->DeviceIdentifier, ??, sizeof(??GUID)); */
if (Flags & WINED3DENUM_NO_WHQL_LEVEL) {
*(pIdentifier->WHQLLevel) = 0;
} else { } else {
FIXME_(d3d_caps)("Adapter not primary display\n"); *(pIdentifier->WHQLLevel) = 1;
} }
return WINED3D_OK; return WINED3D_OK;
@ -1512,6 +1486,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
/* TODO: Store an array in the adapter */
if(WineD3D_CreateFakeGLContext()) if(WineD3D_CreateFakeGLContext())
cfgs = glXGetFBConfigs(wined3d_fake_gl_context_display, DefaultScreen(wined3d_fake_gl_context_display), &nCfgs); cfgs = glXGetFBConfigs(wined3d_fake_gl_context_display, DefaultScreen(wined3d_fake_gl_context_display), &nCfgs);
@ -1559,6 +1534,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
/* TODO: Store in Adapter structure */
if (pQualityLevels != NULL) { if (pQualityLevels != NULL) {
static int s_single_shot = 0; static int s_single_shot = 0;
if (!s_single_shot) { if (!s_single_shot) {
@ -1594,6 +1570,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
/* TODO: Store in adapter structure */
if (WineD3D_CreateFakeGLContext()) { if (WineD3D_CreateFakeGLContext()) {
cfgs = glXGetFBConfigs(wined3d_fake_gl_context_display, DefaultScreen(wined3d_fake_gl_context_display), &nCfgs); cfgs = glXGetFBConfigs(wined3d_fake_gl_context_display, DefaultScreen(wined3d_fake_gl_context_display), &nCfgs);
for (it = 0; it < nCfgs; ++it) { for (it = 0; it < nCfgs; ++it) {
@ -1615,6 +1592,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter
return hr; return hr;
} }
#define GLINFO_LOCATION Adapters[Adapter].gl_info
static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType, static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapter, WINED3DDEVTYPE DeviceType,
WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) { WINED3DFORMAT AdapterFormat, DWORD Usage, WINED3DRESOURCETYPE RType, WINED3DFORMAT CheckFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
@ -1923,21 +1901,11 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
/* FIXME: GL info should be per adapter */ select_shader_mode(&Adapters[Adapter].gl_info, DeviceType, &ps_selected_mode, &vs_selected_mode);
/* If we don't know the device settings, go query them now */
if (!This->isGLInfoValid) {
/* use the desktop window to fill gl caps */
BOOL rc = IWineD3DImpl_FillGLCaps(iface, IWineD3DImpl_GetAdapterDisplay(iface, Adapter));
/* We are running off a real context, save the values */
if (rc) This->isGLInfoValid = TRUE;
}
select_shader_mode(&This->gl_info, DeviceType, &ps_selected_mode, &vs_selected_mode);
/* This function should *not* be modifying GL caps /* This function should *not* be modifying GL caps
* TODO: move the functionality where it belongs */ * TODO: move the functionality where it belongs */
select_shader_max_constants(ps_selected_mode, vs_selected_mode, &This->gl_info); select_shader_max_constants(ps_selected_mode, vs_selected_mode, &Adapters[Adapter].gl_info);
/* ------------------------------------------------ /* ------------------------------------------------
The following fields apply to both d3d8 and d3d9 The following fields apply to both d3d8 and d3d9
@ -2312,7 +2280,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support using models with GLSL support only support 2.0. In case of nvidia we can detect VS 2.0 support using
vs_nv_version which is based on NV_vertex_program. For Ati cards there's no easy way, so for vs_nv_version which is based on NV_vertex_program. For Ati cards there's no easy way, so for
now only support 2.0/3.0 detection on Nvidia GeforceFX cards and default to 3.0 for everything else */ now only support 2.0/3.0 detection on Nvidia GeforceFX cards and default to 3.0 for everything else */
if(This->gl_info.vs_nv_version == VS_VERSION_20) if(GLINFO_LOCATION.vs_nv_version == VS_VERSION_20)
*pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0); *pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0);
else else
*pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0); *pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0);
@ -2330,7 +2298,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
if (ps_selected_mode == SHADER_GLSL) { if (ps_selected_mode == SHADER_GLSL) {
/* See the comment about VS2.0/VS3.0 detection as we do the same here but then based on NV_fragment_program /* See the comment about VS2.0/VS3.0 detection as we do the same here but then based on NV_fragment_program
in case of GeforceFX cards. */ in case of GeforceFX cards. */
if(This->gl_info.ps_nv_version == PS_VERSION_20) if(GLINFO_LOCATION.ps_nv_version == PS_VERSION_20)
*pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0); *pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0);
else else
*pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0); *pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0);
@ -2391,15 +2359,15 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
use the VS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum VS3.0 value. */ use the VS 3.0 from MSDN or else if there's OpenGL spec use a hardcoded value minimum VS3.0 value. */
*pCaps->VS20Caps.Caps = WINED3DVS20CAPS_PREDICATION; *pCaps->VS20Caps.Caps = WINED3DVS20CAPS_PREDICATION;
*pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */ *pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* VS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
*pCaps->VS20Caps.NumTemps = max(32, This->gl_info.vs_arb_max_temps); *pCaps->VS20Caps.NumTemps = max(32, GLINFO_LOCATION.vs_arb_max_temps);
*pCaps->VS20Caps.StaticFlowControlDepth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH ; /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */ *pCaps->VS20Caps.StaticFlowControlDepth = WINED3DVS20_MAX_STATICFLOWCONTROLDEPTH ; /* level of nesting in loops / if-statements; VS 3.0 requires MAX (4) */
*pCaps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */ *pCaps->MaxVShaderInstructionsExecuted = 65535; /* VS 3.0 needs at least 65535, some cards even use 2^32-1 */
*pCaps->MaxVertexShader30InstructionSlots = max(512, This->gl_info.vs_arb_max_instructions); *pCaps->MaxVertexShader30InstructionSlots = max(512, GLINFO_LOCATION.vs_arb_max_instructions);
} else if(*pCaps->VertexShaderVersion == WINED3DVS_VERSION(2,0)) { } else if(*pCaps->VertexShaderVersion == WINED3DVS_VERSION(2,0)) {
*pCaps->VS20Caps.Caps = 0; *pCaps->VS20Caps.Caps = 0;
*pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH; *pCaps->VS20Caps.DynamicFlowControlDepth = WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH;
*pCaps->VS20Caps.NumTemps = max(12, This->gl_info.vs_arb_max_temps); *pCaps->VS20Caps.NumTemps = max(12, GLINFO_LOCATION.vs_arb_max_temps);
*pCaps->VS20Caps.StaticFlowControlDepth = 1; *pCaps->VS20Caps.StaticFlowControlDepth = 1;
*pCaps->MaxVShaderInstructionsExecuted = 65535; *pCaps->MaxVShaderInstructionsExecuted = 65535;
@ -2425,17 +2393,17 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter,
WINED3DPS20CAPS_NODEPENDENTREADLIMIT | WINED3DPS20CAPS_NODEPENDENTREADLIMIT |
WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT; WINED3DPS20CAPS_NOTEXINSTRUCTIONLIMIT;
*pCaps->PS20Caps.DynamicFlowControlDepth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */ *pCaps->PS20Caps.DynamicFlowControlDepth = WINED3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_DYNAMICFLOWCONTROLDEPTH (24) */
*pCaps->PS20Caps.NumTemps = max(32, This->gl_info.ps_arb_max_temps); *pCaps->PS20Caps.NumTemps = max(32, GLINFO_LOCATION.ps_arb_max_temps);
*pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */ *pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MAX_STATICFLOWCONTROLDEPTH; /* PS 3.0 requires MAX_STATICFLOWCONTROLDEPTH (4) */
*pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS; /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */ *pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MAX_NUMINSTRUCTIONSLOTS; /* PS 3.0 requires MAX_NUMINSTRUCTIONSLOTS (512) */
*pCaps->MaxPShaderInstructionsExecuted = 65535; *pCaps->MaxPShaderInstructionsExecuted = 65535;
*pCaps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS, This->gl_info.ps_arb_max_instructions); *pCaps->MaxPixelShader30InstructionSlots = max(WINED3DMIN30SHADERINSTRUCTIONS, GLINFO_LOCATION.ps_arb_max_instructions);
} else if(*pCaps->PixelShaderVersion == WINED3DPS_VERSION(2,0)) { } else if(*pCaps->PixelShaderVersion == WINED3DPS_VERSION(2,0)) {
/* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */ /* Below we assume PS2.0 specs, not extended 2.0a(GeforceFX)/2.0b(Radeon R3xx) ones */
*pCaps->PS20Caps.Caps = 0; *pCaps->PS20Caps.Caps = 0;
*pCaps->PS20Caps.DynamicFlowControlDepth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */ *pCaps->PS20Caps.DynamicFlowControlDepth = 0; /* WINED3DVS20_MIN_DYNAMICFLOWCONTROLDEPTH = 0 */
*pCaps->PS20Caps.NumTemps = max(12, This->gl_info.ps_arb_max_temps); *pCaps->PS20Caps.NumTemps = max(12, GLINFO_LOCATION.ps_arb_max_temps);
*pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minumum: 1 */ *pCaps->PS20Caps.StaticFlowControlDepth = WINED3DPS20_MIN_STATICFLOWCONTROLDEPTH; /* Minumum: 1 */
*pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS; /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */ *pCaps->PS20Caps.NumInstructionSlots = WINED3DPS20_MIN_NUMINSTRUCTIONSLOTS; /* Minimum number (64 ALU + 32 Texture), a GeforceFX uses 512 */
@ -2505,6 +2473,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
object->lpVtbl = &IWineD3DDevice_Vtbl; object->lpVtbl = &IWineD3DDevice_Vtbl;
object->ref = 1; object->ref = 1;
object->wineD3D = iface; object->wineD3D = iface;
object->adapter = &Adapters[Adapter];
IWineD3D_AddRef(object->wineD3D); IWineD3D_AddRef(object->wineD3D);
object->parent = parent; object->parent = parent;
@ -2538,12 +2507,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)object->updateStateBlock); IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)object->updateStateBlock);
/* Setup surfaces for the backbuffer, frontbuffer and depthstencil buffer */ /* Setup surfaces for the backbuffer, frontbuffer and depthstencil buffer */
/* Setup some defaults for creating the implicit swapchain */ select_shader_mode(&GLINFO_LOCATION, DeviceType, &object->ps_selected_mode, &object->vs_selected_mode);
ENTER_GL();
/* FIXME: GL info should be per adapter */
IWineD3DImpl_FillGLCaps(iface, IWineD3DImpl_GetAdapterDisplay(iface, Adapter));
LEAVE_GL();
select_shader_mode(&This->gl_info, DeviceType, &object->ps_selected_mode, &object->vs_selected_mode);
if (object->ps_selected_mode == SHADER_GLSL || object->vs_selected_mode == SHADER_GLSL) { if (object->ps_selected_mode == SHADER_GLSL || object->vs_selected_mode == SHADER_GLSL) {
object->shader_backend = &glsl_shader_backend; object->shader_backend = &glsl_shader_backend;
object->glsl_program_lookup = hash_table_create(&glsl_program_key_hash, &glsl_program_key_compare); object->glsl_program_lookup = hash_table_create(&glsl_program_key_hash, &glsl_program_key_compare);
@ -2555,7 +2519,7 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
/* This function should *not* be modifying GL caps /* This function should *not* be modifying GL caps
* TODO: move the functionality where it belongs */ * TODO: move the functionality where it belongs */
select_shader_max_constants(object->ps_selected_mode, object->vs_selected_mode, &This->gl_info); select_shader_max_constants(object->ps_selected_mode, object->vs_selected_mode, &GLINFO_LOCATION);
temp_result = allocate_shader_constants(object->updateStateBlock); temp_result = allocate_shader_constants(object->updateStateBlock);
if (WINED3D_OK != temp_result) if (WINED3D_OK != temp_result)
@ -2602,6 +2566,7 @@ create_device_error:
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
#undef GLINFO_LOCATION
static HRESULT WINAPI IWineD3DImpl_GetParent(IWineD3D *iface, IUnknown **pParent) { static HRESULT WINAPI IWineD3DImpl_GetParent(IWineD3D *iface, IUnknown **pParent) {
IWineD3DImpl *This = (IWineD3DImpl *)iface; IWineD3DImpl *This = (IWineD3DImpl *)iface;
@ -2630,6 +2595,40 @@ ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pVolume) {
return IUnknown_Release(volumeParent); return IUnknown_Release(volumeParent);
} }
BOOL InitAdapters(void) {
HDC device_context;
BOOL ret;
/* No need to hold any lock. The calling library makes sure only one thread calls
* wined3d simultaneously
*/
if(numAdapters > 0) return TRUE;
TRACE("Initializing adapters\n");
/* For now only one default adapter */
{
TRACE("Initializing default adapter\n");
Adapters[0].monitorPoint.x = -1;
Adapters[0].monitorPoint.y = -1;
device_context = GetDC(0);
Adapters[0].display = get_display(device_context);
ReleaseDC(0, device_context);
ret = IWineD3DImpl_FillGLCaps(&Adapters[0].gl_info, Adapters[0].display);
if(ret != TRUE) {
ERR("Failed to initialize gl caps for default adapter\n");
HeapFree(GetProcessHeap(), 0, Adapters);
return FALSE;
}
}
numAdapters = 1;
TRACE("%d adapters successfully initialized\n", numAdapters);
return TRUE;
}
/********************************************************** /**********************************************************
* IWineD3D VTbl follows * IWineD3D VTbl follows
**********************************************************/ **********************************************************/

View File

@ -27,7 +27,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw); WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info #define GLINFO_LOCATION This->adapter->gl_info
#include <stdio.h> #include <stdio.h>

View File

@ -287,7 +287,7 @@ void shader_glsl_load_constants(
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock; IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl*) deviceImpl->wineD3D)->gl_info; WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
GLhandleARB *constant_locations; GLhandleARB *constant_locations;
struct list *constant_list; struct list *constant_list;
@ -583,7 +583,7 @@ static void shader_glsl_get_register_name(
DWORD regtype = shader_get_regtype(param); DWORD regtype = shader_get_regtype(param);
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) arg->shader; IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) arg->shader;
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
WineD3D_GL_Info* gl_info = &((IWineD3DImpl*)deviceImpl->wineD3D)->gl_info; WineD3D_GL_Info* gl_info = &deviceImpl->adapter->gl_info;
char pshader = shader_is_pshader_version(This->baseShader.hex_version); char pshader = shader_is_pshader_version(This->baseShader.hex_version);
char tmpStr[50]; char tmpStr[50];
@ -2099,7 +2099,7 @@ static struct glsl_shader_prog_link *get_glsl_program_entry(IWineD3DDeviceImpl *
void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_link *entry) { void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_link *entry) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
glsl_program_key_t *key; glsl_program_key_t *key;
key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t)); key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t));
@ -2125,7 +2125,7 @@ void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_li
*/ */
static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) { static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
IWineD3DPixelShader *pshader = This->stateBlock->pixelShader; IWineD3DPixelShader *pshader = This->stateBlock->pixelShader;
IWineD3DVertexShader *vshader = This->stateBlock->vertexShader; IWineD3DVertexShader *vshader = This->stateBlock->vertexShader;
struct glsl_shader_prog_link *entry = NULL; struct glsl_shader_prog_link *entry = NULL;
@ -2250,7 +2250,7 @@ static GLhandleARB create_glsl_blt_shader(WineD3D_GL_Info *gl_info) {
static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) { static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
GLhandleARB program_id = 0; GLhandleARB program_id = 0;
if (useVS || usePS) set_glsl_shader_program(iface, usePS, useVS); if (useVS || usePS) set_glsl_shader_program(iface, usePS, useVS);
@ -2264,7 +2264,7 @@ static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
static void shader_glsl_select_depth_blt(IWineD3DDevice *iface) { static void shader_glsl_select_depth_blt(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
static GLhandleARB program_id = 0; static GLhandleARB program_id = 0;
static GLhandleARB loc = -1; static GLhandleARB loc = -1;
@ -2279,7 +2279,7 @@ static void shader_glsl_select_depth_blt(IWineD3DDevice *iface) {
static void shader_glsl_cleanup(IWineD3DDevice *iface) { static void shader_glsl_cleanup(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
GL_EXTCALL(glUseProgramObjectARB(0)); GL_EXTCALL(glUseProgramObjectARB(0));
} }

View File

@ -25,7 +25,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* ******************************************* /* *******************************************
IWineD3DIndexBuffer IUnknown parts follow IWineD3DIndexBuffer IUnknown parts follow

View File

@ -31,7 +31,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->baseShader.device)->wineD3D))->gl_info #define GLINFO_LOCATION ((IWineD3DDeviceImpl *) This->baseShader.device)->adapter->gl_info
#if 0 /* Must not be 1 in cvs version */ #if 0 /* Must not be 1 in cvs version */
# define PSTRACE(A) TRACE A # define PSTRACE(A) TRACE A

View File

@ -33,7 +33,7 @@
*/ */
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->wineD3DDevice->adapter->gl_info
/* ******************************************* /* *******************************************
IWineD3DQuery IUnknown parts follow IWineD3DQuery IUnknown parts follow

View File

@ -34,7 +34,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_shader); WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
#define GLINFO_LOCATION ((IWineD3DImpl *)(stateblock->wineD3DDevice->wineD3D))->gl_info #define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) { static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
/* Used for states which are not mapped to a gl state as-is, but used somehow different, /* Used for states which are not mapped to a gl state as-is, but used somehow different,

View File

@ -24,7 +24,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->wineD3DDevice->adapter->gl_info
/*************************************** /***************************************
* Stateblock helper functions follow * Stateblock helper functions follow

View File

@ -30,7 +30,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface); WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
typedef enum { typedef enum {
NO_CONVERSION, NO_CONVERSION,

View File

@ -24,7 +24,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* ******************************************* /* *******************************************
IWineD3DTexture IUnknown parts follow IWineD3DTexture IUnknown parts follow

View File

@ -27,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info #define GLINFO_LOCATION This->adapter->gl_info
/***************************************************************************** /*****************************************************************************
* Pixel format array * Pixel format array
@ -1217,7 +1217,6 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP
/* Setup the texture operations texture stage states */ /* Setup the texture operations texture stage states */
void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3) void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3)
{ {
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
GLenum src1, src2, src3; GLenum src1, src2, src3;
GLenum opr1, opr2, opr3; GLenum opr1, opr2, opr3;
GLenum comb_target; GLenum comb_target;
@ -2577,7 +2576,7 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) {
* FALSE otherwise * FALSE otherwise
* *
*********************************************************************/ *********************************************************************/
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->resource.wineD3DDevice->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) { BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) {
int x1 = Rect->left, x2 = Rect->right; int x1 = Rect->left, x2 = Rect->right;

View File

@ -24,7 +24,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
#define VB_MAXDECLCHANGES 100 /* After that number we stop converting */ #define VB_MAXDECLCHANGES 100 /* After that number we stop converting */
#define VB_RESETDECLCHANGE 1000 /* Reset the changecount after that number of draws */ #define VB_RESETDECLCHANGE 1000 /* Reset the changecount after that number of draws */

View File

@ -31,7 +31,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->baseShader.device)->wineD3D))->gl_info #define GLINFO_LOCATION ((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info
/* Shader debugging - Change the following line to enable debugging of software /* Shader debugging - Change the following line to enable debugging of software
vertex shaders */ vertex shaders */

View File

@ -24,7 +24,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* ******************************************* /* *******************************************
IWineD3DVolume IUnknown parts follow IWineD3DVolume IUnknown parts follow

View File

@ -24,7 +24,7 @@
#include "wined3d_private.h" #include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d); WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info #define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* ******************************************* /* *******************************************
IWineD3DTexture IUnknown parts follow IWineD3DTexture IUnknown parts follow

View File

@ -59,7 +59,14 @@ long globalChangeGlRam(long glram){
} }
IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent) { IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent) {
IWineD3DImpl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl)); IWineD3DImpl* object;
if (!InitAdapters()) {
ERR("Failed to initialize direct3d adapters\n");
return NULL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
object->lpVtbl = &IWineD3D_Vtbl; object->lpVtbl = &IWineD3D_Vtbl;
object->dxVersion = dxVersion; object->dxVersion = dxVersion;
object->ref = 1; object->ref = 1;
@ -72,7 +79,6 @@ IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *p
} }
TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion); TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
return (IWineD3D *)object; return (IWineD3D *)object;

View File

@ -537,9 +537,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context); void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context);
void apply_fbo_state(IWineD3DDevice *iface); void apply_fbo_state(IWineD3DDevice *iface);
/* Routine to fill gl caps for swapchains and IWineD3D */
BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display);
/* Macros for doing basic GPU detection based on opengl capabilities */ /* Macros for doing basic GPU detection based on opengl capabilities */
#define WINE_D3D6_CAPABLE(gl_info) (gl_info->supported[ARB_MULTITEXTURE]) #define WINE_D3D6_CAPABLE(gl_info) (gl_info->supported[ARB_MULTITEXTURE])
#define WINE_D3D7_CAPABLE(gl_info) (gl_info->supported[ARB_TEXTURE_COMPRESSION] && gl_info->supported[ARB_TEXTURE_CUBE_MAP] && gl_info->supported[ARB_TEXTURE_ENV_DOT3]) #define WINE_D3D7_CAPABLE(gl_info) (gl_info->supported[ARB_TEXTURE_COMPRESSION] && gl_info->supported[ARB_TEXTURE_CUBE_MAP] && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
@ -574,6 +571,16 @@ struct PLIGHTINFOEL {
/* The default light parameters */ /* The default light parameters */
extern const WINED3DLIGHT WINED3D_default_light; extern const WINED3DLIGHT WINED3D_default_light;
/* The adapter structure */
struct WineD3DAdapter
{
POINT monitorPoint;
Display *display;
WineD3D_GL_Info gl_info;
};
extern BOOL InitAdapters(void);
/***************************************************************************** /*****************************************************************************
* IWineD3D implementation structure * IWineD3D implementation structure
*/ */
@ -586,10 +593,6 @@ typedef struct IWineD3DImpl
/* WineD3D Information */ /* WineD3D Information */
IUnknown *parent; IUnknown *parent;
UINT dxVersion; UINT dxVersion;
/* GL Information */
BOOL isGLInfoValid;
WineD3D_GL_Info gl_info;
} IWineD3DImpl; } IWineD3DImpl;
extern const IWineD3DVtbl IWineD3D_Vtbl; extern const IWineD3DVtbl IWineD3D_Vtbl;
@ -620,6 +623,7 @@ struct IWineD3DDeviceImpl
/* WineD3D Information */ /* WineD3D Information */
IUnknown *parent; IUnknown *parent;
IWineD3D *wineD3D; IWineD3D *wineD3D;
struct WineD3DAdapter *adapter;
/* Window styles to restore when switching fullscreen mode */ /* Window styles to restore when switching fullscreen mode */
LONG style; LONG style;