summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_gen.h
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-04-15 09:32:12 +0200
committerbunnei <bunneidev@gmail.com>2018-04-15 17:50:10 +0200
commit73d9c494ea6ae0a8076f679506ff07e2fe014826 (patch)
treef283b7d9b9014488dabd45e97f5687c2d67e842d /src/video_core/renderer_opengl/gl_shader_gen.h
parentMerge pull request #328 from Subv/constbuffers (diff)
downloadyuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar
yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.gz
yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.bz2
yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.lz
yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.xz
yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.tar.zst
yuzu-73d9c494ea6ae0a8076f679506ff07e2fe014826.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_gen.h')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.h38
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