diff options
Diffstat (limited to 'src/video_core/shader')
-rw-r--r-- | src/video_core/shader/control_flow.cpp | 13 | ||||
-rw-r--r-- | src/video_core/shader/control_flow.h | 3 | ||||
-rw-r--r-- | src/video_core/shader/decode.cpp | 4 | ||||
-rw-r--r-- | src/video_core/shader/decode/texture.cpp | 5 | ||||
-rw-r--r-- | src/video_core/shader/registry.cpp (renamed from src/video_core/shader/const_buffer_locker.cpp) | 34 | ||||
-rw-r--r-- | src/video_core/shader/registry.h (renamed from src/video_core/shader/const_buffer_locker.h) | 30 | ||||
-rw-r--r-- | src/video_core/shader/shader_ir.cpp | 5 | ||||
-rw-r--r-- | src/video_core/shader/shader_ir.h | 6 | ||||
-rw-r--r-- | src/video_core/shader/track.cpp | 4 |
9 files changed, 54 insertions, 50 deletions
diff --git a/src/video_core/shader/control_flow.cpp b/src/video_core/shader/control_flow.cpp index 0229733b6..2e2711350 100644 --- a/src/video_core/shader/control_flow.cpp +++ b/src/video_core/shader/control_flow.cpp @@ -13,6 +13,7 @@ #include "common/common_types.h" #include "video_core/shader/ast.h" #include "video_core/shader/control_flow.h" +#include "video_core/shader/registry.h" #include "video_core/shader/shader_ir.h" namespace VideoCommon::Shader { @@ -64,11 +65,11 @@ struct BlockInfo { }; struct CFGRebuildState { - explicit CFGRebuildState(const ProgramCode& program_code, u32 start, ConstBufferLocker& locker) - : program_code{program_code}, locker{locker}, start{start} {} + explicit CFGRebuildState(const ProgramCode& program_code, u32 start, Registry& registry) + : program_code{program_code}, registry{registry}, start{start} {} const ProgramCode& program_code; - ConstBufferLocker& locker; + Registry& registry; u32 start{}; std::vector<BlockInfo> block_info; std::list<u32> inspect_queries; @@ -438,7 +439,7 @@ std::pair<ParseResult, ParseInfo> ParseCode(CFGRebuildState& state, u32 address) const s32 pc_target = offset + result.relative_position; std::vector<CaseBranch> branches; for (u32 i = 0; i < result.entries; i++) { - auto key = state.locker.ObtainKey(result.buffer, result.offset + i * 4); + auto key = state.registry.ObtainKey(result.buffer, result.offset + i * 4); if (!key) { return {ParseResult::AbnormalFlow, parse_info}; } @@ -656,14 +657,14 @@ void DecompileShader(CFGRebuildState& state) { std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code, u32 start_address, const CompilerSettings& settings, - ConstBufferLocker& locker) { + Registry& registry) { auto result_out = std::make_unique<ShaderCharacteristics>(); if (settings.depth == CompileDepth::BruteForce) { result_out->settings.depth = CompileDepth::BruteForce; return result_out; } - CFGRebuildState state{program_code, start_address, locker}; + CFGRebuildState state{program_code, start_address, registry}; // Inspect Code and generate blocks state.labels.clear(); state.labels.emplace(start_address); diff --git a/src/video_core/shader/control_flow.h b/src/video_core/shader/control_flow.h index 5304998b9..62a3510d8 100644 --- a/src/video_core/shader/control_flow.h +++ b/src/video_core/shader/control_flow.h @@ -12,6 +12,7 @@ #include "video_core/engines/shader_bytecode.h" #include "video_core/shader/ast.h" #include "video_core/shader/compiler_settings.h" +#include "video_core/shader/registry.h" #include "video_core/shader/shader_ir.h" namespace VideoCommon::Shader { @@ -111,6 +112,6 @@ struct ShaderCharacteristics { std::unique_ptr<ShaderCharacteristics> ScanFlow(const ProgramCode& program_code, u32 start_address, const CompilerSettings& settings, - ConstBufferLocker& locker); + Registry& registry); } // namespace VideoCommon::Shader diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp index af4490d66..87ac9ac6c 100644 --- a/src/video_core/shader/decode.cpp +++ b/src/video_core/shader/decode.cpp @@ -141,7 +141,7 @@ void ShaderIR::Decode() { std::memcpy(&header, program_code.data(), sizeof(Tegra::Shader::Header)); decompiled = false; - auto info = ScanFlow(program_code, main_offset, settings, locker); + auto info = ScanFlow(program_code, main_offset, settings, registry); auto& shader_info = *info; coverage_begin = shader_info.start; coverage_end = shader_info.end; @@ -356,7 +356,7 @@ u32 ShaderIR::DecodeInstr(NodeBlock& bb, u32 pc) { void ShaderIR::PostDecode() { // Deduce texture handler size if needed - auto gpu_driver = locker.AccessGuestDriverProfile(); + auto gpu_driver = registry.AccessGuestDriverProfile(); DeduceTextureHandlerSize(gpu_driver, used_samplers); // Deduce Indexed Samplers if (!uses_indexed_samplers) { diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp index bee7d8cad..48350e042 100644 --- a/src/video_core/shader/decode/texture.cpp +++ b/src/video_core/shader/decode/texture.cpp @@ -12,6 +12,7 @@ #include "common/logging/log.h" #include "video_core/engines/shader_bytecode.h" #include "video_core/shader/node_helper.h" +#include "video_core/shader/registry.h" #include "video_core/shader/shader_ir.h" namespace VideoCommon::Shader { @@ -359,8 +360,8 @@ ShaderIR::SamplerInfo ShaderIR::GetSamplerInfo(std::optional<SamplerInfo> sample if (sampler_info) { return *sampler_info; } - const auto sampler = - buffer ? locker.ObtainBindlessSampler(*buffer, offset) : locker.ObtainBoundSampler(offset); + const auto sampler = buffer ? registry.ObtainBindlessSampler(*buffer, offset) + : registry.ObtainBoundSampler(offset); if (!sampler) { LOG_WARNING(HW_GPU, "Unknown sampler info"); return SamplerInfo{TextureType::Texture2D, false, false, false}; diff --git a/src/video_core/shader/const_buffer_locker.cpp b/src/video_core/shader/registry.cpp index c859dd7ca..7126caf98 100644 --- a/src/video_core/shader/const_buffer_locker.cpp +++ b/src/video_core/shader/registry.cpp @@ -8,23 +8,23 @@ #include "common/common_types.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/engines/shader_type.h" -#include "video_core/shader/const_buffer_locker.h" +#include "video_core/shader/registry.h" namespace VideoCommon::Shader { using Tegra::Engines::SamplerDescriptor; -ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, - VideoCore::GuestDriverProfile stored_guest_driver_profile) +Registry::Registry(Tegra::Engines::ShaderType shader_stage, + VideoCore::GuestDriverProfile stored_guest_driver_profile) : stage{shader_stage}, stored_guest_driver_profile{stored_guest_driver_profile} {} -ConstBufferLocker::ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, - Tegra::Engines::ConstBufferEngineInterface& engine) +Registry::Registry(Tegra::Engines::ShaderType shader_stage, + Tegra::Engines::ConstBufferEngineInterface& engine) : stage{shader_stage}, engine{&engine} {} -ConstBufferLocker::~ConstBufferLocker() = default; +Registry::~Registry() = default; -std::optional<u32> ConstBufferLocker::ObtainKey(u32 buffer, u32 offset) { +std::optional<u32> Registry::ObtainKey(u32 buffer, u32 offset) { const std::pair<u32, u32> key = {buffer, offset}; const auto iter = keys.find(key); if (iter != keys.end()) { @@ -38,7 +38,7 @@ std::optional<u32> ConstBufferLocker::ObtainKey(u32 buffer, u32 offset) { return value; } -std::optional<SamplerDescriptor> ConstBufferLocker::ObtainBoundSampler(u32 offset) { +std::optional<SamplerDescriptor> Registry::ObtainBoundSampler(u32 offset) { const u32 key = offset; const auto iter = bound_samplers.find(key); if (iter != bound_samplers.end()) { @@ -52,8 +52,8 @@ std::optional<SamplerDescriptor> ConstBufferLocker::ObtainBoundSampler(u32 offse return value; } -std::optional<Tegra::Engines::SamplerDescriptor> ConstBufferLocker::ObtainBindlessSampler( - u32 buffer, u32 offset) { +std::optional<Tegra::Engines::SamplerDescriptor> Registry::ObtainBindlessSampler(u32 buffer, + u32 offset) { const std::pair key = {buffer, offset}; const auto iter = bindless_samplers.find(key); if (iter != bindless_samplers.end()) { @@ -67,7 +67,7 @@ std::optional<Tegra::Engines::SamplerDescriptor> ConstBufferLocker::ObtainBindle return value; } -std::optional<u32> ConstBufferLocker::ObtainBoundBuffer() { +std::optional<u32> Registry::ObtainBoundBuffer() { if (bound_buffer_saved) { return bound_buffer; } @@ -79,24 +79,24 @@ std::optional<u32> ConstBufferLocker::ObtainBoundBuffer() { return bound_buffer; } -void ConstBufferLocker::InsertKey(u32 buffer, u32 offset, u32 value) { +void Registry::InsertKey(u32 buffer, u32 offset, u32 value) { keys.insert_or_assign({buffer, offset}, value); } -void ConstBufferLocker::InsertBoundSampler(u32 offset, SamplerDescriptor sampler) { +void Registry::InsertBoundSampler(u32 offset, SamplerDescriptor sampler) { bound_samplers.insert_or_assign(offset, sampler); } -void ConstBufferLocker::InsertBindlessSampler(u32 buffer, u32 offset, SamplerDescriptor sampler) { +void Registry::InsertBindlessSampler(u32 buffer, u32 offset, SamplerDescriptor sampler) { bindless_samplers.insert_or_assign({buffer, offset}, sampler); } -void ConstBufferLocker::SetBoundBuffer(u32 buffer) { +void Registry::SetBoundBuffer(u32 buffer) { bound_buffer_saved = true; bound_buffer = buffer; } -bool ConstBufferLocker::IsConsistent() const { +bool Registry::IsConsistent() const { if (!engine) { return true; } @@ -119,7 +119,7 @@ bool ConstBufferLocker::IsConsistent() const { }); } -bool ConstBufferLocker::HasEqualKeys(const ConstBufferLocker& rhs) const { +bool Registry::HasEqualKeys(const Registry& rhs) const { return std::tie(keys, bound_samplers, bindless_samplers) == std::tie(rhs.keys, rhs.bound_samplers, rhs.bindless_samplers); } diff --git a/src/video_core/shader/const_buffer_locker.h b/src/video_core/shader/registry.h index 7c6f7bbdd..a5487e1d7 100644 --- a/src/video_core/shader/const_buffer_locker.h +++ b/src/video_core/shader/registry.h @@ -20,21 +20,21 @@ using BindlessSamplerMap = std::unordered_map<std::pair<u32, u32>, Tegra::Engines::SamplerDescriptor, Common::PairHash>; /** - * The ConstBufferLocker is a class use to interface the 3D and compute engines with the shader - * compiler. with it, the shader can obtain required data from GPU state and store it for disk - * shader compilation. + * The Registry is a class use to interface the 3D and compute engines with the shader compiler. + * With it, the shader can obtain required data from GPU state and store it for disk shader + * compilation. */ -class ConstBufferLocker { +class Registry { public: - explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, - VideoCore::GuestDriverProfile stored_guest_driver_profile); + explicit Registry(Tegra::Engines::ShaderType shader_stage, + VideoCore::GuestDriverProfile stored_guest_driver_profile); - explicit ConstBufferLocker(Tegra::Engines::ShaderType shader_stage, - Tegra::Engines::ConstBufferEngineInterface& engine); + explicit Registry(Tegra::Engines::ShaderType shader_stage, + Tegra::Engines::ConstBufferEngineInterface& engine); - ~ConstBufferLocker(); + ~Registry(); - /// Retrieves a key from the locker, if it's registered, it will give the registered value, if + /// Retrieves a key from the registry, if it's registered, it will give the registered value, if /// not it will obtain it from maxwell3d and register it. std::optional<u32> ObtainKey(u32 buffer, u32 offset); @@ -53,15 +53,15 @@ public: /// Inserts a bindless sampler key. void InsertBindlessSampler(u32 buffer, u32 offset, Tegra::Engines::SamplerDescriptor sampler); - /// Set the bound buffer for this locker. + /// Set the bound buffer for this registry. void SetBoundBuffer(u32 buffer); - /// Checks keys and samplers against engine's current const buffers. Returns true if they are - /// the same value, false otherwise; + /// Checks keys and samplers against engine's current const buffers. + /// Returns true if they are the same value, false otherwise. bool IsConsistent() const; - /// Returns true if the keys are equal to the other ones in the locker. - bool HasEqualKeys(const ConstBufferLocker& rhs) const; + /// Returns true if the keys are equal to the other ones in the registry. + bool HasEqualKeys(const Registry& rhs) const; /// Gives an getter to the const buffer keys in the database. const KeyMap& GetKeys() const { diff --git a/src/video_core/shader/shader_ir.cpp b/src/video_core/shader/shader_ir.cpp index 3a5d280a9..425927777 100644 --- a/src/video_core/shader/shader_ir.cpp +++ b/src/video_core/shader/shader_ir.cpp @@ -11,6 +11,7 @@ #include "common/logging/log.h" #include "video_core/engines/shader_bytecode.h" #include "video_core/shader/node_helper.h" +#include "video_core/shader/registry.h" #include "video_core/shader/shader_ir.h" namespace VideoCommon::Shader { @@ -24,8 +25,8 @@ using Tegra::Shader::PredOperation; using Tegra::Shader::Register; ShaderIR::ShaderIR(const ProgramCode& program_code, u32 main_offset, CompilerSettings settings, - ConstBufferLocker& locker) - : program_code{program_code}, main_offset{main_offset}, settings{settings}, locker{locker} { + Registry& registry) + : program_code{program_code}, main_offset{main_offset}, settings{settings}, registry{registry} { Decode(); PostDecode(); } diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h index b0851c3be..dde036b40 100644 --- a/src/video_core/shader/shader_ir.h +++ b/src/video_core/shader/shader_ir.h @@ -18,8 +18,8 @@ #include "video_core/engines/shader_header.h" #include "video_core/shader/ast.h" #include "video_core/shader/compiler_settings.h" -#include "video_core/shader/const_buffer_locker.h" #include "video_core/shader/node.h" +#include "video_core/shader/registry.h" namespace VideoCommon::Shader { @@ -69,7 +69,7 @@ struct GlobalMemoryUsage { class ShaderIR final { public: explicit ShaderIR(const ProgramCode& program_code, u32 main_offset, CompilerSettings settings, - ConstBufferLocker& locker); + Registry& registry); ~ShaderIR(); const std::map<u32, NodeBlock>& GetBasicBlocks() const { @@ -414,7 +414,7 @@ private: const ProgramCode& program_code; const u32 main_offset; const CompilerSettings settings; - ConstBufferLocker& locker; + Registry& registry; bool decompiled{}; bool disable_flow_stack{}; diff --git a/src/video_core/shader/track.cpp b/src/video_core/shader/track.cpp index b1a0aa00c..831219841 100644 --- a/src/video_core/shader/track.cpp +++ b/src/video_core/shader/track.cpp @@ -81,7 +81,7 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, cons MakeTrackSampler<BindlessSamplerNode>(cbuf->GetIndex(), immediate->GetValue()); return {tracked, track}; } else if (const auto operation = std::get_if<OperationNode>(&*offset)) { - auto bound_buffer = locker.ObtainBoundBuffer(); + const auto bound_buffer = registry.ObtainBoundBuffer(); if (!bound_buffer) { return {}; } @@ -94,7 +94,7 @@ std::tuple<Node, TrackSampler> ShaderIR::TrackBindlessSampler(Node tracked, cons } auto [gpr, base_offset] = *pair; const auto offset_inm = std::get_if<ImmediateNode>(&*base_offset); - const auto& gpu_driver = locker.AccessGuestDriverProfile(); + const auto& gpu_driver = registry.AccessGuestDriverProfile(); const u32 bindless_cv = NewCustomVariable(); const Node op = Operation(OperationCode::UDiv, gpr, Immediate(gpu_driver.GetTextureHandlerSize())); |