* core: rpc: revamp rpc server and add new commands
* core: Move GDB packet handling to the frame limiter as well.
* core: gdb: Improve packet handling
The shadow-texture should only actually be binded if shadows are enabled and if the shadow-texture slot is actually enabled. Otherwise the null-surface should be binded. This ensures that we are are not binding whatever texture slot the register happens to be set to as a shadow-texture. This avoids an RGBA4 texture from being binded into the shadow-texture slot in Monster Hunter 4 Ultimate when opening the equipment set screen.
Addresses https://github.com/azahar-emu/azahar/issues/2531
OpenGL does not have tight synchronization primitives like Vulkan and instead must use whole frame-boundaries to determine when it is safe to delete a texture. Updates the `current_frame` index from renderer-base to be a 64-bit integer and derive the OpenGL texture-runtime resource-tick to be from the renderer's frame-index.
We do this for extensions, but should also be doing it for layers as well to ensure we are not enabling instance-layers that the system does not support.
Addresses https://github.com/azahar-emu/azahar/issues/2507
The copy-texture slot will hold onto a texture of the previous size still. Should be destroyed during a ScaleUp so that the next call to `CopyImageView` can recreate this handle at the new size. Fixes recycled surfaces that get upscaled.
Recycled surfaces may only be upscaled, not downscaled. Recycled
surfaces should be less than or equal to the requested resolution-scale
to ensure we are only upscaling surfaces.
If a handle is already created, then calling `Create` on it again will just override the vulkan handles without cleaning them up first.
`Destroy` should be called within `Create` to ensure that all the handles are properly cleaned up before recreating the handles. This also resolves some memory-leaks that I was seeing upon shutting down the program.
Recycling textures from the deletion-queue was creating an inter-frame
dependency. Surfaces in the deletion-queue may possibly be in use still
by a previous frame. When they get picked up to be recycled, it can
possibly be up-scaled, leading to a race condition where a previous
frame is still using the texture while a new frame is trying to upscale
the texture, or do other destructive operations that modify the
image-handle, for further use. This is fixed by ensuring that we use the
deletion-queue's timestamp to indicate that the texture is actually free
for re-use by the current frame.
These two functions allows the texture-runtime implementation to indicate, with greater precision, when the GPU is precisely done with textures so that they can be deleted. For the vulkan implementation in particular, this allows the precise GPU tick value to be used to indicate when textures are able to be safely deleted.
Use an async flush rather than a flush+wait in vulkan's implementation of `Finish()` as well since we just need to increment the tick here.
Previously we were depending on the fact that pass that wrote to the shadow map
also wrote to the descriptor-set that further draw-calls used. But this was not
viable because it created an implicit intra-frame dependency that lead to
crashes. The previous fix broke this dependency by binding the null-texture
in the case that the current framebuffer is not writing to the depth-buffer,
but we also need to handle the case where a draw-call is just _reading_ from
the shadow-texture because a light was configured with a shadow-map.
This should handle all the edge-cases where a draw-call that does not
use any shadow-mapping will get the null-texture. This also adds the
storage-texture usage bit to RGBA8 textures initially since it may later
be found out that the texture is a shadow-source. Vulkan already
mandates that RGBA8 textures support the storage-bit, technically, but
this should still be set.
For later, check out if `nullDescriptor` is supported so that a null
handle can be written rather than using the null surface here.
The shadow-texture should be set to _null_ rather than leaving it unchanged in the case that we are not shadow-rendering.
Otherwise, on Vulkan, the descriptor set will hold onto references to textures for very long periods of times, possibly holding onto textures queued for deletion at a later time. This was causing command buffers to possibly depend on textures that were queued for deletion hundreds of frames later, leading to crashes.
The rasterizer cache garbage collection criteria was interpreting tick-values
incorrectly, and was only incidentally able to garbage collect textures
within 1 frame of latency. Textures that were invalidated farther back in
time, such as when changing the rendering resolution and finding out that they
need to be deleted later on, were not being properly deleted despite having
older tick values(lower tick values). This fixes the issue by using the
correct `<=` comparison and also fixes the Vulkan implementation of
`GetResourceTick` to avoid a race-condition by ensuring we are
using the latest tick value from the GPU and not the last-known
tick-value.
Fixes https://github.com/azahar-emu/azahar/issues/2472
Fixing the check to work correctly in a previous PR caused major audio issues. The old "incorrect" behaviour has existed for 3 years, so we can probably just leave things as they were for now until we can get a proper fix together.
## Summary
Preserve the complete `SurfaceBase` state when creating an OpenGL surface for a custom texture.
The OpenGL custom surface constructor currently uses:
```cpp
SurfaceBase{surface, {}}
```
while the equivalent Vulkan implementation uses:
```cpp
SurfaceBase{surface}
```
Passing an empty flag set causes the replacement OpenGL surface to lose its existing surface flags, including `SurfaceFlagBits::Registered`.
This can later trigger the assertion:
```text
Assertion Failed!
Trying to unregister an already unregistered surface
```
when the surface is passed to `UnregisterSurface()`.
## Change
```diff
- : SurfaceBase{surface, {}}, driver{&runtime_.GetDriver()}, runtime{&runtime_},
+ : SurfaceBase{surface}, driver{&runtime_.GetDriver()}, runtime{&runtime_},
```
This also makes the OpenGL custom surface constructor consistent with the Vulkan implementation.
## Testing
Tested on Azahar 2126.0 (`fbd3fb0`).
I reproduced the issue using:
- The Legend of Zelda: A Link Between Worlds
- OpenGL backend
- Henriko Magnifico's 4K texture pack
- Custom textures enabled
- 10x internal resolution
With the original code, the game consistently hit:
```text
Trying to unregister an already unregistered surface
```
With `SurfaceBase{surface}`, the game ran normally with the custom texture pack enabled.
The test ran for approximately 3 minutes and ended normally, with no:
```text
Assertion Failed
Trying to unregister an already unregistered surface
<Critical>
```
This addresses the OpenGL custom texture crash reported in #2116.
Fixes#2116
RightEyeDisabler::enable_for_frame defaulted to true and is only refreshed
from Settings::values.disable_right_eye_render in ReportEndFrame(), which
first runs at the initial buffer swap. Until then the disabler was active
even for users who have the option turned off, and it can suppress a command
list during that window.
* core: nwm: Get HLE lock on all wifi packet reception
* nwm: Move packet handling to the emulation thread
* Change async packet queue to async event queue
* Add all UDS events as possible async events
* Added async event signal optimization for single threaded NWM
* Register thread ID only once and other minor things
---------
Co-authored-by: U-DESKTOP-7SFAKTP\Ron <lannoene@gmail.com>