diff options
| author | Fernando Sahmkow <fsahmkow27@gmail.com> | 2020-01-07 14:53:46 -0400 |
|---|---|---|
| committer | FernandoS27 <fsahmkow27@gmail.com> | 2020-01-24 16:43:31 -0400 |
| commit | 3c34678627eeb1b48375cf70ec38b72691fedd1e (patch) | |
| tree | 4a1ceb51da3946c9551e62f2bea6163db361ae48 /src/video_core/renderer_opengl | |
| parent | 2b02f29a2ddfe40639ea0f855bdf257beca59e65 (diff) | |
Shader_IR: Implement Injectable Custom Variables to the IR.
Diffstat (limited to 'src/video_core/renderer_opengl')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 20 |
1 files changed, 20 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 4b35396f9..8b413ae9a 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -391,6 +391,7 @@ public: DeclareVertex(); DeclareGeometry(); DeclareRegisters(); + DeclareCustomVariables(); DeclarePredicates(); DeclareLocalMemory(); DeclareInternalFlags(); @@ -503,6 +504,16 @@ private: } } + void DeclareCustomVariables() { + const u32 cv_num = ir.GetCustomVariablesAmount(); + for (u32 i = 0; i < cv_num; ++i) { + code.AddLine("float {} = 0.0f;", GetCustomVariable(i)); + } + if (cv_num > 0) { + code.AddNewLine(); + } + } + void DeclarePredicates() { const auto& predicates = ir.GetPredicates(); for (const auto pred : predicates) { @@ -780,6 +791,11 @@ private: return {GetRegister(index), Type::Float}; } + if (const auto cv = std::get_if<CustomVarNode>(&*node)) { + const u32 index = cv->GetIndex(); + return {GetCustomVariable(index), Type::Float}; + } + if (const auto immediate = std::get_if<ImmediateNode>(&*node)) { const u32 value = immediate->GetValue(); if (value < 10) { @@ -2250,6 +2266,10 @@ private: return GetDeclarationWithSuffix(index, "gpr"); } + std::string GetCustomVariable(u32 index) const { + return GetDeclarationWithSuffix(index, "custom_var"); + } + std::string GetPredicate(Tegra::Shader::Pred pred) const { return GetDeclarationWithSuffix(static_cast<u32>(pred), "pred"); } |
