wined3d: Unify resource preloads.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2016-08-10 18:44:48 +02:00 committed by Alexandre Julliard
parent 850d38efb4
commit 53165034ba
12 changed files with 42 additions and 33 deletions

View File

@ -167,7 +167,7 @@ static void WINAPI d3d8_vertexbuffer_PreLoad(IDirect3DVertexBuffer8 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_buffer_preload(buffer->wined3d_buffer); wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }
@ -444,7 +444,7 @@ static void WINAPI d3d8_indexbuffer_PreLoad(IDirect3DIndexBuffer8 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_buffer_preload(buffer->wined3d_buffer); wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }

View File

@ -187,7 +187,7 @@ static void WINAPI d3d8_texture_2d_PreLoad(IDirect3DTexture8 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(texture->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }
@ -533,7 +533,7 @@ static void WINAPI d3d8_texture_cube_PreLoad(IDirect3DCubeTexture8 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(texture->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }
@ -889,7 +889,7 @@ static void WINAPI d3d8_texture_3d_PreLoad(IDirect3DVolumeTexture8 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(texture->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }

View File

@ -168,7 +168,7 @@ static void WINAPI d3d9_vertexbuffer_PreLoad(IDirect3DVertexBuffer9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_buffer_preload(buffer->wined3d_buffer); wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }
@ -444,7 +444,7 @@ static void WINAPI d3d9_indexbuffer_PreLoad(IDirect3DIndexBuffer9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_buffer_preload(buffer->wined3d_buffer); wined3d_resource_preload(wined3d_buffer_get_resource(buffer->wined3d_buffer));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }

View File

@ -176,7 +176,7 @@ static void WINAPI d3d9_surface_PreLoad(IDirect3DSurface9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(surface->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(surface->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }

View File

@ -189,7 +189,7 @@ static void WINAPI d3d9_texture_2d_PreLoad(IDirect3DTexture9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(texture->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }
@ -578,7 +578,7 @@ static void WINAPI d3d9_texture_cube_PreLoad(IDirect3DCubeTexture9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(texture->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }
@ -980,7 +980,7 @@ static void WINAPI d3d9_texture_3d_PreLoad(IDirect3DVolumeTexture9 *iface)
TRACE("iface %p.\n", iface); TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(texture->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(texture->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
} }

View File

@ -5656,7 +5656,7 @@ static HRESULT d3d_device7_PreLoad(IDirect3DDevice7 *iface, IDirectDrawSurface7
return DDERR_INVALIDPARAMS; return DDERR_INVALIDPARAMS;
wined3d_mutex_lock(); wined3d_mutex_lock();
wined3d_texture_preload(surface->wined3d_texture); wined3d_resource_preload(wined3d_texture_get_resource(surface->wined3d_texture));
wined3d_mutex_unlock(); wined3d_mutex_unlock();
return D3D_OK; return D3D_OK;

View File

@ -928,14 +928,6 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
HeapFree(GetProcessHeap(), 0, data); 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) struct wined3d_resource * CDECL wined3d_buffer_get_resource(struct wined3d_buffer *buffer)
{ {
TRACE("buffer %p.\n", 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) 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)); 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, 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) 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_incref,
buffer_resource_decref, buffer_resource_decref,
buffer_resource_preload,
buffer_unload, buffer_unload,
buffer_resource_sub_resource_map, buffer_resource_sub_resource_map,
buffer_resource_sub_resource_unmap, buffer_resource_sub_resource_unmap,

View File

@ -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); 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) BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
{ {
void **p; void **p;

View File

@ -947,14 +947,6 @@ void wined3d_texture_load(struct wined3d_texture *texture,
texture->flags |= flag; 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) void * CDECL wined3d_texture_get_parent(const struct wined3d_texture *texture)
{ {
TRACE("texture %p.\n", 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)); 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) static void wined3d_texture_unload(struct wined3d_resource *resource)
{ {
struct wined3d_texture *texture = texture_from_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_incref,
texture_resource_decref, texture_resource_decref,
texture_resource_preload,
wined3d_texture_unload, wined3d_texture_unload,
texture_resource_sub_resource_map, texture_resource_sub_resource_map,
texture_resource_sub_resource_unmap, texture_resource_sub_resource_unmap,

View File

@ -29,7 +29,6 @@
@ cdecl wined3d_buffer_get_resource(ptr) @ cdecl wined3d_buffer_get_resource(ptr)
@ cdecl wined3d_buffer_incref(ptr) @ cdecl wined3d_buffer_incref(ptr)
@ cdecl wined3d_buffer_map(ptr long long ptr long) @ cdecl wined3d_buffer_map(ptr long long ptr long)
@ cdecl wined3d_buffer_preload(ptr)
@ cdecl wined3d_buffer_unmap(ptr) @ cdecl wined3d_buffer_unmap(ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr) @ cdecl wined3d_device_acquire_focus_window(ptr ptr)
@ -188,6 +187,7 @@
@ cdecl wined3d_resource_get_parent(ptr) @ cdecl wined3d_resource_get_parent(ptr)
@ cdecl wined3d_resource_get_priority(ptr) @ cdecl wined3d_resource_get_priority(ptr)
@ cdecl wined3d_resource_map(ptr long ptr ptr long) @ 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_parent(ptr ptr)
@ cdecl wined3d_resource_set_priority(ptr long) @ cdecl wined3d_resource_set_priority(ptr long)
@ cdecl wined3d_resource_unmap(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_desc(ptr long ptr)
@ cdecl wined3d_texture_get_sub_resource_parent(ptr long) @ cdecl wined3d_texture_get_sub_resource_parent(ptr long)
@ cdecl wined3d_texture_incref(ptr) @ cdecl wined3d_texture_incref(ptr)
@ cdecl wined3d_texture_preload(ptr)
@ cdecl wined3d_texture_release_dc(ptr long ptr) @ cdecl wined3d_texture_release_dc(ptr long ptr)
@ cdecl wined3d_texture_set_autogen_filter_type(ptr long) @ cdecl wined3d_texture_set_autogen_filter_type(ptr long)
@ cdecl wined3d_texture_set_color_key(ptr long ptr) @ cdecl wined3d_texture_set_color_key(ptr long ptr)

View File

@ -2526,6 +2526,7 @@ struct wined3d_resource_ops
{ {
ULONG (*resource_incref)(struct wined3d_resource *resource); ULONG (*resource_incref)(struct wined3d_resource *resource);
ULONG (*resource_decref)(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); void (*resource_unload)(struct wined3d_resource *resource);
HRESULT (*resource_sub_resource_map)(struct wined3d_resource *resource, unsigned int sub_resource_idx, 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); struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags);

View File

@ -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); struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buffer *buffer);
ULONG __cdecl wined3d_buffer_incref(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); 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); void __cdecl wined3d_buffer_unmap(struct wined3d_buffer *buffer);
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); 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); 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, 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); 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); void __cdecl wined3d_resource_set_parent(struct wined3d_resource *resource, void *parent);
DWORD __cdecl wined3d_resource_set_priority(struct wined3d_resource *resource, DWORD priority); 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); 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); 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); 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); 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_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, HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture *texture,
enum wined3d_texture_filter_type filter_type); enum wined3d_texture_filter_type filter_type);