wined3d-CSMT_Main: Reenable patchset.

For now, various conflicting changes have just been reverted.
This commit is contained in:
Sebastian Lackner
2016-02-21 23:51:33 +01:00
parent b765f1e594
commit 932dd8fbbc
176 changed files with 2271 additions and 1524 deletions

View File

@@ -0,0 +1,171 @@
From c007a75501e40d839902fbc8bbfb4ef291f07bb2 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 21 Feb 2016 23:30:15 +0100
Subject: Revert "wined3d: Introduce wined3d_texture_check_block_align()."
This reverts commit 58719f60d5dca15f0f0de625bc307e04b01fc6d9.
---
dlls/wined3d/surface.c | 31 +++++++++++++++++++++++++++++--
dlls/wined3d/texture.c | 29 -----------------------------
dlls/wined3d/volume.c | 31 +++++++++++++++++++++++++++++--
dlls/wined3d/wined3d_private.h | 2 --
4 files changed, 58 insertions(+), 35 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 7858d15..c1d7b18 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1538,11 +1538,38 @@ void wined3d_surface_upload_data(struct wined3d_surface *surface, const struct w
}
}
+static BOOL surface_check_block_align(struct wined3d_surface *surface, const struct wined3d_box *box)
+{
+ UINT width_mask, height_mask;
+
+ if (!box->left && !box->top
+ && box->right == surface->resource.width
+ && box->bottom == surface->resource.height)
+ return TRUE;
+
+ if ((box->left >= box->right)
+ || (box->top >= box->bottom)
+ || (box->right > surface->resource.width)
+ || (box->bottom > surface->resource.height))
+ return FALSE;
+
+ /* This assumes power of two block sizes, but NPOT block sizes would be
+ * silly anyway. */
+ width_mask = surface->resource.format->block_width - 1;
+ height_mask = surface->resource.format->block_height - 1;
+
+ if (!(box->left & width_mask) && !(box->top & height_mask)
+ && !(box->right & width_mask) && !(box->bottom & height_mask))
+ return TRUE;
+
+ return FALSE;
+}
+
static BOOL surface_check_block_align_rect(struct wined3d_surface *surface, const RECT *rect)
{
struct wined3d_box box = {rect->left, rect->top, rect->right, rect->bottom, 0, 1};
- return wined3d_texture_check_block_align(surface->container, surface->texture_level, &box);
+ return surface_check_block_align(surface, &box);
}
HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,
@@ -2274,7 +2301,7 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
}
if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && box
- && !wined3d_texture_check_block_align(surface->container, surface->texture_level, box))
+ && !surface_check_block_align(surface, box))
{
WARN("Map box %s is misaligned for %ux%u blocks.\n",
debug_box(box), format->block_width, format->block_height);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 804856b..7a24ff0 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1201,35 +1201,6 @@ static const struct wined3d_texture_ops texture3d_ops =
texture3d_prepare_texture,
};
-BOOL wined3d_texture_check_block_align(const struct wined3d_texture *texture,
- unsigned int level, const struct wined3d_box *box)
-{
- const struct wined3d_format *format = texture->resource.format;
- unsigned int height = max(1, texture->resource.height >> level);
- unsigned int width = max(1, texture->resource.width >> level);
- unsigned int width_mask, height_mask;
-
- if ((box->left >= box->right)
- || (box->top >= box->bottom)
- || (box->right > width)
- || (box->bottom > height))
- return FALSE;
-
- /* This assumes power of two block sizes, but NPOT block sizes would be
- * silly anyway.
- *
- * This also assumes that the format's block depth is 1. */
- width_mask = format->block_width - 1;
- height_mask = format->block_height - 1;
-
- if ((box->left & width_mask) || (box->top & height_mask)
- || (box->right & width_mask && box->right != width)
- || (box->bottom & height_mask && box->bottom != height))
- return FALSE;
-
- return TRUE;
-}
-
static HRESULT texture3d_resource_sub_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
{
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 6f5de73..75585d8 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -433,6 +433,34 @@ static void volume_unload(struct wined3d_resource *resource)
resource_unload(resource);
}
+static BOOL volume_check_block_align(const struct wined3d_volume *volume,
+ const struct wined3d_box *box)
+{
+ UINT width_mask, height_mask;
+ const struct wined3d_format *format = volume->resource.format;
+
+ if (!box)
+ return TRUE;
+
+ /* This assumes power of two block sizes, but NPOT block sizes would be
+ * silly anyway.
+ *
+ * This also assumes that the format's block depth is 1. */
+ width_mask = format->block_width - 1;
+ height_mask = format->block_height - 1;
+
+ if (box->left & width_mask)
+ return FALSE;
+ if (box->top & height_mask)
+ return FALSE;
+ if (box->right & width_mask && box->right != volume->resource.width)
+ return FALSE;
+ if (box->bottom & height_mask && box->bottom != volume->resource.height)
+ return FALSE;
+
+ return TRUE;
+}
+
static BOOL wined3d_volume_check_box_dimensions(const struct wined3d_volume *volume,
const struct wined3d_box *box)
{
@@ -484,8 +512,7 @@ HRESULT wined3d_volume_map(struct wined3d_volume *volume,
WARN("Map box is invalid.\n");
return WINED3DERR_INVALIDCALL;
}
- if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && box
- && !wined3d_texture_check_block_align(volume->container, volume->texture_level, box))
+ if ((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !volume_check_block_align(volume, box))
{
WARN("Map box %s is misaligned for %ux%u blocks.\n",
debug_box(box), format->block_width, format->block_height);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index a20bc65..a243727 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2405,8 +2405,6 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
-BOOL wined3d_texture_check_block_align(const struct wined3d_texture *texture,
- unsigned int level, const struct wined3d_box *box) DECLSPEC_HIDDEN;
void wined3d_texture_force_reload(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
--
2.7.1

View File

@@ -0,0 +1,76 @@
From fde2bdfb77c46121de1617f90fbb20662d208edd Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 21 Feb 2016 23:34:22 +0100
Subject: Revert "wined3d: Introduce wined3d_texture_get_pitch()."
This partially reverts commit 65c04ce0409d870bc42ef466027120388abdb83c.
---
dlls/wined3d/surface.c | 11 ++++++++++-
dlls/wined3d/texture.c | 9 ++-------
dlls/wined3d/wined3d_private.h | 1 -
3 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 62a1a3c..dad5c22 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1909,7 +1909,16 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
surface->resource.format = texture_resource->format;
surface->resource.multisample_type = texture_resource->multisample_type;
surface->resource.multisample_quality = texture_resource->multisample_quality;
- surface->resource.size = surface->container->slice_pitch;
+ if (surface->container->row_pitch)
+ {
+ surface->resource.size = height * surface->container->row_pitch;
+ }
+ else
+ {
+ /* User memory surfaces don't have the regular surface alignment. */
+ wined3d_format_calculate_pitch(texture_resource->format, 1, width, height,
+ &surface->container->row_pitch, &surface->resource.size);
+ }
/* The format might be changed to a format that needs conversion.
* If the surface didn't use PBOs previously but could now, don't
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index b4f679c..487b2ef 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -502,7 +502,7 @@ void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture,
if (texture->row_pitch)
{
*row_pitch = texture->row_pitch;
- *slice_pitch = texture->slice_pitch;
+ *slice_pitch = *row_pitch * height;
return;
}
@@ -656,12 +656,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
texture->resource.height = height;
texture->user_memory = mem;
- if ((texture->row_pitch = pitch))
- texture->slice_pitch = height * pitch;
- else
- /* User memory surfaces don't have the regular surface alignment. */
- wined3d_format_calculate_pitch(format, 1, width, height,
- &texture->row_pitch, &texture->slice_pitch);
+ texture->row_pitch = pitch;
texture->flags &= ~WINED3D_TEXTURE_COND_NP2_EMULATED;
if (((width & (width - 1)) || (height & (height - 1))) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0ef64c1..3433ae1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2367,7 +2367,6 @@ struct wined3d_texture
void *user_memory;
unsigned int row_pitch;
- unsigned int slice_pitch;
/* May only be accessed from the command stream worker thread. */
struct wined3d_texture_async
--
2.7.1

View File

@@ -0,0 +1,55 @@
From 979c38f3099fa1d537710254c6f2961e6de7d6d9 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 21 Feb 2016 23:34:31 +0100
Subject: Revert "wined3d: Use wined3d_format_calculate_pitch() in
surface_download_data()."
This reverts commit a95524b8f3abfaa28fc21055d95d4a087a9b6d69.
---
dlls/wined3d/surface.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 93bf718..59c6e5c 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1325,17 +1325,18 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
else
{
unsigned int dst_row_pitch, dst_slice_pitch;
- unsigned int src_row_pitch, src_slice_pitch;
+ unsigned int src_pitch;
GLenum gl_format = format->glFormat;
GLenum gl_type = format->glType;
void *mem;
if (surface->container->flags & WINED3D_TEXTURE_COND_NP2_EMULATED)
{
+ unsigned char alignment = surface->resource.device->surface_alignment;
+ src_pitch = format->byte_count * surface->pow2Width;
wined3d_texture_get_pitch(surface->container, surface->texture_level, &dst_row_pitch, &dst_slice_pitch);
- wined3d_format_calculate_pitch(format, surface->resource.device->surface_alignment,
- surface->pow2Width, surface->pow2Height, &src_row_pitch, &src_slice_pitch);
- mem = HeapAlloc(GetProcessHeap(), 0, src_slice_pitch);
+ src_pitch = (src_pitch + alignment - 1) & ~(alignment - 1);
+ mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * surface->pow2Height);
}
else
{
@@ -1420,11 +1421,11 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
* won't be released, and doesn't have to be re-read. */
src_data = mem;
dst_data = data.addr;
- TRACE("Repacking the surface data from pitch %u to pitch %u.\n", src_row_pitch, dst_row_pitch);
+ TRACE("(%p) : Repacking the surface data from pitch %d to pitch %d\n", surface, src_pitch, dst_row_pitch);
for (y = 0; y < surface->resource.height; ++y)
{
memcpy(dst_data, src_data, dst_row_pitch);
- src_data += src_row_pitch;
+ src_data += src_pitch;
dst_data += dst_row_pitch;
}
--
2.7.1

View File

@@ -1,377 +0,0 @@
From 0121313746277d4ade36ddf19f616fbbb481304e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Thu, 19 Sep 2013 14:22:24 +0200
Subject: wined3d: Merge get_pitch functions.
---
dlls/wined3d/resource.c | 31 +++++++++++++++++
dlls/wined3d/surface.c | 75 +++++++++++++++++++-----------------------
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/volume.c | 28 ++--------------
dlls/wined3d/wined3d_private.h | 5 +--
5 files changed, 70 insertions(+), 71 deletions(-)
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 44cdb43..ed598cc 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -440,3 +440,34 @@ void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
else
resource->draw_binding = WINED3D_LOCATION_TEXTURE_RGB;
}
+
+void wined3d_resource_get_pitch(const struct wined3d_resource *resource, UINT *row_pitch,
+ UINT *slice_pitch)
+{
+ unsigned int alignment;
+ const struct wined3d_format *format = resource->format;
+
+ if (resource->custom_row_pitch)
+ {
+ *row_pitch = resource->custom_row_pitch;
+ *slice_pitch = resource->custom_slice_pitch;
+ return;
+ }
+
+ alignment = resource->device->surface_alignment;
+ *row_pitch = wined3d_format_calculate_pitch(resource->format, resource->width);
+ *row_pitch = (*row_pitch + alignment - 1) & ~(alignment - 1);
+ if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BLOCKS)
+ {
+ /* Since compressed formats are block based, pitch means the amount of
+ * bytes to the next row of block rather than the next row of pixels. */
+ UINT slice_block_count = (resource->height + format->block_height - 1) / format->block_height;
+ *slice_pitch = *row_pitch * slice_block_count;
+ }
+ else
+ {
+ *slice_pitch = *row_pitch * resource->height;
+ }
+
+ TRACE("Returning row pitch %u, slice pitch %u.\n", *row_pitch, *slice_pitch);
+}
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 65cb3b7..293b78d 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -364,6 +364,7 @@ HRESULT surface_create_dib_section(struct wined3d_surface *surface)
BITMAPINFO *b_info;
int extraline = 0;
DWORD *masks;
+ UINT row_pitch, slice_pitch;
TRACE("surface %p.\n", surface);
@@ -409,10 +410,11 @@ HRESULT surface_create_dib_section(struct wined3d_surface *surface)
b_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
/* TODO: Is there a nicer way to force a specific alignment? (8 byte for ddraw) */
- b_info->bmiHeader.biWidth = wined3d_surface_get_pitch(surface) / format->byte_count;
+ wined3d_resource_get_pitch(&surface->resource, &row_pitch, &slice_pitch);
+ b_info->bmiHeader.biWidth = row_pitch / format->byte_count;
b_info->bmiHeader.biHeight = 0 - surface->resource.height - extraline;
b_info->bmiHeader.biSizeImage = (surface->resource.height + extraline)
- * wined3d_surface_get_pitch(surface);
+ * row_pitch;
b_info->bmiHeader.biPlanes = 1;
b_info->bmiHeader.biBitCount = format->byte_count * 8;
@@ -1332,14 +1334,14 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
void *mem;
GLenum gl_format = format->glFormat;
GLenum gl_type = format->glType;
- int src_pitch = 0;
- int dst_pitch = 0;
+ UINT src_pitch = 0;
+ UINT dst_row_pitch, dst_slice_pitch;
if (surface->flags & SFLAG_NONPOW2)
{
unsigned char alignment = surface->resource.device->surface_alignment;
src_pitch = format->byte_count * surface->pow2Width;
- dst_pitch = wined3d_surface_get_pitch(surface);
+ wined3d_resource_get_pitch(&surface->resource, &dst_row_pitch, &dst_slice_pitch);
src_pitch = (src_pitch + alignment - 1) & ~(alignment - 1);
mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * surface->pow2Height);
}
@@ -1426,12 +1428,12 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
* won't be released, and doesn't have to be re-read. */
src_data = mem;
dst_data = data.addr;
- TRACE("(%p) : Repacking the surface data from pitch %d to pitch %d\n", surface, src_pitch, dst_pitch);
+ TRACE("(%p) : Repacking the surface data from pitch %d to pitch %d\n", surface, src_pitch, dst_row_pitch);
for (y = 0; y < surface->resource.height; ++y)
{
- memcpy(dst_data, src_data, dst_pitch);
+ memcpy(dst_data, src_data, dst_row_pitch);
src_data += src_pitch;
- dst_data += dst_pitch;
+ dst_data += dst_row_pitch;
}
HeapFree(GetProcessHeap(), 0, mem);
@@ -1599,7 +1601,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
UINT update_w, update_h;
UINT dst_w, dst_h;
RECT r, dst_rect;
- UINT src_pitch;
+ UINT src_row_pitch, src_slice_pitch;
POINT p;
TRACE("dst_surface %p, dst_point %s, src_surface %p, src_rect %s.\n",
@@ -1687,10 +1689,10 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
wined3d_texture_bind_and_dirtify(dst_surface->container, context, FALSE);
surface_get_memory(src_surface, &data, src_surface->locations);
- src_pitch = wined3d_surface_get_pitch(src_surface);
+ wined3d_resource_get_pitch(&src_surface->resource, &src_row_pitch, &src_slice_pitch);
wined3d_surface_upload_data(dst_surface, gl_info, src_format, src_rect,
- src_pitch, dst_point, FALSE, wined3d_const_bo_address(&data));
+ src_row_pitch, dst_point, FALSE, wined3d_const_bo_address(&data));
context_release(context);
@@ -1892,21 +1894,10 @@ void * CDECL wined3d_surface_get_parent(const struct wined3d_surface *surface)
DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
{
- unsigned int alignment;
- DWORD pitch;
-
- TRACE("surface %p.\n", surface);
-
- if (surface->pitch)
- return surface->pitch;
-
- alignment = surface->resource.device->surface_alignment;
- pitch = wined3d_format_calculate_pitch(surface->resource.format, surface->resource.width);
- pitch = (pitch + alignment - 1) & ~(alignment - 1);
-
- TRACE("Returning %u.\n", pitch);
-
- return pitch;
+ UINT row_pitch, slice_pitch;
+ const struct wined3d_resource *resource = &surface->resource;
+ wined3d_resource_get_pitch(resource, &row_pitch, &slice_pitch);
+ return row_pitch;
}
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
@@ -1959,20 +1950,21 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
valid_location = WINED3D_LOCATION_USER_MEMORY;
}
- surface->pitch = pitch;
+ surface->resource.custom_row_pitch = pitch;
+ surface->resource.custom_slice_pitch = pitch * surface->resource.height;
surface->resource.format = texture_resource->format;
surface->resource.multisample_type = texture_resource->multisample_type;
surface->resource.multisample_quality = texture_resource->multisample_quality;
- if (surface->pitch)
+ if (surface->resource.custom_row_pitch)
{
- surface->resource.size = height * surface->pitch;
+ surface->resource.size = height * surface->resource.custom_row_pitch;
}
else
{
/* User memory surfaces don't have the regular surface alignment. */
surface->resource.size = wined3d_format_calculate_size(texture_resource->format,
1, width, height, 1);
- surface->pitch = wined3d_format_calculate_pitch(texture_resource->format, width);
+ surface->resource.custom_row_pitch = wined3d_format_calculate_pitch(texture_resource->format, width);
}
/* The format might be changed to a format that needs conversion.
@@ -2594,7 +2586,7 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
if (fmt_flags & WINED3DFMT_FLAG_BROKEN_PITCH)
map_desc->row_pitch = surface->resource.width * format->byte_count;
else
- map_desc->row_pitch = wined3d_surface_get_pitch(surface);
+ wined3d_resource_get_pitch(&surface->resource, &map_desc->row_pitch, &map_desc->slice_pitch);
map_desc->slice_pitch = surface->resource.height * map_desc->row_pitch;
if (!box)
@@ -2645,6 +2637,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
int i;
BOOL srcIsUpsideDown;
struct wined3d_bo_address data;
+ DWORD slice_pitch, pitch;
surface_get_memory(surface, &data, dst_location);
@@ -2686,8 +2679,8 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
}
/* Setup pixel store pack state -- to glReadPixels into the correct place */
- gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH,
- wined3d_surface_get_pitch(surface) / surface->resource.format->byte_count);
+ wined3d_resource_get_pitch(&surface->resource, &pitch, &slice_pitch);
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, pitch / surface->resource.format->byte_count);
checkGLcall("glPixelStorei");
gl_info->gl_ops.gl.p_glReadPixels(0, 0,
@@ -2704,8 +2697,6 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
{
/* glReadPixels returns the image upside down, and there is no way to prevent this.
* Flip the lines in software. */
- UINT pitch = wined3d_surface_get_pitch(surface);
-
if (!(row = HeapAlloc(GetProcessHeap(), 0, pitch)))
goto error;
@@ -3859,7 +3850,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
struct wined3d_device *device = surface->resource.device;
const struct wined3d_color_key_conversion *conversion;
struct wined3d_texture *texture = surface->container;
- UINT width, src_pitch, dst_pitch;
+ UINT width, src_row_pitch, src_slice_pitch, dst_pitch;
struct wined3d_bo_address data;
struct wined3d_format format;
POINT dst_point = {0, 0};
@@ -3944,7 +3935,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
wined3d_texture_bind_and_dirtify(texture, context, srgb);
width = surface->resource.width;
- src_pitch = wined3d_surface_get_pitch(surface);
+ wined3d_resource_get_pitch(&surface->resource, &src_row_pitch, &src_slice_pitch);
format = *texture->resource.format;
if ((conversion = wined3d_format_get_color_key_conversion(texture, TRUE)))
@@ -3982,9 +3973,9 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
context_release(context);
return E_OUTOFMEMORY;
}
- format.convert(data.addr, mem, src_pitch, src_pitch * height,
+ format.convert(data.addr, mem, src_row_pitch, src_row_pitch * height,
dst_pitch, dst_pitch * height, width, height, 1);
- src_pitch = dst_pitch;
+ src_row_pitch = dst_pitch;
data.addr = mem;
}
else if (conversion)
@@ -4004,14 +3995,14 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
}
if (texture->swapchain && texture->swapchain->palette)
palette = texture->swapchain->palette;
- conversion->convert(data.addr, src_pitch, mem, dst_pitch,
+ conversion->convert(data.addr, src_row_pitch, mem, dst_pitch,
width, height, palette, &texture->async.gl_color_key);
- src_pitch = dst_pitch;
+ src_row_pitch = dst_pitch;
data.addr = mem;
}
wined3d_surface_upload_data(surface, gl_info, &format, &src_rect,
- src_pitch, &dst_point, srgb, wined3d_const_bo_address(&data));
+ src_row_pitch, &dst_point, srgb, wined3d_const_bo_address(&data));
HeapFree(GetProcessHeap(), 0, mem);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 0c48c91..8646e82 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1141,7 +1141,7 @@ static void texture3d_sub_resource_upload_data(struct wined3d_resource *sub_reso
struct wined3d_const_bo_address addr;
unsigned int row_pitch, slice_pitch;
- wined3d_volume_get_pitch(volume, &row_pitch, &slice_pitch);
+ wined3d_resource_get_pitch(sub_resource, &row_pitch, &slice_pitch);
if (row_pitch != data->row_pitch || slice_pitch != data->slice_pitch)
FIXME("Ignoring row/slice pitch (%u/%u).\n", data->row_pitch, data->slice_pitch);
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 3ac7f98..9235f3f 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -40,30 +40,6 @@ BOOL volume_prepare_system_memory(struct wined3d_volume *volume)
return TRUE;
}
-void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pitch, UINT *slice_pitch)
-{
- const struct wined3d_format *format = volume->resource.format;
-
- if (volume->container->resource.format_flags & WINED3DFMT_FLAG_BLOCKS)
- {
- /* Since compressed formats are block based, pitch means the amount of
- * bytes to the next row of block rather than the next row of pixels. */
- UINT row_block_count = (volume->resource.width + format->block_width - 1) / format->block_width;
- UINT slice_block_count = (volume->resource.height + format->block_height - 1) / format->block_height;
- *row_pitch = row_block_count * format->block_byte_count;
- *slice_pitch = *row_pitch * slice_block_count;
- }
- else
- {
- unsigned char alignment = volume->resource.device->surface_alignment;
- *row_pitch = format->byte_count * volume->resource.width; /* Bytes / row */
- *row_pitch = (*row_pitch + alignment - 1) & ~(alignment - 1);
- *slice_pitch = *row_pitch * volume->resource.height;
- }
-
- TRACE("Returning row pitch %u, slice pitch %u.\n", *row_pitch, *slice_pitch);
-}
-
/* This call just uploads data, the caller is responsible for binding the
* correct texture. */
/* Context activation is done by the caller. */
@@ -95,7 +71,7 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
dst_row_pitch = width * format->conv_byte_count;
dst_slice_pitch = dst_row_pitch * height;
- wined3d_volume_get_pitch(volume, &src_row_pitch, &src_slice_pitch);
+ wined3d_resource_get_pitch(&volume->resource, &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,
@@ -607,7 +583,7 @@ HRESULT wined3d_volume_map(struct wined3d_volume *volume,
}
else
{
- wined3d_volume_get_pitch(volume, &map_desc->row_pitch, &map_desc->slice_pitch);
+ wined3d_resource_get_pitch(&volume->resource, &map_desc->row_pitch, &map_desc->slice_pitch);
}
if (!box)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 8b2cdb2..a0b7681 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2276,6 +2276,7 @@ struct wined3d_resource
UINT size;
DWORD priority;
void *heap_memory;
+ UINT custom_row_pitch, custom_slice_pitch;
struct list resource_list_entry;
void *parent;
@@ -2303,6 +2304,8 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void wined3d_resource_get_pitch(const struct wined3d_resource *resource, UINT *row_pitch,
+ UINT *slice_pitch) DECLSPEC_HIDDEN;
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
@@ -2438,7 +2441,6 @@ BOOL volume_prepare_system_memory(struct wined3d_volume *volume) DECLSPEC_HIDDEN
HRESULT wined3d_volume_create(struct wined3d_texture *container, const struct wined3d_resource_desc *desc,
unsigned int level, struct wined3d_volume **volume) DECLSPEC_HIDDEN;
void wined3d_volume_destroy(struct wined3d_volume *volume) DECLSPEC_HIDDEN;
-void wined3d_volume_get_pitch(const struct wined3d_volume *volume, UINT *row_pitch, UINT *slice_pitch) DECLSPEC_HIDDEN;
void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *context,
BOOL srgb_mode) DECLSPEC_HIDDEN;
void wined3d_volume_invalidate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN;
@@ -2491,7 +2493,6 @@ struct wined3d_surface
DWORD flags;
- UINT pitch;
UINT pow2Width;
UINT pow2Height;
--
2.7.0

View File

@@ -0,0 +1,250 @@
From d26ecafd4c77d62749ea0fe0e7cb4a4cfbad2845 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 21 Feb 2016 23:34:42 +0100
Subject: Revert "wined3d: Handle slice pitch and alignment as well in
wined3d_format_calculate_pitch()."
This reverts commit a0beaa4006b0261587204fdecc08ba0bd941567d.
---
dlls/wined3d/directx.c | 6 +-----
dlls/wined3d/surface.c | 29 +++++++++++++------------
dlls/wined3d/texture.c | 25 +++++++++++++++++++--
dlls/wined3d/utils.c | 49 +++++++++++++++++++++---------------------
dlls/wined3d/wined3d_private.h | 3 +--
5 files changed, 64 insertions(+), 48 deletions(-)
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c
index 5f995ce..329da15 100644
--- a/dlls/wined3d/directx.c
+++ b/dlls/wined3d/directx.c
@@ -4756,7 +4756,6 @@ UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT ad
enum wined3d_format_id format_id, UINT width)
{
const struct wined3d_gl_info *gl_info;
- unsigned int row_pitch, slice_pitch;
TRACE("wined3d %p, adapter_idx %u, format_id %s, width %u.\n",
wined3d, adapter_idx, debug_d3dformat(format_id), width);
@@ -4765,10 +4764,7 @@ UINT CDECL wined3d_calculate_format_pitch(const struct wined3d *wined3d, UINT ad
return ~0u;
gl_info = &wined3d->adapters[adapter_idx].gl_info;
- wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id),
- 1, width, 1, &row_pitch, &slice_pitch);
-
- return row_pitch;
+ return wined3d_format_calculate_pitch(wined3d_get_format(gl_info, format_id), width);
}
HRESULT CDECL wined3d_check_device_format_conversion(const struct wined3d *wined3d, UINT adapter_idx,
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 4d11787..5182b29 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1917,8 +1917,9 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
else
{
/* User memory surfaces don't have the regular surface alignment. */
- wined3d_format_calculate_pitch(texture_resource->format, 1, width, height,
- &surface->container->row_pitch, &surface->resource.size);
+ surface->resource.size = wined3d_format_calculate_size(texture_resource->format,
+ 1, width, height, 1);
+ surface->container->row_pitch = wined3d_format_calculate_pitch(texture_resource->format, width);
}
/* The format might be changed to a format that needs conversion.
@@ -3806,7 +3807,7 @@ static HRESULT surface_load_drawable(struct wined3d_surface *surface,
static HRESULT surface_load_texture(struct wined3d_surface *surface,
struct wined3d_context *context, BOOL srgb)
{
- unsigned int width, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch;
+ unsigned int width, src_row_pitch, src_slice_pitch, dst_pitch;
const RECT src_rect = {0, 0, surface->resource.width, surface->resource.height};
const struct wined3d_gl_info *gl_info = context->gl_info;
struct wined3d_device *device = surface->resource.device;
@@ -3926,17 +3927,17 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
UINT height = surface->resource.height;
format.byte_count = format.conv_byte_count;
- wined3d_format_calculate_pitch(&format, 1, width, height, &dst_row_pitch, &dst_slice_pitch);
+ dst_pitch = wined3d_format_calculate_pitch(&format, width);
- if (!(mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch)))
+ if (!(mem = HeapAlloc(GetProcessHeap(), 0, dst_pitch * height)))
{
- ERR("Out of memory (%u).\n", dst_slice_pitch);
+ ERR("Out of memory (%u).\n", dst_pitch * height);
context_release(context);
return E_OUTOFMEMORY;
}
format.convert(data.addr, mem, src_row_pitch, src_slice_pitch,
- dst_row_pitch, dst_slice_pitch, width, height, 1);
- src_row_pitch = dst_row_pitch;
+ dst_pitch, dst_pitch * height, width, height, 1);
+ src_row_pitch = dst_pitch;
data.addr = mem;
}
else if (conversion)
@@ -3945,20 +3946,20 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
struct wined3d_palette *palette = NULL;
UINT height = surface->resource.height;
- wined3d_format_calculate_pitch(&format, device->surface_alignment,
- width, height, &dst_row_pitch, &dst_slice_pitch);
+ dst_pitch = wined3d_format_calculate_pitch(&format, width);
+ dst_pitch = (dst_pitch + device->surface_alignment - 1) & ~(device->surface_alignment - 1);
- if (!(mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch)))
+ if (!(mem = HeapAlloc(GetProcessHeap(), 0, dst_pitch * height)))
{
- ERR("Out of memory (%u).\n", dst_slice_pitch);
+ ERR("Out of memory (%u).\n", dst_pitch * height);
context_release(context);
return E_OUTOFMEMORY;
}
if (texture->swapchain && texture->swapchain->palette)
palette = texture->swapchain->palette;
- conversion->convert(data.addr, src_row_pitch, mem, dst_row_pitch,
+ conversion->convert(data.addr, src_row_pitch, mem, dst_pitch,
width, height, palette, &texture->async.gl_color_key);
- src_row_pitch = dst_row_pitch;
+ src_row_pitch = dst_pitch;
data.addr = mem;
}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 487b2ef..8fe6251 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -496,6 +496,8 @@ void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture,
unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
{
const struct wined3d_resource *resource = &texture->resource;
+ const struct wined3d_format *format = resource->format;
+ unsigned int alignment = resource->device->surface_alignment;
unsigned int width = max(1, texture->resource.width >> level);
unsigned int height = max(1, texture->resource.height >> level);
@@ -506,8 +508,27 @@ void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture,
return;
}
- wined3d_format_calculate_pitch(resource->format, resource->device->surface_alignment,
- width, height, row_pitch, slice_pitch);
+ if (resource->format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BLOCKS)
+ {
+ unsigned int row_block_count = (width + format->block_width - 1) / format->block_width;
+ unsigned int slice_block_count = (height + format->block_height - 1) / format->block_height;
+ *row_pitch = row_block_count * format->block_byte_count;
+ *row_pitch = (*row_pitch + alignment - 1) & ~(alignment - 1);
+ *slice_pitch = *row_pitch * slice_block_count;
+ }
+ else
+ {
+ *row_pitch = format->byte_count * width; /* Bytes / row */
+ *row_pitch = (*row_pitch + alignment - 1) & ~(alignment - 1);
+ *slice_pitch = *row_pitch * height;
+ }
+
+ if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_HEIGHT_SCALE)
+ {
+ /* The D3D format requirements make sure that the resulting format is an integer again */
+ *slice_pitch *= format->height_scale.numerator;
+ *slice_pitch /= format->height_scale.denominator;
+ }
}
DWORD CDECL wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod)
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index b52b967..81fb262 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -3199,47 +3199,46 @@ const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl
return &gl_info->formats[idx];
}
-void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
- unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch)
+UINT wined3d_format_calculate_pitch(const struct wined3d_format *format, UINT width)
{
/* For block based formats, pitch means the amount of bytes to the next
* row of blocks rather than the next row of pixels. */
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BLOCKS)
+ return format->block_byte_count * ((width + format->block_width - 1) / format->block_width);
+
+ return format->byte_count * width;
+}
+
+UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT alignment,
+ UINT width, UINT height, UINT depth)
+{
+ UINT pitch = wined3d_format_calculate_pitch(format, width);
+ UINT size;
+
+ if (format->id == WINED3DFMT_UNKNOWN)
+ {
+ size = 0;
+ }
+ else if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BLOCKS)
{
- unsigned int row_block_count = (width + format->block_width - 1) / format->block_width;
- unsigned int slice_block_count = (height + format->block_height - 1) / format->block_height;
- *row_pitch = row_block_count * format->block_byte_count;
- *row_pitch = (*row_pitch + alignment - 1) & ~(alignment - 1);
- *slice_pitch = *row_pitch * slice_block_count;
+ UINT row_count = (height + format->block_height - 1) / format->block_height;
+ size = row_count * ((pitch + alignment - 1) & ~(alignment - 1));
}
else
{
- *row_pitch = format->byte_count * width; /* Bytes / row */
- *row_pitch = (*row_pitch + alignment - 1) & ~(alignment - 1);
- *slice_pitch = *row_pitch * height;
+ size = height * ((pitch + alignment - 1) & ~(alignment - 1));
}
if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_HEIGHT_SCALE)
{
/* The D3D format requirements make sure that the resulting format is an integer again */
- *slice_pitch *= format->height_scale.numerator;
- *slice_pitch /= format->height_scale.denominator;
+ size *= format->height_scale.numerator;
+ size /= format->height_scale.denominator;
}
- TRACE("Returning row pitch %u, slice pitch %u.\n", *row_pitch, *slice_pitch);
-}
-
-UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT alignment,
- UINT width, UINT height, UINT depth)
-{
- unsigned int row_pitch, slice_pitch;
+ size *= depth;
- if (format->id == WINED3DFMT_UNKNOWN)
- return 0;
-
- wined3d_format_calculate_pitch(format, alignment, width, height, &row_pitch, &slice_pitch);
-
- return slice_pitch * depth;
+ return size;
}
/*****************************************************************************
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3433ae1..712267c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3347,8 +3347,7 @@ struct wined3d_format
const struct wined3d_format *wined3d_get_format(const struct wined3d_gl_info *gl_info,
enum wined3d_format_id format_id) DECLSPEC_HIDDEN;
-void wined3d_format_calculate_pitch(const struct wined3d_format *format, unsigned int alignment,
- unsigned int width, unsigned int height, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
+UINT wined3d_format_calculate_pitch(const struct wined3d_format *format, UINT width) DECLSPEC_HIDDEN;
UINT wined3d_format_calculate_size(const struct wined3d_format *format,
UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
DWORD wined3d_format_convert_from_float(const struct wined3d_surface *surface,
--
2.7.1

View File

@@ -1,33 +1,22 @@
From c40334a562447ca292f9699a1d3b2b725a78c844 Mon Sep 17 00:00:00 2001
From ced9d2e5e64407781a03c6e3e619fc36ecee4d45 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 10 Feb 2016 02:05:11 +0100
Subject: Revert "wined3d: Store custom pitches in the texture instead of the
surface."
This reverts commit 195d16c8267fcd5085048b3513571e2fee0eb548.
This partially reverts commit 195d16c8267fcd5085048b3513571e2fee0eb548.
---
dlls/wined3d/surface.c | 14 ++++++++------
dlls/wined3d/texture.c | 3 +--
dlls/wined3d/wined3d_private.h | 4 ++--
3 files changed, 11 insertions(+), 10 deletions(-)
dlls/wined3d/surface.c | 10 ++++++----
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/wined3d_private.h | 3 ++-
3 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 665af4a..65e07c5 100644
index 5182b29..0a8509c 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1897,8 +1897,8 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
TRACE("surface %p.\n", surface);
- if (surface->container->row_pitch)
- return surface->container->row_pitch;
+ if (surface->pitch)
+ return surface->pitch;
alignment = surface->resource.device->surface_alignment;
pitch = wined3d_format_calculate_pitch(surface->resource.format, surface->resource.width);
@@ -1909,7 +1909,8 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
return pitch;
@@ -1863,7 +1863,8 @@ static inline unsigned short float_32_to_16(const float *in)
return ret;
}
-HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
@@ -36,7 +25,7 @@ index 665af4a..65e07c5 100644
{
struct wined3d_resource *texture_resource = &surface->container->resource;
unsigned int width, height;
@@ -1958,19 +1959,20 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
@@ -1907,19 +1908,20 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struc
surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
valid_location = WINED3D_LOCATION_USER_MEMORY;
}
@@ -61,14 +50,12 @@ index 665af4a..65e07c5 100644
/* The format might be changed to a format that needs conversion.
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 0a084de..4ded4ca 100644
index 8fe6251..f0ed152 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -645,9 +645,8 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
texture->resource.height = height;
texture->user_memory = mem;
- texture->row_pitch = pitch;
@@ -684,7 +684,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
&& !gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
- return wined3d_surface_update_desc(surface, gl_info);
+ return wined3d_surface_update_desc(surface, gl_info, pitch);
@@ -76,18 +63,10 @@ index 0a084de..4ded4ca 100644
void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3fadff6..2ff3b99 100644
index 712267c..1cf309c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2365,7 +2365,6 @@ struct wined3d_texture
GLenum target;
void *user_memory;
- unsigned int row_pitch;
/* May only be accessed from the command stream worker thread. */
struct wined3d_texture_async
@@ -2493,6 +2492,7 @@ struct wined3d_surface
@@ -2498,6 +2498,7 @@ struct wined3d_surface
DWORD flags;
@@ -95,7 +74,7 @@ index 3fadff6..2ff3b99 100644
UINT pow2Width;
UINT pow2Height;
@@ -2570,7 +2570,7 @@ void surface_set_texture_target(struct wined3d_surface *surface, GLenum target,
@@ -2575,7 +2576,7 @@ void surface_set_texture_target(struct wined3d_surface *surface, GLenum target,
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
HRESULT wined3d_surface_unmap(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
@@ -105,5 +84,5 @@ index 3fadff6..2ff3b99 100644
struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN;
void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
--
2.7.0
2.7.1

View File

@@ -1,4 +1,4 @@
From 351ce90ef3980bf24e295982bc4046708255ad1e Mon Sep 17 00:00:00 2001
From adf0f2d92cb2c1711518bf519c1c96fb64ceef5a Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 10 Feb 2016 02:05:20 +0100
Subject: Revert "wined3d: Store the "user_memory" pointer in the texture
@@ -7,12 +7,12 @@ Subject: Revert "wined3d: Store the "user_memory" pointer in the texture
This reverts commit 77088e3faaded7f583903102240b9a2879a42fe8.
---
dlls/wined3d/surface.c | 10 +++++-----
dlls/wined3d/texture.c | 4 +---
dlls/wined3d/wined3d_private.h | 5 ++---
3 files changed, 8 insertions(+), 11 deletions(-)
dlls/wined3d/texture.c | 3 +--
dlls/wined3d/wined3d_private.h | 4 ++--
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 65e07c5..65cb3b7 100644
index cdbb2be..0be82ff 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -488,7 +488,7 @@ static void surface_get_memory(const struct wined3d_surface *surface, struct win
@@ -33,7 +33,7 @@ index 65e07c5..65cb3b7 100644
ERR("Map binding is set to WINED3D_LOCATION_USER_MEMORY but surface->user_memory is NULL.\n");
break;
@@ -1910,7 +1910,7 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
@@ -1897,7 +1897,7 @@ DWORD wined3d_surface_get_pitch(const struct wined3d_surface *surface)
}
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
@@ -42,16 +42,16 @@ index 65e07c5..65cb3b7 100644
{
struct wined3d_resource *texture_resource = &surface->container->resource;
unsigned int width, height;
@@ -1954,7 +1954,7 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
else
surface->flags &= ~SFLAG_NONPOW2;
@@ -1936,7 +1936,7 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
surface->pow2Height <<= 1;
}
- if (surface->container->user_memory)
+ if ((surface->user_memory = mem))
{
surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
valid_location = WINED3D_LOCATION_USER_MEMORY;
@@ -2567,7 +2567,7 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
@@ -2549,7 +2549,7 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
break;
case WINED3D_LOCATION_USER_MEMORY:
@@ -61,34 +61,39 @@ index 65e07c5..65cb3b7 100644
case WINED3D_LOCATION_DIB:
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 4ded4ca..0c48c91 100644
index e1786c9..ea04663 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -644,9 +644,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
@@ -685,7 +685,6 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
texture->resource.width = width;
texture->resource.height = height;
- texture->user_memory = mem;
-
texture->row_pitch = pitch;
texture->flags &= ~WINED3D_TEXTURE_COND_NP2_EMULATED;
@@ -693,7 +692,7 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
&& !gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
- return wined3d_surface_update_desc(surface, gl_info, pitch);
+ return wined3d_surface_update_desc(surface, gl_info, mem, pitch);
}
void wined3d_texture_prepare_texture(struct wined3d_texture *texture, struct wined3d_context *context, BOOL srgb)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 2ff3b99..8b2cdb2 100644
index c486c92..a7ba298 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2364,8 +2364,6 @@ struct wined3d_texture
@@ -2366,7 +2366,6 @@ struct wined3d_texture
DWORD flags;
GLenum target;
- void *user_memory;
-
unsigned int row_pitch;
/* May only be accessed from the command stream worker thread. */
struct wined3d_texture_async
{
@@ -2488,6 +2486,7 @@ struct wined3d_surface
@@ -2491,6 +2490,7 @@ struct wined3d_surface
struct wined3d_resource resource;
const struct wined3d_surface_ops *surface_ops;
struct wined3d_texture *container;
@@ -96,7 +101,7 @@ index 2ff3b99..8b2cdb2 100644
DWORD locations;
DWORD flags;
@@ -2570,7 +2569,7 @@ void surface_set_texture_target(struct wined3d_surface *surface, GLenum target,
@@ -2574,7 +2574,7 @@ void surface_set_texture_target(struct wined3d_surface *surface, GLenum target,
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
HRESULT wined3d_surface_unmap(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
@@ -106,5 +111,5 @@ index 2ff3b99..8b2cdb2 100644
struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN;
void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
--
2.7.0
2.7.1

View File

@@ -0,0 +1,195 @@
From 2d4d9e65962f93d9aabea0aa891cc95fa1b8ccdc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Thu, 19 Sep 2013 14:22:24 +0200
Subject: wined3d: Merge get_pitch functions.
---
dlls/wined3d/resource.c | 31 +++++++++++++++++++++++++++++++
dlls/wined3d/surface.c | 22 +++++++++++-----------
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/volume.c | 2 +-
dlls/wined3d/wined3d_private.h | 4 +++-
5 files changed, 47 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 44cdb43..ed598cc 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -440,3 +440,34 @@ void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
else
resource->draw_binding = WINED3D_LOCATION_TEXTURE_RGB;
}
+
+void wined3d_resource_get_pitch(const struct wined3d_resource *resource, UINT *row_pitch,
+ UINT *slice_pitch)
+{
+ unsigned int alignment;
+ const struct wined3d_format *format = resource->format;
+
+ if (resource->custom_row_pitch)
+ {
+ *row_pitch = resource->custom_row_pitch;
+ *slice_pitch = resource->custom_slice_pitch;
+ return;
+ }
+
+ alignment = resource->device->surface_alignment;
+ *row_pitch = wined3d_format_calculate_pitch(resource->format, resource->width);
+ *row_pitch = (*row_pitch + alignment - 1) & ~(alignment - 1);
+ if (format->flags[WINED3D_GL_RES_TYPE_TEX_2D] & WINED3DFMT_FLAG_BLOCKS)
+ {
+ /* Since compressed formats are block based, pitch means the amount of
+ * bytes to the next row of block rather than the next row of pixels. */
+ UINT slice_block_count = (resource->height + format->block_height - 1) / format->block_height;
+ *slice_pitch = *row_pitch * slice_block_count;
+ }
+ else
+ {
+ *slice_pitch = *row_pitch * resource->height;
+ }
+
+ TRACE("Returning row pitch %u, slice pitch %u.\n", *row_pitch, *slice_pitch);
+}
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index aff6162..418efa3 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -395,7 +395,7 @@ HRESULT surface_create_dib_section(struct wined3d_surface *surface)
return E_OUTOFMEMORY;
b_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- wined3d_texture_get_pitch(surface->container, surface->texture_level, &row_pitch, &slice_pitch);
+ wined3d_resource_get_pitch(&surface->resource, &row_pitch, &slice_pitch);
b_info->bmiHeader.biWidth = row_pitch / format->byte_count;
b_info->bmiHeader.biHeight = 0 - surface->resource.height;
b_info->bmiHeader.biSizeImage = slice_pitch;
@@ -1319,7 +1319,7 @@ static void surface_download_data(struct wined3d_surface *surface, const struct
{
unsigned char alignment = surface->resource.device->surface_alignment;
src_pitch = format->byte_count * surface->pow2Width;
- wined3d_texture_get_pitch(surface->container, surface->texture_level, &dst_row_pitch, &dst_slice_pitch);
+ wined3d_resource_get_pitch(&surface->resource, &dst_row_pitch, &dst_slice_pitch);
src_pitch = (src_pitch + alignment - 1) & ~(alignment - 1);
mem = HeapAlloc(GetProcessHeap(), 0, src_pitch * surface->pow2Height);
}
@@ -1667,7 +1667,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
wined3d_texture_bind_and_dirtify(dst_surface->container, context, FALSE);
surface_get_memory(src_surface, &data, src_surface->locations);
- wined3d_texture_get_pitch(src_surface->container, src_surface->texture_level, &src_row_pitch, &src_slice_pitch);
+ wined3d_resource_get_pitch(&src_surface->resource, &src_row_pitch, &src_slice_pitch);
wined3d_surface_upload_data(dst_surface, gl_info, src_format, src_rect,
src_row_pitch, dst_point, FALSE, wined3d_const_bo_address(&data));
@@ -1908,20 +1908,21 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
valid_location = WINED3D_LOCATION_USER_MEMORY;
}
- surface->pitch = pitch;
+ surface->resource.custom_row_pitch = pitch;
+ surface->resource.custom_slice_pitch = pitch * surface->resource.height;
surface->resource.format = texture_resource->format;
surface->resource.multisample_type = texture_resource->multisample_type;
surface->resource.multisample_quality = texture_resource->multisample_quality;
- if (surface->pitch)
+ if (surface->resource.custom_row_pitch)
{
- surface->resource.size = height * surface->pitch;
+ surface->resource.size = height * surface->resource.custom_row_pitch;
}
else
{
/* User memory surfaces don't have the regular surface alignment. */
surface->resource.size = wined3d_format_calculate_size(texture_resource->format,
1, width, height, 1);
- surface->pitch = wined3d_format_calculate_pitch(texture_resource->format, width);
+ surface->resource.custom_row_pitch = wined3d_format_calculate_pitch(texture_resource->format, width);
}
/* The format might be changed to a format that needs conversion.
@@ -2547,8 +2548,7 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
}
else
{
- wined3d_texture_get_pitch(surface->container, surface->texture_level,
- &map_desc->row_pitch, &map_desc->slice_pitch);
+ wined3d_resource_get_pitch(&surface->resource, &map_desc->row_pitch, &map_desc->slice_pitch);
}
if (!box)
@@ -2640,7 +2640,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
checkGLcall("glBindBuffer");
}
- wined3d_texture_get_pitch(surface->container, surface->texture_level, &row_pitch, &slice_pitch);
+ wined3d_resource_get_pitch(&surface->resource, &row_pitch, &slice_pitch);
/* Setup pixel store pack state -- to glReadPixels into the correct place */
gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, row_pitch / surface->resource.format->byte_count);
@@ -3897,7 +3897,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
wined3d_texture_prepare_texture(texture, context, srgb);
wined3d_texture_bind_and_dirtify(texture, context, srgb);
- wined3d_texture_get_pitch(texture, surface->texture_level, &src_row_pitch, &src_slice_pitch);
+ wined3d_resource_get_pitch(&surface->resource, &src_row_pitch, &src_slice_pitch);
width = surface->resource.width;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index a443b5d..cb7ae9c 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1180,7 +1180,7 @@ static void texture3d_sub_resource_upload_data(struct wined3d_resource *sub_reso
struct wined3d_const_bo_address addr;
unsigned int row_pitch, slice_pitch;
- wined3d_texture_get_pitch(volume->container, volume->texture_level, &row_pitch, &slice_pitch);
+ wined3d_resource_get_pitch(sub_resource, &row_pitch, &slice_pitch);
if (row_pitch != data->row_pitch || slice_pitch != data->slice_pitch)
FIXME("Ignoring row/slice pitch (%u/%u).\n", data->row_pitch, data->slice_pitch);
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 75585d8..d97db80 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -71,7 +71,7 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
dst_row_pitch = width * format->conv_byte_count;
dst_slice_pitch = dst_row_pitch * height;
- wined3d_texture_get_pitch(volume->container, volume->texture_level, &src_row_pitch, &src_slice_pitch);
+ wined3d_resource_get_pitch(&volume->resource, &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,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 1dc499e..90a489e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2277,6 +2277,7 @@ struct wined3d_resource
UINT size;
DWORD priority;
void *heap_memory;
+ UINT custom_row_pitch, custom_slice_pitch;
struct list resource_list_entry;
void *parent;
@@ -2304,6 +2305,8 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+void wined3d_resource_get_pitch(const struct wined3d_resource *resource, UINT *row_pitch,
+ UINT *slice_pitch) DECLSPEC_HIDDEN;
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
@@ -2498,7 +2501,6 @@ struct wined3d_surface
DWORD flags;
- UINT pitch;
UINT pow2Width;
UINT pow2Height;
--
2.7.1

View File

@@ -1,4 +1,4 @@
From 00f61862ec59e32534adfabc359009143a9b9651 Mon Sep 17 00:00:00 2001
From 5b4915863af63b0df11c80611d327820f63f5d0b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20D=C3=B6singer?= <stefan@codeweavers.com>
Date: Thu, 16 Jan 2014 22:04:55 +0100
Subject: wined3d: Move bitmap_data and user_memory into the resource.
@@ -11,7 +11,7 @@ I may want to change this to keep this in the surface. Not sure yet.
3 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index ad9310a..65eefa9 100644
index 79be75f..ad15f4a 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -88,7 +88,7 @@ static void surface_cleanup(struct wined3d_surface *surface)
@@ -23,7 +23,7 @@ index ad9310a..65eefa9 100644
}
if (surface->overlay_dest)
@@ -456,7 +456,7 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
@@ -456,7 +456,7 @@ HRESULT surface_create_dib_section(struct wined3d_surface *surface)
TRACE("Creating a DIB section with size %dx%dx%d, size=%d.\n",
b_info->bmiHeader.biWidth, b_info->bmiHeader.biHeight,
b_info->bmiHeader.biBitCount, b_info->bmiHeader.biSizeImage);
@@ -32,7 +32,7 @@ index ad9310a..65eefa9 100644
if (!surface->dib.DIBsection)
{
@@ -465,7 +465,7 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
@@ -465,7 +465,7 @@ HRESULT surface_create_dib_section(struct wined3d_surface *surface)
return HRESULT_FROM_WIN32(GetLastError());
}
@@ -75,7 +75,7 @@ index ad9310a..65eefa9 100644
break;
case WINED3D_LOCATION_BUFFER:
@@ -2100,7 +2100,7 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
@@ -1914,7 +1914,7 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
{
DeleteDC(surface->hDC);
DeleteObject(surface->dib.DIBsection);
@@ -84,16 +84,16 @@ index ad9310a..65eefa9 100644
surface->flags &= ~SFLAG_DIBSECTION;
create_dib = TRUE;
}
@@ -2132,7 +2132,7 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
else
surface->flags &= ~SFLAG_NONPOW2;
@@ -1941,7 +1941,7 @@ HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
surface->pow2Height <<= 1;
}
- if ((surface->user_memory = mem))
+ if ((surface->resource.user_memory = mem))
{
surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
valid_location = WINED3D_LOCATION_USER_MEMORY;
@@ -2750,11 +2750,11 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
@@ -2555,11 +2555,11 @@ HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_
break;
case WINED3D_LOCATION_USER_MEMORY:
@@ -108,10 +108,10 @@ index ad9310a..65eefa9 100644
case WINED3D_LOCATION_BUFFER:
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index 4f6be9e..d0b8cf0 100644
index 41cd400..3ca22cf 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -666,9 +666,9 @@ static void swapchain_gdi_present(struct wined3d_swapchain *swapchain, const REC
@@ -680,9 +680,9 @@ static void swapchain_gdi_present(struct wined3d_swapchain *swapchain, const REC
{
void *tmp;
@@ -125,10 +125,10 @@ index 4f6be9e..d0b8cf0 100644
if (front->resource.heap_memory)
ERR("GDI Surface %p has heap memory allocated.\n", front);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 9d2e40a..3776439 100644
index e7c872d..861057d 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2164,7 +2164,7 @@ struct wined3d_resource
@@ -2277,7 +2277,7 @@ struct wined3d_resource
UINT depth;
UINT size;
DWORD priority;
@@ -137,7 +137,7 @@ index 9d2e40a..3776439 100644
UINT custom_row_pitch, custom_slice_pitch;
struct list resource_list_entry;
DWORD locations;
@@ -2343,7 +2343,6 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
@@ -2459,7 +2459,6 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
struct wined3d_surface_dib
{
HBITMAP DIBsection;
@@ -145,7 +145,7 @@ index 9d2e40a..3776439 100644
UINT bitmap_size;
};
@@ -2377,7 +2376,6 @@ struct wined3d_surface
@@ -2493,7 +2492,6 @@ struct wined3d_surface
struct wined3d_resource resource;
const struct wined3d_surface_ops *surface_ops;
struct wined3d_texture *container;
@@ -154,5 +154,5 @@ index 9d2e40a..3776439 100644
DWORD flags;
--
2.5.1
2.7.1

Some files were not shown because too many files have changed in this diff Show More