Commit 3179a6af authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Introduce wined3d_resource_prepare_sysmem().

parent dc23cca3
......@@ -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;
}
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 */
......
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