aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/bufferobj.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-01-20 09:35:29 +0100
committermarha <marha@users.sourceforge.net>2012-01-20 09:35:29 +0100
commita8ef69cc0c9e5281e6b745dd4a2be75f629eb8b8 (patch)
tree8bc980551565964e13d046f54ee3876ba2bb7f14 /mesalib/src/mesa/main/bufferobj.c
parent34c1e86406451a3604de4982339058088434ab40 (diff)
downloadvcxsrv-a8ef69cc0c9e5281e6b745dd4a2be75f629eb8b8.tar.gz
vcxsrv-a8ef69cc0c9e5281e6b745dd4a2be75f629eb8b8.tar.bz2
vcxsrv-a8ef69cc0c9e5281e6b745dd4a2be75f629eb8b8.zip
xserver xkeyboard-config git update 20 jan 2012
Diffstat (limited to 'mesalib/src/mesa/main/bufferobj.c')
-rw-r--r--mesalib/src/mesa/main/bufferobj.c44
1 files changed, 31 insertions, 13 deletions
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 5f8071f58..5b6db78d8 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -49,13 +49,6 @@
/*#define BOUNDS_CHECK*/
-#if FEATURE_OES_mapbuffer
-#define DEFAULT_ACCESS GL_MAP_WRITE_BIT
-#else
-#define DEFAULT_ACCESS (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT)
-#endif
-
-
/**
* Used as a placeholder for buffer objects between glGenBuffers() and
* glBindBuffer() so that glIsBuffer() can work correctly.
@@ -122,6 +115,30 @@ get_buffer(struct gl_context *ctx, GLenum target)
}
+static inline GLenum
+default_access_mode(const struct gl_context *ctx)
+{
+ /* Table 2.6 on page 31 (page 44 of the PDF) of the OpenGL 1.5 spec says:
+ *
+ * Name Type Initial Value Legal Values
+ * ... ... ... ...
+ * BUFFER_ACCESS enum READ_WRITE READ_ONLY, WRITE_ONLY
+ * READ_WRITE
+ *
+ * However, table 6.8 in the GL_OES_mapbuffer extension says:
+ *
+ * Get Value Type Get Command Value Description
+ * --------- ---- ----------- ----- -----------
+ * BUFFER_ACCESS_OES Z1 GetBufferParameteriv WRITE_ONLY_OES buffer map flag
+ *
+ * The difference is because GL_OES_mapbuffer only supports mapping buffers
+ * write-only.
+ */
+ return (ctx->API == API_OPENGLES)
+ ? GL_MAP_WRITE_BIT : (GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
+}
+
+
/**
* Convert a GLbitfield describing the mapped buffer access flags
* into one of GL_READ_WRITE, GL_READ_ONLY, or GL_WRITE_ONLY.
@@ -213,7 +230,7 @@ _mesa_new_buffer_object( struct gl_context *ctx, GLuint name, GLenum target )
(void) ctx;
obj = MALLOC_STRUCT(gl_buffer_object);
- _mesa_initialize_buffer_object(obj, name, target);
+ _mesa_initialize_buffer_object(ctx, obj, name, target);
return obj;
}
@@ -311,7 +328,8 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
* Initialize a buffer object to default values.
*/
void
-_mesa_initialize_buffer_object( struct gl_buffer_object *obj,
+_mesa_initialize_buffer_object( struct gl_context *ctx,
+ struct gl_buffer_object *obj,
GLuint name, GLenum target )
{
(void) target;
@@ -321,7 +339,7 @@ _mesa_initialize_buffer_object( struct gl_buffer_object *obj,
obj->RefCount = 1;
obj->Name = name;
obj->Usage = GL_STATIC_DRAW_ARB;
- obj->AccessFlags = DEFAULT_ACCESS;
+ obj->AccessFlags = default_access_mode(ctx);
}
@@ -740,7 +758,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
if (_mesa_bufferobj_mapped(bufObj)) {
/* if mapped, unmap it now */
ctx->Driver.UnmapBuffer(ctx, bufObj);
- bufObj->AccessFlags = DEFAULT_ACCESS;
+ bufObj->AccessFlags = default_access_mode(ctx);
bufObj->Pointer = NULL;
}
@@ -900,7 +918,7 @@ _mesa_BufferDataARB(GLenum target, GLsizeiptrARB size,
if (_mesa_bufferobj_mapped(bufObj)) {
/* Unmap the existing buffer. We'll replace it now. Not an error. */
ctx->Driver.UnmapBuffer(ctx, bufObj);
- bufObj->AccessFlags = DEFAULT_ACCESS;
+ bufObj->AccessFlags = default_access_mode(ctx);
ASSERT(bufObj->Pointer == NULL);
}
@@ -1119,7 +1137,7 @@ _mesa_UnmapBufferARB(GLenum target)
#endif
status = ctx->Driver.UnmapBuffer( ctx, bufObj );
- bufObj->AccessFlags = DEFAULT_ACCESS;
+ bufObj->AccessFlags = default_access_mode(ctx);
ASSERT(bufObj->Pointer == NULL);
ASSERT(bufObj->Offset == 0);
ASSERT(bufObj->Length == 0);