[PATCH 3/8] wined3d: Pass a texture and sub-resource index to wined3d_volume_upload_data().
Henri Verbeet
hverbeet at codeweavers.com
Thu Apr 21 10:05:05 CDT 2016
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
---
dlls/wined3d/device.c | 2 +-
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/volume.c | 34 ++++++++++++++++------------------
dlls/wined3d/wined3d_private.h | 4 ++--
4 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 121a8ee..fd7f818 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3601,7 +3601,7 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
data.buffer_object = 0;
data.addr = src.data;
- wined3d_volume_upload_data(dst_texture->sub_resources[i].u.volume, context, &data);
+ wined3d_volume_upload_data(dst_texture, i, context, &data);
wined3d_texture_invalidate_location(dst_texture, i, ~WINED3D_LOCATION_TEXTURE_RGB);
if (FAILED(hr = wined3d_resource_unmap(&src_texture->resource, src_level + i)))
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index f1896fd..eb0ad2f 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1992,7 +1992,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int
addr.buffer_object = 0;
addr.addr = data->data;
- wined3d_volume_upload_data(texture->sub_resources[sub_resource_idx].u.volume, context, &addr);
+ wined3d_volume_upload_data(texture, sub_resource_idx, context, &addr);
}
static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 3106ac7..f59f963 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -30,23 +30,22 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
/* This call just uploads data, the caller is responsible for binding the
* correct texture. */
/* Context activation is done by the caller. */
-void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context,
- const struct wined3d_const_bo_address *data)
+void wined3d_volume_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ const struct wined3d_context *context, const struct wined3d_const_bo_address *data)
{
- const struct wined3d_gl_info *gl_info = context->gl_info;
- struct wined3d_texture *texture = volume->container;
const struct wined3d_format *format = texture->resource.format;
+ unsigned int level = sub_resource_idx % texture->level_count;
+ const struct wined3d_gl_info *gl_info = context->gl_info;
unsigned int width, height, depth;
const void *mem = data->addr;
void *converted_mem = NULL;
- TRACE("volume %p, context %p, level %u, format %s (%#x).\n",
- volume, context, volume->texture_level, debug_d3dformat(format->id),
- format->id);
+ TRACE("texture %p, sub_resource_idx %u, context %p, format %s (%#x).\n",
+ texture, level, context, debug_d3dformat(format->id), format->id);
- width = wined3d_texture_get_level_width(texture, volume->texture_level);
- height = wined3d_texture_get_level_height(texture, volume->texture_level);
- depth = wined3d_texture_get_level_depth(texture, volume->texture_level);
+ width = wined3d_texture_get_level_width(texture, level);
+ height = wined3d_texture_get_level_height(texture, level);
+ depth = wined3d_texture_get_level_depth(texture, level);
if (format->convert)
{
@@ -54,14 +53,14 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
UINT src_row_pitch, src_slice_pitch;
if (data->buffer_object)
- ERR("Loading a converted volume from a PBO.\n");
+ ERR("Loading a converted texture from a PBO.\n");
if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
ERR("Converting a block-based format.\n");
dst_row_pitch = width * format->conv_byte_count;
dst_slice_pitch = dst_row_pitch * height;
- wined3d_texture_get_pitch(texture, volume->texture_level, &src_row_pitch, &src_slice_pitch);
+ wined3d_texture_get_pitch(texture, level, &src_row_pitch, &src_slice_pitch);
converted_mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch * depth);
format->convert(data->addr, converted_mem, src_row_pitch, src_slice_pitch,
@@ -75,9 +74,8 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
checkGLcall("glBindBuffer");
}
- GL_EXTCALL(glTexSubImage3D(GL_TEXTURE_3D, volume->texture_level, 0, 0, 0,
- width, height, depth,
- format->glFormat, format->glType, mem));
+ GL_EXTCALL(glTexSubImage3D(GL_TEXTURE_3D, level, 0, 0, 0,
+ width, height, depth, format->glFormat, format->glType, mem));
checkGLcall("glTexSubImage3D");
if (data->buffer_object)
@@ -163,7 +161,7 @@ static void wined3d_volume_srgb_transfer(struct wined3d_volume *volume,
wined3d_texture_bind_and_dirtify(texture, context, !dest_is_srgb);
wined3d_volume_download_data(volume, context, &data);
wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb);
- wined3d_volume_upload_data(volume, context, wined3d_const_bo_address(&data));
+ wined3d_volume_upload_data(texture, volume->texture_level, context, wined3d_const_bo_address(&data));
HeapFree(GetProcessHeap(), 0, data.addr);
}
@@ -215,14 +213,14 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
data.addr += sub_resource->offset;
wined3d_texture_bind_and_dirtify(texture, context,
location == WINED3D_LOCATION_TEXTURE_SRGB);
- wined3d_volume_upload_data(volume, context, &data);
+ wined3d_volume_upload_data(texture, sub_resource_idx, context, &data);
}
else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
{
struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
wined3d_texture_bind_and_dirtify(texture, context,
location == WINED3D_LOCATION_TEXTURE_SRGB);
- wined3d_volume_upload_data(volume, context, &data);
+ wined3d_volume_upload_data(texture, sub_resource_idx, context, &data);
}
else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
{
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 2c19e7e..099d1ee 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2611,8 +2611,8 @@ struct wined3d_volume
BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
-void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context,
- const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
+void wined3d_volume_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
+ const struct wined3d_context *context, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
struct wined3d_renderbuffer_entry
{
--
2.1.4
More information about the wine-patches
mailing list