aboutsummaryrefslogtreecommitdiff
path: root/source/Mesh.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/Mesh.hpp')
-rw-r--r--source/Mesh.hpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/source/Mesh.hpp b/source/Mesh.hpp
index a1c0984..bc755a3 100644
--- a/source/Mesh.hpp
+++ b/source/Mesh.hpp
@@ -31,7 +31,7 @@ struct GpuIndexBuffer : public RefCounted {
void Upload(const std::byte* data, Tags::IndexType type, size_t count);
};
-struct BufferBindings : public RefCounted {
+struct BufferBindings {
SmallVector<RcPtr<GpuVertexBuffer>, 4> bindings;
int GetMaxBindingIndex() const;
@@ -44,14 +44,15 @@ struct BufferBindings : public RefCounted {
};
struct VertexElementFormat {
- int offset;
- int bindingIndex;
- Tags::VertexElementType type;
- Tags::VertexElementSemantic semantic;
+ /// NOTE:
+ /// "Automatic" means it will be set inside VertexFormat::AddElement()
+ /// "Parameter" means it must be set by the user
+ /* Automatic */ int offset;
+ /* Parameter */ int bindingIndex;
+ /* Parameter */ Tags::VertexElementType type;
+ /* Parameter */ Tags::VertexElementSemantic semantic;
int GetStride() const;
-
- auto operator<=>(const VertexElementFormat&) const = default;
};
struct VertexFormat : public RefCounted {
@@ -61,24 +62,22 @@ struct VertexFormat : public RefCounted {
const std::vector<VertexElementFormat>& GetElements() { return elements; }
void AddElement(VertexElementFormat element);
void RemoveElement(int index);
-
- void Sort();
- void CompactBindingIndex();
};
+// Initialized in main()
+inline RcPtr<VertexFormat> gVformatStandard{};
+inline RcPtr<VertexFormat> gVformatStandardPacked{};
+
+// TODO handle immutability
class GpuMesh : public RefCounted {
public:
RcPtr<VertexFormat> vertFormat;
- RcPtr<BufferBindings> vertBufBindings;
+ BufferBindings vertBufBindings;
RcPtr<GpuIndexBuffer> indexBuf;
public:
- GpuMesh(VertexFormat* vertexFormat, BufferBindings* bindings, GpuIndexBuffer* indexBuffer);
+ GpuMesh();
+ ~GpuMesh();
bool IsEmpty() const;
- void SetVertex(VertexFormat* vertexFormat, BufferBindings* bindings);
- VertexFormat* GetVertexFormat() const;
- BufferBindings* GetVertexBufferBindings() const;
- void SetIndex(GpuIndexBuffer* buffer);
- GpuIndexBuffer* GetIndexBuffer() const;
};