From ec4eb4502af2006b045131639f6469499c0609ff Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 3 May 2025 14:52:16 +1000 Subject: [PATCH] fix build script issue, update asset file version --- build.sh | 21 ++++++++++++++------- src/assets.c | 15 +++++---------- src/assets.h | 6 +----- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/build.sh b/build.sh index 8c26e15..f7600db 100755 --- a/build.sh +++ b/build.sh @@ -47,14 +47,14 @@ glsl_stage_geom="-fshader-stage=geom" glsl_stage_comp="-fshader-stage=comp" glsl_out="-o./shaders/glsl/" -clang_common="${include_flags} ${render_flag} -DCOMPILER_CLANG -std=c23 -fuse-ld=mold -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 -ferror-limit=600" +clang_common="${include_flags} ${render_flag} -DCOMPILER_CLANG -std=c23 -fuse-ld=mold -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-for-loop-analysis -DVMA_STATIC_VULKAN_FUNCTIONS=0 -ferror-limit=60" clang_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common}" clang_release="$compiler -O2 ${clang_common}" clang_test="$compiler -O2 -DBUILD_TEST=1 ${clang_common}" clang_link="-lpthread -lm -lrt -ldl ${render_link} -lstdc++" clang_out="-o" -gcc_common="${include_flags} ${render_flag} -DCOMPILER_GCC -std=c23 -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 -fzero-init-padding-bits=union" +gcc_common="${include_flags} ${render_flag} -DCOMPILER_GCC -std=c23 -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 -fzero-init-padding-bits=unions" gcc_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common}" gcc_release="$compiler -O2 ${gcc_common} ${render_flag}" gcc_test="$compiler -O0 -DBUILD_TEST=1 ${gcc_common} ${render_flag}" @@ -111,10 +111,17 @@ if ! [ -f libvma.a ]; then ar rcs libvma.a vma.o fi -./Packer - -$compile $source_files $compile_link $link_os_gfx $out $out_name - -elif [ -v packer ]; then +elif [ -v packer ] || ! [ -f Packer ]; then $compile $packer_source_files $compile_link $link_os_gfx $packer_include_flags $out $packer_out_name fi + +if [ -v pack ]; then + cd .. + ./build/Packer + cd build +fi + +if ! [ -v packer ]; then + $compile $source_files $compile_link $link_os_gfx $out $out_name +fi + diff --git a/src/assets.c b/src/assets.c index a5cd9a0..1d3416d 100644 --- a/src/assets.c +++ b/src/assets.c @@ -63,17 +63,10 @@ static Asset apLoadTexture(TextureAsset asset_id) u8 *img = FLMemAlloc(asset_info->len); MemCpy(img, &ASSET_PACK[asset_info->data_offset], asset_info->len); - int x, y, ch; - asset.bytes = stbi_load_from_memory(img, asset_info->len, &x, &y, &ch, 4); - + asset.bytes = img; asset.len = asset_info->len; - asset.texture_meta.w = u32(x); - asset.texture_meta.h = u32(y); - asset.texture_meta.ch = u32(ch); Texture_Asset_Lookup[asset_id] = asset; - - FLMemFree(img); } return asset; @@ -92,6 +85,9 @@ static Asset apLoadShader(ShaderAsset asset_id) if (asset.bytes == NULL) { AssetFile *asset_info = Shader_Assets + asset_id; + + Printfln("%llu %llu", asset_info->len, asset_info->data_offset); + asset.bytes = FLMemAlloc(asset_info->len); MemCpy(asset.bytes, &ASSET_PACK[asset_info->data_offset], asset_info->len); asset.len = asset_info->len; @@ -111,8 +107,7 @@ static void apUnloadTexture(Asset asset) { Texture_Asset_Lookup[i].bytes = NULL; Texture_Asset_Lookup[i].len = 0; - stbi_image_free(asset.bytes); - + FLMemFree(asset.bytes); break; } } diff --git a/src/assets.h b/src/assets.h index 0408962..f78b1d1 100644 --- a/src/assets.h +++ b/src/assets.h @@ -2,7 +2,7 @@ // ::Assets::Macros::Header:: -#define FILE_VERSION 0 +#define FILE_VERSION 1 #define CreateMagicValue(a, b, c, d) ((u32)(d << 24) | (u32)(c << 16) | (u32)(b << 8) | (u32)(a)) @@ -78,10 +78,6 @@ typedef struct Asset { u8 *bytes; u64 len; - union - { - TextureAssetMeta texture_meta; - }; } Asset; typedef struct AssetTag