1 // Copyright 2008 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #pragma once
6 
7 #include <array>
8 #include <memory>
9 
10 #include "Common/CommonTypes.h"
11 #include "Common/GL/GLUtil.h"
12 #include "VideoCommon/NativeVertexFormat.h"
13 #include "VideoCommon/VertexManagerBase.h"
14 
15 namespace OGL
16 {
17 class StreamBuffer;
18 class GLVertexFormat : public NativeVertexFormat
19 {
20 public:
21   GLVertexFormat(const PortableVertexDeclaration& vtx_decl);
22   ~GLVertexFormat();
23 
24   GLuint VAO;
25 };
26 
27 // Handles the OpenGL details of drawing lots of vertices quickly.
28 // Other functionality is moving out.
29 class VertexManager final : public VertexManagerBase
30 {
31 public:
32   VertexManager();
33   ~VertexManager() override;
34 
35   bool Initialize() override;
36 
37   void UploadUtilityUniforms(const void* uniforms, u32 uniforms_size) override;
38   bool UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format,
39                          u32* out_offset) override;
40   bool UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format, u32* out_offset,
41                          const void* palette_data, u32 palette_size,
42                          TexelBufferFormat palette_format, u32* out_palette_offset) override;
43 
44   GLuint GetVertexBufferHandle() const;
45   GLuint GetIndexBufferHandle() const;
46 
47 protected:
48   void ResetBuffer(u32 vertex_stride) override;
49   void CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_indices, u32* out_base_vertex,
50                     u32* out_base_index) override;
51   void UploadUniforms() override;
52 
53 private:
54   std::unique_ptr<StreamBuffer> m_vertex_buffer;
55   std::unique_ptr<StreamBuffer> m_index_buffer;
56   std::unique_ptr<StreamBuffer> m_texel_buffer;
57   std::array<GLuint, NUM_TEXEL_BUFFER_FORMATS> m_texel_buffer_views{};
58 };
59 }  // namespace OGL
60