summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 2ded14b0de7..74c9e2f40d4 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -506,8 +506,24 @@ static void brw_prepare_vertices(struct brw_context *brw)
ptr = glarray->Ptr;
}
else if (interleaved != glarray->StrideB ||
- (uintptr_t)(glarray->Ptr - ptr) > interleaved)
+ glarray->Ptr < ptr ||
+ (uintptr_t)(glarray->Ptr - ptr) + glarray->_ElementSize > interleaved)
{
+ /* If our stride is different from the first attribute's stride,
+ * or if the first attribute's stride didn't cover our element,
+ * disable the interleaved upload optimization. The second case
+ * can most commonly occur in cases where there is a single vertex
+ * and, for example, the data is stored on the application's
+ * stack.
+ *
+ * NOTE: This will also disable the optimization in cases where
+ * the data is in a different order than the array indices.
+ * Something like:
+ *
+ * float data[...];
+ * glVertexAttribPointer(0, 4, GL_FLOAT, 32, &data[4]);
+ * glVertexAttribPointer(1, 4, GL_FLOAT, 32, &data[0]);
+ */
interleaved = 0;
}