summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c11
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffer_objects.c46
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffer_objects.h8
3 files changed, 27 insertions, 38 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 8952e97674c..62e43e83bb8 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -253,8 +253,7 @@ copy_array_to_vbo_array( struct brw_context *brw,
&buffer->bo, &buffer->offset);
} else {
const unsigned char *src = element->glarray->Ptr;
- char *dst = intel_upload_map(&brw->intel, size,
- &buffer->bo, &buffer->offset);
+ char *dst = intel_upload_map(&brw->intel, size);
int i;
for (i = 0; i < element->count; i++) {
@@ -262,6 +261,8 @@ copy_array_to_vbo_array( struct brw_context *brw,
src += element->glarray->StrideB;
dst += dst_stride;
}
+ intel_upload_unmap(&brw->intel, dst, size,
+ &buffer->bo, &buffer->offset);
}
}
@@ -421,9 +422,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
int count = upload[0]->count, offset;
char *map;
- map = intel_upload_map(&brw->intel, total_size * count,
- &buffer->bo, &buffer->offset);
-
+ map = intel_upload_map(&brw->intel, total_size * count);
for (i = offset = 0; i < nr_uploads; i++) {
const unsigned char *src = upload[i]->glarray->Ptr;
int size = upload[i]->element_size;
@@ -442,6 +441,8 @@ static void brw_prepare_vertices(struct brw_context *brw)
offset += size;
}
+ intel_upload_unmap(&brw->intel, map, total_size * count,
+ &buffer->bo, &buffer->offset);
buffer->stride = offset;
j++;
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index 4edf29ec759..9d54f47fead 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -619,7 +619,7 @@ void intel_upload_data(struct intel_context *intel,
*return_offset = intel->upload.offset;
if (intel->upload.buffer_len &&
- intel->upload.buffer_len + asize > sizeof(intel->upload.buffer))
+ intel->upload.buffer_len + size > sizeof(intel->upload.buffer))
{
drm_intel_bo_subdata(intel->upload.bo,
intel->upload.buffer_offset,
@@ -646,25 +646,12 @@ void intel_upload_data(struct intel_context *intel,
intel->upload.offset += asize;
}
-void *intel_upload_map(struct intel_context *intel,
- GLuint size,
- drm_intel_bo **return_bo,
- GLuint *return_offset)
+void *intel_upload_map(struct intel_context *intel, GLuint size)
{
- GLuint asize = ALIGN(size, 64);
char *ptr;
- if (intel->upload.bo == NULL ||
- intel->upload.offset + size > intel->upload.bo->size) {
- wrap_buffers(intel, size);
- }
-
- drm_intel_bo_reference(intel->upload.bo);
- *return_bo = intel->upload.bo;
- *return_offset = intel->upload.offset;
-
if (intel->upload.buffer_len &&
- intel->upload.buffer_len + asize > sizeof(intel->upload.buffer))
+ intel->upload.buffer_len + size > sizeof(intel->upload.buffer))
{
drm_intel_bo_subdata(intel->upload.bo,
intel->upload.buffer_offset,
@@ -673,26 +660,25 @@ void *intel_upload_map(struct intel_context *intel,
intel->upload.buffer_len = 0;
}
- if (size < sizeof(intel->upload.buffer))
- {
- if (intel->upload.buffer_len == 0)
- intel->upload.buffer_offset = intel->upload.offset;
-
+ if (size <= sizeof(intel->upload.buffer))
ptr = intel->upload.buffer + intel->upload.buffer_len;
- intel->upload.buffer_len += asize;
- }
else
- {
- drm_intel_gem_bo_map_gtt(intel->upload.bo);
- ptr = intel->upload.bo->virtual;
- ptr += intel->upload.offset;
- }
-
- intel->upload.offset += asize;
+ ptr = malloc(size);
return ptr;
}
+void intel_upload_unmap(struct intel_context *intel,
+ const void *ptr, GLuint size,
+ drm_intel_bo **return_bo,
+ GLuint *return_offset)
+{
+ intel_upload_data(intel, ptr, size, return_bo, return_offset);
+
+ if (size > sizeof(intel->upload.buffer))
+ free((void*)ptr);
+}
+
drm_intel_bo *
intel_bufferobj_source(struct intel_context *intel,
struct intel_buffer_object *intel_obj,
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.h b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
index 4b66bf7d593..2d86becdf3e 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.h
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.h
@@ -76,9 +76,11 @@ void intel_upload_data(struct intel_context *intel,
GLuint *return_offset);
void *intel_upload_map(struct intel_context *intel,
- GLuint size,
- drm_intel_bo **return_bo,
- GLuint *return_offset);
+ GLuint size);
+void intel_upload_unmap(struct intel_context *intel,
+ const void *ptr, GLuint size,
+ drm_intel_bo **return_bo,
+ GLuint *return_offset);
void intel_upload_finish(struct intel_context *intel);