diff options
author | bunnei <bunneidev@gmail.com> | 2018-04-15 18:12:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-15 18:12:17 +0200 |
commit | 34264879b359107ec0c2fdb6af4b17faf52e4a6a (patch) | |
tree | f283b7d9b9014488dabd45e97f5687c2d67e842d /src/video_core/renderer_opengl/gl_shader_gen.h | |
parent | Merge pull request #328 from Subv/constbuffers (diff) | |
parent | shaders: Expose hints about used const buffers. (diff) | |
download | yuzu-34264879b359107ec0c2fdb6af4b17faf52e4a6a.tar yuzu-34264879b359107ec0c2fdb6af4b17faf52e4a6a.tar.gz yuzu-34264879b359107ec0c2fdb6af4b17faf52e4a6a.tar.bz2 yuzu-34264879b359107ec0c2fdb6af4b17faf52e4a6a.tar.lz yuzu-34264879b359107ec0c2fdb6af4b17faf52e4a6a.tar.xz yuzu-34264879b359107ec0c2fdb6af4b17faf52e4a6a.tar.zst yuzu-34264879b359107ec0c2fdb6af4b17faf52e4a6a.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_gen.h')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 925e66ee4..3d9aead74 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.h +++ b/src/video_core/renderer_opengl/gl_shader_gen.h @@ -7,6 +7,8 @@ #include <array> #include <string> #include <type_traits> +#include <utility> +#include <vector> #include "common/common_types.h" #include "common/hash.h" @@ -16,6 +18,38 @@ constexpr size_t MAX_PROGRAM_CODE_LENGTH{0x1000}; using ProgramCode = std::array<u64, MAX_PROGRAM_CODE_LENGTH>; +class ConstBufferEntry { +public: + void MarkAsUsed(unsigned index, unsigned offset) { + is_used = true; + this->index = index; + max_offset = std::max(max_offset, offset); + } + + bool IsUsed() const { + return is_used; + } + + unsigned GetIndex() const { + return index; + } + + unsigned GetSize() const { + return max_offset + 1; + } + +private: + bool is_used{}; + unsigned index{}; + unsigned max_offset{}; +}; + +struct ShaderEntries { + std::vector<ConstBufferEntry> const_buffer_entries; +}; + +using ProgramResult = std::pair<std::string, ShaderEntries>; + struct ShaderSetup { ShaderSetup(ProgramCode&& program_code) : program_code(std::move(program_code)) {} @@ -58,13 +92,13 @@ struct MaxwellFSConfig : Common::HashableStruct<MaxwellShaderConfigCommon> { * Generates the GLSL vertex shader program source code for the given VS program * @returns String of the shader source code */ -std::string GenerateVertexShader(const ShaderSetup& setup, const MaxwellVSConfig& config); +ProgramResult GenerateVertexShader(const ShaderSetup& setup, const MaxwellVSConfig& config); /** * Generates the GLSL fragment shader program source code for the given FS program * @returns String of the shader source code */ -std::string GenerateFragmentShader(const ShaderSetup& setup, const MaxwellFSConfig& config); +ProgramResult GenerateFragmentShader(const ShaderSetup& setup, const MaxwellFSConfig& config); } // namespace GLShader |