}
-void
-_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
- GLenum target, GLsizeiptr size, const GLvoid *data,
- GLenum usage, const char *func)
+static ALWAYS_INLINE void
+buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage,
+ const char *func, bool no_error)
{
bool valid_usage;
_mesa_enum_to_string(usage));
}
- if (size < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", func);
- return;
- }
-
- switch (usage) {
- case GL_STREAM_DRAW_ARB:
- valid_usage = (ctx->API != API_OPENGLES);
- break;
-
- case GL_STATIC_DRAW_ARB:
- case GL_DYNAMIC_DRAW_ARB:
- valid_usage = true;
- break;
-
- case GL_STREAM_READ_ARB:
- case GL_STREAM_COPY_ARB:
- case GL_STATIC_READ_ARB:
- case GL_STATIC_COPY_ARB:
- case GL_DYNAMIC_READ_ARB:
- case GL_DYNAMIC_COPY_ARB:
- valid_usage = _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx);
- break;
+ if (!no_error) {
+ if (size < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", func);
+ return;
+ }
- default:
- valid_usage = false;
- break;
- }
+ switch (usage) {
+ case GL_STREAM_DRAW_ARB:
+ valid_usage = (ctx->API != API_OPENGLES);
+ break;
+ case GL_STATIC_DRAW_ARB:
+ case GL_DYNAMIC_DRAW_ARB:
+ valid_usage = true;
+ break;
+ case GL_STREAM_READ_ARB:
+ case GL_STREAM_COPY_ARB:
+ case GL_STATIC_READ_ARB:
+ case GL_STATIC_COPY_ARB:
+ case GL_DYNAMIC_READ_ARB:
+ case GL_DYNAMIC_COPY_ARB:
+ valid_usage = _mesa_is_desktop_gl(ctx) || _mesa_is_gles3(ctx);
+ break;
+ default:
+ valid_usage = false;
+ break;
+ }
- if (!valid_usage) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid usage: %s)", func,
- _mesa_enum_to_string(usage));
- return;
- }
+ if (!valid_usage) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid usage: %s)", func,
+ _mesa_enum_to_string(usage));
+ return;
+ }
- if (bufObj->Immutable || bufObj->HandleAllocated) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s(immutable)", func);
- return;
+ 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. */
GL_DYNAMIC_STORAGE_BIT,
bufObj)) {
if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
- /* From GL_AMD_pinned_memory:
- *
- * INVALID_OPERATION is generated by BufferData if <target> is
- * EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, and the store cannot be
- * mapped to the GPU address space.
- */
- _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);
- }
- else {
+ if (!no_error) {
+ /* From GL_AMD_pinned_memory:
+ *
+ * INVALID_OPERATION is generated by BufferData if <target> is
+ * EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD, and the store cannot be
+ * mapped to the GPU address space.
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", func);
+ }
+ } else {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
}
}
}
+static void
+buffer_data_error(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLenum usage, const char *func)
+{
+ buffer_data(ctx, bufObj, target, size, data, usage, func, false);
+}
+
+void
+_mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
+ GLenum target, GLsizeiptr size, const GLvoid *data,
+ GLenum usage, const char *func)
+{
+ buffer_data_error(ctx, bufObj, target, size, data, usage, func);
+}
+
void GLAPIENTRY
_mesa_BufferData(GLenum target, GLsizeiptr size,
const GLvoid *data, GLenum usage)