diff options
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_context.cpp | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index 0d7f7bc3b..36527bbd4 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -236,6 +236,9 @@ void SetupOutPerVertex(EmitContext& ctx, std::string& header) { | |||
| 236 | if (!StoresPerVertexAttributes(ctx.stage)) { | 236 | if (!StoresPerVertexAttributes(ctx.stage)) { |
| 237 | return; | 237 | return; |
| 238 | } | 238 | } |
| 239 | if (ctx.uses_geometry_passthrough) { | ||
| 240 | return; | ||
| 241 | } | ||
| 239 | header += "out gl_PerVertex{vec4 gl_Position;"; | 242 | header += "out gl_PerVertex{vec4 gl_Position;"; |
| 240 | if (ctx.info.stores[IR::Attribute::PointSize]) { | 243 | if (ctx.info.stores[IR::Attribute::PointSize]) { |
| 241 | header += "float gl_PointSize;"; | 244 | header += "float gl_PointSize;"; |
| @@ -272,12 +275,13 @@ void SetupLegacyInPerFragment(EmitContext& ctx, std::string& header) { | |||
| 272 | 275 | ||
| 273 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | 276 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| 274 | const RuntimeInfo& runtime_info_) | 277 | const RuntimeInfo& runtime_info_) |
| 275 | : info{program.info}, profile{profile_}, runtime_info{runtime_info_} { | 278 | : info{program.info}, profile{profile_}, runtime_info{runtime_info_}, stage{program.stage}, |
| 279 | uses_geometry_passthrough{program.is_geometry_passthrough && | ||
| 280 | profile.support_geometry_shader_passthrough} { | ||
| 276 | if (profile.need_fastmath_off) { | 281 | if (profile.need_fastmath_off) { |
| 277 | header += "#pragma optionNV(fastmath off)\n"; | 282 | header += "#pragma optionNV(fastmath off)\n"; |
| 278 | } | 283 | } |
| 279 | SetupExtensions(); | 284 | SetupExtensions(); |
| 280 | stage = program.stage; | ||
| 281 | switch (program.stage) { | 285 | switch (program.stage) { |
| 282 | case Stage::VertexA: | 286 | case Stage::VertexA: |
| 283 | case Stage::VertexB: | 287 | case Stage::VertexB: |
| @@ -295,10 +299,17 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 295 | break; | 299 | break; |
| 296 | case Stage::Geometry: | 300 | case Stage::Geometry: |
| 297 | stage_name = "gs"; | 301 | stage_name = "gs"; |
| 298 | header += fmt::format("layout({})in;layout({},max_vertices={})out;" | 302 | header += fmt::format("layout({})in;", InputPrimitive(runtime_info.input_topology)); |
| 299 | "in gl_PerVertex{{vec4 gl_Position;}}gl_in[];", | 303 | if (uses_geometry_passthrough) { |
| 300 | InputPrimitive(runtime_info.input_topology), | 304 | header += "layout(passthrough)in gl_PerVertex{vec4 gl_Position;};"; |
| 301 | OutputPrimitive(program.output_topology), program.output_vertices); | 305 | break; |
| 306 | } else if (program.is_geometry_passthrough && | ||
| 307 | !profile.support_geometry_shader_passthrough) { | ||
| 308 | LOG_WARNING(Shader_GLSL, "Passthrough geometry program used but not supported"); | ||
| 309 | } | ||
| 310 | header += fmt::format( | ||
| 311 | "layout({},max_vertices={})out;in gl_PerVertex{{vec4 gl_Position;}}gl_in[];", | ||
| 312 | OutputPrimitive(program.output_topology), program.output_vertices); | ||
| 302 | break; | 313 | break; |
| 303 | case Stage::Fragment: | 314 | case Stage::Fragment: |
| 304 | stage_name = "fs"; | 315 | stage_name = "fs"; |
| @@ -329,7 +340,9 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 329 | if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) { | 340 | if (!info.loads.Generic(index) || !runtime_info.previous_stage_stores.Generic(index)) { |
| 330 | continue; | 341 | continue; |
| 331 | } | 342 | } |
| 332 | header += fmt::format("layout(location={}){}in vec4 in_attr{}{};", index, | 343 | const auto qualifier{uses_geometry_passthrough ? "passthrough" |
| 344 | : fmt::format("location={}", index)}; | ||
| 345 | header += fmt::format("layout({}){}in vec4 in_attr{}{};", qualifier, | ||
| 333 | InterpDecorator(info.interpolation[index]), index, | 346 | InterpDecorator(info.interpolation[index]), index, |
| 334 | InputArrayDecorator(stage)); | 347 | InputArrayDecorator(stage)); |
| 335 | } | 348 | } |
| @@ -412,6 +425,9 @@ void EmitContext::SetupExtensions() { | |||
| 412 | if (info.uses_derivatives && profile.support_gl_derivative_control) { | 425 | if (info.uses_derivatives && profile.support_gl_derivative_control) { |
| 413 | header += "#extension GL_ARB_derivative_control : enable\n"; | 426 | header += "#extension GL_ARB_derivative_control : enable\n"; |
| 414 | } | 427 | } |
| 428 | if (uses_geometry_passthrough) { | ||
| 429 | header += "#extension GL_NV_geometry_shader_passthrough : enable\n"; | ||
| 430 | } | ||
| 415 | } | 431 | } |
| 416 | 432 | ||
| 417 | void EmitContext::DefineConstantBuffers(Bindings& bindings) { | 433 | void EmitContext::DefineConstantBuffers(Bindings& bindings) { |