From 5edf24b51025fef4d78e5f9d4038267e472b2f55 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 12 Jul 2019 02:00:04 -0300 Subject: [PATCH] gl_state: Add support for glBindImageTextures --- src/video_core/renderer_opengl/gl_state.cpp | 21 +++++++++++++++++++++ src/video_core/renderer_opengl/gl_state.h | 3 +++ 2 files changed, 24 insertions(+) diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index f4777d0b0..a38f88182 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -545,6 +545,26 @@ void OpenGLState::ApplySamplers() const { } } +void OpenGLState::ApplyImages() const { + bool has_delta{}; + std::size_t first{}; + std::size_t last{}; + for (std::size_t i = 0; i < std::size(images); ++i) { + if (!UpdateValue(cur_state.images[i], images[i])) { + continue; + } + if (!has_delta) { + first = i; + has_delta = true; + } + last = i; + } + if (has_delta) { + glBindImageTextures(static_cast(first), static_cast(last - first + 1), + images.data() + first); + } +} + void OpenGLState::Apply() { MICROPROFILE_SCOPE(OpenGL_State); ApplyFramebufferState(); @@ -576,6 +596,7 @@ void OpenGLState::Apply() { ApplyLogicOp(); ApplyTextures(); ApplySamplers(); + ApplyImages(); if (dirty.polygon_offset) { ApplyPolygonOffset(); dirty.polygon_offset = false; diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index fdf9a8a12..9748d60e2 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h @@ -134,6 +134,8 @@ public: }; std::array texture_units; + std::array images{}; + struct { GLuint read_framebuffer; // GL_READ_FRAMEBUFFER_BINDING GLuint draw_framebuffer; // GL_DRAW_FRAMEBUFFER_BINDING @@ -220,6 +222,7 @@ public: void ApplyLogicOp() const; void ApplyTextures() const; void ApplySamplers() const; + void ApplyImages() const; void ApplyDepthClamp() const; void ApplyPolygonOffset() const; void ApplyAlphaTest() const;