Commit 352d0493 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

wined3d: Rename buffer dirty ranges fields.

Make the fields names consistent with each other and with the usual scheme for field naming.
parent 344eee20
...@@ -70,38 +70,38 @@ static void buffer_invalidate_bo_range(struct wined3d_buffer *buffer, unsigned i ...@@ -70,38 +70,38 @@ static void buffer_invalidate_bo_range(struct wined3d_buffer *buffer, unsigned i
goto invalidate_all; goto invalidate_all;
} }
if (!wined3d_array_reserve((void **)&buffer->maps, &buffer->maps_size, if (!wined3d_array_reserve((void **)&buffer->dirty_ranges, &buffer->dirty_ranges_capacity,
buffer->modified_areas + 1, sizeof(*buffer->maps))) buffer->dirty_range_count + 1, sizeof(*buffer->dirty_ranges)))
{ {
ERR("Failed to allocate maps array, invalidating entire buffer.\n"); ERR("Failed to allocate dirty ranges array, invalidating entire buffer.\n");
goto invalidate_all; goto invalidate_all;
} }
buffer->maps[buffer->modified_areas].offset = offset; buffer->dirty_ranges[buffer->dirty_range_count].offset = offset;
buffer->maps[buffer->modified_areas].size = size; buffer->dirty_ranges[buffer->dirty_range_count].size = size;
++buffer->modified_areas; ++buffer->dirty_range_count;
return; return;
invalidate_all: invalidate_all:
buffer->modified_areas = 1; buffer->dirty_range_count = 1;
buffer->maps[0].offset = 0; buffer->dirty_ranges[0].offset = 0;
buffer->maps[0].size = buffer->resource.size; buffer->dirty_ranges[0].size = buffer->resource.size;
} }
static inline void buffer_clear_dirty_areas(struct wined3d_buffer *This) static inline void buffer_clear_dirty_areas(struct wined3d_buffer *buffer)
{ {
This->modified_areas = 0; buffer->dirty_range_count = 0;
} }
static BOOL buffer_is_dirty(const struct wined3d_buffer *buffer) static BOOL buffer_is_dirty(const struct wined3d_buffer *buffer)
{ {
return !!buffer->modified_areas; return !!buffer->dirty_range_count;
} }
static BOOL buffer_is_fully_dirty(const struct wined3d_buffer *buffer) static BOOL buffer_is_fully_dirty(const struct wined3d_buffer *buffer)
{ {
return buffer->modified_areas == 1 return buffer->dirty_range_count == 1
&& !buffer->maps->offset && buffer->maps->size == buffer->resource.size; && !buffer->dirty_ranges[0].offset && buffer->dirty_ranges[0].size == buffer->resource.size;
} }
void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location) void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location)
...@@ -534,10 +534,10 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined ...@@ -534,10 +534,10 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
return; return;
} }
for (range_idx = 0; range_idx < buffer->modified_areas; ++range_idx) for (range_idx = 0; range_idx < buffer->dirty_range_count; ++range_idx)
{ {
start = buffer->maps[range_idx].offset; start = buffer->dirty_ranges[range_idx].offset;
end = start + buffer->maps[range_idx].size; end = start + buffer->dirty_ranges[range_idx].size;
memcpy(data + start, (BYTE *)buffer->resource.heap_memory + start, end - start); memcpy(data + start, (BYTE *)buffer->resource.heap_memory + start, end - start);
for (i = start / buffer->stride; i < min((end / buffer->stride) + 1, vertex_count); ++i) for (i = start / buffer->stride; i < min((end / buffer->stride) + 1, vertex_count); ++i)
...@@ -568,7 +568,8 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined ...@@ -568,7 +568,8 @@ static void buffer_conversion_upload(struct wined3d_buffer *buffer, struct wined
dst.addr = NULL; dst.addr = NULL;
src.buffer_object = NULL; src.buffer_object = NULL;
src.addr = data; src.addr = data;
wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps, WINED3D_MAP_WRITE); wined3d_context_copy_bo_address(context, &dst, &src,
buffer->dirty_range_count, buffer->dirty_ranges, WINED3D_MAP_WRITE);
heap_free(data); heap_free(data);
} }
...@@ -657,11 +658,11 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, ...@@ -657,11 +658,11 @@ BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer,
{ {
uint32_t map_flags = WINED3D_MAP_WRITE; uint32_t map_flags = WINED3D_MAP_WRITE;
if (buffer->modified_areas == 1 && !buffer->maps[0].offset if (buffer_is_fully_dirty(buffer))
&& buffer->maps[0].size == buffer->resource.size)
map_flags |= WINED3D_MAP_DISCARD; map_flags |= WINED3D_MAP_DISCARD;
wined3d_context_copy_bo_address(context, &dst, &src, buffer->modified_areas, buffer->maps, map_flags); wined3d_context_copy_bo_address(context, &dst, &src,
buffer->dirty_range_count, buffer->dirty_ranges, map_flags);
} }
else else
{ {
...@@ -776,7 +777,7 @@ static void wined3d_buffer_destroy_object(void *object) ...@@ -776,7 +777,7 @@ static void wined3d_buffer_destroy_object(void *object)
context_release(context); context_release(context);
} }
heap_free(buffer->conversion_map); heap_free(buffer->conversion_map);
heap_free(buffer->maps); heap_free(buffer->dirty_ranges);
} }
void wined3d_buffer_cleanup(struct wined3d_buffer *buffer) void wined3d_buffer_cleanup(struct wined3d_buffer *buffer)
...@@ -1079,7 +1080,6 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc ...@@ -1079,7 +1080,6 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx) static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{ {
struct wined3d_buffer *buffer = buffer_from_resource(resource); struct wined3d_buffer *buffer = buffer_from_resource(resource);
unsigned int range_count = buffer->modified_areas;
struct wined3d_device *device = resource->device; struct wined3d_device *device = resource->device;
struct wined3d_context *context; struct wined3d_context *context;
struct wined3d_bo_address addr; struct wined3d_bo_address addr;
...@@ -1112,7 +1112,7 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou ...@@ -1112,7 +1112,7 @@ static HRESULT buffer_resource_sub_resource_unmap(struct wined3d_resource *resou
addr.buffer_object = buffer->buffer_object; addr.buffer_object = buffer->buffer_object;
addr.addr = 0; addr.addr = 0;
wined3d_context_unmap_bo_address(context, &addr, range_count, buffer->maps); wined3d_context_unmap_bo_address(context, &addr, buffer->dirty_range_count, buffer->dirty_ranges);
context_release(context); context_release(context);
...@@ -1399,7 +1399,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d ...@@ -1399,7 +1399,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
if (!(buffer->maps = heap_alloc(sizeof(*buffer->maps)))) if (!(buffer->dirty_ranges = heap_alloc(sizeof(*buffer->dirty_ranges))))
{ {
ERR("Out of memory.\n"); ERR("Out of memory.\n");
buffer_resource_unload(resource); buffer_resource_unload(resource);
...@@ -1407,7 +1407,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d ...@@ -1407,7 +1407,7 @@ static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d
wined3d_resource_wait_idle(resource); wined3d_resource_wait_idle(resource);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
} }
buffer->maps_size = 1; buffer->dirty_ranges_capacity = 1;
if (buffer->locations & WINED3D_LOCATION_DISCARDED) if (buffer->locations & WINED3D_LOCATION_DISCARDED)
buffer->resource.client.addr.buffer_object = CLIENT_BO_DISCARDED; buffer->resource.client.addr.buffer_object = CLIENT_BO_DISCARDED;
......
...@@ -3832,8 +3832,11 @@ struct wined3d_buffer ...@@ -3832,8 +3832,11 @@ struct wined3d_buffer
struct wined3d_bo *buffer_object; struct wined3d_bo *buffer_object;
struct wined3d_bo_user bo_user; struct wined3d_bo_user bo_user;
struct wined3d_range *maps; /* For buffers which are GPU accessible but for which BUFFER is not
SIZE_T maps_size, modified_areas; * currently a valid location, this is a list of areas that need to be
* uploaded to BUFFER. */
struct wined3d_range *dirty_ranges;
SIZE_T dirty_range_count, dirty_ranges_capacity;
/* conversion stuff */ /* conversion stuff */
UINT decl_change_count, full_conversion_count; UINT decl_change_count, full_conversion_count;
......
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