summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2018-03-27 04:49:05 +0200
committerJames Rowe <jroweboy@gmail.com>2018-04-07 04:44:45 +0200
commit65ea52394b7b9d8356ee5e9b0e1fce62ce99712f (patch)
tree04631ff4ea6a6a0ad7919c697d53428bc3c2aa91
parentGL: Remove remaining references to 3DS-specific pixel formats (diff)
downloadyuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar
yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar.gz
yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar.bz2
yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar.lz
yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar.xz
yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar.zst
yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.zip
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index fe9c76917..942b12d70 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -134,8 +134,11 @@ static void AllocateSurfaceTexture(GLuint texture, const FormatTuple& format_tup
cur_state.Apply();
glActiveTexture(GL_TEXTURE0);
- glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0,
- format_tuple.format, format_tuple.type, nullptr);
+ if (!format_tuple.compressed) {
+ // Only pre-create the texture for non-compressed textures.
+ glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0,
+ format_tuple.format, format_tuple.type, nullptr);
+ }
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
@@ -565,9 +568,18 @@ void CachedSurface::UploadGLTexture(const MathUtil::Rectangle<u32>& rect, GLuint
glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(stride));
glActiveTexture(GL_TEXTURE0);
- glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()),
- static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type,
- &gl_buffer[buffer_offset]);
+ if (tuple.compressed) {
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, tuple.internal_format,
+ static_cast<GLsizei>(rect.GetWidth()),
+ static_cast<GLsizei>(rect.GetHeight()), 0,
+ rect.GetWidth() * rect.GetHeight() *
+ GetGLBytesPerPixel(pixel_format) / tuple.compression_factor,
+ &gl_buffer[buffer_offset]);
+ } else {
+ glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()),
+ static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type,
+ &gl_buffer[buffer_offset]);
+ }
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);