From 47ff00881703eeab03d32e60289ac34b7f4a7994 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 28 Apr 2016 19:01:47 +0200 Subject: Refactor: Extract VertexLoader from command_processor.cpp. Preparation for a similar concept to Dolphin or PPSSPP. These can be JIT-ed and cached. --- src/video_core/vertex_loader.h | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/video_core/vertex_loader.h (limited to 'src/video_core/vertex_loader.h') diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h new file mode 100644 index 000000000..4ff62d97b --- /dev/null +++ b/src/video_core/vertex_loader.h @@ -0,0 +1,53 @@ +#pragma once + +#include "video_core/pica.h" +#include "video_core/shader/shader.h" + +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 ranges; +}; + +class VertexLoader { +public: + void Setup(const Pica::Regs ®s); + void LoadVertex(int index, int vertex, Shader::InputVertex &input, MemoryAccesses &memory_accesses); + + u32 GetPhysicalBaseAddress() const { return base_address; } + int GetNumTotalAttributes() const { return num_total_attributes; } +private: + u32 vertex_attribute_sources[16]; + u32 vertex_attribute_strides[16] = {}; + Regs::VertexAttributeFormat vertex_attribute_formats[16] = {}; + u32 vertex_attribute_elements[16] = {}; + u32 vertex_attribute_element_size[16] = {}; + bool vertex_attribute_is_default[16]; + u32 base_address; + int num_total_attributes; +}; + +} // namespace Pica -- cgit v1.2.3 From d00e2340c63c61ccb987c4ab0d76957f6cc84144 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 28 Apr 2016 19:40:11 +0200 Subject: Move "&" to their proper place, add missing includes and make some properly relative. --- src/video_core/vertex_loader.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/video_core/vertex_loader.h') diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h index 4ff62d97b..560d36edc 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -1,5 +1,8 @@ #pragma once +#include +#include + #include "video_core/pica.h" #include "video_core/shader/shader.h" @@ -34,8 +37,8 @@ public: class VertexLoader { public: - void Setup(const Pica::Regs ®s); - void LoadVertex(int index, int vertex, Shader::InputVertex &input, MemoryAccesses &memory_accesses); + void Setup(const Pica::Regs& regs); + void LoadVertex(int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses); u32 GetPhysicalBaseAddress() const { return base_address; } int GetNumTotalAttributes() const { return num_total_attributes; } -- cgit v1.2.3 From 2403e86cbb5c49afeceb98f7c6e843da78dff415 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 28 Apr 2016 20:17:35 +0200 Subject: Don't keep base_address in the loader, it doesn't belong there (with it, the loader can't be cached). --- src/video_core/vertex_loader.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/video_core/vertex_loader.h') diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h index 560d36edc..40c5e83c9 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -38,10 +38,10 @@ public: class VertexLoader { public: void Setup(const Pica::Regs& regs); - void LoadVertex(int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses); + void LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses); - u32 GetPhysicalBaseAddress() const { return base_address; } int GetNumTotalAttributes() const { return num_total_attributes; } + private: u32 vertex_attribute_sources[16]; u32 vertex_attribute_strides[16] = {}; @@ -49,7 +49,6 @@ private: u32 vertex_attribute_elements[16] = {}; u32 vertex_attribute_element_size[16] = {}; bool vertex_attribute_is_default[16]; - u32 base_address; int num_total_attributes; }; -- cgit v1.2.3 From 251f29dd7fa530997cd6d27a8db28c4a39efd127 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Thu, 28 Apr 2016 21:43:49 +0200 Subject: Optimize the vertex loader, nearly doubling its speed. --- src/video_core/vertex_loader.h | 1 - 1 file changed, 1 deletion(-) (limited to 'src/video_core/vertex_loader.h') diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h index 40c5e83c9..7267ea9c6 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -47,7 +47,6 @@ private: u32 vertex_attribute_strides[16] = {}; Regs::VertexAttributeFormat vertex_attribute_formats[16] = {}; u32 vertex_attribute_elements[16] = {}; - u32 vertex_attribute_element_size[16] = {}; bool vertex_attribute_is_default[16]; int num_total_attributes; }; -- cgit v1.2.3 From a86d7cacc1f56c6e8ff5f046ba7e2477e92d873f Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Fri, 29 Apr 2016 08:50:21 +0200 Subject: Move and rename the MemoryAccesses class to MemoryAccessTracker. --- src/video_core/vertex_loader.h | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) (limited to 'src/video_core/vertex_loader.h') diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h index 7267ea9c6..ff42d1596 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -5,40 +5,14 @@ #include "video_core/pica.h" #include "video_core/shader/shader.h" +#include "video_core/debug_utils/debug_utils.h" 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 ranges; -}; - class VertexLoader { public: 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; } -- cgit v1.2.3