BigFile/Sasquatch #1
@@ -16,7 +16,7 @@ namespace Bigfoot
|
||||
/*
|
||||
* BigFile location
|
||||
*/
|
||||
constexpr eastl::string_view BIGFILE_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks-bigfile.db"};
|
||||
constexpr eastl::string_view BIGFILE_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks.db"};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Bigfoot
|
||||
/*
|
||||
* Sasquatch location
|
||||
*/
|
||||
constexpr eastl::string_view SASQUATCH_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks-sasquatch.sasquatch"};
|
||||
constexpr eastl::string_view SASQUATCH_ENGINEBENCHMARKS_LOCATION {"./EngineBenchmarks.sasquatch"};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -9,5 +9,3 @@ target_link_libraries(${PROJECT_NAME}
|
||||
$<LINK_LIBRARY:WHOLE_ARCHIVE,AssetsForBenchmarking>)
|
||||
|
||||
bigfoot_create_bigfile("Benchmarks/Tools")
|
||||
|
||||
bigfoot_create_sasquatch_info()
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace Bigfoot
|
||||
/*
|
||||
* BigFile location
|
||||
*/
|
||||
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks-bigfile.db"};
|
||||
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERBENCHMARKS_LOCATION {"./SasquatchBakerBenchmarks.db"};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
|
||||
-22
@@ -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>
|
||||
|
||||
#define BIGFOOT_GAME
|
||||
#include <SasquatchBakerBenchmarks/BigFileInfo_generated.hpp>
|
||||
#include <SasquatchBakerBenchmarks/SasquatchInfo_generated.hpp>
|
||||
#undef BIGFOOT_GAME
|
||||
|
||||
#include <AssetsForBenchmarking/Asset/BenchmarkAsset.hpp>
|
||||
|
||||
@@ -35,7 +32,7 @@ class SasquatchBakerFixture: public benchmark::Fixture
|
||||
void SetUp(benchmark::State&) override
|
||||
{
|
||||
m_bigFile.Clear();
|
||||
m_sasquatch.Delete();
|
||||
m_outputFile.Delete();
|
||||
|
||||
eastl::vector<AssetMetadata> metadatas;
|
||||
eastl::vector<eastl::vector<std::byte>> flatbuffers;
|
||||
@@ -64,11 +61,13 @@ class SasquatchBakerFixture: public benchmark::Fixture
|
||||
|
||||
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}};
|
||||
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)
|
||||
{
|
||||
Bake(m_bigFile, m_sasquatch);
|
||||
bytesProcessed += static_cast<std::int64_t>(m_sasquatch.GetSize());
|
||||
Bake(m_bigFile, m_outputFile);
|
||||
bytesProcessed += static_cast<std::int64_t>(m_outputFile.GetSize());
|
||||
}
|
||||
|
||||
state.SetItemsProcessed(state.iterations() * ASSET_COUNT);
|
||||
|
||||
@@ -63,6 +63,7 @@ class BigFile: public DataAccessor
|
||||
* \param p_uuid The asset to get the flatbuffer of
|
||||
* \return The flatbuffer, or nullopt if the asset was not found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The flatbuffers that were found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The metadata, or nullopt if the asset was not found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The metadatas that were found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The HardReferences of the asset
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The HardReferences of the assets
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \param p_hardReferences The HardReferences the asset points to
|
||||
*/
|
||||
[[nodiscard]]
|
||||
void SaveAssetFlatbuffer(const AssetMetadata& p_metadata,
|
||||
const eastl::span<const std::byte> p_flatbuffer,
|
||||
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
|
||||
* \param p_hardReferences The HardReferences the asset points to
|
||||
*/
|
||||
[[nodiscard]]
|
||||
void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas,
|
||||
eastl::span<const eastl::vector<std::byte>> p_flatbuffers,
|
||||
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 True if it exists, false otherwise
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool Has(const UUID& p_uuid) const override;
|
||||
|
||||
BigFile& operator=(const BigFile& p_bigFile) = delete;
|
||||
|
||||
@@ -45,6 +45,7 @@ class DataAccessor
|
||||
* \param p_uuid The asset to get the flatbuffer of
|
||||
* \return The flatbuffer, or nullopt if the asset was not found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The flatbuffers that were found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The metadata, or nullopt if the asset was not found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The metadatas that were found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The HardReferences of the asset
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The HardReferences of the assets
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \param p_hardReferences The HardReferences the asset points to
|
||||
*/
|
||||
[[nodiscard]]
|
||||
virtual void SaveAssetFlatbuffer(const AssetMetadata& p_metadata,
|
||||
const eastl::span<const std::byte> p_flatbuffer,
|
||||
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
|
||||
* \param p_hardReferences The HardReferences the asset points to
|
||||
*/
|
||||
[[nodiscard]]
|
||||
virtual void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas,
|
||||
eastl::span<const eastl::vector<std::byte>> p_flatbuffers,
|
||||
const eastl::span<const eastl::vector<UUID>> p_uuids) = 0;
|
||||
@@ -115,6 +123,7 @@ class DataAccessor
|
||||
* \param p_uuid The asset to check
|
||||
* \param True if it exists, false otherwise
|
||||
*/
|
||||
[[nodiscard]]
|
||||
virtual bool Has(const UUID& p_uuid) const = 0;
|
||||
|
||||
DataAccessor& operator=(const DataAccessor& p_accessor) = default;
|
||||
|
||||
@@ -117,11 +117,9 @@ class SasquatchWriter
|
||||
*/
|
||||
eastl::vector<SasquatchEntry> m_entries;
|
||||
};
|
||||
#endif
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
#ifdef BIGFOOT_GAME
|
||||
class Sasquatch: public DataAccessor
|
||||
{
|
||||
public:
|
||||
@@ -137,12 +135,20 @@ class Sasquatch: public DataAccessor
|
||||
|
||||
~Sasquatch() override = default;
|
||||
|
||||
/**
|
||||
* Get the header
|
||||
*
|
||||
* \return The header
|
||||
*/
|
||||
const SasquatchHeader& GetHeader() const;
|
||||
|
||||
/**
|
||||
* Get an Asset flatbuffer
|
||||
*
|
||||
* \param p_uuid The asset to get the flatbuffer of
|
||||
* \return The flatbuffer, or nullopt if the asset was not found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The flatbuffers that were found
|
||||
*/
|
||||
[[nodiscard]]
|
||||
eastl::vector<eastl::vector<std::byte>> GetAssetFlatbuffers(eastl::span<const UUID> p_uuids) const override;
|
||||
|
||||
/**
|
||||
* Sasquatch only serves flatbuffers: this will always fail
|
||||
*
|
||||
*/
|
||||
[[nodiscard]]
|
||||
AssetMetadata GetAssetMetadata(const UUID& p_uuid) const override;
|
||||
|
||||
/**
|
||||
* Sasquatch only serves flatbuffers: this will always fail
|
||||
*
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The HardReferences of the asset
|
||||
*/
|
||||
[[nodiscard]]
|
||||
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
|
||||
* \return The HardReferences of the assets
|
||||
*/
|
||||
[[nodiscard]]
|
||||
eastl::vector<eastl::vector<UUID>> GetAssetsHardReferences(eastl::span<const UUID> p_uuids) const override;
|
||||
|
||||
/**
|
||||
* Sasquatch is read-only: this will always fail
|
||||
*
|
||||
*/
|
||||
[[nodiscard]]
|
||||
void SaveAssetFlatbuffer(const AssetMetadata& p_metadata,
|
||||
eastl::span<const std::byte> p_flatbuffer,
|
||||
eastl::span<const UUID> p_hardReferences) override;
|
||||
@@ -193,6 +205,7 @@ class Sasquatch: public DataAccessor
|
||||
* Sasquatch is read-only: this will always fail
|
||||
*
|
||||
*/
|
||||
[[nodiscard]]
|
||||
void SaveAssetFlatbuffers(eastl::span<const AssetMetadata> p_metadatas,
|
||||
eastl::span<const eastl::vector<std::byte>> p_flatbuffers,
|
||||
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 True if it exists, false otherwise
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool Has(const UUID& p_uuid) const override;
|
||||
|
||||
Sasquatch& operator=(const Sasquatch& p_sasquatch) = delete;
|
||||
@@ -223,6 +237,11 @@ class Sasquatch: public DataAccessor
|
||||
*/
|
||||
MemoryMappedFile m_file;
|
||||
|
||||
/**
|
||||
* The sasquatch header
|
||||
*/
|
||||
SasquatchHeader m_header;
|
||||
|
||||
/**
|
||||
* UUID to entry
|
||||
*/
|
||||
|
||||
@@ -104,11 +104,9 @@ void SasquatchWriter::WriteAsset(const UUID& p_uuid,
|
||||
|
||||
m_entries.push_back(entry);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
#ifdef BIGFOOT_GAME
|
||||
Sasquatch::Sasquatch(const File& p_file):
|
||||
m_file(p_file)
|
||||
{
|
||||
@@ -119,36 +117,35 @@ Sasquatch::Sasquatch(const File& p_file):
|
||||
"Sasquatch file {} is smaller than its header",
|
||||
p_file.GetPath());
|
||||
|
||||
SasquatchHeader header;
|
||||
std::memcpy(&header, data.data(), sizeof(SasquatchHeader));
|
||||
std::memcpy(&m_header, data.data(), sizeof(SasquatchHeader));
|
||||
|
||||
CRITICAL_ASSERT(EngineAssertHandler,
|
||||
header.m_magic == SasquatchHeader::MAGIC,
|
||||
m_header.m_magic == SasquatchHeader::MAGIC,
|
||||
"Sasquatch file {} has an invalid magic number (got {} / expected {})",
|
||||
p_file.GetPath(),
|
||||
header.m_magic,
|
||||
m_header.m_magic,
|
||||
SasquatchHeader::MAGIC);
|
||||
CRITICAL_ASSERT(EngineAssertHandler,
|
||||
header.m_version == SasquatchHeader::VERSION,
|
||||
m_header.m_version == SasquatchHeader::VERSION,
|
||||
"Sasquatch file {} has an unsupported version (got {} / expected {})",
|
||||
p_file.GetPath(),
|
||||
header.m_version,
|
||||
m_header.m_version,
|
||||
SasquatchHeader::VERSION);
|
||||
|
||||
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 {})",
|
||||
p_file.GetPath(),
|
||||
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())
|
||||
{
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
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;
|
||||
{
|
||||
BigFile::Request sizeRequest {p_bigFile,
|
||||
"SELECT COALESCE(SUM(LENGTH(AssetHardReference)), 0) FROM AssetHardReference;"};
|
||||
"SELECT COALESCE(SUM(LENGTH(HardReference)), 0) FROM AssetHardReference;"};
|
||||
[[maybe_unused]]
|
||||
const bool hasSize = sizeRequest.Step();
|
||||
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};
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Bigfoot
|
||||
/*
|
||||
* BigFile location
|
||||
*/
|
||||
constexpr eastl::string_view BIGFILE_ENGINETESTS_LOCATION {"./EngineTests-bigfile.db"};
|
||||
constexpr eastl::string_view BIGFILE_ENGINETESTS_LOCATION {"./EngineTests.db"};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Bigfoot
|
||||
/*
|
||||
* Sasquatch location
|
||||
*/
|
||||
constexpr eastl::string_view SASQUATCH_ENGINETESTS_LOCATION {"./EngineTests-sasquatch.sasquatch"};
|
||||
constexpr eastl::string_view SASQUATCH_ENGINETESTS_LOCATION {"./EngineTests.sasquatch"};
|
||||
} // namespace Bigfoot
|
||||
#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)
|
||||
{
|
||||
const UUID uuid;
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ namespace Bigfoot
|
||||
/*
|
||||
* BigFile location
|
||||
*/
|
||||
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests-bigfile.db"};
|
||||
constexpr eastl::string_view BIGFILE_SASQUATCHBAKERTESTS_LOCATION {"./SasquatchBakerTests.db"};
|
||||
} // namespace Bigfoot
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -27,57 +27,28 @@ class SasquatchBakerFixture: public ::testing::Test
|
||||
void SetUp() override
|
||||
{
|
||||
m_bigFile.Clear();
|
||||
m_sasquatch.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;
|
||||
m_outputFile.Delete();
|
||||
}
|
||||
|
||||
static constexpr eastl::string_view SASQUATCH_SASQUATCHBAKERTESTS_LOCATION {
|
||||
"./SasquatchBakerTests-sasquatch.sasquatch"};
|
||||
"./SasquatchBakerTests.sasquatch"};
|
||||
BigFile m_bigFile {File {BIGFILE_SASQUATCHBAKERTESTS_LOCATION}};
|
||||
File m_sasquatch {SASQUATCH_SASQUATCHBAKERTESTS_LOCATION};
|
||||
File m_outputFile {SASQUATCH_SASQUATCHBAKERTESTS_LOCATION};
|
||||
};
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
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());
|
||||
ASSERT_EQ(data.size(), sizeof(SasquatchHeader));
|
||||
const eastl::vector<std::byte> data = m_outputFile.Read(0, m_outputFile.GetSize());
|
||||
ASSERT_EQ(m_outputFile.GetSize(), sizeof(SasquatchHeader));
|
||||
|
||||
const SasquatchHeader header = ReadHeader(data);
|
||||
EXPECT_EQ(header.m_magic, SasquatchHeader::MAGIC);
|
||||
EXPECT_EQ(header.m_version, SasquatchHeader::VERSION);
|
||||
EXPECT_EQ(header.m_assetCount, 0);
|
||||
EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC);
|
||||
EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION);
|
||||
EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 0);
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
@@ -109,13 +80,16 @@ TEST_F(SasquatchBakerFixture, Bake_ShouldWriteEveryAssetOfTheBigFile)
|
||||
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());
|
||||
const SasquatchHeader header = ReadHeader(data);
|
||||
EXPECT_EQ(header.m_assetCount, 2);
|
||||
EXPECT_EQ(sasquatch.GetHeader().m_magic, SasquatchHeader::MAGIC);
|
||||
EXPECT_EQ(sasquatch.GetHeader().m_version, SasquatchHeader::VERSION);
|
||||
EXPECT_EQ(sasquatch.GetHeader().m_assetCount, 2);
|
||||
|
||||
EXPECT_TRUE(FindEntry(data, assetA.GetHeader().uuid).has_value());
|
||||
EXPECT_TRUE(FindEntry(data, assetB.GetHeader().uuid).has_value());
|
||||
EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetA.GetHeader().uuid).empty());
|
||||
EXPECT_FALSE(sasquatch.GetAssetFlatbuffer(assetB.GetHeader().uuid).empty());
|
||||
|
||||
EXPECT_FALSE(sasquatch.GetAssetHardReferences(assetB.GetHeader().uuid).empty());
|
||||
}
|
||||
} // namespace Bigfoot
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ function(bigfoot_create_logger)
|
||||
endfunction()
|
||||
|
||||
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_DIRECTORY ${OUTPUT_PATH_BIGFILE_ABSOLUTE} DIRECTORY)
|
||||
|
||||
@@ -30,7 +30,7 @@ function(bigfoot_create_bigfile ParentFolder)
|
||||
add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}BigFile)
|
||||
|
||||
string(TOUPPER ${PROJECT_NAME} BIGFILE_NAME)
|
||||
set(BIGFILE_LOCATION "./${PROJECT_NAME}-bigfile.db")
|
||||
set(BIGFILE_LOCATION "./${PROJECT_NAME}.db")
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/BigFile/BigFileInfo_generated.hpp.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/BigFileInfo_generated.hpp
|
||||
@@ -40,7 +40,7 @@ endfunction()
|
||||
|
||||
function(bigfoot_create_sasquatch_info)
|
||||
string(TOUPPER ${PROJECT_NAME} SASQUATCH_NAME)
|
||||
set(SASQUATCH_LOCATION "./${PROJECT_NAME}-sasquatch.sasquatch")
|
||||
set(SASQUATCH_LOCATION "./${PROJECT_NAME}.sasquatch")
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/Bigfoot/Sources/Engine/Include/Engine/Sasquatch/SasquatchInfo_generated.hpp.in
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Include/${PROJECT_NAME}/SasquatchInfo_generated.hpp
|
||||
|
||||
Reference in New Issue
Block a user