Commit Graph

28995 Commits

Author SHA1 Message Date
JosJuice ca508e4503 ControllerInterface/Android: Handle input events
Android doesn't let us poll inputs whenever we want. Instead, we
listen to input events (activities will have to forward them to the
input backend), and store the received values in atomic variables
in the Input classes. This is similar in concept to how ButtonManager
worked, but without its homegrown second input mapping system.
2023-03-03 22:28:23 +01:00
JosJuice 792cb62195 ControllerInterface/Android: Implement device population 2023-03-03 22:28:23 +01:00
JosJuice 0150f521f7 ControllerInterface/Android: Rip out ButtonManager
ButtonManager is very different from how a normal input backend works,
and is making it hard for us to improve controller support on Android.
The following commits will add a new input backend in its place.
2023-03-03 22:28:23 +01:00
JosJuice 95ce41ac56
Merge pull request #11399 from JosJuice/jit-one-stack
Jit: Don't use a second stack
2023-03-03 22:27:16 +01:00
Minty-Meeo bf079d6d3a [[unlikely]] ASSERT
and other ASSERT usage changes
2023-03-02 19:54:15 -06:00
Mai 6361586a04
Merge pull request #11582 from Pokechu22/software-crash-on-startup
Software: Fix regressions from "Kill Renderer"
2023-03-02 15:13:00 -05:00
Mai ab2f8d3475
Merge pull request #11607 from AdmiralCurtiss/sd-progress
Qt/WiiPane: Add progress window for SD card conversion.
2023-03-02 15:08:18 -05:00
Pokechu22 9cdc0aca9b Software: Fix "Auto-Adjust Window Size"
This also needs to be handled on the software renderer path.
2023-03-02 11:08:49 -08:00
Pokechu22 78428dd8db Software: Fix crash on startup when using "Compile Shaders Before Starting"
When that setting is enabled, m_xfb_entry is initially not present (during the phase where a shader compilation progress bar would be shown). The main path checks for m_xfb_entry, but the software renderer fallback path didn't.

Fixes another aspect of https://bugs.dolphin-emu.org/issues/13172.
2023-03-02 11:08:49 -08:00
Pokechu22 4a2d3c83c7 Software: Implement GetSurfaceInfo()
Before, it used a fallback where it returned a default object, where the width and height were set to 0. Presenter::Initialize() used GetSurfaceInfo to set the backbuffer size, then used that size when initializing the on-screen UI (even for the software renderer, where the on-screen UI isn't currently present), which meant that ImGui got a window size of 0 and thus resulted in a failed assertion.

Although BindBackbuffer checks for size changes, it doesn't help because ImGui has already been initialized, and the size hasn't actually changed since initialization occured.

Fixes one aspect of https://bugs.dolphin-emu.org/issues/13172.
2023-03-02 11:08:49 -08:00
SMarioMan 078730c873
Avoid altering TCP sockets
Co-authored-by: sepalani <sepalani@hotmail.fr>
2023-03-01 20:52:43 -05:00
iwubcode 42cb3f3904 VideoCommon: remove HiResTexture DDS loading, update hirestexture logic to use custom texture data 2023-03-01 12:11:04 -06:00
iwubcode 3e35255983 VideoCommon: add class to load custom texture data 2023-03-01 11:58:37 -06:00
Admiral H. Curtiss e2bd7d1d95
Common/FatFsUtil: Close temp file before deleting it on conversion failure. 2023-02-28 20:31:56 +01:00
Admiral H. Curtiss fe26b54efd
Qt/WiiPane: Add progress window for SD card conversion. 2023-02-28 20:31:55 +01:00
Admiral H. Curtiss 435d8c39ee
Common/FatFsUtil: Add callback for cancelling SD card conversion. 2023-02-28 20:31:51 +01:00
JosJuice b6256a57ef Jit: Move stack handling code to JitBase
Deduplication between Jit64 and JitArm64.
2023-02-28 20:30:06 +01:00
JosJuice 86c1f6e1e7 Jit: Don't use a second stack
This second stack leads to JNI problems on Android, because ART fetches
the address and size of the original stack using pthread functions
(see GetThreadStack in art/runtime/thread.cc), and (presumably) treats
stack addresses outside of the original stack as invalid. (What I don't
understand is why some JNI operations on the CPU thread work fine
despite this but others don't.)

Instead of creating a second stack, let's borrow the approach ART uses:
Use pthread functions to find out the stack's address and size, then
install guard pages at an appropriate location. This lets us get rid
of a workaround we had in the MsgAlert function.

Because we're no longer choosing the stack size ourselves, I've made some
tweaks to where the put the guard pages. Previously we had a stack of
2 MiB and a safe zone of 512 KiB. We now accept stacks as small as 512 KiB
(used on macOS) and use a safe zone of 256 KiB. I feel like this should
be fine, but haven't done much testing beyond "it seems to work".

By the way, on Windows it was already the case that we didn't create
a second stack... But there was a bug in the implementation!
The code for protecting the stack has to run on the CPU thread, since
it's the CPU thread's stack we want to protect, but it was actually
running on EmuThread. This commit fixes that, since now this bug
matters on other operating systems too.
2023-02-28 20:29:46 +01:00
JosJuice 0cdae98181 Jit: Fix GUARD_OFFSET calculation
Seems like this was broken all along. The safe zone is at the lower
addresses of the stack, not the higher addresses.
2023-02-28 19:11:35 +01:00
Admiral H. Curtiss a0974c18cd
RiivolutionPatcher: Use capitalization of file that exists in the host file system if possible.
Fixes https://bugs.dolphin-emu.org/issues/13138
2023-02-28 00:56:34 +01:00
Admiral H. Curtiss bdb19085c4
Common: Add utility function for case-insensitive string comparison. 2023-02-28 00:56:33 +01:00
JosJuice 7586fc8134
Merge pull request #11608 from Dentomologist/fix_dynamicinputtextures_directory_error_logs
UICommon: Create Load/DynamicInputTextures directory on startup
2023-02-27 18:07:57 +01:00
Admiral H. Curtiss 251fb92b80
Merge pull request #11606 from JosJuice/control-group-save-enabled
InputCommon: Fix ControlGroup::SaveConfig with DefaultValue::Disabled
2023-02-27 12:02:25 +01:00
Admiral H. Curtiss c730ee2de2
Merge pull request #11596 from AdmiralCurtiss/copyany
Common/FileUtil: Migrate CopyDir() to a more clear interface.
2023-02-27 12:02:00 +01:00
Admiral H. Curtiss a11b9d585f
Common/FileUtil: Remove obsolete CopyDir() function. 2023-02-26 23:17:10 +01:00
Admiral H. Curtiss 4f462b4ef6
Migrate destructive calls of File::CopyDir() to File::Move(). 2023-02-26 23:17:10 +01:00
Admiral H. Curtiss 5367bf394c
Common/FileUtil: Add Move() function. 2023-02-26 23:17:09 +01:00
Dentomologist e62162e486 UICommon: Create Load/DynamicInputTextures directory on startup
Fix console error spam on Dolphin and game startup if the directory
doesn't exist.
2023-02-26 13:10:15 -08:00
Daniel Garza 02f7c0213f
Qt/GameList: Also filter by filename when searching. 2023-02-26 19:13:45 +01:00
JosJuice 9b3816c993 InputCommon: Fix ControlGroup::SaveConfig with DefaultValue::Disabled
I also changed LoadConfig, but that change doesn't affect correctness,
it's only so it looks neat by matching SaveConfig.

This bug was added in 18a4afb053, the
commit that introduced DefaultValue::Disabled. The bug can't actually be
triggered in master, but it can be triggered in the Android input
overhaul PR.
2023-02-26 17:45:09 +01:00
Admiral H. Curtiss 26adf78e45
Merge pull request #11602 from JosJuice/cpu-guard-expression
PowerPC: Rework CPUThreadGuard handling in Expression.cpp
2023-02-26 11:55:47 +01:00
Shawn Hoffman 28956cc6c2 workaround msvc optimizer bug 2023-02-25 23:26:27 -08:00
Dentomologist ad6e95afb4 D3D: Restore workaround for erroneous NaN optimization
The HLSL compiler incorrectly decides isnan can't be true, so this
workaround was originally added in 52c82733 but lost during the
conversion to SPIR-V.
2023-02-25 16:27:30 -08:00
JosJuice ae5311d6e6 PowerPC: Rework CPUThreadGuard handling in Expression.cpp
See https://github.com/dolphin-emu/dolphin/pull/11554#discussion_r1113949572.
2023-02-25 16:13:34 +01:00
Dentomologist d18735e82e Qt/WiimoteControllersWidget: Add bluetooth unavailable message 2023-02-24 14:30:43 -08:00
Admiral H. Curtiss 1ed0e014cd
Migrate non-destructive calls of File::CopyDir() to File::Copy(). 2023-02-24 20:32:19 +01:00
Admiral H. Curtiss 884917a6d5
Common/FileUtil: Use non-throwing overload of is_directory() in CreateDir() and CreateFullPath(). 2023-02-24 20:32:19 +01:00
Admiral H. Curtiss e479f92418
Common/FileUtil: Add CreateDirs() function as a wrapper around std::filesystem::create_directories(). 2023-02-24 20:32:18 +01:00
Admiral H. Curtiss 616d57e7fc
Common/FileUtil: Add Copy() function as a wrapper around std::filesystem::copy(). 2023-02-24 20:32:18 +01:00
iwubcode 5d571b068f VideoBackends: rework d3d11 to specify samplers/bound textures using a bitset with a constant size, instead of hardcoding each individual enumeration value 2023-02-24 11:32:48 -06:00
Shawn Hoffman 2c2fb869a2 use std-provided randomness for JitArm64 unittests
decreases runtime significantly and lessens dependency on mbedtls
2023-02-22 12:55:12 -08:00
Admiral H. Curtiss e52aa52a66
Common/FileUtil: Rename Copy() to CopyRegularFile().
This is to clarify that it can only copy files, not folders.
2023-02-22 11:43:58 +01:00
Léo Lam 3c4a21315d
Merge pull request #11592 from Pokechu22/fix-delete-ticket
IOS/ES: Fix crash when deleting tickets
2023-02-21 10:53:37 +01:00
Pokechu22 f2ac3aec94 IOS/ES: Fix crash when deleting tickets
This broke formatting the system memory; see https://bugs.dolphin-emu.org/issues/13176. After calling ticket.DeleteTicket(), ticket.m_bytes was 0-length, but calling ticket.IsV1Ticket() still attempted to read from m_bytes.

This was introduced in 2fd9852ca8, although it didn't actually cause a crash until 929fba08e7.
2023-02-20 18:33:34 -08:00
Mai 6f21ce7d95
Merge pull request #11555 from CookiePLMonster/wil-todos
Address WIL todos in UICommon.cpp
2023-02-20 10:14:49 -05:00
Admiral H. Curtiss 4e6c89fbfd
Qt/CodeViewWidget: Don't read PC in Update() if we don't have a CPU thread guard. 2023-02-20 03:10:12 +01:00
Admiral H. Curtiss ef1520c2c6
Qt/CodeViewWidget: Don't try to pause emulator in Update() if we happen to be on a breakpoint. 2023-02-20 02:56:04 +01:00
Seeky 4e6e510003
Debugger: Add string comparison to conditional breakpoints. 2023-02-20 01:40:33 +01:00
JosJuice 78c53bfec8 Jit64: Fix the offsetAddedToAddress correction
The LEA that the signal handler is trying to undo the effects of is a
32-bit instruction, and the value in the register prior to the LEA is
also 32-bit, so the signal handler should use a 32-bit write.

(Actually, in the end this doesn't really matter, because the first
instruction that reads this value after backpatching is also a 32-bit
instruction...)
2023-02-18 21:14:31 +01:00
Admiral H. Curtiss 8db35e6d04
Merge pull request #11578 from Pokechu22/memory-leaks-feb-2023
Fix various memory leaks
2023-02-18 13:56:34 +01:00
Pokechu22 c94aacc968 AudioPane: Fix inconsistent initial state of audio stretching labels
This resulted in the labels being solid black even when audio stretching is disabled the first time the settings are opened, but then properly being greyed out after changing a setting (even the audio backend or DSP emulation engine, not just whether audio stretching is enabled).
2023-02-17 18:51:41 -08:00
Pokechu22 f1f3fd5d9d InputCommon: Fix memory leak in ExpressionParser
We allocate in MakeSuppressor via `return unique_ptr(std::make_unique<...>(...).release(), InvokingDeleter{}`, so it wasn't properly getting freed.
2023-02-17 18:29:36 -08:00
Pokechu22 b6d476241a CodeViewWidget: Fix memory leak
Per https://doc.qt.io/qt-6/qabstractitemview.html#setItemDelegateForColumn setItemDelegateForColumn does not take ownership of the parameter, so it was not being deleted. Specifying a parent to QObject (via QStyledItemDelegate's constructor) will allow it to automatically be deleted, per https://doc.qt.io/qt-6/objecttrees.html. The other instance of a QItemDelegate in IOWindow.cpp already used this.
2023-02-17 18:29:32 -08:00
Pokechu22 1c5e223532 MemoryViewWidget: Fix memory leaks
bp_item/row_item/item were never deleted, and the normal Qt ownership system wasn't applying to them because they were being cloned.
2023-02-17 18:17:01 -08:00
Admiral H. Curtiss 74abf48234
Merge pull request #11576 from yannhodiesne/convert-prevent-file-deletion
Check the input and destination paths before converting a game file onto itself
2023-02-17 18:49:15 +01:00
Markus Wick b381df700c
Merge pull request #11577 from JosJuice/android-armeabi-v7a
Android: Fix armeabi-v7a build
2023-02-17 17:57:38 +01:00
JosJuice 90b676d368 Android: Fix armeabi-v7a build
This very much isn't a build configuration that we're going to ship,
but I want to be able to tell people that they can build it on their
own if they really want to see how terribly it performs :)

Just like before, you'll need to edit two lines in app/build.gradle to
define ENABLE_GENERIC=ON and actually enable armeabi-v7a if you want an
armeabi-v7a build. This commit just fixes some compilations errors that
crop up if you do so.
2023-02-17 16:58:24 +01:00
Yann Hodiesne 49e897422f
Use a success count instead of files count 2023-02-17 15:49:31 +01:00
Yann Hodiesne cb42a03299
Check the input and destination paths before converting a game file onto itself
Before these changes you could tell Dolphin to convert a game file into the same format it is already in, leading to the FileDialog using the input path as the default destination path
An unsuspecting user could then click Save and Dolphin would try to convert the input file by writing the destination file on top of it... leading to an I/O error and the input file being entirely removed
2023-02-17 14:26:50 +01:00
Scott Mansell 28331c5905
Merge pull request #11574 from K0bin/val-fix
VideoBackends:Vulkan: Fix printing validation errors
2023-02-17 14:52:45 +13:00
Admiral H. Curtiss 0c48324c75
Jit64: Use 5 byte jump in mtmsr for the CP interrupt check.
WriteExternalExceptionExit() can write more than the maximum offset of the small jump.
2023-02-16 19:26:19 +01:00
Robin Kertels 2695666e6d
VideoBackends:Vulkan: Fix printing validation errors 2023-02-16 17:53:15 +01:00
Scott Mansell 6038a6e2db
Merge pull request #11569 from Hibyehello/patch-1
VideoBackend: Make Metal Default on MacOS
2023-02-16 21:08:35 +13:00
Pokechu22 74a14c7d1f ControllerInterface: Fix uninitialized variables in DualShockUDPClient
Strangely, this case did not trigger a C26495 warning in Visual Studio's analyzer; instead, I spotted this when using Valgrind.
2023-02-15 19:23:47 -08:00
Pokechu22 67381cdb8b VideoCommon: Remove unused ShutdownImGui function declaration
This was moved to the ~OnScreenUI() destructor in 0d4537d60f.
2023-02-15 19:20:59 -08:00
Pokechu22 8802f96b7e Fix uninitialized variable warnings (C26495) 2023-02-15 19:18:39 -08:00
Josh cd38ed76e2
Keep Vulkan precedence over OpenGL 2023-02-15 12:22:56 -06:00
Josh 546a016dc8
VideoBackend: Make Metal Default on MacOS 2023-02-15 12:05:54 -06:00
SMarioMan 301e97f7f7
Remove WinAPI-specific type from socket request 2023-02-15 09:29:21 -05:00
SMarioMan a45f6d9438
Enable broadcast permissions in socket requests 2023-02-15 07:59:38 -05:00
Admiral H. Curtiss 0758e00cfe
Common/FileUtil: Revert behavior of CreateFullPath().
This was accidentally changed in 7e6436db34.
2023-02-15 02:21:50 +01:00
Admiral H. Curtiss 661b74f4a3
Merge pull request #11564 from JosJuice/jitarm64-cmp-order
JitArm64: Fix special cases of cmp
2023-02-14 20:19:07 +01:00
Admiral H. Curtiss e1d3237dbd
Merge pull request #11342 from TellowKrinkle/GLLayerMac
VideoCommon: Fix stereoscopic 3D on OpenGL < 4.3 (macOS)
2023-02-14 20:17:22 +01:00
JosJuice 0049a76775 JitArm64: Fix special cases of cmp
This fixes a regression from 592ba31. When `a` was a constant 0 and `b`
was a non-constant 0x80000000, the 32-bit negation operation would
overflow, causing an incorrect result. The sign extension needs to happen
before the negation to avoid overflow.

Note that I can't merge the SXTW and NEG into one instruction.
NEG is an alias for SUB with the first operand being set to ZR,
but "SUB (extended register)" treats register 31 as SP instead of ZR.

I've also changed the order for the case where `a` is a constant
0xFFFFFFFF. I don't think the order actually affects correctness here,
but let's use the same order for all the cases since it makes the code
easier to reason about.
2023-02-14 19:16:00 +01:00
Admiral H. Curtiss 22ed084209
Merge pull request #11563 from JosJuice/host-lock-cpu-fixups
Follow-up fixes for "Properly lock CPU before accessing emulated memory"
2023-02-14 19:04:21 +01:00
JosJuice 5b6784432c Follow-up fixes for "Properly lock CPU before accessing emulated memory" 2023-02-14 18:44:16 +01:00
TellowKrinkle f25a0b43b6 VideoCommon: Fix stereoscopic 3D on OpenGL < 4.3 (macOS) 2023-02-14 18:25:33 +01:00
Pokechu22 4f6ce51d69 VideoCommon: Clear blend configuration if color/alpha update disabled
This works around an Intel driver bug where, on D3D12 only, dual-source blending behaves incorrectly if the second source is unused on. This bug is visible in skyboxes in Super Mario Sunshine, which first draw clouds and sun flare in greyscale and then draw the sky afterwards with a source factor of 1 and a dest factor of 1-src_color (this results in the clouds being tinted blue). This process is done on an RGB888 framebuffer, so alpha update is disabled. (Color update is enabled; note that if you look at this in Dolphin's fifo analyzer, it won't be enabled because they use the BP mask functionality to only change the blending functions and not alpha/color update, for whatever reason.)
2023-02-13 18:22:41 -08:00
Admiral H. Curtiss 5f929d00eb
Merge pull request #11560 from phire/EventHook_construct_on_first_use
HookableEvent: Switch to construct on first use
2023-02-14 01:01:03 +01:00
Admiral H. Curtiss 34a459bed7
Merge pull request #11445 from JosJuice/jit64-wraparound-backpatch
Jit64: Properly handle backpatching overflowed address calculations
2023-02-14 01:00:13 +01:00
Admiral H. Curtiss 3458c58c7d
Merge pull request #11503 from JosJuice/ppcanalyst-read-cr
PPCAnalyst: Actually check if instructions want CR
2023-02-14 00:55:24 +01:00
Admiral H. Curtiss e2d7b6d079
Merge pull request #11559 from Pokechu22/cache-fix-plru-updates
PPCCache: Update PLRU on any cache access
2023-02-14 00:50:54 +01:00
Admiral H. Curtiss 8f91cb62e6
Merge pull request #11426 from shuffle2/stdfs
fileutil: use std::filesystem
2023-02-14 00:50:34 +01:00
Admiral H. Curtiss e1dbea3658
JIT: Fix calls to HLE::Execute.
This got broken in 7cecb28bdf.
2023-02-13 11:47:47 +01:00
Scott Mansell 05181f6b88 HookableEvent: Switch to construct on first use
A registration might happen during static initialization, which opens
us up to issues with ordering of static initialization.
2023-02-13 18:48:43 +13:00
Scott Mansell 1fc5d37fd2
Merge pull request #11558 from Pokechu22/vertex-loader-size-assertion-details
VertexLoader: Add more info to m_vertex_size == m_src_ofs assertion
2023-02-13 17:34:04 +13:00
Pokechu22 cc411c4e41 VertexLoader: Add more info to m_vertex_size == m_src_ofs assertion 2023-02-12 20:10:38 -08:00
Pokechu22 14c4f4e7f6 PPCCache: Update PLRU on any cache access
The previous code only updated the PLRU on cache misses, which made it so that the least recently inserted cache block was evicted, instead of the least recently used/hit one.

This regressed in 9d39647f9e (part of #11183, but it was fine in e97d380437), although beforehand it was only implemented for the instruction cache, and the instruction cache hit extremely infrequently when the JIT or cached interpreter is in use, which generally keeps it from behaving correctly (the pure interpreter behaves correctly with it).

I'm not aware of any games that are affected by this, though I did not do extensive testing.
2023-02-12 19:59:19 -08:00
Scott Mansell a4729a026f
Merge pull request #11554 from JosJuice/host-lock-cpu
DolphinQt: Properly lock CPU before accessing emulated memory
2023-02-13 16:08:36 +13:00
Scott Mansell f37113204f
Merge pull request #11550 from iwubcode/set_common_samplers_count
VideoCommon: add constant value for maximum number of pixel samplers
2023-02-13 16:05:51 +13:00
Scott Mansell 2c24d07837
Merge pull request #11538 from t895/disc-speed-stuff
Rename "Speed up Disc Transfer Rate" to "Emulate Disc Speed"
2023-02-13 15:46:56 +13:00
Charles Lombardo 0ed64b080f Rename Fast Disc Speed to Emulate Disc Speed and invert option 2023-02-12 16:20:38 -05:00
Admiral H. Curtiss 300d63b492
DiscIO/FileBlob: Make m_size unsigned. 2023-02-12 20:51:08 +01:00
JosJuice 611e721a4d Jit64: Properly handle backpatching overflowed address calculations
Previously we would only backpatch overflowed address calculations
if the overflow was 0x1000 or less. Now we can handle the full 2 GiB
of overflow in both directions.

I'm also making equivalent changes to JitArm64's code. This isn't because
it needs it – JitArm64 address calculations should never overflow – but
because I wanted to get rid of the 0x100001000 inherited from Jit64 that
makes even less sense for JitArm64 than for Jit64.
2023-02-12 20:48:27 +01:00
Admiral H. Curtiss c3dee1f11c
Merge pull request #11499 from iwubcode/graphics-mod-pass-base-path
VideoCommon: allow graphics mods to have access to the file path where the config exists to load additional files
2023-02-12 19:04:59 +01:00
Silent 9f3d3e2b9c
Address WIL todos in UICommon.cpp 2023-02-12 15:05:54 +01:00
JosJuice 6f0266e8de DolphinQt: Only update call stack if paused
This avoids a pseudo infinite loop where CodeWidget::UpdateCallstack
would lock the CPU in order to read the call stack, causing the CPU to
call Host_UpdateDisasmDialog because it's transitioning from running to
pausing, causing Host::UpdateDisasmDialog to be emitted, causing
CodeWidget::Update to be called, once again causing
CodeWidget::UpdateCallstack to be called, repeating the cycle.

Dolphin didn't go completely unresponsive during this, because
Host_UpdateDisasmDialog schedules the emitting of Host::UpdateDisasmDialog
to happen on another thread without blocking, but it was stopping certain
operations like exiting emulation from working.
2023-02-12 12:50:28 +01:00
JosJuice 7cecb28bdf DolphinQt: Properly lock CPU before accessing emulated memory
This fixes a problem I was having where using frame advance with the
debugger open would frequently cause panic alerts about invalid addresses
due to the CPU thread changing MSR.DR while the host thread was trying
to access memory.

To aid in tracking down all the places where we weren't properly locking
the CPU, I've created a new type (in Core.h) that you have to pass as a
reference or pointer to functions that require running as the CPU thread.
2023-02-12 11:27:50 +01:00
MayImilae 508c79a66f Rename VI Skip to VBI Skip
VI Skip was very hard to explain on the blog, so this small changes
clarifies what VI Skip is to resolve that issue.
2023-02-11 20:28:41 -08:00
iwubcode 20dc4401c5 VideoCommon: pass a graphics mod base path to the graphics mod, so it can lookup other relative files if necessary 2023-02-11 00:21:40 -06:00