diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_resource_manager.cpp | 18 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_resource_manager.h | 25 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 15 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 4 |
4 files changed, 62 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 f0ddfb276..c0aee770f 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.cpp +++ b/src/video_core/renderer_opengl/gl_resource_manager.cpp | |||
| @@ -15,6 +15,24 @@ MICROPROFILE_DEFINE(OpenGL_ResourceDeletion, "OpenGL", "Resource Deletion", MP_R | |||
| 15 | 15 | ||
| 16 | namespace OpenGL { | 16 | namespace OpenGL { |
| 17 | 17 | ||
| 18 | void OGLRenderbuffer::Create() { | ||
| 19 | if (handle != 0) | ||
| 20 | return; | ||
| 21 | |||
| 22 | MICROPROFILE_SCOPE(OpenGL_ResourceCreation); | ||
| 23 | glGenRenderbuffers(1, &handle); | ||
| 24 | } | ||
| 25 | |||
| 26 | void OGLRenderbuffer::Release() { | ||
| 27 | if (handle == 0) | ||
| 28 | return; | ||
| 29 | |||
| 30 | MICROPROFILE_SCOPE(OpenGL_ResourceDeletion); | ||
| 31 | glDeleteRenderbuffers(1, &handle); | ||
| 32 | OpenGLState::GetCurState().ResetRenderbuffer(handle).Apply(); | ||
| 33 | handle = 0; | ||
| 34 | } | ||
| 35 | |||
| 18 | void OGLTexture::Create(GLenum target) { | 36 | void OGLTexture::Create(GLenum target) { |
| 19 | if (handle != 0) | 37 | if (handle != 0) |
| 20 | return; | 38 | return; |
diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h index 514d1d165..995a4e45e 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.h +++ b/src/video_core/renderer_opengl/gl_resource_manager.h | |||
| @@ -11,6 +11,31 @@ | |||
| 11 | 11 | ||
| 12 | namespace OpenGL { | 12 | namespace OpenGL { |
| 13 | 13 | ||
| 14 | class OGLRenderbuffer : private NonCopyable { | ||
| 15 | public: | ||
| 16 | OGLRenderbuffer() = default; | ||
| 17 | |||
| 18 | OGLRenderbuffer(OGLRenderbuffer&& o) noexcept : handle(std::exchange(o.handle, 0)) {} | ||
| 19 | |||
| 20 | ~OGLRenderbuffer() { | ||
| 21 | Release(); | ||
| 22 | } | ||
| 23 | |||
| 24 | OGLRenderbuffer& operator=(OGLRenderbuffer&& o) noexcept { | ||
| 25 | Release(); | ||
| 26 | handle = std::exchange(o.handle, 0); | ||
| 27 | return *this; | ||
| 28 | } | ||
| 29 | |||
| 30 | /// Creates a new internal OpenGL resource and stores the handle | ||
| 31 | void Create(); | ||
| 32 | |||
| 33 | /// Deletes the internal OpenGL resource | ||
| 34 | void Release(); | ||
| 35 | |||
| 36 | GLuint handle = 0; | ||
| 37 | }; | ||
| 38 | |||
| 14 | class OGLTexture : private NonCopyable { | 39 | class OGLTexture : private NonCopyable { |
| 15 | public: | 40 | public: |
| 16 | OGLTexture() = default; | 41 | OGLTexture() = default; |
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index ab1f7983c..7d3bc1a1f 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -423,6 +423,13 @@ void OpenGLState::ApplyClipControl() { | |||
| 423 | } | 423 | } |
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | void OpenGLState::ApplyRenderBuffer() { | ||
| 427 | if (cur_state.renderbuffer != renderbuffer) { | ||
| 428 | cur_state.renderbuffer = renderbuffer; | ||
| 429 | glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer); | ||
| 430 | } | ||
| 431 | } | ||
| 432 | |||
| 426 | void OpenGLState::ApplyTextures() { | 433 | void OpenGLState::ApplyTextures() { |
| 427 | const std::size_t size = std::size(textures); | 434 | const std::size_t size = std::size(textures); |
| 428 | for (std::size_t i = 0; i < size; ++i) { | 435 | for (std::size_t i = 0; i < size; ++i) { |
| @@ -478,6 +485,7 @@ void OpenGLState::Apply() { | |||
| 478 | ApplyPolygonOffset(); | 485 | ApplyPolygonOffset(); |
| 479 | ApplyAlphaTest(); | 486 | ApplyAlphaTest(); |
| 480 | ApplyClipControl(); | 487 | ApplyClipControl(); |
| 488 | ApplyRenderBuffer(); | ||
| 481 | } | 489 | } |
| 482 | 490 | ||
| 483 | void OpenGLState::EmulateViewportWithScissor() { | 491 | void OpenGLState::EmulateViewportWithScissor() { |
| @@ -551,4 +559,11 @@ OpenGLState& OpenGLState::ResetFramebuffer(GLuint handle) { | |||
| 551 | return *this; | 559 | return *this; |
| 552 | } | 560 | } |
| 553 | 561 | ||
| 562 | OpenGLState& OpenGLState::ResetRenderbuffer(GLuint handle) { | ||
| 563 | if (renderbuffer == handle) { | ||
| 564 | renderbuffer = 0; | ||
| 565 | } | ||
| 566 | return *this; | ||
| 567 | } | ||
| 568 | |||
| 554 | } // namespace OpenGL | 569 | } // namespace OpenGL |
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index 4953eeda2..bce662f2c 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -158,6 +158,8 @@ public: | |||
| 158 | GLenum depth_mode = GL_NEGATIVE_ONE_TO_ONE; | 158 | GLenum depth_mode = GL_NEGATIVE_ONE_TO_ONE; |
| 159 | } clip_control; | 159 | } clip_control; |
| 160 | 160 | ||
| 161 | GLuint renderbuffer{}; // GL_RENDERBUFFER_BINDING | ||
| 162 | |||
| 161 | OpenGLState(); | 163 | OpenGLState(); |
| 162 | 164 | ||
| 163 | /// Get the currently active OpenGL state | 165 | /// Get the currently active OpenGL state |
| @@ -196,6 +198,7 @@ public: | |||
| 196 | void ApplyPolygonOffset(); | 198 | void ApplyPolygonOffset(); |
| 197 | void ApplyAlphaTest(); | 199 | void ApplyAlphaTest(); |
| 198 | void ApplyClipControl(); | 200 | void ApplyClipControl(); |
| 201 | void ApplyRenderBuffer(); | ||
| 199 | 202 | ||
| 200 | /// Resets any references to the given resource | 203 | /// Resets any references to the given resource |
| 201 | OpenGLState& UnbindTexture(GLuint handle); | 204 | OpenGLState& UnbindTexture(GLuint handle); |
| @@ -204,6 +207,7 @@ public: | |||
| 204 | OpenGLState& ResetPipeline(GLuint handle); | 207 | OpenGLState& ResetPipeline(GLuint handle); |
| 205 | OpenGLState& ResetVertexArray(GLuint handle); | 208 | OpenGLState& ResetVertexArray(GLuint handle); |
| 206 | OpenGLState& ResetFramebuffer(GLuint handle); | 209 | OpenGLState& ResetFramebuffer(GLuint handle); |
| 210 | OpenGLState& ResetRenderbuffer(GLuint handle); | ||
| 207 | 211 | ||
| 208 | /// Viewport does not affects glClearBuffer so emulate viewport using scissor test | 212 | /// Viewport does not affects glClearBuffer so emulate viewport using scissor test |
| 209 | void EmulateViewportWithScissor(); | 213 | void EmulateViewportWithScissor(); |