Refactored the entire project (again)
This commit is contained in:
parent
61e2c71093
commit
8a1f8dbfdb
@ -2,7 +2,9 @@ cmake_minimum_required(VERSION 3.30)
|
||||
project(prototype1 C)
|
||||
|
||||
#include_directories(${CMAKE_SOURCE_DIR})
|
||||
set(CMAKE_C_FLAGS "-Wall -Wextra -Werror=implicit-function-declaration -Werror=return-type --std=c99 -g -ggdb -O0")
|
||||
set(CMAKE_C_FLAGS "-Wno-unused-parameter \
|
||||
-Wall -Wextra -Werror=implicit-function-declaration -Werror=return-type \
|
||||
--std=c99 -g -ggdb -O0")
|
||||
|
||||
execute_process(
|
||||
COMMAND pkg-config --cflags libpipewire-0.3
|
||||
@ -25,14 +27,14 @@ add_compile_definitions(_POSIX_C_SOURCE=200112L)
|
||||
add_compile_definitions(_GNU_SOURCE)
|
||||
add_compile_options(-fno-trapping-math)
|
||||
|
||||
#add_executable(codegen_l1 src/l1/codegen/codegen.c)
|
||||
#add_executable(codegen_l1 src/l1/anne/codegen.c)
|
||||
#target_compile_definitions(codegen_l1
|
||||
# PRIVATE PROTOTYPE1_L1_CODEGEN_BOOTSTRAP_USE_CHICKEN_VECU8)
|
||||
|
||||
add_executable(0_test src/l1/tests/t0.c)
|
||||
add_executable(1_test src/l1/tests/t1.c)
|
||||
add_executable(0_test src/l1_4/tests/t0.c)
|
||||
add_executable(1_test src/l1_4/tests/t1.c)
|
||||
|
||||
add_executable(codegen_l2 src/l2/codegen/codegen.c)
|
||||
add_executable(codegen_l1_5 src/l1_5/anne/codegen.c)
|
||||
|
||||
add_executable(0_render_test src/l2/tests/r0/r0.c gen/l_wl_protocols/xdg-shell-private.c)
|
||||
target_link_libraries(0_render_test -lvulkan -lwayland-client -lm -lxkbcommon)
|
||||
@ -46,9 +48,6 @@ target_link_libraries(1_render_test -lwayland-client -lrt -lm -lxkbcommon)
|
||||
add_executable(2a_render_test src/l2/tests/r2/r2a.c gen/l_wl_protocols/xdg-shell-private.c)
|
||||
target_link_libraries(2a_render_test ${LIBPIPEWIRE_LIBS} -lwayland-client -lrt -lm -lxkbcommon)
|
||||
|
||||
add_executable(2b_render_test src/l2/tests/r2/r2b.c)
|
||||
target_link_libraries(2b_render_test ${LIBPIPEWIRE_LIBS} -lm)
|
||||
|
||||
add_executable(3_render_test src/l2/tests/r3/r3.c gen/l_wl_protocols/xdg-shell-private.c)
|
||||
target_link_libraries(3_render_test -lwayland-client -lm -lvulkan -lxkbcommon)
|
||||
|
||||
|
||||
70
Makefile
70
Makefile
@ -1,47 +1,46 @@
|
||||
HEADERS_src_l1 := $(shell find src/l1 -type f -name '*.h')
|
||||
HEADERS_gen_l1 := $(shell find gen/l1 -type f -name '*.h') essence_gen_l1
|
||||
find_headers = $(shell find src/$(1) -type f -name '*.h')
|
||||
|
||||
HEADERS_src_l2 := $(shell find src/l2 -type f -name '*.h')
|
||||
HEADERS_gen_l2 := $(shell find gen/l2 -type f -name '*.h') essence_gen_l2
|
||||
HEADERS_src_l1 := $(call find_headers,l1)
|
||||
HEADERS_gen_l1 := $(HEADERS_src_l1) gen/l1/dorothy.txt
|
||||
|
||||
HEADERS_src_l3 := $(shell find src/l3 -type f -name '*.h')
|
||||
HEADERS_src_l1_5 = $(HEADERS_gen_l1) $(call find_headers,l1_5)
|
||||
HEADERS_gen_l1_5 := $(HEADERS_src_l1_5) gen/l1_5/dorothy.txt
|
||||
|
||||
cflags := -Wall -Wextra -Werror=implicit-function-declaration -Werror=return-type --std=c99 -g -ggdb -O0 \
|
||||
HEADERS_src_l2 := $(HEADERS_gen_l1_5) $(call find_headers,l2)
|
||||
HEADERS_gen_l2 := $(HEADERS_src_l2) gen/l2/dorothy.txt
|
||||
|
||||
cflags := -Wall -Wextra -Werror=implicit-function-declaration -Werror=return-type -Wno-unused-parameter \
|
||||
--std=c99 -g -ggdb -O0 \
|
||||
-fno-trapping-math -D_POSIX_C_SOURCE=200112L -D_GNU_SOURCE
|
||||
cc := gcc
|
||||
|
||||
wl_protocols := $(shell pkg-config --variable=pkgdatadir wayland-protocols)
|
||||
libpipewire_flags := $(shell pkg-config --cflags --libs libpipewire-0.3)
|
||||
|
||||
out/l1/codegen: src/l1/codegen/codegen.c $(HEADERS_src_l1)
|
||||
out/l1/codegen: src/l1/anne/codegen.c $(HEADERS_src_l1)
|
||||
mkdir -p out/l1
|
||||
$(cc) $(cflags) -D PROTOTYPE1_L1_CODEGEN_BOOTSTRAP_USE_CHICKEN_VECU8 -o $@ $<
|
||||
|
||||
.PHONY: essence_gen_l1
|
||||
essence_gen_l1: out/l1/codegen
|
||||
gen/l1/dorothy.txt: out/l1/codegen
|
||||
mkdir -p gen
|
||||
cd gen && ../out/l1/codegen
|
||||
|
||||
|
||||
out/l1/t0: src/l1/tests/t0.c $(HEADERS_gen_l1) $(HEADERS_src_l1)
|
||||
mkdir -p out/l1
|
||||
out/l1_4/t0: src/l1_4/tests/t0.c $(HEADERS_gen_l1)
|
||||
mkdir -p out/l1_4
|
||||
$(cc) $(cflags) -o $@ $<
|
||||
|
||||
out/l1/t1: src/l1/tests/t1.c $(HEADERS_gen_l1) $(HEADERS_src_l1)
|
||||
mkdir -p out/l1
|
||||
out/l1_4/t1: src/l1_4/tests/t1.c $(HEADERS_gen_l1)
|
||||
mkdir -p out/l1_4
|
||||
$(cc) $(cflags) -o $@ $<
|
||||
|
||||
|
||||
|
||||
|
||||
out/l2/codegen: src/l2/codegen/codegen.c $(HEADERS_src_l2) $(HEADERS_gen_l1) $(HEADERS_src_l1)
|
||||
mkdir -p out/l2
|
||||
out/l1_5/codegen: src/l1_5/anne/codegen.c $(HEADERS_src_l1_5)
|
||||
mkdir -p out/l1_5
|
||||
$(cc) $(cflags) -o $@ $<
|
||||
|
||||
.PHONY: essence_gen_l2
|
||||
essence_gen_l2: out/l2/codegen
|
||||
gen/l1_5/dorothy.txt: out/l1_5/codegen
|
||||
mkdir -p gen
|
||||
cd gen && ../out/l2/codegen
|
||||
cd gen && ../out/l1_5/codegen
|
||||
|
||||
gen/l_wl_protocols/xdg-shell-client.h: $(wl_protocols)/stable/xdg-shell/xdg-shell.xml
|
||||
mkdir -p gen/l_wl_protocols
|
||||
@ -51,33 +50,26 @@ gen/l_wl_protocols/xdg-shell-private.c: $(wl_protocols)/stable/xdg-shell/xdg-she
|
||||
mkdir -p gen/l_wl_protocols
|
||||
wayland-scanner private-code $< $@
|
||||
|
||||
l_wl_protocols := gen/l_wl_protocols/xdg-shell-client.h gen/l_wl_protocols/xdg-shell-private.c
|
||||
xdg_shell_private := gen/l_wl_protocols/xdg-shell-private.c
|
||||
l_wl_protocols := gen/l_wl_protocols/xdg-shell-client.h $(xdg_shell_private)
|
||||
|
||||
out/l2/r0: src/l2/tests/r0/r0.c $(HEADERS_gen_l2) $(HEADERS_src_l2) $(HEADERS_gen_l1) $(HEADERS_src_l1) \
|
||||
$(l_wl_protocols)
|
||||
out/l2/r0: src/l2/tests/r0/r0.c $(HEADERS_src_l2) $(l_wl_protocols)
|
||||
mkdir -p out/l2
|
||||
$(cc) $(cflags) -o $@ $< gen/l_wl_protocols/xdg-shell-private.c -lvulkan -lm -lxkbcommon -lwayland-client
|
||||
$(cc) $(cflags) -o $@ $< $(xdg_shell_private) -lvulkan -lm -lxkbcommon -lwayland-client
|
||||
|
||||
out/l2/r1: src/l2/tests/r1/r1.c $(HEADERS_gen_l2) $(HEADERS_src_l2) $(HEADERS_gen_l1) $(HEADERS_src_l1) \
|
||||
$(l_wl_protocols)
|
||||
out/l2/r1: src/l2/tests/r1/r1.c $(HEADERS_src_l2) $(l_wl_protocols)
|
||||
mkdir -p out/l2
|
||||
$(cc) $(cflags) -o $@ $< gen/l_wl_protocols/xdg-shell-private.c -lwayland-client -lrt -lxkbcommon -lm
|
||||
$(cc) $(cflags) -o $@ $< $(xdg_shell_private) -lwayland-client -lrt -lxkbcommon -lm
|
||||
|
||||
out/l2/r2a: src/l2/tests/r2/r2a.c $(HEADERS_gen_l2) $(HEADERS_src_l2) $(HEADERS_gen_l1) $(HEADERS_src_l1) \
|
||||
$(l_wl_protocols)
|
||||
out/l2/r2a: src/l2/tests/r2/r2a.c $(HEADERS_src_l2) $(l_wl_protocols)
|
||||
mkdir -p out/l2
|
||||
$(cc) $(cflags) -o $@ $< gen/l_wl_protocols/xdg-shell-private.c -lwayland-client -lrt -lxkbcommon -lm $(libpipewire_flags)
|
||||
$(cc) $(cflags) -o $@ $< $(xdg_shell_private) -lwayland-client -lrt -lxkbcommon -lm $(libpipewire_flags)
|
||||
|
||||
out/l2/r2b: src/l2/tests/r2/r2b.c $(HEADERS_gen_l2) $(HEADERS_src_l2) $(HEADERS_gen_l1) $(HEADERS_src_l1)
|
||||
out/l2/r3: src/l2/tests/r3/r3.c $(HEADERS_src_l2) $(l_wl_protocols)
|
||||
mkdir -p out/l2
|
||||
$(cc) $(cflags) -o $@ $< -lwayland-client -lrt -lxkbcommon -lm $(libpipewire_flags)
|
||||
|
||||
out/l2/r3: src/l2/tests/r3/r3.c $(HEADERS_gen_l2) $(HEADERS_src_l2) $(HEADERS_gen_l1) $(HEADERS_src_l1) \
|
||||
$(l_wl_protocols)
|
||||
mkdir -p out/l2
|
||||
$(cc) $(cflags) -o $@ $< gen/l_wl_protocols/xdg-shell-private.c -lwayland-client -lrt -lxkbcommon -lm -lvulkan
|
||||
$(cc) $(cflags) -o $@ $< $(xdg_shell_private) -lwayland-client -lrt -lxkbcommon -lm -lvulkan
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -rf gen out
|
||||
|
||||
.PHONY: clean
|
||||
|
||||
@ -4,8 +4,6 @@
|
||||
|
||||
#import calc
|
||||
|
||||
#let VAR = [123123]
|
||||
|
||||
#let norm-vec2(A) = calc.sqrt(A.at(0) * A.at(0) + A.at(1) * A.at(1))
|
||||
|
||||
#let rotate-vec2(V, angle) = (
|
||||
|
||||
28
src/l1/anne/codegen.c
Normal file
28
src/l1/anne/codegen.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include "../system/fsmanip.h"
|
||||
|
||||
#include "util_temp_very_base.h"
|
||||
#include "geom.h"
|
||||
#include "util_temp_geom.h"
|
||||
#include "pixel_masses.h"
|
||||
|
||||
#include "some_tests.h"
|
||||
#include "util_temp_vulkan.h"
|
||||
#include "margaret/vulkan_utils.h"
|
||||
#include "marie/graphics_geom.h"
|
||||
#include "liza.h"
|
||||
|
||||
int main() {
|
||||
mkdir_nofail("l1");
|
||||
mkdir_nofail("l1/eve");
|
||||
generate_util_temp_very_base_headers();
|
||||
generate_geom_header();
|
||||
generate_util_temp_geom_headers();
|
||||
generate_pixel_masses_header();
|
||||
generate_headers_for_r0_r1_r2_r3();
|
||||
generate_util_templ_inst_for_vulkan_headers();
|
||||
generate_margaret_eve_for_vulkan_utils();
|
||||
generate_marie_headers_for_graphics_geom();
|
||||
generate_liza_l1_headers();
|
||||
finish_layer(cstr("l1"));
|
||||
return 0;
|
||||
}
|
||||
@ -1,13 +1,11 @@
|
||||
#ifndef PROTOTYPE_SRC_L2_CODEGEN_GEOM_H
|
||||
#define PROTOTYPE_SRC_L2_CODEGEN_GEOM_H
|
||||
#ifndef PROTOTYPE_SRC_L1_CODEGEN_GEOM_H
|
||||
#define PROTOTYPE_SRC_L1_CODEGEN_GEOM_H
|
||||
|
||||
// todo: check for bugs
|
||||
|
||||
#include "../../l1/codegen/codegen.h"
|
||||
#include "../codegen/codegen.h"
|
||||
|
||||
SpanU8 vec_field_name(int ci) {
|
||||
assert(0 <= ci && ci < 4);
|
||||
return cstr(ci == 0 ? "x" : (ci == 1 ? "y" : (ci == 2 ? "z" : "w")));
|
||||
return ci == 0 ? cstr("x") : (ci == 1 ? cstr("y") : (ci == 2 ? cstr("z") : cstr("w")));
|
||||
}
|
||||
|
||||
NODISCARD VecU8 codegen_name_xvecn(SpanU8 xvec, int n) {
|
||||
@ -420,17 +418,17 @@ NODISCARD VecU8 generate_xmat234x234_structs_methods(SpanU8 xmat, SpanU8 xvec, S
|
||||
}
|
||||
|
||||
void generate_geom_header() {
|
||||
VecU8 res = begin_header(cstr("PROTOTYPE1_GEN_L2_GEOM"));
|
||||
VecU8_append_span(&res, cstr("#include \"../../src/l1/core/int_primitives.h\"\n"));
|
||||
VecU8_append_span(&res, cstr("#include <math.h>\n\n"));
|
||||
VecU8_append_vec(&res, generate_xvec234_structs_and_base_methods(cstr("cvec"), cstr("U8")));
|
||||
VecU8_append_vec(&res, generate_xvec234_structs_and_base_methods(cstr("ivec"), cstr("S32")));
|
||||
GeneratedHeader res = begin_header(cstr("l1/geom.h"));
|
||||
VecU8_append_span(&res.result, cstr("#include \"../../src/l1/core/int_primitives.h\"\n"));
|
||||
VecU8_append_span(&res.result, cstr("#include <math.h>\n\n"));
|
||||
VecU8_append_vec(&res.result, generate_xvec234_structs_and_base_methods(cstr("cvec"), cstr("U8")));
|
||||
VecU8_append_vec(&res.result, generate_xvec234_structs_and_base_methods(cstr("ivec"), cstr("S32")));
|
||||
|
||||
VecU8_append_vec(&res, generate_xvec234_structs_and_cool_methods(cstr("vec"), cstr("float"), cstr("sqrtf")));
|
||||
VecU8_append_vec(&res, generate_xvec234_structs_and_cool_methods(cstr("dvec"), cstr("double"), cstr("sqrt")));
|
||||
VecU8_append_vec(&res, generate_xmat234x234_structs_methods(cstr("mat"), cstr("vec"), cstr("float"), sizeof(float)));
|
||||
VecU8_append_vec(&res, generate_xmat234x234_structs_methods(cstr("dmat"), cstr("dvec"), cstr("double"), sizeof(double)));
|
||||
finish_header(res, "l2/geom.h");
|
||||
VecU8_append_vec(&res.result, generate_xvec234_structs_and_cool_methods(cstr("vec"), cstr("float"), cstr("sqrtf")));
|
||||
VecU8_append_vec(&res.result, generate_xvec234_structs_and_cool_methods(cstr("dvec"), cstr("double"), cstr("sqrt")));
|
||||
VecU8_append_vec(&res.result, generate_xmat234x234_structs_methods(cstr("mat"), cstr("vec"), cstr("float"), sizeof(float)));
|
||||
VecU8_append_vec(&res.result, generate_xmat234x234_structs_methods(cstr("dmat"), cstr("dvec"), cstr("double"), sizeof(double)));
|
||||
finish_header(res);
|
||||
}
|
||||
|
||||
#endif
|
||||
20
src/l1/anne/liza.h
Normal file
20
src/l1/anne/liza.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_LIZA_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_LIZA_H
|
||||
|
||||
#include "../codegen/util_template_inst.h"
|
||||
|
||||
void generate_liza_l1_headers() {
|
||||
SpanU8 l = cstr("l1");
|
||||
SpanU8 ns = cstr("liza");
|
||||
mkdir_nofail("l1/eve/liza");
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("BoxLizaSound"),
|
||||
(util_templates_instantiation_options){ .vec = true});
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("PlayingSound"),
|
||||
(util_templates_instantiation_options){.vec_extended = true});
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("BoxLizaInstrument"),
|
||||
(util_templates_instantiation_options){ .vec = true});
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("MyInstrument"),
|
||||
(util_templates_instantiation_options){ .vec = true});
|
||||
}
|
||||
|
||||
#endif
|
||||
24
src/l1/anne/margaret/vulkan_utils.h
Normal file
24
src/l1/anne/margaret/vulkan_utils.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_MARGARET_VULKAN_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_MARGARET_VULKAN_H
|
||||
|
||||
#include "../../codegen/util_template_inst.h"
|
||||
|
||||
void generate_margaret_eve_for_vulkan_utils() {
|
||||
SpanU8 l = cstr("l1");
|
||||
SpanU8 ns = cstr("margaret");
|
||||
mkdir_nofail("l1/eve/margaret");
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("MargaretScoredPhysicalDevice"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .span = true,
|
||||
.mut_span = true, .collab_vec_span = true, .span_sort = true});
|
||||
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("MargaretBufferInMemoryInfo"), true, false);
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("PtrMargaretBufferInMemoryInfo"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .span = true, .mut_span = true,
|
||||
.collab_vec_span = true});
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("MargaretImageInMemoryInfo"), true, false);
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("PtrMargaretImageInMemoryInfo"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .span = true, .mut_span = true,
|
||||
.collab_vec_span = true});
|
||||
}
|
||||
|
||||
#endif
|
||||
14
src/l1/anne/marie/graphics_geom.h
Normal file
14
src/l1/anne/marie/graphics_geom.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_MARIE_GRAPHICS_GEOM_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_MARIE_GRAPHICS_GEOM_H
|
||||
|
||||
#include "../../codegen/util_template_inst.h"
|
||||
|
||||
void generate_marie_headers_for_graphics_geom() {
|
||||
SpanU8 l = cstr("l1");
|
||||
SpanU8 ns = cstr("marie");
|
||||
mkdir_nofail("l1/eve/marie");
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("MarieTriangle"), true, false);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("MarieTriangleAttr"), true, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef PROTOTYPE_SRC_L2_CODEGEN_PIXEL_MASSES_H
|
||||
#define PROTOTYPE_SRC_L2_CODEGEN_PIXEL_MASSES_H
|
||||
#ifndef PROTOTYPE_SRC_L1_CODEGEN_PIXEL_MASSES_H
|
||||
#define PROTOTYPE_SRC_L1_CODEGEN_PIXEL_MASSES_H
|
||||
|
||||
#include "../../l1/codegen/codegen.h"
|
||||
#include "../codegen/codegen.h"
|
||||
|
||||
/* Used to generate both _at() and _cat() methods */
|
||||
NODISCARD VecU8 generate_texture_data_method_at(SpanU8 tex, SpanU8 pixvec, SpanU8 memb, bool const_access) {
|
||||
@ -10,8 +10,8 @@ NODISCARD VecU8 generate_texture_data_method_at(SpanU8 tex, SpanU8 pixvec, SpanU
|
||||
SPACE4 "assert(x < self->width);\n"
|
||||
SPACE4 "return %s_%sat(&self->pixels, x + y * self->width);\n"
|
||||
"}\n\n",
|
||||
cstr(const_access ? "const " : ""), memb, tex, cstr(const_access ? "" : "m"),
|
||||
cstr(const_access ? "const " : ""), tex, pixvec, cstr(const_access ? "" : "m"));
|
||||
const_access ? cstr("const ") : cstr(""), memb, tex, const_access ? cstr("") : cstr("m"),
|
||||
const_access ? cstr("const ") : cstr(""), tex, pixvec, const_access ? cstr("") : cstr("m"));
|
||||
}
|
||||
|
||||
/* `tex` is the type name of texture data type
|
||||
@ -132,14 +132,14 @@ NODISCARD VecU8 generate_texture_data_struct_and_necc_methods(SpanU8 tex, SpanU8
|
||||
}
|
||||
|
||||
void generate_pixel_masses_header() {
|
||||
VecU8 res = begin_header(cstr("PROTOTYPE1_GEN_L2_PIXEL_MASSES"));
|
||||
VecU8_append_span(&res, cstr("#include \"../l1/VecAndSpan_int_primitives.h\"\n"));
|
||||
VecU8_append_span(&res, cstr("#include \"../../src/l1/system/fileio.h\"\n"));
|
||||
VecU8_append_span(&res, cstr("#include \"VecAndSpan_cvec.h\"\n\n"));
|
||||
VecU8_append_vec(&res, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8"), cstr("U8")));
|
||||
VecU8_append_vec(&res, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8G8B8"), cstr("cvec3")));
|
||||
VecU8_append_vec(&res, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8G8B8A8"), cstr("cvec4")));
|
||||
finish_header(res, "l2/pixel_masses.h");
|
||||
GeneratedHeader res = begin_header(cstr("l1/pixel_masses.h"));
|
||||
VecU8_append_span(&res.result, cstr("#include \"VecAndSpan_int_primitives.h\"\n"));
|
||||
VecU8_append_span(&res.result, cstr("#include \"../../src/l1/system/fileio.h\"\n"));
|
||||
VecU8_append_span(&res.result, cstr("#include \"VecAndSpan_cvec.h\"\n\n"));
|
||||
VecU8_append_vec(&res.result, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8"), cstr("U8")));
|
||||
VecU8_append_vec(&res.result, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8G8B8"), cstr("cvec3")));
|
||||
VecU8_append_vec(&res.result, generate_texture_data_struct_and_necc_methods(cstr("TextureDataR8G8B8A8"), cstr("cvec4")));
|
||||
finish_header(res);
|
||||
}
|
||||
|
||||
|
||||
34
src/l1/anne/some_tests.h
Normal file
34
src/l1/anne/some_tests.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_SOME_TESTS_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_SOME_TESTS_H
|
||||
|
||||
#include "../codegen/util_template_inst.h"
|
||||
|
||||
void generate_headers_for_r0_r1_r2_r3() {
|
||||
SpanU8 l = cstr("l1");
|
||||
mkdir_nofail("l1/eve/r0");
|
||||
{ /* Needed in r0_assets.h */
|
||||
SpanU8 ns = cstr("r0");
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("GenericMeshVertex"), 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("GenericMeshInstance"), true, false);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("ShinyMeshVertex"), true, true);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("ShinyMeshInstance"), true, false);
|
||||
generate_eve_span_company_for_non_primitive_clonable(l, ns, cstr("ShinyMeshInSceneTemplate"), true, false);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("Pipeline0Spotlight"), true, false);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("Pipeline0PointLight"), true, false);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("Wimbzle"), true, false);
|
||||
generate_eve_span_company_for_primitive(l, ns, cstr("Nibzle"), true, false);
|
||||
/* r0_scene.h */
|
||||
generate_eve_span_company_for_non_primitive_non_clonable(l, ns, cstr("UsedGenericModelOnScene"), true, false);
|
||||
generate_eve_span_company_for_non_primitive_non_clonable(l, ns, cstr("UsedShinyModelOnScene"), true, false);
|
||||
}
|
||||
mkdir_nofail("l1/eve/r2");
|
||||
{ /* r2 */
|
||||
SpanU8 ns = cstr("r2");
|
||||
generate_util_templ_inst_eve_header(l, ns, cstr("PlayingSound"), (util_templates_instantiation_options){
|
||||
.vec_extended = true});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
35
src/l1/anne/util_temp_geom.h
Normal file
35
src/l1/anne/util_temp_geom.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_UTIL_TEMP_GEOM_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_UTIL_TEMP_GEOM_H
|
||||
|
||||
#include "../codegen/util_template_inst.h"
|
||||
|
||||
void generate_util_temp_geom_headers() {
|
||||
{
|
||||
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_cvec.h"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"geom.h\"\n"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[] = {cstr("cvec3"), cstr("cvec4")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head.result, generate_util_templates_instantiation(T[i],
|
||||
(util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = true, .span = true, .collab_vec_span = true,
|
||||
}));
|
||||
}
|
||||
finish_header(head);
|
||||
}
|
||||
{
|
||||
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_vec.h"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"geom.h\"\n"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[] = {cstr("vec2"), cstr("vec3"), cstr("vec4")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head.result, generate_util_templates_instantiation(T[i],
|
||||
(util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = true, .span = true, .collab_vec_span = true,
|
||||
}));
|
||||
}
|
||||
finish_header(head);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
60
src/l1/anne/util_temp_very_base.h
Normal file
60
src/l1/anne/util_temp_very_base.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_UTIL_TEMP_VERY_BASE_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_UTIL_TEMP_VERY_BASE_H
|
||||
|
||||
#include "../codegen/util_template_inst.h"
|
||||
|
||||
/* These headers are guarded */
|
||||
void generate_util_temp_very_base_headers() {
|
||||
{
|
||||
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_int_primitives.h"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[4] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head.result, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_integer = true, .t_primitive = true, .vec = true, .vec_extended = true,
|
||||
.vec_equal = true, .span = true, .span_extended = true, .mut_span = true,
|
||||
.collab_vec_span = true, .collab_vec_span_extended = true,
|
||||
}));
|
||||
}
|
||||
finish_header(head);
|
||||
}
|
||||
{
|
||||
GeneratedHeader head = begin_header(cstr("l1/Option_int_primitives.h"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[4] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head.result, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_integer = true, .t_primitive = true, .option = true
|
||||
}));
|
||||
}
|
||||
finish_header(head);
|
||||
}
|
||||
{
|
||||
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_Vec_int_primitives.h"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"VecAndSpan_int_primitives.h\"\n\n"));
|
||||
SpanU8 T[4] = {cstr("VecU8"), cstr("VecU16"), cstr("VecU32"), cstr("VecU64")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head.result, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_clonable = true, .vec = true, .vec_extended = true, .span = true, .collab_vec_span = true, .vec_equal = true,
|
||||
}));
|
||||
}
|
||||
VecU8_append_vec(&head.result, generate_VecT_new_of_size_method(cstr("VecU8")));
|
||||
finish_header(head);
|
||||
}
|
||||
{
|
||||
GeneratedHeader head = begin_header(cstr("l1/VecAndSpan_Span_int_primitives.h"));
|
||||
VecU8_append_span(&head.result, cstr("#include \"VecAndSpan_int_primitives.h\"\n\n"));
|
||||
SpanU8 T[1] = {cstr("SpanU8")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head.result, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = true, .span = true, .mut_span = true,
|
||||
.collab_vec_span = true,
|
||||
}));
|
||||
}
|
||||
finish_header(head);
|
||||
}
|
||||
generate_guarded_span_company_for_primitive(cstr("l1"), cstr(""),
|
||||
cstr("CSTR"), cstr(""), true, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
33
src/l1/anne/util_temp_vulkan.h
Normal file
33
src/l1/anne/util_temp_vulkan.h
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_ANNE_VULKAN_H
|
||||
#define PROTOTYPE1_SRC_L1_ANNE_VULKAN_H
|
||||
|
||||
#include "../codegen/util_template_inst.h"
|
||||
|
||||
/* These headers will be guarded */
|
||||
void generate_util_templ_inst_for_vulkan_headers() {
|
||||
SpanU8 vulkan_dep = cstr("#include <vulkan/vulkan.h>");
|
||||
SpanU8 l = cstr("l1");
|
||||
SpanU8 ns = cstr("vulkan");
|
||||
mkdir_nofail("l1/vulkan");
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkQueueFamilyProperties"), vulkan_dep, true, false);
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkExtensionProperties"), vulkan_dep, true, false);
|
||||
generate_util_templ_inst_guarded_header(l, ns, cstr("VkSurfaceFormatKHR"), vulkan_dep,
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .option = true });
|
||||
generate_util_templ_inst_guarded_header(l, ns, cstr("VkPresentModeKHR"), vulkan_dep,
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .option = true });
|
||||
generate_util_templ_inst_guarded_header(l, ns, cstr("VkCompositeAlphaFlagBitsKHR"), vulkan_dep,
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .option = true });
|
||||
generate_util_templ_inst_guarded_header(l, ns, cstr("VkExtent2D"), vulkan_dep,
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .option = true });
|
||||
generate_util_templ_inst_guarded_header(l, ns, cstr("VkFormat"), vulkan_dep,
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .span = true, .option = true });
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkPhysicalDevice"), vulkan_dep, true, false);
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkImage"), vulkan_dep, true, false);
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkImageView"), vulkan_dep, true, false);
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkFramebuffer"), vulkan_dep, true, false);
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkSemaphore"), vulkan_dep, true, false);
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkDescriptorPoolSize"), vulkan_dep, true, false);
|
||||
generate_guarded_span_company_for_primitive(l, ns, cstr("VkBufferCopy"), vulkan_dep, true, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,55 +0,0 @@
|
||||
#include "util_template_inst.h"
|
||||
#include "../system/fsmanip.h"
|
||||
|
||||
int main() {
|
||||
make_dir_nofail("l1");
|
||||
{
|
||||
VecU8 head = begin_header(cstr("PROTOTYPE1_GEN_L1_VECANDSPAN_INT_PRIMITIVES_H"));
|
||||
VecU8_append_span(&head, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[4] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_integer = true, .t_primitive = true, .vec = true, .vec_extended = true,
|
||||
.vec_equal = true, .span = true, .span_extended = true, .mut_span = true,
|
||||
.collab_vec_span = true, .collab_vec_span_extended = true,
|
||||
}));
|
||||
}
|
||||
finish_header(head, "l1/VecAndSpan_int_primitives.h");
|
||||
}
|
||||
{
|
||||
VecU8 head = begin_header(cstr("PROTOTYPE1_GEN_L1_OPTION_INT_PRIMITIVES_H"));
|
||||
VecU8_append_span(&head, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[4] = {cstr("U8"), cstr("U16"), cstr("U32"), cstr("U64")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_integer = true, .t_primitive = true, .option = true
|
||||
}));
|
||||
}
|
||||
finish_header(head, "l1/Option_int_primitives.h");
|
||||
}
|
||||
{
|
||||
VecU8 head = begin_header(cstr("PROTOTYPE1_GEN_L1_VECANDSPAN_VEC_INT_PRIMITIVES_H"));
|
||||
VecU8_append_span(&head, cstr("#include \"VecAndSpan_int_primitives.h\"\n\n"));
|
||||
SpanU8 T[4] = {cstr("VecU8"), cstr("VecU16"), cstr("VecU32"), cstr("VecU64")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_clonable = true, .vec = true, .vec_extended = true, .span = true, .collab_vec_span = true, .vec_equal = true,
|
||||
}));
|
||||
}
|
||||
VecU8_append_vec(&head, generate_VecT_new_of_size_method(cstr("VecU8")));
|
||||
finish_header(head, "l1/VecAndSpan_Vec_int_primitives.h");
|
||||
}
|
||||
{
|
||||
VecU8 head = begin_header(cstr("PROTOTYPE1_GEN_L1_VECANDSPAN_SPAN_INT_PRIMITIVES_H"));
|
||||
VecU8_append_span(&head, cstr("#include \"VecAndSpan_int_primitives.h\"\n\n"));
|
||||
SpanU8 T[1] = {cstr("SpanU8")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&head, generate_util_templates_instantiation(T[i], (util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = true, .span = true, .mut_span = true,
|
||||
.collab_vec_span = true,
|
||||
}));
|
||||
}
|
||||
finish_header(head, "l1/VecAndSpan_Span_int_primitives.h");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -3,23 +3,38 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../system/fileio.h"
|
||||
#include "../system/fsmanip.h"
|
||||
#include "../core/VecU8_as_str.h"
|
||||
|
||||
NODISCARD VecU8 begin_header(SpanU8 guard) {
|
||||
typedef struct {
|
||||
VecU8 result;
|
||||
VecU8 nt_filename;
|
||||
} GeneratedHeader;
|
||||
|
||||
NODISCARD GeneratedHeader begin_header(SpanU8 filename) {
|
||||
VecU8 res = VecU8_new();
|
||||
VecU8 guard = VecU8_from_cstr("PROTOTYPE1_GEN_");
|
||||
for (size_t i = 0; i < filename.len; i++) {
|
||||
char ch = (char)*SpanU8_at(filename, i);
|
||||
if (ch == '.' || ch == '/' || ch == '-' || ch == ',')
|
||||
VecU8_append(&guard, '_');
|
||||
else
|
||||
VecU8_append(&guard, ch);
|
||||
}
|
||||
VecU8_append_span(&res, cstr("#ifndef "));
|
||||
VecU8_append_span(&res, guard);
|
||||
VecU8_append_span(&res, VecU8_to_span(&guard));
|
||||
VecU8_append_span(&res, cstr("\n#define "));
|
||||
VecU8_append_span(&res, guard);
|
||||
VecU8_append_vec(&res, guard);
|
||||
VecU8_append_span(&res, cstr("\n/* Automatically generated file. Do not edit it. */\n\n"));
|
||||
return res;
|
||||
return (GeneratedHeader){.result = res, .nt_filename = VecU8_fmt("%s%c", filename, 0) };
|
||||
}
|
||||
|
||||
/* Codegen script's working directory should be `gen` */
|
||||
void finish_header(VecU8 text_before_endif, const char* filename) {
|
||||
VecU8_append_span(&text_before_endif, cstr("#endif\n"));
|
||||
write_whole_file_or_abort(filename, VecU8_to_span(&text_before_endif));
|
||||
VecU8_drop(text_before_endif);
|
||||
void finish_header(GeneratedHeader header) {
|
||||
VecU8_append_span(&header.result, cstr("#endif\n"));
|
||||
write_whole_file_or_abort((const char*)header.nt_filename.buf, VecU8_to_span(&header.result));
|
||||
VecU8_drop(header.nt_filename);
|
||||
VecU8_drop(header.result);
|
||||
}
|
||||
|
||||
#define SPACE4 " "
|
||||
@ -27,4 +42,10 @@ void finish_header(VecU8 text_before_endif, const char* filename) {
|
||||
#define SPACE12 " "
|
||||
#define SPACE16 " "
|
||||
|
||||
void finish_layer(SpanU8 layer_name) {
|
||||
VecU8 nt_name = VecU8_fmt("%s/dorothy.txt%c", layer_name, 0);
|
||||
write_whole_file_or_abort((const char*)nt_name.buf, cstr(""));
|
||||
VecU8_drop(nt_name);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -462,31 +462,35 @@ typedef struct {
|
||||
bool option;
|
||||
} util_templates_instantiation_options;
|
||||
|
||||
void util_templates_instantiation_options_fix(util_templates_instantiation_options* op) {
|
||||
if (op->t_integer)
|
||||
op->t_primitive = true;
|
||||
if (op->t_primitive)
|
||||
op->t_clonable = true;
|
||||
if (op->vec_extended)
|
||||
op->vec = true;
|
||||
if (op->vec_equal)
|
||||
op->vec = true;
|
||||
if (op->span_extended)
|
||||
op->span = true;
|
||||
if (op->span_sort)
|
||||
op->span = true;
|
||||
if (op->mut_span)
|
||||
op->span = true;
|
||||
if (op->collab_vec_span_extended)
|
||||
op->collab_vec_span = true;
|
||||
if (op->collab_vec_span) {
|
||||
op->span = true;
|
||||
op->vec = true;
|
||||
}
|
||||
assert(op->vec || op->span || op->option);
|
||||
assert(op->t_primitive || !op->t_integer);
|
||||
assert(!op->t_primitive || op->t_clonable);
|
||||
}
|
||||
|
||||
NODISCARD VecU8 generate_util_templates_instantiation(SpanU8 T, util_templates_instantiation_options op) {
|
||||
VecU8 res = VecU8_new();
|
||||
if (op.t_integer)
|
||||
op.t_primitive = true;
|
||||
if (op.t_primitive)
|
||||
op.t_clonable = true;
|
||||
if (op.vec_extended)
|
||||
op.vec = true;
|
||||
if (op.vec_equal)
|
||||
op.vec = true;
|
||||
if (op.span_extended)
|
||||
op.span = true;
|
||||
if (op.span_sort)
|
||||
op.span = true;
|
||||
if (op.mut_span)
|
||||
op.span = true;
|
||||
if (op.collab_vec_span_extended)
|
||||
op.collab_vec_span = true;
|
||||
if (op.collab_vec_span) {
|
||||
op.span = true;
|
||||
op.vec = true;
|
||||
}
|
||||
assert(op.vec || op.span || op.option);
|
||||
assert(op.t_primitive || !op.t_integer);
|
||||
assert(!op.t_primitive || op.t_clonable);
|
||||
util_templates_instantiation_options_fix(&op);
|
||||
if (op.vec) {
|
||||
VecU8_append_vec(&res, generate_VecT_struct_and_base_methods(T, op.t_primitive, op.t_clonable));
|
||||
}
|
||||
@ -515,34 +519,97 @@ NODISCARD VecU8 generate_util_templates_instantiation(SpanU8 T, util_templates_i
|
||||
return res;
|
||||
}
|
||||
|
||||
/* You want bonus_ns to be cstr("").*/
|
||||
void generate_eve_header(SpanU8 layer, SpanU8 bonus_ns, SpanU8 T, util_templates_instantiation_options op) {
|
||||
VecU8 text = vcstr("/*Automatically generated file. Do not edit it */\n\n");
|
||||
NODISCARD VecU8 util_templates_instantiation_get_appropriate_filename(
|
||||
SpanU8 T, util_templates_instantiation_options op
|
||||
) {
|
||||
util_templates_instantiation_options_fix(&op);
|
||||
return VecU8_fmt("%s%s%s%s%s""%s%s.h",
|
||||
op.vec ? cstr("Vec") : cstr(""), op.vec && op.span ? cstr("And") : cstr(""), op.span ? cstr("Span") : cstr(""),
|
||||
(op.span || op.vec) && op.option ? cstr("And") : cstr(""), op.option ? cstr("Option") : cstr(""),
|
||||
(int)op.vec + (int)op.span + (int)op.option > 1 ? cstr("_") : cstr(""), T);
|
||||
}
|
||||
|
||||
void generate_util_templ_inst_eve_header(SpanU8 layer, SpanU8 bonus_ns, SpanU8 T, util_templates_instantiation_options op) {
|
||||
VecU8 text = vcstr("/* Automatically generated file. Do not edit it.\n"
|
||||
" * Do not include it in more than one place */\n\n");
|
||||
VecU8_append_vec(&text, generate_util_templates_instantiation(T, op));
|
||||
VecU8 filename = VecU8_fmt("%s/eve/%s/""%s%s%s%s%s""%s%s.h", layer, bonus_ns,
|
||||
cstr(op.vec ? "Vec" : ""), cstr(op.vec && op.span ? "And" : ""), cstr(op.span ? "Span" : ""),
|
||||
cstr((op.span && op.option) || (op.vec && !op.span && op.option) ? "And" : ""), cstr(op.option ? "Option" : ""),
|
||||
cstr((int)op.vec + (int)op.span + (int)op.option > 1 ? "_" : ""), T);
|
||||
VecU8_append(&filename, 0);
|
||||
write_whole_file_or_abort((const char*)filename.buf, VecU8_to_span(&text));
|
||||
VecU8 filename = util_templates_instantiation_get_appropriate_filename(T, op);
|
||||
// todo: add %v that takes a vector
|
||||
VecU8 nt_path = VecU8_fmt("%s/eve/%s/%s%c", layer, bonus_ns, VecU8_to_span(&filename), 0);
|
||||
write_whole_file_or_abort((const char*)nt_path.buf, VecU8_to_span(&text));
|
||||
VecU8_drop(nt_path);
|
||||
VecU8_drop(filename);
|
||||
VecU8_drop(text);
|
||||
}
|
||||
|
||||
void generate_eve_span_garden_for_primitive(SpanU8 layer, SpanU8 ns, SpanU8 T, bool with_vector, bool with_span) {
|
||||
generate_eve_header(layer, ns, T, (util_templates_instantiation_options){
|
||||
void generate_eve_span_company_for_primitive(SpanU8 layer, SpanU8 ns, SpanU8 T, bool with_vector, bool with_span) {
|
||||
generate_util_templ_inst_eve_header(layer, ns, T, (util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = with_vector, .span = with_span, .collab_vec_span = with_vector && with_span
|
||||
});
|
||||
}
|
||||
|
||||
void generate_eve_span_garden_for_non_primitive_clonable(SpanU8 layer, SpanU8 ns, SpanU8 T, bool with_vector, bool with_span) {
|
||||
generate_eve_header(layer, ns, T, (util_templates_instantiation_options){
|
||||
void generate_eve_span_company_for_non_primitive_clonable(SpanU8 layer, SpanU8 ns, SpanU8 T, bool with_vector, bool with_span) {
|
||||
generate_util_templ_inst_eve_header(layer, ns, T, (util_templates_instantiation_options){
|
||||
.t_clonable = true, .vec = with_vector, .span = with_span, .collab_vec_span = with_vector && with_span
|
||||
});
|
||||
}
|
||||
|
||||
void generate_eve_span_garden_for_non_primitive_non_clonable(SpanU8 layer, SpanU8 ns, SpanU8 T, bool with_vector, bool with_span) {
|
||||
generate_eve_header(layer, ns, T, (util_templates_instantiation_options){
|
||||
void generate_eve_span_company_for_non_primitive_non_clonable(SpanU8 layer, SpanU8 ns, SpanU8 T, bool with_vector, bool with_span) {
|
||||
generate_util_templ_inst_eve_header(layer, ns, T, (util_templates_instantiation_options){
|
||||
.vec = with_vector, .span = with_span, .collab_vec_span = with_vector && with_span
|
||||
});
|
||||
}
|
||||
|
||||
int get_number_of_parts_in_header_namespace(SpanU8 ns) {
|
||||
int a = 0;
|
||||
for (size_t i = 0; i < ns.len; i++) {
|
||||
if (*SpanU8_at(ns, i) != '/' && (i == 0 || *SpanU8_at(ns, i - 1) == '/'))
|
||||
a++;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
void generate_util_templ_inst_guarded_header(
|
||||
SpanU8 layer, SpanU8 bonus_ns, SpanU8 T, SpanU8 dependencies,
|
||||
util_templates_instantiation_options op
|
||||
) {
|
||||
assert(layer.len > 1);
|
||||
VecU8 filename = util_templates_instantiation_get_appropriate_filename(T, op);
|
||||
VecU8 path = VecU8_fmt("%s/%s%s%s", layer, bonus_ns, bonus_ns.len ? cstr("/") : cstr(""), VecU8_to_span(&filename));
|
||||
GeneratedHeader head = begin_header(VecU8_to_span(&path));
|
||||
VecU8_drop(path);
|
||||
VecU8_drop(filename);
|
||||
VecU8_append_span(&head.result, cstr("#include \"../../"));
|
||||
int to_my_layer = get_number_of_parts_in_header_namespace(bonus_ns);
|
||||
for (int i = 0; i < to_my_layer; i++)
|
||||
VecU8_append_span(&head.result, cstr("../"));
|
||||
VecU8_append_span(&head.result, cstr("src/l1/core/util.h\"\n"));
|
||||
VecU8_append_span(&head.result, dependencies);
|
||||
VecU8_append_span(&head.result, cstr("\n\n"));
|
||||
VecU8_append_vec(&head.result, generate_util_templates_instantiation(T, op));
|
||||
finish_header(head);
|
||||
}
|
||||
|
||||
void generate_guarded_span_company_for_primitive(
|
||||
SpanU8 layer, SpanU8 ns, SpanU8 T, SpanU8 dependencies, bool with_vector, bool with_span
|
||||
) {
|
||||
generate_util_templ_inst_guarded_header(layer, ns, T, dependencies, (util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = with_vector, .span = with_span, .collab_vec_span = with_vector && with_span
|
||||
});
|
||||
}
|
||||
|
||||
void generate_guarded_span_company_for_non_primitive_clonable(
|
||||
SpanU8 layer, SpanU8 ns, SpanU8 T, SpanU8 dependencies, bool with_vector, bool with_span
|
||||
) {
|
||||
generate_util_templ_inst_guarded_header(layer, ns, T, dependencies, (util_templates_instantiation_options){
|
||||
.t_clonable = true, .vec = with_vector, .span = with_span, .collab_vec_span = with_vector && with_span
|
||||
});
|
||||
}
|
||||
|
||||
void generate_guarded_span_company_for_non_primitive_non_clonable(
|
||||
SpanU8 layer, SpanU8 ns, SpanU8 T, SpanU8 dependencies, bool with_vector, bool with_span
|
||||
) {
|
||||
generate_util_templ_inst_guarded_header(layer, ns, T, dependencies, (util_templates_instantiation_options){
|
||||
.vec = with_vector, .span = with_span, .collab_vec_span = with_vector && with_span
|
||||
});
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ VecU8 VecU8_from_cstr(const char* dc) {
|
||||
SpanU8 SpanU8_from_cstr(const char* dc) {
|
||||
return (SpanU8){.data = (const U8*)dc, .len = strlen(dc)};
|
||||
}
|
||||
#define cstr(dc) SpanU8_from_cstr(dc)
|
||||
#define cstr(dc) ((SpanU8){(const U8*)dc, sizeof(dc) - 1})
|
||||
|
||||
/* Not thread safe (for stdout) !*/
|
||||
void SpanU8_print(SpanU8 str) {
|
||||
@ -73,7 +73,7 @@ NODISCARD VecU8 VecU8_fmt(const char* fmt, ...) {
|
||||
SpanU8 s = va_arg(args, SpanU8);
|
||||
k += s.len;
|
||||
} else if (*ch == 'c') {
|
||||
int byte = va_arg(args, int);
|
||||
va_arg(args, int);
|
||||
k ++;
|
||||
} else
|
||||
abortf("Format syntax error at pos %lu! Watch out, be careful", (size_t)(ch - fmt));
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define PROTOTYPE1_SRC_CORE_INT_PRIMITIVES_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef uint8_t U8;
|
||||
typedef uint16_t U16;
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
#ifndef PROTOTYPE_1_SRC_L2_MARIE_GEOM_ALG_UTILS_H
|
||||
#define PROTOTYPE_1_SRC_L2_MARIE_GEOM_ALG_UTILS_H
|
||||
#ifndef PROTOTYPE_1_SRC_L1_MARIE_GEOM_ALG_UTILS_H
|
||||
#define PROTOTYPE_1_SRC_L1_MARIE_GEOM_ALG_UTILS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include "../../../gen/l2/geom.h"
|
||||
#include "../../l1/core/util.h"
|
||||
#include "../../../gen/l1/geom.h"
|
||||
#include "../core/util.h"
|
||||
|
||||
/* float size check and IEEE‑754 binary32 characteristic checks */
|
||||
_Static_assert(sizeof(float) == 4,
|
||||
@ -54,7 +54,7 @@ typedef struct {
|
||||
vec2 v2;
|
||||
} MarieTriangle;
|
||||
|
||||
#include "../../../gen/l2/eve/VecMarieTriangle.h"
|
||||
#include "../../../gen/l1/eve/marie/VecMarieTriangle.h"
|
||||
|
||||
typedef struct {
|
||||
MariePlaneVertAttr v0;
|
||||
@ -62,7 +62,7 @@ typedef struct {
|
||||
MariePlaneVertAttr v2;
|
||||
} MarieTriangleAttr;
|
||||
|
||||
#include "../../../gen/l2/eve/VecMarieTriangleAttr.h"
|
||||
#include "../../../gen/l1/eve/marie/VecMarieTriangleAttr.h"
|
||||
|
||||
vec2 marie_intersect_lines(vec2 A1, vec2 B1, vec2 A2, vec2 B2) {
|
||||
vec2 alpha = vec2_minus_vec2(B1, A1);
|
||||
@ -7,7 +7,7 @@
|
||||
#include "../core/util.h"
|
||||
|
||||
/* Aborts on error */
|
||||
void make_dir_nofail(const char* filename) {
|
||||
void mkdir_nofail(const char* filename) {
|
||||
int ret = mkdir(filename, S_IRWXU | S_IRGRP | S_IXGRP);
|
||||
if (ret < 0 && errno != EEXIST)
|
||||
abortf("Unable to create directory %s\n", filename);
|
||||
|
||||
37
src/l1/system/shared_memory.h
Normal file
37
src/l1/system/shared_memory.h
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef PROTOTYPE1_SRC_L1_SYSTEM_SHARED_MEMORY_H
|
||||
#define PROTOTYPE1_SRC_L1_SYSTEM_SHARED_MEMORY_H
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include "../core/util.h"
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
static int create_shm_file(){
|
||||
char name[] = "/prototype1-XXXXXXXXXXXX";
|
||||
U64 v = ((U64)rand() << 32) + (U64)rand();
|
||||
for (int i = 0; i < 12; i++) {
|
||||
name[sizeof(name) - 1 - 12 + i] = 'A' + (v&15) + (v&16)*2;
|
||||
v >>= 5;
|
||||
}
|
||||
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
if (fd < 0)
|
||||
abortf("shm_open(\"%s\")", name);
|
||||
if (shm_unlink(name) < 0)
|
||||
abortf("shm_unlink(\"%s\")", name);
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int allocate_shm_file(size_t size) {
|
||||
int fd = create_shm_file();
|
||||
int ret;
|
||||
do {
|
||||
ret = ftruncate(fd, size);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
if (ret < 0) {
|
||||
abortf("ftruncate(%ld)", size);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
#endif
|
||||
11
src/l1_5/anne/codegen.c
Normal file
11
src/l1_5/anne/codegen.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "../../l1/system/fsmanip.h"
|
||||
|
||||
#include "marie/clipping.h"
|
||||
|
||||
int main() {
|
||||
mkdir_nofail("l1_5");
|
||||
mkdir_nofail("l1_5/marie");
|
||||
generate_marie_clipping_header();
|
||||
finish_layer(cstr("l1_5"));
|
||||
return 0;
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_CODEGEN_CLIPPING_H
|
||||
#define PROTOTYPE1_SRC_L2_CODEGEN_CLIPPING_H
|
||||
#ifndef PROTOTYPE1_SRC_L1_CODEGEN_CLIPPING_H
|
||||
#define PROTOTYPE1_SRC_L1_CODEGEN_CLIPPING_H
|
||||
|
||||
#include "../../l1/codegen/codegen.h"
|
||||
#include "../../../gen/l1/VecAndSpan_Span_int_primitives.h"
|
||||
#include "../../../l1/codegen/codegen.h"
|
||||
#include "../../../../gen/l1/VecAndSpan_Span_int_primitives.h"
|
||||
|
||||
// todo: move all of this to marie namespace
|
||||
// todo: instead of returning triangles, return points of convex polygon
|
||||
@ -24,7 +24,7 @@ int comparison_triang_groups[18][3] = {
|
||||
{22, 20, 10}, {22, 20, 11}, {22, 20, 12},
|
||||
};
|
||||
|
||||
int permutations_of_sigma3(int ns[static 3]) {
|
||||
int permutations_of_sigma3(const int ns[static 3]) {
|
||||
return (ns[0] > ns[1]) + (ns[1] > ns[2]) + (ns[0] > ns[2]);
|
||||
}
|
||||
|
||||
@ -97,8 +97,8 @@ void append_intersection_eol_stmt(VecU8* str, char tr1, int A1, int B1, char tr2
|
||||
}
|
||||
|
||||
SpanU8 marie_names_of_two_clipping_triangles[6] = {
|
||||
{"C.v0", 4}, {"C.v1", 4}, {"C.v2", 4},
|
||||
{"T.v0", 4}, {"T.v1", 4}, {"T.v2", 4},
|
||||
cstr("C.v0"), cstr("C.v1"), cstr("C.v2"),
|
||||
cstr("T.v0"), cstr("T.v1"), cstr("T.v2"),
|
||||
};
|
||||
|
||||
NODISCARD SpanU8 get_firstborn_vertex_stmt(char tr, int id) {
|
||||
@ -123,7 +123,7 @@ void append_triangle_registration_stmt(VecU8* str, SpanU8 P0, SpanU8 P1, SpanU8
|
||||
void append_answering_stmt(VecU8* res, SpanSpanU8 vertices, int tabulation_lvl) {
|
||||
size_t n = vertices.len;
|
||||
assert(n >= 3);
|
||||
for (int i = 0; i < n - 2; i++) {
|
||||
for (size_t i = 0; i < n - 2; i++) {
|
||||
for (int sp = 0; sp < tabulation_lvl; sp++)
|
||||
VecU8_append(res, ' ');
|
||||
append_triangle_registration_stmt(res, *SpanSpanU8_at(vertices, i),
|
||||
@ -284,7 +284,7 @@ void generate_func_clip_triang_on_triang_case_where_some_vertex_stuck(VecU8* res
|
||||
if (!tables_turned) {
|
||||
/* Case where TA and TB are in different sectors and rc++ is inside tT
|
||||
* Result is a quadrangle */
|
||||
VecU8_append_span(res, cstr(SPACE12 " else {"));
|
||||
VecU8_append_span(res, cstr(" else {\n"));
|
||||
VecU8_append_span(res, cstr(SPACE16 "vec2 PA = "));
|
||||
append_intersection_eol_stmt(res, tT, pl, TA, tC, rc, mod3_inc(rc));
|
||||
VecU8_append_span(res, cstr(SPACE16 "vec2 PB = "));
|
||||
@ -408,12 +408,12 @@ NODISCARD VecU8 generate_func_clip_ccw_triang_with_ccw_triang_append_to_Vec() {
|
||||
return res;
|
||||
}
|
||||
|
||||
void generate_clipping_header() {
|
||||
VecU8 res = begin_header(cstr("PROTOTYPE1_GEN_L2_MARIE_CLIPPING"));
|
||||
VecU8_append_span(&res, cstr("#include \"../geom.h\"\n"
|
||||
"#include \"../../../src/l2/marie/geom_alg_utils.h\"\n\n"));
|
||||
VecU8_append_vec(&res, generate_func_clip_ccw_triang_with_ccw_triang_append_to_Vec());
|
||||
finish_header(res, "l2/marie/clipping.h");
|
||||
void generate_marie_clipping_header() {
|
||||
GeneratedHeader res = begin_header(cstr("l1_5/marie/clipping.h"));
|
||||
VecU8_append_span(&res.result, cstr("#include \"../../l1/geom.h\"\n"
|
||||
"#include \"../../../src/l1/marie/geom_alg_utils.h\"\n\n"));
|
||||
VecU8_append_vec(&res.result, generate_func_clip_ccw_triang_with_ccw_triang_append_to_Vec());
|
||||
finish_header(res);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_CORE_STRINGOP_H
|
||||
#define PROTOTYPE1_SRC_L2_CORE_STRINGOP_H
|
||||
#ifndef PROTOTYPE1_SRC_L1_5_CORE_STRINGOP_H
|
||||
#define PROTOTYPE1_SRC_L1_5_CORE_STRINGOP_H
|
||||
|
||||
#include "../../../gen/l1/VecAndSpan_int_primitives.h"
|
||||
#include "../../../gen/l1/VecAndSpan_Vec_int_primitives.h"
|
||||
@ -1,115 +0,0 @@
|
||||
#include "geom.h"
|
||||
#include "pixel_masses.h"
|
||||
#include "clipping.h"
|
||||
#include "../../l1/system/fsmanip.h"
|
||||
#include "../../l1/codegen/util_template_inst.h"
|
||||
|
||||
void eve_of_l2() {
|
||||
make_dir_nofail("l2/eve");
|
||||
make_dir_nofail("l2/eve/r0");
|
||||
/* Needed in r0_assets.h */
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("GenericMeshVertex"), true, true);
|
||||
generate_eve_span_garden_for_non_primitive_clonable(cstr("l2"), cstr("r0"), cstr("GenericMeshInSceneTemplate"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("GenericMeshInstance"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("ShinyMeshVertex"), true, true);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("ShinyMeshInstance"), true, false);
|
||||
generate_eve_span_garden_for_non_primitive_clonable(cstr("l2"), cstr("r0"), cstr("ShinyMeshInSceneTemplate"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("Pipeline0Spotlight"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("Pipeline0PointLight"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("Wimbzle"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr("r0"), cstr("Nibzle"), true, false);
|
||||
/* Needed in graphics_geom.h */
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("MarieTriangle"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("MarieTriangleAttr"), true, false);
|
||||
/* Needed in r0_scene.h */
|
||||
generate_eve_span_garden_for_non_primitive_non_clonable(cstr("l2"), cstr("r0"), cstr("UsedGenericModelOnScene"), true, false);
|
||||
generate_eve_span_garden_for_non_primitive_non_clonable(cstr("l2"), cstr("r0"), cstr("UsedShinyModelOnScene"), true, false);
|
||||
/* Needed in margaret/vulkan.h */
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("CSTR"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkQueueFamilyProperties"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkExtensionProperties"), true, false);
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("VkSurfaceFormatKHR"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .option = true });
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("VkPresentModeKHR"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .option = true });
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("VkCompositeAlphaFlagBitsKHR"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .option = true });
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("VkExtent2D"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .option = true });
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("VkFormat"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .span = true, .option = true });
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("MargaretScoredPhysicalDevice"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .span = true,
|
||||
.mut_span = true, .collab_vec_span = true, .span_sort = true});
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkPhysicalDevice"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkImage"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkImageView"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkFramebuffer"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkSemaphore"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("MargaretBufferInMemoryInfo"), true, false);
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("PtrMargaretBufferInMemoryInfo"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .span = true, .mut_span = true,
|
||||
.collab_vec_span = true});
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("MargaretImageInMemoryInfo"), true, false);
|
||||
generate_eve_header(cstr("l2"), cstr(""), cstr("PtrMargaretImageInMemoryInfo"),
|
||||
(util_templates_instantiation_options){ .t_primitive = true, .vec = true, .span = true, .mut_span = true,
|
||||
.collab_vec_span = true});
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkDescriptorPoolSize"), true, false);
|
||||
generate_eve_span_garden_for_primitive(cstr("l2"), cstr(""), cstr("VkBufferCopy"), true, false);
|
||||
// todo: move vectors of vulkan handlers to some other place, away from margaret header
|
||||
/* Needed in r0.c */
|
||||
make_dir_nofail("l2/eve/r2");
|
||||
/* Needed in r2 */
|
||||
generate_eve_header(cstr("l2"), cstr("r2"), cstr("BoxLizaSound"),
|
||||
(util_templates_instantiation_options){ .vec = true});
|
||||
generate_eve_header(cstr("l2"), cstr("r2"), cstr("PlayingSound"),
|
||||
(util_templates_instantiation_options){.vec_extended = true});
|
||||
generate_eve_header(cstr("l2"), cstr("r2"), cstr("BoxLizaInstrument"),
|
||||
(util_templates_instantiation_options){ .vec = true});
|
||||
generate_eve_header(cstr("l2"), cstr("r2"), cstr("MyInstrument"),
|
||||
(util_templates_instantiation_options){ .vec = true});
|
||||
}
|
||||
|
||||
void generate_Vec_cvec_header() {
|
||||
VecU8 res = begin_header(cstr("PROTOTYPE1_GEN_L2_VECANDSPAN_GEOM_CVEC_H"));
|
||||
VecU8_append_span(&res, cstr("#include \"geom.h\"\n"));
|
||||
VecU8_append_span(&res, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[] = {cstr("cvec3"), cstr("cvec4")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&res, generate_util_templates_instantiation(T[i],
|
||||
(util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = true, .span = true, .collab_vec_span = true,
|
||||
}));
|
||||
}
|
||||
finish_header(res, "l2/VecAndSpan_cvec.h");
|
||||
}
|
||||
|
||||
void generate_Vec_vec_header() {
|
||||
VecU8 res = begin_header(cstr("PROTOTYPE1_GEN_L2_VECANDSPAN_GEOM_VEC_H"));
|
||||
VecU8_append_span(&res, cstr("#include \"geom.h\"\n"));
|
||||
VecU8_append_span(&res, cstr("#include \"../../src/l1/core/util.h\"\n\n"));
|
||||
SpanU8 T[] = {cstr("vec2"), cstr("vec3"), cstr("vec4")};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(T); i++) {
|
||||
VecU8_append_vec(&res, generate_util_templates_instantiation(T[i],
|
||||
(util_templates_instantiation_options){
|
||||
.t_primitive = true, .vec = true, .span = true, .collab_vec_span = true,
|
||||
}));
|
||||
}
|
||||
finish_header(res, "l2/VecAndSpan_vec.h");
|
||||
}
|
||||
|
||||
int main() {
|
||||
make_dir_nofail("l2");
|
||||
/* These headers are unordered by their nature */
|
||||
eve_of_l2();
|
||||
|
||||
generate_geom_header();
|
||||
|
||||
generate_Vec_cvec_header();
|
||||
generate_Vec_vec_header();
|
||||
|
||||
generate_pixel_masses_header();
|
||||
make_dir_nofail("l2/marie");
|
||||
generate_clipping_header();
|
||||
return 0;
|
||||
}
|
||||
38
src/l2/liza/instrument.h
Normal file
38
src/l2/liza/instrument.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_LIZA_INSTRUMENT_H
|
||||
#define PROTOTYPE1_SRC_L2_LIZA_INSTRUMENT_H
|
||||
|
||||
#include "playing_sound_loop.h"
|
||||
|
||||
// todo: rewrite with the help of l1_5
|
||||
|
||||
typedef struct {
|
||||
/* self (takes ownership) */
|
||||
void (*drop)(void*);
|
||||
/* self, frequency, time, returns: new sound box */
|
||||
BoxLizaSound (*ding)(const void*, double, double);
|
||||
// todo: request options for instrument
|
||||
} LizaInstrument_Table;
|
||||
|
||||
typedef struct {
|
||||
const void* r;
|
||||
const LizaInstrument_Table* t;
|
||||
} RefLizaInstrument;
|
||||
|
||||
typedef struct {
|
||||
void* r;
|
||||
const LizaInstrument_Table* t;
|
||||
} MutLizaInstrument;
|
||||
|
||||
typedef struct {
|
||||
void* m;
|
||||
const LizaInstrument_Table* t;
|
||||
} BoxLizaInstrument;
|
||||
|
||||
void BoxLizaInstrument_drop(BoxLizaInstrument self) {
|
||||
self.t->drop(self.m);
|
||||
}
|
||||
|
||||
#include "../../../gen/l1/eve/liza/VecBoxLizaInstrument.h"
|
||||
|
||||
|
||||
#endif
|
||||
41
src/l2/liza/playing_sound_loop.h
Normal file
41
src/l2/liza/playing_sound_loop.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_LIZA_PLAYING_SOUND_LOOP_H
|
||||
#define PROTOTYPE1_SRC_L2_LIZA_PLAYING_SOUND_LOOP_H
|
||||
|
||||
// todo: move loop here and rewrite with l1_5 help
|
||||
|
||||
#include "../../l1/core/int_primitives.h"
|
||||
|
||||
typedef struct {
|
||||
/* self (takes ownership) */
|
||||
void (*drop)(void*);
|
||||
/* self, returns: pcm value */
|
||||
double (*next)(void*);
|
||||
/* self, returns: duration in frames */
|
||||
size_t (*get_duration)(const void*);
|
||||
} LizaSound_Table;
|
||||
|
||||
typedef struct {
|
||||
const void* r;
|
||||
const LizaSound_Table* t;
|
||||
} RefLizaSound;
|
||||
|
||||
typedef struct {
|
||||
void* r;
|
||||
const LizaSound_Table* t;
|
||||
} MutRefLizaSound;
|
||||
|
||||
/* Existence of Box<Trait> type implies that _drop method is virtual according to this trait */
|
||||
typedef struct {
|
||||
void* m; /* Owns memory block r and object in it */
|
||||
const LizaSound_Table* t;
|
||||
} BoxLizaSound;
|
||||
|
||||
void BoxLizaSound_drop(BoxLizaSound self) {
|
||||
self.t->drop(self.m);
|
||||
free(self.m);
|
||||
}
|
||||
|
||||
#include "../../../gen/l1/eve/liza/VecBoxLizaSound.h"
|
||||
|
||||
|
||||
#endif
|
||||
@ -2,6 +2,7 @@
|
||||
#define PROTOTYPE1_SRC_L2_MARGARET_TIME_H
|
||||
|
||||
#include <time.h>
|
||||
#include "../../l1/core/util.h"
|
||||
|
||||
typedef struct timespec margaret_ns_time;
|
||||
|
||||
@ -3,13 +3,29 @@
|
||||
|
||||
#include "../../../gen/l1/Option_int_primitives.h"
|
||||
#include "../../../gen/l1/VecAndSpan_Vec_int_primitives.h"
|
||||
#include <vulkan/vulkan.h>
|
||||
#include <vulkan/vulkan_wayland.h>
|
||||
#include "../core/stringop.h"
|
||||
#include "../../l1_5/core/stringop.h"
|
||||
#include "../../l1/system/fileio.h"
|
||||
#include "time.h"
|
||||
#include "time_utils.h"
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "../../../gen/l1/vulkan/VecVkFramebuffer.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkImage.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkSemaphore.h"
|
||||
#include "../../../gen/l1/vulkan/OptionVkExtent2D.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkBufferCopy.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkExtensionProperties.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkImageView.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkPhysicalDevice.h"
|
||||
#include "../../../gen/l1/vulkan/SpanAndOption_VkFormat.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkDescriptorPoolSize.h"
|
||||
#include "../../../gen/l1/vulkan/VecVkQueueFamilyProperties.h"
|
||||
#include "../../../gen/l1/vulkan/OptionVkCompositeAlphaFlagBitsKHR.h"
|
||||
#include "../../../gen/l1/vulkan/VecAndOption_VkPresentModeKHR.h"
|
||||
#include "../../../gen/l1/vulkan/VecAndOption_VkSurfaceFormatKHR.h"
|
||||
#include <vulkan/vulkan_wayland.h>
|
||||
|
||||
|
||||
|
||||
|
||||
void margaret_create_debug_utils_messenger_EXT(
|
||||
VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
|
||||
@ -44,7 +60,7 @@ static VKAPI_ATTR VkBool32 VKAPI_CALL margaret_static_debug_callback(
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
#include "../../../gen/l2/eve/VecCSTR.h"
|
||||
#include "../../../gen/l1/VecCSTR.h"
|
||||
|
||||
typedef struct {
|
||||
VkInstance instance;
|
||||
@ -130,8 +146,6 @@ typedef struct {
|
||||
U32 for_presentation;
|
||||
} MargaretChosenQueueFamilies;
|
||||
|
||||
#include "../../../gen/l2/eve/VecVkQueueFamilyProperties.h"
|
||||
|
||||
/* MargaretChosenQueueFamilies or a static string, describing which part could not be found
|
||||
* (may replace with VecU8 later) */
|
||||
typedef struct {
|
||||
@ -172,8 +186,6 @@ ResultMargaretChosenQueueFamiliesOrSpanU8 margaret_choose_good_queue_families(Vk
|
||||
} };
|
||||
}
|
||||
|
||||
#include "../../../gen/l2/eve/VecVkExtensionProperties.h"
|
||||
|
||||
// These are not the same as instance extensions
|
||||
VecVecU8 margaret_get_extensions_of_physical_device(VkPhysicalDevice physical_device) {
|
||||
uint32_t extensions_count = 0;
|
||||
@ -315,11 +327,6 @@ VkDevice margaret_create_logical_device(VkPhysicalDevice physical_device, Margar
|
||||
return device;
|
||||
}
|
||||
|
||||
#include "../../../gen/l2/eve/OptionVkExtent2D.h"
|
||||
#include "../../../gen/l2/eve/VecAndOption_VkSurfaceFormatKHR.h"
|
||||
#include "../../../gen/l2/eve/VecAndOption_VkPresentModeKHR.h"
|
||||
#include "../../../gen/l2/eve/OptionVkCompositeAlphaFlagBitsKHR.h"
|
||||
|
||||
/* These variables are in some way enforced by VkSurfaceCapabilitiesKHR (but not completely determined) */
|
||||
typedef struct {
|
||||
VkSurfaceFormatKHR surface_format;
|
||||
@ -446,8 +453,6 @@ ResultMargaretChosenSwapchainDetailsOrSpanU8 margaret_choose_swapchain_details(
|
||||
};
|
||||
}
|
||||
|
||||
#include "../../../gen/l2/eve/SpanAndOption_VkFormat.h"
|
||||
|
||||
OptionVkFormat margaret_find_supported_format_for_linear_tiling(
|
||||
VkPhysicalDevice physical_device, SpanVkFormat candidates, VkFormatFeatureFlags required_features
|
||||
) {
|
||||
@ -569,8 +574,7 @@ MargaretScoredPhysicalDevice margaret_score_physical_device(
|
||||
|
||||
#define MargaretScoredPhysicalDevice_less_MargaretScoredPhysicalDevice(cap, cbp) ((cap)->score < (cbp)->score)
|
||||
|
||||
#include "../../../gen/l2/eve/VecAndSpan_MargaretScoredPhysicalDevice.h"
|
||||
#include "../../../gen/l2/eve/VecVkPhysicalDevice.h"
|
||||
#include "../../../gen/l1/eve/margaret/VecAndSpan_MargaretScoredPhysicalDevice.h"
|
||||
|
||||
VecMargaretScoredPhysicalDevice margaret_get_physical_devices_scored(
|
||||
VkInstance instance, VkSurfaceKHR surface,
|
||||
@ -662,11 +666,6 @@ VkSwapchainKHR margaret_create_swapchain (
|
||||
return swapchain;
|
||||
}
|
||||
|
||||
#include "../../../gen/l2/eve/VecVkImage.h"
|
||||
#include "../../../gen/l2/eve/VecVkImageView.h"
|
||||
#include "../../../gen/l2/eve/VecVkFramebuffer.h"
|
||||
#include "../../../gen/l2/eve/VecVkSemaphore.h"
|
||||
|
||||
VecVkImageView margaret_create_swapchain_image_views(
|
||||
VkDevice device, VkSwapchainKHR swapchain,
|
||||
VkFormat image_format
|
||||
@ -910,10 +909,10 @@ typedef struct {
|
||||
|
||||
typedef MargaretImageInMemoryInfo* PtrMargaretImageInMemoryInfo;
|
||||
|
||||
#include "../../../gen/l2/eve/VecMargaretBufferInMemoryInfo.h"
|
||||
#include "../../../gen/l2/eve/VecAndSpan_PtrMargaretBufferInMemoryInfo.h"
|
||||
#include "../../../gen/l2/eve/VecMargaretImageInMemoryInfo.h"
|
||||
#include "../../../gen/l2/eve/VecAndSpan_PtrMargaretImageInMemoryInfo.h"
|
||||
#include "../../../gen/l1/eve/margaret/VecMargaretBufferInMemoryInfo.h"
|
||||
#include "../../../gen/l1/eve/margaret/VecAndSpan_PtrMargaretBufferInMemoryInfo.h"
|
||||
#include "../../../gen/l1/eve/margaret/VecMargaretImageInMemoryInfo.h"
|
||||
#include "../../../gen/l1/eve/margaret/VecAndSpan_PtrMargaretImageInMemoryInfo.h"
|
||||
|
||||
// A handy function to initialize buffers and images (attaching them to allocated memory)
|
||||
VkDeviceMemory margaret_initialize_buffers_and_images(
|
||||
@ -1244,8 +1243,6 @@ VkSampler margaret_create_sampler(VkPhysicalDevice physical_device, VkDevice dev
|
||||
return sampler;
|
||||
}
|
||||
|
||||
#include "../../../gen/l2/eve/VecVkDescriptorPoolSize.h"
|
||||
|
||||
VkDescriptorPool margaret_create_descriptor_set_pool(VkDevice device,
|
||||
uint32_t ubo_descriptor_count, uint32_t image_sampler_descriptor_count, uint32_t max_sets
|
||||
) {
|
||||
@ -1286,6 +1283,4 @@ VkDescriptorSet margaret_allocate_descriptor_set(VkDevice device, VkDescriptorPo
|
||||
return descriptor_set;
|
||||
}
|
||||
|
||||
#include "../../../gen/l2/eve/VecVkBufferCopy.h"
|
||||
|
||||
#endif
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_MARIE_GRAPHICS_GEOM_H
|
||||
#define PROTOTYPE1_SRC_L2_MARIE_GRAPHICS_GEOM_H
|
||||
|
||||
#include "../../../gen/l2/geom.h"
|
||||
#include "../../../gen/l1/geom.h"
|
||||
#include "math.h"
|
||||
|
||||
mat4 marie_translation_mat4(vec3 vec) {
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
#ifndef SPLITTER_DRAFT_SRC_L2_MARIE_RASTERIZATION_H
|
||||
#define SPLITTER_DRAFT_SRC_L2_MARIE_RASTERIZATION_H
|
||||
|
||||
#include "../../../gen/l2/geom.h"
|
||||
#include "../../../gen/l2/pixel_masses.h"
|
||||
#include "geom_alg_utils.h"
|
||||
#include "../../../gen/l1/geom.h"
|
||||
#include "../../l1/marie/geom_alg_utils.h"
|
||||
|
||||
typedef struct {
|
||||
/* guest, x, y, attribute (custom) */
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_MARIE_SHAPE_GEOM_H
|
||||
#define PROTOTYPE1_SRC_L2_MARIE_SHAPE_GEOM_H
|
||||
|
||||
#include "../../../gen/l2/marie/clipping.h"
|
||||
#include "../../../gen/l1_5/marie/clipping.h"
|
||||
|
||||
void marie_clip_triang_with_triang_append_to_Vec(MarieTriangle C, MarieTriangle T, VecMarieTriangle* pile) {
|
||||
float SC = marie_surface(C.v0, C.v1, C.v2);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include "../../margaret/vulkan.h"
|
||||
#include "../../../../gen/l2/geom.h"
|
||||
#include "../../margaret/vulkan_utils.h"
|
||||
#include "../../../../gen/l1/geom.h"
|
||||
#include <math.h>
|
||||
#include <sys/mman.h>
|
||||
#include "../../../l1/system/fileio.h"
|
||||
@ -1635,9 +1635,9 @@ void calling_system_func(const char* command) {
|
||||
}
|
||||
|
||||
void compile_shader_dir(SpanU8 name) {
|
||||
make_dir_nofail("shaders/spv");
|
||||
mkdir_nofail("shaders/spv");
|
||||
VecU8 spv_shader_dir_name = VecU8_fmt("shaders/spv/%s%c", name, 0);
|
||||
make_dir_nofail((CSTR)spv_shader_dir_name.buf);
|
||||
mkdir_nofail((CSTR)spv_shader_dir_name.buf);
|
||||
VecU8_drop(spv_shader_dir_name);
|
||||
VecU8 vert_cmd = VecU8_fmt("glslc -o shaders/spv/%s/vert.spv shaders/glsl/%s/%s.vert%c", name, name, name, 0);
|
||||
calling_system_func((CSTR)vert_cmd.buf);
|
||||
|
||||
@ -5,15 +5,15 @@
|
||||
#include "../../../../gen/l1/VecAndSpan_int_primitives.h"
|
||||
#include "../../../l1/system/fileio.h"
|
||||
#include <math.h>
|
||||
#include "../../../../gen/l2/VecAndSpan_vec.h"
|
||||
#include "../../../../gen/l2/pixel_masses.h"
|
||||
#include "../../../../gen/l1/VecAndSpan_vec.h"
|
||||
#include "../../../../gen/l1/pixel_masses.h"
|
||||
#include "../../marie/rasterization.h"
|
||||
|
||||
typedef struct {
|
||||
vec3 pos;
|
||||
vec2 tex;
|
||||
} GenericMeshVertex;
|
||||
#include "../../../../gen/l2/eve/r0/VecAndSpan_GenericMeshVertex.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecAndSpan_GenericMeshVertex.h"
|
||||
|
||||
typedef struct {
|
||||
VecGenericMeshVertex vertices;
|
||||
@ -42,12 +42,12 @@ GenericMeshInSceneTemplate GenericMeshInSceneTemplate_clone(const GenericMeshInS
|
||||
return (GenericMeshInSceneTemplate){.topology = GenericMeshTopology_clone(&self->topology), .max_instance_count = self->max_instance_count};
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r0/VecGenericMeshInSceneTemplate.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecGenericMeshInSceneTemplate.h"
|
||||
|
||||
typedef struct {
|
||||
mat4 model_t;
|
||||
} GenericMeshInstance;
|
||||
#include "../../../../gen/l2/eve/r0/VecGenericMeshInstance.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecGenericMeshInstance.h"
|
||||
|
||||
|
||||
|
||||
@ -55,7 +55,7 @@ typedef struct {
|
||||
vec3 pos;
|
||||
vec3 normal;
|
||||
} ShinyMeshVertex;
|
||||
#include "../../../../gen/l2/eve/r0/VecAndSpan_ShinyMeshVertex.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecAndSpan_ShinyMeshVertex.h"
|
||||
|
||||
typedef struct {
|
||||
VecShinyMeshVertex vertices;
|
||||
@ -85,14 +85,14 @@ ShinyMeshInSceneTemplate ShinyMeshInSceneTemplate_clone(const ShinyMeshInSceneTe
|
||||
.max_instance_count = self->max_instance_count};
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r0/VecShinyMeshInSceneTemplate.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecShinyMeshInSceneTemplate.h"
|
||||
|
||||
typedef struct {
|
||||
mat4 model_t;
|
||||
vec3 color_off;
|
||||
vec3 color_on;
|
||||
} ShinyMeshInstance;
|
||||
#include "../../../../gen/l2/eve/r0/VecShinyMeshInstance.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecShinyMeshInstance.h"
|
||||
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ typedef struct {
|
||||
float d;
|
||||
char _padding_3[12];
|
||||
} Pipeline0Spotlight;
|
||||
#include "../../../../gen/l2/eve/r0/VecPipeline0Spotlight.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecPipeline0Spotlight.h"
|
||||
|
||||
typedef struct {
|
||||
vec3 pos;
|
||||
@ -125,7 +125,7 @@ typedef struct {
|
||||
vec3 color;
|
||||
char _padding_1[4];
|
||||
} Pipeline0PointLight;
|
||||
#include "../../../../gen/l2/eve/r0/VecPipeline0PointLight.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecPipeline0PointLight.h"
|
||||
|
||||
typedef struct {
|
||||
VecGenericMeshInSceneTemplate generic_models;
|
||||
@ -347,7 +347,7 @@ typedef struct {
|
||||
float brd;
|
||||
} Wimbzle;
|
||||
|
||||
#include "../../../../gen/l2/eve/r0/VecWimbzle.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecWimbzle.h"
|
||||
|
||||
typedef struct {
|
||||
vec2 center;
|
||||
@ -355,7 +355,7 @@ typedef struct {
|
||||
float hc;
|
||||
} Nibzle;
|
||||
|
||||
#include "../../../../gen/l2/eve/r0/VecNibzle.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecNibzle.h"
|
||||
|
||||
typedef struct {
|
||||
VecWimbzle wimbzles;
|
||||
@ -524,7 +524,7 @@ typedef struct {
|
||||
cvec3 normal_compr;
|
||||
} draw_polygon_on_normal_texture_absolutely_flat_H_DrawGuest;
|
||||
|
||||
void draw_polygon_on_normal_texture_absolutely_flat_h_draw_cb(void* ug, S32 x, S32 y, vec4) {
|
||||
void draw_polygon_on_normal_texture_absolutely_flat_h_draw_cb(void* ug, S32 x, S32 y, vec4 attr) {
|
||||
draw_polygon_on_normal_texture_absolutely_flat_H_DrawGuest* g = ug;
|
||||
*TextureDataR8G8B8_mat(g->tex, x, y) = g->normal_compr;
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ void UsedGenericModelOnScene_drop(UsedGenericModelOnScene self) {
|
||||
VecGenericMeshInstance_drop(self.instances);
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r0/VecUsedGenericModelOnScene.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecUsedGenericModelOnScene.h"
|
||||
|
||||
typedef struct {
|
||||
ModelOnSceneMem model;
|
||||
@ -36,7 +36,7 @@ void UsedShinyModelOnScene_drop(UsedShinyModelOnScene self) {
|
||||
VecShinyMeshInstance_drop(self.instances);
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r0/VecUsedShinyModelOnScene.h"
|
||||
#include "../../../../gen/l1/eve/r0/VecUsedShinyModelOnScene.h"
|
||||
|
||||
typedef struct {
|
||||
float fov;
|
||||
|
||||
@ -1,14 +1,11 @@
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <wayland-client.h>
|
||||
#include "../../../../gen/l_wl_protocols/xdg-shell-client.h"
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
|
||||
#include "../../../l1/core/util.h"
|
||||
#include "../../../l1/system/shared_memory.h"
|
||||
#include "../../marie/graphics_geom.h"
|
||||
#include "../../marie/rasterization.h"
|
||||
|
||||
@ -20,32 +17,6 @@
|
||||
|
||||
_Static_assert(INT32_MAX / MAX_BUFFER_WIDTH / MAX_BUFFER_HEIGHT / 4 / SWAPCHAIN_SLOTS > 1, "Swapchain is too big");
|
||||
|
||||
static int create_shm_file(){
|
||||
char name[] = "/prototype1-XXXXXXXXXXXX";
|
||||
U64 v = ((U64)rand() << 32) + (U64)rand();
|
||||
for (int i = 0; i < 12; i++) {
|
||||
name[sizeof(name) - 1 - 12 + i] = 'A' + (v&15) + (v&16)*2;
|
||||
v >>= 5;
|
||||
}
|
||||
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
if (fd < 0)
|
||||
abortf("shm_open(\"%s\")", name);
|
||||
if (shm_unlink(name) < 0)
|
||||
abortf("shm_unlink(\"%s\")", name);
|
||||
return fd;
|
||||
}
|
||||
|
||||
static int allocate_shm_file(size_t size) {
|
||||
int fd = create_shm_file();
|
||||
int ret;
|
||||
do {
|
||||
ret = ftruncate(fd, size);
|
||||
} while (ret < 0 && errno == EINTR);
|
||||
if (ret < 0) {
|
||||
abortf("ftruncate(%ld)", size);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
int fd;
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_TESTS_R2_LIZA_H
|
||||
#define PROTOTYPE1_SRC_L2_TESTS_R2_LIZA_H
|
||||
|
||||
typedef struct {
|
||||
/* self (takes ownership) */
|
||||
void (*drop)(void*);
|
||||
/* self, returns: pcm value */
|
||||
double (*next)(void*);
|
||||
/* self, returns: duration in frames */
|
||||
size_t (*get_duration)(const void*);
|
||||
} LizaSound_Table;
|
||||
|
||||
typedef struct {
|
||||
const void* r;
|
||||
const LizaSound_Table* t;
|
||||
} RefLizaSound;
|
||||
|
||||
typedef struct {
|
||||
void* r;
|
||||
const LizaSound_Table* t;
|
||||
} MutRefLizaSound;
|
||||
|
||||
/* Existence of Box<Trait> type implies that _drop method is virtual according to this trait */
|
||||
typedef struct {
|
||||
void* m; /* Owns memory block r and object in it */
|
||||
const LizaSound_Table* t;
|
||||
} BoxLizaSound;
|
||||
|
||||
void BoxLizaSound_drop(BoxLizaSound self) {
|
||||
self.t->drop(self.m);
|
||||
free(self.m);
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r2/VecBoxLizaSound.h"
|
||||
|
||||
typedef struct {
|
||||
/* self (takes ownership) */
|
||||
void (*drop)(void*);
|
||||
/* self, frequency, time, returns: new sound box */
|
||||
BoxLizaSound (*ding)(const void*, double, double);
|
||||
// todo: request options for instrument
|
||||
} LizaInstrument_Table;
|
||||
|
||||
typedef struct {
|
||||
const void* r;
|
||||
const LizaInstrument_Table* t;
|
||||
} RefLizaInstrument;
|
||||
|
||||
typedef struct {
|
||||
void* r;
|
||||
const LizaInstrument_Table* t;
|
||||
} MutLizaInstrument;
|
||||
|
||||
typedef struct {
|
||||
void* m;
|
||||
const LizaInstrument_Table* t;
|
||||
} BoxLizaInstrument;
|
||||
|
||||
void BoxLizaInstrument_drop(BoxLizaInstrument self) {
|
||||
self.t->drop(self.m);
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r2/VecBoxLizaInstrument.h"
|
||||
|
||||
#endif
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef PROTOTYPE1_SRC_L2_TESTS_R2_LIZA_COLLECTION_H
|
||||
#define PROTOTYPE1_SRC_L2_TESTS_R2_LIZA_COLLECTION_H
|
||||
|
||||
#include "liza.h"
|
||||
#include "../../liza/instrument.h"
|
||||
|
||||
// todo: dfasjshfdasfkjld
|
||||
// double get_decay_factor(double planned_decay_time, double passes_per_second) {
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "../../../l1/system/pthread.h"
|
||||
#include "../../margaret/time.h"
|
||||
#include "../../margaret/time_utils.h"
|
||||
#include "../../marie/graphics_geom.h"
|
||||
#include "../../marie/rasterization.h"
|
||||
|
||||
@ -46,7 +46,7 @@ void PlayingSound_drop(PlayingSound self) {
|
||||
BoxLizaSound_drop(self.gen);
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r2/PlayingSound.h"
|
||||
#include "../../../../gen/l1/eve/r2/VecPlayingSound.h"
|
||||
|
||||
double fix_loud_sound(double a) {
|
||||
const double L = 0.5;
|
||||
@ -260,7 +260,7 @@ void MyInstrument_drop(MyInstrument self) {
|
||||
BoxLizaInstrument_drop(self.liza);
|
||||
}
|
||||
|
||||
#include "../../../../gen/l2/eve/r2/VecMyInstrument.h"
|
||||
#include "../../../../gen/l1/eve/liza/VecMyInstrument.h"
|
||||
|
||||
typedef struct {
|
||||
/* Globals */
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include "../../../l1/system/pthread.h"
|
||||
#include "../../margaret/time.h"
|
||||
#include "../../margaret/time_utils.h"
|
||||
|
||||
#define DEFAULT_RATE 44100
|
||||
#define DEFAULT_CHANNELS 2
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
#include "../../../../gen/l_wl_protocols/xdg-shell-client.h"
|
||||
#include <xkbcommon/xkbcommon.h>
|
||||
#include "../../../l1/core/util.h"
|
||||
#include "../../margaret/vulkan.h"
|
||||
#include "../../margaret/vulkan_utils.h"
|
||||
#include <poll.h>
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user