wined3d-CSMT_Helper: Move 'Merge get_pitch' patch into CSMT_Main.

This commit is contained in:
Sebastian Lackner
2015-07-29 03:58:55 +02:00
parent c258f95d4b
commit 025e40edcc
179 changed files with 1139 additions and 987 deletions

View File

@@ -94,7 +94,7 @@ index 0000000..0439375
+#include "config.h" /* Needed to get PACKAGE_VERSION */
+
+#define WINE_FILEDESCRIPTION_STR "Wine D3D"
+#define WINE_FILENAME_STR "wined3d.dll"
+#define WINE_FILENAME_STR "wined3d-csmt.dll"
+#define WINE_FILEVERSION_STR PACKAGE_VERSION
+#define WINE_PRODUCTVERSION_STR PACKAGE_VERSION
+#define WINE_PRODUCTNAME_STR "Wine D3D"

View File

@@ -1,459 +0,0 @@
From e34f6f432826634f80cefdc9311c5472eae80dad 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/ddraw/surface.c | 12 +++++--
dlls/wined3d/resource.c | 31 ++++++++++++++++
dlls/wined3d/surface.c | 81 ++++++++++++++++++------------------------
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/volume.c | 28 ++-------------
dlls/wined3d/wined3d.spec | 2 +-
dlls/wined3d/wined3d_private.h | 3 +-
include/wine/wined3d.h | 3 +-
8 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index f716cfc..da64d97 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -6212,6 +6212,10 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, stru
DDSURFACEDESC2 *desc = &surface->surface_desc;
struct wined3d_resource_desc wined3d_desc;
unsigned int version = texture->version;
+ UINT row_pitch, slice_pitch;
+ struct wined3d_resource *resource = wined3d_surface_get_resource(wined3d_surface);
+
+ wined3d_resource_get_pitch(resource, &row_pitch, &slice_pitch);
surface->IDirectDrawSurface7_iface.lpVtbl = &ddraw_surface7_vtbl;
surface->IDirectDrawSurface4_iface.lpVtbl = &ddraw_surface4_vtbl;
@@ -6242,7 +6246,7 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, stru
}
*desc = texture->surface_desc;
- wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &wined3d_desc);
+ wined3d_resource_get_desc(resource, &wined3d_desc);
desc->dwWidth = wined3d_desc.width;
desc->dwHeight = wined3d_desc.height;
surface->first_attached = surface;
@@ -6252,14 +6256,16 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, stru
if (desc->dwFlags & DDSD_LPSURFACE)
desc->u1.dwLinearSize = ~0u;
else
- desc->u1.dwLinearSize = wined3d_surface_get_pitch(wined3d_surface) * ((desc->dwHeight + 3) / 4);
+ {
+ desc->u1.dwLinearSize = row_pitch * ((desc->dwHeight + 3) / 4);
+ }
desc->dwFlags |= DDSD_LINEARSIZE;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH);
}
else
{
if (!(desc->dwFlags & DDSD_LPSURFACE))
- desc->u1.lPitch = wined3d_surface_get_pitch(wined3d_surface);
+ desc->u1.lPitch = row_pitch;
desc->dwFlags |= DDSD_PITCH;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE);
}
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index e9e586f..648882e 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -405,3 +405,34 @@ void wined3d_resource_update_draw_binding(struct wined3d_resource *resource)
else
resource->draw_binding = WINED3D_LOCATION_TEXTURE_RGB;
}
+
+void CDECL 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 1ea8e61..5460f79 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -364,6 +364,7 @@ static 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 @@ static 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;
@@ -1305,14 +1307,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);
}
@@ -1399,12 +1401,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);
@@ -1559,7 +1561,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",
@@ -1647,10 +1649,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);
@@ -1931,25 +1933,6 @@ HRESULT CDECL wined3d_surface_restore(struct wined3d_surface *surface)
return WINED3D_OK;
}
-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;
-}
-
HRESULT CDECL wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y)
{
LONG w, h;
@@ -2130,20 +2113,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.size = wined3d_format_calculate_size(texture_resource->format, 1, width, height, 1);
+ surface->resource.custom_row_pitch = wined3d_format_calculate_pitch(texture_resource->format, width);
+ surface->resource.custom_slice_pitch = surface->resource.custom_row_pitch * surface->resource.height; /* FIXME */
}
/* The format might be changed to a format that needs conversion.
@@ -2763,7 +2747,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
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 = 0;
if (!rect)
@@ -2890,6 +2874,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
int i;
BOOL srcIsUpsideDown;
struct wined3d_bo_address data;
+ UINT row_pitch, slice_pitch;
surface_get_memory(surface, &data, dst_location);
@@ -2926,8 +2911,8 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
}
/* 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, &row_pitch, &slice_pitch);
+ gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH, row_pitch / surface->resource.format->byte_count);
checkGLcall("glPixelStorei");
gl_info->gl_ops.gl.p_glReadPixels(0, 0,
@@ -2944,7 +2929,9 @@ static void read_from_framebuffer(struct wined3d_surface *surface, DWORD dst_loc
{
/* 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);
+ UINT pitch, slice_pitch;
+
+ wined3d_resource_get_pitch(&surface->resource, &pitch, &slice_pitch);
if (!(row = HeapAlloc(GetProcessHeap(), 0, pitch)))
goto error;
@@ -4125,7 +4112,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
const struct wined3d_color_key_conversion *conversion;
struct wined3d_texture *texture = surface->container;
struct wined3d_context *context;
- 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};
@@ -4213,7 +4200,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)))
@@ -4251,9 +4238,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)
@@ -4273,14 +4260,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));
context_release(context);
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 1e039e4..f4e77fb 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1233,7 +1233,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 424938a..b672d4a 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,
@@ -643,7 +619,7 @@ HRESULT CDECL 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.spec b/dlls/wined3d/wined3d.spec
index bc1129f..fcabd53 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -182,6 +182,7 @@
@ cdecl wined3d_resource_get_desc(ptr ptr)
@ cdecl wined3d_resource_get_parent(ptr)
+@ cdecl wined3d_resource_get_pitch(ptr ptr ptr)
@ cdecl wined3d_resource_get_priority(ptr)
@ cdecl wined3d_resource_set_parent(ptr ptr)
@ cdecl wined3d_resource_set_priority(ptr long)
@@ -227,7 +228,6 @@
@ cdecl wined3d_surface_get_flip_status(ptr long)
@ cdecl wined3d_surface_get_overlay_position(ptr ptr ptr)
@ cdecl wined3d_surface_get_parent(ptr)
-@ cdecl wined3d_surface_get_pitch(ptr)
@ cdecl wined3d_surface_get_render_target_data(ptr ptr)
@ cdecl wined3d_surface_get_resource(ptr)
@ cdecl wined3d_surface_getdc(ptr ptr)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0f181f3..9e6cb5e 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2136,6 +2136,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;
@@ -2300,7 +2301,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;
@@ -2350,7 +2350,6 @@ struct wined3d_surface
DWORD flags;
- UINT pitch;
UINT pow2Width;
UINT pow2Height;
diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h
index a1803bb..fc91d02 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2427,6 +2427,8 @@ static inline HRESULT wined3d_private_store_set_private_data(struct wined3d_priv
void __cdecl wined3d_resource_get_desc(const struct wined3d_resource *resource,
struct wined3d_resource_desc *desc);
void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resource);
+void __cdecl wined3d_resource_get_pitch(const struct wined3d_resource *resource, UINT *row_pitch,
+ UINT *slice_pitch);
DWORD __cdecl wined3d_resource_get_priority(const struct wined3d_resource *resource);
void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent);
DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority);
@@ -2485,7 +2487,6 @@ HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *sur
HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags);
HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y);
void * __cdecl wined3d_surface_get_parent(const struct wined3d_surface *surface);
-DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_get_render_target_data(struct wined3d_surface *surface,
struct wined3d_surface *render_target);
struct wined3d_resource * __cdecl wined3d_surface_get_resource(struct wined3d_surface *surface);
--
2.4.2