summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar bunnei2018-04-06 23:53:19 -0400
committerGravatar bunnei2018-04-13 23:48:20 -0400
commitdbfd106ba023e408bdb733f39af30134712b97bf (patch)
treeaab2a36318d6a6925a1644a4ec622c9f5c4ba599 /src/video_core
parentgl_shader_decompiler: Add skeleton code from Citra for shader analysis. (diff)
downloadyuzu-dbfd106ba023e408bdb733f39af30134712b97bf.tar.gz
yuzu-dbfd106ba023e408bdb733f39af30134712b97bf.tar.xz
yuzu-dbfd106ba023e408bdb733f39af30134712b97bf.zip
gl_resource_manager: Grab latest upstream.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_resource_manager.h116
1 files changed, 86 insertions, 30 deletions
diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h
index 7da5e74d1..557f73a51 100644
--- a/src/video_core/renderer_opengl/gl_resource_manager.h
+++ b/src/video_core/renderer_opengl/gl_resource_manager.h
@@ -13,14 +13,16 @@
13class OGLTexture : private NonCopyable { 13class OGLTexture : private NonCopyable {
14public: 14public:
15 OGLTexture() = default; 15 OGLTexture() = default;
16 OGLTexture(OGLTexture&& o) { 16
17 std::swap(handle, o.handle); 17 OGLTexture(OGLTexture&& o) : handle(std::exchange(o.handle, 0)) {}
18 } 18
19 ~OGLTexture() { 19 ~OGLTexture() {
20 Release(); 20 Release();
21 } 21 }
22
22 OGLTexture& operator=(OGLTexture&& o) { 23 OGLTexture& operator=(OGLTexture&& o) {
23 std::swap(handle, o.handle); 24 Release();
25 handle = std::exchange(o.handle, 0);
24 return *this; 26 return *this;
25 } 27 }
26 28
@@ -46,14 +48,16 @@ public:
46class OGLSampler : private NonCopyable { 48class OGLSampler : private NonCopyable {
47public: 49public:
48 OGLSampler() = default; 50 OGLSampler() = default;
49 OGLSampler(OGLSampler&& o) { 51
50 std::swap(handle, o.handle); 52 OGLSampler(OGLSampler&& o) : handle(std::exchange(o.handle, 0)) {}
51 } 53
52 ~OGLSampler() { 54 ~OGLSampler() {
53 Release(); 55 Release();
54 } 56 }
57
55 OGLSampler& operator=(OGLSampler&& o) { 58 OGLSampler& operator=(OGLSampler&& o) {
56 std::swap(handle, o.handle); 59 Release();
60 handle = std::exchange(o.handle, 0);
57 return *this; 61 return *this;
58 } 62 }
59 63
@@ -79,25 +83,71 @@ public:
79class OGLShader : private NonCopyable { 83class OGLShader : private NonCopyable {
80public: 84public:
81 OGLShader() = default; 85 OGLShader() = default;
82 OGLShader(OGLShader&& o) { 86
83 std::swap(handle, o.handle); 87 OGLShader(OGLShader&& o) : handle(std::exchange(o.handle, 0)) {}
84 } 88
85 ~OGLShader() { 89 ~OGLShader() {
86 Release(); 90 Release();
87 } 91 }
92
88 OGLShader& operator=(OGLShader&& o) { 93 OGLShader& operator=(OGLShader&& o) {
89 std::swap(handle, o.handle); 94 Release();
95 handle = std::exchange(o.handle, 0);
90 return *this; 96 return *this;
91 } 97 }
92 98
93 /// Creates a new internal OpenGL resource and stores the handle 99 void Create(const char* source, GLenum type) {
94 void Create(const char* vert_shader, const char* geo_shader, const char* frag_shader, 100 if (handle != 0)
95 const std::vector<const char*>& feedback_vars = {}, 101 return;
96 bool separable_program = false) { 102 if (source == nullptr)
103 return;
104 handle = GLShader::LoadShader(source, type);
105 }
106
107 void Release() {
108 if (handle == 0)
109 return;
110 glDeleteShader(handle);
111 handle = 0;
112 }
113
114 GLuint handle = 0;
115};
116
117class OGLProgram : private NonCopyable {
118public:
119 OGLProgram() = default;
120
121 OGLProgram(OGLProgram&& o) : handle(std::exchange(o.handle, 0)) {}
122
123 ~OGLProgram() {
124 Release();
125 }
126
127 OGLProgram& operator=(OGLProgram&& o) {
128 Release();
129 handle = std::exchange(o.handle, 0);
130 return *this;
131 }
132
133 template <typename... T>
134 void Create(bool separable_program = false, T... shaders) {
97 if (handle != 0) 135 if (handle != 0)
98 return; 136 return;
99 handle = GLShader::LoadProgram(vert_shader, geo_shader, frag_shader, feedback_vars, 137 handle = GLShader::LoadProgram(separable_program, shaders...);
100 separable_program); 138 }
139
140 /// Creates a new internal OpenGL resource and stores the handle
141 void CreateFromSource(const char* vert_shader, const char* geo_shader, const char* frag_shader,
142 bool separable_program = false) {
143 OGLShader vert, geo, frag;
144 if (vert_shader)
145 vert.Create(vert_shader, GL_VERTEX_SHADER);
146 if (geo_shader)
147 geo.Create(geo_shader, GL_GEOMETRY_SHADER);
148 if (frag_shader)
149 frag.Create(frag_shader, GL_FRAGMENT_SHADER);
150 Create(separable_program, vert.handle, geo.handle, frag.handle);
101 } 151 }
102 152
103 /// Deletes the internal OpenGL resource 153 /// Deletes the internal OpenGL resource
@@ -148,14 +198,16 @@ public:
148class OGLBuffer : private NonCopyable { 198class OGLBuffer : private NonCopyable {
149public: 199public:
150 OGLBuffer() = default; 200 OGLBuffer() = default;
151 OGLBuffer(OGLBuffer&& o) { 201
152 std::swap(handle, o.handle); 202 OGLBuffer(OGLBuffer&& o) : handle(std::exchange(o.handle, 0)) {}
153 } 203
154 ~OGLBuffer() { 204 ~OGLBuffer() {
155 Release(); 205 Release();
156 } 206 }
207
157 OGLBuffer& operator=(OGLBuffer&& o) { 208 OGLBuffer& operator=(OGLBuffer&& o) {
158 std::swap(handle, o.handle); 209 Release();
210 handle = std::exchange(o.handle, 0);
159 return *this; 211 return *this;
160 } 212 }
161 213
@@ -214,14 +266,16 @@ public:
214class OGLVertexArray : private NonCopyable { 266class OGLVertexArray : private NonCopyable {
215public: 267public:
216 OGLVertexArray() = default; 268 OGLVertexArray() = default;
217 OGLVertexArray(OGLVertexArray&& o) { 269
218 std::swap(handle, o.handle); 270 OGLVertexArray(OGLVertexArray&& o) : handle(std::exchange(o.handle, 0)) {}
219 } 271
220 ~OGLVertexArray() { 272 ~OGLVertexArray() {
221 Release(); 273 Release();
222 } 274 }
275
223 OGLVertexArray& operator=(OGLVertexArray&& o) { 276 OGLVertexArray& operator=(OGLVertexArray&& o) {
224 std::swap(handle, o.handle); 277 Release();
278 handle = std::exchange(o.handle, 0);
225 return *this; 279 return *this;
226 } 280 }
227 281
@@ -247,14 +301,16 @@ public:
247class OGLFramebuffer : private NonCopyable { 301class OGLFramebuffer : private NonCopyable {
248public: 302public:
249 OGLFramebuffer() = default; 303 OGLFramebuffer() = default;
250 OGLFramebuffer(OGLFramebuffer&& o) { 304
251 std::swap(handle, o.handle); 305 OGLFramebuffer(OGLFramebuffer&& o) : handle(std::exchange(o.handle, 0)) {}
252 } 306
253 ~OGLFramebuffer() { 307 ~OGLFramebuffer() {
254 Release(); 308 Release();
255 } 309 }
310
256 OGLFramebuffer& operator=(OGLFramebuffer&& o) { 311 OGLFramebuffer& operator=(OGLFramebuffer&& o) {
257 std::swap(handle, o.handle); 312 Release();
313 handle = std::exchange(o.handle, 0);
258 return *this; 314 return *this;
259 } 315 }
260 316