summaryrefslogtreecommitdiff
path: root/src/citra_qt/debugger/graphics/graphics_tracing.cpp
diff options
context:
space:
mode:
authorGravatar James Rowe2018-01-11 19:21:20 -0700
committerGravatar James Rowe2018-01-12 19:11:03 -0700
commitebf9a784a9f7f4148a669dbb39e7cd50df779a14 (patch)
treed585685a1c0a34b903af1d086d62560bf56bb29f /src/citra_qt/debugger/graphics/graphics_tracing.cpp
parentconfig: Default CPU core to Unicorn. (diff)
downloadyuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.gz
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.tar.xz
yuzu-ebf9a784a9f7f4148a669dbb39e7cd50df779a14.zip
Massive removal of unused modules
Diffstat (limited to 'src/citra_qt/debugger/graphics/graphics_tracing.cpp')
-rw-r--r--src/citra_qt/debugger/graphics/graphics_tracing.cpp177
1 files changed, 0 insertions, 177 deletions
diff --git a/src/citra_qt/debugger/graphics/graphics_tracing.cpp b/src/citra_qt/debugger/graphics/graphics_tracing.cpp
deleted file mode 100644
index 40d5bed51..000000000
--- a/src/citra_qt/debugger/graphics/graphics_tracing.cpp
+++ /dev/null
@@ -1,177 +0,0 @@
1// Copyright 2015 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <algorithm>
6#include <array>
7#include <iterator>
8#include <memory>
9#include <QBoxLayout>
10#include <QComboBox>
11#include <QFileDialog>
12#include <QMessageBox>
13#include <QPushButton>
14#include <boost/range/algorithm/copy.hpp>
15#include "citra_qt/debugger/graphics/graphics_tracing.h"
16#include "common/common_types.h"
17#include "core/hw/gpu.h"
18#include "core/hw/lcd.h"
19#include "core/tracer/recorder.h"
20#include "nihstro/float24.h"
21#include "video_core/pica_state.h"
22
23GraphicsTracingWidget::GraphicsTracingWidget(std::shared_ptr<Pica::DebugContext> debug_context,
24 QWidget* parent)
25 : BreakPointObserverDock(debug_context, tr("CiTrace Recorder"), parent) {
26
27 setObjectName("CiTracing");
28
29 QPushButton* start_recording = new QPushButton(tr("Start Recording"));
30 QPushButton* stop_recording =
31 new QPushButton(QIcon::fromTheme("document-save"), tr("Stop and Save"));
32 QPushButton* abort_recording = new QPushButton(tr("Abort Recording"));
33
34 connect(this, SIGNAL(SetStartTracingButtonEnabled(bool)), start_recording,
35 SLOT(setVisible(bool)));
36 connect(this, SIGNAL(SetStopTracingButtonEnabled(bool)), stop_recording,
37 SLOT(setVisible(bool)));
38 connect(this, SIGNAL(SetAbortTracingButtonEnabled(bool)), abort_recording,
39 SLOT(setVisible(bool)));
40 connect(start_recording, SIGNAL(clicked()), this, SLOT(StartRecording()));
41 connect(stop_recording, SIGNAL(clicked()), this, SLOT(StopRecording()));
42 connect(abort_recording, SIGNAL(clicked()), this, SLOT(AbortRecording()));
43
44 stop_recording->setVisible(false);
45 abort_recording->setVisible(false);
46
47 auto main_widget = new QWidget;
48 auto main_layout = new QVBoxLayout;
49 {
50 auto sub_layout = new QHBoxLayout;
51 sub_layout->addWidget(start_recording);
52 sub_layout->addWidget(stop_recording);
53 sub_layout->addWidget(abort_recording);
54 main_layout->addLayout(sub_layout);
55 }
56 main_widget->setLayout(main_layout);
57 setWidget(main_widget);
58}
59
60void GraphicsTracingWidget::StartRecording() {
61 auto context = context_weak.lock();
62 if (!context)
63 return;
64
65 auto shader_binary = Pica::g_state.vs.program_code;
66 auto swizzle_data = Pica::g_state.vs.swizzle_data;
67
68 // Encode floating point numbers to 24-bit values
69 // TODO: Drop this explicit conversion once we store float24 values bit-correctly internally.
70 std::array<u32, 4 * 16> default_attributes;
71 for (unsigned i = 0; i < 16; ++i) {
72 for (unsigned comp = 0; comp < 3; ++comp) {
73 default_attributes[4 * i + comp] = nihstro::to_float24(
74 Pica::g_state.input_default_attributes.attr[i][comp].ToFloat32());
75 }
76 }
77
78 std::array<u32, 4 * 96> vs_float_uniforms;
79 for (unsigned i = 0; i < 96; ++i)
80 for (unsigned comp = 0; comp < 3; ++comp)
81 vs_float_uniforms[4 * i + comp] =
82 nihstro::to_float24(Pica::g_state.vs.uniforms.f[i][comp].ToFloat32());
83
84 CiTrace::Recorder::InitialState state;
85 std::copy_n((u32*)&GPU::g_regs, sizeof(GPU::g_regs) / sizeof(u32),
86 std::back_inserter(state.gpu_registers));
87 std::copy_n((u32*)&LCD::g_regs, sizeof(LCD::g_regs) / sizeof(u32),
88 std::back_inserter(state.lcd_registers));
89 std::copy_n((u32*)&Pica::g_state.regs, sizeof(Pica::g_state.regs) / sizeof(u32),
90 std::back_inserter(state.pica_registers));
91 boost::copy(default_attributes, std::back_inserter(state.default_attributes));
92 boost::copy(shader_binary, std::back_inserter(state.vs_program_binary));
93 boost::copy(swizzle_data, std::back_inserter(state.vs_swizzle_data));
94 boost::copy(vs_float_uniforms, std::back_inserter(state.vs_float_uniforms));
95 // boost::copy(TODO: Not implemented, std::back_inserter(state.gs_program_binary));
96 // boost::copy(TODO: Not implemented, std::back_inserter(state.gs_swizzle_data));
97 // boost::copy(TODO: Not implemented, std::back_inserter(state.gs_float_uniforms));
98
99 auto recorder = new CiTrace::Recorder(state);
100 context->recorder = std::shared_ptr<CiTrace::Recorder>(recorder);
101
102 emit SetStartTracingButtonEnabled(false);
103 emit SetStopTracingButtonEnabled(true);
104 emit SetAbortTracingButtonEnabled(true);
105}
106
107void GraphicsTracingWidget::StopRecording() {
108 auto context = context_weak.lock();
109 if (!context)
110 return;
111
112 QString filename = QFileDialog::getSaveFileName(this, tr("Save CiTrace"), "citrace.ctf",
113 tr("CiTrace File (*.ctf)"));
114
115 if (filename.isEmpty()) {
116 // If the user canceled the dialog, keep recording
117 return;
118 }
119
120 context->recorder->Finish(filename.toStdString());
121 context->recorder = nullptr;
122
123 emit SetStopTracingButtonEnabled(false);
124 emit SetAbortTracingButtonEnabled(false);
125 emit SetStartTracingButtonEnabled(true);
126}
127
128void GraphicsTracingWidget::AbortRecording() {
129 auto context = context_weak.lock();
130 if (!context)
131 return;
132
133 context->recorder = nullptr;
134
135 emit SetStopTracingButtonEnabled(false);
136 emit SetAbortTracingButtonEnabled(false);
137 emit SetStartTracingButtonEnabled(true);
138}
139
140void GraphicsTracingWidget::OnBreakPointHit(Pica::DebugContext::Event event, void* data) {
141 widget()->setEnabled(true);
142}
143
144void GraphicsTracingWidget::OnResumed() {
145 widget()->setEnabled(false);
146}
147
148void GraphicsTracingWidget::OnEmulationStarting(EmuThread* emu_thread) {
149 // Disable tracing starting/stopping until a GPU breakpoint is reached
150 widget()->setEnabled(false);
151}
152
153void GraphicsTracingWidget::OnEmulationStopping() {
154 // TODO: Is it safe to access the context here?
155
156 auto context = context_weak.lock();
157 if (!context)
158 return;
159
160 if (context->recorder) {
161 auto reply =
162 QMessageBox::question(this, tr("CiTracing still active"),
163 tr("A CiTrace is still being recorded. Do you want to save it? "
164 "If not, all recorded data will be discarded."),
165 QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
166
167 if (reply == QMessageBox::Yes) {
168 StopRecording();
169 } else {
170 AbortRecording();
171 }
172 }
173
174 // If the widget was disabled before, enable it now to allow starting
175 // tracing before starting the next emulation session
176 widget()->setEnabled(true);
177}