Commit e0d30e8e authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Extend wined3d_texture_upload_data() to support partial uploads.

parent c63e3261
...@@ -3602,7 +3602,7 @@ static HRESULT wined3d_device_update_texture_3d(struct wined3d_device *device, ...@@ -3602,7 +3602,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_texture_upload_data(dst_texture, i, context, &data, src.row_pitch, src.slice_pitch); wined3d_texture_upload_data(dst_texture, i, context, NULL, &data, src.row_pitch, src.slice_pitch);
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)))
......
...@@ -1436,24 +1436,37 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture, ...@@ -1436,24 +1436,37 @@ HRESULT CDECL wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
} }
void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, void wined3d_texture_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_context *context, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch) const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
{ {
texture->texture_ops->texture_upload_data(texture, sub_resource_idx, texture->texture_ops->texture_upload_data(texture, sub_resource_idx,
context, data, row_pitch, slice_pitch); context, box, data, row_pitch, slice_pitch);
} }
static void texture2d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, static void texture2d_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_context *context, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch) const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
{ {
static const POINT dst_point = {0, 0};
unsigned int texture_level; unsigned int texture_level;
POINT dst_point;
RECT src_rect; RECT src_rect;
texture_level = sub_resource_idx % texture->level_count; src_rect.left = 0;
SetRect(&src_rect, 0, 0, wined3d_texture_get_level_width(texture, texture_level), src_rect.top = 0;
wined3d_texture_get_level_height(texture, texture_level)); if (box)
{
dst_point.x = box->left;
dst_point.y = box->top;
src_rect.right = box->right - box->left;
src_rect.bottom = box->bottom - box->top;
}
else
{
dst_point.x = dst_point.y = 0;
texture_level = sub_resource_idx % texture->level_count;
src_rect.right = wined3d_texture_get_level_width(texture, texture_level);
src_rect.bottom = wined3d_texture_get_level_height(texture, texture_level);
}
wined3d_surface_upload_data(texture->sub_resources[sub_resource_idx].u.surface, context->gl_info, wined3d_surface_upload_data(texture->sub_resources[sub_resource_idx].u.surface, context->gl_info,
texture->resource.format, &src_rect, row_pitch, &dst_point, FALSE, data); texture->resource.format, &src_rect, row_pitch, &dst_point, FALSE, data);
...@@ -2093,8 +2106,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3 ...@@ -2093,8 +2106,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
* correct texture. */ * correct texture. */
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, static void texture3d_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_context *context, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch) const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch)
{ {
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; unsigned int level = sub_resource_idx % texture->level_count;
...@@ -2104,8 +2117,12 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int ...@@ -2104,8 +2117,12 @@ static void texture3d_upload_data(struct wined3d_texture *texture, unsigned int
const void *mem = data->addr; const void *mem = data->addr;
void *converted_mem = NULL; void *converted_mem = NULL;
TRACE("texture %p, sub_resource_idx %u, context %p, data {%#x:%p}, row_pitch %#x, slice_pitch %#x.\n", TRACE("texture %p, sub_resource_idx %u, context %p, box %s, data {%#x:%p}, row_pitch %#x, slice_pitch %#x.\n",
texture, sub_resource_idx, context, data->buffer_object, data->addr, row_pitch, slice_pitch); texture, sub_resource_idx, context, debug_box(box),
data->buffer_object, data->addr, row_pitch, slice_pitch);
if (box)
FIXME("Partial upload not supported yet.\n");
width = wined3d_texture_get_level_width(texture, level); width = wined3d_texture_get_level_width(texture, level);
height = wined3d_texture_get_level_height(texture, level); height = wined3d_texture_get_level_height(texture, level);
...@@ -2208,7 +2225,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in ...@@ -2208,7 +2225,7 @@ static void texture3d_srgb_transfer(struct wined3d_texture *texture, unsigned in
texture3d_download_data(texture, sub_resource_idx, context, &data); texture3d_download_data(texture, sub_resource_idx, context, &data);
wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb); wined3d_texture_bind_and_dirtify(texture, context, dest_is_srgb);
texture3d_upload_data(texture, sub_resource_idx, context, texture3d_upload_data(texture, sub_resource_idx, context,
wined3d_const_bo_address(&data), row_pitch, slice_pitch); NULL, wined3d_const_bo_address(&data), row_pitch, slice_pitch);
HeapFree(GetProcessHeap(), 0, data.addr); HeapFree(GetProcessHeap(), 0, data.addr);
} }
...@@ -2261,7 +2278,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in ...@@ -2261,7 +2278,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
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_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
texture3d_upload_data(texture, sub_resource_idx, context, &data, row_pitch, slice_pitch); texture3d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
} }
else if (sub_resource->locations & WINED3D_LOCATION_BUFFER) else if (sub_resource->locations & WINED3D_LOCATION_BUFFER)
{ {
...@@ -2269,7 +2286,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in ...@@ -2269,7 +2286,7 @@ static BOOL texture3d_load_location(struct wined3d_texture *texture, unsigned in
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_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch); wined3d_texture_get_pitch(texture, sub_resource_idx, &row_pitch, &slice_pitch);
texture3d_upload_data(texture, sub_resource_idx, context, &data, row_pitch, slice_pitch); texture3d_upload_data(texture, sub_resource_idx, context, NULL, &data, row_pitch, slice_pitch);
} }
else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB) else if (sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB)
{ {
......
...@@ -2649,8 +2649,8 @@ struct gl_texture ...@@ -2649,8 +2649,8 @@ struct gl_texture
struct wined3d_texture_ops struct wined3d_texture_ops
{ {
void (*texture_upload_data)(struct wined3d_texture *texture, unsigned int sub_resource_idx, void (*texture_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_context *context, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch); const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch);
BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx, BOOL (*texture_load_location)(struct wined3d_texture *texture, unsigned int sub_resource_idx,
struct wined3d_context *context, DWORD location); struct wined3d_context *context, DWORD location);
void (*texture_prepare_texture)(struct wined3d_texture *texture, void (*texture_prepare_texture)(struct wined3d_texture *texture,
...@@ -2807,8 +2807,8 @@ void wined3d_texture_set_swapchain(struct wined3d_texture *texture, ...@@ -2807,8 +2807,8 @@ void wined3d_texture_set_swapchain(struct wined3d_texture *texture,
void wined3d_texture_unmap_bo_address(const struct wined3d_bo_address *data, void wined3d_texture_unmap_bo_address(const struct wined3d_bo_address *data,
const struct wined3d_gl_info *gl_info, GLenum binding) DECLSPEC_HIDDEN; const struct wined3d_gl_info *gl_info, GLenum binding) DECLSPEC_HIDDEN;
void wined3d_texture_upload_data(struct wined3d_texture *texture, unsigned int sub_resource_idx, void wined3d_texture_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_context *context, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN; const struct wined3d_const_bo_address *data, unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN;
void wined3d_texture_validate_location(struct wined3d_texture *texture, void wined3d_texture_validate_location(struct wined3d_texture *texture,
unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN; unsigned int sub_resource_idx, DWORD location) DECLSPEC_HIDDEN;
......
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