diff options
| author | 2019-06-19 22:28:26 -0400 | |
|---|---|---|
| committer | 2019-06-19 22:28:26 -0400 | |
| commit | c28694d907320ab2d611518274d3befb8d2c8347 (patch) | |
| tree | 3850948af5c4f98f5c146348672a2d919ac7e820 /src | |
| parent | Merge pull request #2590 from lioncash/event (diff) | |
| parent | core: Remove unused CiTrace source files (diff) | |
| download | yuzu-c28694d907320ab2d611518274d3befb8d2c8347.tar.gz yuzu-c28694d907320ab2d611518274d3befb8d2c8347.tar.xz yuzu-c28694d907320ab2d611518274d3befb8d2c8347.zip | |
Merge pull request #2591 from lioncash/record
core: Remove unused CiTrace source files
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/core/tracer/citrace.h | 100 | ||||
| -rw-r--r-- | src/core/tracer/recorder.cpp | 208 | ||||
| -rw-r--r-- | src/core/tracer/recorder.h | 87 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 1 |
5 files changed, 0 insertions, 399 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a2e2e976e..4204ace2b 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -463,9 +463,6 @@ add_library(core STATIC | |||
| 463 | settings.h | 463 | settings.h |
| 464 | telemetry_session.cpp | 464 | telemetry_session.cpp |
| 465 | telemetry_session.h | 465 | telemetry_session.h |
| 466 | tracer/citrace.h | ||
| 467 | tracer/recorder.cpp | ||
| 468 | tracer/recorder.h | ||
| 469 | ) | 466 | ) |
| 470 | 467 | ||
| 471 | create_target_directory_groups(core) | 468 | create_target_directory_groups(core) |
diff --git a/src/core/tracer/citrace.h b/src/core/tracer/citrace.h deleted file mode 100644 index 21fdc127a..000000000 --- a/src/core/tracer/citrace.h +++ /dev/null | |||
| @@ -1,100 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | namespace CiTrace { | ||
| 10 | |||
| 11 | // NOTE: Things are stored in little-endian | ||
| 12 | |||
| 13 | #pragma pack(1) | ||
| 14 | |||
| 15 | struct CTHeader { | ||
| 16 | static const char* ExpectedMagicWord() { | ||
| 17 | return "CiTr"; | ||
| 18 | } | ||
| 19 | |||
| 20 | static u32 ExpectedVersion() { | ||
| 21 | return 1; | ||
| 22 | } | ||
| 23 | |||
| 24 | char magic[4]; | ||
| 25 | u32 version; | ||
| 26 | u32 header_size; | ||
| 27 | |||
| 28 | struct { | ||
| 29 | // NOTE: Register range sizes are technically hardware-constants, but the actual limits | ||
| 30 | // aren't known. Hence we store the presumed limits along the offsets. | ||
| 31 | // Sizes are given in u32 units. | ||
| 32 | u32 gpu_registers; | ||
| 33 | u32 gpu_registers_size; | ||
| 34 | u32 lcd_registers; | ||
| 35 | u32 lcd_registers_size; | ||
| 36 | u32 pica_registers; | ||
| 37 | u32 pica_registers_size; | ||
| 38 | u32 default_attributes; | ||
| 39 | u32 default_attributes_size; | ||
| 40 | u32 vs_program_binary; | ||
| 41 | u32 vs_program_binary_size; | ||
| 42 | u32 vs_swizzle_data; | ||
| 43 | u32 vs_swizzle_data_size; | ||
| 44 | u32 vs_float_uniforms; | ||
| 45 | u32 vs_float_uniforms_size; | ||
| 46 | u32 gs_program_binary; | ||
| 47 | u32 gs_program_binary_size; | ||
| 48 | u32 gs_swizzle_data; | ||
| 49 | u32 gs_swizzle_data_size; | ||
| 50 | u32 gs_float_uniforms; | ||
| 51 | u32 gs_float_uniforms_size; | ||
| 52 | |||
| 53 | // Other things we might want to store here: | ||
| 54 | // - Initial framebuffer data, maybe even a full copy of FCRAM/VRAM | ||
| 55 | // - Lookup tables for fragment lighting | ||
| 56 | // - Lookup tables for procedural textures | ||
| 57 | } initial_state_offsets; | ||
| 58 | |||
| 59 | u32 stream_offset; | ||
| 60 | u32 stream_size; | ||
| 61 | }; | ||
| 62 | |||
| 63 | enum CTStreamElementType : u32 { | ||
| 64 | FrameMarker = 0xE1, | ||
| 65 | MemoryLoad = 0xE2, | ||
| 66 | RegisterWrite = 0xE3, | ||
| 67 | }; | ||
| 68 | |||
| 69 | struct CTMemoryLoad { | ||
| 70 | u32 file_offset; | ||
| 71 | u32 size; | ||
| 72 | u32 physical_address; | ||
| 73 | u32 pad; | ||
| 74 | }; | ||
| 75 | |||
| 76 | struct CTRegisterWrite { | ||
| 77 | u32 physical_address; | ||
| 78 | |||
| 79 | enum : u32 { | ||
| 80 | SIZE_8 = 0xD1, | ||
| 81 | SIZE_16 = 0xD2, | ||
| 82 | SIZE_32 = 0xD3, | ||
| 83 | SIZE_64 = 0xD4, | ||
| 84 | } size; | ||
| 85 | |||
| 86 | // TODO: Make it clearer which bits of this member are used for sizes other than 32 bits | ||
| 87 | u64 value; | ||
| 88 | }; | ||
| 89 | |||
| 90 | struct CTStreamElement { | ||
| 91 | CTStreamElementType type; | ||
| 92 | |||
| 93 | union { | ||
| 94 | CTMemoryLoad memory_load; | ||
| 95 | CTRegisterWrite register_write; | ||
| 96 | }; | ||
| 97 | }; | ||
| 98 | |||
| 99 | #pragma pack() | ||
| 100 | } // namespace CiTrace | ||
diff --git a/src/core/tracer/recorder.cpp b/src/core/tracer/recorder.cpp deleted file mode 100644 index 73cacb47f..000000000 --- a/src/core/tracer/recorder.cpp +++ /dev/null | |||
| @@ -1,208 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <cstring> | ||
| 6 | #include "common/assert.h" | ||
| 7 | #include "common/file_util.h" | ||
| 8 | #include "common/logging/log.h" | ||
| 9 | #include "core/tracer/recorder.h" | ||
| 10 | |||
| 11 | namespace CiTrace { | ||
| 12 | |||
| 13 | Recorder::Recorder(const InitialState& initial_state) : initial_state(initial_state) {} | ||
| 14 | |||
| 15 | void Recorder::Finish(const std::string& filename) { | ||
| 16 | // Setup CiTrace header | ||
| 17 | CTHeader header; | ||
| 18 | std::memcpy(header.magic, CTHeader::ExpectedMagicWord(), 4); | ||
| 19 | header.version = CTHeader::ExpectedVersion(); | ||
| 20 | header.header_size = sizeof(CTHeader); | ||
| 21 | |||
| 22 | // Calculate file offsets | ||
| 23 | auto& initial = header.initial_state_offsets; | ||
| 24 | |||
| 25 | initial.gpu_registers_size = static_cast<u32>(initial_state.gpu_registers.size()); | ||
| 26 | initial.lcd_registers_size = static_cast<u32>(initial_state.lcd_registers.size()); | ||
| 27 | initial.pica_registers_size = static_cast<u32>(initial_state.pica_registers.size()); | ||
| 28 | initial.default_attributes_size = static_cast<u32>(initial_state.default_attributes.size()); | ||
| 29 | initial.vs_program_binary_size = static_cast<u32>(initial_state.vs_program_binary.size()); | ||
| 30 | initial.vs_swizzle_data_size = static_cast<u32>(initial_state.vs_swizzle_data.size()); | ||
| 31 | initial.vs_float_uniforms_size = static_cast<u32>(initial_state.vs_float_uniforms.size()); | ||
| 32 | initial.gs_program_binary_size = static_cast<u32>(initial_state.gs_program_binary.size()); | ||
| 33 | initial.gs_swizzle_data_size = static_cast<u32>(initial_state.gs_swizzle_data.size()); | ||
| 34 | initial.gs_float_uniforms_size = static_cast<u32>(initial_state.gs_float_uniforms.size()); | ||
| 35 | header.stream_size = static_cast<u32>(stream.size()); | ||
| 36 | |||
| 37 | initial.gpu_registers = sizeof(header); | ||
| 38 | initial.lcd_registers = initial.gpu_registers + initial.gpu_registers_size * sizeof(u32); | ||
| 39 | initial.pica_registers = initial.lcd_registers + initial.lcd_registers_size * sizeof(u32); | ||
| 40 | ; | ||
| 41 | initial.default_attributes = initial.pica_registers + initial.pica_registers_size * sizeof(u32); | ||
| 42 | initial.vs_program_binary = | ||
| 43 | initial.default_attributes + initial.default_attributes_size * sizeof(u32); | ||
| 44 | initial.vs_swizzle_data = | ||
| 45 | initial.vs_program_binary + initial.vs_program_binary_size * sizeof(u32); | ||
| 46 | initial.vs_float_uniforms = | ||
| 47 | initial.vs_swizzle_data + initial.vs_swizzle_data_size * sizeof(u32); | ||
| 48 | initial.gs_program_binary = | ||
| 49 | initial.vs_float_uniforms + initial.vs_float_uniforms_size * sizeof(u32); | ||
| 50 | initial.gs_swizzle_data = | ||
| 51 | initial.gs_program_binary + initial.gs_program_binary_size * sizeof(u32); | ||
| 52 | initial.gs_float_uniforms = | ||
| 53 | initial.gs_swizzle_data + initial.gs_swizzle_data_size * sizeof(u32); | ||
| 54 | header.stream_offset = initial.gs_float_uniforms + initial.gs_float_uniforms_size * sizeof(u32); | ||
| 55 | |||
| 56 | // Iterate through stream elements, update relevant stream element data | ||
| 57 | for (auto& stream_element : stream) { | ||
| 58 | switch (stream_element.data.type) { | ||
| 59 | case MemoryLoad: { | ||
| 60 | auto& file_offset = memory_regions[stream_element.hash]; | ||
| 61 | if (!stream_element.uses_existing_data) { | ||
| 62 | file_offset = header.stream_offset; | ||
| 63 | } | ||
| 64 | stream_element.data.memory_load.file_offset = file_offset; | ||
| 65 | break; | ||
| 66 | } | ||
| 67 | |||
| 68 | default: | ||
| 69 | // Other commands don't use any extra data | ||
| 70 | DEBUG_ASSERT(stream_element.extra_data.size() == 0); | ||
| 71 | break; | ||
| 72 | } | ||
| 73 | header.stream_offset += static_cast<u32>(stream_element.extra_data.size()); | ||
| 74 | } | ||
| 75 | |||
| 76 | try { | ||
| 77 | // Open file and write header | ||
| 78 | FileUtil::IOFile file(filename, "wb"); | ||
| 79 | std::size_t written = file.WriteObject(header); | ||
| 80 | if (written != 1 || file.Tell() != initial.gpu_registers) | ||
| 81 | throw "Failed to write header"; | ||
| 82 | |||
| 83 | // Write initial state | ||
| 84 | written = | ||
| 85 | file.WriteArray(initial_state.gpu_registers.data(), initial_state.gpu_registers.size()); | ||
| 86 | if (written != initial_state.gpu_registers.size() || file.Tell() != initial.lcd_registers) | ||
| 87 | throw "Failed to write GPU registers"; | ||
| 88 | |||
| 89 | written = | ||
| 90 | file.WriteArray(initial_state.lcd_registers.data(), initial_state.lcd_registers.size()); | ||
| 91 | if (written != initial_state.lcd_registers.size() || file.Tell() != initial.pica_registers) | ||
| 92 | throw "Failed to write LCD registers"; | ||
| 93 | |||
| 94 | written = file.WriteArray(initial_state.pica_registers.data(), | ||
| 95 | initial_state.pica_registers.size()); | ||
| 96 | if (written != initial_state.pica_registers.size() || | ||
| 97 | file.Tell() != initial.default_attributes) | ||
| 98 | throw "Failed to write Pica registers"; | ||
| 99 | |||
| 100 | written = file.WriteArray(initial_state.default_attributes.data(), | ||
| 101 | initial_state.default_attributes.size()); | ||
| 102 | if (written != initial_state.default_attributes.size() || | ||
| 103 | file.Tell() != initial.vs_program_binary) | ||
| 104 | throw "Failed to write default vertex attributes"; | ||
| 105 | |||
| 106 | written = file.WriteArray(initial_state.vs_program_binary.data(), | ||
| 107 | initial_state.vs_program_binary.size()); | ||
| 108 | if (written != initial_state.vs_program_binary.size() || | ||
| 109 | file.Tell() != initial.vs_swizzle_data) | ||
| 110 | throw "Failed to write vertex shader program binary"; | ||
| 111 | |||
| 112 | written = file.WriteArray(initial_state.vs_swizzle_data.data(), | ||
| 113 | initial_state.vs_swizzle_data.size()); | ||
| 114 | if (written != initial_state.vs_swizzle_data.size() || | ||
| 115 | file.Tell() != initial.vs_float_uniforms) | ||
| 116 | throw "Failed to write vertex shader swizzle data"; | ||
| 117 | |||
| 118 | written = file.WriteArray(initial_state.vs_float_uniforms.data(), | ||
| 119 | initial_state.vs_float_uniforms.size()); | ||
| 120 | if (written != initial_state.vs_float_uniforms.size() || | ||
| 121 | file.Tell() != initial.gs_program_binary) | ||
| 122 | throw "Failed to write vertex shader float uniforms"; | ||
| 123 | |||
| 124 | written = file.WriteArray(initial_state.gs_program_binary.data(), | ||
| 125 | initial_state.gs_program_binary.size()); | ||
| 126 | if (written != initial_state.gs_program_binary.size() || | ||
| 127 | file.Tell() != initial.gs_swizzle_data) | ||
| 128 | throw "Failed to write geomtry shader program binary"; | ||
| 129 | |||
| 130 | written = file.WriteArray(initial_state.gs_swizzle_data.data(), | ||
| 131 | initial_state.gs_swizzle_data.size()); | ||
| 132 | if (written != initial_state.gs_swizzle_data.size() || | ||
| 133 | file.Tell() != initial.gs_float_uniforms) | ||
| 134 | throw "Failed to write geometry shader swizzle data"; | ||
| 135 | |||
| 136 | written = file.WriteArray(initial_state.gs_float_uniforms.data(), | ||
| 137 | initial_state.gs_float_uniforms.size()); | ||
| 138 | if (written != initial_state.gs_float_uniforms.size() || | ||
| 139 | file.Tell() != initial.gs_float_uniforms + sizeof(u32) * initial.gs_float_uniforms_size) | ||
| 140 | throw "Failed to write geometry shader float uniforms"; | ||
| 141 | |||
| 142 | // Iterate through stream elements, write "extra data" | ||
| 143 | for (const auto& stream_element : stream) { | ||
| 144 | if (stream_element.extra_data.size() == 0) | ||
| 145 | continue; | ||
| 146 | |||
| 147 | written = | ||
| 148 | file.WriteBytes(stream_element.extra_data.data(), stream_element.extra_data.size()); | ||
| 149 | if (written != stream_element.extra_data.size()) | ||
| 150 | throw "Failed to write extra data"; | ||
| 151 | } | ||
| 152 | |||
| 153 | if (file.Tell() != header.stream_offset) | ||
| 154 | throw "Unexpected end of extra data"; | ||
| 155 | |||
| 156 | // Write actual stream elements | ||
| 157 | for (const auto& stream_element : stream) { | ||
| 158 | if (1 != file.WriteObject(stream_element.data)) | ||
| 159 | throw "Failed to write stream element"; | ||
| 160 | } | ||
| 161 | } catch (const char* str) { | ||
| 162 | LOG_ERROR(HW_GPU, "Writing CiTrace file failed: {}", str); | ||
| 163 | } | ||
| 164 | } | ||
| 165 | |||
| 166 | void Recorder::FrameFinished() { | ||
| 167 | stream.push_back({{FrameMarker}}); | ||
| 168 | } | ||
| 169 | |||
| 170 | void Recorder::MemoryAccessed(const u8* data, u32 size, u32 physical_address) { | ||
| 171 | StreamElement element = {{MemoryLoad}}; | ||
| 172 | element.data.memory_load.size = size; | ||
| 173 | element.data.memory_load.physical_address = physical_address; | ||
| 174 | |||
| 175 | // Compute hash over given memory region to check if the contents are already stored internally | ||
| 176 | boost::crc_32_type result; | ||
| 177 | result.process_bytes(data, size); | ||
| 178 | element.hash = result.checksum(); | ||
| 179 | |||
| 180 | element.uses_existing_data = (memory_regions.find(element.hash) != memory_regions.end()); | ||
| 181 | if (!element.uses_existing_data) { | ||
| 182 | element.extra_data.resize(size); | ||
| 183 | memcpy(element.extra_data.data(), data, size); | ||
| 184 | memory_regions.insert({element.hash, 0}); // file offset will be initialized in Finish() | ||
| 185 | } | ||
| 186 | |||
| 187 | stream.push_back(element); | ||
| 188 | } | ||
| 189 | |||
| 190 | template <typename T> | ||
| 191 | void Recorder::RegisterWritten(u32 physical_address, T value) { | ||
| 192 | StreamElement element = {{RegisterWrite}}; | ||
| 193 | element.data.register_write.size = | ||
| 194 | (sizeof(T) == 1) ? CTRegisterWrite::SIZE_8 | ||
| 195 | : (sizeof(T) == 2) ? CTRegisterWrite::SIZE_16 | ||
| 196 | : (sizeof(T) == 4) ? CTRegisterWrite::SIZE_32 | ||
| 197 | : CTRegisterWrite::SIZE_64; | ||
| 198 | element.data.register_write.physical_address = physical_address; | ||
| 199 | element.data.register_write.value = value; | ||
| 200 | |||
| 201 | stream.push_back(element); | ||
| 202 | } | ||
| 203 | |||
| 204 | template void Recorder::RegisterWritten(u32, u8); | ||
| 205 | template void Recorder::RegisterWritten(u32, u16); | ||
| 206 | template void Recorder::RegisterWritten(u32, u32); | ||
| 207 | template void Recorder::RegisterWritten(u32, u64); | ||
| 208 | } // namespace CiTrace | ||
diff --git a/src/core/tracer/recorder.h b/src/core/tracer/recorder.h deleted file mode 100644 index e1cefd5fe..000000000 --- a/src/core/tracer/recorder.h +++ /dev/null | |||
| @@ -1,87 +0,0 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <string> | ||
| 8 | #include <unordered_map> | ||
| 9 | #include <vector> | ||
| 10 | #include <boost/crc.hpp> | ||
| 11 | #include "common/common_types.h" | ||
| 12 | #include "core/tracer/citrace.h" | ||
| 13 | |||
| 14 | namespace CiTrace { | ||
| 15 | |||
| 16 | class Recorder { | ||
| 17 | public: | ||
| 18 | struct InitialState { | ||
| 19 | std::vector<u32> gpu_registers; | ||
| 20 | std::vector<u32> lcd_registers; | ||
| 21 | std::vector<u32> pica_registers; | ||
| 22 | std::vector<u32> default_attributes; | ||
| 23 | std::vector<u32> vs_program_binary; | ||
| 24 | std::vector<u32> vs_swizzle_data; | ||
| 25 | std::vector<u32> vs_float_uniforms; | ||
| 26 | std::vector<u32> gs_program_binary; | ||
| 27 | std::vector<u32> gs_swizzle_data; | ||
| 28 | std::vector<u32> gs_float_uniforms; | ||
| 29 | }; | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Recorder constructor | ||
| 33 | * @param initial_state Initial recorder state | ||
| 34 | */ | ||
| 35 | explicit Recorder(const InitialState& initial_state); | ||
| 36 | |||
| 37 | /// Finish recording of this Citrace and save it using the given filename. | ||
| 38 | void Finish(const std::string& filename); | ||
| 39 | |||
| 40 | /// Mark end of a frame | ||
| 41 | void FrameFinished(); | ||
| 42 | |||
| 43 | /** | ||
| 44 | * Store a copy of the given memory range in the recording. | ||
| 45 | * @note Use this whenever the GPU is about to access a particular memory region. | ||
| 46 | * @note The implementation will make sure to minimize redundant memory updates. | ||
| 47 | */ | ||
| 48 | void MemoryAccessed(const u8* data, u32 size, u32 physical_address); | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Record a register write. | ||
| 52 | * @note Use this whenever a GPU-related MMIO register has been written to. | ||
| 53 | */ | ||
| 54 | template <typename T> | ||
| 55 | void RegisterWritten(u32 physical_address, T value); | ||
| 56 | |||
| 57 | private: | ||
| 58 | // Initial state of recording start | ||
| 59 | InitialState initial_state; | ||
| 60 | |||
| 61 | // Command stream | ||
| 62 | struct StreamElement { | ||
| 63 | CTStreamElement data; | ||
| 64 | |||
| 65 | /** | ||
| 66 | * Extra data to store along "core" data. | ||
| 67 | * This is e.g. used for data used in MemoryUpdates. | ||
| 68 | */ | ||
| 69 | std::vector<u8> extra_data; | ||
| 70 | |||
| 71 | /// Optional CRC hash (e.g. for hashing memory regions) | ||
| 72 | boost::crc_32_type::value_type hash; | ||
| 73 | |||
| 74 | /// If true, refer to data already written to the output file instead of extra_data | ||
| 75 | bool uses_existing_data; | ||
| 76 | }; | ||
| 77 | |||
| 78 | std::vector<StreamElement> stream; | ||
| 79 | |||
| 80 | /** | ||
| 81 | * Internal cache which maps hashes of memory contents to file offsets at which those memory | ||
| 82 | * contents are stored. | ||
| 83 | */ | ||
| 84 | std::unordered_map<boost::crc_32_type::value_type /*hash*/, u32 /*file_offset*/> memory_regions; | ||
| 85 | }; | ||
| 86 | |||
| 87 | } // namespace CiTrace | ||
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 3451d321d..aafd6f31b 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -18,7 +18,6 @@ | |||
| 18 | #include "core/perf_stats.h" | 18 | #include "core/perf_stats.h" |
| 19 | #include "core/settings.h" | 19 | #include "core/settings.h" |
| 20 | #include "core/telemetry_session.h" | 20 | #include "core/telemetry_session.h" |
| 21 | #include "core/tracer/recorder.h" | ||
| 22 | #include "video_core/morton.h" | 21 | #include "video_core/morton.h" |
| 23 | #include "video_core/renderer_opengl/gl_rasterizer.h" | 22 | #include "video_core/renderer_opengl/gl_rasterizer.h" |
| 24 | #include "video_core/renderer_opengl/renderer_opengl.h" | 23 | #include "video_core/renderer_opengl/renderer_opengl.h" |