aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/bufferobj.c112
1 files changed, 64 insertions, 48 deletions
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index b46b81271a1..1bae0258054 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -1923,10 +1923,10 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
}
-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;
@@ -1938,44 +1938,43 @@ _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
_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. */
@@ -2002,20 +2001,37 @@ _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
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)