r300/compiler: fix the instruction limit in vertex shaders
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_buffer_objects.c
index e8ae51e6eab17db37eb694dc5f71ecfb0a27df56..0897dafbd8be05e08b5697d86c3433e13e0444d2 100644 (file)
@@ -70,7 +70,7 @@ radeonDeleteBufferObject(GLcontext * ctx,
         radeon_bo_unref(radeon_obj->bo);
     }
 
-    _mesa_free(radeon_obj);
+    free(radeon_obj);
 }
 
 
@@ -78,9 +78,10 @@ radeonDeleteBufferObject(GLcontext * ctx,
  * Allocate space for and store data in a buffer object.  Any data that was
  * previously stored in the buffer object is lost.  If data is NULL,
  * memory will be allocated, but no copy will occur.
- * Called via glBufferDataARB().
+ * Called via ctx->Driver.BufferData().
+ * \return GL_TRUE for success, GL_FALSE if out of memory
  */
-static void
+static GLboolean
 radeonBufferData(GLcontext * ctx,
                  GLenum target,
                  GLsizeiptrARB size,
@@ -107,14 +108,18 @@ radeonBufferData(GLcontext * ctx,
                                         RADEON_GEM_DOMAIN_GTT,
                                         0);
 
+        if (!radeon_obj->bo)
+            return GL_FALSE;
+
         if (data != NULL) {
             radeon_bo_map(radeon_obj->bo, GL_TRUE);
 
-            _mesa_memcpy(radeon_obj->bo->ptr, data, size);
+            memcpy(radeon_obj->bo->ptr, data, size);
 
             radeon_bo_unmap(radeon_obj->bo);
         }
     }
+    return GL_TRUE;
 }
 
 /**
@@ -131,11 +136,16 @@ radeonBufferSubData(GLcontext * ctx,
                     const GLvoid * data,
                     struct gl_buffer_object *obj)
 {
+    radeonContextPtr radeon = RADEON_CONTEXT(ctx);
     struct radeon_buffer_object *radeon_obj = get_radeon_buffer_object(obj);
 
+    if (radeon_bo_is_referenced_by_cs(radeon_obj->bo, radeon->cmdbuf.cs)) {
+        radeon_firevertices(radeon);
+    }
+
     radeon_bo_map(radeon_obj->bo, GL_TRUE);
 
-    _mesa_memcpy(radeon_obj->bo->ptr + offset, data, size);
+    memcpy(radeon_obj->bo->ptr + offset, data, size);
 
     radeon_bo_unmap(radeon_obj->bo);
 }
@@ -155,7 +165,7 @@ radeonGetBufferSubData(GLcontext * ctx,
 
     radeon_bo_map(radeon_obj->bo, GL_FALSE);
 
-    _mesa_memcpy(data, radeon_obj->bo->ptr + offset, size);
+    memcpy(data, radeon_obj->bo->ptr + offset, size);
 
     radeon_bo_unmap(radeon_obj->bo);
 }
@@ -182,7 +192,11 @@ radeonMapBuffer(GLcontext * ctx,
 
     radeon_bo_map(radeon_obj->bo, access == GL_WRITE_ONLY_ARB);
 
-    return obj->Pointer = radeon_obj->bo->ptr;
+    obj->Pointer = radeon_obj->bo->ptr;
+    obj->Length = obj->Size;
+    obj->Offset = 0;
+
+    return obj->Pointer;
 }
 
 
@@ -198,9 +212,12 @@ radeonUnmapBuffer(GLcontext * ctx,
 
     if (radeon_obj->bo != NULL) {
         radeon_bo_unmap(radeon_obj->bo);
-        obj->Pointer = NULL;
     }
 
+    obj->Pointer = NULL;
+    obj->Offset = 0;
+    obj->Length = 0;
+
     return GL_TRUE;
 }