X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fglthread.h;h=c13ca9e823695ce89ea666bbeeb0299d94b42947;hb=9037005d6034d6bcbeb508e0f783622e2351b957;hp=8cd5d0226743d92dacf35600f83a78ee62e9920e;hpb=43d66c8c2d4d3d4dee1309856b6ce6c5393682e5;p=mesa.git diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h index 8cd5d022674..c13ca9e8236 100644 --- a/src/mesa/main/glthread.h +++ b/src/mesa/main/glthread.h @@ -46,9 +46,33 @@ #include #include #include "util/u_queue.h" +#include "GL/gl.h" +#include "compiler/shader_enums.h" -enum marshal_dispatch_cmd_id; struct gl_context; +struct gl_buffer_object; +struct _mesa_HashTable; + +struct glthread_attrib_binding { + struct gl_buffer_object *buffer; /**< where non-VBO data was uploaded */ + int offset; /**< offset to uploaded non-VBO data */ + const void *original_pointer; /**< restore this pointer after the draw */ +}; + +struct glthread_vao { + GLuint Name; + GLuint CurrentElementBufferName; + GLbitfield Enabled; + GLbitfield UserPointerMask; + GLbitfield NonZeroDivisorMask; + + struct { + GLuint ElementSize; + GLsizei Stride; + GLuint Divisor; + const void *Pointer; + } Attrib[VERT_ATTRIB_MAX]; +}; /** A single batch of commands queued up for execution. */ struct glthread_batch @@ -60,9 +84,14 @@ struct glthread_batch struct gl_context *ctx; /** Amount of data used by batch commands, in bytes. */ - size_t used; + int used; /** Data contained in the command buffer. */ +#ifdef _MSC_VER + __declspec(align(8)) +#else + __attribute__((aligned(8))) +#endif uint8_t buffer[MARSHAL_MAX_CMD_SIZE]; }; @@ -74,33 +103,75 @@ 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; /** Index of the batch being filled and about to be submitted. */ unsigned next; - /** - * 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 element_array_is_vbo; + /** Upload buffer. */ + struct gl_buffer_object *upload_buffer; + uint8_t *upload_ptr; + unsigned upload_offset; + int upload_buffer_private_refcount; + + /** Caps. */ + GLboolean SupportsBufferUploads; + + /** Vertex Array objects tracked by glthread independently of Mesa. */ + struct _mesa_HashTable *VAOs; + struct glthread_vao *CurrentVAO; + struct glthread_vao *LastLookedUpVAO; + struct glthread_vao DefaultVAO; + int ClientActiveTexture; + + /** Currently-bound buffer object IDs. */ + GLuint CurrentArrayBufferName; + GLuint CurrentDrawIndirectBufferName; }; void _mesa_glthread_init(struct gl_context *ctx); void _mesa_glthread_destroy(struct gl_context *ctx); -void _mesa_glthread_restore_dispatch(struct gl_context *ctx); +void _mesa_glthread_restore_dispatch(struct gl_context *ctx, const char *func); +void _mesa_glthread_disable(struct gl_context *ctx, const char *func); 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_upload(struct gl_context *ctx, const void *data, + GLsizeiptr size, unsigned *out_offset, + struct gl_buffer_object **out_buffer, + uint8_t **out_ptr); + +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_ClientState(struct gl_context *ctx, GLuint *vaobj, + gl_vert_attrib attrib, bool enable); +void _mesa_glthread_AttribDivisor(struct gl_context *ctx, const GLuint *vaobj, + gl_vert_attrib attrib, GLuint divisor); +void _mesa_glthread_AttribPointer(struct gl_context *ctx, gl_vert_attrib attrib, + GLint size, GLenum type, GLsizei stride, + const void *pointer); +void _mesa_glthread_DSAAttribPointer(struct gl_context *ctx, GLuint vao, + GLuint buffer, gl_vert_attrib attrib, + GLint size, GLenum type, GLsizei stride, + GLintptr offset); #endif /* _GLTHREAD_H*/