st: use pointer_to_offset() cast wrapper to convert pointers to uint
authorBrian Paul <brianp@vmware.com>
Mon, 9 Mar 2009 15:33:46 +0000 (09:33 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 9 Mar 2009 15:42:26 +0000 (09:42 -0600)
Silences warnings with 64-bit builds.  See comments for details.

src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_draw.h
src/mesa/state_tracker/st_draw_feedback.c

index be1d9a86281c83daa9d66a1f4bf1e4558fd0ee02..772280d7b8d8ec77f93887ed26c46b31b991759c 100644 (file)
@@ -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 */
index 659c3ac834f194386daae2cf92a4230847cf7ce0..da04fce8e24bfb832b851129a40b344c1999aa19 100644 (file)
@@ -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
index d63d8cae28e5cde6fb3a9984fbbb130765490d49..e533afd051e578b23bdce0254d8699c005b005a3 100644 (file)
@@ -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 {