summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/backend/glsl/emit_glsl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_glsl.cpp')
-rw-r--r--src/shader_recompiler/backend/glsl/emit_glsl.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_glsl.cpp b/src/shader_recompiler/backend/glsl/emit_glsl.cpp
index 7b57c1e91..b189f6c11 100644
--- a/src/shader_recompiler/backend/glsl/emit_glsl.cpp
+++ b/src/shader_recompiler/backend/glsl/emit_glsl.cpp
@@ -172,19 +172,28 @@ std::string GlslVersionSpecifier(const EmitContext& ctx) {
172 return ""; 172 return "";
173} 173}
174 174
175bool IsPreciseType(GlslVarType type) {
176 switch (type) {
177 case GlslVarType::PrecF32:
178 case GlslVarType::PrecF64:
179 return true;
180 default:
181 return false;
182 }
183}
184
175void DefineVariables(const EmitContext& ctx, std::string& header) { 185void DefineVariables(const EmitContext& ctx, std::string& header) {
176 for (u32 i = 0; i < static_cast<u32>(GlslVarType::Void); ++i) { 186 for (u32 i = 0; i < static_cast<u32>(GlslVarType::Void); ++i) {
177 const auto type{static_cast<GlslVarType>(i)}; 187 const auto type{static_cast<GlslVarType>(i)};
178 const auto& tracker{ctx.var_alloc.GetUseTracker(type)}; 188 const auto& tracker{ctx.var_alloc.GetUseTracker(type)};
179 const auto type_name{ctx.var_alloc.GetGlslType(type)}; 189 const auto type_name{ctx.var_alloc.GetGlslType(type)};
180 const auto precise{ 190 const auto precise{IsPreciseType(type) ? "precise " : ""};
181 (type == GlslVarType::PrecF32 || type == GlslVarType::PrecF64) ? "precise " : ""};
182 // Temps/return types that are never used are stored at index 0 191 // Temps/return types that are never used are stored at index 0
183 if (tracker.uses_temp) { 192 if (tracker.uses_temp) {
184 header += fmt::format("{}{} {}={}(0);", precise, type_name, 193 header += fmt::format("{}{} t{}={}(0);", precise, type_name,
185 ctx.var_alloc.Representation(0, type), type_name); 194 ctx.var_alloc.Representation(0, type), type_name);
186 } 195 }
187 for (u32 index = 1; index <= tracker.num_used; ++index) { 196 for (u32 index = 0; index < tracker.num_used; ++index) {
188 header += fmt::format("{}{} {}={}(0);", precise, type_name, 197 header += fmt::format("{}{} {}={}(0);", precise, type_name,
189 ctx.var_alloc.Representation(index, type), type_name); 198 ctx.var_alloc.Representation(index, type), type_name);
190 } 199 }