fix build script issue, update asset file version

This commit is contained in:
Matthew 2025-05-03 14:52:16 +10:00
parent 0c73af4374
commit ec4eb4502a
3 changed files with 20 additions and 22 deletions

View File

@ -47,14 +47,14 @@ glsl_stage_geom="-fshader-stage=geom"
glsl_stage_comp="-fshader-stage=comp" glsl_stage_comp="-fshader-stage=comp"
glsl_out="-o./shaders/glsl/" 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_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${clang_common}"
clang_release="$compiler -O2 ${clang_common}" clang_release="$compiler -O2 ${clang_common}"
clang_test="$compiler -O2 -DBUILD_TEST=1 ${clang_common}" clang_test="$compiler -O2 -DBUILD_TEST=1 ${clang_common}"
clang_link="-lpthread -lm -lrt -ldl ${render_link} -lstdc++" clang_link="-lpthread -lm -lrt -ldl ${render_link} -lstdc++"
clang_out="-o" 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_debug="$compiler -g -O0 -DBUILD_DEBUG=1 ${gcc_common}"
gcc_release="$compiler -O2 ${gcc_common} ${render_flag}" gcc_release="$compiler -O2 ${gcc_common} ${render_flag}"
gcc_test="$compiler -O0 -DBUILD_TEST=1 ${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 ar rcs libvma.a vma.o
fi fi
./Packer elif [ -v packer ] || ! [ -f Packer ]; then
$compile $source_files $compile_link $link_os_gfx $out $out_name
elif [ -v packer ]; then
$compile $packer_source_files $compile_link $link_os_gfx $packer_include_flags $out $packer_out_name $compile $packer_source_files $compile_link $link_os_gfx $packer_include_flags $out $packer_out_name
fi 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

View File

@ -63,17 +63,10 @@ static Asset apLoadTexture(TextureAsset asset_id)
u8 *img = FLMemAlloc(asset_info->len); u8 *img = FLMemAlloc(asset_info->len);
MemCpy(img, &ASSET_PACK[asset_info->data_offset], asset_info->len); MemCpy(img, &ASSET_PACK[asset_info->data_offset], asset_info->len);
int x, y, ch; asset.bytes = img;
asset.bytes = stbi_load_from_memory(img, asset_info->len, &x, &y, &ch, 4);
asset.len = asset_info->len; 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; Texture_Asset_Lookup[asset_id] = asset;
FLMemFree(img);
} }
return asset; return asset;
@ -92,6 +85,9 @@ static Asset apLoadShader(ShaderAsset asset_id)
if (asset.bytes == NULL) if (asset.bytes == NULL)
{ {
AssetFile *asset_info = Shader_Assets + asset_id; AssetFile *asset_info = Shader_Assets + asset_id;
Printfln("%llu %llu", asset_info->len, asset_info->data_offset);
asset.bytes = FLMemAlloc(asset_info->len); asset.bytes = FLMemAlloc(asset_info->len);
MemCpy(asset.bytes, &ASSET_PACK[asset_info->data_offset], asset_info->len); MemCpy(asset.bytes, &ASSET_PACK[asset_info->data_offset], asset_info->len);
asset.len = 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].bytes = NULL;
Texture_Asset_Lookup[i].len = 0; Texture_Asset_Lookup[i].len = 0;
stbi_image_free(asset.bytes); FLMemFree(asset.bytes);
break; break;
} }
} }

View File

@ -2,7 +2,7 @@
// ::Assets::Macros::Header:: // ::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)) #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; u8 *bytes;
u64 len; u64 len;
union
{
TextureAssetMeta texture_meta;
};
} Asset; } Asset;
typedef struct AssetTag typedef struct AssetTag