diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 7a3280620..5876145ef 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -661,8 +661,8 @@ void CachedSurface::FlushGLBuffer() { | |||
| 661 | gl_buffer[0].resize(GetSizeInBytes()); | 661 | gl_buffer[0].resize(GetSizeInBytes()); |
| 662 | 662 | ||
| 663 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); | 663 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); |
| 664 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT | 664 | const u32 align = std::clamp(params.RowAlign(0), 1U, 8U); |
| 665 | ASSERT(params.width * GetBytesPerPixel(params.pixel_format) % 4 == 0); | 665 | glPixelStorei(GL_PACK_ALIGNMENT, align); |
| 666 | glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); | 666 | glPixelStorei(GL_PACK_ROW_LENGTH, static_cast<GLint>(params.width)); |
| 667 | ASSERT(!tuple.compressed); | 667 | ASSERT(!tuple.compressed); |
| 668 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); | 668 | glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); |
| @@ -707,8 +707,8 @@ void CachedSurface::UploadGLMipmapTexture(u32 mip_map, GLuint read_fb_handle, | |||
| 707 | 707 | ||
| 708 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); | 708 | const FormatTuple& tuple = GetFormatTuple(params.pixel_format, params.component_type); |
| 709 | 709 | ||
| 710 | // Ensure no bad interactions with GL_UNPACK_ALIGNMENT | 710 | const u32 align = std::clamp(params.RowAlign(mip_map), 1U, 8U); |
| 711 | ASSERT(params.MipWidth(mip_map) * GetBytesPerPixel(params.pixel_format) % 4 == 0); | 711 | glPixelStorei(GL_UNPACK_ALIGNMENT, align); |
| 712 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(params.MipWidth(mip_map))); | 712 | glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(params.MipWidth(mip_map))); |
| 713 | 713 | ||
| 714 | const auto image_size = static_cast<GLsizei>(params.GetMipmapSizeGL(mip_map, false)); | 714 | const auto image_size = static_cast<GLsizei>(params.GetMipmapSizeGL(mip_map, false)); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index ad4fd3ad2..db280dbb3 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <vector> | 11 | #include <vector> |
| 12 | 12 | ||
| 13 | #include "common/alignment.h" | 13 | #include "common/alignment.h" |
| 14 | #include "common/bit_util.h" | ||
| 14 | #include "common/common_types.h" | 15 | #include "common/common_types.h" |
| 15 | #include "common/hash.h" | 16 | #include "common/hash.h" |
| 16 | #include "common/math_util.h" | 17 | #include "common/math_util.h" |
| @@ -205,6 +206,13 @@ struct SurfaceParams { | |||
| 205 | return bd; | 206 | return bd; |
| 206 | } | 207 | } |
| 207 | 208 | ||
| 209 | u32 RowAlign(u32 mip_level) const { | ||
| 210 | const u32 m_width = MipWidth(mip_level); | ||
| 211 | const u32 bytes_per_pixel = GetBytesPerPixel(pixel_format); | ||
| 212 | const u32 l2 = Common::CountTrailingZeroes32(m_width * bytes_per_pixel); | ||
| 213 | return (1U << l2); | ||
| 214 | } | ||
| 215 | |||
| 208 | /// Creates SurfaceParams from a texture configuration | 216 | /// Creates SurfaceParams from a texture configuration |
| 209 | static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config, | 217 | static SurfaceParams CreateForTexture(const Tegra::Texture::FullTextureInfo& config, |
| 210 | const GLShader::SamplerEntry& entry); | 218 | const GLShader::SamplerEntry& entry); |