From 8ea5e7dfb57ebda2ad2229e4e94dfd5e2c24c091 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 29 Apr 2016 11:06:03 -0400 Subject: vertex_loader: Use std::array instead of raw C arrays --- src/video_core/vertex_loader.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 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 becf5a403..3b511945a 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -1,7 +1,8 @@ #pragma once -#include "common/common_types.h" +#include +#include "common/common_types.h" #include "video_core/pica.h" namespace Pica { @@ -22,11 +23,11 @@ public: 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] = {}; - bool vertex_attribute_is_default[16]; + std::array vertex_attribute_sources; + std::array vertex_attribute_strides{}; + std::array vertex_attribute_formats; + std::array vertex_attribute_elements{}; + std::array vertex_attribute_is_default; int num_total_attributes; }; -- cgit v1.2.3 From 769f4a7018e170448f7f1c307f2bcfa26f59ecba Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 29 Apr 2016 11:16:52 -0400 Subject: vertex_loader: initialize_num_total_attributes. Keeps the public API sane. --- src/video_core/vertex_loader.h | 2 +- 1 file changed, 1 insertion(+), 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 3b511945a..4ed8cd3fd 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -28,7 +28,7 @@ private: std::array vertex_attribute_formats; std::array vertex_attribute_elements{}; std::array vertex_attribute_is_default; - int num_total_attributes; + int num_total_attributes = 0; }; } // namespace Pica -- cgit v1.2.3 From 1357724cd946f3a9f31dbe3ace55a9588f3c6f2f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 29 Apr 2016 11:23:40 -0400 Subject: vertex_loader: Add constructors to facilitate immediate and two-step initialization --- src/video_core/vertex_loader.h | 5 +++++ 1 file changed, 5 insertions(+) (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 4ed8cd3fd..2a97b97c8 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -17,6 +17,11 @@ class InputVertex; class VertexLoader { public: + VertexLoader() = default; + explicit VertexLoader(const Pica::Regs& regs) { + Setup(regs); + } + void Setup(const Pica::Regs& regs); void LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, DebugUtils::MemoryAccessTracker& memory_accesses); -- cgit v1.2.3 From 5587383eb72b02af79526d6fe5e662b281b4b32b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 29 Apr 2016 11:27:15 -0400 Subject: 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. --- src/video_core/vertex_loader.h | 1 + 1 file changed, 1 insertion(+) (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 2a97b97c8..7192120a5 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -34,6 +34,7 @@ private: std::array vertex_attribute_elements{}; std::array vertex_attribute_is_default; int num_total_attributes = 0; + bool is_setup = false; }; } // namespace Pica -- cgit v1.2.3 From 6d5f2a3cff519ca2811033d8381fac2515a74af8 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 8 May 2016 23:04:42 -0400 Subject: vertex_loader: Correct forward declaration of InputVertex It's actually a struct, not a class. --- src/video_core/vertex_loader.h | 2 +- 1 file changed, 1 insertion(+), 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 7192120a5..ac162c254 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -12,7 +12,7 @@ class MemoryAccessTracker; } namespace Shader { -class InputVertex; +struct InputVertex; } class VertexLoader { -- cgit v1.2.3