summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/citra_qt/CMakeLists.txt2
-rw-r--r--src/citra_qt/debugger/wait_tree.cpp417
-rw-r--r--src/citra_qt/debugger/wait_tree.h186
-rw-r--r--src/citra_qt/main.cpp13
-rw-r--r--src/citra_qt/main.h2
-rw-r--r--src/core/file_sys/archive_backend.h7
-rw-r--r--src/core/file_sys/disk_archive.cpp4
-rw-r--r--src/core/file_sys/disk_archive.h1
-rw-r--r--src/core/file_sys/ivfc_archive.cpp6
-rw-r--r--src/core/file_sys/ivfc_archive.h1
-rw-r--r--src/core/hle/kernel/event.h6
-rw-r--r--src/core/hle/kernel/kernel.cpp4
-rw-r--r--src/core/hle/kernel/kernel.h9
-rw-r--r--src/core/hle/kernel/thread.cpp4
-rw-r--r--src/core/hle/kernel/thread.h5
-rw-r--r--src/core/hle/kernel/timer.h1
-rw-r--r--src/core/hle/service/fs/archive.cpp12
-rw-r--r--src/core/hle/service/fs/archive.h9
-rw-r--r--src/core/hle/service/fs/fs_user.cpp75
-rw-r--r--src/core/hle/svc.cpp4
-rw-r--r--src/core/hw/gpu.cpp573
-rw-r--r--src/core/memory.cpp3
-rw-r--r--src/video_core/rasterizer_interface.h7
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp10
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h1
25 files changed, 1086 insertions, 276 deletions
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt
index e97d33da4..b3c01ddd8 100644
--- a/src/citra_qt/CMakeLists.txt
+++ b/src/citra_qt/CMakeLists.txt
@@ -15,6 +15,7 @@ set(SRCS
debugger/profiler.cpp
debugger/ramview.cpp
debugger/registers.cpp
+ debugger/wait_tree.cpp
util/spinbox.cpp
util/util.cpp
bootmanager.cpp
@@ -48,6 +49,7 @@ set(HEADERS
debugger/profiler.h
debugger/ramview.h
debugger/registers.h
+ debugger/wait_tree.h
util/spinbox.h
util/util.h
bootmanager.h
diff --git a/src/citra_qt/debugger/wait_tree.cpp b/src/citra_qt/debugger/wait_tree.cpp
new file mode 100644
index 000000000..be5a51e52
--- /dev/null
+++ b/src/citra_qt/debugger/wait_tree.cpp
@@ -0,0 +1,417 @@
+// Copyright 2016 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "citra_qt/debugger/wait_tree.h"
+#include "citra_qt/util/util.h"
+
+#include "core/hle/kernel/event.h"
+#include "core/hle/kernel/mutex.h"
+#include "core/hle/kernel/semaphore.h"
+#include "core/hle/kernel/session.h"
+#include "core/hle/kernel/thread.h"
+#include "core/hle/kernel/timer.h"
+
+WaitTreeItem::~WaitTreeItem() {}
+
+QColor WaitTreeItem::GetColor() const {
+ return QColor(Qt::GlobalColor::black);
+}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeItem::GetChildren() const {
+ return {};
+}
+
+void WaitTreeItem::Expand() {
+ if (IsExpandable() && !expanded) {
+ children = GetChildren();
+ for (std::size_t i = 0; i < children.size(); ++i) {
+ children[i]->parent = this;
+ children[i]->row = i;
+ }
+ expanded = true;
+ }
+}
+
+WaitTreeItem* WaitTreeItem::Parent() const {
+ return parent;
+}
+
+const std::vector<std::unique_ptr<WaitTreeItem>>& WaitTreeItem::Children() const {
+ return children;
+}
+
+bool WaitTreeItem::IsExpandable() const {
+ return false;
+}
+
+std::size_t WaitTreeItem::Row() const {
+ return row;
+}
+
+std::vector<std::unique_ptr<WaitTreeThread>> WaitTreeItem::MakeThreadItemList() {
+ const auto& threads = Kernel::GetThreadList();
+ std::vector<std::unique_ptr<WaitTreeThread>> item_list;
+ item_list.reserve(threads.size());
+ for (std::size_t i = 0; i < threads.size(); ++i) {
+ item_list.push_back(std::make_unique<WaitTreeThread>(*threads[i]));
+ item_list.back()->row = i;
+ }
+ return item_list;
+}
+
+WaitTreeText::WaitTreeText(const QString& t) : text(t) {}
+
+QString WaitTreeText::GetText() const {
+ return text;
+}
+
+WaitTreeWaitObject::WaitTreeWaitObject(const Kernel::WaitObject& o) : object(o) {}
+
+bool WaitTreeExpandableItem::IsExpandable() const {
+ return true;
+}
+
+QString WaitTreeWaitObject::GetText() const {
+ return tr("[%1]%2 %3")
+ .arg(object.GetObjectId())
+ .arg(QString::fromStdString(object.GetTypeName()),
+ QString::fromStdString(object.GetName()));
+}
+
+std::unique_ptr<WaitTreeWaitObject> WaitTreeWaitObject::make(const Kernel::WaitObject& object) {
+ switch (object.GetHandleType()) {
+ case Kernel::HandleType::Event:
+ return std::make_unique<WaitTreeEvent>(static_cast<const Kernel::Event&>(object));
+ case Kernel::HandleType::Mutex:
+ return std::make_unique<WaitTreeMutex>(static_cast<const Kernel::Mutex&>(object));
+ case Kernel::HandleType::Semaphore:
+ return std::make_unique<WaitTreeSemaphore>(static_cast<const Kernel::Semaphore&>(object));
+ case Kernel::HandleType::Timer:
+ return std::make_unique<WaitTreeTimer>(static_cast<const Kernel::Timer&>(object));
+ case Kernel::HandleType::Thread:
+ return std::make_unique<WaitTreeThread>(static_cast<const Kernel::Thread&>(object));
+ default:
+ return std::make_unique<WaitTreeWaitObject>(object);
+ }
+}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeWaitObject::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list;
+
+ const auto& threads = object.GetWaitingThreads();
+ if (threads.empty()) {
+ list.push_back(std::make_unique<WaitTreeText>(tr("waited by no thread")));
+ } else {
+ list.push_back(std::make_unique<WaitTreeThreadList>(threads));
+ }
+ return list;
+}
+
+QString WaitTreeWaitObject::GetResetTypeQString(Kernel::ResetType reset_type) {
+ switch (reset_type) {
+ case Kernel::ResetType::OneShot:
+ return tr("one shot");
+ case Kernel::ResetType::Sticky:
+ return tr("sticky");
+ case Kernel::ResetType::Pulse:
+ return tr("pulse");
+ }
+}
+
+WaitTreeObjectList::WaitTreeObjectList(
+ const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& list, bool w_all)
+ : object_list(list), wait_all(w_all) {}
+
+QString WaitTreeObjectList::GetText() const {
+ if (wait_all)
+ return tr("waiting for all objects");
+ return tr("waiting for one of the following objects");
+}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeObjectList::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(object_list.size());
+ std::transform(object_list.begin(), object_list.end(), list.begin(),
+ [](const auto& t) { return WaitTreeWaitObject::make(*t); });
+ return list;
+}
+
+WaitTreeThread::WaitTreeThread(const Kernel::Thread& thread) : WaitTreeWaitObject(thread) {}
+
+QString WaitTreeThread::GetText() const {
+ const auto& thread = static_cast<const Kernel::Thread&>(object);
+ QString status;
+ switch (thread.status) {
+ case THREADSTATUS_RUNNING:
+ status = tr("running");
+ break;
+ case THREADSTATUS_READY:
+ status = tr("ready");
+ break;
+ case THREADSTATUS_WAIT_ARB:
+ status = tr("waiting for address 0x%1").arg(thread.wait_address, 8, 16, QLatin1Char('0'));
+ break;
+ case THREADSTATUS_WAIT_SLEEP:
+ status = tr("sleeping");
+ break;
+ case THREADSTATUS_WAIT_SYNCH:
+ status = tr("waiting for objects");
+ break;
+ case THREADSTATUS_DORMANT:
+ status = tr("dormant");
+ break;
+ case THREADSTATUS_DEAD:
+ status = tr("dead");
+ break;
+ }
+ QString pc_info = tr(" PC = 0x%1 LR = 0x%2")
+ .arg(thread.context.pc, 8, 16, QLatin1Char('0'))
+ .arg(thread.context.lr, 8, 16, QLatin1Char('0'));
+ return WaitTreeWaitObject::GetText() + pc_info + " (" + status + ") ";
+}
+
+QColor WaitTreeThread::GetColor() const {
+ const auto& thread = static_cast<const Kernel::Thread&>(object);
+ switch (thread.status) {
+ case THREADSTATUS_RUNNING:
+ return QColor(Qt::GlobalColor::darkGreen);
+ case THREADSTATUS_READY:
+ return QColor(Qt::GlobalColor::darkBlue);
+ case THREADSTATUS_WAIT_ARB:
+ return QColor(Qt::GlobalColor::darkRed);
+ case THREADSTATUS_WAIT_SLEEP:
+ return QColor(Qt::GlobalColor::darkYellow);
+ case THREADSTATUS_WAIT_SYNCH:
+ return QColor(Qt::GlobalColor::red);
+ case THREADSTATUS_DORMANT:
+ return QColor(Qt::GlobalColor::darkCyan);
+ case THREADSTATUS_DEAD:
+ return QColor(Qt::GlobalColor::gray);
+ default:
+ return WaitTreeItem::GetColor();
+ }
+}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThread::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
+
+ const auto& thread = static_cast<const Kernel::Thread&>(object);
+
+ QString processor;
+ switch (thread.processor_id) {
+ case ThreadProcessorId::THREADPROCESSORID_DEFAULT:
+ processor = tr("default");
+ break;
+ case ThreadProcessorId::THREADPROCESSORID_ALL:
+ processor = tr("all");
+ break;
+ case ThreadProcessorId::THREADPROCESSORID_0:
+ processor = tr("AppCore");
+ break;
+ case ThreadProcessorId::THREADPROCESSORID_1:
+ processor = tr("SysCore");
+ break;
+ default:
+ processor = tr("Unknown processor %1").arg(thread.processor_id);
+ break;
+ }
+
+ list.push_back(std::make_unique<WaitTreeText>(tr("processor = %1").arg(processor)));
+ list.push_back(std::make_unique<WaitTreeText>(tr("thread id = %1").arg(thread.GetThreadId())));
+ list.push_back(std::make_unique<WaitTreeText>(tr("priority = %1(current) / %2(normal)")
+ .arg(thread.current_priority)
+ .arg(thread.nominal_priority)));
+ list.push_back(std::make_unique<WaitTreeText>(
+ tr("last running ticks = %1").arg(thread.last_running_ticks)));
+
+ if (thread.held_mutexes.empty()) {
+ list.push_back(std::make_unique<WaitTreeText>(tr("not holding mutex")));
+ } else {
+ list.push_back(std::make_unique<WaitTreeMutexList>(thread.held_mutexes));
+ }
+ if (thread.status == THREADSTATUS_WAIT_SYNCH) {
+ list.push_back(std::make_unique<WaitTreeObjectList>(thread.wait_objects, thread.wait_all));
+ }
+
+ return list;
+}
+
+WaitTreeEvent::WaitTreeEvent(const Kernel::Event& object) : WaitTreeWaitObject(object) {}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeEvent::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
+
+ list.push_back(std::make_unique<WaitTreeText>(
+ tr("reset type = %1")
+ .arg(GetResetTypeQString(static_cast<const Kernel::Event&>(object).reset_type))));
+ return list;
+}
+
+WaitTreeMutex::WaitTreeMutex(const Kernel::Mutex& object) : WaitTreeWaitObject(object) {}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutex::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
+
+ const auto& mutex = static_cast<const Kernel::Mutex&>(object);
+ if (mutex.lock_count) {
+ list.push_back(
+ std::make_unique<WaitTreeText>(tr("locked %1 times by thread:").arg(mutex.lock_count)));
+ list.push_back(std::make_unique<WaitTreeThread>(*mutex.holding_thread));
+ } else {
+ list.push_back(std::make_unique<WaitTreeText>(tr("free")));
+ }
+ return list;
+}
+
+WaitTreeSemaphore::WaitTreeSemaphore(const Kernel::Semaphore& object)
+ : WaitTreeWaitObject(object) {}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeSemaphore::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
+
+ const auto& semaphore = static_cast<const Kernel::Semaphore&>(object);
+ list.push_back(
+ std::make_unique<WaitTreeText>(tr("available count = %1").arg(semaphore.available_count)));
+ list.push_back(std::make_unique<WaitTreeText>(tr("max count = %1").arg(semaphore.max_count)));
+ return list;
+}
+
+WaitTreeTimer::WaitTreeTimer(const Kernel::Timer& object) : WaitTreeWaitObject(object) {}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeTimer::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(WaitTreeWaitObject::GetChildren());
+
+ const auto& timer = static_cast<const Kernel::Timer&>(object);
+
+ list.push_back(std::make_unique<WaitTreeText>(
+ tr("reset type = %1").arg(GetResetTypeQString(timer.reset_type))));
+ list.push_back(
+ std::make_unique<WaitTreeText>(tr("initial delay = %1").arg(timer.initial_delay)));
+ list.push_back(
+ std::make_unique<WaitTreeText>(tr("interval delay = %1").arg(timer.interval_delay)));
+ return list;
+}
+
+WaitTreeMutexList::WaitTreeMutexList(
+ const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& list)
+ : mutex_list(list) {}
+
+QString WaitTreeMutexList::GetText() const {
+ return tr("holding mutexes");
+}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeMutexList::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(mutex_list.size());
+ std::transform(mutex_list.begin(), mutex_list.end(), list.begin(),
+ [](const auto& t) { return std::make_unique<WaitTreeMutex>(*t); });
+ return list;
+}
+
+WaitTreeThreadList::WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list)
+ : thread_list(list) {}
+
+QString WaitTreeThreadList::GetText() const {
+ return tr("waited by thread");
+}
+
+std::vector<std::unique_ptr<WaitTreeItem>> WaitTreeThreadList::GetChildren() const {
+ std::vector<std::unique_ptr<WaitTreeItem>> list(thread_list.size());
+ std::transform(thread_list.begin(), thread_list.end(), list.begin(),
+ [](const auto& t) { return std::make_unique<WaitTreeThread>(*t); });
+ return list;
+}
+
+WaitTreeModel::WaitTreeModel(QObject* parent) : QAbstractItemModel(parent) {}
+
+QModelIndex WaitTreeModel::index(int row, int column, const QModelIndex& parent) const {
+ if (!hasIndex(row, column, parent))
+ return {};
+
+ if (parent.isValid()) {
+ WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer());
+ parent_item->Expand();
+ return createIndex(row, column, parent_item->Children()[row].get());
+ }
+
+ return createIndex(row, column, thread_items[row].get());
+}
+
+QModelIndex WaitTreeModel::parent(const QModelIndex& index) const {
+ if (!index.isValid())
+ return {};
+
+ WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(index.internalPointer())->Parent();
+ if (!parent_item) {
+ return QModelIndex();
+ }
+ return createIndex(static_cast<int>(parent_item->Row()), 0, parent_item);
+}
+
+int WaitTreeModel::rowCount(const QModelIndex& parent) const {
+ if (!parent.isValid())
+ return static_cast<int>(thread_items.size());
+
+ WaitTreeItem* parent_item = static_cast<WaitTreeItem*>(parent.internalPointer());
+ parent_item->Expand();
+ return static_cast<int>(parent_item->Children().size());
+}
+
+int WaitTreeModel::columnCount(const QModelIndex&) const {
+ return 1;
+}
+
+QVariant WaitTreeModel::data(const QModelIndex& index, int role) const {
+ if (!index.isValid())
+ return {};
+
+ switch (role) {
+ case Qt::DisplayRole:
+ return static_cast<WaitTreeItem*>(index.internalPointer())->GetText();
+ case Qt::ForegroundRole:
+ return static_cast<WaitTreeItem*>(index.internalPointer())->GetColor();
+ default:
+ return {};
+ }
+}
+
+void WaitTreeModel::ClearItems() {
+ thread_items.clear();
+}
+
+void WaitTreeModel::InitItems() {
+ thread_items = WaitTreeItem::MakeThreadItemList();
+}
+
+WaitTreeWidget::WaitTreeWidget(QWidget* parent) : QDockWidget(tr("Wait Tree"), parent) {
+ setObjectName("WaitTreeWidget");
+ view = new QTreeView(this);
+ view->setHeaderHidden(true);
+ setWidget(view);
+ setEnabled(false);
+}
+
+void WaitTreeWidget::OnDebugModeEntered() {
+ if (!Core::g_app_core)
+ return;
+ model->InitItems();
+ view->setModel(model);
+ setEnabled(true);
+}
+
+void WaitTreeWidget::OnDebugModeLeft() {
+ setEnabled(false);
+ view->setModel(nullptr);
+ model->ClearItems();
+}
+
+void WaitTreeWidget::OnEmulationStarting(EmuThread* emu_thread) {
+ model = new WaitTreeModel(this);
+ view->setModel(model);
+ setEnabled(false);
+}
+
+void WaitTreeWidget::OnEmulationStopping() {
+ view->setModel(nullptr);
+ delete model;
+ setEnabled(false);
+}
diff --git a/src/citra_qt/debugger/wait_tree.h b/src/citra_qt/debugger/wait_tree.h
new file mode 100644
index 000000000..5d1d964d1
--- /dev/null
+++ b/src/citra_qt/debugger/wait_tree.h
@@ -0,0 +1,186 @@
+// Copyright 2016 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include <boost/container/flat_set.hpp>
+
+#include <QAbstractItemModel>
+#include <QDockWidget>
+#include <QTreeView>
+
+#include "core/core.h"
+#include "core/hle/kernel/kernel.h"
+
+class EmuThread;
+
+namespace Kernel {
+class WaitObject;
+class Event;
+class Mutex;
+class Semaphore;
+class Session;
+class Thread;
+class Timer;
+}
+
+class WaitTreeThread;
+
+class WaitTreeItem : public QObject {
+ Q_OBJECT
+public:
+ virtual bool IsExpandable() const;
+ virtual std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const;
+ virtual QString GetText() const = 0;
+ virtual QColor GetColor() const;
+ virtual ~WaitTreeItem();
+ void Expand();
+ WaitTreeItem* Parent() const;
+ const std::vector<std::unique_ptr<WaitTreeItem>>& Children() const;
+ std::size_t Row() const;
+ static std::vector<std::unique_ptr<WaitTreeThread>> MakeThreadItemList();
+
+private:
+ std::size_t row;
+ bool expanded = false;
+ WaitTreeItem* parent = nullptr;
+ std::vector<std::unique_ptr<WaitTreeItem>> children;
+};
+
+class WaitTreeText : public WaitTreeItem {
+ Q_OBJECT
+public:
+ WaitTreeText(const QString& text);
+ QString GetText() const override;
+
+private:
+ QString text;
+};
+
+class WaitTreeExpandableItem : public WaitTreeItem {
+ Q_OBJECT
+public:
+ bool IsExpandable() const override;
+};
+
+class WaitTreeWaitObject : public WaitTreeExpandableItem {
+ Q_OBJECT
+public:
+ WaitTreeWaitObject(const Kernel::WaitObject& object);
+ static std::unique_ptr<WaitTreeWaitObject> make(const Kernel::WaitObject& object);
+ QString GetText() const override;
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+
+protected:
+ const Kernel::WaitObject& object;
+
+ static QString GetResetTypeQString(Kernel::ResetType reset_type);
+};
+
+class WaitTreeObjectList : public WaitTreeExpandableItem {
+ Q_OBJECT
+public:
+ WaitTreeObjectList(const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& list,
+ bool wait_all);
+ QString GetText() const override;
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+
+private:
+ const std::vector<Kernel::SharedPtr<Kernel::WaitObject>>& object_list;
+ bool wait_all;
+};
+
+class WaitTreeThread : public WaitTreeWaitObject {
+ Q_OBJECT
+public:
+ WaitTreeThread(const Kernel::Thread& thread);
+ QString GetText() const override;
+ QColor GetColor() const override;
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+};
+
+class WaitTreeEvent : public WaitTreeWaitObject {
+ Q_OBJECT
+public:
+ WaitTreeEvent(const Kernel::Event& object);
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+};
+
+class WaitTreeMutex : public WaitTreeWaitObject {
+ Q_OBJECT
+public:
+ WaitTreeMutex(const Kernel::Mutex& object);
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+};
+
+class WaitTreeSemaphore : public WaitTreeWaitObject {
+ Q_OBJECT
+public:
+ WaitTreeSemaphore(const Kernel::Semaphore& object);
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+};
+
+class WaitTreeTimer : public WaitTreeWaitObject {
+ Q_OBJECT
+public:
+ WaitTreeTimer(const Kernel::Timer& object);
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+};
+
+class WaitTreeMutexList : public WaitTreeExpandableItem {
+ Q_OBJECT
+public:
+ WaitTreeMutexList(const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& list);
+ QString GetText() const override;
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+
+private:
+ const boost::container::flat_set<Kernel::SharedPtr<Kernel::Mutex>>& mutex_list;
+};
+
+class WaitTreeThreadList : public WaitTreeExpandableItem {
+ Q_OBJECT
+public:
+ WaitTreeThreadList(const std::vector<Kernel::SharedPtr<Kernel::Thread>>& list);
+ QString GetText() const override;
+ std::vector<std::unique_ptr<WaitTreeItem>> GetChildren() const override;
+
+private:
+ const std::vector<Kernel::SharedPtr<Kernel::Thread>>& thread_list;
+};
+
+class WaitTreeModel : public QAbstractItemModel {
+ Q_OBJECT
+
+public:
+ WaitTreeModel(QObject* parent = nullptr);
+
+ QVariant data(const QModelIndex& index, int role) const override;
+ QModelIndex index(int row, int column, const QModelIndex& parent) const override;
+ QModelIndex parent(const QModelIndex& index) const override;
+ int rowCount(const QModelIndex& parent) const override;
+ int columnCount(const QModelIndex& parent) const override;
+
+ void ClearItems();
+ void InitItems();
+
+private:
+ std::vector<std::unique_ptr<WaitTreeThread>> thread_items;
+};
+
+class WaitTreeWidget : public QDockWidget {
+ Q_OBJECT
+
+public:
+ WaitTreeWidget(QWidget* parent = nullptr);
+
+public slots:
+ void OnDebugModeEntered();
+ void OnDebugModeLeft();
+
+ void OnEmulationStarting(EmuThread* emu_thread);
+ void OnEmulationStopping();
+
+private:
+ QTreeView* view;
+ WaitTreeModel* model;
+};
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 0c7bedfcf..8322e2305 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -25,6 +25,7 @@
#include "citra_qt/debugger/profiler.h"
#include "citra_qt/debugger/ramview.h"
#include "citra_qt/debugger/registers.h"
+#include "citra_qt/debugger/wait_tree.h"
#include "citra_qt/game_list.h"
#include "citra_qt/hotkeys.h"
#include "citra_qt/main.h"
@@ -104,6 +105,10 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
connect(graphicsSurfaceViewerAction, SIGNAL(triggered()), this,
SLOT(OnCreateGraphicsSurfaceViewer()));
+ waitTreeWidget = new WaitTreeWidget(this);
+ addDockWidget(Qt::LeftDockWidgetArea, waitTreeWidget);
+ waitTreeWidget->hide();
+
QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging"));
debug_menu->addAction(graphicsSurfaceViewerAction);
debug_menu->addSeparator();
@@ -119,6 +124,7 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
debug_menu->addAction(graphicsBreakpointsWidget->toggleViewAction());
debug_menu->addAction(graphicsVertexShaderWidget->toggleViewAction());
debug_menu->addAction(graphicsTracingWidget->toggleViewAction());
+ debug_menu->addAction(waitTreeWidget->toggleViewAction());
// Set default UI state
// geometry: 55% of the window contents are in the upper screen half, 45% in the lower half
@@ -184,6 +190,9 @@ GMainWindow::GMainWindow() : config(new Config()), emu_thread(nullptr) {
connect(this, SIGNAL(EmulationStarting(EmuThread*)), graphicsTracingWidget,
SLOT(OnEmulationStarting(EmuThread*)));
connect(this, SIGNAL(EmulationStopping()), graphicsTracingWidget, SLOT(OnEmulationStopping()));
+ connect(this, SIGNAL(EmulationStarting(EmuThread*)), waitTreeWidget,
+ SLOT(OnEmulationStarting(EmuThread*)));
+ connect(this, SIGNAL(EmulationStopping()), waitTreeWidget, SLOT(OnEmulationStopping()));
// Setup hotkeys
RegisterHotkey("Main Window", "Load File", QKeySequence::Open);
@@ -345,12 +354,16 @@ void GMainWindow::BootGame(const std::string& filename) {
SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
connect(emu_thread.get(), SIGNAL(DebugModeEntered()), callstackWidget,
SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
+ connect(emu_thread.get(), SIGNAL(DebugModeEntered()), waitTreeWidget,
+ SLOT(OnDebugModeEntered()), Qt::BlockingQueuedConnection);
connect(emu_thread.get(), SIGNAL(DebugModeLeft()), disasmWidget, SLOT(OnDebugModeLeft()),
Qt::BlockingQueuedConnection);
connect(emu_thread.get(), SIGNAL(DebugModeLeft()), registersWidget, SLOT(OnDebugModeLeft()),
Qt::BlockingQueuedConnection);
connect(emu_thread.get(), SIGNAL(DebugModeLeft()), callstackWidget, SLOT(OnDebugModeLeft()),
Qt::BlockingQueuedConnection);
+ connect(emu_thread.get(), SIGNAL(DebugModeLeft()), waitTreeWidget, SLOT(OnDebugModeLeft()),
+ Qt::BlockingQueuedConnection);
// Update the GUI
registersWidget->OnDebugModeEntered();
diff --git a/src/citra_qt/main.h b/src/citra_qt/main.h
index c4349513f..2cf308d80 100644
--- a/src/citra_qt/main.h
+++ b/src/citra_qt/main.h
@@ -21,6 +21,7 @@ class RegistersWidget;
class CallstackWidget;
class GPUCommandStreamWidget;
class GPUCommandListWidget;
+class WaitTreeWidget;
class GMainWindow : public QMainWindow {
Q_OBJECT
@@ -128,6 +129,7 @@ private:
CallstackWidget* callstackWidget;
GPUCommandStreamWidget* graphicsWidget;
GPUCommandListWidget* graphicsCommandsWidget;
+ WaitTreeWidget* waitTreeWidget;
QAction* actions_recent_files[max_recent_files_item];
};
diff --git a/src/core/file_sys/archive_backend.h b/src/core/file_sys/archive_backend.h
index d69c3c785..06b8f2ed7 100644
--- a/src/core/file_sys/archive_backend.h
+++ b/src/core/file_sys/archive_backend.h
@@ -112,6 +112,13 @@ public:
virtual bool DeleteDirectory(const Path& path) const = 0;
/**
+ * Delete a directory specified by its path and anything under it
+ * @param path Path relative to the archive
+ * @return Whether the directory could be deleted
+ */
+ virtual bool DeleteDirectoryRecursively(const Path& path) const = 0;
+
+ /**
* Create a file specified by its path
* @param path Path relative to the Archive
* @param size The size of the new file, filled with zeroes
diff --git a/src/core/file_sys/disk_archive.cpp b/src/core/file_sys/disk_archive.cpp
index 0f66998e1..2f05af361 100644
--- a/src/core/file_sys/disk_archive.cpp
+++ b/src/core/file_sys/disk_archive.cpp
@@ -51,6 +51,10 @@ bool DiskArchive::DeleteDirectory(const Path& path) const {
return FileUtil::DeleteDir(mount_point + path.AsString());
}
+bool DiskArchive::DeleteDirectoryRecursively(const Path& path) const {
+ return FileUtil::DeleteDirRecursively(mount_point + path.AsString());
+}
+
ResultCode DiskArchive::CreateFile(const FileSys::Path& path, u64 size) const {
std::string full_path = mount_point + path.AsString();
diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h
index 2165f27f9..59ebb2002 100644
--- a/src/core/file_sys/disk_archive.h
+++ b/src/core/file_sys/disk_archive.h
@@ -38,6 +38,7 @@ public:
ResultCode DeleteFile(const Path& path) const override;
bool RenameFile(const Path& src_path, const Path& dest_path) const override;
bool DeleteDirectory(const Path& path) const override;
+ bool DeleteDirectoryRecursively(const Path& path) const override;
ResultCode CreateFile(const Path& path, u64 size) const override;
bool CreateDirectory(const Path& path) const override;
bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
diff --git a/src/core/file_sys/ivfc_archive.cpp b/src/core/file_sys/ivfc_archive.cpp
index 49cc1de10..af59d296d 100644
--- a/src/core/file_sys/ivfc_archive.cpp
+++ b/src/core/file_sys/ivfc_archive.cpp
@@ -43,6 +43,12 @@ bool IVFCArchive::DeleteDirectory(const Path& path) const {
return false;
}
+bool IVFCArchive::DeleteDirectoryRecursively(const Path& path) const {
+ LOG_CRITICAL(Service_FS, "Attempted to delete a directory from an IVFC archive (%s).",
+ GetName().c_str());
+ return false;
+}
+
ResultCode IVFCArchive::CreateFile(const Path& path, u64 size) const {
LOG_CRITICAL(Service_FS, "Attempted to create a file in an IVFC archive (%s).",
GetName().c_str());
diff --git a/src/core/file_sys/ivfc_archive.h b/src/core/file_sys/ivfc_archive.h
index 0df6cf83a..2fbb3a568 100644
--- a/src/core/file_sys/ivfc_archive.h
+++ b/src/core/file_sys/ivfc_archive.h
@@ -37,6 +37,7 @@ public:
ResultCode DeleteFile(const Path& path) const override;
bool RenameFile(const Path& src_path, const Path& dest_path) const override;
bool DeleteDirectory(const Path& path) const override;
+ bool DeleteDirectoryRecursively(const Path& path) const override;
ResultCode CreateFile(const Path& path, u64 size) const override;
bool CreateDirectory(const Path& path) const override;
bool RenameDirectory(const Path& src_path, const Path& dest_path) const override;
diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h
index 6fe74065d..8dcd23edb 100644
--- a/src/core/hle/kernel/event.h
+++ b/src/core/hle/kernel/event.h
@@ -9,12 +9,6 @@
namespace Kernel {
-enum class ResetType {
- OneShot,
- Sticky,
- Pulse,
-};
-
class Event final : public WaitObject {
public:
/**
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 9a2c8ce05..9e1795927 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -40,6 +40,10 @@ void WaitObject::WakeupAllWaitingThreads() {
HLE::Reschedule(__func__);
}
+const std::vector<SharedPtr<Thread>>& WaitObject::GetWaitingThreads() const {
+ return waiting_threads;
+}
+
HandleTable::HandleTable() {
next_generation = 1;
Clear();
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 0e95f7ff0..6b8dbecff 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -53,6 +53,12 @@ enum {
DEFAULT_STACK_SIZE = 0x4000,
};
+enum class ResetType {
+ OneShot,
+ Sticky,
+ Pulse,
+};
+
class Object : NonCopyable {
public:
virtual ~Object() {}
@@ -149,6 +155,9 @@ public:
/// Wake up all threads waiting on this object
void WakeupAllWaitingThreads();
+ /// Get a const reference to the waiting threads list for debug use
+ const std::vector<SharedPtr<Thread>>& GetWaitingThreads() const;
+
private:
/// Threads waiting for this object to become available
std::vector<SharedPtr<Thread>> waiting_threads;
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 4486a812c..c4eeeee56 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -665,4 +665,8 @@ void ThreadingShutdown() {
ready_queue.clear();
}
+const std::vector<SharedPtr<Thread>>& GetThreadList() {
+ return thread_list;
+}
+
} // namespace
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h
index f63131716..e0ffcea8a 100644
--- a/src/core/hle/kernel/thread.h
+++ b/src/core/hle/kernel/thread.h
@@ -236,4 +236,9 @@ void ThreadingInit();
*/
void ThreadingShutdown();
+/**
+ * Get a const reference to the thread list for debug use
+ */
+const std::vector<SharedPtr<Thread>>& GetThreadList();
+
} // namespace
diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h
index 59a77aad3..18ea0236b 100644
--- a/src/core/hle/kernel/timer.h
+++ b/src/core/hle/kernel/timer.h
@@ -5,7 +5,6 @@
#pragma once
#include "common/common_types.h"
-#include "core/hle/kernel/event.h"
#include "core/hle/kernel/kernel.h"
namespace Kernel {
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index 4dc7e1e3c..7f9696bfb 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -362,6 +362,18 @@ ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSy
ErrorSummary::Canceled, ErrorLevel::Status);
}
+ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
+ const FileSys::Path& path) {
+ ArchiveBackend* archive = GetArchive(archive_handle);
+ if (archive == nullptr)
+ return ERR_INVALID_ARCHIVE_HANDLE;
+
+ if (archive->DeleteDirectoryRecursively(path))
+ return RESULT_SUCCESS;
+ return ResultCode(ErrorDescription::NoData, ErrorModule::FS, // TODO: verify description
+ ErrorSummary::Canceled, ErrorLevel::Status);
+}
+
ResultCode CreateFileInArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
u64 file_size) {
ArchiveBackend* archive = GetArchive(archive_handle);
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h
index 533be34a4..41a76285c 100644
--- a/src/core/hle/service/fs/archive.h
+++ b/src/core/hle/service/fs/archive.h
@@ -133,6 +133,15 @@ ResultCode RenameFileBetweenArchives(ArchiveHandle src_archive_handle,
ResultCode DeleteDirectoryFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path);
/**
+ * Delete a Directory and anything under it from an Archive
+ * @param archive_handle Handle to an open Archive object
+ * @param path Path to the Directory inside of the Archive
+ * @return Whether deletion succeeded
+ */
+ResultCode DeleteDirectoryRecursivelyFromArchive(ArchiveHandle archive_handle,
+ const FileSys::Path& path);
+
+/**
* Create a File in an Archive
* @param archive_handle Handle to an open Archive object
* @param path Path to the File inside of the Archive
diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp
index 94f053dc2..00edc7622 100644
--- a/src/core/hle/service/fs/fs_user.cpp
+++ b/src/core/hle/service/fs/fs_user.cpp
@@ -64,7 +64,7 @@ static void OpenFile(Service::Interface* self) {
u32 filename_ptr = cmd_buff[9];
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
- LOG_DEBUG(Service_FS, "path=%s, mode=%d attrs=%u", file_path.DebugStr().c_str(), mode.hex,
+ LOG_DEBUG(Service_FS, "path=%s, mode=%u attrs=%u", file_path.DebugStr().c_str(), mode.hex,
attributes);
ResultVal<SharedPtr<File>> file_res = OpenFileFromArchive(archive_handle, file_path, mode);
@@ -112,15 +112,15 @@ static void OpenFileDirectly(Service::Interface* self) {
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
- LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s file_path=%s, mode=%u attributes=%d",
- archive_id, archive_path.DebugStr().c_str(), file_path.DebugStr().c_str(), mode.hex,
- attributes);
+ LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s file_path=%s, mode=%u attributes=%u",
+ static_cast<u32>(archive_id), archive_path.DebugStr().c_str(),
+ file_path.DebugStr().c_str(), mode.hex, attributes);
ResultVal<ArchiveHandle> archive_handle = OpenArchive(archive_id, archive_path);
if (archive_handle.Failed()) {
LOG_ERROR(Service_FS,
"failed to get a handle for archive archive_id=0x%08X archive_path=%s",
- archive_id, archive_path.DebugStr().c_str());
+ static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
cmd_buff[1] = archive_handle.Code().raw;
cmd_buff[3] = 0;
return;
@@ -133,7 +133,7 @@ static void OpenFileDirectly(Service::Interface* self) {
cmd_buff[3] = Kernel::g_handle_table.Create(*file_res).MoveFrom();
} else {
cmd_buff[3] = 0;
- LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%d",
+ LOG_ERROR(Service_FS, "failed to get a handle for file %s mode=%u attributes=%u",
file_path.DebugStr().c_str(), mode.hex, attributes);
}
}
@@ -159,7 +159,7 @@ static void DeleteFile(Service::Interface* self) {
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", filename_type, filename_size,
+ LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(filename_type), filename_size,
file_path.DebugStr().c_str());
cmd_buff[1] = DeleteFileFromArchive(archive_handle, file_path).raw;
@@ -198,9 +198,10 @@ static void RenameFile(Service::Interface* self) {
FileSys::Path dest_file_path(dest_filename_type, dest_filename_size, dest_filename_ptr);
LOG_DEBUG(Service_FS,
- "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
- src_filename_type, src_filename_size, src_file_path.DebugStr().c_str(),
- dest_filename_type, dest_filename_size, dest_file_path.DebugStr().c_str());
+ "src_type=%u src_size=%u src_data=%s dest_type=%u dest_size=%u dest_data=%s",
+ static_cast<u32>(src_filename_type), src_filename_size,
+ src_file_path.DebugStr().c_str(), static_cast<u32>(dest_filename_type),
+ dest_filename_size, dest_file_path.DebugStr().c_str());
cmd_buff[1] = RenameFileBetweenArchives(src_archive_handle, src_file_path, dest_archive_handle,
dest_file_path)
@@ -228,13 +229,42 @@ static void DeleteDirectory(Service::Interface* self) {
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
+ LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(dirname_type), dirname_size,
dir_path.DebugStr().c_str());
cmd_buff[1] = DeleteDirectoryFromArchive(archive_handle, dir_path).raw;
}
/*
+ * FS_User::DeleteDirectoryRecursively service function
+ * Inputs:
+ * 0 : Command header 0x08070142
+ * 1 : Transaction
+ * 2 : Archive handle lower word
+ * 3 : Archive handle upper word
+ * 4 : Directory path string type
+ * 5 : Directory path string size
+ * 7 : Directory path string data
+ * Outputs:
+ * 1 : Result of function, 0 on success, otherwise error code
+ */
+static void DeleteDirectoryRecursively(Service::Interface* self) {
+ u32* cmd_buff = Kernel::GetCommandBuffer();
+
+ ArchiveHandle archive_handle = MakeArchiveHandle(cmd_buff[2], cmd_buff[3]);
+ auto dirname_type = static_cast<FileSys::LowPathType>(cmd_buff[4]);
+ u32 dirname_size = cmd_buff[5];
+ u32 dirname_ptr = cmd_buff[7];
+
+ FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
+
+ LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(dirname_type), dirname_size,
+ dir_path.DebugStr().c_str());
+
+ cmd_buff[1] = DeleteDirectoryRecursivelyFromArchive(archive_handle, dir_path).raw;
+}
+
+/*
* FS_User::CreateFile service function
* Inputs:
* 0 : Command header 0x08080202
@@ -258,7 +288,7 @@ static void CreateFile(Service::Interface* self) {
FileSys::Path file_path(filename_type, filename_size, filename_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%llu data=%s", filename_type, file_size,
+ LOG_DEBUG(Service_FS, "type=%u size=%llu data=%s", static_cast<u32>(filename_type), file_size,
file_path.DebugStr().c_str());
cmd_buff[1] = CreateFileInArchive(archive_handle, file_path, file_size).raw;
@@ -285,7 +315,7 @@ static void CreateDirectory(Service::Interface* self) {
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
+ LOG_DEBUG(Service_FS, "type=%u size=%d data=%s", static_cast<u32>(dirname_type), dirname_size,
dir_path.DebugStr().c_str());
cmd_buff[1] = CreateDirectoryFromArchive(archive_handle, dir_path).raw;
@@ -322,10 +352,10 @@ static void RenameDirectory(Service::Interface* self) {
FileSys::Path src_dir_path(src_dirname_type, src_dirname_size, src_dirname_ptr);
FileSys::Path dest_dir_path(dest_dirname_type, dest_dirname_size, dest_dirname_ptr);
- LOG_DEBUG(Service_FS,
- "src_type=%d src_size=%d src_data=%s dest_type=%d dest_size=%d dest_data=%s",
- src_dirname_type, src_dirname_size, src_dir_path.DebugStr().c_str(),
- dest_dirname_type, dest_dirname_size, dest_dir_path.DebugStr().c_str());
+ LOG_DEBUG(
+ Service_FS, "src_type=%u src_size=%u src_data=%s dest_type=%u dest_size=%u dest_data=%s",
+ static_cast<u32>(src_dirname_type), src_dirname_size, src_dir_path.DebugStr().c_str(),
+ static_cast<u32>(dest_dirname_type), dest_dirname_size, dest_dir_path.DebugStr().c_str());
cmd_buff[1] = RenameDirectoryBetweenArchives(src_archive_handle, src_dir_path,
dest_archive_handle, dest_dir_path)
@@ -355,7 +385,7 @@ static void OpenDirectory(Service::Interface* self) {
FileSys::Path dir_path(dirname_type, dirname_size, dirname_ptr);
- LOG_DEBUG(Service_FS, "type=%d size=%d data=%s", dirname_type, dirname_size,
+ LOG_DEBUG(Service_FS, "type=%u size=%u data=%s", static_cast<u32>(dirname_type), dirname_size,
dir_path.DebugStr().c_str());
ResultVal<SharedPtr<Directory>> dir_res = OpenDirectoryFromArchive(archive_handle, dir_path);
@@ -390,7 +420,7 @@ static void OpenArchive(Service::Interface* self) {
u32 archivename_ptr = cmd_buff[5];
FileSys::Path archive_path(archivename_type, archivename_size, archivename_ptr);
- LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", archive_id,
+ LOG_DEBUG(Service_FS, "archive_id=0x%08X archive_path=%s", static_cast<u32>(archive_id),
archive_path.DebugStr().c_str());
ResultVal<ArchiveHandle> handle = OpenArchive(archive_id, archive_path);
@@ -402,7 +432,7 @@ static void OpenArchive(Service::Interface* self) {
cmd_buff[2] = cmd_buff[3] = 0;
LOG_ERROR(Service_FS,
"failed to get a handle for archive archive_id=0x%08X archive_path=%s",
- archive_id, archive_path.DebugStr().c_str());
+ static_cast<u32>(archive_id), archive_path.DebugStr().c_str());
}
}
@@ -485,7 +515,8 @@ static void FormatSaveData(Service::Interface* self) {
LOG_DEBUG(Service_FS, "archive_path=%s", archive_path.DebugStr().c_str());
if (archive_id != FS::ArchiveIdCode::SaveData) {
- LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u", archive_id);
+ LOG_ERROR(Service_FS, "tried to format an archive different than SaveData, %u",
+ static_cast<u32>(archive_id));
cmd_buff[1] = ResultCode(ErrorDescription::FS_InvalidPath, ErrorModule::FS,
ErrorSummary::InvalidArgument, ErrorLevel::Usage)
.raw;
@@ -868,7 +899,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x08040142, DeleteFile, "DeleteFile"},
{0x08050244, RenameFile, "RenameFile"},
{0x08060142, DeleteDirectory, "DeleteDirectory"},
- {0x08070142, nullptr, "DeleteDirectoryRecursively"},
+ {0x08070142, DeleteDirectoryRecursively, "DeleteDirectoryRecursively"},
{0x08080202, CreateFile, "CreateFile"},
{0x08090182, CreateDirectory, "CreateDirectory"},
{0x080A0244, RenameDirectory, "RenameDirectory"},
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 02b397eba..c6b80dc50 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -576,6 +576,7 @@ static ResultCode CreateMutex(Handle* out_handle, u32 initial_locked) {
using Kernel::Mutex;
SharedPtr<Mutex> mutex = Mutex::Create(initial_locked != 0);
+ mutex->name = Common::StringFromFormat("mutex-%08x", Core::g_app_core->GetReg(14));
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(mutex)));
LOG_TRACE(Kernel_SVC, "called initial_locked=%s : created handle=0x%08X",
@@ -646,6 +647,7 @@ static ResultCode CreateSemaphore(Handle* out_handle, s32 initial_count, s32 max
using Kernel::Semaphore;
CASCADE_RESULT(SharedPtr<Semaphore> semaphore, Semaphore::Create(initial_count, max_count));
+ semaphore->name = Common::StringFromFormat("semaphore-%08x", Core::g_app_core->GetReg(14));
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(semaphore)));
LOG_TRACE(Kernel_SVC, "called initial_count=%d, max_count=%d, created handle=0x%08X",
@@ -702,6 +704,7 @@ static ResultCode CreateEvent(Handle* out_handle, u32 reset_type) {
using Kernel::Event;
SharedPtr<Event> evt = Event::Create(static_cast<Kernel::ResetType>(reset_type));
+ evt->name = Common::StringFromFormat("event-%08x", Core::g_app_core->GetReg(14));
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(evt)));
LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type,
@@ -748,6 +751,7 @@ static ResultCode CreateTimer(Handle* out_handle, u32 reset_type) {
using Kernel::Timer;
SharedPtr<Timer> timer = Timer::Create(static_cast<Kernel::ResetType>(reset_type));
+ timer->name = Common::StringFromFormat("timer-%08x", Core::g_app_core->GetReg(14));
CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(std::move(timer)));
LOG_TRACE(Kernel_SVC, "called reset_type=0x%08X : created handle=0x%08X", reset_type,
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp
index 0e6b91e3a..28cb97d8e 100644
--- a/src/core/hw/gpu.cpp
+++ b/src/core/hw/gpu.cpp
@@ -80,6 +80,319 @@ static Math::Vec4<u8> DecodePixel(Regs::PixelFormat input_format, const u8* src_
MICROPROFILE_DEFINE(GPU_DisplayTransfer, "GPU", "DisplayTransfer", MP_RGB(100, 100, 255));
MICROPROFILE_DEFINE(GPU_CmdlistProcessing, "GPU", "Cmdlist Processing", MP_RGB(100, 255, 100));
+static void MemoryFill(const Regs::MemoryFillConfig& config) {
+ const PAddr start_addr = config.GetStartAddress();
+ const PAddr end_addr = config.GetEndAddress();
+
+ // TODO: do hwtest with these cases
+ if (!Memory::IsValidPhysicalAddress(start_addr)) {
+ LOG_CRITICAL(HW_GPU, "invalid start address 0x%08X", start_addr);
+ return;
+ }
+
+ if (!Memory::IsValidPhysicalAddress(end_addr)) {
+ LOG_CRITICAL(HW_GPU, "invalid end address 0x%08X", end_addr);
+ return;
+ }
+
+ if (end_addr <= start_addr) {
+ LOG_CRITICAL(HW_GPU, "invalid memory range from 0x%08X to 0x%08X", start_addr, end_addr);
+ return;
+ }
+
+ u8* start = Memory::GetPhysicalPointer(start_addr);
+ u8* end = Memory::GetPhysicalPointer(end_addr);
+
+ // TODO: Consider always accelerating and returning vector of
+ // regions that the accelerated fill did not cover to
+ // reduce/eliminate the fill that the cpu has to do.
+ // This would also mean that the flush below is not needed.
+ // Fill should first flush all surfaces that touch but are
+ // not completely within the fill range.
+ // Then fill all completely covered surfaces, and return the
+ // regions that were between surfaces or within the touching
+ // ones for cpu to manually fill here.
+ if (VideoCore::g_renderer->Rasterizer()->AccelerateFill(config))
+ return;
+
+ Memory::RasterizerFlushAndInvalidateRegion(config.GetStartAddress(),
+ config.GetEndAddress() - config.GetStartAddress());
+
+ if (config.fill_24bit) {
+ // fill with 24-bit values
+ for (u8* ptr = start; ptr < end; ptr += 3) {
+ ptr[0] = config.value_24bit_r;
+ ptr[1] = config.value_24bit_g;
+ ptr[2] = config.value_24bit_b;
+ }
+ } else if (config.fill_32bit) {
+ // fill with 32-bit values
+ if (end > start) {
+ u32 value = config.value_32bit;
+ size_t len = (end - start) / sizeof(u32);
+ for (size_t i = 0; i < len; ++i)
+ memcpy(&start[i * sizeof(u32)], &value, sizeof(u32));
+ }
+ } else {
+ // fill with 16-bit values
+ u16 value_16bit = config.value_16bit.Value();
+ for (u8* ptr = start; ptr < end; ptr += sizeof(u16))
+ memcpy(ptr, &value_16bit, sizeof(u16));
+ }
+}
+
+static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
+ const PAddr src_addr = config.GetPhysicalInputAddress();
+ const PAddr dst_addr = config.GetPhysicalOutputAddress();
+
+ // TODO: do hwtest with these cases
+ if (!Memory::IsValidPhysicalAddress(src_addr)) {
+ LOG_CRITICAL(HW_GPU, "invalid input address 0x%08X", src_addr);
+ return;
+ }
+
+ if (!Memory::IsValidPhysicalAddress(dst_addr)) {
+ LOG_CRITICAL(HW_GPU, "invalid output address 0x%08X", dst_addr);
+ return;
+ }
+
+ if (config.input_width == 0) {
+ LOG_CRITICAL(HW_GPU, "zero input width");
+ return;
+ }
+
+ if (config.input_height == 0) {
+ LOG_CRITICAL(HW_GPU, "zero input height");
+ return;
+ }
+
+ if (config.output_width == 0) {
+ LOG_CRITICAL(HW_GPU, "zero output width");
+ return;
+ }
+
+ if (config.output_height == 0) {
+ LOG_CRITICAL(HW_GPU, "zero output height");
+ return;
+ }
+
+ if (VideoCore::g_renderer->Rasterizer()->AccelerateDisplayTransfer(config))
+ return;
+
+ u8* src_pointer = Memory::GetPhysicalPointer(src_addr);
+ u8* dst_pointer = Memory::GetPhysicalPointer(dst_addr);
+
+ if (config.scaling > config.ScaleXY) {
+ LOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode %u",
+ config.scaling.Value());
+ UNIMPLEMENTED();
+ return;
+ }
+
+ if (config.input_linear && config.scaling != config.NoScale) {
+ LOG_CRITICAL(HW_GPU, "Scaling is only implemented on tiled input");
+ UNIMPLEMENTED();
+ return;
+ }
+
+ int horizontal_scale = config.scaling != config.NoScale ? 1 : 0;
+ int vertical_scale = config.scaling == config.ScaleXY ? 1 : 0;
+
+ u32 output_width = config.output_width >> horizontal_scale;
+ u32 output_height = config.output_height >> vertical_scale;
+
+ u32 input_size =
+ config.input_width * config.input_height * GPU::Regs::BytesPerPixel(config.input_format);
+ u32 output_size = output_width * output_height * GPU::Regs::BytesPerPixel(config.output_format);
+
+ Memory::RasterizerFlushRegion(config.GetPhysicalInputAddress(), input_size);
+ Memory::RasterizerFlushAndInvalidateRegion(config.GetPhysicalOutputAddress(), output_size);
+
+ for (u32 y = 0; y < output_height; ++y) {
+ for (u32 x = 0; x < output_width; ++x) {
+ Math::Vec4<u8> src_color;
+
+ // Calculate the [x,y] position of the input image
+ // based on the current output position and the scale
+ u32 input_x = x << horizontal_scale;
+ u32 input_y = y << vertical_scale;
+
+ u32 output_y;
+ if (config.flip_vertically) {
+ // Flip the y value of the output data,
+ // we do this after calculating the [x,y] position of the input image
+ // to account for the scaling options.
+ output_y = output_height - y - 1;
+ } else {
+ output_y = y;
+ }
+
+ u32 dst_bytes_per_pixel = GPU::Regs::BytesPerPixel(config.output_format);
+ u32 src_bytes_per_pixel = GPU::Regs::BytesPerPixel(config.input_format);
+ u32 src_offset;
+ u32 dst_offset;
+
+ if (config.input_linear) {
+ if (!config.dont_swizzle) {
+ // Interpret the input as linear and the output as tiled
+ u32 coarse_y = output_y & ~7;
+ u32 stride = output_width * dst_bytes_per_pixel;
+
+ src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel;
+ dst_offset = VideoCore::GetMortonOffset(x, output_y, dst_bytes_per_pixel) +
+ coarse_y * stride;
+ } else {
+ // Both input and output are linear
+ src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel;
+ dst_offset = (x + output_y * output_width) * dst_bytes_per_pixel;
+ }
+ } else {
+ if (!config.dont_swizzle) {
+ // Interpret the input as tiled and the output as linear
+ u32 coarse_y = input_y & ~7;
+ u32 stride = config.input_width * src_bytes_per_pixel;
+
+ src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) +
+ coarse_y * stride;
+ dst_offset = (x + output_y * output_width) * dst_bytes_per_pixel;
+ } else {
+ // Both input and output are tiled
+ u32 out_coarse_y = output_y & ~7;
+ u32 out_stride = output_width * dst_bytes_per_pixel;
+
+ u32 in_coarse_y = input_y & ~7;
+ u32 in_stride = config.input_width * src_bytes_per_pixel;
+
+ src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) +
+ in_coarse_y * in_stride;
+ dst_offset = VideoCore::GetMortonOffset(x, output_y, dst_bytes_per_pixel) +
+ out_coarse_y * out_stride;
+ }
+ }
+
+ const u8* src_pixel = src_pointer + src_offset;
+ src_color = DecodePixel(config.input_format, src_pixel);
+ if (config.scaling == config.ScaleX) {
+ Math::Vec4<u8> pixel =
+ DecodePixel(config.input_format, src_pixel + src_bytes_per_pixel);
+ src_color = ((src_color + pixel) / 2).Cast<u8>();
+ } else if (config.scaling == config.ScaleXY) {
+ Math::Vec4<u8> pixel1 =
+ DecodePixel(config.input_format, src_pixel + 1 * src_bytes_per_pixel);
+ Math::Vec4<u8> pixel2 =
+ DecodePixel(config.input_format, src_pixel + 2 * src_bytes_per_pixel);
+ Math::Vec4<u8> pixel3 =
+ DecodePixel(config.input_format, src_pixel + 3 * src_bytes_per_pixel);
+ src_color = (((src_color + pixel1) + (pixel2 + pixel3)) / 4).Cast<u8>();
+ }
+
+ u8* dst_pixel = dst_pointer + dst_offset;
+ switch (config.output_format) {
+ case Regs::PixelFormat::RGBA8:
+ Color::EncodeRGBA8(src_color, dst_pixel);
+ break;
+
+ case Regs::PixelFormat::RGB8:
+ Color::EncodeRGB8(src_color, dst_pixel);
+ break;
+
+ case Regs::PixelFormat::RGB565:
+ Color::EncodeRGB565(src_color, dst_pixel);
+ break;
+
+ case Regs::PixelFormat::RGB5A1:
+ Color::EncodeRGB5A1(src_color, dst_pixel);
+ break;
+
+ case Regs::PixelFormat::RGBA4:
+ Color::EncodeRGBA4(src_color, dst_pixel);
+ break;
+
+ default:
+ LOG_ERROR(HW_GPU, "Unknown destination framebuffer format %x",
+ config.output_format.Value());
+ break;
+ }
+ }
+ }
+}
+
+static void TextureCopy(const Regs::DisplayTransferConfig& config) {
+ const PAddr src_addr = config.GetPhysicalInputAddress();
+ const PAddr dst_addr = config.GetPhysicalOutputAddress();
+
+ // TODO: do hwtest with these cases
+ if (!Memory::IsValidPhysicalAddress(src_addr)) {
+ LOG_CRITICAL(HW_GPU, "invalid input address 0x%08X", src_addr);
+ return;
+ }
+
+ if (!Memory::IsValidPhysicalAddress(dst_addr)) {
+ LOG_CRITICAL(HW_GPU, "invalid output address 0x%08X", dst_addr);
+ return;
+ }
+
+ if (config.texture_copy.input_width == 0) {
+ LOG_CRITICAL(HW_GPU, "zero input width");
+ return;
+ }
+
+ if (config.texture_copy.output_width == 0) {
+ LOG_CRITICAL(HW_GPU, "zero output width");
+ return;
+ }
+
+ if (config.texture_copy.size == 0) {
+ LOG_CRITICAL(HW_GPU, "zero size");
+ return;
+ }
+
+ if (VideoCore::g_renderer->Rasterizer()->AccelerateTextureCopy(config))
+ return;
+
+ u8* src_pointer = Memory::GetPhysicalPointer(src_addr);
+ u8* dst_pointer = Memory::GetPhysicalPointer(dst_addr);
+
+ u32 input_width = config.texture_copy.input_width * 16;
+ u32 input_gap = config.texture_copy.input_gap * 16;
+ u32 output_width = config.texture_copy.output_width * 16;
+ u32 output_gap = config.texture_copy.output_gap * 16;
+
+ size_t contiguous_input_size =
+ config.texture_copy.size / input_width * (input_width + input_gap);
+ Memory::RasterizerFlushRegion(config.GetPhysicalInputAddress(),
+ static_cast<u32>(contiguous_input_size));
+
+ size_t contiguous_output_size =
+ config.texture_copy.size / output_width * (output_width + output_gap);
+ Memory::RasterizerFlushAndInvalidateRegion(config.GetPhysicalOutputAddress(),
+ static_cast<u32>(contiguous_output_size));
+
+ u32 remaining_size = config.texture_copy.size;
+ u32 remaining_input = input_width;
+ u32 remaining_output = output_width;
+ while (remaining_size > 0) {
+ u32 copy_size = std::min({remaining_input, remaining_output, remaining_size});
+
+ std::memcpy(dst_pointer, src_pointer, copy_size);
+ src_pointer += copy_size;
+ dst_pointer += copy_size;
+
+ remaining_input -= copy_size;
+ remaining_output -= copy_size;
+ remaining_size -= copy_size;
+
+ if (remaining_input == 0) {
+ remaining_input = input_width;
+ src_pointer += input_gap;
+ }
+ if (remaining_output == 0) {
+ remaining_output = output_width;
+ dst_pointer += output_gap;
+ }
+ }
+}
+
template <typename T>
inline void Write(u32 addr, const T data) {
addr -= HW::VADDR_GPU;
@@ -102,50 +415,13 @@ inline void Write(u32 addr, const T data) {
auto& config = g_regs.memory_fill_config[is_second_filler];
if (config.trigger) {
- if (config.address_start) { // Some games pass invalid values here
- u8* start = Memory::GetPhysicalPointer(config.GetStartAddress());
- u8* end = Memory::GetPhysicalPointer(config.GetEndAddress());
-
- // TODO: Consider always accelerating and returning vector of
- // regions that the accelerated fill did not cover to
- // reduce/eliminate the fill that the cpu has to do.
- // This would also mean that the flush below is not needed.
- // Fill should first flush all surfaces that touch but are
- // not completely within the fill range.
- // Then fill all completely covered surfaces, and return the
- // regions that were between surfaces or within the touching
- // ones for cpu to manually fill here.
- if (!VideoCore::g_renderer->Rasterizer()->AccelerateFill(config)) {
- Memory::RasterizerFlushAndInvalidateRegion(config.GetStartAddress(),
- config.GetEndAddress() -
- config.GetStartAddress());
-
- if (config.fill_24bit) {
- // fill with 24-bit values
- for (u8* ptr = start; ptr < end; ptr += 3) {
- ptr[0] = config.value_24bit_r;
- ptr[1] = config.value_24bit_g;
- ptr[2] = config.value_24bit_b;
- }
- } else if (config.fill_32bit) {
- // fill with 32-bit values
- if (end > start) {
- u32 value = config.value_32bit;
- size_t len = (end - start) / sizeof(u32);
- for (size_t i = 0; i < len; ++i)
- memcpy(&start[i * sizeof(u32)], &value, sizeof(u32));
- }
- } else {
- // fill with 16-bit values
- u16 value_16bit = config.value_16bit.Value();
- for (u8* ptr = start; ptr < end; ptr += sizeof(u16))
- memcpy(ptr, &value_16bit, sizeof(u16));
- }
- }
-
- LOG_TRACE(HW_GPU, "MemoryFill from 0x%08x to 0x%08x", config.GetStartAddress(),
- config.GetEndAddress());
+ MemoryFill(config);
+ LOG_TRACE(HW_GPU, "MemoryFill from 0x%08x to 0x%08x", config.GetStartAddress(),
+ config.GetEndAddress());
+ // It seems that it won't signal interrupt if "address_start" is zero.
+ // TODO: hwtest this
+ if (config.GetStartAddress() != 0) {
if (!is_second_filler) {
GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PSC0);
} else {
@@ -171,207 +447,22 @@ inline void Write(u32 addr, const T data) {
Pica::g_debug_context->OnEvent(Pica::DebugContext::Event::IncomingDisplayTransfer,
nullptr);
- if (!VideoCore::g_renderer->Rasterizer()->AccelerateDisplayTransfer(config)) {
- u8* src_pointer = Memory::GetPhysicalPointer(config.GetPhysicalInputAddress());
- u8* dst_pointer = Memory::GetPhysicalPointer(config.GetPhysicalOutputAddress());
-
- if (config.is_texture_copy) {
- u32 input_width = config.texture_copy.input_width * 16;
- u32 input_gap = config.texture_copy.input_gap * 16;
- u32 output_width = config.texture_copy.output_width * 16;
- u32 output_gap = config.texture_copy.output_gap * 16;
-
- size_t contiguous_input_size =
- config.texture_copy.size / input_width * (input_width + input_gap);
- Memory::RasterizerFlushRegion(config.GetPhysicalInputAddress(),
- static_cast<u32>(contiguous_input_size));
-
- size_t contiguous_output_size =
- config.texture_copy.size / output_width * (output_width + output_gap);
- Memory::RasterizerFlushAndInvalidateRegion(
- config.GetPhysicalOutputAddress(),
- static_cast<u32>(contiguous_output_size));
-
- u32 remaining_size = config.texture_copy.size;
- u32 remaining_input = input_width;
- u32 remaining_output = output_width;
- while (remaining_size > 0) {
- u32 copy_size =
- std::min({remaining_input, remaining_output, remaining_size});
-
- std::memcpy(dst_pointer, src_pointer, copy_size);
- src_pointer += copy_size;
- dst_pointer += copy_size;
-
- remaining_input -= copy_size;
- remaining_output -= copy_size;
- remaining_size -= copy_size;
-
- if (remaining_input == 0) {
- remaining_input = input_width;
- src_pointer += input_gap;
- }
- if (remaining_output == 0) {
- remaining_output = output_width;
- dst_pointer += output_gap;
- }
- }
-
- LOG_TRACE(
- HW_GPU,
- "TextureCopy: 0x%X bytes from 0x%08X(%u+%u)-> 0x%08X(%u+%u), flags 0x%08X",
- config.texture_copy.size, config.GetPhysicalInputAddress(), input_width,
- input_gap, config.GetPhysicalOutputAddress(), output_width, output_gap,
- config.flags);
-
- GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PPF);
- break;
- }
-
- if (config.scaling > config.ScaleXY) {
- LOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode %u",
- config.scaling.Value());
- UNIMPLEMENTED();
- break;
- }
-
- if (config.input_linear && config.scaling != config.NoScale) {
- LOG_CRITICAL(HW_GPU, "Scaling is only implemented on tiled input");
- UNIMPLEMENTED();
- break;
- }
-
- int horizontal_scale = config.scaling != config.NoScale ? 1 : 0;
- int vertical_scale = config.scaling == config.ScaleXY ? 1 : 0;
-
- u32 output_width = config.output_width >> horizontal_scale;
- u32 output_height = config.output_height >> vertical_scale;
-
- u32 input_size = config.input_width * config.input_height *
- GPU::Regs::BytesPerPixel(config.input_format);
- u32 output_size =
- output_width * output_height * GPU::Regs::BytesPerPixel(config.output_format);
-
- Memory::RasterizerFlushRegion(config.GetPhysicalInputAddress(), input_size);
- Memory::RasterizerFlushAndInvalidateRegion(config.GetPhysicalOutputAddress(),
- output_size);
-
- for (u32 y = 0; y < output_height; ++y) {
- for (u32 x = 0; x < output_width; ++x) {
- Math::Vec4<u8> src_color;
-
- // Calculate the [x,y] position of the input image
- // based on the current output position and the scale
- u32 input_x = x << horizontal_scale;
- u32 input_y = y << vertical_scale;
-
- if (config.flip_vertically) {
- // Flip the y value of the output data,
- // we do this after calculating the [x,y] position of the input image
- // to account for the scaling options.
- y = output_height - y - 1;
- }
-
- u32 dst_bytes_per_pixel = GPU::Regs::BytesPerPixel(config.output_format);
- u32 src_bytes_per_pixel = GPU::Regs::BytesPerPixel(config.input_format);
- u32 src_offset;
- u32 dst_offset;
-
- if (config.input_linear) {
- if (!config.dont_swizzle) {
- // Interpret the input as linear and the output as tiled
- u32 coarse_y = y & ~7;
- u32 stride = output_width * dst_bytes_per_pixel;
-
- src_offset =
- (input_x + input_y * config.input_width) * src_bytes_per_pixel;
- dst_offset = VideoCore::GetMortonOffset(x, y, dst_bytes_per_pixel) +
- coarse_y * stride;
- } else {
- // Both input and output are linear
- src_offset =
- (input_x + input_y * config.input_width) * src_bytes_per_pixel;
- dst_offset = (x + y * output_width) * dst_bytes_per_pixel;
- }
- } else {
- if (!config.dont_swizzle) {
- // Interpret the input as tiled and the output as linear
- u32 coarse_y = input_y & ~7;
- u32 stride = config.input_width * src_bytes_per_pixel;
-
- src_offset = VideoCore::GetMortonOffset(input_x, input_y,
- src_bytes_per_pixel) +
- coarse_y * stride;
- dst_offset = (x + y * output_width) * dst_bytes_per_pixel;
- } else {
- // Both input and output are tiled
- u32 out_coarse_y = y & ~7;
- u32 out_stride = output_width * dst_bytes_per_pixel;
-
- u32 in_coarse_y = input_y & ~7;
- u32 in_stride = config.input_width * src_bytes_per_pixel;
-
- src_offset = VideoCore::GetMortonOffset(input_x, input_y,
- src_bytes_per_pixel) +
- in_coarse_y * in_stride;
- dst_offset = VideoCore::GetMortonOffset(x, y, dst_bytes_per_pixel) +
- out_coarse_y * out_stride;
- }
- }
-
- const u8* src_pixel = src_pointer + src_offset;
- src_color = DecodePixel(config.input_format, src_pixel);
- if (config.scaling == config.ScaleX) {
- Math::Vec4<u8> pixel =
- DecodePixel(config.input_format, src_pixel + src_bytes_per_pixel);
- src_color = ((src_color + pixel) / 2).Cast<u8>();
- } else if (config.scaling == config.ScaleXY) {
- Math::Vec4<u8> pixel1 = DecodePixel(
- config.input_format, src_pixel + 1 * src_bytes_per_pixel);
- Math::Vec4<u8> pixel2 = DecodePixel(
- config.input_format, src_pixel + 2 * src_bytes_per_pixel);
- Math::Vec4<u8> pixel3 = DecodePixel(
- config.input_format, src_pixel + 3 * src_bytes_per_pixel);
- src_color = (((src_color + pixel1) + (pixel2 + pixel3)) / 4).Cast<u8>();
- }
-
- u8* dst_pixel = dst_pointer + dst_offset;
- switch (config.output_format) {
- case Regs::PixelFormat::RGBA8:
- Color::EncodeRGBA8(src_color, dst_pixel);
- break;
-
- case Regs::PixelFormat::RGB8:
- Color::EncodeRGB8(src_color, dst_pixel);
- break;
-
- case Regs::PixelFormat::RGB565:
- Color::EncodeRGB565(src_color, dst_pixel);
- break;
-
- case Regs::PixelFormat::RGB5A1:
- Color::EncodeRGB5A1(src_color, dst_pixel);
- break;
-
- case Regs::PixelFormat::RGBA4:
- Color::EncodeRGBA4(src_color, dst_pixel);
- break;
-
- default:
- LOG_ERROR(HW_GPU, "Unknown destination framebuffer format %x",
- config.output_format.Value());
- break;
- }
- }
- }
-
- LOG_TRACE(HW_GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> "
+ if (config.is_texture_copy) {
+ TextureCopy(config);
+ LOG_TRACE(HW_GPU, "TextureCopy: 0x%X bytes from 0x%08X(%u+%u)-> "
+ "0x%08X(%u+%u), flags 0x%08X",
+ config.texture_copy.size, config.GetPhysicalInputAddress(),
+ config.texture_copy.input_width * 16, config.texture_copy.input_gap * 16,
+ config.GetPhysicalOutputAddress(), config.texture_copy.output_width * 16,
+ config.texture_copy.output_gap * 16, config.flags);
+ } else {
+ DisplayTransfer(config);
+ LOG_TRACE(HW_GPU, "DisplayTransfer: 0x%08x(%ux%u)-> "
"0x%08x(%ux%u), dst format %x, flags 0x%08X",
- config.output_height * output_width *
- GPU::Regs::BytesPerPixel(config.output_format),
config.GetPhysicalInputAddress(), config.input_width.Value(),
config.input_height.Value(), config.GetPhysicalOutputAddress(),
- output_width, output_height, config.output_format.Value(), config.flags);
+ config.output_width.Value(), config.output_height.Value(),
+ config.output_format.Value(), config.flags);
}
g_regs.display_transfer_config.trigger = 0;
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index df029d655..64c388374 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -251,6 +251,9 @@ bool IsValidVirtualAddress(const VAddr vaddr) {
if (page_pointer)
return true;
+ if (current_page_table->attributes[vaddr >> PAGE_BITS] == PageType::RasterizerCachedMemory)
+ return true;
+
if (current_page_table->attributes[vaddr >> PAGE_BITS] != PageType::Special)
return false;
diff --git a/src/video_core/rasterizer_interface.h b/src/video_core/rasterizer_interface.h
index 71df233b5..8ef7e74c7 100644
--- a/src/video_core/rasterizer_interface.h
+++ b/src/video_core/rasterizer_interface.h
@@ -42,11 +42,16 @@ public:
/// and invalidated
virtual void FlushAndInvalidateRegion(PAddr addr, u32 size) = 0;
- /// Attempt to use a faster method to perform a display transfer
+ /// Attempt to use a faster method to perform a display transfer with is_texture_copy = 0
virtual bool AccelerateDisplayTransfer(const GPU::Regs::DisplayTransferConfig& config) {
return false;
}
+ /// Attempt to use a faster method to perform a display transfer with is_texture_copy = 1
+ virtual bool AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config) {
+ return false;
+ }
+
/// Attempt to use a faster method to fill a region
virtual bool AccelerateFill(const GPU::Regs::MemoryFillConfig& config) {
return false;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 62c9af28c..7cc3b407a 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -709,11 +709,6 @@ bool RasterizerOpenGL::AccelerateDisplayTransfer(const GPU::Regs::DisplayTransfe
using PixelFormat = CachedSurface::PixelFormat;
using SurfaceType = CachedSurface::SurfaceType;
- if (config.is_texture_copy) {
- // TODO(tfarley): Try to hardware accelerate this
- return false;
- }
-
CachedSurface src_params;
src_params.addr = config.GetPhysicalInputAddress();
src_params.width = config.output_width;
@@ -768,6 +763,11 @@ bool RasterizerOpenGL::AccelerateDisplayTransfer(const GPU::Regs::DisplayTransfe
return true;
}
+bool RasterizerOpenGL::AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config) {
+ // TODO(tfarley): Try to hardware accelerate this
+ return false;
+}
+
bool RasterizerOpenGL::AccelerateFill(const GPU::Regs::MemoryFillConfig& config) {
using PixelFormat = CachedSurface::PixelFormat;
using SurfaceType = CachedSurface::SurfaceType;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 7b4ce2ac5..e1a9cb361 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -238,6 +238,7 @@ public:
void FlushRegion(PAddr addr, u32 size) override;
void FlushAndInvalidateRegion(PAddr addr, u32 size) override;
bool AccelerateDisplayTransfer(const GPU::Regs::DisplayTransferConfig& config) override;
+ bool AccelerateTextureCopy(const GPU::Regs::DisplayTransferConfig& config) override;
bool AccelerateFill(const GPU::Regs::MemoryFillConfig& config) override;
bool AccelerateDisplay(const GPU::Regs::FramebufferConfig& config, PAddr framebuffer_addr,
u32 pixel_stride, ScreenInfo& screen_info) override;