diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 49de853a724..738a274ea13 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -766,7 +766,7 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface, resource = wined3d_texture_get_sub_resource(object->wined3d_texture, 0); surface = wined3d_resource_get_parent(resource); - wined3d_surface_set_mem(surface->wined3d_surface, *shared_handle); + wined3d_surface_set_mem(surface->wined3d_surface, *shared_handle, 0); } TRACE("Created texture %p.\n", object); diff --git a/dlls/ddraw/surface.c b/dlls/ddraw/surface.c index 4ca02bdc24c..4108fcd9681 100644 --- a/dlls/ddraw/surface.c +++ b/dlls/ddraw/surface.c @@ -4233,7 +4233,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface, | DDSD_HEIGHT | DDSD_PITCH | DDSD_CAPS; enum wined3d_format_id format_id; BOOL update_wined3d = FALSE; - UINT width, height; + UINT pitch, width, height; TRACE("iface %p, surface_desc %p, flags %#x.\n", iface, DDSD, Flags); @@ -4293,6 +4293,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface, TRACE("Surface pitch changed from %u to %u.\n", This->surface_desc.u1.lPitch, DDSD->u1.lPitch); update_wined3d = TRUE; } + pitch = DDSD->u1.lPitch; width = DDSD->dwWidth; } else if (DDSD->dwFlags & DDSD_PITCH) @@ -4302,6 +4303,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface, } else { + pitch = This->surface_desc.u1.lPitch; width = This->surface_desc.dwWidth; } @@ -4370,8 +4372,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface, if (DDSD->dwFlags & DDSD_LPSURFACE && DDSD->lpSurface) { - hr = wined3d_surface_set_mem(This->wined3d_surface, DDSD->lpSurface); - if (FAILED(hr)) + if (FAILED(hr = wined3d_surface_set_mem(This->wined3d_surface, DDSD->lpSurface, pitch))) { /* No need for a trace here, wined3d does that for us */ switch(hr) @@ -5843,8 +5844,15 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, } if (desc->dwFlags & DDSD_LPSURFACE) { - hr = wined3d_surface_set_mem(surface->wined3d_surface, desc->lpSurface); - if (FAILED(hr)) + UINT pitch = 0; + + if (desc->dwFlags & DDSD_PITCH) + { + pitch = desc->u1.lPitch; + surface->surface_desc.u1.lPitch = pitch; + } + + if (FAILED(hr = wined3d_surface_set_mem(surface->wined3d_surface, desc->lpSurface, pitch))) { ERR("Failed to set surface memory, hr %#x.\n", hr); wined3d_surface_decref(surface->wined3d_surface); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 773424a5f41..a325ac0a773 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -101,7 +101,7 @@ static void surface_cleanup(struct wined3d_surface *surface) } if (surface->flags & SFLAG_USERPTR) - wined3d_surface_set_mem(surface, NULL); + wined3d_surface_set_mem(surface, NULL, 0); if (surface->overlay_dest) list_remove(&surface->overlay_entry); @@ -3202,6 +3202,9 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface) TRACE("surface %p.\n", surface); + if (surface->pitch) + return surface->pitch; + if (format->flags & WINED3DFMT_FLAG_BLOCKS) { /* Since compressed formats are block based, pitch means the amount of @@ -3221,7 +3224,7 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface) return pitch; } -HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem) +HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem, UINT pitch) { TRACE("surface %p, mem %p.\n", surface, mem); @@ -3290,6 +3293,8 @@ HRESULT CDECL wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem surface_modify_location(surface, SFLAG_INSYSMEM, TRUE); } + surface->pitch = pitch; + return WINED3D_OK; } diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 8357d2b9511..f451b7a35ac 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -226,7 +226,7 @@ @ cdecl wined3d_surface_releasedc(ptr ptr) @ cdecl wined3d_surface_restore(ptr) @ cdecl wined3d_surface_set_color_key(ptr long ptr) -@ cdecl wined3d_surface_set_mem(ptr ptr) +@ cdecl wined3d_surface_set_mem(ptr ptr long) @ cdecl wined3d_surface_set_overlay_position(ptr long long) @ cdecl wined3d_surface_set_palette(ptr ptr) @ cdecl wined3d_surface_set_priority(ptr long) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 4ac9098220c..82a4584b6ba 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2095,8 +2095,9 @@ struct wined3d_surface DWORD flags; - UINT pow2Width; - UINT pow2Height; + UINT pitch; + UINT pow2Width; + UINT pow2Height; /* A method to retrieve the drawable size. Not in the Vtable to make it changeable */ void (*get_drawable_size)(const struct wined3d_context *context, UINT *width, UINT *height); diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index a7a53f1d9af..86e8b5b1d95 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2332,7 +2332,7 @@ HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC d HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface); HRESULT __cdecl wined3d_surface_set_color_key(struct wined3d_surface *surface, DWORD flags, const struct wined3d_color_key *color_key); -HRESULT __cdecl wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem); +HRESULT __cdecl wined3d_surface_set_mem(struct wined3d_surface *surface, void *mem, UINT pitch); HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y); void __cdecl wined3d_surface_set_palette(struct wined3d_surface *surface, struct wined3d_palette *palette); DWORD __cdecl wined3d_surface_set_priority(struct wined3d_surface *surface, DWORD new_priority);