#ifndef EMULATOR_INCLUDE_EMULATOR_GRAPHICS_SHADER_RECOMPILER_SERIALIZE_H_ #define EMULATOR_INCLUDE_EMULATOR_GRAPHICS_SHADER_RECOMPILER_SERIALIZE_H_ #include "common/assert.h" #include "graphics/shader/recompiler/backend/spirv/SpirvEmitter.h" #include "graphics/shader/recompiler/ir/ShaderIR.h" #include "graphics/shader/recompiler/ir/passes/ResourceMaterialization.h" #include "graphics/shader/rectListShader.h" #include #include #include #include #include #include #include #include #include // Shader cache records. Io(io, value) appends value to a Writer or reads it back from a Reader // field by field, so padding never reaches the bytes; instructions travel as plan-local indices. namespace Libs::Graphics::ShaderRecompiler::IR { struct Writer { std::vector bytes; std::unordered_map index; // Instructions that values may refer to. void Raw(const void* data, size_t size) { const auto* begin = static_cast(data); bytes.insert(bytes.end(), begin, begin + size); } }; struct Reader { std::span bytes; std::vector insts; // Instructions by index. bool ok = true; // False once a read ran past the end or was invalid. void Raw(void* data, size_t size) { ok = ok && size <= bytes.size(); if (!ok) return; std::copy_n(bytes.data(), size, static_cast(data)); bytes = bytes.subspan(size); } // Every element takes at least one byte, which bounds counts read from damaged records. uint32_t Count(uint32_t count) { ok = ok && count <= bytes.size(); return ok ? count : 0u; } }; template constexpr bool Reading = std::is_same_v; template class Of> constexpr bool IsA = false; template