tmp: fix android raii
Some checks failed
eden-build / source (pull_request) Has been skipped
eden-build / linux (pull_request) Successful in 25m23s
eden-build / android (pull_request) Has been cancelled
eden-build / windows (msvc) (pull_request) Has been cancelled
eden-license / license-header (pull_request_target) Has been cancelled
Some checks failed
eden-build / source (pull_request) Has been skipped
eden-build / linux (pull_request) Successful in 25m23s
eden-build / android (pull_request) Has been cancelled
eden-build / windows (msvc) (pull_request) Has been cancelled
eden-license / license-header (pull_request_target) Has been cancelled
- update some translations - fix glasm-spirv mixup. - temporarily remove raii fixes on android, fixes black screen but causes soft crashes Signed-off-by: swurl <swurl@swurl.xyz>
This commit is contained in:
parent
4965c8d51c
commit
205a895367
10 changed files with 216 additions and 63 deletions
|
@ -87,8 +87,8 @@
|
|||
|
||||
<string-array name="rendererShaderNames">
|
||||
<item>@string/shader_backend_glsl</item>
|
||||
<item>@string/shader_backend_spirv</item>
|
||||
<item>@string/shader_backend_glasm</item>
|
||||
<item>@string/shader_backend_spirv</item>
|
||||
</string-array>
|
||||
|
||||
<integer-array name="rendererShaderValues">
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
<string name="show_speed">Show Speed</string>
|
||||
<string name="show_speed_description">Display current emulation speed percentage</string>
|
||||
<string name="show_app_ram_usage">Show App Memory Usage</string>
|
||||
<string name="show_app_ram_usage_description">Display the amount of RAM getting used by the emulator</string>
|
||||
<string name="show_app_ram_usage_description">Display the amount of RAM the emulator is using</string>
|
||||
<string name="show_system_ram_usage">Show System Memory Usage</string>
|
||||
<string name="show_system_ram_usage_description">Display the amount of RAM getting used by the system</string>
|
||||
<string name="show_system_ram_usage_description">Display the amount of RAM used by the system</string>
|
||||
<string name="show_bat_temperature">Show Battery Temperature</string>
|
||||
<string name="show_bat_temperature_description">Display current Battery temperature in Celsius and Fahrenheit</string>
|
||||
<string name="overlay_position">Overlay Position</string>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<string name="dyna_state3">EDS3 + VertexInputDynamicState</string>
|
||||
<string name="dyna_state3_description">Improves performance on newer devices. Only supported on Vulkan 1.3+ GPUs.</string>
|
||||
<string name="use_sync_core">Synchronize Core Speed</string>
|
||||
<string name="use_sync_core_description">Synchronize the core tick speed to the maximum speed percentage to improve performance without altering the games actual speed.</string>
|
||||
<string name="use_sync_core_description">Synchronize the core tick speed to the maximum speed percentage to improve performance without altering the game\'s actual speed.</string>
|
||||
<string name="use_auto_stub">Use Auto Stub</string>
|
||||
<string name="use_auto_stub_description">Automatically stub missing services and functions. This may improve compatibility but can cause crashes and stability issues.</string>
|
||||
<string name="uninstall_firmware">Uninstall firmware</string>
|
||||
|
@ -389,7 +389,7 @@
|
|||
<string name="renderer_optimize_spirv_output">Optimize SPIRV output</string>
|
||||
<string name="renderer_optimize_spirv_output_description">Optimizes compiled shader to improve GPU efficiency.</string>
|
||||
<string name="renderer_asynchronous_shaders">Use asynchronous shaders</string>
|
||||
<string name="renderer_asynchronous_shaders_description">Compiles shaders asynchronously, reducing stutter but may introduce glitches.</string>
|
||||
<string name="renderer_asynchronous_shaders_description">Compiles shaders asynchronously. This may reduce stutters but may also introduce glitches.</string>
|
||||
<string name="use_fast_gpu_time">Use Fast GPU Time</string>
|
||||
<string name="use_fast_gpu_time_description">Forces most games to run at their highest native resolution. This option is hacky and may cause issues.</string>
|
||||
<string name="renderer_reactive_flushing">Use reactive flushing</string>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2025 eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <cstring>
|
||||
|
@ -99,52 +102,91 @@ Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dl
|
|||
}
|
||||
|
||||
RendererVulkan::RendererVulkan(Core::Frontend::EmuWindow& emu_window,
|
||||
Tegra::MaxwellDeviceMemoryManager& device_memory_, Tegra::GPU& gpu_,
|
||||
std::unique_ptr<Core::Frontend::GraphicsContext> context_) try
|
||||
: RendererBase(emu_window, std::move(context_)), device_memory(device_memory_), gpu(gpu_),
|
||||
library(OpenLibrary(context.get())),
|
||||
Tegra::MaxwellDeviceMemoryManager& device_memory_,
|
||||
Tegra::GPU& gpu_,
|
||||
std::unique_ptr<Core::Frontend::GraphicsContext> context_)
|
||||
try
|
||||
: RendererBase(emu_window, std::move(context_))
|
||||
, device_memory(device_memory_)
|
||||
, gpu(gpu_)
|
||||
, library(OpenLibrary(context.get()))
|
||||
,
|
||||
// Create raw Vulkan instance first
|
||||
instance(CreateInstance(*library, dld, VK_API_VERSION_1_1, render_window.GetWindowInfo().type,
|
||||
Settings::values.renderer_debug.GetValue())),
|
||||
instance(CreateInstance(*library,
|
||||
dld,
|
||||
VK_API_VERSION_1_1,
|
||||
render_window.GetWindowInfo().type,
|
||||
Settings::values.renderer_debug.GetValue()))
|
||||
,
|
||||
// Now create RAII wrappers for the resources in the correct order
|
||||
managed_instance(MakeManagedInstance(instance, dld)),
|
||||
managed_instance(MakeManagedInstance(instance, dld))
|
||||
,
|
||||
// Create debug messenger if debug is enabled
|
||||
debug_messenger(Settings::values.renderer_debug ? CreateDebugUtilsCallback(instance)
|
||||
: vk::DebugUtilsMessenger{}),
|
||||
managed_debug_messenger(Settings::values.renderer_debug
|
||||
: vk::DebugUtilsMessenger{})
|
||||
, managed_debug_messenger(Settings::values.renderer_debug
|
||||
? MakeManagedDebugUtilsMessenger(debug_messenger, instance, dld)
|
||||
: ManagedDebugUtilsMessenger{}),
|
||||
: ManagedDebugUtilsMessenger{})
|
||||
,
|
||||
// Create surface
|
||||
surface(CreateSurface(instance, render_window.GetWindowInfo())),
|
||||
managed_surface(MakeManagedSurface(surface, instance, dld)),
|
||||
device(CreateDevice(instance, dld, *surface)),
|
||||
memory_allocator(device), state_tracker(),
|
||||
scheduler(device, state_tracker),
|
||||
swapchain(*surface, device, scheduler, render_window.GetFramebufferLayout().width,
|
||||
render_window.GetFramebufferLayout().height),
|
||||
present_manager(instance, render_window, device, memory_allocator, scheduler, swapchain,
|
||||
*surface),
|
||||
blit_swapchain(device_memory, device, memory_allocator, present_manager, scheduler,
|
||||
PresentFiltersForDisplay),
|
||||
blit_capture(device_memory, device, memory_allocator, present_manager, scheduler,
|
||||
PresentFiltersForDisplay),
|
||||
blit_applet(device_memory, device, memory_allocator, present_manager, scheduler,
|
||||
PresentFiltersForAppletCapture),
|
||||
rasterizer(render_window, gpu, device_memory, device, memory_allocator, state_tracker,
|
||||
scheduler),
|
||||
applet_frame() {
|
||||
surface(CreateSurface(instance, render_window.GetWindowInfo()))
|
||||
, managed_surface(MakeManagedSurface(surface, instance, dld))
|
||||
, device(CreateDevice(instance, dld, *surface))
|
||||
, memory_allocator(device)
|
||||
, state_tracker()
|
||||
, scheduler(device, state_tracker)
|
||||
, swapchain(*surface,
|
||||
device,
|
||||
scheduler,
|
||||
render_window.GetFramebufferLayout().width,
|
||||
render_window.GetFramebufferLayout().height)
|
||||
, present_manager(instance,
|
||||
render_window,
|
||||
device,
|
||||
memory_allocator,
|
||||
scheduler,
|
||||
swapchain,
|
||||
#ifdef ANDROID
|
||||
surface)
|
||||
,
|
||||
#else
|
||||
*surface)
|
||||
,
|
||||
#endif
|
||||
blit_swapchain(device_memory,
|
||||
device,
|
||||
memory_allocator,
|
||||
present_manager,
|
||||
scheduler,
|
||||
PresentFiltersForDisplay)
|
||||
, blit_capture(device_memory,
|
||||
device,
|
||||
memory_allocator,
|
||||
present_manager,
|
||||
scheduler,
|
||||
PresentFiltersForDisplay)
|
||||
, blit_applet(device_memory,
|
||||
device,
|
||||
memory_allocator,
|
||||
present_manager,
|
||||
scheduler,
|
||||
PresentFiltersForAppletCapture)
|
||||
, rasterizer(render_window, gpu, device_memory, device, memory_allocator, state_tracker, scheduler)
|
||||
, applet_frame() {
|
||||
|
||||
if (Settings::values.renderer_force_max_clock.GetValue() && device.ShouldBoostClocks()) {
|
||||
turbo_mode.emplace(instance, dld);
|
||||
scheduler.RegisterOnSubmit([this] { turbo_mode->QueueSubmitted(); });
|
||||
}
|
||||
|
||||
#ifndef ANDROID
|
||||
// Release ownership from the old instance and surface
|
||||
instance.release();
|
||||
surface.release();
|
||||
if (Settings::values.renderer_debug) {
|
||||
debug_messenger.release();
|
||||
}
|
||||
#endif
|
||||
|
||||
Report();
|
||||
} catch (const vk::Exception& exception) {
|
||||
|
|
|
@ -95,15 +95,31 @@ bool CanBlitToSwapchain(const vk::PhysicalDevice& physical_device, VkFormat form
|
|||
|
||||
} // Anonymous namespace
|
||||
|
||||
PresentManager::PresentManager(const vk::Instance& instance_, Core::Frontend::EmuWindow& render_window_,
|
||||
const Device& device_, MemoryAllocator& memory_allocator_, Scheduler& scheduler_,
|
||||
Swapchain& swapchain_, VkSurfaceKHR_T* surface_handle_)
|
||||
: instance{instance_}, render_window{render_window_}, device{device_},
|
||||
memory_allocator{memory_allocator_}, scheduler{scheduler_}, swapchain{swapchain_},
|
||||
surface_handle{surface_handle_},
|
||||
blit_supported{CanBlitToSwapchain(device.GetPhysical(),
|
||||
swapchain.GetImageViewFormat())},
|
||||
use_present_thread{Settings::values.async_presentation.GetValue()} {
|
||||
PresentManager::PresentManager(const vk::Instance& instance_,
|
||||
Core::Frontend::EmuWindow& render_window_,
|
||||
const Device& device_,
|
||||
MemoryAllocator& memory_allocator_,
|
||||
Scheduler& scheduler_,
|
||||
Swapchain& swapchain_,
|
||||
#ifdef ANDROID
|
||||
vk::SurfaceKHR& surface_)
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle_)
|
||||
#endif
|
||||
: instance{instance_}
|
||||
, render_window{render_window_}
|
||||
, device{device_}
|
||||
, memory_allocator{memory_allocator_}
|
||||
, scheduler{scheduler_}
|
||||
, swapchain{swapchain_}
|
||||
#ifdef ANDROID
|
||||
, surface{surface_}
|
||||
#else
|
||||
, surface_handle{surface_handle_}
|
||||
#endif
|
||||
, blit_supported{CanBlitToSwapchain(device.GetPhysical(), swapchain.GetImageViewFormat())}
|
||||
, use_present_thread{Settings::values.async_presentation.GetValue()}
|
||||
{
|
||||
SetImageCount();
|
||||
|
||||
auto& dld = device.GetLogical();
|
||||
|
@ -289,7 +305,11 @@ void PresentManager::PresentThread(std::stop_token token) {
|
|||
}
|
||||
|
||||
void PresentManager::RecreateSwapchain(Frame* frame) {
|
||||
#ifndef ANDROID
|
||||
swapchain.Create(surface_handle, frame->width, frame->height); // Pass raw pointer
|
||||
#else
|
||||
swapchain.Create(*surface, frame->width, frame->height); // Pass raw pointer
|
||||
#endif
|
||||
SetImageCount();
|
||||
}
|
||||
|
||||
|
@ -307,6 +327,9 @@ void PresentManager::CopyToSwapchain(Frame* frame) {
|
|||
try {
|
||||
// Recreate surface and swapchain if needed.
|
||||
if (requires_recreation) {
|
||||
#ifdef ANDROID
|
||||
surface = CreateSurface(instance, render_window.GetWindowInfo());
|
||||
#endif
|
||||
RecreateSwapchain(frame);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,17 @@ struct Frame {
|
|||
|
||||
class PresentManager {
|
||||
public:
|
||||
PresentManager(const vk::Instance& instance, Core::Frontend::EmuWindow& render_window,
|
||||
const Device& device, MemoryAllocator& memory_allocator, Scheduler& scheduler,
|
||||
Swapchain& swapchain, VkSurfaceKHR_T* surface_handle);
|
||||
PresentManager(const vk::Instance& instance,
|
||||
Core::Frontend::EmuWindow& render_window,
|
||||
const Device& device,
|
||||
MemoryAllocator& memory_allocator,
|
||||
Scheduler& scheduler,
|
||||
Swapchain& swapchain,
|
||||
#ifdef ANDROID
|
||||
vk::SurfaceKHR& surface);
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle);
|
||||
#endif
|
||||
~PresentManager();
|
||||
|
||||
/// Returns the last used presentation frame
|
||||
|
@ -73,7 +81,11 @@ private:
|
|||
MemoryAllocator& memory_allocator;
|
||||
Scheduler& scheduler;
|
||||
Swapchain& swapchain;
|
||||
#ifdef ANDROID
|
||||
vk::SurfaceKHR& surface;
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle;
|
||||
#endif
|
||||
vk::CommandPool cmdpool;
|
||||
std::vector<Frame> frames;
|
||||
std::queue<Frame*> present_queue;
|
||||
|
|
|
@ -105,23 +105,58 @@ VkCompositeAlphaFlagBitsKHR ChooseAlphaFlags(const VkSurfaceCapabilitiesKHR& cap
|
|||
|
||||
} // Anonymous namespace
|
||||
|
||||
Swapchain::Swapchain(VkSurfaceKHR_T* surface_handle_, const Device& device_, Scheduler& scheduler_,
|
||||
u32 width_, u32 height_)
|
||||
: surface_handle{surface_handle_}, device{device_}, scheduler{scheduler_} {
|
||||
Swapchain::Swapchain(
|
||||
#ifdef ANDROID
|
||||
VkSurfaceKHR surface_,
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle_,
|
||||
#endif
|
||||
const Device& device_,
|
||||
Scheduler& scheduler_,
|
||||
u32 width_,
|
||||
u32 height_)
|
||||
#ifdef ANDROID
|
||||
: surface(surface_)
|
||||
#else
|
||||
: surface_handle{surface_handle_}
|
||||
#endif
|
||||
, device{device_}
|
||||
, scheduler{scheduler_}
|
||||
{
|
||||
#ifdef ANDROID
|
||||
Create(surface, width_, height_);
|
||||
#else
|
||||
Create(surface_handle, width_, height_);
|
||||
#endif
|
||||
}
|
||||
|
||||
Swapchain::~Swapchain() = default;
|
||||
|
||||
void Swapchain::Create(VkSurfaceKHR_T* surface_handle_, u32 width_, u32 height_) {
|
||||
void Swapchain::Create(
|
||||
#ifdef ANDROID
|
||||
VkSurfaceKHR surface_,
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle_,
|
||||
#endif
|
||||
u32 width_,
|
||||
u32 height_)
|
||||
{
|
||||
is_outdated = false;
|
||||
is_suboptimal = false;
|
||||
width = width_;
|
||||
height = height_;
|
||||
#ifdef ANDROID
|
||||
surface = surface_;
|
||||
#else
|
||||
surface_handle = surface_handle_;
|
||||
#endif
|
||||
|
||||
const auto physical_device = device.GetPhysical();
|
||||
#ifdef ANDROID
|
||||
const auto capabilities{physical_device.GetSurfaceCapabilitiesKHR(surface)};
|
||||
#else
|
||||
const auto capabilities{physical_device.GetSurfaceCapabilitiesKHR(surface_handle)};
|
||||
#endif
|
||||
if (capabilities.maxImageExtent.width == 0 || capabilities.maxImageExtent.height == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -199,10 +234,17 @@ void Swapchain::Present(VkSemaphore render_semaphore) {
|
|||
|
||||
void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {
|
||||
const auto physical_device{device.GetPhysical()};
|
||||
|
||||
#ifdef ANDROID
|
||||
const auto formats{physical_device.GetSurfaceFormatsKHR(surface)};
|
||||
const auto present_modes = physical_device.GetSurfacePresentModesKHR(surface);
|
||||
#else
|
||||
const auto formats{physical_device.GetSurfaceFormatsKHR(surface_handle)};
|
||||
const auto present_modes = physical_device.GetSurfacePresentModesKHR(surface_handle);
|
||||
has_mailbox = std::find(present_modes.begin(), present_modes.end(),
|
||||
VK_PRESENT_MODE_MAILBOX_KHR) != present_modes.end();
|
||||
#endif
|
||||
|
||||
has_mailbox = std::find(present_modes.begin(), present_modes.end(), VK_PRESENT_MODE_MAILBOX_KHR)
|
||||
!= present_modes.end();
|
||||
has_imm = std::find(present_modes.begin(), present_modes.end(),
|
||||
VK_PRESENT_MODE_IMMEDIATE_KHR) != present_modes.end();
|
||||
has_fifo_relaxed = std::find(present_modes.begin(), present_modes.end(),
|
||||
|
@ -228,7 +270,11 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {
|
|||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
#ifdef ANDROID
|
||||
.surface = surface,
|
||||
#else
|
||||
.surface = surface_handle,
|
||||
#endif
|
||||
.minImageCount = requested_image_count,
|
||||
.imageFormat = surface_format.format,
|
||||
.imageColorSpace = surface_format.colorSpace,
|
||||
|
@ -269,7 +315,11 @@ void Swapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities) {
|
|||
swapchain_ci.flags |= VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR;
|
||||
}
|
||||
// Request the size again to reduce the possibility of a TOCTOU race condition.
|
||||
#ifdef ANDROID
|
||||
const auto updated_capabilities = physical_device.GetSurfaceCapabilitiesKHR(surface);
|
||||
#else
|
||||
const auto updated_capabilities = physical_device.GetSurfaceCapabilitiesKHR(surface_handle);
|
||||
#endif
|
||||
swapchain_ci.imageExtent = ChooseSwapExtent(updated_capabilities, width, height);
|
||||
// Don't add code within this and the swapchain creation.
|
||||
swapchain = device.GetLogical().CreateSwapchainKHR(swapchain_ci);
|
||||
|
|
|
@ -21,12 +21,27 @@ class Scheduler;
|
|||
|
||||
class Swapchain {
|
||||
public:
|
||||
explicit Swapchain(VkSurfaceKHR_T* surface_handle, const Device& device, Scheduler& scheduler, u32 width,
|
||||
explicit Swapchain(
|
||||
#ifdef ANDROID
|
||||
VkSurfaceKHR surface,
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle,
|
||||
#endif
|
||||
const Device& device,
|
||||
Scheduler& scheduler,
|
||||
u32 width,
|
||||
u32 height);
|
||||
~Swapchain();
|
||||
|
||||
/// Creates (or recreates) the swapchain with a given size.
|
||||
void Create(VkSurfaceKHR_T* surface_handle, u32 width, u32 height);
|
||||
void Create(
|
||||
#ifdef ANDROID
|
||||
VkSurfaceKHR surface,
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle,
|
||||
#endif
|
||||
u32 width,
|
||||
u32 height);
|
||||
|
||||
/// Acquires the next image in the swapchain, waits as needed.
|
||||
bool AcquireNextImage();
|
||||
|
@ -110,7 +125,12 @@ private:
|
|||
|
||||
bool NeedsPresentModeUpdate() const;
|
||||
|
||||
#ifdef ANDROID
|
||||
VkSurfaceKHR surface;
|
||||
#else
|
||||
VkSurfaceKHR_T* surface_handle;
|
||||
#endif
|
||||
|
||||
const Device& device;
|
||||
Scheduler& scheduler;
|
||||
|
||||
|
|
|
@ -430,6 +430,7 @@ public:
|
|||
return handle != nullptr;
|
||||
}
|
||||
|
||||
#ifndef ANDROID
|
||||
/**
|
||||
* Releases ownership of the managed handle.
|
||||
* The caller is responsible for managing the lifetime of the returned handle.
|
||||
|
@ -438,6 +439,7 @@ public:
|
|||
Type release() noexcept {
|
||||
return std::exchange(handle, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
Type handle = nullptr;
|
||||
|
@ -510,6 +512,7 @@ public:
|
|||
return handle != nullptr;
|
||||
}
|
||||
|
||||
#ifndef ANDROID
|
||||
/**
|
||||
* Releases ownership of the managed handle.
|
||||
* The caller is responsible for managing the lifetime of the returned handle.
|
||||
|
@ -518,6 +521,7 @@ public:
|
|||
Type release() noexcept {
|
||||
return std::exchange(handle, nullptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
Type handle = nullptr;
|
||||
|
|
|
@ -544,7 +544,9 @@ std::unique_ptr<ComboboxTranslationMap> ComboboxEnumeration(QWidget* parent) {
|
|||
{
|
||||
PAIR(MemoryLayout, Memory_4Gb, tr("4GB DRAM (Default)")),
|
||||
PAIR(MemoryLayout, Memory_6Gb, tr("6GB DRAM (Unsafe)")),
|
||||
PAIR(MemoryLayout, Memory_8Gb, tr("8GB DRAM (Unsafe)")),
|
||||
PAIR(MemoryLayout, Memory_8Gb, tr("8GB DRAM")),
|
||||
PAIR(MemoryLayout, Memory_10Gb, tr("10GB DRAM (Unsafe)")),
|
||||
PAIR(MemoryLayout, Memory_12Gb, tr("12GB DRAM (Unsafe)")),
|
||||
}});
|
||||
translations->insert({Settings::EnumMetadata<Settings::ConsoleMode>::Index(),
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue