mirror of
https://github.com/Adamcake/Bolt.git
synced 2026-05-24 17:14:28 -04:00
library: unix sockets and worker thread
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user