Compare commits

..

1 Commits

Author SHA1 Message Date
c652b5535e frame_dumper: Use jthread 2023-08-05 13:45:44 +03:00
21 changed files with 155 additions and 125 deletions

View File

@ -57,7 +57,6 @@ CMAKE_DEPENDENT_OPTION(ENABLE_TESTS "Enable generating tests executable" ON "NOT
CMAKE_DEPENDENT_OPTION(ENABLE_DEDICATED_ROOM "Enable generating dedicated room executable" ON "NOT ANDROID AND NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_DEDICATED_ROOM "Enable generating dedicated room executable" ON "NOT ANDROID AND NOT IOS" OFF)
option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON) option(ENABLE_WEB_SERVICE "Enable web services (telemetry, etc.)" ON)
option(ENABLE_SCRIPTING "Enable RPC server for scripting" ON)
CMAKE_DEPENDENT_OPTION(ENABLE_CUBEB "Enables the cubeb audio backend" ON "NOT IOS" OFF) CMAKE_DEPENDENT_OPTION(ENABLE_CUBEB "Enables the cubeb audio backend" ON "NOT IOS" OFF)
option(ENABLE_OPENAL "Enables the OpenAL audio backend" ON) option(ENABLE_OPENAL "Enables the OpenAL audio backend" ON)

View File

@ -298,11 +298,6 @@ QAbstractItemView:read-only {
alternate-background-color: #232629; alternate-background-color: #232629;
} }
/* Workaround for https://bugreports.qt.io/browse/QTBUG-115529 */
QAbstractItemView:item {
border: 0px;
}
QWidget:focus { QWidget:focus {
border: 1px solid #3daee9; border: 1px solid #3daee9;
} }

View File

@ -481,11 +481,6 @@ QAbstractItemView QLineEdit {
padding: 2px; padding: 2px;
} }
/* Workaround for https://bugreports.qt.io/browse/QTBUG-115529 */
QAbstractItemView:item {
border: 0px;
}
/* QAbstractScrollArea ---------------------------------------------------- /* QAbstractScrollArea ----------------------------------------------------
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qabstractscrollarea https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qabstractscrollarea

View File

@ -173,7 +173,7 @@ endif()
add_library(json-headers INTERFACE) add_library(json-headers INTERFACE)
target_include_directories(json-headers INTERFACE ./json) target_include_directories(json-headers INTERFACE ./json)
# OpenSSL if (ENABLE_WEB_SERVICE)
if (USE_SYSTEM_OPENSSL) if (USE_SYSTEM_OPENSSL)
find_package(OpenSSL 1.1) find_package(OpenSSL 1.1)
if (OPENSSL_FOUND) if (OPENSSL_FOUND)
@ -193,19 +193,17 @@ if (NOT OPENSSL_FOUND)
DEFINITION OPENSSL_LIBS) DEFINITION OPENSSL_LIBS)
endif() endif()
if(ANDROID)
add_subdirectory(android-ifaddrs)
endif()
# httplib # httplib
add_library(httplib INTERFACE) add_library(httplib INTERFACE)
target_include_directories(httplib INTERFACE ./httplib) target_include_directories(httplib INTERFACE ./httplib)
target_compile_options(httplib INTERFACE -DCPPHTTPLIB_OPENSSL_SUPPORT) target_compile_options(httplib INTERFACE -DCPPHTTPLIB_OPENSSL_SUPPORT)
target_link_libraries(httplib INTERFACE ${OPENSSL_LIBRARIES}) target_link_libraries(httplib INTERFACE ${OPENSSL_LIBRARIES})
if(ANDROID)
add_subdirectory(android-ifaddrs)
target_link_libraries(httplib INTERFACE ifaddrs)
endif()
# cpp-jwt # cpp-jwt
if (ENABLE_WEB_SERVICE)
add_library(cpp-jwt INTERFACE) add_library(cpp-jwt INTERFACE)
target_include_directories(cpp-jwt INTERFACE ./cpp-jwt/include) target_include_directories(cpp-jwt INTERFACE ./cpp-jwt/include)
target_compile_definitions(cpp-jwt INTERFACE CPP_JWT_USE_VENDORED_NLOHMANN_JSON) target_compile_definitions(cpp-jwt INTERFACE CPP_JWT_USE_VENDORED_NLOHMANN_JSON)

View File

@ -341,6 +341,10 @@ if (USE_DISCORD_PRESENCE)
target_compile_definitions(citra-qt PRIVATE -DUSE_DISCORD_PRESENCE) target_compile_definitions(citra-qt PRIVATE -DUSE_DISCORD_PRESENCE)
endif() endif()
if (ENABLE_WEB_SERVICE)
target_compile_definitions(citra-qt PRIVATE -DENABLE_WEB_SERVICE)
endif()
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
install(TARGETS citra-qt RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") install(TARGETS citra-qt RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif() endif()

View File

@ -16,7 +16,6 @@
#include "citra_qt/debugger/graphics/graphics_cmdlists.h" #include "citra_qt/debugger/graphics/graphics_cmdlists.h"
#include "citra_qt/util/util.h" #include "citra_qt/util/util.h"
#include "common/vector_math.h" #include "common/vector_math.h"
#include "core/core.h"
#include "core/memory.h" #include "core/memory.h"
#include "video_core/debug_utils/debug_utils.h" #include "video_core/debug_utils/debug_utils.h"
#include "video_core/pica_state.h" #include "video_core/pica_state.h"
@ -167,7 +166,7 @@ void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) {
const auto format = texture.format; const auto format = texture.format;
const auto info = Pica::Texture::TextureInfo::FromPicaRegister(config, format); const auto info = Pica::Texture::TextureInfo::FromPicaRegister(config, format);
const u8* src = system.Memory().GetPhysicalPointer(config.GetPhysicalAddress()); const u8* src = memory.GetPhysicalPointer(config.GetPhysicalAddress());
new_info_widget = new TextureInfoWidget(src, info); new_info_widget = new TextureInfoWidget(src, info);
} }
if (command_info_widget) { if (command_info_widget) {
@ -181,8 +180,8 @@ void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) {
} }
#undef COMMAND_IN_RANGE #undef COMMAND_IN_RANGE
GPUCommandListWidget::GPUCommandListWidget(Core::System& system_, QWidget* parent) GPUCommandListWidget::GPUCommandListWidget(Memory::MemorySystem& memory_, QWidget* parent)
: QDockWidget(tr("Pica Command List"), parent), system{system_} { : QDockWidget(tr("Pica Command List"), parent), memory{memory_} {
setObjectName(QStringLiteral("Pica Command List")); setObjectName(QStringLiteral("Pica Command List"));
GPUCommandListModel* model = new GPUCommandListModel(this); GPUCommandListModel* model = new GPUCommandListModel(this);

View File

@ -11,8 +11,8 @@
class QPushButton; class QPushButton;
class QTreeView; class QTreeView;
namespace Core { namespace Memory {
class System; class MemorySystem;
} }
class GPUCommandListModel : public QAbstractListModel { class GPUCommandListModel : public QAbstractListModel {
@ -42,7 +42,7 @@ class GPUCommandListWidget : public QDockWidget {
Q_OBJECT Q_OBJECT
public: public:
explicit GPUCommandListWidget(Core::System& system, QWidget* parent = nullptr); explicit GPUCommandListWidget(Memory::MemorySystem& memory, QWidget* parent = nullptr);
public slots: public slots:
void OnToggleTracing(); void OnToggleTracing();
@ -57,7 +57,7 @@ signals:
private: private:
std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace; std::unique_ptr<Pica::DebugUtils::PicaTrace> pica_trace;
Core::System& system; Memory::MemorySystem& memory;
QTreeView* list_widget; QTreeView* list_widget;
QWidget* command_info_widget; QWidget* command_info_widget;
QPushButton* toggle_tracing; QPushButton* toggle_tracing;

View File

@ -448,7 +448,7 @@ void GMainWindow::InitializeDebugWidgets() {
graphicsWidget->hide(); graphicsWidget->hide();
debug_menu->addAction(graphicsWidget->toggleViewAction()); debug_menu->addAction(graphicsWidget->toggleViewAction());
graphicsCommandsWidget = new GPUCommandListWidget(system, this); graphicsCommandsWidget = new GPUCommandListWidget(system.Memory(), this);
addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget); addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget);
graphicsCommandsWidget->hide(); graphicsCommandsWidget->hide();
debug_menu->addAction(graphicsCommandsWidget->toggleViewAction()); debug_menu->addAction(graphicsCommandsWidget->toggleViewAction());

View File

@ -461,6 +461,14 @@ add_library(citra_core STATIC
perf_stats.cpp perf_stats.cpp
perf_stats.h perf_stats.h
precompiled_headers.h precompiled_headers.h
rpc/packet.cpp
rpc/packet.h
rpc/rpc_server.cpp
rpc/rpc_server.h
rpc/server.cpp
rpc/server.h
rpc/udp_server.cpp
rpc/udp_server.h
savestate.cpp savestate.cpp
savestate.h savestate.h
system_titles.cpp system_titles.cpp
@ -475,26 +483,16 @@ add_library(citra_core STATIC
create_target_directory_groups(citra_core) create_target_directory_groups(citra_core)
target_link_libraries(citra_core PUBLIC citra_common PRIVATE audio_core network video_core) target_link_libraries(citra_core PUBLIC citra_common PRIVATE audio_core network video_core)
target_link_libraries(citra_core PRIVATE Boost::boost Boost::serialization Boost::iostreams httplib) target_link_libraries(citra_core PRIVATE Boost::boost Boost::serialization Boost::iostreams)
target_link_libraries(citra_core PUBLIC dds-ktx PRIVATE cryptopp fmt::fmt lodepng open_source_archives) target_link_libraries(citra_core PUBLIC dds-ktx PRIVATE cryptopp fmt::fmt lodepng open_source_archives)
set_target_properties(citra_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) set_target_properties(citra_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)
target_link_libraries(citra_core PRIVATE web_service) target_compile_definitions(citra_core PRIVATE -DENABLE_WEB_SERVICE -DCPPHTTPLIB_OPENSSL_SUPPORT)
target_link_libraries(citra_core PRIVATE web_service ${OPENSSL_LIBS} httplib)
if (ANDROID)
target_link_libraries(citra_core PRIVATE ifaddrs)
endif() endif()
if (ENABLE_SCRIPTING)
target_compile_definitions(citra_core PUBLIC -DENABLE_SCRIPTING)
target_sources(citra_core PRIVATE
rpc/packet.cpp
rpc/packet.h
rpc/rpc_server.cpp
rpc/rpc_server.h
rpc/server.cpp
rpc/server.h
rpc/udp_server.cpp
rpc/udp_server.h
)
endif() endif()
if ("x86_64" IN_LIST ARCHITECTURE OR "arm64" IN_LIST ARCHITECTURE) if ("x86_64" IN_LIST ARCHITECTURE OR "arm64" IN_LIST ARCHITECTURE)

View File

@ -45,9 +45,7 @@
#include "core/hw/lcd.h" #include "core/hw/lcd.h"
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "core/movie.h" #include "core/movie.h"
#ifdef ENABLE_SCRIPTING
#include "core/rpc/server.h" #include "core/rpc/server.h"
#endif
#include "core/telemetry_session.h" #include "core/telemetry_session.h"
#include "network/network.h" #include "network/network.h"
#include "video_core/custom_textures/custom_tex_manager.h" #include "video_core/custom_textures/custom_tex_manager.h"
@ -420,9 +418,7 @@ System::ResultStatus System::Init(Frontend::EmuWindow& emu_window,
telemetry_session = std::make_unique<Core::TelemetrySession>(); telemetry_session = std::make_unique<Core::TelemetrySession>();
#ifdef ENABLE_SCRIPTING
rpc_server = std::make_unique<RPC::Server>(*this); rpc_server = std::make_unique<RPC::Server>(*this);
#endif
service_manager = std::make_unique<Service::SM::ServiceManager>(*this); service_manager = std::make_unique<Service::SM::ServiceManager>(*this);
archive_manager = std::make_unique<Service::FS::ArchiveManager>(*this); archive_manager = std::make_unique<Service::FS::ArchiveManager>(*this);
@ -559,9 +555,7 @@ void System::Shutdown(bool is_deserializing) {
} }
custom_tex_manager.reset(); custom_tex_manager.reset();
telemetry_session.reset(); telemetry_session.reset();
#ifdef ENABLE_SCRIPTING
rpc_server.reset(); rpc_server.reset();
#endif
archive_manager.reset(); archive_manager.reset();
service_manager.reset(); service_manager.reset();
dsp_core.reset(); dsp_core.reset();

View File

@ -405,10 +405,8 @@ private:
/// Image interface /// Image interface
std::shared_ptr<Frontend::ImageInterface> registered_image_interface; std::shared_ptr<Frontend::ImageInterface> registered_image_interface;
#ifdef ENABLE_SCRIPTING
/// RPC Server for scripting support /// RPC Server for scripting support
std::unique_ptr<RPC::Server> rpc_server; std::unique_ptr<RPC::Server> rpc_server;
#endif
std::unique_ptr<Service::FS::ArchiveManager> archive_manager; std::unique_ptr<Service::FS::ArchiveManager> archive_manager;

View File

@ -77,6 +77,7 @@ static std::pair<std::string, std::string> SplitUrl(const std::string& url) {
void Context::MakeRequest() { void Context::MakeRequest() {
ASSERT(state == RequestState::NotStarted); ASSERT(state == RequestState::NotStarted);
#ifdef ENABLE_WEB_SERVICE
const auto& [host, path] = SplitUrl(url); const auto& [host, path] = SplitUrl(url);
const auto client = std::make_unique<httplib::Client>(host); const auto client = std::make_unique<httplib::Client>(host);
SSL_CTX* ctx = client->ssl_context(); SSL_CTX* ctx = client->ssl_context();
@ -127,6 +128,10 @@ void Context::MakeRequest() {
// TODO(B3N30): Verify this state on HW // TODO(B3N30): Verify this state on HW
state = RequestState::ReadyToDownloadContent; state = RequestState::ReadyToDownloadContent;
} }
#else
LOG_ERROR(Service_HTTP, "Tried to make request but WebServices is not enabled in this build");
state = RequestState::TimedOut;
#endif
} }
void HTTP_C::Initialize(Kernel::HLERequestContext& ctx) { void HTTP_C::Initialize(Kernel::HLERequestContext& ctx) {

View File

@ -17,10 +17,12 @@
#include <boost/serialization/unordered_map.hpp> #include <boost/serialization/unordered_map.hpp>
#include <boost/serialization/vector.hpp> #include <boost/serialization/vector.hpp>
#include <boost/serialization/weak_ptr.hpp> #include <boost/serialization/weak_ptr.hpp>
#ifdef ENABLE_WEB_SERVICE
#if defined(__ANDROID__) #if defined(__ANDROID__)
#include <ifaddrs.h> #include <ifaddrs.h>
#endif #endif
#include <httplib.h> #include <httplib.h>
#endif
#include "core/hle/kernel/shared_memory.h" #include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"
@ -215,7 +217,9 @@ public:
std::future<void> request_future; std::future<void> request_future;
std::atomic<u64> current_download_size_bytes; std::atomic<u64> current_download_size_bytes;
std::atomic<u64> total_download_size_bytes; std::atomic<u64> total_download_size_bytes;
#ifdef ENABLE_WEB_SERVICE
httplib::Response response; httplib::Response response;
#endif
}; };
struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase { struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase {

View File

@ -10,6 +10,7 @@ create_target_directory_groups(citra-room)
target_link_libraries(citra-room PRIVATE citra_common network) target_link_libraries(citra-room PRIVATE citra_common network)
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)
target_compile_definitions(citra-room PRIVATE -DENABLE_WEB_SERVICE)
target_link_libraries(citra-room PRIVATE web_service) target_link_libraries(citra-room PRIVATE web_service)
endif() endif()

View File

@ -19,10 +19,14 @@ add_library(network STATIC
create_target_directory_groups(network) create_target_directory_groups(network)
if (ENABLE_WEB_SERVICE) if (ENABLE_WEB_SERVICE)
target_link_libraries(network PRIVATE web_service) target_compile_definitions(network PRIVATE -DENABLE_WEB_SERVICE -DCPPHTTPLIB_OPENSSL_SUPPORT)
target_link_libraries(network PRIVATE web_service httplib)
if (ANDROID)
target_link_libraries(network PRIVATE ifaddrs)
endif()
endif() endif()
target_link_libraries(network PRIVATE citra_common enet Boost::serialization httplib) target_link_libraries(network PRIVATE citra_common enet Boost::serialization)
set_target_properties(network PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) set_target_properties(network PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
if (CITRA_USE_PRECOMPILED_HEADERS) if (CITRA_USE_PRECOMPILED_HEADERS)

View File

@ -127,29 +127,6 @@ void RasterizerCache<T>::RemoveFramebuffers(SurfaceId surface_id) {
} }
} }
template <class T>
void RasterizerCache<T>::RemoveTextureCubeFace(SurfaceId surface_id) {
if (False(slot_surfaces[surface_id].flags & SurfaceFlagBits::Tracked)) {
return;
}
for (auto it = texture_cube_cache.begin(); it != texture_cube_cache.end();) {
TextureCube& cube = it->second;
for (SurfaceId& face_id : cube.face_ids) {
if (face_id == surface_id) {
face_id = SurfaceId{};
}
}
if (std::none_of(cube.face_ids.begin(), cube.face_ids.end(),
[](SurfaceId id) { return id; })) {
sentenced.emplace_back(cube.surface_id, frame_tick);
it = texture_cube_cache.erase(it);
} else {
it++;
}
}
}
template <class T> template <class T>
bool RasterizerCache<T>::AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config) { bool RasterizerCache<T>::AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config) {
const DebugScope scope{runtime, Common::Vec4f{0.f, 0.f, 1.f, 1.f}, const DebugScope scope{runtime, Common::Vec4f{0.f, 0.f, 1.f, 1.f},
@ -889,6 +866,39 @@ SurfaceId RasterizerCache<T>::FindMatch(const SurfaceParams& params, ScaleMatch
return match_id; return match_id;
} }
template <class T>
void RasterizerCache<T>::DuplicateSurface(SurfaceId src_id, SurfaceId dst_id) {
Surface& src_surface = slot_surfaces[src_id];
Surface& dst_surface = slot_surfaces[dst_id];
ASSERT(dst_surface.addr <= src_surface.addr && dst_surface.end >= src_surface.end);
const auto src_rect = src_surface.GetScaledRect();
const auto dst_rect = dst_surface.GetScaledSubRect(src_surface);
ASSERT(src_rect.GetWidth() == dst_rect.GetWidth());
const TextureCopy copy = {
.src_level = 0,
.dst_level = 0,
.src_offset = {src_rect.left, src_rect.bottom},
.dst_offset = {dst_rect.left, dst_rect.bottom},
.extent = {src_rect.GetWidth(), src_rect.GetHeight()},
};
runtime.CopyTextures(src_surface, dst_surface, copy);
dst_surface.invalid_regions -= src_surface.GetInterval();
dst_surface.invalid_regions += src_surface.invalid_regions;
SurfaceRegions regions;
for (const auto& pair : RangeFromInterval(dirty_regions, src_surface.GetInterval())) {
if (pair.second == src_id) {
regions += pair.first;
}
}
for (const auto& interval : regions) {
dirty_regions.set({interval, dst_id});
}
}
template <class T> template <class T>
void RasterizerCache<T>::ValidateSurface(SurfaceId surface_id, PAddr addr, u32 size) { void RasterizerCache<T>::ValidateSurface(SurfaceId surface_id, PAddr addr, u32 size) {
if (size == 0) [[unlikely]] { if (size == 0) [[unlikely]] {
@ -1047,7 +1057,6 @@ bool RasterizerCache<T>::UploadCustomSurface(SurfaceId surface_id, SurfaceInterv
const SurfaceBase old_surface{slot_surfaces[surface_id]}; const SurfaceBase old_surface{slot_surfaces[surface_id]};
const SurfaceId old_id = const SurfaceId old_id =
slot_surfaces.swap_and_insert(surface_id, runtime, old_surface, material); slot_surfaces.swap_and_insert(surface_id, runtime, old_surface, material);
slot_surfaces[old_id].flags &= ~SurfaceFlagBits::Registered;
sentenced.emplace_back(old_id, frame_tick); sentenced.emplace_back(old_id, frame_tick);
} }
Surface& surface = slot_surfaces[surface_id]; Surface& surface = slot_surfaces[surface_id];
@ -1194,6 +1203,7 @@ void RasterizerCache<T>::ClearAll(bool flush) {
cached_pages -= flush_interval; cached_pages -= flush_interval;
dirty_regions.clear(); dirty_regions.clear();
page_table.clear(); page_table.clear();
remove_surfaces.clear();
} }
template <class T> template <class T>
@ -1222,7 +1232,7 @@ void RasterizerCache<T>::FlushRegion(PAddr addr, u32 size, SurfaceId flush_surfa
interval.lower(), interval.upper()}; interval.lower(), interval.upper()};
SCOPE_EXIT({ flushed_intervals += interval; }); SCOPE_EXIT({ flushed_intervals += interval; });
if (surface.type == SurfaceType::Fill) { if (surface.IsFill()) {
DownloadFillSurface(surface, interval); DownloadFillSurface(surface, interval);
continue; continue;
} }
@ -1264,7 +1274,6 @@ void RasterizerCache<T>::InvalidateRegion(PAddr addr, u32 size, SurfaceId region
region_owner.MarkValid(invalid_interval); region_owner.MarkValid(invalid_interval);
} }
boost::container::small_vector<SurfaceId, 4> remove_surfaces;
ForEachSurfaceInRegion(addr, size, [&](SurfaceId surface_id, Surface& surface) { ForEachSurfaceInRegion(addr, size, [&](SurfaceId surface_id, Surface& surface) {
if (surface_id == region_owner_id) { if (surface_id == region_owner_id) {
return; return;
@ -1292,12 +1301,13 @@ void RasterizerCache<T>::InvalidateRegion(PAddr addr, u32 size, SurfaceId region
for (const SurfaceId surface_id : remove_surfaces) { for (const SurfaceId surface_id : remove_surfaces) {
UnregisterSurface(surface_id); UnregisterSurface(surface_id);
if (slot_surfaces[surface_id].type != SurfaceType::Fill) { if (!slot_surfaces[surface_id].IsFill()) {
sentenced.emplace_back(surface_id, frame_tick); sentenced.emplace_back(surface_id, frame_tick);
} else { } else {
slot_surfaces.erase(surface_id); slot_surfaces.erase(surface_id);
} }
} }
remove_surfaces.clear();
} }
template <class T> template <class T>
@ -1357,7 +1367,25 @@ void RasterizerCache<T>::UnregisterSurface(SurfaceId surface_id) {
surfaces.erase(vector_it); surfaces.erase(vector_it);
}); });
RemoveTextureCubeFace(surface_id); if (False(surface.flags & SurfaceFlagBits::Tracked)) {
return;
}
for (auto it = texture_cube_cache.begin(); it != texture_cube_cache.end();) {
TextureCube& cube = it->second;
for (SurfaceId& face_id : cube.face_ids) {
if (face_id == surface_id) {
face_id = SurfaceId{};
}
}
if (std::none_of(cube.face_ids.begin(), cube.face_ids.end(),
[](SurfaceId id) { return id; })) {
sentenced.emplace_back(cube.surface_id, frame_tick);
it = texture_cube_cache.erase(it);
} else {
it++;
}
}
} }
template <class T> template <class T>
@ -1369,6 +1397,7 @@ void RasterizerCache<T>::UnregisterAll() {
} }
} }
texture_cube_cache.clear(); texture_cube_cache.clear();
remove_surfaces.clear();
} }
template <class T> template <class T>

View File

@ -165,8 +165,8 @@ private:
/// Removes any framebuffers that reference the provided surface_id. /// Removes any framebuffers that reference the provided surface_id.
void RemoveFramebuffers(SurfaceId surface_id); void RemoveFramebuffers(SurfaceId surface_id);
/// Removes any references of the provided surface id from cached texture cubes. /// Transfers ownership of a memory region from src_surface to dest_surface
void RemoveTextureCubeFace(SurfaceId surface_id); void DuplicateSurface(SurfaceId src_id, SurfaceId dst_id);
/// Computes the hash of the provided texture data. /// Computes the hash of the provided texture data.
u64 ComputeHash(const SurfaceParams& load_info, std::span<u8> upload_data); u64 ComputeHash(const SurfaceParams& load_info, std::span<u8> upload_data);
@ -224,6 +224,7 @@ private:
Common::SlotVector<Framebuffer> slot_framebuffers; Common::SlotVector<Framebuffer> slot_framebuffers;
SurfaceMap dirty_regions; SurfaceMap dirty_regions;
PageMap cached_pages; PageMap cached_pages;
std::vector<SurfaceId> remove_surfaces;
u32 resolution_scale_factor; u32 resolution_scale_factor;
u64 frame_tick{}; u64 frame_tick{};
FramebufferParams fb_params; FramebufferParams fb_params;

View File

@ -46,6 +46,10 @@ public:
/// Returns true if the surface contains a custom material with a normal map. /// Returns true if the surface contains a custom material with a normal map.
bool HasNormalMap() const noexcept; bool HasNormalMap() const noexcept;
bool IsFill() const noexcept {
return type == SurfaceType::Fill;
}
bool Overlaps(PAddr overlap_addr, size_t overlap_size) const noexcept { bool Overlaps(PAddr overlap_addr, size_t overlap_size) const noexcept {
const PAddr overlap_end = overlap_addr + static_cast<PAddr>(overlap_size); const PAddr overlap_end = overlap_addr + static_cast<PAddr>(overlap_size);
return addr < overlap_end && overlap_addr < end; return addr < overlap_end && overlap_addr < end;

View File

@ -5,6 +5,9 @@
#include <glad/glad.h> #include <glad/glad.h>
#include <utility> #include <utility>
#include "core/core.h"
#include "core/dumping/backend.h"
#include "core/frontend/emu_window.h" #include "core/frontend/emu_window.h"
#include "video_core/renderer_opengl/frame_dumper_opengl.h" #include "video_core/renderer_opengl/frame_dumper_opengl.h"
#include "video_core/renderer_opengl/gl_texture_mailbox.h" #include "video_core/renderer_opengl/gl_texture_mailbox.h"
@ -12,13 +15,9 @@
namespace OpenGL { namespace OpenGL {
FrameDumperOpenGL::FrameDumperOpenGL(Core::System& system_, Frontend::EmuWindow& emu_window) FrameDumperOpenGL::FrameDumperOpenGL(Core::System& system_, Frontend::EmuWindow& emu_window)
: system(system_), context(emu_window.CreateSharedContext()) {} : system{system_}, context{emu_window.CreateSharedContext()} {}
FrameDumperOpenGL::~FrameDumperOpenGL() { FrameDumperOpenGL::~FrameDumperOpenGL() = default;
if (present_thread.joinable()) {
present_thread.join();
}
}
bool FrameDumperOpenGL::IsDumping() const { bool FrameDumperOpenGL::IsDumping() const {
auto video_dumper = system.GetVideoDumper(); auto video_dumper = system.GetVideoDumper();
@ -35,19 +34,19 @@ void FrameDumperOpenGL::StartDumping() {
present_thread.join(); present_thread.join();
} }
present_thread = std::thread(&FrameDumperOpenGL::PresentLoop, this); present_thread = std::jthread([this](std::stop_token stop_token) { PresentLoop(stop_token); });
} }
void FrameDumperOpenGL::StopDumping() { void FrameDumperOpenGL::StopDumping() {
stop_requested.store(true, std::memory_order_relaxed); present_thread.request_stop();
} }
void FrameDumperOpenGL::PresentLoop() { void FrameDumperOpenGL::PresentLoop(std::stop_token stop_token) {
const auto scope = context->Acquire(); const auto scope = context->Acquire();
InitializeOpenGLObjects(); InitializeOpenGLObjects();
const auto& layout = GetLayout(); const auto& layout = GetLayout();
while (!stop_requested.exchange(false)) { while (!stop_token.stop_requested()) {
auto frame = mailbox->TryGetPresentFrame(200); auto frame = mailbox->TryGetPresentFrame(200);
if (!frame) { if (!frame) {
continue; continue;

View File

@ -6,9 +6,8 @@
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include <thread>
#include "core/core.h" #include "common/polyfill_thread.h"
#include "core/dumping/backend.h"
#include "core/frontend/framebuffer_layout.h" #include "core/frontend/framebuffer_layout.h"
#include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/gl_resource_manager.h"
@ -18,6 +17,10 @@ class GraphicsContext;
class TextureMailbox; class TextureMailbox;
} // namespace Frontend } // namespace Frontend
namespace Core {
class System;
}
namespace OpenGL { namespace OpenGL {
class RendererOpenGL; class RendererOpenGL;
@ -42,12 +45,12 @@ public:
private: private:
void InitializeOpenGLObjects(); void InitializeOpenGLObjects();
void CleanupOpenGLObjects(); void CleanupOpenGLObjects();
void PresentLoop(); void PresentLoop(std::stop_token stop_token);
private:
Core::System& system; Core::System& system;
std::unique_ptr<Frontend::GraphicsContext> context; std::unique_ptr<Frontend::GraphicsContext> context;
std::thread present_thread; std::jthread present_thread;
std::atomic_bool stop_requested{false};
// PBOs used to dump frames faster // PBOs used to dump frames faster
std::array<OGLBuffer, 2> pbos; std::array<OGLBuffer, 2> pbos;

View File

@ -16,7 +16,7 @@ add_library(web_service STATIC
create_target_directory_groups(web_service) create_target_directory_groups(web_service)
target_compile_definitions(web_service PUBLIC -DENABLE_WEB_SERVICE) target_compile_definitions(web_service PRIVATE -DCPPHTTPLIB_OPENSSL_SUPPORT)
target_link_libraries(web_service PRIVATE citra_common network json-headers httplib cpp-jwt) target_link_libraries(web_service PRIVATE citra_common network json-headers httplib cpp-jwt)
target_link_libraries(web_service PUBLIC ${OPENSSL_LIBS}) target_link_libraries(web_service PUBLIC ${OPENSSL_LIBS})
set_target_properties(web_service PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO}) set_target_properties(web_service PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})