diff options
| author | 2021-06-02 00:48:49 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:37 -0400 | |
| commit | 6577a63d368afa57d5f29df40e524af30eaabffa (patch) | |
| tree | f7f8395570364499933551332c4c9c92c00d650d /src/shader_recompiler/backend/glsl/emit_context.cpp | |
| parent | glsl: Implement transform feedback (diff) | |
| download | yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar.gz yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.tar.xz yuzu-6577a63d368afa57d5f29df40e524af30eaabffa.zip | |
glsl: skip gl_ViewportIndex write if device does not support it
Diffstat (limited to 'src/shader_recompiler/backend/glsl/emit_context.cpp')
| -rw-r--r-- | src/shader_recompiler/backend/glsl/emit_context.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/shader_recompiler/backend/glsl/emit_context.cpp b/src/shader_recompiler/backend/glsl/emit_context.cpp index 58355d5e3..846d38bfc 100644 --- a/src/shader_recompiler/backend/glsl/emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/emit_context.cpp | |||
| @@ -148,23 +148,24 @@ std::string_view OutputPrimitive(OutputTopology topology) { | |||
| 148 | throw InvalidArgument("Invalid output topology {}", topology); | 148 | throw InvalidArgument("Invalid output topology {}", topology); |
| 149 | } | 149 | } |
| 150 | 150 | ||
| 151 | void SetupOutPerVertex(Stage stage, const Info& info, std::string& header) { | 151 | void SetupOutPerVertex(EmitContext& ctx, std::string& header) { |
| 152 | if (!StoresPerVertexAttributes(stage)) { | 152 | if (!StoresPerVertexAttributes(ctx.stage)) { |
| 153 | return; | 153 | return; |
| 154 | } | 154 | } |
| 155 | header += "out gl_PerVertex{"; | 155 | header += "out gl_PerVertex{"; |
| 156 | header += "vec4 gl_Position;"; | 156 | header += "vec4 gl_Position;"; |
| 157 | if (info.stores_point_size) { | 157 | if (ctx.info.stores_point_size) { |
| 158 | header += "float gl_PointSize;"; | 158 | header += "float gl_PointSize;"; |
| 159 | } | 159 | } |
| 160 | if (info.stores_clip_distance) { | 160 | if (ctx.info.stores_clip_distance) { |
| 161 | header += "float gl_ClipDistance[];"; | 161 | header += "float gl_ClipDistance[];"; |
| 162 | } | 162 | } |
| 163 | if (info.stores_viewport_index && stage != Stage::Geometry) { | 163 | if (ctx.info.stores_viewport_index && ctx.supports_viewport_layer && |
| 164 | ctx.stage != Stage::Geometry) { | ||
| 164 | header += "int gl_ViewportIndex;"; | 165 | header += "int gl_ViewportIndex;"; |
| 165 | } | 166 | } |
| 166 | header += "};\n"; | 167 | header += "};\n"; |
| 167 | if (info.stores_viewport_index && stage == Stage::Geometry) { | 168 | if (ctx.info.stores_viewport_index && ctx.stage == Stage::Geometry) { |
| 168 | header += "out int gl_ViewportIndex;"; | 169 | header += "out int gl_ViewportIndex;"; |
| 169 | } | 170 | } |
| 170 | } | 171 | } |
| @@ -173,6 +174,7 @@ void SetupOutPerVertex(Stage stage, const Info& info, std::string& header) { | |||
| 173 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, | 174 | EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile& profile_, |
| 174 | const RuntimeInfo& runtime_info_) | 175 | const RuntimeInfo& runtime_info_) |
| 175 | : info{program.info}, profile{profile_}, runtime_info{runtime_info_} { | 176 | : info{program.info}, profile{profile_}, runtime_info{runtime_info_} { |
| 177 | supports_viewport_layer = profile.support_gl_vertex_viewport_layer; | ||
| 176 | SetupExtensions(header); | 178 | SetupExtensions(header); |
| 177 | stage = program.stage; | 179 | stage = program.stage; |
| 178 | switch (program.stage) { | 180 | switch (program.stage) { |
| @@ -206,7 +208,7 @@ EmitContext::EmitContext(IR::Program& program, Bindings& bindings, const Profile | |||
| 206 | program.workgroup_size[2]); | 208 | program.workgroup_size[2]); |
| 207 | break; | 209 | break; |
| 208 | } | 210 | } |
| 209 | SetupOutPerVertex(stage, info, header); | 211 | SetupOutPerVertex(*this, header); |
| 210 | for (size_t index = 0; index < info.input_generics.size(); ++index) { | 212 | for (size_t index = 0; index < info.input_generics.size(); ++index) { |
| 211 | const auto& generic{info.input_generics[index]}; | 213 | const auto& generic{info.input_generics[index]}; |
| 212 | if (generic.used) { | 214 | if (generic.used) { |
| @@ -276,7 +278,7 @@ void EmitContext::SetupExtensions(std::string&) { | |||
| 276 | header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; | 278 | header += "#extension GL_ARB_gpu_shader_int64 : enable\n"; |
| 277 | } | 279 | } |
| 278 | } | 280 | } |
| 279 | if (info.stores_viewport_index && stage != Stage::Geometry) { | 281 | if (info.stores_viewport_index && supports_viewport_layer && stage != Stage::Geometry) { |
| 280 | header += "#extension GL_ARB_shader_viewport_layer_array : enable\n"; | 282 | header += "#extension GL_ARB_shader_viewport_layer_array : enable\n"; |
| 281 | } | 283 | } |
| 282 | } | 284 | } |