From bdab18d2d9bd7007f8846029fd14a868a229e9ab Mon Sep 17 00:00:00 2001
From: wwylele <wwylele@gmail.com>
Date: Tue, 10 Apr 2018 00:29:52 +0300
Subject: [PATCH] gl_resource_manager: add OGLPipeline

---
 .../renderer_opengl/gl_resource_manager.h     | 32 +++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h
index d57a0ff89..dcaa9a0f3 100644
--- a/src/video_core/renderer_opengl/gl_resource_manager.h
+++ b/src/video_core/renderer_opengl/gl_resource_manager.h
@@ -158,6 +158,38 @@ public:
     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) {
+        Release();
+        handle = std::exchange<GLuint>(o.handle, 0);
+        return *this;
+    }
+
+    void Create() {
+        if (handle != 0)
+            return;
+        glGenProgramPipelines(1, &handle);
+    }
+
+    void Release() {
+        if (handle == 0)
+            return;
+        glDeleteProgramPipelines(1, &handle);
+        OpenGLState::GetCurState().ResetPipeline(handle).Apply();
+        handle = 0;
+    }
+
+    GLuint handle = 0;
+};
+
 class OGLBuffer : private NonCopyable {
 public:
     OGLBuffer() = default;