mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-25 03:25:17 +00:00
more
This commit is contained in:
parent
09f844add1
commit
bde3873781
@ -13,11 +13,11 @@ namespace ShaderCache {
|
|||||||
|
|
||||||
const auto shader_cache_dir = Common::FS::GetUserPath(Common::FS::PathType::ShaderDir) / "cache";
|
const auto shader_cache_dir = Common::FS::GetUserPath(Common::FS::PathType::ShaderDir) / "cache";
|
||||||
|
|
||||||
std::string CreateShaderID(u64 pgm_hash, size_t perm_idx, std::ostream& info_dump, std::ostream& profile_dump) {
|
std::string CreateShaderID(u64 pgm_hash, size_t perm_idx, std::ostream& info_serialized, std::ostream& profile_serialized) {
|
||||||
std::ostringstream info_stream, profile_stream;
|
std::ostringstream info_stream, profile_stream;
|
||||||
info_stream << pgm_hash << perm_idx;
|
info_stream << pgm_hash << perm_idx;
|
||||||
info_stream << info_dump.rdbuf();
|
info_stream << info_serialized.rdbuf();
|
||||||
profile_stream << profile_dump.rdbuf();
|
profile_stream << profile_serialized.rdbuf();
|
||||||
|
|
||||||
std::string combined_data = info_stream.str() + profile_stream.str();
|
std::string combined_data = info_stream.str() + profile_stream.str();
|
||||||
|
|
||||||
@ -26,12 +26,20 @@ std::string CreateShaderID(u64 pgm_hash, size_t perm_idx, std::ostream& info_dum
|
|||||||
return std::to_string(shader_id);
|
return std::to_string(shader_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpInfo(std::ostream& info_dump, Shader::Info info) {
|
void SerializeInfo(std::ostream& info_serialized, Shader::Info info) {
|
||||||
writeBin(info_dump, info.mrt_mask);
|
writeBin(info_serialized, info.mrt_mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpProfile(std::ostream& profile_dump, Shader::Profile profile) {
|
void DeserializeInfo(std::istream& info_serialized, Shader::Info& info) {
|
||||||
writeBin(profile_dump, profile.has_broken_spirv_clamp);
|
readBin(info_serialized, info.mrt_mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SerializeProfile(std::ostream& profile_serialized, Shader::Profile profile) {
|
||||||
|
writeBin(profile_serialized, profile.has_broken_spirv_clamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeserializeProfile(std::istream& profile_serialized, Shader::Profile& profile) {
|
||||||
|
readBin(profile_serialized, profile.has_broken_spirv_clamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckShaderCache(std::string shader_id) {
|
bool CheckShaderCache(std::string shader_id) {
|
||||||
@ -48,7 +56,7 @@ bool GetShader(std::string shader_id) {
|
|||||||
spirv_cache_file.Read(spv);
|
spirv_cache_file.Read(spv);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_dump, std::ostream& profile_dump) {
|
void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_serialized, std::ostream& profile_serialized) {
|
||||||
std::string spirv_cache_filename = shader_id + ".spv ";
|
std::string spirv_cache_filename = shader_id + ".spv ";
|
||||||
std::filesystem::path spirv_cache_file_path = shader_cache_dir / spirv_cache_filename;
|
std::filesystem::path spirv_cache_file_path = shader_cache_dir / spirv_cache_filename;
|
||||||
Common::FS::IOFile shader_cache_file(spirv_cache_file_path, Common::FS::FileAccessMode::Write);
|
Common::FS::IOFile shader_cache_file(spirv_cache_file_path, Common::FS::FileAccessMode::Write);
|
||||||
@ -58,8 +66,8 @@ void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_d
|
|||||||
Common::FS::IOFile resources_dump_file(resources_dump_file_path, Common::FS::FileAccessMode::Write);
|
Common::FS::IOFile resources_dump_file(resources_dump_file_path, Common::FS::FileAccessMode::Write);
|
||||||
// Schreibe beide Streams nacheinander in die Ressourcen-Datei
|
// Schreibe beide Streams nacheinander in die Ressourcen-Datei
|
||||||
std::ostringstream info_stream, profile_stream;
|
std::ostringstream info_stream, profile_stream;
|
||||||
info_stream << info_dump.rdbuf();
|
info_stream << info_serialized.rdbuf();
|
||||||
profile_stream << profile_dump.rdbuf();
|
profile_stream << profile_serialized.rdbuf();
|
||||||
|
|
||||||
// Schreibe zuerst die Größe des info-Dumps, dann die Daten
|
// Schreibe zuerst die Größe des info-Dumps, dann die Daten
|
||||||
u32 info_size = static_cast<u32>(info_stream.str().size());
|
u32 info_size = static_cast<u32>(info_stream.str().size());
|
||||||
@ -69,8 +77,6 @@ void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_d
|
|||||||
u32 profile_size = static_cast<u32>(profile_stream.str().size());
|
u32 profile_size = static_cast<u32>(profile_stream.str().size());
|
||||||
resources_dump_file.WriteString(
|
resources_dump_file.WriteString(
|
||||||
std::span<const char>(profile_stream.str().data(), profile_size));
|
std::span<const char>(profile_stream.str().data(), profile_size));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ShaderCache
|
} // namespace ShaderCache
|
@ -10,8 +10,8 @@ namespace ShaderCache {
|
|||||||
|
|
||||||
std::string CreateShaderID(u64 pgm_hash, size_t perm_idx, std::ostream& info_dump,
|
std::string CreateShaderID(u64 pgm_hash, size_t perm_idx, std::ostream& info_dump,
|
||||||
std::ostream& profile_dump);
|
std::ostream& profile_dump);
|
||||||
void DumpInfo(std::ostream& info_dump, Shader::Info info);
|
void SerializeInfo(std::ostream& info_dump, Shader::Info info);
|
||||||
void DumpProfile(std::ostream& profile_dump, Shader::Profile profile);
|
void SerializeProfile(std::ostream& profile_dump, Shader::Profile profile);
|
||||||
bool CheckShaderCache(std::string shader_id);
|
bool CheckShaderCache(std::string shader_id);
|
||||||
bool GetShader(std::string shader_id);
|
bool GetShader(std::string shader_id);
|
||||||
void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_dump,
|
void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_dump,
|
||||||
|
@ -493,11 +493,11 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info, Shader::Runtim
|
|||||||
perm_idx != 0 ? "(permutation)" : "");
|
perm_idx != 0 ? "(permutation)" : "");
|
||||||
DumpShader(code, info.pgm_hash, info.stage, perm_idx, "bin");
|
DumpShader(code, info.pgm_hash, info.stage, perm_idx, "bin");
|
||||||
|
|
||||||
std::ostringstream info_dump, profile_dump;
|
std::ostringstream info_serialized, profile_serialized;
|
||||||
::ShaderCache::DumpInfo(info_dump, info);
|
::ShaderCache::SerializeInfo(info_serialized, info);
|
||||||
::ShaderCache::DumpProfile(profile_dump, profile);
|
::ShaderCache::SerializeProfile(profile_serialized, profile);
|
||||||
std::string shader_id = ::ShaderCache::CreateShaderID(info.pgm_hash, perm_idx, info_dump, profile_dump);
|
std::string shader_id = ::ShaderCache::CreateShaderID(info.pgm_hash, perm_idx, info_serialized, profile_serialized);
|
||||||
::ShaderCache::AddShader(shader_id, std::vector<u32>{}, info_dump, profile_dump);
|
::ShaderCache::AddShader(shader_id, std::vector<u32>{}, info_serialized, profile_serialized);
|
||||||
LOG_INFO(Render_Vulkan, "Shader ID: {}", shader_id);
|
LOG_INFO(Render_Vulkan, "Shader ID: {}", shader_id);
|
||||||
|
|
||||||
const auto ir_program = Shader::TranslateProgram(code, pools, info, runtime_info, profile);
|
const auto ir_program = Shader::TranslateProgram(code, pools, info, runtime_info, profile);
|
||||||
|
Loading…
Reference in New Issue
Block a user