Pica/DebugUtils: Include uniform information into shader dumps.
This commit is contained in:
parent
4cb302c8ae
commit
2e3601f415
|
@ -272,10 +272,9 @@ void GraphicsVertexShaderModel::DumpShader() {
|
||||||
auto& setup = Pica::g_state.vs;
|
auto& setup = Pica::g_state.vs;
|
||||||
auto& config = Pica::g_state.regs.vs;
|
auto& config = Pica::g_state.regs.vs;
|
||||||
|
|
||||||
Pica::DebugUtils::DumpShader(setup.program_code.data(), setup.program_code.size(),
|
Pica::DebugUtils::DumpShader(config, setup, Pica::g_state.regs.vs_output_attributes);
|
||||||
setup.swizzle_data.data(), setup.swizzle_data.size(),
|
|
||||||
config.main_offset, Pica::g_state.regs.vs_output_attributes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::DebugContext > debug_context,
|
GraphicsVertexShaderWidget::GraphicsVertexShaderWidget(std::shared_ptr< Pica::DebugContext > debug_context,
|
||||||
QWidget* parent)
|
QWidget* parent)
|
||||||
: BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) {
|
: BreakPointObserverDock(debug_context, "Pica Vertex Shader", parent) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <nihstro/float24.h>
|
||||||
#include <nihstro/shader_binary.h>
|
#include <nihstro/shader_binary.h>
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
@ -110,8 +111,7 @@ void GeometryDumper::Dump() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size,
|
void DumpShader(const Regs::ShaderConfig& config, const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes)
|
||||||
u32 main_offset, const Regs::VSOutputAttributes* output_attributes)
|
|
||||||
{
|
{
|
||||||
struct StuffToWrite {
|
struct StuffToWrite {
|
||||||
u8* pointer;
|
u8* pointer;
|
||||||
|
@ -231,25 +231,66 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
|
||||||
|
|
||||||
// TODO: Reduce the amount of binary code written to relevant portions
|
// TODO: Reduce the amount of binary code written to relevant portions
|
||||||
dvlp.binary_offset = write_offset - dvlp_offset;
|
dvlp.binary_offset = write_offset - dvlp_offset;
|
||||||
dvlp.binary_size_words = binary_size;
|
dvlp.binary_size_words = setup.program_code.size();
|
||||||
QueueForWriting((u8*)binary_data, binary_size * sizeof(u32));
|
QueueForWriting((u8*)setup.program_code.data(), setup.program_code.size() * sizeof(u32));
|
||||||
|
|
||||||
dvlp.swizzle_info_offset = write_offset - dvlp_offset;
|
dvlp.swizzle_info_offset = write_offset - dvlp_offset;
|
||||||
dvlp.swizzle_info_num_entries = swizzle_size;
|
dvlp.swizzle_info_num_entries = setup.swizzle_data.size();
|
||||||
u32 dummy = 0;
|
u32 dummy = 0;
|
||||||
for (unsigned int i = 0; i < swizzle_size; ++i) {
|
for (unsigned int i = 0; i < setup.swizzle_data.size(); ++i) {
|
||||||
QueueForWriting((u8*)&swizzle_data[i], sizeof(swizzle_data[i]));
|
QueueForWriting((u8*)&setup.swizzle_data[i], sizeof(setup.swizzle_data[i]));
|
||||||
QueueForWriting((u8*)&dummy, sizeof(dummy));
|
QueueForWriting((u8*)&dummy, sizeof(dummy));
|
||||||
}
|
}
|
||||||
|
|
||||||
dvle.main_offset_words = main_offset;
|
dvle.main_offset_words = config.main_offset;
|
||||||
dvle.output_register_table_offset = write_offset - dvlb.dvle_offset;
|
dvle.output_register_table_offset = write_offset - dvlb.dvle_offset;
|
||||||
dvle.output_register_table_size = static_cast<u32>(output_info_table.size());
|
dvle.output_register_table_size = static_cast<u32>(output_info_table.size());
|
||||||
QueueForWriting((u8*)output_info_table.data(), static_cast<u32>(output_info_table.size() * sizeof(OutputRegisterInfo)));
|
QueueForWriting((u8*)output_info_table.data(), static_cast<u32>(output_info_table.size() * sizeof(OutputRegisterInfo)));
|
||||||
|
|
||||||
// TODO: Create a label table for "main"
|
// TODO: Create a label table for "main"
|
||||||
|
|
||||||
// TODO: Write uniforms as constants
|
std::vector<nihstro::ConstantInfo> constant_table;
|
||||||
|
for (unsigned i = 0; i < setup.uniforms.b.size(); ++i) {
|
||||||
|
nihstro::ConstantInfo constant;
|
||||||
|
memset(&constant, 0, sizeof(constant));
|
||||||
|
constant.type = nihstro::ConstantInfo::Bool;
|
||||||
|
constant.regid = i;
|
||||||
|
constant.b = setup.uniforms.b[i];
|
||||||
|
constant_table.emplace_back(constant);
|
||||||
|
}
|
||||||
|
for (unsigned i = 0; i < setup.uniforms.i.size(); ++i) {
|
||||||
|
nihstro::ConstantInfo constant;
|
||||||
|
memset(&constant, 0, sizeof(constant));
|
||||||
|
constant.type = nihstro::ConstantInfo::Int;
|
||||||
|
constant.regid = i;
|
||||||
|
constant.i.x = setup.uniforms.i[i].x;
|
||||||
|
constant.i.y = setup.uniforms.i[i].y;
|
||||||
|
constant.i.z = setup.uniforms.i[i].z;
|
||||||
|
constant.i.w = setup.uniforms.i[i].w;
|
||||||
|
constant_table.emplace_back(constant);
|
||||||
|
}
|
||||||
|
for (unsigned i = 0; i < sizeof(setup.uniforms.f) / sizeof(setup.uniforms.f[0]); ++i) {
|
||||||
|
nihstro::ConstantInfo constant;
|
||||||
|
memset(&constant, 0, sizeof(constant));
|
||||||
|
constant.type = nihstro::ConstantInfo::Float;
|
||||||
|
constant.regid = i;
|
||||||
|
constant.f.x = nihstro::to_float24(setup.uniforms.f[i].x.ToFloat32());
|
||||||
|
constant.f.y = nihstro::to_float24(setup.uniforms.f[i].y.ToFloat32());
|
||||||
|
constant.f.z = nihstro::to_float24(setup.uniforms.f[i].z.ToFloat32());
|
||||||
|
constant.f.w = nihstro::to_float24(setup.uniforms.f[i].w.ToFloat32());
|
||||||
|
|
||||||
|
// Store constant if it's different from zero..
|
||||||
|
if (setup.uniforms.f[i].x.ToFloat32() != 0.0 ||
|
||||||
|
setup.uniforms.f[i].y.ToFloat32() != 0.0 ||
|
||||||
|
setup.uniforms.f[i].z.ToFloat32() != 0.0 ||
|
||||||
|
setup.uniforms.f[i].w.ToFloat32() != 0.0)
|
||||||
|
constant_table.emplace_back(constant);
|
||||||
|
}
|
||||||
|
dvle.constant_table_offset = write_offset - dvlb.dvle_offset;
|
||||||
|
dvle.constant_table_size = constant_table.size();
|
||||||
|
for (const auto& constant : constant_table) {
|
||||||
|
QueueForWriting((uint8_t*)&constant, sizeof(constant));
|
||||||
|
}
|
||||||
|
|
||||||
// Write data to file
|
// Write data to file
|
||||||
static int dump_index = 0;
|
static int dump_index = 0;
|
||||||
|
|
|
@ -181,8 +181,7 @@ private:
|
||||||
std::vector<Face> faces;
|
std::vector<Face> faces;
|
||||||
};
|
};
|
||||||
|
|
||||||
void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data, u32 swizzle_size,
|
void DumpShader(const Regs::ShaderConfig& config, const State::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes);
|
||||||
u32 main_offset, const Regs::VSOutputAttributes* output_attributes);
|
|
||||||
|
|
||||||
|
|
||||||
// Utility class to log Pica commands.
|
// Utility class to log Pica commands.
|
||||||
|
|
Loading…
Reference in New Issue