CiTrace: Record default vertex attributes.
This commit is contained in:
parent
0799b40caa
commit
fd62580985
5 changed files with 64 additions and 42 deletions
|
@ -62,12 +62,20 @@ void GraphicsTracingWidget::StartRecording() {
|
||||||
|
|
||||||
// Encode floating point numbers to 24-bit values
|
// Encode floating point numbers to 24-bit values
|
||||||
// TODO: Drop this explicit conversion once we store float24 values bit-correctly internally.
|
// TODO: Drop this explicit conversion once we store float24 values bit-correctly internally.
|
||||||
|
std::array<Math::Vec4<uint32_t>, 16> default_attributes;
|
||||||
|
for (unsigned i = 0; i < 16; ++i) {
|
||||||
|
for (unsigned comp = 0; comp < 3; ++comp) {
|
||||||
|
default_attributes[i][comp] = nihstro::to_float24(Pica::g_state.vs.default_attributes[i][comp].ToFloat32());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::array<Math::Vec4<uint32_t>, 96> vs_float_uniforms;
|
std::array<Math::Vec4<uint32_t>, 96> vs_float_uniforms;
|
||||||
for (unsigned i = 0; i < 96; ++i)
|
for (unsigned i = 0; i < 96; ++i)
|
||||||
for (unsigned comp = 0; comp < 3; ++comp)
|
for (unsigned comp = 0; comp < 3; ++comp)
|
||||||
vs_float_uniforms[i][comp] = nihstro::to_float24(Pica::g_state.vs.uniforms.f[i][comp].ToFloat32());
|
vs_float_uniforms[i][comp] = nihstro::to_float24(Pica::g_state.vs.uniforms.f[i][comp].ToFloat32());
|
||||||
|
|
||||||
auto recorder = new CiTrace::Recorder((u32*)&GPU::g_regs, 0x700, nullptr, 0, (u32*)&Pica::g_state.regs, 0x300,
|
auto recorder = new CiTrace::Recorder((u32*)&GPU::g_regs, 0x700, nullptr, 0, (u32*)&Pica::g_state.regs, 0x300,
|
||||||
|
(u32*)default_attributes.data(), default_attributes.size() * 4,
|
||||||
shader_binary.data(), shader_binary.size(),
|
shader_binary.data(), shader_binary.size(),
|
||||||
swizzle_data.data(), swizzle_data.size(),
|
swizzle_data.data(), swizzle_data.size(),
|
||||||
(u32*)vs_float_uniforms.data(), vs_float_uniforms.size() * 4,
|
(u32*)vs_float_uniforms.data(), vs_float_uniforms.size() * 4,
|
||||||
|
|
|
@ -245,7 +245,7 @@ set(HEADERS
|
||||||
loader/loader.h
|
loader/loader.h
|
||||||
loader/ncch.h
|
loader/ncch.h
|
||||||
tracer/recorder.h
|
tracer/recorder.h
|
||||||
tracer/tracer.h
|
tracer/citrace.h
|
||||||
mem_map.h
|
mem_map.h
|
||||||
memory.h
|
memory.h
|
||||||
memory_setup.h
|
memory_setup.h
|
||||||
|
|
|
@ -35,6 +35,8 @@ struct CTHeader {
|
||||||
uint32_t lcd_registers_size;
|
uint32_t lcd_registers_size;
|
||||||
uint32_t pica_registers;
|
uint32_t pica_registers;
|
||||||
uint32_t pica_registers_size;
|
uint32_t pica_registers_size;
|
||||||
|
uint32_t default_attributes;
|
||||||
|
uint32_t default_attributes_size;
|
||||||
uint32_t vs_program_binary;
|
uint32_t vs_program_binary;
|
||||||
uint32_t vs_program_binary_size;
|
uint32_t vs_program_binary_size;
|
||||||
uint32_t vs_swizzle_data;
|
uint32_t vs_swizzle_data;
|
||||||
|
@ -50,7 +52,8 @@ struct CTHeader {
|
||||||
|
|
||||||
// Other things we might want to store here:
|
// Other things we might want to store here:
|
||||||
// - Initial framebuffer data, maybe even a full copy of FCRAM/VRAM
|
// - Initial framebuffer data, maybe even a full copy of FCRAM/VRAM
|
||||||
// - Default vertex attributes
|
// - Lookup tables for fragment lighting
|
||||||
|
// - Lookup tables for procedural textures
|
||||||
} initial_state_offsets;
|
} initial_state_offsets;
|
||||||
|
|
||||||
uint32_t stream_offset;
|
uint32_t stream_offset;
|
|
@ -15,6 +15,7 @@ namespace CiTrace {
|
||||||
Recorder::Recorder(u32* gpu_registers, u32 gpu_registers_size,
|
Recorder::Recorder(u32* gpu_registers, u32 gpu_registers_size,
|
||||||
u32* lcd_registers, u32 lcd_registers_size,
|
u32* lcd_registers, u32 lcd_registers_size,
|
||||||
u32* pica_registers, u32 pica_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_program_binary, u32 vs_program_binary_size,
|
||||||
u32* vs_swizzle_data, u32 vs_swizzle_data_size,
|
u32* vs_swizzle_data, u32 vs_swizzle_data_size,
|
||||||
u32* vs_float_uniforms, u32 vs_float_uniforms_size,
|
u32* vs_float_uniforms, u32 vs_float_uniforms_size,
|
||||||
|
@ -24,6 +25,7 @@ Recorder::Recorder(u32* gpu_registers, u32 gpu_registers_size,
|
||||||
: gpu_registers(gpu_registers, gpu_registers + gpu_registers_size),
|
: gpu_registers(gpu_registers, gpu_registers + gpu_registers_size),
|
||||||
lcd_registers(lcd_registers, lcd_registers + lcd_registers_size),
|
lcd_registers(lcd_registers, lcd_registers + lcd_registers_size),
|
||||||
pica_registers(pica_registers, pica_registers + pica_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_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_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),
|
vs_float_uniforms(vs_float_uniforms, vs_float_uniforms + vs_float_uniforms_size),
|
||||||
|
@ -46,6 +48,7 @@ void Recorder::Finish(const std::string& filename) {
|
||||||
initial.gpu_registers_size = gpu_registers.size();
|
initial.gpu_registers_size = gpu_registers.size();
|
||||||
initial.lcd_registers_size = lcd_registers.size();
|
initial.lcd_registers_size = lcd_registers.size();
|
||||||
initial.pica_registers_size = pica_registers.size();
|
initial.pica_registers_size = pica_registers.size();
|
||||||
|
initial.default_attributes_size = default_attributes.size();
|
||||||
initial.vs_program_binary_size = vs_program_binary.size();
|
initial.vs_program_binary_size = vs_program_binary.size();
|
||||||
initial.vs_swizzle_data_size = vs_swizzle_data.size();
|
initial.vs_swizzle_data_size = vs_swizzle_data.size();
|
||||||
initial.vs_float_uniforms_size = vs_float_uniforms.size();
|
initial.vs_float_uniforms_size = vs_float_uniforms.size();
|
||||||
|
@ -57,7 +60,8 @@ void Recorder::Finish(const std::string& filename) {
|
||||||
initial.gpu_registers = sizeof(header);
|
initial.gpu_registers = sizeof(header);
|
||||||
initial.lcd_registers = initial.gpu_registers + initial.gpu_registers_size * sizeof(u32);
|
initial.lcd_registers = initial.gpu_registers + initial.gpu_registers_size * sizeof(u32);
|
||||||
initial.pica_registers = initial.lcd_registers + initial.lcd_registers_size * sizeof(u32);;
|
initial.pica_registers = initial.lcd_registers + initial.lcd_registers_size * sizeof(u32);;
|
||||||
initial.vs_program_binary = initial.pica_registers + initial.pica_registers_size * sizeof(u32);
|
initial.default_attributes = initial.pica_registers + initial.pica_registers_size * sizeof(u32);
|
||||||
|
initial.vs_program_binary = initial.default_attributes + initial.default_attributes_size * sizeof(u32);
|
||||||
initial.vs_swizzle_data = initial.vs_program_binary + initial.vs_program_binary_size * sizeof(u32);
|
initial.vs_swizzle_data = initial.vs_program_binary + initial.vs_program_binary_size * sizeof(u32);
|
||||||
initial.vs_float_uniforms = initial.vs_swizzle_data + initial.vs_swizzle_data_size * sizeof(u32);
|
initial.vs_float_uniforms = initial.vs_swizzle_data + initial.vs_swizzle_data_size * sizeof(u32);
|
||||||
initial.gs_program_binary = initial.vs_float_uniforms + initial.vs_float_uniforms_size * sizeof(u32);
|
initial.gs_program_binary = initial.vs_float_uniforms + initial.vs_float_uniforms_size * sizeof(u32);
|
||||||
|
@ -103,9 +107,13 @@ void Recorder::Finish(const std::string& filename) {
|
||||||
throw "Failed to write LCD registers";
|
throw "Failed to write LCD registers";
|
||||||
|
|
||||||
written = file.WriteArray(pica_registers.data(), pica_registers.size());
|
written = file.WriteArray(pica_registers.data(), pica_registers.size());
|
||||||
if (written != pica_registers.size() || file.Tell() != initial.vs_program_binary)
|
if (written != 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());
|
||||||
|
if (written != default_attributes.size() || file.Tell() != initial.vs_program_binary)
|
||||||
|
throw "Failed to write default vertex attributes";
|
||||||
|
|
||||||
written = file.WriteArray(vs_program_binary.data(), vs_program_binary.size());
|
written = file.WriteArray(vs_program_binary.data(), vs_program_binary.size());
|
||||||
if (written != vs_program_binary.size() || file.Tell() != initial.vs_swizzle_data)
|
if (written != 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";
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
|
||||||
#include "tracer.h"
|
#include "citrace.h"
|
||||||
|
|
||||||
namespace CiTrace {
|
namespace CiTrace {
|
||||||
|
|
||||||
|
@ -19,11 +19,13 @@ class Recorder {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Recorder constructor
|
* Recorder constructor
|
||||||
|
* @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(u32* gpu_registers, u32 gpu_registers_size,
|
||||||
u32* lcd_registers, u32 lcd_registers_size,
|
u32* lcd_registers, u32 lcd_registers_size,
|
||||||
u32* pica_registers, u32 pica_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_program_binary, u32 vs_program_binary_size,
|
||||||
u32* vs_swizzle_data, u32 vs_swizzle_data_size,
|
u32* vs_swizzle_data, u32 vs_swizzle_data_size,
|
||||||
u32* vs_float_uniforms, u32 vs_float_uniforms_size,
|
u32* vs_float_uniforms, u32 vs_float_uniforms_size,
|
||||||
|
@ -56,6 +58,7 @@ private:
|
||||||
std::vector<u32> gpu_registers;
|
std::vector<u32> gpu_registers;
|
||||||
std::vector<u32> lcd_registers;
|
std::vector<u32> lcd_registers;
|
||||||
std::vector<u32> pica_registers;
|
std::vector<u32> pica_registers;
|
||||||
|
std::vector<u32> default_attributes;
|
||||||
std::vector<u32> vs_program_binary;
|
std::vector<u32> vs_program_binary;
|
||||||
std::vector<u32> vs_swizzle_data;
|
std::vector<u32> vs_swizzle_data;
|
||||||
std::vector<u32> vs_float_uniforms;
|
std::vector<u32> vs_float_uniforms;
|
||||||
|
|
Loading…
Reference in a new issue