summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-02-11 14:45:19 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2011-02-21 12:59:35 +0000
commit94d73d700e804ce78c214c58e84382c81dcb8280 (patch)
tree129d570692cdd12c1ac2bba953b49b66c79965be /src/mesa/drivers/dri/i965
parent559435d9152acc7162e4e60aae6591c7c6c8274b (diff)
i965: interleaved vbo
If the user passed in several arrays interleaved in the same vbo, only emit a single vertex buffer and relocation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index be43dec9a4..587e74426f 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -319,18 +319,33 @@ static void brw_prepare_vertices(struct brw_context *brw)
if (_mesa_is_bufferobj(input->glarray->BufferObj)) {
struct intel_buffer_object *intel_buffer =
intel_buffer_object(input->glarray->BufferObj);
- struct brw_vertex_buffer *buffer = &brw->vb.buffers[j];
-
- /* Named buffer object: Just reference its contents directly. */
- buffer->bo = intel_bufferobj_source(intel, intel_buffer,
- &buffer->offset);
- drm_intel_bo_reference(buffer->bo);
- buffer->offset += (unsigned long)input->glarray->Ptr;
- buffer->stride = input->glarray->StrideB;
-
+ int k;
+
+ for (k = 0; k < i; k++) {
+ struct brw_vertex_element *other = brw->vb.enabled[k];
+ if (input->glarray->BufferObj == other->glarray->BufferObj &&
+ input->glarray->StrideB == other->glarray->StrideB &&
+ (uintptr_t)(input->glarray->Ptr - other->glarray->Ptr) <
+ input->glarray->StrideB)
+ {
+ input->buffer = other->buffer;
+ input->offset = input->glarray->Ptr - other->glarray->Ptr;
+ break;
+ }
+ }
+ if (k == i) {
+ struct brw_vertex_buffer *buffer = &brw->vb.buffers[j];
+ /* Named buffer object: Just reference its contents directly. */
+ buffer->bo = intel_bufferobj_source(intel, intel_buffer,
+ &buffer->offset);
+ drm_intel_bo_reference(buffer->bo);
+ buffer->offset += (uintptr_t)input->glarray->Ptr;
+ buffer->stride = input->glarray->StrideB;
+
+ input->buffer = j++;
+ input->offset = 0;
+ }
input->count = input->glarray->_MaxElement;
- input->offset = 0;
- input->buffer = j++;
/* This is a common place to reach if the user mistakenly supplies
* a pointer in place of a VBO offset. If we just let it go through,
@@ -363,7 +378,7 @@ static void brw_prepare_vertices(struct brw_context *brw)
ptr = input->glarray->Ptr;
}
else if (interleave != input->glarray->StrideB ||
- (GLuint)(input->glarray->Ptr - ptr) > interleave)
+ (uintptr_t)(input->glarray->Ptr - ptr) > interleave)
{
interleave = 0;
}