mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-18 23:07:07 -05:00
Since 2688b7646 a read and written V# element is staged in device memory
up to 16 MiB when the direct dispatch's threads times the V# stride cover
at least half of it. A raw buffer has stride 0, so it never passed and
kept the 2 MiB written window: GL storage buffers compiled by Mesa stay
bound in place in the host import however hard a dispatch sweeps them.
The PS5 OpenGL Showcase's particle update (262,144 threads, each loading
and storing its own 32-byte record of an 8 MiB SSBO) took about 53 ms of
GPU per frame on an RTX 4060 bound in place; staged it takes about 0.1 ms
plus 2.2 ms of bulk copies.
The recompiler already records the furthest byte each buffer resource's
accesses reach past their base (maxByteExtent). The binding plan now
carries it per guest buffer element (DescriptorBinding::bufferExtent,
shader disk cache format 37), and a raw element uses it as its record
size in the sweep test. Strided elements are unchanged.
83 lines
3.2 KiB
C++
83 lines
3.2 KiB
C++
#ifndef CORE_SHADER_RECOMPILER_SHADERDISKCACHE_HPP
|
|
#define CORE_SHADER_RECOMPILER_SHADERDISKCACHE_HPP
|
|
|
|
#include "CompiledVariant.hpp"
|
|
#include "IntermediateRepresentation/IrMetadata/ResourcePlan.hpp"
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <memory>
|
|
#include <span>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace ShaderRecompiler::ShaderDiskCache {
|
|
|
|
inline constexpr std::uint32_t FormatVersion = 40;
|
|
|
|
enum class LoadStatus {
|
|
Loaded,
|
|
Absent,
|
|
KeyMismatch,
|
|
Rejected,
|
|
};
|
|
|
|
struct Counters {
|
|
std::uint64_t hits = 0;
|
|
std::uint64_t misses = 0;
|
|
std::uint64_t writes = 0;
|
|
std::uint64_t loadFailures = 0;
|
|
std::uint64_t writeFailures = 0;
|
|
std::uint64_t bytesRead = 0;
|
|
std::uint64_t bytesWritten = 0;
|
|
std::uint64_t planHits = 0;
|
|
std::uint64_t planMisses = 0;
|
|
std::uint64_t planWrites = 0;
|
|
std::uint64_t planLoadFailures = 0;
|
|
std::uint64_t prebuiltHits = 0;
|
|
std::uint64_t prebuiltMisses = 0;
|
|
std::uint64_t prebuiltRejected = 0;
|
|
std::uint64_t lookupNanoseconds = 0;
|
|
std::uint64_t readNanoseconds = 0;
|
|
std::uint64_t decodeNanoseconds = 0;
|
|
std::uint64_t loadNanoseconds = 0;
|
|
std::uint64_t maxLoadNanoseconds = 0;
|
|
std::uint64_t prebuiltBytesRead = 0;
|
|
std::uint64_t prebuiltLoadNanoseconds = 0;
|
|
};
|
|
|
|
[[nodiscard]] std::uint64_t SourceVersion();
|
|
|
|
void BuildKey(const RecompileRequest& request, std::uint32_t hostSubgroupSize, std::vector<std::byte>& key);
|
|
|
|
[[nodiscard]] std::string EntryName(std::span<const std::byte> key);
|
|
|
|
void EncodeResult(const RecompileResult& result, std::vector<std::byte>& out);
|
|
[[nodiscard]] bool DecodeResult(std::span<const std::byte> bytes, RecompileResult& result, std::shared_ptr<const void> owner = nullptr);
|
|
|
|
[[nodiscard]] std::vector<std::byte> EncodeEntry(std::span<const std::byte> key, const CompiledVariant& variant);
|
|
[[nodiscard]] LoadStatus DecodeEntry(std::span<const std::byte> file, std::span<const std::byte> key, CompiledVariant& variant, std::shared_ptr<const void> owner = nullptr);
|
|
|
|
void BuildPlanKey(const RecompileRequest& request, std::uint32_t hostSubgroupSize, std::vector<std::byte>& key);
|
|
[[nodiscard]] bool EncodePlan(const IrResourcePlan& plan, std::vector<std::byte>& out);
|
|
[[nodiscard]] bool DecodePlan(std::span<const std::byte> bytes, IrResourcePlan& plan);
|
|
[[nodiscard]] std::vector<std::byte> EncodePlanEntry(std::span<const std::byte> key, const IrResourcePlan& plan);
|
|
[[nodiscard]] LoadStatus DecodePlanEntry(std::span<const std::byte> file, std::span<const std::byte> key, IrResourcePlan& plan);
|
|
|
|
[[nodiscard]] bool Enabled();
|
|
[[nodiscard]] std::filesystem::path EntryDirectory();
|
|
|
|
[[nodiscard]] bool Load(std::span<const std::byte> key, CompiledVariant& variant);
|
|
void Store(std::vector<std::byte> key, std::shared_ptr<const CompiledVariant> variant);
|
|
[[nodiscard]] std::shared_ptr<const CompiledVariant> Persist(std::span<const std::byte> key, const CompiledVariant& variant);
|
|
[[nodiscard]] bool LoadPlan(std::span<const std::byte> key, IrResourcePlan& plan);
|
|
void StorePlan(std::vector<std::byte> key, std::shared_ptr<const IrResourcePlan> plan);
|
|
void Flush();
|
|
void Shutdown();
|
|
[[nodiscard]] unsigned Writers();
|
|
[[nodiscard]] Counters Totals();
|
|
|
|
}
|
|
|
|
#endif
|