/* API Functions */
/**********************************************************************/
+void GLAPIENTRY
+_mesa_BindBuffer_no_error(GLenum target, GLuint buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ struct gl_buffer_object **bindTarget = get_buffer_target(ctx, target);
+ bind_buffer_object(ctx, bindTarget, buffer);
+}
+
+
void GLAPIENTRY
_mesa_BindBuffer(GLenum target, GLuint buffer)
{
* driver internals.
*/
static void
-create_buffers(GLsizei n, GLuint *buffers, bool dsa)
+create_buffers(struct gl_context *ctx, GLsizei n, GLuint *buffers, bool dsa)
{
- GET_CURRENT_CONTEXT(ctx);
GLuint first;
struct gl_buffer_object *buf;
- const char *func = dsa ? "glCreateBuffers" : "glGenBuffers";
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "%s(%d)\n", func, n);
-
- if (n < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(n %d < 0)", func, n);
+ if (!buffers)
return;
- }
-
- if (!buffers) {
- return;
- }
/*
* This must be atomic (generation and allocation of buffer object IDs)
assert(ctx->Driver.NewBufferObject);
buf = ctx->Driver.NewBufferObject(ctx, buffers[i]);
if (!buf) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCreateBuffers");
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
return;
}
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
}
+
+static void
+create_buffers_err(struct gl_context *ctx, GLsizei n, GLuint *buffers, bool dsa)
+{
+ const char *func = dsa ? "glCreateBuffers" : "glGenBuffers";
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "%s(%d)\n", func, n);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n %d < 0)", func, n);
+ return;
+ }
+
+ create_buffers(ctx, n, buffers, dsa);
+}
+
/**
* Generate a set of unique buffer object IDs and store them in \c buffers.
*
* \param n Number of IDs to generate.
* \param buffers Array of \c n locations to store the IDs.
*/
+void GLAPIENTRY
+_mesa_GenBuffers_no_error(GLsizei n, GLuint *buffers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ create_buffers(ctx, n, buffers, false);
+}
+
+
void GLAPIENTRY
_mesa_GenBuffers(GLsizei n, GLuint *buffers)
{
- create_buffers(n, buffers, false);
+ GET_CURRENT_CONTEXT(ctx);
+ create_buffers_err(ctx, n, buffers, false);
}
/**
* \param n Number of IDs to generate.
* \param buffers Array of \c n locations to store the IDs.
*/
+void GLAPIENTRY
+_mesa_CreateBuffers_no_error(GLsizei n, GLuint *buffers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ create_buffers(ctx, n, buffers, true);
+}
+
+
void GLAPIENTRY
_mesa_CreateBuffers(GLsizei n, GLuint *buffers)
{
- create_buffers(n, buffers, true);
+ GET_CURRENT_CONTEXT(ctx);
+ create_buffers_err(ctx, n, buffers, true);
}
return false;
}
- if (bufObj->Immutable) {
+ if (bufObj->Immutable || bufObj->HandleAllocated) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);
return false;
}
/* Unmap the existing buffer. We'll replace it now. Not an error. */
_mesa_buffer_unmap_all_mappings(ctx, bufObj);
- FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
+ FLUSH_VERTICES(ctx, 0);
bufObj->Written = GL_TRUE;
bufObj->Immutable = GL_TRUE;
return;
}
- if (bufObj->Immutable) {
+ if (bufObj->Immutable || bufObj->HandleAllocated) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);
return;
}
/* Unmap the existing buffer. We'll replace it now. Not an error. */
_mesa_buffer_unmap_all_mappings(ctx, bufObj);
- FLUSH_VERTICES(ctx, _NEW_BUFFER_OBJECT);
+ FLUSH_VERTICES(ctx, 0);
bufObj->Written = GL_TRUE;
bufObj->MinMaxCacheDirty = true;
bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
}
+static void
+bind_buffer_range_shader_storage_buffer(struct gl_context *ctx,
+ GLuint index,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset,
+ GLsizeiptr size)
+{
+ if (bufObj == ctx->Shared->NullBufferObj) {
+ offset = -1;
+ size = -1;
+ }
+
+ _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, bufObj);
+ bind_shader_storage_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
+}
+
/**
* Bind a region of a buffer object to a shader storage block binding point.
* \param index the shader storage buffer binding point index
* \param size size of the buffer object region
*/
static void
-bind_buffer_range_shader_storage_buffer(struct gl_context *ctx,
- GLuint index,
- struct gl_buffer_object *bufObj,
- GLintptr offset,
- GLsizeiptr size)
+bind_buffer_range_shader_storage_buffer_err(struct gl_context *ctx,
+ GLuint index,
+ struct gl_buffer_object *bufObj,
+ GLintptr offset, GLsizeiptr size)
{
if (index >= ctx->Const.MaxShaderStorageBufferBindings) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(index=%d)", index);
return;
}
- if (bufObj == ctx->Shared->NullBufferObj) {
- offset = -1;
- size = -1;
- }
-
- _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, bufObj);
- bind_shader_storage_buffer(ctx, index, bufObj, offset, size, GL_FALSE);
+ bind_buffer_range_shader_storage_buffer(ctx, index, bufObj, offset, size);
}
/**
}
}
+static void
+bind_atomic_buffer(struct gl_context *ctx, unsigned index,
+ struct gl_buffer_object *bufObj, GLintptr offset,
+ GLsizeiptr size)
+{
+ _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer, bufObj);
+
+ struct gl_atomic_buffer_binding *binding =
+ &ctx->AtomicBufferBindings[index];
+ if (binding->BufferObject == bufObj &&
+ binding->Offset == offset &&
+ binding->Size == size) {
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
+
+ set_atomic_buffer_binding(ctx, binding, bufObj, offset, size);
+}
+
/**
* Binds a buffer object to an atomic buffer binding point.
*
* updating it.
*/
static void
-bind_atomic_buffer(struct gl_context *ctx,
- unsigned index,
- struct gl_buffer_object *bufObj,
- GLintptr offset,
- GLsizeiptr size,
- const char *name)
+bind_atomic_buffer_err(struct gl_context *ctx, unsigned index,
+ struct gl_buffer_object *bufObj, GLintptr offset,
+ GLsizeiptr size, const char *name)
{
- struct gl_atomic_buffer_binding *binding;
-
if (index >= ctx->Const.MaxAtomicBufferBindings) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%d)", name, index);
return;
return;
}
- _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer, bufObj);
-
- binding = &ctx->AtomicBufferBindings[index];
- if (binding->BufferObject == bufObj &&
- binding->Offset == offset &&
- binding->Size == size) {
- return;
- }
-
- FLUSH_VERTICES(ctx, 0);
- ctx->NewDriverState |= ctx->DriverFlags.NewAtomicBuffer;
-
- set_atomic_buffer_binding(ctx, binding, bufObj, offset, size);
+ bind_atomic_buffer(ctx, index, bufObj, offset, size);
}
static inline bool
_mesa_HashUnlockMutex(ctx->Shared->BufferObjects);
}
-void GLAPIENTRY
-_mesa_BindBufferRange(GLenum target, GLuint index,
- GLuint buffer, GLintptr offset, GLsizeiptr size)
+static ALWAYS_INLINE void
+bind_buffer_range(GLenum target, GLuint index, GLuint buffer, GLintptr offset,
+ GLsizeiptr size, bool no_error)
{
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
&bufObj, "glBindBufferRange"))
return;
- if (!bufObj) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBindBufferRange(invalid buffer=%u)", buffer);
- return;
- }
+ if (no_error) {
+ switch (target) {
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ _mesa_bind_buffer_range_xfb(ctx, ctx->TransformFeedback.CurrentObject,
+ index, bufObj, offset, size);
+ return;
+ case GL_UNIFORM_BUFFER:
+ bind_buffer_range_uniform_buffer(ctx, index, bufObj, offset, size);
+ return;
+ case GL_SHADER_STORAGE_BUFFER:
+ bind_buffer_range_shader_storage_buffer(ctx, index, bufObj, offset,
+ size);
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER:
+ bind_atomic_buffer(ctx, index, bufObj, offset, size);
+ return;
+ default:
+ unreachable("invalid BindBufferRange target with KHR_no_error");
+ }
+ } else {
+ if (!bufObj) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindBufferRange(invalid buffer=%u)", buffer);
+ return;
+ }
+
+ if (buffer != 0) {
+ if (size <= 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)",
+ (int) size);
+ return;
+ }
+ }
- if (buffer != 0) {
- if (size <= 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size=%d)",
- (int) size);
+ switch (target) {
+ case GL_TRANSFORM_FEEDBACK_BUFFER:
+ if (!_mesa_validate_buffer_range_xfb(ctx,
+ ctx->TransformFeedback.CurrentObject,
+ index, bufObj, offset, size,
+ false))
+ return;
+
+ _mesa_bind_buffer_range_xfb(ctx, ctx->TransformFeedback.CurrentObject,
+ index, bufObj, offset, size);
+ return;
+ case GL_UNIFORM_BUFFER:
+ bind_buffer_range_uniform_buffer_err(ctx, index, bufObj, offset,
+ size);
+ return;
+ case GL_SHADER_STORAGE_BUFFER:
+ bind_buffer_range_shader_storage_buffer_err(ctx, index, bufObj,
+ offset, size);
+ return;
+ case GL_ATOMIC_COUNTER_BUFFER:
+ bind_atomic_buffer_err(ctx, index, bufObj, offset, size,
+ "glBindBufferRange");
+ return;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)");
return;
}
}
+}
- switch (target) {
- case GL_TRANSFORM_FEEDBACK_BUFFER:
- _mesa_bind_buffer_range_transform_feedback(ctx,
- ctx->TransformFeedback.CurrentObject,
- index, bufObj, offset, size,
- false);
- return;
- case GL_UNIFORM_BUFFER:
- bind_buffer_range_uniform_buffer_err(ctx, index, bufObj, offset, size);
- return;
- case GL_SHADER_STORAGE_BUFFER:
- bind_buffer_range_shader_storage_buffer(ctx, index, bufObj, offset, size);
- return;
- case GL_ATOMIC_COUNTER_BUFFER:
- bind_atomic_buffer(ctx, index, bufObj, offset, size,
- "glBindBufferRange");
- return;
- default:
- _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferRange(target)");
- return;
- }
+void GLAPIENTRY
+_mesa_BindBufferRange_no_error(GLenum target, GLuint index, GLuint buffer,
+ GLintptr offset, GLsizeiptr size)
+{
+ bind_buffer_range(target, index, buffer, offset, size, true);
+}
+
+void GLAPIENTRY
+_mesa_BindBufferRange(GLenum target, GLuint index,
+ GLuint buffer, GLintptr offset, GLsizeiptr size)
+{
+ bind_buffer_range(target, index, buffer, offset, size, false);
}
void GLAPIENTRY
bind_buffer_base_shader_storage_buffer(ctx, index, bufObj);
return;
case GL_ATOMIC_COUNTER_BUFFER:
- bind_atomic_buffer(ctx, index, bufObj, 0, 0,
- "glBindBufferBase");
+ bind_atomic_buffer_err(ctx, index, bufObj, 0, 0,
+ "glBindBufferBase");
return;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferBase(target)");
}
}
+static ALWAYS_INLINE void
+invalidate_buffer_subdata(struct gl_context *ctx,
+ struct gl_buffer_object *bufObj, GLintptr offset,
+ GLsizeiptr length)
+{
+ if (ctx->Driver.InvalidateBufferSubData)
+ ctx->Driver.InvalidateBufferSubData(ctx, bufObj, offset, length);
+}
+
+void GLAPIENTRY
+_mesa_InvalidateBufferSubData_no_error(GLuint buffer, GLintptr offset,
+ GLsizeiptr length)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
+ invalidate_buffer_subdata(ctx, bufObj, offset, length);
+}
+
void GLAPIENTRY
_mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
GLsizeiptr length)
return;
}
- if (ctx->Driver.InvalidateBufferSubData)
- ctx->Driver.InvalidateBufferSubData(ctx, bufObj, offset, length);
+ invalidate_buffer_subdata(ctx, bufObj, offset, length);
+}
+
+void GLAPIENTRY
+_mesa_InvalidateBufferData_no_error(GLuint buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ struct gl_buffer_object *bufObj =_mesa_lookup_bufferobj(ctx, buffer);
+ invalidate_buffer_subdata(ctx, bufObj, 0, bufObj->Size);
}
void GLAPIENTRY
return;
}
- if (ctx->Driver.InvalidateBufferSubData)
- ctx->Driver.InvalidateBufferSubData(ctx, bufObj, 0, bufObj->Size);
+ invalidate_buffer_subdata(ctx, bufObj, 0, bufObj->Size);
}
static void