Move and rename the MemoryAccesses class to MemoryAccessTracker.
This commit is contained in:
parent
a442ee07f4
commit
a86d7cacc1
4 changed files with 35 additions and 32 deletions
|
@ -224,7 +224,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MemoryAccesses memory_accesses;
|
DebugUtils::MemoryAccessTracker memory_accesses;
|
||||||
|
|
||||||
// Simple circular-replacement vertex cache
|
// Simple circular-replacement vertex cache
|
||||||
// The size has been tuned for optimal balance between hit-rate and the cost of lookup
|
// The size has been tuned for optimal balance between hit-rate and the cost of lookup
|
||||||
|
|
|
@ -206,6 +206,36 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data);
|
||||||
|
|
||||||
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages);
|
void DumpTevStageConfig(const std::array<Pica::Regs::TevStageConfig,6>& stages);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in the vertex loader to merge access records. TODO: Investigate if actually useful.
|
||||||
|
*/
|
||||||
|
class MemoryAccessTracker {
|
||||||
|
/// Combine overlapping and close ranges
|
||||||
|
void SimplifyRanges() {
|
||||||
|
for (auto it = ranges.begin(); it != ranges.end(); ++it) {
|
||||||
|
// NOTE: We add 32 to the range end address to make sure "close" ranges are combined, too
|
||||||
|
auto it2 = std::next(it);
|
||||||
|
while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) {
|
||||||
|
it->second = std::max(it->second, it2->first + it2->second - it->first);
|
||||||
|
it2 = ranges.erase(it2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Record a particular memory access in the list
|
||||||
|
void AddAccess(u32 paddr, u32 size) {
|
||||||
|
// Create new range or extend existing one
|
||||||
|
ranges[paddr] = std::max(ranges[paddr], size);
|
||||||
|
|
||||||
|
// Simplify ranges...
|
||||||
|
SimplifyRanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Map of accessed ranges (mapping start address to range size)
|
||||||
|
std::map<u32, u32> ranges;
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -12,8 +12,7 @@
|
||||||
|
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
|
|
||||||
#include "debug_utils/debug_utils.h"
|
#include "video_core/debug_utils/debug_utils.h"
|
||||||
|
|
||||||
#include "video_core/pica.h"
|
#include "video_core/pica.h"
|
||||||
#include "video_core/pica_state.h"
|
#include "video_core/pica_state.h"
|
||||||
#include "video_core/pica_types.h"
|
#include "video_core/pica_types.h"
|
||||||
|
@ -63,7 +62,7 @@ void VertexLoader::Setup(const Pica::Regs& regs) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses) {
|
void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses) {
|
||||||
for (int i = 0; i < num_total_attributes; ++i) {
|
for (int i = 0; i < num_total_attributes; ++i) {
|
||||||
if (vertex_attribute_elements[i] != 0) {
|
if (vertex_attribute_elements[i] != 0) {
|
||||||
// Load per-vertex data from the loader arrays
|
// Load per-vertex data from the loader arrays
|
||||||
|
|
|
@ -5,40 +5,14 @@
|
||||||
|
|
||||||
#include "video_core/pica.h"
|
#include "video_core/pica.h"
|
||||||
#include "video_core/shader/shader.h"
|
#include "video_core/shader/shader.h"
|
||||||
|
#include "video_core/debug_utils/debug_utils.h"
|
||||||
|
|
||||||
namespace Pica {
|
namespace Pica {
|
||||||
|
|
||||||
class MemoryAccesses {
|
|
||||||
/// Combine overlapping and close ranges
|
|
||||||
void SimplifyRanges() {
|
|
||||||
for (auto it = ranges.begin(); it != ranges.end(); ++it) {
|
|
||||||
// NOTE: We add 32 to the range end address to make sure "close" ranges are combined, too
|
|
||||||
auto it2 = std::next(it);
|
|
||||||
while (it2 != ranges.end() && it->first + it->second + 32 >= it2->first) {
|
|
||||||
it->second = std::max(it->second, it2->first + it2->second - it->first);
|
|
||||||
it2 = ranges.erase(it2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
/// Record a particular memory access in the list
|
|
||||||
void AddAccess(u32 paddr, u32 size) {
|
|
||||||
// Create new range or extend existing one
|
|
||||||
ranges[paddr] = std::max(ranges[paddr], size);
|
|
||||||
|
|
||||||
// Simplify ranges...
|
|
||||||
SimplifyRanges();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Map of accessed ranges (mapping start address to range size)
|
|
||||||
std::map<u32, u32> ranges;
|
|
||||||
};
|
|
||||||
|
|
||||||
class VertexLoader {
|
class VertexLoader {
|
||||||
public:
|
public:
|
||||||
void Setup(const Pica::Regs& regs);
|
void Setup(const Pica::Regs& regs);
|
||||||
void LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses);
|
void LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses);
|
||||||
|
|
||||||
int GetNumTotalAttributes() const { return num_total_attributes; }
|
int GetNumTotalAttributes() const { return num_total_attributes; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue