From: Zebediah Figura zfigura@codeweavers.com
--- dlls/wined3d/cs.c | 5 ++-- dlls/wined3d/surface.c | 26 +++++++++---------- dlls/wined3d/texture.c | 47 +++++++++++++++++----------------- dlls/wined3d/wined3d_private.h | 5 ++-- 4 files changed, 41 insertions(+), 42 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index bca0b017c1f..e938a0e1df7 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2594,9 +2594,8 @@ static void wined3d_cs_exec_blt_sub_resource(struct wined3d_cs *cs, const void * return; }
- wined3d_texture_get_bo_address(src_texture, op->src_sub_resource_idx, &addr, location); - wined3d_texture_get_pitch(src_texture, op->src_sub_resource_idx % src_texture->level_count, - &row_pitch, &slice_pitch); + wined3d_texture_get_bo_address(src_texture, op->src_sub_resource_idx, + &addr, &row_pitch, &slice_pitch, location);
dst_texture->texture_ops->texture_upload_data(context, wined3d_const_bo_address(&addr), dst_texture->resource.format, &op->src_box, row_pitch, slice_pitch, dst_texture, diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index fd8db9ce60d..24a08e3a797 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -289,8 +289,8 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr map_binding = src_texture->resource.map_binding; if (!wined3d_texture_load_location(src_texture, sub_resource_idx, context, map_binding)) ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(map_binding)); - wined3d_texture_get_pitch(src_texture, texture_level, &src_row_pitch, &src_slice_pitch); - wined3d_texture_get_bo_address(src_texture, sub_resource_idx, &src_data, map_binding); + wined3d_texture_get_bo_address(src_texture, sub_resource_idx, + &src_data, &src_row_pitch, &src_slice_pitch, map_binding);
if (conv) { @@ -303,8 +303,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr map_binding = dst_texture->resource.map_binding; if (!wined3d_texture_load_location(dst_texture, 0, context, map_binding)) ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding)); - wined3d_texture_get_pitch(dst_texture, 0, &dst_row_pitch, &dst_slice_pitch); - wined3d_texture_get_bo_address(dst_texture, 0, &dst_data, map_binding); + wined3d_texture_get_bo_address(dst_texture, 0, &dst_data, &dst_row_pitch, &dst_slice_pitch, map_binding);
src = wined3d_context_map_bo_address(context, &src_data, src_texture->sub_resources[sub_resource_idx].size, WINED3D_MAP_READ); @@ -359,7 +358,7 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i unsigned int i;
/* dst_location was already prepared by the caller. */ - wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, dst_location); + wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, &row_pitch, &slice_pitch, dst_location); offset = data.addr;
restore_texture = context->current_rt.texture; @@ -418,7 +417,6 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i }
level = sub_resource_idx % texture->level_count; - wined3d_texture_get_pitch(texture, level, &row_pitch, &slice_pitch); format_gl = wined3d_format_gl(resource->format);
/* Setup pixel store pack state -- to glReadPixels into the correct place */ @@ -699,8 +697,8 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int if (!wined3d_texture_load_location(dst_texture, dst_sub_resource_idx, context, map_binding)) ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding)); wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~map_binding); - wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch); - wined3d_texture_get_bo_address(dst_texture, dst_sub_resource_idx, &dst_data, map_binding); + wined3d_texture_get_bo_address(dst_texture, dst_sub_resource_idx, + &dst_data, &dst_map.row_pitch, &dst_map.slice_pitch, map_binding); dst_map.data = wined3d_context_map_bo_address(context, &dst_data, dst_texture->sub_resources[dst_sub_resource_idx].size, WINED3D_MAP_READ | WINED3D_MAP_WRITE);
@@ -736,8 +734,8 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int texture_level = src_sub_resource_idx % src_texture->level_count; if (!wined3d_texture_load_location(src_texture, src_sub_resource_idx, context, map_binding)) ERR("Failed to load the source sub-resource into %s.\n", wined3d_debug_location(map_binding)); - wined3d_texture_get_pitch(src_texture, texture_level, &src_map.row_pitch, &src_map.slice_pitch); - wined3d_texture_get_bo_address(src_texture, src_sub_resource_idx, &src_data, map_binding); + wined3d_texture_get_bo_address(src_texture, src_sub_resource_idx, + &src_data, &src_map.row_pitch, &src_map.slice_pitch, map_binding); src_map.data = wined3d_context_map_bo_address(context, &src_data, src_texture->sub_resources[src_sub_resource_idx].size, WINED3D_MAP_READ);
@@ -755,8 +753,8 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int ERR("Failed to load the destination sub-resource into %s.\n", wined3d_debug_location(map_binding));
wined3d_texture_invalidate_location(dst_texture, dst_sub_resource_idx, ~map_binding); - wined3d_texture_get_pitch(dst_texture, texture_level, &dst_map.row_pitch, &dst_map.slice_pitch); - wined3d_texture_get_bo_address(dst_texture, dst_sub_resource_idx, &dst_data, map_binding); + wined3d_texture_get_bo_address(dst_texture, dst_sub_resource_idx, + &dst_data, &dst_map.row_pitch, &dst_map.slice_pitch, map_binding); dst_map.data = wined3d_context_map_bo_address(context, &dst_data, dst_texture->sub_resources[dst_sub_resource_idx].size, WINED3D_MAP_WRITE); } @@ -1219,8 +1217,8 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view, if (!wined3d_texture_load_location(texture, view->sub_resource_idx, context, map_binding)) ERR("Failed to load the sub-resource into %s.\n", wined3d_debug_location(map_binding)); wined3d_texture_invalidate_location(texture, view->sub_resource_idx, ~map_binding); - wined3d_texture_get_pitch(texture, level, &map.row_pitch, &map.slice_pitch); - wined3d_texture_get_bo_address(texture, view->sub_resource_idx, &data, map_binding); + wined3d_texture_get_bo_address(texture, view->sub_resource_idx, &data, + &map.row_pitch, &map.slice_pitch, map_binding); map.data = wined3d_context_map_bo_address(context, &data, texture->sub_resources[view->sub_resource_idx].size, WINED3D_MAP_WRITE); range.offset = 0; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 626b0908c68..5f639ff4326 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -733,8 +733,8 @@ void wined3d_texture_invalidate_location(struct wined3d_texture *texture, sub_resource_idx, texture); }
-void wined3d_texture_get_bo_address(const struct wined3d_texture *texture, - unsigned int sub_resource_idx, struct wined3d_bo_address *data, uint32_t location) +void wined3d_texture_get_bo_address(const struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_bo_address *data, unsigned int *row_pitch, unsigned int *slice_pitch, uint32_t location) { struct wined3d_texture_sub_resource *sub_resource = &texture->sub_resources[sub_resource_idx];
@@ -757,6 +757,9 @@ void wined3d_texture_get_bo_address(const struct wined3d_texture *texture, } data->buffer_object = 0; } + + if (row_pitch) + wined3d_texture_get_pitch(texture, sub_resource_idx % texture->level_count, row_pitch, slice_pitch); }
void wined3d_texture_clear_dirty_regions(struct wined3d_texture *texture) @@ -823,11 +826,12 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture, && (current & (wined3d_texture_sysmem_locations | WINED3D_LOCATION_CLEARED))) { struct wined3d_bo_address source, destination; + unsigned int row_pitch, slice_pitch; struct wined3d_range range;
if (!wined3d_texture_prepare_location(texture, sub_resource_idx, context, location)) return FALSE; - wined3d_texture_get_bo_address(texture, sub_resource_idx, &destination, location); + wined3d_texture_get_bo_address(texture, sub_resource_idx, &destination, &row_pitch, &slice_pitch, location); range.offset = 0; range.size = texture->sub_resources[sub_resource_idx].size; if (current & WINED3D_LOCATION_CLEARED) @@ -849,12 +853,13 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture, c = texture->sub_resources[sub_resource_idx].clear_value.colour; }
- wined3d_texture_get_pitch(texture, level_idx, &map.row_pitch, &map.slice_pitch); if (destination.buffer_object) map.data = wined3d_context_map_bo_address(context, &destination, range.size, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD); else map.data = destination.addr; + map.row_pitch = row_pitch; + map.slice_pitch = slice_pitch;
wined3d_texture_get_level_box(texture, level_idx, &box); wined3d_resource_memory_colour_fill(&texture->resource, &map, &c, &box, true); @@ -865,7 +870,7 @@ BOOL wined3d_texture_load_location(struct wined3d_texture *texture, else { wined3d_texture_get_bo_address(texture, sub_resource_idx, - &source, (current & wined3d_texture_sysmem_locations)); + &source, NULL, NULL, (current & wined3d_texture_sysmem_locations)); wined3d_context_copy_bo_address(context, &destination, &source, 1, &range); } ret = TRUE; @@ -902,13 +907,13 @@ static void wined3d_texture_get_memory(struct wined3d_texture *texture, unsigned } if (locations & WINED3D_LOCATION_BUFFER) { - wined3d_texture_get_bo_address(texture, sub_resource_idx, data, WINED3D_LOCATION_BUFFER); + wined3d_texture_get_bo_address(texture, sub_resource_idx, data, NULL, NULL, WINED3D_LOCATION_BUFFER); return; }
if (locations & WINED3D_LOCATION_SYSMEM) { - wined3d_texture_get_bo_address(texture, sub_resource_idx, data, WINED3D_LOCATION_SYSMEM); + wined3d_texture_get_bo_address(texture, sub_resource_idx, data, NULL, NULL, WINED3D_LOCATION_SYSMEM); return; }
@@ -1148,8 +1153,8 @@ static void wined3d_texture_create_dc(void *object) wined3d_texture_load_location(texture, sub_resource_idx, context, texture->resource.map_binding); } wined3d_texture_invalidate_location(texture, sub_resource_idx, ~texture->resource.map_binding); - wined3d_texture_get_pitch(texture, level, &row_pitch, &slice_pitch); - wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, texture->resource.map_binding); + wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, + &row_pitch, &slice_pitch, texture->resource.map_binding); if (data.buffer_object) { if (!context) @@ -1222,7 +1227,7 @@ static void wined3d_texture_destroy_dc(void *object) dc_info->dc = NULL; dc_info->bitmap = NULL;
- wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, texture->resource.map_binding); + wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, NULL, NULL, texture->resource.map_binding); if (data.buffer_object) { context = context_acquire(device, NULL, 0); @@ -3060,11 +3065,10 @@ static BOOL wined3d_texture_gl_load_sysmem(struct wined3d_texture_gl *texture_gl unsigned int src_location;
level = sub_resource_idx % texture_gl->t.level_count; - wined3d_texture_get_bo_address(&texture_gl->t, sub_resource_idx, &data, dst_location); + wined3d_texture_get_bo_address(&texture_gl->t, sub_resource_idx, &data, &row_pitch, &slice_pitch, dst_location); src_location = sub_resource->locations & WINED3D_LOCATION_TEXTURE_RGB ? WINED3D_LOCATION_TEXTURE_RGB : WINED3D_LOCATION_TEXTURE_SRGB; wined3d_texture_get_level_box(&texture_gl->t, level, &src_box); - wined3d_texture_get_pitch(&texture_gl->t, level, &row_pitch, &slice_pitch); wined3d_texture_gl_download_data(&context_gl->c, &texture_gl->t, sub_resource_idx, src_location, &src_box, &data, texture_gl->t.resource.format, 0, 0, 0, row_pitch, slice_pitch);
@@ -3450,7 +3454,7 @@ static bool wined3d_texture_gl_clear(struct wined3d_texture *texture,
if (!wined3d_texture_prepare_location(texture, sub_resource_idx, &context_gl->c, WINED3D_LOCATION_SYSMEM)) return false; - wined3d_texture_get_bo_address(texture, sub_resource_idx, &addr, WINED3D_LOCATION_SYSMEM); + wined3d_texture_get_bo_address(texture, sub_resource_idx, &addr, NULL, NULL, WINED3D_LOCATION_SYSMEM); memset(addr.addr, 0, sub_resource->size); wined3d_texture_validate_location(texture, sub_resource_idx, WINED3D_LOCATION_SYSMEM); return true; @@ -3774,7 +3778,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour } }
- wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, resource->map_binding); + wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, NULL, NULL, resource->map_binding); base_memory = wined3d_context_map_bo_address(context, &data, sub_resource->size, flags); sub_resource->map_flags = flags; TRACE("Base memory pointer %p.\n", base_memory); @@ -3824,7 +3828,7 @@ static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *reso
context = context_acquire(device, NULL, 0);
- wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, texture->resource.map_binding); + wined3d_texture_get_bo_address(texture, sub_resource_idx, &data, NULL, NULL, texture->resource.map_binding); range.offset = 0; range.size = sub_resource->size; wined3d_context_unmap_bo_address(context, &data, !!(sub_resource->map_flags & WINED3D_MAP_WRITE), &range); @@ -4671,8 +4675,8 @@ void wined3d_texture_upload_from_texture(struct wined3d_texture *dst_texture, un void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx) { - unsigned int src_level, dst_level, dst_row_pitch, dst_slice_pitch; unsigned int dst_location = dst_texture->resource.map_binding; + unsigned int src_level, dst_row_pitch, dst_slice_pitch; struct wined3d_context *context; struct wined3d_bo_address data; struct wined3d_box src_box; @@ -4681,7 +4685,8 @@ void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, context = context_acquire(src_texture->resource.device, NULL, 0);
wined3d_texture_prepare_location(dst_texture, dst_sub_resource_idx, context, dst_location); - wined3d_texture_get_bo_address(dst_texture, dst_sub_resource_idx, &data, dst_location); + wined3d_texture_get_bo_address(dst_texture, dst_sub_resource_idx, + &data, &dst_row_pitch, &dst_slice_pitch, dst_location);
if (src_texture->sub_resources[src_sub_resource_idx].locations & WINED3D_LOCATION_TEXTURE_RGB) src_location = WINED3D_LOCATION_TEXTURE_RGB; @@ -4690,9 +4695,6 @@ void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, src_level = src_sub_resource_idx % src_texture->level_count; wined3d_texture_get_level_box(src_texture, src_level, &src_box);
- dst_level = dst_sub_resource_idx % dst_texture->level_count; - wined3d_texture_get_pitch(dst_texture, dst_level, &dst_row_pitch, &dst_slice_pitch); - src_texture->texture_ops->texture_download_data(context, src_texture, src_sub_resource_idx, src_location, &src_box, &data, dst_texture->resource.format, 0, 0, 0, dst_row_pitch, dst_slice_pitch);
@@ -5335,7 +5337,7 @@ static bool wined3d_texture_vk_clear(struct wined3d_texture_vk *texture_vk,
if (!wined3d_texture_prepare_location(&texture_vk->t, sub_resource_idx, context, WINED3D_LOCATION_SYSMEM)) return false; - wined3d_texture_get_bo_address(&texture_vk->t, sub_resource_idx, &addr, WINED3D_LOCATION_SYSMEM); + wined3d_texture_get_bo_address(&texture_vk->t, sub_resource_idx, &addr, NULL, NULL, WINED3D_LOCATION_SYSMEM); memset(addr.addr, 0, sub_resource->size); wined3d_texture_validate_location(&texture_vk->t, sub_resource_idx, WINED3D_LOCATION_SYSMEM); return true; @@ -5440,9 +5442,8 @@ static BOOL wined3d_texture_vk_load_sysmem(struct wined3d_texture_vk *texture_vk }
level = sub_resource_idx % texture_vk->t.level_count; - wined3d_texture_get_bo_address(&texture_vk->t, sub_resource_idx, &data, location); + wined3d_texture_get_bo_address(&texture_vk->t, sub_resource_idx, &data, &row_pitch, &slice_pitch, location); wined3d_texture_get_level_box(&texture_vk->t, level, &src_box); - wined3d_texture_get_pitch(&texture_vk->t, level, &row_pitch, &slice_pitch); wined3d_texture_vk_download_data(context, &texture_vk->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB, &src_box, &data, texture_vk->t.resource.format, 0, 0, 0, row_pitch, slice_pitch);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index f808852ffef..f40949d5256 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4742,8 +4742,9 @@ void texture2d_read_from_framebuffer(struct wined3d_texture *texture, unsigned i void wined3d_texture_cleanup(struct wined3d_texture *texture) DECLSPEC_HIDDEN; void wined3d_texture_download_from_texture(struct wined3d_texture *dst_texture, unsigned int dst_sub_resource_idx, struct wined3d_texture *src_texture, unsigned int src_sub_resource_idx) DECLSPEC_HIDDEN; -void wined3d_texture_get_bo_address(const struct wined3d_texture *texture, - unsigned int sub_resource_idx, struct wined3d_bo_address *data, uint32_t location) DECLSPEC_HIDDEN; +void wined3d_texture_get_bo_address(const struct wined3d_texture *texture, unsigned int sub_resource_idx, + struct wined3d_bo_address *data, unsigned int *row_pitch, + unsigned int *slice_pitch, uint32_t location) DECLSPEC_HIDDEN; GLenum wined3d_texture_get_gl_buffer(const struct wined3d_texture *texture) DECLSPEC_HIDDEN; void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location) DECLSPEC_HIDDEN;