summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_decompiler.h
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2018-12-26 05:57:14 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-01-15 21:54:53 +0100
commitaf5d7e2c49d1cfe470b0b4ebd55561f9f22dc677 (patch)
treefe95585385e2569af1f80b6e6c63918e24b64e5f /src/video_core/renderer_opengl/gl_shader_decompiler.h
parentshader_ir: Remove RZ and use Register::ZeroIndex instead (diff)
downloadyuzu-af5d7e2c49d1cfe470b0b4ebd55561f9f22dc677.tar
yuzu-af5d7e2c49d1cfe470b0b4ebd55561f9f22dc677.tar.gz
yuzu-af5d7e2c49d1cfe470b0b4ebd55561f9f22dc677.tar.bz2
yuzu-af5d7e2c49d1cfe470b0b4ebd55561f9f22dc677.tar.lz
yuzu-af5d7e2c49d1cfe470b0b4ebd55561f9f22dc677.tar.xz
yuzu-af5d7e2c49d1cfe470b0b4ebd55561f9f22dc677.tar.zst
yuzu-af5d7e2c49d1cfe470b0b4ebd55561f9f22dc677.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_decompiler.h')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.h b/src/video_core/renderer_opengl/gl_shader_decompiler.h
new file mode 100644
index 000000000..396a560d8
--- /dev/null
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.h
@@ -0,0 +1,88 @@
+// Copyright 2018 yuzu Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <string>
+#include <utility>
+#include <vector>
+#include "common/common_types.h"
+#include "video_core/engines/maxwell_3d.h"
+#include "video_core/shader/shader_ir.h"
+
+namespace VideoCommon::Shader {
+class ShaderIR;
+}
+
+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();
+
+ProgramResult Decompile(const VideoCommon::Shader::ShaderIR& ir, Maxwell::ShaderStage stage,
+ const std::string& suffix);
+
+} // namespace OpenGL::GLShader \ No newline at end of file