mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 18:15:14 +00:00
fmask, refactoring, fixes and mac fix(?)
This commit is contained in:
parent
1c8c009221
commit
b1db45a64d
@ -690,6 +690,7 @@ set(COMMON src/common/logging/backend.cpp
|
||||
src/common/rdtsc.h
|
||||
src/common/recursive_lock.cpp
|
||||
src/common/recursive_lock.h
|
||||
src/common/serialization.h
|
||||
src/common/sha1.h
|
||||
src/common/shared_first_mutex.h
|
||||
src/common/signal_context.h
|
||||
|
3
externals/CMakeLists.txt
vendored
3
externals/CMakeLists.txt
vendored
@ -216,7 +216,8 @@ if (NOT TARGET stb::headers)
|
||||
add_library(stb::headers ALIAS stb)
|
||||
endif()
|
||||
|
||||
if (NOT TARGET cereal::cereal)
|
||||
# cereal
|
||||
if (NOT TARGET cereal::cereal AND NOT APPLE)
|
||||
set(SKIP_PERFORMANCE_COMPARISON ON "")
|
||||
set(BUILD_SANDBOX OFF "")
|
||||
set(BUILD_TESTS OFF "")
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "core/memory.h"
|
||||
#include "emulator.h"
|
||||
#include "video_core/renderdoc.h"
|
||||
#include "video_core/renderer_vulkan/shader_cache.h"
|
||||
|
||||
Frontend::WindowSDL* g_window = nullptr;
|
||||
|
||||
@ -256,10 +257,9 @@ void Emulator::Run(std::filesystem::path file, const std::vector<std::string> ar
|
||||
}
|
||||
VideoCore::SetOutputDir(mount_captures_dir, id);
|
||||
|
||||
const auto shader_cache_dir = Common::FS::GetUserPath(Common::FS::PathType::ShaderDir) / "cache";
|
||||
if (!std::filesystem::exists(shader_cache_dir)) {
|
||||
std::filesystem::create_directories(shader_cache_dir);
|
||||
LOG_INFO(Loader, "Created shader cache directory: {}", shader_cache_dir.string());
|
||||
if (!std::filesystem::exists(SHADER_CACHE_DIR)) {
|
||||
std::filesystem::create_directories(SHADER_CACHE_DIR);
|
||||
LOG_INFO(Loader, "Created shader cache directory: {}", SHADER_CACHE_DIR.string());
|
||||
}
|
||||
// Initialize kernel and library facilities.
|
||||
Libraries::InitHLELibs(&linker->GetHLESymbols());
|
||||
|
@ -29,8 +29,6 @@ using u32 = uint32_t;
|
||||
|
||||
namespace ShaderCache {
|
||||
|
||||
const auto shader_cache_dir = Common::FS::GetUserPath(Common::FS::PathType::ShaderDir) / "cache";
|
||||
std::unordered_map<std::string, std::vector<u32>> g_ud_storage;
|
||||
|
||||
u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec) {
|
||||
u64 hash = 0;
|
||||
@ -246,8 +244,9 @@ u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec) {
|
||||
}
|
||||
|
||||
bool CheckShaderCache(std::string shader_id) {
|
||||
std::filesystem::path spirv_cache_file_path = shader_cache_dir / (shader_id + ".spv");
|
||||
std::filesystem::path resources_file_path = shader_cache_dir / (shader_id + ".resources");
|
||||
std::filesystem::path spirv_cache_file_path = SHADER_CACHE_DIR / static_cast<std::filesystem::path>(shader_id + ".spv");
|
||||
std::filesystem::path resources_file_path = SHADER_CACHE_DIR / static_cast<std::filesystem::path>(shader_id + ".resources");
|
||||
;
|
||||
|
||||
if (!std::filesystem::exists(spirv_cache_file_path)) {
|
||||
return false;
|
||||
@ -282,14 +281,17 @@ bool CheckShaderCache(std::string shader_id) {
|
||||
}
|
||||
|
||||
void GetShader(std::string shader_id, Shader::Info& info, std::vector<u32>& spv) {
|
||||
std::string spirv_cache_filename = shader_id + ".spv";
|
||||
std::filesystem::path spirv_cache_file_path = shader_cache_dir / spirv_cache_filename;
|
||||
// read spirv
|
||||
std::filesystem::path spirv_cache_filename = shader_id + ".spv";
|
||||
std::filesystem::path spirv_cache_file_path = SHADER_CACHE_DIR / spirv_cache_filename;
|
||||
Common::FS::IOFile spirv_cache_file(spirv_cache_file_path, Common::FS::FileAccessMode::Read);
|
||||
spv.resize(spirv_cache_file.GetSize() / sizeof(u32));
|
||||
spirv_cache_file.Read(spv);
|
||||
spirv_cache_file.Close();
|
||||
|
||||
std::filesystem::path resources_dump_file_path = shader_cache_dir / (shader_id + ".resources");
|
||||
// read resources
|
||||
std::filesystem::path resource_dump_filename = shader_id + ".resources";
|
||||
std::filesystem::path resources_dump_file_path = SHADER_CACHE_DIR / resource_dump_filename;
|
||||
Common::FS::IOFile resources_dump_file(resources_dump_file_path,
|
||||
Common::FS::FileAccessMode::Read);
|
||||
|
||||
@ -305,13 +307,14 @@ void GetShader(std::string shader_id, Shader::Info& info, std::vector<u32>& spv)
|
||||
}
|
||||
|
||||
void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_serialized) {
|
||||
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_filename = shader_id + ".spv";
|
||||
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);
|
||||
shader_cache_file.WriteSpan(std::span<const u32>(spv));
|
||||
shader_cache_file.Close();
|
||||
|
||||
std::filesystem::path resources_dump_file_path = shader_cache_dir / (shader_id + ".resources");
|
||||
std::filesystem::path resource_dump_filename = shader_id + ".resources";
|
||||
std::filesystem::path resources_dump_file_path = SHADER_CACHE_DIR / resource_dump_filename;
|
||||
Common::FS::IOFile resources_dump_file(resources_dump_file_path,
|
||||
Common::FS::FileAccessMode::Write);
|
||||
|
||||
@ -331,6 +334,7 @@ void SerializeInfo(std::ostream& info_serialized, Shader::Info &info) {
|
||||
ar << info.buffers;
|
||||
ar << info.images;
|
||||
ar << info.samplers;
|
||||
ar << info.fmasks;
|
||||
|
||||
}
|
||||
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace ShaderCache {
|
||||
|
||||
#define SHADER_CACHE_DIR (Common::FS::GetUserPath(Common::FS::PathType::ShaderDir) / "cache" / "portable")
|
||||
|
||||
u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec);
|
||||
void SerializeInfo(
|
||||
std::ostream& info_serialized, Shader::Info& info);
|
||||
|
@ -5,27 +5,12 @@
|
||||
#include <cereal/types/map.hpp>
|
||||
#include <cereal/types/variant.hpp>
|
||||
#include <cereal/types/utility.hpp>
|
||||
|
||||
#include "common/serialization.h"
|
||||
#include "shader_recompiler/info.h"
|
||||
|
||||
namespace cereal {
|
||||
|
||||
// boost::small_vector
|
||||
template<class Archive, class T, std::size_t N, class Alloc>
|
||||
void save(Archive& ar, boost::container::small_vector<T, N, Alloc> const& smallVector) {
|
||||
ar(static_cast<std::uint32_t>(smallVector.size()));
|
||||
for (auto const& element : smallVector)
|
||||
ar(element);
|
||||
}
|
||||
|
||||
template<class Archive, class T, std::size_t N, class Alloc>
|
||||
void load(Archive& ar, boost::container::small_vector<T, N, Alloc>& smallVector) {
|
||||
std::uint32_t elementCount;
|
||||
ar(elementCount);
|
||||
smallVector.resize(elementCount);
|
||||
for (auto& element : smallVector)
|
||||
ar(element);
|
||||
}
|
||||
|
||||
// Shader::Info::UserDataMask
|
||||
template<class Archive>
|
||||
void serialize(Archive& ar, Shader::Info::UserDataMask& mask) {
|
||||
@ -89,4 +74,10 @@ void serialize(Archive& ar, Shader::SamplerResource& sampler) {
|
||||
static_cast<u32>(sampler.disable_aniso));
|
||||
}
|
||||
|
||||
// Shader::FMaskResource
|
||||
template<class Archive>
|
||||
void serialize(Archive& ar, Shader::FMaskResource& fmask) {
|
||||
cereal::binary_data(reinterpret_cast<uint8_t*>(&fmask), sizeof(fmask));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user