子项目不再共享 Conan 依赖 (#601)

* chore: 子项目之间不再共享 Conan 依赖
这可以有效减小可执行文件的体积

* chore: 修复编译

* chore: 不要复制 conanfile.txt

* Update build.yml
This commit is contained in:
刘旭 2023-05-12 18:22:02 +08:00 committed by GitHub
commit 92348d8a88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 114 additions and 75 deletions

View file

@ -5,6 +5,7 @@
#include "Logger.h"
#include "CommonSharedConstants.h"
#include <d3dcompiler.h>
#include <zstd.h>
#include "Utils.h"
// YAS 暂不支持 ARM64
@ -121,6 +122,37 @@ void serialize(Archive& ar, EffectDesc& o) {
ar& o.name& o.outSizeExpr& o.params& o.textures& o.samplers& o.passes& o.flags;
}
static bool ZstdCompress(std::span<const BYTE> src, std::vector<BYTE>& dest, int compressionLevel) noexcept {
dest.resize(ZSTD_compressBound(src.size()));
size_t size = ZSTD_compress(dest.data(), dest.size(), src.data(), src.size(), compressionLevel);
if (ZSTD_isError(size)) {
Logger::Get().Error(StrUtils::Concat("压缩失败:", ZSTD_getErrorName(size)));
return false;
}
dest.resize(size);
return true;
}
static bool ZstdDecompress(std::span<const BYTE> src, std::vector<BYTE>& dest) noexcept {
auto size = ZSTD_getFrameContentSize(src.data(), src.size());
if (size == ZSTD_CONTENTSIZE_UNKNOWN || size == ZSTD_CONTENTSIZE_ERROR) {
Logger::Get().Error("ZSTD_getFrameContentSize 失败");
return false;
}
dest.resize(size);
size = ZSTD_decompress(dest.data(), dest.size(), src.data(), src.size());
if (ZSTD_isError(size)) {
Logger::Get().Error(StrUtils::Concat("解压失败:", ZSTD_getErrorName(size)));
return false;
}
dest.resize(size);
return true;
}
static constexpr const uint32_t MAX_CACHE_COUNT = 127;
@ -209,7 +241,7 @@ bool EffectCacheManager::Load(std::wstring_view effectName, std::wstring_view ha
return false;
}
if (!Utils::ZstdDecompress(compressedBuf, buf)) {
if (!ZstdDecompress(compressedBuf, buf)) {
Logger::Get().Error("解压缓存失败");
return false;
}
@ -251,7 +283,7 @@ void EffectCacheManager::Save(std::wstring_view effectName, std::wstring_view ha
}
if (!Utils::ZstdCompress(buf, compressedBuf, CACHE_COMPRESSION_LEVEL)) {
if (!ZstdCompress(buf, compressedBuf, CACHE_COMPRESSION_LEVEL)) {
Logger::Get().Error("压缩缓存失败");
return;
}