Commit 6e5fa922 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

ddraw: Use wined3d_texture_get_pitch() in ddraw_surface_init().

parent f8c858c3
...@@ -4774,7 +4774,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent ...@@ -4774,7 +4774,7 @@ static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent
return DDERR_OUTOFVIDEOMEMORY; return DDERR_OUTOFVIDEOMEMORY;
} }
ddraw_surface_init(ddraw_surface, ddraw, wined3d_texture, sub_resource_idx, surface, parent_ops); ddraw_surface_init(ddraw_surface, ddraw, wined3d_texture, sub_resource_idx, parent_ops);
*parent = ddraw_surface; *parent = ddraw_surface;
ddraw_update_lost_surfaces(ddraw); ddraw_update_lost_surfaces(ddraw);
......
...@@ -213,7 +213,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_ ...@@ -213,7 +213,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN; struct wined3d_rendertarget_view *ddraw_surface_get_rendertarget_view(struct ddraw_surface *surface) DECLSPEC_HIDDEN;
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN; const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN; ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface, HRESULT ddraw_surface_update_frontbuffer(struct ddraw_surface *surface,
const RECT *rect, BOOL read) DECLSPEC_HIDDEN; const RECT *rect, BOOL read) DECLSPEC_HIDDEN;
......
...@@ -6253,9 +6253,10 @@ fail: ...@@ -6253,9 +6253,10 @@ fail:
void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx,
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) const struct wined3d_parent_ops **parent_ops)
{ {
struct ddraw_texture *texture = wined3d_texture_get_parent(wined3d_texture); struct ddraw_texture *texture = wined3d_texture_get_parent(wined3d_texture);
unsigned int texture_level, row_pitch, slice_pitch;
DDSURFACEDESC2 *desc = &surface->surface_desc; DDSURFACEDESC2 *desc = &surface->surface_desc;
unsigned int version = texture->version; unsigned int version = texture->version;
...@@ -6290,24 +6291,21 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, ...@@ -6290,24 +6291,21 @@ void ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
*desc = texture->surface_desc; *desc = texture->surface_desc;
surface->first_attached = surface; surface->first_attached = surface;
texture_level = desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP ? sub_resource_idx % desc->u2.dwMipMapCount : 0;
wined3d_texture_get_pitch(wined3d_texture, texture_level, &row_pitch, &slice_pitch);
if (format_is_compressed(&desc->u4.ddpfPixelFormat)) if (format_is_compressed(&desc->u4.ddpfPixelFormat))
{ {
unsigned int texture_level, row_pitch;
texture_level = desc->ddsCaps.dwCaps & DDSCAPS_MIPMAP ? sub_resource_idx % desc->u2.dwMipMapCount : 0;
row_pitch = wined3d_surface_get_pitch(wined3d_surface);
if (desc->dwFlags & DDSD_LPSURFACE) if (desc->dwFlags & DDSD_LPSURFACE)
desc->u1.dwLinearSize = ~0u; desc->u1.dwLinearSize = ~0u;
else else
desc->u1.dwLinearSize = row_pitch * ((max(1, desc->dwHeight >> texture_level) + 3) / 4); desc->u1.dwLinearSize = slice_pitch;
desc->dwFlags |= DDSD_LINEARSIZE; desc->dwFlags |= DDSD_LINEARSIZE;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH); desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_PITCH);
} }
else else
{ {
if (!(desc->dwFlags & DDSD_LPSURFACE)) 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_PITCH;
desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE); desc->dwFlags &= ~(DDSD_LPSURFACE | DDSD_LINEARSIZE);
} }
......
...@@ -1883,19 +1883,6 @@ static inline unsigned short float_32_to_16(const float *in) ...@@ -1883,19 +1883,6 @@ static inline unsigned short float_32_to_16(const float *in)
return ret; return ret;
} }
DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
{
unsigned int row_pitch, slice_pitch;
TRACE("surface %p.\n", surface);
wined3d_texture_get_pitch(surface->container, surface->texture_level, &row_pitch, &slice_pitch);
TRACE("Returning %u.\n", row_pitch);
return row_pitch;
}
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info) HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
{ {
struct wined3d_resource *texture_resource = &surface->container->resource; struct wined3d_resource *texture_resource = &surface->container->resource;
......
...@@ -499,7 +499,7 @@ void * CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture) ...@@ -499,7 +499,7 @@ void * CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
return texture->resource.parent; return texture->resource.parent;
} }
void wined3d_texture_get_pitch(const struct wined3d_texture *texture, void CDECL wined3d_texture_get_pitch(const struct wined3d_texture *texture,
unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch) unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch)
{ {
const struct wined3d_resource *resource = &texture->resource; const struct wined3d_resource *resource = &texture->resource;
......
...@@ -220,8 +220,6 @@ ...@@ -220,8 +220,6 @@
@ cdecl wined3d_stateblock_decref(ptr) @ cdecl wined3d_stateblock_decref(ptr)
@ cdecl wined3d_stateblock_incref(ptr) @ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_surface_get_pitch(ptr)
@ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr) @ cdecl wined3d_swapchain_create(ptr ptr ptr ptr ptr)
@ cdecl wined3d_swapchain_decref(ptr) @ cdecl wined3d_swapchain_decref(ptr)
@ cdecl wined3d_swapchain_get_back_buffer(ptr long) @ cdecl wined3d_swapchain_get_back_buffer(ptr long)
...@@ -250,6 +248,7 @@ ...@@ -250,6 +248,7 @@
@ cdecl wined3d_texture_get_lod(ptr) @ cdecl wined3d_texture_get_lod(ptr)
@ cdecl wined3d_texture_get_overlay_position(ptr long ptr ptr) @ cdecl wined3d_texture_get_overlay_position(ptr long ptr ptr)
@ cdecl wined3d_texture_get_parent(ptr) @ cdecl wined3d_texture_get_parent(ptr)
@ cdecl wined3d_texture_get_pitch(ptr long ptr ptr)
@ cdecl wined3d_texture_get_resource(ptr) @ cdecl wined3d_texture_get_resource(ptr)
@ cdecl wined3d_texture_get_sub_resource(ptr long) @ cdecl wined3d_texture_get_sub_resource(ptr long)
@ cdecl wined3d_texture_incref(ptr) @ cdecl wined3d_texture_incref(ptr)
......
...@@ -2402,8 +2402,6 @@ void wined3d_texture_bind(struct wined3d_texture *texture, ...@@ -2402,8 +2402,6 @@ void wined3d_texture_bind(struct wined3d_texture *texture,
void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture, void wined3d_texture_bind_and_dirtify(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_force_reload(struct wined3d_texture *texture) DECLSPEC_HIDDEN; void wined3d_texture_force_reload(struct wined3d_texture *texture) DECLSPEC_HIDDEN;
void wined3d_texture_get_pitch(const struct wined3d_texture *texture,
unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch) DECLSPEC_HIDDEN;
void wined3d_texture_load(struct wined3d_texture *texture, void wined3d_texture_load(struct wined3d_texture *texture,
struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN; struct wined3d_context *context, BOOL srgb) DECLSPEC_HIDDEN;
void wined3d_texture_prepare_texture(struct wined3d_texture *texture, void wined3d_texture_prepare_texture(struct wined3d_texture *texture,
......
...@@ -2479,8 +2479,6 @@ HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device, ...@@ -2479,8 +2479,6 @@ HRESULT __cdecl wined3d_stateblock_create(struct wined3d_device *device,
ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock); ULONG __cdecl wined3d_stateblock_decref(struct wined3d_stateblock *stateblock);
ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock); ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
DWORD __cdecl wined3d_surface_get_pitch(const struct wined3d_surface *surface);
HRESULT __cdecl wined3d_swapchain_create(struct wined3d_device *device, struct wined3d_swapchain_desc *desc, HRESULT __cdecl wined3d_swapchain_create(struct wined3d_device *device, struct wined3d_swapchain_desc *desc,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain); void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_swapchain **swapchain);
ULONG __cdecl wined3d_swapchain_decref(struct wined3d_swapchain *swapchain); ULONG __cdecl wined3d_swapchain_decref(struct wined3d_swapchain *swapchain);
...@@ -2527,6 +2525,8 @@ DWORD __cdecl wined3d_texture_get_lod(const struct wined3d_texture *texture); ...@@ -2527,6 +2525,8 @@ DWORD __cdecl wined3d_texture_get_lod(const struct wined3d_texture *texture);
HRESULT __cdecl wined3d_texture_get_overlay_position(const struct wined3d_texture *texture, HRESULT __cdecl wined3d_texture_get_overlay_position(const struct wined3d_texture *texture,
unsigned int sub_resource_idx, LONG *x, LONG *y); unsigned int sub_resource_idx, LONG *x, LONG *y);
void * __cdecl wined3d_texture_get_parent(const struct wined3d_texture *texture); void * __cdecl wined3d_texture_get_parent(const struct wined3d_texture *texture);
void __cdecl wined3d_texture_get_pitch(const struct wined3d_texture *texture,
unsigned int level, unsigned int *row_pitch, unsigned int *slice_pitch);
struct wined3d_resource * __cdecl wined3d_texture_get_resource(struct wined3d_texture *texture); struct wined3d_resource * __cdecl wined3d_texture_get_resource(struct wined3d_texture *texture);
struct wined3d_resource * __cdecl wined3d_texture_get_sub_resource(const struct wined3d_texture *texture, struct wined3d_resource * __cdecl wined3d_texture_get_sub_resource(const struct wined3d_texture *texture,
UINT sub_resource_idx); UINT sub_resource_idx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment