summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/kernel/svc.cpp5
-rw-r--r--src/core/hle/kernel/thread.cpp7
-rw-r--r--src/core/hle/kernel/thread.h9
-rw-r--r--src/core/hle/service/am/am.cpp40
-rw-r--r--src/core/hle/service/am/am.h3
-rw-r--r--src/video_core/CMakeLists.txt2
-rw-r--r--src/video_core/engines/maxwell_3d.cpp8
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp185
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.cpp142
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.h3
-rw-r--r--src/video_core/shader/decode/other.cpp2
-rw-r--r--src/video_core/surface.cpp321
-rw-r--r--src/video_core/surface.h20
-rw-r--r--src/video_core/texture_cache/format_lookup_table.cpp208
-rw-r--r--src/video_core/texture_cache/format_lookup_table.h51
-rw-r--r--src/video_core/texture_cache/surface_params.cpp32
-rw-r--r--src/video_core/texture_cache/surface_params.h9
-rw-r--r--src/video_core/texture_cache/texture_cache.h16
-rw-r--r--src/yuzu/main.ui13
19 files changed, 492 insertions, 584 deletions
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index c63a9ba8b..b2cef3be9 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -505,6 +505,11 @@ static ResultCode WaitSynchronization(Core::System& system, Handle* index, VAddr
505 return RESULT_TIMEOUT; 505 return RESULT_TIMEOUT;
506 } 506 }
507 507
508 if (thread->IsSyncCancelled()) {
509 thread->SetSyncCancelled(false);
510 return ERR_SYNCHRONIZATION_CANCELED;
511 }
512
508 for (auto& object : objects) { 513 for (auto& object : objects) {
509 object->AddWaitingThread(thread); 514 object->AddWaitingThread(thread);
510 } 515 }
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index ee7531f2d..ab0e82ac2 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -120,8 +120,11 @@ void Thread::ResumeFromWait() {
120} 120}
121 121
122void Thread::CancelWait() { 122void Thread::CancelWait() {
123 ASSERT(GetStatus() == ThreadStatus::WaitSynch); 123 if (GetSchedulingStatus() != ThreadSchedStatus::Paused) {
124 ClearWaitObjects(); 124 is_sync_cancelled = true;
125 return;
126 }
127 is_sync_cancelled = false;
125 SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED); 128 SetWaitSynchronizationResult(ERR_SYNCHRONIZATION_CANCELED);
126 ResumeFromWait(); 129 ResumeFromWait();
127} 130}
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index c9870873d..25a6ed234 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -440,6 +440,14 @@ public:
440 is_running = value; 440 is_running = value;
441 } 441 }
442 442
443 bool IsSyncCancelled() const {
444 return is_sync_cancelled;
445 }
446
447 void SetSyncCancelled(bool value) {
448 is_sync_cancelled = value;
449 }
450
443private: 451private:
444 explicit Thread(KernelCore& kernel); 452 explicit Thread(KernelCore& kernel);
445 ~Thread() override; 453 ~Thread() override;
@@ -524,6 +532,7 @@ private:
524 532
525 u32 scheduling_state = 0; 533 u32 scheduling_state = 0;
526 bool is_running = false; 534 bool is_running = false;
535 bool is_sync_cancelled = false;
527 536
528 std::string name; 537 std::string name;
529}; 538};
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index a5702e1ab..701f05019 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -1076,7 +1076,7 @@ IApplicationFunctions::IApplicationFunctions(Core::System& system_)
1076 {100, &IApplicationFunctions::InitializeApplicationCopyrightFrameBuffer, "InitializeApplicationCopyrightFrameBuffer"}, 1076 {100, &IApplicationFunctions::InitializeApplicationCopyrightFrameBuffer, "InitializeApplicationCopyrightFrameBuffer"},
1077 {101, &IApplicationFunctions::SetApplicationCopyrightImage, "SetApplicationCopyrightImage"}, 1077 {101, &IApplicationFunctions::SetApplicationCopyrightImage, "SetApplicationCopyrightImage"},
1078 {102, &IApplicationFunctions::SetApplicationCopyrightVisibility, "SetApplicationCopyrightVisibility"}, 1078 {102, &IApplicationFunctions::SetApplicationCopyrightVisibility, "SetApplicationCopyrightVisibility"},
1079 {110, nullptr, "QueryApplicationPlayStatistics"}, 1079 {110, &IApplicationFunctions::QueryApplicationPlayStatistics, "QueryApplicationPlayStatistics"},
1080 {111, &IApplicationFunctions::QueryApplicationPlayStatisticsByUid, "QueryApplicationPlayStatisticsByUid"}, 1080 {111, &IApplicationFunctions::QueryApplicationPlayStatisticsByUid, "QueryApplicationPlayStatisticsByUid"},
1081 {120, nullptr, "ExecuteProgram"}, 1081 {120, nullptr, "ExecuteProgram"},
1082 {121, nullptr, "ClearUserChannel"}, 1082 {121, nullptr, "ClearUserChannel"},
@@ -1336,12 +1336,16 @@ void IApplicationFunctions::GetPseudoDeviceId(Kernel::HLERequestContext& ctx) {
1336} 1336}
1337 1337
1338void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) { 1338void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
1339 struct Parameters {
1340 FileSys::SaveDataType type;
1341 u128 user_id;
1342 u64 new_normal_size;
1343 u64 new_journal_size;
1344 };
1345 static_assert(sizeof(Parameters) == 40);
1346
1339 IPC::RequestParser rp{ctx}; 1347 IPC::RequestParser rp{ctx};
1340 const auto type{rp.PopRaw<FileSys::SaveDataType>()}; 1348 const auto [type, user_id, new_normal_size, new_journal_size] = rp.PopRaw<Parameters>();
1341 rp.Skip(1, false);
1342 const auto user_id{rp.PopRaw<u128>()};
1343 const auto new_normal_size{rp.PopRaw<u64>()};
1344 const auto new_journal_size{rp.PopRaw<u64>()};
1345 1349
1346 LOG_DEBUG(Service_AM, 1350 LOG_DEBUG(Service_AM,
1347 "called with type={:02X}, user_id={:016X}{:016X}, new_normal={:016X}, " 1351 "called with type={:02X}, user_id={:016X}{:016X}, new_normal={:016X}, "
@@ -1360,10 +1364,14 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
1360} 1364}
1361 1365
1362void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) { 1366void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
1367 struct Parameters {
1368 FileSys::SaveDataType type;
1369 u128 user_id;
1370 };
1371 static_assert(sizeof(Parameters) == 24);
1372
1363 IPC::RequestParser rp{ctx}; 1373 IPC::RequestParser rp{ctx};
1364 const auto type{rp.PopRaw<FileSys::SaveDataType>()}; 1374 const auto [type, user_id] = rp.PopRaw<Parameters>();
1365 rp.Skip(1, false);
1366 const auto user_id{rp.PopRaw<u128>()};
1367 1375
1368 LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type), 1376 LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type),
1369 user_id[1], user_id[0]); 1377 user_id[1], user_id[0]);
@@ -1377,12 +1385,12 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
1377 rb.Push(size.journal); 1385 rb.Push(size.journal);
1378} 1386}
1379 1387
1380void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx) { 1388void IApplicationFunctions::QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx) {
1381 LOG_WARNING(Service_AM, "(STUBBED) called"); 1389 LOG_WARNING(Service_AM, "(STUBBED) called");
1382 1390
1383 IPC::ResponseBuilder rb{ctx, 2, 1}; 1391 IPC::ResponseBuilder rb{ctx, 3};
1384 rb.Push(RESULT_SUCCESS); 1392 rb.Push(RESULT_SUCCESS);
1385 rb.PushCopyObjects(gpu_error_detected_event.readable); 1393 rb.Push<u32>(0);
1386} 1394}
1387 1395
1388void IApplicationFunctions::QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx) { 1396void IApplicationFunctions::QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx) {
@@ -1393,6 +1401,14 @@ void IApplicationFunctions::QueryApplicationPlayStatisticsByUid(Kernel::HLEReque
1393 rb.Push<u32>(0); 1401 rb.Push<u32>(0);
1394} 1402}
1395 1403
1404void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx) {
1405 LOG_WARNING(Service_AM, "(STUBBED) called");
1406
1407 IPC::ResponseBuilder rb{ctx, 2, 1};
1408 rb.Push(RESULT_SUCCESS);
1409 rb.PushCopyObjects(gpu_error_detected_event.readable);
1410}
1411
1396void InstallInterfaces(SM::ServiceManager& service_manager, 1412void InstallInterfaces(SM::ServiceManager& service_manager,
1397 std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) { 1413 std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) {
1398 auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel()); 1414 auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel());
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h
index f64013ea0..06a65b5ed 100644
--- a/src/core/hle/service/am/am.h
+++ b/src/core/hle/service/am/am.h
@@ -255,8 +255,9 @@ private:
255 void InitializeApplicationCopyrightFrameBuffer(Kernel::HLERequestContext& ctx); 255 void InitializeApplicationCopyrightFrameBuffer(Kernel::HLERequestContext& ctx);
256 void SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx); 256 void SetApplicationCopyrightImage(Kernel::HLERequestContext& ctx);
257 void SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx); 257 void SetApplicationCopyrightVisibility(Kernel::HLERequestContext& ctx);
258 void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx); 258 void QueryApplicationPlayStatistics(Kernel::HLERequestContext& ctx);
259 void QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx); 259 void QueryApplicationPlayStatisticsByUid(Kernel::HLERequestContext& ctx);
260 void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx);
260 261
261 bool launch_popped_application_specific = false; 262 bool launch_popped_application_specific = false;
262 bool launch_popped_account_preselect = false; 263 bool launch_popped_account_preselect = false;
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 45d8eaf23..6f3f2aa9f 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -127,6 +127,8 @@ add_library(video_core STATIC
127 shader/track.cpp 127 shader/track.cpp
128 surface.cpp 128 surface.cpp
129 surface.h 129 surface.h
130 texture_cache/format_lookup_table.cpp
131 texture_cache/format_lookup_table.h
130 texture_cache/surface_base.cpp 132 texture_cache/surface_base.cpp
131 texture_cache/surface_base.h 133 texture_cache/surface_base.h
132 texture_cache/surface_params.cpp 134 texture_cache/surface_params.cpp
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 42ce49a4d..a44c09003 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -742,14 +742,6 @@ Texture::TICEntry Maxwell3D::GetTICEntry(u32 tic_index) const {
742 Texture::TICEntry tic_entry; 742 Texture::TICEntry tic_entry;
743 memory_manager.ReadBlockUnsafe(tic_address_gpu, &tic_entry, sizeof(Texture::TICEntry)); 743 memory_manager.ReadBlockUnsafe(tic_address_gpu, &tic_entry, sizeof(Texture::TICEntry));
744 744
745 [[maybe_unused]] const auto r_type{tic_entry.r_type.Value()};
746 [[maybe_unused]] const auto g_type{tic_entry.g_type.Value()};
747 [[maybe_unused]] const auto b_type{tic_entry.b_type.Value()};
748 [[maybe_unused]] const auto a_type{tic_entry.a_type.Value()};
749
750 // TODO(Subv): Different data types for separate components are not supported
751 DEBUG_ASSERT(r_type == g_type && r_type == b_type && r_type == a_type);
752
753 return tic_entry; 745 return tic_entry;
754} 746}
755 747
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 55b3e58b2..4659e098f 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -23,7 +23,6 @@ namespace OpenGL {
23using Tegra::Texture::SwizzleSource; 23using Tegra::Texture::SwizzleSource;
24using VideoCore::MortonSwizzleMode; 24using VideoCore::MortonSwizzleMode;
25 25
26using VideoCore::Surface::ComponentType;
27using VideoCore::Surface::PixelFormat; 26using VideoCore::Surface::PixelFormat;
28using VideoCore::Surface::SurfaceCompression; 27using VideoCore::Surface::SurfaceCompression;
29using VideoCore::Surface::SurfaceTarget; 28using VideoCore::Surface::SurfaceTarget;
@@ -40,114 +39,95 @@ struct FormatTuple {
40 GLint internal_format; 39 GLint internal_format;
41 GLenum format; 40 GLenum format;
42 GLenum type; 41 GLenum type;
43 ComponentType component_type;
44 bool compressed; 42 bool compressed;
45}; 43};
46 44
47constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{ 45constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{
48 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8U 46 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8U
49 {GL_RGBA8, GL_RGBA, GL_BYTE, ComponentType::SNorm, false}, // ABGR8S 47 {GL_RGBA8, GL_RGBA, GL_BYTE, false}, // ABGR8S
50 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, ComponentType::UInt, false}, // ABGR8UI 48 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, false}, // ABGR8UI
51 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5U 49 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5U
52 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, ComponentType::UNorm, 50 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10U
53 false}, // A2B10G10R10U 51 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5U
54 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, ComponentType::UNorm, false}, // A1B5G5R5U 52 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, false}, // R8U
55 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // R8U 53 {GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, false}, // R8UI
56 {GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, ComponentType::UInt, false}, // R8UI 54 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, false}, // RGBA16F
57 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, ComponentType::Float, false}, // RGBA16F 55 {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, false}, // RGBA16U
58 {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RGBA16U 56 {GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, false}, // RGBA16UI
59 {GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RGBA16UI 57 {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, false}, // R11FG11FB10F
60 {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, ComponentType::Float, 58 {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, false}, // RGBA32UI
61 false}, // R11FG11FB10F 59 {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
62 {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // RGBA32UI 60 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
63 {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 61 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
64 true}, // DXT1 62 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, true}, // DXN1
65 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 63 {GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, true}, // DXN2UNORM
66 true}, // DXT23 64 {GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_INT, true}, // DXN2SNORM
67 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 65 {GL_COMPRESSED_RGBA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // BC7U
68 true}, // DXT45 66 {GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // BC6H_UF16
69 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 67 {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // BC6H_SF16
70 {GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 68 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_4X4
71 true}, // DXN2UNORM 69 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, false}, // BGRA8
72 {GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_INT, ComponentType::SNorm, true}, // DXN2SNORM 70 {GL_RGBA32F, GL_RGBA, GL_FLOAT, false}, // RGBA32F
73 {GL_COMPRESSED_RGBA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 71 {GL_RG32F, GL_RG, GL_FLOAT, false}, // RG32F
74 true}, // BC7U 72 {GL_R32F, GL_RED, GL_FLOAT, false}, // R32F
75 {GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::Float, 73 {GL_R16F, GL_RED, GL_HALF_FLOAT, false}, // R16F
76 true}, // BC6H_UF16 74 {GL_R16, GL_RED, GL_UNSIGNED_SHORT, false}, // R16U
77 {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::Float, 75 {GL_R16_SNORM, GL_RED, GL_SHORT, false}, // R16S
78 true}, // BC6H_SF16 76 {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, false}, // R16UI
79 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 77 {GL_R16I, GL_RED_INTEGER, GL_SHORT, false}, // R16I
80 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 78 {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, false}, // RG16
81 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F 79 {GL_RG16F, GL_RG, GL_HALF_FLOAT, false}, // RG16F
82 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F 80 {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, false}, // RG16UI
83 {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F 81 {GL_RG16I, GL_RG_INTEGER, GL_SHORT, false}, // RG16I
84 {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F 82 {GL_RG16_SNORM, GL_RG, GL_SHORT, false}, // RG16S
85 {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16U 83 {GL_RGB32F, GL_RGB, GL_FLOAT, false}, // RGB32F
86 {GL_R16_SNORM, GL_RED, GL_SHORT, ComponentType::SNorm, false}, // R16S 84 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // RGBA8_SRGB
87 {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // R16UI 85 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, false}, // RG8U
88 {GL_R16I, GL_RED_INTEGER, GL_SHORT, ComponentType::SInt, false}, // R16I 86 {GL_RG8, GL_RG, GL_BYTE, false}, // RG8S
89 {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RG16 87 {GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, false}, // RG32UI
90 {GL_RG16F, GL_RG, GL_HALF_FLOAT, ComponentType::Float, false}, // RG16F 88 {GL_RGB16F, GL_RGBA16, GL_HALF_FLOAT, false}, // RGBX16F
91 {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI 89 {GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, false}, // R32UI
92 {GL_RG16I, GL_RG_INTEGER, GL_SHORT, ComponentType::SInt, false}, // RG16I 90 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X8
93 {GL_RG16_SNORM, GL_RG, GL_SHORT, ComponentType::SNorm, false}, // RG16S 91 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X5
94 {GL_RGB32F, GL_RGB, GL_FLOAT, ComponentType::Float, false}, // RGB32F 92 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X4
95 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, 93 {GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE, false}, // BGRA8
96 false}, // RGBA8_SRGB
97 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // RG8U
98 {GL_RG8, GL_RG, GL_BYTE, ComponentType::SNorm, false}, // RG8S
99 {GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // RG32UI
100 {GL_RGB16F, GL_RGBA16, GL_HALF_FLOAT, ComponentType::Float, false}, // RGBX16F
101 {GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // R32UI
102 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X8
103 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X5
104 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4
105 {GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
106 // Compressed sRGB formats 94 // Compressed sRGB formats
107 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 95 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1_SRGB
108 true}, // DXT1_SRGB 96 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23_SRGB
109 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 97 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45_SRGB
110 true}, // DXT23_SRGB 98 {GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // BC7U_SRGB
111 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 99 {GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, false}, // R4G4B4A4U
112 true}, // DXT45_SRGB 100 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_4X4_SRGB
113 {GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 101 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X8_SRGB
114 true}, // BC7U_SRGB 102 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X5_SRGB
115 {GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, ComponentType::UNorm, false}, // R4G4B4A4U 103 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X4_SRGB
116 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4_SRGB 104 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X5
117 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X8_SRGB 105 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X5_SRGB
118 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X5_SRGB 106 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X8
119 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4_SRGB 107 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X8_SRGB
120 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5 108 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X6
121 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5_SRGB 109 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X6_SRGB
122 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8 110 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X10
123 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8_SRGB 111 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X10_SRGB
124 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X6 112 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_12X12
125 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X6_SRGB 113 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_12X12_SRGB
126 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X10 114 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X6
127 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X10_SRGB 115 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X6_SRGB
128 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_12X12 116 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X5
129 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_12X12_SRGB 117 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X5_SRGB
130 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X6 118 {GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, false}, // E5B9G9R9F
131 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X6_SRGB
132 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X5
133 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X5_SRGB
134 {GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, ComponentType::Float, false}, // E5B9G9R9F
135 119
136 // Depth formats 120 // Depth formats
137 {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F 121 {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, false}, // Z32F
138 {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, ComponentType::UNorm, 122 {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, false}, // Z16
139 false}, // Z16
140 123
141 // DepthStencil formats 124 // DepthStencil formats
142 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, 125 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, false}, // Z24S8
143 false}, // Z24S8 126 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, false}, // S8Z24
144 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, 127 {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, false}, // Z32FS8
145 false}, // S8Z24
146 {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
147 ComponentType::Float, false}, // Z32FS8
148}}; 128}};
149 129
150const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) { 130const FormatTuple& GetFormatTuple(PixelFormat pixel_format) {
151 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size()); 131 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size());
152 const auto& format{tex_format_tuples[static_cast<std::size_t>(pixel_format)]}; 132 const auto& format{tex_format_tuples[static_cast<std::size_t>(pixel_format)]};
153 return format; 133 return format;
@@ -249,7 +229,7 @@ OGLTexture CreateTexture(const SurfaceParams& params, GLenum target, GLenum inte
249 229
250CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& params) 230CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& params)
251 : VideoCommon::SurfaceBase<View>(gpu_addr, params) { 231 : VideoCommon::SurfaceBase<View>(gpu_addr, params) {
252 const auto& tuple{GetFormatTuple(params.pixel_format, params.component_type)}; 232 const auto& tuple{GetFormatTuple(params.pixel_format)};
253 internal_format = tuple.internal_format; 233 internal_format = tuple.internal_format;
254 format = tuple.format; 234 format = tuple.format;
255 type = tuple.type; 235 type = tuple.type;
@@ -451,8 +431,7 @@ OGLTextureView CachedSurfaceView::CreateTextureView() const {
451 texture_view.Create(); 431 texture_view.Create();
452 432
453 const GLuint handle{texture_view.handle}; 433 const GLuint handle{texture_view.handle};
454 const FormatTuple& tuple{ 434 const FormatTuple& tuple{GetFormatTuple(owner_params.pixel_format)};
455 GetFormatTuple(owner_params.pixel_format, owner_params.component_type)};
456 435
457 glTextureView(handle, target, surface.texture.handle, tuple.internal_format, params.base_level, 436 glTextureView(handle, target, surface.texture.handle, tuple.internal_format, params.base_level,
458 params.num_levels, params.base_layer, params.num_layers); 437 params.num_levels, params.base_layer, params.num_layers);
@@ -562,8 +541,8 @@ void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface)
562 const auto& dst_params = dst_surface->GetSurfaceParams(); 541 const auto& dst_params = dst_surface->GetSurfaceParams();
563 UNIMPLEMENTED_IF(src_params.num_levels > 1 || dst_params.num_levels > 1); 542 UNIMPLEMENTED_IF(src_params.num_levels > 1 || dst_params.num_levels > 1);
564 543
565 const auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); 544 const auto source_format = GetFormatTuple(src_params.pixel_format);
566 const auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); 545 const auto dest_format = GetFormatTuple(dst_params.pixel_format);
567 546
568 const std::size_t source_size = src_surface->GetHostSizeInBytes(); 547 const std::size_t source_size = src_surface->GetHostSizeInBytes();
569 const std::size_t dest_size = dst_surface->GetHostSizeInBytes(); 548 const std::size_t dest_size = dst_surface->GetHostSizeInBytes();
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
index 3c5acda3e..463ed43ae 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
@@ -95,83 +95,82 @@ vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compar
95} // namespace Sampler 95} // namespace Sampler
96 96
97struct FormatTuple { 97struct FormatTuple {
98 vk::Format format; ///< Vulkan format 98 vk::Format format; ///< Vulkan format
99 ComponentType component_type; ///< Abstracted component type 99 bool attachable; ///< True when this format can be used as an attachment
100 bool attachable; ///< True when this format can be used as an attachment
101}; 100};
102 101
103static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{ 102static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{
104 {vk::Format::eA8B8G8R8UnormPack32, ComponentType::UNorm, true}, // ABGR8U 103 {vk::Format::eA8B8G8R8UnormPack32, true}, // ABGR8U
105 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ABGR8S 104 {vk::Format::eUndefined, false}, // ABGR8S
106 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ABGR8UI 105 {vk::Format::eUndefined, false}, // ABGR8UI
107 {vk::Format::eB5G6R5UnormPack16, ComponentType::UNorm, false}, // B5G6R5U 106 {vk::Format::eB5G6R5UnormPack16, false}, // B5G6R5U
108 {vk::Format::eA2B10G10R10UnormPack32, ComponentType::UNorm, true}, // A2B10G10R10U 107 {vk::Format::eA2B10G10R10UnormPack32, true}, // A2B10G10R10U
109 {vk::Format::eUndefined, ComponentType::Invalid, false}, // A1B5G5R5U 108 {vk::Format::eUndefined, false}, // A1B5G5R5U
110 {vk::Format::eR8Unorm, ComponentType::UNorm, true}, // R8U 109 {vk::Format::eR8Unorm, true}, // R8U
111 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R8UI 110 {vk::Format::eUndefined, false}, // R8UI
112 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA16F 111 {vk::Format::eUndefined, false}, // RGBA16F
113 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA16U 112 {vk::Format::eUndefined, false}, // RGBA16U
114 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA16UI 113 {vk::Format::eUndefined, false}, // RGBA16UI
115 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R11FG11FB10F 114 {vk::Format::eUndefined, false}, // R11FG11FB10F
116 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA32UI 115 {vk::Format::eUndefined, false}, // RGBA32UI
117 {vk::Format::eBc1RgbaUnormBlock, ComponentType::UNorm, false}, // DXT1 116 {vk::Format::eBc1RgbaUnormBlock, false}, // DXT1
118 {vk::Format::eBc2UnormBlock, ComponentType::UNorm, false}, // DXT23 117 {vk::Format::eBc2UnormBlock, false}, // DXT23
119 {vk::Format::eBc3UnormBlock, ComponentType::UNorm, false}, // DXT45 118 {vk::Format::eBc3UnormBlock, false}, // DXT45
120 {vk::Format::eBc4UnormBlock, ComponentType::UNorm, false}, // DXN1 119 {vk::Format::eBc4UnormBlock, false}, // DXN1
121 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXN2UNORM 120 {vk::Format::eUndefined, false}, // DXN2UNORM
122 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXN2SNORM 121 {vk::Format::eUndefined, false}, // DXN2SNORM
123 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC7U 122 {vk::Format::eUndefined, false}, // BC7U
124 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC6H_UF16 123 {vk::Format::eUndefined, false}, // BC6H_UF16
125 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC6H_SF16 124 {vk::Format::eUndefined, false}, // BC6H_SF16
126 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_4X4 125 {vk::Format::eUndefined, false}, // ASTC_2D_4X4
127 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BGRA8 126 {vk::Format::eUndefined, false}, // BGRA8
128 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA32F 127 {vk::Format::eUndefined, false}, // RGBA32F
129 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG32F 128 {vk::Format::eUndefined, false}, // RG32F
130 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R32F 129 {vk::Format::eUndefined, false}, // R32F
131 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16F 130 {vk::Format::eUndefined, false}, // R16F
132 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16U 131 {vk::Format::eUndefined, false}, // R16U
133 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16S 132 {vk::Format::eUndefined, false}, // R16S
134 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16UI 133 {vk::Format::eUndefined, false}, // R16UI
135 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16I 134 {vk::Format::eUndefined, false}, // R16I
136 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16 135 {vk::Format::eUndefined, false}, // RG16
137 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16F 136 {vk::Format::eUndefined, false}, // RG16F
138 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16UI 137 {vk::Format::eUndefined, false}, // RG16UI
139 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16I 138 {vk::Format::eUndefined, false}, // RG16I
140 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16S 139 {vk::Format::eUndefined, false}, // RG16S
141 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGB32F 140 {vk::Format::eUndefined, false}, // RGB32F
142 {vk::Format::eA8B8G8R8SrgbPack32, ComponentType::UNorm, true}, // RGBA8_SRGB 141 {vk::Format::eA8B8G8R8SrgbPack32, true}, // RGBA8_SRGB
143 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG8U 142 {vk::Format::eUndefined, false}, // RG8U
144 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG8S 143 {vk::Format::eUndefined, false}, // RG8S
145 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG32UI 144 {vk::Format::eUndefined, false}, // RG32UI
146 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBX16F 145 {vk::Format::eUndefined, false}, // RGBX16F
147 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R32UI 146 {vk::Format::eUndefined, false}, // R32UI
148 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X8 147 {vk::Format::eUndefined, false}, // ASTC_2D_8X8
149 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X5 148 {vk::Format::eUndefined, false}, // ASTC_2D_8X5
150 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X4 149 {vk::Format::eUndefined, false}, // ASTC_2D_5X4
151 150
152 // Compressed sRGB formats 151 // Compressed sRGB formats
153 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BGRA8_SRGB 152 {vk::Format::eUndefined, false}, // BGRA8_SRGB
154 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXT1_SRGB 153 {vk::Format::eUndefined, false}, // DXT1_SRGB
155 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXT23_SRGB 154 {vk::Format::eUndefined, false}, // DXT23_SRGB
156 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXT45_SRGB 155 {vk::Format::eUndefined, false}, // DXT45_SRGB
157 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC7U_SRGB 156 {vk::Format::eUndefined, false}, // BC7U_SRGB
158 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_4X4_SRGB 157 {vk::Format::eUndefined, false}, // ASTC_2D_4X4_SRGB
159 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X8_SRGB 158 {vk::Format::eUndefined, false}, // ASTC_2D_8X8_SRGB
160 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X5_SRGB 159 {vk::Format::eUndefined, false}, // ASTC_2D_8X5_SRGB
161 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X4_SRGB 160 {vk::Format::eUndefined, false}, // ASTC_2D_5X4_SRGB
162 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X5 161 {vk::Format::eUndefined, false}, // ASTC_2D_5X5
163 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X5_SRGB 162 {vk::Format::eUndefined, false}, // ASTC_2D_5X5_SRGB
164 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_10X8 163 {vk::Format::eUndefined, false}, // ASTC_2D_10X8
165 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_10X8_SRGB 164 {vk::Format::eUndefined, false}, // ASTC_2D_10X8_SRGB
166 165
167 // Depth formats 166 // Depth formats
168 {vk::Format::eD32Sfloat, ComponentType::Float, true}, // Z32F 167 {vk::Format::eD32Sfloat, true}, // Z32F
169 {vk::Format::eD16Unorm, ComponentType::UNorm, true}, // Z16 168 {vk::Format::eD16Unorm, true}, // Z16
170 169
171 // DepthStencil formats 170 // DepthStencil formats
172 {vk::Format::eD24UnormS8Uint, ComponentType::UNorm, true}, // Z24S8 171 {vk::Format::eD24UnormS8Uint, true}, // Z24S8
173 {vk::Format::eD24UnormS8Uint, ComponentType::UNorm, true}, // S8Z24 (emulated) 172 {vk::Format::eD24UnormS8Uint, true}, // S8Z24 (emulated)
174 {vk::Format::eUndefined, ComponentType::Invalid, false}, // Z32FS8 173 {vk::Format::eUndefined, false}, // Z32FS8
175}}; 174}};
176 175
177static constexpr bool IsZetaFormat(PixelFormat pixel_format) { 176static constexpr bool IsZetaFormat(PixelFormat pixel_format) {
@@ -180,14 +179,13 @@ static constexpr bool IsZetaFormat(PixelFormat pixel_format) {
180} 179}
181 180
182std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type, 181std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type,
183 PixelFormat pixel_format, ComponentType component_type) { 182 PixelFormat pixel_format) {
184 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size()); 183 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size());
185 184
186 const auto tuple = tex_format_tuples[static_cast<u32>(pixel_format)]; 185 const auto tuple = tex_format_tuples[static_cast<u32>(pixel_format)];
187 UNIMPLEMENTED_IF_MSG(tuple.format == vk::Format::eUndefined, 186 UNIMPLEMENTED_IF_MSG(tuple.format == vk::Format::eUndefined,
188 "Unimplemented texture format with pixel format={} and component type={}", 187 "Unimplemented texture format with pixel format={}",
189 static_cast<u32>(pixel_format), static_cast<u32>(component_type)); 188 static_cast<u32>(pixel_format));
190 ASSERT_MSG(component_type == tuple.component_type, "Component type mismatch");
191 189
192 auto usage = vk::FormatFeatureFlagBits::eSampledImage | 190 auto usage = vk::FormatFeatureFlagBits::eSampledImage |
193 vk::FormatFeatureFlagBits::eTransferDst | vk::FormatFeatureFlagBits::eTransferSrc; 191 vk::FormatFeatureFlagBits::eTransferDst | vk::FormatFeatureFlagBits::eTransferSrc;
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.h b/src/video_core/renderer_vulkan/maxwell_to_vk.h
index 4cadc0721..5b0ffd87a 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.h
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.h
@@ -16,7 +16,6 @@ namespace Vulkan::MaxwellToVK {
16 16
17using Maxwell = Tegra::Engines::Maxwell3D::Regs; 17using Maxwell = Tegra::Engines::Maxwell3D::Regs;
18using PixelFormat = VideoCore::Surface::PixelFormat; 18using PixelFormat = VideoCore::Surface::PixelFormat;
19using ComponentType = VideoCore::Surface::ComponentType;
20 19
21namespace Sampler { 20namespace Sampler {
22 21
@@ -31,7 +30,7 @@ vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compar
31} // namespace Sampler 30} // namespace Sampler
32 31
33std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type, 32std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type,
34 PixelFormat pixel_format, ComponentType component_type); 33 PixelFormat pixel_format);
35 34
36vk::ShaderStageFlagBits ShaderStage(Maxwell::ShaderStage stage); 35vk::ShaderStageFlagBits ShaderStage(Maxwell::ShaderStage stage);
37 36
diff --git a/src/video_core/shader/decode/other.cpp b/src/video_core/shader/decode/other.cpp
index 116b95f76..17cd45d3c 100644
--- a/src/video_core/shader/decode/other.cpp
+++ b/src/video_core/shader/decode/other.cpp
@@ -256,7 +256,7 @@ u32 ShaderIR::DecodeOther(NodeBlock& bb, u32 pc) {
256 break; 256 break;
257 } 257 }
258 case OpCode::Id::DEPBAR: { 258 case OpCode::Id::DEPBAR: {
259 LOG_WARNING(HW_GPU, "DEPBAR instruction is stubbed"); 259 LOG_DEBUG(HW_GPU, "DEPBAR instruction is stubbed");
260 break; 260 break;
261 } 261 }
262 default: 262 default:
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index 4b6846113..1655ccf16 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -168,311 +168,6 @@ PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format)
168 } 168 }
169} 169}
170 170
171PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
172 Tegra::Texture::ComponentType component_type,
173 bool is_srgb) {
174 // TODO(Subv): Properly implement this
175 switch (format) {
176 case Tegra::Texture::TextureFormat::A8R8G8B8:
177 if (is_srgb) {
178 return PixelFormat::RGBA8_SRGB;
179 }
180 switch (component_type) {
181 case Tegra::Texture::ComponentType::UNORM:
182 return PixelFormat::ABGR8U;
183 case Tegra::Texture::ComponentType::SNORM:
184 return PixelFormat::ABGR8S;
185 case Tegra::Texture::ComponentType::UINT:
186 return PixelFormat::ABGR8UI;
187 default:
188 break;
189 }
190 break;
191 case Tegra::Texture::TextureFormat::B5G6R5:
192 switch (component_type) {
193 case Tegra::Texture::ComponentType::UNORM:
194 return PixelFormat::B5G6R5U;
195 default:
196 break;
197 }
198 break;
199 case Tegra::Texture::TextureFormat::A2B10G10R10:
200 switch (component_type) {
201 case Tegra::Texture::ComponentType::UNORM:
202 return PixelFormat::A2B10G10R10U;
203 default:
204 break;
205 }
206 break;
207 case Tegra::Texture::TextureFormat::A1B5G5R5:
208 switch (component_type) {
209 case Tegra::Texture::ComponentType::UNORM:
210 return PixelFormat::A1B5G5R5U;
211 default:
212 break;
213 }
214 break;
215 case Tegra::Texture::TextureFormat::A4B4G4R4:
216 switch (component_type) {
217 case Tegra::Texture::ComponentType::UNORM:
218 return PixelFormat::R4G4B4A4U;
219 default:
220 break;
221 }
222 break;
223 case Tegra::Texture::TextureFormat::R8:
224 switch (component_type) {
225 case Tegra::Texture::ComponentType::UNORM:
226 return PixelFormat::R8U;
227 case Tegra::Texture::ComponentType::UINT:
228 return PixelFormat::R8UI;
229 default:
230 break;
231 }
232 break;
233 case Tegra::Texture::TextureFormat::G8R8:
234 // TextureFormat::G8R8 is actually ordered red then green, as such we can use
235 // PixelFormat::RG8U and PixelFormat::RG8S. This was tested with The Legend of Zelda: Breath
236 // of the Wild, which uses this format to render the hearts on the UI.
237 switch (component_type) {
238 case Tegra::Texture::ComponentType::UNORM:
239 return PixelFormat::RG8U;
240 case Tegra::Texture::ComponentType::SNORM:
241 return PixelFormat::RG8S;
242 default:
243 break;
244 }
245 break;
246 case Tegra::Texture::TextureFormat::R16_G16_B16_A16:
247 switch (component_type) {
248 case Tegra::Texture::ComponentType::UNORM:
249 return PixelFormat::RGBA16U;
250 case Tegra::Texture::ComponentType::FLOAT:
251 return PixelFormat::RGBA16F;
252 case Tegra::Texture::ComponentType::UINT:
253 return PixelFormat::RGBA16UI;
254 default:
255 break;
256 }
257 break;
258 case Tegra::Texture::TextureFormat::BF10GF11RF11:
259 switch (component_type) {
260 case Tegra::Texture::ComponentType::FLOAT:
261 return PixelFormat::R11FG11FB10F;
262 default:
263 break;
264 }
265 break;
266 case Tegra::Texture::TextureFormat::R32_G32_B32_A32:
267 switch (component_type) {
268 case Tegra::Texture::ComponentType::FLOAT:
269 return PixelFormat::RGBA32F;
270 case Tegra::Texture::ComponentType::UINT:
271 return PixelFormat::RGBA32UI;
272 default:
273 break;
274 }
275 break;
276 case Tegra::Texture::TextureFormat::R32_G32:
277 switch (component_type) {
278 case Tegra::Texture::ComponentType::FLOAT:
279 return PixelFormat::RG32F;
280 case Tegra::Texture::ComponentType::UINT:
281 return PixelFormat::RG32UI;
282 default:
283 break;
284 }
285 break;
286 case Tegra::Texture::TextureFormat::R32_G32_B32:
287 switch (component_type) {
288 case Tegra::Texture::ComponentType::FLOAT:
289 return PixelFormat::RGB32F;
290 default:
291 break;
292 }
293 break;
294 case Tegra::Texture::TextureFormat::R16:
295 switch (component_type) {
296 case Tegra::Texture::ComponentType::FLOAT:
297 return PixelFormat::R16F;
298 case Tegra::Texture::ComponentType::UNORM:
299 return PixelFormat::R16U;
300 case Tegra::Texture::ComponentType::SNORM:
301 return PixelFormat::R16S;
302 case Tegra::Texture::ComponentType::UINT:
303 return PixelFormat::R16UI;
304 case Tegra::Texture::ComponentType::SINT:
305 return PixelFormat::R16I;
306 default:
307 break;
308 }
309 break;
310 case Tegra::Texture::TextureFormat::R32:
311 switch (component_type) {
312 case Tegra::Texture::ComponentType::FLOAT:
313 return PixelFormat::R32F;
314 case Tegra::Texture::ComponentType::UINT:
315 return PixelFormat::R32UI;
316 default:
317 break;
318 }
319 break;
320 case Tegra::Texture::TextureFormat::E5B9G9R9_SHAREDEXP:
321 switch (component_type) {
322 case Tegra::Texture::ComponentType::FLOAT:
323 return PixelFormat::E5B9G9R9F;
324 default:
325 break;
326 }
327 break;
328 case Tegra::Texture::TextureFormat::ZF32:
329 return PixelFormat::Z32F;
330 case Tegra::Texture::TextureFormat::Z16:
331 return PixelFormat::Z16;
332 case Tegra::Texture::TextureFormat::S8Z24:
333 return PixelFormat::S8Z24;
334 case Tegra::Texture::TextureFormat::ZF32_X24S8:
335 return PixelFormat::Z32FS8;
336 case Tegra::Texture::TextureFormat::DXT1:
337 return is_srgb ? PixelFormat::DXT1_SRGB : PixelFormat::DXT1;
338 case Tegra::Texture::TextureFormat::DXT23:
339 return is_srgb ? PixelFormat::DXT23_SRGB : PixelFormat::DXT23;
340 case Tegra::Texture::TextureFormat::DXT45:
341 return is_srgb ? PixelFormat::DXT45_SRGB : PixelFormat::DXT45;
342 case Tegra::Texture::TextureFormat::DXN1:
343 return PixelFormat::DXN1;
344 case Tegra::Texture::TextureFormat::DXN2:
345 switch (component_type) {
346 case Tegra::Texture::ComponentType::UNORM:
347 return PixelFormat::DXN2UNORM;
348 case Tegra::Texture::ComponentType::SNORM:
349 return PixelFormat::DXN2SNORM;
350 default:
351 break;
352 }
353 break;
354 case Tegra::Texture::TextureFormat::BC7U:
355 return is_srgb ? PixelFormat::BC7U_SRGB : PixelFormat::BC7U;
356 case Tegra::Texture::TextureFormat::BC6H_UF16:
357 return PixelFormat::BC6H_UF16;
358 case Tegra::Texture::TextureFormat::BC6H_SF16:
359 return PixelFormat::BC6H_SF16;
360 case Tegra::Texture::TextureFormat::ASTC_2D_4X4:
361 return is_srgb ? PixelFormat::ASTC_2D_4X4_SRGB : PixelFormat::ASTC_2D_4X4;
362 case Tegra::Texture::TextureFormat::ASTC_2D_5X4:
363 return is_srgb ? PixelFormat::ASTC_2D_5X4_SRGB : PixelFormat::ASTC_2D_5X4;
364 case Tegra::Texture::TextureFormat::ASTC_2D_5X5:
365 return is_srgb ? PixelFormat::ASTC_2D_5X5_SRGB : PixelFormat::ASTC_2D_5X5;
366 case Tegra::Texture::TextureFormat::ASTC_2D_8X8:
367 return is_srgb ? PixelFormat::ASTC_2D_8X8_SRGB : PixelFormat::ASTC_2D_8X8;
368 case Tegra::Texture::TextureFormat::ASTC_2D_8X5:
369 return is_srgb ? PixelFormat::ASTC_2D_8X5_SRGB : PixelFormat::ASTC_2D_8X5;
370 case Tegra::Texture::TextureFormat::ASTC_2D_10X8:
371 return is_srgb ? PixelFormat::ASTC_2D_10X8_SRGB : PixelFormat::ASTC_2D_10X8;
372 case Tegra::Texture::TextureFormat::ASTC_2D_6X6:
373 return is_srgb ? PixelFormat::ASTC_2D_6X6_SRGB : PixelFormat::ASTC_2D_6X6;
374 case Tegra::Texture::TextureFormat::ASTC_2D_10X10:
375 return is_srgb ? PixelFormat::ASTC_2D_10X10_SRGB : PixelFormat::ASTC_2D_10X10;
376 case Tegra::Texture::TextureFormat::ASTC_2D_12X12:
377 return is_srgb ? PixelFormat::ASTC_2D_12X12_SRGB : PixelFormat::ASTC_2D_12X12;
378 case Tegra::Texture::TextureFormat::ASTC_2D_8X6:
379 return is_srgb ? PixelFormat::ASTC_2D_8X6_SRGB : PixelFormat::ASTC_2D_8X6;
380 case Tegra::Texture::TextureFormat::ASTC_2D_6X5:
381 return is_srgb ? PixelFormat::ASTC_2D_6X5_SRGB : PixelFormat::ASTC_2D_6X5;
382 case Tegra::Texture::TextureFormat::R16_G16:
383 switch (component_type) {
384 case Tegra::Texture::ComponentType::FLOAT:
385 return PixelFormat::RG16F;
386 case Tegra::Texture::ComponentType::UNORM:
387 return PixelFormat::RG16;
388 case Tegra::Texture::ComponentType::SNORM:
389 return PixelFormat::RG16S;
390 case Tegra::Texture::ComponentType::UINT:
391 return PixelFormat::RG16UI;
392 case Tegra::Texture::ComponentType::SINT:
393 return PixelFormat::RG16I;
394 default:
395 break;
396 }
397 break;
398 default:
399 break;
400 }
401 LOG_CRITICAL(HW_GPU, "Unimplemented format={}, component_type={}", static_cast<u32>(format),
402 static_cast<u32>(component_type));
403 UNREACHABLE();
404 return PixelFormat::ABGR8U;
405}
406
407ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) {
408 // TODO(Subv): Implement more component types
409 switch (type) {
410 case Tegra::Texture::ComponentType::UNORM:
411 return ComponentType::UNorm;
412 case Tegra::Texture::ComponentType::FLOAT:
413 return ComponentType::Float;
414 case Tegra::Texture::ComponentType::SNORM:
415 return ComponentType::SNorm;
416 case Tegra::Texture::ComponentType::UINT:
417 return ComponentType::UInt;
418 case Tegra::Texture::ComponentType::SINT:
419 return ComponentType::SInt;
420 default:
421 LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type));
422 UNREACHABLE();
423 return ComponentType::UNorm;
424 }
425}
426
427ComponentType ComponentTypeFromRenderTarget(Tegra::RenderTargetFormat format) {
428 // TODO(Subv): Implement more render targets
429 switch (format) {
430 case Tegra::RenderTargetFormat::RGBA8_UNORM:
431 case Tegra::RenderTargetFormat::RGBA8_SRGB:
432 case Tegra::RenderTargetFormat::BGRA8_UNORM:
433 case Tegra::RenderTargetFormat::BGRA8_SRGB:
434 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
435 case Tegra::RenderTargetFormat::R8_UNORM:
436 case Tegra::RenderTargetFormat::RG16_UNORM:
437 case Tegra::RenderTargetFormat::R16_UNORM:
438 case Tegra::RenderTargetFormat::B5G6R5_UNORM:
439 case Tegra::RenderTargetFormat::BGR5A1_UNORM:
440 case Tegra::RenderTargetFormat::RG8_UNORM:
441 case Tegra::RenderTargetFormat::RGBA16_UNORM:
442 return ComponentType::UNorm;
443 case Tegra::RenderTargetFormat::RGBA8_SNORM:
444 case Tegra::RenderTargetFormat::RG16_SNORM:
445 case Tegra::RenderTargetFormat::R16_SNORM:
446 case Tegra::RenderTargetFormat::RG8_SNORM:
447 return ComponentType::SNorm;
448 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
449 case Tegra::RenderTargetFormat::RGBX16_FLOAT:
450 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
451 case Tegra::RenderTargetFormat::RGBA32_FLOAT:
452 case Tegra::RenderTargetFormat::RG32_FLOAT:
453 case Tegra::RenderTargetFormat::RG16_FLOAT:
454 case Tegra::RenderTargetFormat::R16_FLOAT:
455 case Tegra::RenderTargetFormat::R32_FLOAT:
456 return ComponentType::Float;
457 case Tegra::RenderTargetFormat::RGBA32_UINT:
458 case Tegra::RenderTargetFormat::RGBA16_UINT:
459 case Tegra::RenderTargetFormat::RG16_UINT:
460 case Tegra::RenderTargetFormat::R8_UINT:
461 case Tegra::RenderTargetFormat::R16_UINT:
462 case Tegra::RenderTargetFormat::RG32_UINT:
463 case Tegra::RenderTargetFormat::R32_UINT:
464 case Tegra::RenderTargetFormat::RGBA8_UINT:
465 return ComponentType::UInt;
466 case Tegra::RenderTargetFormat::RG16_SINT:
467 case Tegra::RenderTargetFormat::R16_SINT:
468 return ComponentType::SInt;
469 default:
470 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
471 UNREACHABLE();
472 return ComponentType::UNorm;
473 }
474}
475
476PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { 171PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) {
477 switch (format) { 172 switch (format) {
478 case Tegra::FramebufferConfig::PixelFormat::ABGR8: 173 case Tegra::FramebufferConfig::PixelFormat::ABGR8:
@@ -487,22 +182,6 @@ PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat
487 } 182 }
488} 183}
489 184
490ComponentType ComponentTypeFromDepthFormat(Tegra::DepthFormat format) {
491 switch (format) {
492 case Tegra::DepthFormat::Z16_UNORM:
493 case Tegra::DepthFormat::S8_Z24_UNORM:
494 case Tegra::DepthFormat::Z24_S8_UNORM:
495 return ComponentType::UNorm;
496 case Tegra::DepthFormat::Z32_FLOAT:
497 case Tegra::DepthFormat::Z32_S8_X24_FLOAT:
498 return ComponentType::Float;
499 default:
500 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
501 UNREACHABLE();
502 return ComponentType::UNorm;
503 }
504}
505
506SurfaceType GetFormatType(PixelFormat pixel_format) { 185SurfaceType GetFormatType(PixelFormat pixel_format) {
507 if (static_cast<std::size_t>(pixel_format) < 186 if (static_cast<std::size_t>(pixel_format) <
508 static_cast<std::size_t>(PixelFormat::MaxColorFormat)) { 187 static_cast<std::size_t>(PixelFormat::MaxColorFormat)) {
diff --git a/src/video_core/surface.h b/src/video_core/surface.h
index d3bcd38c5..0d17a93ed 100644
--- a/src/video_core/surface.h
+++ b/src/video_core/surface.h
@@ -106,18 +106,8 @@ enum class PixelFormat {
106 Max = MaxDepthStencilFormat, 106 Max = MaxDepthStencilFormat,
107 Invalid = 255, 107 Invalid = 255,
108}; 108};
109
110static constexpr std::size_t MaxPixelFormat = static_cast<std::size_t>(PixelFormat::Max); 109static constexpr std::size_t MaxPixelFormat = static_cast<std::size_t>(PixelFormat::Max);
111 110
112enum class ComponentType {
113 Invalid = 0,
114 SNorm = 1,
115 UNorm = 2,
116 SInt = 3,
117 UInt = 4,
118 Float = 5,
119};
120
121enum class SurfaceType { 111enum class SurfaceType {
122 ColorTexture = 0, 112 ColorTexture = 0,
123 Depth = 1, 113 Depth = 1,
@@ -609,18 +599,8 @@ PixelFormat PixelFormatFromDepthFormat(Tegra::DepthFormat format);
609 599
610PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format); 600PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format);
611 601
612PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
613 Tegra::Texture::ComponentType component_type,
614 bool is_srgb);
615
616ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type);
617
618ComponentType ComponentTypeFromRenderTarget(Tegra::RenderTargetFormat format);
619
620PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format); 602PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format);
621 603
622ComponentType ComponentTypeFromDepthFormat(Tegra::DepthFormat format);
623
624SurfaceType GetFormatType(PixelFormat pixel_format); 604SurfaceType GetFormatType(PixelFormat pixel_format);
625 605
626bool IsPixelFormatASTC(PixelFormat format); 606bool IsPixelFormatASTC(PixelFormat format);
diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp
new file mode 100644
index 000000000..271e67533
--- /dev/null
+++ b/src/video_core/texture_cache/format_lookup_table.cpp
@@ -0,0 +1,208 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <array>
6#include "common/common_types.h"
7#include "common/logging/log.h"
8#include "video_core/texture_cache/format_lookup_table.h"
9
10namespace VideoCommon {
11
12using Tegra::Texture::ComponentType;
13using Tegra::Texture::TextureFormat;
14using VideoCore::Surface::PixelFormat;
15
16namespace {
17
18constexpr auto SNORM = ComponentType::SNORM;
19constexpr auto UNORM = ComponentType::UNORM;
20constexpr auto SINT = ComponentType::SINT;
21constexpr auto UINT = ComponentType::UINT;
22constexpr auto SNORM_FORCE_FP16 = ComponentType::SNORM_FORCE_FP16;
23constexpr auto UNORM_FORCE_FP16 = ComponentType::UNORM_FORCE_FP16;
24constexpr auto FLOAT = ComponentType::FLOAT;
25constexpr bool C = false; // Normal color
26constexpr bool S = true; // Srgb
27
28struct Table {
29 constexpr Table(TextureFormat texture_format, bool is_srgb, ComponentType red_component,
30 ComponentType green_component, ComponentType blue_component,
31 ComponentType alpha_component, PixelFormat pixel_format)
32 : texture_format{texture_format}, pixel_format{pixel_format}, red_component{red_component},
33 green_component{green_component}, blue_component{blue_component},
34 alpha_component{alpha_component}, is_srgb{is_srgb} {}
35
36 TextureFormat texture_format;
37 PixelFormat pixel_format;
38 ComponentType red_component;
39 ComponentType green_component;
40 ComponentType blue_component;
41 ComponentType alpha_component;
42 bool is_srgb;
43};
44constexpr std::array<Table, 74> DefinitionTable = {{
45 {TextureFormat::A8R8G8B8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ABGR8U},
46 {TextureFormat::A8R8G8B8, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::ABGR8S},
47 {TextureFormat::A8R8G8B8, C, UINT, UINT, UINT, UINT, PixelFormat::ABGR8UI},
48 {TextureFormat::A8R8G8B8, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::RGBA8_SRGB},
49
50 {TextureFormat::B5G6R5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::B5G6R5U},
51
52 {TextureFormat::A2B10G10R10, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::A2B10G10R10U},
53
54 {TextureFormat::A1B5G5R5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::A1B5G5R5U},
55
56 {TextureFormat::A4B4G4R4, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::R4G4B4A4U},
57
58 {TextureFormat::R8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::R8U},
59 {TextureFormat::R8, C, UINT, UINT, UINT, UINT, PixelFormat::R8UI},
60
61 {TextureFormat::G8R8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::RG8U},
62 {TextureFormat::G8R8, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::RG8S},
63
64 {TextureFormat::R16_G16_B16_A16, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::RGBA16U},
65 {TextureFormat::R16_G16_B16_A16, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::RGBA16F},
66 {TextureFormat::R16_G16_B16_A16, C, UINT, UINT, UINT, UINT, PixelFormat::RGBA16UI},
67
68 {TextureFormat::R16_G16, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::RG16F},
69 {TextureFormat::R16_G16, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::RG16},
70 {TextureFormat::R16_G16, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::RG16S},
71 {TextureFormat::R16_G16, C, UINT, UINT, UINT, UINT, PixelFormat::RG16UI},
72 {TextureFormat::R16_G16, C, SINT, SINT, SINT, SINT, PixelFormat::RG16I},
73
74 {TextureFormat::R16, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::R16F},
75 {TextureFormat::R16, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::R16U},
76 {TextureFormat::R16, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::R16S},
77 {TextureFormat::R16, C, UINT, UINT, UINT, UINT, PixelFormat::R16UI},
78 {TextureFormat::R16, C, SINT, SINT, SINT, SINT, PixelFormat::R16I},
79
80 {TextureFormat::BF10GF11RF11, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::R11FG11FB10F},
81
82 {TextureFormat::R32_G32_B32_A32, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::RGBA32F},
83 {TextureFormat::R32_G32_B32_A32, C, UINT, UINT, UINT, UINT, PixelFormat::RGBA32UI},
84
85 {TextureFormat::R32_G32_B32, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::RGB32F},
86
87 {TextureFormat::R32_G32, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::RG32F},
88 {TextureFormat::R32_G32, C, UINT, UINT, UINT, UINT, PixelFormat::RG32UI},
89
90 {TextureFormat::R32, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::R32F},
91 {TextureFormat::R32, C, UINT, UINT, UINT, UINT, PixelFormat::R32UI},
92
93 {TextureFormat::E5B9G9R9_SHAREDEXP, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::E5B9G9R9F},
94
95 {TextureFormat::ZF32, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::Z32F},
96 {TextureFormat::Z16, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::Z16},
97 {TextureFormat::S8Z24, C, UINT, UNORM, UNORM, UNORM, PixelFormat::S8Z24},
98 {TextureFormat::ZF32_X24S8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::Z32FS8},
99
100 {TextureFormat::DXT1, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT1},
101 {TextureFormat::DXT1, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT1_SRGB},
102
103 {TextureFormat::DXT23, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT23},
104 {TextureFormat::DXT23, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT23_SRGB},
105
106 {TextureFormat::DXT45, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45},
107 {TextureFormat::DXT45, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXT45_SRGB},
108
109 // TODO: Use a different pixel format for SNORM
110 {TextureFormat::DXN1, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN1},
111 {TextureFormat::DXN1, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN1},
112
113 {TextureFormat::DXN2, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::DXN2UNORM},
114 {TextureFormat::DXN2, C, SNORM, SNORM, SNORM, SNORM, PixelFormat::DXN2SNORM},
115
116 {TextureFormat::BC7U, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::BC7U},
117 {TextureFormat::BC7U, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::BC7U_SRGB},
118
119 {TextureFormat::BC6H_SF16, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::BC6H_SF16},
120 {TextureFormat::BC6H_UF16, C, FLOAT, FLOAT, FLOAT, FLOAT, PixelFormat::BC6H_UF16},
121
122 {TextureFormat::ASTC_2D_4X4, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_4X4},
123 {TextureFormat::ASTC_2D_4X4, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_4X4_SRGB},
124
125 {TextureFormat::ASTC_2D_5X4, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_5X4},
126 {TextureFormat::ASTC_2D_5X4, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_5X4_SRGB},
127
128 {TextureFormat::ASTC_2D_5X5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_5X5},
129 {TextureFormat::ASTC_2D_5X5, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_5X5_SRGB},
130
131 {TextureFormat::ASTC_2D_8X8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_8X8},
132 {TextureFormat::ASTC_2D_8X8, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_8X8_SRGB},
133
134 {TextureFormat::ASTC_2D_8X5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_8X5},
135 {TextureFormat::ASTC_2D_8X5, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_8X5_SRGB},
136
137 {TextureFormat::ASTC_2D_10X8, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_10X8},
138 {TextureFormat::ASTC_2D_10X8, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_10X8_SRGB},
139
140 {TextureFormat::ASTC_2D_6X6, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_6X6},
141 {TextureFormat::ASTC_2D_6X6, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_6X6_SRGB},
142
143 {TextureFormat::ASTC_2D_10X10, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_10X10},
144 {TextureFormat::ASTC_2D_10X10, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_10X10_SRGB},
145
146 {TextureFormat::ASTC_2D_12X12, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_12X12},
147 {TextureFormat::ASTC_2D_12X12, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_12X12_SRGB},
148
149 {TextureFormat::ASTC_2D_8X6, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_8X6},
150 {TextureFormat::ASTC_2D_8X6, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_8X6_SRGB},
151
152 {TextureFormat::ASTC_2D_6X5, C, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_6X5},
153 {TextureFormat::ASTC_2D_6X5, S, UNORM, UNORM, UNORM, UNORM, PixelFormat::ASTC_2D_6X5_SRGB},
154}};
155
156} // Anonymous namespace
157
158FormatLookupTable::FormatLookupTable() {
159 table.fill(static_cast<u8>(PixelFormat::Invalid));
160
161 for (const auto& entry : DefinitionTable) {
162 table[CalculateIndex(entry.texture_format, entry.is_srgb != 0, entry.red_component,
163 entry.green_component, entry.blue_component, entry.alpha_component)] =
164 static_cast<u8>(entry.pixel_format);
165 }
166}
167
168PixelFormat FormatLookupTable::GetPixelFormat(TextureFormat format, bool is_srgb,
169 ComponentType red_component,
170 ComponentType green_component,
171 ComponentType blue_component,
172 ComponentType alpha_component) const noexcept {
173 const auto pixel_format = static_cast<PixelFormat>(table[CalculateIndex(
174 format, is_srgb, red_component, green_component, blue_component, alpha_component)]);
175 // [[likely]]
176 if (pixel_format != PixelFormat::Invalid) {
177 return pixel_format;
178 }
179 UNIMPLEMENTED_MSG("texture format={} srgb={} components={{{} {} {} {}}}",
180 static_cast<int>(format), is_srgb, static_cast<int>(red_component),
181 static_cast<int>(green_component), static_cast<int>(blue_component),
182 static_cast<int>(alpha_component));
183 return PixelFormat::ABGR8U;
184}
185
186void FormatLookupTable::Set(TextureFormat format, bool is_srgb, ComponentType red_component,
187 ComponentType green_component, ComponentType blue_component,
188 ComponentType alpha_component, PixelFormat pixel_format) {}
189
190std::size_t FormatLookupTable::CalculateIndex(TextureFormat format, bool is_srgb,
191 ComponentType red_component,
192 ComponentType green_component,
193 ComponentType blue_component,
194 ComponentType alpha_component) noexcept {
195 const auto format_index = static_cast<std::size_t>(format);
196 const auto red_index = static_cast<std::size_t>(red_component);
197 const auto green_index = static_cast<std::size_t>(red_component);
198 const auto blue_index = static_cast<std::size_t>(red_component);
199 const auto alpha_index = static_cast<std::size_t>(red_component);
200 const std::size_t srgb_index = is_srgb ? 1 : 0;
201
202 return format_index * PerFormat +
203 srgb_index * PerComponent * PerComponent * PerComponent * PerComponent +
204 alpha_index * PerComponent * PerComponent * PerComponent +
205 blue_index * PerComponent * PerComponent + green_index * PerComponent + red_index;
206}
207
208} // namespace VideoCommon
diff --git a/src/video_core/texture_cache/format_lookup_table.h b/src/video_core/texture_cache/format_lookup_table.h
new file mode 100644
index 000000000..aa77e0a5a
--- /dev/null
+++ b/src/video_core/texture_cache/format_lookup_table.h
@@ -0,0 +1,51 @@
1// Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <array>
8#include <limits>
9#include "video_core/surface.h"
10#include "video_core/textures/texture.h"
11
12namespace VideoCommon {
13
14class FormatLookupTable {
15public:
16 explicit FormatLookupTable();
17
18 VideoCore::Surface::PixelFormat GetPixelFormat(
19 Tegra::Texture::TextureFormat format, bool is_srgb,
20 Tegra::Texture::ComponentType red_component, Tegra::Texture::ComponentType green_component,
21 Tegra::Texture::ComponentType blue_component,
22 Tegra::Texture::ComponentType alpha_component) const noexcept;
23
24private:
25 static_assert(VideoCore::Surface::MaxPixelFormat <= std::numeric_limits<u8>::max());
26
27 static constexpr std::size_t NumTextureFormats = 128;
28
29 static constexpr std::size_t PerComponent = 8;
30 static constexpr std::size_t PerComponents2 = PerComponent * PerComponent;
31 static constexpr std::size_t PerComponents3 = PerComponents2 * PerComponent;
32 static constexpr std::size_t PerComponents4 = PerComponents3 * PerComponent;
33 static constexpr std::size_t PerFormat = PerComponents4 * 2;
34
35 static std::size_t CalculateIndex(Tegra::Texture::TextureFormat format, bool is_srgb,
36 Tegra::Texture::ComponentType red_component,
37 Tegra::Texture::ComponentType green_component,
38 Tegra::Texture::ComponentType blue_component,
39 Tegra::Texture::ComponentType alpha_component) noexcept;
40
41 void Set(Tegra::Texture::TextureFormat format, bool is_srgb,
42 Tegra::Texture::ComponentType red_component,
43 Tegra::Texture::ComponentType green_component,
44 Tegra::Texture::ComponentType blue_component,
45 Tegra::Texture::ComponentType alpha_component,
46 VideoCore::Surface::PixelFormat pixel_format);
47
48 std::array<u8, NumTextureFormats * PerFormat> table;
49};
50
51} // namespace VideoCommon
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index 1e4d3fb79..858e17e08 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -2,24 +2,23 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <map> 5#include <algorithm>
6#include <string>
7#include <tuple>
6 8
7#include "common/alignment.h" 9#include "common/alignment.h"
8#include "common/bit_util.h" 10#include "common/bit_util.h"
9#include "core/core.h" 11#include "core/core.h"
10#include "video_core/engines/shader_bytecode.h" 12#include "video_core/engines/shader_bytecode.h"
11#include "video_core/surface.h" 13#include "video_core/surface.h"
14#include "video_core/texture_cache/format_lookup_table.h"
12#include "video_core/texture_cache/surface_params.h" 15#include "video_core/texture_cache/surface_params.h"
13 16
14namespace VideoCommon { 17namespace VideoCommon {
15 18
16using VideoCore::Surface::ComponentTypeFromDepthFormat;
17using VideoCore::Surface::ComponentTypeFromRenderTarget;
18using VideoCore::Surface::ComponentTypeFromTexture;
19using VideoCore::Surface::PixelFormat; 19using VideoCore::Surface::PixelFormat;
20using VideoCore::Surface::PixelFormatFromDepthFormat; 20using VideoCore::Surface::PixelFormatFromDepthFormat;
21using VideoCore::Surface::PixelFormatFromRenderTargetFormat; 21using VideoCore::Surface::PixelFormatFromRenderTargetFormat;
22using VideoCore::Surface::PixelFormatFromTextureFormat;
23using VideoCore::Surface::SurfaceTarget; 22using VideoCore::Surface::SurfaceTarget;
24using VideoCore::Surface::SurfaceTargetFromTextureType; 23using VideoCore::Surface::SurfaceTargetFromTextureType;
25using VideoCore::Surface::SurfaceType; 24using VideoCore::Surface::SurfaceType;
@@ -69,7 +68,8 @@ constexpr u32 GetMipmapSize(bool uncompressed, u32 mip_size, u32 tile) {
69 68
70} // Anonymous namespace 69} // Anonymous namespace
71 70
72SurfaceParams SurfaceParams::CreateForTexture(const Tegra::Texture::TICEntry& tic, 71SurfaceParams SurfaceParams::CreateForTexture(const FormatLookupTable& lookup_table,
72 const Tegra::Texture::TICEntry& tic,
73 const VideoCommon::Shader::Sampler& entry) { 73 const VideoCommon::Shader::Sampler& entry) {
74 SurfaceParams params; 74 SurfaceParams params;
75 params.is_tiled = tic.IsTiled(); 75 params.is_tiled = tic.IsTiled();
@@ -78,8 +78,8 @@ SurfaceParams SurfaceParams::CreateForTexture(const Tegra::Texture::TICEntry& ti
78 params.block_height = params.is_tiled ? tic.BlockHeight() : 0, 78 params.block_height = params.is_tiled ? tic.BlockHeight() : 0,
79 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0, 79 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0,
80 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1; 80 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1;
81 params.pixel_format = 81 params.pixel_format = lookup_table.GetPixelFormat(
82 PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion); 82 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type);
83 params.type = GetFormatType(params.pixel_format); 83 params.type = GetFormatType(params.pixel_format);
84 if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) { 84 if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) {
85 switch (params.pixel_format) { 85 switch (params.pixel_format) {
@@ -99,7 +99,6 @@ SurfaceParams SurfaceParams::CreateForTexture(const Tegra::Texture::TICEntry& ti
99 } 99 }
100 params.type = GetFormatType(params.pixel_format); 100 params.type = GetFormatType(params.pixel_format);
101 } 101 }
102 params.component_type = ComponentTypeFromTexture(tic.r_type.Value());
103 params.type = GetFormatType(params.pixel_format); 102 params.type = GetFormatType(params.pixel_format);
104 // TODO: on 1DBuffer we should use the tic info. 103 // TODO: on 1DBuffer we should use the tic info.
105 if (tic.IsBuffer()) { 104 if (tic.IsBuffer()) {
@@ -128,7 +127,8 @@ SurfaceParams SurfaceParams::CreateForTexture(const Tegra::Texture::TICEntry& ti
128 return params; 127 return params;
129} 128}
130 129
131SurfaceParams SurfaceParams::CreateForImage(const Tegra::Texture::TICEntry& tic, 130SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_table,
131 const Tegra::Texture::TICEntry& tic,
132 const VideoCommon::Shader::Image& entry) { 132 const VideoCommon::Shader::Image& entry) {
133 SurfaceParams params; 133 SurfaceParams params;
134 params.is_tiled = tic.IsTiled(); 134 params.is_tiled = tic.IsTiled();
@@ -137,10 +137,9 @@ SurfaceParams SurfaceParams::CreateForImage(const Tegra::Texture::TICEntry& tic,
137 params.block_height = params.is_tiled ? tic.BlockHeight() : 0, 137 params.block_height = params.is_tiled ? tic.BlockHeight() : 0,
138 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0, 138 params.block_depth = params.is_tiled ? tic.BlockDepth() : 0,
139 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1; 139 params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1;
140 params.pixel_format = 140 params.pixel_format = lookup_table.GetPixelFormat(
141 PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion); 141 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type);
142 params.type = GetFormatType(params.pixel_format); 142 params.type = GetFormatType(params.pixel_format);
143 params.component_type = ComponentTypeFromTexture(tic.r_type.Value());
144 params.type = GetFormatType(params.pixel_format); 143 params.type = GetFormatType(params.pixel_format);
145 params.target = ImageTypeToSurfaceTarget(entry.GetType()); 144 params.target = ImageTypeToSurfaceTarget(entry.GetType());
146 // TODO: on 1DBuffer we should use the tic info. 145 // TODO: on 1DBuffer we should use the tic info.
@@ -181,7 +180,6 @@ SurfaceParams SurfaceParams::CreateForDepthBuffer(
181 params.block_depth = std::min(block_depth, 5U); 180 params.block_depth = std::min(block_depth, 5U);
182 params.tile_width_spacing = 1; 181 params.tile_width_spacing = 1;
183 params.pixel_format = PixelFormatFromDepthFormat(format); 182 params.pixel_format = PixelFormatFromDepthFormat(format);
184 params.component_type = ComponentTypeFromDepthFormat(format);
185 params.type = GetFormatType(params.pixel_format); 183 params.type = GetFormatType(params.pixel_format);
186 params.width = zeta_width; 184 params.width = zeta_width;
187 params.height = zeta_height; 185 params.height = zeta_height;
@@ -206,7 +204,6 @@ SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::siz
206 params.block_depth = config.memory_layout.block_depth; 204 params.block_depth = config.memory_layout.block_depth;
207 params.tile_width_spacing = 1; 205 params.tile_width_spacing = 1;
208 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 206 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format);
209 params.component_type = ComponentTypeFromRenderTarget(config.format);
210 params.type = GetFormatType(params.pixel_format); 207 params.type = GetFormatType(params.pixel_format);
211 if (params.is_tiled) { 208 if (params.is_tiled) {
212 params.pitch = 0; 209 params.pitch = 0;
@@ -236,7 +233,6 @@ SurfaceParams SurfaceParams::CreateForFermiCopySurface(
236 params.block_depth = params.is_tiled ? std::min(config.BlockDepth(), 5U) : 0, 233 params.block_depth = params.is_tiled ? std::min(config.BlockDepth(), 5U) : 0,
237 params.tile_width_spacing = 1; 234 params.tile_width_spacing = 1;
238 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 235 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format);
239 params.component_type = ComponentTypeFromRenderTarget(config.format);
240 params.type = GetFormatType(params.pixel_format); 236 params.type = GetFormatType(params.pixel_format);
241 params.width = config.width; 237 params.width = config.width;
242 params.height = config.height; 238 params.height = config.height;
@@ -355,10 +351,10 @@ std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size
355 351
356bool SurfaceParams::operator==(const SurfaceParams& rhs) const { 352bool SurfaceParams::operator==(const SurfaceParams& rhs) const {
357 return std::tie(is_tiled, block_width, block_height, block_depth, tile_width_spacing, width, 353 return std::tie(is_tiled, block_width, block_height, block_depth, tile_width_spacing, width,
358 height, depth, pitch, num_levels, pixel_format, component_type, type, target) == 354 height, depth, pitch, num_levels, pixel_format, type, target) ==
359 std::tie(rhs.is_tiled, rhs.block_width, rhs.block_height, rhs.block_depth, 355 std::tie(rhs.is_tiled, rhs.block_width, rhs.block_height, rhs.block_depth,
360 rhs.tile_width_spacing, rhs.width, rhs.height, rhs.depth, rhs.pitch, 356 rhs.tile_width_spacing, rhs.width, rhs.height, rhs.depth, rhs.pitch,
361 rhs.num_levels, rhs.pixel_format, rhs.component_type, rhs.type, rhs.target); 357 rhs.num_levels, rhs.pixel_format, rhs.type, rhs.target);
362} 358}
363 359
364std::string SurfaceParams::TargetName() const { 360std::string SurfaceParams::TargetName() const {
diff --git a/src/video_core/texture_cache/surface_params.h b/src/video_core/texture_cache/surface_params.h
index c58e7f8a4..709aa0dc2 100644
--- a/src/video_core/texture_cache/surface_params.h
+++ b/src/video_core/texture_cache/surface_params.h
@@ -16,16 +16,20 @@
16 16
17namespace VideoCommon { 17namespace VideoCommon {
18 18
19class FormatLookupTable;
20
19using VideoCore::Surface::SurfaceCompression; 21using VideoCore::Surface::SurfaceCompression;
20 22
21class SurfaceParams { 23class SurfaceParams {
22public: 24public:
23 /// Creates SurfaceCachedParams from a texture configuration. 25 /// Creates SurfaceCachedParams from a texture configuration.
24 static SurfaceParams CreateForTexture(const Tegra::Texture::TICEntry& tic, 26 static SurfaceParams CreateForTexture(const FormatLookupTable& lookup_table,
27 const Tegra::Texture::TICEntry& tic,
25 const VideoCommon::Shader::Sampler& entry); 28 const VideoCommon::Shader::Sampler& entry);
26 29
27 /// Creates SurfaceCachedParams from an image configuration. 30 /// Creates SurfaceCachedParams from an image configuration.
28 static SurfaceParams CreateForImage(const Tegra::Texture::TICEntry& tic, 31 static SurfaceParams CreateForImage(const FormatLookupTable& lookup_table,
32 const Tegra::Texture::TICEntry& tic,
29 const VideoCommon::Shader::Image& entry); 33 const VideoCommon::Shader::Image& entry);
30 34
31 /// Creates SurfaceCachedParams for a depth buffer configuration. 35 /// Creates SurfaceCachedParams for a depth buffer configuration.
@@ -248,7 +252,6 @@ public:
248 u32 num_levels; 252 u32 num_levels;
249 u32 emulated_levels; 253 u32 emulated_levels;
250 VideoCore::Surface::PixelFormat pixel_format; 254 VideoCore::Surface::PixelFormat pixel_format;
251 VideoCore::Surface::ComponentType component_type;
252 VideoCore::Surface::SurfaceType type; 255 VideoCore::Surface::SurfaceType type;
253 VideoCore::Surface::SurfaceTarget target; 256 VideoCore::Surface::SurfaceTarget target;
254 257
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 6a92b22d3..41309ebea 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -29,6 +29,7 @@
29#include "video_core/rasterizer_interface.h" 29#include "video_core/rasterizer_interface.h"
30#include "video_core/surface.h" 30#include "video_core/surface.h"
31#include "video_core/texture_cache/copy_params.h" 31#include "video_core/texture_cache/copy_params.h"
32#include "video_core/texture_cache/format_lookup_table.h"
32#include "video_core/texture_cache/surface_base.h" 33#include "video_core/texture_cache/surface_base.h"
33#include "video_core/texture_cache/surface_params.h" 34#include "video_core/texture_cache/surface_params.h"
34#include "video_core/texture_cache/surface_view.h" 35#include "video_core/texture_cache/surface_view.h"
@@ -96,7 +97,7 @@ public:
96 if (!gpu_addr) { 97 if (!gpu_addr) {
97 return {}; 98 return {};
98 } 99 }
99 const auto params{SurfaceParams::CreateForTexture(tic, entry)}; 100 const auto params{SurfaceParams::CreateForTexture(format_lookup_table, tic, entry)};
100 const auto [surface, view] = GetSurface(gpu_addr, params, true, false); 101 const auto [surface, view] = GetSurface(gpu_addr, params, true, false);
101 if (guard_samplers) { 102 if (guard_samplers) {
102 sampled_textures.push_back(surface); 103 sampled_textures.push_back(surface);
@@ -111,7 +112,7 @@ public:
111 if (!gpu_addr) { 112 if (!gpu_addr) {
112 return {}; 113 return {};
113 } 114 }
114 const auto params{SurfaceParams::CreateForImage(tic, entry)}; 115 const auto params{SurfaceParams::CreateForImage(format_lookup_table, tic, entry)};
115 const auto [surface, view] = GetSurface(gpu_addr, params, true, false); 116 const auto [surface, view] = GetSurface(gpu_addr, params, true, false);
116 if (guard_samplers) { 117 if (guard_samplers) {
117 sampled_textures.push_back(surface); 118 sampled_textures.push_back(surface);
@@ -485,15 +486,13 @@ private:
485 GetSiblingFormat(cr_params.pixel_format) == params.pixel_format) { 486 GetSiblingFormat(cr_params.pixel_format) == params.pixel_format) {
486 SurfaceParams new_params = params; 487 SurfaceParams new_params = params;
487 new_params.pixel_format = cr_params.pixel_format; 488 new_params.pixel_format = cr_params.pixel_format;
488 new_params.component_type = cr_params.component_type;
489 new_params.type = cr_params.type; 489 new_params.type = cr_params.type;
490 new_surface = GetUncachedSurface(gpu_addr, new_params); 490 new_surface = GetUncachedSurface(gpu_addr, new_params);
491 } else { 491 } else {
492 new_surface = GetUncachedSurface(gpu_addr, params); 492 new_surface = GetUncachedSurface(gpu_addr, params);
493 } 493 }
494 const auto& final_params = new_surface->GetSurfaceParams(); 494 const auto& final_params = new_surface->GetSurfaceParams();
495 if (cr_params.type != final_params.type || 495 if (cr_params.type != final_params.type) {
496 (cr_params.component_type != final_params.component_type)) {
497 BufferCopy(current_surface, new_surface); 496 BufferCopy(current_surface, new_surface);
498 } else { 497 } else {
499 std::vector<CopyParams> bricks = current_surface->BreakDown(final_params); 498 std::vector<CopyParams> bricks = current_surface->BreakDown(final_params);
@@ -835,12 +834,11 @@ private:
835 } 834 }
836 } 835 }
837 836
838 const auto inherit_format = ([](SurfaceParams& to, TSurface from) { 837 const auto inherit_format = [](SurfaceParams& to, TSurface from) {
839 const SurfaceParams& params = from->GetSurfaceParams(); 838 const SurfaceParams& params = from->GetSurfaceParams();
840 to.pixel_format = params.pixel_format; 839 to.pixel_format = params.pixel_format;
841 to.component_type = params.component_type;
842 to.type = params.type; 840 to.type = params.type;
843 }); 841 };
844 // Now we got the cases where one or both is Depth and the other is not known 842 // Now we got the cases where one or both is Depth and the other is not known
845 if (!incomplete_src) { 843 if (!incomplete_src) {
846 inherit_format(src_params, deduced_src.surface); 844 inherit_format(src_params, deduced_src.surface);
@@ -956,6 +954,8 @@ private:
956 954
957 VideoCore::RasterizerInterface& rasterizer; 955 VideoCore::RasterizerInterface& rasterizer;
958 956
957 FormatLookupTable format_lookup_table;
958
959 u64 ticks{}; 959 u64 ticks{};
960 960
961 // Guards the cache for protection conflicts. 961 // Guards the cache for protection conflicts.
diff --git a/src/yuzu/main.ui b/src/yuzu/main.ui
index a1ce3c0c3..21f422500 100644
--- a/src/yuzu/main.ui
+++ b/src/yuzu/main.ui
@@ -140,11 +140,6 @@
140 <string>Load Folder...</string> 140 <string>Load Folder...</string>
141 </property> 141 </property>
142 </action> 142 </action>
143 <action name="action_Load_Symbol_Map">
144 <property name="text">
145 <string>Load Symbol Map...</string>
146 </property>
147 </action>
148 <action name="action_Exit"> 143 <action name="action_Exit">
149 <property name="text"> 144 <property name="text">
150 <string>E&amp;xit</string> 145 <string>E&amp;xit</string>
@@ -221,14 +216,6 @@
221 <string>Show Status Bar</string> 216 <string>Show Status Bar</string>
222 </property> 217 </property>
223 </action> 218 </action>
224 <action name="action_Select_Game_List_Root">
225 <property name="text">
226 <string>Select Game Directory...</string>
227 </property>
228 <property name="toolTip">
229 <string>Selects a folder to display in the game list</string>
230 </property>
231 </action>
232 <action name="action_Select_NAND_Directory"> 219 <action name="action_Select_NAND_Directory">
233 <property name="text"> 220 <property name="text">
234 <string>Select NAND Directory...</string> 221 <string>Select NAND Directory...</string>