diff options
| author | 2018-03-26 21:49:05 -0500 | |
|---|---|---|
| committer | 2018-04-06 20:44:45 -0600 | |
| commit | 65ea52394b7b9d8356ee5e9b0e1fce62ce99712f (patch) | |
| tree | 04631ff4ea6a6a0ad7919c697d53428bc3c2aa91 /src | |
| parent | GL: Remove remaining references to 3DS-specific pixel formats (diff) | |
| download | yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar.gz yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.tar.xz yuzu-65ea52394b7b9d8356ee5e9b0e1fce62ce99712f.zip | |
GLCache: Support uploading compressed textures to the GPU.
Compressed texture formats like DXT1, DXT2, DXT3, etc will use this to ease the load on the CPU.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 22 |
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 | |||
| 134 | cur_state.Apply(); | 134 | cur_state.Apply(); |
| 135 | glActiveTexture(GL_TEXTURE0); | 135 | glActiveTexture(GL_TEXTURE0); |
| 136 | 136 | ||
| 137 | glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0, | 137 | if (!format_tuple.compressed) { |
| 138 | format_tuple.format, format_tuple.type, nullptr); | 138 | // Only pre-create the texture for non-compressed textures. |
| 139 | glTexImage2D(GL_TEXTURE_2D, 0, format_tuple.internal_format, width, height, 0, | ||
| 140 | format_tuple.format, format_tuple.type, nullptr); | ||
| 141 | } | ||
| 139 | 142 | ||
| 140 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); | 143 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0); |
| 141 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 144 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| @@ -565,9 +568,18 @@ void CachedSurface::UploadGLTexture(const MathUtil::Rectangle<u32>& rect, GLuint | |||
| 565 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(stride)); | 568 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(stride)); |
| 566 | 569 | ||
| 567 | glActiveTexture(GL_TEXTURE0); | 570 | glActiveTexture(GL_TEXTURE0); |
| 568 | glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()), | 571 | if (tuple.compressed) { |
| 569 | static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type, | 572 | glCompressedTexImage2D(GL_TEXTURE_2D, 0, tuple.internal_format, |
| 570 | &gl_buffer[buffer_offset]); | 573 | static_cast<GLsizei>(rect.GetWidth()), |
| 574 | static_cast<GLsizei>(rect.GetHeight()), 0, | ||
| 575 | rect.GetWidth() * rect.GetHeight() * | ||
| 576 | GetGLBytesPerPixel(pixel_format) / tuple.compression_factor, | ||
| 577 | &gl_buffer[buffer_offset]); | ||
| 578 | } else { | ||
| 579 | glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast<GLsizei>(rect.GetWidth()), | ||
| 580 | static_cast<GLsizei>(rect.GetHeight()), tuple.format, tuple.type, | ||
| 581 | &gl_buffer[buffer_offset]); | ||
| 582 | } | ||
| 571 | 583 | ||
| 572 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); | 584 | glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); |
| 573 | 585 | ||