Overte C++ Documentation
gpu/src/gpu/Forward.h
1 //
2 // Created by Bradley Austin Davis on 2015/08/15
3 // Copyright 2015 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 #pragma once
9 #ifndef hifi_gpu_Forward_h
10 #define hifi_gpu_Forward_h
11 
12 #include <stdint.h>
13 #include <memory>
14 #include <mutex>
15 #include <vector>
16 
17 #include <glm/glm.hpp>
18 
19 namespace gpu {
20  using Mutex = std::mutex;
21  using Lock = std::unique_lock<Mutex>;
22 
23  class Batch;
24  using BatchPointer = std::shared_ptr<Batch>;
25  class Backend;
26  using BackendPointer = std::shared_ptr<Backend>;
27  class Context;
28  using ContextPointer = std::shared_ptr<Context>;
29  class GPUObject;
30  class Frame;
31  using FramePointer = std::shared_ptr<Frame>;
32 
33  using Stamp = int;
34  using uint32 = uint32_t;
35  using int32 = int32_t;
36  using uint16 = uint16_t;
37  using int16 = int16_t;
38  using uint8 = uint8_t;
39  using int8 = int8_t;
40 
41  using Byte = uint8;
42  using Size = size_t;
43  static const Size INVALID_SIZE = (Size)-1;
44 
45  using Offset = size_t;
46  using Offsets = std::vector<Offset>;
47 
48  using Mat4 = glm::mat4;
49  using Mat3 = glm::mat3;
50  using Vec4 = glm::vec4;
51  using Vec4i = glm::ivec4;
52  using Vec3 = glm::vec3;
53  using Vec2 = glm::vec2;
54  using Vec2i = glm::ivec2;
55  using Vec2u = glm::uvec2;
56  using Vec3u = glm::uvec3;
57  using Vec3u = glm::uvec3;
58 
59  class Element;
60  using Format = Element;
61  class Swapchain;
62  using SwapchainPointer = std::shared_ptr<Swapchain>;
63  class Framebuffer;
64  using FramebufferPointer = std::shared_ptr<Framebuffer>;
65  class Pipeline;
66  using PipelinePointer = std::shared_ptr<Pipeline>;
67  using Pipelines = std::vector<PipelinePointer>;
68  class Query;
69  using QueryPointer = std::shared_ptr<Query>;
70  using Queries = std::vector<QueryPointer>;
71  class Resource;
72  class Buffer;
73  using BufferPointer = std::shared_ptr<Buffer>;
74  using Buffers = std::vector<BufferPointer>;
75  class BufferView;
76  class Shader;
77  using ShaderPointer = std::shared_ptr<Shader>;
78  using Shaders = std::vector<ShaderPointer>;
79  class State;
80  using StatePointer = std::shared_ptr<State>;
81  using States = std::vector<StatePointer>;
82  class Stream;
83  class BufferStream;
84  using BufferStreamPointer = std::shared_ptr<BufferStream>;
85  class Texture;
86  class SphericalHarmonics;
87  using SHPointer = std::shared_ptr<SphericalHarmonics>;
88  class Sampler;
89  class Texture;
90  using TexturePointer = std::shared_ptr<Texture>;
91  using TextureWeakPointer = std::weak_ptr<Texture>;
92  using Textures = std::vector<TexturePointer>;
93  class TextureView;
94  using TextureViews = std::vector<TextureView>;
95  class TextureTable;
96  using TextureTablePointer = std::shared_ptr<TextureTable>;
97 
98  struct StereoState {
99  StereoState() {}
100  bool isStereo() const {
101  return _enable && !_contextDisable;
102  }
103  bool _enable{ false };
104  bool _contextDisable { false };
105  bool _skybox{ false };
106  // 0 for left eye, 1 for right eye
107  uint8 _pass{ 0 };
108  Mat4 _eyeViews[2];
109  Mat4 _eyeProjections[2];
110  };
111 
112  class Serializer;
113  class Deserializer;
114 
115  class GPUObject {
116  public:
117  virtual ~GPUObject() = default;
118  };
119 
120  class GPUObjectPointer {
121  private:
122  using GPUObjectUniquePointer = std::unique_ptr<GPUObject>;
123 
124  // This shouldn't be used by anything else than the Backend class with the proper casting.
125  mutable GPUObjectUniquePointer _gpuObject;
126  void setGPUObject(GPUObject* gpuObject) const { _gpuObject.reset(gpuObject); }
127  GPUObject* getGPUObject() const { return _gpuObject.get(); }
128 
129  friend class Backend;
130  friend class Texture;
131  };
132 
133  namespace gl {
134  class GLBackend;
135  class GLBuffer;
136  }
137 
138  namespace gl41 {
139  class GL41Backend;
140  class GL41Buffer;
141  }
142 
143  namespace gl45 {
144  class GL45Backend;
145  class GL45Buffer;
146  }
147 
148  namespace gles {
149  class GLESBackend;
150  class GLESBuffer;
151  }
152 }
153 
154 #endif
Provides the Mat4 scripting interface.
Definition: Mat4.h:44
Base class for resources.
Definition: ResourceCache.h:409
A simple object wrapper for an OpenGL texture.
Definition: material-networking/src/material-networking/TextureCache.h:39
Provides the Vec3 scripting interface.
Definition: Vec3.h:80