Added patches for CSMT support (not enabled yet).

This commit is contained in:
Sebastian Lackner
2014-12-14 20:24:48 +01:00
parent 152e0e26a9
commit 5c6cef5ac8
181 changed files with 34347 additions and 1 deletions

View File

@@ -0,0 +1,406 @@
From e40fbe3feb09e745a7cb95413b23f3087a2859af 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 | 70 +++++++++++++++++-------------------------
dlls/wined3d/volume.c | 29 ++---------------
dlls/wined3d/wined3d.spec | 2 +-
dlls/wined3d/wined3d_private.h | 2 +-
include/wine/wined3d.h | 3 +-
7 files changed, 74 insertions(+), 75 deletions(-)
diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c
index a4184b8..a0d7f2d 100644
--- a/dlls/ddraw/surface.c
+++ b/dlls/ddraw/surface.c
@@ -6158,6 +6158,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;
@@ -6188,7 +6192,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;
@@ -6198,14 +6202,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 0ab55dc..8032a4c 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -331,3 +331,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 & 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 092cbe6..d9b1846 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;
@@ -1359,14 +1361,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);
}
@@ -1453,12 +1455,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);
@@ -1612,7 +1614,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",
@@ -1698,9 +1700,9 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
wined3d_texture_bind(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);
- surface_upload_data(dst_surface, gl_info, src_format, src_rect, src_pitch, dst_point, FALSE, &data);
+ surface_upload_data(dst_surface, gl_info, src_format, src_rect, src_row_pitch, dst_point, FALSE, &data);
context_invalidate_active_texture(context);
@@ -2008,25 +2010,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;
@@ -2207,12 +2190,13 @@ 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)
- surface->resource.size = height * surface->pitch;
+ if (surface->resource.custom_row_pitch)
+ surface->resource.size = height * surface->resource.custom_row_pitch;
else
surface->resource.size = wined3d_format_calculate_size(texture_resource->format,
texture_resource->device->surface_alignment, width, height, 1);
@@ -2680,7 +2664,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
if (format->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)
@@ -2860,7 +2844,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;
@@ -4092,7 +4078,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};
@@ -4187,7 +4173,7 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
else surface->flags &= ~SFLAG_GLCKEY;
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)))
@@ -4226,9 +4212,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)
@@ -4248,13 +4234,13 @@ 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->src_blt_color_key);
- src_pitch = dst_pitch;
+ src_row_pitch = dst_pitch;
data.addr = mem;
}
- surface_upload_data(surface, gl_info, &format, &src_rect, src_pitch, &dst_point, srgb, &data);
+ surface_upload_data(surface, gl_info, &format, &src_rect, src_row_pitch, &dst_point, srgb, &data);
context_release(context);
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index 58d7321..af99825 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -40,31 +40,6 @@ BOOL volume_prepare_system_memory(struct wined3d_volume *volume)
return TRUE;
}
-static 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 (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);
-}
-
/* Context activation is done by the caller. */
void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context,
const struct wined3d_bo_address *data)
@@ -95,7 +70,7 @@ void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wine
dst_row_pitch = (dst_row_pitch + alignment - 1) & ~(alignment - 1);
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);
mem = HeapAlloc(GetProcessHeap(), 0, dst_slice_pitch * depth);
format->convert(data->addr, mem, src_row_pitch, src_slice_pitch,
@@ -638,7 +613,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 7a77003..95885c7 100644
--- a/dlls/wined3d/wined3d.spec
+++ b/dlls/wined3d/wined3d.spec
@@ -181,6 +181,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)
@@ -226,7 +227,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 7935a5d..abd8d2b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2080,6 +2080,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;
@@ -2298,7 +2299,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 0cf26e1..3d24b98 100644
--- a/include/wine/wined3d.h
+++ b/include/wine/wined3d.h
@@ -2411,6 +2411,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);
@@ -2468,7 +2470,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.1.3

View File