From e5b5807c6d4fd1d6750b304e415ee65542d2bdfe Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 15 Mar 2025 21:22:36 +1100 Subject: [PATCH] rendering refactor, dxvk started, script updated --- .gitignore | 1 + build.sh | 24 +- src/entry_linux.c | 8 +- src/entry_linux.h | 2 - src/entry_windows.c | 8 +- src/file_data/spv.c | 461 +++++++++++++++++++++++++++ src/game.c | 71 ++++- src/game.h | 4 +- src/platform_linux.c | 26 +- src/platform_linux.h | 1 + src/render.c | 31 +- src/render.h | 93 +++++- src/render_d3d11.c | 40 +++ src/render_d3d11.h | 13 + src/render_vulkan.c | 525 ++++++++++++++++++++++++++----- src/render_vulkan.h | 85 +++-- src/shaders/glsl/gui.frag.glsl | 15 + src/shaders/glsl/gui.vert.glsl | 36 +++ src/shaders/glsl/structures.glsl | 54 ++-- src/shared_types.h | 109 +++++-- src/util.c | 80 +++-- src/util.h | 47 +-- src/vulkan_config.c | 26 ++ 23 files changed, 1441 insertions(+), 319 deletions(-) create mode 100644 src/render_d3d11.c create mode 100644 src/render_d3d11.h create mode 100644 src/shaders/glsl/gui.frag.glsl create mode 100644 src/shaders/glsl/gui.vert.glsl diff --git a/.gitignore b/.gitignore index 567609b..28757d3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ build/ +external/dxvk diff --git a/build.sh b/build.sh index 1b509c6..aa05932 100755 --- a/build.sh +++ b/build.sh @@ -8,20 +8,20 @@ if [ -v debug ]; then echo "[debug mode]"; fi if [ -v release ]; then echo "[release mode]"; fi if [ -v gcc ]; then compiler="${CC:-gcc}"; cpp_compiler="g++"; echo "[gcc compiler]"; fi if [ -v clang ]; then compiler="${CC:-clang}"; cpp_compiler="clang++"; echo "[clang compiler]"; fi -if [ -v vulkan ]; then render_flag="-DSTG_VULKAN_RENDERER"; echo "[vulkan renderer]"; fi +if [ ! -v vulkan ] && [ ! -v dx11 ]; then vulkan=1; fi +if [ -v vulkan ]; then render_flag="-DSTG_VULKAN_RENDERER"; fi +if [ -v vulkan ]; then render_link="-lvulkan -l:libvma.a"; echo "[vulkan renderer]"; fi if [ -v opengl ] && [ ! -v render_flag ]; then render_flag="-DSTG_OPENGL_RENDERER"; echo "[opengl renderer]"; fi if [ -v webgl ] && [ ! -v render_flag ]; then render_flag="-DSTG_WEBGL_RENDERER"; echo "[webgl renderer]"; fi if [ -v dx11 ] && [ ! -v render_flag ]; then render_flag="-DSTG_DX11_RENDERER"; echo "[dx11 renderer]"; fi +if [ -v dx11 ]; then render_link="-l:libdxvk_d3d11.so.0"; fi if [ ! -v render_flag ]; then render_flag="-DSTG_VULKAN_RENDERER"; vulkan="vulkan"; echo "[default renderer - vulkan]"; fi -# for command line build args -auto_compile_flags="${render_flag}" - # source files source_files="../src/entry_linux.c" # includes -include_flags="-I../src/ -I../external/ -L." +include_flags="-I../src/ -I../external/ -L. -I../external/dxvk/include/ -L../external/dxvk/lib/" # executable name out_name="Gears" @@ -44,16 +44,16 @@ glsl_stage_comp="-fshader-stage=comp" glsl_out="-o./shaders/glsl/" -clang_common="${include_flags} -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis" -clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common} ${auto_compile_flags}" -clang_release="$compiler -O2 ${clang_common} ${auto_compile_flags}" +clang_common="${include_flags} ${render_flag} -g -Xclang -flto-visibility-public-std -Wno-unknown-warning-option -fdiagnostics-absolute-paths -Wall -Wno-missing-braces -Wno-unused-function -Wno-writable-strings -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-register -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-single-bit-bitfield-constant-conversion -Wno-compare-distinct-pointer-types -Wno-initializer-overrides -Wno-incompatible-pointer-types-discards-qualifiers -Wno-for-loop-analysis -DVMA_STATIC_VULKAN_FUNCTIONS=0" +clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common}" +clang_release="$compiler -g -O2 ${clang_common}" clang_link="-lpthread -lm -lrt -ldl -l:libvma.a" clang_out="-o" -gcc_common="${include_flags} -std=c99 -fuse-ld=mold -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf" -gcc_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common} ${auto_compile_flags}" -gcc_release="$compiler -O2 ${gcc_common} ${auto_compile_flags}" -gcc_link="-lpthread -lm -lrt -ldl -l:libvma.a -lstdc++" +gcc_common="${include_flags} ${render_flag} -std=c99 -fuse-ld=mold -g -Wno-unknown-warning-option -Wall -Wno-missing-braces -Wno-unused-function -Wno-attributes -Wno-unused-value -Wno-unused-variable -Wno-unused-local-typedef -Wno-deprecated-declarations -Wno-unused-but-set-variable -Wno-compare-distinct-pointer-types -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf -DVMA_STATIC_VULKAN_FUNCTIONS=0" +gcc_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common}" +gcc_release="$compiler -g -O2 ${gcc_common} ${render_flag}" +gcc_link="-lpthread -lm -lrt -ldl ${render_link} -lstdc++" gcc_out="-o" link_dll="-fPIC" diff --git a/src/entry_linux.c b/src/entry_linux.c index 16401c7..6854861 100644 --- a/src/entry_linux.c +++ b/src/entry_linux.c @@ -14,9 +14,13 @@ int main(int argc, char **argv) Arena *arena = CreateArenaDebug(mem, MB(32), __LINE__); isize renderer_mem_size = MB(8); + isize game_mem_size = MB(16); rawptr renderer_mem = ArenaAlloc(arena, renderer_mem_size); - Arena *renderer_arena = CreateArenaDebug(renderer_mem, MB(8), __LINE__); + Arena *renderer_arena = CreateArenaDebug(renderer_mem, renderer_mem_size, 2); + + rawptr game_mem = ArenaAlloc(arena, game_mem_size); + Arena *game_arena = CreateArenaDebug(game_mem, game_mem_size, 3); Assert(CreatePlatformWindow(), "Failed to initialize the window"); @@ -30,7 +34,7 @@ int main(int argc, char **argv) while (!global_quit) { GetWindowEvents(inputs, &i_count); - RunCycle(inputs, i_count); + RunCycle(game_arena, inputs, i_count); } DestroyGame(); diff --git a/src/entry_linux.h b/src/entry_linux.h index bf87802..83d47c1 100644 --- a/src/entry_linux.h +++ b/src/entry_linux.h @@ -6,8 +6,6 @@ #define WINDOW_NAME "Video Game" -#include - #include "stb/stb_sprintf.h" #include "shared_types.h" diff --git a/src/entry_windows.c b/src/entry_windows.c index 1b935b1..da69c31 100644 --- a/src/entry_windows.c +++ b/src/entry_windows.c @@ -22,9 +22,13 @@ int CALLBACK WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line Arena *arena = CreateArenaDebug(mem, MB(32), 1); isize renderer_mem_size = MB(8); + isize game_mem_size = MB(16); rawptr renderer_mem = ArenaAlloc(arena, renderer_mem_size); - Arena *renderer_arena = CreateArenaDebug(renderer_mem, MB(8), 2); + Arena *renderer_arena = CreateArenaDebug(renderer_mem, renderer_mem_size, 2); + + rawptr game_mem = ArenaAlloc(arena, game_mem_size); + Arena *game_arena = CreateArenaDebug(game_mem, game_mem_size, 3); Assert(CreatePlatformWindow(), "Failed to initialize window"); @@ -36,7 +40,7 @@ int CALLBACK WinMain(HINSTANCE instance, HINSTANCE prev_instance, LPSTR cmd_line while (!global_quit) { GetWindowEvents(); - RunCycle(inputs, i_count); + RunCycle(game_arena, inputs, i_count); } DestroyGame(); diff --git a/src/file_data/spv.c b/src/file_data/spv.c index bd07df7..4b61c16 100644 --- a/src/file_data/spv.c +++ b/src/file_data/spv.c @@ -1,3 +1,464 @@ +unsigned char shader_gui_frag[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x06, 0x01, 0x00, 0x0b, 0x00, 0x0d, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0xe3, 0x14, 0x00, 0x00, + 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, + 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x03, 0x00, 0xe4, 0x14, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x0e, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x02, 0x00, 0x00, 0x00, 0xcc, 0x01, 0x00, 0x00, 0x04, 0x00, 0x07, 0x00, + 0x47, 0x4c, 0x5f, 0x45, 0x58, 0x54, 0x5f, 0x62, 0x75, 0x66, 0x66, 0x65, + 0x72, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, 0x6e, 0x63, 0x65, 0x00, + 0x04, 0x00, 0x0a, 0x00, 0x47, 0x4c, 0x5f, 0x47, 0x4f, 0x4f, 0x47, 0x4c, + 0x45, 0x5f, 0x63, 0x70, 0x70, 0x5f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x5f, + 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, + 0x76, 0x65, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x47, 0x4c, 0x5f, 0x47, + 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, + 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x6f, 0x75, 0x74, 0x5f, 0x66, 0x72, 0x61, 0x67, 0x5f, 0x63, 0x6f, 0x6c, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x06, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x47, 0x6c, 0x6f, 0x62, + 0x61, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x72, 0x65, 0x73, 0x00, 0x05, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x70, + 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6c, 0x61, 0x63, + 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x69, 0x6d, 0x61, 0x67, + 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x73, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, 0x49, 0x6d, 0x61, 0x67, + 0x65, 0x73, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x50, 0x42, 0x52, 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x73, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x61, 0x6c, 0x62, 0x65, 0x64, 0x6f, 0x00, 0x00, + 0x06, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x6d, 0x65, 0x74, 0x61, + 0x6c, 0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x72, 0x6f, 0x75, 0x67, + 0x68, 0x6e, 0x65, 0x73, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x61, 0x6f, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x26, 0x00, 0x00, 0x00, 0x4d, 0x61, 0x74, 0x65, + 0x72, 0x69, 0x61, 0x6c, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x27, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, + 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x50, 0x43, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x23, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x04, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x09, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x22, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x07, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, + 0x27, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x28, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 +}; +unsigned int shader_gui_frag_len = 1808; +unsigned char shader_gui_vert[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x06, 0x01, 0x00, 0x0b, 0x00, 0x0d, 0x00, + 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0xe3, 0x14, 0x00, 0x00, + 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, + 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x03, 0x00, 0xe4, 0x14, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0xcc, 0x01, 0x00, 0x00, + 0x04, 0x00, 0x07, 0x00, 0x47, 0x4c, 0x5f, 0x45, 0x58, 0x54, 0x5f, 0x62, + 0x75, 0x66, 0x66, 0x65, 0x72, 0x5f, 0x72, 0x65, 0x66, 0x65, 0x72, 0x65, + 0x6e, 0x63, 0x65, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x47, 0x4c, 0x5f, 0x47, + 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f, 0x63, 0x70, 0x70, 0x5f, 0x73, 0x74, + 0x79, 0x6c, 0x65, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x64, 0x69, 0x72, + 0x65, 0x63, 0x74, 0x69, 0x76, 0x65, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, + 0x47, 0x4c, 0x5f, 0x47, 0x4f, 0x4f, 0x47, 0x4c, 0x45, 0x5f, 0x69, 0x6e, + 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x69, 0x72, 0x65, 0x63, 0x74, + 0x69, 0x76, 0x65, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x70, 0x30, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x5f, 0x67, 0x75, 0x69, 0x5f, 0x70, + 0x6f, 0x73, 0x5f, 0x30, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x70, 0x31, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x5f, 0x67, 0x75, 0x69, 0x5f, 0x70, + 0x6f, 0x73, 0x5f, 0x31, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6c, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x69, 0x6e, 0x5f, 0x63, 0x6f, 0x6c, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x76, 0x65, 0x72, 0x74, + 0x69, 0x63, 0x65, 0x73, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x64, 0x73, 0x74, 0x5f, 0x68, 0x61, 0x6c, 0x66, + 0x5f, 0x73, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x64, 0x73, 0x74, 0x5f, 0x63, 0x65, 0x6e, 0x74, + 0x65, 0x72, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x2f, 0x00, 0x00, 0x00, + 0x64, 0x73, 0x74, 0x5f, 0x70, 0x6f, 0x73, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x56, 0x65, 0x72, 0x74, 0x65, + 0x78, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x3b, 0x00, 0x00, 0x00, 0x6f, 0x75, 0x74, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, + 0x72, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, + 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x07, 0x00, + 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x43, + 0x6c, 0x69, 0x70, 0x44, 0x69, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x00, + 0x06, 0x00, 0x07, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x67, 0x6c, 0x5f, 0x43, 0x75, 0x6c, 0x6c, 0x44, 0x69, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x00, 0x05, 0x00, 0x03, 0x00, 0x41, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, + 0x6d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x4a, 0x00, 0x00, 0x00, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, + 0x05, 0x00, 0x06, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x53, 0x68, 0x61, 0x64, + 0x65, 0x72, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x06, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x70, 0x6c, 0x61, 0x63, 0x65, 0x68, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x00, 0x05, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x69, 0x6d, 0x61, 0x67, 0x65, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x64, 0x00, 0x00, 0x00, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x73, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x49, 0x6d, 0x61, 0x67, 0x65, 0x73, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x50, 0x42, 0x52, 0x4d, 0x61, 0x74, 0x65, 0x72, + 0x69, 0x61, 0x6c, 0x73, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x61, 0x6c, 0x62, 0x65, + 0x64, 0x6f, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x00, 0x00, + 0x06, 0x00, 0x06, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x6d, 0x65, 0x74, 0x61, 0x6c, 0x6c, 0x69, 0x63, 0x00, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x06, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x72, 0x6f, 0x75, 0x67, 0x68, 0x6e, 0x65, 0x73, 0x73, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x04, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x61, 0x6f, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x6d, 0x00, 0x00, 0x00, + 0x4d, 0x61, 0x74, 0x65, 0x72, 0x69, 0x61, 0x6c, 0x73, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x43, 0x6f, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x04, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0x65, 0x73, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x70, 0x00, 0x00, 0x00, 0x50, 0x43, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x32, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x3f, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x64, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x64, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x6d, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x6d, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x04, 0x00, 0x18, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xbf, + 0x2c, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x2c, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x07, 0x00, 0x18, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x15, 0x00, 0x04, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x3a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, + 0x3e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x06, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x3f, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x44, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x49, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x4b, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x03, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, + 0x5d, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x5e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x03, 0x00, 0x61, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x62, 0x00, 0x00, 0x00, + 0x61, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x19, 0x00, 0x09, 0x00, 0x65, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x04, 0x00, 0x66, 0x00, 0x00, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x67, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x67, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x69, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x07, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x04, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x6c, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x03, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x6f, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x22, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x08, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x44, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x06, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x4a, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x00, 0x00, 0x41, 0x00, 0x06, 0x00, 0x4b, 0x00, 0x00, 0x00, + 0x53, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x07, 0x00, 0x10, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x4f, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x59, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 +}; +unsigned int shader_gui_vert_len = 3644; unsigned char shader_quad_frag[] = { 0x03, 0x02, 0x23, 0x07, 0x00, 0x06, 0x01, 0x00, 0x0b, 0x00, 0x0d, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, diff --git a/src/game.c b/src/game.c index 9005057..27b4331 100644 --- a/src/game.c +++ b/src/game.c @@ -8,15 +8,74 @@ static void DestroyGame() DestroyRenderer(); } -static void RunCycle(GameInput *inputs, u32 i_count) +static void RunCycle(Arena *arena, GameInput *inputs, u32 i_count) { - for (u32 i = 0; i < i_count; i++) - { - Printfln("input: %d", inputs[i].code); - } + GUIContext ctx = { + .vertices = ArenaAlloc(arena, sizeof(GUIVertex) * 128), + .vertices_len = 0, + .indices = ArenaAlloc(arena, sizeof(u32) * 512), + .indices_len = 0, + .instance_count = 0, + }; + + PushConst pc = {}; + + DrawRect(&ctx, (Vec2){ .x = 20.0f, .y = 20.0f }, (Vec2){ .x = 200.0f, .y = 200.0f }, (Vec4){ .r = 0.0f, .g = 0.3f, .b = 0.7f, .a = 1.0f}); + + RenderBuffer vertex_buffer = { + .type = RENDER_BUFFER_TYPE_VERTEX, + .size = sizeof(GUIVertex) * ctx.vertices_len, + }; + + RenderBuffer index_buffer = { + .type = RENDER_BUFFER_TYPE_INDEX, + .size = sizeof(u32) * ctx.indices_len, + }; + + CreateAndUploadToBuffer(&vertex_buffer, ctx.vertices); + CreateAndUploadToBuffer(&index_buffer, ctx.indices); BeginFrame(); - DrawTriangle(); + + BindPipeline(PIPELINE_GUI, PIPELINE_TYPE_GRAPHICS); + + BindVertexBuffer(&vertex_buffer); + BindIndexBuffer(&index_buffer); + + GetViewportSize(&pc.res); + + SetPushConstants(&pc); + + DrawIndexed(4, ctx.instance_count); + FinishFrame(); + + //if (renderer.frame_state.prev_buffer_count > 0) + //FreeBuffers(renderer.frame_state.prev_buffers, renderer.frame_state.prev_buffer_count); + + ArenaFree(arena); + + u32 buffer_count = 2; + renderer.frame_state.prev_buffers = ArenaAlloc(arena, sizeof(RenderBuffer) * buffer_count); + renderer.frame_state.prev_buffers[0] = vertex_buffer; + renderer.frame_state.prev_buffers[1] = index_buffer; + renderer.frame_state.prev_buffer_count = buffer_count; } +static void DrawRect(GUIContext *ctx, Vec2 p0, Vec2 p1, Vec4 col) +{ + ctx->vertices[ctx->vertices_len].p0 = p0; + ctx->vertices[ctx->vertices_len].p1 = p1; + ctx->vertices[ctx->vertices_len].col = col; + + ctx->vertices_len += 1; + + ctx->indices[ctx->indices_len] = ctx->indices_len; + ctx->indices[ctx->indices_len+1] = ctx->indices_len+1; + ctx->indices[ctx->indices_len+2] = ctx->indices_len+2; + ctx->indices[ctx->indices_len+3] = ctx->indices_len+3; + + ctx->indices_len += 4; + + ctx->instance_count += 1; +} diff --git a/src/game.h b/src/game.h index fed6722..c8a4b46 100644 --- a/src/game.h +++ b/src/game.h @@ -1,6 +1,6 @@ #pragma once -static void RunCycle(GameInput *inputs, u32 i_count); +static void RunCycle(Arena *arena, GameInput *inputs, u32 i_count); static void InitializeGame(Arena *arena); static void DestroyGame(); - +static void DrawRect(GUIContext *ctx, Vec2 p0, Vec2 p1, Vec4 col); diff --git a/src/platform_linux.c b/src/platform_linux.c index cc31f0c..f209d7f 100644 --- a/src/platform_linux.c +++ b/src/platform_linux.c @@ -290,16 +290,18 @@ void HandleWindowEvent(GameInput *inputs, u32 *i_count, b32 wait_for_event) case XCB_CLIENT_MESSAGE: { xcb_client_message_event_t *msg = (xcb_client_message_event_t *)e; + if (msg->window != linux_window.window) + break; + if (msg->data.data32[0] == linux_window.close_event) - { global_quit = true; - } + + if (msg->type == XCB_ATOM_NOTICE) + SetRenderResolution(linux_window.w, linux_window.h); } break; case XCB_EXPOSE: { - xcb_expose_event_t *expose_e = (xcb_expose_event_t *)e; - linux_window.w = expose_e->width; - linux_window.h = expose_e->height; + RepaintWindow(); } break; case XCB_CONFIGURE_NOTIFY: { @@ -309,7 +311,6 @@ void HandleWindowEvent(GameInput *inputs, u32 *i_count, b32 wait_for_event) { linux_window.w = configure_event->width; linux_window.h = configure_event->height; - SetRenderResolution(linux_window.w, linux_window.h); } } break; case XCB_KEY_RELEASE: @@ -345,6 +346,19 @@ void HandleWindowEvent(GameInput *inputs, u32 *i_count, b32 wait_for_event) } while(!wait_for_event && !has_max_inputs); } +void RepaintWindow() +{ + xcb_client_message_event_t client_message = { + .response_type = XCB_CLIENT_MESSAGE, + .format = 32, + .window = linux_window.window, + .type = XCB_ATOM_NOTICE, + }; + + xcb_send_event(linux_window.connection, 0, linux_window.window, 0, (char *)&client_message); + xcb_flush(linux_window.connection); +} + KeyboardInput ConvertInputEvent(u32 x_key) { switch (x_key) diff --git a/src/platform_linux.h b/src/platform_linux.h index 1fcac5c..e6c0059 100644 --- a/src/platform_linux.h +++ b/src/platform_linux.h @@ -82,6 +82,7 @@ b32 WaitForWindowEvent(GameInput *input); WindowSize _GetWindowSize(); void HandleWindowEvent(GameInput *inputs, u32 *input_count, b32 wait_for_event); KeyboardInput ConvertInputEvent(u32 x_key); +void RepaintWindow(); // Platform API END diff --git a/src/render.c b/src/render.c index 3f80f57..e3b1753 100644 --- a/src/render.c +++ b/src/render.c @@ -10,34 +10,7 @@ #error Not yet implemented #endif -#if STG_DX11_RENDERER -#error Not yet implemented +#if STG_DX11_RENDERER && __linux__ +#include "render_d3d11.c" #endif -b32 InitRenderer(Arena *arena) { - return _InitRenderer(arena); -} - -void DestroyRenderer() { - _DestroyRenderer(); -} - -b32 BeginFrame() -{ - return _BeginFrame(); -} - -void DrawTriangle() -{ - _DrawTriangle(); -} - -b32 FinishFrame() -{ - return _FinishFrame(); -} - -void SetRenderResolution(u32 x, u32 y) -{ - _SetRenderResolution(x, y); -} diff --git a/src/render.h b/src/render.h index 3007614..0d46d08 100644 --- a/src/render.h +++ b/src/render.h @@ -1,5 +1,85 @@ #pragma once +typedef enum Pipeline_e +{ + PIPELINE_CUBE, + PIPELINE_GUI, + + PIPELINE_MAX, +} PipelineHandle; + +typedef enum PipelineType_e +{ + PIPELINE_TYPE_GRAPHICS = 0, + PIPELINE_TYPE_COMPUTE = 1, +} PipelineType; + +typedef enum RenderBufferType_e +{ + RENDER_BUFFER_TYPE_NONE = 0x0000, + RENDER_BUFFER_TYPE_VERTEX = 0x001, + RENDER_BUFFER_TYPE_INDEX = 0x002, + RENDER_BUFFER_TYPE_UNIFORM = 0x004, + RENDER_BUFFER_TYPE_STAGING = 0x008, + RENDER_BUFFER_TYPE_STORAGE = 0x010, +} RenderBufferType; + +typedef enum VertexAttrType_e +{ + VERTEX_ATTRIBUTE_TYPE_VERTEX = 0, + VERTEX_ATTRIBUTE_TYPE_COLOR = 1, +} VertexAttrType; + +// Renderer Front End Types + +// Declarations + +// @requirement RenderBuffer type; +// @requirement u32 size; +typedef struct RenderBuffer_t RenderBuffer; +typedef struct PushConst_t PushConst; +typedef struct ShaderGlobals_t ShaderGlobals; + +// Types +typedef struct RenderBuffers_t +{ + RenderBuffer *buffers; + u32 len; +} RenderBuffers; + +// Renderer Front End Types END + +// Back End API + +// Initialization +b32 InitRenderer(Arena *arena); +void DestroyRenderer(); + +// Buffers +static b32 CreateBuffer(RenderBuffer *buffer); +static void FreeBuffers(RenderBuffer *buffers, u32 buffer_count); +static b32 UploadToBuffer(RenderBuffer *buffer, rawptr ptr); +static b32 CreateAndUploadToBuffer(RenderBuffer *buffer, rawptr ptr); +static void BindVertexBuffer(RenderBuffer *buffer); +static void BindIndexBuffer(RenderBuffer *buffer); + +// Uniforms/PushConstants +static void GetViewportSize(Vec2 *size); +static void SetGlobalUniform(ShaderGlobals *globals); +static void SetPushConstants(PushConst *pc); + +// Config +static void SetRenderResolution(u32 x, u32 y); + +// Rendering +static b32 BeginFrame(); +static b32 FinishFrame(); +static void DrawIndexed(u32 index_count, u32 instance_count); +static void BindPipeline(PipelineHandle handle, PipelineType type); + +// Placeholders (Remove me) +static void DrawTriangle(); + #if STG_VULKAN_RENDERER #include "render_vulkan.h" #endif @@ -12,15 +92,6 @@ #error Not yet implemented #endif -#if STG_DX11_RENDERER -#error Not yet implemented +#if STG_DX11_RENDERER && __linux__ +#include "render_d3d11.h" #endif - -b32 InitRenderer(Arena *arena); -void DestroyRenderer(); - -// Drawing -static b32 DrawFrame(); -static void DrawTriangle(); -static b32 FinishFrame(); -static void SetRenderResolution(u32 x, u32 y); diff --git a/src/render_d3d11.c b/src/render_d3d11.c new file mode 100644 index 0000000..d7d2308 --- /dev/null +++ b/src/render_d3d11.c @@ -0,0 +1,40 @@ +b32 _InitRenderer(Arena *arena) +{ + ID3D11Device *device; + ID3D11DeviceContext *ctx; + + D3D_FEATURE_LEVEL levels[] = { D3D_FEATURE_LEVEL_11_0 }; + HRESULT hr = D3D11CreateDevice(NULL, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, levels, Len(levels), D3D11_SDK_VERSION, &device, NULL, &ctx); + + return true; +} + +void _DestroyRenderer() +{ + +} + +b32 _BeginFrame() +{ + return true; +} + +b32 _DrawTriangle() +{ + return true; +} + +b32 _FinishFrame() +{ + return true; +} + +void _SetRenderResolution(u32 x, u32 y) +{ + +} + +static void DrawGUI(GUIContext *ctx) +{ + +} diff --git a/src/render_d3d11.h b/src/render_d3d11.h new file mode 100644 index 0000000..e7cba32 --- /dev/null +++ b/src/render_d3d11.h @@ -0,0 +1,13 @@ +#pragma once + +#ifdef __linux__ +#include "d3d11.h" +#endif + +b32 _InitRenderer(Arena *arena); +void _DestroyRenderer(); +b32 _BeginFrame(); +b32 _DrawTriangle(); +b32 _FinishFrame(); +void _SetRenderResolution(u32 x, u32 y); +static void DrawGUI(GUIContext *ctx); diff --git a/src/render_vulkan.c b/src/render_vulkan.c index 8c44fbb..7a8de74 100644 --- a/src/render_vulkan.c +++ b/src/render_vulkan.c @@ -3,14 +3,14 @@ */ // TODO(MA): Make separate functions for debug/non debug builds for readability -b32 _InitRenderer(Arena *arena) +b32 InitRenderer(Arena *arena) { Assert(InitVulkan(arena), "InitVkLib failure"); return true; } -void _DestroyRenderer() +void DestroyRenderer() { DestroyVulkan(); } @@ -40,11 +40,57 @@ static VkSemaphore GetFrameSwapSem() return renderer.vk.frame.swapchain_sems[GetFrameIndex()]; } -b32 _BeginFrame() +static void BeginRendering() +{ + VkCommandBuffer cmd = GetFrameCmdBuf(); + + TransitionImage(cmd, &renderer.vk.sc.draw_img, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); + TransitionImage(cmd, &renderer.vk.sc.depth_img, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL); + + VkRenderingAttachmentInfo col_attach_info = { + .sType = STYPE(RENDERING_ATTACHMENT_INFO), + .imageView = renderer.vk.sc.draw_img.view, + .imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, + .loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR, + .storeOp = VK_ATTACHMENT_STORE_OP_STORE, + .clearValue = { { 0.2f, 0.2f, 0.2f, 1.0f } }, + }; + + VkRenderingAttachmentInfo depth_attach_info = { + .sType = STYPE(RENDERING_ATTACHMENT_INFO), + .imageView = renderer.vk.sc.depth_img.view, + .imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL, + .loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR, + .storeOp = VK_ATTACHMENT_STORE_OP_STORE, + }; + + VkRenderingInfo render_info = { + .sType = STYPE(RENDERING_INFO), + .layerCount = 1, + .colorAttachmentCount = 1, + .pColorAttachments = &col_attach_info, + .pDepthAttachment = &depth_attach_info, + .renderArea = { + .extent = { + .width = renderer.vk.sc.extent.width, + .height = renderer.vk.sc.extent.height, + }, + }, + }; + + vkCmdBeginRendering(cmd, &render_info); + + vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, renderer.vk.pipe.pipeline_layout, 0, DESC_TYPE_MAX, renderer.vk.pipe.sets, 0, NULL); +} + +b32 BeginFrame() { b32 success = true; VkResult result; + if (renderer.pending.resized) + ResizeSwapchain(); + VkDevice device = renderer.vk.device; VkSwapchainKHR swapchain = renderer.vk.swapchain; VkCommandBuffer cmd = GetFrameCmdBuf(); @@ -108,71 +154,41 @@ b32 _BeginFrame() } } - if (success) - { - VkImage curr_img = renderer.vk.sc.imgs[renderer.frame_state.img_ix]; - - VkImageSubresourceRange clear_range = { - .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT, - .baseMipLevel = 0, - .levelCount = VK_REMAINING_MIP_LEVELS, - .baseArrayLayer = 0, - .layerCount = VK_REMAINING_ARRAY_LAYERS, - }; - VkClearColorValue clear_value = { { 1.0f, 0.0f, 0.0f, 1.0f } }; - TransitionImageLayout(cmd, renderer.vk.sc.imgs[renderer.frame_state.img_ix], VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL); - vkCmdClearColorImage(cmd, renderer.vk.sc.imgs[renderer.frame_state.img_ix], VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, &clear_value, 1, &clear_range); - - TransitionImage(cmd, &renderer.vk.sc.draw_img, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL); - TransitionImage(cmd, &renderer.vk.sc.depth_img, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL); - - VkRenderingAttachmentInfo col_attach_info = { - .sType = STYPE(RENDERING_ATTACHMENT_INFO), - .imageView = renderer.vk.sc.draw_img.view, - .imageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, - .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD, - .storeOp = VK_ATTACHMENT_STORE_OP_STORE, - }; - - VkRenderingAttachmentInfo depth_attach_info = { - .sType = STYPE(RENDERING_ATTACHMENT_INFO), - .imageView = renderer.vk.sc.depth_img.view, - .imageLayout = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL, - .loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR, - .storeOp = VK_ATTACHMENT_STORE_OP_STORE, - }; - - VkRenderingInfo render_info = { - .sType = STYPE(RENDERING_INFO), - .layerCount = 1, - .colorAttachmentCount = 1, - .pColorAttachments = &col_attach_info, - .pDepthAttachment = &depth_attach_info, - .renderArea = { - .extent = { - .width = renderer.vk.sc.extent.width, - .height = renderer.vk.sc.extent.height, - }, - }, - }; - - vkCmdBeginRendering(cmd, &render_info); - } - return success; } -void _ClearScreen() +void ClearScreen() { } -void _DrawTriangle() +static void DrawGUI(GUIContext *ctx) { + if (!renderer.frame_state.begin_rendering) + BeginRendering(); + VkCommandBuffer cmd = GetFrameCmdBuf(); - vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, renderer.vk.pipe.pipelines[PIPELINE_CUBE]); - vkCmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, renderer.vk.pipe.pipeline_layout, 0, DESC_TYPE_MAX, renderer.vk.pipe.sets, 0, NULL); + if (renderer.frame_state.last_pipeline != PIPELINE_GUI) + { + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, renderer.vk.pipe.pipelines[PIPELINE_GUI]); + renderer.frame_state.last_pipeline = PIPELINE_GUI; + } + + +} + +static void BindPipeline(PipelineHandle handle, PipelineType type) +{ + if (!renderer.frame_state.begin_rendering) + { + BeginRendering(); + renderer.frame_state.begin_rendering = true; + } + + VkCommandBuffer cmd = GetFrameCmdBuf(); + + vkCmdBindPipeline(cmd, (VkPipelineBindPoint)type, renderer.vk.pipe.pipelines[handle]); VkViewport viewport = { .width = (f32)renderer.vk.sc.extent.width, @@ -190,14 +206,32 @@ void _DrawTriangle() }; vkCmdSetScissor(cmd, 0, 1, &scissor); - - vkCmdDraw(cmd, 3, 1, 0, 0); - - // TODO(MA): maybe store current image layout between functions } -b32 _FinishFrame() +static void DrawIndexed(u32 index_count, u32 instance_count) { + VkCommandBuffer cmd = GetFrameCmdBuf(); + + vkCmdDrawIndexed(cmd, index_count, instance_count, 0, 0, 0); +} + +void DrawTriangle() +{ + VkCommandBuffer cmd = GetFrameCmdBuf(); + + vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, renderer.vk.pipe.pipelines[PIPELINE_CUBE]); + + + vkCmdDraw(cmd, 3, 1, 0, 0); +} + +b32 FinishFrame() +{ + if (!renderer.frame_state.begin_rendering) + Assert(false, "FinishFrame called without beginning rendering"); + + renderer.frame_state.begin_rendering = false; + b32 success = true; VkResult result; @@ -292,7 +326,300 @@ b32 _FinishFrame() return success; } -static void _SetRenderResolution(u32 x, u32 y) +static void GetViewportSize(Vec2 *size) +{ + size->x = (f32)renderer.vk.sc.extent.width; + size->y = (f32)renderer.vk.sc.extent.height; +} + +static void SetGlobalUniform(ShaderGlobals *globals) +{ + +} + +static void FreeBuffers(RenderBuffer *buffers, u32 buffer_count) +{ + VkDevice device = renderer.vk.device; + VmaAllocator alloc = renderer.vk.alloc; + + // TODO: make this better at some point + for (u32 i = 0; i < buffer_count; i++) + { + vmaDestroyBuffer(alloc, buffers[i].buffer, buffers[i].alloc); + } +} + +static void SetPushConstants(PushConst *pc) +{ + VkCommandBuffer cmd = GetFrameCmdBuf(); + + vkCmdPushConstants(cmd, + renderer.vk.pipe.pipeline_layout, + VK_SHADER_STAGE_VERTEX_BIT|VK_SHADER_STAGE_FRAGMENT_BIT|VK_SHADER_STAGE_COMPUTE_BIT, + 0, + sizeof(PushConst), + pc); +} + +static void BindVertexBuffer(RenderBuffer *buffer) +{ + Assert(buffer && buffer->type == RENDER_BUFFER_TYPE_VERTEX, "BindVertexBuffer: invalid buffer provided"); + + VkCommandBuffer cmd = GetFrameCmdBuf(); + VkDeviceSize offsets = 0; + + vkCmdBindVertexBuffers(cmd, 0, 1, &buffer->buffer, &offsets); +} + +static void BindIndexBuffer(RenderBuffer *buffer) +{ + Assert(buffer && buffer->type == RENDER_BUFFER_TYPE_INDEX, "BindIndexBuffer: invalid buffer provided"); + + VkCommandBuffer cmd = GetFrameCmdBuf(); + + vkCmdBindIndexBuffer(cmd, buffer->buffer, 0, VK_INDEX_TYPE_UINT32); +} + +static b32 BeginImmSubmit(VkDevice device, VkFence *fence, VkCommandBuffer cmd) +{ + b32 success = true; + + VkResult result = vkResetFences(device, 1, fence); + if (result != VK_SUCCESS) + { + Printfln("vkResetFences failure: %s", VkResultStr(result)); + success = false; + } + + if (success) + { + result = vkResetCommandBuffer(cmd, 0); + if (result != VK_SUCCESS) + { + Printfln("vkResetCommandBuffer failure: %s", VkResultStr(result)); + success = false; + } + } + + if (success) + { + VkCommandBufferBeginInfo buf_info = { + .sType = STYPE(COMMAND_BUFFER_BEGIN_INFO), + .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, + }; + + result = vkBeginCommandBuffer(cmd, &buf_info); + if (result != VK_SUCCESS) + { + Printfln("vkBeginCommandBuffer failure: %s", VkResultStr(result)); + success = false; + } + } + + return success; +} + +static b32 FinishImmSubmit(VkDevice device, VkFence *fence, VkCommandBuffer cmd, VkQueue queue) +{ + b32 success = true; + + VkResult result = vkEndCommandBuffer(cmd); + if (result != VK_SUCCESS) + { + Printfln("vkEndCommandBuffer imm failure: %s", VkResultStr(result)); + success = false; + } + + if (success) + { + VkCommandBufferSubmitInfo cmd_submit_info = { + .sType = STYPE(COMMAND_BUFFER_SUBMIT_INFO), + .commandBuffer = cmd, + }; + + VkSubmitInfo2 submit_info = { + .sType = STYPE(SUBMIT_INFO_2), + .commandBufferInfoCount = 1, + .pCommandBufferInfos = &cmd_submit_info, + }; + + result = vkQueueSubmit2(queue, 1, &submit_info, *fence); + if (result != VK_SUCCESS) + { + Printfln("vkQueueSubmit2 imm failure: %s", VkResultStr(result)); + success = false; + } + } + + if (success) + { + result = vkWaitForFences(device, 1, fence, true, 9999999999); + if (result != VK_SUCCESS) + { + Printfln("vkWaitForFences imm failure: %s", VkResultStr(result)); + success = false; + } + } + + return success; +} + +static b32 CreateBuffer(RenderBuffer *buffer) +{ + Assert(buffer, "CreateBuffer: RenderBuffer must not be null"); + Assert(buffer->type != RENDER_BUFFER_TYPE_NONE, "CreateBuffer: RenderBuffer type must not be RENDER_BUFFER_TYPE_NONE"); + + b32 success = true; + VkResult result; + + DeviceQueues *queues = &renderer.vk.queues; + ImmediateStructures *imm = &renderer.vk.imm; + VmaAllocator alloc = renderer.vk.alloc; + + VkBufferCreateInfo buffer_info = { + .sType = STYPE(BUFFER_CREATE_INFO), + .size = (VkDeviceSize)buffer->size, + }; + + VmaAllocationCreateInfo alloc_info = { + .usage = VMA_MEMORY_USAGE_UNKNOWN, + .flags = VMA_ALLOCATION_CREATE_MAPPED_BIT, + }; + + switch (buffer->type) + { + case RENDER_BUFFER_TYPE_VERTEX: + { + buffer_info.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | + VK_BUFFER_USAGE_TRANSFER_DST_BIT | + VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + alloc_info.requiredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + } break; + case RENDER_BUFFER_TYPE_INDEX: + { + buffer_info.usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | + VK_BUFFER_USAGE_TRANSFER_DST_BIT | + VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + alloc_info.requiredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + } break; + case RENDER_BUFFER_TYPE_UNIFORM: + { + buffer_info.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | + VK_BUFFER_USAGE_TRANSFER_DST_BIT; + alloc_info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + } break; + case RENDER_BUFFER_TYPE_STAGING: + { + buffer_info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT; + alloc_info.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; + } break; + case RENDER_BUFFER_TYPE_STORAGE: + { + buffer_info.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | + VK_BUFFER_USAGE_TRANSFER_DST_BIT; + alloc_info.requiredFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT; + } break; + case RENDER_BUFFER_TYPE_NONE: + default: + Assert(false, "CreateBuffer: Unknown buffer type provided"); + } + + if (queues->graphics != queues->transfer) + { + buffer_info.sharingMode = VK_SHARING_MODE_CONCURRENT; + buffer_info.queueFamilyIndexCount = 2; + buffer_info.pQueueFamilyIndices = (u32[]){queues->graphics, queues->transfer}; + } + + result = vmaCreateBuffer(alloc, &buffer_info, &alloc_info, &buffer->buffer, &buffer->alloc, &buffer->info); + if (result != VK_SUCCESS) + { + Printfln("vmaCreateBuffer failure: %s", VkResultStr(result)); + success = false; + } + + return success; +} + +static b32 UploadToBuffer(RenderBuffer *buffer, rawptr ptr) +{ + Assert(buffer, "UploadToBuffer: buffer must not be null"); + Assert(ptr, "UploadToBuffer: ptr must not be null"); + + b32 success = true; + + ImmediateStructures *imm = &renderer.vk.imm; + VkDevice device = renderer.vk.device; + VkQueue queue = renderer.vk.queues.transfer_queue; + VmaAllocator alloc = renderer.vk.alloc; + rawptr mapped_buffer = NULL; + + b32 host_visible = buffer->type & HOST_VISIBLE_BUFFERS; + + if (host_visible) + { + vmaMapMemory(alloc, buffer->alloc, &mapped_buffer); + MemCpy(mapped_buffer, ptr, buffer->size); + } + else + { + RenderBuffer staging_buffer = { .type = RENDER_BUFFER_TYPE_STAGING, .size = buffer->size }; + + success = CreateBuffer(&staging_buffer); + + b32 buffer_created = success; + + if (success) + { + vmaMapMemory(alloc, staging_buffer.alloc, &mapped_buffer); + MemCpy(mapped_buffer, ptr, staging_buffer.size); + } + + if (success) + success = BeginImmSubmit(device, &imm->fence, imm->cmd); + + b32 imm_started = success; + + if (success) + { + VkBufferCopy buffer_copy = { .size = (VkDeviceSize)buffer->size }; + vkCmdCopyBuffer(imm->cmd, staging_buffer.buffer, buffer->buffer, 1, &buffer_copy); + } + + if (imm_started) + FinishImmSubmit(device, &imm->fence, imm->cmd, queue); + + if (buffer_created) + { + vmaUnmapMemory(alloc, staging_buffer.alloc); + vmaDestroyBuffer(alloc, staging_buffer.buffer, staging_buffer.alloc); + } + } + + return success; +} + +static b32 CreateAndUploadToBuffer(RenderBuffer *buffer, rawptr ptr) +{ + b32 success = true; + + success = CreateBuffer(buffer); + + if (success) + success = UploadToBuffer(buffer, ptr); + + return success; +} + +static b32 UploadGUIBuffer(MeshBuffer *buf, GUIContext *ctx) +{ + b32 success = true; + return success; +} + +static void SetRenderResolution(u32 x, u32 y) { renderer.pending.render_width = x; renderer.pending.render_height = y; @@ -407,6 +734,8 @@ static void TransitionImage(VkCommandBuffer cmd, Image *img, VkImageLayout new) static b32 InitVulkan(Arena *arena) { + CustomizePipelines(); + Assert(arena != NULL, "Vulkan memory is null"); renderer.perm_arena = arena; void *mem = ArenaAlloc(arena, MB(4)); @@ -743,6 +1072,7 @@ static b32 InitVkDeviceFunctions() { INIT_DEV_FN(vkCmdSetScissor); INIT_DEV_FN(vkCmdPushConstants); INIT_DEV_FN(vkCmdBindIndexBuffer); + INIT_DEV_FN(vkCmdBindVertexBuffers); INIT_DEV_FN(vkCmdDrawIndexed); INIT_DEV_FN(vkCmdBlitImage2); INIT_DEV_FN(vkCmdPipelineBarrier2); @@ -900,7 +1230,7 @@ static b32 CreateImmediateStructures() cmd_buf_info.commandPool = imm->pool; - result = vkAllocateCommandBuffers(device, &cmd_buf_info, &imm->buffer); + result = vkAllocateCommandBuffers(device, &cmd_buf_info, &imm->cmd); if (result != VK_SUCCESS) success = false; @@ -1131,6 +1461,13 @@ static b32 CreatePipelines() success &= CreateShaderModule(shader_quad_vert, shader_quad_vert_len, &cube_vert); success &= CreateShaderModule(shader_quad_frag, shader_quad_frag_len, &cube_frag); + VkPipelineRenderingCreateInfo pipeline_render_info = { + .sType = STYPE(PIPELINE_RENDERING_CREATE_INFO), + .colorAttachmentCount = 1, + .pColorAttachmentFormats = &renderer.vk.sc.draw_img.fmt, + .depthAttachmentFormat = renderer.vk.sc.depth_img.fmt, + }; + VkPipelineShaderStageCreateInfo cube_shader_stages[] = { { .sType = STYPE(PIPELINE_SHADER_STAGE_CREATE_INFO), @@ -1146,13 +1483,6 @@ static b32 CreatePipelines() }, }; - VkPipelineRenderingCreateInfo pipeline_render_info = { - .sType = STYPE(PIPELINE_RENDERING_CREATE_INFO), - .colorAttachmentCount = 1, - .pColorAttachmentFormats = &renderer.vk.sc.draw_img.fmt, - .depthAttachmentFormat = renderer.vk.sc.depth_img.fmt, - }; - cube_create_info.pStages = cube_shader_stages; cube_create_info.stageCount = Len(cube_shader_stages); cube_create_info.layout = renderer.vk.pipe.pipeline_layout; @@ -1168,6 +1498,40 @@ static b32 CreatePipelines() vkDestroyShaderModule(device, cube_vert, NULL); vkDestroyShaderModule(device, cube_frag, NULL); + VkShaderModule gui_vert, gui_frag; + success &= CreateShaderModule(shader_gui_vert, shader_gui_vert_len, &gui_vert); + success &= CreateShaderModule(shader_gui_frag, shader_gui_frag_len, &gui_frag); + + VkPipelineShaderStageCreateInfo gui_shader_stages[] = { + { + .sType = STYPE(PIPELINE_SHADER_STAGE_CREATE_INFO), + .stage = VK_SHADER_STAGE_VERTEX_BIT, + .module = gui_vert, + .pName = "main", + }, + { + .sType = STYPE(PIPELINE_SHADER_STAGE_CREATE_INFO), + .stage = VK_SHADER_STAGE_FRAGMENT_BIT, + .module = gui_frag, + .pName = "main", + }, + }; + + gui_create_info.pStages = gui_shader_stages; + gui_create_info.stageCount = Len(gui_shader_stages); + gui_create_info.layout = renderer.vk.pipe.pipeline_layout; + gui_create_info.pNext = &pipeline_render_info; + + result = vkCreateGraphicsPipelines(device, 0, 1, &gui_create_info, NULL, &renderer.vk.pipe.pipelines[PIPELINE_GUI]); + if (result != VK_SUCCESS) + { + Printfln("vkCreateGraphicsPipelines failure: %s", VkResultStr(result)); + success = false; + } + + vkDestroyShaderModule(device, gui_vert, NULL); + vkDestroyShaderModule(device, gui_frag, NULL); + return success; } @@ -1243,7 +1607,7 @@ static void DestroyVulkan() DestroySwapchain(); vkDestroyFence(device, imm.fence, NULL); - vkFreeCommandBuffers(device, imm.pool, 1, &imm.buffer); + vkFreeCommandBuffers(device, imm.pool, 1, &imm.cmd); vkDestroyCommandPool(device, imm.pool, NULL); for (u32 i = 0; i < sc.img_count; i++) @@ -1268,6 +1632,21 @@ static void DestroyVulkan() vkDestroyInstance(renderer.vk.inst, NULL); } +void VkInfo(const char *str) +{ + Printfln("[INFO] %s", str); +} + +void VkWarn(const char *str) +{ + Printfln("[WARN] %s", str); +} + +void VkError(const char *str) +{ + Printfln("[ERROR] %s", str); +} + const char *VkResultStr(VkResult result) { switch (result) diff --git a/src/render_vulkan.h b/src/render_vulkan.h index e7f58cc..f9d3ba1 100644 --- a/src/render_vulkan.h +++ b/src/render_vulkan.h @@ -122,6 +122,7 @@ VK_DECLARE(vkCmdSetViewport); VK_DECLARE(vkCmdSetScissor); VK_DECLARE(vkCmdPushConstants); VK_DECLARE(vkCmdBindIndexBuffer); +VK_DECLARE(vkCmdBindVertexBuffers); VK_DECLARE(vkCmdDrawIndexed); VK_DECLARE(vkCmdBlitImage2); VK_DECLARE(vkCmdPipelineBarrier2); @@ -142,15 +143,11 @@ VK_DECLARE(vkCmdClearColorImage); #include "vma/vk_mem_alloc.h" +// Defines +#define HOST_VISIBLE_BUFFERS (RENDER_BUFFER_TYPE_UNIFORM | RENDER_BUFFER_TYPE_STAGING) + // Types -typedef enum Pipeline_e -{ - PIPELINE_CUBE, - - PIPELINE_MAX, -} PipelineHandle; - typedef enum DescType_e { DESC_TYPE_SHARED, @@ -161,6 +158,32 @@ typedef enum DescType_e DESC_TYPE_MAX, } DescType; +typedef struct ShaderGlobals_t +{ + Vec2 res; +} ShaderGlobals; + +typedef struct RenderBuffer_t +{ + RenderBufferType type; + VkBuffer buffer; + VmaAllocation alloc; + VmaAllocationInfo info; + u32 size; + i32 mem_index; // TODO(MA): use this +} RenderBuffer; + +typedef struct +{ + RenderBuffer index_buf, vertex_buf; + u32 index_count; +} MeshBuffer; + +typedef struct +{ + f32 res[2]; +} GlobalUniforms; + typedef struct { u16 *free; @@ -178,13 +201,9 @@ typedef struct VkPipeline pipelines[PIPELINE_MAX]; } PipelineStructures; -typedef struct +typedef struct PushConst_t { - Mat4 view_matrix; - VkDeviceAddress vertex_buf; - u32 img_ix; - u32 samp_ix; - u32 storage_ix; + Vec2 res; } PushConst; typedef struct @@ -199,7 +218,7 @@ typedef struct typedef struct { VkCommandPool pool; - VkCommandBuffer buffer; + VkCommandBuffer cmd; VkFence fence; } ImmediateStructures; @@ -230,8 +249,10 @@ typedef struct { typedef struct { u32 img_ix; u64 frame_cnt; - b8 comp_started; - b8 gfx_started; + b8 begin_rendering; + PipelineHandle last_pipeline; + RenderBuffer *prev_buffers; + u32 prev_buffer_count; } FrameState; typedef struct { @@ -258,13 +279,14 @@ typedef struct { b8 resized; } PendingUpdates; -typedef struct { +typedef struct Renderer_t +{ Vulkan_t vk; FrameState frame_state; PendingUpdates pending; Arena *arena; Arena *perm_arena; -} Renderer_t; +} Renderer; // Renderer Function Declarations @@ -307,6 +329,14 @@ static VkSemaphore GetFrameRenderSem(); static VkSemaphore GetFrameSwapSem(); static u32 GetFrameIndex(); static VkImage GetFrameSwapImage(); +static void BeginRendering(); + +// Immediate Submit +static b32 BeginImmSubmit(VkDevice device, VkFence *fence, VkCommandBuffer cmd); +static b32 FinishImmSubmit(VkDevice device, VkFence *fence, VkCommandBuffer cmd, VkQueue queue); + +// Buffers +static b32 UploadGUIBuffer(MeshBuffer *buf, GUIContext *ctx); // Destroy static void DestroyVulkan(); @@ -323,11 +353,16 @@ static VkExtent2D SelectSwapchainExtent(VkSurfaceCapabilitiesKHR *capabilities); static VkSurfaceFormatKHR SelectSwapchainFormat(VkSurfaceFormatKHR *formats); static void ResizeSwapchain(); +// Logging +static void VkInfo(const char *str); +static void VkWarn(const char *str); +static void VkError(const char *str); + // Renderer Functions Declarations END #include "vulkan_config.c" -static Renderer_t renderer = { +static Renderer renderer = { .vk = { .queues = { .graphics = -1, @@ -360,15 +395,3 @@ static char *vulkan_libs[] = { #endif -// BACKEND API - -// Init -b32 _InitRenderer(Arena *arena); -void _DestroyRenderer(); - -// Rendering -static b32 _BeginFrame(); -static void _DrawTriangle(); -static b32 _FinishFrame(); -static void _SetRenderResolution(u32 x, u32 y); - diff --git a/src/shaders/glsl/gui.frag.glsl b/src/shaders/glsl/gui.frag.glsl new file mode 100644 index 0000000..dbc5066 --- /dev/null +++ b/src/shaders/glsl/gui.frag.glsl @@ -0,0 +1,15 @@ +#version 460 + +#extension GL_EXT_buffer_reference : require +#extension GL_GOOGLE_include_directive : require + +#include "structures.glsl" + +layout (location = 0) in vec4 in_color; + +layout (location = 0) out vec4 out_frag_col; + +void main() +{ + out_frag_col = in_color; +} diff --git a/src/shaders/glsl/gui.vert.glsl b/src/shaders/glsl/gui.vert.glsl new file mode 100644 index 0000000..d8b5495 --- /dev/null +++ b/src/shaders/glsl/gui.vert.glsl @@ -0,0 +1,36 @@ +#version 460 + +#extension GL_EXT_buffer_reference : require +#extension GL_GOOGLE_include_directive : require + +#include "structures.glsl" + +layout (location = 0) in vec2 in_gui_pos_0; +layout (location = 1) in vec2 in_gui_pos_1; +layout (location = 2) in vec4 in_col; + +layout (location = 0) out vec4 out_color; + +void main() +{ + vec2 p0 = in_gui_pos_0; + vec2 p1 = in_gui_pos_1; + vec4 col = in_col; + + vec2 vertices[] = { + {-1, -1}, + {-1, +1}, + {+1, -1}, + {+1, +1}, + }; + + vec2 dst_half_size = (p1 - p0) / 2; + vec2 dst_center = (p1 + p0) / 2; + vec2 dst_pos = (vertices[gl_VertexIndex] * dst_half_size * dst_center); + + out_color = col; + gl_Position = vec4(2 * dst_pos.x / Globals.res.x - 1, + 2 * dst_pos.y / Globals.res.y - 1, + 0, + 1); +} diff --git a/src/shaders/glsl/structures.glsl b/src/shaders/glsl/structures.glsl index 55d8b56..55a39b3 100644 --- a/src/shaders/glsl/structures.glsl +++ b/src/shaders/glsl/structures.glsl @@ -3,30 +3,23 @@ // ========================================== struct Vertex { - float uv_x; - float uv_y; - float x, y, z; + float uv_x; + float uv_y; + float x, y, z; +}; + +struct GUIVertex { + vec2 p0; + vec2 p1; + vec4 col; }; layout (set = 0, binding = 0) uniform GlobalUniform { - mat4 camera_view; - mat4 camera_projection; - mat4 camera_view_projection; - mat4 camera_view_inverse; - mat4 camera_projection_inverse; - mat4 camera_previous_view; - mat4 camera_previous_projection; - vec2 render_resolution; - vec2 jitter_offset; - float delta; - uint frame_count; + vec2 res; } Globals; layout (set = 0, binding = 1) uniform ShaderOptions { - float exposure; - float alpha; - int debug_display; - uint albedo_texture_indices[]; + float placeholder; } Options; layout (rgba16f, set = 0, binding = 2) uniform image2D image; @@ -36,22 +29,21 @@ layout (set = 1, binding = 0) uniform sampler2D Textures[]; layout (rgba8_snorm, set = 2, binding = 0) uniform image2D Images[]; layout (set = 3, binding = 0) uniform PBRMaterials { - vec3 albedo; - vec3 normal; - float metallic; - float roughness; - float ao; + vec3 albedo; + vec3 normal; + float metallic; + float roughness; + float ao; } Materials[]; - layout (std430, buffer_reference) readonly buffer VertexBuffer { - Vertex vertices[]; + Vertex vertices[]; }; -layout (push_constant) uniform constants { - mat4 render_matrix; - VertexBuffer vertex_buffer; - uint sampler_index; - uint image_index; - uint material_index; +layout (std430, buffer_reference) readonly buffer GUIVertexBuffer { + GUIVertex vertices[]; +}; + +layout (push_constant) uniform Constants { + vec2 res; } PC; diff --git a/src/shared_types.h b/src/shared_types.h index ca6abf3..592ed8f 100644 --- a/src/shared_types.h +++ b/src/shared_types.h @@ -1,9 +1,10 @@ #pragma once -#ifdef __linux__ - #include + +#ifdef __linux__ #include +#endif typedef int8_t i8; typedef int16_t i16; @@ -18,50 +19,33 @@ typedef uint64_t u64; typedef intptr_t intptr; typedef uintptr_t uintptr; +typedef float f32; +typedef double f64; + +typedef uint8_t b8; +typedef uint32_t b32; + +typedef void * rawptr; + +#ifdef __linux__ + typedef ssize_t isize; typedef size_t usize; -typedef float f32; -typedef double f64; - -typedef uint8_t b8; -typedef uint32_t b32; - -typedef void * rawptr; - #elif _WIN32 -#include - -typedef int8_t i8; -typedef int16_t i16; -typedef int32_t i32; -typedef int64_t i64; - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -typedef intptr_t intptr; -typedef uintptr_t uintptr; - #if defined ( _WIN64 ) + typedef int64_t isize; typedef uint64_t usize; + #elif defined ( _WIN32 ) + typedef int32_t isize; typedef uint32_t usize; + #endif -typedef float f32; -typedef double f64; - -typedef uint8_t b8; -typedef uint32_t b32; - -typedef void * rawptr; - #elif __APPLE__ || __MACH__ #else // unix @@ -179,9 +163,68 @@ typedef enum KeyboardInput_e KB_MAX } KeyboardInput; +typedef union +{ + struct { f32 r, g; }; + struct { f32 x, y; }; +} Vec2; + +typedef union +{ + struct { f32 x, y, z; }; + struct { f32 r, g, b; }; +} Vec3; + +typedef union +{ + struct { f32 x, y, z, w; }; + struct { f32 r, g, b, a; }; +} Vec4; + +typedef union +{ + struct { i32 x, y; }; + struct { i32 r, g; }; +} iVec2; + +typedef union +{ + struct { i32 x, y, z; }; + struct { i32 r, g, b; }; +} iVec3; + +typedef union +{ + struct { i32 x, y, z, w; }; + struct { i32 r, g, b, a; }; +} iVec4; + +typedef f32 Mat2[4]; +typedef f32 Mat3[9]; +typedef f32 Mat4[16]; + +typedef f64 dMat2[4]; +typedef f64 dMat3[9]; +typedef f64 dMat4[16]; + typedef struct { KeyboardInput code; b8 pressed; } GameInput; // TODO: add gamepad input +typedef struct +{ + Vec2 p0; + Vec2 p1; + Vec4 col; +} GUIVertex; + +typedef struct +{ + GUIVertex *vertices; + u32 vertices_len; + u32 *indices; + u32 indices_len; + u32 instance_count; +} GUIContext; diff --git a/src/util.c b/src/util.c index 8989a00..bbca5b1 100644 --- a/src/util.c +++ b/src/util.c @@ -26,12 +26,16 @@ i32 SPrintf(char *buf, rawptr fmt, ...) void MemZero(void *ptr, isize size) { + if (!size || !ptr) return; + isize iter_size = size > sizeof(u64) ? 8 : 1; iter_size *= 4; isize iter_len = size / iter_size; + + u64 *mem = (u64 *)ptr; + if (iter_size > sizeof(u64)) { - u64 *mem = (u64 *)ptr; while (iter_len > 0) { mem[0] = 0; @@ -41,41 +45,51 @@ void MemZero(void *ptr, isize size) mem += 4; iter_len--; } - - isize rem_len = size % iter_size; - while (rem_len > 0) - { - mem[0] = 0; - mem++; - rem_len--; - } - } - else - { - u8 *mem = (u8 *)ptr; - while (iter_len > 0) - { - mem[0] = 0; - mem[1] = 0; - mem[2] = 0; - mem[3] = 0; - mem += 4; - iter_len--; - } - - isize rem_len = size % iter_size; - while (rem_len > 0) - { - mem[0] = 0; - mem++; - rem_len--; - } } - u8 *test_ptr = (u8 *)ptr; - for (isize i = 0; i < size; i++) + u8 *byte_mem = (u8 *)mem; + isize rem_len = size % iter_size; + while (rem_len > 0) { - assert(test_ptr[i] == 0); + byte_mem[0] = 0; + byte_mem++; + rem_len--; + } +} + +void MemCpy(rawptr dst, rawptr src, usize size) +{ + isize iter_size = size > sizeof(u64) ? 8 : 1; + iter_size *= 4; + isize iter_len = size / iter_size; + + u64 *mem_dst = (u64 *)dst; + u64 *mem_src = (u64 *)src; + + if (iter_size > sizeof(size)) + { + while (iter_len > 0) + { + mem_dst[0] = mem_src[0]; + mem_dst[1] = mem_src[1]; + mem_dst[2] = mem_src[2]; + mem_dst[3] = mem_src[3]; + mem_dst += 4; + mem_src += 4; + iter_len--; + } + } + + + u8 *byte_dst = (u8 *)mem_dst; + u8 *byte_src = (u8 *)mem_src; + isize rem_len = size % iter_size; + while (rem_len > 0) + { + byte_dst[0] = byte_src[0]; + byte_dst++; + byte_src++; + rem_len--; } } diff --git a/src/util.h b/src/util.h index 650f7f5..299dc8f 100644 --- a/src/util.h +++ b/src/util.h @@ -19,52 +19,6 @@ #define IsPow2(x) ((x) != 0 && ((x) &((x) - 1)) == 0) #define PtrAdd(ptr, add) (((char *)ptr) + add) -// Types - -typedef union -{ - struct { f32 r, g; }; - struct { f32 x, y; }; -} Vec2; - -typedef union -{ - struct { f32 x, y, z; }; - struct { f32 r, g, b; }; -} Vec3; - -typedef union -{ - struct { f32 x, y, z, w; }; - struct { f32 r, g, b, a; }; -} Vec4; - -typedef union -{ - struct { i32 x, y; }; - struct { i32 r, g; }; -} iVec2; - -typedef union -{ - struct { i32 x, y, z; }; - struct { i32 r, g, b; }; -} iVec3; - -typedef union -{ - struct { i32 x, y, z, w; }; - struct { i32 r, g, b, a; }; -} iVec4; - -typedef f32 Mat2[4]; -typedef f32 Mat3[9]; -typedef f32 Mat4[16]; - -typedef f64 dMat2[4]; -typedef f64 dMat3[9]; -typedef f64 dMat4[16]; - // String Functions u32 StrLen(const char *str); b32 StrEq(const char *l, const char *r); @@ -72,6 +26,7 @@ i32 SPrintf(char *buf, rawptr fmt, ...); // Memory Functions void MemZero(void *ptr, isize size); +void MemCpy(rawptr dst, rawptr src, usize len); // Math Functions u32 u32Min(u32 l, u32 r); diff --git a/src/vulkan_config.c b/src/vulkan_config.c index e680c2e..b757ba5 100644 --- a/src/vulkan_config.c +++ b/src/vulkan_config.c @@ -424,4 +424,30 @@ VkGraphicsPipelineCreateInfo pipeline##_create_info = { \ INIT_PIPELINE_DEFAULTS(cube); +// GUI Pipeline +INIT_PIPELINE_DEFAULTS(gui); +VkVertexInputBindingDescription gui_input_bind_desc = { + .binding = 0, + .stride = sizeof(GUIVertex), + .inputRate = VK_VERTEX_INPUT_RATE_INSTANCE, +}; + +VkVertexInputAttributeDescription gui_input_descriptions[] = { + { .binding = 0, .location = 0, .format = VK_FORMAT_R32G32_SFLOAT, .offset = 0 }, + { .binding = 0, .location = 1, .format = VK_FORMAT_R32G32_SFLOAT, .offset = offsetof(GUIVertex, p1) }, + { .binding = 0, .location = 2, .format = VK_FORMAT_R32G32B32A32_SFLOAT, .offset = offsetof(GUIVertex, col) }, +}; + +VkPipelineVertexInputStateCreateInfo gui_vertex_input_info = { + .sType = STYPE(PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO), + .vertexBindingDescriptionCount = 1, + .pVertexBindingDescriptions = &gui_input_bind_desc, + .vertexAttributeDescriptionCount = Len(gui_input_descriptions), + .pVertexAttributeDescriptions = gui_input_descriptions, +}; + +static void CustomizePipelines() +{ + gui_create_info.pVertexInputState = &gui_vertex_input_info; +}