diff options
author | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-06-08 00:04:01 +0200 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:37 +0200 |
commit | 258106038e921de6863d3e871a82fb7a0c77f10d (patch) | |
tree | 31079d1db5089646912fed49b4e075dbaaaa3b25 /src/shader_recompiler/backend/glsl/var_alloc.cpp | |
parent | glsl: Implement barriers (diff) | |
download | yuzu-258106038e921de6863d3e871a82fb7a0c77f10d.tar yuzu-258106038e921de6863d3e871a82fb7a0c77f10d.tar.gz yuzu-258106038e921de6863d3e871a82fb7a0c77f10d.tar.bz2 yuzu-258106038e921de6863d3e871a82fb7a0c77f10d.tar.lz yuzu-258106038e921de6863d3e871a82fb7a0c77f10d.tar.xz yuzu-258106038e921de6863d3e871a82fb7a0c77f10d.tar.zst yuzu-258106038e921de6863d3e871a82fb7a0c77f10d.zip |
Diffstat (limited to 'src/shader_recompiler/backend/glsl/var_alloc.cpp')
-rw-r--r-- | src/shader_recompiler/backend/glsl/var_alloc.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/shader_recompiler/backend/glsl/var_alloc.cpp b/src/shader_recompiler/backend/glsl/var_alloc.cpp index 0ae56651e..95e8233e2 100644 --- a/src/shader_recompiler/backend/glsl/var_alloc.cpp +++ b/src/shader_recompiler/backend/glsl/var_alloc.cpp @@ -116,8 +116,8 @@ std::string VarAlloc::Define(IR::Inst& inst, GlslVarType type) { id.type.Assign(type); GetUseTracker(type).uses_temp = true; inst.SetDefinition<Id>(id); + return "t" + Representation(inst.Definition<Id>()); } - return Representation(inst.Definition<Id>()); } std::string VarAlloc::Define(IR::Inst& inst, IR::Type type) { @@ -156,21 +156,27 @@ std::string VarAlloc::GetGlslType(IR::Type type) const { Id VarAlloc::Alloc(GlslVarType type) { auto& use_tracker{GetUseTracker(type)}; - if (use_tracker.num_used < NUM_VARS) { - for (size_t var = 1; var < NUM_VARS; ++var) { - if (use_tracker.var_use[var]) { - continue; - } - use_tracker.num_used = std::max(use_tracker.num_used, var + 1); - use_tracker.var_use[var] = true; - Id ret{}; - ret.is_valid.Assign(1); - ret.type.Assign(type); - ret.index.Assign(static_cast<u32>(var)); - return ret; + const auto num_vars{use_tracker.var_use.size()}; + for (size_t var = 0; var < num_vars; ++var) { + if (use_tracker.var_use[var]) { + continue; } + use_tracker.num_used = std::max(use_tracker.num_used, var + 1); + use_tracker.var_use[var] = true; + Id ret{}; + ret.is_valid.Assign(1); + ret.type.Assign(type); + ret.index.Assign(static_cast<u32>(var)); + return ret; } - throw NotImplementedException("Variable spilling"); + // Allocate a new variable + use_tracker.var_use.push_back(true); + Id ret{}; + ret.is_valid.Assign(1); + ret.type.Assign(type); + ret.index.Assign(static_cast<u32>(use_tracker.num_used)); + ++use_tracker.num_used; + return ret; } void VarAlloc::Free(Id id) { |