#ifndef EMULATOR_INCLUDE_EMULATOR_GRAPHICS_SHADER_RECOMPILER_SRTWALKER_H_ #define EMULATOR_INCLUDE_EMULATOR_GRAPHICS_SHADER_RECOMPILER_SRTWALKER_H_ #include "graphics/shader/recompiler/ir/ShaderIR.h" #include namespace Libs::Graphics::ShaderRecompiler::IR { class Value; using SrtMemoryReader = bool (*)(void* userdata, uint64_t address, uint32_t* value); struct SrtRuntime { std::span user_data; uint64_t shader_base = 0; SrtMemoryReader read_memory = nullptr; void* userdata = nullptr; SrtMemoryReader read_specialization_memory = nullptr; }; enum class RuntimeValueType { Any, Integer }; // Collects reachable ReadConst values. Immediate offsets receive compact flat-buffer slots; // dynamic offsets remain explicit and are never assigned a fake slot. void BuildSrtPlan(Program& program); bool ValidateRuntimeValue(const ResourcePlan& program, Value value, RuntimeValueType type = RuntimeValueType::Any); bool EvaluateUniformValues(const ResourcePlan& program, std::span values, const SrtRuntime& runtime, std::span results); bool EvaluateDescriptorSource(const ResourcePlan& program, uint32_t source, const SrtRuntime& runtime, DescriptorValue& result); // Evaluates one runtime snapshot transactionally. Scalar values and ReadConst results shared by // several descriptors are memoized once across the batch. bool EvaluateDescriptorSources(const ResourcePlan& program, std::span sources, const SrtRuntime& runtime, std::vector& results); // Evaluates potentially reachable descriptor sources and the flattened immediate SRT with one // memoized scalar walk. Inactive descriptors are zero; on failure no destination is changed. bool EvaluateRuntimeSources(const ResourcePlan& program, std::span sources, const SrtRuntime& runtime, std::vector& results, std::vector& flat, std::span clean_flat_slots, std::vector& active_sources); bool WalkSrt(const ResourcePlan& program, const SrtRuntime& runtime, std::vector& flat); } // namespace Libs::Graphics::ShaderRecompiler::IR #endif /* EMULATOR_INCLUDE_EMULATOR_GRAPHICS_SHADER_RECOMPILER_SRTWALKER_H_ */