diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-01-14 04:58:15 +0100 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-02-07 02:20:57 +0100 |
commit | a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf (patch) | |
tree | 84ffe77dabc36e77dc0fb543d96d8774483c67a0 /src/video_core/renderer_opengl/gl_shader_cache.h | |
parent | gl_shader_disk_cache: Add transferable cache invalidation (diff) | |
download | yuzu-a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf.tar yuzu-a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf.tar.gz yuzu-a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf.tar.bz2 yuzu-a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf.tar.lz yuzu-a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf.tar.xz yuzu-a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf.tar.zst yuzu-a3703f5767332dfc5f7e8d37a1f715d8ccb76fcf.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.h | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h index 18fb80bcc..763a47bce 100644 --- a/src/video_core/renderer_opengl/gl_shader_cache.h +++ b/src/video_core/renderer_opengl/gl_shader_cache.h @@ -7,6 +7,7 @@ #include <array> #include <map> #include <memory> +#include <set> #include <tuple> #include <glad/glad.h> @@ -23,13 +24,25 @@ namespace OpenGL { class CachedShader; class RasterizerOpenGL; +struct UnspecializedShader; using Shader = std::shared_ptr<CachedShader>; +using CachedProgram = std::shared_ptr<OGLProgram>; using Maxwell = Tegra::Engines::Maxwell3D::Regs; +using PrecompiledPrograms = std::map<ShaderDiskCacheUsage, CachedProgram>; +using PrecompiledShaders = std::map<u64, GLShader::ProgramResult>; class CachedShader final : public RasterizerCacheObject { public: - CachedShader(VAddr addr, Maxwell::ShaderProgram program_type); + explicit CachedShader(VAddr addr, u64 unique_identifier, Maxwell::ShaderProgram program_type, + ShaderDiskCacheOpenGL& disk_cache, + const PrecompiledPrograms& precompiled_programs, + ProgramCode&& program_code, ProgramCode&& program_code_b); + + explicit CachedShader(VAddr addr, u64 unique_identifier, Maxwell::ShaderProgram program_type, + ShaderDiskCacheOpenGL& disk_cache, + const PrecompiledPrograms& precompiled_programs, + GLShader::ProgramResult result); VAddr GetAddr() const override { return addr; @@ -56,33 +69,35 @@ private: // declared by the hardware. Workaround this issue by generating a different shader per input // topology class. struct GeometryPrograms { - OGLProgram points; - OGLProgram lines; - OGLProgram lines_adjacency; - OGLProgram triangles; - OGLProgram triangles_adjacency; + CachedProgram points; + CachedProgram lines; + CachedProgram lines_adjacency; + CachedProgram triangles; + CachedProgram triangles_adjacency; }; - std::string AllocateBindings(BaseBindings base_bindings); - GLuint GetGeometryShader(GLenum primitive_mode, BaseBindings base_bindings); /// Generates a geometry shader or returns one that already exists. - GLuint LazyGeometryProgram(OGLProgram& target_program, BaseBindings base_bindings, - const std::string& glsl_topology, u32 max_vertices, - const std::string& debug_name); + GLuint LazyGeometryProgram(CachedProgram& target_program, BaseBindings base_bindings, + GLenum primitive_mode); + + CachedProgram TryLoadProgram(GLenum primitive_mode, BaseBindings base_bindings) const; + + ShaderDiskCacheUsage GetUsage(GLenum primitive_mode, BaseBindings base_bindings) const; - void CalculateProperties(); + const VAddr addr; + const u64 unique_identifier; + const Maxwell::ShaderProgram program_type; + ShaderDiskCacheOpenGL& disk_cache; + const PrecompiledPrograms& precompiled_programs; - VAddr addr{}; std::size_t shader_length{}; - Maxwell::ShaderProgram program_type{}; - GLShader::ShaderSetup setup; GLShader::ShaderEntries entries; std::string code; - std::map<BaseBindings, OGLProgram> programs; + std::map<BaseBindings, CachedProgram> programs; std::map<BaseBindings, GeometryPrograms> geometry_programs; std::map<u32, GLuint> cbuf_resource_cache; @@ -101,7 +116,19 @@ public: Shader GetStageProgram(Maxwell::ShaderProgram program); private: + std::map<u64, UnspecializedShader> GenerateUnspecializedShaders( + const std::vector<ShaderDiskCacheRaw>& raws); + + CachedProgram GeneratePrecompiledProgram( + std::vector<ShaderDiskCachePrecompiledEntry>& precompiled, + const ShaderDiskCachePrecompiledEntry& precompiled_entry, + const std::set<GLenum>& supported_formats); + std::array<Shader, Maxwell::MaxShaderProgram> last_shaders; + + ShaderDiskCacheOpenGL disk_cache; + PrecompiledShaders precompiled_shaders; + PrecompiledPrograms precompiled_programs; }; } // namespace OpenGL |