summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp16
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp21
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h2
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp13
-rw-r--r--src/video_core/renderer_opengl/gl_state.h3
5 files changed, 8 insertions, 47 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index ba65db419..cc7e782a4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -189,10 +189,6 @@ void RasterizerOpenGL::DrawTriangles() {
189 GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 189 GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
190 (has_stencil && depth_surface != nullptr) ? depth_surface->texture.handle : 0, 0); 190 (has_stencil && depth_surface != nullptr) ? depth_surface->texture.handle : 0, 0);
191 191
192 if (OpenGLState::CheckFBStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
193 return;
194 }
195
196 // Sync the viewport 192 // Sync the viewport
197 // These registers hold half-width and half-height, so must be multiplied by 2 193 // These registers hold half-width and half-height, so must be multiplied by 2
198 GLsizei viewport_width = (GLsizei)Pica::float24::FromRaw(regs.viewport_size_x).ToFloat32() * 2; 194 GLsizei viewport_width = (GLsizei)Pica::float24::FromRaw(regs.viewport_size_x).ToFloat32() * 2;
@@ -807,10 +803,6 @@ bool RasterizerOpenGL::AccelerateFill(const GPU::Regs::MemoryFillConfig& config)
807 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 803 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0,
808 0); 804 0);
809 805
810 if (OpenGLState::CheckFBStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
811 return false;
812 }
813
814 GLfloat color_values[4] = {0.0f, 0.0f, 0.0f, 0.0f}; 806 GLfloat color_values[4] = {0.0f, 0.0f, 0.0f, 0.0f};
815 807
816 // TODO: Handle additional pixel format and fill value size combinations to accelerate more 808 // TODO: Handle additional pixel format and fill value size combinations to accelerate more
@@ -895,10 +887,6 @@ bool RasterizerOpenGL::AccelerateFill(const GPU::Regs::MemoryFillConfig& config)
895 dst_surface->texture.handle, 0); 887 dst_surface->texture.handle, 0);
896 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); 888 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
897 889
898 if (OpenGLState::CheckFBStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
899 return false;
900 }
901
902 GLfloat value_float; 890 GLfloat value_float;
903 if (dst_surface->pixel_format == CachedSurface::PixelFormat::D16) { 891 if (dst_surface->pixel_format == CachedSurface::PixelFormat::D16) {
904 value_float = config.value_32bit / 65535.0f; // 2^16 - 1 892 value_float = config.value_32bit / 65535.0f; // 2^16 - 1
@@ -914,10 +902,6 @@ bool RasterizerOpenGL::AccelerateFill(const GPU::Regs::MemoryFillConfig& config)
914 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 902 glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
915 dst_surface->texture.handle, 0); 903 dst_surface->texture.handle, 0);
916 904
917 if (OpenGLState::CheckFBStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
918 return false;
919 }
920
921 GLfloat value_float = (config.value_32bit & 0xFFFFFF) / 16777215.0f; // 2^24 - 1 905 GLfloat value_float = (config.value_32bit & 0xFFFFFF) / 16777215.0f; // 2^24 - 1
922 GLint value_int = (config.value_32bit >> 24); 906 GLint value_int = (config.value_32bit >> 24);
923 907
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 61f6e767f..0b2e48407 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -103,7 +103,7 @@ static void MortonCopyPixels(CachedSurface::PixelFormat pixel_format, u32 width,
103 } 103 }
104} 104}
105 105
106bool RasterizerCacheOpenGL::BlitTextures(GLuint src_tex, GLuint dst_tex, 106void RasterizerCacheOpenGL::BlitTextures(GLuint src_tex, GLuint dst_tex,
107 CachedSurface::SurfaceType type, 107 CachedSurface::SurfaceType type,
108 const MathUtil::Rectangle<int>& src_rect, 108 const MathUtil::Rectangle<int>& src_rect,
109 const MathUtil::Rectangle<int>& dst_rect) { 109 const MathUtil::Rectangle<int>& dst_rect) {
@@ -158,21 +158,14 @@ bool RasterizerCacheOpenGL::BlitTextures(GLuint src_tex, GLuint dst_tex,
158 buffers = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; 158 buffers = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
159 } 159 }
160 160
161 bool can_blit = OpenGLState::CheckFBStatus(GL_READ_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE && 161 glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom, dst_rect.left,
162 OpenGLState::CheckFBStatus(GL_DRAW_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE; 162 dst_rect.top, dst_rect.right, dst_rect.bottom, buffers,
163 163 buffers == GL_COLOR_BUFFER_BIT ? GL_LINEAR : GL_NEAREST);
164 if (can_blit) {
165 glBlitFramebuffer(src_rect.left, src_rect.top, src_rect.right, src_rect.bottom,
166 dst_rect.left, dst_rect.top, dst_rect.right, dst_rect.bottom, buffers,
167 buffers == GL_COLOR_BUFFER_BIT ? GL_LINEAR : GL_NEAREST);
168 }
169 164
170 // Restore previous framebuffer bindings 165 // Restore previous framebuffer bindings
171 cur_state.draw.read_framebuffer = old_fbs[0]; 166 cur_state.draw.read_framebuffer = old_fbs[0];
172 cur_state.draw.draw_framebuffer = old_fbs[1]; 167 cur_state.draw.draw_framebuffer = old_fbs[1];
173 cur_state.Apply(); 168 cur_state.Apply();
174
175 return can_blit;
176} 169}
177 170
178bool RasterizerCacheOpenGL::TryBlitSurfaces(CachedSurface* src_surface, 171bool RasterizerCacheOpenGL::TryBlitSurfaces(CachedSurface* src_surface,
@@ -186,9 +179,9 @@ bool RasterizerCacheOpenGL::TryBlitSurfaces(CachedSurface* src_surface,
186 return false; 179 return false;
187 } 180 }
188 181
189 return BlitTextures(src_surface->texture.handle, dst_surface->texture.handle, 182 BlitTextures(src_surface->texture.handle, dst_surface->texture.handle,
190 CachedSurface::GetFormatType(src_surface->pixel_format), src_rect, 183 CachedSurface::GetFormatType(src_surface->pixel_format), src_rect, dst_rect);
191 dst_rect); 184 return true;
192} 185}
193 186
194static void AllocateSurfaceTexture(GLuint texture, CachedSurface::PixelFormat pixel_format, 187static void AllocateSurfaceTexture(GLuint texture, CachedSurface::PixelFormat pixel_format,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 32abfbaf5..b50e8292b 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -187,7 +187,7 @@ public:
187 ~RasterizerCacheOpenGL(); 187 ~RasterizerCacheOpenGL();
188 188
189 /// Blits one texture to another 189 /// Blits one texture to another
190 bool BlitTextures(GLuint src_tex, GLuint dst_tex, CachedSurface::SurfaceType type, 190 void BlitTextures(GLuint src_tex, GLuint dst_tex, CachedSurface::SurfaceType type,
191 const MathUtil::Rectangle<int>& src_rect, 191 const MathUtil::Rectangle<int>& src_rect,
192 const MathUtil::Rectangle<int>& dst_rect); 192 const MathUtil::Rectangle<int>& dst_rect);
193 193
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index 2a731f483..3c03b424a 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -232,19 +232,6 @@ void OpenGLState::Apply() const {
232 cur_state = *this; 232 cur_state = *this;
233} 233}
234 234
235GLenum OpenGLState::CheckFBStatus(GLenum target) {
236 GLenum fb_status = glCheckFramebufferStatus(target);
237 if (fb_status != GL_FRAMEBUFFER_COMPLETE) {
238 const char* fb_description =
239 (target == GL_READ_FRAMEBUFFER ? "READ"
240 : (target == GL_DRAW_FRAMEBUFFER ? "DRAW" : "UNK"));
241 LOG_CRITICAL(Render_OpenGL, "OpenGL %s framebuffer check failed, status %X", fb_description,
242 fb_status);
243 }
244
245 return fb_status;
246}
247
248void OpenGLState::ResetTexture(GLuint handle) { 235void OpenGLState::ResetTexture(GLuint handle) {
249 for (auto& unit : cur_state.texture_units) { 236 for (auto& unit : cur_state.texture_units) {
250 if (unit.texture_2d == handle) { 237 if (unit.texture_2d == handle) {
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index 01dead883..aee3c2946 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -90,9 +90,6 @@ public:
90 /// Apply this state as the current OpenGL state 90 /// Apply this state as the current OpenGL state
91 void Apply() const; 91 void Apply() const;
92 92
93 /// Check the status of the current OpenGL read or draw framebuffer configuration
94 static GLenum CheckFBStatus(GLenum target);
95
96 /// Resets and unbinds any references to the given resource in the current OpenGL state 93 /// Resets and unbinds any references to the given resource in the current OpenGL state
97 static void ResetTexture(GLuint handle); 94 static void ResetTexture(GLuint handle);
98 static void ResetSampler(GLuint handle); 95 static void ResetSampler(GLuint handle);