forked from ShuriZma/suyu
1
0
Fork 0

vertex_loader: Provide an assertion for ensuring the loader has been setup

Also adds an assert to ensure that Setup is not called more than once
during a VertexLoader's lifetime.
This commit is contained in:
Lioncash 2016-04-29 11:27:15 -04:00
parent 1357724cd9
commit 5587383eb7
2 changed files with 7 additions and 0 deletions

View File

@ -21,6 +21,8 @@
namespace Pica { namespace Pica {
void VertexLoader::Setup(const Pica::Regs& regs) { void VertexLoader::Setup(const Pica::Regs& regs) {
ASSERT_MSG(!is_setup, "VertexLoader is not intended to be setup more than once.");
const auto& attribute_config = regs.vertex_attributes; const auto& attribute_config = regs.vertex_attributes;
num_total_attributes = attribute_config.GetNumTotalAttributes(); num_total_attributes = attribute_config.GetNumTotalAttributes();
@ -60,9 +62,13 @@ void VertexLoader::Setup(const Pica::Regs& regs) {
} }
} }
} }
is_setup = true;
} }
void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses) { void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses) {
ASSERT_MSG(is_setup, "A VertexLoader needs to be setup before loading vertices.");
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

View File

@ -34,6 +34,7 @@ private:
std::array<u32, 16> vertex_attribute_elements{}; std::array<u32, 16> vertex_attribute_elements{};
std::array<bool, 16> vertex_attribute_is_default; std::array<bool, 16> vertex_attribute_is_default;
int num_total_attributes = 0; int num_total_attributes = 0;
bool is_setup = false;
}; };
} // namespace Pica } // namespace Pica