summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar tfarley2015-05-29 20:53:50 -0400
committerGravatar tfarley2015-06-08 19:18:19 -0400
commit5025b35563873091eb3638bdae6b3380b3c1e290 (patch)
tree0da8a845c1a612c718b1e09cdec37cd17c8fbfbf /src
parentDepth format fix (crush3d intro/black screens) (diff)
downloadyuzu-5025b35563873091eb3638bdae6b3380b3c1e290.tar.gz
yuzu-5025b35563873091eb3638bdae6b3380b3c1e290.tar.xz
yuzu-5025b35563873091eb3638bdae6b3380b3c1e290.zip
Liberal texture unbind (clout menu)
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp38
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp6
2 files changed, 40 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 6779d17cf..3396d72cc 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -94,14 +94,27 @@ void RasterizerOpenGL::InitObjects() {
94 // Create textures for OGL framebuffer that will be rendered to, initially 1x1 to succeed in framebuffer creation 94 // Create textures for OGL framebuffer that will be rendered to, initially 1x1 to succeed in framebuffer creation
95 fb_color_texture.texture.Create(); 95 fb_color_texture.texture.Create();
96 ReconfigureColorTexture(fb_color_texture, Pica::Regs::ColorFormat::RGBA8, 1, 1); 96 ReconfigureColorTexture(fb_color_texture, Pica::Regs::ColorFormat::RGBA8, 1, 1);
97
98 state.texture_units[0].enabled_2d = true;
99 state.texture_units[0].texture_2d = fb_color_texture.texture.handle;
100 state.Apply();
101
97 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); 102 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
98 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 103 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
99 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 104 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
100 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 105 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
101 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 106 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
102 107
108 state.texture_units[0].texture_2d = 0;
109 state.Apply();
110
103 fb_depth_texture.texture.Create(); 111 fb_depth_texture.texture.Create();
104 ReconfigureDepthTexture(fb_depth_texture, Pica::Regs::DepthFormat::D16, 1, 1); 112 ReconfigureDepthTexture(fb_depth_texture, Pica::Regs::DepthFormat::D16, 1, 1);
113
114 state.texture_units[0].enabled_2d = true;
115 state.texture_units[0].texture_2d = fb_depth_texture.texture.handle;
116 state.Apply();
117
105 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); 118 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
106 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 119 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
107 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 120 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
@@ -110,14 +123,13 @@ void RasterizerOpenGL::InitObjects() {
110 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); 123 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
111 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE); 124 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
112 125
126 state.texture_units[0].texture_2d = 0;
127 state.Apply();
128
113 // Configure OpenGL framebuffer 129 // Configure OpenGL framebuffer
114 framebuffer.Create(); 130 framebuffer.Create();
115 131
116 state.draw.framebuffer = framebuffer.handle; 132 state.draw.framebuffer = framebuffer.handle;
117
118 // Unbind texture to allow binding to framebuffer
119 state.texture_units[0].enabled_2d = true;
120 state.texture_units[0].texture_2d = 0;
121 state.Apply(); 133 state.Apply();
122 134
123 glActiveTexture(GL_TEXTURE0); 135 glActiveTexture(GL_TEXTURE0);
@@ -472,6 +484,9 @@ void RasterizerOpenGL::ReconfigureColorTexture(TextureInfo& texture, Pica::Regs:
472 glActiveTexture(GL_TEXTURE0); 484 glActiveTexture(GL_TEXTURE0);
473 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, texture.width, texture.height, 0, 485 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, texture.width, texture.height, 0,
474 texture.gl_format, texture.gl_type, nullptr); 486 texture.gl_format, texture.gl_type, nullptr);
487
488 state.texture_units[0].texture_2d = 0;
489 state.Apply();
475} 490}
476 491
477void RasterizerOpenGL::ReconfigureDepthTexture(DepthTextureInfo& texture, Pica::Regs::DepthFormat format, u32 width, u32 height) { 492void RasterizerOpenGL::ReconfigureDepthTexture(DepthTextureInfo& texture, Pica::Regs::DepthFormat format, u32 width, u32 height) {
@@ -513,6 +528,9 @@ void RasterizerOpenGL::ReconfigureDepthTexture(DepthTextureInfo& texture, Pica::
513 glActiveTexture(GL_TEXTURE0); 528 glActiveTexture(GL_TEXTURE0);
514 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, texture.width, texture.height, 0, 529 glTexImage2D(GL_TEXTURE_2D, 0, internal_format, texture.width, texture.height, 0,
515 texture.gl_format, texture.gl_type, nullptr); 530 texture.gl_format, texture.gl_type, nullptr);
531
532 state.texture_units[0].texture_2d = 0;
533 state.Apply();
516} 534}
517 535
518void RasterizerOpenGL::SyncFramebuffer() { 536void RasterizerOpenGL::SyncFramebuffer() {
@@ -777,6 +795,9 @@ void RasterizerOpenGL::ReloadColorBuffer() {
777 glActiveTexture(GL_TEXTURE0); 795 glActiveTexture(GL_TEXTURE0);
778 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, fb_color_texture.width, fb_color_texture.height, 796 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, fb_color_texture.width, fb_color_texture.height,
779 fb_color_texture.gl_format, fb_color_texture.gl_type, temp_fb_color_buffer.get()); 797 fb_color_texture.gl_format, fb_color_texture.gl_type, temp_fb_color_buffer.get());
798
799 state.texture_units[0].texture_2d = 0;
800 state.Apply();
780} 801}
781 802
782void RasterizerOpenGL::ReloadDepthBuffer() { 803void RasterizerOpenGL::ReloadDepthBuffer() {
@@ -828,6 +849,9 @@ void RasterizerOpenGL::ReloadDepthBuffer() {
828 glActiveTexture(GL_TEXTURE0); 849 glActiveTexture(GL_TEXTURE0);
829 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, fb_depth_texture.width, fb_depth_texture.height, 850 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, fb_depth_texture.width, fb_depth_texture.height,
830 fb_depth_texture.gl_format, fb_depth_texture.gl_type, temp_fb_depth_buffer.get()); 851 fb_depth_texture.gl_format, fb_depth_texture.gl_type, temp_fb_depth_buffer.get());
852
853 state.texture_units[0].texture_2d = 0;
854 state.Apply();
831} 855}
832 856
833void RasterizerOpenGL::CommitColorBuffer() { 857void RasterizerOpenGL::CommitColorBuffer() {
@@ -846,6 +870,9 @@ void RasterizerOpenGL::CommitColorBuffer() {
846 glActiveTexture(GL_TEXTURE0); 870 glActiveTexture(GL_TEXTURE0);
847 glGetTexImage(GL_TEXTURE_2D, 0, fb_color_texture.gl_format, fb_color_texture.gl_type, temp_gl_color_buffer.get()); 871 glGetTexImage(GL_TEXTURE_2D, 0, fb_color_texture.gl_format, fb_color_texture.gl_type, temp_gl_color_buffer.get());
848 872
873 state.texture_units[0].texture_2d = 0;
874 state.Apply();
875
849 // Directly copy pixels. Internal OpenGL color formats are consistent so no conversion is necessary. 876 // Directly copy pixels. Internal OpenGL color formats are consistent so no conversion is necessary.
850 for (int y = 0; y < fb_color_texture.height; ++y) { 877 for (int y = 0; y < fb_color_texture.height; ++y) {
851 for (int x = 0; x < fb_color_texture.width; ++x) { 878 for (int x = 0; x < fb_color_texture.width; ++x) {
@@ -881,6 +908,9 @@ void RasterizerOpenGL::CommitDepthBuffer() {
881 glActiveTexture(GL_TEXTURE0); 908 glActiveTexture(GL_TEXTURE0);
882 glGetTexImage(GL_TEXTURE_2D, 0, fb_depth_texture.gl_format, fb_depth_texture.gl_type, temp_gl_depth_buffer.get()); 909 glGetTexImage(GL_TEXTURE_2D, 0, fb_depth_texture.gl_format, fb_depth_texture.gl_type, temp_gl_depth_buffer.get());
883 910
911 state.texture_units[0].texture_2d = 0;
912 state.Apply();
913
884 u8* temp_gl_depth_data = bytes_per_pixel == 3 ? (temp_gl_depth_buffer.get() + 1) : temp_gl_depth_buffer.get(); 914 u8* temp_gl_depth_data = bytes_per_pixel == 3 ? (temp_gl_depth_buffer.get() + 1) : temp_gl_depth_buffer.get();
885 915
886 if (fb_depth_texture.format == Pica::Regs::DepthFormat::D24S8) { 916 if (fb_depth_texture.format == Pica::Regs::DepthFormat::D24S8) {
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 382aeaa05..058ad12cd 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -170,6 +170,9 @@ void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig&
170 texture.gl_format, texture.gl_type, framebuffer_data); 170 texture.gl_format, texture.gl_type, framebuffer_data);
171 171
172 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 172 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
173
174 state.texture_units[0].texture_2d = 0;
175 state.Apply();
173} 176}
174 177
175/** 178/**
@@ -239,6 +242,9 @@ void RendererOpenGL::InitOpenGLObjects() {
239 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 242 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
240 } 243 }
241 244
245 state.texture_units[0].texture_2d = 0;
246 state.Apply();
247
242 hw_rasterizer->InitObjects(); 248 hw_rasterizer->InitObjects();
243} 249}
244 250