diff options
author | bunnei <bunneidev@gmail.com> | 2018-08-23 23:30:27 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-08-28 00:26:46 +0200 |
commit | b55d8111e66ab909ec932850284a7afd13827303 (patch) | |
tree | f98c72d65efc52ef63c151801337a16eafeb4357 /src/video_core/renderer_opengl/gl_shader_cache.h | |
parent | gl_rasterizer_cache: Update to use RasterizerCache base class. (diff) | |
download | yuzu-b55d8111e66ab909ec932850284a7afd13827303.tar yuzu-b55d8111e66ab909ec932850284a7afd13827303.tar.gz yuzu-b55d8111e66ab909ec932850284a7afd13827303.tar.bz2 yuzu-b55d8111e66ab909ec932850284a7afd13827303.tar.lz yuzu-b55d8111e66ab909ec932850284a7afd13827303.tar.xz yuzu-b55d8111e66ab909ec932850284a7afd13827303.tar.zst yuzu-b55d8111e66ab909ec932850284a7afd13827303.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_cache.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.h b/src/video_core/renderer_opengl/gl_shader_cache.h new file mode 100644 index 000000000..44156dcab --- /dev/null +++ b/src/video_core/renderer_opengl/gl_shader_cache.h @@ -0,0 +1,69 @@ +// Copyright 2018 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <memory> +#include <unordered_map> + +#include "common/common_types.h" +#include "video_core/memory_manager.h" +#include "video_core/rasterizer_cache.h" +#include "video_core/renderer_opengl/gl_resource_manager.h" +#include "video_core/renderer_opengl/gl_shader_gen.h" + +namespace OpenGL { + +class CachedShader; +using Shader = std::shared_ptr<CachedShader>; +using Maxwell = Tegra::Engines::Maxwell3D::Regs; + +class CachedShader final { +public: + CachedShader(Tegra::GPUVAddr addr, Maxwell::ShaderProgram program_type); + + /// Gets the address of the shader in guest memory, required for cache management + Tegra::GPUVAddr GetAddr() const { + return addr; + } + + /// Gets the size of the shader in guest memory, required for cache management + size_t GetSizeInBytes() const { + return sizeof(GLShader::ProgramCode); + } + + /// Gets the shader entries for the shader + const GLShader::ShaderEntries& GetShaderEntries() const { + return entries; + } + + /// Gets the GL program handle for the shader + GLuint GetProgramHandle() const { + return program.handle; + } + + /// Gets the GL program resource location for the specified resource, caching as needed + GLuint GetProgramResourceIndex(const std::string& name); + + /// Gets the GL uniform location for the specified resource, caching as needed + GLint GetUniformLocation(const std::string& name); + +private: + Tegra::GPUVAddr addr; + Maxwell::ShaderProgram program_type; + GLShader::ShaderSetup setup; + GLShader::ShaderEntries entries; + OGLProgram program; + + std::unordered_map<std::string, GLuint> resource_cache; + std::unordered_map<std::string, GLint> uniform_cache; +}; + +class ShaderCacheOpenGL final : public RasterizerCache<Shader> { +public: + /// Gets the current specified shader stage program + Shader GetStageProgram(Maxwell::ShaderProgram program); +}; + +} // namespace OpenGL |