diff options
| author | 2018-11-21 22:17:15 -0300 | |
|---|---|---|
| committer | 2018-11-21 22:31:42 -0300 | |
| commit | 74eb16521fe812934f74e61b84d44cde9af08f96 (patch) | |
| tree | 9c8c3a600e5b2704f3b36e01f1020519c4999d93 | |
| parent | gl_shader_decompiler: Rename control codes to condition codes (diff) | |
| download | yuzu-74eb16521fe812934f74e61b84d44cde9af08f96.tar.gz yuzu-74eb16521fe812934f74e61b84d44cde9af08f96.tar.xz yuzu-74eb16521fe812934f74e61b84d44cde9af08f96.zip | |
gl_shader_decompiler: Rename internal flag strings
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 91e844960..e1ecabb2d 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -34,6 +34,17 @@ constexpr u32 PROGRAM_HEADER_SIZE = sizeof(Tegra::Shader::Header); | |||
| 34 | constexpr u32 MAX_GEOMETRY_BUFFERS = 6; | 34 | constexpr u32 MAX_GEOMETRY_BUFFERS = 6; |
| 35 | constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested | 35 | constexpr u32 MAX_ATTRIBUTES = 0x100; // Size in vec4s, this value is untested |
| 36 | 36 | ||
| 37 | static const char* INTERNAL_FLAG_NAMES[] = {"zero_flag", "sign_flag", "carry_flag", | ||
| 38 | "overflow_flag"}; | ||
| 39 | |||
| 40 | enum class InternalFlag : u64 { | ||
| 41 | ZeroFlag = 0, | ||
| 42 | SignFlag = 1, | ||
| 43 | CarryFlag = 2, | ||
| 44 | OverflowFlag = 3, | ||
| 45 | Amount | ||
| 46 | }; | ||
| 47 | |||
| 37 | class DecompileFail : public std::runtime_error { | 48 | class DecompileFail : public std::runtime_error { |
| 38 | public: | 49 | public: |
| 39 | using std::runtime_error::runtime_error; | 50 | using std::runtime_error::runtime_error; |
| @@ -257,14 +268,6 @@ private: | |||
| 257 | const std::string& suffix; | 268 | const std::string& suffix; |
| 258 | }; | 269 | }; |
| 259 | 270 | ||
| 260 | enum class InternalFlag : u64 { | ||
| 261 | ZeroFlag = 0, | ||
| 262 | CarryFlag = 1, | ||
| 263 | OverflowFlag = 2, | ||
| 264 | NaNFlag = 3, | ||
| 265 | Amount | ||
| 266 | }; | ||
| 267 | |||
| 268 | /** | 271 | /** |
| 269 | * Used to manage shader registers that are emulated with GLSL. This class keeps track of the state | 272 | * Used to manage shader registers that are emulated with GLSL. This class keeps track of the state |
| 270 | * of all registers (e.g. whether they are currently being used as Floats or Integers), and | 273 | * of all registers (e.g. whether they are currently being used as Floats or Integers), and |
| @@ -464,13 +467,15 @@ public: | |||
| 464 | } | 467 | } |
| 465 | } | 468 | } |
| 466 | 469 | ||
| 467 | std::string GetInternalFlag(const InternalFlag ii) const { | 470 | std::string GetInternalFlag(const InternalFlag flag) const { |
| 468 | const u32 code = static_cast<u32>(ii); | 471 | const auto index = static_cast<u32>(flag); |
| 469 | return "internalFlag_" + std::to_string(code) + suffix; | 472 | ASSERT(index < static_cast<u32>(InternalFlag::Amount)); |
| 473 | |||
| 474 | return std::string(INTERNAL_FLAG_NAMES[index]) + '_' + suffix; | ||
| 470 | } | 475 | } |
| 471 | 476 | ||
| 472 | void SetInternalFlag(const InternalFlag ii, const std::string& value) const { | 477 | void SetInternalFlag(const InternalFlag flag, const std::string& value) const { |
| 473 | shader.AddLine(GetInternalFlag(ii) + " = " + value + ';'); | 478 | shader.AddLine(GetInternalFlag(flag) + " = " + value + ';'); |
| 474 | } | 479 | } |
| 475 | 480 | ||
| 476 | /** | 481 | /** |
| @@ -621,8 +626,8 @@ private: | |||
| 621 | 626 | ||
| 622 | /// Generates declarations for internal flags. | 627 | /// Generates declarations for internal flags. |
| 623 | void GenerateInternalFlags() { | 628 | void GenerateInternalFlags() { |
| 624 | for (u32 ii = 0; ii < static_cast<u64>(InternalFlag::Amount); ii++) { | 629 | for (u32 flag = 0; flag < static_cast<u32>(InternalFlag::Amount); flag++) { |
| 625 | const InternalFlag code = static_cast<InternalFlag>(ii); | 630 | const InternalFlag code = static_cast<InternalFlag>(flag); |
| 626 | declarations.AddLine("bool " + GetInternalFlag(code) + " = false;"); | 631 | declarations.AddLine("bool " + GetInternalFlag(code) + " = false;"); |
| 627 | } | 632 | } |
| 628 | declarations.AddNewLine(); | 633 | declarations.AddNewLine(); |