diff options
| author | 2018-03-19 18:51:43 -0400 | |
|---|---|---|
| committer | 2018-03-19 23:14:03 -0400 | |
| commit | 4bdb46e4c2bbdbb4f0a8480a74ee9887fa1995df (patch) | |
| tree | 4b44ac0965df8e1488c2931d1269bab459cfacf6 | |
| parent | renderer_gl: Port over gl_rasterizer_cache module from Citra. (diff) | |
| download | yuzu-4bdb46e4c2bbdbb4f0a8480a74ee9887fa1995df.tar.gz yuzu-4bdb46e4c2bbdbb4f0a8480a74ee9887fa1995df.tar.xz yuzu-4bdb46e4c2bbdbb4f0a8480a74ee9887fa1995df.zip | |
renderer_gl: Port over gl_shader_decompiler module from Citra.
| -rw-r--r-- | src/video_core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 58 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.h | 27 |
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 | |||
| 11 | namespace Maxwell3D { | ||
| 12 | namespace Shader { | ||
| 13 | namespace Decompiler { | ||
| 14 | |||
| 15 | constexpr u32 PROGRAM_END = MAX_PROGRAM_CODE_LENGTH; | ||
| 16 | |||
| 17 | class Impl { | ||
| 18 | public: | ||
| 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 | |||
| 33 | private: | ||
| 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 | |||
| 44 | std::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 | |||
| 10 | namespace Maxwell3D { | ||
| 11 | namespace Shader { | ||
| 12 | namespace Decompiler { | ||
| 13 | |||
| 14 | constexpr size_t MAX_PROGRAM_CODE_LENGTH{0x100000}; | ||
| 15 | constexpr size_t MAX_SWIZZLE_DATA_LENGTH{0x100000}; | ||
| 16 | |||
| 17 | std::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 | ||