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
|
#pragma once
|
||||||
|
|
||||||
#include <cereal/archives/binary.hpp>
|
|
||||||
#include <boost/container/small_vector.hpp>
|
#include <boost/container/small_vector.hpp>
|
||||||
|
#include <cereal/archives/binary.hpp>
|
||||||
#include <common/types.h>
|
#include <common/types.h>
|
||||||
|
|
||||||
namespace cereal {
|
namespace cereal {
|
||||||
|
|
||||||
// boost::small_vector
|
// 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) {
|
void save(Archive& ar, boost::container::small_vector<T, N, Alloc> const& smallVector) {
|
||||||
ar(make_size_tag(static_cast<u32>(smallVector.size())));
|
ar(make_size_tag(static_cast<u32>(smallVector.size())));
|
||||||
for (auto const& element : smallVector)
|
for (auto const& element : smallVector)
|
||||||
ar(element);
|
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) {
|
void load(Archive& ar, boost::container::small_vector<T, N, Alloc>& smallVector) {
|
||||||
u32 elementCount;
|
u32 elementCount;
|
||||||
ar(make_size_tag(elementCount));
|
ar(make_size_tag(elementCount));
|
||||||
@ -26,4 +26,4 @@ void load(Archive& ar, boost::container::small_vector<T, N, Alloc>& smallVector)
|
|||||||
ar(element);
|
ar(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace cereal
|
@ -93,6 +93,8 @@ struct ImageResource {
|
|||||||
using ImageResourceList = boost::container::small_vector<ImageResource, NumImages>;
|
using ImageResourceList = boost::container::small_vector<ImageResource, NumImages>;
|
||||||
|
|
||||||
struct SamplerResource {
|
struct SamplerResource {
|
||||||
|
SamplerResource() = default;
|
||||||
|
|
||||||
std::variant<u32, AmdGpu::Sampler> sampler;
|
std::variant<u32, AmdGpu::Sampler> sampler;
|
||||||
u32 associated_image : 4;
|
u32 associated_image : 4;
|
||||||
u32 disable_aniso : 1;
|
u32 disable_aniso : 1;
|
||||||
|
@ -29,7 +29,6 @@ using u32 = uint32_t;
|
|||||||
|
|
||||||
namespace ShaderCache {
|
namespace ShaderCache {
|
||||||
|
|
||||||
|
|
||||||
u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec) {
|
u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec) {
|
||||||
u64 hash = 0;
|
u64 hash = 0;
|
||||||
|
|
||||||
@ -244,9 +243,11 @@ u64 CalculateSpecializationHash(const Shader::StageSpecialization& spec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CheckShaderCache(std::string shader_id) {
|
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 spirv_cache_file_path =
|
||||||
std::filesystem::path resources_file_path = SHADER_CACHE_DIR / static_cast<std::filesystem::path>(shader_id + ".resources");
|
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)) {
|
if (!std::filesystem::exists(spirv_cache_file_path)) {
|
||||||
return false;
|
return false;
|
||||||
@ -324,7 +325,7 @@ void AddShader(std::string shader_id, std::vector<u32> spv, std::ostream& info_s
|
|||||||
resources_dump_file.Close();
|
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);
|
cereal::BinaryOutputArchive ar(info_serialized);
|
||||||
ar << info.ud_mask;
|
ar << info.ud_mask;
|
||||||
ar << info.gs_copy_data;
|
ar << info.gs_copy_data;
|
||||||
@ -333,7 +334,23 @@ void SerializeInfo(std::ostream& info_serialized, Shader::Info &info) {
|
|||||||
ar << info.images;
|
ar << info.images;
|
||||||
ar << info.samplers;
|
ar << info.samplers;
|
||||||
ar << info.fmasks;
|
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
|
} // namespace ShaderCache
|
@ -2,82 +2,73 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cereal/types/array.hpp>
|
||||||
#include <cereal/types/map.hpp>
|
#include <cereal/types/map.hpp>
|
||||||
#include <cereal/types/variant.hpp>
|
|
||||||
#include <cereal/types/utility.hpp>
|
#include <cereal/types/utility.hpp>
|
||||||
|
#include <cereal/types/variant.hpp>
|
||||||
|
#include <cereal/types/vector.hpp>
|
||||||
#include "common/serialization.h"
|
#include "common/serialization.h"
|
||||||
#include "shader_recompiler/info.h"
|
#include "shader_recompiler/info.h"
|
||||||
|
|
||||||
|
#include "shader_recompiler/info.h"
|
||||||
|
|
||||||
namespace cereal {
|
namespace cereal {
|
||||||
|
|
||||||
// Shader::Info::UserDataMask
|
// Shader::Info::UserDataMask
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, Shader::Info::UserDataMask& mask) {
|
void serialize(Archive& ar, Shader::Info::UserDataMask& mask) {
|
||||||
ar(mask.mask);
|
ar(mask.mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shader::CopyShaderData
|
// Shader::CopyShaderData
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, Shader::CopyShaderData& data) {
|
void serialize(Archive& ar, Shader::CopyShaderData& data) {
|
||||||
ar(
|
ar(data.attr_map, data.num_attrs, data.output_vertices);
|
||||||
data.attr_map,
|
|
||||||
data.num_attrs,
|
|
||||||
data.output_vertices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AmdGPU::Buffer
|
// AmdGPU::Buffer
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, AmdGpu::Buffer& buffer) {
|
void serialize(Archive& ar, AmdGpu::Buffer& buffer) {
|
||||||
ar(cereal::binary_data(reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer)));
|
ar(cereal::binary_data(reinterpret_cast<uint8_t*>(&buffer), sizeof(buffer)));
|
||||||
// is base_adress cacheable?
|
// is base_adress cacheable?
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shader::BufferResource
|
// Shader::BufferResource
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, Shader::BufferResource& buffer)
|
void serialize(Archive& ar, Shader::BufferResource& buffer) {
|
||||||
{
|
ar(buffer.sharp_idx, buffer.used_types, buffer.inline_cbuf, buffer.buffer_type,
|
||||||
ar(
|
buffer.instance_attrib, buffer.is_written, buffer.is_formatted);
|
||||||
buffer.sharp_idx,
|
|
||||||
buffer.used_types,
|
|
||||||
buffer.inline_cbuf,
|
|
||||||
buffer.buffer_type,
|
|
||||||
buffer.instance_attrib,
|
|
||||||
buffer.is_written,
|
|
||||||
buffer.is_formatted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shader::ImageResource
|
// Shader::ImageResource
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, Shader::ImageResource& image)
|
void serialize(Archive& ar, Shader::ImageResource& image) {
|
||||||
{
|
ar(image.sharp_idx, image.is_depth, image.is_atomic, image.is_array, image.is_written,
|
||||||
ar(
|
image.is_r128);
|
||||||
image.sharp_idx,
|
|
||||||
image.is_depth,
|
|
||||||
image.is_atomic,
|
|
||||||
image.is_array,
|
|
||||||
image.is_written,
|
|
||||||
image.is_r128);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AmdGpu::Sampler
|
// AmdGpu::Sampler
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, AmdGpu::Sampler& sampler) {
|
void serialize(Archive& ar, AmdGpu::Sampler& sampler) {
|
||||||
ar(cereal::binary_data(reinterpret_cast<u8*>(&sampler), sizeof(sampler)));
|
ar(cereal::binary_data(reinterpret_cast<u8*>(&sampler), sizeof(sampler)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shader::SamplerResource
|
// Shader::SamplerResource
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, Shader::SamplerResource& sampler) {
|
void serialize(Archive& ar, Shader::SamplerResource& sampler) {
|
||||||
ar(sampler.sampler);
|
ar(sampler.sampler);
|
||||||
ar(static_cast<u32>(sampler.associated_image),
|
ar(static_cast<u32>(sampler.associated_image), static_cast<u32>(sampler.disable_aniso));
|
||||||
static_cast<u32>(sampler.disable_aniso));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shader::FMaskResource
|
// Shader::FMaskResource
|
||||||
template<class Archive>
|
template <class Archive>
|
||||||
void serialize(Archive& ar, Shader::FMaskResource& fmask) {
|
void serialize(Archive& ar, Shader::FMaskResource& fmask) {
|
||||||
cereal::binary_data(reinterpret_cast<uint8_t*>(&fmask), sizeof(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