Commit 243ac3ed authored by Roderick Colenbrander's avatar Roderick Colenbrander Committed by Alexandre Julliard

wined3d: Move video memory tracking to the adapter.

parent 5ab977e2
...@@ -99,7 +99,7 @@ static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3 ...@@ -99,7 +99,7 @@ static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3
*pp##type = NULL; \ *pp##type = NULL; \
return WINED3DERR_OUTOFVIDEOMEMORY; \ return WINED3DERR_OUTOFVIDEOMEMORY; \
} \ } \
globalChangeGlRam(_size); \ WineD3DAdapterChangeGLRam(This, _size); \
} \ } \
object->resource.allocatedMemory = (0 == _size ? NULL : Pool == WINED3DPOOL_DEFAULT ? NULL : HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, _size)); \ object->resource.allocatedMemory = (0 == _size ? NULL : Pool == WINED3DPOOL_DEFAULT ? NULL : HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, _size)); \
if (object->resource.allocatedMemory == NULL && _size != 0 && Pool != WINED3DPOOL_DEFAULT) { \ if (object->resource.allocatedMemory == NULL && _size != 0 && Pool != WINED3DPOOL_DEFAULT) { \
...@@ -2295,24 +2295,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDirect3D(IWineD3DDevice *iface, IWin ...@@ -2295,24 +2295,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDirect3D(IWineD3DDevice *iface, IWin
} }
static UINT WINAPI IWineD3DDeviceImpl_GetAvailableTextureMem(IWineD3DDevice *iface) { static UINT WINAPI IWineD3DDeviceImpl_GetAvailableTextureMem(IWineD3DDevice *iface) {
/** NOTE: There's a probably a hack-around for this one by putting as many pbuffers, VBOs (or whatever)
* into the video ram as possible and seeing how many fit
* you can also get the correct initial value from nvidia and ATI's driver via X
* texture memory is video memory + AGP memory
*******************/
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
static BOOL showfixmes = TRUE;
if (showfixmes) {
FIXME("(%p) : stub, simulating %dMB for now, returning %dMB left\n", This,
(wined3d_settings.emulated_textureram/(1024*1024)),
((wined3d_settings.emulated_textureram - wineD3DGlobalStatistics->glsurfaceram) / (1024*1024)));
showfixmes = FALSE;
}
TRACE("(%p) : simulating %dMB, returning %dMB left\n", This, TRACE("(%p) : simulating %dMB, returning %dMB left\n", This,
(wined3d_settings.emulated_textureram/(1024*1024)), (This->adapter->TextureRam/(1024*1024)),
((wined3d_settings.emulated_textureram - wineD3DGlobalStatistics->glsurfaceram) / (1024*1024))); ((This->adapter->TextureRam - This->adapter->UsedTextureRam) / (1024*1024)));
/* return simulated texture memory left */ /* return simulated texture memory left */
return (wined3d_settings.emulated_textureram - wineD3DGlobalStatistics->glsurfaceram); return (This->adapter->TextureRam - This->adapter->UsedTextureRam);
} }
......
...@@ -277,6 +277,14 @@ static BOOL WineD3D_CreateFakeGLContext(void) { ...@@ -277,6 +277,14 @@ static BOOL WineD3D_CreateFakeGLContext(void) {
return FALSE; return FALSE;
} }
/* Adjust the amount of used texture memory */
long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram){
UINT Adapter = D3DDevice->adapterNo;
Adapters[Adapter].UsedTextureRam += glram;
TRACE("Adjusted gl ram by %ld to %d\n", glram, Adapters[Adapter].UsedTextureRam);
return Adapters[Adapter].UsedTextureRam;
}
/********************************************************** /**********************************************************
* IUnknown parts follows * IUnknown parts follows
...@@ -1034,16 +1042,11 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) { ...@@ -1034,16 +1042,11 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
} }
TRACE("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", gl_info->gl_vendor, gl_info->gl_card); TRACE("FOUND (fake) card: 0x%x (vendor id), 0x%x (device id)\n", gl_info->gl_vendor, gl_info->gl_card);
/* Unless VideoMemorySize is set in the registry, the default is 0 /* If we have an estimate use it, else default to 64MB; */
* TODO: put emulated_textureram in the device */ if(vidmem)
if(wined3d_settings.emulated_textureram == 0) { gl_info->vidmem = vidmem*1024*1024; /* convert from MBs to bytes */
/* If we have an estimate use it, else default to 64MB */ else
if(vidmem) gl_info->vidmem = WINE_DEFAULT_VIDMEM;
wined3d_settings.emulated_textureram = vidmem*1024*1024; /* convert from MBs to bytes */
else
wined3d_settings.emulated_textureram = WINE_DEFAULT_VIDMEM;
TRACE("Emulating %d MB of texture memory\n", wined3d_settings.emulated_textureram);
}
/* Load all the lookup tables /* Load all the lookup tables
TODO: It may be a good idea to make minLookup and maxLookup const and populate them in wined3d_private.h where they are declared */ TODO: It may be a good idea to make minLookup and maxLookup const and populate them in wined3d_private.h where they are declared */
...@@ -2743,6 +2746,14 @@ BOOL InitAdapters(void) { ...@@ -2743,6 +2746,14 @@ BOOL InitAdapters(void) {
Adapters[0].driver = "Display"; Adapters[0].driver = "Display";
Adapters[0].description = "Direct3D HAL"; Adapters[0].description = "Direct3D HAL";
/* Use the VideoRamSize registry setting when set */
if(wined3d_settings.emulated_textureram)
Adapters[0].TextureRam = wined3d_settings.emulated_textureram;
else
Adapters[0].TextureRam = Adapters[0].gl_info.vidmem;
Adapters[0].UsedTextureRam = 0;
TRACE("Emulating %dMB of texture ram\n", Adapters[0].TextureRam);
/* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */ /* Initialize the Adapter's DeviceName which is required for ChangeDisplaySettings and friends */
DisplayDevice.cb = sizeof(DisplayDevice); DisplayDevice.cb = sizeof(DisplayDevice);
EnumDisplayDevicesW(NULL, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice, 0); EnumDisplayDevicesW(NULL, 0 /* Adapter 0 = iDevNum 0 */, &DisplayDevice, 0);
......
...@@ -71,7 +71,7 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){ ...@@ -71,7 +71,7 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
TRACE("(%p) Cleaning up resource\n", This); TRACE("(%p) Cleaning up resource\n", This);
if (This->resource.pool == WINED3DPOOL_DEFAULT) { if (This->resource.pool == WINED3DPOOL_DEFAULT) {
TRACE("Decrementing device memory pool by %u\n", This->resource.size); TRACE("Decrementing device memory pool by %u\n", This->resource.size);
globalChangeGlRam(-This->resource.size); WineD3DAdapterChangeGLRam(This->resource.wineD3DDevice, -This->resource.size);
} }
LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData) { LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData) {
......
...@@ -46,19 +46,6 @@ wined3d_settings_t wined3d_settings = ...@@ -46,19 +46,6 @@ wined3d_settings_t wined3d_settings =
NULL /* No wine logo by default */ NULL /* No wine logo by default */
}; };
WineD3DGlobalStatistics *wineD3DGlobalStatistics = NULL;
long globalChangeGlRam(long glram){
/* FIXME: replace this function with object tracking */
int result;
wineD3DGlobalStatistics->glsurfaceram += glram;
TRACE("Adjusted gl ram by %ld to %d\n", glram, wineD3DGlobalStatistics->glsurfaceram);
result = wineD3DGlobalStatistics->glsurfaceram;
return result;
}
IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent) { IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent) {
IWineD3DImpl* object; IWineD3DImpl* object;
...@@ -76,13 +63,6 @@ IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *p ...@@ -76,13 +63,6 @@ IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *p
object->ref = 1; object->ref = 1;
object->parent = parent; object->parent = parent;
/*Create a structure for storing global data in*/
if(wineD3DGlobalStatistics == NULL){
TRACE("Creating global statistics store\n");
wineD3DGlobalStatistics = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wineD3DGlobalStatistics));
}
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;
......
...@@ -326,23 +326,6 @@ typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl; ...@@ -326,23 +326,6 @@ typedef struct IWineD3DSurfaceImpl IWineD3DSurfaceImpl;
typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl; typedef struct IWineD3DPaletteImpl IWineD3DPaletteImpl;
typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl; typedef struct IWineD3DDeviceImpl IWineD3DDeviceImpl;
/* Tracking */
/* TODO: Move some of this to the device */
long globalChangeGlRam(long glram);
/* Memory and object tracking */
/*Structure for holding information on all direct3d objects
useful for making sure tracking is ok and when release is called on a device!
and probably quite handy for debugging and dumping states out
*/
typedef struct WineD3DGlobalStatistics {
int glsurfaceram; /* The aproximate amount of glTexture memory allocated for textures */
} WineD3DGlobalStatistics;
extern WineD3DGlobalStatistics* wineD3DGlobalStatistics;
/* Global variables */ /* Global variables */
extern const float identity[16]; extern const float identity[16];
...@@ -597,10 +580,13 @@ struct WineD3DAdapter ...@@ -597,10 +580,13 @@ struct WineD3DAdapter
WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */ WCHAR DeviceName[CCHDEVICENAME]; /* DeviceName for use with e.g. ChangeDisplaySettings */
int nCfgs; int nCfgs;
WineD3D_PixelFormat *cfgs; WineD3D_PixelFormat *cfgs;
unsigned int TextureRam; /* Amount of texture memory both video ram + AGP/TurboCache/HyperMemory/.. */
unsigned int UsedTextureRam;
}; };
extern BOOL InitAdapters(void); extern BOOL InitAdapters(void);
extern BOOL initPixelFormats(WineD3D_GL_Info *gl_info); extern BOOL initPixelFormats(WineD3D_GL_Info *gl_info);
extern long WineD3DAdapterChangeGLRam(IWineD3DDeviceImpl *D3DDevice, long glram);
/***************************************************************************** /*****************************************************************************
* High order patch management * High order patch management
......
...@@ -3702,6 +3702,7 @@ typedef struct _WineD3D_GL_Info { ...@@ -3702,6 +3702,7 @@ typedef struct _WineD3D_GL_Info {
GL_Vendors gl_vendor; GL_Vendors gl_vendor;
GL_Cards gl_card; GL_Cards gl_card;
UINT vidmem;
DWORD gl_driver_version; DWORD gl_driver_version;
CHAR gl_renderer[255]; CHAR gl_renderer[255];
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment