Merge branch 'master' into stl_exporter

This commit is contained in:
Vladyslav_Baranovskyi_EXT
2025-02-11 10:31:05 +01:00
18 changed files with 238 additions and 85 deletions

View File

@@ -1,10 +1,12 @@
include(CheckIPOSupported)
function(SetOptimisationSettings)
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
check_ipo_supported(RESULT result)
if(result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE PARENT_SCOPE)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
check_ipo_supported(RESULT result)
if(result)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE PARENT_SCOPE)
endif()
endif()
endif()
@@ -20,7 +22,7 @@ endfunction()
function(SetWarningSettings TARGET)
if (LINUX)
target_compile_options(${TARGET} PRIVATE -Wall -Wno-unknown-pragmas)
target_compile_options(${TARGET} PRIVATE -Wall -Wno-unknown-pragmas -Werror=return-type)
elseif (WIN32)
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)

View File

@@ -23,7 +23,7 @@ namespace OpenVulkano
Observable(const T& initValue) : object(initValue) {}
Observable(T&& initValue) : object(std::forward(initValue)) {}
Observable(T&& initValue) : object(std::forward<T>(initValue)) {}
//TODO make this somehow only work for none string types to prevent issues?
/*template<typename = std::enable_if_t<std::is_default_constructible_v<T>>>
@@ -46,6 +46,8 @@ namespace OpenVulkano
template<typename = std::enable_if_t<std::is_copy_assignable_v<T>>>
operator T() const { return object; }
const T& Get() const { return object; }
operator const T&() const { return object; }
bool operator ==(const T& other) const { return object == other; }
@@ -56,13 +58,14 @@ namespace OpenVulkano
bool operator >=(const T& other) const { return object >= other; }
bool operator !() const { return !object; }
template<std::enable_if<std::is_convertible_v<T, bool>>>
operator bool() const { return static_cast<bool>(object); }
//template<typename = std::enable_if_t<std::is_convertible_v<T, bool>>>
operator bool() const requires std::convertible_to<T, bool>
{ return static_cast<bool>(object); }
auto& operator ++() { ++object; Notify(); return *this; }
auto& operator --() { --object; Notify(); return *this; }
auto& operator ++(int) { object++; Notify(); return *this; }
auto& operator --(int) { object--; Notify(); return *this; }
T operator ++(int) { T temp = *this; ++object; Notify(); return temp; }
T operator --(int) { T temp = *this; --object; Notify(); return temp; }
auto& operator +=(const T& other) { object += other; Notify(); return *this; }
auto& operator -=(const T& other) { object -= other; Notify(); return *this; }

View File

@@ -16,12 +16,32 @@
#include "Math/RGB565.hpp"
#include "Math/RGBA5551.hpp"
#include "Math/Timestamp.hpp"
#include "Data/Containers/String.hpp"
#include <yaml-cpp/yaml.h>
#include <fmt/format.h>
#include <c4/format.hpp>
namespace YAML
{
template<>
struct convert<OpenVulkano::String>
{
static Node encode(const OpenVulkano::String& string)
{
return Node(static_cast<const std::string&>(string));
}
static bool decode(const Node& node, OpenVulkano::String& string)
{
if (node.IsScalar())
{
string = node.as<std::string>();
return true;
}
return false;
}
};
template<>
struct convert<OpenVulkano::UUID>
{

View File

@@ -7,6 +7,7 @@
#include "ArchiveConfiguration.hpp"
#include "Base/Utils.hpp"
#include <archive.h>
#include <filesystem>
namespace OpenVulkano
{
@@ -34,9 +35,9 @@ namespace OpenVulkano
return std::string(tName);
}
ArchiveConfiguration ArchiveConfiguration::FromFileName(const char* fileName)
ArchiveConfiguration ArchiveConfiguration::FromFileName(std::filesystem::path fileName)
{
std::string_view fName = fileName;
std::string_view fName = fileName.string();
ArchiveConfiguration ac;
if (auto type = ArchiveType::FromExtension(fName))
{
@@ -77,4 +78,4 @@ namespace OpenVulkano
{
return COMP_MAP[static_cast<int>(compression)];
}
}
}

View File

@@ -6,6 +6,8 @@
#pragma once
#include <filesystem>
#include "ArchiveType.hpp"
#include <string>
@@ -25,7 +27,7 @@ namespace OpenVulkano
: type(archiveType), compression(compressionType), compressionLevel(level)
{}
[[nodiscard]] static ArchiveConfiguration FromFileName(const char* fileName);
[[nodiscard]] static ArchiveConfiguration FromFileName(std::filesystem::path fileName);
[[nodiscard]] std::string GetFileExtension() const;

View File

@@ -18,6 +18,12 @@ namespace OpenVulkano
namespace
{
constexpr int BUFFER_SIZE = 16384;
const char* ArchivePasswordCallbackHandler(struct archive *, void *_client_data)
{
ArchiveReader* reader = static_cast<ArchiveReader*>(_client_data);
return reader->GetPasswordCallback()();
}
}
ArchiveReader::ArchiveReader(const std::shared_ptr<spdlog::logger>& logger, std::optional<ArchiveType::Type> archiveType)
@@ -26,7 +32,15 @@ namespace OpenVulkano
ArchiveReader::ArchiveReader(const std::string& archiveFile, const std::shared_ptr<spdlog::logger>& logger, std::optional<ArchiveType::Type> archiveType)
: ArchiveReader(archiveFile.c_str(), logger, archiveType)
{}
{
}
ArchiveReader::ArchiveReader(const std::filesystem::path& archiveFile, const std::shared_ptr<spdlog::logger>& logger,
std::optional<ArchiveType::Type> archiveType)
: ArchiveReader(logger, archiveType)
{
Open(archiveFile);
}
ArchiveReader::ArchiveReader(const char* archiveFile, const std::shared_ptr<spdlog::logger>& logger, std::optional<ArchiveType::Type> archiveType)
: ArchiveReader(logger, archiveType)
@@ -42,6 +56,11 @@ namespace OpenVulkano
ArchiveReader::~ArchiveReader() = default;
void ArchiveReader::SetPasswordCallback(const decltype(m_passwordCallback)& callback)
{
archive_read_set_passphrase_callback(m_archive, this, &ArchivePasswordCallbackHandler);
}
void ArchiveReader::PrepOpen()
{
if (m_open)
@@ -55,14 +74,23 @@ namespace OpenVulkano
m_open = true;
}
bool ArchiveReader::Open(const std::filesystem::path& archiveFile)
{
PrepOpen();
if constexpr (std::is_same_v<std::filesystem::path::value_type, char>)
ChkErr(archive_read_open_filename(m_archive, (const char*)archiveFile.c_str(), BUFFER_SIZE));
else
ChkErr(archive_read_open_filename_w(m_archive, (const wchar_t*)archiveFile.c_str(), BUFFER_SIZE));
ReadNextHeader();
return HasNext();
}
bool ArchiveReader::Open(const char* archiveFile)
{
if (archiveFile[0] == '\0')
{
if (m_logger)
{
m_logger->error("Unable to open archive file with an empty name!");
}
if (m_logger) m_logger->error("Unable to open archive file with an empty name!");
return false;
}
PrepOpen();
@@ -87,14 +115,14 @@ namespace OpenVulkano
bool ArchiveReader::Open(const std::vector<std::string>& archiveFiles)
{
if (archiveFiles.empty()) return false;
ArchiveConfiguration ac = ArchiveConfiguration::FromFileName(archiveFiles.front().c_str());
const ArchiveConfiguration ac = ArchiveConfiguration::FromFileName(archiveFiles.front().c_str());
if (ac.type == ArchiveType::TAR) // TODO handle all archive types correctly
{ // Queue based approach for all archive types that do not natively support split archives
for(const std::string& file : archiveFiles)
{
m_archivesToRead.push(file);
}
bool state = Open(m_archivesToRead.front());
const bool state = Open(m_archivesToRead.front());
m_archivesToRead.pop();
return state;
}
@@ -165,20 +193,14 @@ namespace OpenVulkano
ArchiveType::Type type = *m_archiveType;
switch (type)
{
case ArchiveType::ZIP:
return archive_read_support_format_zip;
case ArchiveType::SEVEN_ZIP:
return archive_read_support_format_7zip;
case ArchiveType::CPIO:
return archive_read_support_format_cpio;
case ArchiveType::ISO:
return archive_read_support_format_iso9660;
case ArchiveType::TAR:
return archive_read_support_format_tar;
case ArchiveType::WARC:
return archive_read_support_format_warc;
case ArchiveType::XAR:
return archive_read_support_format_xar;
case ArchiveType::SEVEN_ZIP: return archive_read_support_format_7zip;
case ArchiveType::ZIP: return archive_read_support_format_zip;
case ArchiveType::CPIO: return archive_read_support_format_cpio;
case ArchiveType::ISO: return archive_read_support_format_iso9660;
case ArchiveType::TAR: return archive_read_support_format_tar;
case ArchiveType::WARC: return archive_read_support_format_warc;
case ArchiveType::XAR: return archive_read_support_format_xar;
case ArchiveType::SHAR: break; // nothing to do
}
return archive_read_support_format_all;
}
@@ -192,6 +214,28 @@ namespace OpenVulkano
}
return count;
}
size_t ArchiveReader::ExtractRemaining(const std::filesystem::path &targetDir)
{
size_t count = 0;
while (ExtractNext(targetDir))
{
count++;
}
return count;
}
size_t ArchiveReader::ExtractRemaining(const std::filesystem::path& targetDir, const std::function<void(const FileDescription&)> extractionCallback)
{
size_t count = 0;
std::optional<FileDescription> fd;
while ((fd = ExtractNext(targetDir)))
{
extractionCallback(fd.value());
count++;
}
return count;
}
bool ArchiveReader::HasNext() const
{
@@ -235,19 +279,21 @@ namespace OpenVulkano
return std::nullopt;
}
std::optional<FileDescription> ArchiveReader::ExtractNext(std::string_view targetDir)
std::optional<FileDescription> ArchiveReader::ExtractNext(const std::filesystem::path& targetDir)
{
if (SkipTill(std::filesystem::file_type::regular))
{
FileDescription fileDescription = GetNextDescription();
std::string outputFileName;
outputFileName.reserve(targetDir.size() + 1 + fileDescription.path.size());
outputFileName.append(targetDir).append("/").append(fileDescription.path);
std::string outputFilePath;
if (m_filePathRewrite)
outputFilePath = (targetDir / m_filePathRewrite(fileDescription.path)).string();
else
outputFilePath = (targetDir / fileDescription.path).string();
std::unique_ptr<archive, decltype(archive_write_free)*> a(archive_write_disk_new(), archive_write_free);
std::unique_ptr<archive_entry, decltype(archive_entry_free)*> entry(archive_entry_clone(m_archiveEntry), archive_entry_free);
const std::unique_ptr<archive, decltype(archive_write_free)*> a(archive_write_disk_new(), archive_write_free);
const std::unique_ptr<archive_entry, decltype(archive_entry_free)*> entry(archive_entry_clone(m_archiveEntry), archive_entry_free);
archive_entry_set_pathname(entry.get(), outputFileName.c_str());
archive_entry_set_pathname(entry.get(), outputFilePath.c_str());
ChkErr(archive_write_disk_set_options(a.get(), ARCHIVE_EXTRACT_TIME | ARCHIVE_EXTRACT_PERM | ARCHIVE_EXTRACT_ACL | ARCHIVE_EXTRACT_FFLAGS));

View File

@@ -12,17 +12,18 @@
#include <string_view>
#include <optional>
#include <functional>
#include <ostream>
#include <queue>
namespace OpenVulkano
{
class ArchiveReader final : public ArchiveBase
{
bool m_open = false;
bool m_eof = false;
std::optional<ArchiveType::Type> m_archiveType;
std::queue<std::string> m_archivesToRead;
std::function<const char*()> m_passwordCallback;
std::function<std::string(std::string)> m_filePathRewrite;
bool m_open = false;
bool m_eof = false;
public:
explicit ArchiveReader(const std::shared_ptr<spdlog::logger>& logger = nullptr, std::optional<ArchiveType::Type> archiveType = std::nullopt);
@@ -31,10 +32,16 @@ namespace OpenVulkano
explicit ArchiveReader(const std::string& archiveFile, const std::shared_ptr<spdlog::logger>& logger = nullptr, std::optional<ArchiveType::Type> archiveType = std::nullopt);
explicit ArchiveReader(const std::filesystem::path& archiveFile, const std::shared_ptr<spdlog::logger>& logger = nullptr, std::optional<ArchiveType::Type> archiveType = std::nullopt);
ArchiveReader(const void* archiveBuffer, size_t size, const std::shared_ptr<spdlog::logger>& logger = nullptr, std::optional<ArchiveType::Type> archiveType = std::nullopt);
~ArchiveReader() override;
void SetPasswordCallback(const decltype(m_passwordCallback)& callback);
bool Open(const std::filesystem::path& archiveFile);
bool Open(const char* archiveFile);
bool Open(const std::string& archiveFile);
@@ -47,7 +54,11 @@ namespace OpenVulkano
[[nodiscard]] bool IsOpen() const { return m_open; }
size_t ExtractRemaining(std::string_view targetDir);
[[deprecated]] size_t ExtractRemaining(std::string_view targetDir);
size_t ExtractRemaining(const std::filesystem::path& targetDir);
size_t ExtractRemaining(const std::filesystem::path& targetDir, const std::function<void(const FileDescription&)> extractionCallback);
// Element wise operations
[[nodiscard]] bool HasNext() const;
@@ -60,7 +71,9 @@ namespace OpenVulkano
std::optional<FileDescription> GetNextDirectory();
std::optional<FileDescription> ExtractNext(std::string_view targetDir);
[[deprecated]] std::optional<FileDescription> ExtractNext(std::string_view targetDir) { return ExtractNext(std::filesystem::path(targetDir)); }
std::optional<FileDescription> ExtractNext(const std::filesystem::path& targetDir);
std::optional<std::pair<FileDescription, Array<char>>> GetNextFile();
@@ -72,6 +85,12 @@ namespace OpenVulkano
bool GetNextFileAsStream(const std::function<void(const FileDescription&, std::istream&)>& streamReader);
const decltype(m_passwordCallback)& GetPasswordCallback() const { return m_passwordCallback; }
void SetPathRewriteFunction(const decltype(m_filePathRewrite)& rewriteFunc) { m_filePathRewrite = rewriteFunc; }
const decltype(m_filePathRewrite)& GetPathRewriteFunction() const { return m_filePathRewrite; }
private:
void ReadNextHeader();
std::function<int(archive*)> GetCurrentFormatReadFunc() const;

View File

@@ -11,10 +11,11 @@
#include <archive.h>
#include <archive_entry.h>
#include <iostream>
#include <units.h>
namespace OpenVulkano
{
ArchiveWriter::ArchiveWriter(const char* fileName, ArchiveConfiguration archiveConfiguration, const std::shared_ptr<spdlog::logger>& logger)
ArchiveWriter::ArchiveWriter(const char* fileName, ArchiveConfiguration archiveConfiguration, const std::shared_ptr<spdlog::logger>& logger, const char* password)
: ArchiveBase(archive_write_new(), archive_entry_new(), logger)
, m_archiveConfig(archiveConfiguration)
, m_shouldCompress(&SimpleFileTypeShouldCompressChecker)
@@ -30,9 +31,33 @@ namespace OpenVulkano
std::string level = "compression-level=" + std::to_string(archiveConfiguration.compressionLevel);
ChkErr(archive_write_set_options(m_archive, level.c_str()));
}
if (password) ChkErr(archive_write_set_passphrase(m_archive, password));
ChkErr(archive_write_open_filename(m_archive, fileName));
}
ArchiveWriter::ArchiveWriter(const std::filesystem::path& fileName, ArchiveConfiguration archiveConfiguration, const std::shared_ptr<spdlog::logger>& logger, const char* password)
: ArchiveBase(archive_write_new(), archive_entry_new(), logger)
, m_archiveConfig(archiveConfiguration)
, m_shouldCompress(&SimpleFileTypeShouldCompressChecker)
{ //TODO error handling
ChkErr(archive_write_set_format(m_archive, archiveConfiguration.GetLibArchiveArchiveType()));
if (archiveConfiguration.type == ArchiveType::TAR)
{
ChkErr(archive_write_add_filter(m_archive, archiveConfiguration.GetLibArchiveCompressionType()));
}
if (archiveConfiguration.compression != CompressionType::NONE &&
archiveConfiguration.compressionLevel > 0)
{
std::string level = "compression-level=" + std::to_string(archiveConfiguration.compressionLevel);
ChkErr(archive_write_set_options(m_archive, level.c_str()));
}
if (password) ChkErr(archive_write_set_passphrase(m_archive, password));
if constexpr (std::is_same_v<std::filesystem::path::value_type, char>)
ChkErr(archive_write_open_filename(m_archive, (const char*)fileName.c_str()));
else
ChkErr(archive_write_open_filename_w(m_archive, (const wchar_t*)fileName.c_str()));
}
ArchiveWriter::~ArchiveWriter()
{
if (m_asBuffer) { m_asBuffer->Close(); m_asBuffer = nullptr; }
@@ -53,7 +78,7 @@ namespace OpenVulkano
ChkErr(result);
LibArchiveHelper::CheckError(result, archiveDisk.get(), m_logger);
ChkErr(archive_write_finish_entry(m_archive));
m_bytesWritten += archive_entry_size(m_archiveEntry);
m_bytesWritten += static_cast<size_t>(archive_entry_size(m_archiveEntry));
return true;
}

View File

@@ -9,6 +9,7 @@
#include "ArchiveBase.hpp"
#include "ArchiveConfiguration.hpp"
#include "IArchiveWriter.hpp"
#include "Base/Observable.hpp"
namespace OpenVulkano
{
@@ -20,17 +21,23 @@ namespace OpenVulkano
friend ArchiveStreamBufferWriter;
ArchiveConfiguration m_archiveConfig;
size_t m_bytesWritten = 0;
Observable<size_t> m_bytesWritten { 0 };
ArchiveOStream::ASBufferPtr m_asBuffer = nullptr;
bool m_lastCompressed = true;
std::function<bool(const FileDescription&)> m_shouldCompress;
public:
ArchiveWriter(const char* fileName, const std::shared_ptr<spdlog::logger>& logger = nullptr)
: ArchiveWriter(fileName, ArchiveConfiguration::FromFileName(fileName), logger)
ArchiveWriter(const char* fileName, const std::shared_ptr<spdlog::logger>& logger = nullptr, const char* password = nullptr)
: ArchiveWriter(fileName, ArchiveConfiguration::FromFileName(fileName), logger, password)
{}
ArchiveWriter(const char* fileName, ArchiveConfiguration archiveConfiguration, const std::shared_ptr<spdlog::logger>& logger = nullptr);
ArchiveWriter(const char* fileName, ArchiveConfiguration archiveConfiguration, const std::shared_ptr<spdlog::logger>& logger = nullptr, const char* password = nullptr);
ArchiveWriter(const std::filesystem::path& fileName, const std::shared_ptr<spdlog::logger>& logger = nullptr, const char* password = nullptr)
: ArchiveWriter(fileName, ArchiveConfiguration::FromFileName(fileName), logger, password)
{}
ArchiveWriter(const std::filesystem::path& fileName, ArchiveConfiguration archiveConfiguration, const std::shared_ptr<spdlog::logger>& logger = nullptr, const char* password = nullptr);
~ArchiveWriter() override;
@@ -43,6 +50,8 @@ namespace OpenVulkano
void SetShouldCompressFunction(const std::function<bool(const FileDescription&)>& shouldComp) override { m_shouldCompress = shouldComp; }
decltype(m_bytesWritten)& GetBytesWrittenObservable() { return m_bytesWritten; }
private:
void WriteHeader(const FileDescription& fileDescription);
@@ -50,4 +59,4 @@ namespace OpenVulkano
void SetCompressed();
};
}
}

View File

@@ -52,7 +52,7 @@ namespace OpenVulkano
bool AddFile(const char* inArchiveName, const void* buffer, size_t length)
{
FileDescription description = FileDescription::MakeDescriptionForFile(inArchiveName, length);
FileDescription description = FileDescription::MkFile(inArchiveName, length);
return AddFile(description, buffer);
}
@@ -64,7 +64,7 @@ namespace OpenVulkano
if (buffer.first == nullptr) continue;
size += buffer.second;
}
FileDescription description = FileDescription::MakeDescriptionForFile(fileName, size);
const FileDescription description = FileDescription::MkFile(fileName, size);
return AddFile(description, buffers);
}
@@ -95,4 +95,4 @@ namespace OpenVulkano
return true;
}
};
}
}

View File

@@ -12,8 +12,8 @@ namespace OpenVulkano
{
struct FileDescription
{
constexpr static inline std::filesystem::perms ALL_READ = std::filesystem::perms::owner_read | std::filesystem::perms::group_read | std::filesystem::perms::others_read;
constexpr static inline size_t UNKNOWN_SIZE = SIZE_MAX;
constexpr static std::filesystem::perms ALL_READ = std::filesystem::perms::owner_read | std::filesystem::perms::group_read | std::filesystem::perms::others_read;
constexpr static size_t UNKNOWN_SIZE = SIZE_MAX;
std::filesystem::file_type type;
std::string path;
@@ -21,7 +21,10 @@ namespace OpenVulkano
std::filesystem::perms permissions;
time_t createTime = {}, modTime = {};
static FileDescription MakeDescriptionForFile(const char* path, size_t size)
[[deprecated("Use MkFile instead")]]
static FileDescription MakeDescriptionForFile(const char* path, const size_t size) { return MkFile(path, size); }
static FileDescription MkFile(const char* path, const size_t size)
{
return {
std::filesystem::file_type::regular,
@@ -31,5 +34,30 @@ namespace OpenVulkano
std::time(nullptr), std::time(nullptr)
};
}
static FileDescription MkFile(const std::string& path, const size_t size)
{
return {
std::filesystem::file_type::regular,
path,
size,
std::filesystem::perms::owner_write | ALL_READ,
std::time(nullptr), std::time(nullptr)
};
}
static FileDescription MkDir(const char* path)
{
FileDescription desc = MkFile(path, 0);
desc.type = std::filesystem::file_type::directory;
return desc;
}
static FileDescription MkDir(const std::string& path)
{
FileDescription desc = MkFile(path, 0);
desc.type = std::filesystem::file_type::directory;
return desc;
}
};
}

View File

@@ -56,8 +56,7 @@ namespace OpenVulkano
[[nodiscard]] std::filesystem::path GetXDGFolderDefault(const char* envName, std::string_view defaultRelativePath)
{
#ifndef TARGET_OS_IOS != 1
const char* envValue = std::getenv(envName);
if (envValue)
if (const char* envValue = std::getenv(envName))
{
if (envValue[0] == '/') return envValue;
std::cerr << "Ignoring environment '" << envName << "' (value: '" << envValue << "') because it's relative! XDG specifies it should be absolute path. Falling back to default path.";

View File

@@ -13,9 +13,9 @@ namespace OpenVulkano
{
namespace YuvUtils
{
inline void NV12FromChromaPlanes(unsigned char* __restrict src, unsigned char* __restrict dest, int chromaChannelPixelCount)
inline void NV12FromChromaPlanes(unsigned char* __restrict src, unsigned char* __restrict dest, size_t chromaChannelPixelCount)
{
for(int i = 0; i < chromaChannelPixelCount; i++)
for(size_t i = 0; i < chromaChannelPixelCount; i++)
{
dest[i * 2] = src[i];
dest[i * 2 + 1] = src[i + chromaChannelPixelCount];
@@ -45,7 +45,6 @@ namespace OpenVulkano
{
if (srcLumRowPadding)
{
uint32_t srcOffset = 0, destOffset = 0;
for(uint32_t y = 0, srcOffset = 0, destOffset = 0; y < sizeLumY; y++, srcOffset += sizeLumX + srcLumRowPadding, destOffset += sizeLumX)
{
memcpy(buffer.get() + destOffset, srcLum + srcOffset, sizeLumX);

View File

@@ -242,8 +242,8 @@ namespace OpenVulkano
{
if (format == m_format)
{
return format >= BC1_RGB_UNORM_BLOCK && format <= ASTC_12x12_SRGB_BLOCK
|| format >= ASTC_4x4_SFLOAT_BLOCK && format <= PVRTC2_4BPP_SRGB_BLOCK_IMG;
return (format >= BC1_RGB_UNORM_BLOCK && format <= ASTC_12x12_SRGB_BLOCK) ||
(format >= ASTC_4x4_SFLOAT_BLOCK && format <= PVRTC2_4BPP_SRGB_BLOCK_IMG);
}
}
return false;
@@ -268,4 +268,4 @@ namespace OpenVulkano
#ifndef __APPLE__
DataFormat DataFormat::GetFromMetalPixelFormat(int formatId) { return UNDEFINED; }
#endif
}
}

View File

@@ -130,18 +130,18 @@ namespace OpenVulkano::Scene
std::stringstream objContents;
WriteObjContents(geometry, DEFAULT_OBJ_MATERIAL_NAME, objContents);
std::string objContentsStr = objContents.str();
FileDescription objDesc = FileDescription::MakeDescriptionForFile("model.obj", objContentsStr.size());
FileDescription objDesc = FileDescription::MkFile("model.obj", objContentsStr.size());
zipWriter.AddFile(objDesc, objContentsStr.data());
}
{
FileDescription mtlDesc = FileDescription::MakeDescriptionForFile("material.mtl", DEFAULT_OBJ_MATERIAL_CONTENTS.size());
FileDescription mtlDesc = FileDescription::MkFile("material.mtl", DEFAULT_OBJ_MATERIAL_CONTENTS.size());
zipWriter.AddFile(mtlDesc, DEFAULT_OBJ_MATERIAL_CONTENTS.data());
}
if (!texturePath.empty() && std::filesystem::exists(texturePath))
{
MemMappedFile textureFile(texturePath);
FileDescription texDesc = FileDescription::MakeDescriptionForFile("texture.png", textureFile.Size());
FileDescription texDesc = FileDescription::MkFile("texture.png", textureFile.Size());
zipWriter.AddFile(texDesc, textureFile.Data());
}
}
@@ -154,14 +154,14 @@ namespace OpenVulkano::Scene
std::stringstream usdFile;
WriteUsdContents(usdFile, geometry);
std::string usdFileStr = usdFile.str();
FileDescription usdDesc = FileDescription::MakeDescriptionForFile("geometry.usda", usdFileStr.size());
FileDescription usdDesc = FileDescription::MkFile("geometry.usda", usdFileStr.size());
zipWriter.AddFile(usdDesc, usdFileStr.data());
}
if (!texturePath.empty() && std::filesystem::exists(texturePath))
{
MemMappedFile textureFile(texturePath);
FileDescription texDesc = FileDescription::MakeDescriptionForFile("texture.png", textureFile.Size());
FileDescription texDesc = FileDescription::MkFile("texture.png", textureFile.Size());
zipWriter.AddFile(texDesc, textureFile.Data());
}
}
@@ -232,4 +232,4 @@ namespace OpenVulkano::Scene
throw std::runtime_error("Unable to convert the scene to FBX: Assimp is not available!");
#endif
}
}
}

View File

@@ -154,7 +154,7 @@ namespace OpenVulkano::Scene
indices = nullptr;
}
uint32_t Geometry::GetIndex(uint32_t index) const
uint32_t Geometry::GetIndex(size_t index) const
{
uint32_t result = 0;

View File

@@ -56,7 +56,7 @@ namespace OpenVulkano
Vertex* GetVertices() const { return vertices; }
void* GetIndices() const { return indices; }
uint32_t GetIndex(uint32_t index) const;
uint32_t GetIndex(size_t index) const;
uint16_t* GetIndices16() const { return static_cast<uint16_t*>(indices); }
uint32_t* GetIndices32() const { return static_cast<uint32_t*>(indices); }
uint32_t GetIndexCount() const { return indexCount; }

View File

@@ -18,19 +18,19 @@ using namespace OpenVulkano;
namespace
{
std::string dummyArchiveDir()
std::filesystem::path dummyArchiveDir()
{
return AppFolders::GetAppTempDir().string();
return AppFolders::GetAppTempDir();
}
std::string dummyArchivePath()
std::filesystem::path dummyArchivePath()
{
return dummyArchiveDir() + "/test_archive.zip";
return dummyArchiveDir() / "test_archive.zip";
}
void makeDummyArchive()
{
ArchiveWriter writer(dummyArchivePath().c_str());
ArchiveWriter writer(dummyArchivePath());
FileDescription desc;
desc.path = "stream1.txt";
@@ -70,7 +70,7 @@ TEST_CASE("Dummy archive creation, default constructor", "[ArchiveReader]")
TEST_CASE("Open Archive from File", "[ArchiveReader]")
{
{
std::string testArchive = dummyArchivePath();
auto testArchive = dummyArchivePath();
ArchiveReader reader;
bool opened = reader.Open(testArchive);
REQUIRE(opened == true);
@@ -112,10 +112,10 @@ TEST_CASE("Open Archive from Directory with Pattern", "[ArchiveReader]")
TEST_CASE("ExtractNext and Skip Functions", "[ArchiveReader]")
{
std::string testArchive = dummyArchivePath();
auto testArchive = dummyArchivePath();
ArchiveReader reader(testArchive);
size_t extractedFiles = reader.ExtractRemaining(dummyArchiveDir().c_str());
size_t extractedFiles = reader.ExtractRemaining(dummyArchiveDir());
REQUIRE(extractedFiles > 0);
reader.SkipNext();
REQUIRE(reader.HasNext() == false);
@@ -127,7 +127,7 @@ TEST_CASE("ExtractNext and Skip Functions", "[ArchiveReader]")
TEST_CASE("Get Next File Operations", "[ArchiveReader]")
{
std::string testArchive = dummyArchivePath();
auto testArchive = dummyArchivePath();
ArchiveReader reader(testArchive);