mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-22 18:15:14 +00:00
clang + deserialize + flattened_udbuf + fs_interpolation
This commit is contained in:
parent
4a3bbb3747
commit
0da10ee091
@ -3,21 +3,21 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cereal/archives/binary.hpp>
|
||||
#include <boost/container/small_vector.hpp>
|
||||
#include <cereal/archives/binary.hpp>
|
||||
#include <common/types.h>
|
||||
|
||||
namespace cereal {
|
||||
|
||||
// boost::small_vector
|
||||
template<class Archive, class T, std::size_t N, class Alloc>
|
||||
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(make_size_tag(static_cast<u32>(smallVector.size())));
|
||||
for (auto const& element : smallVector)
|
||||
ar(element);
|
||||
}
|
||||
|
||||
template<class Archive, class T, std::size_t N, class Alloc>
|
||||
template <class Archive, class T, std::size_t N, class Alloc>
|
||||
void load(Archive& ar, boost::container::small_vector<T, N, Alloc>& smallVector) {
|
||||
u32 elementCount;
|
||||
ar(make_size_tag(elementCount));
|
||||
@ -26,4 +26,4 @@ void load(Archive& ar, boost::container::small_vector<T, N, Alloc>& smallVector)
|
||||
ar(element);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace cereal
|
@ -93,6 +93,8 @@ struct ImageResource {
|
||||
using ImageResourceList = boost::container::small_vector<ImageResource, NumImages>;
|
||||
|
||||
struct SamplerResource {
|
||||
SamplerResource() = default;
|
||||
|
||||
std::variant<u32, AmdGpu::Sampler> sampler;
|
||||
u32 associated_image : 4;
|
||||
u32 disable_aniso : 1;
|
||||
|
@ -29,7 +29,6 @@ using u32 = uint32_t;
|
||||
|
||||
namespace ShaderCache {
|
||||
|
||||
|
||||
u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec) {
|
||||
u64 hash = 0;
|
||||
|
||||
@ -244,9 +243,11 @@ u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec) {
|
||||
}
|
||||
|
||||
bool CheckShaderCache(std::string shader_id) {
|
||||
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");
|
||||
;
|
||||
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;
|
||||
@ -324,7 +325,7 @@ void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_s
|
||||
resources_dump_file.Close();
|
||||
}
|
||||
|
||||
void SerializeInfo(std::ostream& info_serialized, Shader::Info &info) {
|
||||
void SerializeInfo(std::ostream& info_serialized, Shader::Info& info) {
|
||||
cereal::BinaryOutputArchive ar(info_serialized);
|
||||
ar << info.ud_mask;
|
||||
ar << info.gs_copy_data;
|
||||
@ -333,7 +334,23 @@ void SerializeInfo(std::ostream& info_serialized, Shader::Info &info) {
|
||||
ar << info.images;
|
||||
ar << info.samplers;
|
||||
ar << info.fmasks;
|
||||
// srt info
|
||||
ar << info.flattened_ud_buf;
|
||||
ar << info.fs_interpolation;
|
||||
}
|
||||
|
||||
void DeserializeInfo(std::istream& info_serialized, Shader::Info& info) {
|
||||
cereal::BinaryInputArchive ar(info_serialized);
|
||||
ar >> info.ud_mask;
|
||||
ar >> info.gs_copy_data;
|
||||
ar >> info.uses_patches;
|
||||
ar >> info.buffers;
|
||||
ar >> info.images;
|
||||
ar >> info.samplers;
|
||||
ar >> info.fmasks;
|
||||
// srt info
|
||||
ar >> info.flattened_ud_buf;
|
||||
ar >> info.fs_interpolation;
|
||||
}
|
||||
|
||||
} // namespace ShaderCache
|
@ -2,82 +2,73 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include <cereal/types/array.hpp>
|
||||
#include <cereal/types/map.hpp>
|
||||
#include <cereal/types/variant.hpp>
|
||||
#include <cereal/types/utility.hpp>
|
||||
|
||||
#include <cereal/types/variant.hpp>
|
||||
#include <cereal/types/vector.hpp>
|
||||
#include "common/serialization.h"
|
||||
#include "shader_recompiler/info.h"
|
||||
|
||||
#include "shader_recompiler/info.h"
|
||||
|
||||
namespace cereal {
|
||||
|
||||
// Shader::Info::UserDataMask
|
||||
template<class Archive>
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, Shader::Info::UserDataMask& mask) {
|
||||
ar(mask.mask);
|
||||
}
|
||||
|
||||
// Shader::CopyShaderData
|
||||
template<class Archive>
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, Shader::CopyShaderData& data) {
|
||||
ar(
|
||||
data.attr_map,
|
||||
data.num_attrs,
|
||||
data.output_vertices);
|
||||
ar(data.attr_map, data.num_attrs, data.output_vertices);
|
||||
}
|
||||
|
||||
// AmdGPU::Buffer
|
||||
template<class Archive>
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, AmdGpu::Buffer& buffer) {
|
||||
ar(cereal::binary_data(reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer)));
|
||||
// is base_adress cacheable?
|
||||
}
|
||||
|
||||
// Shader::BufferResource
|
||||
template<class Archive>
|
||||
void serialize(Archive& ar, Shader::BufferResource& buffer)
|
||||
{
|
||||
ar(
|
||||
buffer.sharp_idx,
|
||||
buffer.used_types,
|
||||
buffer.inline_cbuf,
|
||||
buffer.buffer_type,
|
||||
buffer.instance_attrib,
|
||||
buffer.is_written,
|
||||
buffer.is_formatted);
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, Shader::BufferResource& buffer) {
|
||||
ar(buffer.sharp_idx, buffer.used_types, buffer.inline_cbuf, buffer.buffer_type,
|
||||
buffer.instance_attrib, buffer.is_written, buffer.is_formatted);
|
||||
}
|
||||
|
||||
// Shader::ImageResource
|
||||
template<class Archive>
|
||||
void serialize(Archive& ar, Shader::ImageResource& image)
|
||||
{
|
||||
ar(
|
||||
image.sharp_idx,
|
||||
image.is_depth,
|
||||
image.is_atomic,
|
||||
image.is_array,
|
||||
image.is_written,
|
||||
image.is_r128);
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, Shader::ImageResource& image) {
|
||||
ar(image.sharp_idx, image.is_depth, image.is_atomic, image.is_array, image.is_written,
|
||||
image.is_r128);
|
||||
}
|
||||
|
||||
// AmdGpu::Sampler
|
||||
template<class Archive>
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, AmdGpu::Sampler& sampler) {
|
||||
ar(cereal::binary_data(reinterpret_cast<u8*>(&sampler), sizeof(sampler)));
|
||||
}
|
||||
|
||||
// Shader::SamplerResource
|
||||
template<class Archive>
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, Shader::SamplerResource& sampler) {
|
||||
ar(sampler.sampler);
|
||||
ar(static_cast<u32>(sampler.associated_image),
|
||||
static_cast<u32>(sampler.disable_aniso));
|
||||
ar(static_cast<u32>(sampler.associated_image), static_cast<u32>(sampler.disable_aniso));
|
||||
}
|
||||
|
||||
// Shader::FMaskResource
|
||||
template<class Archive>
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, Shader::FMaskResource& fmask) {
|
||||
cereal::binary_data(reinterpret_cast<uint8_t*>(&fmask), sizeof(fmask));
|
||||
}
|
||||
|
||||
// Shader::Info::Interpolation
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, Shader::Info::Interpolation& interpolation) {
|
||||
ar(interpolation.primary, interpolation.auxiliary);
|
||||
}
|
||||
} // namespace cereal
|
Loading…
Reference in New Issue
Block a user