summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony Wasserka <NeoBrainX@gmail.com>2014-08-17 14:06:58 +0200
committerTony Wasserka <NeoBrainX@gmail.com>2014-08-25 22:03:18 +0200
commit6ea003c7b5ec97d0a754197654cdf6e7fccdba24 (patch)
treeb565322792f592bc2708a969cb395bc0679fe018 /src
parentGSP: Update framebuffer information when necessary. (diff)
downloadyuzu-6ea003c7b5ec97d0a754197654cdf6e7fccdba24.tar
yuzu-6ea003c7b5ec97d0a754197654cdf6e7fccdba24.tar.gz
yuzu-6ea003c7b5ec97d0a754197654cdf6e7fccdba24.tar.bz2
yuzu-6ea003c7b5ec97d0a754197654cdf6e7fccdba24.tar.lz
yuzu-6ea003c7b5ec97d0a754197654cdf6e7fccdba24.tar.xz
yuzu-6ea003c7b5ec97d0a754197654cdf6e7fccdba24.tar.zst
yuzu-6ea003c7b5ec97d0a754197654cdf6e7fccdba24.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/CMakeLists.txt2
-rw-r--r--src/video_core/command_processor.cpp8
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp60
-rw-r--r--src/video_core/debug_utils/debug_utils.h40
-rw-r--r--src/video_core/video_core.vcxproj2
-rw-r--r--src/video_core/video_core.vcxproj.filters15
6 files changed, 123 insertions, 4 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt
index 8e7b93acb..71a1b5ecc 100644
--- a/src/video_core/CMakeLists.txt
+++ b/src/video_core/CMakeLists.txt
@@ -5,6 +5,7 @@ set(SRCS clipper.cpp
utils.cpp
vertex_shader.cpp
video_core.cpp
+ debug_utils/debug_utils.cpp
renderer_opengl/renderer_opengl.cpp)
set(HEADERS clipper.h
@@ -17,6 +18,7 @@ set(HEADERS clipper.h
renderer_base.h
vertex_shader.h
video_core.h
+ debug_utils/debug_utils.h
renderer_opengl/renderer_opengl.h)
add_library(video_core STATIC ${SRCS} ${HEADERS})
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;
}
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
new file mode 100644
index 000000000..ac895ec3a
--- /dev/null
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -0,0 +1,60 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include <fstream>
+#include <string>
+
+#include "video_core/pica.h"
+
+#include "debug_utils.h"
+
+namespace Pica {
+
+namespace DebugUtils {
+
+void GeometryDumper::AddVertex(std::array<float,3> pos, TriangleTopology topology) {
+ vertices.push_back({pos[0], pos[1], pos[2]});
+
+ int num_vertices = vertices.size();
+
+ switch (topology) {
+ case TriangleTopology::List:
+ case TriangleTopology::ListIndexed:
+ if (0 == (num_vertices % 3))
+ faces.push_back({ num_vertices-3, num_vertices-2, num_vertices-1 });
+ break;
+
+ default:
+ ERROR_LOG(GPU, "Unknown triangle topology %x", (int)topology);
+ exit(0);
+ break;
+ }
+}
+
+void GeometryDumper::Dump() {
+ // NOTE: Permanently enabling this just trashes hard disks for no reason.
+ // Hence, this is currently disabled.
+ return;
+
+ static int index = 0;
+ std::string filename = std::string("geometry_dump") + std::to_string(++index) + ".obj";
+
+ std::ofstream file(filename);
+
+ for (const auto& vertex : vertices) {
+ file << "v " << vertex.pos[0]
+ << " " << vertex.pos[1]
+ << " " << vertex.pos[2] << std::endl;
+ }
+
+ for (const Face& face : faces) {
+ file << "f " << 1+face.index[0]
+ << " " << 1+face.index[1]
+ << " " << 1+face.index[2] << std::endl;
+ }
+}
+
+} // namespace
+
+} // namespace
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h
new file mode 100644
index 000000000..9b4dce539
--- /dev/null
+++ b/src/video_core/debug_utils/debug_utils.h
@@ -0,0 +1,40 @@
+// Copyright 2014 Citra Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <vector>
+
+#include "video_core/pica.h"
+
+namespace Pica {
+
+namespace DebugUtils {
+
+using TriangleTopology = Regs::TriangleTopology;
+
+// Simple utility class for dumping geometry data to an OBJ file
+class GeometryDumper {
+public:
+ void AddVertex(std::array<float,3> pos, TriangleTopology topology);
+
+ void Dump();
+
+private:
+ struct Vertex {
+ std::array<float,3> pos;
+ };
+
+ struct Face {
+ int index[3];
+ };
+
+ std::vector<Vertex> vertices;
+ std::vector<Face> faces;
+};
+
+} // namespace
+
+} // namespace
diff --git a/src/video_core/video_core.vcxproj b/src/video_core/video_core.vcxproj
index 48d77cdc4..4e129fbe7 100644
--- a/src/video_core/video_core.vcxproj
+++ b/src/video_core/video_core.vcxproj
@@ -19,6 +19,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
+ <ClCompile Include="debug_utils\debug_utils.cpp" />
<ClCompile Include="renderer_opengl\renderer_opengl.cpp" />
<ClCompile Include="clipper.cpp" />
<ClCompile Include="command_processor.cpp" />
@@ -40,6 +41,7 @@
<ClInclude Include="utils.h" />
<ClInclude Include="vertex_shader.h" />
<ClInclude Include="video_core.h" />
+ <ClInclude Include="debug_utils\debug_utils.h" />
<ClInclude Include="renderer_opengl\renderer_opengl.h" />
</ItemGroup>
<ItemGroup>
diff --git a/src/video_core/video_core.vcxproj.filters b/src/video_core/video_core.vcxproj.filters
index 31af4f1df..90541aca0 100644
--- a/src/video_core/video_core.vcxproj.filters
+++ b/src/video_core/video_core.vcxproj.filters
@@ -4,6 +4,9 @@
<Filter Include="renderer_opengl">
<UniqueIdentifier>{e0245557-dbd4-423e-9399-513d5e99f1e4}</UniqueIdentifier>
</Filter>
+ <Filter Include="debug_utils">
+ <UniqueIdentifier>{0ac498e6-bbd8-46e3-9d5f-e816546ab90e}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="renderer_opengl\renderer_opengl.cpp">
@@ -16,11 +19,11 @@
<ClCompile Include="utils.cpp" />
<ClCompile Include="vertex_shader.cpp" />
<ClCompile Include="video_core.cpp" />
+ <ClCompile Include="debug_utils\debug_utils.cpp">
+ <Filter>debug_utils</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
- <ClInclude Include="renderer_opengl\renderer_opengl.h">
- <Filter>renderer_opengl</Filter>
- </ClInclude>
<ClInclude Include="clipper.h" />
<ClInclude Include="command_processor.h" />
<ClInclude Include="gpu_debugger.h" />
@@ -32,8 +35,12 @@
<ClInclude Include="utils.h" />
<ClInclude Include="vertex_shader.h" />
<ClInclude Include="video_core.h" />
+ <ClInclude Include="renderer_opengl\renderer_opengl.h" />
+ <ClInclude Include="debug_utils\debug_utils.h">
+ <Filter>debug_utils</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
-</Project>
+</Project> \ No newline at end of file