diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_context.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index ed10eca8a..f0e9dffc2 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -200,6 +200,27 @@ std::string_view OutputPrimitive(OutputTopology topology) { | |||
| 200 | throw InvalidArgument("Invalid output topology {}", topology); | 200 | throw InvalidArgument("Invalid output topology {}", topology); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | void SetupLegacyOutPerVertex(EmitContext& ctx, std::string& header) { | ||
| 204 | if (!ctx.info.stores_legacy_varyings) { | ||
| 205 | return; | ||
| 206 | } | ||
| 207 | if (ctx.info.stores_fixed_fnc_textures) { | ||
| 208 | header += "vec4 gl_TexCoord[8];"; | ||
| 209 | } | ||
| 210 | if (ctx.info.stores_color_front_diffuse) { | ||
| 211 | header += "vec4 gl_FrontColor;"; | ||
| 212 | } | ||
| 213 | if (ctx.info.stores_color_front_specular) { | ||
| 214 | header += "vec4 gl_FrontSecondaryColor;"; | ||
| 215 | } | ||
| 216 | if (ctx.info.stores_color_back_diffuse) { | ||
| 217 | header += "vec4 gl_BackColor;"; | ||
| 218 | } | ||
| 219 | if (ctx.info.stores_color_back_specular) { | ||
| 220 | header += "vec4 gl_BackSecondaryColor;"; | ||
| 221 | } | ||
| 222 | } | ||
| 223 | |||
| 203 | void SetupOutPerVertex(EmitContext& ctx, std::string& header) { | 224 | void SetupOutPerVertex(EmitContext& ctx, std::string& header) { |
| 204 | if (!StoresPerVertexAttributes(ctx.stage)) { | 225 | if (!StoresPerVertexAttributes(ctx.stage)) { |
| 205 | return; | 226 | return; |
| @@ -215,18 +236,34 @@ void SetupOutPerVertex(EmitContext& ctx, std::string& header) { | |||
| 215 | ctx.stage != Stage::Geometry) { | 236 | ctx.stage != Stage::Geometry) { |
| 216 | header += "int gl_ViewportIndex;"; | 237 | header += "int gl_ViewportIndex;"; |
| 217 | } | 238 | } |
| 239 | SetupLegacyOutPerVertex(ctx, header); | ||
| 218 | header += "};"; | 240 | header += "};"; |
| 219 | if (ctx.info.stores_viewport_index && ctx.stage == Stage::Geometry) { | 241 | if (ctx.info.stores_viewport_index && ctx.stage == Stage::Geometry) { |
| 220 | header += "out int gl_ViewportIndex;"; | 242 | header += "out int gl_ViewportIndex;"; |
| 221 | } | 243 | } |
| 222 | } | 244 | } |
| 245 | |||
| 246 | void SetupLegacyInPerFragment(EmitContext& ctx, std::string& header) { | ||
| 247 | if (!ctx.info.loads_legacy_varyings) { | ||
| 248 | return; | ||
| 249 | } | ||
| 250 | header += "in gl_PerFragment{"; | ||
| 251 | if (ctx.info.loads_fixed_fnc_textures) { | ||
| 252 | header += "vec4 gl_TexCoord[8];"; | ||
| 253 | } | ||
| 254 | if (ctx.info.loads_color_front_diffuse) { | ||
| 255 | header += "vec4 gl_Color;"; | ||
| 256 | } | ||
| 257 | header += "};"; | ||
| 258 | } | ||
| 259 | |||
| 223 | } // Anonymous namespace | 260 | } // Anonymous namespace |
| 224 | 261 | ||
| 225 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | 262 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| 226 | const RuntimeInfo& runtime_info_) | 263 | const RuntimeInfo& runtime_info_) |
| 227 | : info{program.info}, profile{profile_}, runtime_info{runtime_info_} { | 264 | : info{program.info}, profile{profile_}, runtime_info{runtime_info_} { |
| 228 | header += "#pragma optionNV(fastmath off)\n"; | 265 | header += "#pragma optionNV(fastmath off)\n"; |
| 229 | SetupExtensions(header); | 266 | SetupExtensions(); |
| 230 | stage = program.stage; | 267 | stage = program.stage; |
| 231 | switch (program.stage) { | 268 | switch (program.stage) { |
| 232 | case Stage::VertexA: | 269 | case Stage::VertexA: |
| @@ -271,6 +308,8 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 271 | break; | 308 | break; |
| 272 | } | 309 | } |
| 273 | SetupOutPerVertex(*this, header); | 310 | SetupOutPerVertex(*this, header); |
| 311 | SetupLegacyInPerFragment(*this, header); | ||
| 312 | |||
| 274 | for (size_t index = 0; index < info.input_generics.size(); ++index) { | 313 | for (size_t index = 0; index < info.input_generics.size(); ++index) { |
| 275 | const auto& generic{info.input_generics[index]}; | 314 | const auto& generic{info.input_generics[index]}; |
| 276 | if (generic.used) { | 315 | if (generic.used) { |
| @@ -306,7 +345,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 306 | DefineConstants(); | 345 | DefineConstants(); |
| 307 | } | 346 | } |
| 308 | 347 | ||
| 309 | void EmitContext::SetupExtensions(std::string&) { | 348 | void EmitContext::SetupExtensions() { |
| 310 | if (profile.support_gl_texture_shadow_lod) { | 349 | if (profile.support_gl_texture_shadow_lod) { |
| 311 | header += "#extension GL_EXT_texture_shadow_lod : enable\n"; | 350 | header += "#extension GL_EXT_texture_shadow_lod : enable\n"; |
| 312 | } | 351 | } |