-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
83 lines (71 loc) · 2.95 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <fstream>
#include "state.h"
#include <cereal/archives/binary.hpp>
#include <Emu/RSX/rsx_trace.h>
#include <algorithm>
//#include <Emu/RSX/Common/BufferUtils.h>
#include <Emu/RSX/gcm_printing.h>
namespace
{
template<typename T>
void fill_variant_vector(std::vector<gsl::byte> values,
const rsx::frame_capture_data::draw_state &draw_state,
QList<QVariant> &lst)
{
return;
/*
std::vector<gsl::byte> readable_index(values.size());
write_index_array_data_to_buffer(readable_index, values,
draw_state.state.index_type(), rsx::primitive_type::triangles, false, -1, {{0, values.size() / sizeof(T)}},
[](auto) { return false; });
gsl::span<T> casted_readable_index = {reinterpret_cast<T*>(values.data()), gsl::narrow<int>(values.size() / sizeof(T))};
std::for_each(casted_readable_index.begin(), casted_readable_index.end(),
[&lst](auto v) {lst.append(QVariant::fromValue(v));});*/
}
}
std::tuple<QList<QObject*>, QStringList> load_command_trace()
{
// Unfortunatly QTextStream isn't compatible with std::iostream
std::fstream f("../bin/capture.txt", std::ios::in | std::ios::binary);
cereal::BinaryInputArchive archive(f);
rsx::frame_capture_data frame_debug;
archive(frame_debug);
QList<QObject*> st;
for (const rsx::frame_capture_data::draw_state &draw_state : frame_debug.draw_calls)
{
auto *tmp = new qt_rsx_state;
*tmp = draw_state.state;
tmp->_name = QString::fromStdString(draw_state.name);
tmp->_transform_program = QString::fromStdString(draw_state.programs.first);
tmp->_shader_program = QString::fromStdString(draw_state.programs.second);
switch (draw_state.state.index_type())
{
case rsx::index_array_type::u16:
fill_variant_vector<u16>(draw_state.index, draw_state, tmp->_index_list);
break;
case rsx::index_array_type::u32:
fill_variant_vector<u32>(draw_state.index, draw_state, tmp->_index_list);
break;
}
st.append(tmp);
}
QStringList commands;
std::transform(frame_debug.command_queue.begin(), frame_debug.command_queue.end(),
std::back_inserter(commands),
[](const std::pair<u32, u32> pair){ return QString::fromStdString(rsx::get_pretty_printing_function(pair.first)(pair.second));});
return std::make_tuple(st, commands);
}
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
QQmlContext* ctx = engine.rootContext();
std::tuple<QList<QObject*>, QStringList > st = load_command_trace();
ctx->setContextProperty("commandList", std::get<1>(st));
ctx->setContextProperty("stateList", QVariant::fromValue(std::get<0>(st)));
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
return app.exec();
}