Commit aaca15f1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Pass a texture and sub-resource index to wined3d_volume_upload_data().

parent 17768e56
...@@ -3601,7 +3601,7 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device, ...@@ -3601,7 +3601,7 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device,
data.buffer_object = 0; data.buffer_object = 0;
data.addr = src.data; 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); wined3d_texture_invalidate_location(dst_texture, i, ~WINED3D_LOCATION_TEXTURE_RGB);
if (FAILED(hr = wined3d_resource_unmap(&src_texture->resource, src_level + i))) if (FAILED(hr = wined3d_resource_unmap(&src_texture->resource, src_level + i)))
......
...@@ -1992,7 +1992,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int ...@@ -1992,7 +1992,7 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int
addr.buffer_object = 0; addr.buffer_object = 0;
addr.addr = data->data; 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, static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx,
......
...@@ -30,23 +30,22 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_perf); ...@@ -30,23 +30,22 @@ WINE_DECLARE_DEBUG_CHANNEL(d3d_perf);
/* This call just uploads data, the caller is responsible for binding the /* This call just uploads data, the caller is responsible for binding the
* correct texture. */ * correct texture. */
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, void wined3d_volume_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_const_bo_address *data) 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; 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; unsigned int width, height, depth;
const void *mem = data->addr; const void *mem = data->addr;
void *converted_mem = NULL; void *converted_mem = NULL;
TRACE("volume %p, context %p, level %u, format %s (%#x).\n", TRACE("texture %p, sub_resource_idx %u, context %p, format %s (%#x).\n",
volume, context, volume->texture_level, debug_d3dformat(format->id), texture, level, context, debug_d3dformat(format->id), format->id);
format->id);
width = wined3d_texture_get_level_width(texture, volume->texture_level); width = wined3d_texture_get_level_width(texture, level);
height = wined3d_texture_get_level_height(texture, volume->texture_level); height = wined3d_texture_get_level_height(texture, level);
depth = wined3d_texture_get_level_depth(texture, volume->texture_level); depth = wined3d_texture_get_level_depth(texture, level);
if (format->convert) if (format->convert)
{ {
...@@ -54,14 +53,14 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine ...@@ -54,14 +53,14 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
UINT src_row_pitch, src_slice_pitch; UINT src_row_pitch, src_slice_pitch;
if (data->buffer_object) 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) if (texture->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
ERR("Converting a block-based format.\n"); ERR("Converting a block-based format.\n");
dst_row_pitch = width * format->conv_byte_count; dst_row_pitch = width * format->conv_byte_count;
dst_slice_pitch = dst_row_pitch * height; 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); converted_mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch * depth);
format->convert(data->addr, converted_mem, src_row_pitch, src_slice_pitch, 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 ...@@ -75,9 +74,8 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
checkGLcall("glBindBuffer"); checkGLcall("glBindBuffer");
} }
GL_EXTCALL(glTexSubImage3D(GL_TEXTURE_3D, volume->texture_level, 0, 0, 0, GL_EXTCALL(glTexSubImage3D(GL_TEXTURE_3D, level, 0, 0, 0,
width, height, depth, width, height, depth, format->glFormat, format->glType, mem));
format->glFormat, format->glType, mem));
checkGLcall("glTexSubImage3D"); checkGLcall("glTexSubImage3D");
if (data->buffer_object) if (data->buffer_object)
...@@ -163,7 +161,7 @@ static void wined3d_volume_srgb_transfer(struct wined3d_volume *volume, ...@@ -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_texture_bind_and_dirtify(texture, context, !dest_is_srgb);
wined3d_volume_download_data(volume, context, &data); wined3d_volume_download_data(volume, context, &data);
wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb); 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); HeapFree(GetProcessHeap(), 0, data.addr);
} }
...@@ -215,14 +213,14 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume, ...@@ -215,14 +213,14 @@ BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
data.addr += sub_resource->offset; data.addr += sub_resource->offset;
wined3d_texture_bind_and_dirtify(texture, context, wined3d_texture_bind_and_dirtify(texture, context,
location == WINED3D_LOCATION_TEXTURE_SRGB); 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) else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
{ {
struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL}; struct wined3d_const_bo_address data = {sub_resource->buffer_object, NULL};
wined3d_texture_bind_and_dirtify(texture, context, wined3d_texture_bind_and_dirtify(texture, context,
location == WINED3D_LOCATION_TEXTURE_SRGB); 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) else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
{ {
......
...@@ -2611,8 +2611,8 @@ struct wined3d_volume ...@@ -2611,8 +2611,8 @@ struct wined3d_volume
BOOL wined3d_volume_load_location(struct wined3d_volume *volume, BOOL wined3d_volume_load_location(struct wined3d_volume *volume,
struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN; struct wined3d_context *context, DWORD location) DECLSPEC_HIDDEN;
void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context, void wined3d_volume_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx,
const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN; const struct wined3d_context *context, const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
struct wined3d_renderbuffer_entry struct wined3d_renderbuffer_entry
{ {
......
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