wined3d: Pass a resource to wined3d_resource_allocate_sysmem().
This commit is contained in:
parent
2b2bf64d3b
commit
261246ef21
|
@ -500,7 +500,8 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, struct wined3d_context *con
|
|||
/* AllocatedMemory exists if the buffer is double buffered or has no buffer object at all */
|
||||
if(This->resource.allocatedMemory) return This->resource.allocatedMemory;
|
||||
|
||||
This->resource.heap_memory = wined3d_resource_allocate_sysmem(This->resource.size);
|
||||
if (!wined3d_resource_allocate_sysmem(&This->resource))
|
||||
ERR("Failed to allocate system memory.\n");
|
||||
This->resource.allocatedMemory = This->resource.heap_memory;
|
||||
|
||||
if (This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
|
||||
|
|
|
@ -120,11 +120,10 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
|
|||
|
||||
if (size)
|
||||
{
|
||||
resource->heap_memory = wined3d_resource_allocate_sysmem(size);
|
||||
if (!resource->heap_memory)
|
||||
if (!wined3d_resource_allocate_sysmem(resource))
|
||||
{
|
||||
ERR("Out of memory!\n");
|
||||
return WINED3DERR_OUTOFVIDEOMEMORY;
|
||||
ERR("Failed to allocate system memory.\n");
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -344,19 +343,21 @@ void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, st
|
|||
desc->size = resource->size;
|
||||
}
|
||||
|
||||
void *wined3d_resource_allocate_sysmem(SIZE_T size)
|
||||
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
|
||||
{
|
||||
void **p;
|
||||
SIZE_T align = RESOURCE_ALIGNMENT - 1 + sizeof(*p);
|
||||
void *mem;
|
||||
|
||||
if (!(mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size + align)))
|
||||
return NULL;
|
||||
if (!(mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, resource->size + align)))
|
||||
return FALSE;
|
||||
|
||||
p = (void **)(((ULONG_PTR)mem + align) & ~(RESOURCE_ALIGNMENT - 1)) - 1;
|
||||
*p = mem;
|
||||
|
||||
return ++p;
|
||||
resource->heap_memory = ++p;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wined3d_resource_free_sysmem(void *mem)
|
||||
|
|
|
@ -587,9 +587,8 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
|
|||
{
|
||||
/* Whatever surface we have, make sure that there is memory allocated
|
||||
* for the downloaded copy, or a PBO to map. */
|
||||
if (!surface->resource.heap_memory)
|
||||
surface->resource.heap_memory = wined3d_resource_allocate_sysmem(surface->resource.size);
|
||||
|
||||
if (!surface->resource.heap_memory && !wined3d_resource_allocate_sysmem(&surface->resource))
|
||||
ERR("Failed to allocate system memory.\n");
|
||||
surface->resource.allocatedMemory = surface->resource.heap_memory;
|
||||
|
||||
if (surface->flags & SFLAG_INSYSMEM)
|
||||
|
@ -1432,7 +1431,7 @@ static void surface_remove_pbo(struct wined3d_surface *surface, const struct win
|
|||
else
|
||||
{
|
||||
if (!surface->resource.heap_memory)
|
||||
surface->resource.heap_memory = wined3d_resource_allocate_sysmem(surface->resource.size);
|
||||
wined3d_resource_allocate_sysmem(&surface->resource);
|
||||
else if (!(surface->flags & SFLAG_CLIENT))
|
||||
ERR("Surface %p has heap_memory %p and flags %#x.\n",
|
||||
surface, surface->resource.heap_memory, surface->flags);
|
||||
|
@ -1458,9 +1457,9 @@ static BOOL surface_init_sysmem(struct wined3d_surface *surface)
|
|||
{
|
||||
if (!surface->resource.heap_memory)
|
||||
{
|
||||
if (!(surface->resource.heap_memory = wined3d_resource_allocate_sysmem(surface->resource.size)))
|
||||
if (!wined3d_resource_allocate_sysmem(&surface->resource))
|
||||
{
|
||||
ERR("Failed to allocate memory.\n");
|
||||
ERR("Failed to allocate system memory.\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -391,9 +391,11 @@ static BOOL volume_prepare_system_memory(struct wined3d_volume *volume)
|
|||
if (volume->resource.allocatedMemory)
|
||||
return TRUE;
|
||||
|
||||
volume->resource.heap_memory = wined3d_resource_allocate_sysmem(volume->resource.size);
|
||||
if (!volume->resource.heap_memory)
|
||||
if (!wined3d_resource_allocate_sysmem(&volume->resource))
|
||||
{
|
||||
ERR("Failed to allocate system memory.\n");
|
||||
return FALSE;
|
||||
}
|
||||
volume->resource.allocatedMemory = volume->resource.heap_memory;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -1984,7 +1984,6 @@ struct wined3d_resource_ops
|
|||
void (*resource_unload)(struct wined3d_resource *resource);
|
||||
};
|
||||
|
||||
void *wined3d_resource_allocate_sysmem(SIZE_T size) DECLSPEC_HIDDEN;
|
||||
void wined3d_resource_free_sysmem(void *mem) DECLSPEC_HIDDEN;
|
||||
|
||||
struct wined3d_resource
|
||||
|
@ -2025,6 +2024,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
|
|||
const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
|
||||
DWORD resource_set_priority(struct wined3d_resource *resource, DWORD priority) DECLSPEC_HIDDEN;
|
||||
void resource_unload(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource,
|
||||
DWORD flags) DECLSPEC_HIDDEN;
|
||||
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
|
||||
|
|
Loading…
Reference in New Issue