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

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-04-21 17:05:05 +02:00 committed by Alexandre Julliard
parent 17768e567b
commit aaca15f172
4 changed files with 20 additions and 22 deletions

View File

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

View File

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

View File

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

View File

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