Fixed some bugs in MargaretImgAllocator and MargaretBufAllocator. Refactored r0, now it is not r0, I added Alice game engince namespace. I added mesh handler type, all stupid SceneTemplate crap is gone. There is no limit on model count and isntance count. I added haskell bindings for running Alice. Unfortunately, calculus exam is after-tomorrow, I don't have much time to organize my code

This commit is contained in:
Андреев Григорий 2025-12-27 21:35:23 +03:00
parent ae38b3b01e
commit cf237d1c0b
9 changed files with 877 additions and 887 deletions

2
.gitignore vendored
View File

@ -16,4 +16,4 @@ GRAPH*.gv
GRAPH*.png
SICK_JOKE*
*.hi
*_stub.h
*_stub.h

View File

@ -60,5 +60,5 @@ add_executable(codegen_l1_5 src/l1_5/anne/codegen.c)
add_executable(l2_tex_gen src/l2/anne/codegen.c)
target_link_libraries(l2_tex_gen -lm -lpng)
add_executable(l2_allie_in_r4 src/l2/allie/allie.c gen/l_wl_protocols/xdg-shell-private.c)
target_link_libraries(l2_allie_in_r4 -lvulkan -lwayland-client -lm -lxkbcommon -lpng -lfreetype)
add_executable(l2_r4 src/l3/r4/r4.c gen/l_wl_protocols/xdg-shell-private.c)
target_link_libraries(l2_r4 -lvulkan -lwayland-client -lm -lxkbcommon -lpng -lfreetype)

View File

@ -9,17 +9,17 @@ void generate_code_for_alice_on_l1(){
SpanU8 l = cstr("l1"), ns = cstr("alice");
/* Assets: model topology */
generate_eve_span_company_for_primitive(l, ns, cstr("GenericMeshVertexInc"), true, true);
generate_eve_span_company_for_non_primitive_clonable(l, ns, cstr("GenericMeshInSceneTemplate"), true, false);
generate_eve_span_company_for_primitive(l, ns, cstr("ShinyMeshVertexInc"), true, true);
generate_eve_span_company_for_non_primitive_clonable(l, ns, cstr("ShinyMeshTopology"), true, false);
/* Engine stuff */
generate_eve_span_company_for_primitive(l, ns, cstr("GenericModelOnSceneMem"), true, false);
generate_eve_span_company_for_primitive(l, ns, cstr("ShinyModelOnSceneMem"), true, false);
generate_eve_span_company_for_primitive(l, ns, cstr("GenericModelTexVulkPointers"), true, false);
// todo: yes, maybe right now it is not primitive but I surely will make it primitive someday. Right now I don't care
generate_List_templ_inst_eve_header(l, ns, (list_instantiation_op){
.T = cstr("AliceGenericMeshHand"), .t_primitive = true}, true);
generate_List_templ_inst_eve_header(l, ns, (list_instantiation_op){
.T = cstr("AliceShinyMeshHand"), .t_primitive = true}, true);
generate_eve_span_company_for_primitive(l, ns, cstr("ObjectInfo"), true, false); // todo: delete this crap
generate_eve_span_company_for_primitive(l, ns, cstr("RefListNodeAliceGenericMeshHand"), true, false);
generate_eve_span_company_for_primitive(l, ns, cstr("RefListNodeAliceShinyMeshHand"), true, false);
}
#endif

View File

@ -38,24 +38,15 @@ typedef struct {
VecU8 diffuse_texture_path;
VecU8 normal_texture_path;
VecU8 specular_texture_path;
} GenericMeshInSceneTemplate;
} GenericMeshAndTextureFilePath;
void GenericMeshInSceneTemplate_drop(GenericMeshInSceneTemplate self) {
void GenericMeshInSceneTemplate_drop(GenericMeshAndTextureFilePath self) {
GenericMeshTopology_drop(self.topology);
VecU8_drop(self.diffuse_texture_path);
VecU8_drop(self.normal_texture_path);
VecU8_drop(self.specular_texture_path);
}
GenericMeshInSceneTemplate GenericMeshInSceneTemplate_clone(const GenericMeshInSceneTemplate* self) {
return (GenericMeshInSceneTemplate){.topology = GenericMeshTopology_clone(&self->topology),
.diffuse_texture_path = VecU8_clone(&self->diffuse_texture_path),
.normal_texture_path = VecU8_clone(&self->normal_texture_path),
.specular_texture_path = VecU8_clone(&self->specular_texture_path)};
}
#include "../../../gen/l1/eve/alice/VecGenericMeshInSceneTemplate.h"
typedef struct {
mat4 model_t;
} GenericMeshInstanceInc;
@ -91,7 +82,6 @@ ShinyMeshTopology ShinyMeshTopology_clone(const ShinyMeshTopology* self) {
VecU32_clone(&self->indexes)};
}
#include "../../../gen/l1/eve/alice/VecShinyMeshTopology.h"
typedef struct{
mat4 model_t;
@ -133,15 +123,6 @@ typedef struct {
char _padding_1[4];
} Pipeline0PointLight;
typedef struct {
VecGenericMeshInSceneTemplate generic_models;
VecShinyMeshTopology shiny_models;
} SceneTemplate;
void SceneTemplate_drop(SceneTemplate self) {
VecGenericMeshInSceneTemplate_drop(self.generic_models);
}
#define pipeline_0_ubo_point_light_max_count 120
#define pipeline_0_ubo_spotlight_max_count 20

File diff suppressed because it is too large Load Diff

View File

@ -141,8 +141,8 @@ CubeVertOfFace CubeVertOfFace_next(CubeVertOfFace vert) {
}
// todo: yes, it is AGAINST THE RULES to take from l3 when being on l2, but we fjsdafklj lI WILL REMOVE THIS OK, MAN CALM DOWN
GenericMeshInSceneTemplate GenericMeshInSceneTemplate_for_log(SpanU8 root_dir, U64 w, U64 r, U64 k) {
return (GenericMeshInSceneTemplate){.topology = generate_one_fourth_of_a_cylinder((float)w, (float)r, k),
GenericMeshAndTextureFilePath GenericMeshAndTextureFilePath_for_log(SpanU8 root_dir, U64 w, U64 r, U64 k) {
return (GenericMeshAndTextureFilePath){.topology = generate_one_fourth_of_a_cylinder((float)w, (float)r, k),
.diffuse_texture_path = VecU8_fmt("%s/src/l3/textures/log_%u_%u_%u_diffuse.png", root_dir, w, r, k),
.normal_texture_path = VecU8_fmt("%s/gen/l2/textures/r4/log_%u_%u_%u_NORMAL.png", root_dir, w, r, k),
.specular_texture_path = VecU8_fmt("%s/src/l3/textures/log_%u_%u_%u_specular.png", root_dir, w, r, k),

View File

@ -202,6 +202,9 @@ void MargaretBufAllocator_free(MargaretBufAllocator* self, MargaretSubbuf alloca
MargaretBufAllocator__insert_gap(self, allocation.block,
left_free_space.start,
right_free_space.start + right_free_space.len - left_free_space.start);
bool eret = BufRBTree_MapU64ToU64_erase(&allocation.block->occupants, allocation.start);
assert(eret);
}
/* Idk how to hide this monster */

View File

@ -442,6 +442,10 @@ void MargaretImgAllocator_free(MargaretImgAllocator* self, MargaretImgAllocation
MargaretImgAllocator__insert_gap(self, allocation.block,
left_free_space.start,
right_free_space.start + right_free_space.len - left_free_space.start);
MargaretImgAllocatorOneBlock* block = VecMargaretImgAllocatorOneBlock_mat(&self->blocks, allocation.block);
bool eret = BufRBTree_MapU64ToU64_erase(&block->images, allocation.start);
assert(eret);
}
NODISCARD MargaretImgAllocation MargaretImgAllocator__alloc(

18
src/l3/r4/r4.c Normal file
View File

@ -0,0 +1,18 @@
#include "../../l2/allie/allie.c"
void main_h_on_wayland_keyboard_key(Alice* alice){
}
void main_h_on_another_frame(Alice* alice){
}
int main(){
Alice* alice = Alice_new();
Alice_mainloop(alice, &(AliceCallbacks){
.on_wl_keyboard_key = main_h_on_wayland_keyboard_key,
.on_another_frame = main_h_on_another_frame,
});
return 0;
}