[PATCH 4/5] wined3d: Move heap_memory into the sub resource.
Stefan Dösinger
stefan at codeweavers.com
Mon Feb 10 06:28:20 CST 2014
---
dlls/wined3d/buffer.c | 36 +++++++++++-----------
dlls/wined3d/drawprim.c | 2 +-
dlls/wined3d/resource.c | 68 ++++++++++++++++++++++++++++--------------
dlls/wined3d/surface.c | 30 +++++++++----------
dlls/wined3d/swapchain.c | 4 +--
dlls/wined3d/volume.c | 22 +++++++-------
dlls/wined3d/wined3d_private.h | 14 +++++++--
7 files changed, 103 insertions(+), 73 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 61d62f8..8b991c4 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -182,7 +182,7 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wine
* we're not double buffering, so we can release the heap mem afterwards
*/
GL_EXTCALL(glBufferDataARB(This->buffer_type_hint, This->sub_resource.resource.size,
- This->sub_resource.resource.heap_memory, gl_usage));
+ This->sub_resource.heap_memory, gl_usage));
error = gl_info->gl_ops.gl.p_glGetError();
if (error != GL_NO_ERROR)
{
@@ -195,7 +195,7 @@ static void buffer_create_buffer_object(struct wined3d_buffer *This, struct wine
if (This->flags & WINED3D_BUFFER_DOUBLEBUFFER)
buffer_invalidate_bo_range(This, 0, 0);
else
- wined3d_resource_free_sysmem(&This->sub_resource.resource);
+ wined3d_sub_resource_free_sysmem(&This->sub_resource);
return;
@@ -469,7 +469,7 @@ void buffer_get_memory(struct wined3d_buffer *buffer, struct wined3d_context *co
return;
}
}
- data->addr = buffer->sub_resource.resource.heap_memory;
+ data->addr = buffer->sub_resource.heap_memory;
}
else
{
@@ -492,10 +492,10 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, struct wined3d_context *con
const struct wined3d_gl_info *gl_info = context->gl_info;
/* Heap_memory exists if the buffer is double buffered or has no buffer object at all. */
- if (This->sub_resource.resource.heap_memory)
- return This->sub_resource.resource.heap_memory;
+ if (This->sub_resource.heap_memory)
+ return This->sub_resource.heap_memory;
- if (!wined3d_resource_allocate_sysmem(&This->sub_resource.resource))
+ if (!wined3d_sub_resource_allocate_sysmem(&This->sub_resource))
ERR("Failed to allocate system memory.\n");
if (This->buffer_type_hint == GL_ELEMENT_ARRAY_BUFFER_ARB)
@@ -503,10 +503,10 @@ BYTE *buffer_get_sysmem(struct wined3d_buffer *This, struct wined3d_context *con
GL_EXTCALL(glBindBufferARB(This->buffer_type_hint, This->buffer_object));
GL_EXTCALL(glGetBufferSubDataARB(This->buffer_type_hint, 0,
- This->sub_resource.resource.size, This->sub_resource.resource.heap_memory));
+ This->sub_resource.resource.size, This->sub_resource.heap_memory));
This->flags |= WINED3D_BUFFER_DOUBLEBUFFER;
- return This->sub_resource.resource.heap_memory;
+ return This->sub_resource.heap_memory;
}
static void buffer_unload(struct wined3d_resource *resource)
@@ -563,7 +563,7 @@ ULONG CDECL wined3d_buffer_decref(struct wined3d_buffer *buffer)
HeapFree(GetProcessHeap(), 0, buffer->conversion_map);
}
- resource_cleanup(&buffer->sub_resource.resource);
+ wined3d_sub_resource_cleanup(&buffer->sub_resource);
buffer->sub_resource.resource.parent_ops->wined3d_object_destroyed(buffer->sub_resource.resource.parent);
HeapFree(GetProcessHeap(), 0, buffer->maps);
HeapFree(GetProcessHeap(), 0, buffer);
@@ -707,7 +707,7 @@ static void buffer_direct_upload(struct wined3d_buffer *This, const struct wined
start = This->maps[This->modified_areas].offset;
len = This->maps[This->modified_areas].size;
- memcpy(map + start, (BYTE *)This->sub_resource.resource.heap_memory + start, len);
+ memcpy(map + start, (BYTE *)This->sub_resource.heap_memory + start, len);
if (gl_info->supported[ARB_MAP_BUFFER_RANGE])
{
@@ -859,7 +859,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
if (!buffer->conversion_map)
{
/* That means that there is nothing to fixup. Just upload from
- * buffer->sub_resource.resource.heap_memory directly into the vbo. Do not
+ * buffer->sub_resource.heap_memory directly into the vbo. Do not
* free the system memory copy because drawPrimitive may need it if
* the stride is 0, for instancing emulation, vertex blending
* emulation or shader emulation. */
@@ -895,7 +895,7 @@ void buffer_internal_preload(struct wined3d_buffer *buffer, struct wined3d_conte
len = buffer->maps[buffer->modified_areas].size;
end = start + len;
- memcpy(data + start, (BYTE *)buffer->sub_resource.resource.heap_memory + start, end - start);
+ memcpy(data + start, (BYTE *)buffer->sub_resource.heap_memory + start, end - start);
for (i = start / buffer->stride; i < min((end / buffer->stride) + 1, vertices); ++i)
{
for (j = 0; j < buffer->stride; ++j)
@@ -1023,7 +1023,7 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
TRACE("Falling back to doublebuffered operation\n");
buffer_get_sysmem(buffer, context);
}
- TRACE("New pointer is %p.\n", buffer->sub_resource.resource.heap_memory);
+ TRACE("New pointer is %p.\n", buffer->sub_resource.heap_memory);
buffer->map_ptr = NULL;
}
context_release(context);
@@ -1050,7 +1050,7 @@ HRESULT CDECL wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UIN
}
}
- base = buffer->map_ptr ? buffer->map_ptr : buffer->sub_resource.resource.heap_memory;
+ base = buffer->map_ptr ? buffer->map_ptr : buffer->sub_resource.heap_memory;
*data = base + offset;
TRACE("Returning memory at %p (base %p, offset %u).\n", *data, base, offset);
@@ -1148,7 +1148,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
return WINED3DERR_INVALIDCALL;
}
- hr = resource_init(&buffer->sub_resource.resource, device, WINED3D_RTYPE_BUFFER, format,
+ hr = wined3d_sub_resource_init(&buffer->sub_resource, device, WINED3D_RTYPE_BUFFER, format,
WINED3D_MULTISAMPLE_NONE, 0, usage, pool, size, 1, 1, size,
parent, parent_ops, &buffer_resource_ops);
if (FAILED(hr))
@@ -1160,7 +1160,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
TRACE("size %#x, usage %#x, format %s, memory @ %p, iface @ %p.\n",
buffer->sub_resource.resource.size, buffer->sub_resource.resource.usage,
- debug_d3dformat(buffer->sub_resource.resource.format->id), buffer->sub_resource.resource.heap_memory, buffer);
+ debug_d3dformat(buffer->sub_resource.resource.format->id), buffer->sub_resource.heap_memory, buffer);
if (device->create_parms.flags & WINED3DCREATE_SOFTWARE_VERTEXPROCESSING)
{
@@ -1206,7 +1206,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
{
ERR("Failed to map buffer, hr %#x\n", hr);
buffer_unload(&buffer->sub_resource.resource);
- resource_cleanup(&buffer->sub_resource.resource);
+ wined3d_sub_resource_cleanup(&buffer->sub_resource);
return hr;
}
@@ -1220,7 +1220,7 @@ static HRESULT buffer_init(struct wined3d_buffer *buffer, struct wined3d_device
{
ERR("Out of memory\n");
buffer_unload(&buffer->sub_resource.resource);
- resource_cleanup(&buffer->sub_resource.resource);
+ wined3d_sub_resource_cleanup(&buffer->sub_resource);
return E_OUTOFMEMORY;
}
buffer->maps_size = 1;
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index fc06ab3..935ab2a 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -693,7 +693,7 @@ void draw_primitive(struct wined3d_device *device, UINT start_idx, UINT index_co
{
struct wined3d_buffer *index_buffer = state->index_buffer;
if (!index_buffer->buffer_object || !stream_info->all_vbo)
- idx_data = index_buffer->sub_resource.resource.heap_memory;
+ idx_data = index_buffer->sub_resource.heap_memory;
else
{
ib_query = index_buffer->query;
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index 177d23e..255f636 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -84,8 +84,6 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
void *parent, const struct wined3d_parent_ops *parent_ops,
const struct wined3d_resource_ops *resource_ops)
{
- const struct wined3d *d3d = device->wined3d;
-
resource_check_usage(usage);
if (pool != WINED3D_POOL_SCRATCH)
{
@@ -118,9 +116,30 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
resource->resource_ops = resource_ops;
list_init(&resource->privateData);
+ device_resource_add(device, resource);
+
+ return WINED3D_OK;
+}
+
+HRESULT wined3d_sub_resource_init(struct wined3d_sub_resource *sub_resource, struct wined3d_device *device,
+ enum wined3d_resource_type type, const struct wined3d_format *format,
+ enum wined3d_multisample_type multisample_type, UINT multisample_quality,
+ DWORD usage, enum wined3d_pool pool, UINT width, UINT height, UINT depth, UINT size,
+ void *parent, const struct wined3d_parent_ops *parent_ops,
+ const struct wined3d_resource_ops *resource_ops)
+{
+ const struct wined3d *d3d = device->wined3d;
+ HRESULT hr;
+
+ hr = resource_init(&sub_resource->resource, device, type, format, multisample_type,
+ multisample_quality, usage, pool, width, height, depth, size, parent,
+ parent_ops, resource_ops);
+ if (FAILED(hr))
+ return hr;
+
if (size)
{
- if (!wined3d_resource_allocate_sysmem(resource))
+ if (!wined3d_sub_resource_allocate_sysmem(sub_resource))
{
ERR("Failed to allocate system memory.\n");
return E_OUTOFMEMORY;
@@ -128,7 +147,7 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
}
else
{
- resource->heap_memory = NULL;
+ sub_resource->heap_memory = NULL;
}
/* Check that we have enough video ram left */
@@ -137,32 +156,23 @@ HRESULT resource_init(struct wined3d_resource *resource, struct wined3d_device *
if (size > wined3d_device_get_available_texture_mem(device))
{
ERR("Out of adapter memory\n");
- wined3d_resource_free_sysmem(resource);
+ wined3d_sub_resource_free_sysmem(sub_resource);
return WINED3DERR_OUTOFVIDEOMEMORY;
}
adapter_adjust_memory(device->adapter, size);
}
- device_resource_add(device, resource);
-
- return WINED3D_OK;
+ return hr;
}
void resource_cleanup(struct wined3d_resource *resource)
{
- const struct wined3d *d3d = resource->device->wined3d;
struct private_data *data;
struct list *e1, *e2;
HRESULT hr;
TRACE("Cleaning up resource %p.\n", resource);
- if (resource->pool == WINED3D_POOL_DEFAULT && d3d->flags & WINED3D_VIDMEM_ACCOUNTING)
- {
- TRACE("Decrementing device memory pool by %u.\n", resource->size);
- adapter_adjust_memory(resource->device->adapter, 0 - resource->size);
- }
-
LIST_FOR_EACH_SAFE(e1, e2, &resource->privateData)
{
data = LIST_ENTRY(e1, struct private_data, entry);
@@ -171,11 +181,23 @@ void resource_cleanup(struct wined3d_resource *resource)
ERR("Failed to free private data when destroying resource %p, hr = %#x.\n", resource, hr);
}
- wined3d_resource_free_sysmem(resource);
-
device_resource_released(resource->device, resource);
}
+void wined3d_sub_resource_cleanup(struct wined3d_sub_resource *sub_resource)
+{
+ const struct wined3d *d3d = sub_resource->resource.device->wined3d;
+
+ if (sub_resource->resource.pool == WINED3D_POOL_DEFAULT && d3d->flags & WINED3D_VIDMEM_ACCOUNTING)
+ {
+ TRACE("Decrementing device memory pool by %u.\n", sub_resource->resource.size);
+ adapter_adjust_memory(sub_resource->resource.device->adapter, 0 - sub_resource->resource.size);
+ }
+
+ wined3d_sub_resource_free_sysmem(sub_resource);
+ resource_cleanup(&sub_resource->resource);
+}
+
void resource_unload(struct wined3d_resource *resource)
{
if (resource->map_count)
@@ -345,32 +367,32 @@ void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, st
desc->size = resource->size;
}
-BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource)
+BOOL wined3d_sub_resource_allocate_sysmem(struct wined3d_sub_resource *sub_resource)
{
void **p;
SIZE_T align = RESOURCE_ALIGNMENT - 1 + sizeof(*p);
void *mem;
- if (!(mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, resource->size + align)))
+ if (!(mem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sub_resource->resource.size + align)))
return FALSE;
p = (void **)(((ULONG_PTR)mem + align) & ~(RESOURCE_ALIGNMENT - 1)) - 1;
*p = mem;
- resource->heap_memory = ++p;
+ sub_resource->heap_memory = ++p;
return TRUE;
}
-void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
+void wined3d_sub_resource_free_sysmem(struct wined3d_sub_resource *sub_resource)
{
- void **p = resource->heap_memory;
+ void **p = sub_resource->heap_memory;
if (!p)
return;
HeapFree(GetProcessHeap(), 0, *(--p));
- resource->heap_memory = NULL;
+ sub_resource->heap_memory = NULL;
}
DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource, DWORD flags)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index a04060f..f323c24 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -100,7 +100,7 @@ static void surface_cleanup(struct wined3d_surface *surface)
overlay->overlay_dest = NULL;
}
- resource_cleanup(&surface->sub_resource.resource);
+ wined3d_sub_resource_cleanup(&surface->sub_resource);
}
void surface_update_draw_binding(struct wined3d_surface *surface)
@@ -529,7 +529,7 @@ static void surface_get_memory(const struct wined3d_surface *surface, struct win
}
if (location & WINED3D_LOCATION_SYSMEM)
{
- data->addr = surface->sub_resource.resource.heap_memory;
+ data->addr = surface->sub_resource.heap_memory;
data->buffer_object = 0;
return;
}
@@ -575,12 +575,12 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
{
TRACE("surface %p.\n", surface);
- if (surface->sub_resource.resource.heap_memory)
+ if (surface->sub_resource.heap_memory)
return;
/* Whatever surface we have, make sure that there is memory allocated
* for the downloaded copy, or a PBO to map. */
- if (!wined3d_resource_allocate_sysmem(&surface->sub_resource.resource))
+ if (!wined3d_sub_resource_allocate_sysmem(&surface->sub_resource))
ERR("Failed to allocate system memory.\n");
if (surface->locations & WINED3D_LOCATION_SYSMEM)
@@ -619,7 +619,7 @@ static void surface_evict_sysmem(struct wined3d_surface *surface)
if (surface->sub_resource.resource.map_count || surface->flags & SFLAG_DONOTFREE)
return;
- wined3d_resource_free_sysmem(&surface->sub_resource.resource);
+ wined3d_sub_resource_free_sysmem(&surface->sub_resource);
surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM);
}
@@ -1281,7 +1281,7 @@ static void surface_unload(struct wined3d_resource *resource)
* or the depth stencil into an FBO the texture or render buffer will be removed
* and all flags get lost */
surface_prepare_system_memory(surface);
- memset(surface->sub_resource.resource.heap_memory, 0, surface->sub_resource.resource.size);
+ memset(surface->sub_resource.heap_memory, 0, surface->sub_resource.resource.size);
surface_validate_location(surface, WINED3D_LOCATION_SYSMEM);
surface_invalidate_location(surface, ~WINED3D_LOCATION_SYSMEM);
@@ -2035,7 +2035,7 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
if (gl_info->supported[APPLE_CLIENT_STORAGE])
{
if (surface->flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_CONVERTED)
- || !surface->sub_resource.resource.heap_memory)
+ || !surface->sub_resource.heap_memory)
{
/* In some cases we want to disable client storage.
* SFLAG_NONPOW2 has a bigger opengl texture than the client memory, and different pitches
@@ -2048,7 +2048,7 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
else
{
surface->flags |= SFLAG_CLIENT;
- mem = surface->sub_resource.resource.heap_memory;
+ mem = surface->sub_resource.heap_memory;
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
@@ -2634,7 +2634,7 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
}
surface->locations = 0;
- wined3d_resource_free_sysmem(&surface->sub_resource.resource);
+ wined3d_sub_resource_free_sysmem(&surface->sub_resource);
surface->sub_resource.resource.width = width;
surface->sub_resource.resource.height = height;
@@ -3103,7 +3103,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
switch (surface->map_binding)
{
case WINED3D_LOCATION_SYSMEM:
- base_memory = surface->sub_resource.resource.heap_memory;
+ base_memory = surface->sub_resource.heap_memory;
break;
case WINED3D_LOCATION_USER_MEMORY:
@@ -3831,9 +3831,9 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back)
front->dib.bitmap_data = back->dib.bitmap_data;
back->dib.bitmap_data = tmp;
- tmp = front->sub_resource.resource.heap_memory;
- front->sub_resource.resource.heap_memory = back->sub_resource.resource.heap_memory;
- back->sub_resource.resource.heap_memory = tmp;
+ tmp = front->sub_resource.heap_memory;
+ front->sub_resource.heap_memory = back->sub_resource.heap_memory;
+ back->sub_resource.heap_memory = tmp;
}
/* Flip the PBO */
@@ -6382,7 +6382,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
else
surface->surface_ops = &surface_ops;
- if (FAILED(hr = resource_init(&surface->sub_resource.resource, device, WINED3D_RTYPE_SURFACE, format,
+ if (FAILED(hr = wined3d_sub_resource_init(&surface->sub_resource, device, WINED3D_RTYPE_SURFACE, format,
desc->multisample_type, multisample_quality, desc->usage, desc->pool, desc->width, desc->height, 1,
resource_size, NULL, &wined3d_null_parent_ops, &surface_resource_ops)))
{
@@ -6425,7 +6425,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
if (surface->map_binding == WINED3D_LOCATION_DIB)
{
- wined3d_resource_free_sysmem(&surface->sub_resource.resource);
+ wined3d_sub_resource_free_sysmem(&surface->sub_resource);
surface_validate_location(surface, WINED3D_LOCATION_DIB);
surface_invalidate_location(surface, WINED3D_LOCATION_SYSMEM);
}
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index b289aae..b3212d8 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -684,10 +684,10 @@ static void swapchain_gdi_present(struct wined3d_swapchain *swapchain, const REC
front->dib.bitmap_data = back->dib.bitmap_data;
back->dib.bitmap_data = tmp;
- if (front->sub_resource.resource.heap_memory)
+ if (front->sub_resource.heap_memory)
ERR("GDI Surface %p has heap memory allocated.\n", front);
- if (back->sub_resource.resource.heap_memory)
+ if (back->sub_resource.heap_memory)
ERR("GDI Surface %p has heap memory allocated.\n", back);
}
diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c
index dfdeb61..e08a5e4 100644
--- a/dlls/wined3d/volume.c
+++ b/dlls/wined3d/volume.c
@@ -36,10 +36,10 @@ void volume_set_container(struct wined3d_volume *volume, struct wined3d_texture
static BOOL volume_prepare_system_memory(struct wined3d_volume *volume)
{
- if (volume->sub_resource.resource.heap_memory)
+ if (volume->sub_resource.heap_memory)
return TRUE;
- if (!wined3d_resource_allocate_sysmem(&volume->sub_resource.resource))
+ if (!wined3d_sub_resource_allocate_sysmem(&volume->sub_resource))
{
ERR("Failed to allocate system memory.\n");
return FALSE;
@@ -61,7 +61,7 @@ static void wined3d_volume_allocate_texture(struct wined3d_volume *volume,
TRACE("Enabling GL_UNPACK_CLIENT_STORAGE_APPLE for volume %p\n", volume);
gl_info->gl_ops.gl.p_glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)");
- mem = volume->sub_resource.resource.heap_memory;
+ mem = volume->sub_resource.heap_memory;
volume->flags |= WINED3D_VFLAG_CLIENT_STORAGE;
}
@@ -211,7 +211,7 @@ static void wined3d_volume_download_data(struct wined3d_volume *volume,
static void wined3d_volume_evict_sysmem(struct wined3d_volume *volume)
{
- wined3d_resource_free_sysmem(&volume->sub_resource.resource);
+ wined3d_sub_resource_free_sysmem(&volume->sub_resource);
wined3d_volume_invalidate_location(volume, WINED3D_LOCATION_SYSMEM);
}
@@ -314,7 +314,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume,
}
else if (volume->locations & WINED3D_LOCATION_SYSMEM)
{
- struct wined3d_bo_address data = {0, volume->sub_resource.resource.heap_memory};
+ struct wined3d_bo_address data = {0, volume->sub_resource.heap_memory};
wined3d_volume_upload_data(volume, context, &data);
}
else if (volume->locations & WINED3D_LOCATION_BUFFER)
@@ -343,7 +343,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume,
break;
case WINED3D_LOCATION_SYSMEM:
- if (!volume->sub_resource.resource.heap_memory)
+ if (!volume->sub_resource.heap_memory)
ERR("Trying to load WINED3D_LOCATION_SYSMEM without setting it up first.\n");
if (volume->locations & WINED3D_LOCATION_DISCARDED)
@@ -353,7 +353,7 @@ static void wined3d_volume_load_location(struct wined3d_volume *volume,
}
else if (volume->locations & (WINED3D_LOCATION_TEXTURE_RGB | WINED3D_LOCATION_TEXTURE_SRGB))
{
- struct wined3d_bo_address data = {0, volume->sub_resource.resource.heap_memory};
+ struct wined3d_bo_address data = {0, volume->sub_resource.heap_memory};
if (volume->locations & WINED3D_LOCATION_TEXTURE_RGB)
wined3d_texture_bind_and_dirtify(volume->container, context, FALSE);
@@ -541,7 +541,7 @@ ULONG CDECL wined3d_volume_decref(struct wined3d_volume *volume)
if (volume->pbo)
wined3d_volume_free_pbo(volume);
- resource_cleanup(&volume->sub_resource.resource);
+ wined3d_sub_resource_cleanup(&volume->sub_resource);
volume->sub_resource.resource.parent_ops->wined3d_object_destroyed(volume->sub_resource.resource.parent);
HeapFree(GetProcessHeap(), 0, volume);
}
@@ -715,7 +715,7 @@ HRESULT CDECL wined3d_volume_map(struct wined3d_volume *volume,
wined3d_volume_load_location(volume, context, WINED3D_LOCATION_SYSMEM);
context_release(context);
}
- base_memory = volume->sub_resource.resource.heap_memory;
+ base_memory = volume->sub_resource.heap_memory;
}
TRACE("Base memory pointer %p.\n", base_memory);
@@ -840,7 +840,7 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture
size = wined3d_format_calculate_size(format, device->surface_alignment, desc->width, desc->height, desc->depth);
- if (FAILED(hr = resource_init(&volume->sub_resource.resource, device, WINED3D_RTYPE_VOLUME, format,
+ if (FAILED(hr = wined3d_sub_resource_init(&volume->sub_resource, device, WINED3D_RTYPE_VOLUME, format,
WINED3D_MULTISAMPLE_NONE, 0, desc->usage, desc->pool, desc->width, desc->height, desc->depth,
size, NULL, &wined3d_null_parent_ops, &volume_resource_ops)))
{
@@ -855,7 +855,7 @@ static HRESULT volume_init(struct wined3d_volume *volume, struct wined3d_texture
&& gl_info->supported[ARB_PIXEL_BUFFER_OBJECT]
&& !format->convert)
{
- wined3d_resource_free_sysmem(&volume->sub_resource.resource);
+ wined3d_sub_resource_free_sysmem(&volume->sub_resource);
volume->flags |= WINED3D_VFLAG_PBO;
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index d3c0f5b..facd0a0 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1999,7 +1999,6 @@ struct wined3d_resource
UINT depth;
UINT size;
DWORD priority;
- void *heap_memory;
struct list privateData;
struct list resource_list_entry;
@@ -2018,8 +2017,6 @@ 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;
-void wined3d_resource_free_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;
@@ -2031,8 +2028,19 @@ GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
struct wined3d_sub_resource
{
struct wined3d_resource resource;
+ void *heap_memory;
};
+BOOL wined3d_sub_resource_allocate_sysmem(struct wined3d_sub_resource *sub_resource) DECLSPEC_HIDDEN;
+void wined3d_sub_resource_cleanup(struct wined3d_sub_resource *sub_resource) DECLSPEC_HIDDEN;
+void wined3d_sub_resource_free_sysmem(struct wined3d_sub_resource *sub_resource) DECLSPEC_HIDDEN;
+HRESULT wined3d_sub_resource_init(struct wined3d_sub_resource *sub_resource, struct wined3d_device *device,
+ enum wined3d_resource_type type, const struct wined3d_format *format,
+ enum wined3d_multisample_type multisample_type, UINT multisample_quality,
+ DWORD usage, enum wined3d_pool pool, UINT width, UINT height, UINT depth, UINT size,
+ void *parent, const struct wined3d_parent_ops *parent_ops,
+ const struct wined3d_resource_ops *resource_ops) DECLSPEC_HIDDEN;
+
enum wined3d_texture_state
{
WINED3DTEXSTA_ADDRESSU = 0,
--
1.8.3.2
More information about the wine-patches
mailing list