aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt26
-rw-r--r--CONTRIBUTING.md102
-rw-r--r--README.md10
-rw-r--r--externals/cmake-modules/FindGLEW.cmake47
-rw-r--r--src/citra/CMakeLists.txt11
-rw-r--r--src/citra/citra.cpp9
-rw-r--r--src/citra/emu_window/emu_window_glfw.cpp14
-rw-r--r--src/citra_qt/CMakeLists.txt29
-rw-r--r--src/citra_qt/bootmanager.cpp34
-rw-r--r--src/citra_qt/citra_qt.vcxproj8
-rw-r--r--src/citra_qt/citra_qt.vcxproj.filters22
-rw-r--r--src/citra_qt/debugger/graphics.cpp83
-rw-r--r--src/citra_qt/debugger/graphics.hxx43
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.cpp139
-rw-r--r--src/citra_qt/debugger/graphics_cmdlists.hxx64
-rw-r--r--src/citra_qt/main.cpp12
-rw-r--r--src/citra_qt/main.hxx4
-rw-r--r--src/common/CMakeLists.txt41
-rw-r--r--src/common/chunk_file.h5
-rw-r--r--src/common/common.h48
-rw-r--r--src/common/common.vcxproj3
-rw-r--r--src/common/common.vcxproj.filters5
-rw-r--r--src/common/common_types.h4
-rw-r--r--src/common/log.h2
-rw-r--r--src/common/log_manager.cpp2
-rw-r--r--src/common/platform.h4
-rw-r--r--src/common/register_set.h161
-rw-r--r--src/core/CMakeLists.txt50
-rw-r--r--src/core/arm/arm_interface.h2
-rw-r--r--src/core/arm/interpreter/mmu/maverick.cpp4
-rw-r--r--src/core/arm/interpreter/vfp/vfp_helper.h4
-rw-r--r--src/core/arm/interpreter/vfp/vfpdouble.cpp8
-rw-r--r--src/core/arm/interpreter/vfp/vfpsingle.cpp4
-rw-r--r--src/core/core.cpp6
-rw-r--r--src/core/core.vcxproj6
-rw-r--r--src/core/core.vcxproj.filters6
-rw-r--r--src/core/hle/service/gsp.cpp70
-rw-r--r--src/core/hle/service/gsp.h17
-rw-r--r--src/core/hle/service/service.h2
-rw-r--r--src/core/hw/gpu.cpp (renamed from src/core/hw/lcd.cpp)71
-rw-r--r--src/core/hw/gpu.h (renamed from src/core/hw/lcd.h)36
-rw-r--r--src/core/hw/hw.cpp16
-rw-r--r--src/core/hw/ndma.cpp4
-rw-r--r--src/video_core/CMakeLists.txt7
-rw-r--r--src/video_core/gpu_debugger.h157
-rw-r--r--src/video_core/pica.h130
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp10
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h4
-rw-r--r--src/video_core/utils.cpp8
-rw-r--r--src/video_core/video_core.cpp6
-rw-r--r--src/video_core/video_core.vcxproj6
-rw-r--r--src/video_core/video_core.vcxproj.filters4
52 files changed, 1417 insertions, 153 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a588fe19..1c7d9834 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,21 +2,37 @@ cmake_minimum_required(VERSION 2.6)
project(citra)
-SET(GCC_COMPILE_FLAGS "-std=c++11 -fpermissive")
+SET(CXX_COMPILE_FLAGS "-std=c++11")
# silence some spam
add_definitions(-Wno-attributes)
add_definitions(-DSINGLETHREADED)
-add_definitions(${GCC_COMPILE_FLAGS})
+add_definitions(${CXX_COMPILE_FLAGS})
# dependency checking
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/CMakeTests)
-include(FindOpenGL REQUIRED)
include(FindX11 REQUIRED)
find_package(PkgConfig REQUIRED)
+find_package(GLEW REQUIRED)
+find_package(OpenGL REQUIRED)
pkg_search_module(GLFW REQUIRED glfw3)
+# corefoundation is required only on OSX
+IF (APPLE)
+ FIND_LIBRARY(COREFOUNDATION_LIBRARY CoreFoundation)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
+ENDIF (APPLE)
+
+#external includes
include_directories(${GLFW_INCLUDE_DIRS})
+include_directories(${OPENGL_INCLUDE_DIR})
+include_directories(${GLEW_INCLUDE_PATH})
+
+# workaround for GLFW linking on OSX
+link_directories(${GLFW_LIBRARY_DIRS})
+
option(DISABLE_QT4 "Disable Qt4 GUI" OFF)
if(NOT DISABLE_QT4)
include(FindQt4)
@@ -32,14 +48,10 @@ if(NOT DISABLE_QT4)
endif()
# generate git revision information
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules/")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REF_SPEC GIT_REV)
git_describe(GIT_DESC --always --long --dirty)
git_branch_name(GIT_BRANCH)
-
-# external includes
-include_directories(${OPENGL_INCLUDE_DIR})
# internal includes
include_directories(src)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 00000000..cb1067c9
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,102 @@
+# Contributing
+Citra is a brand new project, so we have a great opportunity to keep things clean and well organized early on. As such, coding style is very important when making commits. They aren't very strict rules since we want to be flexible and we understand that under certain circumstances some of them can be counterproductive. Just try to follow as many of them as possible:
+
+### General Rules
+* A lot of code was taken from other projects (e.g. Dolphin, PPSSPP, Gekko, SkyEye). In general, when editing other people's code, follow the style of the module you're in (or better yet, fix the style if it drastically differs from our guide).
+* Line width is typically 100 characters, but this isn't strictly enforced. Please do not use 80-characters.
+* Don't ever introduce new external dependencies into Core
+* Don't use any platform specific code in Core
+* Use namespaces often
+
+### Naming Rules
+* Functions
+ * CamelCase, "_" may also be used for clarity (e.g. ARM_InitCore)
+* Variables
+ * lower_case_underscored
+ * Prefix "g_" if global
+* Classes
+ * CamelCase, "_" may also be used for clarity (e.g. OGL_VideoInterface)
+* Files/Folders
+ * lower_case_underscored
+* Namespaces
+ * CamelCase, "_" may also be used for clarity (e.g. ARM_InitCore)
+
+### Indentation/Whitespace Style
+Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spaces instead.
+
+```cpp
+namespace Example {
+
+// Namespace contents are not indented
+
+// Declare globals at the top
+int g_foo = 0;
+char* g_some_pointer; // Notice the position of the *
+
+enum SomeEnum {
+ COLOR_RED,
+ COLOR_GREEN,
+ COLOR_BLUE
+};
+
+struct Position {
+ int x, y;
+};
+
+// Use "typename" rather than "class" here, just to be consistent
+template
+void FooBar() {
+ int some_array[] = {
+ 5,
+ 25,
+ 7,
+ 42
+ };
+
+ if (note == the_space_after_the_if) {
+ CallAfunction();
+ } else {
+ // Use a space after the // when commenting
+ }
+
+ // Comment directly above code when possible
+ if (some_condition) single_statement();
+
+ // Place a single space after the for loop semicolons
+ for (int i = 0; i != 25; ++i) {
+ // This is how we write loops
+ }
+
+ DoStuff(this, function, call, takes, up, multiple,
+ lines, like, this);
+
+ if (this || condition_takes_up_multiple &&
+ lines && like && this || everything ||
+ alright || then) {
+ }
+
+ switch (var) {
+ // No indentation for case label
+ case 1: {
+ int case_var = var + 3;
+ DoSomething(case_var);
+ break;
+ }
+ case 3:
+ DoSomething(var);
+ return;
+
+ default:
+ // Yes, even break for the last case
+ break;
+ }
+
+ std::vector
+ you_can_declare,
+ a_few,
+ variables,
+ like_this;
+}
+
+}
+```
diff --git a/README.md b/README.md
index 832b647b..e9bd8967 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,16 @@
citra emulator
==============
-[![Travis CI Build Status](https://travis-ci.org/bunnei/citra.svg)](https://travis-ci.org/bunnei/citra)
+[![Travis CI Build Status](https://travis-ci.org/citra-emu/citra.svg)](https://travis-ci.org/citra-emu/citra)
-An experimental open-source Nintendo 3DS emulator/debugger written in C++. At this time, it only emulates a very small subset of 3DS hardware, and therefore is only useful for booting/debugging very simple homebrew demos. Citra is licensed under the GPLv2. Refer to the license.txt file included. Please read the [FAQ](https://github.com/bunnei/citra/wiki/FAQ) before getting started with the project.
+An experimental open-source Nintendo 3DS emulator/debugger written in C++. At this time, it only emulates a very small subset of 3DS hardware, and therefore is only useful for booting/debugging very simple homebrew demos. Citra is licensed under the GPLv2. Refer to the license.txt file included. Please read the [FAQ](https://github.com/citra-emu/citra/wiki/FAQ) before getting started with the project.
For development discussion, please join us @ #citra on [freenode](http://webchat.freenode.net/).
### Development
-If you want to contribute please take a took at the [Coding Style](https://github.com/bunnei/citra/wiki/Coding-Style), [Roadmap](https://github.com/bunnei/citra/wiki/Roadmap) and [Developer Information](https://github.com/bunnei/citra/wiki/Developer-Information) pages. You should as well contact any of the developers in the forum in order to know about the current state of the emulator.
+If you want to contribute please take a took at the [Contributor's Guide](CONTRIBUTING.md), [Roadmap](https://github.com/citra-emu/citra/wiki/Roadmap) and [Developer Information](https://github.com/citra-emu/citra/wiki/Developer-Information) pages. You should as well contact any of the developers in the forum in order to know about the current state of the emulator.
### Building
-* __Windows__: [Windows Build](https://github.com/bunnei/citra/wiki/Windows-Build)
-* __Linux__: [Linux Build](https://github.com/bunnei/citra/wiki/Linux-Build)
+* __Windows__: [Windows Build](https://github.com/citra-emu/citra/wiki/Windows-Build)
+* __Linux__: [Linux Build](https://github.com/citra-emu/citra/wiki/Linux-Build)
diff --git a/externals/cmake-modules/FindGLEW.cmake b/externals/cmake-modules/FindGLEW.cmake
new file mode 100644
index 00000000..105e30eb
--- /dev/null
+++ b/externals/cmake-modules/FindGLEW.cmake
@@ -0,0 +1,47 @@
+#
+# Try to find GLEW library and include path.
+# Once done this will define
+#
+# GLEW_FOUND
+# GLEW_INCLUDE_PATH
+# GLEW_LIBRARY
+#
+
+IF (WIN32)
+ FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
+ $ENV{PROGRAMFILES}/GLEW/include
+ ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include
+ DOC "The directory where GL/glew.h resides")
+ FIND_LIBRARY( GLEW_LIBRARY
+ NAMES glew GLEW glew32 glew32s
+ PATHS
+ $ENV{PROGRAMFILES}/GLEW/lib
+ ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
+ ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
+ DOC "The GLEW library")
+ELSE (WIN32)
+ FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
+ /usr/include
+ /usr/local/include
+ /sw/include
+ /opt/local/include
+ DOC "The directory where GL/glew.h resides")
+ FIND_LIBRARY( GLEW_LIBRARY
+ NAMES GLEW glew
+ PATHS
+ /usr/lib64
+ /usr/lib
+ /usr/local/lib64
+ /usr/local/lib
+ /sw/lib
+ /opt/local/lib
+ DOC "The GLEW library")
+ENDIF (WIN32)
+
+IF (GLEW_INCLUDE_PATH)
+ SET( GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
+ELSE (GLEW_INCLUDE_PATH)
+ SET( GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
+ENDIF (GLEW_INCLUDE_PATH)
+
+MARK_AS_ADVANCED( GLEW_FOUND )
diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt
index 147f51e9..1ad607d7 100644
--- a/src/citra/CMakeLists.txt
+++ b/src/citra/CMakeLists.txt
@@ -1,12 +1,19 @@
set(SRCS citra.cpp
emu_window/emu_window_glfw.cpp)
+set(HEADERS citra.h
+ resource.h)
# NOTE: This is a workaround for CMake bug 0006976 (missing X11_xf86vmode_LIB variable)
if (NOT X11_xf86vmode_LIB)
set(X11_xv86vmode_LIB Xxf86vm)
endif()
-add_executable(citra ${SRCS})
-target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB})
+add_executable(citra ${SRCS} ${HEADERS})
+
+if (APPLE)
+ target_link_libraries(citra core common video_core iconv pthread ${COREFOUNDATION_LIBRARY} ${OPENGL_LIBRARIES} ${GLEW_LIBRARY} ${GLFW_LIBRARIES})
+else()
+ target_link_libraries(citra core common video_core GLEW pthread X11 Xxf86vm Xi Xcursor ${OPENGL_LIBRARIES} ${GLFW_LIBRARIES} rt ${X11_Xrandr_LIB} ${X11_xv86vmode_LIB})
+endif()
#install(TARGETS citra RUNTIME DESTINATION ${bindir})
diff --git a/src/citra/citra.cpp b/src/citra/citra.cpp
index 6f3bc6f8..5a8642d1 100644
--- a/src/citra/citra.cpp
+++ b/src/citra/citra.cpp
@@ -24,7 +24,14 @@ int __cdecl main(int argc, char **argv) {
System::Init(emu_window);
- std::string boot_filename = "homebrew.elf";
+ std::string boot_filename;
+
+ if (argc < 2) {
+ ERROR_LOG(BOOT, "Failed to load ROM: No ROM specified");
+ }
+ else {
+ boot_filename = argv[1];
+ }
std::string error_str;
bool res = Loader::LoadFile(boot_filename, &error_str);
diff --git a/src/citra/emu_window/emu_window_glfw.cpp b/src/citra/emu_window/emu_window_glfw.cpp
index e6943f14..f882a825 100644
--- a/src/citra/emu_window/emu_window_glfw.cpp
+++ b/src/citra/emu_window/emu_window_glfw.cpp
@@ -27,11 +27,23 @@ EmuWindow_GLFW::EmuWindow_GLFW() {
exit(1);
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
+
+#if EMU_PLATFORM == PLATFORM_MACOSX
+ // GLFW on OSX requires these window hints to be set to create a 3.2+ GL context.
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+#endif
+
m_render_window = glfwCreateWindow(VideoCore::kScreenTopWidth,
(VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight),
m_window_title.c_str(), NULL, NULL);
+ if (m_render_window == NULL) {
+ printf("Failed to create GLFW window! Exiting...");
+ exit(1);
+ }
+
// Setup callbacks
glfwSetWindowUserPointer(m_render_window, this);
//glfwSetKeyCallback(m_render_window, OnKeyEvent);
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt
index 594460a7..7f880df8 100644
--- a/src/citra_qt/CMakeLists.txt
+++ b/src/citra_qt/CMakeLists.txt
@@ -2,12 +2,31 @@ set(SRCS
bootmanager.cpp
debugger/callstack.cpp
debugger/disassembler.cpp
+ debugger/graphics.cpp
+ debugger/graphics_cmdlists.cpp
debugger/ramview.cpp
debugger/registers.cpp
hotkeys.cpp
main.cpp
config/controller_config.cpp
config/controller_config_util.cpp)
+set (HEADERS
+ bootmanager.hxx
+ debugger/callstack.hxx
+ debugger/disassembler.hxx
+ debugger/ramview.hxx
+ debugger/registers.hxx
+ hotkeys.hxx
+ main.hxx
+ ui_callstack.h
+ ui_controller_config.h
+ ui_disassembler.h
+ ui_hotkeys.h
+ ui_main.h
+ ui_registers.h
+ version.h
+ config/controller_config.hxx
+ config/controller_config_util.hxx)
qt4_wrap_ui(UI_HDRS
debugger/callstack.ui
@@ -21,6 +40,8 @@ qt4_wrap_cpp(MOC_SRCS
bootmanager.hxx
debugger/callstack.hxx
debugger/disassembler.hxx
+ debugger/graphics.hxx
+ debugger/graphics_cmdlists.hxx
debugger/registers.hxx
debugger/ramview.hxx
hotkeys.hxx
@@ -32,7 +53,11 @@ qt4_wrap_cpp(MOC_SRCS
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(./)
-add_executable(citra-qt ${SRCS} ${MOC_SRCS} ${UI_HDRS})
-target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} rt GLEW ${GLFW_LIBRARIES})
+add_executable(citra-qt ${SRCS} ${HEADERS} ${MOC_SRCS} ${UI_HDRS})
+if (APPLE)
+ target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES})
+else()
+ target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} rt GLEW ${GLFW_LIBRARIES})
+endif()
#install(TARGETS citra-qt RUNTIME DESTINATION ${bindir})
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index cf9e1bff..f8511641 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -50,7 +50,7 @@ void EmuThread::run()
void EmuThread::Stop()
{
- if (!isRunning())
+ if (!isRunning())
{
INFO_LOG(MASTER_LOG, "EmuThread::Stop called while emu thread wasn't running, returning...");
return;
@@ -65,7 +65,7 @@ void EmuThread::Stop()
terminate();
wait(1000);
if (isRunning())
- WARN_LOG(MASTER_LOG, "EmuThread STILL running, something is wrong here...");
+ WARN_LOG(MASTER_LOG, "EmuThread STILL running, something is wrong here...");
}
INFO_LOG(MASTER_LOG, "EmuThread stopped");
}
@@ -76,9 +76,8 @@ void EmuThread::Stop()
class GGLWidgetInternal : public QGLWidget
{
public:
- GGLWidgetInternal(GRenderWindow* parent) : QGLWidget(parent)
+ GGLWidgetInternal(QGLFormat fmt, GRenderWindow* parent) : QGLWidget(parent)
{
- setAutoBufferSwap(false);
doneCurrent();
parent_ = parent;
}
@@ -106,8 +105,13 @@ EmuThread& GRenderWindow::GetEmuThread()
GRenderWindow::GRenderWindow(QWidget* parent) : QWidget(parent), emu_thread(this)
{
// TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, WA_DontShowOnScreen, WA_DeleteOnClose
-
- child = new GGLWidgetInternal(this);
+ QGLFormat fmt;
+ fmt.setProfile(QGLFormat::CoreProfile);
+ fmt.setVersion(3,2);
+ fmt.setSampleBuffers(true);
+ fmt.setSamples(4);
+
+ child = new GGLWidgetInternal(fmt, this);
QBoxLayout* layout = new QHBoxLayout(this);
resize(VideoCore::kScreenTopWidth, VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight);
layout->addWidget(child);
@@ -147,12 +151,12 @@ void GRenderWindow::DoneCurrent()
void GRenderWindow::PollEvents() {
// TODO(ShizZy): Does this belong here? This is a reasonable place to update the window title
// from the main thread, but this should probably be in an event handler...
- /*
- static char title[128];
+ /*
+ static char title[128];
sprintf(title, "%s (FPS: %02.02f)", window_title_.c_str(),
video_core::g_renderer->current_fps());
setWindowTitle(title);
- */
+ */
}
void GRenderWindow::BackupGeometry()
@@ -185,26 +189,26 @@ QByteArray GRenderWindow::saveGeometry()
void GRenderWindow::keyPressEvent(QKeyEvent* event)
{
- /*
- bool key_processed = false;
+ /*
+ bool key_processed = false;
for (unsigned int channel = 0; channel < 4 && controller_interface(); ++channel)
if (controller_interface()->SetControllerStatus(channel, event->key(), input_common::GCController::PRESSED))
key_processed = true;
if (!key_processed)
QWidget::keyPressEvent(event);
- */
+ */
}
void GRenderWindow::keyReleaseEvent(QKeyEvent* event)
{
- /*
- bool key_processed = false;
+ /*
+ bool key_processed = false;
for (unsigned int channel = 0; channel < 4 && controller_interface(); ++channel)
if (controller_interface()->SetControllerStatus(channel, event->key(), input_common::GCController::RELEASED))
key_processed = true;
if (!key_processed)
QWidget::keyPressEvent(event);
- */
+ */
} \ No newline at end of file
diff --git a/src/citra_qt/citra_qt.vcxproj b/src/citra_qt/citra_qt.vcxproj
index 3f24bbfb..c99c8eee 100644
--- a/src/citra_qt/citra_qt.vcxproj
+++ b/src/citra_qt/citra_qt.vcxproj
@@ -130,6 +130,8 @@
<ClCompile Include="config\controller_config.cpp" />
<ClCompile Include="config\controller_config_util.cpp" />
<ClCompile Include="debugger\callstack.cpp" />
+ <ClCompile Include="debugger\graphics.cpp" />
+ <ClCompile Include="debugger\graphics_cmdlists.cpp" />
<ClCompile Include="debugger\registers.cpp" />
<ClCompile Include="debugger\disassembler.cpp" />
<ClCompile Include="debugger\ramview.cpp" />
@@ -143,9 +145,11 @@
<MOC Include="..\..\externals\qhexedit\qhexedit_p.h" />
<MOC Include="..\..\externals\qhexedit\xbytearray.h" />
<MOC Include="debugger\callstack.hxx" />
- <MOC Include="debugger\registers.hxx" />
<MOC Include="debugger\disassembler.hxx" />
+ <MOC Include="debugger\graphics.hxx" />
+ <MOC Include="debugger\graphics_cmdlists.hxx" />
<MOC Include="debugger\ramview.hxx" />
+ <MOC Include="debugger\registers.hxx" />
<MOC Include="bootmanager.hxx" />
<MOC Include="hotkeys.hxx" />
<MOC Include="main.hxx" />
@@ -182,4 +186,4 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="qt-build.targets" />
</ImportGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/citra_qt/citra_qt.vcxproj.filters b/src/citra_qt/citra_qt.vcxproj.filters
index 2b3838e2..903082c3 100644
--- a/src/citra_qt/citra_qt.vcxproj.filters
+++ b/src/citra_qt/citra_qt.vcxproj.filters
@@ -36,10 +36,16 @@
<ClCompile Include="debugger\callstack.cpp">
<Filter>debugger</Filter>
</ClCompile>
- <ClCompile Include="debugger\ramview.cpp">
+ <ClCompile Include="debugger\disassembler.cpp">
<Filter>debugger</Filter>
</ClCompile>
- <ClCompile Include="debugger\disassembler.cpp">
+ <ClCompile Include="debugger\graphics.cpp">
+ <Filter>debugger</Filter>
+ </ClCompile>
+ <ClCompile Include="debugger\graphics_cmdlists.cpp">
+ <Filter>debugger</Filter>
+ </ClCompile>
+ <ClCompile Include="debugger\ramview.cpp">
<Filter>debugger</Filter>
</ClCompile>
<ClCompile Include="debugger\registers.cpp">
@@ -65,10 +71,16 @@
<MOC Include="debugger\callstack.hxx">
<Filter>debugger</Filter>
</MOC>
- <MOC Include="debugger\ramview.hxx">
+ <MOC Include="debugger\disassembler.hxx">
<Filter>debugger</Filter>
</MOC>
- <MOC Include="debugger\disassembler.hxx">
+ <MOC Include="debugger\graphics.hxx">
+ <Filter>debugger</Filter>
+ </MOC>
+ <MOC Include="debugger\graphics_cmdlists.hxx">
+ <Filter>debugger</Filter>
+ </MOC>
+ <MOC Include="debugger\ramview.hxx">
<Filter>debugger</Filter>
</MOC>
<MOC Include="debugger\registers.hxx">
@@ -106,4 +118,4 @@
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/citra_qt/debugger/graphics.cpp b/src/citra_qt/debugger/graphics.cpp
new file mode 100644
index 00000000..9aaade8f
--- /dev/null
+++ b/src/citra_qt/debugger/graphics.cpp
@@ -0,0 +1,83 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "graphics.hxx"
+#include <QListView>
+#include <QVBoxLayout>
+#include <QDebug>
+
+extern GraphicsDebugger g_debugger;
+
+GPUCommandStreamItemModel::GPUCommandStreamItemModel(QObject* parent) : QAbstractListModel(parent), command_count(0)
+{
+ connect(this, SIGNAL(GXCommandFinished(int)), this, SLOT(OnGXCommandFinishedInternal(int)));
+}
+
+int GPUCommandStreamItemModel::rowCount(const QModelIndex& parent) const
+{
+ return command_count;
+}
+
+QVariant GPUCommandStreamItemModel::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ int command_index = index.row();
+ const GSP_GPU::GXCommand& command = GetDebugger()->ReadGXCommandHistory(command_index);
+ if (role == Qt::DisplayRole)
+ {
+ std::map<GSP_GPU::GXCommandId, const char*> command_names;
+ command_names[GSP_GPU::GXCommandId::REQUEST_DMA] = "REQUEST_DMA";
+ command_names[GSP_GPU::GXCommandId::SET_COMMAND_LIST_FIRST] = "SET_COMMAND_LIST_FIRST";
+ command_names[GSP_GPU::GXCommandId::SET_MEMORY_FILL] = "SET_MEMORY_FILL";
+ command_names[GSP_GPU::GXCommandId::SET_DISPLAY_TRANSFER] = "SET_DISPLAY_TRANSFER";
+ command_names[GSP_GPU::GXCommandId::SET_TEXTURE_COPY] = "SET_TEXTURE_COPY";
+ command_names[GSP_GPU::GXCommandId::SET_COMMAND_LIST_LAST] = "SET_COMMAND_LIST_LAST";
+ QString str = QString("%1 %2 %3 %4 %5 %6 %7 %8 %9").arg(command_names[static_cast<GSP_GPU::GXCommandId>(command.id)])
+ .arg(command.data[0], 8, 16, QLatin1Char('0'))
+ .arg(command.data[1], 8, 16, QLatin1Char('0'))
+ .arg(command.data[2], 8, 16, QLatin1Char('0'))
+ .arg(command.data[3], 8, 16, QLatin1Char('0'))
+ .arg(command.data[4], 8, 16, QLatin1Char('0'))
+ .arg(command.data[5], 8, 16, QLatin1Char('0'))
+ .arg(command.data[6], 8, 16, QLatin1Char('0'))
+ .arg(command.data[7], 8, 16, QLatin1Char('0'));
+ return QVariant(str);
+ }
+ else
+ {
+ return QVariant();
+ }
+}
+
+void GPUCommandStreamItemModel::GXCommandProcessed(int total_command_count)
+{
+ emit GXCommandFinished(total_command_count);
+}
+
+void GPUCommandStreamItemModel::OnGXCommandFinishedInternal(int total_command_count)
+{
+ if (total_command_count == 0)
+ return;
+
+ int prev_command_count = command_count;
+ command_count = total_command_count;
+ emit dataChanged(index(prev_command_count,0), index(total_command_count-1,0));
+}
+
+
+GPUCommandStreamWidget::GPUCommandStreamWidget(QWidget* parent) : QDockWidget(tr("Graphics Debugger"), parent)
+{
+ // TODO: set objectName!
+
+ GPUCommandStreamItemModel* command_model = new GPUCommandStreamItemModel(this);
+ g_debugger.RegisterObserver(command_model);
+
+ QListView* command_list = new QListView;
+ command_list->setModel(command_model);
+ command_list->setFont(QFont("monospace"));
+
+ setWidget(command_list);
+}
diff --git a/src/citra_qt/debugger/graphics.hxx b/src/citra_qt/debugger/graphics.hxx
new file mode 100644
index 00000000..72656f93
--- /dev/null
+++ b/src/citra_qt/debugger/graphics.hxx
@@ -0,0 +1,43 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <QAbstractListModel>
+#include <QDockWidget>
+
+#include "video_core/gpu_debugger.h"
+
+class GPUCommandStreamItemModel : public QAbstractListModel, public GraphicsDebugger::DebuggerObserver
+{
+ Q_OBJECT
+
+public:
+ GPUCommandStreamItemModel(QObject* parent);
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
+
+public:
+ void GXCommandProcessed(int total_command_count) override;
+
+public slots:
+ void OnGXCommandFinishedInternal(int total_command_count);
+
+signals:
+ void GXCommandFinished(int total_command_count);
+
+private:
+ int command_count;
+};
+
+class GPUCommandStreamWidget : public QDockWidget
+{
+ Q_OBJECT
+
+public:
+ GPUCommandStreamWidget(QWidget* parent = 0);
+
+private:
+};
diff --git a/src/citra_qt/debugger/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics_cmdlists.cpp
new file mode 100644
index 00000000..195197ef
--- /dev/null
+++ b/src/citra_qt/debugger/graphics_cmdlists.cpp
@@ -0,0 +1,139 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "graphics_cmdlists.hxx"
+#include <QTreeView>
+
+extern GraphicsDebugger g_debugger;
+
+GPUCommandListModel::GPUCommandListModel(QObject* parent) : QAbstractItemModel(parent)
+{
+ root_item = new TreeItem(TreeItem::ROOT, 0, NULL, this);
+
+ connect(this, SIGNAL(CommandListCalled()), this, SLOT(OnCommandListCalledInternal()), Qt::UniqueConnection);
+}
+
+QModelIndex GPUCommandListModel::index(int row, int column, const QModelIndex& parent) const
+{
+ TreeItem* item;
+
+ if (!parent.isValid()) {
+ item = root_item;
+ } else {
+ item = (TreeItem*)parent.internalPointer();
+ }
+
+ return createIndex(row, column, item->children[row]);
+}
+
+QModelIndex GPUCommandListModel::parent(const QModelIndex& child) const
+{
+ if (!child.isValid())
+ return QModelIndex();
+
+ TreeItem* item = (TreeItem*)child.internalPointer();
+
+ if (item->parent == NULL)
+ return QModelIndex();
+
+ return createIndex(item->parent->index, 0, item->parent);
+}
+
+int GPUCommandListModel::rowCount(const QModelIndex& parent) const
+{
+ TreeItem* item;
+ if (!parent.isValid()) {
+ item = root_item;
+ } else {
+ item = (TreeItem*)parent.internalPointer();
+ }
+ return item->children.size();
+}
+
+int GPUCommandListModel::columnCount(const QModelIndex& parent) const
+{
+ return 2;
+}
+
+QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ const TreeItem* item = (const TreeItem*)index.internalPointer();
+
+ if (item->type == TreeItem::COMMAND_LIST)
+ {
+ const GraphicsDebugger::PicaCommandList& cmdlist = command_lists[item->index].second;
+ u32 address = command_lists[item->index].first;
+
+ if (role == Qt::DisplayRole && index.column() == 0)
+ {
+ return QVariant(QString("0x%1 bytes at 0x%2").arg(cmdlist.size(), 0, 16).arg(address, 8, 16, QLatin1Char('0')));
+ }
+ }
+ else
+ {
+ // index refers to a specific command
+ const GraphicsDebugger::PicaCommandList& cmdlist = command_lists[item->parent->index].second;
+ const GraphicsDebugger::PicaCommand& cmd = cmdlist[item->index];
+ const Pica::CommandHeader& header = cmd.GetHeader();
+
+ if (role == Qt::DisplayRole) {
+ QString content;
+ if (index.column() == 0) {
+ content = Pica::command_names[header.cmd_id];
+ content.append(" ");
+ } else if (index.column() == 1) {
+ for (int j = 0; j < cmd.size(); ++j)
+ content.append(QString("%1 ").arg(cmd[j], 8, 16, QLatin1Char('0')));
+ }
+
+ return QVariant(content);
+ }
+ }
+
+ return QVariant();
+}
+
+void GPUCommandListModel::OnCommandListCalled(const GraphicsDebugger::PicaCommandList& lst, bool is_new)
+{
+ emit CommandListCalled();
+}
+
+
+void GPUCommandListModel::OnCommandListCalledInternal()
+{
+ beginResetModel();
+
+ command_lists = GetDebugger()->GetCommandLists();
+
+ // delete root item and rebuild tree
+ delete root_item;
+ root_item = new TreeItem(TreeItem::ROOT, 0, NULL, this);
+
+ for (int command_list_idx = 0; command_list_idx < command_lists.size(); ++command_list_idx) {
+ TreeItem* command_list_item = new TreeItem(TreeItem::COMMAND_LIST, command_list_idx, root_item, root_item);
+ root_item->children.push_back(command_list_item);
+
+ const GraphicsDebugger::PicaCommandList& command_list = command_lists[command_list_idx].second;
+ for (int command_idx = 0; command_idx < command_list.size(); ++command_idx) {
+ TreeItem* command_item = new TreeItem(TreeItem::COMMAND, command_idx, command_list_item, command_list_item);
+ command_list_item->children.push_back(command_item);
+ }
+ }
+
+ endResetModel();
+}
+
+GPUCommandListWidget::GPUCommandListWidget(QWidget* parent) : QDockWidget(tr("Pica Command List"), parent)
+{
+ GPUCommandListModel* model = new GPUCommandListModel(this);
+ g_debugger.RegisterObserver(model);
+
+ QTreeView* tree_widget = new QTreeView;
+ tree_widget->setModel(model);
+ tree_widget->setFont(QFont("monospace"));
+ setWidget(tree_widget);
+}
diff --git a/src/citra_qt/debugger/graphics_cmdlists.hxx b/src/citra_qt/debugger/graphics_cmdlists.hxx
new file mode 100644
index 00000000..b4e6e3c8
--- /dev/null
+++ b/src/citra_qt/debugger/graphics_cmdlists.hxx
@@ -0,0 +1,64 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <QAbstractItemModel>
+#include <QDockWidget>
+
+#include "video_core/gpu_debugger.h"
+
+// TODO: Rename class, since it's not actually a list model anymore...
+class GPUCommandListModel : public QAbstractItemModel, public GraphicsDebugger::DebuggerObserver
+{
+ Q_OBJECT
+
+public:
+ GPUCommandListModel(QObject* parent);
+
+ QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex& child) const;
+ int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
+
+public:
+ void OnCommandListCalled(const GraphicsDebugger::PicaCommandList& lst, bool is_new) override;
+
+public slots:
+ void OnCommandListCalledInternal();
+
+signals:
+ void CommandListCalled();
+
+private:
+ struct TreeItem : public QObject
+ {
+ enum Type {
+ ROOT,
+ COMMAND_LIST,
+ COMMAND
+ };
+
+ TreeItem(Type type, int index, TreeItem* item_parent, QObject* parent) : QObject(parent), type(type), index(index), parent(item_parent) {}
+
+ Type type;
+ int index;
+ std::vector<TreeItem*> children;
+ TreeItem* parent;
+ };
+
+ std::vector<std::pair<u32,GraphicsDebugger::PicaCommandList>> command_lists;
+ TreeItem* root_item;
+};
+
+class GPUCommandListWidget : public QDockWidget
+{
+ Q_OBJECT
+
+public:
+ GPUCommandListWidget(QWidget* parent = 0);
+
+private:
+};
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 9be98290..087716c0 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -19,6 +19,8 @@
#include "debugger/registers.hxx"
#include "debugger/callstack.hxx"
#include "debugger/ramview.hxx"
+#include "debugger/graphics.hxx"
+#include "debugger/graphics_cmdlists.hxx"
#include "core/system.h"
#include "core/loader.h"
@@ -47,10 +49,20 @@ GMainWindow::GMainWindow()
addDockWidget(Qt::RightDockWidgetArea, callstackWidget);
callstackWidget->hide();
+ graphicsWidget = new GPUCommandStreamWidget(this);
+ addDockWidget(Qt::RightDockWidgetArea, graphicsWidget);
+ callstackWidget->hide();
+
+ graphicsCommandsWidget = new GPUCommandListWidget(this);
+ addDockWidget(Qt::RightDockWidgetArea, graphicsCommandsWidget);
+ callstackWidget->hide();
+
QMenu* debug_menu = ui.menu_View->addMenu(tr("Debugging"));
debug_menu->addAction(disasmWidget->toggleViewAction());
debug_menu->addAction(registersWidget->toggleViewAction());
debug_menu->addAction(callstackWidget->toggleViewAction());
+ debug_menu->addAction(graphicsWidget->toggleViewAction());
+ debug_menu->addAction(graphicsCommandsWidget->toggleViewAction());
// Set default UI state
// geometry: 55% of the window contents are in the upper screen half, 45% in the lower half
diff --git a/src/citra_qt/main.hxx b/src/citra_qt/main.hxx
index fa122f76..6bcb37a3 100644
--- a/src/citra_qt/main.hxx
+++ b/src/citra_qt/main.hxx
@@ -10,6 +10,8 @@ class GRenderWindow;
class DisassemblerWidget;
class RegistersWidget;
class CallstackWidget;
+class GPUCommandStreamWidget;
+class GPUCommandListWidget;
class GMainWindow : public QMainWindow
{
@@ -50,6 +52,8 @@ private:
DisassemblerWidget* disasmWidget;
RegistersWidget* registersWidget;
CallstackWidget* callstackWidget;
+ GPUCommandStreamWidget* graphicsWidget;
+ GPUCommandListWidget* graphicsCommandsWidget;
};
#endif // _CITRA_QT_MAIN_HXX_
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 5eaf6736..aae18339 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -19,4 +19,43 @@ set(SRCS break_points.cpp
timer.cpp
utf8.cpp)
-add_library(common STATIC ${SRCS})
+set(HEADERS atomic.h
+ atomic_gcc.h
+ atomic_win32.h
+ bit_field.h
+ break_points.h
+ chunk_file.h
+ common_funcs.h
+ common_paths.h
+ common_types.h
+ common.h
+ console_listener.h
+ cpu_detect.h
+ debug_interface.h
+ emu_window.h
+ extended_trace.h
+ fifo_queue.h
+ file_search.h
+ file_util.h
+ hash.h
+ linear_disk_cache.h
+ log_manager.h
+ log.h
+ math_util.h
+ mem_arena.h
+ memory_util.h
+ msg_handler.h
+ platform.h
+ scm_rev.h
+ std_condition_variable.h
+ std_mutex.h
+ std_thread.h
+ string_util.h
+ swap.h
+ symbols.h
+ thread.h
+ thunk.h
+ timer.h
+ utf8.h)
+
+add_library(common STATIC ${SRCS} ${HEADERS})
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index a4120585..8c9f839d 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -654,7 +654,8 @@ inline PointerWrapSection::~PointerWrapSection() {
}
-class CChunkFileReader
+// Commented out because it is currently unused, and breaks builds on OSX
+/*class CChunkFileReader
{
public:
enum Error {
@@ -869,6 +870,6 @@ private:
int UncompressedSize;
char GitVersion[32];
};
-};
+}; */
#endif // _POINTERWRAP_H_
diff --git a/src/common/common.h b/src/common/common.h
index 41875785..09027cae 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -21,7 +21,7 @@
#define STACKALIGN
-#if __cplusplus >= 201103 || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__)
+#if __cplusplus >= 201103L || defined(_MSC_VER) || defined(__GXX_EXPERIMENTAL_CXX0X__)
#define HAVE_CXX11_SYNTAX 1
#endif
@@ -96,8 +96,6 @@ private:
// Windows compatibility
#ifndef _WIN32
-#include <limits.h>
-#define MAX_PATH PATH_MAX
#ifdef _LP64
#define _M_X64 1
#else
@@ -159,4 +157,48 @@ enum EMUSTATE_CHANGE
EMUSTATE_CHANGE_STOP
};
+
+#ifdef _MSC_VER
+#ifndef _XBOX
+inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); }
+inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
+inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); }
+#else
+inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); }
+inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); }
+inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); }
+#endif
+#else
+// TODO: speedup
+inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
+inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);}
+inline unsigned long long bswap64(unsigned long long x) {return ((unsigned long long)bswap32(x) << 32) | bswap32(x >> 32); }
+#endif
+
+inline float bswapf(float f) {
+ union {
+ float f;
+ unsigned int u32;
+ } dat1, dat2;
+
+ dat1.f = f;
+ dat2.u32 = bswap32(dat1.u32);
+
+ return dat2.f;
+}
+
+inline double bswapd(double f) {
+ union {
+ double f;
+ unsigned long long u64;
+ } dat1, dat2;
+
+ dat1.f = f;
+ dat2.u64 = bswap64(dat1.u64);
+
+ return dat2.f;
+}
+
+#include "swap.h"
+
#endif // _COMMON_H_
diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj
index 86295a48..1f5c714c 100644
--- a/src/common/common.vcxproj
+++ b/src/common/common.vcxproj
@@ -182,6 +182,7 @@
<ClInclude Include="mem_arena.h" />
<ClInclude Include="msg_handler.h" />
<ClInclude Include="platform.h" />
+ <ClInclude Include="register_set.h" />
<ClInclude Include="scm_rev.h" />
<ClInclude Include="std_condition_variable.h" />
<ClInclude Include="std_mutex.h" />
@@ -221,4 +222,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters
index 84cfa883..e8c4ce36 100644
--- a/src/common/common.vcxproj.filters
+++ b/src/common/common.vcxproj.filters
@@ -4,6 +4,7 @@
<ClInclude Include="atomic.h" />
<ClInclude Include="atomic_gcc.h" />
<ClInclude Include="atomic_win32.h" />
+ <ClInclude Include="bit_field.h" />
<ClInclude Include="break_points.h" />
<ClInclude Include="chunk_file.h" />
<ClInclude Include="common.h" />
@@ -28,6 +29,7 @@
<ClInclude Include="memory_util.h" />
<ClInclude Include="msg_handler.h" />
<ClInclude Include="platform.h" />
+ <ClInclude Include="register_set.h" />
<ClInclude Include="std_condition_variable.h" />
<ClInclude Include="std_mutex.h" />
<ClInclude Include="std_thread.h" />
@@ -39,7 +41,6 @@
<ClInclude Include="utf8.h" />
<ClInclude Include="symbols.h" />
<ClInclude Include="scm_rev.h" />
- <ClInclude Include="bit_field.h" />
<ClInclude Include="thread_queue_list.h" />
</ItemGroup>
<ItemGroup>
@@ -65,4 +66,4 @@
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/common/common_types.h b/src/common/common_types.h
index 4289b88d..40241050 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -62,7 +62,7 @@ typedef signed long long s64; ///< 64-bit signed int
typedef float f32; ///< 32-bit floating point
typedef double f64; ///< 64-bit floating point
-#include "common/swap.h"
+#include "common/common.h"
/// Union for fast 16-bit type casting
union t16 {
@@ -100,6 +100,7 @@ union t128 {
__m128 a; ///< 128-bit floating point (__m128 maps to the XMM[0-7] registers)
};
+namespace common {
/// Rectangle data structure
class Rect {
public:
@@ -123,3 +124,4 @@ public:
return (x0_ == val.x0_ && y0_ == val.y0_ && x1_ == val.x1_ && y1_ == val.y1_);
}
};
+}
diff --git a/src/common/log.h b/src/common/log.h
index a3c8bdde..e923224e 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -63,7 +63,7 @@ enum LOG_TYPE {
NDMA,
HLE,
RENDER,
- LCD,
+ GPU,
HW,
TIME,
NETPLAY,
diff --git a/src/common/log_manager.cpp b/src/common/log_manager.cpp
index b6caba3b..4e1cb60b 100644
--- a/src/common/log_manager.cpp
+++ b/src/common/log_manager.cpp
@@ -67,7 +67,7 @@ LogManager::LogManager()
m_Log[LogTypes::WII_IPC_ES] = new LogContainer("WII_IPC_ES", "WII IPC ES");
m_Log[LogTypes::WII_IPC_FILEIO] = new LogContainer("WII_IPC_FILEIO", "WII IPC FILEIO");
m_Log[LogTypes::RENDER] = new LogContainer("RENDER", "RENDER");
- m_Log[LogTypes::LCD] = new LogContainer("LCD", "LCD");
+ m_Log[LogTypes::GPU] = new LogContainer("GPU", "GPU");
m_Log[LogTypes::SVC] = new LogContainer("SVC", "Supervisor Call HLE");
m_Log[LogTypes::NDMA] = new LogContainer("NDMA", "NDMA");
m_Log[LogTypes::HLE] = new LogContainer("HLE", "High Level Emulation");
diff --git a/src/common/platform.h b/src/common/platform.h
index 1e8dffbd..b02b52cd 100644
--- a/src/common/platform.h
+++ b/src/common/platform.h
@@ -47,7 +47,7 @@
#define EMU_PLATFORM PLATFORM_WINDOWS
#elif defined( __APPLE__ ) || defined( __APPLE_CC__ )
-#define EMU_PLATFORM PLATFORM_MAXOSX
+#define EMU_PLATFORM PLATFORM_MACOSX
#elif defined(__linux__)
#define EMU_PLATFORM PLATFORM_LINUX
@@ -87,7 +87,6 @@ inline struct tm* localtime_r(const time_t *clock, struct tm *result) {
#define __stdcall
#define __cdecl
-#define LONG long
#define BOOL bool
#define DWORD u32
@@ -97,7 +96,6 @@ inline struct tm* localtime_r(const time_t *clock, struct tm *result) {
// TODO: Hacks..
#include <limits.h>
-#define MAX_PATH PATH_MAX
#include <strings.h>
#define stricmp(str1, str2) strcasecmp(str1, str2)
diff --git a/src/common/register_set.h b/src/common/register_set.h
new file mode 100644
index 00000000..0418551b
--- /dev/null
+++ b/src/common/register_set.h
@@ -0,0 +1,161 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+// Copyright 2014 Tony Wasserka
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// * Neither the name of the owner nor the names of its contributors may
+// be used to endorse or promote products derived from this software
+// without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+/*
+ * Standardized way to define a group of registers and corresponding data structures. To define
+ * a new register set, first define struct containing an enumeration called "Id" containing
+ * all register IDs and a template union called "Struct". Specialize the Struct union for any
+ * register ID which needs to be accessed in a specialized way. You can then declare the object
+ * containing all register values using the RegisterSet<BaseType, DefiningStruct> type, where
+ * BaseType is the underlying type of each register (e.g. u32).
+ * Of course, you'll usually want to implement the Struct template such that they are of the same
+ * size as BaseType. However, it's also possible to make it larger, e.g. when you want to describe
+ * multiple registers with the same structure.
+ *
+ * Example:
+ *
+ * struct Regs {
+ * enum Id : u32 {
+ * Value1 = 0,
+ * Value2 = 1,
+ * Value3 = 2,
+ * NumIds = 3
+ * };
+ *
+ * // declare register definition structures
+ * template<Id id>
+ * union Struct;
+ * };
+ *
+ * // Define register set object
+ * RegisterSet<u32, CommandIds> registers;
+ *
+ * // define register definition structures
+ * template<>
+ * union Regs::Struct<Regs::Value1> {
+ * BitField<0, 4, u32> some_field;
+ * BitField<4, 3, u32> some_other_field;
+ * };
+ *
+ * Usage in external code (within SomeNamespace scope):
+ *
+ * For a register which maps to a single index:
+ * registers.Get<Regs::Value1>().some_field = some_value;
+ *
+ * For a register which maps to different indices, e.g. a group of similar registers
+ * registers.Get<Regs::Value1>(index).some_field = some_value;
+ *
+ *
+ * @tparam BaseType Base type used for storing individual registers, e.g. u32
+ * @tparam RegDefinition Class defining an enumeration called "Id" and a template<Id id> union, as described above.
+ * @note RegDefinition::Id needs to have an enum value called NumIds defining the number of registers to be allocated.
+ */
+template<typename BaseType, typename RegDefinition>
+struct RegisterSet {
+ // Register IDs
+ using Id = typename RegDefinition::Id;
+
+ // type used for *this
+ using ThisType = RegisterSet<BaseType, RegDefinition>;
+
+ // Register definition structs, defined in RegDefinition
+ template<Id id>
+ using Struct = typename RegDefinition::template Struct<id>;
+
+
+ /*
+ * Lookup register with the given id and return it as the corresponding structure type.
+ * @note This just forwards the arguments to Get(Id).
+ */
+ template<Id id>
+ const Struct<id>& Get() const {
+ return Get<id>(id);
+ }
+
+ /*
+ * Lookup register with the given id and return it as the corresponding structure type.
+ * @note This just forwards the arguments to Get(Id).
+ */
+ template<Id id>
+ Struct<id>& Get() {
+ return Get<id>(id);
+ }
+
+ /*
+ * Lookup register with the given index and return it as the corresponding structure type.
+ * @todo Is this portable with regards to structures larger than BaseType?
+ * @note if index==id, you don't need to specify the function parameter.
+ */
+ template<Id id>
+ const Struct<id>& Get(const Id& index) const {
+ const int idx = static_cast<size_t>(index);
+ return *reinterpret_cast<const Struct<id>*>(&raw[idx]);
+ }
+
+ /*
+ * Lookup register with the given index and return it as the corresponding structure type.
+ * @note This just forwards the arguments to the const version of Get(Id).
+ * @note if index==id, you don't need to specify the function parameter.
+ */
+ template<Id id>
+ Struct<id>& Get(const Id& index) {
+ return const_cast<Struct<id>&>(GetThis().Get<id>(index));
+ }
+
+ /*
+ * Plain array access.
+ * @note If you want to have this casted to a register defininition struct, use Get() instead.
+ */
+ const BaseType& operator[] (const Id& id) const {
+ return raw[static_cast<size_t>(id)];
+ }
+
+ /*
+ * Plain array access.
+ * @note If you want to have this casted to a register defininition struct, use Get() instead.
+ * @note This operator just forwards its argument to the const version.
+ */
+ BaseType& operator[] (const Id& id) {
+ return const_cast<BaseType&>(GetThis()[id]);
+ }
+
+private:
+ /*
+ * Returns a const reference to "this".
+ */
+ const ThisType& GetThis() const {
+ return static_cast<const ThisType&>(*this);
+ }
+
+ BaseType raw[Id::NumIds];
+};
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 7236033c..7116b88e 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -44,8 +44,54 @@ set(SRCS core.cpp
hle/service/ndm.cpp
hle/service/service.cpp
hle/service/srv.cpp
+ hw/gpu.cpp
hw/hw.cpp
- hw/lcd.cpp
hw/ndma.cpp)
-add_library(core STATIC ${SRCS})
+set(HEADERS core.h
+ core_timing.h
+ loader.h
+ mem_map.h
+ system.h
+ arm/disassembler/arm_disasm.h
+ arm/disassembler/load_symbol_map.h
+ arm/interpreter/arm_interpreter.h
+ arm/interpreter/arm_regformat.h
+ arm/interpreter/armcpu.h
+ arm/interpreter/armdefs.h
+ arm/interpreter/armemu.h
+ arm/interpreter/armmmu.h
+ arm/interpreter/armos.h
+ arm/interpreter/skyeye_defs.h
+ arm/interpreter/mmu/arm1176jzf_s_mmu.h
+ arm/interpreter/mmu/cache.h
+ arm/interpreter/mmu/rb.h
+ arm/interpreter/mmu/sa_mmu.h
+ arm/interpreter/mmu/tlb.h
+ arm/interpreter/mmu/wb.h
+ arm/interpreter/vfp/asm_vfp.h
+ arm/interpreter/vfp/vfp.h
+ arm/interpreter/vfp/vfp_helper.h
+ elf/elf_reader.h
+ elf/elf_types.h
+ file_sys/directory_file_system.h
+ file_sys/file_sys.h
+ file_sys/meta_file_system.h
+ hle/config_mem.h
+ hle/coprocessor.h
+ hle/hle.h
+ hle/svc.h
+ hle/kernel/kernel.h
+ hle/kernel/mutex.h
+ hle/kernel/thread.h
+ hle/function_wrappers.h
+ hle/service/apt.h
+ hle/service/gsp.h
+ hle/service/hid.h
+ hle/service/service.h
+ hle/service/srv.h
+ hw/gpu.h
+ hw/hw.h
+ hw/ndma.h)
+
+add_library(core STATIC ${SRCS} ${HEADERS})
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 316b50fb..be677ae2 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -25,7 +25,7 @@ public:
*/
void Run(int num_instructions) {
ExecuteInstructions(num_instructions);
- num_instructions += num_instructions;
+ this->num_instructions += num_instructions;
}
/// Step CPU by one instruction
diff --git a/src/core/arm/interpreter/mmu/maverick.cpp b/src/core/arm/interpreter/mmu/maverick.cpp
index 0e98ef22..adcc2efb 100644
--- a/src/core/arm/interpreter/mmu/maverick.cpp
+++ b/src/core/arm/interpreter/mmu/maverick.cpp
@@ -86,12 +86,12 @@ static union
} reg_conv;
static void
-printf_nothing (void *foo, ...)
+printf_nothing (const char *foo, ...)
{
}
static void
-cirrus_not_implemented (char *insn)
+cirrus_not_implemented (const char *insn)
{
fprintf (stderr, "Cirrus instruction '%s' not implemented.\n", insn);
fprintf (stderr, "aborting!\n");
diff --git a/src/core/arm/interpreter/vfp/vfp_helper.h b/src/core/arm/interpreter/vfp/vfp_helper.h
index 80f9a93f..b222e79f 100644
--- a/src/core/arm/interpreter/vfp/vfp_helper.h
+++ b/src/core/arm/interpreter/vfp/vfp_helper.h
@@ -50,7 +50,7 @@
#define pr_info //printf
#define pr_debug //printf
-static u32 fls(int x);
+static u32 vfp_fls(int x);
#define do_div(n, base) {n/=base;}
/* From vfpinstr.h */
@@ -508,7 +508,7 @@ struct op {
u32 flags;
};
-static inline u32 fls(int x)
+static u32 vfp_fls(int x)
{
int r = 32;
diff --git a/src/core/arm/interpreter/vfp/vfpdouble.cpp b/src/core/arm/interpreter/vfp/vfpdouble.cpp
index cd5b5afa..7f975cbe 100644
--- a/src/core/arm/interpreter/vfp/vfpdouble.cpp
+++ b/src/core/arm/interpreter/vfp/vfpdouble.cpp
@@ -69,9 +69,9 @@ static void vfp_double_dump(const char *str, struct vfp_double *d)
static void vfp_double_normalise_denormal(struct vfp_double *vd)
{
- int bits = 31 - fls(vd->significand >> 32);
+ int bits = 31 - vfp_fls(vd->significand >> 32);
if (bits == 31)
- bits = 63 - fls(vd->significand);
+ bits = 63 - vfp_fls(vd->significand);
vfp_double_dump("normalise_denormal: in", vd);
@@ -108,9 +108,9 @@ u32 vfp_double_normaliseround(ARMul_State* state, int dd, struct vfp_double *vd,
exponent = vd->exponent;
significand = vd->significand;
- shift = 32 - fls(significand >> 32);
+ shift = 32 - vfp_fls(significand >> 32);
if (shift == 32)
- shift = 64 - fls(significand);
+ shift = 64 - vfp_fls(significand);
if (shift) {
exponent -= shift;
significand <<= shift;
diff --git a/src/core/arm/interpreter/vfp/vfpsingle.cpp b/src/core/arm/interpreter/vfp/vfpsingle.cpp
index 05279f5c..602713cf 100644
--- a/src/core/arm/interpreter/vfp/vfpsingle.cpp
+++ b/src/core/arm/interpreter/vfp/vfpsingle.cpp
@@ -69,7 +69,7 @@ static void vfp_single_dump(const char *str, struct vfp_single *s)
static void vfp_single_normalise_denormal(struct vfp_single *vs)
{
- int bits = 31 - fls(vs->significand);
+ int bits = 31 - vfp_fls(vs->significand);
vfp_single_dump("normalise_denormal: in", vs);
@@ -111,7 +111,7 @@ u32 vfp_single_normaliseround(ARMul_State* state, int sd, struct vfp_single *vs,
* bit 31, so we have VFP_SINGLE_LOW_BITS + 1 below the least
* significant bit.
*/
- shift = 32 - fls(significand);
+ shift = 32 - vfp_fls(significand);
if (shift < 32 && shift) {
exponent -= shift;
significand <<= shift;
diff --git a/src/core/core.cpp b/src/core/core.cpp
index d366498a..7dc0809d 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -9,7 +9,7 @@
#include "core/core.h"
#include "core/mem_map.h"
#include "core/hw/hw.h"
-#include "core/hw/lcd.h"
+#include "core/hw/gpu.h"
#include "core/arm/disassembler/arm_disasm.h"
#include "core/arm/interpreter/arm_interpreter.h"
@@ -26,7 +26,7 @@ ARM_Interface* g_sys_core = nullptr; ///< ARM11 system (OS) core
/// Run the core CPU loop
void RunLoop() {
for (;;){
- g_app_core->Run(LCD::kFrameTicks);
+ g_app_core->Run(GPU::kFrameTicks);
HW::Update();
Kernel::Reschedule();
}
@@ -38,7 +38,7 @@ void SingleStep() {
// Update and reschedule after approx. 1 frame
u64 current_ticks = Core::g_app_core->GetTicks();
- if ((current_ticks - g_last_ticks) >= LCD::kFrameTicks || HLE::g_reschedule) {
+ if ((current_ticks - g_last_ticks) >= GPU::kFrameTicks || HLE::g_reschedule) {
g_last_ticks = current_ticks;
HW::Update();
Kernel::Reschedule();
diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj
index 6fec75d7..8eb189a8 100644
--- a/src/core/core.vcxproj
+++ b/src/core/core.vcxproj
@@ -179,8 +179,8 @@
<ClCompile Include="hle\service\service.cpp" />
<ClCompile Include="hle\service\srv.cpp" />
<ClCompile Include="hle\svc.cpp" />
+ <ClCompile Include="hw\gpu.cpp" />
<ClCompile Include="hw\hw.cpp" />
- <ClCompile Include="hw\lcd.cpp" />
<ClCompile Include="hw\ndma.cpp" />
<ClCompile Include="loader.cpp" />
<ClCompile Include="mem_map.cpp" />
@@ -230,8 +230,8 @@
<ClInclude Include="hle\service\service.h" />
<ClInclude Include="hle\service\srv.h" />
<ClInclude Include="hle\svc.h" />
+ <ClInclude Include="hw\gpu.h" />
<ClInclude Include="hw\hw.h" />
- <ClInclude Include="hw\lcd.h" />
<ClInclude Include="hw\ndma.h" />
<ClInclude Include="loader.h" />
<ClInclude Include="mem_map.h" />
@@ -243,4 +243,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters
index 8e5966d7..da781f81 100644
--- a/src/core/core.vcxproj.filters
+++ b/src/core/core.vcxproj.filters
@@ -102,7 +102,7 @@
<ClCompile Include="hw\ndma.cpp">
<Filter>hw</Filter>
</ClCompile>
- <ClCompile Include="hw\lcd.cpp">
+ <ClCompile Include="hw\gpu.cpp">
<Filter>hw</Filter>
</ClCompile>
<ClCompile Include="arm\disassembler\load_symbol_map.cpp">
@@ -250,7 +250,7 @@
<ClInclude Include="hw\ndma.h">
<Filter>hw</Filter>
</ClInclude>
- <ClInclude Include="hw\lcd.h">
+ <ClInclude Include="hw\gpu.h">
<Filter>hw</Filter>
</ClInclude>
<ClInclude Include="arm\disassembler\load_symbol_map.h">
@@ -311,4 +311,4 @@
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/core/hle/service/gsp.cpp b/src/core/hle/service/gsp.cpp
index f31e7d86..f75ba75c 100644
--- a/src/core/hle/service/gsp.cpp
+++ b/src/core/hle/service/gsp.cpp
@@ -11,25 +11,29 @@
#include "core/hle/kernel/event.h"
#include "core/hle/service/gsp.h"
-#include "core/hw/lcd.h"
+#include "core/hw/gpu.h"
+
+#include "video_core/gpu_debugger.h"
////////////////////////////////////////////////////////////////////////////////////////////////////
+// Main graphics debugger object - TODO: Here is probably not the best place for this
+GraphicsDebugger g_debugger;
+
/// GSP shared memory GX command buffer header
union GX_CmdBufferHeader {
u32 hex;
- // Current command index. This index is updated by GSP module after loading the command data,
- // right before the command is processed. When this index is updated by GSP module, the total
+ // Current command index. This index is updated by GSP module after loading the command data,
+ // right before the command is processed. When this index is updated by GSP module, the total
// commands field is decreased by one as well.
BitField<0,8,u32> index;
-
+
// Total commands to process, must not be value 0 when GSP module handles commands. This must be
- // <=15 when writing a command to shared memory. This is incremented by the application when
- // writing a command to shared memory, after increasing this value TriggerCmdReqQueue is only
+ // <=15 when writing a command to shared memory. This is incremented by the application when
+ // writing a command to shared memory, after increasing this value TriggerCmdReqQueue is only
// used if this field is value 1.
BitField<8,8,u32> number_commands;
-
};
/// Gets the address of the start (header) of a command buffer in GSP shared memory
@@ -45,7 +49,11 @@ static inline u8* GX_GetCmdBufferPointer(u32 thread_id, u32 offset=0) {
/// Finishes execution of a GSP command
void GX_FinishCommand(u32 thread_id) {
GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id);
+
+ g_debugger.GXCommandProcessed(GX_GetCmdBufferPointer(thread_id, 0x20 + (header->index * 0x20)));
+
header->number_commands = header->number_commands - 1;
+ // TODO: Increment header->index?
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -57,24 +65,20 @@ Handle g_event_handle = 0;
u32 g_thread_id = 0;
enum {
- CMD_GX_REQUEST_DMA = 0x00000000,
-};
-
-enum {
REG_FRAMEBUFFER_1 = 0x00400468,
REG_FRAMEBUFFER_2 = 0x00400494,
};
/// Read a GSP GPU hardware register
void ReadHWRegs(Service::Interface* self) {
- static const u32 framebuffer_1[] = {LCD::PADDR_VRAM_TOP_LEFT_FRAME1, LCD::PADDR_VRAM_TOP_RIGHT_FRAME1};
- static const u32 framebuffer_2[] = {LCD::PADDR_VRAM_TOP_LEFT_FRAME2, LCD::PADDR_VRAM_TOP_RIGHT_FRAME2};
+ static const u32 framebuffer_1[] = {GPU::PADDR_VRAM_TOP_LEFT_FRAME1, GPU::PADDR_VRAM_TOP_RIGHT_FRAME1};
+ static const u32 framebuffer_2[] = {GPU::PADDR_VRAM_TOP_LEFT_FRAME2, GPU::PADDR_VRAM_TOP_RIGHT_FRAME2};
u32* cmd_buff = Service::GetCommandBuffer();
u32 reg_addr = cmd_buff[1];
u32 size = cmd_buff[2];
u32* dst = (u32*)Memory::GetPointer(cmd_buff[0x41]);
-
+
switch (reg_addr) {
// NOTE: Calling SetFramebufferLocation here is a hack... Not sure the correct way yet to set
@@ -83,13 +87,13 @@ void ReadHWRegs(Service::Interface* self) {
// Top framebuffer 1 addresses
case REG_FRAMEBUFFER_1:
- LCD::SetFramebufferLocation(LCD::FRAMEBUFFER_LOCATION_VRAM);
+ GPU::SetFramebufferLocation(GPU::FRAMEBUFFER_LOCATION_VRAM);
memcpy(dst, framebuffer_1, size);
break;
// Top framebuffer 2 addresses
case REG_FRAMEBUFFER_2:
- LCD::SetFramebufferLocation(LCD::FRAMEBUFFER_LOCATION_VRAM);
+ GPU::SetFramebufferLocation(GPU::FRAMEBUFFER_LOCATION_VRAM);
memcpy(dst, framebuffer_2, size);
break;
@@ -119,22 +123,50 @@ void RegisterInterruptRelayQueue(Service::Interface* self) {
cmd_buff[2] = g_thread_id; // ThreadID
}
+
/// This triggers handling of the GX command written to the command buffer in shared memory.
void TriggerCmdReqQueue(Service::Interface* self) {
GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(g_thread_id);
u32* cmd_buff = (u32*)GX_GetCmdBufferPointer(g_thread_id, 0x20 + (header->index * 0x20));
- switch (cmd_buff[0]) {
+ switch (static_cast<GXCommandId>(cmd_buff[0])) {
// GX request DMA - typically used for copying memory from GSP heap to VRAM
- case CMD_GX_REQUEST_DMA:
+ case GXCommandId::REQUEST_DMA:
memcpy(Memory::GetPointer(cmd_buff[2]), Memory::GetPointer(cmd_buff[1]), cmd_buff[3]);
break;
+ case GXCommandId::SET_COMMAND_LIST_LAST:
+ GPU::Write<u32>(GPU::Registers::CommandListAddress, cmd_buff[1] >> 3);
+ GPU::Write<u32>(GPU::Registers::CommandListSize, cmd_buff[2] >> 3);
+ GPU::Write<u32>(GPU::Registers::ProcessCommandList, 1); // TODO: Not sure if we are supposed to always write this
+
+ // TODO: Move this to GPU
+ // TODO: Not sure what units the size is measured in
+ g_debugger.CommandListCalled(cmd_buff[1], (u32*)Memory::GetPointer(cmd_buff[1]), cmd_buff[2]);
+ break;
+
+ case GXCommandId::SET_MEMORY_FILL:
+ break;
+
+ case GXCommandId::SET_DISPLAY_TRANSFER:
+ break;
+
+ case GXCommandId::SET_TEXTURE_COPY:
+ break;
+
+ case GXCommandId::SET_COMMAND_LIST_FIRST:
+ {
+ //u32* buf0_data = (u32*)Memory::GetPointer(cmd_buff[1]);
+ //u32* buf1_data = (u32*)Memory::GetPointer(cmd_buff[3]);
+ //u32* buf2_data = (u32*)Memory::GetPointer(cmd_buff[5]);
+ break;
+ }
+
default:
ERROR_LOG(GSP, "unknown command 0x%08X", cmd_buff[0]);
}
-
+
GX_FinishCommand(g_thread_id);
}
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h
index eb5786cd..214de140 100644
--- a/src/core/hle/service/gsp.h
+++ b/src/core/hle/service/gsp.h
@@ -11,6 +11,23 @@
namespace GSP_GPU {
+enum class GXCommandId : u32 {
+ REQUEST_DMA = 0x00000000,
+ SET_COMMAND_LIST_LAST = 0x00000001,
+ SET_MEMORY_FILL = 0x00000002, // TODO: Confirm? (lictru uses 0x01000102)
+ SET_DISPLAY_TRANSFER = 0x00000003,
+ SET_TEXTURE_COPY = 0x00000004,
+ SET_COMMAND_LIST_FIRST = 0x00000005,
+};
+
+union GXCommand {
+ struct {
+ GXCommandId id;
+ };
+
+ u32 data[0x20];
+};
+
/// Interface to "srv:" service
class Interface : public Service::Interface {
public:
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 166d1303..dcd52572 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -71,7 +71,7 @@ public:
/// Frees a handle from the service
template <class T>
void DeleteHandle(const Handle handle) {
- g_object_pool.Destroy<T>(handle);
+ Kernel::g_object_pool.Destroy<T>(handle);
m_handles.erase(std::remove(m_handles.begin(), m_handles.end(), handle), m_handles.end());
}
diff --git a/src/core/hw/lcd.cpp b/src/core/hw/gpu.cpp
index 6cbce14e..f0ca4ead 100644
--- a/src/core/hw/lcd.cpp
+++ b/src/core/hw/gpu.cpp
@@ -7,13 +7,13 @@
#include "core/core.h"
#include "core/mem_map.h"
-#include "core/hw/lcd.h"
+#include "core/hle/kernel/thread.h"
+#include "core/hw/gpu.h"
#include "video_core/video_core.h"
-#include "core/hle/kernel/thread.h"
-namespace LCD {
+namespace GPU {
Registers g_regs;
@@ -59,7 +59,7 @@ const FramebufferLocation GetFramebufferLocation() {
} else if ((g_regs.framebuffer_top_right_1 & ~Memory::FCRAM_MASK) == Memory::FCRAM_PADDR) {
return FRAMEBUFFER_LOCATION_FCRAM;
} else {
- ERROR_LOG(LCD, "unknown framebuffer location!");
+ ERROR_LOG(GPU, "unknown framebuffer location!");
}
return FRAMEBUFFER_LOCATION_UNKNOWN;
}
@@ -76,7 +76,7 @@ const u8* GetFramebufferPointer(const u32 address) {
case FRAMEBUFFER_LOCATION_VRAM:
return (const u8*)Memory::GetPointer(Memory::VirtualAddressFromPhysical_VRAM(address));
default:
- ERROR_LOG(LCD, "unknown framebuffer location");
+ ERROR_LOG(GPU, "unknown framebuffer location");
}
return NULL;
}
@@ -84,34 +84,73 @@ const u8* GetFramebufferPointer(const u32 address) {
template <typename T>
inline void Read(T &var, const u32 addr) {
switch (addr) {
- case REG_FRAMEBUFFER_TOP_LEFT_1:
+ case Registers::FramebufferTopLeft1:
var = g_regs.framebuffer_top_left_1;
break;
- case REG_FRAMEBUFFER_TOP_LEFT_2:
+
+ case Registers::FramebufferTopLeft2:
var = g_regs.framebuffer_top_left_2;
break;
- case REG_FRAMEBUFFER_TOP_RIGHT_1:
+
+ case Registers::FramebufferTopRight1:
var = g_regs.framebuffer_top_right_1;
break;
- case REG_FRAMEBUFFER_TOP_RIGHT_2:
+
+ case Registers::FramebufferTopRight2:
var = g_regs.framebuffer_top_right_2;
break;
- case REG_FRAMEBUFFER_SUB_LEFT_1:
+
+ case Registers::FramebufferSubLeft1:
var = g_regs.framebuffer_sub_left_1;
break;
- case REG_FRAMEBUFFER_SUB_RIGHT_1:
+
+ case Registers::FramebufferSubRight1:
var = g_regs.framebuffer_sub_right_1;
break;
+
+ case Registers::CommandListSize:
+ var = g_regs.command_list_size;
+ break;
+
+ case Registers::CommandListAddress:
+ var = g_regs.command_list_address;
+ break;
+
+ case Registers::ProcessCommandList:
+ var = g_regs.command_processing_enabled;
+ break;
+
default:
- ERROR_LOG(LCD, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr);
+ ERROR_LOG(GPU, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr);
break;
}
-
}
template <typename T>
inline void Write(u32 addr, const T data) {
- ERROR_LOG(LCD, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr);
+ switch (static_cast<Registers::Id>(addr)) {
+ case Registers::CommandListSize:
+ g_regs.command_list_size = data;
+ break;
+
+ case Registers::CommandListAddress:
+ g_regs.command_list_address = data;
+ break;
+
+ case Registers::ProcessCommandList:
+ g_regs.command_processing_enabled = data;
+ if (g_regs.command_processing_enabled & 1)
+ {
+ // u32* buffer = (u32*)Memory::GetPointer(g_regs.command_list_address << 3);
+ ERROR_LOG(GPU, "Beginning %x bytes of commands from address %x", g_regs.command_list_size, g_regs.command_list_address << 3);
+ // TODO: Process command list!
+ }
+ break;
+
+ default:
+ ERROR_LOG(GPU, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr);
+ break;
+ }
}
// Explicitly instantiate template functions because we aren't defining this in the header:
@@ -142,12 +181,12 @@ void Update() {
void Init() {
g_last_ticks = Core::g_app_core->GetTicks();
SetFramebufferLocation(FRAMEBUFFER_LOCATION_FCRAM);
- NOTICE_LOG(LCD, "initialized OK");
+ NOTICE_LOG(GPU, "initialized OK");
}
/// Shutdown hardware
void Shutdown() {
- NOTICE_LOG(LCD, "shutdown OK");
+ NOTICE_LOG(GPU, "shutdown OK");
}
} // namespace
diff --git a/src/core/hw/lcd.h b/src/core/hw/gpu.h
index 7484f8f6..3314ba98 100644
--- a/src/core/hw/lcd.h
+++ b/src/core/hw/gpu.h
@@ -6,12 +6,27 @@
#include "common/common_types.h"
-namespace LCD {
+namespace GPU {
static const u32 kFrameCycles = 268123480 / 60; ///< 268MHz / 60 frames per second
static const u32 kFrameTicks = kFrameCycles / 3; ///< Approximate number of instructions/frame
struct Registers {
+ enum Id : u32 {
+ FramebufferTopLeft1 = 0x1EF00468, // Main LCD, first framebuffer for 3D left
+ FramebufferTopLeft2 = 0x1EF0046C, // Main LCD, second framebuffer for 3D left
+ FramebufferTopRight1 = 0x1EF00494, // Main LCD, first framebuffer for 3D right
+ FramebufferTopRight2 = 0x1EF00498, // Main LCD, second framebuffer for 3D right
+ FramebufferSubLeft1 = 0x1EF00568, // Sub LCD, first framebuffer
+ FramebufferSubLeft2 = 0x1EF0056C, // Sub LCD, second framebuffer
+ FramebufferSubRight1 = 0x1EF00594, // Sub LCD, unused first framebuffer
+ FramebufferSubRight2 = 0x1EF00598, // Sub LCD, unused second framebuffer
+
+ CommandListSize = 0x1EF018E0,
+ CommandListAddress = 0x1EF018E8,
+ ProcessCommandList = 0x1EF018F0,
+ };
+
u32 framebuffer_top_left_1;
u32 framebuffer_top_left_2;
u32 framebuffer_top_right_1;
@@ -20,6 +35,10 @@ struct Registers {
u32 framebuffer_sub_left_2;
u32 framebuffer_sub_right_1;
u32 framebuffer_sub_right_2;
+
+ u32 command_list_size;
+ u32 command_list_address;
+ u32 command_processing_enabled;
};
extern Registers g_regs;
@@ -27,7 +46,7 @@ extern Registers g_regs;
enum {
TOP_ASPECT_X = 0x5,
TOP_ASPECT_Y = 0x3,
-
+
TOP_HEIGHT = 240,
TOP_WIDTH = 400,
BOTTOM_WIDTH = 320,
@@ -51,21 +70,10 @@ enum {
PADDR_VRAM_SUB_FRAME2 = 0x18249CF0,
};
-enum {
- REG_FRAMEBUFFER_TOP_LEFT_1 = 0x1EF00468, // Main LCD, first framebuffer for 3D left
- REG_FRAMEBUFFER_TOP_LEFT_2 = 0x1EF0046C, // Main LCD, second framebuffer for 3D left
- REG_FRAMEBUFFER_TOP_RIGHT_1 = 0x1EF00494, // Main LCD, first framebuffer for 3D right
- REG_FRAMEBUFFER_TOP_RIGHT_2 = 0x1EF00498, // Main LCD, second framebuffer for 3D right
- REG_FRAMEBUFFER_SUB_LEFT_1 = 0x1EF00568, // Sub LCD, first framebuffer
- REG_FRAMEBUFFER_SUB_LEFT_2 = 0x1EF0056C, // Sub LCD, second framebuffer
- REG_FRAMEBUFFER_SUB_RIGHT_1 = 0x1EF00594, // Sub LCD, unused first framebuffer
- REG_FRAMEBUFFER_SUB_RIGHT_2 = 0x1EF00598, // Sub LCD, unused second framebuffer
-};
-
/// Framebuffer location
enum FramebufferLocation {
FRAMEBUFFER_LOCATION_UNKNOWN, ///< Framebuffer location is unknown
- FRAMEBUFFER_LOCATION_FCRAM, ///< Framebuffer is in the GSP heap
+ FRAMEBUFFER_LOCATION_FCRAM, ///< Framebuffer is in the GSP heap
FRAMEBUFFER_LOCATION_VRAM, ///< Framebuffer is in VRAM
};
diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp
index 85669ae7..ed70486e 100644
--- a/src/core/hw/hw.cpp
+++ b/src/core/hw/hw.cpp
@@ -6,7 +6,7 @@
#include "common/log.h"
#include "core/hw/hw.h"
-#include "core/hw/lcd.h"
+#include "core/hw/gpu.h"
#include "core/hw/ndma.h"
namespace HW {
@@ -34,7 +34,7 @@ enum {
VADDR_CDMA = 0xFFFDA000, // CoreLink DMA-330? Info
VADDR_DSP_2 = 0x1ED03000,
VADDR_HASH_2 = 0x1EE01000,
- VADDR_LCD = 0x1EF00000,
+ VADDR_GPU = 0x1EF00000,
};
template <typename T>
@@ -46,8 +46,8 @@ inline void Read(T &var, const u32 addr) {
// NDMA::Read(var, addr);
// break;
- case VADDR_LCD:
- LCD::Read(var, addr);
+ case VADDR_GPU:
+ GPU::Read(var, addr);
break;
default:
@@ -64,8 +64,8 @@ inline void Write(u32 addr, const T data) {
// NDMA::Write(addr, data);
// break;
- case VADDR_LCD:
- LCD::Write(addr, data);
+ case VADDR_GPU:
+ GPU::Write(addr, data);
break;
default:
@@ -87,13 +87,13 @@ template void Write<u8>(u32 addr, const u8 data);
/// Update hardware
void Update() {
- LCD::Update();
+ GPU::Update();
NDMA::Update();
}
/// Initialize hardware
void Init() {
- LCD::Init();
+ GPU::Init();
NDMA::Init();
NOTICE_LOG(HW, "initialized OK");
}
diff --git a/src/core/hw/ndma.cpp b/src/core/hw/ndma.cpp
index 52e459eb..f6aa72d1 100644
--- a/src/core/hw/ndma.cpp
+++ b/src/core/hw/ndma.cpp
@@ -37,12 +37,12 @@ void Update() {
/// Initialize hardware
void Init() {
- NOTICE_LOG(LCD, "initialized OK");
+ NOTICE_LOG(GPU, "initialized OK");
}
/// Shutdown hardware
void Shutdown() {
- NOTICE_LOG(LCD, "shutdown OK");
+ NOTICE_LOG(GPU, "shutdown OK");
}
} // namespace
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 56394b93..e43e6e1b 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -2,4 +2,9 @@ set(SRCS video_core.cpp
utils.cpp
renderer_opengl/renderer_opengl.cpp)
-add_library(video_core STATIC ${SRCS})
+set(HEADERS video_core.h
+ utils.h
+ renderer_base.h
+ renderer_opengl/renderer_opengl.h)
+
+add_library(video_core STATIC ${SRCS} ${HEADERS})
diff --git a/src/video_core/gpu_debugger.h b/src/video_core/gpu_debugger.h
new file mode 100644
index 00000000..5d909beb
--- /dev/null
+++ b/src/video_core/gpu_debugger.h
@@ -0,0 +1,157 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <algorithm>
+#include <functional>
+#include <vector>
+
+#include "common/log.h"
+
+#include "core/hle/service/gsp.h"
+#include "pica.h"
+
+class GraphicsDebugger
+{
+public:
+ // A few utility structs used to expose data
+ // A vector of commands represented by their raw byte sequence
+ struct PicaCommand : public std::vector<u32>
+ {
+ const Pica::CommandHeader& GetHeader() const
+ {
+ const u32& val = at(1);
+ return *(Pica::CommandHeader*)&val;
+ }
+ };
+
+ typedef std::vector<PicaCommand> PicaCommandList;
+
+ // Base class for all objects which need to be notified about GPU events
+ class DebuggerObserver
+ {
+ public:
+ DebuggerObserver() : observed(nullptr) { }
+
+ virtual ~DebuggerObserver()
+ {
+ if (observed)
+ observed->UnregisterObserver(this);
+ }
+
+ /**
+ * Called when a GX command has been processed and is ready for being
+ * read via GraphicsDebugger::ReadGXCommandHistory.
+ * @param total_command_count Total number of commands in the GX history
+ * @note All methods in this class are called from the GSP thread
+ */
+ virtual void GXCommandProcessed(int total_command_count)
+ {
+ const GSP_GPU::GXCommand& cmd = observed->ReadGXCommandHistory(total_command_count-1);
+ ERROR_LOG(GSP, "Received command: id=%x", cmd.id);
+ }
+
+ /**
+ * @param lst command list which triggered this call
+ * @param is_new true if the command list was called for the first time
+ * @todo figure out how to make sure called functions don't keep references around beyond their life time
+ */
+ virtual void OnCommandListCalled(const PicaCommandList& lst, bool is_new)
+ {
+ ERROR_LOG(GSP, "Command list called: %d", (int)is_new);
+ }
+
+ protected:
+ const GraphicsDebugger* GetDebugger() const
+ {
+ return observed;
+ }
+
+ private:
+ GraphicsDebugger* observed;
+ bool in_destruction;
+
+ friend class GraphicsDebugger;
+ };
+
+ void GXCommandProcessed(u8* command_data)
+ {
+ gx_command_history.push_back(GSP_GPU::GXCommand());
+ GSP_GPU::GXCommand& cmd = gx_command_history[gx_command_history.size()-1];
+
+ const int cmd_length = sizeof(GSP_GPU::GXCommand);
+ memcpy(cmd.data, command_data, cmd_length);
+
+ ForEachObserver([this](DebuggerObserver* observer) {
+ observer->GXCommandProcessed(this->gx_command_history.size());
+ } );
+ }
+
+ void CommandListCalled(u32 address, u32* command_list, u32 size_in_words)
+ {
+ PicaCommandList cmdlist;
+ for (u32* parse_pointer = command_list; parse_pointer < command_list + size_in_words;)
+ {
+ const Pica::CommandHeader header = static_cast<Pica::CommandHeader>(parse_pointer[1]);
+
+ cmdlist.push_back(PicaCommand());
+ auto& cmd = cmdlist.back();
+
+ size_t size = 2 + header.extra_data_length;
+ size = (size + 1) / 2 * 2; // align to 8 bytes
+ cmd.reserve(size);
+ std::copy(parse_pointer, parse_pointer + size, std::back_inserter(cmd));
+
+ parse_pointer += size;
+ }
+
+ auto obj = std::pair<u32,PicaCommandList>(address, cmdlist);
+ auto it = std::find(command_lists.begin(), command_lists.end(), obj);
+ bool is_new = (it == command_lists.end());
+ if (is_new)
+ command_lists.push_back(obj);
+
+ ForEachObserver([&](DebuggerObserver* observer) {
+ observer->OnCommandListCalled(obj.second, is_new);
+ } );
+ }
+
+ const GSP_GPU::GXCommand& ReadGXCommandHistory(int index) const
+ {
+ // TODO: Is this thread-safe?
+ return gx_command_history[index];
+ }
+
+ const std::vector<std::pair<u32,PicaCommandList>>& GetCommandLists() const
+ {
+ return command_lists;
+ }
+
+ void RegisterObserver(DebuggerObserver* observer)
+ {
+ // TODO: Check for duplicates
+ observers.push_back(observer);
+ observer->observed = this;
+ }
+
+ void UnregisterObserver(DebuggerObserver* observer)
+ {
+ std::remove(observers.begin(), observers.end(), observer);
+ observer->observed = nullptr;
+ }
+
+private:
+ void ForEachObserver(std::function<void (DebuggerObserver*)> func)
+ {
+ std::for_each(observers.begin(),observers.end(), func);
+ }
+
+ std::vector<DebuggerObserver*> observers;
+
+ std::vector<GSP_GPU::GXCommand> gx_command_history;
+
+ // vector of pairs of command lists and their storage address
+ std::vector<std::pair<u32,PicaCommandList>> command_lists;
+};
diff --git a/src/video_core/pica.h b/src/video_core/pica.h
new file mode 100644
index 00000000..f0fa3aba
--- /dev/null
+++ b/src/video_core/pica.h
@@ -0,0 +1,130 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <initializer_list>
+#include <map>
+
+#include "common/bit_field.h"
+#include "common/common_types.h"
+#include "common/register_set.h"
+
+namespace Pica {
+
+struct Regs {
+ enum Id : u32 {
+ ViewportSizeX = 0x41,
+ ViewportInvSizeX = 0x42,
+ ViewportSizeY = 0x43,
+ ViewportInvSizeY = 0x44,
+ ViewportCorner = 0x68,
+ DepthBufferFormat = 0x116,
+ ColorBufferFormat = 0x117,
+ DepthBufferAddress = 0x11C,
+ ColorBufferAddress = 0x11D,
+ ColorBufferSize = 0x11E,
+
+ VertexArrayBaseAddr = 0x200,
+ VertexDescriptor = 0x201, // 0x202
+ VertexAttributeOffset = 0x203, // 0x206,0x209,0x20C,0x20F,0x212,0x215,0x218,0x21B,0x21E,0x221,0x224
+ VertexAttributeInfo0 = 0x204, // 0x207,0x20A,0x20D,0x210,0x213,0x216,0x219,0x21C,0x21F,0x222,0x225
+ VertexAttributeInfo1 = 0x205, // 0x208,0x20B,0x20E,0x211,0x214,0x217,0x21A,0x21D,0x220,0x223,0x226
+
+ NumIds = 0x300,
+ };
+
+ template<Id id>
+ union Struct;
+};
+
+static inline Regs::Id VertexAttributeOffset(int n)
+{
+ return static_cast<Regs::Id>(0x203 + 3*n);
+}
+
+static inline Regs::Id VertexAttributeInfo0(int n)
+{
+ return static_cast<Regs::Id>(0x204 + 3*n);
+}
+
+static inline Regs::Id VertexAttributeInfo1(int n)
+{
+ return static_cast<Regs::Id>(0x205 + 3*n);
+}
+
+union CommandHeader {
+ CommandHeader(u32 h) : hex(h) {}
+
+ u32 hex;
+
+ BitField< 0, 16, Regs::Id> cmd_id;
+ BitField<16, 4, u32> parameter_mask;
+ BitField<20, 11, u32> extra_data_length;
+ BitField<31, 1, u32> group_commands;
+};
+
+static std::map<Regs::Id, const char*> command_names = {
+ {Regs::ViewportSizeX, "ViewportSizeX" },
+ {Regs::ViewportInvSizeX, "ViewportInvSizeX" },
+ {Regs::ViewportSizeY, "ViewportSizeY" },
+ {Regs::ViewportInvSizeY, "ViewportInvSizeY" },
+ {Regs::ViewportCorner, "ViewportCorner" },
+ {Regs::DepthBufferFormat, "DepthBufferFormat" },
+ {Regs::ColorBufferFormat, "ColorBufferFormat" },
+ {Regs::DepthBufferAddress, "DepthBufferAddress" },
+ {Regs::ColorBufferAddress, "ColorBufferAddress" },
+ {Regs::ColorBufferSize, "ColorBufferSize" },
+};
+
+template<>
+union Regs::Struct<Regs::ViewportSizeX> {
+ BitField<0, 24, u32> value;
+};
+
+template<>
+union Regs::Struct<Regs::ViewportSizeY> {
+ BitField<0, 24, u32> value;
+};
+
+template<>
+union Regs::Struct<Regs::VertexDescriptor> {
+ enum class Format : u64 {
+ BYTE = 0,
+ UBYTE = 1,
+ SHORT = 2,
+ FLOAT = 3,
+ };
+
+ BitField< 0, 2, Format> format0;
+ BitField< 2, 2, u64> size0; // number of elements minus 1
+ BitField< 4, 2, Format> format1;
+ BitField< 6, 2, u64> size1;
+ BitField< 8, 2, Format> format2;
+ BitField<10, 2, u64> size2;
+ BitField<12, 2, Format> format3;
+ BitField<14, 2, u64> size3;
+ BitField<16, 2, Format> format4;
+ BitField<18, 2, u64> size4;
+ BitField<20, 2, Format> format5;
+ BitField<22, 2, u64> size5;
+ BitField<24, 2, Format> format6;
+ BitField<26, 2, u64> size6;
+ BitField<28, 2, Format> format7;
+ BitField<30, 2, u64> size7;
+ BitField<32, 2, Format> format8;
+ BitField<34, 2, u64> size8;
+ BitField<36, 2, Format> format9;
+ BitField<38, 2, u64> size9;
+ BitField<40, 2, Format> format10;
+ BitField<42, 2, u64> size10;
+ BitField<44, 2, Format> format11;
+ BitField<46, 2, u64> size11;
+
+ BitField<48, 12, u64> attribute_mask;
+ BitField<60, 4, u64> num_attributes; // number of total attributes minus 1
+};
+
+
+} // namespace
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 24f9a91f..70af47c5 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -2,7 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include "core/hw/lcd.h"
+#include "core/hw/gpu.h"
#include "video_core/video_core.h"
#include "video_core/renderer_opengl/renderer_opengl.h"
@@ -37,7 +37,7 @@ void RendererOpenGL::SwapBuffers() {
// EFB->XFB copy
// TODO(bunnei): This is a hack and does not belong here. The copy should be triggered by some
// register write We're also treating both framebuffers as a single one in OpenGL.
- Rect framebuffer_size(0, 0, m_resolution_width, m_resolution_height);
+ common::Rect framebuffer_size(0, 0, m_resolution_width, m_resolution_height);
RenderXFB(framebuffer_size, framebuffer_size);
// XFB->Window copy
@@ -75,10 +75,10 @@ void RendererOpenGL::FlipFramebuffer(const u8* in, u8* out) {
* @param src_rect Source rectangle in XFB to copy
* @param dst_rect Destination rectangle in output framebuffer to copy to
*/
-void RendererOpenGL::RenderXFB(const Rect& src_rect, const Rect& dst_rect) {
+void RendererOpenGL::RenderXFB(const common::Rect& src_rect, const common::Rect& dst_rect) {
- FlipFramebuffer(LCD::GetFramebufferPointer(LCD::g_regs.framebuffer_top_left_1), m_xfb_top_flipped);
- FlipFramebuffer(LCD::GetFramebufferPointer(LCD::g_regs.framebuffer_sub_left_1), m_xfb_bottom_flipped);
+ FlipFramebuffer(GPU::GetFramebufferPointer(GPU::g_regs.framebuffer_top_left_1), m_xfb_top_flipped);
+ FlipFramebuffer(GPU::GetFramebufferPointer(GPU::g_regs.framebuffer_sub_left_1), m_xfb_bottom_flipped);
// Blit the top framebuffer
// ------------------------
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index 4c0b6e59..dd811cad 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -28,7 +28,7 @@ public:
* @param src_rect Source rectangle in XFB to copy
* @param dst_rect Destination rectangle in output framebuffer to copy to
*/
- void RenderXFB(const Rect& src_rect, const Rect& dst_rect);
+ void RenderXFB(const common::Rect& src_rect, const common::Rect& dst_rect);
/**
* Set the emulator window to use for renderer
@@ -59,7 +59,7 @@ private:
* @param out Pointer to output buffer with flipped framebuffer
* @todo Early on hack... I'd like to find a more efficient way of doing this /bunnei
*/
- void RendererOpenGL::FlipFramebuffer(const u8* in, u8* out);
+ void FlipFramebuffer(const u8* in, u8* out);
EmuWindow* m_render_window; ///< Handle to render window
diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp
index 67d74a2d..b94376ac 100644
--- a/src/video_core/utils.cpp
+++ b/src/video_core/utils.cpp
@@ -8,7 +8,6 @@
#include "video_core/utils.h"
namespace VideoCore {
-
/**
* Dumps a texture to TGA
* @param filename String filename to dump texture to
@@ -32,9 +31,9 @@ void DumpTGA(std::string filename, int width, int height, u8* raw_data) {
fwrite(&hdr, sizeof(TGAHeader), 1, fout);
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
- r = raw_data[(4 * (i * width)) + (4 * j) + 0];
- g = raw_data[(4 * (i * width)) + (4 * j) + 1];
- b = raw_data[(4 * (i * width)) + (4 * j) + 2];
+ b = raw_data[(3 * (i * width)) + (3 * j) + 0];
+ g = raw_data[(3 * (i * width)) + (3 * j) + 1];
+ r = raw_data[(3 * (i * width)) + (3 * j) + 2];
putc(b, fout);
putc(g, fout);
putc(r, fout);
@@ -42,5 +41,4 @@ void DumpTGA(std::string filename, int width, int height, u8* raw_data) {
}
fclose(fout);
}
-
} // namespace
diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp
index f2e17f9f..3b8039de 100644
--- a/src/video_core/video_core.cpp
+++ b/src/video_core/video_core.cpp
@@ -30,6 +30,12 @@ void Start() {
/// Initialize the video core
void Init(EmuWindow* emu_window) {
+
+#if EMU_PLATFORM == PLATFORM_MACOSX
+ // Known problem with GLEW prevents contexts above 2.x on OSX unless glewExperimental is enabled.
+ glewExperimental = GL_TRUE;
+#endif
+
g_emu_window = emu_window;
g_emu_window->MakeCurrent();
g_renderer = new RendererOpenGL();
diff --git a/src/video_core/video_core.vcxproj b/src/video_core/video_core.vcxproj
index d8c53271..d77be2be 100644
--- a/src/video_core/video_core.vcxproj
+++ b/src/video_core/video_core.vcxproj
@@ -24,10 +24,12 @@
<ClCompile Include="video_core.cpp" />
</ItemGroup>
<ItemGroup>
+ <ClInclude Include="gpu_debugger.h" />
+ <ClInclude Include="pica.h" />
<ClInclude Include="renderer_base.h" />
- <ClInclude Include="renderer_opengl\renderer_opengl.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="video_core.h" />
+ <ClInclude Include="renderer_opengl\renderer_opengl.h" />
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
@@ -128,4 +130,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
-</Project> \ No newline at end of file
+</Project>
diff --git a/src/video_core/video_core.vcxproj.filters b/src/video_core/video_core.vcxproj.filters
index 4eb2ef0a..b89ac1ac 100644
--- a/src/video_core/video_core.vcxproj.filters
+++ b/src/video_core/video_core.vcxproj.filters
@@ -16,6 +16,8 @@
<ClInclude Include="renderer_opengl\renderer_opengl.h">
<Filter>renderer_opengl</Filter>
</ClInclude>
+ <ClInclude Include="gpu_debugger.h" />
+ <ClInclude Include="pica.h" />
<ClInclude Include="renderer_base.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="video_core.h" />
@@ -23,4 +25,4 @@
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
-</Project> \ No newline at end of file
+</Project>