glthread: reduce dereferences of the next batch
[mesa.git] / src / mesa / main / glthread.h
index d8e9c3da84a77c4dd09153273d7d10adc2c93171..a50b2f87ceb4e3d97021e6b02386106591e1345e 100644 (file)
 #include <stdbool.h>
 #include "util/u_queue.h"
 #include "GL/gl.h"
+#include "compiler/shader_enums.h"
 
 struct gl_context;
 struct _mesa_HashTable;
 
 struct glthread_vao {
    GLuint Name;
-   bool HasUserPointer;
-   bool IndexBufferIsUserPointer;
+   GLuint CurrentElementBufferName;
+   GLbitfield Enabled;
+   GLbitfield UserPointerMask;
 };
 
 /** A single batch of commands queued up for execution. */
@@ -86,9 +88,15 @@ struct glthread_state
    /** This is sent to the driver for framebuffer overlay / HUD. */
    struct util_queue_monitoring stats;
 
+   /** Whether GLThread is enabled. */
+   bool enabled;
+
    /** The ring of batches in memory. */
    struct glthread_batch batches[MARSHAL_MAX_BATCHES];
 
+   /** Pointer to the batch currently being filled. */
+   struct glthread_batch *next_batch;
+
    /** Index of the last submitted batch. */
    unsigned last;
 
@@ -100,18 +108,11 @@ struct glthread_state
    struct glthread_vao *CurrentVAO;
    struct glthread_vao *LastLookedUpVAO;
    struct glthread_vao DefaultVAO;
+   int ClientActiveTexture;
 
-   /**
-    * Tracks on the main thread side whether the current vertex array binding
-    * is in a VBO.
-    */
-   bool vertex_array_is_vbo;
-
-   /**
-    * Tracks on the main thread side whether the current element array (index
-    * buffer) binding is in a VBO.
-    */
-   bool draw_indirect_buffer_is_vbo;
+   /** Currently-bound buffer object IDs. */
+   GLuint CurrentArrayBufferName;
+   GLuint CurrentDrawIndirectBufferName;
 };
 
 void _mesa_glthread_init(struct gl_context *ctx);
@@ -123,11 +124,19 @@ void _mesa_glthread_flush_batch(struct gl_context *ctx);
 void _mesa_glthread_finish(struct gl_context *ctx);
 void _mesa_glthread_finish_before(struct gl_context *ctx, const char *func);
 
+void _mesa_glthread_BindBuffer(struct gl_context *ctx, GLenum target,
+                               GLuint buffer);
+void _mesa_glthread_DeleteBuffers(struct gl_context *ctx, GLsizei n,
+                                  const GLuint *buffers);
+
 void _mesa_glthread_BindVertexArray(struct gl_context *ctx, GLuint id);
 void _mesa_glthread_DeleteVertexArrays(struct gl_context *ctx,
                                        GLsizei n, const GLuint *ids);
 void _mesa_glthread_GenVertexArrays(struct gl_context *ctx,
                                     GLsizei n, GLuint *arrays);
-void _mesa_glthread_AttribPointer(struct gl_context *ctx);
+void _mesa_glthread_ClientState(struct gl_context *ctx, GLuint *vaobj,
+                                gl_vert_attrib attrib, bool enable);
+void _mesa_glthread_AttribPointer(struct gl_context *ctx,
+                                  gl_vert_attrib attrib);
 
 #endif /* _GLTHREAD_H*/