library: unix sockets and worker thread

This commit is contained in:
Adam
2023-11-26 05:59:39 +00:00
parent f904039eda
commit 4de5958894
3 changed files with 518 additions and 272 deletions

View File

@@ -2,6 +2,8 @@
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <unistd.h>
void _bolt_glcontext_init(struct GLContext*, void*, void*);
void _bolt_glcontext_free(struct GLContext*);
@@ -53,7 +55,7 @@ struct STRUCT* _bolt_get_##NAME(struct GLList* list, ID_TYPE id) { \
pointer_cache[id] = ptr; \
ptr->id = id; \
struct STRUCT* inc_ptr = ptr; \
while (list->first_empty < PTR_LIST_CAPACITY && inc_ptr->id != 0) { \
while (list->first_empty < list->capacity && inc_ptr->id != 0) { \
inc_ptr += 1; \
list->first_empty += 1; \
} \
@@ -224,6 +226,7 @@ void _bolt_glcontext_init(struct GLContext* context, void* egl_context, void* eg
}
}
memset(context, 0, sizeof(*context));
socketpair(AF_UNIX, SOCK_STREAM, 0, context->sockets);
context->id = (uintptr_t)egl_context;
if (shared) {
context->uniform_buffer = shared->uniform_buffer;
@@ -243,6 +246,8 @@ void _bolt_glcontext_init(struct GLContext* context, void* egl_context, void* eg
}
void _bolt_glcontext_free(struct GLContext* context) {
close(context->sockets[0]);
close(context->sockets[1]);
if (context->is_shared_owner) {
free(context->programs.pointers);
free(context->buffers.pointers);

View File

@@ -84,6 +84,7 @@ void _bolt_get_attr_binding(const struct GLAttrBinding*, size_t, size_t, float*)
// are actually safe assumptions in valid OpenGL usage.
struct GLContext {
uintptr_t id;
int sockets[2];
struct GLList programs;
struct GLList buffers;
struct GLList textures;

View File

File diff suppressed because it is too large Load Diff