summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--].ci/scripts/linux/docker.sh2
-rwxr-xr-x[-rw-r--r--].ci/scripts/windows/docker.sh10
-rw-r--r--CMakeModules/MinGWCross.cmake4
m---------externals/cubeb0
-rw-r--r--src/common/uuid.h5
-rw-r--r--src/core/hle/kernel/handle_table.cpp2
-rw-r--r--src/core/hle/kernel/mutex.cpp5
-rw-r--r--src/core/hle/kernel/process_capability.cpp30
-rw-r--r--src/core/hle/kernel/readable_event.cpp13
-rw-r--r--src/core/hle/kernel/resource_limit.cpp2
-rw-r--r--src/core/hle/kernel/svc.cpp7
-rw-r--r--src/core/hle/kernel/thread.cpp2
-rw-r--r--src/core/hle/service/acc/acc.cpp59
-rw-r--r--src/core/hle/service/acc/acc.h3
-rw-r--r--src/core/hle/service/acc/acc_su.cpp2
-rw-r--r--src/core/hle/service/acc/acc_u0.cpp2
-rw-r--r--src/core/hle/service/acc/acc_u1.cpp2
-rw-r--r--src/core/hle/service/am/am.cpp17
-rw-r--r--src/core/hle/service/audio/audin_u.cpp70
-rw-r--r--src/core/hle/service/audio/audin_u.h29
-rw-r--r--src/core/hle/service/caps/caps_su.cpp11
-rw-r--r--src/core/hle/service/caps/caps_su.h3
-rw-r--r--src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h5
-rw-r--r--src/core/settings.cpp1
-rw-r--r--src/input_common/main.cpp6
-rw-r--r--src/video_core/buffer_cache/buffer_cache.h7
-rw-r--r--src/video_core/engines/maxwell_3d.cpp4
-rw-r--r--src/video_core/engines/maxwell_3d.h5
-rw-r--r--src/video_core/fence_manager.h6
-rw-r--r--src/video_core/rasterizer_interface.h3
-rw-r--r--src/video_core/renderer_opengl/gl_buffer_cache.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_buffer_cache.h2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp35
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h1
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp52
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.h33
-rw-r--r--src/video_core/renderer_vulkan/renderer_vulkan.cpp3
-rw-r--r--src/video_core/renderer_vulkan/renderer_vulkan.h1
-rw-r--r--src/video_core/renderer_vulkan/vk_blit_screen.h1
-rw-r--r--src/video_core/renderer_vulkan/vk_buffer_cache.cpp4
-rw-r--r--src/video_core/renderer_vulkan/vk_buffer_cache.h5
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pass.cpp2
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pass.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pipeline.cpp2
-rw-r--r--src/video_core/renderer_vulkan/vk_compute_pipeline.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_descriptor_pool.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_descriptor_pool.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_device.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.h3
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.cpp5
-rw-r--r--src/video_core/renderer_vulkan/vk_pipeline_cache.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_query_cache.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_query_cache.h1
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp40
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.h3
-rw-r--r--src/video_core/renderer_vulkan/vk_sampler_cache.cpp3
-rw-r--r--src/video_core/renderer_vulkan/vk_scheduler.cpp1
-rw-r--r--src/video_core/renderer_vulkan/vk_scheduler.h1
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp72
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.h4
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_util.cpp3
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_util.h1
-rw-r--r--src/video_core/renderer_vulkan/vk_staging_buffer_pool.h2
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.cpp3
-rw-r--r--src/video_core/renderer_vulkan/vk_texture_cache.h6
-rw-r--r--src/video_core/renderer_vulkan/vk_update_descriptor.h1
-rw-r--r--src/video_core/renderer_vulkan/wrapper.cpp1
-rw-r--r--src/video_core/renderer_vulkan/wrapper.h10
-rw-r--r--src/video_core/shader/decode.cpp18
-rw-r--r--src/video_core/shader/decode/image.cpp18
-rw-r--r--src/video_core/shader/decode/texture.cpp192
-rw-r--r--src/video_core/shader/node.h129
-rw-r--r--src/video_core/shader/shader_ir.h34
-rw-r--r--src/video_core/texture_cache/surface_params.cpp10
-rw-r--r--src/video_core/texture_cache/texture_cache.h4
-rw-r--r--src/yuzu/bootmanager.cpp4
-rw-r--r--src/yuzu/configuration/config.cpp3
-rw-r--r--src/yuzu/configuration/configure_general.cpp2
-rw-r--r--src/yuzu/configuration/configure_general.ui7
-rw-r--r--src/yuzu/main.cpp56
-rw-r--r--src/yuzu/main.h5
-rw-r--r--src/yuzu/uisettings.h1
83 files changed, 650 insertions, 467 deletions
diff --git a/.ci/scripts/linux/docker.sh b/.ci/scripts/linux/docker.sh
index f11878128..5559a527c 100644..100755
--- a/.ci/scripts/linux/docker.sh
+++ b/.ci/scripts/linux/docker.sh
@@ -5,7 +5,7 @@ cd /yuzu
5ccache -s 5ccache -s
6 6
7mkdir build || true && cd build 7mkdir build || true && cd build
8cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DYUZU_USE_BUNDLED_UNICORN=ON -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON -DENABLE_VULKAN=No 8cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DYUZU_USE_BUNDLED_UNICORN=ON -DYUZU_USE_QT_WEB_ENGINE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/lib/ccache/gcc -DCMAKE_CXX_COMPILER=/usr/lib/ccache/g++ -DYUZU_ENABLE_COMPATIBILITY_REPORTING=${ENABLE_COMPATIBILITY_REPORTING:-"OFF"} -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DUSE_DISCORD_PRESENCE=ON
9 9
10ninja 10ninja
11 11
diff --git a/.ci/scripts/windows/docker.sh b/.ci/scripts/windows/docker.sh
index beb554b65..5d5650d3b 100644..100755
--- a/.ci/scripts/windows/docker.sh
+++ b/.ci/scripts/windows/docker.sh
@@ -13,7 +13,7 @@ echo '' >> /bin/cmd
13chmod +x /bin/cmd 13chmod +x /bin/cmd
14 14
15mkdir build || true && cd build 15mkdir build || true && cd build
16cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DYUZU_USE_BUNDLED_UNICORN=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release -DENABLE_VULKAN=No 16cmake .. -G Ninja -DDISPLAY_VERSION=$1 -DCMAKE_TOOLCHAIN_FILE="$(pwd)/../CMakeModules/MinGWCross.cmake" -DUSE_CCACHE=ON -DYUZU_USE_BUNDLED_UNICORN=ON -DENABLE_COMPATIBILITY_LIST_DOWNLOAD=ON -DCMAKE_BUILD_TYPE=Release
17ninja 17ninja
18 18
19# Clean up the dirty hacks 19# Clean up the dirty hacks
@@ -29,7 +29,13 @@ echo 'Prepare binaries...'
29cd .. 29cd ..
30mkdir package 30mkdir package
31 31
32QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt5/plugins/platforms/' 32if [ -d "/usr/x86_64-w64-mingw32/lib/qt5/plugins/platforms/" ]; then
33 QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt5/plugins/platforms/'
34else
35 #fallback to qt
36 QT_PLATFORM_DLL_PATH='/usr/x86_64-w64-mingw32/lib/qt/plugins/platforms/'
37fi
38
33find build/ -name "yuzu*.exe" -exec cp {} 'package' \; 39find build/ -name "yuzu*.exe" -exec cp {} 'package' \;
34 40
35# copy Qt plugins 41# copy Qt plugins
diff --git a/CMakeModules/MinGWCross.cmake b/CMakeModules/MinGWCross.cmake
index 29ecd1ac4..b268e72d8 100644
--- a/CMakeModules/MinGWCross.cmake
+++ b/CMakeModules/MinGWCross.cmake
@@ -10,8 +10,8 @@ set(SDL2_PATH ${MINGW_PREFIX})
10set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-) 10set(MINGW_TOOL_PREFIX ${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-)
11 11
12# Specify the cross compiler 12# Specify the cross compiler
13set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc-posix) 13set(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc)
14set(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++-posix) 14set(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++)
15set(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres) 15set(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}windres)
16 16
17# Mingw tools 17# Mingw tools
diff --git a/externals/cubeb b/externals/cubeb
Subproject 6f2420de8f155b10330cf973900ac7bdbfee589 Subproject 616d773441b5355800ce64197a699e6cd6b3617
diff --git a/src/common/uuid.h b/src/common/uuid.h
index f6ad064fb..4d3af8cec 100644
--- a/src/common/uuid.h
+++ b/src/common/uuid.h
@@ -40,6 +40,11 @@ struct UUID {
40 uuid = INVALID_UUID; 40 uuid = INVALID_UUID;
41 } 41 }
42 42
43 // TODO(ogniK): Properly generate a Nintendo ID
44 constexpr u64 GetNintendoID() const {
45 return uuid[0];
46 }
47
43 std::string Format() const; 48 std::string Format() const;
44 std::string FormatSwitch() const; 49 std::string FormatSwitch() const;
45}; 50};
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index e441a27fc..35448b576 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -30,6 +30,7 @@ HandleTable::~HandleTable() = default;
30 30
31ResultCode HandleTable::SetSize(s32 handle_table_size) { 31ResultCode HandleTable::SetSize(s32 handle_table_size) {
32 if (static_cast<u32>(handle_table_size) > MAX_COUNT) { 32 if (static_cast<u32>(handle_table_size) > MAX_COUNT) {
33 LOG_ERROR(Kernel, "Handle table size {} is greater than {}", handle_table_size, MAX_COUNT);
33 return ERR_OUT_OF_MEMORY; 34 return ERR_OUT_OF_MEMORY;
34 } 35 }
35 36
@@ -80,6 +81,7 @@ ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
80 81
81ResultCode HandleTable::Close(Handle handle) { 82ResultCode HandleTable::Close(Handle handle) {
82 if (!IsValid(handle)) { 83 if (!IsValid(handle)) {
84 LOG_ERROR(Kernel, "Handle is not valid! handle={:08X}", handle);
83 return ERR_INVALID_HANDLE; 85 return ERR_INVALID_HANDLE;
84 } 86 }
85 87
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index eff4e45b0..7869eb32b 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -7,6 +7,7 @@
7#include <vector> 7#include <vector>
8 8
9#include "common/assert.h" 9#include "common/assert.h"
10#include "common/logging/log.h"
10#include "core/core.h" 11#include "core/core.h"
11#include "core/hle/kernel/errors.h" 12#include "core/hle/kernel/errors.h"
12#include "core/hle/kernel/handle_table.h" 13#include "core/hle/kernel/handle_table.h"
@@ -67,6 +68,7 @@ ResultCode Mutex::TryAcquire(VAddr address, Handle holding_thread_handle,
67 Handle requesting_thread_handle) { 68 Handle requesting_thread_handle) {
68 // The mutex address must be 4-byte aligned 69 // The mutex address must be 4-byte aligned
69 if ((address % sizeof(u32)) != 0) { 70 if ((address % sizeof(u32)) != 0) {
71 LOG_ERROR(Kernel, "Address is not 4-byte aligned! address={:016X}", address);
70 return ERR_INVALID_ADDRESS; 72 return ERR_INVALID_ADDRESS;
71 } 73 }
72 74
@@ -88,6 +90,8 @@ ResultCode Mutex::TryAcquire(VAddr address, Handle holding_thread_handle,
88 } 90 }
89 91
90 if (holding_thread == nullptr) { 92 if (holding_thread == nullptr) {
93 LOG_ERROR(Kernel, "Holding thread does not exist! thread_handle={:08X}",
94 holding_thread_handle);
91 return ERR_INVALID_HANDLE; 95 return ERR_INVALID_HANDLE;
92 } 96 }
93 97
@@ -109,6 +113,7 @@ ResultCode Mutex::TryAcquire(VAddr address, Handle holding_thread_handle,
109ResultCode Mutex::Release(VAddr address) { 113ResultCode Mutex::Release(VAddr address) {
110 // The mutex address must be 4-byte aligned 114 // The mutex address must be 4-byte aligned
111 if ((address % sizeof(u32)) != 0) { 115 if ((address % sizeof(u32)) != 0) {
116 LOG_ERROR(Kernel, "Address is not 4-byte aligned! address={:016X}", address);
112 return ERR_INVALID_ADDRESS; 117 return ERR_INVALID_ADDRESS;
113 } 118 }
114 119
diff --git a/src/core/hle/kernel/process_capability.cpp b/src/core/hle/kernel/process_capability.cpp
index 48e5ae682..63880f13d 100644
--- a/src/core/hle/kernel/process_capability.cpp
+++ b/src/core/hle/kernel/process_capability.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/bit_util.h" 5#include "common/bit_util.h"
6#include "common/logging/log.h"
6#include "core/hle/kernel/errors.h" 7#include "core/hle/kernel/errors.h"
7#include "core/hle/kernel/handle_table.h" 8#include "core/hle/kernel/handle_table.h"
8#include "core/hle/kernel/memory/page_table.h" 9#include "core/hle/kernel/memory/page_table.h"
@@ -119,22 +120,30 @@ ResultCode ProcessCapabilities::ParseCapabilities(const u32* capabilities,
119 // The MapPhysical type uses two descriptor flags for its parameters. 120 // The MapPhysical type uses two descriptor flags for its parameters.
120 // If there's only one, then there's a problem. 121 // If there's only one, then there's a problem.
121 if (i >= num_capabilities) { 122 if (i >= num_capabilities) {
123 LOG_ERROR(Kernel, "Invalid combination! i={}", i);
122 return ERR_INVALID_COMBINATION; 124 return ERR_INVALID_COMBINATION;
123 } 125 }
124 126
125 const auto size_flags = capabilities[i]; 127 const auto size_flags = capabilities[i];
126 if (GetCapabilityType(size_flags) != CapabilityType::MapPhysical) { 128 if (GetCapabilityType(size_flags) != CapabilityType::MapPhysical) {
129 LOG_ERROR(Kernel, "Invalid capability type! size_flags={}", size_flags);
127 return ERR_INVALID_COMBINATION; 130 return ERR_INVALID_COMBINATION;
128 } 131 }
129 132
130 const auto result = HandleMapPhysicalFlags(descriptor, size_flags, page_table); 133 const auto result = HandleMapPhysicalFlags(descriptor, size_flags, page_table);
131 if (result.IsError()) { 134 if (result.IsError()) {
135 LOG_ERROR(Kernel, "Failed to map physical flags! descriptor={}, size_flags={}",
136 descriptor, size_flags);
132 return result; 137 return result;
133 } 138 }
134 } else { 139 } else {
135 const auto result = 140 const auto result =
136 ParseSingleFlagCapability(set_flags, set_svc_bits, descriptor, page_table); 141 ParseSingleFlagCapability(set_flags, set_svc_bits, descriptor, page_table);
137 if (result.IsError()) { 142 if (result.IsError()) {
143 LOG_ERROR(
144 Kernel,
145 "Failed to parse capability flag! set_flags={}, set_svc_bits={}, descriptor={}",
146 set_flags, set_svc_bits, descriptor);
138 return result; 147 return result;
139 } 148 }
140 } 149 }
@@ -162,6 +171,9 @@ ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& s
162 const u32 flag_length = GetFlagBitOffset(type); 171 const u32 flag_length = GetFlagBitOffset(type);
163 const u32 set_flag = 1U << flag_length; 172 const u32 set_flag = 1U << flag_length;
164 if ((set_flag & set_flags & InitializeOnceMask) != 0) { 173 if ((set_flag & set_flags & InitializeOnceMask) != 0) {
174 LOG_ERROR(Kernel,
175 "Attempted to initialize flags that may only be initialized once. set_flags={}",
176 set_flags);
165 return ERR_INVALID_COMBINATION; 177 return ERR_INVALID_COMBINATION;
166 } 178 }
167 set_flags |= set_flag; 179 set_flags |= set_flag;
@@ -187,6 +199,7 @@ ResultCode ProcessCapabilities::ParseSingleFlagCapability(u32& set_flags, u32& s
187 break; 199 break;
188 } 200 }
189 201
202 LOG_ERROR(Kernel, "Invalid capability type! type={}", static_cast<u32>(type));
190 return ERR_INVALID_CAPABILITY_DESCRIPTOR; 203 return ERR_INVALID_CAPABILITY_DESCRIPTOR;
191} 204}
192 205
@@ -208,23 +221,31 @@ void ProcessCapabilities::Clear() {
208 221
209ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) { 222ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) {
210 if (priority_mask != 0 || core_mask != 0) { 223 if (priority_mask != 0 || core_mask != 0) {
224 LOG_ERROR(Kernel, "Core or priority mask are not zero! priority_mask={}, core_mask={}",
225 priority_mask, core_mask);
211 return ERR_INVALID_CAPABILITY_DESCRIPTOR; 226 return ERR_INVALID_CAPABILITY_DESCRIPTOR;
212 } 227 }
213 228
214 const u32 core_num_min = (flags >> 16) & 0xFF; 229 const u32 core_num_min = (flags >> 16) & 0xFF;
215 const u32 core_num_max = (flags >> 24) & 0xFF; 230 const u32 core_num_max = (flags >> 24) & 0xFF;
216 if (core_num_min > core_num_max) { 231 if (core_num_min > core_num_max) {
232 LOG_ERROR(Kernel, "Core min is greater than core max! core_num_min={}, core_num_max={}",
233 core_num_min, core_num_max);
217 return ERR_INVALID_COMBINATION; 234 return ERR_INVALID_COMBINATION;
218 } 235 }
219 236
220 const u32 priority_min = (flags >> 10) & 0x3F; 237 const u32 priority_min = (flags >> 10) & 0x3F;
221 const u32 priority_max = (flags >> 4) & 0x3F; 238 const u32 priority_max = (flags >> 4) & 0x3F;
222 if (priority_min > priority_max) { 239 if (priority_min > priority_max) {
240 LOG_ERROR(Kernel,
241 "Priority min is greater than priority max! priority_min={}, priority_max={}",
242 core_num_min, priority_max);
223 return ERR_INVALID_COMBINATION; 243 return ERR_INVALID_COMBINATION;
224 } 244 }
225 245
226 // The switch only has 4 usable cores. 246 // The switch only has 4 usable cores.
227 if (core_num_max >= 4) { 247 if (core_num_max >= 4) {
248 LOG_ERROR(Kernel, "Invalid max cores specified! core_num_max={}", core_num_max);
228 return ERR_INVALID_PROCESSOR_ID; 249 return ERR_INVALID_PROCESSOR_ID;
229 } 250 }
230 251
@@ -259,6 +280,7 @@ ResultCode ProcessCapabilities::HandleSyscallFlags(u32& set_svc_bits, u32 flags)
259 } 280 }
260 281
261 if (svc_number >= svc_capabilities.size()) { 282 if (svc_number >= svc_capabilities.size()) {
283 LOG_ERROR(Kernel, "Process svc capability is out of range! svc_number={}", svc_number);
262 return ERR_OUT_OF_RANGE; 284 return ERR_OUT_OF_RANGE;
263 } 285 }
264 286
@@ -295,6 +317,8 @@ ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) {
295 // emulate that, it's sufficient to mark every interrupt as defined. 317 // emulate that, it's sufficient to mark every interrupt as defined.
296 318
297 if (interrupt >= interrupt_capabilities.size()) { 319 if (interrupt >= interrupt_capabilities.size()) {
320 LOG_ERROR(Kernel, "Process interrupt capability is out of range! svc_number={}",
321 interrupt);
298 return ERR_OUT_OF_RANGE; 322 return ERR_OUT_OF_RANGE;
299 } 323 }
300 324
@@ -307,6 +331,7 @@ ResultCode ProcessCapabilities::HandleInterruptFlags(u32 flags) {
307ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) { 331ResultCode ProcessCapabilities::HandleProgramTypeFlags(u32 flags) {
308 const u32 reserved = flags >> 17; 332 const u32 reserved = flags >> 17;
309 if (reserved != 0) { 333 if (reserved != 0) {
334 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
310 return ERR_RESERVED_VALUE; 335 return ERR_RESERVED_VALUE;
311 } 336 }
312 337
@@ -324,6 +349,9 @@ ResultCode ProcessCapabilities::HandleKernelVersionFlags(u32 flags) {
324 const u32 major_version = kernel_version >> 19; 349 const u32 major_version = kernel_version >> 19;
325 350
326 if (major_version != 0 || flags < 0x80000) { 351 if (major_version != 0 || flags < 0x80000) {
352 LOG_ERROR(Kernel,
353 "Kernel version is non zero or flags are too small! major_version={}, flags={}",
354 major_version, flags);
327 return ERR_INVALID_CAPABILITY_DESCRIPTOR; 355 return ERR_INVALID_CAPABILITY_DESCRIPTOR;
328 } 356 }
329 357
@@ -334,6 +362,7 @@ ResultCode ProcessCapabilities::HandleKernelVersionFlags(u32 flags) {
334ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) { 362ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) {
335 const u32 reserved = flags >> 26; 363 const u32 reserved = flags >> 26;
336 if (reserved != 0) { 364 if (reserved != 0) {
365 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
337 return ERR_RESERVED_VALUE; 366 return ERR_RESERVED_VALUE;
338 } 367 }
339 368
@@ -344,6 +373,7 @@ ResultCode ProcessCapabilities::HandleHandleTableFlags(u32 flags) {
344ResultCode ProcessCapabilities::HandleDebugFlags(u32 flags) { 373ResultCode ProcessCapabilities::HandleDebugFlags(u32 flags) {
345 const u32 reserved = flags >> 19; 374 const u32 reserved = flags >> 19;
346 if (reserved != 0) { 375 if (reserved != 0) {
376 LOG_ERROR(Kernel, "Reserved value is non-zero! reserved={}", reserved);
347 return ERR_RESERVED_VALUE; 377 return ERR_RESERVED_VALUE;
348 } 378 }
349 379
diff --git a/src/core/hle/kernel/readable_event.cpp b/src/core/hle/kernel/readable_event.cpp
index 9d3d3a81b..00860fcbd 100644
--- a/src/core/hle/kernel/readable_event.cpp
+++ b/src/core/hle/kernel/readable_event.cpp
@@ -4,6 +4,7 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include "common/assert.h" 6#include "common/assert.h"
7#include "common/logging/log.h"
7#include "core/hle/kernel/errors.h" 8#include "core/hle/kernel/errors.h"
8#include "core/hle/kernel/object.h" 9#include "core/hle/kernel/object.h"
9#include "core/hle/kernel/readable_event.h" 10#include "core/hle/kernel/readable_event.h"
@@ -23,10 +24,12 @@ void ReadableEvent::Acquire(Thread* thread) {
23} 24}
24 25
25void ReadableEvent::Signal() { 26void ReadableEvent::Signal() {
26 if (!is_signaled) { 27 if (is_signaled) {
27 is_signaled = true; 28 return;
28 SynchronizationObject::Signal(); 29 }
29 }; 30
31 is_signaled = true;
32 SynchronizationObject::Signal();
30} 33}
31 34
32void ReadableEvent::Clear() { 35void ReadableEvent::Clear() {
@@ -35,6 +38,8 @@ void ReadableEvent::Clear() {
35 38
36ResultCode ReadableEvent::Reset() { 39ResultCode ReadableEvent::Reset() {
37 if (!is_signaled) { 40 if (!is_signaled) {
41 LOG_ERROR(Kernel, "Handle is not signaled! object_id={}, object_type={}, object_name={}",
42 GetObjectId(), GetTypeName(), GetName());
38 return ERR_INVALID_STATE; 43 return ERR_INVALID_STATE;
39 } 44 }
40 45
diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp
index 96e5b9892..d9beaa3a4 100644
--- a/src/core/hle/kernel/resource_limit.cpp
+++ b/src/core/hle/kernel/resource_limit.cpp
@@ -69,6 +69,8 @@ ResultCode ResourceLimit::SetLimitValue(ResourceType resource, s64 value) {
69 limit[index] = value; 69 limit[index] = value;
70 return RESULT_SUCCESS; 70 return RESULT_SUCCESS;
71 } else { 71 } else {
72 LOG_ERROR(Kernel, "Limit value is too large! resource={}, value={}, index={}",
73 static_cast<u32>(resource), value, index);
72 return ERR_INVALID_STATE; 74 return ERR_INVALID_STATE;
73 } 75 }
74} 76}
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 41ef2caf6..4ae4529f5 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -685,6 +685,8 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
685 case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource: 685 case GetInfoType::TotalPhysicalMemoryAvailableWithoutSystemResource:
686 case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: { 686 case GetInfoType::TotalPhysicalMemoryUsedWithoutSystemResource: {
687 if (info_sub_id != 0) { 687 if (info_sub_id != 0) {
688 LOG_ERROR(Kernel_SVC, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id,
689 info_sub_id);
688 return ERR_INVALID_ENUM_VALUE; 690 return ERR_INVALID_ENUM_VALUE;
689 } 691 }
690 692
@@ -692,6 +694,8 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
692 system.Kernel().CurrentProcess()->GetHandleTable(); 694 system.Kernel().CurrentProcess()->GetHandleTable();
693 const auto process = current_process_handle_table.Get<Process>(static_cast<Handle>(handle)); 695 const auto process = current_process_handle_table.Get<Process>(static_cast<Handle>(handle));
694 if (!process) { 696 if (!process) {
697 LOG_ERROR(Kernel_SVC, "Process is not valid! info_id={}, info_sub_id={}, handle={:08X}",
698 info_id, info_sub_id, handle);
695 return ERR_INVALID_HANDLE; 699 return ERR_INVALID_HANDLE;
696 } 700 }
697 701
@@ -783,10 +787,13 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, u64 ha
783 787
784 case GetInfoType::RegisterResourceLimit: { 788 case GetInfoType::RegisterResourceLimit: {
785 if (handle != 0) { 789 if (handle != 0) {
790 LOG_ERROR(Kernel, "Handle is non zero! handle={:08X}", handle);
786 return ERR_INVALID_HANDLE; 791 return ERR_INVALID_HANDLE;
787 } 792 }
788 793
789 if (info_sub_id != 0) { 794 if (info_sub_id != 0) {
795 LOG_ERROR(Kernel, "Info sub id is non zero! info_id={}, info_sub_id={}", info_id,
796 info_sub_id);
790 return ERR_INVALID_COMBINATION; 797 return ERR_INVALID_COMBINATION;
791 } 798 }
792 799
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index a919750a6..db7f379ac 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -423,6 +423,8 @@ ResultCode Thread::SetCoreAndAffinityMask(s32 new_core, u64 new_affinity_mask) {
423 if (new_core == THREADPROCESSORID_DONT_UPDATE) { 423 if (new_core == THREADPROCESSORID_DONT_UPDATE) {
424 new_core = use_override ? ideal_core_override : ideal_core; 424 new_core = use_override ? ideal_core_override : ideal_core;
425 if ((new_affinity_mask & (1ULL << new_core)) == 0) { 425 if ((new_affinity_mask & (1ULL << new_core)) == 0) {
426 LOG_ERROR(Kernel, "New affinity mask is incorrect! new_core={}, new_affinity_mask={}",
427 new_core, new_affinity_mask);
426 return ERR_INVALID_COMBINATION; 428 return ERR_INVALID_COMBINATION;
427 } 429 }
428 } 430 }
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index cfac8ca9a..630a8b048 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -228,7 +228,8 @@ public:
228 228
229class IManagerForApplication final : public ServiceFramework<IManagerForApplication> { 229class IManagerForApplication final : public ServiceFramework<IManagerForApplication> {
230public: 230public:
231 IManagerForApplication() : ServiceFramework("IManagerForApplication") { 231 explicit IManagerForApplication(Common::UUID user_id)
232 : ServiceFramework("IManagerForApplication"), user_id(user_id) {
232 // clang-format off 233 // clang-format off
233 static const FunctionInfo functions[] = { 234 static const FunctionInfo functions[] = {
234 {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"}, 235 {0, &IManagerForApplication::CheckAvailability, "CheckAvailability"},
@@ -254,12 +255,14 @@ private:
254 } 255 }
255 256
256 void GetAccountId(Kernel::HLERequestContext& ctx) { 257 void GetAccountId(Kernel::HLERequestContext& ctx) {
257 LOG_WARNING(Service_ACC, "(STUBBED) called"); 258 LOG_DEBUG(Service_ACC, "called");
258 // Should return a nintendo account ID 259
259 IPC::ResponseBuilder rb{ctx, 4}; 260 IPC::ResponseBuilder rb{ctx, 4};
260 rb.Push(RESULT_SUCCESS); 261 rb.Push(RESULT_SUCCESS);
261 rb.PushRaw<u64>(1); 262 rb.PushRaw<u64>(user_id.GetNintendoID());
262 } 263 }
264
265 Common::UUID user_id;
263}; 266};
264 267
265void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) { 268void Module::Interface::GetUserCount(Kernel::HLERequestContext& ctx) {
@@ -319,46 +322,37 @@ void Module::Interface::IsUserRegistrationRequestPermitted(Kernel::HLERequestCon
319 322
320void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) { 323void Module::Interface::InitializeApplicationInfo(Kernel::HLERequestContext& ctx) {
321 IPC::RequestParser rp{ctx}; 324 IPC::RequestParser rp{ctx};
322 auto pid = rp.Pop<u64>();
323 325
324 LOG_DEBUG(Service_ACC, "called, process_id={}", pid); 326 LOG_DEBUG(Service_ACC, "called");
325 IPC::ResponseBuilder rb{ctx, 2}; 327 IPC::ResponseBuilder rb{ctx, 2};
326 rb.Push(InitializeApplicationInfoBase(pid)); 328 rb.Push(InitializeApplicationInfoBase());
327} 329}
328 330
329void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx) { 331void Module::Interface::InitializeApplicationInfoRestricted(Kernel::HLERequestContext& ctx) {
330 IPC::RequestParser rp{ctx}; 332 IPC::RequestParser rp{ctx};
331 auto pid = rp.Pop<u64>();
332 333
333 LOG_WARNING(Service_ACC, "(Partial implementation) called, process_id={}", pid); 334 LOG_WARNING(Service_ACC, "(Partial implementation) called");
334 335
335 // TODO(ogniK): We require checking if the user actually owns the title and what not. As of 336 // TODO(ogniK): We require checking if the user actually owns the title and what not. As of
336 // currently, we assume the user owns the title. InitializeApplicationInfoBase SHOULD be called 337 // currently, we assume the user owns the title. InitializeApplicationInfoBase SHOULD be called
337 // first then we do extra checks if the game is a digital copy. 338 // first then we do extra checks if the game is a digital copy.
338 339
339 IPC::ResponseBuilder rb{ctx, 2}; 340 IPC::ResponseBuilder rb{ctx, 2};
340 rb.Push(InitializeApplicationInfoBase(pid)); 341 rb.Push(InitializeApplicationInfoBase());
341} 342}
342 343
343ResultCode Module::Interface::InitializeApplicationInfoBase(u64 process_id) { 344ResultCode Module::Interface::InitializeApplicationInfoBase() {
344 if (application_info) { 345 if (application_info) {
345 LOG_ERROR(Service_ACC, "Application already initialized"); 346 LOG_ERROR(Service_ACC, "Application already initialized");
346 return ERR_ACCOUNTINFO_ALREADY_INITIALIZED; 347 return ERR_ACCOUNTINFO_ALREADY_INITIALIZED;
347 } 348 }
348 349
349 const auto& list = system.Kernel().GetProcessList(); 350 // TODO(ogniK): This should be changed to reflect the target process for when we have multiple
350 const auto iter = std::find_if(list.begin(), list.end(), [&process_id](const auto& process) { 351 // processes emulated. As we don't actually have pid support we should assume we're just using
351 return process->GetProcessID() == process_id; 352 // our own process
352 }); 353 const auto& current_process = system.Kernel().CurrentProcess();
353 354 const auto launch_property =
354 if (iter == list.end()) { 355 system.GetARPManager().GetLaunchProperty(current_process->GetTitleID());
355 LOG_ERROR(Service_ACC, "Failed to find process ID");
356 application_info.application_type = ApplicationType::Unknown;
357
358 return ERR_ACCOUNTINFO_BAD_APPLICATION;
359 }
360
361 const auto launch_property = system.GetARPManager().GetLaunchProperty((*iter)->GetTitleID());
362 356
363 if (launch_property.Failed()) { 357 if (launch_property.Failed()) {
364 LOG_ERROR(Service_ACC, "Failed to get launch property"); 358 LOG_ERROR(Service_ACC, "Failed to get launch property");
@@ -372,10 +366,12 @@ ResultCode Module::Interface::InitializeApplicationInfoBase(u64 process_id) {
372 case FileSys::StorageId::Host: 366 case FileSys::StorageId::Host:
373 case FileSys::StorageId::NandUser: 367 case FileSys::StorageId::NandUser:
374 case FileSys::StorageId::SdCard: 368 case FileSys::StorageId::SdCard:
369 case FileSys::StorageId::None: // Yuzu specific, differs from hardware
375 application_info.application_type = ApplicationType::Digital; 370 application_info.application_type = ApplicationType::Digital;
376 break; 371 break;
377 default: 372 default:
378 LOG_ERROR(Service_ACC, "Invalid game storage ID"); 373 LOG_ERROR(Service_ACC, "Invalid game storage ID! storage_id={}",
374 launch_property->base_game_storage_id);
379 return ERR_ACCOUNTINFO_BAD_APPLICATION; 375 return ERR_ACCOUNTINFO_BAD_APPLICATION;
380 } 376 }
381 377
@@ -389,7 +385,7 @@ void Module::Interface::GetBaasAccountManagerForApplication(Kernel::HLERequestCo
389 LOG_DEBUG(Service_ACC, "called"); 385 LOG_DEBUG(Service_ACC, "called");
390 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 386 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
391 rb.Push(RESULT_SUCCESS); 387 rb.Push(RESULT_SUCCESS);
392 rb.PushIpcInterface<IManagerForApplication>(); 388 rb.PushIpcInterface<IManagerForApplication>(profile_manager->GetLastOpenedUser());
393} 389}
394 390
395void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) { 391void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx) {
@@ -428,6 +424,17 @@ void Module::Interface::GetProfileEditor(Kernel::HLERequestContext& ctx) {
428 rb.PushIpcInterface<IProfileEditor>(user_id, *profile_manager); 424 rb.PushIpcInterface<IProfileEditor>(user_id, *profile_manager);
429} 425}
430 426
427void Module::Interface::ListQualifiedUsers(Kernel::HLERequestContext& ctx) {
428 LOG_DEBUG(Service_ACC, "called");
429
430 // All users should be qualified. We don't actually have parental control or anything to do with
431 // nintendo online currently. We're just going to assume the user running the game has access to
432 // the game regardless of parental control settings.
433 ctx.WriteBuffer(profile_manager->GetAllUsers());
434 IPC::ResponseBuilder rb{ctx, 2};
435 rb.Push(RESULT_SUCCESS);
436}
437
431void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx) { 438void Module::Interface::TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx) {
432 LOG_DEBUG(Service_ACC, "called"); 439 LOG_DEBUG(Service_ACC, "called");
433 // A u8 is passed into this function which we can safely ignore. It's to determine if we have 440 // A u8 is passed into this function which we can safely ignore. It's to determine if we have
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h
index 7a7dc9ec6..74ca39d6e 100644
--- a/src/core/hle/service/acc/acc.h
+++ b/src/core/hle/service/acc/acc.h
@@ -33,9 +33,10 @@ public:
33 void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx); 33 void TrySelectUserWithoutInteraction(Kernel::HLERequestContext& ctx);
34 void IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx); 34 void IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx);
35 void GetProfileEditor(Kernel::HLERequestContext& ctx); 35 void GetProfileEditor(Kernel::HLERequestContext& ctx);
36 void ListQualifiedUsers(Kernel::HLERequestContext& ctx);
36 37
37 private: 38 private:
38 ResultCode InitializeApplicationInfoBase(u64 process_id); 39 ResultCode InitializeApplicationInfoBase();
39 40
40 enum class ApplicationType : u32_le { 41 enum class ApplicationType : u32_le {
41 GameCard = 0, 42 GameCard = 0,
diff --git a/src/core/hle/service/acc/acc_su.cpp b/src/core/hle/service/acc/acc_su.cpp
index ae88deda5..2eefc6df5 100644
--- a/src/core/hle/service/acc/acc_su.cpp
+++ b/src/core/hle/service/acc/acc_su.cpp
@@ -35,7 +35,7 @@ ACC_SU::ACC_SU(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p
35 {113, nullptr, "GetSaveDataThumbnailExistence"}, 35 {113, nullptr, "GetSaveDataThumbnailExistence"},
36 {120, nullptr, "ListOpenUsersInApplication"}, 36 {120, nullptr, "ListOpenUsersInApplication"},
37 {130, nullptr, "ActivateOpenContextRetention"}, 37 {130, nullptr, "ActivateOpenContextRetention"},
38 {140, nullptr, "ListQualifiedUsers"}, 38 {140, &ACC_SU::ListQualifiedUsers, "ListQualifiedUsers"},
39 {150, nullptr, "AuthenticateApplicationAsync"}, 39 {150, nullptr, "AuthenticateApplicationAsync"},
40 {190, nullptr, "GetUserLastOpenedApplication"}, 40 {190, nullptr, "GetUserLastOpenedApplication"},
41 {191, nullptr, "ActivateOpenContextHolder"}, 41 {191, nullptr, "ActivateOpenContextHolder"},
diff --git a/src/core/hle/service/acc/acc_u0.cpp b/src/core/hle/service/acc/acc_u0.cpp
index 0ac19f4ff..fb4e7e772 100644
--- a/src/core/hle/service/acc/acc_u0.cpp
+++ b/src/core/hle/service/acc/acc_u0.cpp
@@ -32,7 +32,7 @@ ACC_U0::ACC_U0(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p
32 {130, nullptr, "LoadOpenContext"}, 32 {130, nullptr, "LoadOpenContext"},
33 {131, nullptr, "ListOpenContextStoredUsers"}, 33 {131, nullptr, "ListOpenContextStoredUsers"},
34 {140, &ACC_U0::InitializeApplicationInfoRestricted, "InitializeApplicationInfoRestricted"}, 34 {140, &ACC_U0::InitializeApplicationInfoRestricted, "InitializeApplicationInfoRestricted"},
35 {141, nullptr, "ListQualifiedUsers"}, 35 {141, &ACC_U0::ListQualifiedUsers, "ListQualifiedUsers"},
36 {150, &ACC_U0::IsUserAccountSwitchLocked, "IsUserAccountSwitchLocked"}, 36 {150, &ACC_U0::IsUserAccountSwitchLocked, "IsUserAccountSwitchLocked"},
37 }; 37 };
38 // clang-format on 38 // clang-format on
diff --git a/src/core/hle/service/acc/acc_u1.cpp b/src/core/hle/service/acc/acc_u1.cpp
index 2b9c11928..9f29cdc82 100644
--- a/src/core/hle/service/acc/acc_u1.cpp
+++ b/src/core/hle/service/acc/acc_u1.cpp
@@ -34,7 +34,7 @@ ACC_U1::ACC_U1(std::shared_ptr<Module> module, std::shared_ptr<ProfileManager> p
34 {112, nullptr, "LoadSaveDataThumbnail"}, 34 {112, nullptr, "LoadSaveDataThumbnail"},
35 {113, nullptr, "GetSaveDataThumbnailExistence"}, 35 {113, nullptr, "GetSaveDataThumbnailExistence"},
36 {130, nullptr, "ActivateOpenContextRetention"}, 36 {130, nullptr, "ActivateOpenContextRetention"},
37 {140, nullptr, "ListQualifiedUsers"}, 37 {140, &ACC_U1::ListQualifiedUsers, "ListQualifiedUsers"},
38 {150, nullptr, "AuthenticateApplicationAsync"}, 38 {150, nullptr, "AuthenticateApplicationAsync"},
39 {190, nullptr, "GetUserLastOpenedApplication"}, 39 {190, nullptr, "GetUserLastOpenedApplication"},
40 {191, nullptr, "ActivateOpenContextHolder"}, 40 {191, nullptr, "ActivateOpenContextHolder"},
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index 30cd73252..4df74c4f9 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -1335,12 +1335,23 @@ void IApplicationFunctions::SetTerminateResult(Kernel::HLERequestContext& ctx) {
1335} 1335}
1336 1336
1337void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) { 1337void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
1338 LOG_WARNING(Service_AM, "(STUBBED) called"); 1338 LOG_DEBUG(Service_AM, "called");
1339
1340 std::array<u8, 0x10> version_string{};
1341
1342 FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()};
1343 const auto res = pm.GetControlMetadata();
1344 if (res.first != nullptr) {
1345 const auto& version = res.first->GetVersionString();
1346 std::copy(version.begin(), version.end(), version_string.begin());
1347 } else {
1348 constexpr u128 default_version = {1, 0};
1349 std::memcpy(version_string.data(), default_version.data(), sizeof(u128));
1350 }
1339 1351
1340 IPC::ResponseBuilder rb{ctx, 6}; 1352 IPC::ResponseBuilder rb{ctx, 6};
1341 rb.Push(RESULT_SUCCESS); 1353 rb.Push(RESULT_SUCCESS);
1342 rb.Push<u64>(1); 1354 rb.PushRaw(version_string);
1343 rb.Push<u64>(0);
1344} 1355}
1345 1356
1346void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) { 1357void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp
index d7f1d348d..3e2299426 100644
--- a/src/core/hle/service/audio/audin_u.cpp
+++ b/src/core/hle/service/audio/audin_u.cpp
@@ -2,6 +2,9 @@
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 "common/logging/log.h"
6#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/hle_ipc.h"
5#include "core/hle/service/audio/audin_u.h" 8#include "core/hle/service/audio/audin_u.h"
6 9
7namespace Service::Audio { 10namespace Service::Audio {
@@ -36,11 +39,12 @@ public:
36AudInU::AudInU() : ServiceFramework("audin:u") { 39AudInU::AudInU() : ServiceFramework("audin:u") {
37 // clang-format off 40 // clang-format off
38 static const FunctionInfo functions[] = { 41 static const FunctionInfo functions[] = {
39 {0, nullptr, "ListAudioIns"}, 42 {0, &AudInU::ListAudioIns, "ListAudioIns"},
40 {1, nullptr, "OpenAudioIn"}, 43 {1, &AudInU::OpenAudioIn, "OpenAudioIn"},
41 {2, nullptr, "Unknown"}, 44 {2, &AudInU::ListAudioIns, "ListAudioInsAuto"},
42 {3, nullptr, "OpenAudioInAuto"}, 45 {3, &AudInU::OpenAudioIn, "OpenAudioInAuto"},
43 {4, nullptr, "ListAudioInsAuto"}, 46 {4, &AudInU::ListAudioInsAutoFiltered, "ListAudioInsAutoFiltered"},
47 {5, &AudInU::OpenAudioInProtocolSpecified, "OpenAudioInProtocolSpecified"},
44 }; 48 };
45 // clang-format on 49 // clang-format on
46 50
@@ -49,4 +53,60 @@ AudInU::AudInU() : ServiceFramework("audin:u") {
49 53
50AudInU::~AudInU() = default; 54AudInU::~AudInU() = default;
51 55
56void AudInU::ListAudioIns(Kernel::HLERequestContext& ctx) {
57 LOG_DEBUG(Service_Audio, "called");
58 const std::size_t count = ctx.GetWriteBufferSize() / sizeof(AudioInDeviceName);
59
60 const std::size_t device_count = std::min(count, audio_device_names.size());
61 std::vector<AudioInDeviceName> device_names;
62 device_names.reserve(device_count);
63
64 for (std::size_t i = 0; i < device_count; i++) {
65 const auto& device_name = audio_device_names[i];
66 auto& entry = device_names.emplace_back();
67 device_name.copy(entry.data(), device_name.size());
68 }
69
70 ctx.WriteBuffer(device_names);
71
72 IPC::ResponseBuilder rb{ctx, 3};
73 rb.Push(RESULT_SUCCESS);
74 rb.Push(static_cast<u32>(device_names.size()));
75}
76
77void AudInU::ListAudioInsAutoFiltered(Kernel::HLERequestContext& ctx) {
78 LOG_DEBUG(Service_Audio, "called");
79 constexpr u32 device_count = 0;
80
81 // Since we don't actually use any other audio input devices, we return 0 devices. Filtered
82 // device listing just omits the default input device
83
84 IPC::ResponseBuilder rb{ctx, 3};
85 rb.Push(RESULT_SUCCESS);
86 rb.Push(static_cast<u32>(device_count));
87}
88
89void AudInU::OpenInOutImpl(Kernel::HLERequestContext& ctx) {
90 AudInOutParams params{};
91 params.channel_count = 2;
92 params.sample_format = SampleFormat::PCM16;
93 params.sample_rate = 48000;
94 params.state = State::Started;
95
96 IPC::ResponseBuilder rb{ctx, 6, 0, 1};
97 rb.Push(RESULT_SUCCESS);
98 rb.PushRaw<AudInOutParams>(params);
99 rb.PushIpcInterface<IAudioIn>();
100}
101
102void AudInU::OpenAudioIn(Kernel::HLERequestContext& ctx) {
103 LOG_WARNING(Service_Audio, "(STUBBED) called");
104 OpenInOutImpl(ctx);
105}
106
107void AudInU::OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx) {
108 LOG_WARNING(Service_Audio, "(STUBBED) called");
109 OpenInOutImpl(ctx);
110}
111
52} // namespace Service::Audio 112} // namespace Service::Audio
diff --git a/src/core/hle/service/audio/audin_u.h b/src/core/hle/service/audio/audin_u.h
index 0538b9560..a599f4a64 100644
--- a/src/core/hle/service/audio/audin_u.h
+++ b/src/core/hle/service/audio/audin_u.h
@@ -16,6 +16,35 @@ class AudInU final : public ServiceFramework<AudInU> {
16public: 16public:
17 explicit AudInU(); 17 explicit AudInU();
18 ~AudInU() override; 18 ~AudInU() override;
19
20private:
21 enum class SampleFormat : u32_le {
22 PCM16 = 2,
23 };
24
25 enum class State : u32_le {
26 Started = 0,
27 Stopped = 1,
28 };
29
30 struct AudInOutParams {
31 u32_le sample_rate{};
32 u32_le channel_count{};
33 SampleFormat sample_format{};
34 State state{};
35 };
36 static_assert(sizeof(AudInOutParams) == 0x10, "AudInOutParams is an invalid size");
37
38 using AudioInDeviceName = std::array<char, 256>;
39 static constexpr std::array<std::string_view, 1> audio_device_names{{
40 "BuiltInHeadset",
41 }};
42
43 void ListAudioIns(Kernel::HLERequestContext& ctx);
44 void ListAudioInsAutoFiltered(Kernel::HLERequestContext& ctx);
45 void OpenInOutImpl(Kernel::HLERequestContext& ctx);
46 void OpenAudioIn(Kernel::HLERequestContext& ctx);
47 void OpenAudioInProtocolSpecified(Kernel::HLERequestContext& ctx);
19}; 48};
20 49
21} // namespace Service::Audio 50} // namespace Service::Audio
diff --git a/src/core/hle/service/caps/caps_su.cpp b/src/core/hle/service/caps/caps_su.cpp
index b4d9355ef..e8b0698e8 100644
--- a/src/core/hle/service/caps/caps_su.cpp
+++ b/src/core/hle/service/caps/caps_su.cpp
@@ -2,6 +2,8 @@
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 "common/logging/log.h"
6#include "core/hle/ipc_helpers.h"
5#include "core/hle/service/caps/caps_su.h" 7#include "core/hle/service/caps/caps_su.h"
6 8
7namespace Service::Capture { 9namespace Service::Capture {
@@ -9,7 +11,7 @@ namespace Service::Capture {
9CAPS_SU::CAPS_SU() : ServiceFramework("caps:su") { 11CAPS_SU::CAPS_SU() : ServiceFramework("caps:su") {
10 // clang-format off 12 // clang-format off
11 static const FunctionInfo functions[] = { 13 static const FunctionInfo functions[] = {
12 {32, nullptr, "SetShimLibraryVersion"}, 14 {32, &CAPS_SU::SetShimLibraryVersion, "SetShimLibraryVersion"},
13 {201, nullptr, "SaveScreenShot"}, 15 {201, nullptr, "SaveScreenShot"},
14 {203, nullptr, "SaveScreenShotEx0"}, 16 {203, nullptr, "SaveScreenShotEx0"},
15 {205, nullptr, "SaveScreenShotEx1"}, 17 {205, nullptr, "SaveScreenShotEx1"},
@@ -22,4 +24,11 @@ CAPS_SU::CAPS_SU() : ServiceFramework("caps:su") {
22 24
23CAPS_SU::~CAPS_SU() = default; 25CAPS_SU::~CAPS_SU() = default;
24 26
27void CAPS_SU::SetShimLibraryVersion(Kernel::HLERequestContext& ctx) {
28 LOG_WARNING(Service_Capture, "(STUBBED) called");
29
30 IPC::ResponseBuilder rb{ctx, 2};
31 rb.Push(RESULT_SUCCESS);
32}
33
25} // namespace Service::Capture 34} // namespace Service::Capture
diff --git a/src/core/hle/service/caps/caps_su.h b/src/core/hle/service/caps/caps_su.h
index cb11f7c9a..c494d7c84 100644
--- a/src/core/hle/service/caps/caps_su.h
+++ b/src/core/hle/service/caps/caps_su.h
@@ -16,6 +16,9 @@ class CAPS_SU final : public ServiceFramework<CAPS_SU> {
16public: 16public:
17 explicit CAPS_SU(); 17 explicit CAPS_SU();
18 ~CAPS_SU() override; 18 ~CAPS_SU() override;
19
20private:
21 void SetShimLibraryVersion(Kernel::HLERequestContext& ctx);
19}; 22};
20 23
21} // namespace Service::Capture 24} // namespace Service::Capture
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
index 642b0a2cb..07b644ec5 100644
--- a/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
+++ b/src/core/hle/service/nvdrv/devices/nvhost_ctrl_gpu.h
@@ -159,9 +159,10 @@ private:
159 static_assert(sizeof(IoctlFlushL2) == 8, "IoctlFlushL2 is incorrect size"); 159 static_assert(sizeof(IoctlFlushL2) == 8, "IoctlFlushL2 is incorrect size");
160 160
161 struct IoctlGetGpuTime { 161 struct IoctlGetGpuTime {
162 u64_le gpu_time; 162 u64_le gpu_time{};
163 INSERT_PADDING_WORDS(2);
163 }; 164 };
164 static_assert(sizeof(IoctlGetGpuTime) == 8, "IoctlGetGpuTime is incorrect size"); 165 static_assert(sizeof(IoctlGetGpuTime) == 0x10, "IoctlGetGpuTime is incorrect size");
165 166
166 u32 GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output, 167 u32 GetCharacteristics(const std::vector<u8>& input, std::vector<u8>& output,
167 std::vector<u8>& output2, IoctlVersion version); 168 std::vector<u8>& output2, IoctlVersion version);
diff --git a/src/core/settings.cpp b/src/core/settings.cpp
index cd6c257f5..2b0bdc4d3 100644
--- a/src/core/settings.cpp
+++ b/src/core/settings.cpp
@@ -96,6 +96,7 @@ void LogSettings() {
96 LogSetting("Renderer_UseAsynchronousGpuEmulation", 96 LogSetting("Renderer_UseAsynchronousGpuEmulation",
97 Settings::values.use_asynchronous_gpu_emulation); 97 Settings::values.use_asynchronous_gpu_emulation);
98 LogSetting("Renderer_UseVsync", Settings::values.use_vsync); 98 LogSetting("Renderer_UseVsync", Settings::values.use_vsync);
99 LogSetting("Renderer_AnisotropicFilteringLevel", Settings::values.max_anisotropy);
99 LogSetting("Audio_OutputEngine", Settings::values.sink_id); 100 LogSetting("Audio_OutputEngine", Settings::values.sink_id);
100 LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching); 101 LogSetting("Audio_EnableAudioStretching", Settings::values.enable_audio_stretching);
101 LogSetting("Audio_OutputDevice", Settings::values.audio_device_id); 102 LogSetting("Audio_OutputDevice", Settings::values.audio_device_id);
diff --git a/src/input_common/main.cpp b/src/input_common/main.cpp
index c98c848cf..95e351e24 100644
--- a/src/input_common/main.cpp
+++ b/src/input_common/main.cpp
@@ -18,7 +18,9 @@ namespace InputCommon {
18 18
19static std::shared_ptr<Keyboard> keyboard; 19static std::shared_ptr<Keyboard> keyboard;
20static std::shared_ptr<MotionEmu> motion_emu; 20static std::shared_ptr<MotionEmu> motion_emu;
21#ifdef HAVE_SDL2
21static std::unique_ptr<SDL::State> sdl; 22static std::unique_ptr<SDL::State> sdl;
23#endif
22static std::unique_ptr<CemuhookUDP::State> udp; 24static std::unique_ptr<CemuhookUDP::State> udp;
23 25
24void Init() { 26void Init() {
@@ -29,7 +31,9 @@ void Init() {
29 motion_emu = std::make_shared<MotionEmu>(); 31 motion_emu = std::make_shared<MotionEmu>();
30 Input::RegisterFactory<Input::MotionDevice>("motion_emu", motion_emu); 32 Input::RegisterFactory<Input::MotionDevice>("motion_emu", motion_emu);
31 33
34#ifdef HAVE_SDL2
32 sdl = SDL::Init(); 35 sdl = SDL::Init();
36#endif
33 37
34 udp = CemuhookUDP::Init(); 38 udp = CemuhookUDP::Init();
35} 39}
@@ -40,7 +44,9 @@ void Shutdown() {
40 Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button"); 44 Input::UnregisterFactory<Input::AnalogDevice>("analog_from_button");
41 Input::UnregisterFactory<Input::MotionDevice>("motion_emu"); 45 Input::UnregisterFactory<Input::MotionDevice>("motion_emu");
42 motion_emu.reset(); 46 motion_emu.reset();
47#ifdef HAVE_SDL2
43 sdl.reset(); 48 sdl.reset();
49#endif
44 udp.reset(); 50 udp.reset();
45} 51}
46 52
diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h
index 510f11089..56e570994 100644
--- a/src/video_core/buffer_cache/buffer_cache.h
+++ b/src/video_core/buffer_cache/buffer_cache.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
8#include <list> 7#include <list>
9#include <memory> 8#include <memory>
10#include <mutex> 9#include <mutex>
@@ -89,10 +88,6 @@ public:
89 map->MarkAsWritten(true); 88 map->MarkAsWritten(true);
90 MarkRegionAsWritten(map->GetStart(), map->GetEnd() - 1); 89 MarkRegionAsWritten(map->GetStart(), map->GetEnd() - 1);
91 } 90 }
92 } else {
93 if (map->IsWritten()) {
94 WriteBarrier();
95 }
96 } 91 }
97 92
98 return {ToHandle(block), static_cast<u64>(block->GetOffset(cpu_addr))}; 93 return {ToHandle(block), static_cast<u64>(block->GetOffset(cpu_addr))};
@@ -254,8 +249,6 @@ protected:
254 249
255 virtual BufferType ToHandle(const OwnerBuffer& storage) = 0; 250 virtual BufferType ToHandle(const OwnerBuffer& storage) = 0;
256 251
257 virtual void WriteBarrier() = 0;
258
259 virtual OwnerBuffer CreateBlock(VAddr cpu_addr, std::size_t size) = 0; 252 virtual OwnerBuffer CreateBlock(VAddr cpu_addr, std::size_t size) = 0;
260 253
261 virtual void UploadBlockData(const OwnerBuffer& buffer, std::size_t offset, std::size_t size, 254 virtual void UploadBlockData(const OwnerBuffer& buffer, std::size_t offset, std::size_t size,
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 39e3b66a2..7db055ea0 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -184,6 +184,10 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
184 } 184 }
185 185
186 switch (method) { 186 switch (method) {
187 case MAXWELL3D_REG_INDEX(wait_for_idle): {
188 rasterizer.WaitForIdle();
189 break;
190 }
187 case MAXWELL3D_REG_INDEX(shadow_ram_control): { 191 case MAXWELL3D_REG_INDEX(shadow_ram_control): {
188 shadow_state.shadow_ram_control = static_cast<Regs::ShadowRamControl>(method_call.argument); 192 shadow_state.shadow_ram_control = static_cast<Regs::ShadowRamControl>(method_call.argument);
189 break; 193 break;
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 5e522e0d2..864924ff3 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -709,7 +709,9 @@ public:
709 709
710 union { 710 union {
711 struct { 711 struct {
712 INSERT_UNION_PADDING_WORDS(0x45); 712 INSERT_UNION_PADDING_WORDS(0x44);
713
714 u32 wait_for_idle;
713 715
714 struct { 716 struct {
715 u32 upload_address; 717 u32 upload_address;
@@ -1536,6 +1538,7 @@ private:
1536 static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \ 1538 static_assert(offsetof(Maxwell3D::Regs, field_name) == position * 4, \
1537 "Field " #field_name " has invalid position") 1539 "Field " #field_name " has invalid position")
1538 1540
1541ASSERT_REG_POSITION(wait_for_idle, 0x44);
1539ASSERT_REG_POSITION(macros, 0x45); 1542ASSERT_REG_POSITION(macros, 0x45);
1540ASSERT_REG_POSITION(shadow_ram_control, 0x49); 1543ASSERT_REG_POSITION(shadow_ram_control, 0x49);
1541ASSERT_REG_POSITION(upload, 0x60); 1544ASSERT_REG_POSITION(upload, 0x60);
diff --git a/src/video_core/fence_manager.h b/src/video_core/fence_manager.h
index dabd1588c..8b2a6a42c 100644
--- a/src/video_core/fence_manager.h
+++ b/src/video_core/fence_manager.h
@@ -88,7 +88,8 @@ public:
88 } 88 }
89 PopAsyncFlushes(); 89 PopAsyncFlushes();
90 if (current_fence->IsSemaphore()) { 90 if (current_fence->IsSemaphore()) {
91 memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload()); 91 memory_manager.template Write<u32>(current_fence->GetAddress(),
92 current_fence->GetPayload());
92 } else { 93 } else {
93 gpu.IncrementSyncPoint(current_fence->GetPayload()); 94 gpu.IncrementSyncPoint(current_fence->GetPayload());
94 } 95 }
@@ -134,7 +135,8 @@ private:
134 } 135 }
135 PopAsyncFlushes(); 136 PopAsyncFlushes();
136 if (current_fence->IsSemaphore()) { 137 if (current_fence->IsSemaphore()) {
137 memory_manager.Write<u32>(current_fence->GetAddress(), current_fence->GetPayload()); 138 memory_manager.template Write<u32>(current_fence->GetAddress(),
139 current_fence->GetPayload());
138 } else { 140 } else {
139 gpu.IncrementSyncPoint(current_fence->GetPayload()); 141 gpu.IncrementSyncPoint(current_fence->GetPayload());
140 } 142 }
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h
index 603f61952..3cbdac8e7 100644
--- a/src/video_core/rasterizer_interface.h
+++ b/src/video_core/rasterizer_interface.h
@@ -80,6 +80,9 @@ public:
80 /// and invalidated 80 /// and invalidated
81 virtual void FlushAndInvalidateRegion(VAddr addr, u64 size) = 0; 81 virtual void FlushAndInvalidateRegion(VAddr addr, u64 size) = 0;
82 82
83 /// Notify the host renderer to wait for previous primitive and compute operations.
84 virtual void WaitForIdle() = 0;
85
83 /// Notify the rasterizer to send all written commands to the host GPU. 86 /// Notify the rasterizer to send all written commands to the host GPU.
84 virtual void FlushCommands() = 0; 87 virtual void FlushCommands() = 0;
85 88
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
index 4efce0de7..d2cab50bd 100644
--- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
@@ -51,10 +51,6 @@ Buffer OGLBufferCache::CreateBlock(VAddr cpu_addr, std::size_t size) {
51 return std::make_shared<CachedBufferBlock>(cpu_addr, size); 51 return std::make_shared<CachedBufferBlock>(cpu_addr, size);
52} 52}
53 53
54void OGLBufferCache::WriteBarrier() {
55 glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT);
56}
57
58GLuint OGLBufferCache::ToHandle(const Buffer& buffer) { 54GLuint OGLBufferCache::ToHandle(const Buffer& buffer) {
59 return buffer->GetHandle(); 55 return buffer->GetHandle();
60} 56}
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h
index a74817857..a9e86cfc7 100644
--- a/src/video_core/renderer_opengl/gl_buffer_cache.h
+++ b/src/video_core/renderer_opengl/gl_buffer_cache.h
@@ -59,8 +59,6 @@ protected:
59 59
60 GLuint ToHandle(const Buffer& buffer) override; 60 GLuint ToHandle(const Buffer& buffer) override;
61 61
62 void WriteBarrier() override;
63
64 void UploadBlockData(const Buffer& buffer, std::size_t offset, std::size_t size, 62 void UploadBlockData(const Buffer& buffer, std::size_t offset, std::size_t size,
65 const u8* data) override; 63 const u8* data) override;
66 64
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index f33c4a8f9..8b3b3ce92 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -59,14 +59,12 @@ constexpr std::size_t NumSupportedVertexAttributes = 16;
59template <typename Engine, typename Entry> 59template <typename Engine, typename Entry>
60Tegra::Texture::FullTextureInfo GetTextureInfo(const Engine& engine, const Entry& entry, 60Tegra::Texture::FullTextureInfo GetTextureInfo(const Engine& engine, const Entry& entry,
61 ShaderType shader_type, std::size_t index = 0) { 61 ShaderType shader_type, std::size_t index = 0) {
62 if (entry.IsBindless()) { 62 if (entry.is_bindless) {
63 const Tegra::Texture::TextureHandle tex_handle = 63 const auto tex_handle = engine.AccessConstBuffer32(shader_type, entry.buffer, entry.offset);
64 engine.AccessConstBuffer32(shader_type, entry.GetBuffer(), entry.GetOffset());
65 return engine.GetTextureInfo(tex_handle); 64 return engine.GetTextureInfo(tex_handle);
66 } 65 }
67 const auto& gpu_profile = engine.AccessGuestDriverProfile(); 66 const auto& gpu_profile = engine.AccessGuestDriverProfile();
68 const u32 offset = 67 const u32 offset = entry.offset + static_cast<u32>(index * gpu_profile.GetTextureHandlerSize());
69 entry.GetOffset() + static_cast<u32>(index * gpu_profile.GetTextureHandlerSize());
70 if constexpr (std::is_same_v<Engine, Tegra::Engines::Maxwell3D>) { 68 if constexpr (std::is_same_v<Engine, Tegra::Engines::Maxwell3D>) {
71 return engine.GetStageTexture(shader_type, offset); 69 return engine.GetStageTexture(shader_type, offset);
72 } else { 70 } else {
@@ -748,6 +746,17 @@ void RasterizerOpenGL::FlushAndInvalidateRegion(VAddr addr, u64 size) {
748 InvalidateRegion(addr, size); 746 InvalidateRegion(addr, size);
749} 747}
750 748
749void RasterizerOpenGL::WaitForIdle() {
750 // Place a barrier on everything that is not framebuffer related.
751 // This is related to another flag that is not currently implemented.
752 glMemoryBarrier(GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT | GL_ELEMENT_ARRAY_BARRIER_BIT |
753 GL_UNIFORM_BARRIER_BIT | GL_TEXTURE_FETCH_BARRIER_BIT |
754 GL_SHADER_IMAGE_ACCESS_BARRIER_BIT | GL_COMMAND_BARRIER_BIT |
755 GL_PIXEL_BUFFER_BARRIER_BIT | GL_TEXTURE_UPDATE_BARRIER_BIT |
756 GL_BUFFER_UPDATE_BARRIER_BIT | GL_TRANSFORM_FEEDBACK_BARRIER_BIT |
757 GL_SHADER_STORAGE_BARRIER_BIT | GL_QUERY_BUFFER_BARRIER_BIT);
758}
759
751void RasterizerOpenGL::FlushCommands() { 760void RasterizerOpenGL::FlushCommands() {
752 // Only flush when we have commands queued to OpenGL. 761 // Only flush when we have commands queued to OpenGL.
753 if (num_queued_commands == 0) { 762 if (num_queued_commands == 0) {
@@ -856,9 +865,9 @@ void RasterizerOpenGL::SetupDrawGlobalMemory(std::size_t stage_index, const Shad
856 865
857 u32 binding = device.GetBaseBindings(stage_index).shader_storage_buffer; 866 u32 binding = device.GetBaseBindings(stage_index).shader_storage_buffer;
858 for (const auto& entry : shader->GetEntries().global_memory_entries) { 867 for (const auto& entry : shader->GetEntries().global_memory_entries) {
859 const auto addr{cbufs.const_buffers[entry.GetCbufIndex()].address + entry.GetCbufOffset()}; 868 const GPUVAddr addr{cbufs.const_buffers[entry.cbuf_index].address + entry.cbuf_offset};
860 const auto gpu_addr{memory_manager.Read<u64>(addr)}; 869 const GPUVAddr gpu_addr{memory_manager.Read<u64>(addr)};
861 const auto size{memory_manager.Read<u32>(addr + 8)}; 870 const u32 size{memory_manager.Read<u32>(addr + 8)};
862 SetupGlobalMemory(binding++, entry, gpu_addr, size); 871 SetupGlobalMemory(binding++, entry, gpu_addr, size);
863 } 872 }
864} 873}
@@ -870,7 +879,7 @@ void RasterizerOpenGL::SetupComputeGlobalMemory(const Shader& kernel) {
870 879
871 u32 binding = 0; 880 u32 binding = 0;
872 for (const auto& entry : kernel->GetEntries().global_memory_entries) { 881 for (const auto& entry : kernel->GetEntries().global_memory_entries) {
873 const auto addr{cbufs[entry.GetCbufIndex()].Address() + entry.GetCbufOffset()}; 882 const auto addr{cbufs[entry.cbuf_index].Address() + entry.cbuf_offset};
874 const auto gpu_addr{memory_manager.Read<u64>(addr)}; 883 const auto gpu_addr{memory_manager.Read<u64>(addr)};
875 const auto size{memory_manager.Read<u32>(addr + 8)}; 884 const auto size{memory_manager.Read<u32>(addr + 8)};
876 SetupGlobalMemory(binding++, entry, gpu_addr, size); 885 SetupGlobalMemory(binding++, entry, gpu_addr, size);
@@ -881,7 +890,7 @@ void RasterizerOpenGL::SetupGlobalMemory(u32 binding, const GlobalMemoryEntry& e
881 GPUVAddr gpu_addr, std::size_t size) { 890 GPUVAddr gpu_addr, std::size_t size) {
882 const auto alignment{device.GetShaderStorageBufferAlignment()}; 891 const auto alignment{device.GetShaderStorageBufferAlignment()};
883 const auto [ssbo, buffer_offset] = 892 const auto [ssbo, buffer_offset] =
884 buffer_cache.UploadMemory(gpu_addr, size, alignment, entry.IsWritten()); 893 buffer_cache.UploadMemory(gpu_addr, size, alignment, entry.is_written);
885 glBindBufferRange(GL_SHADER_STORAGE_BUFFER, binding, ssbo, buffer_offset, 894 glBindBufferRange(GL_SHADER_STORAGE_BUFFER, binding, ssbo, buffer_offset,
886 static_cast<GLsizeiptr>(size)); 895 static_cast<GLsizeiptr>(size));
887} 896}
@@ -892,7 +901,7 @@ void RasterizerOpenGL::SetupDrawTextures(std::size_t stage_index, const Shader&
892 u32 binding = device.GetBaseBindings(stage_index).sampler; 901 u32 binding = device.GetBaseBindings(stage_index).sampler;
893 for (const auto& entry : shader->GetEntries().samplers) { 902 for (const auto& entry : shader->GetEntries().samplers) {
894 const auto shader_type = static_cast<ShaderType>(stage_index); 903 const auto shader_type = static_cast<ShaderType>(stage_index);
895 for (std::size_t i = 0; i < entry.Size(); ++i) { 904 for (std::size_t i = 0; i < entry.size; ++i) {
896 const auto texture = GetTextureInfo(maxwell3d, entry, shader_type, i); 905 const auto texture = GetTextureInfo(maxwell3d, entry, shader_type, i);
897 SetupTexture(binding++, texture, entry); 906 SetupTexture(binding++, texture, entry);
898 } 907 }
@@ -904,7 +913,7 @@ void RasterizerOpenGL::SetupComputeTextures(const Shader& kernel) {
904 const auto& compute = system.GPU().KeplerCompute(); 913 const auto& compute = system.GPU().KeplerCompute();
905 u32 binding = 0; 914 u32 binding = 0;
906 for (const auto& entry : kernel->GetEntries().samplers) { 915 for (const auto& entry : kernel->GetEntries().samplers) {
907 for (std::size_t i = 0; i < entry.Size(); ++i) { 916 for (std::size_t i = 0; i < entry.size; ++i) {
908 const auto texture = GetTextureInfo(compute, entry, ShaderType::Compute, i); 917 const auto texture = GetTextureInfo(compute, entry, ShaderType::Compute, i);
909 SetupTexture(binding++, texture, entry); 918 SetupTexture(binding++, texture, entry);
910 } 919 }
@@ -961,7 +970,7 @@ void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& t
961 if (!tic.IsBuffer()) { 970 if (!tic.IsBuffer()) {
962 view->ApplySwizzle(tic.x_source, tic.y_source, tic.z_source, tic.w_source); 971 view->ApplySwizzle(tic.x_source, tic.y_source, tic.z_source, tic.w_source);
963 } 972 }
964 if (entry.IsWritten()) { 973 if (entry.is_written) {
965 view->MarkAsModified(texture_cache.Tick()); 974 view->MarkAsModified(texture_cache.Tick());
966 } 975 }
967 glBindImageTexture(binding, view->GetTexture(), 0, GL_TRUE, 0, GL_READ_WRITE, 976 glBindImageTexture(binding, view->GetTexture(), 0, GL_TRUE, 0, GL_READ_WRITE,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 87249fb6f..b94c65907 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -75,6 +75,7 @@ public:
75 void SignalSyncPoint(u32 value) override; 75 void SignalSyncPoint(u32 value) override;
76 void ReleaseFences() override; 76 void ReleaseFences() override;
77 void FlushAndInvalidateRegion(VAddr addr, u64 size) override; 77 void FlushAndInvalidateRegion(VAddr addr, u64 size) override;
78 void WaitForIdle() override;
78 void FlushCommands() override; 79 void FlushCommands() override;
79 void TickFrame() override; 80 void TickFrame() override;
80 bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src, 81 bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 3803a6f3a..99fd4ae2c 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -870,13 +870,13 @@ private:
870 for (const auto& sampler : ir.GetSamplers()) { 870 for (const auto& sampler : ir.GetSamplers()) {
871 const std::string name = GetSampler(sampler); 871 const std::string name = GetSampler(sampler);
872 const std::string description = fmt::format("layout (binding = {}) uniform", binding); 872 const std::string description = fmt::format("layout (binding = {}) uniform", binding);
873 binding += sampler.IsIndexed() ? sampler.Size() : 1; 873 binding += sampler.is_indexed ? sampler.size : 1;
874 874
875 std::string sampler_type = [&]() { 875 std::string sampler_type = [&]() {
876 if (sampler.IsBuffer()) { 876 if (sampler.is_buffer) {
877 return "samplerBuffer"; 877 return "samplerBuffer";
878 } 878 }
879 switch (sampler.GetType()) { 879 switch (sampler.type) {
880 case Tegra::Shader::TextureType::Texture1D: 880 case Tegra::Shader::TextureType::Texture1D:
881 return "sampler1D"; 881 return "sampler1D";
882 case Tegra::Shader::TextureType::Texture2D: 882 case Tegra::Shader::TextureType::Texture2D:
@@ -890,17 +890,17 @@ private:
890 return "sampler2D"; 890 return "sampler2D";
891 } 891 }
892 }(); 892 }();
893 if (sampler.IsArray()) { 893 if (sampler.is_array) {
894 sampler_type += "Array"; 894 sampler_type += "Array";
895 } 895 }
896 if (sampler.IsShadow()) { 896 if (sampler.is_shadow) {
897 sampler_type += "Shadow"; 897 sampler_type += "Shadow";
898 } 898 }
899 899
900 if (!sampler.IsIndexed()) { 900 if (!sampler.is_indexed) {
901 code.AddLine("{} {} {};", description, sampler_type, name); 901 code.AddLine("{} {} {};", description, sampler_type, name);
902 } else { 902 } else {
903 code.AddLine("{} {} {}[{}];", description, sampler_type, name, sampler.Size()); 903 code.AddLine("{} {} {}[{}];", description, sampler_type, name, sampler.size);
904 } 904 }
905 } 905 }
906 if (!ir.GetSamplers().empty()) { 906 if (!ir.GetSamplers().empty()) {
@@ -946,14 +946,14 @@ private:
946 u32 binding = device.GetBaseBindings(stage).image; 946 u32 binding = device.GetBaseBindings(stage).image;
947 for (const auto& image : ir.GetImages()) { 947 for (const auto& image : ir.GetImages()) {
948 std::string qualifier = "coherent volatile"; 948 std::string qualifier = "coherent volatile";
949 if (image.IsRead() && !image.IsWritten()) { 949 if (image.is_read && !image.is_written) {
950 qualifier += " readonly"; 950 qualifier += " readonly";
951 } else if (image.IsWritten() && !image.IsRead()) { 951 } else if (image.is_written && !image.is_read) {
952 qualifier += " writeonly"; 952 qualifier += " writeonly";
953 } 953 }
954 954
955 const char* format = image.IsAtomic() ? "r32ui, " : ""; 955 const char* format = image.is_atomic ? "r32ui, " : "";
956 const char* type_declaration = GetImageTypeDeclaration(image.GetType()); 956 const char* type_declaration = GetImageTypeDeclaration(image.type);
957 code.AddLine("layout ({}binding = {}) {} uniform uimage{} {};", format, binding++, 957 code.AddLine("layout ({}binding = {}) {} uniform uimage{} {};", format, binding++,
958 qualifier, type_declaration, GetImage(image)); 958 qualifier, type_declaration, GetImage(image));
959 } 959 }
@@ -1337,8 +1337,8 @@ private:
1337 ASSERT(meta); 1337 ASSERT(meta);
1338 1338
1339 const std::size_t count = operation.GetOperandsCount(); 1339 const std::size_t count = operation.GetOperandsCount();
1340 const bool has_array = meta->sampler.IsArray(); 1340 const bool has_array = meta->sampler.is_array;
1341 const bool has_shadow = meta->sampler.IsShadow(); 1341 const bool has_shadow = meta->sampler.is_shadow;
1342 1342
1343 std::string expr = "texture" + function_suffix; 1343 std::string expr = "texture" + function_suffix;
1344 if (!meta->aoffi.empty()) { 1344 if (!meta->aoffi.empty()) {
@@ -1346,7 +1346,7 @@ private:
1346 } else if (!meta->ptp.empty()) { 1346 } else if (!meta->ptp.empty()) {
1347 expr += "Offsets"; 1347 expr += "Offsets";
1348 } 1348 }
1349 if (!meta->sampler.IsIndexed()) { 1349 if (!meta->sampler.is_indexed) {
1350 expr += '(' + GetSampler(meta->sampler) + ", "; 1350 expr += '(' + GetSampler(meta->sampler) + ", ";
1351 } else { 1351 } else {
1352 expr += '(' + GetSampler(meta->sampler) + '[' + Visit(meta->index).AsUint() + "], "; 1352 expr += '(' + GetSampler(meta->sampler) + '[' + Visit(meta->index).AsUint() + "], ";
@@ -1982,7 +1982,7 @@ private:
1982 1982
1983 std::string expr = GenerateTexture( 1983 std::string expr = GenerateTexture(
1984 operation, "", {TextureOffset{}, TextureArgument{Type::Float, meta->bias}}); 1984 operation, "", {TextureOffset{}, TextureArgument{Type::Float, meta->bias}});
1985 if (meta->sampler.IsShadow()) { 1985 if (meta->sampler.is_shadow) {
1986 expr = "vec4(" + expr + ')'; 1986 expr = "vec4(" + expr + ')';
1987 } 1987 }
1988 return {expr + GetSwizzle(meta->element), Type::Float}; 1988 return {expr + GetSwizzle(meta->element), Type::Float};
@@ -1994,7 +1994,7 @@ private:
1994 1994
1995 std::string expr = GenerateTexture( 1995 std::string expr = GenerateTexture(
1996 operation, "Lod", {TextureArgument{Type::Float, meta->lod}, TextureOffset{}}); 1996 operation, "Lod", {TextureArgument{Type::Float, meta->lod}, TextureOffset{}});
1997 if (meta->sampler.IsShadow()) { 1997 if (meta->sampler.is_shadow) {
1998 expr = "vec4(" + expr + ')'; 1998 expr = "vec4(" + expr + ')';
1999 } 1999 }
2000 return {expr + GetSwizzle(meta->element), Type::Float}; 2000 return {expr + GetSwizzle(meta->element), Type::Float};
@@ -2003,11 +2003,11 @@ private:
2003 Expression TextureGather(Operation operation) { 2003 Expression TextureGather(Operation operation) {
2004 const auto& meta = std::get<MetaTexture>(operation.GetMeta()); 2004 const auto& meta = std::get<MetaTexture>(operation.GetMeta());
2005 2005
2006 const auto type = meta.sampler.IsShadow() ? Type::Float : Type::Int; 2006 const auto type = meta.sampler.is_shadow ? Type::Float : Type::Int;
2007 const bool separate_dc = meta.sampler.IsShadow(); 2007 const bool separate_dc = meta.sampler.is_shadow;
2008 2008
2009 std::vector<TextureIR> ir; 2009 std::vector<TextureIR> ir;
2010 if (meta.sampler.IsShadow()) { 2010 if (meta.sampler.is_shadow) {
2011 ir = {TextureOffset{}}; 2011 ir = {TextureOffset{}};
2012 } else { 2012 } else {
2013 ir = {TextureOffset{}, TextureArgument{type, meta.component}}; 2013 ir = {TextureOffset{}, TextureArgument{type, meta.component}};
@@ -2052,7 +2052,7 @@ private:
2052 constexpr std::array constructors = {"int", "ivec2", "ivec3", "ivec4"}; 2052 constexpr std::array constructors = {"int", "ivec2", "ivec3", "ivec4"};
2053 const auto meta = std::get_if<MetaTexture>(&operation.GetMeta()); 2053 const auto meta = std::get_if<MetaTexture>(&operation.GetMeta());
2054 ASSERT(meta); 2054 ASSERT(meta);
2055 UNIMPLEMENTED_IF(meta->sampler.IsArray()); 2055 UNIMPLEMENTED_IF(meta->sampler.is_array);
2056 const std::size_t count = operation.GetOperandsCount(); 2056 const std::size_t count = operation.GetOperandsCount();
2057 2057
2058 std::string expr = "texelFetch("; 2058 std::string expr = "texelFetch(";
@@ -2073,7 +2073,7 @@ private:
2073 } 2073 }
2074 expr += ')'; 2074 expr += ')';
2075 2075
2076 if (meta->lod && !meta->sampler.IsBuffer()) { 2076 if (meta->lod && !meta->sampler.is_buffer) {
2077 expr += ", "; 2077 expr += ", ";
2078 expr += Visit(meta->lod).AsInt(); 2078 expr += Visit(meta->lod).AsInt();
2079 } 2079 }
@@ -2084,12 +2084,10 @@ private:
2084 } 2084 }
2085 2085
2086 Expression TextureGradient(Operation operation) { 2086 Expression TextureGradient(Operation operation) {
2087 const auto meta = std::get_if<MetaTexture>(&operation.GetMeta()); 2087 const auto& meta = std::get<MetaTexture>(operation.GetMeta());
2088 ASSERT(meta);
2089
2090 std::string expr = 2088 std::string expr =
2091 GenerateTexture(operation, "Grad", {TextureDerivates{}, TextureOffset{}}); 2089 GenerateTexture(operation, "Grad", {TextureDerivates{}, TextureOffset{}});
2092 return {std::move(expr) + GetSwizzle(meta->element), Type::Float}; 2090 return {std::move(expr) + GetSwizzle(meta.element), Type::Float};
2093 } 2091 }
2094 2092
2095 Expression ImageLoad(Operation operation) { 2093 Expression ImageLoad(Operation operation) {
@@ -2608,11 +2606,11 @@ private:
2608 } 2606 }
2609 2607
2610 std::string GetSampler(const Sampler& sampler) const { 2608 std::string GetSampler(const Sampler& sampler) const {
2611 return AppendSuffix(static_cast<u32>(sampler.GetIndex()), "sampler"); 2609 return AppendSuffix(sampler.index, "sampler");
2612 } 2610 }
2613 2611
2614 std::string GetImage(const Image& image) const { 2612 std::string GetImage(const Image& image) const {
2615 return AppendSuffix(static_cast<u32>(image.GetIndex()), "image"); 2613 return AppendSuffix(image.index, "image");
2616 } 2614 }
2617 2615
2618 std::string AppendSuffix(u32 index, std::string_view name) const { 2616 std::string AppendSuffix(u32 index, std::string_view name) const {
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.h b/src/video_core/renderer_opengl/gl_shader_decompiler.h
index e7dbd810c..e8a178764 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.h
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.h
@@ -33,36 +33,19 @@ public:
33 } 33 }
34 34
35private: 35private:
36 u32 index{}; 36 u32 index = 0;
37}; 37};
38 38
39class GlobalMemoryEntry { 39struct GlobalMemoryEntry {
40public: 40 constexpr explicit GlobalMemoryEntry(u32 cbuf_index, u32 cbuf_offset, bool is_read,
41 explicit GlobalMemoryEntry(u32 cbuf_index, u32 cbuf_offset, bool is_read, bool is_written) 41 bool is_written)
42 : cbuf_index{cbuf_index}, cbuf_offset{cbuf_offset}, is_read{is_read}, is_written{ 42 : cbuf_index{cbuf_index}, cbuf_offset{cbuf_offset}, is_read{is_read}, is_written{
43 is_written} {} 43 is_written} {}
44 44
45 u32 GetCbufIndex() const { 45 u32 cbuf_index = 0;
46 return cbuf_index; 46 u32 cbuf_offset = 0;
47 } 47 bool is_read = false;
48 48 bool is_written = false;
49 u32 GetCbufOffset() const {
50 return cbuf_offset;
51 }
52
53 bool IsRead() const {
54 return is_read;
55 }
56
57 bool IsWritten() const {
58 return is_written;
59 }
60
61private:
62 u32 cbuf_index{};
63 u32 cbuf_offset{};
64 bool is_read{};
65 bool is_written{};
66}; 49};
67 50
68struct ShaderEntries { 51struct ShaderEntries {
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp
index 04532f8f8..59b441943 100644
--- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp
+++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp
@@ -12,15 +12,12 @@
12 12
13#include <fmt/format.h> 13#include <fmt/format.h>
14 14
15#include "common/assert.h"
16#include "common/dynamic_library.h" 15#include "common/dynamic_library.h"
17#include "common/logging/log.h" 16#include "common/logging/log.h"
18#include "common/telemetry.h" 17#include "common/telemetry.h"
19#include "core/core.h" 18#include "core/core.h"
20#include "core/core_timing.h" 19#include "core/core_timing.h"
21#include "core/frontend/emu_window.h" 20#include "core/frontend/emu_window.h"
22#include "core/memory.h"
23#include "core/perf_stats.h"
24#include "core/settings.h" 21#include "core/settings.h"
25#include "core/telemetry_session.h" 22#include "core/telemetry_session.h"
26#include "video_core/gpu.h" 23#include "video_core/gpu.h"
diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h
index 18270909b..522b5bff8 100644
--- a/src/video_core/renderer_vulkan/renderer_vulkan.h
+++ b/src/video_core/renderer_vulkan/renderer_vulkan.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <optional>
9#include <string> 8#include <string>
10#include <vector> 9#include <vector>
11 10
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.h b/src/video_core/renderer_vulkan/vk_blit_screen.h
index 5eb544aea..243640fab 100644
--- a/src/video_core/renderer_vulkan/vk_blit_screen.h
+++ b/src/video_core/renderer_vulkan/vk_blit_screen.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <array>
8#include <memory> 7#include <memory>
9#include <tuple> 8#include <tuple>
10 9
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
index 81e1de2be..5b494da8c 100644
--- a/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_buffer_cache.cpp
@@ -5,11 +5,7 @@
5#include <algorithm> 5#include <algorithm>
6#include <cstring> 6#include <cstring>
7#include <memory> 7#include <memory>
8#include <optional>
9#include <tuple>
10 8
11#include "common/assert.h"
12#include "common/bit_util.h"
13#include "core/core.h" 9#include "core/core.h"
14#include "video_core/renderer_vulkan/vk_buffer_cache.h" 10#include "video_core/renderer_vulkan/vk_buffer_cache.h"
15#include "video_core/renderer_vulkan/vk_device.h" 11#include "video_core/renderer_vulkan/vk_device.h"
diff --git a/src/video_core/renderer_vulkan/vk_buffer_cache.h b/src/video_core/renderer_vulkan/vk_buffer_cache.h
index 3cd2e2774..a54583e7d 100644
--- a/src/video_core/renderer_vulkan/vk_buffer_cache.h
+++ b/src/video_core/renderer_vulkan/vk_buffer_cache.h
@@ -5,14 +5,11 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <unordered_map>
9#include <vector>
10 8
11#include "common/common_types.h" 9#include "common/common_types.h"
12#include "video_core/buffer_cache/buffer_cache.h" 10#include "video_core/buffer_cache/buffer_cache.h"
13#include "video_core/rasterizer_cache.h" 11#include "video_core/rasterizer_cache.h"
14#include "video_core/renderer_vulkan/vk_memory_manager.h" 12#include "video_core/renderer_vulkan/vk_memory_manager.h"
15#include "video_core/renderer_vulkan/vk_resource_manager.h"
16#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h" 13#include "video_core/renderer_vulkan/vk_staging_buffer_pool.h"
17#include "video_core/renderer_vulkan/vk_stream_buffer.h" 14#include "video_core/renderer_vulkan/vk_stream_buffer.h"
18#include "video_core/renderer_vulkan/wrapper.h" 15#include "video_core/renderer_vulkan/wrapper.h"
@@ -55,8 +52,6 @@ public:
55protected: 52protected:
56 VkBuffer ToHandle(const Buffer& buffer) override; 53 VkBuffer ToHandle(const Buffer& buffer) override;
57 54
58 void WriteBarrier() override {}
59
60 Buffer CreateBlock(VAddr cpu_addr, std::size_t size) override; 55 Buffer CreateBlock(VAddr cpu_addr, std::size_t size) override;
61 56
62 void UploadBlockData(const Buffer& buffer, std::size_t offset, std::size_t size, 57 void UploadBlockData(const Buffer& buffer, std::size_t offset, std::size_t size,
diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.cpp b/src/video_core/renderer_vulkan/vk_compute_pass.cpp
index 7b0268033..da71e710c 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pass.cpp
+++ b/src/video_core/renderer_vulkan/vk_compute_pass.cpp
@@ -6,7 +6,7 @@
6#include <memory> 6#include <memory>
7#include <optional> 7#include <optional>
8#include <utility> 8#include <utility>
9#include <vector> 9
10#include "common/alignment.h" 10#include "common/alignment.h"
11#include "common/assert.h" 11#include "common/assert.h"
12#include "common/common_types.h" 12#include "common/common_types.h"
diff --git a/src/video_core/renderer_vulkan/vk_compute_pass.h b/src/video_core/renderer_vulkan/vk_compute_pass.h
index 26bf834de..230b526bc 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pass.h
+++ b/src/video_core/renderer_vulkan/vk_compute_pass.h
@@ -6,7 +6,7 @@
6 6
7#include <optional> 7#include <optional>
8#include <utility> 8#include <utility>
9#include <vector> 9
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "video_core/engines/maxwell_3d.h" 11#include "video_core/engines/maxwell_3d.h"
12#include "video_core/renderer_vulkan/vk_descriptor_pool.h" 12#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
index 52566bb79..8e1b46277 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp
@@ -2,14 +2,12 @@
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 <memory>
6#include <vector> 5#include <vector>
7 6
8#include "video_core/renderer_vulkan/vk_compute_pipeline.h" 7#include "video_core/renderer_vulkan/vk_compute_pipeline.h"
9#include "video_core/renderer_vulkan/vk_descriptor_pool.h" 8#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
10#include "video_core/renderer_vulkan/vk_device.h" 9#include "video_core/renderer_vulkan/vk_device.h"
11#include "video_core/renderer_vulkan/vk_pipeline_cache.h" 10#include "video_core/renderer_vulkan/vk_pipeline_cache.h"
12#include "video_core/renderer_vulkan/vk_resource_manager.h"
13#include "video_core/renderer_vulkan/vk_scheduler.h" 11#include "video_core/renderer_vulkan/vk_scheduler.h"
14#include "video_core/renderer_vulkan/vk_shader_decompiler.h" 12#include "video_core/renderer_vulkan/vk_shader_decompiler.h"
15#include "video_core/renderer_vulkan/vk_update_descriptor.h" 13#include "video_core/renderer_vulkan/vk_update_descriptor.h"
diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.h b/src/video_core/renderer_vulkan/vk_compute_pipeline.h
index 33b9af29e..6e2f22a4a 100644
--- a/src/video_core/renderer_vulkan/vk_compute_pipeline.h
+++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.h
@@ -4,8 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8
9#include "common/common_types.h" 7#include "common/common_types.h"
10#include "video_core/renderer_vulkan/vk_descriptor_pool.h" 8#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
11#include "video_core/renderer_vulkan/vk_shader_decompiler.h" 9#include "video_core/renderer_vulkan/vk_shader_decompiler.h"
diff --git a/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp b/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp
index e9d528aa6..890fd52cf 100644
--- a/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp
+++ b/src/video_core/renderer_vulkan/vk_descriptor_pool.cpp
@@ -2,7 +2,6 @@
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 <memory>
6#include <vector> 5#include <vector>
7 6
8#include "common/common_types.h" 7#include "common/common_types.h"
diff --git a/src/video_core/renderer_vulkan/vk_descriptor_pool.h b/src/video_core/renderer_vulkan/vk_descriptor_pool.h
index ab40c70f0..9efa66bef 100644
--- a/src/video_core/renderer_vulkan/vk_descriptor_pool.h
+++ b/src/video_core/renderer_vulkan/vk_descriptor_pool.h
@@ -4,10 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <memory>
8#include <vector> 7#include <vector>
9 8
10#include "common/common_types.h"
11#include "video_core/renderer_vulkan/vk_resource_manager.h" 9#include "video_core/renderer_vulkan/vk_resource_manager.h"
12#include "video_core/renderer_vulkan/wrapper.h" 10#include "video_core/renderer_vulkan/wrapper.h"
13 11
diff --git a/src/video_core/renderer_vulkan/vk_device.cpp b/src/video_core/renderer_vulkan/vk_device.cpp
index e90c76492..0e4bbca97 100644
--- a/src/video_core/renderer_vulkan/vk_device.cpp
+++ b/src/video_core/renderer_vulkan/vk_device.cpp
@@ -4,7 +4,6 @@
4 4
5#include <bitset> 5#include <bitset>
6#include <chrono> 6#include <chrono>
7#include <cstdlib>
8#include <optional> 7#include <optional>
9#include <string_view> 8#include <string_view>
10#include <thread> 9#include <thread>
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index 852a17a70..1ac981974 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -6,7 +6,6 @@
6#include <cstring> 6#include <cstring>
7#include <vector> 7#include <vector>
8 8
9#include "common/assert.h"
10#include "common/common_types.h" 9#include "common/common_types.h"
11#include "common/microprofile.h" 10#include "common/microprofile.h"
12#include "video_core/renderer_vulkan/fixed_pipeline_state.h" 11#include "video_core/renderer_vulkan/fixed_pipeline_state.h"
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
index 7aba70960..a1d699a6c 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.h
@@ -5,16 +5,13 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <memory>
9#include <optional> 8#include <optional>
10#include <unordered_map>
11#include <vector> 9#include <vector>
12 10
13#include "video_core/engines/maxwell_3d.h" 11#include "video_core/engines/maxwell_3d.h"
14#include "video_core/renderer_vulkan/fixed_pipeline_state.h" 12#include "video_core/renderer_vulkan/fixed_pipeline_state.h"
15#include "video_core/renderer_vulkan/vk_descriptor_pool.h" 13#include "video_core/renderer_vulkan/vk_descriptor_pool.h"
16#include "video_core/renderer_vulkan/vk_renderpass_cache.h" 14#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
17#include "video_core/renderer_vulkan/vk_resource_manager.h"
18#include "video_core/renderer_vulkan/vk_shader_decompiler.h" 15#include "video_core/renderer_vulkan/vk_shader_decompiler.h"
19#include "video_core/renderer_vulkan/wrapper.h" 16#include "video_core/renderer_vulkan/wrapper.h"
20 17
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
index 9b703a2f0..fe45ed269 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
@@ -22,7 +22,6 @@
22#include "video_core/renderer_vulkan/vk_pipeline_cache.h" 22#include "video_core/renderer_vulkan/vk_pipeline_cache.h"
23#include "video_core/renderer_vulkan/vk_rasterizer.h" 23#include "video_core/renderer_vulkan/vk_rasterizer.h"
24#include "video_core/renderer_vulkan/vk_renderpass_cache.h" 24#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
25#include "video_core/renderer_vulkan/vk_resource_manager.h"
26#include "video_core/renderer_vulkan/vk_scheduler.h" 25#include "video_core/renderer_vulkan/vk_scheduler.h"
27#include "video_core/renderer_vulkan/vk_update_descriptor.h" 26#include "video_core/renderer_vulkan/vk_update_descriptor.h"
28#include "video_core/renderer_vulkan/wrapper.h" 27#include "video_core/renderer_vulkan/wrapper.h"
@@ -85,7 +84,7 @@ void AddBindings(std::vector<VkDescriptorSetLayoutBinding>& bindings, u32& bindi
85 u32 count = 1; 84 u32 count = 1;
86 if constexpr (descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) { 85 if constexpr (descriptor_type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) {
87 // Combined image samplers can be arrayed. 86 // Combined image samplers can be arrayed.
88 count = container[i].Size(); 87 count = container[i].size;
89 } 88 }
90 VkDescriptorSetLayoutBinding& entry = bindings.emplace_back(); 89 VkDescriptorSetLayoutBinding& entry = bindings.emplace_back();
91 entry.binding = binding++; 90 entry.binding = binding++;
@@ -362,7 +361,7 @@ void AddEntry(std::vector<VkDescriptorUpdateTemplateEntry>& template_entries, u3
362 361
363 if constexpr (descriptor_type == COMBINED_IMAGE_SAMPLER) { 362 if constexpr (descriptor_type == COMBINED_IMAGE_SAMPLER) {
364 for (u32 i = 0; i < count; ++i) { 363 for (u32 i = 0; i < count; ++i) {
365 const u32 num_samplers = container[i].Size(); 364 const u32 num_samplers = container[i].size;
366 VkDescriptorUpdateTemplateEntry& entry = template_entries.emplace_back(); 365 VkDescriptorUpdateTemplateEntry& entry = template_entries.emplace_back();
367 entry.dstBinding = binding; 366 entry.dstBinding = binding;
368 entry.dstArrayElement = 0; 367 entry.dstArrayElement = 0;
diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.h b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
index ebddafb73..0b5796fef 100644
--- a/src/video_core/renderer_vulkan/vk_pipeline_cache.h
+++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.h
@@ -21,13 +21,11 @@
21#include "video_core/renderer_vulkan/fixed_pipeline_state.h" 21#include "video_core/renderer_vulkan/fixed_pipeline_state.h"
22#include "video_core/renderer_vulkan/vk_graphics_pipeline.h" 22#include "video_core/renderer_vulkan/vk_graphics_pipeline.h"
23#include "video_core/renderer_vulkan/vk_renderpass_cache.h" 23#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
24#include "video_core/renderer_vulkan/vk_resource_manager.h"
25#include "video_core/renderer_vulkan/vk_shader_decompiler.h" 24#include "video_core/renderer_vulkan/vk_shader_decompiler.h"
26#include "video_core/renderer_vulkan/wrapper.h" 25#include "video_core/renderer_vulkan/wrapper.h"
27#include "video_core/shader/memory_util.h" 26#include "video_core/shader/memory_util.h"
28#include "video_core/shader/registry.h" 27#include "video_core/shader/registry.h"
29#include "video_core/shader/shader_ir.h" 28#include "video_core/shader/shader_ir.h"
30#include "video_core/surface.h"
31 29
32namespace Core { 30namespace Core {
33class System; 31class System;
diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp
index 813f7c162..bc91c48cc 100644
--- a/src/video_core/renderer_vulkan/vk_query_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp
@@ -4,7 +4,6 @@
4 4
5#include <algorithm> 5#include <algorithm>
6#include <cstddef> 6#include <cstddef>
7#include <cstdint>
8#include <utility> 7#include <utility>
9#include <vector> 8#include <vector>
10 9
diff --git a/src/video_core/renderer_vulkan/vk_query_cache.h b/src/video_core/renderer_vulkan/vk_query_cache.h
index b63784f4b..40119e6d3 100644
--- a/src/video_core/renderer_vulkan/vk_query_cache.h
+++ b/src/video_core/renderer_vulkan/vk_query_cache.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <cstddef> 7#include <cstddef>
8#include <cstdint>
9#include <memory> 8#include <memory>
10#include <utility> 9#include <utility>
11#include <vector> 10#include <vector>
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 776053de5..8b009fc22 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -9,14 +9,12 @@
9#include <vector> 9#include <vector>
10 10
11#include <boost/container/static_vector.hpp> 11#include <boost/container/static_vector.hpp>
12#include <boost/functional/hash.hpp>
13 12
14#include "common/alignment.h" 13#include "common/alignment.h"
15#include "common/assert.h" 14#include "common/assert.h"
16#include "common/logging/log.h" 15#include "common/logging/log.h"
17#include "common/microprofile.h" 16#include "common/microprofile.h"
18#include "core/core.h" 17#include "core/core.h"
19#include "core/memory.h"
20#include "core/settings.h" 18#include "core/settings.h"
21#include "video_core/engines/kepler_compute.h" 19#include "video_core/engines/kepler_compute.h"
22#include "video_core/engines/maxwell_3d.h" 20#include "video_core/engines/maxwell_3d.h"
@@ -119,14 +117,13 @@ template <typename Engine, typename Entry>
119Tegra::Texture::FullTextureInfo GetTextureInfo(const Engine& engine, const Entry& entry, 117Tegra::Texture::FullTextureInfo GetTextureInfo(const Engine& engine, const Entry& entry,
120 std::size_t stage, std::size_t index = 0) { 118 std::size_t stage, std::size_t index = 0) {
121 const auto stage_type = static_cast<Tegra::Engines::ShaderType>(stage); 119 const auto stage_type = static_cast<Tegra::Engines::ShaderType>(stage);
122 if (entry.IsBindless()) { 120 if (entry.is_bindless) {
123 const Tegra::Texture::TextureHandle tex_handle = 121 const auto tex_handle = engine.AccessConstBuffer32(stage_type, entry.buffer, entry.offset);
124 engine.AccessConstBuffer32(stage_type, entry.GetBuffer(), entry.GetOffset());
125 return engine.GetTextureInfo(tex_handle); 122 return engine.GetTextureInfo(tex_handle);
126 } 123 }
127 const auto& gpu_profile = engine.AccessGuestDriverProfile(); 124 const auto& gpu_profile = engine.AccessGuestDriverProfile();
128 const u32 entry_offset = static_cast<u32>(index * gpu_profile.GetTextureHandlerSize()); 125 const u32 entry_offset = static_cast<u32>(index * gpu_profile.GetTextureHandlerSize());
129 const u32 offset = entry.GetOffset() + entry_offset; 126 const u32 offset = entry.offset + entry_offset;
130 if constexpr (std::is_same_v<Engine, Tegra::Engines::Maxwell3D>) { 127 if constexpr (std::is_same_v<Engine, Tegra::Engines::Maxwell3D>) {
131 return engine.GetStageTexture(stage_type, offset); 128 return engine.GetStageTexture(stage_type, offset);
132 } else { 129 } else {
@@ -302,7 +299,7 @@ RasterizerVulkan::RasterizerVulkan(Core::System& system, Core::Frontend::EmuWind
302 buffer_cache(*this, system, device, memory_manager, scheduler, staging_pool), 299 buffer_cache(*this, system, device, memory_manager, scheduler, staging_pool),
303 sampler_cache(device), 300 sampler_cache(device),
304 fence_manager(system, *this, device, scheduler, texture_cache, buffer_cache, query_cache), 301 fence_manager(system, *this, device, scheduler, texture_cache, buffer_cache, query_cache),
305 query_cache(system, *this, device, scheduler) { 302 query_cache(system, *this, device, scheduler), wfi_event{device.GetLogical().CreateEvent()} {
306 scheduler.SetQueryCache(query_cache); 303 scheduler.SetQueryCache(query_cache);
307} 304}
308 305
@@ -576,6 +573,26 @@ void RasterizerVulkan::FlushAndInvalidateRegion(VAddr addr, u64 size) {
576 InvalidateRegion(addr, size); 573 InvalidateRegion(addr, size);
577} 574}
578 575
576void RasterizerVulkan::WaitForIdle() {
577 // Everything but wait pixel operations. This intentionally includes FRAGMENT_SHADER_BIT because
578 // fragment shaders can still write storage buffers.
579 VkPipelineStageFlags flags =
580 VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT | VK_PIPELINE_STAGE_VERTEX_INPUT_BIT |
581 VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT |
582 VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT |
583 VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
584 VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT | VK_PIPELINE_STAGE_TRANSFER_BIT;
585 if (device.IsExtTransformFeedbackSupported()) {
586 flags |= VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT;
587 }
588
589 scheduler.RequestOutsideRenderPassOperationContext();
590 scheduler.Record([event = *wfi_event, flags](vk::CommandBuffer cmdbuf) {
591 cmdbuf.SetEvent(event, flags);
592 cmdbuf.WaitEvents(event, flags, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, {}, {}, {});
593 });
594}
595
579void RasterizerVulkan::FlushCommands() { 596void RasterizerVulkan::FlushCommands() {
580 if (draw_counter > 0) { 597 if (draw_counter > 0) {
581 draw_counter = 0; 598 draw_counter = 0;
@@ -896,6 +913,9 @@ void RasterizerVulkan::SetupVertexArrays(FixedPipelineState::VertexInput& vertex
896 913
897void RasterizerVulkan::SetupIndexBuffer(BufferBindings& buffer_bindings, DrawParameters& params, 914void RasterizerVulkan::SetupIndexBuffer(BufferBindings& buffer_bindings, DrawParameters& params,
898 bool is_indexed) { 915 bool is_indexed) {
916 if (params.num_vertices == 0) {
917 return;
918 }
899 const auto& regs = system.GPU().Maxwell3D().regs; 919 const auto& regs = system.GPU().Maxwell3D().regs;
900 switch (regs.draw.topology) { 920 switch (regs.draw.topology) {
901 case Maxwell::PrimitiveTopology::Quads: { 921 case Maxwell::PrimitiveTopology::Quads: {
@@ -971,7 +991,7 @@ void RasterizerVulkan::SetupGraphicsTextures(const ShaderEntries& entries, std::
971 MICROPROFILE_SCOPE(Vulkan_Textures); 991 MICROPROFILE_SCOPE(Vulkan_Textures);
972 const auto& gpu = system.GPU().Maxwell3D(); 992 const auto& gpu = system.GPU().Maxwell3D();
973 for (const auto& entry : entries.samplers) { 993 for (const auto& entry : entries.samplers) {
974 for (std::size_t i = 0; i < entry.Size(); ++i) { 994 for (std::size_t i = 0; i < entry.size; ++i) {
975 const auto texture = GetTextureInfo(gpu, entry, stage, i); 995 const auto texture = GetTextureInfo(gpu, entry, stage, i);
976 SetupTexture(texture, entry); 996 SetupTexture(texture, entry);
977 } 997 }
@@ -1023,7 +1043,7 @@ void RasterizerVulkan::SetupComputeTextures(const ShaderEntries& entries) {
1023 MICROPROFILE_SCOPE(Vulkan_Textures); 1043 MICROPROFILE_SCOPE(Vulkan_Textures);
1024 const auto& gpu = system.GPU().KeplerCompute(); 1044 const auto& gpu = system.GPU().KeplerCompute();
1025 for (const auto& entry : entries.samplers) { 1045 for (const auto& entry : entries.samplers) {
1026 for (std::size_t i = 0; i < entry.Size(); ++i) { 1046 for (std::size_t i = 0; i < entry.size; ++i) {
1027 const auto texture = GetTextureInfo(gpu, entry, ComputeShaderIndex, i); 1047 const auto texture = GetTextureInfo(gpu, entry, ComputeShaderIndex, i);
1028 SetupTexture(texture, entry); 1048 SetupTexture(texture, entry);
1029 } 1049 }
@@ -1105,7 +1125,7 @@ void RasterizerVulkan::SetupTexture(const Tegra::Texture::FullTextureInfo& textu
1105void RasterizerVulkan::SetupImage(const Tegra::Texture::TICEntry& tic, const ImageEntry& entry) { 1125void RasterizerVulkan::SetupImage(const Tegra::Texture::TICEntry& tic, const ImageEntry& entry) {
1106 auto view = texture_cache.GetImageSurface(tic, entry); 1126 auto view = texture_cache.GetImageSurface(tic, entry);
1107 1127
1108 if (entry.IsWritten()) { 1128 if (entry.is_written) {
1109 view->MarkAsModified(texture_cache.Tick()); 1129 view->MarkAsModified(texture_cache.Tick());
1110 } 1130 }
1111 1131
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h
index d41a7929e..0ed0e48c6 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.h
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.h
@@ -14,7 +14,6 @@
14#include <boost/functional/hash.hpp> 14#include <boost/functional/hash.hpp>
15 15
16#include "common/common_types.h" 16#include "common/common_types.h"
17#include "video_core/memory_manager.h"
18#include "video_core/rasterizer_accelerated.h" 17#include "video_core/rasterizer_accelerated.h"
19#include "video_core/rasterizer_interface.h" 18#include "video_core/rasterizer_interface.h"
20#include "video_core/renderer_vulkan/fixed_pipeline_state.h" 19#include "video_core/renderer_vulkan/fixed_pipeline_state.h"
@@ -127,6 +126,7 @@ public:
127 void SignalSyncPoint(u32 value) override; 126 void SignalSyncPoint(u32 value) override;
128 void ReleaseFences() override; 127 void ReleaseFences() override;
129 void FlushAndInvalidateRegion(VAddr addr, u64 size) override; 128 void FlushAndInvalidateRegion(VAddr addr, u64 size) override;
129 void WaitForIdle() override;
130 void FlushCommands() override; 130 void FlushCommands() override;
131 void TickFrame() override; 131 void TickFrame() override;
132 bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src, 132 bool AccelerateSurfaceCopy(const Tegra::Engines::Fermi2D::Regs::Surface& src,
@@ -276,6 +276,7 @@ private:
276 276
277 vk::Buffer default_buffer; 277 vk::Buffer default_buffer;
278 VKMemoryCommit default_buffer_commit; 278 VKMemoryCommit default_buffer_commit;
279 vk::Event wfi_event;
279 280
280 std::array<View, Maxwell::NumRenderTargets> color_attachments; 281 std::array<View, Maxwell::NumRenderTargets> color_attachments;
281 View zeta_attachment; 282 View zeta_attachment;
diff --git a/src/video_core/renderer_vulkan/vk_sampler_cache.cpp b/src/video_core/renderer_vulkan/vk_sampler_cache.cpp
index 07bbcf520..2687d8d95 100644
--- a/src/video_core/renderer_vulkan/vk_sampler_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_sampler_cache.cpp
@@ -2,11 +2,8 @@
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 <cstring>
6#include <optional>
7#include <unordered_map> 5#include <unordered_map>
8 6
9#include "common/assert.h"
10#include "video_core/renderer_vulkan/maxwell_to_vk.h" 7#include "video_core/renderer_vulkan/maxwell_to_vk.h"
11#include "video_core/renderer_vulkan/vk_sampler_cache.h" 8#include "video_core/renderer_vulkan/vk_sampler_cache.h"
12#include "video_core/renderer_vulkan/wrapper.h" 9#include "video_core/renderer_vulkan/wrapper.h"
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp
index ae7ba3eb5..82ec9180e 100644
--- a/src/video_core/renderer_vulkan/vk_scheduler.cpp
+++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp
@@ -8,7 +8,6 @@
8#include <thread> 8#include <thread>
9#include <utility> 9#include <utility>
10 10
11#include "common/assert.h"
12#include "common/microprofile.h" 11#include "common/microprofile.h"
13#include "video_core/renderer_vulkan/vk_device.h" 12#include "video_core/renderer_vulkan/vk_device.h"
14#include "video_core/renderer_vulkan/vk_query_cache.h" 13#include "video_core/renderer_vulkan/vk_query_cache.h"
diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h
index 82a8adc69..970a65566 100644
--- a/src/video_core/renderer_vulkan/vk_scheduler.h
+++ b/src/video_core/renderer_vulkan/vk_scheduler.h
@@ -7,7 +7,6 @@
7#include <atomic> 7#include <atomic>
8#include <condition_variable> 8#include <condition_variable>
9#include <memory> 9#include <memory>
10#include <optional>
11#include <stack> 10#include <stack>
12#include <thread> 11#include <thread>
13#include <utility> 12#include <utility>
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 20b6ca0ad..18678968c 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -103,8 +103,8 @@ struct GenericVaryingDescription {
103}; 103};
104 104
105spv::Dim GetSamplerDim(const Sampler& sampler) { 105spv::Dim GetSamplerDim(const Sampler& sampler) {
106 ASSERT(!sampler.IsBuffer()); 106 ASSERT(!sampler.is_buffer);
107 switch (sampler.GetType()) { 107 switch (sampler.type) {
108 case Tegra::Shader::TextureType::Texture1D: 108 case Tegra::Shader::TextureType::Texture1D:
109 return spv::Dim::Dim1D; 109 return spv::Dim::Dim1D;
110 case Tegra::Shader::TextureType::Texture2D: 110 case Tegra::Shader::TextureType::Texture2D:
@@ -114,13 +114,13 @@ spv::Dim GetSamplerDim(const Sampler& sampler) {
114 case Tegra::Shader::TextureType::TextureCube: 114 case Tegra::Shader::TextureType::TextureCube:
115 return spv::Dim::Cube; 115 return spv::Dim::Cube;
116 default: 116 default:
117 UNIMPLEMENTED_MSG("Unimplemented sampler type={}", static_cast<u32>(sampler.GetType())); 117 UNIMPLEMENTED_MSG("Unimplemented sampler type={}", static_cast<int>(sampler.type));
118 return spv::Dim::Dim2D; 118 return spv::Dim::Dim2D;
119 } 119 }
120} 120}
121 121
122std::pair<spv::Dim, bool> GetImageDim(const Image& image) { 122std::pair<spv::Dim, bool> GetImageDim(const Image& image) {
123 switch (image.GetType()) { 123 switch (image.type) {
124 case Tegra::Shader::ImageType::Texture1D: 124 case Tegra::Shader::ImageType::Texture1D:
125 return {spv::Dim::Dim1D, false}; 125 return {spv::Dim::Dim1D, false};
126 case Tegra::Shader::ImageType::TextureBuffer: 126 case Tegra::Shader::ImageType::TextureBuffer:
@@ -134,7 +134,7 @@ std::pair<spv::Dim, bool> GetImageDim(const Image& image) {
134 case Tegra::Shader::ImageType::Texture3D: 134 case Tegra::Shader::ImageType::Texture3D:
135 return {spv::Dim::Dim3D, false}; 135 return {spv::Dim::Dim3D, false};
136 default: 136 default:
137 UNIMPLEMENTED_MSG("Unimplemented image type={}", static_cast<u32>(image.GetType())); 137 UNIMPLEMENTED_MSG("Unimplemented image type={}", static_cast<int>(image.type));
138 return {spv::Dim::Dim2D, false}; 138 return {spv::Dim::Dim2D, false};
139 } 139 }
140} 140}
@@ -879,11 +879,11 @@ private:
879 879
880 u32 DeclareTexelBuffers(u32 binding) { 880 u32 DeclareTexelBuffers(u32 binding) {
881 for (const auto& sampler : ir.GetSamplers()) { 881 for (const auto& sampler : ir.GetSamplers()) {
882 if (!sampler.IsBuffer()) { 882 if (!sampler.is_buffer) {
883 continue; 883 continue;
884 } 884 }
885 ASSERT(!sampler.IsArray()); 885 ASSERT(!sampler.is_array);
886 ASSERT(!sampler.IsShadow()); 886 ASSERT(!sampler.is_shadow);
887 887
888 constexpr auto dim = spv::Dim::Buffer; 888 constexpr auto dim = spv::Dim::Buffer;
889 constexpr int depth = 0; 889 constexpr int depth = 0;
@@ -894,23 +894,23 @@ private:
894 const Id image_type = TypeImage(t_float, dim, depth, arrayed, ms, sampled, format); 894 const Id image_type = TypeImage(t_float, dim, depth, arrayed, ms, sampled, format);
895 const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, image_type); 895 const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, image_type);
896 const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant); 896 const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant);
897 AddGlobalVariable(Name(id, fmt::format("sampler_{}", sampler.GetIndex()))); 897 AddGlobalVariable(Name(id, fmt::format("sampler_{}", sampler.index)));
898 Decorate(id, spv::Decoration::Binding, binding++); 898 Decorate(id, spv::Decoration::Binding, binding++);
899 Decorate(id, spv::Decoration::DescriptorSet, DESCRIPTOR_SET); 899 Decorate(id, spv::Decoration::DescriptorSet, DESCRIPTOR_SET);
900 900
901 texel_buffers.emplace(sampler.GetIndex(), TexelBuffer{image_type, id}); 901 texel_buffers.emplace(sampler.index, TexelBuffer{image_type, id});
902 } 902 }
903 return binding; 903 return binding;
904 } 904 }
905 905
906 u32 DeclareSamplers(u32 binding) { 906 u32 DeclareSamplers(u32 binding) {
907 for (const auto& sampler : ir.GetSamplers()) { 907 for (const auto& sampler : ir.GetSamplers()) {
908 if (sampler.IsBuffer()) { 908 if (sampler.is_buffer) {
909 continue; 909 continue;
910 } 910 }
911 const auto dim = GetSamplerDim(sampler); 911 const auto dim = GetSamplerDim(sampler);
912 const int depth = sampler.IsShadow() ? 1 : 0; 912 const int depth = sampler.is_shadow ? 1 : 0;
913 const int arrayed = sampler.IsArray() ? 1 : 0; 913 const int arrayed = sampler.is_array ? 1 : 0;
914 constexpr bool ms = false; 914 constexpr bool ms = false;
915 constexpr int sampled = 1; 915 constexpr int sampled = 1;
916 constexpr auto format = spv::ImageFormat::Unknown; 916 constexpr auto format = spv::ImageFormat::Unknown;
@@ -918,17 +918,17 @@ private:
918 const Id sampler_type = TypeSampledImage(image_type); 918 const Id sampler_type = TypeSampledImage(image_type);
919 const Id sampler_pointer_type = 919 const Id sampler_pointer_type =
920 TypePointer(spv::StorageClass::UniformConstant, sampler_type); 920 TypePointer(spv::StorageClass::UniformConstant, sampler_type);
921 const Id type = sampler.IsIndexed() 921 const Id type = sampler.is_indexed
922 ? TypeArray(sampler_type, Constant(t_uint, sampler.Size())) 922 ? TypeArray(sampler_type, Constant(t_uint, sampler.size))
923 : sampler_type; 923 : sampler_type;
924 const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, type); 924 const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, type);
925 const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant); 925 const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant);
926 AddGlobalVariable(Name(id, fmt::format("sampler_{}", sampler.GetIndex()))); 926 AddGlobalVariable(Name(id, fmt::format("sampler_{}", sampler.index)));
927 Decorate(id, spv::Decoration::Binding, binding++); 927 Decorate(id, spv::Decoration::Binding, binding++);
928 Decorate(id, spv::Decoration::DescriptorSet, DESCRIPTOR_SET); 928 Decorate(id, spv::Decoration::DescriptorSet, DESCRIPTOR_SET);
929 929
930 sampled_images.emplace(sampler.GetIndex(), SampledImage{image_type, sampler_type, 930 sampled_images.emplace(
931 sampler_pointer_type, id}); 931 sampler.index, SampledImage{image_type, sampler_type, sampler_pointer_type, id});
932 } 932 }
933 return binding; 933 return binding;
934 } 934 }
@@ -943,17 +943,17 @@ private:
943 const Id image_type = TypeImage(t_uint, dim, depth, arrayed, ms, sampled, format, {}); 943 const Id image_type = TypeImage(t_uint, dim, depth, arrayed, ms, sampled, format, {});
944 const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, image_type); 944 const Id pointer_type = TypePointer(spv::StorageClass::UniformConstant, image_type);
945 const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant); 945 const Id id = OpVariable(pointer_type, spv::StorageClass::UniformConstant);
946 AddGlobalVariable(Name(id, fmt::format("image_{}", image.GetIndex()))); 946 AddGlobalVariable(Name(id, fmt::format("image_{}", image.index)));
947 947
948 Decorate(id, spv::Decoration::Binding, binding++); 948 Decorate(id, spv::Decoration::Binding, binding++);
949 Decorate(id, spv::Decoration::DescriptorSet, DESCRIPTOR_SET); 949 Decorate(id, spv::Decoration::DescriptorSet, DESCRIPTOR_SET);
950 if (image.IsRead() && !image.IsWritten()) { 950 if (image.is_read && !image.is_written) {
951 Decorate(id, spv::Decoration::NonWritable); 951 Decorate(id, spv::Decoration::NonWritable);
952 } else if (image.IsWritten() && !image.IsRead()) { 952 } else if (image.is_written && !image.is_read) {
953 Decorate(id, spv::Decoration::NonReadable); 953 Decorate(id, spv::Decoration::NonReadable);
954 } 954 }
955 955
956 images.emplace(static_cast<u32>(image.GetIndex()), StorageImage{image_type, id}); 956 images.emplace(image.index, StorageImage{image_type, id});
957 } 957 }
958 return binding; 958 return binding;
959 } 959 }
@@ -1620,11 +1620,11 @@ private:
1620 1620
1621 Id GetTextureSampler(Operation operation) { 1621 Id GetTextureSampler(Operation operation) {
1622 const auto& meta = std::get<MetaTexture>(operation.GetMeta()); 1622 const auto& meta = std::get<MetaTexture>(operation.GetMeta());
1623 ASSERT(!meta.sampler.IsBuffer()); 1623 ASSERT(!meta.sampler.is_buffer);
1624 1624
1625 const auto& entry = sampled_images.at(meta.sampler.GetIndex()); 1625 const auto& entry = sampled_images.at(meta.sampler.index);
1626 Id sampler = entry.variable; 1626 Id sampler = entry.variable;
1627 if (meta.sampler.IsIndexed()) { 1627 if (meta.sampler.is_indexed) {
1628 const Id index = AsInt(Visit(meta.index)); 1628 const Id index = AsInt(Visit(meta.index));
1629 sampler = OpAccessChain(entry.sampler_pointer_type, sampler, index); 1629 sampler = OpAccessChain(entry.sampler_pointer_type, sampler, index);
1630 } 1630 }
@@ -1633,8 +1633,8 @@ private:
1633 1633
1634 Id GetTextureImage(Operation operation) { 1634 Id GetTextureImage(Operation operation) {
1635 const auto& meta = std::get<MetaTexture>(operation.GetMeta()); 1635 const auto& meta = std::get<MetaTexture>(operation.GetMeta());
1636 const u32 index = meta.sampler.GetIndex(); 1636 const u32 index = meta.sampler.index;
1637 if (meta.sampler.IsBuffer()) { 1637 if (meta.sampler.is_buffer) {
1638 const auto& entry = texel_buffers.at(index); 1638 const auto& entry = texel_buffers.at(index);
1639 return OpLoad(entry.image_type, entry.image); 1639 return OpLoad(entry.image_type, entry.image);
1640 } else { 1640 } else {
@@ -1645,7 +1645,7 @@ private:
1645 1645
1646 Id GetImage(Operation operation) { 1646 Id GetImage(Operation operation) {
1647 const auto& meta = std::get<MetaImage>(operation.GetMeta()); 1647 const auto& meta = std::get<MetaImage>(operation.GetMeta());
1648 const auto entry = images.at(meta.image.GetIndex()); 1648 const auto entry = images.at(meta.image.index);
1649 return OpLoad(entry.image_type, entry.image); 1649 return OpLoad(entry.image_type, entry.image);
1650 } 1650 }
1651 1651
@@ -1661,7 +1661,7 @@ private:
1661 } 1661 }
1662 if (const auto meta = std::get_if<MetaTexture>(&operation.GetMeta())) { 1662 if (const auto meta = std::get_if<MetaTexture>(&operation.GetMeta())) {
1663 // Add array coordinate for textures 1663 // Add array coordinate for textures
1664 if (meta->sampler.IsArray()) { 1664 if (meta->sampler.is_array) {
1665 Id array = AsInt(Visit(meta->array)); 1665 Id array = AsInt(Visit(meta->array));
1666 if (type == Type::Float) { 1666 if (type == Type::Float) {
1667 array = OpConvertSToF(t_float, array); 1667 array = OpConvertSToF(t_float, array);
@@ -1767,7 +1767,7 @@ private:
1767 operands.push_back(GetOffsetCoordinates(operation)); 1767 operands.push_back(GetOffsetCoordinates(operation));
1768 } 1768 }
1769 1769
1770 if (meta.sampler.IsShadow()) { 1770 if (meta.sampler.is_shadow) {
1771 const Id dref = AsFloat(Visit(meta.depth_compare)); 1771 const Id dref = AsFloat(Visit(meta.depth_compare));
1772 return {OpImageSampleDrefExplicitLod(t_float, sampler, coords, dref, mask, operands), 1772 return {OpImageSampleDrefExplicitLod(t_float, sampler, coords, dref, mask, operands),
1773 Type::Float}; 1773 Type::Float};
@@ -1782,7 +1782,7 @@ private:
1782 1782
1783 const Id coords = GetCoordinates(operation, Type::Float); 1783 const Id coords = GetCoordinates(operation, Type::Float);
1784 Id texture{}; 1784 Id texture{};
1785 if (meta.sampler.IsShadow()) { 1785 if (meta.sampler.is_shadow) {
1786 texture = OpImageDrefGather(t_float4, GetTextureSampler(operation), coords, 1786 texture = OpImageDrefGather(t_float4, GetTextureSampler(operation), coords,
1787 AsFloat(Visit(meta.depth_compare))); 1787 AsFloat(Visit(meta.depth_compare)));
1788 } else { 1788 } else {
@@ -1809,8 +1809,8 @@ private:
1809 } 1809 }
1810 1810
1811 const Id lod = AsUint(Visit(operation[0])); 1811 const Id lod = AsUint(Visit(operation[0]));
1812 const std::size_t coords_count = [&]() { 1812 const std::size_t coords_count = [&meta] {
1813 switch (const auto type = meta.sampler.GetType(); type) { 1813 switch (const auto type = meta.sampler.type) {
1814 case Tegra::Shader::TextureType::Texture1D: 1814 case Tegra::Shader::TextureType::Texture1D:
1815 return 1; 1815 return 1;
1816 case Tegra::Shader::TextureType::Texture2D: 1816 case Tegra::Shader::TextureType::Texture2D:
@@ -1819,7 +1819,7 @@ private:
1819 case Tegra::Shader::TextureType::Texture3D: 1819 case Tegra::Shader::TextureType::Texture3D:
1820 return 3; 1820 return 3;
1821 default: 1821 default:
1822 UNREACHABLE_MSG("Invalid texture type={}", static_cast<u32>(type)); 1822 UNREACHABLE_MSG("Invalid texture type={}", static_cast<int>(type));
1823 return 2; 1823 return 2;
1824 } 1824 }
1825 }(); 1825 }();
@@ -1862,7 +1862,7 @@ private:
1862 const Id image = GetTextureImage(operation); 1862 const Id image = GetTextureImage(operation);
1863 const Id coords = GetCoordinates(operation, Type::Int); 1863 const Id coords = GetCoordinates(operation, Type::Int);
1864 Id fetch; 1864 Id fetch;
1865 if (meta.lod && !meta.sampler.IsBuffer()) { 1865 if (meta.lod && !meta.sampler.is_buffer) {
1866 fetch = OpImageFetch(t_float4, image, coords, spv::ImageOperandsMask::Lod, 1866 fetch = OpImageFetch(t_float4, image, coords, spv::ImageOperandsMask::Lod,
1867 AsInt(Visit(meta.lod))); 1867 AsInt(Visit(meta.lod)));
1868 } else { 1868 } else {
@@ -2980,7 +2980,7 @@ ShaderEntries GenerateShaderEntries(const VideoCommon::Shader::ShaderIR& ir) {
2980 entries.global_buffers.emplace_back(base.cbuf_index, base.cbuf_offset, usage.is_written); 2980 entries.global_buffers.emplace_back(base.cbuf_index, base.cbuf_offset, usage.is_written);
2981 } 2981 }
2982 for (const auto& sampler : ir.GetSamplers()) { 2982 for (const auto& sampler : ir.GetSamplers()) {
2983 if (sampler.IsBuffer()) { 2983 if (sampler.is_buffer) {
2984 entries.texel_buffers.emplace_back(sampler); 2984 entries.texel_buffers.emplace_back(sampler);
2985 } else { 2985 } else {
2986 entries.samplers.emplace_back(sampler); 2986 entries.samplers.emplace_back(sampler);
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.h b/src/video_core/renderer_vulkan/vk_shader_decompiler.h
index ffea4709e..f4c05ac3c 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.h
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.h
@@ -5,11 +5,7 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <bitset>
9#include <memory>
10#include <set> 8#include <set>
11#include <type_traits>
12#include <utility>
13#include <vector> 9#include <vector>
14 10
15#include "common/common_types.h" 11#include "common/common_types.h"
diff --git a/src/video_core/renderer_vulkan/vk_shader_util.cpp b/src/video_core/renderer_vulkan/vk_shader_util.cpp
index 784839327..112df9c71 100644
--- a/src/video_core/renderer_vulkan/vk_shader_util.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_util.cpp
@@ -4,8 +4,7 @@
4 4
5#include <cstring> 5#include <cstring>
6#include <memory> 6#include <memory>
7#include <vector> 7
8#include "common/alignment.h"
9#include "common/assert.h" 8#include "common/assert.h"
10#include "common/common_types.h" 9#include "common/common_types.h"
11#include "video_core/renderer_vulkan/vk_device.h" 10#include "video_core/renderer_vulkan/vk_device.h"
diff --git a/src/video_core/renderer_vulkan/vk_shader_util.h b/src/video_core/renderer_vulkan/vk_shader_util.h
index be38d6697..d1d3f3cae 100644
--- a/src/video_core/renderer_vulkan/vk_shader_util.h
+++ b/src/video_core/renderer_vulkan/vk_shader_util.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <vector>
8#include "common/common_types.h" 7#include "common/common_types.h"
9#include "video_core/renderer_vulkan/wrapper.h" 8#include "video_core/renderer_vulkan/wrapper.h"
10 9
diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h
index faf6418fd..3c4901437 100644
--- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h
+++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h
@@ -5,8 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <climits> 7#include <climits>
8#include <unordered_map>
9#include <utility>
10#include <vector> 8#include <vector>
11 9
12#include "common/common_types.h" 10#include "common/common_types.h"
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
index de4c23120..55f43e61b 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp
@@ -10,11 +10,9 @@
10#include <variant> 10#include <variant>
11#include <vector> 11#include <vector>
12 12
13#include "common/alignment.h"
14#include "common/assert.h" 13#include "common/assert.h"
15#include "common/common_types.h" 14#include "common/common_types.h"
16#include "core/core.h" 15#include "core/core.h"
17#include "core/memory.h"
18#include "video_core/engines/maxwell_3d.h" 16#include "video_core/engines/maxwell_3d.h"
19#include "video_core/morton.h" 17#include "video_core/morton.h"
20#include "video_core/renderer_vulkan/maxwell_to_vk.h" 18#include "video_core/renderer_vulkan/maxwell_to_vk.h"
@@ -26,7 +24,6 @@
26#include "video_core/renderer_vulkan/vk_texture_cache.h" 24#include "video_core/renderer_vulkan/vk_texture_cache.h"
27#include "video_core/renderer_vulkan/wrapper.h" 25#include "video_core/renderer_vulkan/wrapper.h"
28#include "video_core/surface.h" 26#include "video_core/surface.h"
29#include "video_core/textures/convert.h"
30 27
31namespace Vulkan { 28namespace Vulkan {
32 29
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h
index 115595f28..f211ccb1e 100644
--- a/src/video_core/renderer_vulkan/vk_texture_cache.h
+++ b/src/video_core/renderer_vulkan/vk_texture_cache.h
@@ -7,19 +7,13 @@
7#include <memory> 7#include <memory>
8#include <unordered_map> 8#include <unordered_map>
9 9
10#include "common/assert.h"
11#include "common/common_types.h" 10#include "common/common_types.h"
12#include "common/logging/log.h"
13#include "common/math_util.h"
14#include "video_core/gpu.h"
15#include "video_core/rasterizer_cache.h"
16#include "video_core/renderer_vulkan/vk_image.h" 11#include "video_core/renderer_vulkan/vk_image.h"
17#include "video_core/renderer_vulkan/vk_memory_manager.h" 12#include "video_core/renderer_vulkan/vk_memory_manager.h"
18#include "video_core/renderer_vulkan/vk_scheduler.h" 13#include "video_core/renderer_vulkan/vk_scheduler.h"
19#include "video_core/renderer_vulkan/wrapper.h" 14#include "video_core/renderer_vulkan/wrapper.h"
20#include "video_core/texture_cache/surface_base.h" 15#include "video_core/texture_cache/surface_base.h"
21#include "video_core/texture_cache/texture_cache.h" 16#include "video_core/texture_cache/texture_cache.h"
22#include "video_core/textures/decoders.h"
23 17
24namespace Core { 18namespace Core {
25class System; 19class System;
diff --git a/src/video_core/renderer_vulkan/vk_update_descriptor.h b/src/video_core/renderer_vulkan/vk_update_descriptor.h
index 6ba2c9997..cc7e3dff4 100644
--- a/src/video_core/renderer_vulkan/vk_update_descriptor.h
+++ b/src/video_core/renderer_vulkan/vk_update_descriptor.h
@@ -4,7 +4,6 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <type_traits>
8#include <variant> 7#include <variant>
9#include <boost/container/static_vector.hpp> 8#include <boost/container/static_vector.hpp>
10 9
diff --git a/src/video_core/renderer_vulkan/wrapper.cpp b/src/video_core/renderer_vulkan/wrapper.cpp
index 7f5bc1404..2ce9b0626 100644
--- a/src/video_core/renderer_vulkan/wrapper.cpp
+++ b/src/video_core/renderer_vulkan/wrapper.cpp
@@ -87,6 +87,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
87 X(vkCmdSetStencilReference); 87 X(vkCmdSetStencilReference);
88 X(vkCmdSetStencilWriteMask); 88 X(vkCmdSetStencilWriteMask);
89 X(vkCmdSetViewport); 89 X(vkCmdSetViewport);
90 X(vkCmdWaitEvents);
90 X(vkCreateBuffer); 91 X(vkCreateBuffer);
91 X(vkCreateBufferView); 92 X(vkCreateBufferView);
92 X(vkCreateCommandPool); 93 X(vkCreateCommandPool);
diff --git a/src/video_core/renderer_vulkan/wrapper.h b/src/video_core/renderer_vulkan/wrapper.h
index bda16a2cb..98937a77a 100644
--- a/src/video_core/renderer_vulkan/wrapper.h
+++ b/src/video_core/renderer_vulkan/wrapper.h
@@ -205,6 +205,7 @@ struct DeviceDispatch : public InstanceDispatch {
205 PFN_vkCmdSetStencilReference vkCmdSetStencilReference; 205 PFN_vkCmdSetStencilReference vkCmdSetStencilReference;
206 PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask; 206 PFN_vkCmdSetStencilWriteMask vkCmdSetStencilWriteMask;
207 PFN_vkCmdSetViewport vkCmdSetViewport; 207 PFN_vkCmdSetViewport vkCmdSetViewport;
208 PFN_vkCmdWaitEvents vkCmdWaitEvents;
208 PFN_vkCreateBuffer vkCreateBuffer; 209 PFN_vkCreateBuffer vkCreateBuffer;
209 PFN_vkCreateBufferView vkCreateBufferView; 210 PFN_vkCreateBufferView vkCreateBufferView;
210 PFN_vkCreateCommandPool vkCreateCommandPool; 211 PFN_vkCreateCommandPool vkCreateCommandPool;
@@ -958,6 +959,15 @@ public:
958 dld->vkCmdSetEvent(handle, event, stage_flags); 959 dld->vkCmdSetEvent(handle, event, stage_flags);
959 } 960 }
960 961
962 void WaitEvents(Span<VkEvent> events, VkPipelineStageFlags src_stage_mask,
963 VkPipelineStageFlags dst_stage_mask, Span<VkMemoryBarrier> memory_barriers,
964 Span<VkBufferMemoryBarrier> buffer_barriers,
965 Span<VkImageMemoryBarrier> image_barriers) const noexcept {
966 dld->vkCmdWaitEvents(handle, events.size(), events.data(), src_stage_mask, dst_stage_mask,
967 memory_barriers.size(), memory_barriers.data(), buffer_barriers.size(),
968 buffer_barriers.data(), image_barriers.size(), image_barriers.data());
969 }
970
961 void BindTransformFeedbackBuffersEXT(u32 first, u32 count, const VkBuffer* buffers, 971 void BindTransformFeedbackBuffersEXT(u32 first, u32 count, const VkBuffer* buffers,
962 const VkDeviceSize* offsets, 972 const VkDeviceSize* offsets,
963 const VkDeviceSize* sizes) const noexcept { 973 const VkDeviceSize* sizes) const noexcept {
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp
index 1167ff4ec..a75a5cc63 100644
--- a/src/video_core/shader/decode.cpp
+++ b/src/video_core/shader/decode.cpp
@@ -32,11 +32,11 @@ void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile& gpu_driver,
32 u32 count{}; 32 u32 count{};
33 std::vector<u32> bound_offsets; 33 std::vector<u32> bound_offsets;
34 for (const auto& sampler : used_samplers) { 34 for (const auto& sampler : used_samplers) {
35 if (sampler.IsBindless()) { 35 if (sampler.is_bindless) {
36 continue; 36 continue;
37 } 37 }
38 ++count; 38 ++count;
39 bound_offsets.emplace_back(sampler.GetOffset()); 39 bound_offsets.emplace_back(sampler.offset);
40 } 40 }
41 if (count > 1) { 41 if (count > 1) {
42 gpu_driver.DeduceTextureHandlerSize(std::move(bound_offsets)); 42 gpu_driver.DeduceTextureHandlerSize(std::move(bound_offsets));
@@ -46,14 +46,14 @@ void DeduceTextureHandlerSize(VideoCore::GuestDriverProfile& gpu_driver,
46std::optional<u32> TryDeduceSamplerSize(const Sampler& sampler_to_deduce, 46std::optional<u32> TryDeduceSamplerSize(const Sampler& sampler_to_deduce,
47 VideoCore::GuestDriverProfile& gpu_driver, 47 VideoCore::GuestDriverProfile& gpu_driver,
48 const std::list<Sampler>& used_samplers) { 48 const std::list<Sampler>& used_samplers) {
49 const u32 base_offset = sampler_to_deduce.GetOffset(); 49 const u32 base_offset = sampler_to_deduce.offset;
50 u32 max_offset{std::numeric_limits<u32>::max()}; 50 u32 max_offset{std::numeric_limits<u32>::max()};
51 for (const auto& sampler : used_samplers) { 51 for (const auto& sampler : used_samplers) {
52 if (sampler.IsBindless()) { 52 if (sampler.is_bindless) {
53 continue; 53 continue;
54 } 54 }
55 if (sampler.GetOffset() > base_offset) { 55 if (sampler.offset > base_offset) {
56 max_offset = std::min(sampler.GetOffset(), max_offset); 56 max_offset = std::min(sampler.offset, max_offset);
57 } 57 }
58 } 58 }
59 if (max_offset == std::numeric_limits<u32>::max()) { 59 if (max_offset == std::numeric_limits<u32>::max()) {
@@ -353,14 +353,14 @@ void ShaderIR::PostDecode() {
353 return; 353 return;
354 } 354 }
355 for (auto& sampler : used_samplers) { 355 for (auto& sampler : used_samplers) {
356 if (!sampler.IsIndexed()) { 356 if (!sampler.is_indexed) {
357 continue; 357 continue;
358 } 358 }
359 if (const auto size = TryDeduceSamplerSize(sampler, gpu_driver, used_samplers)) { 359 if (const auto size = TryDeduceSamplerSize(sampler, gpu_driver, used_samplers)) {
360 sampler.SetSize(*size); 360 sampler.size = *size;
361 } else { 361 } else {
362 LOG_CRITICAL(HW_GPU, "Failed to deduce size of indexed sampler"); 362 LOG_CRITICAL(HW_GPU, "Failed to deduce size of indexed sampler");
363 sampler.SetSize(1); 363 sampler.size = 1;
364 } 364 }
365 } 365 }
366} 366}
diff --git a/src/video_core/shader/decode/image.cpp b/src/video_core/shader/decode/image.cpp
index 85ee9aa5e..60b6ad72a 100644
--- a/src/video_core/shader/decode/image.cpp
+++ b/src/video_core/shader/decode/image.cpp
@@ -485,11 +485,10 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
485Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) { 485Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) {
486 const auto offset = static_cast<u32>(image.index.Value()); 486 const auto offset = static_cast<u32>(image.index.Value());
487 487
488 const auto it = 488 const auto it = std::find_if(std::begin(used_images), std::end(used_images),
489 std::find_if(std::begin(used_images), std::end(used_images), 489 [offset](const Image& entry) { return entry.offset == offset; });
490 [offset](const Image& entry) { return entry.GetOffset() == offset; });
491 if (it != std::end(used_images)) { 490 if (it != std::end(used_images)) {
492 ASSERT(!it->IsBindless() && it->GetType() == it->GetType()); 491 ASSERT(!it->is_bindless && it->type == type);
493 return *it; 492 return *it;
494 } 493 }
495 494
@@ -505,13 +504,12 @@ Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::Im
505 const auto buffer = std::get<1>(result); 504 const auto buffer = std::get<1>(result);
506 const auto offset = std::get<2>(result); 505 const auto offset = std::get<2>(result);
507 506
508 const auto it = 507 const auto it = std::find_if(std::begin(used_images), std::end(used_images),
509 std::find_if(std::begin(used_images), std::end(used_images), 508 [buffer, offset](const Image& entry) {
510 [buffer = buffer, offset = offset](const Image& entry) { 509 return entry.buffer == buffer && entry.offset == offset;
511 return entry.GetBuffer() == buffer && entry.GetOffset() == offset; 510 });
512 });
513 if (it != std::end(used_images)) { 511 if (it != std::end(used_images)) {
514 ASSERT(it->IsBindless() && it->GetType() == it->GetType()); 512 ASSERT(it->is_bindless && it->type == type);
515 return *it; 513 return *it;
516 } 514 }
517 515
diff --git a/src/video_core/shader/decode/texture.cpp b/src/video_core/shader/decode/texture.cpp
index e68f1d305..8f0bb996e 100644
--- a/src/video_core/shader/decode/texture.cpp
+++ b/src/video_core/shader/decode/texture.cpp
@@ -139,15 +139,15 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
139 } 139 }
140 const Node component = Immediate(static_cast<u32>(instr.tld4s.component)); 140 const Node component = Immediate(static_cast<u32>(instr.tld4s.component));
141 141
142 const SamplerInfo info{TextureType::Texture2D, false, is_depth_compare, false}; 142 SamplerInfo info;
143 const Sampler& sampler = *GetSampler(instr.sampler, info); 143 info.is_shadow = is_depth_compare;
144 const std::optional<Sampler> sampler = GetSampler(instr.sampler, info);
144 145
145 Node4 values; 146 Node4 values;
146 for (u32 element = 0; element < values.size(); ++element) { 147 for (u32 element = 0; element < values.size(); ++element) {
147 auto coords_copy = coords; 148 MetaTexture meta{*sampler, {}, depth_compare, aoffi, {}, {},
148 MetaTexture meta{sampler, {}, depth_compare, aoffi, {}, {}, 149 {}, {}, component, element, {}};
149 {}, {}, component, element, {}}; 150 values[element] = Operation(OperationCode::TextureGather, meta, coords);
150 values[element] = Operation(OperationCode::TextureGather, meta, std::move(coords_copy));
151 } 151 }
152 152
153 if (instr.tld4s.fp16_flag) { 153 if (instr.tld4s.fp16_flag) {
@@ -165,18 +165,20 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
165 "AOFFI is not implemented"); 165 "AOFFI is not implemented");
166 166
167 const bool is_array = instr.txd.is_array != 0; 167 const bool is_array = instr.txd.is_array != 0;
168 u64 base_reg = instr.gpr8.Value();
169 const auto derivate_reg = instr.gpr20.Value(); 168 const auto derivate_reg = instr.gpr20.Value();
170 const auto texture_type = instr.txd.texture_type.Value(); 169 const auto texture_type = instr.txd.texture_type.Value();
171 const auto coord_count = GetCoordCount(texture_type); 170 const auto coord_count = GetCoordCount(texture_type);
172 Node index_var{}; 171 u64 base_reg = instr.gpr8.Value();
173 const Sampler* sampler = 172 Node index_var;
174 is_bindless 173 SamplerInfo info;
175 ? GetBindlessSampler(base_reg, index_var, {{texture_type, is_array, false, false}}) 174 info.type = texture_type;
176 : GetSampler(instr.sampler, {{texture_type, is_array, false, false}}); 175 info.is_array = is_array;
176 const std::optional<Sampler> sampler = is_bindless
177 ? GetBindlessSampler(base_reg, info, index_var)
178 : GetSampler(instr.sampler, info);
177 Node4 values; 179 Node4 values;
178 if (sampler == nullptr) { 180 if (!sampler) {
179 std::generate(values.begin(), values.end(), [] { return Immediate(0); }); 181 std::generate(values.begin(), values.end(), [this] { return Immediate(0); });
180 WriteTexInstructionFloat(bb, instr, values); 182 WriteTexInstructionFloat(bb, instr, values);
181 break; 183 break;
182 } 184 }
@@ -214,14 +216,12 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
214 is_bindless = true; 216 is_bindless = true;
215 [[fallthrough]]; 217 [[fallthrough]];
216 case OpCode::Id::TXQ: { 218 case OpCode::Id::TXQ: {
217 // TODO: The new commits on the texture refactor, change the way samplers work. 219 Node index_var;
218 // Sadly, not all texture instructions specify the type of texture their sampler 220 const std::optional<Sampler> sampler = is_bindless
219 // uses. This must be fixed at a later instance. 221 ? GetBindlessSampler(instr.gpr8, {}, index_var)
220 Node index_var{}; 222 : GetSampler(instr.sampler, {});
221 const Sampler* sampler = 223
222 is_bindless ? GetBindlessSampler(instr.gpr8, index_var) : GetSampler(instr.sampler); 224 if (!sampler) {
223
224 if (sampler == nullptr) {
225 u32 indexer = 0; 225 u32 indexer = 0;
226 for (u32 element = 0; element < 4; ++element) { 226 for (u32 element = 0; element < 4; ++element) {
227 if (!instr.txq.IsComponentEnabled(element)) { 227 if (!instr.txq.IsComponentEnabled(element)) {
@@ -267,12 +267,17 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
267 UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV), 267 UNIMPLEMENTED_IF_MSG(instr.tmml.UsesMiscMode(Tegra::Shader::TextureMiscMode::NDV),
268 "NDV is not implemented"); 268 "NDV is not implemented");
269 269
270 auto texture_type = instr.tmml.texture_type.Value(); 270 const auto texture_type = instr.tmml.texture_type.Value();
271 Node index_var{}; 271 const bool is_array = instr.tmml.array != 0;
272 const Sampler* sampler = 272 SamplerInfo info;
273 is_bindless ? GetBindlessSampler(instr.gpr20, index_var) : GetSampler(instr.sampler); 273 info.type = texture_type;
274 274 info.is_array = is_array;
275 if (sampler == nullptr) { 275 Node index_var;
276 const std::optional<Sampler> sampler =
277 is_bindless ? GetBindlessSampler(instr.gpr20, info, index_var)
278 : GetSampler(instr.sampler, info);
279
280 if (!sampler) {
276 u32 indexer = 0; 281 u32 indexer = 0;
277 for (u32 element = 0; element < 2; ++element) { 282 for (u32 element = 0; element < 2; ++element) {
278 if (!instr.tmml.IsComponentEnabled(element)) { 283 if (!instr.tmml.IsComponentEnabled(element)) {
@@ -299,12 +304,11 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
299 coords.push_back(GetRegister(instr.gpr8.Value() + 1)); 304 coords.push_back(GetRegister(instr.gpr8.Value() + 1));
300 break; 305 break;
301 default: 306 default:
302 UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<u32>(texture_type)); 307 UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<int>(texture_type));
303 308
304 // Fallback to interpreting as a 2D texture for now 309 // Fallback to interpreting as a 2D texture for now
305 coords.push_back(GetRegister(instr.gpr8.Value() + 0)); 310 coords.push_back(GetRegister(instr.gpr8.Value() + 0));
306 coords.push_back(GetRegister(instr.gpr8.Value() + 1)); 311 coords.push_back(GetRegister(instr.gpr8.Value() + 1));
307 texture_type = TextureType::Texture2D;
308 } 312 }
309 u32 indexer = 0; 313 u32 indexer = 0;
310 for (u32 element = 0; element < 2; ++element) { 314 for (u32 element = 0; element < 2; ++element) {
@@ -353,98 +357,103 @@ u32 ShaderIR::DecodeTexture(NodeBlock& bb, u32 pc) {
353 return pc; 357 return pc;
354} 358}
355 359
356ShaderIR::SamplerInfo ShaderIR::GetSamplerInfo(std::optional<SamplerInfo> sampler_info, u32 offset, 360ShaderIR::SamplerInfo ShaderIR::GetSamplerInfo(SamplerInfo info, u32 offset,
357 std::optional<u32> buffer) { 361 std::optional<u32> buffer) {
358 if (sampler_info) { 362 if (info.IsComplete()) {
359 return *sampler_info; 363 return info;
360 } 364 }
361 const auto sampler = buffer ? registry.ObtainBindlessSampler(*buffer, offset) 365 const auto sampler = buffer ? registry.ObtainBindlessSampler(*buffer, offset)
362 : registry.ObtainBoundSampler(offset); 366 : registry.ObtainBoundSampler(offset);
363 if (!sampler) { 367 if (!sampler) {
364 LOG_WARNING(HW_GPU, "Unknown sampler info"); 368 LOG_WARNING(HW_GPU, "Unknown sampler info");
365 return SamplerInfo{TextureType::Texture2D, false, false, false}; 369 info.type = info.type.value_or(Tegra::Shader::TextureType::Texture2D);
366 } 370 info.is_array = info.is_array.value_or(false);
367 return SamplerInfo{sampler->texture_type, sampler->is_array != 0, sampler->is_shadow != 0, 371 info.is_shadow = info.is_shadow.value_or(false);
368 sampler->is_buffer != 0}; 372 info.is_buffer = info.is_buffer.value_or(false);
373 return info;
374 }
375 info.type = info.type.value_or(sampler->texture_type);
376 info.is_array = info.is_array.value_or(sampler->is_array != 0);
377 info.is_shadow = info.is_shadow.value_or(sampler->is_shadow != 0);
378 info.is_buffer = info.is_buffer.value_or(sampler->is_buffer != 0);
379 return info;
369} 380}
370 381
371const Sampler* ShaderIR::GetSampler(const Tegra::Shader::Sampler& sampler, 382std::optional<Sampler> ShaderIR::GetSampler(Tegra::Shader::Sampler sampler,
372 std::optional<SamplerInfo> sampler_info) { 383 SamplerInfo sampler_info) {
373 const auto offset = static_cast<u32>(sampler.index.Value()); 384 const auto offset = static_cast<u32>(sampler.index.Value());
374 const auto info = GetSamplerInfo(sampler_info, offset); 385 const auto info = GetSamplerInfo(sampler_info, offset);
375 386
376 // If this sampler has already been used, return the existing mapping. 387 // If this sampler has already been used, return the existing mapping.
377 const auto it = 388 const auto it = std::find_if(used_samplers.begin(), used_samplers.end(),
378 std::find_if(used_samplers.begin(), used_samplers.end(), 389 [offset](const Sampler& entry) { return entry.offset == offset; });
379 [offset](const Sampler& entry) { return entry.GetOffset() == offset; });
380 if (it != used_samplers.end()) { 390 if (it != used_samplers.end()) {
381 ASSERT(!it->IsBindless() && it->GetType() == info.type && it->IsArray() == info.is_array && 391 ASSERT(!it->is_bindless && it->type == info.type && it->is_array == info.is_array &&
382 it->IsShadow() == info.is_shadow && it->IsBuffer() == info.is_buffer); 392 it->is_shadow == info.is_shadow && it->is_buffer == info.is_buffer);
383 return &*it; 393 return *it;
384 } 394 }
385 395
386 // Otherwise create a new mapping for this sampler 396 // Otherwise create a new mapping for this sampler
387 const auto next_index = static_cast<u32>(used_samplers.size()); 397 const auto next_index = static_cast<u32>(used_samplers.size());
388 return &used_samplers.emplace_back(next_index, offset, info.type, info.is_array, info.is_shadow, 398 return used_samplers.emplace_back(next_index, offset, *info.type, *info.is_array,
389 info.is_buffer, false); 399 *info.is_shadow, *info.is_buffer, false);
390} 400}
391 401
392const Sampler* ShaderIR::GetBindlessSampler(Tegra::Shader::Register reg, Node& index_var, 402std::optional<Sampler> ShaderIR::GetBindlessSampler(Tegra::Shader::Register reg, SamplerInfo info,
393 std::optional<SamplerInfo> sampler_info) { 403 Node& index_var) {
394 const Node sampler_register = GetRegister(reg); 404 const Node sampler_register = GetRegister(reg);
395 const auto [base_node, tracked_sampler_info] = 405 const auto [base_node, tracked_sampler_info] =
396 TrackBindlessSampler(sampler_register, global_code, static_cast<s64>(global_code.size())); 406 TrackBindlessSampler(sampler_register, global_code, static_cast<s64>(global_code.size()));
397 ASSERT(base_node != nullptr); 407 ASSERT(base_node != nullptr);
398 if (base_node == nullptr) { 408 if (base_node == nullptr) {
399 return nullptr; 409 return std::nullopt;
400 } 410 }
401 411
402 if (const auto bindless_sampler_info = 412 if (const auto bindless_sampler_info =
403 std::get_if<BindlessSamplerNode>(&*tracked_sampler_info)) { 413 std::get_if<BindlessSamplerNode>(&*tracked_sampler_info)) {
404 const u32 buffer = bindless_sampler_info->GetIndex(); 414 const u32 buffer = bindless_sampler_info->GetIndex();
405 const u32 offset = bindless_sampler_info->GetOffset(); 415 const u32 offset = bindless_sampler_info->GetOffset();
406 const auto info = GetSamplerInfo(sampler_info, offset, buffer); 416 info = GetSamplerInfo(info, offset, buffer);
407 417
408 // If this sampler has already been used, return the existing mapping. 418 // If this sampler has already been used, return the existing mapping.
409 const auto it = 419 const auto it = std::find_if(used_samplers.begin(), used_samplers.end(),
410 std::find_if(used_samplers.begin(), used_samplers.end(), 420 [buffer = buffer, offset = offset](const Sampler& entry) {
411 [buffer = buffer, offset = offset](const Sampler& entry) { 421 return entry.buffer == buffer && entry.offset == offset;
412 return entry.GetBuffer() == buffer && entry.GetOffset() == offset; 422 });
413 });
414 if (it != used_samplers.end()) { 423 if (it != used_samplers.end()) {
415 ASSERT(it->IsBindless() && it->GetType() == info.type && 424 ASSERT(it->is_bindless && it->type == info.type && it->is_array == info.is_array &&
416 it->IsArray() == info.is_array && it->IsShadow() == info.is_shadow); 425 it->is_shadow == info.is_shadow);
417 return &*it; 426 return *it;
418 } 427 }
419 428
420 // Otherwise create a new mapping for this sampler 429 // Otherwise create a new mapping for this sampler
421 const auto next_index = static_cast<u32>(used_samplers.size()); 430 const auto next_index = static_cast<u32>(used_samplers.size());
422 return &used_samplers.emplace_back(next_index, offset, buffer, info.type, info.is_array, 431 return used_samplers.emplace_back(next_index, offset, buffer, *info.type, *info.is_array,
423 info.is_shadow, info.is_buffer, false); 432 *info.is_shadow, *info.is_buffer, false);
424 } else if (const auto array_sampler_info = 433 }
425 std::get_if<ArraySamplerNode>(&*tracked_sampler_info)) { 434 if (const auto array_sampler_info = std::get_if<ArraySamplerNode>(&*tracked_sampler_info)) {
426 const u32 base_offset = array_sampler_info->GetBaseOffset() / 4; 435 const u32 base_offset = array_sampler_info->GetBaseOffset() / 4;
427 index_var = GetCustomVariable(array_sampler_info->GetIndexVar()); 436 index_var = GetCustomVariable(array_sampler_info->GetIndexVar());
428 const auto info = GetSamplerInfo(sampler_info, base_offset); 437 info = GetSamplerInfo(info, base_offset);
429 438
430 // If this sampler has already been used, return the existing mapping. 439 // If this sampler has already been used, return the existing mapping.
431 const auto it = std::find_if( 440 const auto it = std::find_if(
432 used_samplers.begin(), used_samplers.end(), 441 used_samplers.begin(), used_samplers.end(),
433 [base_offset](const Sampler& entry) { return entry.GetOffset() == base_offset; }); 442 [base_offset](const Sampler& entry) { return entry.offset == base_offset; });
434 if (it != used_samplers.end()) { 443 if (it != used_samplers.end()) {
435 ASSERT(!it->IsBindless() && it->GetType() == info.type && 444 ASSERT(!it->is_bindless && it->type == info.type && it->is_array == info.is_array &&
436 it->IsArray() == info.is_array && it->IsShadow() == info.is_shadow && 445 it->is_shadow == info.is_shadow && it->is_buffer == info.is_buffer &&
437 it->IsBuffer() == info.is_buffer && it->IsIndexed()); 446 it->is_indexed);
438 return &*it; 447 return *it;
439 } 448 }
440 449
441 uses_indexed_samplers = true; 450 uses_indexed_samplers = true;
442 // Otherwise create a new mapping for this sampler 451 // Otherwise create a new mapping for this sampler
443 const auto next_index = static_cast<u32>(used_samplers.size()); 452 const auto next_index = static_cast<u32>(used_samplers.size());
444 return &used_samplers.emplace_back(next_index, base_offset, info.type, info.is_array, 453 return used_samplers.emplace_back(next_index, base_offset, *info.type, *info.is_array,
445 info.is_shadow, info.is_buffer, true); 454 *info.is_shadow, *info.is_buffer, true);
446 } 455 }
447 return nullptr; 456 return std::nullopt;
448} 457}
449 458
450void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) { 459void ShaderIR::WriteTexInstructionFloat(NodeBlock& bb, Instruction instr, const Node4& components) {
@@ -529,10 +538,16 @@ Node4 ShaderIR::GetTextureCode(Instruction instr, TextureType texture_type,
529 ASSERT_MSG(texture_type != TextureType::Texture3D || !is_array || !is_shadow, 538 ASSERT_MSG(texture_type != TextureType::Texture3D || !is_array || !is_shadow,
530 "Illegal texture type"); 539 "Illegal texture type");
531 540
532 const SamplerInfo info{texture_type, is_array, is_shadow, false}; 541 SamplerInfo info;
542 info.type = texture_type;
543 info.is_array = is_array;
544 info.is_shadow = is_shadow;
545 info.is_buffer = false;
546
533 Node index_var; 547 Node index_var;
534 const Sampler* sampler = is_bindless ? GetBindlessSampler(*bindless_reg, index_var, info) 548 const std::optional<Sampler> sampler = is_bindless
535 : GetSampler(instr.sampler, info); 549 ? GetBindlessSampler(*bindless_reg, info, index_var)
550 : GetSampler(instr.sampler, info);
536 if (!sampler) { 551 if (!sampler) {
537 return {Immediate(0), Immediate(0), Immediate(0), Immediate(0)}; 552 return {Immediate(0), Immediate(0), Immediate(0), Immediate(0)};
538 } 553 }
@@ -683,12 +698,17 @@ Node4 ShaderIR::GetTld4Code(Instruction instr, TextureType texture_type, bool de
683 698
684 u64 parameter_register = instr.gpr20.Value(); 699 u64 parameter_register = instr.gpr20.Value();
685 700
686 const SamplerInfo info{texture_type, is_array, depth_compare, false}; 701 SamplerInfo info;
687 Node index_var{}; 702 info.type = texture_type;
688 const Sampler* sampler = is_bindless ? GetBindlessSampler(parameter_register++, index_var, info) 703 info.is_array = is_array;
689 : GetSampler(instr.sampler, info); 704 info.is_shadow = depth_compare;
705
706 Node index_var;
707 const std::optional<Sampler> sampler =
708 is_bindless ? GetBindlessSampler(parameter_register++, info, index_var)
709 : GetSampler(instr.sampler, info);
690 Node4 values; 710 Node4 values;
691 if (sampler == nullptr) { 711 if (!sampler) {
692 for (u32 element = 0; element < values.size(); ++element) { 712 for (u32 element = 0; element < values.size(); ++element) {
693 values[element] = Immediate(0); 713 values[element] = Immediate(0);
694 } 714 }
@@ -743,12 +763,12 @@ Node4 ShaderIR::GetTldCode(Tegra::Shader::Instruction instr) {
743 // const Node aoffi_register{is_aoffi ? GetRegister(gpr20_cursor++) : nullptr}; 763 // const Node aoffi_register{is_aoffi ? GetRegister(gpr20_cursor++) : nullptr};
744 // const Node multisample{is_multisample ? GetRegister(gpr20_cursor++) : nullptr}; 764 // const Node multisample{is_multisample ? GetRegister(gpr20_cursor++) : nullptr};
745 765
746 const auto& sampler = *GetSampler(instr.sampler); 766 const std::optional<Sampler> sampler = GetSampler(instr.sampler, {});
747 767
748 Node4 values; 768 Node4 values;
749 for (u32 element = 0; element < values.size(); ++element) { 769 for (u32 element = 0; element < values.size(); ++element) {
750 auto coords_copy = coords; 770 auto coords_copy = coords;
751 MetaTexture meta{sampler, array_register, {}, {}, {}, {}, {}, lod, {}, element, {}}; 771 MetaTexture meta{*sampler, array_register, {}, {}, {}, {}, {}, lod, {}, element, {}};
752 values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); 772 values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy));
753 } 773 }
754 774
@@ -756,7 +776,11 @@ Node4 ShaderIR::GetTldCode(Tegra::Shader::Instruction instr) {
756} 776}
757 777
758Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is_array) { 778Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is_array) {
759 const Sampler& sampler = *GetSampler(instr.sampler); 779 SamplerInfo info;
780 info.type = texture_type;
781 info.is_array = is_array;
782 info.is_shadow = false;
783 const std::optional<Sampler> sampler = GetSampler(instr.sampler, info);
760 784
761 const std::size_t type_coord_count = GetCoordCount(texture_type); 785 const std::size_t type_coord_count = GetCoordCount(texture_type);
762 const bool lod_enabled = instr.tlds.GetTextureProcessMode() == TextureProcessMode::LL; 786 const bool lod_enabled = instr.tlds.GetTextureProcessMode() == TextureProcessMode::LL;
@@ -784,7 +808,7 @@ Node4 ShaderIR::GetTldsCode(Instruction instr, TextureType texture_type, bool is
784 Node4 values; 808 Node4 values;
785 for (u32 element = 0; element < values.size(); ++element) { 809 for (u32 element = 0; element < values.size(); ++element) {
786 auto coords_copy = coords; 810 auto coords_copy = coords;
787 MetaTexture meta{sampler, array, {}, {}, {}, {}, {}, lod, {}, element, {}}; 811 MetaTexture meta{*sampler, array, {}, {}, {}, {}, {}, lod, {}, element, {}};
788 values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy)); 812 values[element] = Operation(OperationCode::TexelFetch, meta, std::move(coords_copy));
789 } 813 }
790 return values; 814 return values;
diff --git a/src/video_core/shader/node.h b/src/video_core/shader/node.h
index 3f5a7bc7a..601c822d2 100644
--- a/src/video_core/shader/node.h
+++ b/src/video_core/shader/node.h
@@ -267,76 +267,30 @@ class ArraySamplerNode;
267using TrackSamplerData = std::variant<BindlessSamplerNode, ArraySamplerNode>; 267using TrackSamplerData = std::variant<BindlessSamplerNode, ArraySamplerNode>;
268using TrackSampler = std::shared_ptr<TrackSamplerData>; 268using TrackSampler = std::shared_ptr<TrackSamplerData>;
269 269
270class Sampler { 270struct Sampler {
271public: 271 /// Bound samplers constructor
272 /// This constructor is for bound samplers
273 constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type, 272 constexpr explicit Sampler(u32 index, u32 offset, Tegra::Shader::TextureType type,
274 bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) 273 bool is_array, bool is_shadow, bool is_buffer, bool is_indexed)
275 : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow}, 274 : index{index}, offset{offset}, type{type}, is_array{is_array}, is_shadow{is_shadow},
276 is_buffer{is_buffer}, is_indexed{is_indexed} {} 275 is_buffer{is_buffer}, is_indexed{is_indexed} {}
277 276
278 /// This constructor is for bindless samplers 277 /// Bindless samplers constructor
279 constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type, 278 constexpr explicit Sampler(u32 index, u32 offset, u32 buffer, Tegra::Shader::TextureType type,
280 bool is_array, bool is_shadow, bool is_buffer, bool is_indexed) 279 bool is_array, bool is_shadow, bool is_buffer, bool is_indexed)
281 : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array}, 280 : index{index}, offset{offset}, buffer{buffer}, type{type}, is_array{is_array},
282 is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true}, is_indexed{is_indexed} {} 281 is_shadow{is_shadow}, is_buffer{is_buffer}, is_bindless{true}, is_indexed{is_indexed} {}
283 282
284 constexpr u32 GetIndex() const { 283 u32 index = 0; ///< Emulated index given for the this sampler.
285 return index; 284 u32 offset = 0; ///< Offset in the const buffer from where the sampler is being read.
286 } 285 u32 buffer = 0; ///< Buffer where the bindless sampler is being read (unused on bound samplers).
287 286 u32 size = 1; ///< Size of the sampler.
288 constexpr u32 GetOffset() const {
289 return offset;
290 }
291
292 constexpr u32 GetBuffer() const {
293 return buffer;
294 }
295
296 constexpr Tegra::Shader::TextureType GetType() const {
297 return type;
298 }
299
300 constexpr bool IsArray() const {
301 return is_array;
302 }
303
304 constexpr bool IsShadow() const {
305 return is_shadow;
306 }
307
308 constexpr bool IsBuffer() const {
309 return is_buffer;
310 }
311
312 constexpr bool IsBindless() const {
313 return is_bindless;
314 }
315
316 constexpr bool IsIndexed() const {
317 return is_indexed;
318 }
319
320 constexpr u32 Size() const {
321 return size;
322 }
323
324 constexpr void SetSize(u32 new_size) {
325 size = new_size;
326 }
327
328private:
329 u32 index{}; ///< Emulated index given for the this sampler.
330 u32 offset{}; ///< Offset in the const buffer from where the sampler is being read.
331 u32 buffer{}; ///< Buffer where the bindless sampler is being read (unused on bound samplers).
332 u32 size{1}; ///< Size of the sampler.
333 287
334 Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc) 288 Tegra::Shader::TextureType type{}; ///< The type used to sample this texture (Texture2D, etc)
335 bool is_array{}; ///< Whether the texture is being sampled as an array texture or not. 289 bool is_array = false; ///< Whether the texture is being sampled as an array texture or not.
336 bool is_shadow{}; ///< Whether the texture is being sampled as a depth texture or not. 290 bool is_shadow = false; ///< Whether the texture is being sampled as a depth texture or not.
337 bool is_buffer{}; ///< Whether the texture is a texture buffer without sampler. 291 bool is_buffer = false; ///< Whether the texture is a texture buffer without sampler.
338 bool is_bindless{}; ///< Whether this sampler belongs to a bindless texture or not. 292 bool is_bindless = false; ///< Whether this sampler belongs to a bindless texture or not.
339 bool is_indexed{}; ///< Whether this sampler is an indexed array of textures. 293 bool is_indexed = false; ///< Whether this sampler is an indexed array of textures.
340}; 294};
341 295
342/// Represents a tracked bindless sampler into a direct const buffer 296/// Represents a tracked bindless sampler into a direct const buffer
@@ -381,13 +335,13 @@ private:
381 u32 offset; 335 u32 offset;
382}; 336};
383 337
384class Image final { 338struct Image {
385public: 339public:
386 /// This constructor is for bound images 340 /// Bound images constructor
387 constexpr explicit Image(u32 index, u32 offset, Tegra::Shader::ImageType type) 341 constexpr explicit Image(u32 index, u32 offset, Tegra::Shader::ImageType type)
388 : index{index}, offset{offset}, type{type} {} 342 : index{index}, offset{offset}, type{type} {}
389 343
390 /// This constructor is for bindless samplers 344 /// Bindless samplers constructor
391 constexpr explicit Image(u32 index, u32 offset, u32 buffer, Tegra::Shader::ImageType type) 345 constexpr explicit Image(u32 index, u32 offset, u32 buffer, Tegra::Shader::ImageType type)
392 : index{index}, offset{offset}, buffer{buffer}, type{type}, is_bindless{true} {} 346 : index{index}, offset{offset}, buffer{buffer}, type{type}, is_bindless{true} {}
393 347
@@ -405,53 +359,20 @@ public:
405 is_atomic = true; 359 is_atomic = true;
406 } 360 }
407 361
408 constexpr u32 GetIndex() const { 362 u32 index = 0;
409 return index; 363 u32 offset = 0;
410 } 364 u32 buffer = 0;
411
412 constexpr u32 GetOffset() const {
413 return offset;
414 }
415
416 constexpr u32 GetBuffer() const {
417 return buffer;
418 }
419
420 constexpr Tegra::Shader::ImageType GetType() const {
421 return type;
422 }
423
424 constexpr bool IsBindless() const {
425 return is_bindless;
426 }
427
428 constexpr bool IsWritten() const {
429 return is_written;
430 }
431
432 constexpr bool IsRead() const {
433 return is_read;
434 }
435
436 constexpr bool IsAtomic() const {
437 return is_atomic;
438 }
439
440private:
441 u32 index{};
442 u32 offset{};
443 u32 buffer{};
444 365
445 Tegra::Shader::ImageType type{}; 366 Tegra::Shader::ImageType type{};
446 bool is_bindless{}; 367 bool is_bindless = false;
447 bool is_written{}; 368 bool is_written = false;
448 bool is_read{}; 369 bool is_read = false;
449 bool is_atomic{}; 370 bool is_atomic = false;
450}; 371};
451 372
452struct GlobalMemoryBase { 373struct GlobalMemoryBase {
453 u32 cbuf_index{}; 374 u32 cbuf_index = 0;
454 u32 cbuf_offset{}; 375 u32 cbuf_offset = 0;
455 376
456 bool operator<(const GlobalMemoryBase& rhs) const { 377 bool operator<(const GlobalMemoryBase& rhs) const {
457 return std::tie(cbuf_index, cbuf_offset) < std::tie(rhs.cbuf_index, rhs.cbuf_offset); 378 return std::tie(cbuf_index, cbuf_offset) < std::tie(rhs.cbuf_index, rhs.cbuf_offset);
@@ -465,7 +386,7 @@ struct MetaArithmetic {
465 386
466/// Parameters describing a texture sampler 387/// Parameters describing a texture sampler
467struct MetaTexture { 388struct MetaTexture {
468 const Sampler& sampler; 389 Sampler sampler;
469 Node array; 390 Node array;
470 Node depth_compare; 391 Node depth_compare;
471 std::vector<Node> aoffi; 392 std::vector<Node> aoffi;
diff --git a/src/video_core/shader/shader_ir.h b/src/video_core/shader/shader_ir.h
index 69de5e68b..15ae152f2 100644
--- a/src/video_core/shader/shader_ir.h
+++ b/src/video_core/shader/shader_ir.h
@@ -28,12 +28,11 @@ struct ShaderBlock;
28 28
29constexpr u32 MAX_PROGRAM_LENGTH = 0x1000; 29constexpr u32 MAX_PROGRAM_LENGTH = 0x1000;
30 30
31class ConstBuffer { 31struct ConstBuffer {
32public: 32 constexpr explicit ConstBuffer(u32 max_offset, bool is_indirect)
33 explicit ConstBuffer(u32 max_offset, bool is_indirect)
34 : max_offset{max_offset}, is_indirect{is_indirect} {} 33 : max_offset{max_offset}, is_indirect{is_indirect} {}
35 34
36 ConstBuffer() = default; 35 constexpr ConstBuffer() = default;
37 36
38 void MarkAsUsed(u64 offset) { 37 void MarkAsUsed(u64 offset) {
39 max_offset = std::max(max_offset, static_cast<u32>(offset)); 38 max_offset = std::max(max_offset, static_cast<u32>(offset));
@@ -56,8 +55,8 @@ public:
56 } 55 }
57 56
58private: 57private:
59 u32 max_offset{}; 58 u32 max_offset = 0;
60 bool is_indirect{}; 59 bool is_indirect = false;
61}; 60};
62 61
63struct GlobalMemoryUsage { 62struct GlobalMemoryUsage {
@@ -191,10 +190,14 @@ private:
191 friend class ASTDecoder; 190 friend class ASTDecoder;
192 191
193 struct SamplerInfo { 192 struct SamplerInfo {
194 Tegra::Shader::TextureType type; 193 std::optional<Tegra::Shader::TextureType> type;
195 bool is_array; 194 std::optional<bool> is_array;
196 bool is_shadow; 195 std::optional<bool> is_shadow;
197 bool is_buffer; 196 std::optional<bool> is_buffer;
197
198 constexpr bool IsComplete() const noexcept {
199 return type && is_array && is_shadow && is_buffer;
200 }
198 }; 201 };
199 202
200 void Decode(); 203 void Decode();
@@ -327,16 +330,15 @@ private:
327 OperationCode GetPredicateCombiner(Tegra::Shader::PredOperation operation); 330 OperationCode GetPredicateCombiner(Tegra::Shader::PredOperation operation);
328 331
329 /// Queries the missing sampler info from the execution context. 332 /// Queries the missing sampler info from the execution context.
330 SamplerInfo GetSamplerInfo(std::optional<SamplerInfo> sampler_info, u32 offset, 333 SamplerInfo GetSamplerInfo(SamplerInfo info, u32 offset,
331 std::optional<u32> buffer = std::nullopt); 334 std::optional<u32> buffer = std::nullopt);
332 335
333 /// Accesses a texture sampler 336 /// Accesses a texture sampler.
334 const Sampler* GetSampler(const Tegra::Shader::Sampler& sampler, 337 std::optional<Sampler> GetSampler(Tegra::Shader::Sampler sampler, SamplerInfo info);
335 std::optional<SamplerInfo> sampler_info = std::nullopt);
336 338
337 /// Accesses a texture sampler for a bindless texture. 339 /// Accesses a texture sampler for a bindless texture.
338 const Sampler* GetBindlessSampler(Tegra::Shader::Register reg, Node& index_var, 340 std::optional<Sampler> GetBindlessSampler(Tegra::Shader::Register reg, SamplerInfo info,
339 std::optional<SamplerInfo> sampler_info = std::nullopt); 341 Node& index_var);
340 342
341 /// Accesses an image. 343 /// Accesses an image.
342 Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type); 344 Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type);
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index 0de499946..884fabffe 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -81,7 +81,7 @@ SurfaceParams SurfaceParams::CreateForTexture(const FormatLookupTable& lookup_ta
81 params.pixel_format = lookup_table.GetPixelFormat( 81 params.pixel_format = lookup_table.GetPixelFormat(
82 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type); 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.is_shadow && params.type == SurfaceType::ColorTexture) {
85 switch (params.pixel_format) { 85 switch (params.pixel_format) {
86 case PixelFormat::R16U: 86 case PixelFormat::R16U:
87 case PixelFormat::R16F: 87 case PixelFormat::R16F:
@@ -108,7 +108,7 @@ SurfaceParams SurfaceParams::CreateForTexture(const FormatLookupTable& lookup_ta
108 params.emulated_levels = 1; 108 params.emulated_levels = 1;
109 params.is_layered = false; 109 params.is_layered = false;
110 } else { 110 } else {
111 params.target = TextureTypeToSurfaceTarget(entry.GetType(), entry.IsArray()); 111 params.target = TextureTypeToSurfaceTarget(entry.type, entry.is_array);
112 params.width = tic.Width(); 112 params.width = tic.Width();
113 params.height = tic.Height(); 113 params.height = tic.Height();
114 params.depth = tic.Depth(); 114 params.depth = tic.Depth();
@@ -138,7 +138,7 @@ SurfaceParams SurfaceParams::CreateForImage(const FormatLookupTable& lookup_tabl
138 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type); 138 tic.format, params.srgb_conversion, tic.r_type, tic.g_type, tic.b_type, tic.a_type);
139 params.type = GetFormatType(params.pixel_format); 139 params.type = GetFormatType(params.pixel_format);
140 params.type = GetFormatType(params.pixel_format); 140 params.type = GetFormatType(params.pixel_format);
141 params.target = ImageTypeToSurfaceTarget(entry.GetType()); 141 params.target = ImageTypeToSurfaceTarget(entry.type);
142 // TODO: on 1DBuffer we should use the tic info. 142 // TODO: on 1DBuffer we should use the tic info.
143 if (tic.IsBuffer()) { 143 if (tic.IsBuffer()) {
144 params.target = SurfaceTarget::TextureBuffer; 144 params.target = SurfaceTarget::TextureBuffer;
@@ -248,12 +248,12 @@ SurfaceParams SurfaceParams::CreateForFermiCopySurface(
248 248
249VideoCore::Surface::SurfaceTarget SurfaceParams::ExpectedTarget( 249VideoCore::Surface::SurfaceTarget SurfaceParams::ExpectedTarget(
250 const VideoCommon::Shader::Sampler& entry) { 250 const VideoCommon::Shader::Sampler& entry) {
251 return TextureTypeToSurfaceTarget(entry.GetType(), entry.IsArray()); 251 return TextureTypeToSurfaceTarget(entry.type, entry.is_array);
252} 252}
253 253
254VideoCore::Surface::SurfaceTarget SurfaceParams::ExpectedTarget( 254VideoCore::Surface::SurfaceTarget SurfaceParams::ExpectedTarget(
255 const VideoCommon::Shader::Image& entry) { 255 const VideoCommon::Shader::Image& entry) {
256 return ImageTypeToSurfaceTarget(entry.GetType()); 256 return ImageTypeToSurfaceTarget(entry.type);
257} 257}
258 258
259bool SurfaceParams::IsLayered() const { 259bool SurfaceParams::IsLayered() const {
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index d2d2846e6..d6efc34b2 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -1172,7 +1172,7 @@ private:
1172 /// Returns true the shader sampler entry is compatible with the TIC texture type. 1172 /// Returns true the shader sampler entry is compatible with the TIC texture type.
1173 static bool IsTypeCompatible(Tegra::Texture::TextureType tic_type, 1173 static bool IsTypeCompatible(Tegra::Texture::TextureType tic_type,
1174 const VideoCommon::Shader::Sampler& entry) { 1174 const VideoCommon::Shader::Sampler& entry) {
1175 const auto shader_type = entry.GetType(); 1175 const auto shader_type = entry.type;
1176 switch (tic_type) { 1176 switch (tic_type) {
1177 case Tegra::Texture::TextureType::Texture1D: 1177 case Tegra::Texture::TextureType::Texture1D:
1178 case Tegra::Texture::TextureType::Texture1DArray: 1178 case Tegra::Texture::TextureType::Texture1DArray:
@@ -1193,7 +1193,7 @@ private:
1193 if (shader_type == Tegra::Shader::TextureType::TextureCube) { 1193 if (shader_type == Tegra::Shader::TextureType::TextureCube) {
1194 return true; 1194 return true;
1195 } 1195 }
1196 return shader_type == Tegra::Shader::TextureType::Texture2D && entry.IsArray(); 1196 return shader_type == Tegra::Shader::TextureType::Texture2D && entry.is_array;
1197 } 1197 }
1198 UNREACHABLE(); 1198 UNREACHABLE();
1199 return true; 1199 return true;
diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp
index 1cac2f942..3d759f77b 100644
--- a/src/yuzu/bootmanager.cpp
+++ b/src/yuzu/bootmanager.cpp
@@ -292,6 +292,8 @@ GRenderWindow::GRenderWindow(GMainWindow* parent_, EmuThread* emu_thread_)
292 setLayout(layout); 292 setLayout(layout);
293 InputCommon::Init(); 293 InputCommon::Init();
294 294
295 this->setMouseTracking(true);
296
295 connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete); 297 connect(this, &GRenderWindow::FirstFrameDisplayed, parent_, &GMainWindow::OnLoadComplete);
296} 298}
297 299
@@ -385,6 +387,7 @@ void GRenderWindow::mousePressEvent(QMouseEvent* event) {
385 } else if (event->button() == Qt::RightButton) { 387 } else if (event->button() == Qt::RightButton) {
386 InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y()); 388 InputCommon::GetMotionEmu()->BeginTilt(pos.x(), pos.y());
387 } 389 }
390 QWidget::mousePressEvent(event);
388} 391}
389 392
390void GRenderWindow::mouseMoveEvent(QMouseEvent* event) { 393void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
@@ -397,6 +400,7 @@ void GRenderWindow::mouseMoveEvent(QMouseEvent* event) {
397 const auto [x, y] = ScaleTouch(pos); 400 const auto [x, y] = ScaleTouch(pos);
398 this->TouchMoved(x, y); 401 this->TouchMoved(x, y);
399 InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y()); 402 InputCommon::GetMotionEmu()->Tilt(pos.x(), pos.y());
403 QWidget::mouseMoveEvent(event);
400} 404}
401 405
402void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) { 406void GRenderWindow::mouseReleaseEvent(QMouseEvent* event) {
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index a44eed047..75c6cf20b 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -743,6 +743,8 @@ void Config::ReadUIValues() {
743 UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt(); 743 UISettings::values.profile_index = ReadSetting(QStringLiteral("profileIndex"), 0).toUInt();
744 UISettings::values.pause_when_in_background = 744 UISettings::values.pause_when_in_background =
745 ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool(); 745 ReadSetting(QStringLiteral("pauseWhenInBackground"), false).toBool();
746 UISettings::values.hide_mouse =
747 ReadSetting(QStringLiteral("hideInactiveMouse"), false).toBool();
746 748
747 ApplyDefaultProfileIfInputInvalid(); 749 ApplyDefaultProfileIfInputInvalid();
748 750
@@ -1169,6 +1171,7 @@ void Config::SaveUIValues() {
1169 WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0); 1171 WriteSetting(QStringLiteral("profileIndex"), UISettings::values.profile_index, 0);
1170 WriteSetting(QStringLiteral("pauseWhenInBackground"), 1172 WriteSetting(QStringLiteral("pauseWhenInBackground"),
1171 UISettings::values.pause_when_in_background, false); 1173 UISettings::values.pause_when_in_background, false);
1174 WriteSetting(QStringLiteral("hideInactiveMouse"), UISettings::values.hide_mouse, false);
1172 1175
1173 qt_config->endGroup(); 1176 qt_config->endGroup();
1174} 1177}
diff --git a/src/yuzu/configuration/configure_general.cpp b/src/yuzu/configuration/configure_general.cpp
index 5ef927114..cb95423e0 100644
--- a/src/yuzu/configuration/configure_general.cpp
+++ b/src/yuzu/configuration/configure_general.cpp
@@ -26,6 +26,7 @@ void ConfigureGeneral::SetConfiguration() {
26 ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing); 26 ui->toggle_check_exit->setChecked(UISettings::values.confirm_before_closing);
27 ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot); 27 ui->toggle_user_on_boot->setChecked(UISettings::values.select_user_on_boot);
28 ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background); 28 ui->toggle_background_pause->setChecked(UISettings::values.pause_when_in_background);
29 ui->toggle_hide_mouse->setChecked(UISettings::values.hide_mouse);
29 30
30 ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit); 31 ui->toggle_frame_limit->setChecked(Settings::values.use_frame_limit);
31 ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked()); 32 ui->frame_limit->setEnabled(ui->toggle_frame_limit->isChecked());
@@ -36,6 +37,7 @@ void ConfigureGeneral::ApplyConfiguration() {
36 UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked(); 37 UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
37 UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked(); 38 UISettings::values.select_user_on_boot = ui->toggle_user_on_boot->isChecked();
38 UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked(); 39 UISettings::values.pause_when_in_background = ui->toggle_background_pause->isChecked();
40 UISettings::values.hide_mouse = ui->toggle_hide_mouse->isChecked();
39 41
40 Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked(); 42 Settings::values.use_frame_limit = ui->toggle_frame_limit->isChecked();
41 Settings::values.frame_limit = ui->frame_limit->value(); 43 Settings::values.frame_limit = ui->frame_limit->value();
diff --git a/src/yuzu/configuration/configure_general.ui b/src/yuzu/configuration/configure_general.ui
index 857119bb3..fc3b7e65a 100644
--- a/src/yuzu/configuration/configure_general.ui
+++ b/src/yuzu/configuration/configure_general.ui
@@ -72,6 +72,13 @@
72 </property> 72 </property>
73 </widget> 73 </widget>
74 </item> 74 </item>
75 <item>
76 <widget class="QCheckBox" name="toggle_hide_mouse">
77 <property name="text">
78 <string>Hide mouse on inactivity</string>
79 </property>
80 </widget>
81 </item>
75 </layout> 82 </layout>
76 </item> 83 </item>
77 </layout> 84 </layout>
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index b44b4276c..0a6839b2d 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -135,6 +135,8 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
135} 135}
136#endif 136#endif
137 137
138constexpr int default_mouse_timeout = 2500;
139
138constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000; 140constexpr u64 DLC_BASE_TITLE_ID_MASK = 0xFFFFFFFFFFFFE000;
139 141
140/** 142/**
@@ -236,6 +238,14 @@ GMainWindow::GMainWindow()
236 // Show one-time "callout" messages to the user 238 // Show one-time "callout" messages to the user
237 ShowTelemetryCallout(); 239 ShowTelemetryCallout();
238 240
241 // make sure menubar has the arrow cursor instead of inheriting from this
242 ui.menubar->setCursor(QCursor());
243 statusBar()->setCursor(QCursor());
244
245 mouse_hide_timer.setInterval(default_mouse_timeout);
246 connect(&mouse_hide_timer, &QTimer::timeout, this, &GMainWindow::HideMouseCursor);
247 connect(ui.menubar, &QMenuBar::hovered, this, &GMainWindow::ShowMouseCursor);
248
239 QStringList args = QApplication::arguments(); 249 QStringList args = QApplication::arguments();
240 if (args.length() >= 2) { 250 if (args.length() >= 2) {
241 BootGame(args[1]); 251 BootGame(args[1]);
@@ -1012,6 +1022,13 @@ void GMainWindow::BootGame(const QString& filename) {
1012 async_status_button->setDisabled(true); 1022 async_status_button->setDisabled(true);
1013 renderer_status_button->setDisabled(true); 1023 renderer_status_button->setDisabled(true);
1014 1024
1025 if (UISettings::values.hide_mouse) {
1026 mouse_hide_timer.start();
1027 setMouseTracking(true);
1028 ui.centralwidget->setMouseTracking(true);
1029 ui.menubar->setMouseTracking(true);
1030 }
1031
1015 const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID(); 1032 const u64 title_id = Core::System::GetInstance().CurrentProcess()->GetTitleID();
1016 1033
1017 std::string title_name; 1034 std::string title_name;
@@ -1080,6 +1097,10 @@ void GMainWindow::ShutdownGame() {
1080 game_list->show(); 1097 game_list->show();
1081 game_list->setFilterFocus(); 1098 game_list->setFilterFocus();
1082 1099
1100 setMouseTracking(false);
1101 ui.centralwidget->setMouseTracking(false);
1102 ui.menubar->setMouseTracking(false);
1103
1083 UpdateWindowTitle(); 1104 UpdateWindowTitle();
1084 1105
1085 // Disable status bar updates 1106 // Disable status bar updates
@@ -1837,6 +1858,17 @@ void GMainWindow::OnConfigure() {
1837 1858
1838 config->Save(); 1859 config->Save();
1839 1860
1861 if (UISettings::values.hide_mouse && emulation_running) {
1862 setMouseTracking(true);
1863 ui.centralwidget->setMouseTracking(true);
1864 ui.menubar->setMouseTracking(true);
1865 mouse_hide_timer.start();
1866 } else {
1867 setMouseTracking(false);
1868 ui.centralwidget->setMouseTracking(false);
1869 ui.menubar->setMouseTracking(false);
1870 }
1871
1840 dock_status_button->setChecked(Settings::values.use_docked_mode); 1872 dock_status_button->setChecked(Settings::values.use_docked_mode);
1841 async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation); 1873 async_status_button->setChecked(Settings::values.use_asynchronous_gpu_emulation);
1842#ifdef HAS_VULKAN 1874#ifdef HAS_VULKAN
@@ -1970,6 +2002,30 @@ void GMainWindow::UpdateStatusBar() {
1970 emu_frametime_label->setVisible(true); 2002 emu_frametime_label->setVisible(true);
1971} 2003}
1972 2004
2005void GMainWindow::HideMouseCursor() {
2006 if (emu_thread == nullptr || UISettings::values.hide_mouse == false) {
2007 mouse_hide_timer.stop();
2008 ShowMouseCursor();
2009 return;
2010 }
2011 setCursor(QCursor(Qt::BlankCursor));
2012}
2013
2014void GMainWindow::ShowMouseCursor() {
2015 unsetCursor();
2016 if (emu_thread != nullptr && UISettings::values.hide_mouse) {
2017 mouse_hide_timer.start();
2018 }
2019}
2020
2021void GMainWindow::mouseMoveEvent(QMouseEvent* event) {
2022 ShowMouseCursor();
2023}
2024
2025void GMainWindow::mousePressEvent(QMouseEvent* event) {
2026 ShowMouseCursor();
2027}
2028
1973void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) { 2029void GMainWindow::OnCoreError(Core::System::ResultStatus result, std::string details) {
1974 QMessageBox::StandardButton answer; 2030 QMessageBox::StandardButton answer;
1975 QString status_message; 2031 QString status_message;
diff --git a/src/yuzu/main.h b/src/yuzu/main.h
index 0b750689d..60b17c54a 100644
--- a/src/yuzu/main.h
+++ b/src/yuzu/main.h
@@ -216,6 +216,8 @@ private:
216 std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id); 216 std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
217 void UpdateWindowTitle(const QString& title_name = {}); 217 void UpdateWindowTitle(const QString& title_name = {});
218 void UpdateStatusBar(); 218 void UpdateStatusBar();
219 void HideMouseCursor();
220 void ShowMouseCursor();
219 221
220 Ui::MainWindow ui; 222 Ui::MainWindow ui;
221 223
@@ -244,6 +246,7 @@ private:
244 QString game_path; 246 QString game_path;
245 247
246 bool auto_paused = false; 248 bool auto_paused = false;
249 QTimer mouse_hide_timer;
247 250
248 // FS 251 // FS
249 std::shared_ptr<FileSys::VfsFilesystem> vfs; 252 std::shared_ptr<FileSys::VfsFilesystem> vfs;
@@ -265,4 +268,6 @@ protected:
265 void dropEvent(QDropEvent* event) override; 268 void dropEvent(QDropEvent* event) override;
266 void dragEnterEvent(QDragEnterEvent* event) override; 269 void dragEnterEvent(QDragEnterEvent* event) override;
267 void dragMoveEvent(QDragMoveEvent* event) override; 270 void dragMoveEvent(QDragMoveEvent* event) override;
271 void mouseMoveEvent(QMouseEvent* event) override;
272 void mousePressEvent(QMouseEvent* event) override;
268}; 273};
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h
index a675ecf4d..830932d45 100644
--- a/src/yuzu/uisettings.h
+++ b/src/yuzu/uisettings.h
@@ -59,6 +59,7 @@ struct Values {
59 bool confirm_before_closing; 59 bool confirm_before_closing;
60 bool first_start; 60 bool first_start;
61 bool pause_when_in_background; 61 bool pause_when_in_background;
62 bool hide_mouse;
62 63
63 bool select_user_on_boot; 64 bool select_user_on_boot;
64 65