temp push

This commit is contained in:
Fire Cube 2025-04-30 19:56:38 +02:00
parent cbeaf46102
commit 2aee03218c
5 changed files with 74 additions and 3 deletions

View File

@ -633,6 +633,7 @@ set(COMMON src/common/logging/backend.cpp
src/common/arch.h
src/common/assert.cpp
src/common/assert.h
src/common/binary_helper.h
src/common/bit_field.h
src/common/bounded_threadsafe_queue.h
src/common/concepts.h

View File

@ -0,0 +1,43 @@
#include <iostream>
#include <vector>
using u32 = uint32_t;
template <typename T>
void writeBin(std::ostream& os, const T& v) {
os.write(reinterpret_cast<const char*>(&v), sizeof(T));
}
template <typename T>
void readBin(std::istream& is, T& v) {
is.read(reinterpret_cast<char*>(&v), sizeof(T));
}
// Spezialfall für Arrays/Blöcke
template <typename T>
void writeBlock(std::ostream& os, const T* data, size_t count) {
os.write(reinterpret_cast<const char*>(data), sizeof(T) * count);
}
template <typename T>
void readBlock(std::istream& is, T* data, size_t count) {
is.read(reinterpret_cast<char*>(data), sizeof(T) * count);
}
// Spezialfall für Container
template <typename T>
void writeContainer(std::ostream& os, const std::vector<T>& v) {
u32 n = static_cast<u32>(v.size());
writeBin(os, n);
if (n)
writeBlock(os, v.data(), n);
}
template <typename T>
void readContainer(std::istream& is, std::vector<T>& v) {
u32 n;
readBin(is, n);
v.resize(n);
if (n)
readBlock(is, v.data(), n);
}

View File

@ -0,0 +1,28 @@
#include <iostream>
#include <vector>
#include <functional>
namespace ShaderCache {
const auto shader_cache_dir = Common::FS::GetUserPath(Common::FS::PathType::ShaderDir) / "cache";
std::string CreateShaderID(std::ostream& info_dump, std::ostream& profile_dump) {
std::ostringstream info_stream, profile_stream;
info_stream << info_dump.rdbuf();
profile_stream << profile_dump.rdbuf();
std::string combined_data = info_stream.str() + profile_stream.str();
std::hash<std::string> hasher;
size_t shader_id = hasher(combined_data);
return std::to_string(shader_id);
}
void GetShader{
}
void AddShader(std::vector<u32> spv, std::ostream& info_dump, std::ostream& profile_dump) {
std::string spirv_cache_filename = shader_name + ".spv ";
}
}

View File

@ -493,13 +493,12 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info, Shader::Runtim
DumpShader(code, info.pgm_hash, info.stage, perm_idx, "bin");
const auto ir_program = Shader::TranslateProgram(code, pools, info, runtime_info, profile);
std::string shader_name = GetShaderName(info.stage, info.pgm_hash, perm_idx);
std::string spirv_cache_filename =
shader_name + "_" + Common::g_scm_rev + ".spv ";
const auto shader_cache_dir =
Common::FS::GetUserPath(Common::FS::PathType::ShaderDir) / "cache";
std::filesystem::path spirv_cache_file_path = shader_cache_dir / spirv_cache_filename;
std::vector<u32> spv;