Ocular Engine
GPUBuffer.hpp
1 
17 #pragma once
18 #ifndef __H__OCULAR_GRAPHICS_GPU_BUFFER__H__
19 #define __H__OCULAR_GRAPHICS_GPU_BUFFER__H__
20 
21 #include <cstdint>
22 
23 //------------------------------------------------------------------------------------------
24 
29 namespace Ocular
30 {
35  namespace Graphics
36  {
40  enum class GPUBufferAccess
41  {
42  None = 0,
43  Read,
44  Write,
45  ReadWrite
46  };
47 
51  enum class GPUBufferStage
52  {
53  None = 0,
54  Vertex = 1,
55  Geometry = 2,
56  Fragment = 4
57  };
58 
63  {
66 
67  GPUBufferAccess cpuAccess;
68  GPUBufferAccess gpuAccess;
69 
70  GPUBufferStage stage;
71 
72  uint32_t bufferSize;
73  uint32_t elementSize;
74  uint32_t slot;
75  };
76 
81  class GPUBuffer
82  {
83  public:
84 
85  GPUBuffer(GPUBufferDescriptor const& descriptor);
86  ~GPUBuffer();
87 
88  //------------------------------------------------------------
89 
93  virtual void bind();
94 
98  virtual void unbind();
99 
106  virtual bool build(void const* source);
107 
119  virtual bool read(void* destination, uint32_t start, uint32_t size);
120 
132  virtual bool write(void const* source, uint32_t start, uint32_t size);
133 
137  GPUBufferDescriptor const& getDescriptor() const;
138 
139  protected:
140 
141  GPUBufferDescriptor m_Descriptor;
142 
143  private:
144  };
145  }
149 }
154 //------------------------------------------------------------------------------------------
155 
156 #endif
virtual bool read(void *destination, uint32_t start, uint32_t size)
Definition: GPUBuffer.cpp:75
virtual void unbind()
Definition: GPUBuffer.cpp:65
virtual bool build(void const *source)
Definition: GPUBuffer.cpp:70
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
A generic buffer that can be uploaded to the GPU.
Definition: GPUBuffer.hpp:81
Definition: GPUBuffer.hpp:62
virtual void bind()
Definition: GPUBuffer.cpp:60
GPUBufferDescriptor const & getDescriptor() const
Definition: GPUBuffer.cpp:85
virtual bool write(void const *source, uint32_t start, uint32_t size)
Definition: GPUBuffer.cpp:80