mesa: fix invalid target error handling for teximage
[mesa.git] / src / mesa / main / marshal.h
index 23b33002e42f14bce86a5036c7245e2f69c5725b..63e0295576ef04fde2b5f44704873492404a9cbe 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "main/glthread.h"
 #include "main/context.h"
+#include "main/macros.h"
 
 struct marshal_cmd_base
 {
@@ -46,28 +47,68 @@ struct marshal_cmd_base
    uint16_t cmd_size;
 };
 
-
 static inline void *
 _mesa_glthread_allocate_command(struct gl_context *ctx,
                                 uint16_t cmd_id,
                                 size_t size)
 {
    struct glthread_state *glthread = ctx->GLThread;
+   struct glthread_batch *next = &glthread->batches[glthread->next];
    struct marshal_cmd_base *cmd_base;
+   const size_t aligned_size = ALIGN(size, 8);
 
-   if (unlikely(glthread->batch->used + size > MARSHAL_MAX_CMD_SIZE))
+   if (unlikely(next->used + size > MARSHAL_MAX_CMD_SIZE)) {
       _mesa_glthread_flush_batch(ctx);
+      next = &glthread->batches[glthread->next];
+   }
 
-   cmd_base = (struct marshal_cmd_base *)
-      &glthread->batch->buffer[glthread->batch->used];
-   glthread->batch->used += size;
+   cmd_base = (struct marshal_cmd_base *)&next->buffer[next->used];
+   next->used += aligned_size;
    cmd_base->cmd_id = cmd_id;
-   cmd_base->cmd_size = size;
+   cmd_base->cmd_size = aligned_size;
    return cmd_base;
 }
 
+/**
+ * Instead of conditionally handling marshaling previously-bound user vertex
+ * array data in draw calls (deprecated and removed in GL core), we just
+ * disable threading at the point where the user sets a user vertex array.
+ */
+static inline bool
+_mesa_glthread_is_non_vbo_vertex_attrib_pointer(const struct gl_context *ctx)
+{
+   struct glthread_state *glthread = ctx->GLThread;
+
+   return ctx->API != API_OPENGL_CORE && !glthread->vertex_array_is_vbo;
+}
+
+/**
+ * Instead of conditionally handling marshaling immediate index data in draw
+ * calls (deprecated and removed in GL core), we just disable threading.
+ */
+static inline bool
+_mesa_glthread_is_non_vbo_draw_elements(const struct gl_context *ctx)
+{
+   struct glthread_state *glthread = ctx->GLThread;
+
+   return ctx->API != API_OPENGL_CORE && !glthread->element_array_is_vbo;
+}
+
 #define DEBUG_MARSHAL_PRINT_CALLS 0
 
+/**
+ * This is printed when we have fallen back to a sync. This can happen when
+ * MARSHAL_MAX_CMD_SIZE is exceeded.
+ */
+static inline void
+debug_print_sync_fallback(const char *func)
+{
+#if DEBUG_MARSHAL_PRINT_CALLS
+   printf("fallback to sync: %s\n", func);
+#endif
+}
+
+
 static inline void
 debug_print_sync(const char *func)
 {
@@ -133,34 +174,26 @@ _mesa_glthread_is_compat_bind_vertex_array(const struct gl_context *ctx)
    return ctx->API != API_OPENGL_CORE;
 }
 
-/**
- * Instead of conditionally handling marshaling previously-bound user vertex
- * array data in draw calls (deprecated and removed in GL core), we just
- * disable threading at the point where the user sets a user vertex array.
- */
-static inline bool
-_mesa_glthread_is_non_vbo_vertex_attrib_pointer(const struct gl_context *ctx)
-{
-   struct glthread_state *glthread = ctx->GLThread;
-
-   return ctx->API != API_OPENGL_CORE && !glthread->vertex_array_is_vbo;
-}
-
-/**
- * Instead of conditionally handling marshaling immediate index data in draw
- * calls (deprecated and removed in GL core), we just disable threading.
- */
-static inline bool
-_mesa_glthread_is_non_vbo_draw_elements(const struct gl_context *ctx)
-{
-   struct glthread_state *glthread = ctx->GLThread;
-
-   return ctx->API != API_OPENGL_CORE && !glthread->element_array_is_vbo;
-}
-
+struct marshal_cmd_Enable;
 struct marshal_cmd_ShaderSource;
 struct marshal_cmd_Flush;
 struct marshal_cmd_BindBuffer;
+struct marshal_cmd_BufferData;
+struct marshal_cmd_BufferSubData;
+struct marshal_cmd_NamedBufferData;
+struct marshal_cmd_NamedBufferSubData;
+struct marshal_cmd_ClearBuffer;
+#define marshal_cmd_ClearBufferfv   marshal_cmd_ClearBuffer
+#define marshal_cmd_ClearBufferiv   marshal_cmd_ClearBuffer
+#define marshal_cmd_ClearBufferuiv  marshal_cmd_ClearBuffer
+#define marshal_cmd_ClearBufferfi   marshal_cmd_ClearBuffer
+
+void
+_mesa_unmarshal_Enable(struct gl_context *ctx,
+                       const struct marshal_cmd_Enable *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_Enable(GLenum cap);
 
 void GLAPIENTRY
 _mesa_marshal_ShaderSource(GLuint shader, GLsizei count,
@@ -184,4 +217,68 @@ void
 _mesa_unmarshal_BindBuffer(struct gl_context *ctx,
                            const struct marshal_cmd_BindBuffer *cmd);
 
+void
+_mesa_unmarshal_BufferData(struct gl_context *ctx,
+                           const struct marshal_cmd_BufferData *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_BufferData(GLenum target, GLsizeiptr size, const GLvoid * data,
+                         GLenum usage);
+
+void
+_mesa_unmarshal_BufferSubData(struct gl_context *ctx,
+                              const struct marshal_cmd_BufferSubData *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_BufferSubData(GLenum target, GLintptr offset, GLsizeiptr size,
+                            const GLvoid * data);
+
+void
+_mesa_unmarshal_NamedBufferData(struct gl_context *ctx,
+                                const struct marshal_cmd_NamedBufferData *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_NamedBufferData(GLuint buffer, GLsizeiptr size,
+                              const GLvoid * data, GLenum usage);
+
+void
+_mesa_unmarshal_NamedBufferSubData(struct gl_context *ctx,
+                                   const struct marshal_cmd_NamedBufferSubData *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_NamedBufferSubData(GLuint buffer, GLintptr offset, GLsizeiptr size,
+                                 const GLvoid * data);
+
+void
+_mesa_unmarshal_ClearBufferfv(struct gl_context *ctx,
+                              const struct marshal_cmd_ClearBuffer *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_ClearBufferfv(GLenum buffer, GLint drawbuffer,
+                            const GLfloat *value);
+
+void
+_mesa_unmarshal_ClearBufferiv(struct gl_context *ctx,
+                              const struct marshal_cmd_ClearBuffer *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_ClearBufferiv(GLenum buffer, GLint drawbuffer,
+                            const GLint *value);
+
+void
+_mesa_unmarshal_ClearBufferuiv(struct gl_context *ctx,
+                               const struct marshal_cmd_ClearBuffer *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_ClearBufferuiv(GLenum buffer, GLint drawbuffer,
+                             const GLuint *value);
+
+void
+_mesa_unmarshal_ClearBufferfi(struct gl_context *ctx,
+                              const struct marshal_cmd_ClearBuffer *cmd);
+
+void GLAPIENTRY
+_mesa_marshal_ClearBufferfi(GLenum buffer, GLint drawbuffer,
+                            const GLfloat depth, const GLint stencil);
+
 #endif /* MARSHAL_H */