diff options
82 files changed, 554 insertions, 653 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ebffc0d85..fa6463b01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,20 +2,67 @@ # dependent libraries. cmake_minimum_required(VERSION 2.8.11) +function(download_bundled_external remote_path lib_name prefix_var) + set(prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}") + if (NOT EXISTS "${prefix}") + message(STATUS "Downloading binaries for ${lib_name}...") + file(DOWNLOAD + https://github.com/citra-emu/ext-windows-bin/raw/master/${remote_path}${lib_name}.7z + "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals") + endif() + message(STATUS "Using bundled binaries at ${prefix}") + set(${prefix_var} "${prefix}" PARENT_SCOPE) +endfunction() + +include(CheckSymbolExists) +function(detect_architecture symbol arch) + if (NOT DEFINED ARCHITECTURE) + set(CMAKE_REQUIRED_QUIET 1) + check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch}) + unset(CMAKE_REQUIRED_QUIET) + + # The output variable needs to be unique across invocations otherwise + # CMake's crazy scope rules will keep it defined + if (ARCHITECTURE_${arch}) + set(ARCHITECTURE "${arch}" PARENT_SCOPE) + set(ARCHITECTURE_${arch} 1 PARENT_SCOPE) + add_definitions(-DARCHITECTURE_${arch}=1) + endif() + endif() +endfunction() + project(citra) +option(ENABLE_GLFW "Enable the GLFW frontend" ON) +option(CITRA_USE_BUNDLED_GLFW "Download bundled GLFW binaries" OFF) + +option(ENABLE_QT "Enable the Qt frontend" ON) +option(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF) +option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF) + if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit) message(STATUS "Copying pre-commit hook") file(COPY hooks/pre-commit DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks) endif() -# Platform-agnostic definition to check if we are on x86_64 -if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "[xX]86_64" OR - ${CMAKE_SYSTEM_PROCESSOR} MATCHES "[aA][mM][dD]64") - set(ARCHITECTURE_x86_64 1) - add_definitions(-DARCHITECTURE_x86_64=1) +if (MSVC) + detect_architecture("_M_AMD64" x86_64) + detect_architecture("_M_IX86" x86) + detect_architecture("_M_ARM" ARM) +else() + detect_architecture("__x86_64__" x86_64) + detect_architecture("__i386__" x86) + detect_architecture("__arm__" ARM) +endif() +if (NOT DEFINED ARCHITECTURE) + set(ARCHITECTURE "GENERIC") + set(ARCHITECTURE_GENERIC 1) + add_definitions(-DARCHITECTURE_GENERIC=1) endif() +message(STATUS "Target architecture: ${ARCHITECTURE}") if (NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") @@ -75,7 +122,7 @@ else() message(STATUS "libpng not found. Some debugging features have been disabled.") endif() -find_package(Boost 1.57.0) +find_package(Boost 1.57.0 QUIET) if (Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) else() @@ -89,60 +136,28 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules") find_package(OpenGL REQUIRED) include_directories(${OPENGL_INCLUDE_DIR}) -option(ENABLE_GLFW "Enable the GLFW frontend" ON) if (ENABLE_GLFW) - if (WIN32) + if (CITRA_USE_BUNDLED_GLFW) # Detect toolchain and platform - if (MSVC) - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(TMP_ARCH "x64") - elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) - set(TMP_ARCH "Win32") - else() - set(TMP_ARCH "UNKNOWN") - message(SEND_ERROR "Couldn't detect your compiler's architecture, you'll have to manually specify the GLFW library to use. (Try checking CMakeOutput.log to find out why.)") - endif() - - if (MSVC11) # Visual C++ 2012 - set(TMP_TOOLSET "v110") - elseif (MSVC12) # Visual C++ 2013 - set(TMP_TOOLSET "v120") - else() - set(TMP_TOOLSET "UNSUPPORTED") - message(SEND_ERROR "We don't supply GLFW binaries for your version of MSVC, you might have to provide them yourself.") - endif() - - set(TMP_TOOLSET "msvc_${TMP_TOOLSET}-${TMP_ARCH}") + if (MSVC14 AND ARCHITECTURE_x86_64) + set(GLFW_VER "glfw-3.1.1-msvc2015_64") + elseif (MSVC12 AND ARCHITECTURE_x86_64) + set(GLFW_VER "glfw-3.1.1-msvc2013_64") else() - # Assume mingw - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set(TMP_ARCH "x86_64") - elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) - set(TMP_ARCH "i686") - else() - set(TMP_ARCH "UNKNOWN") - message(SEND_ERROR "Couldn't detect your compiler's architecture, you'll have to manually specify the GLFW library to use.") - endif() - - set(TMP_TOOLSET "mingw-${TMP_ARCH}") + message(FATAL_ERROR "No bundled GLFW binaries for your toolchain. Disable CITRA_USE_BUNDLED_GLFW and provide your own.") endif() - set(GLFW_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/glfw-3.1.1.bin") - set(GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers") - set(GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib-${TMP_TOOLSET}" CACHE PATH "Path to GLFW3 libraries") - - # Clean up after ourselves - unset(TMP_TOOLSET) - unset(TMP_ARCH) + if (DEFINED GLFW_VER) + download_bundled_external("glfw/" ${GLFW_VER} GLFW_PREFIX) + endif() + set(GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers") + set(GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib" CACHE PATH "Path to GLFW3 libraries") set(GLFW_LIBRARIES glfw3) else() find_package(PkgConfig REQUIRED) pkg_search_module(GLFW REQUIRED glfw3) endif() - - include_directories(${GLFW_INCLUDE_DIRS}) - link_directories(${GLFW_LIBRARY_DIRS}) endif() IF (APPLE) @@ -166,23 +181,33 @@ ELSE() set(PLATFORM_LIBRARIES rt) ENDIF (APPLE) -option(ENABLE_QT "Enable the Qt frontend" ON) -option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF) if (ENABLE_QT) - # Set CMAKE_PREFIX_PATH if QTDIR is defined in the environment This allows CMake to - # automatically find the Qt packages on Windows - if (DEFINED ENV{QTDIR}) - list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}") + if (CITRA_USE_BUNDLED_QT) + if (MSVC14 AND ARCHITECTURE_x86_64) + set(QT_VER qt-5.5-msvc2015_64) + else() + message(FATAL_ERROR "No bundled Qt binaries for your toolchain. Disable CITRA_USE_BUNDLED_QT and provide your own.") + endif() + + if (DEFINED QT_VER) + download_bundled_external("qt/" ${QT_VER} QT_PREFIX) + endif() + + set(QT_PREFIX_HINT HINTS "${QT_PREFIX}") + else() + # Passing an empty HINTS seems to cause default system paths to get ignored in CMake 2.8 so + # make sure to not pass anything if we don't have one. + set(QT_PREFIX_HINT) endif() if (NOT CITRA_FORCE_QT4) - find_package(Qt5 COMPONENTS Widgets OpenGL) + find_package(Qt5 COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT}) set(CITRA_QT_LIBS Qt5::Widgets Qt5::OpenGL) endif() if (CITRA_FORCE_QT4 OR NOT Qt5_FOUND) # Try to fallback to Qt4 - find_package(Qt4 REQUIRED COMPONENTS QtGui QtOpenGL) + find_package(Qt4 REQUIRED COMPONENTS QtGui QtOpenGL ${QT_PREFIX_HINT}) set(CITRA_QT_LIBS Qt4::QtGui Qt4::QtOpenGL) endif() endif() diff --git a/appveyor.yml b/appveyor.yml index 5dc147639..6e073ece7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -18,7 +18,7 @@ install: before_build: - mkdir build - cd build - - cmake -G "Visual Studio 12 Win64" .. + - cmake -G "Visual Studio 12 Win64" -DCITRA_USE_BUNDLED_GLFW=1 -DQt5_DIR=%QTDIR%/lib/cmake/Qt5 .. - cd .. after_build: diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index beb96bd30..e7f8a17f9 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -13,6 +13,9 @@ set(HEADERS create_directory_groups(${SRCS} ${HEADERS}) +include_directories(${GLFW_INCLUDE_DIRS}) +link_directories(${GLFW_LIBRARY_DIRS}) + add_executable(citra ${SRCS} ${HEADERS}) target_link_libraries(citra core video_core common) target_link_libraries(citra ${GLFW_LIBRARIES} ${OPENGL_gl_LIBRARY} inih glad) diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 2aab343f2..7a1360d34 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -1,6 +1,6 @@ +#include <QApplication> #include <QHBoxLayout> #include <QKeyEvent> -#include <QApplication> #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // Required for screen DPI information @@ -8,23 +8,19 @@ #include <QWindow> #endif -#include "bootmanager.h" -#include "main.h" +#include "citra_qt/bootmanager.h" -#include "common/string_util.h" -#include "common/scm_rev.h" #include "common/key_map.h" #include "common/microprofile.h" +#include "common/scm_rev.h" +#include "common/string_util.h" #include "core/core.h" #include "core/settings.h" #include "core/system.h" -#include "video_core/debug_utils/debug_utils.h" - #include "video_core/video_core.h" - -#include "citra_qt/version.h" +#include "video_core/debug_utils/debug_utils.h" #define APP_NAME "citra" #define APP_VERSION "0.1-" VERSION diff --git a/src/citra_qt/bootmanager.h b/src/citra_qt/bootmanager.h index d0fe397af..dc422358e 100644 --- a/src/citra_qt/bootmanager.h +++ b/src/citra_qt/bootmanager.h @@ -6,8 +6,8 @@ #include <condition_variable> #include <mutex> -#include <QThread> #include <QGLWidget> +#include <QThread> #include "common/emu_window.h" #include "common/thread.h" diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index a20351fb8..1f4981ce1 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -6,10 +6,10 @@ #include <QString> #include <QStringList> -#include "core/settings.h" -#include "common/file_util.h" +#include "citra_qt/config.h" -#include "config.h" +#include "common/file_util.h" +#include "core/settings.h" Config::Config() { diff --git a/src/citra_qt/debugger/callstack.cpp b/src/citra_qt/debugger/callstack.cpp index e97e81b65..d45eed179 100644 --- a/src/citra_qt/debugger/callstack.cpp +++ b/src/citra_qt/debugger/callstack.cpp @@ -4,14 +4,14 @@ #include <QStandardItemModel> +#include "citra_qt/debugger/callstack.h" + #include "common/common_types.h" #include "common/symbols.h" -#include "callstack.h" - #include "core/core.h" -#include "core/arm/arm_interface.h" #include "core/memory.h" +#include "core/arm/arm_interface.h" #include "core/arm/disassembler/arm_disasm.h" CallstackWidget::CallstackWidget(QWidget* parent): QDockWidget(parent) diff --git a/src/citra_qt/debugger/callstack.h b/src/citra_qt/debugger/callstack.h index 1a9b6dc81..7aa83db1e 100644 --- a/src/citra_qt/debugger/callstack.h +++ b/src/citra_qt/debugger/callstack.h @@ -12,7 +12,7 @@ class CallstackWidget : public QDockWidget Q_OBJECT public: - CallstackWidget(QWidget* parent = 0); + CallstackWidget(QWidget* parent = nullptr); public slots: void OnDebugModeEntered(); diff --git a/src/citra_qt/debugger/disassembler.cpp b/src/citra_qt/debugger/disassembler.cpp index d3629bbf6..d4f72809d 100644 --- a/src/citra_qt/debugger/disassembler.cpp +++ b/src/citra_qt/debugger/disassembler.cpp @@ -4,20 +4,19 @@ #include <QShortcut> -#include "disassembler.h" +#include "citra_qt/bootmanager.h" +#include "citra_qt/hotkeys.h" +#include "citra_qt/debugger/disassembler.h" +#include "citra_qt/util/util.h" -#include "../bootmanager.h" -#include "../hotkeys.h" - -#include "core/memory.h" - -#include "core/core.h" #include "common/break_points.h" #include "common/symbols.h" + +#include "core/core.h" +#include "core/memory.h" #include "core/arm/arm_interface.h" #include "core/arm/disassembler/arm_disasm.h" - DisassemblerModel::DisassemblerModel(QObject* parent) : QAbstractListModel(parent), base_address(0), code_size(0), program_counter(0), selection(QModelIndex()) { } @@ -78,6 +77,14 @@ QVariant DisassemblerModel::data(const QModelIndex& index, int role) const { break; } + case Qt::FontRole: + { + if (index.column() == 0 || index.column() == 1) { // 2 is the symbols column + return GetMonospaceFont(); + } + break; + } + default: break; } diff --git a/src/citra_qt/debugger/graphics.cpp b/src/citra_qt/debugger/graphics.cpp index 7d15028f0..8008f914c 100644 --- a/src/citra_qt/debugger/graphics.cpp +++ b/src/citra_qt/debugger/graphics.cpp @@ -2,11 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "graphics.h" #include <QListView> -#include <QVBoxLayout> -#include <QDebug> +#include "citra_qt/debugger/graphics.h" #include "citra_qt/util/util.h" extern GraphicsDebugger g_debugger; diff --git a/src/citra_qt/debugger/graphics.h b/src/citra_qt/debugger/graphics.h index 8119b4c87..36b25b81d 100644 --- a/src/citra_qt/debugger/graphics.h +++ b/src/citra_qt/debugger/graphics.h @@ -37,7 +37,7 @@ class GPUCommandStreamWidget : public QDockWidget Q_OBJECT public: - GPUCommandStreamWidget(QWidget* parent = 0); + GPUCommandStreamWidget(QWidget* parent = nullptr); private: }; diff --git a/src/citra_qt/debugger/graphics_breakpoint_observer.cpp b/src/citra_qt/debugger/graphics_breakpoint_observer.cpp index 10ac1ebad..f134eef63 100644 --- a/src/citra_qt/debugger/graphics_breakpoint_observer.cpp +++ b/src/citra_qt/debugger/graphics_breakpoint_observer.cpp @@ -4,7 +4,7 @@ #include <QMetaType> -#include "graphics_breakpoint_observer.h" +#include "citra_qt/debugger/graphics_breakpoint_observer.h" BreakPointObserverDock::BreakPointObserverDock(std::shared_ptr<Pica::DebugContext> debug_context, const QString& title, QWidget* parent) diff --git a/src/citra_qt/debugger/graphics_breakpoints.cpp b/src/citra_qt/debugger/graphics_breakpoints.cpp index 5202c168c..819ec7707 100644 --- a/src/citra_qt/debugger/graphics_breakpoints.cpp +++ b/src/citra_qt/debugger/graphics_breakpoints.cpp @@ -2,16 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <QLabel> #include <QMetaType> #include <QPushButton> #include <QTreeView> #include <QVBoxLayout> -#include <QLabel> -#include "common/assert.h" +#include "citra_qt/debugger/graphics_breakpoints.h" +#include "citra_qt/debugger/graphics_breakpoints_p.h" -#include "graphics_breakpoints.h" -#include "graphics_breakpoints_p.h" +#include "common/assert.h" BreakPointModel::BreakPointModel(std::shared_ptr<Pica::DebugContext> debug_context, QObject* parent) : QAbstractListModel(parent), context_weak(debug_context), diff --git a/src/citra_qt/debugger/graphics_breakpoints.h b/src/citra_qt/debugger/graphics_breakpoints.h index d900729da..2371b0e39 100644 --- a/src/citra_qt/debugger/graphics_breakpoints.h +++ b/src/citra_qt/debugger/graphics_breakpoints.h @@ -6,7 +6,6 @@ #include <memory> -#include <QAbstractListModel> #include <QDockWidget> #include "video_core/debug_utils/debug_utils.h" diff --git a/src/citra_qt/debugger/graphics_breakpoints_p.h b/src/citra_qt/debugger/graphics_breakpoints_p.h index 00d8d5101..251114d06 100644 --- a/src/citra_qt/debugger/graphics_breakpoints_p.h +++ b/src/citra_qt/debugger/graphics_breakpoints_p.h @@ -23,7 +23,7 @@ public: int columnCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - Qt::ItemFlags flags(const QModelIndex &index) const; + Qt::ItemFlags flags(const QModelIndex &index) const override; bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override; diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp index 025434687..ab97c8d2d 100644 --- a/src/citra_qt/debugger/graphics_cmdlists.cpp +++ b/src/citra_qt/debugger/graphics_cmdlists.cpp @@ -4,26 +4,24 @@ #include <QApplication> #include <QClipboard> +#include <QComboBox> +#include <QHeaderView> #include <QLabel> #include <QListView> #include <QMainWindow> #include <QPushButton> -#include <QVBoxLayout> -#include <QTreeView> -#include <QHeaderView> #include <QSpinBox> -#include <QComboBox> +#include <QTreeView> +#include <QVBoxLayout> +#include "citra_qt/debugger/graphics_cmdlists.h" +#include "citra_qt/util/spinbox.h" #include "citra_qt/util/util.h" #include "common/vector_math.h" -#include "video_core/debug_utils/debug_utils.h" #include "video_core/pica.h" - -#include "graphics_cmdlists.h" - -#include "util/spinbox.h" +#include "video_core/debug_utils/debug_utils.h" QImage LoadTexture(u8* src, const Pica::DebugUtils::TextureInfo& info) { QImage decoded_image(info.width, info.height, QImage::Format_ARGB32); @@ -359,7 +357,7 @@ void GPUCommandListWidget::CopyAllToClipboard() { QClipboard* clipboard = QApplication::clipboard(); QString text; - QAbstractItemModel* model = static_cast<QAbstractListModel*>(list_widget->model()); + QAbstractItemModel* model = static_cast<QAbstractItemModel*>(list_widget->model()); for (int row = 0; row < model->rowCount({}); ++row) { for (int col = 0; col < model->columnCount({}); ++col) { diff --git a/src/citra_qt/debugger/graphics_cmdlists.h b/src/citra_qt/debugger/graphics_cmdlists.h index 4859b6ec8..586cc7239 100644 --- a/src/citra_qt/debugger/graphics_cmdlists.h +++ b/src/citra_qt/debugger/graphics_cmdlists.h @@ -41,7 +41,7 @@ class GPUCommandListWidget : public QDockWidget Q_OBJECT public: - GPUCommandListWidget(QWidget* parent = 0); + GPUCommandListWidget(QWidget* parent = nullptr); public slots: void OnToggleTracing(); diff --git a/src/citra_qt/debugger/graphics_framebuffer.cpp b/src/citra_qt/debugger/graphics_framebuffer.cpp index 39eefbf75..80b32eaff 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.cpp +++ b/src/citra_qt/debugger/graphics_framebuffer.cpp @@ -9,18 +9,17 @@ #include <QPushButton> #include <QSpinBox> +#include "citra_qt/debugger/graphics_framebuffer.h" +#include "citra_qt/util/spinbox.h" + #include "common/color.h" -#include "core/hw/gpu.h" #include "core/memory.h" +#include "core/hw/gpu.h" #include "video_core/pica.h" #include "video_core/utils.h" -#include "graphics_framebuffer.h" - -#include "util/spinbox.h" - GraphicsFramebufferWidget::GraphicsFramebufferWidget(std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent) : BreakPointObserverDock(debug_context, tr("Pica Framebuffer"), parent), diff --git a/src/citra_qt/debugger/graphics_framebuffer.h b/src/citra_qt/debugger/graphics_framebuffer.h index e9eae679f..5cd96f2e9 100644 --- a/src/citra_qt/debugger/graphics_framebuffer.h +++ b/src/citra_qt/debugger/graphics_framebuffer.h @@ -4,9 +4,7 @@ #pragma once -#include <QDockWidget> - -#include "graphics_breakpoint_observer.h" +#include "citra_qt/debugger/graphics_breakpoint_observer.h" class QComboBox; class QLabel; diff --git a/src/citra_qt/debugger/graphics_tracing.cpp b/src/citra_qt/debugger/graphics_tracing.cpp index f80cb7493..b0bc782df 100644 --- a/src/citra_qt/debugger/graphics_tracing.cpp +++ b/src/citra_qt/debugger/graphics_tracing.cpp @@ -4,26 +4,25 @@ #include <memory> +#include <boost/range/algorithm/copy.hpp> + #include <QBoxLayout> #include <QComboBox> #include <QFileDialog> -#include <QLabel> #include <QMessageBox> #include <QPushButton> -#include <QSpinBox> -#include <boost/range/algorithm/copy.hpp> +#include "citra_qt/debugger/graphics_tracing.h" #include "common/common_types.h" #include "core/hw/gpu.h" #include "core/hw/lcd.h" -#include "video_core/pica.h" - #include "nihstro/float24.h" -#include "graphics_tracing.h" +#include "video_core/pica.h" + GraphicsTracingWidget::GraphicsTracingWidget(std::shared_ptr<Pica::DebugContext> debug_context, QWidget* parent) diff --git a/src/citra_qt/debugger/graphics_tracing.h b/src/citra_qt/debugger/graphics_tracing.h index 2a0e4819b..753dfa914 100644 --- a/src/citra_qt/debugger/graphics_tracing.h +++ b/src/citra_qt/debugger/graphics_tracing.h @@ -4,7 +4,7 @@ #pragma once -#include "graphics_breakpoint_observer.h" +#include "citra_qt/debugger/graphics_breakpoint_observer.h" class EmuThread; diff --git a/src/citra_qt/debugger/graphics_vertex_shader.cpp b/src/citra_qt/debugger/graphics_vertex_shader.cpp index 1d9a00e89..f915d2bab 100644 --- a/src/citra_qt/debugger/graphics_vertex_shader.cpp +++ b/src/citra_qt/debugger/graphics_vertex_shader.cpp @@ -7,6 +7,7 @@ #include <QBoxLayout> #include <QFileDialog> +#include <QFormLayout> #include <QGroupBox> #include <QLabel> #include <QLineEdit> @@ -15,27 +16,18 @@ #include <QSpinBox> #include <QTreeView> +#include "citra_qt/debugger/graphics_vertex_shader.h" #include "citra_qt/util/util.h" #include "video_core/shader/shader.h" -#include "graphics_vertex_shader.h" - using nihstro::OpCode; using nihstro::Instruction; using nihstro::SourceRegister; using nihstro::SwizzlePattern; -GraphicsVertexShaderModel::GraphicsVertexShaderModel(GraphicsVertexShaderWidget* parent): QAbstractItemModel(parent), par(parent) { - -} +GraphicsVertexShaderModel::GraphicsVertexShaderModel(GraphicsVertexShaderWidget* parent): QAbstractTableModel(parent), par(parent) { -QModelIndex GraphicsVertexShaderModel::index(int row, int column, const QModelIndex& parent) const { - return createIndex(row, column); -} - -QModelIndex GraphicsVertexShaderModel::parent(const QModelIndex& child) const { - return QModelIndex(); } int GraphicsVertexShaderModel::columnCount(const QModelIndex& parent) const { @@ -65,6 +57,28 @@ QVariant GraphicsVertexShaderModel::headerData(int section, Qt::Orientation orie return QVariant(); } +static std::string SelectorToString(u32 selector) { + std::string ret; + for (int i = 0; i < 4; ++i) { + int component = (selector >> ((3 - i) * 2)) & 3; + ret += "xyzw"[component]; + } + return ret; +} + +// e.g. "-c92[a0.x].xyzw" +static void print_input(std::ostringstream& output, const SourceRegister& input, + bool negate, const std::string& swizzle_mask, bool align = true, + const std::string& address_register_name = std::string()) { + if (align) + output << std::setw(4) << std::right; + output << ((negate ? "-" : "") + input.GetName()); + + if (!address_register_name.empty()) + output << '[' << address_register_name << ']'; + output << '.' << swizzle_mask; +}; + QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) const { switch (role) { case Qt::DisplayRole: @@ -81,102 +95,120 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con case 2: { - std::stringstream output; - output.flags(std::ios::hex); - - Instruction instr = par->info.code[index.row()]; - const SwizzlePattern& swizzle = par->info.swizzle_info[instr.common.operand_desc_id].pattern; - - // longest known instruction name: "setemit " - output << std::setw(8) << std::left << instr.opcode.Value().GetInfo().name; - - // e.g. "-c92.xyzw" - static auto print_input = [](std::stringstream& output, const SourceRegister& input, - bool negate, const std::string& swizzle_mask) { - output << std::setw(4) << std::right << (negate ? "-" : "") + input.GetName(); - output << "." << swizzle_mask; + std::ostringstream output; + output.flags(std::ios::uppercase); + + // To make the code aligning columns of assembly easier to keep track of, this function + // keeps track of the start of the start of the previous column, allowing alignment + // based on desired field widths. + int current_column = 0; + auto AlignToColumn = [&](int col_width) { + // Prints spaces to the output to pad previous column to size and advances the + // column marker. + current_column += col_width; + int to_add = std::max(1, current_column - (int)output.tellp()); + for (int i = 0; i < to_add; ++i) { + output << ' '; + } }; - // e.g. "-c92[a0.x].xyzw" - static auto print_input_indexed = [](std::stringstream& output, const SourceRegister& input, - bool negate, const std::string& swizzle_mask, - const std::string& address_register_name) { - std::string relative_address; - if (!address_register_name.empty()) - relative_address = "[" + address_register_name + "]"; + const Instruction instr = par->info.code[index.row()]; + const OpCode opcode = instr.opcode; + const OpCode::Info opcode_info = opcode.GetInfo(); + const u32 operand_desc_id = opcode_info.type == OpCode::Type::MultiplyAdd ? + instr.mad.operand_desc_id.Value() : instr.common.operand_desc_id.Value(); + const SwizzlePattern swizzle = par->info.swizzle_info[operand_desc_id].pattern; - output << std::setw(10) << std::right << (negate ? "-" : "") + input.GetName() + relative_address; - output << "." << swizzle_mask; - }; + // longest known instruction name: "setemit " + int kOpcodeColumnWidth = 8; + // "rXX.xyzw " + int kOutputColumnWidth = 10; + // "-rXX.xyzw ", no attempt is made to align indexed inputs + int kInputOperandColumnWidth = 11; - // Use print_input or print_input_indexed depending on whether relative addressing is used or not. - static auto print_input_indexed_compact = [](std::stringstream& output, const SourceRegister& input, - bool negate, const std::string& swizzle_mask, - const std::string& address_register_name) { - if (address_register_name.empty()) - print_input(output, input, negate, swizzle_mask); - else - print_input_indexed(output, input, negate, swizzle_mask, address_register_name); - }; + output << opcode_info.name; - switch (instr.opcode.Value().GetInfo().type) { + switch (opcode_info.type) { case OpCode::Type::Trivial: // Nothing to do here break; case OpCode::Type::Arithmetic: + case OpCode::Type::MultiplyAdd: { // Use custom code for special instructions - switch (instr.opcode.Value().EffectiveOpCode()) { + switch (opcode.EffectiveOpCode()) { case OpCode::Id::CMP: { + AlignToColumn(kOpcodeColumnWidth); + // NOTE: CMP always writes both cc components, so we do not consider the dest mask here. - output << std::setw(4) << std::right << "cc."; - output << "xy "; + output << " cc.xy"; + AlignToColumn(kOutputColumnWidth); SourceRegister src1 = instr.common.GetSrc1(false); SourceRegister src2 = instr.common.GetSrc2(false); - print_input_indexed_compact(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false).substr(0,1), instr.common.AddressRegisterName()); - output << " " << instr.common.compare_op.ToString(instr.common.compare_op.x) << " "; - print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true).substr(0,1)); + output << ' '; + print_input(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false).substr(0,1), false, instr.common.AddressRegisterName()); + output << ' ' << instr.common.compare_op.ToString(instr.common.compare_op.x) << ' '; + print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true).substr(0,1), false); output << ", "; - print_input_indexed_compact(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false).substr(1,1), instr.common.AddressRegisterName()); - output << " " << instr.common.compare_op.ToString(instr.common.compare_op.y) << " "; - print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true).substr(1,1)); + print_input(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false).substr(1,1), false, instr.common.AddressRegisterName()); + output << ' ' << instr.common.compare_op.ToString(instr.common.compare_op.y) << ' '; + print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true).substr(1,1), false); break; } + case OpCode::Id::MAD: + case OpCode::Id::MADI: + { + AlignToColumn(kOpcodeColumnWidth); + + bool src_is_inverted = 0 != (opcode_info.subtype & OpCode::Info::SrcInversed); + SourceRegister src1 = instr.mad.GetSrc1(src_is_inverted); + SourceRegister src2 = instr.mad.GetSrc2(src_is_inverted); + SourceRegister src3 = instr.mad.GetSrc3(src_is_inverted); + + output << std::setw(3) << std::right << instr.mad.dest.Value().GetName() << '.' << swizzle.DestMaskToString(); + AlignToColumn(kOutputColumnWidth); + print_input(output, src1, swizzle.negate_src1, SelectorToString(swizzle.src1_selector)); + AlignToColumn(kInputOperandColumnWidth); + print_input(output, src2, swizzle.negate_src2, SelectorToString(swizzle.src2_selector)); + AlignToColumn(kInputOperandColumnWidth); + print_input(output, src3, swizzle.negate_src3, SelectorToString(swizzle.src3_selector)); + AlignToColumn(kInputOperandColumnWidth); + break; + } + default: { - bool src_is_inverted = 0 != (instr.opcode.Value().GetInfo().subtype & OpCode::Info::SrcInversed); + AlignToColumn(kOpcodeColumnWidth); + + bool src_is_inverted = 0 != (opcode_info.subtype & OpCode::Info::SrcInversed); - if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::Dest) { + if (opcode_info.subtype & OpCode::Info::Dest) { // e.g. "r12.xy__" - output << std::setw(4) << std::right << instr.common.dest.Value().GetName() + "."; - output << swizzle.DestMaskToString(); - } else if (instr.opcode.Value().GetInfo().subtype == OpCode::Info::MOVA) { - output << std::setw(4) << std::right << "a0."; - output << swizzle.DestMaskToString(); - } else { - output << " "; + output << std::setw(3) << std::right << instr.common.dest.Value().GetName() << '.' << swizzle.DestMaskToString(); + } else if (opcode_info.subtype == OpCode::Info::MOVA) { + output << " a0." << swizzle.DestMaskToString(); } - output << " "; + AlignToColumn(kOutputColumnWidth); - if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::Src1) { + if (opcode_info.subtype & OpCode::Info::Src1) { SourceRegister src1 = instr.common.GetSrc1(src_is_inverted); - print_input_indexed(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false), instr.common.AddressRegisterName()); - } else { - output << " "; + print_input(output, src1, swizzle.negate_src1, swizzle.SelectorToString(false), true, instr.common.AddressRegisterName()); + AlignToColumn(kInputOperandColumnWidth); } // TODO: In some cases, the Address Register is used as an index for SRC2 instead of SRC1 - if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::Src2) { + if (opcode_info.subtype & OpCode::Info::Src2) { SourceRegister src2 = instr.common.GetSrc2(src_is_inverted); print_input(output, src2, swizzle.negate_src2, swizzle.SelectorToString(true)); + AlignToColumn(kInputOperandColumnWidth); } break; } @@ -186,46 +218,55 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con } case OpCode::Type::Conditional: + case OpCode::Type::UniformFlowControl: { - switch (instr.opcode.Value().EffectiveOpCode()) { + output << ' '; + + switch (opcode.EffectiveOpCode()) { case OpCode::Id::LOOP: output << "(unknown instruction format)"; break; default: - output << "if "; - - if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasCondition) { - const char* ops[] = { - " || ", " && ", "", "" - }; - if (instr.flow_control.op != instr.flow_control.JustY) - output << ((!instr.flow_control.refx) ? "!" : " ") << "cc.x"; - - output << ops[instr.flow_control.op]; - - if (instr.flow_control.op != instr.flow_control.JustX) - output << ((!instr.flow_control.refy) ? "!" : " ") << "cc.y"; - - output << " "; - } else if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasUniformIndex) { - output << "b" << instr.flow_control.bool_uniform_id << " "; + if (opcode_info.subtype & OpCode::Info::HasCondition) { + output << '('; + + if (instr.flow_control.op != instr.flow_control.JustY) { + if (instr.flow_control.refx) output << '!'; + output << "cc.x"; + } + + if (instr.flow_control.op == instr.flow_control.Or) { + output << " || "; + } else if (instr.flow_control.op == instr.flow_control.And) { + output << " && "; + } + + if (instr.flow_control.op != instr.flow_control.JustX) { + if (instr.flow_control.refy) output << '!'; + output << "cc.y"; + } + + output << ") "; + } else if (opcode_info.subtype & OpCode::Info::HasUniformIndex) { + output << 'b' << instr.flow_control.bool_uniform_id << ' '; } u32 target_addr = instr.flow_control.dest_offset; u32 target_addr_else = instr.flow_control.dest_offset; - if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasAlternative) { - output << "else jump to 0x" << std::setw(4) << std::right << std::setfill('0') << 4 * instr.flow_control.dest_offset << " "; - } else if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasExplicitDest) { - output << "jump to 0x" << std::setw(4) << std::right << std::setfill('0') << 4 * instr.flow_control.dest_offset << " "; + if (opcode_info.subtype & OpCode::Info::HasAlternative) { + output << "else jump to 0x" << std::setw(4) << std::right << std::setfill('0') << std::hex << (4 * instr.flow_control.dest_offset); + } else if (opcode_info.subtype & OpCode::Info::HasExplicitDest) { + output << "jump to 0x" << std::setw(4) << std::right << std::setfill('0') << std::hex << (4 * instr.flow_control.dest_offset); } else { // TODO: Handle other cases + output << "(unknown destination)"; } - if (instr.opcode.Value().GetInfo().subtype & OpCode::Info::HasFinishPoint) { - output << "(return on " << std::setw(4) << std::right << std::setfill('0') - << 4 * instr.flow_control.dest_offset + 4 * instr.flow_control.num_instructions << ")"; + if (opcode_info.subtype & OpCode::Info::HasFinishPoint) { + output << " (return on 0x" << std::setw(4) << std::right << std::setfill('0') << std::hex + << (4 * instr.flow_control.dest_offset + 4 * instr.flow_control.num_instructions) << ')'; } break; @@ -234,7 +275,7 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con } default: - output << "(unknown instruction format)"; + output << " (unknown instruction format)"; break; } @@ -250,12 +291,23 @@ QVariant GraphicsVertexShaderModel::data(const QModelIndex& index, int role) con return GetMonospaceFont(); case Qt::BackgroundRole: - // Highlight instructions which have no debug data associated to them + { + // Highlight current instruction + int current_record_index = par->cycle_index->value(); + if (current_record_index < par->debug_data.records.size()) { + const auto& current_record = par->debug_data.records[current_record_index]; + if (index.row() == current_record.instruction_offset) { + return QColor(255, 255, 63); + } + } + + // Use a grey background for instructions which have no debug data associated to them for (const auto& record : par->debug_data.records) if (index.row() == record.instruction_offset) return QVariant(); - return QBrush(QColor(255, 255, 127)); + return QBrush(QColor(192, 192, 192)); + } // TODO: Draw arrows for each "reachable" instruction to visualize control flow @@ -288,6 +340,13 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De : BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) { setObjectName("PicaVertexShader"); + // Clear input vertex data so that it contains valid float values in case a debug shader + // execution happens before the first Vertex Loaded breakpoint. + // TODO: This makes a crash in the interpreter much less likely, but not impossible. The + // interpreter should guard against out-of-bounds accesses to ensure crashes in it aren't + // possible. + std::memset(&input_vertex, 0, sizeof(input_vertex)); + auto input_data_mapper = new QSignalMapper(this); // TODO: Support inputting data in hexadecimal raw format @@ -312,9 +371,6 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De cycle_index = new QSpinBox; - connect(this, SIGNAL(SelectCommand(const QModelIndex&, QItemSelectionModel::SelectionFlags)), - binary_list->selectionModel(), SLOT(select(const QModelIndex&, QItemSelectionModel::SelectionFlags))); - connect(dump_shader, SIGNAL(clicked()), this, SLOT(DumpShader())); connect(cycle_index, SIGNAL(valueChanged(int)), this, SLOT(OnCycleIndexChanged(int))); @@ -339,6 +395,9 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De // Create an HBoxLayout to store the widgets used to specify a particular attribute // and store it in a QWidget to allow for easy hiding and unhiding. auto row_layout = new QHBoxLayout; + // Remove unecessary padding between rows + row_layout->setContentsMargins(0, 0, 0, 0); + row_layout->addWidget(new QLabel(tr("Attribute %1").arg(i, 2))); for (unsigned comp = 0; comp < 4; ++comp) row_layout->addWidget(input_data[4 * i + comp]); @@ -358,20 +417,25 @@ GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::De input_data_group->setLayout(sub_layout); main_layout->addWidget(input_data_group); } - { - auto sub_layout = new QHBoxLayout; - sub_layout->addWidget(binary_list); - main_layout->addLayout(sub_layout); - } + + // Make program listing expand to fill available space in the dialog + binary_list->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); + main_layout->addWidget(binary_list); + main_layout->addWidget(dump_shader); { - auto sub_layout = new QHBoxLayout; - sub_layout->addWidget(new QLabel(tr("Cycle Index:"))); - sub_layout->addWidget(cycle_index); + auto sub_layout = new QFormLayout; + sub_layout->addRow(tr("Cycle Index:"), cycle_index); + main_layout->addLayout(sub_layout); } + + // Set a minimum height so that the size of this label doesn't cause the rest of the bottom + // part of the UI to keep jumping up and down when cycling through instructions. + instruction_description->setMinimumHeight(instruction_description->fontMetrics().lineSpacing() * 6); + instruction_description->setAlignment(Qt::AlignLeft | Qt::AlignTop); main_layout->addWidget(instruction_description); - main_layout->addStretch(); + main_widget->setLayout(main_layout); setWidget(main_widget); @@ -418,6 +482,7 @@ void GraphicsVertexShaderWidget::Reload(bool replace_vertex_data, void* vertex_d auto& shader_config = Pica::g_state.regs.vs; for (auto instr : shader_setup.program_code) info.code.push_back({instr}); + int num_attributes = Pica::g_state.regs.vertex_attributes.GetNumTotalAttributes(); for (auto pattern : shader_setup.swizzle_data) info.swizzle_info.push_back({pattern}); @@ -426,19 +491,18 @@ void GraphicsVertexShaderWidget::Reload(bool replace_vertex_data, void* vertex_d info.labels.insert({ entry_point, "main" }); // Generate debug information - debug_data = Pica::Shader::ProduceDebugInfo(input_vertex, 1, shader_config, shader_setup); + debug_data = Pica::Shader::ProduceDebugInfo(input_vertex, num_attributes, shader_config, shader_setup); // Reload widget state - - // Only show input attributes which are used as input to the shader - for (unsigned int attr = 0; attr < 16; ++attr) { - input_data_container[attr]->setVisible(false); - } - for (unsigned int attr = 0; attr < Pica::g_state.regs.vertex_attributes.GetNumTotalAttributes(); ++attr) { + for (unsigned int attr = 0; attr < num_attributes; ++attr) { unsigned source_attr = shader_config.input_register_map.GetRegisterForAttribute(attr); input_data_mapping[source_attr]->setText(QString("-> v%1").arg(attr)); input_data_container[source_attr]->setVisible(true); } + // Only show input attributes which are used as input to the shader + for (unsigned int attr = num_attributes; attr < 16; ++attr) { + input_data_container[attr]->setVisible(false); + } // Initialize debug info text for current cycle count cycle_index->setMaximum(debug_data.records.size() - 1); @@ -453,6 +517,8 @@ void GraphicsVertexShaderWidget::OnResumed() { void GraphicsVertexShaderWidget::OnInputAttributeChanged(int index) { float value = input_data[index]->text().toFloat(); + input_vertex.attr[index / 4][index % 4] = Pica::float24::FromFloat32(value); + // Re-execute shader with updated value Reload(); } @@ -492,8 +558,8 @@ void GraphicsVertexShaderWidget::OnCycleIndexChanged(int index) { instruction_description->setText(text); - // Scroll to current instruction - const QModelIndex& instr_index = model->index(record.instruction_offset, 0); - emit SelectCommand(instr_index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); + // Emit model update notification and scroll to current instruction + QModelIndex instr_index = model->index(record.instruction_offset, 0); + emit model->dataChanged(instr_index, model->index(record.instruction_offset, model->columnCount())); binary_list->scrollTo(instr_index, QAbstractItemView::EnsureVisible); } diff --git a/src/citra_qt/debugger/graphics_vertex_shader.h b/src/citra_qt/debugger/graphics_vertex_shader.h index 1b3f1f7ec..7f06f496a 100644 --- a/src/citra_qt/debugger/graphics_vertex_shader.h +++ b/src/citra_qt/debugger/graphics_vertex_shader.h @@ -4,9 +4,9 @@ #pragma once -#include <QAbstractListModel> +#include <QAbstractTableModel> -#include "graphics_breakpoint_observer.h" +#include "citra_qt/debugger/graphics_breakpoint_observer.h" #include "nihstro/parser_shbin.h" @@ -17,14 +17,12 @@ class QSpinBox; class GraphicsVertexShaderWidget; -class GraphicsVertexShaderModel : public QAbstractItemModel { +class GraphicsVertexShaderModel : public QAbstractTableModel { Q_OBJECT public: GraphicsVertexShaderModel(GraphicsVertexShaderWidget* parent); - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; - QModelIndex parent(const QModelIndex& child) const override; int columnCount(const QModelIndex& parent = QModelIndex()) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; @@ -62,11 +60,6 @@ private slots: */ void Reload(bool replace_vertex_data = false, void* vertex_data = nullptr); - -signals: - // Call this to change the current command selection in the disassembly view - void SelectCommand(const QModelIndex&, QItemSelectionModel::SelectionFlags); - private: QLabel* instruction_description; QTreeView* binary_list; diff --git a/src/citra_qt/debugger/profiler.cpp b/src/citra_qt/debugger/profiler.cpp index 5261d4836..4f6ba0e1f 100644 --- a/src/citra_qt/debugger/profiler.cpp +++ b/src/citra_qt/debugger/profiler.cpp @@ -6,12 +6,11 @@ #include <QPainter> #include <QString> -#include "profiler.h" - +#include "citra_qt/debugger/profiler.h" #include "citra_qt/util/util.h" -#include "common/profiler_reporting.h" #include "common/microprofile.h" +#include "common/profiler_reporting.h" // Include the implementation of the UI in this file. This isn't in microprofile.cpp because the // non-Qt frontends don't need it (and don't implement the UI drawing hooks either). @@ -151,7 +150,7 @@ void ProfilerWidget::setProfilingInfoUpdateEnabled(bool enable) class MicroProfileWidget : public QWidget { public: - MicroProfileWidget(QWidget* parent = 0); + MicroProfileWidget(QWidget* parent = nullptr); protected: void paintEvent(QPaintEvent* ev) override; diff --git a/src/citra_qt/debugger/profiler.h b/src/citra_qt/debugger/profiler.h index 2199eaef1..036054740 100644 --- a/src/citra_qt/debugger/profiler.h +++ b/src/citra_qt/debugger/profiler.h @@ -37,7 +37,7 @@ class ProfilerWidget : public QDockWidget Q_OBJECT public: - ProfilerWidget(QWidget* parent = 0); + ProfilerWidget(QWidget* parent = nullptr); private slots: void setProfilingInfoUpdateEnabled(bool enable); @@ -53,7 +53,7 @@ class MicroProfileDialog : public QWidget { Q_OBJECT public: - MicroProfileDialog(QWidget* parent = 0); + MicroProfileDialog(QWidget* parent = nullptr); /// Returns a QAction that can be used to toggle visibility of this dialog. QAction* toggleViewAction(); diff --git a/src/citra_qt/debugger/ramview.cpp b/src/citra_qt/debugger/ramview.cpp index b6ebc7fc4..02347e83a 100644 --- a/src/citra_qt/debugger/ramview.cpp +++ b/src/citra_qt/debugger/ramview.cpp @@ -2,8 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "ramview.h" - +#include "citra_qt/debugger/ramview.h" GRamView::GRamView(QWidget* parent) : QHexEdit(parent) { diff --git a/src/citra_qt/debugger/ramview.h b/src/citra_qt/debugger/ramview.h index 18423036f..0ef74586b 100644 --- a/src/citra_qt/debugger/ramview.h +++ b/src/citra_qt/debugger/ramview.h @@ -9,7 +9,7 @@ class GRamView : public QHexEdit Q_OBJECT public: - GRamView(QWidget* parent = NULL); + GRamView(QWidget* parent = nullptr); public slots: void OnCPUStepped(); diff --git a/src/citra_qt/debugger/registers.cpp b/src/citra_qt/debugger/registers.cpp index 4174b3945..6100d67c5 100644 --- a/src/citra_qt/debugger/registers.cpp +++ b/src/citra_qt/debugger/registers.cpp @@ -2,7 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "registers.h" +#include <QTreeWidgetItem> + +#include "citra_qt/debugger/registers.h" +#include "citra_qt/util/util.h" #include "core/core.h" #include "core/arm/arm_interface.h" @@ -26,9 +29,32 @@ RegistersWidget::RegistersWidget(QWidget* parent) : QDockWidget(parent) { vfp_registers->addChild(child); } + QFont font = GetMonospaceFont(); + CreateCPSRChildren(); CreateVFPSystemRegisterChildren(); + // Set Registers to display in monospace font + for (int i = 0; i < core_registers->childCount(); ++i) + core_registers->child(i)->setFont(1, font); + + for (int i = 0; i < vfp_registers->childCount(); ++i) + vfp_registers->child(i)->setFont(1, font); + + for (int i = 0; i < vfp_system_registers->childCount(); ++i) { + vfp_system_registers->child(i)->setFont(1, font); + for (int x = 0; x < vfp_system_registers->child(i)->childCount(); ++x) { + vfp_system_registers->child(i)->child(x)->setFont(1, font); + } + } + // Set CSPR to display in monospace font + cpsr->setFont(1, font); + for (int i = 0; i < cpsr->childCount(); ++i) { + cpsr->child(i)->setFont(1, font); + for (int x = 0; x < cpsr->child(i)->childCount(); ++x) { + cpsr->child(i)->child(x)->setFont(1, font); + } + } setEnabled(false); } diff --git a/src/citra_qt/debugger/registers.h b/src/citra_qt/debugger/registers.h index 09b830e80..cf27acc1c 100644 --- a/src/citra_qt/debugger/registers.h +++ b/src/citra_qt/debugger/registers.h @@ -5,9 +5,9 @@ #include "ui_registers.h" #include <QDockWidget> -#include <QTreeWidgetItem> class QTreeWidget; +class QTreeWidgetItem; class EmuThread; class RegistersWidget : public QDockWidget @@ -15,7 +15,7 @@ class RegistersWidget : public QDockWidget Q_OBJECT public: - RegistersWidget(QWidget* parent = NULL); + RegistersWidget(QWidget* parent = nullptr); public slots: void OnDebugModeEntered(); diff --git a/src/citra_qt/hotkeys.cpp b/src/citra_qt/hotkeys.cpp index 5ed6cf0b1..ed6b12fc4 100644 --- a/src/citra_qt/hotkeys.cpp +++ b/src/citra_qt/hotkeys.cpp @@ -8,7 +8,7 @@ #include <QSettings> #include <QShortcut> -#include "hotkeys.h" +#include "citra_qt/hotkeys.h" struct Hotkey { diff --git a/src/citra_qt/hotkeys.h b/src/citra_qt/hotkeys.h index 2317f8188..2fe635882 100644 --- a/src/citra_qt/hotkeys.h +++ b/src/citra_qt/hotkeys.h @@ -47,7 +47,7 @@ class GHotkeysDialog : public QDialog Q_OBJECT public: - GHotkeysDialog(QWidget* parent = NULL); + GHotkeysDialog(QWidget* parent = nullptr); private: Ui::hotkeys ui; diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 8dadb44ef..01841b33c 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -4,51 +4,49 @@ #include <thread> -#include <QtGui> #include <QDesktopWidget> +#include <QtGui> #include <QFileDialog> #include <QMessageBox> #include "qhexedit.h" -#include "main.h" -#include "common/string_util.h" -#include "common/logging/text_formatter.h" -#include "common/logging/log.h" -#include "common/logging/backend.h" -#include "common/logging/filter.h" +#include "citra_qt/bootmanager.h" +#include "citra_qt/config.h" +#include "citra_qt/hotkeys.h" +#include "citra_qt/main.h" + +// Debugger +#include "citra_qt/debugger/callstack.h" +#include "citra_qt/debugger/disassembler.h" +#include "citra_qt/debugger/graphics.h" +#include "citra_qt/debugger/graphics_breakpoints.h" +#include "citra_qt/debugger/graphics_cmdlists.h" +#include "citra_qt/debugger/graphics_framebuffer.h" +#include "citra_qt/debugger/graphics_tracing.h" +#include "citra_qt/debugger/graphics_vertex_shader.h" +#include "citra_qt/debugger/profiler.h" +#include "citra_qt/debugger/ramview.h" +#include "citra_qt/debugger/registers.h" + #include "common/make_unique.h" #include "common/microprofile.h" #include "common/platform.h" #include "common/scm_rev.h" #include "common/scope_exit.h" +#include "common/string_util.h" +#include "common/logging/backend.h" +#include "common/logging/filter.h" +#include "common/logging/log.h" +#include "common/logging/text_formatter.h" -#include "bootmanager.h" -#include "hotkeys.h" - -//debugger -#include "debugger/disassembler.h" -#include "debugger/registers.h" -#include "debugger/callstack.h" -#include "debugger/ramview.h" -#include "debugger/graphics.h" -#include "debugger/graphics_breakpoints.h" -#include "debugger/graphics_cmdlists.h" -#include "debugger/graphics_framebuffer.h" -#include "debugger/graphics_tracing.h" -#include "debugger/graphics_vertex_shader.h" -#include "debugger/profiler.h" - +#include "core/core.h" #include "core/settings.h" #include "core/system.h" -#include "core/core.h" -#include "core/loader/loader.h" #include "core/arm/disassembler/load_symbol_map.h" -#include "citra_qt/config.h" +#include "core/loader/loader.h" #include "video_core/video_core.h" -#include "version.h" - GMainWindow::GMainWindow() : emu_thread(nullptr) { Pica::g_debug_context = Pica::DebugContext::Construct(); @@ -130,11 +128,14 @@ GMainWindow::GMainWindow() : emu_thread(nullptr) // Restore UI state QSettings settings; + + settings.beginGroup("UILayout"); restoreGeometry(settings.value("geometry").toByteArray()); restoreState(settings.value("state").toByteArray()); render_window->restoreGeometry(settings.value("geometryRenderWindow").toByteArray()); microProfileDialog->restoreGeometry(settings.value("microProfileDialogGeometry").toByteArray()); microProfileDialog->setVisible(settings.value("microProfileDialogVisible").toBool()); + settings.endGroup(); ui.action_Use_Hardware_Renderer->setChecked(Settings::values.use_hw_renderer); SetHardwareRendererEnabled(ui.action_Use_Hardware_Renderer->isChecked()); @@ -301,6 +302,10 @@ void GMainWindow::StoreRecentFile(const QString& filename) QStringList recent_files = settings.value("recentFiles").toStringList(); recent_files.prepend(filename); recent_files.removeDuplicates(); + while (recent_files.size() > max_recent_files_item) { + recent_files.removeLast(); + } + settings.setValue("recentFiles", recent_files); UpdateRecentFiles(); @@ -439,11 +444,15 @@ void GMainWindow::OnConfigure() { void GMainWindow::closeEvent(QCloseEvent* event) { // Save window layout QSettings settings(QSettings::IniFormat, QSettings::UserScope, "Citra team", "Citra"); + + settings.beginGroup("UILayout"); settings.setValue("geometry", saveGeometry()); settings.setValue("state", saveState()); settings.setValue("geometryRenderWindow", render_window->saveGeometry()); settings.setValue("microProfileDialogGeometry", microProfileDialog->saveGeometry()); settings.setValue("microProfileDialogVisible", microProfileDialog->isVisible()); + settings.endGroup(); + settings.setValue("singleWindowMode", ui.action_Single_Window_Mode->isChecked()); settings.setValue("displayTitleBars", ui.actionDisplay_widget_title_bars->isChecked()); settings.setValue("firstStart", false); diff --git a/src/citra_qt/util/spinbox.cpp b/src/citra_qt/util/spinbox.cpp index de4060116..415e7fbec 100644 --- a/src/citra_qt/util/spinbox.cpp +++ b/src/citra_qt/util/spinbox.cpp @@ -33,8 +33,8 @@ #include <QLineEdit> #include <QRegExpValidator> +#include "citra_qt/util/spinbox.h" #include "common/assert.h" -#include "spinbox.h" CSpinBox::CSpinBox(QWidget* parent) : QAbstractSpinBox(parent), min_value(-100), max_value(100), value(0), base(10), num_digits(0) { diff --git a/src/citra_qt/util/util.cpp b/src/citra_qt/util/util.cpp index 2cb939af1..f292046b7 100644 --- a/src/citra_qt/util/util.cpp +++ b/src/citra_qt/util/util.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "util.h" +#include "citra_qt/util/util.h" QFont GetMonospaceFont() { QFont font("monospace"); diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 2be6fe996..959084cdf 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -32,7 +32,6 @@ set(HEADERS common_funcs.h common_paths.h common_types.h - debug_interface.h emu_window.h file_util.h hash.h diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp index 023a485a4..e7d0d3e43 100644 --- a/src/common/break_points.cpp +++ b/src/common/break_points.cpp @@ -2,7 +2,6 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/debug_interface.h" #include "common/break_points.h" #include "common/logging/log.h" @@ -101,92 +100,3 @@ void BreakPoints::Clear() m_BreakPoints.clear(); } - -MemChecks::TMemChecksStr MemChecks::GetStrings() const -{ - TMemChecksStr mcs; - for (auto memcheck : m_MemChecks) - { - std::stringstream mc; - mc << std::hex << memcheck.StartAddress; - mc << " " << (memcheck.bRange ? memcheck.EndAddress : memcheck.StartAddress) << " " - << (memcheck.bRange ? "n" : "") - << (memcheck.OnRead ? "r" : "") - << (memcheck.OnWrite ? "w" : "") - << (memcheck.Log ? "l" : "") - << (memcheck.Break ? "p" : ""); - mcs.push_back(mc.str()); - } - - return mcs; -} - -void MemChecks::AddFromStrings(const TMemChecksStr& mcs) -{ - for (auto mcs_item : mcs) - { - TMemCheck mc; - std::stringstream mcstr; - mcstr << std::hex << mcs_item; - mcstr >> mc.StartAddress; - mc.bRange = mcs_item.find("n") != mcs_item.npos; - mc.OnRead = mcs_item.find("r") != mcs_item.npos; - mc.OnWrite = mcs_item.find("w") != mcs_item.npos; - mc.Log = mcs_item.find("l") != mcs_item.npos; - mc.Break = mcs_item.find("p") != mcs_item.npos; - if (mc.bRange) - mcstr >> mc.EndAddress; - else - mc.EndAddress = mc.StartAddress; - Add(mc); - } -} - -void MemChecks::Add(const TMemCheck& rMemoryCheck) -{ - if (GetMemCheck(rMemoryCheck.StartAddress) == 0) - m_MemChecks.push_back(rMemoryCheck); -} - -void MemChecks::Remove(u32 Address) -{ - auto cond = [&Address](const TMemCheck& mc) { return mc.StartAddress == Address; }; - auto it = std::find_if(m_MemChecks.begin(), m_MemChecks.end(), cond); - if (it != m_MemChecks.end()) - m_MemChecks.erase(it); -} - -TMemCheck *MemChecks::GetMemCheck(u32 address) -{ - for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) - { - if (i->bRange) - { - if (address >= i->StartAddress && address <= i->EndAddress) - return &(*i); - } - else if (i->StartAddress == address) - return &(*i); - } - - // none found - return 0; -} - -void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, - bool write, int size, u32 pc) -{ - if ((write && OnWrite) || (!write && OnRead)) - { - if (Log) - { - LOG_DEBUG(Debug_Breakpoint, "CHK %08x (%s) %s%i %0*x at %08x (%s)", - pc, debug_interface->getDescription(pc).c_str(), - write ? "Write" : "Read", size*8, size*2, iValue, addr, - debug_interface->getDescription(addr).c_str() - ); - } - if (Break) - debug_interface->breakNow(); - } -} diff --git a/src/common/break_points.h b/src/common/break_points.h index f0a55e7b1..b0629df37 100644 --- a/src/common/break_points.h +++ b/src/common/break_points.h @@ -18,31 +18,6 @@ struct TBreakPoint bool bTemporary; }; -struct TMemCheck -{ - TMemCheck(): - StartAddress(0), EndAddress(0), - bRange(false), OnRead(false), OnWrite(false), - Log(false), Break(false), numHits(0) - { } - - u32 StartAddress; - u32 EndAddress; - - bool bRange; - - bool OnRead; - bool OnWrite; - - bool Log; - bool Break; - - u32 numHits; - - void Action(DebugInterface *dbg_interface, u32 iValue, u32 addr, - bool write, int size, u32 pc); -}; - // Code breakpoints. class BreakPoints { @@ -73,27 +48,3 @@ private: TBreakPoints m_BreakPoints; u32 m_iBreakOnCount; }; - - -// Memory breakpoints -class MemChecks -{ -public: - typedef std::vector<TMemCheck> TMemChecks; - typedef std::vector<std::string> TMemChecksStr; - - TMemChecks m_MemChecks; - - const TMemChecks& GetMemChecks() { return m_MemChecks; } - - TMemChecksStr GetStrings() const; - void AddFromStrings(const TMemChecksStr& mcs); - - void Add(const TMemCheck& rMemoryCheck); - - // memory breakpoint - TMemCheck *GetMemCheck(u32 address); - void Remove(u32 _Address); - - void Clear() { m_MemChecks.clear(); }; -}; diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h index 8be0b1109..1e1bcff31 100644 --- a/src/common/chunk_file.h +++ b/src/common/chunk_file.h @@ -575,10 +575,10 @@ public: } template<class T, LinkedListItem<T>* (*TNew)(), void (*TFree)(LinkedListItem<T>*), void (*TDo)(PointerWrap&, T*)> - void DoLinkedList(LinkedListItem<T>*& list_start, LinkedListItem<T>** list_end=0) + void DoLinkedList(LinkedListItem<T>*& list_start, LinkedListItem<T>** list_end = nullptr) { LinkedListItem<T>* list_cur = list_start; - LinkedListItem<T>* prev = 0; + LinkedListItem<T>* prev = nullptr; while (true) { diff --git a/src/common/debug_interface.h b/src/common/debug_interface.h deleted file mode 100644 index 32f55cb59..000000000 --- a/src/common/debug_interface.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include <cstring> -#include <string> - -class DebugInterface -{ -protected: - virtual ~DebugInterface() {} - -public: - virtual void disasm(unsigned int /*address*/, char *dest, int /*max_size*/) {strcpy(dest, "NODEBUGGER");} - virtual void getRawMemoryString(int /*memory*/, unsigned int /*address*/, char *dest, int /*max_size*/) {strcpy(dest, "NODEBUGGER");} - virtual int getInstructionSize(int /*instruction*/) {return 1;} - virtual bool isAlive() {return true;} - virtual bool isBreakpoint(unsigned int /*address*/) {return false;} - virtual void setBreakpoint(unsigned int /*address*/){} - virtual void clearBreakpoint(unsigned int /*address*/){} - virtual void clearAllBreakpoints() {} - virtual void toggleBreakpoint(unsigned int /*address*/){} - virtual bool isMemCheck(unsigned int /*address*/) {return false;} - virtual void toggleMemCheck(unsigned int /*address*/){} - virtual unsigned int readMemory(unsigned int /*address*/){return 0;} - virtual void writeExtraMemory(int /*memory*/, unsigned int /*value*/, unsigned int /*address*/) {} - virtual unsigned int readExtraMemory(int /*memory*/, unsigned int /*address*/){return 0;} - virtual unsigned int readInstruction(unsigned int /*address*/){return 0;} - virtual unsigned int getPC() {return 0;} - virtual void setPC(unsigned int /*address*/) {} - virtual void step() {} - virtual void runToBreakpoint() {} - virtual void breakNow() {} - virtual void insertBLR(unsigned int /*address*/, unsigned int /*value*/) {} - virtual void showJitResults(unsigned int /*address*/) {}; - virtual int getColor(unsigned int /*address*/){return 0xFFFFFFFF;} - virtual std::string getDescription(unsigned int /*address*/) = 0; -}; diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 5ef784224..07c7f79c8 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp @@ -28,9 +28,9 @@ void* AllocateExecutableMemory(size_t size, bool low) { #if defined(_WIN32) - void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); #else - static char *map_hint = 0; + static char* map_hint = nullptr; #if defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) // This OS has no flag to enforce allocation below the 4 GB boundary, // but if we hint that we want a low address it is very likely we will @@ -49,9 +49,6 @@ void* AllocateExecutableMemory(size_t size, bool low) , -1, 0); #endif /* defined(_WIN32) */ - // printf("Mapped executable memory at %p (size %ld)\n", ptr, - // (unsigned long)size); - #ifdef _WIN32 if (ptr == nullptr) { @@ -69,7 +66,6 @@ void* AllocateExecutableMemory(size_t size, bool low) { map_hint += size; map_hint = (char*)round_page(map_hint); /* round up to the next page */ - // printf("Next map will (hopefully) be at %p\n", map_hint); } } #endif @@ -85,18 +81,15 @@ void* AllocateExecutableMemory(size_t size, bool low) void* AllocateMemoryPages(size_t size) { #ifdef _WIN32 - void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); + void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); #else - void* ptr = mmap(0, size, PROT_READ | PROT_WRITE, + void* ptr = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (ptr == MAP_FAILED) ptr = nullptr; #endif - // printf("Mapped memory at %p (size %ld)\n", ptr, - // (unsigned long)size); - if (ptr == nullptr) LOG_ERROR(Common_Memory, "Failed to allocate raw memory"); @@ -117,9 +110,6 @@ void* AllocateAlignedMemory(size_t size,size_t alignment) #endif #endif - // printf("Mapped memory at %p (size %ld)\n", ptr, - // (unsigned long)size); - if (ptr == nullptr) LOG_ERROR(Common_Memory, "Failed to allocate aligned memory"); @@ -131,11 +121,8 @@ void FreeMemoryPages(void* ptr, size_t size) if (ptr) { #ifdef _WIN32 - if (!VirtualFree(ptr, 0, MEM_RELEASE)) LOG_ERROR(Common_Memory, "FreeMemoryPages failed!\n%s", GetLastErrorMsg()); - ptr = nullptr; // Is this our responsibility? - #else munmap(ptr, size); #endif diff --git a/src/common/swap.h b/src/common/swap.h index b92e5bfa4..a7c37bc44 100644 --- a/src/common/swap.h +++ b/src/common/swap.h @@ -148,7 +148,7 @@ struct swap_struct_t { typedef swap_struct_t<T, F> swapped_t; protected: - T value; + T value = T(); static T swap(T v) { return F::swap(v); @@ -158,7 +158,7 @@ public: return swap(value); } - swap_struct_t() : value((T)0) {} + swap_struct_t() = default; swap_struct_t(const T &v): value(swap(v)) {} template <typename S> diff --git a/src/common/synchronized_wrapper.h b/src/common/synchronized_wrapper.h index ae5e8b1ed..07105a198 100644 --- a/src/common/synchronized_wrapper.h +++ b/src/common/synchronized_wrapper.h @@ -55,6 +55,7 @@ public: SynchronizedRef& operator=(SynchronizedRef&) = delete; SynchronizedRef& operator=(SynchronizedRef&& o) { std::swap(wrapper, o.wrapper); + return *this; } T& operator*() { return wrapper->data; } diff --git a/src/core/arm/disassembler/arm_disasm.cpp b/src/core/arm/disassembler/arm_disasm.cpp index 77af10b54..76408e9fa 100644 --- a/src/core/arm/disassembler/arm_disasm.cpp +++ b/src/core/arm/disassembler/arm_disasm.cpp @@ -206,7 +206,7 @@ static const char *opcode_names[] = { "swi", "tst", - NULL + nullptr }; // Indexed by the shift type (bits 6-5) @@ -399,7 +399,7 @@ std::string ARM_Disasm::Disassemble(u32 addr, u32 insn) default: return "Error"; } - return NULL; + return nullptr; } std::string ARM_Disasm::DisassembleALU(Opcode opcode, u32 insn) diff --git a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp index 47a9fe804..857e6ce45 100644 --- a/src/core/arm/skyeye_common/vfp/vfpdouble.cpp +++ b/src/core/arm/skyeye_common/vfp/vfpdouble.cpp @@ -299,7 +299,7 @@ static u32 vfp_double_fsqrt(ARMul_State* state, int dd, int unused, int dm, u32 vdp = &vdd; if (tm & VFP_NAN) - ret = vfp_propagate_nan(vdp, &vdm, NULL, fpscr); + ret = vfp_propagate_nan(vdp, &vdm, nullptr, fpscr); else if (vdm.sign == 0) { sqrt_copy: vdp = &vdm; @@ -700,26 +700,26 @@ static struct op fops_ext[] = { { vfp_double_fabs, 0 }, //0x00000001 - FEXT_FABS { vfp_double_fneg, 0 }, //0x00000002 - FEXT_FNEG { vfp_double_fsqrt, 0 }, //0x00000003 - FEXT_FSQRT - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, { vfp_double_fcmp, OP_SCALAR }, //0x00000008 - FEXT_FCMP { vfp_double_fcmpe, OP_SCALAR }, //0x00000009 - FEXT_FCMPE { vfp_double_fcmpz, OP_SCALAR }, //0x0000000A - FEXT_FCMPZ { vfp_double_fcmpez, OP_SCALAR }, //0x0000000B - FEXT_FCMPEZ - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, { vfp_double_fcvts, OP_SCALAR|OP_DD }, //0x0000000F - FEXT_FCVT { vfp_double_fuito, OP_SCALAR|OP_SM }, //0x00000010 - FEXT_FUITO { vfp_double_fsito, OP_SCALAR|OP_SM }, //0x00000011 - FEXT_FSITO - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, { vfp_double_ftoui, OP_SCALAR|OP_SD }, //0x00000018 - FEXT_FTOUI { vfp_double_ftouiz, OP_SCALAR|OP_SD }, //0x00000019 - FEXT_FTOUIZ { vfp_double_ftosi, OP_SCALAR|OP_SD }, //0x0000001A - FEXT_FTOSI diff --git a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp index 0fb3c3bf1..e47ad2760 100644 --- a/src/core/arm/skyeye_common/vfp/vfpsingle.cpp +++ b/src/core/arm/skyeye_common/vfp/vfpsingle.cpp @@ -341,7 +341,7 @@ static u32 vfp_single_fsqrt(ARMul_State* state, int sd, int unused, s32 m, u32 f vsp = &vsd; if (tm & VFP_NAN) - ret = vfp_propagate_nan(vsp, &vsm, NULL, fpscr); + ret = vfp_propagate_nan(vsp, &vsm, nullptr, fpscr); else if (vsm.sign == 0) { sqrt_copy: vsp = &vsm; @@ -725,26 +725,26 @@ static struct op fops_ext[] = { { vfp_single_fabs, 0 }, //0x00000001 - FEXT_FABS { vfp_single_fneg, 0 }, //0x00000002 - FEXT_FNEG { vfp_single_fsqrt, 0 }, //0x00000003 - FEXT_FSQRT - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, { vfp_single_fcmp, OP_SCALAR }, //0x00000008 - FEXT_FCMP { vfp_single_fcmpe, OP_SCALAR }, //0x00000009 - FEXT_FCMPE { vfp_single_fcmpz, OP_SCALAR }, //0x0000000A - FEXT_FCMPZ { vfp_single_fcmpez, OP_SCALAR }, //0x0000000B - FEXT_FCMPEZ - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, { vfp_single_fcvtd, OP_SCALAR|OP_DD }, //0x0000000F - FEXT_FCVT { vfp_single_fuito, OP_SCALAR }, //0x00000010 - FEXT_FUITO { vfp_single_fsito, OP_SCALAR }, //0x00000011 - FEXT_FSITO - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, - { NULL, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, + { nullptr, 0 }, { vfp_single_ftoui, OP_SCALAR }, //0x00000018 - FEXT_FTOUI { vfp_single_ftouiz, OP_SCALAR }, //0x00000019 - FEXT_FTOUIZ { vfp_single_ftosi, OP_SCALAR }, //0x0000001A - FEXT_FTOSI diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 20f2da0fe..56615502c 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -207,7 +207,7 @@ void ScheduleEvent_Threadsafe(s64 cycles_into_future, int event_type, u64 userda Event* new_event = GetNewTsEvent(); new_event->time = GetTicks() + cycles_into_future; new_event->type = event_type; - new_event->next = 0; + new_event->next = nullptr; new_event->userdata = userdata; if (!ts_first) ts_first = new_event; diff --git a/src/core/file_sys/disk_archive.h b/src/core/file_sys/disk_archive.h index c5da07508..aaac65b17 100644 --- a/src/core/file_sys/disk_archive.h +++ b/src/core/file_sys/disk_archive.h @@ -51,7 +51,6 @@ protected: class DiskFile : public FileBackend { public: - DiskFile(); DiskFile(const DiskArchive& archive, const Path& path, const Mode mode); bool Open() override; @@ -73,7 +72,6 @@ protected: class DiskDirectory : public DirectoryBackend { public: - DiskDirectory(); DiskDirectory(const DiskArchive& archive, const Path& path); ~DiskDirectory() override { diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index d6d5328be..1746360e4 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -38,10 +38,9 @@ public: void Acquire() override; /** - * Acquires the specified mutex for the specified thread - * @param mutex Mutex that is to be acquired - * @param thread Thread that will acquire the mutex - */ + * Acquires the specified mutex for the specified thread + * @param thread Thread that will acquire the mutex + */ void Acquire(SharedPtr<Thread> thread); void Release(); diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h index d8dc1fd78..390f5e495 100644 --- a/src/core/hle/kernel/semaphore.h +++ b/src/core/hle/kernel/semaphore.h @@ -17,7 +17,6 @@ class Semaphore final : public WaitObject { public: /** * Creates a semaphore. - * @param handle Pointer to the handle of the newly created object * @param initial_count Number of slots reserved for other threads * @param max_count Maximum number of slots the semaphore can have * @param name Optional name of semaphore diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 1ff1d9b97..97ba57fc5 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -57,7 +57,6 @@ public: * @param arg User data to pass to the thread * @param processor_id The ID(s) of the processors on which the thread is desired to be run * @param stack_top The address of the thread's stack top - * @param stack_size The size of the thread's stack * @return A shared pointer to the newly created thread */ static ResultVal<SharedPtr<Thread>> Create(std::string name, VAddr entry_point, s32 priority, diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h index f61125953..6f7048710 100644 --- a/src/core/hle/service/fs/archive.h +++ b/src/core/hle/service/fs/archive.h @@ -87,7 +87,7 @@ ResultCode CloseArchive(ArchiveHandle handle); /** * Registers an Archive type, instances of which can later be opened using its IdCode. - * @param backend File system backend interface to the archive + * @param factory File system backend interface to the archive * @param id_code Id code used to access this type of archive */ ResultCode RegisterArchiveType(std::unique_ptr<FileSys::ArchiveFactory>&& factory, ArchiveIdCode id_code); diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index d768a3fc7..633b66fe2 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -485,7 +485,7 @@ static void GetHostId(Service::Interface* self) { addrinfo* res; hints.ai_family = AF_INET; - getaddrinfo(name, NULL, &hints, &res); + getaddrinfo(name, nullptr, &hints, &res); sockaddr_in* sock_addr = reinterpret_cast<sockaddr_in*>(res->ai_addr); in_addr* addr = &sock_addr->sin_addr; diff --git a/src/core/hw/y2r.cpp b/src/core/hw/y2r.cpp index 082a4db82..15f96ced8 100644 --- a/src/core/hw/y2r.cpp +++ b/src/core/hw/y2r.cpp @@ -33,7 +33,9 @@ static void ConvertYUVToRGB(InputFormat input_format, for (unsigned int y = 0; y < height; ++y) { for (unsigned int x = 0; x < width; ++x) { - s32 Y, U, V; + s32 Y = 0; + s32 U = 0; + s32 V = 0; switch (input_format) { case InputFormat::YUV422_Indiv8: case InputFormat::YUV422_Indiv16: @@ -269,7 +271,7 @@ void PerformConversion(ConversionConfiguration& cvt) { // LUT used to remap writes to a tile. Used to allow linear or swizzled output without // requiring two different code paths. - const u8* tile_remap; + const u8* tile_remap = nullptr; switch (cvt.block_alignment) { case BlockAlignment::Linear: tile_remap = linear_lut; break; @@ -323,7 +325,8 @@ void PerformConversion(ConversionConfiguration& cvt) { u32* output_buffer = reinterpret_cast<u32*>(data_buffer.get()); for (int i = 0; i < num_tiles; ++i) { - int image_strip_width, output_stride; + int image_strip_width = 0; + int output_stride = 0; switch (cvt.rotation) { case Rotation::None: diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp index 062291006..74eb6e871 100644 --- a/src/core/loader/loader.cpp +++ b/src/core/loader/loader.cpp @@ -50,7 +50,7 @@ static FileType IdentifyFile(FileUtil::IOFile& file) { /** * Guess the type of a bootable file from its extension - * @param extension String extension of bootable file + * @param extension_ String extension of bootable file * @return FileType of file */ static FileType GuessFromExtension(const std::string& extension_) { diff --git a/src/core/loader/ncch.h b/src/core/loader/ncch.h index b4374a476..d875e4cf3 100644 --- a/src/core/loader/ncch.h +++ b/src/core/loader/ncch.h @@ -209,7 +209,9 @@ public: /** * Get the RomFS of the application - * @param buffer Reference to buffer to store data + * @param romfs_file Reference to buffer to store data + * @param offset Offset in the file to the RomFS + * @param size Size of the RomFS in bytes * @return ResultStatus result of function */ ResultStatus ReadRomFS(std::shared_ptr<FileUtil::IOFile>& romfs_file, u64& offset, u64& size) override; diff --git a/src/core/memory.cpp b/src/core/memory.cpp index cde390b8a..b80795e0c 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <array> +#include <cstring> #include "common/assert.h" #include "common/common_types.h" @@ -95,7 +96,9 @@ template <typename T> T Read(const VAddr vaddr) { const u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS]; if (page_pointer) { - return *reinterpret_cast<const T*>(page_pointer + (vaddr & PAGE_MASK)); + T value; + std::memcpy(&value, &page_pointer[vaddr & PAGE_MASK], sizeof(T)); + return value; } PageType type = current_page_table->attributes[vaddr >> PAGE_BITS]; @@ -117,7 +120,7 @@ template <typename T> void Write(const VAddr vaddr, const T data) { u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS]; if (page_pointer) { - *reinterpret_cast<T*>(page_pointer + (vaddr & PAGE_MASK)) = data; + std::memcpy(&page_pointer[vaddr & PAGE_MASK], &data, sizeof(T)); return; } @@ -183,19 +186,9 @@ void Write64(const VAddr addr, const u64 data) { } void WriteBlock(const VAddr addr, const u8* data, const size_t size) { - u32 offset = 0; - while (offset < (size & ~3)) { - Write32(addr + offset, *(u32*)&data[offset]); - offset += 4; - } - - if (size & 2) { - Write16(addr + offset, *(u16*)&data[offset]); - offset += 2; - } - - if (size & 1) + for (u32 offset = 0; offset < size; offset++) { Write8(addr + offset, data[offset]); + } } PAddr VirtualToPhysicalAddress(const VAddr addr) { diff --git a/src/core/tracer/recorder.h b/src/core/tracer/recorder.h index 6e4b70015..a42ccc45f 100644 --- a/src/core/tracer/recorder.h +++ b/src/core/tracer/recorder.h @@ -32,8 +32,7 @@ public: /** * Recorder constructor - * @param default_attributes Pointer to an array of 32-bit-aligned 24-bit floating point values. - * @param vs_float_uniforms Pointer to an array of 32-bit-aligned 24-bit floating point values. + * @param initial_state Initial recorder state */ Recorder(const InitialState& initial_state); diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp index bb6048cc0..ed99c4f13 100644 --- a/src/video_core/clipper.cpp +++ b/src/video_core/clipper.cpp @@ -4,10 +4,10 @@ #include <boost/container/static_vector.hpp> -#include "clipper.h" -#include "pica.h" -#include "rasterizer.h" -#include "shader/shader_interpreter.h" +#include "video_core/clipper.h" +#include "video_core/pica.h" +#include "video_core/rasterizer.h" +#include "video_core/shader/shader_interpreter.h" namespace Pica { diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 6e9cb2586..47afd8938 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -2,25 +2,24 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <cmath> #include <boost/range/algorithm/fill.hpp> #include "common/microprofile.h" #include "common/profiler.h" +#include "core/settings.h" #include "core/hle/service/gsp_gpu.h" #include "core/hw/gpu.h" -#include "core/settings.h" - -#include "debug_utils/debug_utils.h" -#include "clipper.h" -#include "command_processor.h" -#include "math.h" -#include "pica.h" -#include "primitive_assembly.h" -#include "renderer_base.h" -#include "shader/shader_interpreter.h" -#include "video_core.h" +#include "video_core/clipper.h" +#include "video_core/command_processor.h" +#include "video_core/pica.h" +#include "video_core/primitive_assembly.h" +#include "video_core/renderer_base.h" +#include "video_core/video_core.h" +#include "video_core/debug_utils/debug_utils.h" +#include "video_core/shader/shader_interpreter.h" namespace Pica { diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 059445f7d..77a4fe272 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -31,8 +31,7 @@ #include "video_core/renderer_base.h" #include "video_core/utils.h" #include "video_core/video_core.h" - -#include "debug_utils.h" +#include "video_core/debug_utils/debug_utils.h" using nihstro::DVLBHeader; using nihstro::DVLEHeader; @@ -298,7 +297,6 @@ void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, c } // Write data to file - static int dump_index = 0; std::ofstream file(filename, std::ios_base::out | std::ios_base::binary); for (auto& chunk : writing_queue) { @@ -695,7 +693,6 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) { for (unsigned y = 0; y < texture_config.height; ++y) { u8* row_ptr = (u8*)buf + y * row_stride; - u8* ptr = row_ptr; png_write_row(png_ptr, row_ptr); } diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h index 48ac269e3..fae5de7d1 100644 --- a/src/video_core/gpu_debugger.h +++ b/src/video_core/gpu_debugger.h @@ -10,9 +10,6 @@ #include "core/hle/service/gsp_gpu.h" -#include "command_processor.h" -#include "pica.h" - class GraphicsDebugger { public: diff --git a/src/video_core/pica.cpp b/src/video_core/pica.cpp index 61983bc6c..8c528989e 100644 --- a/src/video_core/pica.cpp +++ b/src/video_core/pica.cpp @@ -5,8 +5,8 @@ #include <cstring> #include <unordered_map> -#include "pica.h" -#include "shader/shader.h" +#include "video_core/pica.h" +#include "video_core/shader/shader.h" namespace Pica { diff --git a/src/video_core/pica.h b/src/video_core/pica.h index c1dca5087..ff81b409d 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h @@ -13,8 +13,8 @@ #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" -#include "common/logging/log.h" #include "common/vector_math.h" +#include "common/logging/log.h" namespace Pica { diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp index e2b1df44c..44a8dbfe9 100644 --- a/src/video_core/primitive_assembly.cpp +++ b/src/video_core/primitive_assembly.cpp @@ -2,12 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "pica.h" -#include "primitive_assembly.h" -#include "shader/shader_interpreter.h" - #include "common/logging/log.h" + +#include "video_core/pica.h" +#include "video_core/primitive_assembly.h" #include "video_core/debug_utils/debug_utils.h" +#include "video_core/shader/shader_interpreter.h" namespace Pica { diff --git a/src/video_core/primitive_assembly.h b/src/video_core/primitive_assembly.h index 80432d68a..52d0ec8ff 100644 --- a/src/video_core/primitive_assembly.h +++ b/src/video_core/primitive_assembly.h @@ -8,8 +8,6 @@ #include "video_core/pica.h" -#include "video_core/shader/shader_interpreter.h" - namespace Pica { /* diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 77eadda9e..a90ff5fef 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include <algorithm> +#include <cmath> #include "common/color.h" #include "common/common_types.h" @@ -10,15 +11,14 @@ #include "common/microprofile.h" #include "common/profiler.h" -#include "core/hw/gpu.h" #include "core/memory.h" +#include "core/hw/gpu.h" -#include "debug_utils/debug_utils.h" -#include "math.h" -#include "pica.h" -#include "rasterizer.h" -#include "shader/shader_interpreter.h" +#include "video_core/pica.h" +#include "video_core/rasterizer.h" #include "video_core/utils.h" +#include "video_core/debug_utils/debug_utils.h" +#include "video_core/shader/shader_interpreter.h" namespace Pica { diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 0260a28ce..50eb157a5 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -12,9 +12,9 @@ #include "common/microprofile.h" #include "common/profiler.h" -#include "core/hw/gpu.h" #include "core/memory.h" #include "core/settings.h" +#include "core/hw/gpu.h" #include "video_core/pica.h" #include "video_core/utils.h" @@ -212,9 +212,9 @@ void RasterizerOpenGL::Reset() { void RasterizerOpenGL::AddTriangle(const Pica::Shader::OutputVertex& v0, const Pica::Shader::OutputVertex& v1, const Pica::Shader::OutputVertex& v2) { - vertex_batch.push_back(HardwareVertex(v0)); - vertex_batch.push_back(HardwareVertex(v1)); - vertex_batch.push_back(HardwareVertex(v2)); + vertex_batch.emplace_back(v0); + vertex_batch.emplace_back(v1); + vertex_batch.emplace_back(v2); } void RasterizerOpenGL::DrawTriangles() { diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 24560d7f8..1fe307846 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -9,11 +9,10 @@ #include "common/common_types.h" #include "video_core/hwrasterizer_base.h" +#include "video_core/renderer_opengl/gl_rasterizer_cache.h" +#include "video_core/renderer_opengl/gl_state.h" #include "video_core/shader/shader_interpreter.h" -#include "gl_state.h" -#include "gl_rasterizer_cache.h" - class RasterizerOpenGL : public HWRasterizer { public: diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index d9ccf2a3f..10d4ab0b6 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -10,9 +10,9 @@ #include "core/memory.h" +#include "video_core/debug_utils/debug_utils.h" #include "video_core/renderer_opengl/gl_rasterizer_cache.h" #include "video_core/renderer_opengl/pica_to_gl.h" -#include "video_core/debug_utils/debug_utils.h" RasterizerCacheOpenGL::~RasterizerCacheOpenGL() { FullFlush(); diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index ec56237b5..98a48ffbe 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -4,13 +4,13 @@ #pragma once -#include "gl_state.h" -#include "gl_resource_manager.h" -#include "video_core/debug_utils/debug_utils.h" -#include "video_core/pica.h" - -#include <memory> #include <map> +#include <memory> + +#include "video_core/pica.h" +#include "video_core/debug_utils/debug_utils.h" +#include "video_core/renderer_opengl/gl_resource_manager.h" +#include "video_core/renderer_opengl/gl_state.h" class RasterizerCacheOpenGL : NonCopyable { public: diff --git a/src/video_core/renderer_opengl/gl_shader_util.cpp b/src/video_core/renderer_opengl/gl_shader_util.cpp index 42d0e597c..4cf246c06 100644 --- a/src/video_core/renderer_opengl/gl_shader_util.cpp +++ b/src/video_core/renderer_opengl/gl_shader_util.cpp @@ -2,11 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "gl_shader_util.h" -#include "common/logging/log.h" - -#include <vector> #include <algorithm> +#include <vector> + +#include "common/logging/log.h" +#include "video_core/renderer_opengl/gl_shader_util.h" namespace ShaderUtil { diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index e02c27fbf..77b2816cb 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -2,8 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "video_core/renderer_opengl/gl_state.h" #include "video_core/pica.h" +#include "video_core/renderer_opengl/gl_state.h" OpenGLState OpenGLState::cur_state; diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 067d072ae..22f261c68 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -11,18 +11,18 @@ #include "common/logging/log.h" #include "common/profiler_reporting.h" +#include "core/memory.h" +#include "core/settings.h" #include "core/hw/gpu.h" #include "core/hw/hw.h" #include "core/hw/lcd.h" -#include "core/memory.h" -#include "core/settings.h" #include "video_core/video_core.h" -#include "video_core/renderer_opengl/renderer_opengl.h" +#include "video_core/debug_utils/debug_utils.h" +#include "video_core/renderer_opengl/gl_rasterizer.h" #include "video_core/renderer_opengl/gl_shader_util.h" #include "video_core/renderer_opengl/gl_shaders.h" - -#include "video_core/debug_utils/debug_utils.h" +#include "video_core/renderer_opengl/renderer_opengl.h" /** * Vertex structure that the drawn screen rectangles are composed of. diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 4b023dc98..5677e538b 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -8,13 +8,10 @@ #include <glad/glad.h> -#include "common/math_util.h" - #include "core/hw/gpu.h" #include "video_core/renderer_base.h" #include "video_core/renderer_opengl/gl_state.h" -#include "video_core/renderer_opengl/gl_rasterizer.h" class EmuWindow; @@ -64,9 +61,6 @@ private: void LoadColorToActiveGLTexture(u8 color_r, u8 color_g, u8 color_b, const TextureInfo& texture); - /// Computes the viewport rectangle - MathUtil::Rectangle<unsigned> GetViewportExtent(); - EmuWindow* render_window; ///< Handle to render window u32 last_mode; ///< Last render mode diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index f89117521..59f54236b 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -146,7 +146,6 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup) { UnitState<true> state; - const auto& shader_memory = setup.program_code; state.program_counter = config.main_offset; state.debug.max_offset = 0; state.debug.max_opdesc_id = 0; diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index bac51ddd8..1c6fa592c 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -289,13 +289,13 @@ struct UnitState { DebugData<Debug> debug; - static int InputOffset(const SourceRegister& reg) { + static size_t InputOffset(const SourceRegister& reg) { switch (reg.GetRegisterType()) { case RegisterType::Input: - return (int)offsetof(UnitState::Registers, input) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, input) + reg.GetIndex()*sizeof(Math::Vec4<float24>); case RegisterType::Temporary: - return (int)offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); default: UNREACHABLE(); @@ -303,13 +303,13 @@ struct UnitState { } } - static int OutputOffset(const DestRegister& reg) { + static size_t OutputOffset(const DestRegister& reg) { switch (reg.GetRegisterType()) { case RegisterType::Output: - return (int)offsetof(UnitState::Registers, output) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, output) + reg.GetIndex()*sizeof(Math::Vec4<float24>); case RegisterType::Temporary: - return (int)offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); default: UNREACHABLE(); diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 69e4efa68..7b0c20b74 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -7,9 +7,8 @@ #include <nihstro/shader_bytecode.h> #include "video_core/pica.h" - -#include "shader.h" -#include "shader_interpreter.h" +#include "video_core/shader/shader.h" +#include "video_core/shader/shader_interpreter.h" using nihstro::OpCode; using nihstro::Instruction; diff --git a/src/video_core/shader/shader_interpreter.h b/src/video_core/shader/shader_interpreter.h index 71bcad5ac..294bca50e 100644 --- a/src/video_core/shader/shader_interpreter.h +++ b/src/video_core/shader/shader_interpreter.h @@ -4,9 +4,7 @@ #pragma once -#include "video_core/pica.h" - -#include "shader.h" +#include "video_core/shader/shader.h" namespace Pica { diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index b9a0b19e3..00415e402 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp @@ -144,7 +144,7 @@ static const u8 NO_DEST_REG_MASK = 0xf; */ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) { X64Reg src_ptr; - int src_offset; + size_t src_offset; if (src_reg.GetRegisterType() == RegisterType::FloatUniform) { src_ptr = UNIFORMS; @@ -154,6 +154,9 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source src_offset = UnitState<false>::InputOffset(src_reg); } + int src_offset_disp = (int)src_offset; + ASSERT_MSG(src_offset == src_offset_disp, "Source register offset too large for int type"); + unsigned operand_desc_id; if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD || instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI) { @@ -163,7 +166,7 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source operand_desc_id = instr.mad.operand_desc_id; // Load the source - MOVAPS(dest, MDisp(src_ptr, src_offset)); + MOVAPS(dest, MDisp(src_ptr, src_offset_disp)); } else { operand_desc_id = instr.common.operand_desc_id; @@ -173,13 +176,13 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source if (src_num == offset_src && instr.common.address_register_index != 0) { switch (instr.common.address_register_index) { case 1: // address offset 1 - MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_0, 1, src_offset)); + MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_0, SCALE_1, src_offset_disp)); break; case 2: // address offset 2 - MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_1, 1, src_offset)); + MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_1, SCALE_1, src_offset_disp)); break; - case 3: // adddress offet 3 - MOVAPS(dest, MComplex(src_ptr, LOOPCOUNT_REG, 1, src_offset)); + case 3: // address offset 3 + MOVAPS(dest, MComplex(src_ptr, LOOPCOUNT_REG, SCALE_1, src_offset_disp)); break; default: UNREACHABLE(); @@ -187,7 +190,7 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source } } else { // Load the source - MOVAPS(dest, MDisp(src_ptr, src_offset)); + MOVAPS(dest, MDisp(src_ptr, src_offset_disp)); } } @@ -224,14 +227,17 @@ void JitCompiler::Compile_DestEnable(Instruction instr,X64Reg src) { SwizzlePattern swiz = { g_state.vs.swizzle_data[operand_desc_id] }; + int dest_offset_disp = (int)UnitState<false>::OutputOffset(dest); + ASSERT_MSG(dest_offset_disp == UnitState<false>::OutputOffset(dest), "Destinaton offset too large for int type"); + // If all components are enabled, write the result to the destination register if (swiz.dest_mask == NO_DEST_REG_MASK) { // Store dest back to memory - MOVAPS(MDisp(REGISTERS, UnitState<false>::OutputOffset(dest)), src); + MOVAPS(MDisp(REGISTERS, dest_offset_disp), src); } else { // Not all components are enabled, so mask the result when storing to the destination register... - MOVAPS(SCRATCH, MDisp(REGISTERS, UnitState<false>::OutputOffset(dest))); + MOVAPS(SCRATCH, MDisp(REGISTERS, dest_offset_disp)); if (Common::GetCPUCaps().sse4_1) { u8 mask = ((swiz.dest_mask & 1) << 3) | ((swiz.dest_mask & 8) >> 3) | ((swiz.dest_mask & 2) << 1) | ((swiz.dest_mask & 4) >> 1); @@ -250,7 +256,7 @@ void JitCompiler::Compile_DestEnable(Instruction instr,X64Reg src) { } // Store dest back to memory - MOVAPS(MDisp(REGISTERS, UnitState<false>::OutputOffset(dest)), SCRATCH); + MOVAPS(MDisp(REGISTERS, dest_offset_disp), SCRATCH); } } @@ -743,7 +749,6 @@ void JitCompiler::Compile_NextInstr(unsigned* offset) { CompiledShader* JitCompiler::Compile() { const u8* start = GetCodePtr(); - const auto& code = g_state.vs.program_code; unsigned offset = g_state.regs.vs.main_offset; // The stack pointer is 8 modulo 16 at the entry of a procedure diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h index 8668cfff4..3afbceccf 100644 --- a/src/video_core/shader/shader_jit_x64.h +++ b/src/video_core/shader/shader_jit_x64.h @@ -9,8 +9,7 @@ #include "common/x64/emitter.h" #include "video_core/pica.h" - -#include "shader.h" +#include "video_core/shader/shader.h" using nihstro::Instruction; using nihstro::OpCode; diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp index c7cc93cea..6e1ff5cf4 100644 --- a/src/video_core/utils.cpp +++ b/src/video_core/utils.cpp @@ -2,8 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <stdio.h> -#include <string.h> +#include <cstdio> +#include <cstring> #include "video_core/utils.h" diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 943fde5ee..eaddda668 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -2,17 +2,16 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/logging/log.h" #include "common/emu_window.h" +#include "common/logging/log.h" #include "core/core.h" #include "core/settings.h" -#include "video_core.h" -#include "renderer_base.h" -#include "renderer_opengl/renderer_opengl.h" - -#include "pica.h" +#include "video_core/pica.h" +#include "video_core/renderer_base.h" +#include "video_core/video_core.h" +#include "video_core/renderer_opengl/renderer_opengl.h" //////////////////////////////////////////////////////////////////////////////////////////////////// // Video Core namespace |