shuffled around trace viewer code

This commit is contained in:
Anthony Pesch 2016-03-06 02:02:54 -08:00
parent cdf7a9e021
commit c9880d277f
13 changed files with 47 additions and 61 deletions

View File

@ -131,6 +131,7 @@ set(REDREAM_SOURCES
src/core/string.cc
src/emu/emulator.cc
src/emu/profiler.cc
src/emu/tracer.cc
src/hw/aica/aica.cc
src/hw/gdrom/disc.cc
src/hw/gdrom/gdrom.cc
@ -139,6 +140,7 @@ set(REDREAM_SOURCES
src/hw/holly/texture_cache.cc
src/hw/holly/tile_accelerator.cc
src/hw/holly/tile_renderer.cc
src/hw/holly/trace.cc
src/hw/maple/maple.cc
src/hw/maple/maple_controller.cc
src/hw/sh4/sh4.cc
@ -172,8 +174,6 @@ set(REDREAM_SOURCES
src/sys/memory.cc
src/sys/network.cc
src/sys/window.cc
src/trace/trace.cc
src/trace/trace_viewer.cc
src/main.cc)
if(WIN32)

View File

@ -6,12 +6,12 @@
#include "hw/gdrom/gdrom.h"
#include "hw/holly/texture_cache.h"
#include "hw/holly/tile_renderer.h"
#include "hw/holly/trace.h"
#include "hw/maple/maple.h"
#include "hw/sh4/sh4.h"
#include "hw/dreamcast.h"
#include "hw/memory.h"
#include "renderer/gl_backend.h"
#include "trace/trace.h"
using namespace re;
using namespace re::emu;
@ -23,7 +23,6 @@ using namespace re::hw::maple;
using namespace re::hw::sh4;
using namespace re::renderer;
using namespace re::sys;
using namespace re::trace;
DEFINE_string(bios, "dc_boot.bin", "Path to BIOS");
DEFINE_string(flash, "dc_flash.bin", "Path to flash ROM");

View File

@ -17,10 +17,6 @@ namespace renderer {
class Backend;
}
namespace trace {
class TraceWriter;
}
namespace emu {
class Emulator {

View File

@ -1,14 +1,14 @@
#include <algorithm>
#include "emu/tracer.h"
#include "hw/holly/tile_accelerator.h"
#include "hw/holly/trace.h"
#include "renderer/gl_backend.h"
#include "trace/trace.h"
#include "trace/trace_viewer.h"
using namespace re;
using namespace re::emu;
using namespace re::hw::holly;
using namespace re::renderer;
using namespace re::sys;
using namespace re::trace;
void TraceTextureCache::AddTexture(const TSP &tsp, TCW &tcw,
const uint8_t *palette,
@ -41,19 +41,19 @@ TextureHandle TraceTextureCache::GetTexture(
return texture.handle;
}
TraceViewer::TraceViewer() {
Tracer::Tracer() {
rb_ = new GLBackend(wnd_);
tile_renderer_ = new TileRenderer(*rb_, texcache_);
current_ctx_ = new TileContext();
}
TraceViewer::~TraceViewer() {
Tracer::~Tracer() {
delete rb_;
delete tile_renderer_;
delete current_ctx_;
}
void TraceViewer::Run(const char *path) {
void Tracer::Run(const char *path) {
if (!Init()) {
LOG_WARNING("Failed to initialize trace viewer");
return;
@ -72,7 +72,7 @@ void TraceViewer::Run(const char *path) {
}
}
bool TraceViewer::Init() {
bool Tracer::Init() {
if (!wnd_.Init()) {
return false;
}
@ -84,7 +84,7 @@ bool TraceViewer::Init() {
return true;
}
bool TraceViewer::Parse(const char *path) {
bool Tracer::Parse(const char *path) {
if (!reader_.Parse(path)) {
LOG_WARNING("Failed to parse %s", path);
return false;
@ -103,7 +103,7 @@ bool TraceViewer::Parse(const char *path) {
return true;
}
void TraceViewer::PumpEvents() {
void Tracer::PumpEvents() {
WindowEvent ev;
wnd_.PumpEvents();
@ -128,7 +128,7 @@ void TraceViewer::PumpEvents() {
}
}
void TraceViewer::RenderFrame() {
void Tracer::RenderFrame() {
rb_->BeginFrame();
tile_renderer_->RenderContext(current_ctx_);
@ -141,7 +141,7 @@ void TraceViewer::RenderFrame() {
rb_->EndFrame();
}
int TraceViewer::GetNumFrames() {
int Tracer::GetNumFrames() {
int num_frames = 0;
TraceCommand *cmd = reader_.cmd_head();
@ -157,8 +157,7 @@ int TraceViewer::GetNumFrames() {
return num_frames;
}
void TraceViewer::CopyCommandToContext(const TraceCommand *cmd,
TileContext *ctx) {
void Tracer::CopyCommandToContext(const TraceCommand *cmd, TileContext *ctx) {
CHECK_EQ(cmd->type, TRACE_RENDER_CONTEXT);
ctx->autosort = cmd->render_context.autosort;
@ -176,7 +175,7 @@ void TraceViewer::CopyCommandToContext(const TraceCommand *cmd,
ctx->size = cmd->render_context.data_size;
}
void TraceViewer::PrevContext() {
void Tracer::PrevContext() {
int prev_frame = std::max(1, current_frame_ - 1);
if (prev_frame == current_frame_) {
return;
@ -213,7 +212,7 @@ void TraceViewer::PrevContext() {
CopyCommandToContext(current_cmd_, current_ctx_);
}
void TraceViewer::NextContext() {
void Tracer::NextContext() {
int next_frame = std::min(num_frames_, current_frame_ + 1);
if (next_frame == current_frame_) {
return;

View File

@ -1,14 +1,14 @@
#ifndef TRACE_VIEWER_H
#define TRACE_VIEWER_H
#ifndef TRACER_H
#define TRACER_H
#include <unordered_map>
#include <vector>
#include "hw/holly/tile_renderer.h"
#include "hw/holly/trace.h"
#include "sys/window.h"
#include "trace/trace.h"
namespace re {
namespace trace {
namespace emu {
struct TextureInst {
hw::holly::TSP tsp;
@ -32,10 +32,10 @@ class TraceTextureCache : public hw::holly::TextureProvider {
std::unordered_map<hw::holly::TextureKey, TextureInst> textures_;
};
class TraceViewer {
class Tracer {
public:
TraceViewer();
~TraceViewer();
Tracer();
~Tracer();
void Run(const char *path);
@ -47,7 +47,7 @@ class TraceViewer {
void RenderFrame();
int GetNumFrames();
void CopyCommandToContext(const TraceCommand *cmd,
void CopyCommandToContext(const hw::holly::TraceCommand *cmd,
hw::holly::TileContext *ctx);
void PrevContext();
void NextContext();
@ -58,8 +58,8 @@ class TraceViewer {
hw::holly::TileRenderer *tile_renderer_;
bool running_;
TraceReader reader_;
TraceCommand *current_cmd_;
hw::holly::TraceReader reader_;
hw::holly::TraceCommand *current_cmd_;
int num_frames_;
int current_frame_;
hw::holly::TileContext *current_ctx_;

View File

@ -14,10 +14,6 @@ namespace renderer {
class Backend;
}
namespace trace {
class TraceWriter;
}
namespace hw {
namespace aica {
@ -33,6 +29,7 @@ class Holly;
class PVR2;
class TextureCache;
class TileAccelerator;
class TraceWriter;
}
namespace maple {
@ -164,7 +161,7 @@ class Dreamcast : public Machine {
hw::holly::PVR2 *pvr;
hw::holly::TileAccelerator *ta;
hw::holly::TextureCache *texcache;
trace::TraceWriter *trace_writer;
hw::holly::TraceWriter *trace_writer;
#define HOLLY_REG(offset, name, flags, default, type) \
type &name = reinterpret_cast<type &>(holly_regs[name##_OFFSET].value);

View File

@ -1,9 +1,9 @@
#include "emu/profiler.h"
#include "hw/holly/texture_cache.h"
#include "hw/holly/tile_accelerator.h"
#include "hw/holly/trace.h"
#include "hw/dreamcast.h"
#include "hw/memory.h"
#include "trace/trace.h"
using namespace re::hw;
using namespace re::hw::holly;

View File

@ -1,15 +1,14 @@
#include "core/memory.h"
#include "hw/holly/pixel_convert.h"
#include "hw/holly/tile_accelerator.h"
#include "hw/holly/trace.h"
#include "hw/dreamcast.h"
#include "hw/memory.h"
#include "trace/trace.h"
using namespace re;
using namespace re::hw;
using namespace re::hw::holly;
using namespace re::renderer;
using namespace re::trace;
static void BuildLookupTables();
static int GetParamSize_raw(const PCW &pcw, int vertex_type);

View File

@ -9,10 +9,6 @@
#include "renderer/backend.h"
namespace re {
namespace trace {
class TraceWriter;
}
namespace hw {
class Dreamcast;

View File

@ -16,7 +16,7 @@ union VertexParam;
struct TileContext;
// The TextureCache interface provides an abstraction so the TileAccelerator /
// TraceViewer can provide raw texture and palette data on demand to the
// Tracer can provide raw texture and palette data on demand to the
// TileRenderer. While a static GetTextureKey is provided, each implementation
// is expected to manage their own cache internally.
typedef std::function<renderer::TextureHandle(const uint8_t *, const uint8_t *)>
@ -37,7 +37,7 @@ class TextureProvider {
// The TileRenderer class is responsible for taking a particular TileContext,
// parsing it and ultimately rendering it out to the supplied backend. This
// is split out of the main TileAccelerator code so it can be re-used by
// TraceViewer.
// Tracer.
enum { MAX_SURFACES = 0x10000, MAX_VERTICES = 0x10000 };
class TileRenderer {

View File

@ -1,14 +1,13 @@
#include <unordered_map>
#include "core/assert.h"
#include "hw/holly/trace.h"
#include "sys/filesystem.h"
#include "trace/trace.h"
using namespace re;
using namespace re::hw::holly;
using namespace re::sys;
using namespace re::trace;
void re::trace::GetNextTraceFilename(char *filename, size_t size) {
void re::hw::holly::GetNextTraceFilename(char *filename, size_t size) {
const char *appdir = GetAppDir();
for (int i = 0; i < INT_MAX; i++) {

View File

@ -4,7 +4,8 @@
#include "hw/holly/tile_accelerator.h"
namespace re {
namespace trace {
namespace hw {
namespace holly {
enum TraceCommandType { TRACE_INSERT_TEXTURE, TRACE_RENDER_CONTEXT };
@ -22,8 +23,8 @@ struct TraceCommand {
// and patched to absolute pointers on read
union {
struct {
hw::holly::TSP tsp;
hw::holly::TCW tcw;
TSP tsp;
TCW tcw;
uint32_t palette_size;
const uint8_t *palette;
uint32_t texture_size;
@ -38,9 +39,9 @@ struct TraceCommand {
uint32_t pal_pxl_format;
uint32_t video_width;
uint32_t video_height;
hw::holly::ISP_TSP bg_isp;
hw::holly::TSP bg_tsp;
hw::holly::TCW bg_tcw;
ISP_TSP bg_isp;
TSP bg_tsp;
TCW bg_tcw;
float bg_depth;
uint32_t bg_vertices_size;
const uint8_t *bg_vertices;
@ -78,15 +79,16 @@ class TraceWriter {
bool Open(const char *filename);
void Close();
void WriteInsertTexture(const hw::holly::TSP &tsp, const hw::holly::TCW &tcw,
void WriteInsertTexture(const TSP &tsp, const TCW &tcw,
const uint8_t *palette, int palette_size,
const uint8_t *texture, int texture_size);
void WriteRenderContext(hw::holly::TileContext *tactx);
void WriteRenderContext(TileContext *tactx);
private:
FILE *file_;
};
}
}
}
#endif

View File

@ -2,7 +2,7 @@
#include <memory>
#include <gflags/gflags.h>
#include "emu/emulator.h"
#include "trace/trace_viewer.h"
#include "emu/tracer.h"
#include "sys/exception_handler.h"
#include "sys/filesystem.h"
#include "sys/network.h"
@ -10,7 +10,6 @@
using namespace re;
using namespace re::emu;
using namespace re::sys;
using namespace re::trace;
void InitFlags(int *argc, char ***argv) {
const char *appdir = GetAppDir();
@ -50,7 +49,7 @@ int main(int argc, char **argv) {
const char *load = argc > 1 ? argv[1] : nullptr;
if (load && strstr(load, ".trace")) {
std::unique_ptr<TraceViewer> tracer(new TraceViewer());
std::unique_ptr<Tracer> tracer(new Tracer());
tracer->Run(load);
} else {
std::unique_ptr<Emulator> emu(new Emulator());