[PATCH 4/5] wined3d: Store the mipmap level in the volume (try 2)
Stefan Dösinger
stefan at codeweavers.com
Tue Aug 20 05:07:58 CDT 2013
Try 2: Pass the level through the creation functions instead of a
post-creation setter.
---
dlls/d3d10core/device.c | 8 +++++---
dlls/d3d8/d3d8_private.h | 3 ++-
dlls/d3d8/device.c | 6 +++---
dlls/d3d8/volume.c | 4 ++--
dlls/d3d9/d3d9_private.h | 3 ++-
dlls/d3d9/device.c | 6 +++---
dlls/d3d9/volume.c | 7 ++++---
dlls/wined3d/texture.c | 6 +++---
dlls/wined3d/volume.c | 21 +++++++++++++--------
dlls/wined3d/wined3d_private.h | 3 ++-
include/wine/wined3d.h | 6 +++---
11 files changed, 42 insertions(+), 31 deletions(-)
diff --git a/dlls/d3d10core/device.c b/dlls/d3d10core/device.c
index ba112d9..c40a353 100644
--- a/dlls/d3d10core/device.c
+++ b/dlls/d3d10core/device.c
@@ -1887,8 +1887,9 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
}
static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
- void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
- enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
+ void *container_parent, UINT width, UINT height, UINT depth, UINT level,
+ enum wined3d_format_id format, enum wined3d_pool pool, DWORD usage,
+ struct wined3d_volume **volume)
{
HRESULT hr;
@@ -1898,7 +1899,8 @@ static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *d
format, pool, usage, volume);
hr = wined3d_volume_create(device_from_wined3d_device_parent(device_parent)->wined3d_device,
- width, height, depth, usage, format, pool, NULL, &d3d10_subresource_parent_ops, volume);
+ width, height, depth, level, usage, format, pool, NULL, &d3d10_subresource_parent_ops,
+ volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);
diff --git a/dlls/d3d8/d3d8_private.h b/dlls/d3d8/d3d8_private.h
index 00a81e3..3663c82 100644
--- a/dlls/d3d8/d3d8_private.h
+++ b/dlls/d3d8/d3d8_private.h
@@ -184,7 +184,8 @@ struct d3d8_volume
};
HRESULT volume_init(struct d3d8_volume *volume, struct d3d8_device *device, UINT width, UINT height,
- UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool) DECLSPEC_HIDDEN;
+ UINT depth, UINT level, DWORD usage, enum wined3d_format_id format,
+ enum wined3d_pool pool) DECLSPEC_HIDDEN;
struct d3d8_swapchain
{
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c
index 2f09a4f..54d11bb 100644
--- a/dlls/d3d8/device.c
+++ b/dlls/d3d8/device.c
@@ -2961,8 +2961,8 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
}
static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
- void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
- enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
+ void *container_parent, UINT width, UINT height, UINT depth, UINT level,
+ enum wined3d_format_id format, enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
{
struct d3d8_device *device = device_from_device_parent(device_parent);
struct d3d8_volume *object;
@@ -2982,7 +2982,7 @@ static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *d
return D3DERR_OUTOFVIDEOMEMORY;
}
- hr = volume_init(object, device, width, height, depth, usage, format, pool);
+ hr = volume_init(object, device, width, height, depth, level, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume, hr %#x.\n", hr);
diff --git a/dlls/d3d8/volume.c b/dlls/d3d8/volume.c
index ecd4bb1..688dca1 100644
--- a/dlls/d3d8/volume.c
+++ b/dlls/d3d8/volume.c
@@ -284,14 +284,14 @@ static const struct wined3d_parent_ops d3d8_volume_wined3d_parent_ops =
};
HRESULT volume_init(struct d3d8_volume *volume, struct d3d8_device *device, UINT width, UINT height,
- UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool)
+ UINT depth, UINT level, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool)
{
HRESULT hr;
volume->IDirect3DVolume8_iface.lpVtbl = &d3d8_volume_vtbl;
volume->refcount = 1;
- hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage,
+ hr = wined3d_volume_create(device->wined3d_device, width, height, depth, level, usage,
format, pool, volume, &d3d8_volume_wined3d_parent_ops, &volume->wined3d_volume);
if (FAILED(hr))
{
diff --git a/dlls/d3d9/d3d9_private.h b/dlls/d3d9/d3d9_private.h
index 27a7694..8ef7f9b 100644
--- a/dlls/d3d9/d3d9_private.h
+++ b/dlls/d3d9/d3d9_private.h
@@ -176,7 +176,8 @@ struct d3d9_volume
};
HRESULT volume_init(struct d3d9_volume *volume, struct d3d9_device *device, UINT width, UINT height,
- UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool) DECLSPEC_HIDDEN;
+ UINT depth, UINT level, DWORD usage, enum wined3d_format_id format,
+ enum wined3d_pool pool) DECLSPEC_HIDDEN;
struct d3d9_swapchain
{
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c
index 738a274..eb49a64 100644
--- a/dlls/d3d9/device.c
+++ b/dlls/d3d9/device.c
@@ -3349,8 +3349,8 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
}
static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *device_parent,
- void *container_parent, UINT width, UINT height, UINT depth, enum wined3d_format_id format,
- enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
+ void *container_parent, UINT width, UINT height, UINT depth, UINT level,
+ enum wined3d_format_id format, enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
struct d3d9_volume *object;
@@ -3370,7 +3370,7 @@ static HRESULT CDECL device_parent_create_volume(struct wined3d_device_parent *d
return D3DERR_OUTOFVIDEOMEMORY;
}
- hr = volume_init(object, device, width, height, depth, usage, format, pool);
+ hr = volume_init(object, device, width, height, depth, level, usage, format, pool);
if (FAILED(hr))
{
WARN("Failed to initialize volume, hr %#x.\n", hr);
diff --git a/dlls/d3d9/volume.c b/dlls/d3d9/volume.c
index ba5dc05..1336be5 100644
--- a/dlls/d3d9/volume.c
+++ b/dlls/d3d9/volume.c
@@ -275,15 +275,16 @@ static const struct wined3d_parent_ops d3d9_volume_wined3d_parent_ops =
};
HRESULT volume_init(struct d3d9_volume *volume, struct d3d9_device *device, UINT width, UINT height,
- UINT depth, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool)
+ UINT depth, UINT level, DWORD usage, enum wined3d_format_id format, enum wined3d_pool pool)
{
HRESULT hr;
volume->IDirect3DVolume9_iface.lpVtbl = &d3d9_volume_vtbl;
volume->refcount = 1;
- hr = wined3d_volume_create(device->wined3d_device, width, height, depth, usage & WINED3DUSAGE_MASK,
- format, pool, volume, &d3d9_volume_wined3d_parent_ops, &volume->wined3d_volume);
+ hr = wined3d_volume_create(device->wined3d_device, width, height, depth, level,
+ usage & WINED3DUSAGE_MASK, format, pool, volume, &d3d9_volume_wined3d_parent_ops,
+ &volume->wined3d_volume);
if (FAILED(hr))
{
WARN("Failed to create wined3d volume, hr %#x.\n", hr);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 82f7749..7a09445 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1086,7 +1086,7 @@ static void texture3d_preload(struct wined3d_texture *texture, enum WINED3DSRGB
{
for (i = 0; i < texture->level_count; ++i)
{
- volume_load(volume_from_resource(texture->sub_resources[i]), context, i,
+ wined3d_volume_load(volume_from_resource(texture->sub_resources[i]), context,
texture->flags & WINED3D_TEXTURE_IS_SRGB);
}
}
@@ -1096,7 +1096,7 @@ static void texture3d_preload(struct wined3d_texture *texture, enum WINED3DSRGB
{
struct wined3d_volume *volume = volume_from_resource(texture->sub_resources[i]);
volume_add_dirty_box(volume, NULL);
- volume_load(volume, context, i, texture->flags & WINED3D_TEXTURE_IS_SRGB);
+ wined3d_volume_load(volume, context, texture->flags & WINED3D_TEXTURE_IS_SRGB);
}
}
else
@@ -1252,7 +1252,7 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
/* Create the volume. */
hr = device->device_parent->ops->create_volume(device->device_parent, parent,
- tmp_w, tmp_h, tmp_d, desc->format, desc->pool, desc->usage, &volume);
+ tmp_w, tmp_h, tmp_d, i, desc->format, desc->pool, desc->usage, &volume);
if (FAILED(hr))
{
ERR("Creating a volume for the volume texture failed, hr %#x.\n", hr);
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index fd54a35..613a17c 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -3,6 +3,7 @@
* Copyright 2002-2005 Raphael Junqueira
* Copyright 2005 Oliver Stieber
* Copyright 2009-2011 Henri Verbeet for CodeWeavers
+ * Copyright 2013 Stefan Dösinger for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -77,17 +78,18 @@ void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture
}
/* Context activation is done by the caller. */
-void volume_load(const struct wined3d_volume *volume, struct wined3d_context *context, UINT level, BOOL srgb_mode)
+void wined3d_volume_load(const struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode)
{
const struct wined3d_gl_info *gl_info = context->gl_info;
const struct wined3d_format *format = volume->resource.format;
TRACE("volume %p, context %p, level %u, srgb %#x, format %s (%#x).\n",
- volume, context, level, srgb_mode, debug_d3dformat(format->id), format->id);
+ volume, context, volume->texture_level, srgb_mode, debug_d3dformat(format->id),
+ format->id);
volume_bind_and_dirtify(volume, context);
- GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, level, format->glInternal,
+ GL_EXTCALL(glTexImage3DEXT(GL_TEXTURE_3D, volume->texture_level, format->glInternal,
volume->resource.width, volume->resource.height, volume->resource.depth,
0, format->glFormat, format->glType, volume->resource.allocatedMemory));
checkGLcall("glTexImage3D");
@@ -267,8 +269,8 @@ static const struct wined3d_resource_ops volume_resource_ops =
};
static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device *device, UINT width,
- UINT height, UINT depth, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool,
- void *parent, const struct wined3d_parent_ops *parent_ops)
+ UINT height, UINT depth, UINT level, DWORD usage, enum wined3d_format_id format_id,
+ enum wined3d_pool pool, void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
@@ -293,13 +295,15 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_device
memset(&volume->lockedBox, 0, sizeof(volume->lockedBox));
volume_add_dirty_box(volume, NULL);
+ volume->texture_level = level;
+
return WINED3D_OK;
}
HRESULT CDECL wined3d_volume_create(struct wined3d_device *device, UINT width, UINT height,
- UINT depth, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent,
- const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume)
+ UINT depth, UINT level, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool,
+ void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume)
{
struct wined3d_volume *object;
HRESULT hr;
@@ -315,7 +319,8 @@ HRESULT CDECL wined3d_volume_create(struct wined3d_device *device, UINT width, U
return WINED3DERR_OUTOFVIDEOMEMORY;
}
- hr = volume_init(object, device, width, height, depth, usage, format_id, pool, parent, parent_ops);
+ hr = volume_init(object, device, width, height, depth, level,
+ usage, format_id, pool, parent, parent_ops);
if (FAILED(hr))
{
WARN("Failed to initialize volume, returning %#x.\n", hr);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index f8ba5a5..7f28c42 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2061,6 +2061,7 @@ struct wined3d_volume
struct wined3d_box dirtyBox;
DWORD flags;
+ GLint texture_level;
};
static inline struct wined3d_volume *volume_from_resource(struct wined3d_resource *resource)
@@ -2069,7 +2070,7 @@ static inline struct wined3d_volume *volume_from_resource(struct wined3d_resourc
}
void volume_add_dirty_box(struct wined3d_volume *volume, const struct wined3d_box *dirty_box) DECLSPEC_HIDDEN;
-void volume_load(const struct wined3d_volume *volume, struct wined3d_context *context, UINT level, BOOL srgb_mode) DECLSPEC_HIDDEN;
+void wined3d_volume_load(const struct wined3d_volume *volume, struct wined3d_context *context, BOOL srgb_mode) DECLSPEC_HIDDEN;
void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture *container) DECLSPEC_HIDDEN;
struct wined3d_surface_dib
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index 86e8b5b..e02ebba 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -1987,8 +1987,8 @@ struct wined3d_device_parent_ops
const struct wined3d_resource_desc *desc, UINT sub_resource_idx, DWORD flags,
struct wined3d_surface **surface);
HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent,
- UINT width, UINT height, UINT depth, enum wined3d_format_id format_id, enum wined3d_pool pool, DWORD usage,
- struct wined3d_volume **volume);
+ UINT width, UINT height, UINT depth, UINT level, enum wined3d_format_id format_id,
+ enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume);
HRESULT (__cdecl *create_swapchain)(struct wined3d_device_parent *device_parent,
struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain);
};
@@ -2408,7 +2408,7 @@ void * __cdecl wined3d_vertex_declaration_get_parent(const struct wined3d_vertex
ULONG __cdecl wined3d_vertex_declaration_incref(struct wined3d_vertex_declaration *declaration);
HRESULT __cdecl wined3d_volume_create(struct wined3d_device *device, UINT width, UINT height, UINT depth,
- DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent,
+ UINT level, DWORD usage, enum wined3d_format_id format_id, enum wined3d_pool pool, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_volume **volume);
ULONG __cdecl wined3d_volume_decref(struct wined3d_volume *volume);
struct wined3d_volume * __cdecl wined3d_volume_from_resource(struct wined3d_resource *resource);
--
1.8.1.5
More information about the wine-patches
mailing list