summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-03-19 22:20:49 +0100
committerbunnei <bunneidev@gmail.com>2018-03-20 04:14:02 +0100
commitdb0cfb8e8bac705a2dfa6780b2799905cce16d38 (patch)
tree1dcda4af288eabf5e31ab66ea1572a0d4edf3834 /src
parentrenderer_gl: Port over gl_stream_buffer module from Citra. (diff)
downloadyuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar.gz
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar.bz2
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar.lz
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar.xz
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.tar.zst
yuzu-db0cfb8e8bac705a2dfa6780b2799905cce16d38.zip
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:
if (handle == 0)
return;
glDeleteTextures(1, &handle);
- OpenGLState::ResetTexture(handle);
+ OpenGLState::GetCurState().ResetTexture(handle).Apply();
handle = 0;
}
@@ -69,7 +69,7 @@ public:
if (handle == 0)
return;
glDeleteSamplers(1, &handle);
- OpenGLState::ResetSampler(handle);
+ OpenGLState::GetCurState().ResetSampler(handle).Apply();
handle = 0;
}
@@ -91,10 +91,13 @@ public:
}
/// Creates a new internal OpenGL resource and stores the handle
- void Create(const char* vert_shader, const char* frag_shader) {
+ void Create(const char* vert_shader, const char* geo_shader, const char* frag_shader,
+ const std::vector<const char*>& feedback_vars = {},
+ bool separable_program = false) {
if (handle != 0)
return;
- handle = GLShader::LoadProgram(vert_shader, frag_shader);
+ handle = GLShader::LoadProgram(vert_shader, geo_shader, frag_shader, feedback_vars,
+ separable_program);
}
/// Deletes the internal OpenGL resource
@@ -102,7 +105,40 @@ public:
if (handle == 0)
return;
glDeleteProgram(handle);
- OpenGLState::ResetProgram(handle);
+ OpenGLState::GetCurState().ResetProgram(handle).Apply();
+ handle = 0;
+ }
+
+ GLuint handle = 0;
+};
+
+class OGLPipeline : private NonCopyable {
+public:
+ OGLPipeline() = default;
+ OGLPipeline(OGLPipeline&& o) {
+ handle = std::exchange<GLuint>(o.handle, 0);
+ }
+ ~OGLPipeline() {
+ Release();
+ }
+ OGLPipeline& operator=(OGLPipeline&& o) {
+ handle = std::exchange<GLuint>(o.handle, 0);
+ return *this;
+ }
+
+ /// Creates a new internal OpenGL resource and stores the handle
+ void Create() {
+ if (handle != 0)
+ return;
+ glGenProgramPipelines(1, &handle);
+ }
+
+ /// Deletes the internal OpenGL resource
+ void Release() {
+ if (handle == 0)
+ return;
+ glDeleteProgramPipelines(1, &handle);
+ OpenGLState::GetCurState().ResetPipeline(handle).Apply();
handle = 0;
}
@@ -135,13 +171,46 @@ public:
if (handle == 0)
return;
glDeleteBuffers(1, &handle);
- OpenGLState::ResetBuffer(handle);
+ OpenGLState::GetCurState().ResetBuffer(handle).Apply();
handle = 0;
}
GLuint handle = 0;
};
+class OGLSync : private NonCopyable {
+public:
+ OGLSync() = default;
+
+ OGLSync(OGLSync&& o) : handle(std::exchange(o.handle, nullptr)) {}
+
+ ~OGLSync() {
+ Release();
+ }
+ OGLSync& operator=(OGLSync&& o) {
+ Release();
+ handle = std::exchange(o.handle, nullptr);
+ return *this;
+ }
+
+ /// Creates a new internal OpenGL resource and stores the handle
+ void Create() {
+ if (handle != 0)
+ return;
+ handle = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
+ }
+
+ /// Deletes the internal OpenGL resource
+ void Release() {
+ if (handle == 0)
+ return;
+ glDeleteSync(handle);
+ handle = 0;
+ }
+
+ GLsync handle = 0;
+};
+
class OGLVertexArray : private NonCopyable {
public:
OGLVertexArray() = default;
@@ -168,7 +237,7 @@ public:
if (handle == 0)
return;
glDeleteVertexArrays(1, &handle);
- OpenGLState::ResetVertexArray(handle);
+ OpenGLState::GetCurState().ResetVertexArray(handle).Apply();
handle = 0;
}
@@ -201,7 +270,7 @@ public:
if (handle == 0)
return;
glDeleteFramebuffers(1, &handle);
- OpenGLState::ResetFramebuffer(handle);
+ OpenGLState::GetCurState().ResetFramebuffer(handle).Apply();
handle = 0;
}