summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-06-27 04:05:49 +0200
committerGitHub <noreply@github.com>2018-06-27 04:05:49 +0200
commitdfac394e60d9ae07348b18c88fff7892e4172318 (patch)
tree29d6255ff5d8418c0b7288d37e76ac2f6f2c7328 /src
parentMerge pull request #592 from bunnei/cleanup-gl-state (diff)
parentgl_state: Fix state management for texture swizzle. (diff)
downloadyuzu-dfac394e60d9ae07348b18c88fff7892e4172318.tar
yuzu-dfac394e60d9ae07348b18c88fff7892e4172318.tar.gz
yuzu-dfac394e60d9ae07348b18c88fff7892e4172318.tar.bz2
yuzu-dfac394e60d9ae07348b18c88fff7892e4172318.tar.lz
yuzu-dfac394e60d9ae07348b18c88fff7892e4172318.tar.xz
yuzu-dfac394e60d9ae07348b18c88fff7892e4172318.tar.zst
yuzu-dfac394e60d9ae07348b18c88fff7892e4172318.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp2
-rw-r--r--src/video_core/renderer_opengl/gl_resource_manager.h2
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp11
-rw-r--r--src/video_core/renderer_opengl/gl_state.h15
5 files changed, 20 insertions, 12 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 0f6dec60b..aadf7e233 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -437,7 +437,7 @@ void RasterizerOpenGL::DrawArrays() {
// Unbind textures for potential future use as framebuffer attachments
for (auto& texture_unit : state.texture_units) {
- texture_unit.texture_2d = 0;
+ texture_unit.Unbind();
}
state.Apply();
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 8e74c9412..857164ff6 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -645,7 +645,7 @@ void CachedSurface::DownloadGLTexture(const MathUtil::Rectangle<u32>& rect, GLui
glActiveTexture(GL_TEXTURE0);
glGetTexImage(GL_TEXTURE_2D, 0, tuple.format, tuple.type, &gl_buffer[buffer_offset]);
} else {
- state.ResetTexture(texture.handle);
+ state.UnbindTexture(texture.handle);
state.draw.read_framebuffer = read_fb_handle;
state.Apply();
diff --git a/src/video_core/renderer_opengl/gl_resource_manager.h b/src/video_core/renderer_opengl/gl_resource_manager.h
index 93f9172e7..0fed93ca5 100644
--- a/src/video_core/renderer_opengl/gl_resource_manager.h
+++ b/src/video_core/renderer_opengl/gl_resource_manager.h
@@ -38,7 +38,7 @@ public:
if (handle == 0)
return;
glDeleteTextures(1, &handle);
- OpenGLState::GetCurState().ResetTexture(handle).Apply();
+ OpenGLState::GetCurState().UnbindTexture(handle).Apply();
handle = 0;
}
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index dd5e8de26..2e8a422a8 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -48,12 +48,7 @@ OpenGLState::OpenGLState() {
logic_op = GL_COPY;
for (auto& texture_unit : texture_units) {
- texture_unit.texture_2d = 0;
- texture_unit.sampler = 0;
- texture_unit.swizzle.r = GL_RED;
- texture_unit.swizzle.g = GL_GREEN;
- texture_unit.swizzle.b = GL_BLUE;
- texture_unit.swizzle.a = GL_ALPHA;
+ texture_unit.Reset();
}
draw.read_framebuffer = 0;
@@ -286,10 +281,10 @@ void OpenGLState::Apply() const {
cur_state = *this;
}
-OpenGLState& OpenGLState::ResetTexture(GLuint handle) {
+OpenGLState& OpenGLState::UnbindTexture(GLuint handle) {
for (auto& unit : texture_units) {
if (unit.texture_2d == handle) {
- unit.texture_2d = 0;
+ unit.Unbind();
}
}
return *this;
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index 844144215..3398d7c04 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -91,6 +91,19 @@ public:
GLint b; // GL_TEXTURE_SWIZZLE_B
GLint a; // GL_TEXTURE_SWIZZLE_A
} swizzle;
+
+ void Unbind() {
+ texture_2d = 0;
+ swizzle.r = GL_RED;
+ swizzle.g = GL_GREEN;
+ swizzle.b = GL_BLUE;
+ swizzle.a = GL_ALPHA;
+ }
+
+ void Reset() {
+ Unbind();
+ sampler = 0;
+ }
} texture_units[32];
struct {
@@ -137,7 +150,7 @@ public:
void Apply() const;
/// Resets any references to the given resource
- OpenGLState& ResetTexture(GLuint handle);
+ OpenGLState& UnbindTexture(GLuint handle);
OpenGLState& ResetSampler(GLuint handle);
OpenGLState& ResetProgram(GLuint handle);
OpenGLState& ResetPipeline(GLuint handle);