summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp15
-rw-r--r--src/video_core/textures/decoders.cpp12
-rw-r--r--src/video_core/textures/decoders.h4
-rw-r--r--src/yuzu/debugger/graphics/graphics_surface.cpp2
4 files changed, 21 insertions, 12 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 43c47cb10..19b1d04b9 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -366,15 +366,18 @@ void MortonCopy(u32 stride, u32 block_height, u32 height, u32 block_depth, u32 d
366 366
367 // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual 367 // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual
368 // pixel values. 368 // pixel values.
369 const u32 tile_size{IsFormatBCn(format) ? 4U : 1U}; 369 const u32 tile_size_x{SurfaceParams::GetDefaultBlockWidth(format)};
370 const u32 tile_size_y{SurfaceParams::GetDefaultBlockHeight(format)};
370 371
371 if (morton_to_gl) { 372 if (morton_to_gl) {
372 const std::vector<u8> data = Tegra::Texture::UnswizzleTexture( 373 const std::vector<u8> data =
373 addr, tile_size, bytes_per_pixel, stride, height, depth, block_height, block_depth); 374 Tegra::Texture::UnswizzleTexture(addr, tile_size_x, tile_size_y, bytes_per_pixel,
375 stride, height, depth, block_height, block_depth);
374 const std::size_t size_to_copy{std::min(gl_buffer_size, data.size())}; 376 const std::size_t size_to_copy{std::min(gl_buffer_size, data.size())};
375 memcpy(gl_buffer, data.data(), size_to_copy); 377 memcpy(gl_buffer, data.data(), size_to_copy);
376 } else { 378 } else {
377 Tegra::Texture::CopySwizzledData(stride / tile_size, height / tile_size, depth, 379 Tegra::Texture::CopySwizzledData((stride + tile_size_x - 1) / tile_size_x,
380 (height + tile_size_y - 1) / tile_size_y, depth,
378 bytes_per_pixel, bytes_per_pixel, Memory::GetPointer(addr), 381 bytes_per_pixel, bytes_per_pixel, Memory::GetPointer(addr),
379 gl_buffer, false, block_height, block_depth); 382 gl_buffer, false, block_height, block_depth);
380 } 383 }
@@ -442,6 +445,8 @@ static constexpr GLConversionArray morton_to_gl_fns = {
442 MortonCopy<true, PixelFormat::ASTC_2D_8X8_SRGB>, 445 MortonCopy<true, PixelFormat::ASTC_2D_8X8_SRGB>,
443 MortonCopy<true, PixelFormat::ASTC_2D_8X5_SRGB>, 446 MortonCopy<true, PixelFormat::ASTC_2D_8X5_SRGB>,
444 MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>, 447 MortonCopy<true, PixelFormat::ASTC_2D_5X4_SRGB>,
448 MortonCopy<true, PixelFormat::ASTC_2D_5X5>,
449 MortonCopy<true, PixelFormat::ASTC_2D_5X5_SRGB>,
445 MortonCopy<true, PixelFormat::Z32F>, 450 MortonCopy<true, PixelFormat::Z32F>,
446 MortonCopy<true, PixelFormat::Z16>, 451 MortonCopy<true, PixelFormat::Z16>,
447 MortonCopy<true, PixelFormat::Z24S8>, 452 MortonCopy<true, PixelFormat::Z24S8>,
@@ -510,6 +515,8 @@ static constexpr GLConversionArray gl_to_morton_fns = {
510 nullptr, 515 nullptr,
511 nullptr, 516 nullptr,
512 nullptr, 517 nullptr,
518 nullptr,
519 nullptr,
513 MortonCopy<false, PixelFormat::Z32F>, 520 MortonCopy<false, PixelFormat::Z32F>,
514 MortonCopy<false, PixelFormat::Z16>, 521 MortonCopy<false, PixelFormat::Z16>,
515 MortonCopy<false, PixelFormat::Z24S8>, 522 MortonCopy<false, PixelFormat::Z24S8>,
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 550ca856c..3066abf61 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -227,12 +227,14 @@ u32 BytesPerPixel(TextureFormat format) {
227 } 227 }
228} 228}
229 229
230std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, 230std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y,
231 u32 height, u32 depth, u32 block_height, u32 block_depth) { 231 u32 bytes_per_pixel, u32 width, u32 height, u32 depth,
232 u32 block_height, u32 block_depth) {
232 std::vector<u8> unswizzled_data(width * height * depth * bytes_per_pixel); 233 std::vector<u8> unswizzled_data(width * height * depth * bytes_per_pixel);
233 CopySwizzledData(width / tile_size, height / tile_size, depth, bytes_per_pixel, bytes_per_pixel, 234 CopySwizzledData((width + tile_size_x - 1) / tile_size_x,
234 Memory::GetPointer(address), unswizzled_data.data(), true, block_height, 235 (height + tile_size_y - 1) / tile_size_y, depth, bytes_per_pixel,
235 block_depth); 236 bytes_per_pixel, Memory::GetPointer(address), unswizzled_data.data(), true,
237 block_height, block_depth);
236 return unswizzled_data; 238 return unswizzled_data;
237} 239}
238 240
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h
index b390219e4..ba065510b 100644
--- a/src/video_core/textures/decoders.h
+++ b/src/video_core/textures/decoders.h
@@ -19,8 +19,8 @@ inline std::size_t GetGOBSize() {
19/** 19/**
20 * Unswizzles a swizzled texture without changing its format. 20 * Unswizzles a swizzled texture without changing its format.
21 */ 21 */
22std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, 22std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size_x, u32 tile_size_y,
23 u32 height, u32 depth, 23 u32 bytes_per_pixel, u32 width, u32 height, u32 depth,
24 u32 block_height = TICEntry::DefaultBlockHeight, 24 u32 block_height = TICEntry::DefaultBlockHeight,
25 u32 block_depth = TICEntry::DefaultBlockHeight); 25 u32 block_depth = TICEntry::DefaultBlockHeight);
26 26
diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp
index 0adbab27d..b994a2789 100644
--- a/src/yuzu/debugger/graphics/graphics_surface.cpp
+++ b/src/yuzu/debugger/graphics/graphics_surface.cpp
@@ -387,7 +387,7 @@ void GraphicsSurfaceWidget::OnUpdate() {
387 // TODO(bunnei): Will not work with BCn formats that swizzle 4x4 tiles. 387 // TODO(bunnei): Will not work with BCn formats that swizzle 4x4 tiles.
388 // Needs to be fixed if we plan to use this feature more, otherwise we may remove it. 388 // Needs to be fixed if we plan to use this feature more, otherwise we may remove it.
389 auto unswizzled_data = 389 auto unswizzled_data =
390 Tegra::Texture::UnswizzleTexture(*address, 1, Tegra::Texture::BytesPerPixel(surface_format), 390 Tegra::Texture::UnswizzleTexture(*address, 1, 1, Tegra::Texture::BytesPerPixel(surface_format),
391 surface_width, surface_height, 1U); 391 surface_width, surface_height, 1U);
392 392
393 auto texture_data = Tegra::Texture::DecodeTexture(unswizzled_data, surface_format, 393 auto texture_data = Tegra::Texture::DecodeTexture(unswizzled_data, surface_format,