diff --git a/dlls/d3d8/buffer.c b/dlls/d3d8/buffer.c index 4a0e587b409..aa193142fef 100644 --- a/dlls/d3d8/buffer.c +++ b/dlls/d3d8/buffer.c @@ -167,7 +167,7 @@ static void WINAPI d3d8_vertexbuffer_PreLoad(IDirect3DVertexBuffer8 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_buffer_preload(buffer->wined3d_buffer); + wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer)); wined3d_mutex_unlock(); } @@ -444,7 +444,7 @@ static void WINAPI d3d8_indexbuffer_PreLoad(IDirect3DIndexBuffer8 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_buffer_preload(buffer->wined3d_buffer); + wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer)); wined3d_mutex_unlock(); } diff --git a/dlls/d3d8/texture.c b/dlls/d3d8/texture.c index 324d896bd5a..21f3b67f302 100644 --- a/dlls/d3d8/texture.c +++ b/dlls/d3d8/texture.c @@ -187,7 +187,7 @@ static void WINAPI d3d8_texture_2d_PreLoad(IDirect3DTexture8 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_texture_preload(texture->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture)); wined3d_mutex_unlock(); } @@ -533,7 +533,7 @@ static void WINAPI d3d8_texture_cube_PreLoad(IDirect3DCubeTexture8 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_texture_preload(texture->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture)); wined3d_mutex_unlock(); } @@ -889,7 +889,7 @@ static void WINAPI d3d8_texture_3d_PreLoad(IDirect3DVolumeTexture8 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_texture_preload(texture->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture)); wined3d_mutex_unlock(); } diff --git a/dlls/d3d9/buffer.c b/dlls/d3d9/buffer.c index c7db176d73a..469b345053f 100644 --- a/dlls/d3d9/buffer.c +++ b/dlls/d3d9/buffer.c @@ -168,7 +168,7 @@ static void WINAPI d3d9_vertexbuffer_PreLoad(IDirect3DVertexBuffer9 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_buffer_preload(buffer->wined3d_buffer); + wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer)); wined3d_mutex_unlock(); } @@ -444,7 +444,7 @@ static void WINAPI d3d9_indexbuffer_PreLoad(IDirect3DIndexBuffer9 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_buffer_preload(buffer->wined3d_buffer); + wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer)); wined3d_mutex_unlock(); } diff --git a/dlls/d3d9/surface.c b/dlls/d3d9/surface.c index 2dce998cd65..b007f787df1 100644 --- a/dlls/d3d9/surface.c +++ b/dlls/d3d9/surface.c @@ -176,7 +176,7 @@ static void WINAPI d3d9_surface_PreLoad(IDirect3DSurface9 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_texture_preload(surface->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(surface->wined3d_texture)); wined3d_mutex_unlock(); } diff --git a/dlls/d3d9/texture.c b/dlls/d3d9/texture.c index ae0eaacbc62..bd93d21249f 100644 --- a/dlls/d3d9/texture.c +++ b/dlls/d3d9/texture.c @@ -189,7 +189,7 @@ static void WINAPI d3d9_texture_2d_PreLoad(IDirect3DTexture9 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_texture_preload(texture->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture)); wined3d_mutex_unlock(); } @@ -578,7 +578,7 @@ static void WINAPI d3d9_texture_cube_PreLoad(IDirect3DCubeTexture9 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_texture_preload(texture->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture)); wined3d_mutex_unlock(); } @@ -980,7 +980,7 @@ static void WINAPI d3d9_texture_3d_PreLoad(IDirect3DVolumeTexture9 *iface) TRACE("iface %p.\n", iface); wined3d_mutex_lock(); - wined3d_texture_preload(texture->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture)); wined3d_mutex_unlock(); } diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 2f79c4c23fe..3598bd859c8 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -5656,7 +5656,7 @@ static HRESULT d3d_device7_PreLoad(IDirect3DDevice7 *iface, IDirectDrawSurface7 return DDERR_INVALIDPARAMS; wined3d_mutex_lock(); - wined3d_texture_preload(surface->wined3d_texture); + wined3d_resource_preload(wined3d_texture_get_resource(surface->wined3d_texture)); wined3d_mutex_unlock(); return D3D_OK; diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index d51d0e83969..56bfdfecdf3 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -928,14 +928,6 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte HeapFree(GetProcessHeap(), 0, data); } -void CDECL wined3d_buffer_preload(struct wined3d_buffer *buffer) -{ - struct wined3d_context *context; - context = context_acquire(buffer->resource.device, NULL); - buffer_internal_preload(buffer, context, NULL); - context_release(context); -} - struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffer *buffer) { TRACE("buffer %p.\n", buffer); @@ -1108,7 +1100,7 @@ void CDECL wined3d_buffer_unmap(struct wined3d_buffer *buffer) } else if (buffer->flags & WINED3D_BUFFER_HASDESC) { - wined3d_buffer_preload(buffer); + wined3d_resource_preload(&buffer->resource); } } @@ -1225,6 +1217,15 @@ static ULONG buffer_resource_decref(struct wined3d_resource *resource) return wined3d_buffer_decref(buffer_from_resource(resource)); } +static void buffer_resource_preload(struct wined3d_resource *resource) +{ + struct wined3d_context *context; + + context = context_acquire(resource->device, NULL); + buffer_internal_preload(buffer_from_resource(resource), context, NULL); + context_release(context); +} + static HRESULT buffer_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) { @@ -1267,6 +1268,7 @@ static const struct wined3d_resource_ops buffer_resource_ops = { buffer_resource_incref, buffer_resource_decref, + buffer_resource_preload, buffer_unload, buffer_resource_sub_resource_map, buffer_resource_sub_resource_unmap, diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index a17203d2d7f..f0695ef9e73 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -327,6 +327,11 @@ HRESULT CDECL wined3d_resource_unmap(struct wined3d_resource *resource, unsigned return resource->resource_ops->resource_sub_resource_unmap(resource, sub_resource_idx); } +void CDECL wined3d_resource_preload(struct wined3d_resource *resource) +{ + resource->resource_ops->resource_preload(resource); +} + BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) { void **p; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index c3ecb667306..d2b1be57175 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -947,14 +947,6 @@ void wined3d_texture_load(struct wined3d_texture *texture, texture->flags |= flag; } -void CDECL wined3d_texture_preload(struct wined3d_texture *texture) -{ - struct wined3d_context *context; - context = context_acquire(texture->resource.device, NULL); - wined3d_texture_load(texture, context, texture->flags & WINED3D_TEXTURE_IS_SRGB); - context_release(context); -} - void * CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture) { TRACE("texture %p.\n", texture); @@ -1580,6 +1572,16 @@ static ULONG texture_resource_decref(struct wined3d_resource *resource) return wined3d_texture_decref(texture_from_resource(resource)); } +static void texture_resource_preload(struct wined3d_resource *resource) +{ + struct wined3d_texture *texture = texture_from_resource(resource); + struct wined3d_context *context; + + context = context_acquire(resource->device, NULL); + wined3d_texture_load(texture, context, texture->flags & WINED3D_TEXTURE_IS_SRGB); + context_release(context); +} + static void wined3d_texture_unload(struct wined3d_resource *resource) { struct wined3d_texture *texture = texture_from_resource(resource); @@ -1849,6 +1851,7 @@ static const struct wined3d_resource_ops texture_resource_ops = { texture_resource_incref, texture_resource_decref, + texture_resource_preload, wined3d_texture_unload, texture_resource_sub_resource_map, texture_resource_sub_resource_unmap, diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 5b9b12b61c0..c3899edcdee 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -29,7 +29,6 @@ @ cdecl wined3d_buffer_get_resource(ptr) @ cdecl wined3d_buffer_incref(ptr) @ cdecl wined3d_buffer_map(ptr long long ptr long) -@ cdecl wined3d_buffer_preload(ptr) @ cdecl wined3d_buffer_unmap(ptr) @ cdecl wined3d_device_acquire_focus_window(ptr ptr) @@ -188,6 +187,7 @@ @ cdecl wined3d_resource_get_parent(ptr) @ cdecl wined3d_resource_get_priority(ptr) @ cdecl wined3d_resource_map(ptr long ptr ptr long) +@ cdecl wined3d_resource_preload(ptr) @ cdecl wined3d_resource_set_parent(ptr ptr) @ cdecl wined3d_resource_set_priority(ptr long) @ cdecl wined3d_resource_unmap(ptr long) @@ -265,7 +265,6 @@ @ cdecl wined3d_texture_get_sub_resource_desc(ptr long ptr) @ cdecl wined3d_texture_get_sub_resource_parent(ptr long) @ cdecl wined3d_texture_incref(ptr) -@ cdecl wined3d_texture_preload(ptr) @ cdecl wined3d_texture_release_dc(ptr long ptr) @ cdecl wined3d_texture_set_autogen_filter_type(ptr long) @ cdecl wined3d_texture_set_color_key(ptr long ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 01af06fc264..78839516374 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2526,6 +2526,7 @@ struct wined3d_resource_ops { ULONG (*resource_incref)(struct wined3d_resource *resource); ULONG (*resource_decref)(struct wined3d_resource *resource); + void (*resource_preload)(struct wined3d_resource *resource); void (*resource_unload)(struct wined3d_resource *resource); HRESULT (*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/include/wine/wined3d.h b/include/wine/wined3d.h index 166feccb637..1e50020285d 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2133,7 +2133,6 @@ void * __cdecl wined3d_buffer_get_parent(const struct wined3d_buffer *buffer); struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buffer *buffer); ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer); HRESULT __cdecl wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UINT size, BYTE **data, DWORD flags); -void __cdecl wined3d_buffer_preload(struct wined3d_buffer *buffer); void __cdecl wined3d_buffer_unmap(struct wined3d_buffer *buffer); HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); @@ -2447,6 +2446,7 @@ void * __cdecl wined3d_resource_get_parent(const struct wined3d_resource *resour DWORD __cdecl wined3d_resource_get_priority(const struct wined3d_resource *resource); HRESULT __cdecl wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags); +void __cdecl wined3d_resource_preload(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); HRESULT __cdecl wined3d_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx); @@ -2561,7 +2561,6 @@ HRESULT __cdecl wined3d_texture_get_sub_resource_desc(const struct wined3d_textu unsigned int sub_resource_idx, struct wined3d_sub_resource_desc *desc); void * __cdecl wined3d_texture_get_sub_resource_parent(struct wined3d_texture *texture, unsigned int sub_resource_idx); ULONG __cdecl wined3d_texture_incref(struct wined3d_texture *texture); -void __cdecl wined3d_texture_preload(struct wined3d_texture *texture); HRESULT __cdecl wined3d_texture_release_dc(struct wined3d_texture *texture, unsigned int sub_resource_idx, HDC dc); HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture *texture, enum wined3d_texture_filter_type filter_type);