diff options
| author | 2019-08-29 17:18:04 -0300 | |
|---|---|---|
| committer | 2019-09-05 01:40:24 -0300 | |
| commit | 0f7b813d654b01a52ed26ad3872a2bca12d0c6d0 (patch) | |
| tree | 70ce94f8eeded51adac14259dfadb3e4c8d0d8cf /src | |
| parent | shader_ir: Implement LD_S (diff) | |
| download | yuzu-0f7b813d654b01a52ed26ad3872a2bca12d0c6d0.tar.gz yuzu-0f7b813d654b01a52ed26ad3872a2bca12d0c6d0.tar.xz yuzu-0f7b813d654b01a52ed26ad3872a2bca12d0c6d0.zip | |
gl_shader_decompiler: Implement shared memory
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index a5cc1a86f..c399fab0f 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -325,6 +325,7 @@ public: | |||
| 325 | DeclareRegisters(); | 325 | DeclareRegisters(); |
| 326 | DeclarePredicates(); | 326 | DeclarePredicates(); |
| 327 | DeclareLocalMemory(); | 327 | DeclareLocalMemory(); |
| 328 | DeclareSharedMemory(); | ||
| 328 | DeclareInternalFlags(); | 329 | DeclareInternalFlags(); |
| 329 | DeclareInputAttributes(); | 330 | DeclareInputAttributes(); |
| 330 | DeclareOutputAttributes(); | 331 | DeclareOutputAttributes(); |
| @@ -500,6 +501,13 @@ private: | |||
| 500 | code.AddNewLine(); | 501 | code.AddNewLine(); |
| 501 | } | 502 | } |
| 502 | 503 | ||
| 504 | void DeclareSharedMemory() { | ||
| 505 | if (stage != ProgramType::Compute) { | ||
| 506 | return; | ||
| 507 | } | ||
| 508 | code.AddLine("shared uint {}[];", GetSharedMemory()); | ||
| 509 | } | ||
| 510 | |||
| 503 | void DeclareInternalFlags() { | 511 | void DeclareInternalFlags() { |
| 504 | for (u32 flag = 0; flag < static_cast<u32>(InternalFlag::Amount); flag++) { | 512 | for (u32 flag = 0; flag < static_cast<u32>(InternalFlag::Amount); flag++) { |
| 505 | const auto flag_code = static_cast<InternalFlag>(flag); | 513 | const auto flag_code = static_cast<InternalFlag>(flag); |
| @@ -858,6 +866,12 @@ private: | |||
| 858 | Type::Uint}; | 866 | Type::Uint}; |
| 859 | } | 867 | } |
| 860 | 868 | ||
| 869 | if (const auto smem = std::get_if<SmemNode>(&*node)) { | ||
| 870 | return { | ||
| 871 | fmt::format("{}[{} >> 2]", GetSharedMemory(), Visit(smem->GetAddress()).AsUint()), | ||
| 872 | Type::Uint}; | ||
| 873 | } | ||
| 874 | |||
| 861 | if (const auto internal_flag = std::get_if<InternalFlagNode>(&*node)) { | 875 | if (const auto internal_flag = std::get_if<InternalFlagNode>(&*node)) { |
| 862 | return {GetInternalFlag(internal_flag->GetFlag()), Type::Bool}; | 876 | return {GetInternalFlag(internal_flag->GetFlag()), Type::Bool}; |
| 863 | } | 877 | } |
| @@ -1195,6 +1209,11 @@ private: | |||
| 1195 | target = { | 1209 | target = { |
| 1196 | fmt::format("{}[{} >> 2]", GetLocalMemory(), Visit(lmem->GetAddress()).AsUint()), | 1210 | fmt::format("{}[{} >> 2]", GetLocalMemory(), Visit(lmem->GetAddress()).AsUint()), |
| 1197 | Type::Uint}; | 1211 | Type::Uint}; |
| 1212 | } else if (const auto smem = std::get_if<SmemNode>(&*dest)) { | ||
| 1213 | ASSERT(stage == ProgramType::Compute); | ||
| 1214 | target = { | ||
| 1215 | fmt::format("{}[{} >> 2]", GetSharedMemory(), Visit(smem->GetAddress()).AsUint()), | ||
| 1216 | Type::Uint}; | ||
| 1198 | } else if (const auto gmem = std::get_if<GmemNode>(&*dest)) { | 1217 | } else if (const auto gmem = std::get_if<GmemNode>(&*dest)) { |
| 1199 | const std::string real = Visit(gmem->GetRealAddress()).AsUint(); | 1218 | const std::string real = Visit(gmem->GetRealAddress()).AsUint(); |
| 1200 | const std::string base = Visit(gmem->GetBaseAddress()).AsUint(); | 1219 | const std::string base = Visit(gmem->GetBaseAddress()).AsUint(); |
| @@ -2076,6 +2095,10 @@ private: | |||
| 2076 | return "lmem_" + suffix; | 2095 | return "lmem_" + suffix; |
| 2077 | } | 2096 | } |
| 2078 | 2097 | ||
| 2098 | std::string GetSharedMemory() const { | ||
| 2099 | return fmt::format("smem_{}", suffix); | ||
| 2100 | } | ||
| 2101 | |||
| 2079 | std::string GetInternalFlag(InternalFlag flag) const { | 2102 | std::string GetInternalFlag(InternalFlag flag) const { |
| 2080 | constexpr std::array InternalFlagNames = {"zero_flag", "sign_flag", "carry_flag", | 2103 | constexpr std::array InternalFlagNames = {"zero_flag", "sign_flag", "carry_flag", |
| 2081 | "overflow_flag"}; | 2104 | "overflow_flag"}; |