summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/state_tracker/st_draw.c6
-rw-r--r--src/mesa/state_tracker/st_draw.h15
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c2
3 files changed, 19 insertions, 4 deletions
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index be1d9a8628..772280d7b8 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -379,7 +379,7 @@ setup_interleaved_attribs(GLcontext *ctx,
else {
vbuffer->buffer = NULL;
pipe_buffer_reference(&vbuffer->buffer, stobj->buffer);
- vbuffer->buffer_offset = (unsigned) low;
+ vbuffer->buffer_offset = pointer_to_offset(low);
}
vbuffer->stride = stride; /* in bytes */
vbuffer->max_index = max_index;
@@ -434,7 +434,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
vbuffer[attr].buffer = NULL;
pipe_buffer_reference(&vbuffer[attr].buffer, stobj->buffer);
- vbuffer[attr].buffer_offset = (unsigned) arrays[mesaAttr]->Ptr;
+ vbuffer[attr].buffer_offset = pointer_to_offset(arrays[mesaAttr]->Ptr);
velements[attr].src_offset = 0;
}
else {
@@ -618,7 +618,7 @@ st_draw_vbo(GLcontext *ctx,
/* elements/indexes are in a real VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
pipe_buffer_reference(&indexBuf, stobj->buffer);
- indexOffset = (unsigned) ib->ptr / indexSize;
+ indexOffset = pointer_to_offset(ib->ptr) / indexSize;
}
else {
/* element/indicies are in user space memory */
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index 659c3ac834..da04fce8e2 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -64,4 +64,19 @@ st_feedback_draw_vbo(GLcontext *ctx,
extern GLuint
st_pipe_vertex_format(GLenum type, GLuint size, GLboolean normalized);
+
+/**
+ * When drawing with VBOs, the addresses specified with
+ * glVertex/Color/TexCoordPointer() are really offsets into the VBO, not real
+ * addresses. At some point we need to convert those pointers to offsets.
+ * This function is basically a cast wrapper to avoid warnings when building
+ * in 64-bit mode.
+ */
+static INLINE unsigned
+pointer_to_offset(const void *ptr)
+{
+ return (unsigned) (((unsigned long) ptr) & 0xffffffffUL);
+}
+
+
#endif
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index d63d8cae28..e533afd051 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -153,7 +153,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
vbuffers[attr].buffer = NULL;
pipe_buffer_reference(&vbuffers[attr].buffer, stobj->buffer);
- vbuffers[attr].buffer_offset = (unsigned) arrays[0]->Ptr;/* in bytes */
+ vbuffers[attr].buffer_offset = pointer_to_offset(arrays[0]->Ptr);
velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
}
else {