pool allocation. not working. not sure why. will travel back in time...

This commit is contained in:
2025-09-05 11:21:34 -05:00
parent 75e72ba9ca
commit 1c7a9900be
10 changed files with 145 additions and 109 deletions

View File

@@ -5,16 +5,22 @@
#include <string>
#include "util.hpp"
struct ObjData {
float* verts;
int verts_len;
int* faces;
int faces_len;
};
struct Body {
glm::mat4 pose;
glm::vec4 color;
float scale;
uint ebo;
uint vao;
uint vbo;
uint shader;
std::vector<float> verts;
std::vector<int> faces;
glm::vec4 color;
ObjData data;
};
bool load_body(Body* out_body, std::string filepath);

View File

@@ -15,9 +15,15 @@ typedef LARGE_INTEGER TimeSpan;
typedef DWORD (WINAPI *ThreadFunc)(_In_ LPVOID lpParameter);
typedef LPVOID ThreadArg;
const TimeSpan infinite_ts = LLONG_MAX;
static const LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
const TimeSpan infinite_ts = { .QuadPart = LLONG_MAX };
LARGE_INTEGER _init_freq() {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
return freq;
}
static LARGE_INTEGER freq = _init_freq();
#endif
Thread make_thread(ThreadFunc t, ThreadArg a);
@@ -60,7 +66,7 @@ Thread make_thread(ThreadFunc f, ThreadArg a) {
}
void join(Thread t) {
WaitForSingleObject(t, infinite_ts);
WaitForSingleObject(t, INFINITE);
}
Mutex make_mutex() {
@@ -92,7 +98,11 @@ ConditionVar make_condition_var() {
}
void wait(ConditionVar &c, Mutex &m, TimeSpan ts) {
SleepConditionVariableCS(&c, &m, ts);
if (ts.QuadPart == infinite_ts.QuadPart) {
SleepConditionVariableCS(&c, &m, INFINITE);
} else {
SleepConditionVariableCS(&c, &m, static_cast<DWORD>(to_ms(ts)));
}
}
void wake_one(ConditionVar &c) {
@@ -112,7 +122,7 @@ Semaphore make_semaphore(int initial, int max) {
}
void wait(Semaphore &s) {
WaitForSingleObject(s, infinite_ts);
WaitForSingleObject(s, INFINITE);
}
void post(Semaphore &s) {