summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_resource_manager.cpp18
-rw-r--r--src/video_core/renderer_opengl/gl_resource_manager.h25
2 files changed, 43 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/gl_resource_manager.cpp b/src/video_core/renderer_opengl/gl_resource_manager.cpp
index bfe666a73..9f81c15cb 100644
--- a/src/video_core/renderer_opengl/gl_resource_manager.cpp
+++ b/src/video_core/renderer_opengl/gl_resource_manager.cpp
@@ -33,6 +33,24 @@ void OGLTexture::Release() {
33 handle = 0; 33 handle = 0;
34} 34}
35 35
36void OGLTextureView::Create() {
37 if (handle != 0)
38 return;
39
40 MICROPROFILE_SCOPE(OpenGL_ResourceCreation);
41 glGenTextures(1, &handle);
42}
43
44void OGLTextureView::Release() {
45 if (handle == 0)
46 return;
47
48 MICROPROFILE_SCOPE(OpenGL_ResourceDeletion);
49 glDeleteTextures(1, &handle);
50 OpenGLState::GetCurState().UnbindTexture(handle).Apply();
51 handle = 0;
52}
53
36void OGLSampler::Create() { 54void OGLSampler::Create() {
37 if (handle != 0) 55 if (handle != 0)
38 return; 56 return;
diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h
index fbb93ee49..310ee2bf3 100644
--- a/src/video_core/renderer_opengl/gl_resource_manager.h
+++ b/src/video_core/renderer_opengl/gl_resource_manager.h
@@ -36,6 +36,31 @@ public:
36 GLuint handle = 0; 36 GLuint handle = 0;
37}; 37};
38 38
39class OGLTextureView : private NonCopyable {
40public:
41 OGLTextureView() = default;
42
43 OGLTextureView(OGLTextureView&& o) noexcept : handle(std::exchange(o.handle, 0)) {}
44
45 ~OGLTextureView() {
46 Release();
47 }
48
49 OGLTextureView& operator=(OGLTextureView&& o) noexcept {
50 Release();
51 handle = std::exchange(o.handle, 0);
52 return *this;
53 }
54
55 /// Creates a new internal OpenGL resource and stores the handle
56 void Create();
57
58 /// Deletes the internal OpenGL resource
59 void Release();
60
61 GLuint handle = 0;
62};
63
39class OGLSampler : private NonCopyable { 64class OGLSampler : private NonCopyable {
40public: 65public:
41 OGLSampler() = default; 66 OGLSampler() = default;