diff options
| author | 2016-05-23 21:13:34 -0400 | |
|---|---|---|
| committer | 2016-05-23 21:13:34 -0400 | |
| commit | a316fbb15aedbc23b58474aaca95569788933774 (patch) | |
| tree | 19ead61153a7aaaed3e03a0a7244a6b1cc9bcbd7 | |
| parent | Merge pull request #1837 from wwylele/sync-trap (diff) | |
| parent | vertex_loader: Correct forward declaration of InputVertex (diff) | |
| download | yuzu-a316fbb15aedbc23b58474aaca95569788933774.tar.gz yuzu-a316fbb15aedbc23b58474aaca95569788933774.tar.xz yuzu-a316fbb15aedbc23b58474aaca95569788933774.zip | |
Merge pull request #1733 from lioncash/vert_loader
VertexLoader: Minor changes
| -rw-r--r-- | src/video_core/command_processor.cpp | 3 | ||||
| -rw-r--r-- | src/video_core/vertex_loader.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/vertex_loader.h | 23 |
3 files changed, 23 insertions, 11 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index ad0da796e..bf4664f9e 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -199,9 +199,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 199 | 199 | ||
| 200 | // Processes information about internal vertex attributes to figure out how a vertex is loaded. | 200 | // Processes information about internal vertex attributes to figure out how a vertex is loaded. |
| 201 | // Later, these can be compiled and cached. | 201 | // Later, these can be compiled and cached. |
| 202 | VertexLoader loader; | ||
| 203 | const u32 base_address = regs.vertex_attributes.GetPhysicalBaseAddress(); | 202 | const u32 base_address = regs.vertex_attributes.GetPhysicalBaseAddress(); |
| 204 | loader.Setup(regs); | 203 | VertexLoader loader(regs); |
| 205 | 204 | ||
| 206 | // Load vertices | 205 | // Load vertices |
| 207 | bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed)); | 206 | bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed)); |
diff --git a/src/video_core/vertex_loader.cpp b/src/video_core/vertex_loader.cpp index 83896814f..e40f0f1ee 100644 --- a/src/video_core/vertex_loader.cpp +++ b/src/video_core/vertex_loader.cpp | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | #include <boost/range/algorithm/fill.hpp> | 3 | #include <boost/range/algorithm/fill.hpp> |
| 4 | 4 | ||
| 5 | #include "common/assert.h" | ||
| 6 | #include "common/alignment.h" | 5 | #include "common/alignment.h" |
| 6 | #include "common/assert.h" | ||
| 7 | #include "common/bit_field.h" | 7 | #include "common/bit_field.h" |
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| @@ -21,6 +21,8 @@ | |||
| 21 | namespace Pica { | 21 | namespace Pica { |
| 22 | 22 | ||
| 23 | void VertexLoader::Setup(const Pica::Regs& regs) { | 23 | void VertexLoader::Setup(const Pica::Regs& regs) { |
| 24 | ASSERT_MSG(!is_setup, "VertexLoader is not intended to be setup more than once."); | ||
| 25 | |||
| 24 | const auto& attribute_config = regs.vertex_attributes; | 26 | const auto& attribute_config = regs.vertex_attributes; |
| 25 | num_total_attributes = attribute_config.GetNumTotalAttributes(); | 27 | num_total_attributes = attribute_config.GetNumTotalAttributes(); |
| 26 | 28 | ||
| @@ -60,9 +62,13 @@ void VertexLoader::Setup(const Pica::Regs& regs) { | |||
| 60 | } | 62 | } |
| 61 | } | 63 | } |
| 62 | } | 64 | } |
| 65 | |||
| 66 | is_setup = true; | ||
| 63 | } | 67 | } |
| 64 | 68 | ||
| 65 | void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses) { | 69 | void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses) { |
| 70 | ASSERT_MSG(is_setup, "A VertexLoader needs to be setup before loading vertices."); | ||
| 71 | |||
| 66 | for (int i = 0; i < num_total_attributes; ++i) { | 72 | for (int i = 0; i < num_total_attributes; ++i) { |
| 67 | if (vertex_attribute_elements[i] != 0) { | 73 | if (vertex_attribute_elements[i] != 0) { |
| 68 | // Load per-vertex data from the loader arrays | 74 | // Load per-vertex data from the loader arrays |
diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h index becf5a403..ac162c254 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | 2 | ||
| 3 | #include "common/common_types.h" | 3 | #include <array> |
| 4 | 4 | ||
| 5 | #include "common/common_types.h" | ||
| 5 | #include "video_core/pica.h" | 6 | #include "video_core/pica.h" |
| 6 | 7 | ||
| 7 | namespace Pica { | 8 | namespace Pica { |
| @@ -11,23 +12,29 @@ class MemoryAccessTracker; | |||
| 11 | } | 12 | } |
| 12 | 13 | ||
| 13 | namespace Shader { | 14 | namespace Shader { |
| 14 | class InputVertex; | 15 | struct InputVertex; |
| 15 | } | 16 | } |
| 16 | 17 | ||
| 17 | class VertexLoader { | 18 | class VertexLoader { |
| 18 | public: | 19 | public: |
| 20 | VertexLoader() = default; | ||
| 21 | explicit VertexLoader(const Pica::Regs& regs) { | ||
| 22 | Setup(regs); | ||
| 23 | } | ||
| 24 | |||
| 19 | void Setup(const Pica::Regs& regs); | 25 | void Setup(const Pica::Regs& regs); |
| 20 | void LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses); | 26 | void LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses); |
| 21 | 27 | ||
| 22 | int GetNumTotalAttributes() const { return num_total_attributes; } | 28 | int GetNumTotalAttributes() const { return num_total_attributes; } |
| 23 | 29 | ||
| 24 | private: | 30 | private: |
| 25 | u32 vertex_attribute_sources[16]; | 31 | std::array<u32, 16> vertex_attribute_sources; |
| 26 | u32 vertex_attribute_strides[16] = {}; | 32 | std::array<u32, 16> vertex_attribute_strides{}; |
| 27 | Regs::VertexAttributeFormat vertex_attribute_formats[16] = {}; | 33 | std::array<Regs::VertexAttributeFormat, 16> vertex_attribute_formats; |
| 28 | u32 vertex_attribute_elements[16] = {}; | 34 | std::array<u32, 16> vertex_attribute_elements{}; |
| 29 | bool vertex_attribute_is_default[16]; | 35 | std::array<bool, 16> vertex_attribute_is_default; |
| 30 | int num_total_attributes; | 36 | int num_total_attributes = 0; |
| 37 | bool is_setup = false; | ||
| 31 | }; | 38 | }; |
| 32 | 39 | ||
| 33 | } // namespace Pica | 40 | } // namespace Pica |