diff options
author | bunnei <bunneidev@gmail.com> | 2018-08-10 02:17:48 +0200 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2018-08-10 02:36:03 +0200 |
commit | 3a67876252d616e1221e1a83b2dbe387993ad124 (patch) | |
tree | 4bfd261505903e92c470468165db0c63858bbae8 /src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |
parent | Merge pull request #995 from bunnei/gl-buff-bounds (diff) | |
download | yuzu-3a67876252d616e1221e1a83b2dbe387993ad124.tar yuzu-3a67876252d616e1221e1a83b2dbe387993ad124.tar.gz yuzu-3a67876252d616e1221e1a83b2dbe387993ad124.tar.bz2 yuzu-3a67876252d616e1221e1a83b2dbe387993ad124.tar.lz yuzu-3a67876252d616e1221e1a83b2dbe387993ad124.tar.xz yuzu-3a67876252d616e1221e1a83b2dbe387993ad124.tar.zst yuzu-3a67876252d616e1221e1a83b2dbe387993ad124.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer_cache.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 114d35ce6..885403cd0 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -183,6 +183,21 @@ MathUtil::Rectangle<u32> SurfaceParams::GetRect() const { return {0, actual_height, width, 0}; } +/// Returns true if the specified PixelFormat is a BCn format, e.g. DXT or DXN +static bool IsFormatBCn(PixelFormat format) { + switch (format) { + case PixelFormat::DXT1: + case PixelFormat::DXT23: + case PixelFormat::DXT45: + case PixelFormat::DXN1: + case PixelFormat::DXN2SNORM: + case PixelFormat::DXN2UNORM: + case PixelFormat::BC7U: + return true; + } + return false; +} + template <bool morton_to_gl, PixelFormat format> void MortonCopy(u32 stride, u32 block_height, u32 height, std::vector<u8>& gl_buffer, Tegra::GPUVAddr addr) { @@ -191,16 +206,12 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, std::vector<u8>& gl_bu const auto& gpu = Core::System::GetInstance().GPU(); if (morton_to_gl) { - std::vector<u8> data; - if (SurfaceParams::GetFormatType(format) == SurfaceType::ColorTexture) { - data = Tegra::Texture::UnswizzleTexture( - *gpu.memory_manager->GpuToCpuAddress(addr), - SurfaceParams::TextureFormatFromPixelFormat(format), stride, height, block_height); - } else { - data = Tegra::Texture::UnswizzleDepthTexture( - *gpu.memory_manager->GpuToCpuAddress(addr), - SurfaceParams::DepthFormatFromPixelFormat(format), stride, height, block_height); - } + // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual + // pixel values. + const u32 tile_size{IsFormatBCn(format) ? 4U : 1U}; + const std::vector<u8> data = + Tegra::Texture::UnswizzleTexture(*gpu.memory_manager->GpuToCpuAddress(addr), tile_size, + bytes_per_pixel, stride, height, block_height); const size_t size_to_copy{std::min(gl_buffer.size(), data.size())}; gl_buffer.assign(data.begin(), data.begin() + size_to_copy); } else { |