summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/command_processor.cpp19
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp29
-rw-r--r--src/video_core/debug_utils/debug_utils.h21
-rw-r--r--src/video_core/primitive_assembly.cpp2
4 files changed, 0 insertions, 71 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index 028b59348..08ec2907a 100644
--- a/src/video_core/command_processor.cpp
+++ b/src/video_core/command_processor.cpp
@@ -249,10 +249,6 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
249 const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8); 249 const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8);
250 bool index_u16 = index_info.format != 0; 250 bool index_u16 = index_info.format != 0;
251 251
252#if PICA_DUMP_GEOMETRY
253 DebugUtils::GeometryDumper geometry_dumper;
254 PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex> dumping_primitive_assembler(regs.triangle_topology.Value());
255#endif
256 PrimitiveAssembler<Shader::OutputVertex>& primitive_assembler = g_state.primitive_assembler; 252 PrimitiveAssembler<Shader::OutputVertex>& primitive_assembler = g_state.primitive_assembler;
257 253
258 if (g_debug_context) { 254 if (g_debug_context) {
@@ -388,17 +384,6 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
388 if (g_debug_context) 384 if (g_debug_context)
389 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input); 385 g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input);
390 386
391#if PICA_DUMP_GEOMETRY
392 // NOTE: When dumping geometry, we simply assume that the first input attribute
393 // corresponds to the position for now.
394 DebugUtils::GeometryDumper::Vertex dumped_vertex = {
395 input.attr[0][0].ToFloat32(), input.attr[0][1].ToFloat32(), input.attr[0][2].ToFloat32()
396 };
397 using namespace std::placeholders;
398 dumping_primitive_assembler.SubmitVertex(dumped_vertex,
399 std::bind(&DebugUtils::GeometryDumper::AddTriangle,
400 &geometry_dumper, _1, _2, _3));
401#endif
402 // Send to vertex shader 387 // Send to vertex shader
403 output = Shader::Run(shader_unit, input, attribute_config.GetNumTotalAttributes()); 388 output = Shader::Run(shader_unit, input, attribute_config.GetNumTotalAttributes());
404 389
@@ -424,10 +409,6 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
424 range.second, range.first); 409 range.second, range.first);
425 } 410 }
426 411
427#if PICA_DUMP_GEOMETRY
428 geometry_dumper.Dump();
429#endif
430
431 break; 412 break;
432 } 413 }
433 414
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index bac6d69c7..693f93597 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -85,35 +85,6 @@ std::shared_ptr<DebugContext> g_debug_context; // TODO: Get rid of this global
85 85
86namespace DebugUtils { 86namespace DebugUtils {
87 87
88void GeometryDumper::AddTriangle(Vertex& v0, Vertex& v1, Vertex& v2) {
89 vertices.push_back(v0);
90 vertices.push_back(v1);
91 vertices.push_back(v2);
92
93 int num_vertices = (int)vertices.size();
94 faces.push_back({{ num_vertices-3, num_vertices-2, num_vertices-1 }});
95}
96
97void GeometryDumper::Dump() {
98 static int index = 0;
99 std::string filename = std::string("geometry_dump") + std::to_string(++index) + ".obj";
100
101 std::ofstream file(filename);
102
103 for (const auto& vertex : vertices) {
104 file << "v " << vertex.pos[0]
105 << " " << vertex.pos[1]
106 << " " << vertex.pos[2] << std::endl;
107 }
108
109 for (const Face& face : faces) {
110 file << "f " << 1+face.index[0]
111 << " " << 1+face.index[1]
112 << " " << 1+face.index[2] << std::endl;
113 }
114}
115
116
117void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes) 88void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes)
118{ 89{
119 struct StuffToWrite { 90 struct StuffToWrite {
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h
index 795160a32..7df941619 100644
--- a/src/video_core/debug_utils/debug_utils.h
+++ b/src/video_core/debug_utils/debug_utils.h
@@ -158,30 +158,9 @@ extern std::shared_ptr<DebugContext> g_debug_context; // TODO: Get rid of this g
158 158
159namespace DebugUtils { 159namespace DebugUtils {
160 160
161#define PICA_DUMP_GEOMETRY 0
162#define PICA_DUMP_TEXTURES 0 161#define PICA_DUMP_TEXTURES 0
163#define PICA_LOG_TEV 0 162#define PICA_LOG_TEV 0
164 163
165// Simple utility class for dumping geometry data to an OBJ file
166class GeometryDumper {
167public:
168 struct Vertex {
169 std::array<float,3> pos;
170 };
171
172 void AddTriangle(Vertex& v0, Vertex& v1, Vertex& v2);
173
174 void Dump();
175
176private:
177 struct Face {
178 int index[3];
179 };
180
181 std::vector<Vertex> vertices;
182 std::vector<Face> faces;
183};
184
185void DumpShader(const std::string& filename, const Regs::ShaderConfig& config, 164void DumpShader(const std::string& filename, const Regs::ShaderConfig& config,
186 const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes); 165 const Shader::ShaderSetup& setup, const Regs::VSOutputAttributes* output_attributes);
187 166
diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp
index 0061690f1..ff3e2b862 100644
--- a/src/video_core/primitive_assembly.cpp
+++ b/src/video_core/primitive_assembly.cpp
@@ -68,7 +68,5 @@ void PrimitiveAssembler<VertexType>::Reconfigure(Regs::TriangleTopology topology
68// explicitly instantiate use cases 68// explicitly instantiate use cases
69template 69template
70struct PrimitiveAssembler<Shader::OutputVertex>; 70struct PrimitiveAssembler<Shader::OutputVertex>;
71template
72struct PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex>;
73 71
74} // namespace 72} // namespace