summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/CMakeLists.txt2
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp58
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.h27
3 files changed, 87 insertions, 0 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 92951a7e1..cce29231f 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -16,6 +16,8 @@ add_library(video_core STATIC
16 renderer_opengl/gl_rasterizer_cache.cpp 16 renderer_opengl/gl_rasterizer_cache.cpp
17 renderer_opengl/gl_rasterizer_cache.h 17 renderer_opengl/gl_rasterizer_cache.h
18 renderer_opengl/gl_resource_manager.h 18 renderer_opengl/gl_resource_manager.h
19 renderer_opengl/gl_shader_decompiler.cpp
20 renderer_opengl/gl_shader_decompiler.h
19 renderer_opengl/gl_shader_util.cpp 21 renderer_opengl/gl_shader_util.cpp
20 renderer_opengl/gl_shader_util.h 22 renderer_opengl/gl_shader_util.h
21 renderer_opengl/gl_state.cpp 23 renderer_opengl/gl_state.cpp
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
new file mode 100644
index 000000000..0e0ef18cc
--- /dev/null
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -0,0 +1,58 @@
1// Copyright 2018 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <string>
6#include <queue>
7#include "common/assert.h"
8#include "common/common_types.h"
9#include "video_core/renderer_opengl/gl_shader_decompiler.h"
10
11namespace Maxwell3D {
12namespace Shader {
13namespace Decompiler {
14
15constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH;
16
17class Impl {
18public:
19 Impl(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>& program_code,
20 const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>& swizzle_data, u32 main_offset,
21 const std::function<std::string(u32)>& inputreg_getter,
22 const std::function<std::string(u32)>& outputreg_getter, bool sanitize_mul,
23 const std::string& emit_cb, const std::string& setemit_cb)
24 : program_code(program_code), swizzle_data(swizzle_data), main_offset(main_offset),
25 inputreg_getter(inputreg_getter), outputreg_getter(outputreg_getter),
26 sanitize_mul(sanitize_mul), emit_cb(emit_cb), setemit_cb(setemit_cb) {}
27
28 std::string Decompile() {
29 UNIMPLEMENTED();
30 return {};
31 }
32
33private:
34 const std::array<u32, MAX_PROGRAM_CODE_LENGTH>& program_code;
35 const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>& swizzle_data;
36 u32 main_offset;
37 const std::function<std::string(u32)>& inputreg_getter;
38 const std::function<std::string(u32)>& outputreg_getter;
39 bool sanitize_mul;
40 const std::string& emit_cb;
41 const std::string& setemit_cb;
42};
43
44std::string DecompileProgram(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>& program_code,
45 const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>& swizzle_data,
46 u32 main_offset,
47 const std::function<std::string(u32)>& inputreg_getter,
48 const std::function<std::string(u32)>& outputreg_getter,
49 bool sanitize_mul, const std::string& emit_cb,
50 const std::string& setemit_cb) {
51 Impl impl(program_code, swizzle_data, main_offset, inputreg_getter, outputreg_getter,
52 sanitize_mul, emit_cb, setemit_cb);
53 return impl.Decompile();
54}
55
56} // namespace Decompiler
57} // namespace Shader
58} // namespace Maxwell3D
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..02ebfcbe8
--- /dev/null
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.h
@@ -0,0 +1,27 @@
1// Copyright 2018 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <array>
6#include <functional>
7#include <string>
8#include "common/common_types.h"
9
10namespace Maxwell3D {
11namespace Shader {
12namespace Decompiler {
13
14constexpr size_t MAX_PROGRAM_CODE_LENGTH{0x100000};
15constexpr size_t MAX_SWIZZLE_DATA_LENGTH{0x100000};
16
17std::string DecompileProgram(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>& program_code,
18 const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>& swizzle_data,
19 u32 main_offset,
20 const std::function<std::string(u32)>& inputreg_getter,
21 const std::function<std::string(u32)>& outputreg_getter,
22 bool sanitize_mul, const std::string& emit_cb = "",
23 const std::string& setemit_cb = "");
24
25} // namespace Decompiler
26} // namespace Shader
27} // namespace Maxwell3D