Skip to content
Permalink
Browse files

externals: added magic_enum

  • Loading branch information
JaCzekanski committed Sep 3, 2019
1 parent be5fb14 commit 002766bbc31a91365424486c3a78c68fcc4898ab
Showing with 25 additions and 72 deletions.
  1. +3 βˆ’0 .gitmodules
  2. +1 βˆ’0 externals/magic_enum
  3. +3 βˆ’1 premake5.lua
  4. +0 βˆ’4 src/device/gpu/gpu.cpp
  5. +0 βˆ’2 src/device/gpu/gpu.h
  6. +4 βˆ’2 src/platform/windows/gui/debug.cpp
  7. +14 βˆ’63 src/platform/windows/gui/debug/timers/timers.cpp
@@ -32,3 +32,6 @@
[submodule "externals/EventBus"]
path = externals/EventBus
url = https://github.com/gelldur/EventBus.git
[submodule "externals/magic_enum"]
path = externals/magic_enum
url = https://github.com/Neargye/magic_enum.git
Submodule magic_enum added at 3edfd5
@@ -148,7 +148,8 @@ project "core"
"externals/json/include",
"externals/miniz",
"externals/libchdr/src",
"externals/EventBus/lib/include",
"externals/EventBus/lib/include",
"externals/magic_enum/include",
}

files {
@@ -189,6 +190,7 @@ project "avocado"
"externals/libchdr/src",
"externals/filesystem/include",
"externals/EventBus/lib/include",
"externals/magic_enum/include",
}

links {
@@ -8,10 +8,6 @@
#include "utils/macros.h"

namespace gpu {

const char* CommandStr[] = {"None", "FillRectangle", "Polygon", "Line", "Rectangle",
"CopyCpuToVram1", "CopyCpuToVram2", "CopyVramToCpu", "CopyVramToVram", "Extra"};

GPU::GPU() {
busToken = bus.listen<Event::Config::Graphics>([&](auto) { reload(); });
reload();
@@ -14,8 +14,6 @@ class OpenGL;

namespace gpu {

extern const char* CommandStr[];

const int VRAM_WIDTH = 1024;
const int VRAM_HEIGHT = 512;

@@ -1,4 +1,5 @@
#include <imgui.h>
#include <magic_enum.hpp>
#include <nlohmann/json.hpp>
#include <vector>
#include "../../../cpu/gte/gte.h"
@@ -236,7 +237,8 @@ void gpuLogWindow(System *sys) {
while (clipper.Step()) {
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) {
auto &entry = sys->gpu.get()->gpuLogList[i];
bool nodeOpen = ImGui::TreeNode((void *)(intptr_t)i, "%4d cmd: 0x%02x %s", i, entry.command, gpu::CommandStr[(int)entry.cmd]);
bool nodeOpen = ImGui::TreeNode((void *)(intptr_t)i, "%4d cmd: 0x%02x %s", i, entry.command,
std::string(magic_enum::enum_name(entry.cmd)).c_str());
bool isHovered = ImGui::IsItemHovered();

if (isHovered) {
@@ -372,7 +374,7 @@ void gpuLogWindow(System *sys) {

for (size_t i = 0; i < gpuLog.size(); i++) {
auto e = gpuLog[i];
j.push_back({{"command", e.command}, {"cmd", (int)e.cmd}, {"name", gpu::CommandStr[(int)e.cmd]}, {"args", e.args}});
j.push_back({{"command", e.command}, {"cmd", (int)e.cmd}, {"name", magic_enum::enum_name(e.cmd)}, {"args", e.args}});
}

putFileContents(string_format("%s.json", filename), j.dump(2));
@@ -1,84 +1,35 @@
#include "timers.h"
#include <imgui.h>
#include <magic_enum.hpp>
#include <numeric>
#include "platform/windows/gui/tools.h"
#include "system.h"
#include "utils/string.h"

namespace gui::debug::timers {

#define ENUM_NAME(x) (std::string(magic_enum::enum_name(x)))

std::string getSyncMode(Timer* timer) {
int which = timer->which;
timer::CounterMode mode = timer->mode;

if (which == 0) {
using modes = timer::CounterMode::SyncMode0;
auto mode0 = static_cast<modes>(mode.syncMode);

switch (mode0) {
case modes::pauseDuringHblank: return "pauseDuringHblank";
case modes::resetAtHblank: return "resetAtHblank";
case modes::resetAtHblankAndPauseOutside: return "resetAtHblankAndPauseOutside";
case modes::pauseUntilHblankAndFreerun: return "pauseUntilHblankAndFreerun";
}
switch (timer->which) {
case 0: return ENUM_NAME(static_cast<timer::CounterMode::SyncMode0>(mode.syncMode));
case 1: return ENUM_NAME(static_cast<timer::CounterMode::SyncMode1>(mode.syncMode));
case 2: return ENUM_NAME(static_cast<timer::CounterMode::SyncMode2>(mode.syncMode));
default: return "";
}
if (which == 1) {
using modes = timer::CounterMode::SyncMode1;
auto mode1 = static_cast<modes>(mode.syncMode);

switch (mode1) {
case modes::pauseDuringVblank: return "pauseDuringVblank";
case modes::resetAtVblank: return "resetAtVblank";
case modes::resetAtVblankAndPauseOutside: return "resetAtVblankAndPauseOutside";
case modes::pauseUntilVblankAndFreerun: return "pauseUntilVblankAndFreerun";
}
}
if (which == 2) {
using modes = timer::CounterMode::SyncMode2;
auto mode2 = static_cast<modes>(mode.syncMode);

switch (mode2) {
case modes::stopCounter:
case modes::stopCounter_: return "stopCounter";
case modes::freeRun:
case modes::freeRun_: return "freeRun";
}
}
return "";
}

std::string getClockSource(Timer* timer) {
int which = timer->which;
timer::CounterMode mode = timer->mode;
if (which == 0) {
using modes = timer::CounterMode::ClockSource0;
auto clock = static_cast<modes>(mode.clockSource & 1);

if (clock == modes::dotClock) {
return "Dotclock";
} else {
return "Sysclock";
}
} else if (which == 1) {
using modes = timer::CounterMode::ClockSource1;
auto clock = static_cast<modes>(mode.clockSource & 1);

if (clock == modes::hblank) {
return "HBlank";
} else {
return "Sysclock";
}
} else if (which == 2) {
using modes = timer::CounterMode::ClockSource2;
auto clock = static_cast<modes>((mode.clockSource >> 1) & 1);

if (clock == modes::systemClock_8) {
return "Sysclock/8";
} else {
return "Sysclock";
}

switch (timer->which) {
case 0: return ENUM_NAME(static_cast<timer::CounterMode::ClockSource0>(mode.clockSource & 1));
case 1: return ENUM_NAME(static_cast<timer::CounterMode::ClockSource1>(mode.clockSource & 1));
case 2: return ENUM_NAME(static_cast<timer::CounterMode::ClockSource2>((mode.clockSource >> 1) & 1));
default: return "";
}
return "";
}

struct Field {

0 comments on commit 002766b

Please sign in to comment.
You can’t perform that action at this time.