diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/gpu.cpp | 32 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 7 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 11 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 72 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 140 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/maxwell_to_gl.h | 3 | ||||
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 85 | ||||
| -rw-r--r-- | src/video_core/textures/decoders.h | 4 | ||||
| -rw-r--r-- | src/yuzu/debugger/graphics/graphics_surface.cpp | 6 | ||||
| -rw-r--r-- | src/yuzu/game_list_p.h | 25 |
10 files changed, 154 insertions, 231 deletions
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 4ff4d71c5..b90937d17 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -34,19 +34,51 @@ u32 RenderTargetBytesPerPixel(RenderTargetFormat format) { | |||
| 34 | 34 | ||
| 35 | switch (format) { | 35 | switch (format) { |
| 36 | case RenderTargetFormat::RGBA32_FLOAT: | 36 | case RenderTargetFormat::RGBA32_FLOAT: |
| 37 | case RenderTargetFormat::RGBA32_UINT: | ||
| 37 | return 16; | 38 | return 16; |
| 38 | case RenderTargetFormat::RGBA16_FLOAT: | 39 | case RenderTargetFormat::RGBA16_FLOAT: |
| 39 | case RenderTargetFormat::RG32_FLOAT: | 40 | case RenderTargetFormat::RG32_FLOAT: |
| 40 | return 8; | 41 | return 8; |
| 41 | case RenderTargetFormat::RGBA8_UNORM: | 42 | case RenderTargetFormat::RGBA8_UNORM: |
| 43 | case RenderTargetFormat::RGBA8_SRGB: | ||
| 42 | case RenderTargetFormat::RGB10_A2_UNORM: | 44 | case RenderTargetFormat::RGB10_A2_UNORM: |
| 43 | case RenderTargetFormat::BGRA8_UNORM: | 45 | case RenderTargetFormat::BGRA8_UNORM: |
| 46 | case RenderTargetFormat::RG16_UNORM: | ||
| 47 | case RenderTargetFormat::RG16_SNORM: | ||
| 48 | case RenderTargetFormat::RG16_UINT: | ||
| 49 | case RenderTargetFormat::RG16_SINT: | ||
| 50 | case RenderTargetFormat::RG16_FLOAT: | ||
| 44 | case RenderTargetFormat::R32_FLOAT: | 51 | case RenderTargetFormat::R32_FLOAT: |
| 45 | case RenderTargetFormat::R11G11B10_FLOAT: | 52 | case RenderTargetFormat::R11G11B10_FLOAT: |
| 46 | return 4; | 53 | return 4; |
| 54 | case RenderTargetFormat::R16_UNORM: | ||
| 55 | case RenderTargetFormat::R16_SNORM: | ||
| 56 | case RenderTargetFormat::R16_UINT: | ||
| 57 | case RenderTargetFormat::R16_SINT: | ||
| 58 | case RenderTargetFormat::R16_FLOAT: | ||
| 59 | return 2; | ||
| 60 | case RenderTargetFormat::R8_UNORM: | ||
| 61 | return 1; | ||
| 47 | default: | 62 | default: |
| 48 | UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); | 63 | UNIMPLEMENTED_MSG("Unimplemented render target format {}", static_cast<u32>(format)); |
| 49 | } | 64 | } |
| 50 | } | 65 | } |
| 51 | 66 | ||
| 67 | u32 DepthFormatBytesPerPixel(DepthFormat format) { | ||
| 68 | switch (format) { | ||
| 69 | case DepthFormat::Z32_S8_X24_FLOAT: | ||
| 70 | return 8; | ||
| 71 | case DepthFormat::Z32_FLOAT: | ||
| 72 | case DepthFormat::S8_Z24_UNORM: | ||
| 73 | case DepthFormat::Z24_X8_UNORM: | ||
| 74 | case DepthFormat::Z24_S8_UNORM: | ||
| 75 | case DepthFormat::Z24_C8_UNORM: | ||
| 76 | return 4; | ||
| 77 | case DepthFormat::Z16_UNORM: | ||
| 78 | return 2; | ||
| 79 | default: | ||
| 80 | UNIMPLEMENTED_MSG("Unimplemented Depth format {}", static_cast<u32>(format)); | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 52 | } // namespace Tegra | 84 | } // namespace Tegra |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 874eddd78..0164c747a 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -35,6 +35,10 @@ enum class RenderTargetFormat : u32 { | |||
| 35 | R11G11B10_FLOAT = 0xE0, | 35 | R11G11B10_FLOAT = 0xE0, |
| 36 | R32_FLOAT = 0xE5, | 36 | R32_FLOAT = 0xE5, |
| 37 | B5G6R5_UNORM = 0xE8, | 37 | B5G6R5_UNORM = 0xE8, |
| 38 | R16_UNORM = 0xEE, | ||
| 39 | R16_SNORM = 0xEF, | ||
| 40 | R16_SINT = 0xF0, | ||
| 41 | R16_UINT = 0xF1, | ||
| 38 | R16_FLOAT = 0xF2, | 42 | R16_FLOAT = 0xF2, |
| 39 | R8_UNORM = 0xF3, | 43 | R8_UNORM = 0xF3, |
| 40 | }; | 44 | }; |
| @@ -52,6 +56,9 @@ enum class DepthFormat : u32 { | |||
| 52 | /// Returns the number of bytes per pixel of each rendertarget format. | 56 | /// Returns the number of bytes per pixel of each rendertarget format. |
| 53 | u32 RenderTargetBytesPerPixel(RenderTargetFormat format); | 57 | u32 RenderTargetBytesPerPixel(RenderTargetFormat format); |
| 54 | 58 | ||
| 59 | /// Returns the number of bytes per pixel of each depth format. | ||
| 60 | u32 DepthFormatBytesPerPixel(DepthFormat format); | ||
| 61 | |||
| 55 | class DebugContext; | 62 | class DebugContext; |
| 56 | 63 | ||
| 57 | /** | 64 | /** |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 546e86532..8360feb5d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -332,8 +332,6 @@ std::pair<Surface, Surface> RasterizerOpenGL::ConfigureFramebuffers(bool using_c | |||
| 332 | // TODO(bunnei): Implement this | 332 | // TODO(bunnei): Implement this |
| 333 | const bool has_stencil = false; | 333 | const bool has_stencil = false; |
| 334 | 334 | ||
| 335 | const MathUtil::Rectangle<s32> viewport_rect{regs.viewport_transform[0].GetRect()}; | ||
| 336 | |||
| 337 | const bool write_color_fb = | 335 | const bool write_color_fb = |
| 338 | state.color_mask.red_enabled == GL_TRUE || state.color_mask.green_enabled == GL_TRUE || | 336 | state.color_mask.red_enabled == GL_TRUE || state.color_mask.green_enabled == GL_TRUE || |
| 339 | state.color_mask.blue_enabled == GL_TRUE || state.color_mask.alpha_enabled == GL_TRUE; | 337 | state.color_mask.blue_enabled == GL_TRUE || state.color_mask.alpha_enabled == GL_TRUE; |
| @@ -346,9 +344,10 @@ std::pair<Surface, Surface> RasterizerOpenGL::ConfigureFramebuffers(bool using_c | |||
| 346 | Surface depth_surface; | 344 | Surface depth_surface; |
| 347 | MathUtil::Rectangle<u32> surfaces_rect; | 345 | MathUtil::Rectangle<u32> surfaces_rect; |
| 348 | std::tie(color_surface, depth_surface, surfaces_rect) = | 346 | std::tie(color_surface, depth_surface, surfaces_rect) = |
| 349 | res_cache.GetFramebufferSurfaces(using_color_fb, using_depth_fb, viewport_rect); | 347 | res_cache.GetFramebufferSurfaces(using_color_fb, using_depth_fb); |
| 350 | 348 | ||
| 351 | MathUtil::Rectangle<u32> draw_rect{ | 349 | const MathUtil::Rectangle<s32> viewport_rect{regs.viewport_transform[0].GetRect()}; |
| 350 | const MathUtil::Rectangle<u32> draw_rect{ | ||
| 352 | static_cast<u32>(std::clamp<s32>(static_cast<s32>(surfaces_rect.left) + viewport_rect.left, | 351 | static_cast<u32>(std::clamp<s32>(static_cast<s32>(surfaces_rect.left) + viewport_rect.left, |
| 353 | surfaces_rect.left, surfaces_rect.right)), // Left | 352 | surfaces_rect.left, surfaces_rect.right)), // Left |
| 354 | static_cast<u32>(std::clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + viewport_rect.top, | 353 | static_cast<u32>(std::clamp<s32>(static_cast<s32>(surfaces_rect.bottom) + viewport_rect.top, |
| @@ -812,9 +811,7 @@ void RasterizerOpenGL::SyncClipCoef() { | |||
| 812 | void RasterizerOpenGL::SyncCullMode() { | 811 | void RasterizerOpenGL::SyncCullMode() { |
| 813 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; | 812 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; |
| 814 | 813 | ||
| 815 | // TODO(bunnei): Enable the below once more things work - until then, this may hide regressions | 814 | state.cull.enabled = regs.cull.enabled != 0; |
| 816 | // state.cull.enabled = regs.cull.enabled != 0; | ||
| 817 | state.cull.enabled = false; | ||
| 818 | 815 | ||
| 819 | if (state.cull.enabled) { | 816 | if (state.cull.enabled) { |
| 820 | state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face); | 817 | state.cull.front_face = MaxwellToGL::FrontFace(regs.cull.front_face); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index f6efce818..15a33ed9b 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -122,6 +122,9 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form | |||
| 122 | {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F | 122 | {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F |
| 123 | {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F | 123 | {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F |
| 124 | {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM | 124 | {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM |
| 125 | {GL_R16_SNORM, GL_RED, GL_SHORT, ComponentType::SNorm, false}, // R16S | ||
| 126 | {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // R16UI | ||
| 127 | {GL_R16I, GL_RED_INTEGER, GL_SHORT, ComponentType::SInt, false}, // R16I | ||
| 125 | {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RG16 | 128 | {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RG16 |
| 126 | {GL_RG16F, GL_RG, GL_HALF_FLOAT, ComponentType::Float, false}, // RG16F | 129 | {GL_RG16F, GL_RG, GL_HALF_FLOAT, ComponentType::Float, false}, // RG16F |
| 127 | {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI | 130 | {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI |
| @@ -183,36 +186,49 @@ MathUtil::Rectangle<u32> SurfaceParams::GetRect() const { | |||
| 183 | return {0, actual_height, width, 0}; | 186 | return {0, actual_height, width, 0}; |
| 184 | } | 187 | } |
| 185 | 188 | ||
| 189 | /// Returns true if the specified PixelFormat is a BCn format, e.g. DXT or DXN | ||
| 190 | static bool IsFormatBCn(PixelFormat format) { | ||
| 191 | switch (format) { | ||
| 192 | case PixelFormat::DXT1: | ||
| 193 | case PixelFormat::DXT23: | ||
| 194 | case PixelFormat::DXT45: | ||
| 195 | case PixelFormat::DXN1: | ||
| 196 | case PixelFormat::DXN2SNORM: | ||
| 197 | case PixelFormat::DXN2UNORM: | ||
| 198 | case PixelFormat::BC7U: | ||
| 199 | return true; | ||
| 200 | } | ||
| 201 | return false; | ||
| 202 | } | ||
| 203 | |||
| 186 | template <bool morton_to_gl, PixelFormat format> | 204 | template <bool morton_to_gl, PixelFormat format> |
| 187 | void MortonCopy(u32 stride, u32 block_height, u32 height, u8* gl_buffer, Tegra::GPUVAddr addr) { | 205 | void MortonCopy(u32 stride, u32 block_height, u32 height, std::vector<u8>& gl_buffer, |
| 206 | Tegra::GPUVAddr addr) { | ||
| 188 | constexpr u32 bytes_per_pixel = SurfaceParams::GetFormatBpp(format) / CHAR_BIT; | 207 | constexpr u32 bytes_per_pixel = SurfaceParams::GetFormatBpp(format) / CHAR_BIT; |
| 189 | constexpr u32 gl_bytes_per_pixel = CachedSurface::GetGLBytesPerPixel(format); | 208 | constexpr u32 gl_bytes_per_pixel = CachedSurface::GetGLBytesPerPixel(format); |
| 190 | const auto& gpu = Core::System::GetInstance().GPU(); | 209 | const auto& gpu = Core::System::GetInstance().GPU(); |
| 191 | 210 | ||
| 192 | if (morton_to_gl) { | 211 | if (morton_to_gl) { |
| 193 | if (SurfaceParams::GetFormatType(format) == SurfaceType::ColorTexture) { | 212 | // With the BCn formats (DXT and DXN), each 4x4 tile is swizzled instead of just individual |
| 194 | auto data = Tegra::Texture::UnswizzleTexture( | 213 | // pixel values. |
| 195 | *gpu.memory_manager->GpuToCpuAddress(addr), | 214 | const u32 tile_size{IsFormatBCn(format) ? 4U : 1U}; |
| 196 | SurfaceParams::TextureFormatFromPixelFormat(format), stride, height, block_height); | 215 | const std::vector<u8> data = |
| 197 | std::memcpy(gl_buffer, data.data(), data.size()); | 216 | Tegra::Texture::UnswizzleTexture(*gpu.memory_manager->GpuToCpuAddress(addr), tile_size, |
| 198 | } else { | 217 | bytes_per_pixel, stride, height, block_height); |
| 199 | auto data = Tegra::Texture::UnswizzleDepthTexture( | 218 | const size_t size_to_copy{std::min(gl_buffer.size(), data.size())}; |
| 200 | *gpu.memory_manager->GpuToCpuAddress(addr), | 219 | gl_buffer.assign(data.begin(), data.begin() + size_to_copy); |
| 201 | SurfaceParams::DepthFormatFromPixelFormat(format), stride, height, block_height); | ||
| 202 | std::memcpy(gl_buffer, data.data(), data.size()); | ||
| 203 | } | ||
| 204 | } else { | 220 | } else { |
| 205 | // TODO(bunnei): Assumes the default rendering GOB size of 16 (128 lines). We should | 221 | // TODO(bunnei): Assumes the default rendering GOB size of 16 (128 lines). We should |
| 206 | // check the configuration for this and perform more generic un/swizzle | 222 | // check the configuration for this and perform more generic un/swizzle |
| 207 | LOG_WARNING(Render_OpenGL, "need to use correct swizzle/GOB parameters!"); | 223 | LOG_WARNING(Render_OpenGL, "need to use correct swizzle/GOB parameters!"); |
| 208 | VideoCore::MortonCopyPixels128( | 224 | VideoCore::MortonCopyPixels128( |
| 209 | stride, height, bytes_per_pixel, gl_bytes_per_pixel, | 225 | stride, height, bytes_per_pixel, gl_bytes_per_pixel, |
| 210 | Memory::GetPointer(*gpu.memory_manager->GpuToCpuAddress(addr)), gl_buffer, | 226 | Memory::GetPointer(*gpu.memory_manager->GpuToCpuAddress(addr)), gl_buffer.data(), |
| 211 | morton_to_gl); | 227 | morton_to_gl); |
| 212 | } | 228 | } |
| 213 | } | 229 | } |
| 214 | 230 | ||
| 215 | static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), | 231 | static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPUVAddr), |
| 216 | SurfaceParams::MaxPixelFormat> | 232 | SurfaceParams::MaxPixelFormat> |
| 217 | morton_to_gl_fns = { | 233 | morton_to_gl_fns = { |
| 218 | MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, | 234 | MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, |
| @@ -226,16 +242,17 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), | |||
| 226 | MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, | 242 | MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, |
| 227 | MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, | 243 | MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, |
| 228 | MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>, | 244 | MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>, |
| 229 | MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::RG16>, | 245 | MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::R16S>, |
| 230 | MortonCopy<true, PixelFormat::RG16F>, MortonCopy<true, PixelFormat::RG16UI>, | 246 | MortonCopy<true, PixelFormat::R16UI>, MortonCopy<true, PixelFormat::R16I>, |
| 231 | MortonCopy<true, PixelFormat::RG16I>, MortonCopy<true, PixelFormat::RG16S>, | 247 | MortonCopy<true, PixelFormat::RG16>, MortonCopy<true, PixelFormat::RG16F>, |
| 232 | MortonCopy<true, PixelFormat::RGB32F>, MortonCopy<true, PixelFormat::SRGBA8>, | 248 | MortonCopy<true, PixelFormat::RG16UI>, MortonCopy<true, PixelFormat::RG16I>, |
| 233 | MortonCopy<true, PixelFormat::Z24S8>, MortonCopy<true, PixelFormat::S8Z24>, | 249 | MortonCopy<true, PixelFormat::RG16S>, MortonCopy<true, PixelFormat::RGB32F>, |
| 234 | MortonCopy<true, PixelFormat::Z32F>, MortonCopy<true, PixelFormat::Z16>, | 250 | MortonCopy<true, PixelFormat::SRGBA8>, MortonCopy<true, PixelFormat::Z24S8>, |
| 235 | MortonCopy<true, PixelFormat::Z32FS8>, | 251 | MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, |
| 252 | MortonCopy<true, PixelFormat::Z16>, MortonCopy<true, PixelFormat::Z32FS8>, | ||
| 236 | }; | 253 | }; |
| 237 | 254 | ||
| 238 | static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), | 255 | static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPUVAddr), |
| 239 | SurfaceParams::MaxPixelFormat> | 256 | SurfaceParams::MaxPixelFormat> |
| 240 | gl_to_morton_fns = { | 257 | gl_to_morton_fns = { |
| 241 | MortonCopy<false, PixelFormat::ABGR8>, | 258 | MortonCopy<false, PixelFormat::ABGR8>, |
| @@ -263,6 +280,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), | |||
| 263 | MortonCopy<false, PixelFormat::R32F>, | 280 | MortonCopy<false, PixelFormat::R32F>, |
| 264 | MortonCopy<false, PixelFormat::R16F>, | 281 | MortonCopy<false, PixelFormat::R16F>, |
| 265 | MortonCopy<false, PixelFormat::R16UNORM>, | 282 | MortonCopy<false, PixelFormat::R16UNORM>, |
| 283 | MortonCopy<false, PixelFormat::R16S>, | ||
| 284 | MortonCopy<false, PixelFormat::R16UI>, | ||
| 285 | MortonCopy<false, PixelFormat::R16I>, | ||
| 266 | MortonCopy<false, PixelFormat::RG16>, | 286 | MortonCopy<false, PixelFormat::RG16>, |
| 267 | MortonCopy<false, PixelFormat::RG16F>, | 287 | MortonCopy<false, PixelFormat::RG16F>, |
| 268 | MortonCopy<false, PixelFormat::RG16UI>, | 288 | MortonCopy<false, PixelFormat::RG16UI>, |
| @@ -467,7 +487,7 @@ void CachedSurface::LoadGLBuffer() { | |||
| 467 | gl_buffer.resize(copy_size); | 487 | gl_buffer.resize(copy_size); |
| 468 | 488 | ||
| 469 | morton_to_gl_fns[static_cast<size_t>(params.pixel_format)]( | 489 | morton_to_gl_fns[static_cast<size_t>(params.pixel_format)]( |
| 470 | params.width, params.block_height, params.height, gl_buffer.data(), params.addr); | 490 | params.width, params.block_height, params.height, gl_buffer, params.addr); |
| 471 | } else { | 491 | } else { |
| 472 | const u8* const texture_src_data_end = texture_src_data + copy_size; | 492 | const u8* const texture_src_data_end = texture_src_data + copy_size; |
| 473 | 493 | ||
| @@ -494,7 +514,7 @@ void CachedSurface::FlushGLBuffer() { | |||
| 494 | std::memcpy(dst_buffer, gl_buffer.data(), params.size_in_bytes); | 514 | std::memcpy(dst_buffer, gl_buffer.data(), params.size_in_bytes); |
| 495 | } else { | 515 | } else { |
| 496 | gl_to_morton_fns[static_cast<size_t>(params.pixel_format)]( | 516 | gl_to_morton_fns[static_cast<size_t>(params.pixel_format)]( |
| 497 | params.width, params.block_height, params.height, gl_buffer.data(), params.addr); | 517 | params.width, params.block_height, params.height, gl_buffer, params.addr); |
| 498 | } | 518 | } |
| 499 | } | 519 | } |
| 500 | 520 | ||
| @@ -609,8 +629,8 @@ Surface RasterizerCacheOpenGL::GetTextureSurface(const Tegra::Texture::FullTextu | |||
| 609 | return GetSurface(SurfaceParams::CreateForTexture(config)); | 629 | return GetSurface(SurfaceParams::CreateForTexture(config)); |
| 610 | } | 630 | } |
| 611 | 631 | ||
| 612 | SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces( | 632 | SurfaceSurfaceRect_Tuple RasterizerCacheOpenGL::GetFramebufferSurfaces(bool using_color_fb, |
| 613 | bool using_color_fb, bool using_depth_fb, const MathUtil::Rectangle<s32>& viewport) { | 633 | bool using_depth_fb) { |
| 614 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; | 634 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; |
| 615 | 635 | ||
| 616 | // TODO(bunnei): This is hard corded to use just the first render buffer | 636 | // TODO(bunnei): This is hard corded to use just the first render buffer |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 26e2ee203..e24ba8cfe 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -46,22 +46,25 @@ struct SurfaceParams { | |||
| 46 | R32F = 20, | 46 | R32F = 20, |
| 47 | R16F = 21, | 47 | R16F = 21, |
| 48 | R16UNORM = 22, | 48 | R16UNORM = 22, |
| 49 | RG16 = 23, | 49 | R16S = 23, |
| 50 | RG16F = 24, | 50 | R16UI = 24, |
| 51 | RG16UI = 25, | 51 | R16I = 25, |
| 52 | RG16I = 26, | 52 | RG16 = 26, |
| 53 | RG16S = 27, | 53 | RG16F = 27, |
| 54 | RGB32F = 28, | 54 | RG16UI = 28, |
| 55 | SRGBA8 = 29, | 55 | RG16I = 29, |
| 56 | RG16S = 30, | ||
| 57 | RGB32F = 31, | ||
| 58 | SRGBA8 = 32, | ||
| 56 | 59 | ||
| 57 | MaxColorFormat, | 60 | MaxColorFormat, |
| 58 | 61 | ||
| 59 | // DepthStencil formats | 62 | // DepthStencil formats |
| 60 | Z24S8 = 30, | 63 | Z24S8 = 33, |
| 61 | S8Z24 = 31, | 64 | S8Z24 = 34, |
| 62 | Z32F = 32, | 65 | Z32F = 35, |
| 63 | Z16 = 33, | 66 | Z16 = 36, |
| 64 | Z32FS8 = 34, | 67 | Z32FS8 = 37, |
| 65 | 68 | ||
| 66 | MaxDepthStencilFormat, | 69 | MaxDepthStencilFormat, |
| 67 | 70 | ||
| @@ -122,6 +125,9 @@ struct SurfaceParams { | |||
| 122 | 1, // R32F | 125 | 1, // R32F |
| 123 | 1, // R16F | 126 | 1, // R16F |
| 124 | 1, // R16UNORM | 127 | 1, // R16UNORM |
| 128 | 1, // R16S | ||
| 129 | 1, // R16UI | ||
| 130 | 1, // R16I | ||
| 125 | 1, // RG16 | 131 | 1, // RG16 |
| 126 | 1, // RG16F | 132 | 1, // RG16F |
| 127 | 1, // RG16UI | 133 | 1, // RG16UI |
| @@ -168,6 +174,9 @@ struct SurfaceParams { | |||
| 168 | 32, // R32F | 174 | 32, // R32F |
| 169 | 16, // R16F | 175 | 16, // R16F |
| 170 | 16, // R16UNORM | 176 | 16, // R16UNORM |
| 177 | 16, // R16S | ||
| 178 | 16, // R16UI | ||
| 179 | 16, // R16I | ||
| 171 | 32, // RG16 | 180 | 32, // RG16 |
| 172 | 32, // RG16F | 181 | 32, // RG16F |
| 173 | 32, // RG16UI | 182 | 32, // RG16UI |
| @@ -245,6 +254,14 @@ struct SurfaceParams { | |||
| 245 | return PixelFormat::RG16S; | 254 | return PixelFormat::RG16S; |
| 246 | case Tegra::RenderTargetFormat::R16_FLOAT: | 255 | case Tegra::RenderTargetFormat::R16_FLOAT: |
| 247 | return PixelFormat::R16F; | 256 | return PixelFormat::R16F; |
| 257 | case Tegra::RenderTargetFormat::R16_UNORM: | ||
| 258 | return PixelFormat::R16UNORM; | ||
| 259 | case Tegra::RenderTargetFormat::R16_SNORM: | ||
| 260 | return PixelFormat::R16S; | ||
| 261 | case Tegra::RenderTargetFormat::R16_UINT: | ||
| 262 | return PixelFormat::R16UI; | ||
| 263 | case Tegra::RenderTargetFormat::R16_SINT: | ||
| 264 | return PixelFormat::R16I; | ||
| 248 | case Tegra::RenderTargetFormat::R32_FLOAT: | 265 | case Tegra::RenderTargetFormat::R32_FLOAT: |
| 249 | return PixelFormat::R32F; | 266 | return PixelFormat::R32F; |
| 250 | default: | 267 | default: |
| @@ -293,6 +310,12 @@ struct SurfaceParams { | |||
| 293 | return PixelFormat::R16F; | 310 | return PixelFormat::R16F; |
| 294 | case Tegra::Texture::ComponentType::UNORM: | 311 | case Tegra::Texture::ComponentType::UNORM: |
| 295 | return PixelFormat::R16UNORM; | 312 | return PixelFormat::R16UNORM; |
| 313 | case Tegra::Texture::ComponentType::SNORM: | ||
| 314 | return PixelFormat::R16S; | ||
| 315 | case Tegra::Texture::ComponentType::UINT: | ||
| 316 | return PixelFormat::R16UI; | ||
| 317 | case Tegra::Texture::ComponentType::SINT: | ||
| 318 | return PixelFormat::R16I; | ||
| 296 | } | 319 | } |
| 297 | LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", | 320 | LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", |
| 298 | static_cast<u32>(component_type)); | 321 | static_cast<u32>(component_type)); |
| @@ -348,92 +371,6 @@ struct SurfaceParams { | |||
| 348 | } | 371 | } |
| 349 | } | 372 | } |
| 350 | 373 | ||
| 351 | static Tegra::Texture::TextureFormat TextureFormatFromPixelFormat(PixelFormat format) { | ||
| 352 | // TODO(Subv): Properly implement this | ||
| 353 | switch (format) { | ||
| 354 | case PixelFormat::ABGR8: | ||
| 355 | case PixelFormat::SRGBA8: | ||
| 356 | return Tegra::Texture::TextureFormat::A8R8G8B8; | ||
| 357 | case PixelFormat::B5G6R5: | ||
| 358 | return Tegra::Texture::TextureFormat::B5G6R5; | ||
| 359 | case PixelFormat::A2B10G10R10: | ||
| 360 | return Tegra::Texture::TextureFormat::A2B10G10R10; | ||
| 361 | case PixelFormat::A1B5G5R5: | ||
| 362 | return Tegra::Texture::TextureFormat::A1B5G5R5; | ||
| 363 | case PixelFormat::R8: | ||
| 364 | return Tegra::Texture::TextureFormat::R8; | ||
| 365 | case PixelFormat::G8R8: | ||
| 366 | return Tegra::Texture::TextureFormat::G8R8; | ||
| 367 | case PixelFormat::RGBA16F: | ||
| 368 | return Tegra::Texture::TextureFormat::R16_G16_B16_A16; | ||
| 369 | case PixelFormat::R11FG11FB10F: | ||
| 370 | return Tegra::Texture::TextureFormat::BF10GF11RF11; | ||
| 371 | case PixelFormat::RGBA32UI: | ||
| 372 | return Tegra::Texture::TextureFormat::R32_G32_B32_A32; | ||
| 373 | case PixelFormat::DXT1: | ||
| 374 | return Tegra::Texture::TextureFormat::DXT1; | ||
| 375 | case PixelFormat::DXT23: | ||
| 376 | return Tegra::Texture::TextureFormat::DXT23; | ||
| 377 | case PixelFormat::DXT45: | ||
| 378 | return Tegra::Texture::TextureFormat::DXT45; | ||
| 379 | case PixelFormat::DXN1: | ||
| 380 | return Tegra::Texture::TextureFormat::DXN1; | ||
| 381 | case PixelFormat::DXN2UNORM: | ||
| 382 | case PixelFormat::DXN2SNORM: | ||
| 383 | return Tegra::Texture::TextureFormat::DXN2; | ||
| 384 | case PixelFormat::BC7U: | ||
| 385 | return Tegra::Texture::TextureFormat::BC7U; | ||
| 386 | case PixelFormat::ASTC_2D_4X4: | ||
| 387 | return Tegra::Texture::TextureFormat::ASTC_2D_4X4; | ||
| 388 | case PixelFormat::BGRA8: | ||
| 389 | // TODO(bunnei): This is fine for unswizzling (since we just need the right component | ||
| 390 | // sizes), but could be a bug if we used this function in different ways. | ||
| 391 | return Tegra::Texture::TextureFormat::A8R8G8B8; | ||
| 392 | case PixelFormat::RGBA32F: | ||
| 393 | return Tegra::Texture::TextureFormat::R32_G32_B32_A32; | ||
| 394 | case PixelFormat::RGB32F: | ||
| 395 | return Tegra::Texture::TextureFormat::R32_G32_B32; | ||
| 396 | case PixelFormat::RG32F: | ||
| 397 | return Tegra::Texture::TextureFormat::R32_G32; | ||
| 398 | case PixelFormat::R32F: | ||
| 399 | return Tegra::Texture::TextureFormat::R32; | ||
| 400 | case PixelFormat::R16F: | ||
| 401 | case PixelFormat::R16UNORM: | ||
| 402 | return Tegra::Texture::TextureFormat::R16; | ||
| 403 | case PixelFormat::Z32F: | ||
| 404 | return Tegra::Texture::TextureFormat::ZF32; | ||
| 405 | case PixelFormat::Z24S8: | ||
| 406 | return Tegra::Texture::TextureFormat::Z24S8; | ||
| 407 | case PixelFormat::RG16F: | ||
| 408 | case PixelFormat::RG16: | ||
| 409 | case PixelFormat::RG16UI: | ||
| 410 | case PixelFormat::RG16I: | ||
| 411 | case PixelFormat::RG16S: | ||
| 412 | return Tegra::Texture::TextureFormat::R16_G16; | ||
| 413 | default: | ||
| 414 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | ||
| 415 | UNREACHABLE(); | ||
| 416 | } | ||
| 417 | } | ||
| 418 | |||
| 419 | static Tegra::DepthFormat DepthFormatFromPixelFormat(PixelFormat format) { | ||
| 420 | switch (format) { | ||
| 421 | case PixelFormat::S8Z24: | ||
| 422 | return Tegra::DepthFormat::S8_Z24_UNORM; | ||
| 423 | case PixelFormat::Z24S8: | ||
| 424 | return Tegra::DepthFormat::Z24_S8_UNORM; | ||
| 425 | case PixelFormat::Z32F: | ||
| 426 | return Tegra::DepthFormat::Z32_FLOAT; | ||
| 427 | case PixelFormat::Z16: | ||
| 428 | return Tegra::DepthFormat::Z16_UNORM; | ||
| 429 | case PixelFormat::Z32FS8: | ||
| 430 | return Tegra::DepthFormat::Z32_S8_X24_FLOAT; | ||
| 431 | default: | ||
| 432 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | ||
| 433 | UNREACHABLE(); | ||
| 434 | } | ||
| 435 | } | ||
| 436 | |||
| 437 | static ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) { | 374 | static ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) { |
| 438 | // TODO(Subv): Implement more component types | 375 | // TODO(Subv): Implement more component types |
| 439 | switch (type) { | 376 | switch (type) { |
| @@ -462,9 +399,11 @@ struct SurfaceParams { | |||
| 462 | case Tegra::RenderTargetFormat::RGB10_A2_UNORM: | 399 | case Tegra::RenderTargetFormat::RGB10_A2_UNORM: |
| 463 | case Tegra::RenderTargetFormat::R8_UNORM: | 400 | case Tegra::RenderTargetFormat::R8_UNORM: |
| 464 | case Tegra::RenderTargetFormat::RG16_UNORM: | 401 | case Tegra::RenderTargetFormat::RG16_UNORM: |
| 402 | case Tegra::RenderTargetFormat::R16_UNORM: | ||
| 465 | case Tegra::RenderTargetFormat::B5G6R5_UNORM: | 403 | case Tegra::RenderTargetFormat::B5G6R5_UNORM: |
| 466 | return ComponentType::UNorm; | 404 | return ComponentType::UNorm; |
| 467 | case Tegra::RenderTargetFormat::RG16_SNORM: | 405 | case Tegra::RenderTargetFormat::RG16_SNORM: |
| 406 | case Tegra::RenderTargetFormat::R16_SNORM: | ||
| 468 | return ComponentType::SNorm; | 407 | return ComponentType::SNorm; |
| 469 | case Tegra::RenderTargetFormat::RGBA16_FLOAT: | 408 | case Tegra::RenderTargetFormat::RGBA16_FLOAT: |
| 470 | case Tegra::RenderTargetFormat::R11G11B10_FLOAT: | 409 | case Tegra::RenderTargetFormat::R11G11B10_FLOAT: |
| @@ -476,8 +415,10 @@ struct SurfaceParams { | |||
| 476 | return ComponentType::Float; | 415 | return ComponentType::Float; |
| 477 | case Tegra::RenderTargetFormat::RGBA32_UINT: | 416 | case Tegra::RenderTargetFormat::RGBA32_UINT: |
| 478 | case Tegra::RenderTargetFormat::RG16_UINT: | 417 | case Tegra::RenderTargetFormat::RG16_UINT: |
| 418 | case Tegra::RenderTargetFormat::R16_UINT: | ||
| 479 | return ComponentType::UInt; | 419 | return ComponentType::UInt; |
| 480 | case Tegra::RenderTargetFormat::RG16_SINT: | 420 | case Tegra::RenderTargetFormat::RG16_SINT: |
| 421 | case Tegra::RenderTargetFormat::R16_SINT: | ||
| 481 | return ComponentType::SInt; | 422 | return ComponentType::SInt; |
| 482 | default: | 423 | default: |
| 483 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); | 424 | LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); |
| @@ -634,8 +575,7 @@ public: | |||
| 634 | Surface GetTextureSurface(const Tegra::Texture::FullTextureInfo& config); | 575 | Surface GetTextureSurface(const Tegra::Texture::FullTextureInfo& config); |
| 635 | 576 | ||
| 636 | /// Get the color and depth surfaces based on the framebuffer configuration | 577 | /// Get the color and depth surfaces based on the framebuffer configuration |
| 637 | SurfaceSurfaceRect_Tuple GetFramebufferSurfaces(bool using_color_fb, bool using_depth_fb, | 578 | SurfaceSurfaceRect_Tuple GetFramebufferSurfaces(bool using_color_fb, bool using_depth_fb); |
| 638 | const MathUtil::Rectangle<s32>& viewport); | ||
| 639 | 579 | ||
| 640 | /// Flushes the surface to Switch memory | 580 | /// Flushes the surface to Switch memory |
| 641 | void FlushSurface(const Surface& surface); | 581 | void FlushSurface(const Surface& surface); |
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h index 43be69dd1..c439446b1 100644 --- a/src/video_core/renderer_opengl/maxwell_to_gl.h +++ b/src/video_core/renderer_opengl/maxwell_to_gl.h | |||
| @@ -45,6 +45,9 @@ inline GLenum VertexType(Maxwell::VertexAttribute attrib) { | |||
| 45 | case Maxwell::VertexAttribute::Type::SignedNorm: { | 45 | case Maxwell::VertexAttribute::Type::SignedNorm: { |
| 46 | 46 | ||
| 47 | switch (attrib.size) { | 47 | switch (attrib.size) { |
| 48 | case Maxwell::VertexAttribute::Size::Size_32_32_32: | ||
| 49 | return GL_INT; | ||
| 50 | case Maxwell::VertexAttribute::Size::Size_8_8: | ||
| 48 | case Maxwell::VertexAttribute::Size::Size_8_8_8_8: | 51 | case Maxwell::VertexAttribute::Size::Size_8_8_8_8: |
| 49 | return GL_BYTE; | 52 | return GL_BYTE; |
| 50 | case Maxwell::VertexAttribute::Size::Size_16_16: | 53 | case Maxwell::VertexAttribute::Size::Size_16_16: |
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 7ea66584c..70746a34e 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -86,88 +86,11 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | static u32 DepthBytesPerPixel(DepthFormat format) { | 89 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, |
| 90 | switch (format) { | 90 | u32 height, u32 block_height) { |
| 91 | case DepthFormat::Z16_UNORM: | ||
| 92 | return 2; | ||
| 93 | case DepthFormat::S8_Z24_UNORM: | ||
| 94 | case DepthFormat::Z24_S8_UNORM: | ||
| 95 | case DepthFormat::Z32_FLOAT: | ||
| 96 | return 4; | ||
| 97 | case DepthFormat::Z32_S8_X24_FLOAT: | ||
| 98 | return 8; | ||
| 99 | default: | ||
| 100 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 101 | break; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | |||
| 105 | std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, | ||
| 106 | u32 block_height) { | ||
| 107 | u8* data = Memory::GetPointer(address); | ||
| 108 | u32 bytes_per_pixel = BytesPerPixel(format); | ||
| 109 | |||
| 110 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | ||
| 111 | |||
| 112 | switch (format) { | ||
| 113 | case TextureFormat::DXT1: | ||
| 114 | case TextureFormat::DXT23: | ||
| 115 | case TextureFormat::DXT45: | ||
| 116 | case TextureFormat::DXN1: | ||
| 117 | case TextureFormat::DXN2: | ||
| 118 | case TextureFormat::BC7U: | ||
| 119 | // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel | ||
| 120 | // values. | ||
| 121 | CopySwizzledData(width / 4, height / 4, bytes_per_pixel, bytes_per_pixel, data, | ||
| 122 | unswizzled_data.data(), true, block_height); | ||
| 123 | break; | ||
| 124 | case TextureFormat::A8R8G8B8: | ||
| 125 | case TextureFormat::A2B10G10R10: | ||
| 126 | case TextureFormat::A1B5G5R5: | ||
| 127 | case TextureFormat::B5G6R5: | ||
| 128 | case TextureFormat::R8: | ||
| 129 | case TextureFormat::G8R8: | ||
| 130 | case TextureFormat::R16_G16_B16_A16: | ||
| 131 | case TextureFormat::R32_G32_B32_A32: | ||
| 132 | case TextureFormat::R32_G32: | ||
| 133 | case TextureFormat::R32: | ||
| 134 | case TextureFormat::R16: | ||
| 135 | case TextureFormat::R16_G16: | ||
| 136 | case TextureFormat::BF10GF11RF11: | ||
| 137 | case TextureFormat::ASTC_2D_4X4: | ||
| 138 | case TextureFormat::R32_G32_B32: | ||
| 139 | CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, | ||
| 140 | unswizzled_data.data(), true, block_height); | ||
| 141 | break; | ||
| 142 | default: | ||
| 143 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 144 | break; | ||
| 145 | } | ||
| 146 | |||
| 147 | return unswizzled_data; | ||
| 148 | } | ||
| 149 | |||
| 150 | std::vector<u8> UnswizzleDepthTexture(VAddr address, DepthFormat format, u32 width, u32 height, | ||
| 151 | u32 block_height) { | ||
| 152 | u8* data = Memory::GetPointer(address); | ||
| 153 | u32 bytes_per_pixel = DepthBytesPerPixel(format); | ||
| 154 | |||
| 155 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); | 91 | std::vector<u8> unswizzled_data(width * height * bytes_per_pixel); |
| 156 | 92 | CopySwizzledData(width / tile_size, height / tile_size, bytes_per_pixel, bytes_per_pixel, | |
| 157 | switch (format) { | 93 | Memory::GetPointer(address), unswizzled_data.data(), true, block_height); |
| 158 | case DepthFormat::Z16_UNORM: | ||
| 159 | case DepthFormat::S8_Z24_UNORM: | ||
| 160 | case DepthFormat::Z24_S8_UNORM: | ||
| 161 | case DepthFormat::Z32_FLOAT: | ||
| 162 | case DepthFormat::Z32_S8_X24_FLOAT: | ||
| 163 | CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, | ||
| 164 | unswizzled_data.data(), true, block_height); | ||
| 165 | break; | ||
| 166 | default: | ||
| 167 | UNIMPLEMENTED_MSG("Format not implemented"); | ||
| 168 | break; | ||
| 169 | } | ||
| 170 | |||
| 171 | return unswizzled_data; | 94 | return unswizzled_data; |
| 172 | } | 95 | } |
| 173 | 96 | ||
diff --git a/src/video_core/textures/decoders.h b/src/video_core/textures/decoders.h index 73a4924d1..1f7b731be 100644 --- a/src/video_core/textures/decoders.h +++ b/src/video_core/textures/decoders.h | |||
| @@ -13,8 +13,8 @@ namespace Tegra::Texture { | |||
| 13 | /** | 13 | /** |
| 14 | * Unswizzles a swizzled texture without changing its format. | 14 | * Unswizzles a swizzled texture without changing its format. |
| 15 | */ | 15 | */ |
| 16 | std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, u32 height, | 16 | std::vector<u8> UnswizzleTexture(VAddr address, u32 tile_size, u32 bytes_per_pixel, u32 width, |
| 17 | u32 block_height = TICEntry::DefaultBlockHeight); | 17 | u32 height, u32 block_height = TICEntry::DefaultBlockHeight); |
| 18 | 18 | ||
| 19 | /** | 19 | /** |
| 20 | * Unswizzles a swizzled depth texture without changing its format. | 20 | * Unswizzles a swizzled depth texture without changing its format. |
diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp index 3f7103ab9..e037223c2 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.cpp +++ b/src/yuzu/debugger/graphics/graphics_surface.cpp | |||
| @@ -383,8 +383,10 @@ void GraphicsSurfaceWidget::OnUpdate() { | |||
| 383 | QImage decoded_image(surface_width, surface_height, QImage::Format_ARGB32); | 383 | QImage decoded_image(surface_width, surface_height, QImage::Format_ARGB32); |
| 384 | boost::optional<VAddr> address = gpu.memory_manager->GpuToCpuAddress(surface_address); | 384 | boost::optional<VAddr> address = gpu.memory_manager->GpuToCpuAddress(surface_address); |
| 385 | 385 | ||
| 386 | auto unswizzled_data = | 386 | // TODO(bunnei): Will not work with BCn formats that swizzle 4x4 tiles. |
| 387 | Tegra::Texture::UnswizzleTexture(*address, surface_format, surface_width, surface_height); | 387 | // Needs to be fixed if we plan to use this feature more, otherwise we may remove it. |
| 388 | auto unswizzled_data = Tegra::Texture::UnswizzleTexture( | ||
| 389 | *address, 1, Tegra::Texture::BytesPerPixel(surface_format), surface_width, surface_height); | ||
| 388 | 390 | ||
| 389 | auto texture_data = Tegra::Texture::DecodeTexture(unswizzled_data, surface_format, | 391 | auto texture_data = Tegra::Texture::DecodeTexture(unswizzled_data, surface_format, |
| 390 | surface_width, surface_height); | 392 | surface_width, surface_height); |
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index 114a0fc7f..8fe5e8b80 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <array> | ||
| 7 | #include <atomic> | 8 | #include <atomic> |
| 8 | #include <utility> | 9 | #include <utility> |
| 9 | #include <QImage> | 10 | #include <QImage> |
| @@ -39,7 +40,6 @@ public: | |||
| 39 | * If this class receives valid SMDH data, it will also display game icons and titles. | 40 | * If this class receives valid SMDH data, it will also display game icons and titles. |
| 40 | */ | 41 | */ |
| 41 | class GameListItemPath : public GameListItem { | 42 | class GameListItemPath : public GameListItem { |
| 42 | |||
| 43 | public: | 43 | public: |
| 44 | static const int FullPathRole = Qt::UserRole + 1; | 44 | static const int FullPathRole = Qt::UserRole + 1; |
| 45 | static const int TitleRole = Qt::UserRole + 2; | 45 | static const int TitleRole = Qt::UserRole + 2; |
| @@ -48,18 +48,18 @@ public: | |||
| 48 | 48 | ||
| 49 | GameListItemPath() = default; | 49 | GameListItemPath() = default; |
| 50 | GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data, | 50 | GameListItemPath(const QString& game_path, const std::vector<u8>& picture_data, |
| 51 | const QString& game_name, const QString& game_type, u64 program_id) | 51 | const QString& game_name, const QString& game_type, u64 program_id) { |
| 52 | : GameListItem() { | ||
| 53 | setData(game_path, FullPathRole); | 52 | setData(game_path, FullPathRole); |
| 54 | setData(game_name, TitleRole); | 53 | setData(game_name, TitleRole); |
| 55 | setData(qulonglong(program_id), ProgramIdRole); | 54 | setData(qulonglong(program_id), ProgramIdRole); |
| 56 | setData(game_type, FileTypeRole); | 55 | setData(game_type, FileTypeRole); |
| 57 | 56 | ||
| 57 | const u32 size = UISettings::values.icon_size; | ||
| 58 | |||
| 58 | QPixmap picture; | 59 | QPixmap picture; |
| 59 | u32 size = UISettings::values.icon_size; | 60 | if (!picture.loadFromData(picture_data.data(), static_cast<u32>(picture_data.size()))) { |
| 60 | if (!picture.loadFromData(picture_data.data(), picture_data.size())) | ||
| 61 | picture = GetDefaultIcon(size); | 61 | picture = GetDefaultIcon(size); |
| 62 | 62 | } | |
| 63 | picture = picture.scaled(size, size); | 63 | picture = picture.scaled(size, size); |
| 64 | 64 | ||
| 65 | setData(picture, Qt::DecorationRole); | 65 | setData(picture, Qt::DecorationRole); |
| @@ -70,17 +70,16 @@ public: | |||
| 70 | std::string filename; | 70 | std::string filename; |
| 71 | Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename, | 71 | Common::SplitPath(data(FullPathRole).toString().toStdString(), nullptr, &filename, |
| 72 | nullptr); | 72 | nullptr); |
| 73 | QString title = data(TitleRole).toString(); | ||
| 74 | 73 | ||
| 75 | std::vector<QString> row_data{ | 74 | const std::array<QString, 4> row_data{{ |
| 76 | QString::fromStdString(filename), | 75 | QString::fromStdString(filename), |
| 77 | data(FileTypeRole).toString(), | 76 | data(FileTypeRole).toString(), |
| 78 | QString::fromStdString(fmt::format("0x{:016X}", data(ProgramIdRole).toULongLong())), | 77 | QString::fromStdString(fmt::format("0x{:016X}", data(ProgramIdRole).toULongLong())), |
| 79 | data(TitleRole).toString(), | 78 | data(TitleRole).toString(), |
| 80 | }; | 79 | }}; |
| 81 | 80 | ||
| 82 | auto row1 = row_data.at(UISettings::values.row_1_text_id); | 81 | const auto& row1 = row_data.at(UISettings::values.row_1_text_id); |
| 83 | auto row2 = row_data.at(UISettings::values.row_2_text_id); | 82 | const auto& row2 = row_data.at(UISettings::values.row_2_text_id); |
| 84 | 83 | ||
| 85 | if (row1.isEmpty() || row1 == row2) | 84 | if (row1.isEmpty() || row1 == row2) |
| 86 | return row2; | 85 | return row2; |
| @@ -88,9 +87,9 @@ public: | |||
| 88 | return row1; | 87 | return row1; |
| 89 | 88 | ||
| 90 | return row1 + "\n " + row2; | 89 | return row1 + "\n " + row2; |
| 91 | } else { | ||
| 92 | return GameListItem::data(role); | ||
| 93 | } | 90 | } |
| 91 | |||
| 92 | return GameListItem::data(role); | ||
| 94 | } | 93 | } |
| 95 | }; | 94 | }; |
| 96 | 95 | ||