1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-01 00:46:32 -05:00

Merge branch 'dev' into dev

This commit is contained in:
BoomMicrophone
2024-03-31 17:55:38 +02:00
19 changed files with 170 additions and 89 deletions

View File

@@ -4,6 +4,7 @@
#include <atomic>
#include <chrono>
#include <climits>
#include <mutex>
#include <thread>
#include <fmt/format.h>
@@ -231,8 +232,15 @@ public:
if (!filter.CheckMessage(log_class, log_level)) {
return;
}
message_queue.EmplaceWait(
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message)));
auto entry =
CreateEntry(log_class, log_level, filename, line_num, function, std::move(message));
if (Settings::values.log_async) {
message_queue.EmplaceWait(entry);
} else {
std::scoped_lock l{sync_mutex};
ForEachBackend([&entry](Backend& backend) { backend.Write(entry); });
}
}
private:
@@ -313,6 +321,7 @@ private:
#endif
MPSCQueue<Entry> message_queue{};
std::mutex sync_mutex;
std::chrono::steady_clock::time_point time_origin{std::chrono::steady_clock::now()};
std::jthread backend_thread;
};
@@ -345,9 +354,11 @@ void SetColorConsoleBackendEnabled(bool enabled) {
void FmtLogMessageImpl(Class log_class, Level log_level, const char* filename,
unsigned int line_num, const char* function, fmt::string_view format,
const fmt::format_args& args) {
if (!initialization_in_progress_suppress_logging) {
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
fmt::vformat(format, args));
if (initialization_in_progress_suppress_logging) {
return;
}
Impl::Instance().PushEntry(log_class, log_level, filename, line_num, function,
fmt::vformat(format, args));
}
} // namespace Common::Log

View File

@@ -171,6 +171,7 @@ const char* GetLogClassName(Class log_class) {
#define SUB(x, y) \
case Class::x##_##y: \
return #x "." #y;
// return #x "_" #y;
ALL_LOG_CLASSES()
#undef CLS
#undef SUB

View File

@@ -605,6 +605,7 @@ struct Values {
// Miscellaneous
Setting<std::string> log_filter{linkage, "*:Info", "log_filter", Category::Miscellaneous};
Setting<bool> log_async{linkage, true, "log_async", Category::Miscellaneous};
Setting<bool> use_dev_keys{linkage, false, "use_dev_keys", Category::Miscellaneous};
// Network

View File

@@ -106,6 +106,7 @@ std::unique_ptr<Process> CreateApplicationProcess(std::vector<u8>& out_control,
out_control = nacp.GetRawBytes();
} else {
out_control.resize(sizeof(FileSys::RawNACP));
memset(out_control.data(), 0, sizeof(u8) * out_control.size());
}
auto& storage = system.GetContentProviderUnion();

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-FileCopyrightText: Copyright 2024 suyu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/hle/service/am/applet_data_broker.h"
@@ -101,6 +102,22 @@ Result ILibraryAppletAccessor::PushInData(SharedPointer<IStorage> storage) {
Result ILibraryAppletAccessor::PopOutData(Out<SharedPointer<IStorage>> out_storage) {
LOG_DEBUG(Service_AM, "called");
// suyu todo: move library applet fix to another function
// since this function is only called for applets that give a result,
// applets that don't (e.g. info applets in 1st party games) simply freeze
if (auto caller = m_applet->caller_applet.lock(); caller != nullptr) {
caller->SetInteractibleLocked(true);
caller->lifecycle_manager.SetFocusState(FocusState::InFocus);
caller->lifecycle_manager.UpdateRequestedFocusState();
caller->lifecycle_manager.SetResumeNotificationEnabled(true);
caller->lifecycle_manager.RequestResumeNotification();
caller->UpdateSuspensionStateLocked(true);
} else {
LOG_CRITICAL(Service_AM, "Caller applet pointer is invalid.");
LOG_CRITICAL(Service_AM, "The emulator will freeze!");
}
R_RETURN(m_broker->GetOutData().Pop(out_storage.Get()));
}

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-FileCopyrightText: 2024 sudachi Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <string_view>

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-FileCopyrightText: 2024 sudachi Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <string_view>

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-FileCopyrightText: 2024 sudachi Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <bit>

View File

@@ -1,4 +1,5 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project, 2024 sudachi Emulator Project
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-FileCopyrightText: 2024 sudachi Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once

View File

@@ -73,6 +73,7 @@ void ConfigureDebug::SetConfiguration() {
ui->disable_loop_safety_checks->setChecked(
Settings::values.disable_shader_loop_safety_checks.GetValue());
ui->extended_logging->setChecked(Settings::values.extended_logging.GetValue());
ui->log_async->setChecked(Settings::values.log_async.GetValue());
ui->perform_vulkan_check->setChecked(Settings::values.perform_vulkan_check.GetValue());
#ifdef SUYU_USE_QT_WEB_ENGINE
@@ -115,6 +116,7 @@ void ConfigureDebug::ApplyConfiguration() {
Common::Log::Filter filter;
filter.ParseFilterString(Settings::values.log_filter.GetValue());
Common::Log::SetGlobalFilter(filter);
Settings::values.log_async = ui->log_async->isChecked();
}
void ConfigureDebug::changeEvent(QEvent* event) {

View File

@@ -164,6 +164,20 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="log_async">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>When checked, logging will run asynchronously. This may cut the log on crashes.
When unchecked, logging will run synchronously. This will slow down the emulator, but allow all logs to be written. Useful for debugging.</string>
</property>
<property name="text">
<string>Log asynchronously</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QWidget" name="logging_widget" native="true">
<property name="sizePolicy">
@@ -199,7 +213,14 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="log_filter_edit"/>
<widget class="QLineEdit" name="log_filter_edit">
<property name="toolTip">
<string>Log filter in the form class:level.
Separate multiple filters with a space.
Levels: Trace, Debug, Info, Warning, Error, Critical
Classes: See Common/logging/types.h</string>
</property>
</widget>
</item>
</layout>
</widget>

View File

@@ -1406,7 +1406,7 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
if (runtime->device.HasDebuggingToolAttached()) {
original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str());
}
current_image = *original_image;
current_image = &Image::original_image;
storage_image_views.resize(info.resources.levels);
if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported() &&
Settings::values.astc_recompression.GetValue() ==
@@ -1550,8 +1550,8 @@ VkImageView Image::StorageImageView(s32 level) noexcept {
if (!view) {
const auto format_info =
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
view =
MakeStorageView(runtime->device.GetLogical(), level, current_image, format_info.format);
view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*current_image),
format_info.format);
}
return *view;
}
@@ -1582,7 +1582,7 @@ bool Image::ScaleUp(bool ignore) {
runtime->ViewFormats(info.format));
ignore = false;
}
current_image = *scaled_image;
current_image = &Image::scaled_image;
if (ignore) {
return true;
}
@@ -1607,7 +1607,7 @@ bool Image::ScaleDown(bool ignore) {
}
ASSERT(info.type != ImageType::Linear);
flags &= ~ImageFlagBits::Rescaled;
current_image = *original_image;
current_image = &Image::original_image;
if (ignore) {
return true;
}
@@ -1726,7 +1726,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
const VkImageViewUsageCreateInfo image_view_usage{
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
.pNext = nullptr,
.usage = ImageUsageFlags(format_info, format),
.usage = image.UsageFlags(),
};
const VkImageViewCreateInfo create_info{
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
@@ -2087,4 +2087,4 @@ void TextureCacheRuntime::TransitionImageLayout(Image& image) {
}
}
} // namespace Vulkan
} // namespace Vulkan

View File

@@ -24,7 +24,6 @@ using Common::SlotVector;
using VideoCommon::ImageId;
using VideoCommon::NUM_RT;
using VideoCommon::Region2D;
using VideoCommon::RenderTargets;
using VideoCore::Surface::PixelFormat;
class BlitImageHelper;
@@ -157,13 +156,17 @@ public:
std::span<const VideoCommon::BufferImageCopy> copies);
[[nodiscard]] VkImage Handle() const noexcept {
return current_image;
return *(this->*current_image);
}
[[nodiscard]] VkImageAspectFlags AspectMask() const noexcept {
return aspect_mask;
}
[[nodiscard]] VkImageUsageFlags UsageFlags() const noexcept {
return (this->*current_image).UsageFlags();
}
/// Returns true when the image is already initialized and mark it as initialized
[[nodiscard]] bool ExchangeInitialization() noexcept {
return std::exchange(initialized, true);
@@ -186,11 +189,15 @@ private:
TextureCacheRuntime* runtime{};
vk::Image original_image;
vk::Image scaled_image;
// Use a pointer to field because it is relative, so that the object can be
// moved without breaking the reference.
vk::Image Image::*current_image{};
std::vector<vk::ImageView> storage_image_views;
VkImageAspectFlags aspect_mask = 0;
bool initialized = false;
vk::Image scaled_image{};
VkImage current_image{};
std::unique_ptr<Framebuffer> scale_framebuffer;
std::unique_ptr<ImageView> scale_view;

View File

@@ -247,7 +247,7 @@ vk::Image MemoryAllocator::CreateImage(const VkImageCreateInfo& ci) const {
vk::Check(vmaCreateImage(allocator, &ci, &alloc_ci, &handle, &allocation, nullptr));
return vk::Image(handle, *device.GetLogical(), allocator, allocation,
return vk::Image(handle, ci.usage, *device.GetLogical(), allocator, allocation,
device.GetDispatchLoader());
}

View File

@@ -623,9 +623,10 @@ public:
class Image {
public:
explicit Image(VkImage handle_, VkDevice owner_, VmaAllocator allocator_,
VmaAllocation allocation_, const DeviceDispatch& dld_) noexcept
: handle{handle_}, owner{owner_}, allocator{allocator_},
explicit Image(VkImage handle_, VkImageUsageFlags usage_, VkDevice owner_,
VmaAllocator allocator_, VmaAllocation allocation_,
const DeviceDispatch& dld_) noexcept
: handle{handle_}, usage{usage_}, owner{owner_}, allocator{allocator_},
allocation{allocation_}, dld{&dld_} {}
Image() = default;
@@ -633,12 +634,13 @@ public:
Image& operator=(const Image&) = delete;
Image(Image&& rhs) noexcept
: handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, allocator{rhs.allocator},
allocation{rhs.allocation}, dld{rhs.dld} {}
: handle{std::exchange(rhs.handle, nullptr)}, usage{rhs.usage}, owner{rhs.owner},
allocator{rhs.allocator}, allocation{rhs.allocation}, dld{rhs.dld} {}
Image& operator=(Image&& rhs) noexcept {
Release();
handle = std::exchange(rhs.handle, nullptr);
usage = rhs.usage;
owner = rhs.owner;
allocator = rhs.allocator;
allocation = rhs.allocation;
@@ -665,10 +667,15 @@ public:
void SetObjectNameEXT(const char* name) const;
[[nodiscard]] VkImageUsageFlags UsageFlags() const noexcept {
return usage;
}
private:
void Release() const noexcept;
VkImage handle = nullptr;
VkImageUsageFlags usage{};
VkDevice owner = nullptr;
VmaAllocator allocator = nullptr;
VmaAllocation allocation = nullptr;