Henri Verbeet : wined3d: Introduce wined3d_resource_prepare_sysmem().
Alexandre Julliard
julliard at winehq.org
Fri Aug 16 17:30:49 CDT 2019
Module: wine
Branch: master
Commit: 3179a6af29dca253a9ae98ce53df17bec53f0c35
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3179a6af29dca253a9ae98ce53df17bec53f0c35
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Fri Aug 16 01:49:35 2019 +0430
wined3d: Introduce wined3d_resource_prepare_sysmem().
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wined3d/buffer.c | 9 ++-------
dlls/wined3d/resource.c | 10 +++++++++-
dlls/wined3d/texture.c | 15 ++++-----------
dlls/wined3d/wined3d_private.h | 2 +-
4 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index b5f44c5..eeea57d 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -601,12 +601,7 @@ static BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer,
switch (location)
{
case WINED3D_LOCATION_SYSMEM:
- if (buffer->resource.heap_memory)
- return TRUE;
-
- if (!wined3d_resource_allocate_sysmem(&buffer->resource))
- return FALSE;
- return TRUE;
+ return wined3d_resource_prepare_sysmem(&buffer->resource);
case WINED3D_LOCATION_BUFFER:
if (buffer_gl->buffer_object)
@@ -1419,7 +1414,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d
if (buffer->locations & WINED3D_LOCATION_SYSMEM || !(buffer->flags & WINED3D_BUFFER_USE_BO))
{
- if (!wined3d_resource_allocate_sysmem(&buffer->resource))
+ if (!wined3d_resource_prepare_sysmem(&buffer->resource))
return E_OUTOFMEMORY;
}
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 2897ab1..bba940f 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -395,7 +395,7 @@ void CDECL wined3d_resource_preload(struct wined3d_resource *resource)
wined3d_cs_emit_preload_resource(resource->device->cs, resource);
}
-BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
+static BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
{
void **p;
SIZE_T align = RESOURCE_ALIGNMENT - 1 + sizeof(*p);
@@ -415,6 +415,14 @@ BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
return TRUE;
}
+BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource)
+{
+ if (resource->heap_memory)
+ return TRUE;
+
+ return wined3d_resource_allocate_sysmem(resource);
+}
+
void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
{
void **p = resource->heap_memory;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 4d411bf..7cde07c 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1505,14 +1505,6 @@ void wined3d_texture_gl_set_compatible_renderbuffer(struct wined3d_texture_gl *t
checkGLcall("set compatible renderbuffer");
}
-static BOOL wined3d_texture_prepare_sysmem(struct wined3d_texture *texture)
-{
- if (texture->resource.heap_memory)
- return TRUE;
-
- return wined3d_resource_allocate_sysmem(&texture->resource);
-}
-
HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT width, UINT height,
enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type,
UINT multisample_quality, void *mem, UINT pitch)
@@ -1638,7 +1630,8 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
}
else
{
- wined3d_texture_prepare_sysmem(texture);
+ if (!wined3d_resource_prepare_sysmem(&texture->resource))
+ ERR("Failed to allocate resource memory.\n");
valid_location = WINED3D_LOCATION_SYSMEM;
}
@@ -1813,7 +1806,7 @@ BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned
switch (location)
{
case WINED3D_LOCATION_SYSMEM:
- return wined3d_texture_prepare_sysmem(texture);
+ return wined3d_resource_prepare_sysmem(&texture->resource);
case WINED3D_LOCATION_USER_MEMORY:
if (!texture->user_memory)
@@ -3296,7 +3289,7 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
if (desc->resource_type != WINED3D_RTYPE_TEXTURE_3D
|| !wined3d_texture_use_pbo(texture, gl_info))
{
- if (!wined3d_resource_allocate_sysmem(&texture->resource))
+ if (!wined3d_resource_prepare_sysmem(&texture->resource))
{
wined3d_texture_cleanup_sync(texture);
return E_OUTOFMEMORY;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 3446a84..b37f2c1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3437,7 +3437,6 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
unsigned int size, void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
-BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
const struct wined3d_format *wined3d_resource_get_decompress_format(
const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
@@ -3445,6 +3444,7 @@ unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *re
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
/* Tests show that the start address of resources is 32 byte aligned */
More information about the wine-cvs
mailing list