Hardened SasquatchBaker tests + no -bigfile or -sasquatch
Bigfoot / Sonarqube (push) Skipped
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Failing after 16s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Failing after 17s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Failing after 16s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Failing after 16s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Failing after 16s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Failing after 15s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Failing after 16s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: OFF, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: game) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 0s
Bigfoot / Clang Format Checks (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/host/clang_asan (Unity Build: ON, Variant: toolmode) (push) Canceled after 6s

This commit is contained in:
2026-08-29 19:26:58 +02:00
parent a674533f80
commit 30b56cde66
17 changed files with 101 additions and 102 deletions
@@ -16,7 +16,7 @@ namespace Bigfoot
/* /*
* BigFile location * BigFile location
*/ */
constexpr eastl::string_view BIGFILE_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks-bigfile.db"}; constexpr eastl::string_view BIGFILE_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks.db"};
} // namespace Bigfoot } // namespace Bigfoot
#endif #endif
#endif #endif
@@ -16,7 +16,7 @@ namespace Bigfoot
/* /*
* Sasquatch location * Sasquatch location
*/ */
constexpr eastl::string_view SASQUATCH_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks-sasquatch.sasquatch"}; constexpr eastl::string_view SASQUATCH_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks.sasquatch"};
} // namespace Bigfoot } // namespace Bigfoot
#endif #endif
#endif #endif
@@ -9,5 +9,3 @@ target_link_libraries(${PROJECT_NAME}
$<LINK_LIBRARY:WHOLE_ARCHIVE,AssetsForBenchmarking>) $<LINK_LIBRARY:WHOLE_ARCHIVE,AssetsForBenchmarking>)
bigfoot_create_bigfile("Benchmarks/Tools") bigfoot_create_bigfile("Benchmarks/Tools")
bigfoot_create_sasquatch_info()
@@ -16,7 +16,7 @@ namespace Bigfoot
/* /*
* BigFile location * BigFile location
*/ */
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks-bigfile.db"}; constexpr eastl::string_view BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks.db"};
} // namespace Bigfoot } // namespace Bigfoot
#endif #endif
#endif #endif
@@ -1,22 +0,0 @@
// AUTO-GENERATED DO NOT TOUCH
/*********************************************************************
* \file SasquatchInfo.generated.hpp
*
*********************************************************************/
#ifndef BIGFOOT_SASQUATCHBAKERBENCHMARKS_SASQUATCHINFO_GENERATED_HPP
#define BIGFOOT_SASQUATCHBAKERBENCHMARKS_SASQUATCHINFO_GENERATED_HPP
#include <EASTL/string_view.h>
#if defined BIGFOOT_GAME
namespace Bigfoot
{
/*
* Sasquatch location
*/
constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks-sasquatch.sasquatch"};
} // namespace Bigfoot
#endif
#endif
@@ -11,10 +11,7 @@
#include <System/File/File.hpp> #include <System/File/File.hpp>
#define BIGFOOT_GAME
#include <SasquatchBakerBenchmarks/BigFileInfo_generated.hpp> #include <SasquatchBakerBenchmarks/BigFileInfo_generated.hpp>
#include <SasquatchBakerBenchmarks/SasquatchInfo_generated.hpp>
#undef BIGFOOT_GAME
#include <AssetsForBenchmarking/Asset/BenchmarkAsset.hpp> #include <AssetsForBenchmarking/Asset/BenchmarkAsset.hpp>
@@ -35,7 +32,7 @@ class SasquatchBakerFixture: public benchmark::Fixture
void SetUp(benchmark::State&) override void SetUp(benchmark::State&) override
{ {
m_bigFile.Clear(); m_bigFile.Clear();
m_sasquatch.Delete(); m_outputFile.Delete();
eastl::vector<AssetMetadata> metadatas; eastl::vector<AssetMetadata> metadatas;
eastl::vector<eastl::vector<std::byte>> flatbuffers; eastl::vector<eastl::vector<std::byte>> flatbuffers;
@@ -64,11 +61,13 @@ class SasquatchBakerFixture: public benchmark::Fixture
void TearDown(benchmark::State&) override void TearDown(benchmark::State&) override
{ {
m_sasquatch.Delete(); m_outputFile.Delete();
} }
static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION {
"./SasquatchBakerBenchmarks.sasquatch"};
BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION}}; BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION}};
File m_sasquatch {SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION}; File m_outputFile {SASQUATCH_SASQUATCHBAKERBENCHMARKS_LOCATION};
}; };
/****************************************************************************************/ /****************************************************************************************/
@@ -79,8 +78,8 @@ BENCHMARK_DEFINE_F(SasquatchBakerFixture, Bake)(benchmark::State& state)
for (auto _: state) for (auto _: state)
{ {
Bake(m_bigFile, m_sasquatch); Bake(m_bigFile, m_outputFile);
bytesProcessed += static_cast<std::int64_t>(m_sasquatch.GetSize()); bytesProcessed += static_cast<std::int64_t>(m_outputFile.GetSize());
} }
state.SetItemsProcessed(state.iterations() * ASSET_COUNT); state.SetItemsProcessed(state.iterations() * ASSET_COUNT);
@@ -63,6 +63,7 @@ class BigFile: public DataAccessor
* \param p_uuid The asset to get the flatbuffer of * \param p_uuid The asset to get the flatbuffer of
* \return The flatbuffer, or nullopt if the asset was not found * \return The flatbuffer, or nullopt if the asset was not found
*/ */
[[nodiscard]]
eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const override; eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const override;
/** /**
@@ -71,6 +72,7 @@ class BigFile: public DataAccessor
* \param p_uuids The assets to get the flatbuffers of * \param p_uuids The assets to get the flatbuffers of
* \return The flatbuffers that were found * \return The flatbuffers that were found
*/ */
[[nodiscard]]
eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const override; eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const override;
/** /**
@@ -79,6 +81,7 @@ class BigFile: public DataAccessor
* \param p_uuid The asset to get the metadata of * \param p_uuid The asset to get the metadata of
* \return The metadata, or nullopt if the asset was not found * \return The metadata, or nullopt if the asset was not found
*/ */
[[nodiscard]]
AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override; AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override;
/** /**
@@ -87,6 +90,7 @@ class BigFile: public DataAccessor
* \param p_uuids The assets to get the metadatas of * \param p_uuids The assets to get the metadatas of
* \return The metadatas that were found * \return The metadatas that were found
*/ */
[[nodiscard]]
eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const override; eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const override;
/** /**
@@ -95,6 +99,7 @@ class BigFile: public DataAccessor
* \param p_uuid The asset to get the HardReferences of * \param p_uuid The asset to get the HardReferences of
* \return The HardReferences of the asset * \return The HardReferences of the asset
*/ */
[[nodiscard]]
eastl::vector<UUID> GetAssetHardReferences(const UUID& p_uuid) const override; eastl::vector<UUID> GetAssetHardReferences(const UUID& p_uuid) const override;
/** /**
@@ -103,6 +108,7 @@ class BigFile: public DataAccessor
* \param p_uuids The assets to get the HardReferences of * \param p_uuids The assets to get the HardReferences of
* \return The HardReferences of the assets * \return The HardReferences of the assets
*/ */
[[nodiscard]]
eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const override; eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const override;
/** /**
@@ -112,6 +118,7 @@ class BigFile: public DataAccessor
* \p_flatbuffer The flatbuffer of the asset * \p_flatbuffer The flatbuffer of the asset
* \param p_hardReferences The HardReferences the asset points to * \param p_hardReferences The HardReferences the asset points to
*/ */
[[nodiscard]]
void SaveAssetFlatbuffer(const AssetMetadata& p_metadata, void SaveAssetFlatbuffer(const AssetMetadata& p_metadata,
const eastl::span<const std::byte> p_flatbuffer, const eastl::span<const std::byte> p_flatbuffer,
const eastl::span<const UUID> p_hardReferences) override; const eastl::span<const UUID> p_hardReferences) override;
@@ -123,6 +130,7 @@ class BigFile: public DataAccessor
* \p_flatbuffers The flatbuffers of the assets, matching p_metadatas by index * \p_flatbuffers The flatbuffers of the assets, matching p_metadatas by index
* \param p_hardReferences The HardReferences the asset points to * \param p_hardReferences The HardReferences the asset points to
*/ */
[[nodiscard]]
void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas, void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas,
eastl::span<const eastl::vector<std::byte>> p_flatbuffers, eastl::span<const eastl::vector<std::byte>> p_flatbuffers,
const eastl::span<const eastl::vector<UUID>> p_uuids) override; const eastl::span<const eastl::vector<UUID>> p_uuids) override;
@@ -133,6 +141,7 @@ class BigFile: public DataAccessor
* \param p_uuid The asset to check * \param p_uuid The asset to check
* \param True if it exists, false otherwise * \param True if it exists, false otherwise
*/ */
[[nodiscard]]
bool Has(const UUID& p_uuid) const override; bool Has(const UUID& p_uuid) const override;
BigFile& operator=(const BigFile& p_bigFile) = delete; BigFile& operator=(const BigFile& p_bigFile) = delete;
@@ -45,6 +45,7 @@ class DataAccessor
* \param p_uuid The asset to get the flatbuffer of * \param p_uuid The asset to get the flatbuffer of
* \return The flatbuffer, or nullopt if the asset was not found * \return The flatbuffer, or nullopt if the asset was not found
*/ */
[[nodiscard]]
virtual eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const = 0; virtual eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const = 0;
/** /**
@@ -53,6 +54,7 @@ class DataAccessor
* \param p_uuids The assets to get the flatbuffers of * \param p_uuids The assets to get the flatbuffers of
* \return The flatbuffers that were found * \return The flatbuffers that were found
*/ */
[[nodiscard]]
virtual eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const = 0; virtual eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const = 0;
/** /**
@@ -61,6 +63,7 @@ class DataAccessor
* \param p_uuid The asset to get the metadata of * \param p_uuid The asset to get the metadata of
* \return The metadata, or nullopt if the asset was not found * \return The metadata, or nullopt if the asset was not found
*/ */
[[nodiscard]]
virtual AssetMetadata GetAssetMetadata(const UUID& p_uuid) const = 0; virtual AssetMetadata GetAssetMetadata(const UUID& p_uuid) const = 0;
/** /**
@@ -69,6 +72,7 @@ class DataAccessor
* \param p_uuids The assets to get the metadatas of * \param p_uuids The assets to get the metadatas of
* \return The metadatas that were found * \return The metadatas that were found
*/ */
[[nodiscard]]
virtual eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const = 0; virtual eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const = 0;
/** /**
@@ -77,6 +81,7 @@ class DataAccessor
* \param p_uuid The asset to get the HardReferences of * \param p_uuid The asset to get the HardReferences of
* \return The HardReferences of the asset * \return The HardReferences of the asset
*/ */
[[nodiscard]]
virtual eastl::vector<UUID> GetAssetHardReferences(const UUID& p_uuid) const = 0; virtual eastl::vector<UUID> GetAssetHardReferences(const UUID& p_uuid) const = 0;
/** /**
@@ -85,6 +90,7 @@ class DataAccessor
* \param p_uuids The assets to get the HardReferences of * \param p_uuids The assets to get the HardReferences of
* \return The HardReferences of the assets * \return The HardReferences of the assets
*/ */
[[nodiscard]]
virtual eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const = 0; virtual eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const = 0;
/** /**
@@ -94,6 +100,7 @@ class DataAccessor
* \p_flatbuffer The flatbuffer of the asset * \p_flatbuffer The flatbuffer of the asset
* \param p_hardReferences The HardReferences the asset points to * \param p_hardReferences The HardReferences the asset points to
*/ */
[[nodiscard]]
virtual void SaveAssetFlatbuffer(const AssetMetadata& p_metadata, virtual void SaveAssetFlatbuffer(const AssetMetadata& p_metadata,
const eastl::span<const std::byte> p_flatbuffer, const eastl::span<const std::byte> p_flatbuffer,
const eastl::span<const UUID> p_hardReferences) = 0; const eastl::span<const UUID> p_hardReferences) = 0;
@@ -105,6 +112,7 @@ class DataAccessor
* \p_flatbuffers The flatbuffers of the assets, matching p_metadatas by index * \p_flatbuffers The flatbuffers of the assets, matching p_metadatas by index
* \param p_hardReferences The HardReferences the asset points to * \param p_hardReferences The HardReferences the asset points to
*/ */
[[nodiscard]]
virtual void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas, virtual void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas,
eastl::span<const eastl::vector<std::byte>> p_flatbuffers, eastl::span<const eastl::vector<std::byte>> p_flatbuffers,
const eastl::span<const eastl::vector<UUID>> p_uuids) = 0; const eastl::span<const eastl::vector<UUID>> p_uuids) = 0;
@@ -115,6 +123,7 @@ class DataAccessor
* \param p_uuid The asset to check * \param p_uuid The asset to check
* \param True if it exists, false otherwise * \param True if it exists, false otherwise
*/ */
[[nodiscard]]
virtual bool Has(const UUID& p_uuid) const = 0; virtual bool Has(const UUID& p_uuid) const = 0;
DataAccessor& operator=(const DataAccessor& p_accessor) = default; DataAccessor& operator=(const DataAccessor& p_accessor) = default;
@@ -117,11 +117,9 @@ class SasquatchWriter
*/ */
eastl::vector<SasquatchEntry> m_entries; eastl::vector<SasquatchEntry> m_entries;
}; };
#endif
/****************************************************************************************/ /****************************************************************************************/
#ifdef BIGFOOT_GAME
class Sasquatch: public DataAccessor class Sasquatch: public DataAccessor
{ {
public: public:
@@ -137,12 +135,20 @@ class Sasquatch: public DataAccessor
~Sasquatch() override = default; ~Sasquatch() override = default;
/**
* Get the header
*
* \return The header
*/
const SasquatchHeader& GetHeader() const;
/** /**
* Get an Asset flatbuffer * Get an Asset flatbuffer
* *
* \param p_uuid The asset to get the flatbuffer of * \param p_uuid The asset to get the flatbuffer of
* \return The flatbuffer, or nullopt if the asset was not found * \return The flatbuffer, or nullopt if the asset was not found
*/ */
[[nodiscard]]
eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const override; eastl::vector<std::byte> GetAssetFlatbuffer(const UUID& p_uuid) const override;
/** /**
@@ -151,18 +157,21 @@ class Sasquatch: public DataAccessor
* \param p_uuids The assets to get the flatbuffers of * \param p_uuids The assets to get the flatbuffers of
* \return The flatbuffers that were found * \return The flatbuffers that were found
*/ */
[[nodiscard]]
eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const override; eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const override;
/** /**
* Sasquatch only serves flatbuffers: this will always fail * Sasquatch only serves flatbuffers: this will always fail
* *
*/ */
[[nodiscard]]
AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override; AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override;
/** /**
* Sasquatch only serves flatbuffers: this will always fail * Sasquatch only serves flatbuffers: this will always fail
* *
*/ */
[[nodiscard]]
eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const override; eastl::vector<AssetMetadata> GetAssetMetadatas(eastl::span<const UUID> p_uuids) const override;
/** /**
@@ -171,6 +180,7 @@ class Sasquatch: public DataAccessor
* \param p_uuid The asset to get the HardReferences of * \param p_uuid The asset to get the HardReferences of
* \return The HardReferences of the asset * \return The HardReferences of the asset
*/ */
[[nodiscard]]
eastl::vector<UUID> GetAssetHardReferences(const UUID& p_uuid) const override; eastl::vector<UUID> GetAssetHardReferences(const UUID& p_uuid) const override;
/** /**
@@ -179,12 +189,14 @@ class Sasquatch: public DataAccessor
* \param p_uuids The assets to get the HardReferences of * \param p_uuids The assets to get the HardReferences of
* \return The HardReferences of the assets * \return The HardReferences of the assets
*/ */
[[nodiscard]]
eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const override; eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const override;
/** /**
* Sasquatch is read-only: this will always fail * Sasquatch is read-only: this will always fail
* *
*/ */
[[nodiscard]]
void SaveAssetFlatbuffer(const AssetMetadata& p_metadata, void SaveAssetFlatbuffer(const AssetMetadata& p_metadata,
eastl::span<const std::byte> p_flatbuffer, eastl::span<const std::byte> p_flatbuffer,
eastl::span<const UUID> p_hardReferences) override; eastl::span<const UUID> p_hardReferences) override;
@@ -193,6 +205,7 @@ class Sasquatch: public DataAccessor
* Sasquatch is read-only: this will always fail * Sasquatch is read-only: this will always fail
* *
*/ */
[[nodiscard]]
void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas, void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas,
eastl::span<const eastl::vector<std::byte>> p_flatbuffers, eastl::span<const eastl::vector<std::byte>> p_flatbuffers,
eastl::span<const eastl::vector<UUID>> p_hardReferences) override; eastl::span<const eastl::vector<UUID>> p_hardReferences) override;
@@ -203,6 +216,7 @@ class Sasquatch: public DataAccessor
* \param p_uuid The asset to check * \param p_uuid The asset to check
* \param True if it exists, false otherwise * \param True if it exists, false otherwise
*/ */
[[nodiscard]]
bool Has(const UUID& p_uuid) const override; bool Has(const UUID& p_uuid) const override;
Sasquatch& operator=(const Sasquatch& p_sasquatch) = delete; Sasquatch& operator=(const Sasquatch& p_sasquatch) = delete;
@@ -223,6 +237,11 @@ class Sasquatch: public DataAccessor
*/ */
MemoryMappedFile m_file; MemoryMappedFile m_file;
/**
* The sasquatch header
*/
SasquatchHeader m_header;
/** /**
* UUID to entry * UUID to entry
*/ */
+16 -12
View File
@@ -104,11 +104,9 @@ void SasquatchWriter::WriteAsset(const UUID& p_uuid,
m_entries.push_back(entry); m_entries.push_back(entry);
} }
#endif
/****************************************************************************************/ /****************************************************************************************/
#ifdef BIGFOOT_GAME
Sasquatch::Sasquatch(const File& p_file): Sasquatch::Sasquatch(const File& p_file):
m_file(p_file) m_file(p_file)
{ {
@@ -119,36 +117,35 @@ Sasquatch::Sasquatch(const File& p_file):
"Sasquatch file {} is smaller than its header", "Sasquatch file {} is smaller than its header",
p_file.GetPath()); p_file.GetPath());
SasquatchHeader header; std::memcpy(&m_header, data.data(), sizeof(SasquatchHeader));
std::memcpy(&header, data.data(), sizeof(SasquatchHeader));
CRITICAL_ASSERT(EngineAssertHandler, CRITICAL_ASSERT(EngineAssertHandler,
header.m_magic == SasquatchHeader::MAGIC, m_header.m_magic == SasquatchHeader::MAGIC,
"Sasquatch file {} has an invalid magic number (got {} / expected {})", "Sasquatch file {} has an invalid magic number (got {} / expected {})",
p_file.GetPath(), p_file.GetPath(),
header.m_magic, m_header.m_magic,
SasquatchHeader::MAGIC); SasquatchHeader::MAGIC);
CRITICAL_ASSERT(EngineAssertHandler, CRITICAL_ASSERT(EngineAssertHandler,
header.m_version == SasquatchHeader::VERSION, m_header.m_version == SasquatchHeader::VERSION,
"Sasquatch file {} has an unsupported version (got {} / expected {})", "Sasquatch file {} has an unsupported version (got {} / expected {})",
p_file.GetPath(), p_file.GetPath(),
header.m_version, m_header.m_version,
SasquatchHeader::VERSION); SasquatchHeader::VERSION);
CRITICAL_ASSERT(EngineAssertHandler, CRITICAL_ASSERT(EngineAssertHandler,
data.size() >= sizeof(SasquatchHeader) + header.m_assetCount * sizeof(SasquatchEntry), data.size() >= sizeof(SasquatchHeader) + m_header.m_assetCount * sizeof(SasquatchEntry),
"Sasquatch file {} index is truncated (got {} / expected at least {})", "Sasquatch file {} index is truncated (got {} / expected at least {})",
p_file.GetPath(), p_file.GetPath(),
data.size(), data.size(),
sizeof(SasquatchHeader) + header.m_assetCount * sizeof(SasquatchEntry)); sizeof(SasquatchHeader) + m_header.m_assetCount * sizeof(SasquatchEntry));
eastl::vector<SasquatchEntry> entries(header.m_assetCount); eastl::vector<SasquatchEntry> entries(m_header.m_assetCount);
if (!entries.empty()) if (!entries.empty())
{ {
std::memcpy(entries.data(), data.data() + sizeof(SasquatchHeader), entries.size() * sizeof(SasquatchEntry)); std::memcpy(entries.data(), data.data() + sizeof(SasquatchHeader), entries.size() * sizeof(SasquatchEntry));
} }
m_entries.reserve(header.m_assetCount); m_entries.reserve(m_header.m_assetCount);
for (const SasquatchEntry& entry: entries) for (const SasquatchEntry& entry: entries)
{ {
CRITICAL_ASSERT(EngineAssertHandler, CRITICAL_ASSERT(EngineAssertHandler,
@@ -166,6 +163,13 @@ Sasquatch::Sasquatch(const File& p_file):
/****************************************************************************************/ /****************************************************************************************/
const SasquatchHeader& Sasquatch::GetHeader() const
{
return m_header;
}
/****************************************************************************************/
eastl::vector<std::byte> Sasquatch::GetAssetFlatbuffer(const UUID& p_uuid) const eastl::vector<std::byte> Sasquatch::GetAssetFlatbuffer(const UUID& p_uuid) const
{ {
const auto it = m_entries.find(p_uuid); const auto it = m_entries.find(p_uuid);
@@ -35,11 +35,11 @@ void Bake(const BigFile& p_bigFile, const File& p_outputFile)
std::uint64_t totalHardReferencesBytes = 0; std::uint64_t totalHardReferencesBytes = 0;
{ {
BigFile::Request sizeRequest {p_bigFile, BigFile::Request sizeRequest {p_bigFile,
"SELECT COALESCE(SUM(LENGTH(AssetHardReference)), 0) FROM AssetHardReference;"}; "SELECT COALESCE(SUM(LENGTH(HardReference)), 0) FROM AssetHardReference;"};
[[maybe_unused]] [[maybe_unused]]
const bool hasSize = sizeRequest.Step(); const bool hasSize = sizeRequest.Step();
ASSERT(SasquatchBakerAssertHandler, hasSize, "Failed to sum the hardreferences sizes of the BigFile"); ASSERT(SasquatchBakerAssertHandler, hasSize, "Failed to sum the hardreferences sizes of the BigFile");
totalFlatbufferBytes = sizeRequest.Get(0); totalHardReferencesBytes = sizeRequest.Get(0);
} }
SasquatchWriter writer {p_outputFile, assetCount, totalFlatbufferBytes, totalHardReferencesBytes}; SasquatchWriter writer {p_outputFile, assetCount, totalFlatbufferBytes, totalHardReferencesBytes};
@@ -16,7 +16,7 @@ namespace Bigfoot
/* /*
* BigFile location * BigFile location
*/ */
constexpr eastl::string_view BIGFILE_ENGINETESTS_LOCATION {"./EngineTests-bigfile.db"}; constexpr eastl::string_view BIGFILE_ENGINETESTS_LOCATION {"./EngineTests.db"};
} // namespace Bigfoot } // namespace Bigfoot
#endif #endif
#endif #endif
@@ -16,7 +16,7 @@ namespace Bigfoot
/* /*
* Sasquatch location * Sasquatch location
*/ */
constexpr eastl::string_view SASQUATCH_ENGINETESTS_LOCATION {"./EngineTests-sasquatch.sasquatch"}; constexpr eastl::string_view SASQUATCH_ENGINETESTS_LOCATION {"./EngineTests.sasquatch"};
} // namespace Bigfoot } // namespace Bigfoot
#endif #endif
#endif #endif
@@ -80,6 +80,15 @@ class SasquatchFixture: public ::testing::Test
/****************************************************************************************/ /****************************************************************************************/
TEST_F(SasquatchFixture, GetHeader_ShouldGetTheHeader)
{
EXPECT_EQ(m_sasquatch->GetHeader().m_magic, SasquatchHeader::MAGIC);
EXPECT_EQ(m_sasquatch->GetHeader().m_version, SasquatchHeader::VERSION);
EXPECT_EQ(m_sasquatch->GetHeader().m_assetCount, 2);
}
/****************************************************************************************/
TEST_F(SasquatchFixture, GetAssetHardReference_ShouldReturnEmptyVectorForNonExistentUUID) TEST_F(SasquatchFixture, GetAssetHardReference_ShouldReturnEmptyVectorForNonExistentUUID)
{ {
const UUID uuid; const UUID uuid;
@@ -16,7 +16,7 @@ namespace Bigfoot
/* /*
* BigFile location * BigFile location
*/ */
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests-bigfile.db"}; constexpr eastl::string_view BIGFILE_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests.db"};
} // namespace Bigfoot } // namespace Bigfoot
#endif #endif
#endif #endif
@@ -27,57 +27,28 @@ class SasquatchBakerFixture: public ::testing::Test
void SetUp() override void SetUp() override
{ {
m_bigFile.Clear(); m_bigFile.Clear();
m_sasquatch.Delete(); m_outputFile.Delete();
}
[[nodiscard]]
SasquatchHeader ReadHeader(const eastl::vector<std::byte>& p_data)
{
SasquatchHeader header;
std::memcpy(&header, p_data.data(), sizeof(SasquatchHeader));
return header;
}
[[nodiscard]]
eastl::optional<SasquatchEntry> FindEntry(const eastl::vector<std::byte>& p_data, const UUID& p_uuid)
{
const SasquatchHeader header = ReadHeader(p_data);
for (std::uint64_t i = 0; i < header.m_assetCount; ++i)
{
SasquatchEntry entry;
std::memcpy(&entry,
p_data.data() + sizeof(SasquatchHeader) + i * sizeof(SasquatchEntry),
sizeof(SasquatchEntry));
if (UUID {entry.m_uuid} == p_uuid)
{
return entry;
}
}
return eastl::nullopt;
} }
static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERTESTS_LOCATION { static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERTESTS_LOCATION {
"./SasquatchBakerTests-sasquatch.sasquatch"}; "./SasquatchBakerTests.sasquatch"};
BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERTESTS_LOCATION}}; BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERTESTS_LOCATION}};
File m_sasquatch {SASQUATCH_SASQUATCHBAKERTESTS_LOCATION}; File m_outputFile {SASQUATCH_SASQUATCHBAKERTESTS_LOCATION};
}; };
/****************************************************************************************/ /****************************************************************************************/
TEST_F(SasquatchBakerFixture, Bake_ShouldWriteAnEmptyFileWhenTheBigFileIsEmpty) TEST_F(SasquatchBakerFixture, Bake_ShouldWriteAnEmptyFileWhenTheBigFileIsEmpty)
{ {
Bake(m_bigFile, m_sasquatch); Bake(m_bigFile, m_outputFile);
Sasquatch sasquatch {m_outputFile};
const eastl::vector<std::byte> data = m_sasquatch.Read(0, m_sasquatch.GetSize()); const eastl::vector<std::byte> data = m_outputFile.Read(0, m_outputFile.GetSize());
ASSERT_EQ(data.size(), sizeof(SasquatchHeader)); ASSERT_EQ(m_outputFile.GetSize(), sizeof(SasquatchHeader));
const SasquatchHeader header = ReadHeader(data); EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC);
EXPECT_EQ(header.m_magic, SasquatchHeader::MAGIC); EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION);
EXPECT_EQ(header.m_version, SasquatchHeader::VERSION); EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 0);
EXPECT_EQ(header.m_assetCount, 0);
} }
/****************************************************************************************/ /****************************************************************************************/
@@ -109,13 +80,16 @@ TEST_F(SasquatchBakerFixture, Bake_ShouldWriteEveryAssetOfTheBigFile)
flatbufferB, flatbufferB,
AssetB::GetHardReferences(flatbufferB)); AssetB::GetHardReferences(flatbufferB));
Bake(m_bigFile, m_sasquatch); Bake(m_bigFile, m_outputFile);
Sasquatch sasquatch {m_outputFile};
const eastl::vector<std::byte> data = m_sasquatch.Read(0, m_sasquatch.GetSize()); EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC);
const SasquatchHeader header = ReadHeader(data); EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION);
EXPECT_EQ(header.m_assetCount, 2); EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 2);
EXPECT_TRUE(FindEntry(data, assetA.GetHeader().uuid).has_value()); EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetA.GetHeader().uuid).empty());
EXPECT_TRUE(FindEntry(data, assetB.GetHeader().uuid).has_value()); EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetB.GetHeader().uuid).empty());
EXPECT_FALSE(sasquatch.GetAssetHardReferences(assetB.GetHeader().uuid).empty());
} }
} // namespace Bigfoot } // namespace Bigfoot
+3 -3
View File
@@ -8,7 +8,7 @@ function(bigfoot_create_logger)
endfunction() endfunction()
function(bigfoot_create_bigfile ParentFolder) function(bigfoot_create_bigfile ParentFolder)
set(OUTPUT_PATH_BIGFILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}-bigfile.db") set(OUTPUT_PATH_BIGFILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.db")
get_filename_component(OUTPUT_PATH_BIGFILE_ABSOLUTE ${OUTPUT_PATH_BIGFILE} ABSOLUTE) get_filename_component(OUTPUT_PATH_BIGFILE_ABSOLUTE ${OUTPUT_PATH_BIGFILE} ABSOLUTE)
get_filename_component(OUTPUT_PATH_BIGFILE_DIRECTORY ${OUTPUT_PATH_BIGFILE_ABSOLUTE} DIRECTORY) get_filename_component(OUTPUT_PATH_BIGFILE_DIRECTORY ${OUTPUT_PATH_BIGFILE_ABSOLUTE} DIRECTORY)
@@ -30,7 +30,7 @@ function(bigfoot_create_bigfile ParentFolder)
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}BigFile) add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}BigFile)
string(TOUPPER ${PROJECT_NAME} BIGFILE_NAME) string(TOUPPER ${PROJECT_NAME} BIGFILE_NAME)
set(BIGFILE_LOCATION "./${PROJECT_NAME}-bigfile.db") set(BIGFILE_LOCATION "./${PROJECT_NAME}.db")
configure_file( configure_file(
${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFileInfo_generated.hpp.in ${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFileInfo_generated.hpp.in
${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/BigFileInfo_generated.hpp ${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/BigFileInfo_generated.hpp
@@ -40,7 +40,7 @@ endfunction()
function(bigfoot_create_sasquatch_info) function(bigfoot_create_sasquatch_info)
string(TOUPPER ${PROJECT_NAME} SASQUATCH_NAME) string(TOUPPER ${PROJECT_NAME} SASQUATCH_NAME)
set(SASQUATCH_LOCATION "./${PROJECT_NAME}-sasquatch.sasquatch") set(SASQUATCH_LOCATION "./${PROJECT_NAME}.sasquatch")
configure_file( configure_file(
${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/SasquatchInfo_generated.hpp.in ${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/SasquatchInfo_generated.hpp.in
${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/SasquatchInfo_generated.hpp ${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/SasquatchInfo_generated.hpp