diff options
| author | 2021-05-21 02:57:52 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:33 -0400 | |
| commit | c07cc9d6a560d14e25ec59974ae5a15a7842d779 (patch) | |
| tree | f72f753f27614486b687280ae0d915b34ff240f1 /src | |
| parent | shader: Split profile and runtime information in separate structs (diff) | |
| download | yuzu-c07cc9d6a560d14e25ec59974ae5a15a7842d779.tar.gz yuzu-c07cc9d6a560d14e25ec59974ae5a15a7842d779.tar.xz yuzu-c07cc9d6a560d14e25ec59974ae5a15a7842d779.zip | |
gl_shader_cache: Pass shader runtime information
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.cpp | 76 |
1 files changed, 74 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index d7efbdd01..b4f26dd74 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp | |||
| @@ -184,6 +184,76 @@ GLenum AssemblyStage(size_t stage_index) { | |||
| 184 | UNREACHABLE_MSG("{}", stage_index); | 184 | UNREACHABLE_MSG("{}", stage_index); |
| 185 | return GL_NONE; | 185 | return GL_NONE; |
| 186 | } | 186 | } |
| 187 | |||
| 188 | Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsProgramKey& key, | ||
| 189 | const Shader::IR::Program& program) { | ||
| 190 | UNIMPLEMENTED_IF_MSG(key.xfb_enabled != 0, "Transform feedbacks"); | ||
| 191 | |||
| 192 | Shader::RuntimeInfo info; | ||
| 193 | switch (program.stage) { | ||
| 194 | case Shader::Stage::TessellationEval: | ||
| 195 | // We have to flip tessellation clockwise for some reason... | ||
| 196 | info.tess_clockwise = key.tessellation_clockwise == 0; | ||
| 197 | info.tess_primitive = [&key] { | ||
| 198 | switch (key.tessellation_primitive) { | ||
| 199 | case Maxwell::TessellationPrimitive::Isolines: | ||
| 200 | return Shader::TessPrimitive::Isolines; | ||
| 201 | case Maxwell::TessellationPrimitive::Triangles: | ||
| 202 | return Shader::TessPrimitive::Triangles; | ||
| 203 | case Maxwell::TessellationPrimitive::Quads: | ||
| 204 | return Shader::TessPrimitive::Quads; | ||
| 205 | } | ||
| 206 | UNREACHABLE(); | ||
| 207 | return Shader::TessPrimitive::Triangles; | ||
| 208 | }(); | ||
| 209 | info.tess_spacing = [&] { | ||
| 210 | switch (key.tessellation_spacing) { | ||
| 211 | case Maxwell::TessellationSpacing::Equal: | ||
| 212 | return Shader::TessSpacing::Equal; | ||
| 213 | case Maxwell::TessellationSpacing::FractionalOdd: | ||
| 214 | return Shader::TessSpacing::FractionalOdd; | ||
| 215 | case Maxwell::TessellationSpacing::FractionalEven: | ||
| 216 | return Shader::TessSpacing::FractionalEven; | ||
| 217 | } | ||
| 218 | UNREACHABLE(); | ||
| 219 | return Shader::TessSpacing::Equal; | ||
| 220 | }(); | ||
| 221 | break; | ||
| 222 | case Shader::Stage::Geometry: | ||
| 223 | |||
| 224 | break; | ||
| 225 | default: | ||
| 226 | break; | ||
| 227 | } | ||
| 228 | switch (key.gs_input_topology) { | ||
| 229 | case Maxwell::PrimitiveTopology::Points: | ||
| 230 | info.input_topology = Shader::InputTopology::Points; | ||
| 231 | break; | ||
| 232 | case Maxwell::PrimitiveTopology::Lines: | ||
| 233 | case Maxwell::PrimitiveTopology::LineLoop: | ||
| 234 | case Maxwell::PrimitiveTopology::LineStrip: | ||
| 235 | info.input_topology = Shader::InputTopology::Lines; | ||
| 236 | break; | ||
| 237 | case Maxwell::PrimitiveTopology::Triangles: | ||
| 238 | case Maxwell::PrimitiveTopology::TriangleStrip: | ||
| 239 | case Maxwell::PrimitiveTopology::TriangleFan: | ||
| 240 | case Maxwell::PrimitiveTopology::Quads: | ||
| 241 | case Maxwell::PrimitiveTopology::QuadStrip: | ||
| 242 | case Maxwell::PrimitiveTopology::Polygon: | ||
| 243 | case Maxwell::PrimitiveTopology::Patches: | ||
| 244 | info.input_topology = Shader::InputTopology::Triangles; | ||
| 245 | break; | ||
| 246 | case Maxwell::PrimitiveTopology::LinesAdjacency: | ||
| 247 | case Maxwell::PrimitiveTopology::LineStripAdjacency: | ||
| 248 | info.input_topology = Shader::InputTopology::LinesAdjacency; | ||
| 249 | break; | ||
| 250 | case Maxwell::PrimitiveTopology::TrianglesAdjacency: | ||
| 251 | case Maxwell::PrimitiveTopology::TriangleStripAdjacency: | ||
| 252 | info.input_topology = Shader::InputTopology::TrianglesAdjacency; | ||
| 253 | break; | ||
| 254 | } | ||
| 255 | return info; | ||
| 256 | } | ||
| 187 | } // Anonymous namespace | 257 | } // Anonymous namespace |
| 188 | 258 | ||
| 189 | ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindow& emu_window_, | 259 | ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindow& emu_window_, |
| @@ -283,11 +353,13 @@ std::unique_ptr<GraphicsProgram> ShaderCache::CreateGraphicsProgram( | |||
| 283 | Shader::IR::Program& program{programs[index]}; | 353 | Shader::IR::Program& program{programs[index]}; |
| 284 | const size_t stage_index{index - 1}; | 354 | const size_t stage_index{index - 1}; |
| 285 | infos[stage_index] = &program.info; | 355 | infos[stage_index] = &program.info; |
| 356 | |||
| 357 | const Shader::RuntimeInfo runtime_info{MakeRuntimeInfo(key, program)}; | ||
| 286 | if (device.UseAssemblyShaders()) { | 358 | if (device.UseAssemblyShaders()) { |
| 287 | const std::string code{EmitGLASM(profile, {}, program, binding)}; | 359 | const std::string code{EmitGLASM(profile, runtime_info, program, binding)}; |
| 288 | assembly_programs[stage_index] = CompileProgram(code, AssemblyStage(stage_index)); | 360 | assembly_programs[stage_index] = CompileProgram(code, AssemblyStage(stage_index)); |
| 289 | } else { | 361 | } else { |
| 290 | const std::vector<u32> code{EmitSPIRV(profile, {}, program, binding)}; | 362 | const std::vector<u32> code{EmitSPIRV(profile, runtime_info, program, binding)}; |
| 291 | AddShader(Stage(stage_index), source_program.handle, code); | 363 | AddShader(Stage(stage_index), source_program.handle, code); |
| 292 | } | 364 | } |
| 293 | } | 365 | } |