summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_decompiler.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.h81
1 files changed, 72 insertions, 9 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.h b/src/video_core/renderer_opengl/gl_shader_decompiler.h
index d01a4a7ee..396a560d8 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.h
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.h
@@ -5,21 +5,84 @@
#pragma once
#include <array>
-#include <functional>
-#include <optional>
#include <string>
+#include <utility>
+#include <vector>
#include "common/common_types.h"
#include "video_core/engines/maxwell_3d.h"
-#include "video_core/renderer_opengl/gl_shader_gen.h"
+#include "video_core/shader/shader_ir.h"
-namespace OpenGL::GLShader::Decompiler {
+namespace VideoCommon::Shader {
+class ShaderIR;
+}
-using Tegra::Engines::Maxwell3D;
+namespace OpenGL::GLShader {
+
+using Maxwell = Tegra::Engines::Maxwell3D::Regs;
+
+class ConstBufferEntry : public VideoCommon::Shader::ConstBuffer {
+public:
+ explicit ConstBufferEntry(const VideoCommon::Shader::ConstBuffer& entry,
+ Maxwell::ShaderStage stage, const std::string& name, u32 index)
+ : VideoCommon::Shader::ConstBuffer{entry}, stage{stage}, name{name}, index{index} {}
+
+ const std::string& GetName() const {
+ return name;
+ }
+
+ Maxwell::ShaderStage GetStage() const {
+ return stage;
+ }
+
+ u32 GetIndex() const {
+ return index;
+ }
+
+ u32 GetHash() const {
+ return (static_cast<u32>(stage) << 16) | index;
+ }
+
+private:
+ std::string name;
+ Maxwell::ShaderStage stage{};
+ u32 index{};
+};
+
+class SamplerEntry : public VideoCommon::Shader::Sampler {
+public:
+ explicit SamplerEntry(const VideoCommon::Shader::Sampler& entry, Maxwell::ShaderStage stage,
+ const std::string& name)
+ : VideoCommon::Shader::Sampler{entry}, stage{stage}, name{name} {}
+
+ const std::string& GetName() const {
+ return name;
+ }
+
+ Maxwell::ShaderStage GetStage() const {
+ return stage;
+ }
+
+ u32 GetHash() const {
+ return (static_cast<u32>(stage) << 16) | static_cast<u32>(GetIndex());
+ }
+
+private:
+ std::string name;
+ Maxwell::ShaderStage stage{};
+};
+
+struct ShaderEntries {
+ std::vector<ConstBufferEntry> const_buffers;
+ std::vector<SamplerEntry> samplers;
+ std::array<bool, Maxwell::NumClipDistances> clip_distances{};
+ std::size_t shader_length{};
+};
+
+using ProgramResult = std::pair<std::string, ShaderEntries>;
std::string GetCommonDeclarations();
-std::optional<ProgramResult> DecompileProgram(const ProgramCode& program_code, u32 main_offset,
- Maxwell3D::Regs::ShaderStage stage,
- const std::string& suffix);
+ProgramResult Decompile(const VideoCommon::Shader::ShaderIR& ir, Maxwell::ShaderStage stage,
+ const std::string& suffix);
-} // namespace OpenGL::GLShader::Decompiler
+} // namespace OpenGL::GLShader \ No newline at end of file