mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-27 12:04:16 +01:00
CiTrace: Clean up initialization method.
This commit is contained in:
parent
dc8295298e
commit
29abb11e8f
@ -12,6 +12,8 @@
|
|||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
|
|
||||||
|
#include <boost/range/algorithm/copy.hpp>
|
||||||
|
|
||||||
#include "core/hw/gpu.h"
|
#include "core/hw/gpu.h"
|
||||||
#include "core/hw/lcd.h"
|
#include "core/hw/lcd.h"
|
||||||
|
|
||||||
@ -76,15 +78,19 @@ void GraphicsTracingWidget::StartRecording() {
|
|||||||
for (unsigned comp = 0; comp < 3; ++comp)
|
for (unsigned comp = 0; comp < 3; ++comp)
|
||||||
vs_float_uniforms[4 * i + comp] = nihstro::to_float24(Pica::g_state.vs.uniforms.f[i][comp].ToFloat32());
|
vs_float_uniforms[4 * i + comp] = nihstro::to_float24(Pica::g_state.vs.uniforms.f[i][comp].ToFloat32());
|
||||||
|
|
||||||
auto recorder = new CiTrace::Recorder((u32*)&GPU::g_regs, sizeof(GPU::g_regs) / sizeof(u32),
|
CiTrace::Recorder::InitialState state;
|
||||||
(u32*)&LCD::g_regs, sizeof(LCD::g_regs) / sizeof(u32),
|
std::copy_n((u32*)&GPU::g_regs, sizeof(GPU::g_regs) / sizeof(u32), std::back_inserter(state.gpu_registers));
|
||||||
(u32*)&Pica::g_state.regs, sizeof(Pica::g_state.regs) / sizeof(u32),
|
std::copy_n((u32*)&LCD::g_regs, sizeof(LCD::g_regs) / sizeof(u32), std::back_inserter(state.lcd_registers));
|
||||||
default_attributes.data(), default_attributes.size(),
|
std::copy_n((u32*)&Pica::g_state.regs, sizeof(Pica::g_state.regs) / sizeof(u32), std::back_inserter(state.pica_registers));
|
||||||
shader_binary.data(), shader_binary.size(),
|
boost::copy(default_attributes, std::back_inserter(state.default_attributes));
|
||||||
swizzle_data.data(), swizzle_data.size(),
|
boost::copy(shader_binary, std::back_inserter(state.vs_program_binary));
|
||||||
vs_float_uniforms.data(), vs_float_uniforms.size(),
|
boost::copy(swizzle_data, std::back_inserter(state.vs_swizzle_data));
|
||||||
nullptr, 0, nullptr, 0, nullptr, 0 // Geometry shader is not implemented yet, so submit dummy data for now
|
boost::copy(vs_float_uniforms, std::back_inserter(state.vs_float_uniforms));
|
||||||
);
|
//boost::copy(TODO: Not implemented, std::back_inserter(state.gs_program_binary));
|
||||||
|
//boost::copy(TODO: Not implemented, std::back_inserter(state.gs_swizzle_data));
|
||||||
|
//boost::copy(TODO: Not implemented, std::back_inserter(state.gs_float_uniforms));
|
||||||
|
|
||||||
|
auto recorder = new CiTrace::Recorder(state);
|
||||||
context->recorder = std::shared_ptr<CiTrace::Recorder>(recorder);
|
context->recorder = std::shared_ptr<CiTrace::Recorder>(recorder);
|
||||||
|
|
||||||
emit SetStartTracingButtonEnabled(false);
|
emit SetStartTracingButtonEnabled(false);
|
||||||
|
@ -12,26 +12,7 @@
|
|||||||
|
|
||||||
namespace CiTrace {
|
namespace CiTrace {
|
||||||
|
|
||||||
Recorder::Recorder(u32* gpu_registers, u32 gpu_registers_size,
|
Recorder::Recorder(const InitialState& initial_state) : initial_state(initial_state) {
|
||||||
u32* lcd_registers, u32 lcd_registers_size,
|
|
||||||
u32* pica_registers, u32 pica_registers_size,
|
|
||||||
u32* default_attributes, u32 default_attributes_size,
|
|
||||||
u32* vs_program_binary, u32 vs_program_binary_size,
|
|
||||||
u32* vs_swizzle_data, u32 vs_swizzle_data_size,
|
|
||||||
u32* vs_float_uniforms, u32 vs_float_uniforms_size,
|
|
||||||
u32* gs_program_binary, u32 gs_program_binary_size,
|
|
||||||
u32* gs_swizzle_data, u32 gs_swizzle_data_size,
|
|
||||||
u32* gs_float_uniforms, u32 gs_float_uniforms_size)
|
|
||||||
: gpu_registers(gpu_registers, gpu_registers + gpu_registers_size),
|
|
||||||
lcd_registers(lcd_registers, lcd_registers + lcd_registers_size),
|
|
||||||
pica_registers(pica_registers, pica_registers + pica_registers_size),
|
|
||||||
default_attributes(default_attributes, default_attributes + default_attributes_size),
|
|
||||||
vs_program_binary(vs_program_binary, vs_program_binary + vs_program_binary_size),
|
|
||||||
vs_swizzle_data(vs_swizzle_data, vs_swizzle_data + vs_swizzle_data_size),
|
|
||||||
vs_float_uniforms(vs_float_uniforms, vs_float_uniforms + vs_float_uniforms_size),
|
|
||||||
gs_program_binary(gs_program_binary, gs_program_binary + gs_program_binary_size),
|
|
||||||
gs_swizzle_data(gs_swizzle_data, gs_swizzle_data + gs_swizzle_data_size),
|
|
||||||
gs_float_uniforms(gs_float_uniforms, gs_float_uniforms + gs_float_uniforms_size) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,16 +26,16 @@ void Recorder::Finish(const std::string& filename) {
|
|||||||
// Calculate file offsets
|
// Calculate file offsets
|
||||||
auto& initial = header.initial_state_offsets;
|
auto& initial = header.initial_state_offsets;
|
||||||
|
|
||||||
initial.gpu_registers_size = gpu_registers.size();
|
initial.gpu_registers_size = initial_state.gpu_registers.size();
|
||||||
initial.lcd_registers_size = lcd_registers.size();
|
initial.lcd_registers_size = initial_state.lcd_registers.size();
|
||||||
initial.pica_registers_size = pica_registers.size();
|
initial.pica_registers_size = initial_state.pica_registers.size();
|
||||||
initial.default_attributes_size = default_attributes.size();
|
initial.default_attributes_size = initial_state.default_attributes.size();
|
||||||
initial.vs_program_binary_size = vs_program_binary.size();
|
initial.vs_program_binary_size = initial_state.vs_program_binary.size();
|
||||||
initial.vs_swizzle_data_size = vs_swizzle_data.size();
|
initial.vs_swizzle_data_size = initial_state.vs_swizzle_data.size();
|
||||||
initial.vs_float_uniforms_size = vs_float_uniforms.size();
|
initial.vs_float_uniforms_size = initial_state.vs_float_uniforms.size();
|
||||||
initial.gs_program_binary_size = gs_program_binary.size();
|
initial.gs_program_binary_size = initial_state.gs_program_binary.size();
|
||||||
initial.gs_swizzle_data_size = gs_swizzle_data.size();
|
initial.gs_swizzle_data_size = initial_state.gs_swizzle_data.size();
|
||||||
initial.gs_float_uniforms_size = gs_float_uniforms.size();
|
initial.gs_float_uniforms_size = initial_state.gs_float_uniforms.size();
|
||||||
header.stream_size = stream.size();
|
header.stream_size = stream.size();
|
||||||
|
|
||||||
initial.gpu_registers = sizeof(header);
|
initial.gpu_registers = sizeof(header);
|
||||||
@ -98,44 +79,44 @@ void Recorder::Finish(const std::string& filename) {
|
|||||||
throw "Failed to write header";
|
throw "Failed to write header";
|
||||||
|
|
||||||
// Write initial state
|
// Write initial state
|
||||||
written = file.WriteArray(gpu_registers.data(), gpu_registers.size());
|
written = file.WriteArray(initial_state.gpu_registers.data(), initial_state.gpu_registers.size());
|
||||||
if (written != gpu_registers.size() || file.Tell() != initial.lcd_registers)
|
if (written != initial_state.gpu_registers.size() || file.Tell() != initial.lcd_registers)
|
||||||
throw "Failed to write GPU registers";
|
throw "Failed to write GPU registers";
|
||||||
|
|
||||||
written = file.WriteArray(lcd_registers.data(), lcd_registers.size());
|
written = file.WriteArray(initial_state.lcd_registers.data(), initial_state.lcd_registers.size());
|
||||||
if (written != lcd_registers.size() || file.Tell() != initial.pica_registers)
|
if (written != initial_state.lcd_registers.size() || file.Tell() != initial.pica_registers)
|
||||||
throw "Failed to write LCD registers";
|
throw "Failed to write LCD registers";
|
||||||
|
|
||||||
written = file.WriteArray(pica_registers.data(), pica_registers.size());
|
written = file.WriteArray(initial_state.pica_registers.data(), initial_state.pica_registers.size());
|
||||||
if (written != pica_registers.size() || file.Tell() != initial.default_attributes)
|
if (written != initial_state.pica_registers.size() || file.Tell() != initial.default_attributes)
|
||||||
throw "Failed to write Pica registers";
|
throw "Failed to write Pica registers";
|
||||||
|
|
||||||
written = file.WriteArray(default_attributes.data(), default_attributes.size());
|
written = file.WriteArray(initial_state.default_attributes.data(), initial_state.default_attributes.size());
|
||||||
if (written != default_attributes.size() || file.Tell() != initial.vs_program_binary)
|
if (written != initial_state.default_attributes.size() || file.Tell() != initial.vs_program_binary)
|
||||||
throw "Failed to write default vertex attributes";
|
throw "Failed to write default vertex attributes";
|
||||||
|
|
||||||
written = file.WriteArray(vs_program_binary.data(), vs_program_binary.size());
|
written = file.WriteArray(initial_state.vs_program_binary.data(), initial_state.vs_program_binary.size());
|
||||||
if (written != vs_program_binary.size() || file.Tell() != initial.vs_swizzle_data)
|
if (written != initial_state.vs_program_binary.size() || file.Tell() != initial.vs_swizzle_data)
|
||||||
throw "Failed to write vertex shader program binary";
|
throw "Failed to write vertex shader program binary";
|
||||||
|
|
||||||
written = file.WriteArray(vs_swizzle_data.data(), vs_swizzle_data.size());
|
written = file.WriteArray(initial_state.vs_swizzle_data.data(), initial_state.vs_swizzle_data.size());
|
||||||
if (written != vs_swizzle_data.size() || file.Tell() != initial.vs_float_uniforms)
|
if (written != initial_state.vs_swizzle_data.size() || file.Tell() != initial.vs_float_uniforms)
|
||||||
throw "Failed to write vertex shader swizzle data";
|
throw "Failed to write vertex shader swizzle data";
|
||||||
|
|
||||||
written = file.WriteArray(vs_float_uniforms.data(), vs_float_uniforms.size());
|
written = file.WriteArray(initial_state.vs_float_uniforms.data(), initial_state.vs_float_uniforms.size());
|
||||||
if (written != vs_float_uniforms.size() || file.Tell() != initial.gs_program_binary)
|
if (written != initial_state.vs_float_uniforms.size() || file.Tell() != initial.gs_program_binary)
|
||||||
throw "Failed to write vertex shader float uniforms";
|
throw "Failed to write vertex shader float uniforms";
|
||||||
|
|
||||||
written = file.WriteArray(gs_program_binary.data(), gs_program_binary.size());
|
written = file.WriteArray(initial_state.gs_program_binary.data(), initial_state.gs_program_binary.size());
|
||||||
if (written != gs_program_binary.size() || file.Tell() != initial.gs_swizzle_data)
|
if (written != initial_state.gs_program_binary.size() || file.Tell() != initial.gs_swizzle_data)
|
||||||
throw "Failed to write geomtry shader program binary";
|
throw "Failed to write geomtry shader program binary";
|
||||||
|
|
||||||
written = file.WriteArray(gs_swizzle_data.data(), gs_swizzle_data.size());
|
written = file.WriteArray(initial_state.gs_swizzle_data.data(), initial_state.gs_swizzle_data.size());
|
||||||
if (written != gs_swizzle_data.size() || file.Tell() != initial.gs_float_uniforms)
|
if (written != initial_state.gs_swizzle_data.size() || file.Tell() != initial.gs_float_uniforms)
|
||||||
throw "Failed to write geometry shader swizzle data";
|
throw "Failed to write geometry shader swizzle data";
|
||||||
|
|
||||||
written = file.WriteArray(gs_float_uniforms.data(), gs_float_uniforms.size());
|
written = file.WriteArray(initial_state.gs_float_uniforms.data(), initial_state.gs_float_uniforms.size());
|
||||||
if (written != gs_float_uniforms.size() || file.Tell() != initial.gs_float_uniforms + sizeof(u32) * initial.gs_float_uniforms_size)
|
if (written != initial_state.gs_float_uniforms.size() || file.Tell() != initial.gs_float_uniforms + sizeof(u32) * initial.gs_float_uniforms_size)
|
||||||
throw "Failed to write geometry shader float uniforms";
|
throw "Failed to write geometry shader float uniforms";
|
||||||
|
|
||||||
// Iterate through stream elements, write "extra data"
|
// Iterate through stream elements, write "extra data"
|
||||||
|
@ -17,21 +17,25 @@ namespace CiTrace {
|
|||||||
|
|
||||||
class Recorder {
|
class Recorder {
|
||||||
public:
|
public:
|
||||||
|
struct InitialState {
|
||||||
|
std::vector<u32> gpu_registers;
|
||||||
|
std::vector<u32> lcd_registers;
|
||||||
|
std::vector<u32> pica_registers;
|
||||||
|
std::vector<u32> default_attributes;
|
||||||
|
std::vector<u32> vs_program_binary;
|
||||||
|
std::vector<u32> vs_swizzle_data;
|
||||||
|
std::vector<u32> vs_float_uniforms;
|
||||||
|
std::vector<u32> gs_program_binary;
|
||||||
|
std::vector<u32> gs_swizzle_data;
|
||||||
|
std::vector<u32> gs_float_uniforms;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recorder constructor
|
* Recorder constructor
|
||||||
* @param default_attributes Pointer to an array of 32-bit-aligned 24-bit floating point values.
|
* @param default_attributes Pointer to an array of 32-bit-aligned 24-bit floating point values.
|
||||||
* @param vs_float_uniforms Pointer to an array of 32-bit-aligned 24-bit floating point values.
|
* @param vs_float_uniforms Pointer to an array of 32-bit-aligned 24-bit floating point values.
|
||||||
*/
|
*/
|
||||||
Recorder(u32* gpu_registers, u32 gpu_registers_size,
|
Recorder(const InitialState& initial_state);
|
||||||
u32* lcd_registers, u32 lcd_registers_size,
|
|
||||||
u32* pica_registers, u32 pica_registers_size,
|
|
||||||
u32* default_attributes, u32 default_attributes_size,
|
|
||||||
u32* vs_program_binary, u32 vs_program_binary_size,
|
|
||||||
u32* vs_swizzle_data, u32 vs_swizzle_data_size,
|
|
||||||
u32* vs_float_uniforms, u32 vs_float_uniforms_size,
|
|
||||||
u32* gs_program_binary, u32 gs_program_binary_size,
|
|
||||||
u32* gs_swizzle_data, u32 gs_swizzle_data_size,
|
|
||||||
u32* gs_float_uniforms, u32 gs_float_uniforms_size);
|
|
||||||
|
|
||||||
/// Finish recording of this Citrace and save it using the given filename.
|
/// Finish recording of this Citrace and save it using the given filename.
|
||||||
void Finish(const std::string& filename);
|
void Finish(const std::string& filename);
|
||||||
@ -55,16 +59,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Initial state of recording start
|
// Initial state of recording start
|
||||||
std::vector<u32> gpu_registers;
|
InitialState initial_state;
|
||||||
std::vector<u32> lcd_registers;
|
|
||||||
std::vector<u32> pica_registers;
|
|
||||||
std::vector<u32> default_attributes;
|
|
||||||
std::vector<u32> vs_program_binary;
|
|
||||||
std::vector<u32> vs_swizzle_data;
|
|
||||||
std::vector<u32> vs_float_uniforms;
|
|
||||||
std::vector<u32> gs_program_binary;
|
|
||||||
std::vector<u32> gs_swizzle_data;
|
|
||||||
std::vector<u32> gs_float_uniforms;
|
|
||||||
|
|
||||||
// Command stream
|
// Command stream
|
||||||
struct StreamElement {
|
struct StreamElement {
|
||||||
|
Loading…
Reference in New Issue
Block a user