wined3d: Store the mipmap level in the volume.

oldstable
Stefan Dösinger 2013-08-22 14:57:54 +02:00 committed by Alexandre Julliard
parent 0473a072dd
commit ac871305f8
12 changed files with 45 additions and 33 deletions

View File

@ -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);

View File

@ -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
{

View File

@ -2987,8 +2987,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;
@ -3008,7 +3008,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);

View File

@ -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))
{

View File

@ -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
{

View File

@ -3375,8 +3375,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;
@ -3396,7 +3396,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);

View File

@ -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);

View File

@ -5190,8 +5190,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)
{
TRACE("device_parent %p, container_parent %p, width %u, height %u, depth %u, "
"format %#x, pool %#x, usage %#x, volume %p.\n",

View File

@ -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);

View File

@ -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);
@ -295,13 +297,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;
@ -317,7 +321,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);

View File

@ -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

View File

@ -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);