mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-30 01:01:21 +00:00
* shader: release descriptor dependencies * shader: simplify shared-exit control flow * shader: fix scalar memory loads * shader: fix LDS counter bounds * renderer: skip inactive pixel shaders * shader: respect FP32 mode in comparisons * renderer: fix sampler border colors * shader: resolve descriptors from control flow * shader: resolve descriptors before resource planning * shader: handle scalar guards for image bounds * shader: handle reduced guards for image loops * shader: fix wave guards and material indices * shader: preserve scalar buffer offset alignment and carry * shader: prove masked loop bounds across iteration transitions * shader: preserve source and IR before resource tracking failures * shader: track material keys selected from active lanes * shader: remove obsolete post-dominator analysis * shader: follow bounds guards through control-flow joins
66 lines
2.5 KiB
C++
66 lines
2.5 KiB
C++
#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 <span>
|
|
|
|
namespace Libs::Graphics::ShaderRecompiler::IR {
|
|
|
|
class Value;
|
|
|
|
using SrtMemoryReader = bool (*)(void* userdata, uint64_t address, std::span<uint32_t> values);
|
|
|
|
struct SrtRuntime {
|
|
std::span<const uint32_t> user_data;
|
|
uint64_t shader_base = 0;
|
|
SrtMemoryReader read_memory = nullptr;
|
|
void* userdata = nullptr;
|
|
SrtMemoryReader read_specialization_memory = nullptr;
|
|
};
|
|
|
|
enum class RuntimeValueType { Any, Integer };
|
|
|
|
bool ValidateRuntimeValue(const ResourcePlan& program, Value value,
|
|
RuntimeValueType type = RuntimeValueType::Any);
|
|
// Uses the strict reader for values that affect shader specialization.
|
|
SrtRuntime CleanRuntime(SrtRuntime runtime);
|
|
|
|
// One memoized evaluation session shared by the entire shader resource refresh.
|
|
class SrtWalker {
|
|
public:
|
|
SrtWalker(const ResourcePlan& program, const SrtRuntime& runtime,
|
|
std::span<const uint8_t> clean_flat_slots = {}, SrtWalker* clean_evaluator = nullptr,
|
|
Value active_mask = {});
|
|
~SrtWalker();
|
|
SrtWalker(const SrtWalker&) = delete;
|
|
SrtWalker& operator=(const SrtWalker&) = delete;
|
|
|
|
bool Evaluate(Value value, uint32_t& result);
|
|
bool EvaluateDescriptor(uint32_t source, DescriptorValue& result);
|
|
// An empty span means that all sources are active.
|
|
std::span<const uint8_t> FindActiveSources();
|
|
bool RefreshFlatBuffer(std::vector<uint32_t>& flat);
|
|
|
|
private:
|
|
static ResourcePlan::EvaluationContext& AcquireContext(const ResourcePlan& program);
|
|
static float Float32(uint64_t bits);
|
|
bool EvaluateWide(Value value, uint64_t& result);
|
|
bool Arg(const Inst& inst, size_t index, uint64_t& result);
|
|
bool EvaluatePhi(const Inst& inst, uint64_t& result);
|
|
bool EvaluateExtract(const Inst& inst, uint64_t& result);
|
|
bool EvaluateRawRead(const Inst& inst, uint64_t& result);
|
|
bool EvaluateInst(const Inst& inst, uint64_t& result);
|
|
|
|
const ResourcePlan& m_program;
|
|
SrtRuntime m_runtime;
|
|
std::span<const uint8_t> m_clean_flat_slots;
|
|
SrtWalker* m_clean_evaluator = nullptr;
|
|
Value m_active_mask;
|
|
ResourcePlan::EvaluationContext& m_context;
|
|
};
|
|
|
|
} // namespace Libs::Graphics::ShaderRecompiler::IR
|
|
|
|
#endif /* EMULATOR_INCLUDE_EMULATOR_GRAPHICS_SHADER_RECOMPILER_SRTWALKER_H_ */
|