From 73d9c494ea6ae0a8076f679506ff07e2fe014826 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 15 Apr 2018 03:32:12 -0400 Subject: shaders: Expose hints about used const buffers. --- src/video_core/renderer_opengl/gl_shader_gen.h | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/video_core/renderer_opengl/gl_shader_gen.h') 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 #include #include +#include +#include #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; +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 const_buffer_entries; +}; + +using ProgramResult = std::pair; + struct ShaderSetup { ShaderSetup(ProgramCode&& program_code) : program_code(std::move(program_code)) {} @@ -58,13 +92,13 @@ struct MaxwellFSConfig : Common::HashableStruct { * 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 -- cgit v1.2.3