&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++) {
src += element->glarray->StrideB;
dst += dst_stride;
}
+ intel_upload_unmap(&brw->intel, dst, size,
+ &buffer->bo, &buffer->offset);
}
}
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;
offset += size;
}
+ intel_upload_unmap(&brw->intel, map, total_size * count,
+ &buffer->bo, &buffer->offset);
buffer->stride = offset;
j++;
*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,
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,
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,
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);