Commit 776cc2d7 authored by Jean-Paul Saman's avatar Jean-Paul Saman

vaMapBuffer/vaUnMapBuffer: implemented refcounting on mapping/unmapping

Refcount mapping and unmapping of VABuffers.
parent d51c4dcc
......@@ -209,6 +209,7 @@ create_va_buffer(
obj_buffer->buffer_size = size * num_elements;
obj_buffer->buffer_data = malloc(obj_buffer->buffer_size);
obj_buffer->mtime = 0;
obj_buffer->map_refcnt = 0;
if (!obj_buffer->buffer_data) {
destroy_va_buffer(driver_data, obj_buffer);
......@@ -227,6 +228,8 @@ destroy_va_buffer(
if (!obj_buffer)
return;
ASSERT(obj_buffer->map_refcnt == 0);
if (obj_buffer->buffer_data) {
free(obj_buffer->buffer_data);
obj_buffer->buffer_data = NULL;
......@@ -900,6 +903,7 @@ xvba_MapBuffer(
return VA_STATUS_ERROR_UNKNOWN;
++obj_buffer->mtime;
++obj_buffer->map_refcnt;
return VA_STATUS_SUCCESS;
}
......@@ -917,6 +921,8 @@ xvba_UnmapBuffer(
return VA_STATUS_ERROR_INVALID_BUFFER;
++obj_buffer->mtime;
--obj_buffer->map_refcnt;
ASSERT(obj_buffer->map_refcnt >= 0);
return VA_STATUS_SUCCESS;
}
......
......@@ -33,6 +33,7 @@ struct object_buffer {
unsigned int max_num_elements;
unsigned int num_elements;
uint64_t mtime;
int32_t map_refcnt;
};
// Create VA buffer object
......
......@@ -446,6 +446,9 @@ commit_hw_image(
NOTE: this assumes the user really unmaps the buffer when he is
done with it, as it is actually required */
ASSERT(obj_buffer->map_refcnt == 0);
if (obj_image->hw.mtime < obj_buffer->mtime) {
#if USE_GLX
if (flags & HWIMAGE_TYPE_GLX) {
......
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