=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: d3d: d3d9ex does not do video memory accounting for D3DPOOL_DEFAULT resources.
Alexandre Julliard
julliard at winehq.org
Mon May 20 15:13:57 CDT 2013
Module: wine
Branch: master
Commit: 9287bb80dc974235d43d5ee4fadc86e1a11dbfeb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9287bb80dc974235d43d5ee4fadc86e1a11dbfeb
Author: Stefan Dösinger <stefan at codeweavers.com>
Date: Sun May 19 23:13:30 2013 +0200
d3d: d3d9ex does not do video memory accounting for D3DPOOL_DEFAULT resources.
---
dlls/d3d8/directx.c | 4 +++-
dlls/d3d9/directx.c | 3 ++-
dlls/ddraw/ddraw.c | 2 +-
dlls/wined3d/resource.c | 7 +++++--
include/wine/wined3d.h | 1 +
5 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/dlls/d3d8/directx.c b/dlls/d3d8/directx.c
index 61d187d..4aac722 100644
--- a/dlls/d3d8/directx.c
+++ b/dlls/d3d8/directx.c
@@ -404,11 +404,13 @@ static const struct IDirect3D8Vtbl d3d8_vtbl =
BOOL d3d8_init(struct d3d8 *d3d8)
{
+ DWORD flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING;
+
d3d8->IDirect3D8_iface.lpVtbl = &d3d8_vtbl;
d3d8->refcount = 1;
wined3d_mutex_lock();
- d3d8->wined3d = wined3d_create(8, WINED3D_LEGACY_DEPTH_BIAS);
+ d3d8->wined3d = wined3d_create(8, flags);
wined3d_mutex_unlock();
if (!d3d8->wined3d)
return FALSE;
diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c
index a335375..537e6af 100644
--- a/dlls/d3d9/directx.c
+++ b/dlls/d3d9/directx.c
@@ -632,11 +632,12 @@ static const struct IDirect3D9ExVtbl d3d9_vtbl =
BOOL d3d9_init(struct d3d9 *d3d9, BOOL extended)
{
+ DWORD flags = extended ? 0 : WINED3D_VIDMEM_ACCOUNTING;
d3d9->IDirect3D9Ex_iface.lpVtbl = &d3d9_vtbl;
d3d9->refcount = 1;
wined3d_mutex_lock();
- d3d9->wined3d = wined3d_create(9, 0);
+ d3d9->wined3d = wined3d_create(9, flags);
wined3d_mutex_unlock();
if (!d3d9->wined3d)
return FALSE;
diff --git a/dlls/ddraw/ddraw.c b/dlls/ddraw/ddraw.c
index a459e5f..b2b637e 100644
--- a/dlls/ddraw/ddraw.c
+++ b/dlls/ddraw/ddraw.c
@@ -5234,7 +5234,7 @@ HRESULT ddraw_init(struct ddraw *ddraw, enum wined3d_device_type device_type)
ddraw->numIfaces = 1;
ddraw->ref7 = 1;
- flags = WINED3D_LEGACY_DEPTH_BIAS;
+ flags = WINED3D_LEGACY_DEPTH_BIAS | WINED3D_VIDMEM_ACCOUNTING;
if (DefaultSurfaceType != DDRAW_SURFACE_TYPE_OPENGL)
flags |= WINED3D_NO3D;
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index d784622..0e0678d 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -84,6 +84,8 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops)
{
+ const struct wined3d *d3d = device->wined3d;
+
resource->ref = 1;
resource->device = device;
resource->type = type;
@@ -124,7 +126,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
+ (RESOURCE_ALIGNMENT - 1)) & ~(RESOURCE_ALIGNMENT - 1));
/* Check that we have enough video ram left */
- if (pool == WINED3D_POOL_DEFAULT)
+ if (pool == WINED3D_POOL_DEFAULT && d3d->flags & WINED3D_VIDMEM_ACCOUNTING)
{
if (size > wined3d_device_get_available_texture_mem(device))
{
@@ -142,13 +144,14 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
void resource_cleanup(struct wined3d_resource *resource)
{
+ const struct wined3d *d3d = resource->device->wined3d;
struct private_data *data;
struct list *e1, *e2;
HRESULT hr;
TRACE("Cleaning up resource %p.\n", resource);
- if (resource->pool == WINED3D_POOL_DEFAULT)
+ if (resource->pool == WINED3D_POOL_DEFAULT && d3d->flags & WINED3D_VIDMEM_ACCOUNTING)
{
TRACE("Decrementing device memory pool by %u.\n", resource->size);
adapter_adjust_memory(resource->device->adapter, 0 - resource->size);
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 75cba55..27575bb 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1216,6 +1216,7 @@ enum wined3d_display_rotation
#define WINED3D_LEGACY_DEPTH_BIAS 0x00000001
#define WINED3D_NO3D 0x00000002
+#define WINED3D_VIDMEM_ACCOUNTING 0x00000004
#define WINED3D_RESZ_CODE 0x7fa05000
More information about the wine-cvs
mailing list