diff options
| author | 2015-07-13 21:39:58 +0200 | |
|---|---|---|
| committer | 2015-07-13 21:39:58 +0200 | |
| commit | 884b681ccaf3cb4057ca0ed0102e446736bb535f (patch) | |
| tree | 9359e9b88f0147879c672638d8c02960d2179d3a /src/video_core | |
| parent | Merge pull request #859 from Apology11/master (diff) | |
| parent | CiTrace: Clean up initialization method. (diff) | |
| download | yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar.gz yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.tar.xz yuzu-884b681ccaf3cb4057ca0ed0102e446736bb535f.zip | |
Merge pull request #702 from neobrain/citrace
Add CiTrace recording support.
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/command_processor.cpp | 60 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 6 |
3 files changed, 68 insertions, 2 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 110caec76..2a1c885a7 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -123,12 +123,55 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 123 | PrimitiveAssembler<VertexShader::OutputVertex> primitive_assembler(regs.triangle_topology.Value()); | 123 | PrimitiveAssembler<VertexShader::OutputVertex> primitive_assembler(regs.triangle_topology.Value()); |
| 124 | PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex> dumping_primitive_assembler(regs.triangle_topology.Value()); | 124 | PrimitiveAssembler<DebugUtils::GeometryDumper::Vertex> dumping_primitive_assembler(regs.triangle_topology.Value()); |
| 125 | 125 | ||
| 126 | if (g_debug_context) { | ||
| 127 | for (int i = 0; i < 3; ++i) { | ||
| 128 | const auto texture = regs.GetTextures()[i]; | ||
| 129 | if (!texture.enabled) | ||
| 130 | continue; | ||
| 131 | |||
| 132 | u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress()); | ||
| 133 | if (g_debug_context && Pica::g_debug_context->recorder) | ||
| 134 | g_debug_context->recorder->MemoryAccessed(texture_data, Pica::Regs::NibblesPerPixel(texture.format) * texture.config.width / 2 * texture.config.height, texture.config.GetPhysicalAddress()); | ||
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 138 | class { | ||
| 139 | /// Combine overlapping and close ranges | ||
| 140 | void SimplifyRanges() { | ||
| 141 | for (auto it = ranges.begin(); it != ranges.end(); ++it) { | ||
| 142 | // NOTE: We add 32 to the range end address to make sure "close" ranges are combined, too | ||
| 143 | auto it2 = std::next(it); | ||
| 144 | while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) { | ||
| 145 | it->second = std::max(it->second, it2->first + it2->second - it->first); | ||
| 146 | it2 = ranges.erase(it2); | ||
| 147 | } | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | public: | ||
| 152 | /// Record a particular memory access in the list | ||
| 153 | void AddAccess(u32 paddr, u32 size) { | ||
| 154 | // Create new range or extend existing one | ||
| 155 | ranges[paddr] = std::max(ranges[paddr], size); | ||
| 156 | |||
| 157 | // Simplify ranges... | ||
| 158 | SimplifyRanges(); | ||
| 159 | } | ||
| 160 | |||
| 161 | /// Map of accessed ranges (mapping start address to range size) | ||
| 162 | std::map<u32, u32> ranges; | ||
| 163 | } memory_accesses; | ||
| 164 | |||
| 126 | for (unsigned int index = 0; index < regs.num_vertices; ++index) | 165 | for (unsigned int index = 0; index < regs.num_vertices; ++index) |
| 127 | { | 166 | { |
| 128 | unsigned int vertex = is_indexed ? (index_u16 ? index_address_16[index] : index_address_8[index]) : index; | 167 | unsigned int vertex = is_indexed ? (index_u16 ? index_address_16[index] : index_address_8[index]) : index; |
| 129 | 168 | ||
| 130 | if (is_indexed) { | 169 | if (is_indexed) { |
| 131 | // TODO: Implement some sort of vertex cache! | 170 | // TODO: Implement some sort of vertex cache! |
| 171 | if (g_debug_context && Pica::g_debug_context->recorder) { | ||
| 172 | int size = index_u16 ? 2 : 1; | ||
| 173 | memory_accesses.AddAccess(base_address + index_info.offset + size * index, size); | ||
| 174 | } | ||
| 132 | } | 175 | } |
| 133 | 176 | ||
| 134 | // Initialize data for the current vertex | 177 | // Initialize data for the current vertex |
| @@ -151,7 +194,14 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 151 | 194 | ||
| 152 | // Load per-vertex data from the loader arrays | 195 | // Load per-vertex data from the loader arrays |
| 153 | for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { | 196 | for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { |
| 154 | const u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]); | 197 | u32 source_addr = vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]; |
| 198 | const u8* srcdata = Memory::GetPhysicalPointer(source_addr); | ||
| 199 | |||
| 200 | if (g_debug_context && Pica::g_debug_context->recorder) { | ||
| 201 | memory_accesses.AddAccess(source_addr, | ||
| 202 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::FLOAT) ? 4 | ||
| 203 | : (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::SHORT) ? 2 : 1); | ||
| 204 | } | ||
| 155 | 205 | ||
| 156 | const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : | 206 | const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : |
| 157 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : | 207 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : |
| @@ -213,14 +263,20 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 213 | } | 263 | } |
| 214 | } | 264 | } |
| 215 | 265 | ||
| 266 | for (auto& range : memory_accesses.ranges) { | ||
| 267 | g_debug_context->recorder->MemoryAccessed(Memory::GetPhysicalPointer(range.first), | ||
| 268 | range.second, range.first); | ||
| 269 | } | ||
| 270 | |||
| 216 | if (Settings::values.use_hw_renderer) { | 271 | if (Settings::values.use_hw_renderer) { |
| 217 | VideoCore::g_renderer->hw_rasterizer->DrawTriangles(); | 272 | VideoCore::g_renderer->hw_rasterizer->DrawTriangles(); |
| 218 | } | 273 | } |
| 219 | 274 | ||
| 220 | geometry_dumper.Dump(); | 275 | geometry_dumper.Dump(); |
| 221 | 276 | ||
| 222 | if (g_debug_context) | 277 | if (g_debug_context) { |
| 223 | g_debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); | 278 | g_debug_context->OnEvent(DebugContext::Event::FinishedPrimitiveBatch, nullptr); |
| 279 | } | ||
| 224 | 280 | ||
| 225 | break; | 281 | break; |
| 226 | } | 282 | } |
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index 7926d64ec..2573292e2 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | 14 | ||
| 15 | #include "common/vector_math.h" | 15 | #include "common/vector_math.h" |
| 16 | 16 | ||
| 17 | #include "core/tracer/recorder.h" | ||
| 18 | |||
| 17 | #include "video_core/pica.h" | 19 | #include "video_core/pica.h" |
| 18 | 20 | ||
| 19 | namespace Pica { | 21 | namespace Pica { |
| @@ -129,6 +131,8 @@ public: | |||
| 129 | Event active_breakpoint; | 131 | Event active_breakpoint; |
| 130 | bool at_breakpoint = false; | 132 | bool at_breakpoint = false; |
| 131 | 133 | ||
| 134 | std::shared_ptr<CiTrace::Recorder> recorder = nullptr; | ||
| 135 | |||
| 132 | private: | 136 | private: |
| 133 | /** | 137 | /** |
| 134 | * Private default constructor to make sure people always construct this through Construct() | 138 | * Private default constructor to make sure people always construct this through Construct() |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 9799f74fa..96e12839a 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -22,6 +22,8 @@ | |||
| 22 | #include "video_core/renderer_opengl/gl_shader_util.h" | 22 | #include "video_core/renderer_opengl/gl_shader_util.h" |
| 23 | #include "video_core/renderer_opengl/gl_shaders.h" | 23 | #include "video_core/renderer_opengl/gl_shaders.h" |
| 24 | 24 | ||
| 25 | #include "video_core/debug_utils/debug_utils.h" | ||
| 26 | |||
| 25 | /** | 27 | /** |
| 26 | * Vertex structure that the drawn screen rectangles are composed of. | 28 | * Vertex structure that the drawn screen rectangles are composed of. |
| 27 | */ | 29 | */ |
| @@ -129,6 +131,10 @@ void RendererOpenGL::SwapBuffers() { | |||
| 129 | hw_rasterizer->Reset(); | 131 | hw_rasterizer->Reset(); |
| 130 | } | 132 | } |
| 131 | } | 133 | } |
| 134 | |||
| 135 | if (Pica::g_debug_context && Pica::g_debug_context->recorder) { | ||
| 136 | Pica::g_debug_context->recorder->FrameFinished(); | ||
| 137 | } | ||
| 132 | } | 138 | } |
| 133 | 139 | ||
| 134 | /** | 140 | /** |