From 6ea003c7b5ec97d0a754197654cdf6e7fccdba24 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sun, 17 Aug 2014 14:06:58 +0200 Subject: Pica: Add debug utility functions for dumping geometry data. --- src/video_core/command_processor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 020a4da3f..2027e58d9 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -8,6 +8,7 @@ #include "primitive_assembly.h" #include "vertex_shader.h" +#include "debug_utils/debug_utils.h" namespace Pica { @@ -68,6 +69,8 @@ static inline void WritePicaReg(u32 id, u32 value) { const u16* index_address_16 = (u16*)index_address_8; bool index_u16 = (bool)index_info.format; + DebugUtils::GeometryDumper geometry_dumper; + for (int index = 0; index < registers.num_vertices; ++index) { int vertex = is_indexed ? (index_u16 ? index_address_16[index] : index_address_8[index]) : index; @@ -95,6 +98,10 @@ static inline void WritePicaReg(u32 id, u32 value) { input.attr[i][comp].ToFloat32()); } } + + // NOTE: For now, we simply assume that the first input attribute corresponds to the position. + geometry_dumper.AddVertex({input.attr[0][0].ToFloat32(), input.attr[0][1].ToFloat32(), input.attr[0][2].ToFloat32()}, registers.triangle_topology); + VertexShader::OutputVertex output = VertexShader::RunShader(input, attribute_config.GetNumTotalAttributes()); if (is_indexed) { @@ -103,6 +110,7 @@ static inline void WritePicaReg(u32 id, u32 value) { PrimitiveAssembly::SubmitVertex(output); } + geometry_dumper.Dump(); break; } -- cgit v1.2.3 From 0465adf206255fc114130cc7fcca1e295bcffca2 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Thu, 14 Aug 2014 23:23:55 +0200 Subject: Pica/CommandProcessor: Implement parameter masking. --- src/video_core/command_processor.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 2027e58d9..f7a412bc1 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -24,9 +24,14 @@ static u32 uniform_write_buffer[4]; static u32 vs_binary_write_offset = 0; static u32 vs_swizzle_write_offset = 0; -static inline void WritePicaReg(u32 id, u32 value) { +static inline void WritePicaReg(u32 id, u32 value, u32 mask) { + + if (id >= registers.NumIds()) + return; + + // TODO: Figure out how register masking acts on e.g. vs_uniform_setup.set_value u32 old_value = registers[id]; - registers[id] = value; + registers[id] = (old_value & ~mask) | (value & mask); switch(id) { // It seems like these trigger vertex rendering @@ -215,14 +220,17 @@ static std::ptrdiff_t ExecuteCommandBlock(const u32* first_command_word) { u32* read_pointer = (u32*)first_command_word; - // TODO: Take parameter mask into consideration! + const u32 write_mask = ((header.parameter_mask & 0x1) ? (0xFFu << 0) : 0u) | + ((header.parameter_mask & 0x2) ? (0xFFu << 8) : 0u) | + ((header.parameter_mask & 0x4) ? (0xFFu << 16) : 0u) | + ((header.parameter_mask & 0x8) ? (0xFFu << 24) : 0u); - WritePicaReg(header.cmd_id, *read_pointer); + WritePicaReg(header.cmd_id, *read_pointer, write_mask); read_pointer += 2; for (int i = 1; i < 1+header.extra_data_length; ++i) { u32 cmd = header.cmd_id + ((header.group_commands) ? i : 0); - WritePicaReg(cmd, *read_pointer); + WritePicaReg(cmd, *read_pointer, write_mask); ++read_pointer; } -- cgit v1.2.3 From 26ade98411c1d76540695f15378ff7f6b5388b1a Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Thu, 14 Aug 2014 19:21:55 +0200 Subject: Pica/citra-qt: Replace command list view and command list debugging code with something more sophisticated. --- src/video_core/command_processor.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index f7a412bc1..76fdb4e4a 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -33,6 +33,8 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { u32 old_value = registers[id]; registers[id] = (old_value & ~mask) | (value & mask); + DebugUtils::OnPicaRegWrite(id, registers[id]); + switch(id) { // It seems like these trigger vertex rendering case PICA_REG_INDEX(trigger_draw): -- cgit v1.2.3 From 34fa0b6d9cd9e4027198ce11562da6c03375cd70 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sun, 17 Aug 2014 12:17:32 +0200 Subject: Pica/DebugUtils: Add convenient tev setup printer. --- src/video_core/command_processor.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 76fdb4e4a..8da030601 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -40,6 +40,8 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { case PICA_REG_INDEX(trigger_draw): case PICA_REG_INDEX(trigger_draw_indexed): { + DebugUtils::DumpTevStageConfig(registers.GetTevStages()); + const auto& attribute_config = registers.vertex_attributes; const u8* const base_address = Memory::GetPointer(attribute_config.GetBaseAddress()); -- cgit v1.2.3 From 2f1c129f6407fe2d5c8c3e57c6717d5668570de5 Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Sun, 17 Aug 2014 17:44:55 +0200 Subject: Pica: Consolidate the primitive assembly code in PrimitiveAssembly and GeometryDumper. --- src/video_core/command_processor.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/video_core/command_processor.cpp') diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 8da030601..9567a9849 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 // Refer to the license.txt file included. +#include "clipper.h" #include "command_processor.h" #include "math.h" #include "pica.h" @@ -79,6 +80,8 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { bool index_u16 = (bool)index_info.format; DebugUtils::GeometryDumper geometry_dumper; + PrimitiveAssembler clipper_primitive_assembler(registers.triangle_topology.Value()); + PrimitiveAssembler dumping_primitive_assembler(registers.triangle_topology.Value()); for (int index = 0; index < registers.num_vertices; ++index) { @@ -108,16 +111,25 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { } } - // NOTE: For now, we simply assume that the first input attribute corresponds to the position. - geometry_dumper.AddVertex({input.attr[0][0].ToFloat32(), input.attr[0][1].ToFloat32(), input.attr[0][2].ToFloat32()}, registers.triangle_topology); - + // NOTE: When dumping geometry, we simply assume that the first input attribute + // corresponds to the position for now. + DebugUtils::GeometryDumper::Vertex dumped_vertex = { + input.attr[0][0].ToFloat32(), input.attr[0][1].ToFloat32(), input.attr[0][2].ToFloat32() + }; + using namespace std::placeholders; + dumping_primitive_assembler.SubmitVertex(dumped_vertex, + std::bind(&DebugUtils::GeometryDumper::AddTriangle, + &geometry_dumper, _1, _2, _3)); + + // Send to vertex shader VertexShader::OutputVertex output = VertexShader::RunShader(input, attribute_config.GetNumTotalAttributes()); if (is_indexed) { // TODO: Add processed vertex to vertex cache! } - PrimitiveAssembly::SubmitVertex(output); + // Send to triangle clipper + clipper_primitive_assembler.SubmitVertex(output, Clipper::ProcessTriangle); } geometry_dumper.Dump(); break; -- cgit v1.2.3