summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-03-19 17:20:49 -0400
committerGravatar bunnei2018-03-19 23:14:02 -0400
commitdb0cfb8e8bac705a2dfa6780b2799905cce16d38 (patch)
tree1dcda4af288eabf5e31ab66ea1572a0d4edf3834 /src
parentrenderer_gl: Port over gl_stream_buffer module from Citra. (diff)
downloadyuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar.gz
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar.xz
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.zip
gl_resource_manager: Sync latest version with Citra.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_resource_manager.h85
1 files changed, 77 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h
index 13301ec9f..7da5e74d1 100644
--- a/src/video_core/renderer_opengl/gl_resource_manager.h
+++ b/src/video_core/renderer_opengl/gl_resource_manager.h
@@ -36,7 +36,7 @@ public:
36 if (handle == 0) 36 if (handle == 0)
37 return; 37 return;
38 glDeleteTextures(1, &handle); 38 glDeleteTextures(1, &handle);
39 OpenGLState::ResetTexture(handle); 39 OpenGLState::GetCurState().ResetTexture(handle).Apply();
40 handle = 0; 40 handle = 0;
41 } 41 }
42 42
@@ -69,7 +69,7 @@ public:
69 if (handle == 0) 69 if (handle == 0)
70 return; 70 return;
71 glDeleteSamplers(1, &handle); 71 glDeleteSamplers(1, &handle);
72 OpenGLState::ResetSampler(handle); 72 OpenGLState::GetCurState().ResetSampler(handle).Apply();
73 handle = 0; 73 handle = 0;
74 } 74 }
75 75
@@ -91,10 +91,13 @@ public:
91 } 91 }
92 92
93 /// Creates a new internal OpenGL resource and stores the handle 93 /// Creates a new internal OpenGL resource and stores the handle
94 void Create(const char* vert_shader, const char* frag_shader) { 94 void Create(const char* vert_shader, const char* geo_shader, const char* frag_shader,
95 const std::vector<const char*>& feedback_vars = {},
96 bool separable_program = false) {
95 if (handle != 0) 97 if (handle != 0)
96 return; 98 return;
97 handle = GLShader::LoadProgram(vert_shader, frag_shader); 99 handle = GLShader::LoadProgram(vert_shader, geo_shader, frag_shader, feedback_vars,
100 separable_program);
98 } 101 }
99 102
100 /// Deletes the internal OpenGL resource 103 /// Deletes the internal OpenGL resource
@@ -102,7 +105,40 @@ public:
102 if (handle == 0) 105 if (handle == 0)
103 return; 106 return;
104 glDeleteProgram(handle); 107 glDeleteProgram(handle);
105 OpenGLState::ResetProgram(handle); 108 OpenGLState::GetCurState().ResetProgram(handle).Apply();
109 handle = 0;
110 }
111
112 GLuint handle = 0;
113};
114
115class OGLPipeline : private NonCopyable {
116public:
117 OGLPipeline() = default;
118 OGLPipeline(OGLPipeline&& o) {
119 handle = std::exchange<GLuint>(o.handle, 0);
120 }
121 ~OGLPipeline() {
122 Release();
123 }
124 OGLPipeline& operator=(OGLPipeline&& o) {
125 handle = std::exchange<GLuint>(o.handle, 0);
126 return *this;
127 }
128
129 /// Creates a new internal OpenGL resource and stores the handle
130 void Create() {
131 if (handle != 0)
132 return;
133 glGenProgramPipelines(1, &handle);
134 }
135
136 /// Deletes the internal OpenGL resource
137 void Release() {
138 if (handle == 0)
139 return;
140 glDeleteProgramPipelines(1, &handle);
141 OpenGLState::GetCurState().ResetPipeline(handle).Apply();
106 handle = 0; 142 handle = 0;
107 } 143 }
108 144
@@ -135,13 +171,46 @@ public:
135 if (handle == 0) 171 if (handle == 0)
136 return; 172 return;
137 glDeleteBuffers(1, &handle); 173 glDeleteBuffers(1, &handle);
138 OpenGLState::ResetBuffer(handle); 174 OpenGLState::GetCurState().ResetBuffer(handle).Apply();
139 handle = 0; 175 handle = 0;
140 } 176 }
141 177
142 GLuint handle = 0; 178 GLuint handle = 0;
143}; 179};
144 180
181class OGLSync : private NonCopyable {
182public:
183 OGLSync() = default;
184
185 OGLSync(OGLSync&& o) : handle(std::exchange(o.handle, nullptr)) {}
186
187 ~OGLSync() {
188 Release();
189 }
190 OGLSync& operator=(OGLSync&& o) {
191 Release();
192 handle = std::exchange(o.handle, nullptr);
193 return *this;
194 }
195
196 /// Creates a new internal OpenGL resource and stores the handle
197 void Create() {
198 if (handle != 0)
199 return;
200 handle = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
201 }
202
203 /// Deletes the internal OpenGL resource
204 void Release() {
205 if (handle == 0)
206 return;
207 glDeleteSync(handle);
208 handle = 0;
209 }
210
211 GLsync handle = 0;
212};
213
145class OGLVertexArray : private NonCopyable { 214class OGLVertexArray : private NonCopyable {
146public: 215public:
147 OGLVertexArray() = default; 216 OGLVertexArray() = default;
@@ -168,7 +237,7 @@ public:
168 if (handle == 0) 237 if (handle == 0)
169 return; 238 return;
170 glDeleteVertexArrays(1, &handle); 239 glDeleteVertexArrays(1, &handle);
171 OpenGLState::ResetVertexArray(handle); 240 OpenGLState::GetCurState().ResetVertexArray(handle).Apply();
172 handle = 0; 241 handle = 0;
173 } 242 }
174 243
@@ -201,7 +270,7 @@ public:
201 if (handle == 0) 270 if (handle == 0)
202 return; 271 return;
203 glDeleteFramebuffers(1, &handle); 272 glDeleteFramebuffers(1, &handle);
204 OpenGLState::ResetFramebuffer(handle); 273 OpenGLState::GetCurState().ResetFramebuffer(handle).Apply();
205 handle = 0; 274 handle = 0;
206 } 275 }
207 276