Cogs.Core
BuffersCommon.h
1#pragma once
2
3#include <atomic>
4
5#include "../IBuffers.h"
6#include "../Flags.h"
7#include "../Statistics.h"
8
9namespace Cogs
10{
11 struct BuffersCommon : public IBuffers
12 {
13 virtual VertexFormatHandle createVertexFormat(const VertexElement * elements, size_t count) override;
14 virtual const VertexFormat * getVertexFormat(VertexFormatHandle handle) override;
15
18 const VertexBufferHandle* vertexBufferHandles, const size_t vertexBufferCount,
19 const VertexFormat* const* vertexFormats = nullptr, const uint32_t* vertexBufferStrides = nullptr, const uint32_t* vertexBufferOffsets = nullptr,
20 const IndexBufferHandle indexBufferHandle = IndexBufferHandle::NoHandle, uint32_t indexBufferStride = 0) override;
21
24
31 void recordBufferCreate(BufferHandle handle, BindFlags::EBindFlags bindFlags, size_t bytes);
32
39 void recordBufferRelease(BufferHandle handle, BindFlags::EBindFlags bindFlags, size_t bytes);
40
43
44 enum struct BufferType {
45 Vertex,
46 Index,
47 Constant,
48 Unclassified,
49 Count
50 };
51 struct {
52 std::atomic<size_t> bytes = 0; // Number of bytes in currently allocated buffers of this type.
53 std::atomic<uint32_t> count = 0; // Number of buffers currently allocated of this type.
54 } bufferStats[size_t(BufferType::Count)];
55 };
56}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
EBindFlags
Bind flags enumeration.
Definition: Flags.h:64
virtual VertexArrayObjectHandle loadVertexArrayObject(const EffectHandle effectHandle, const VertexBufferHandle *vertexBufferHandles, const size_t vertexBufferCount, const VertexFormat *const *vertexFormats=nullptr, const uint32_t *vertexBufferStrides=nullptr, const uint32_t *vertexBufferOffsets=nullptr, const IndexBufferHandle indexBufferHandle=IndexBufferHandle::NoHandle, uint32_t indexBufferStride=0) override
void recordBufferRelease(BufferHandle handle, BindFlags::EBindFlags bindFlags, size_t bytes)
void recordBufferCreate(BufferHandle handle, BindFlags::EBindFlags bindFlags, size_t bytes)
void updateResourceStatistics(ResourceStatistics &stats) const
virtual void releaseVertexArrayObject(VertexArrayObjectHandle) override
static const Handle_t NoHandle
Represents a handle to nothing.
Definition: Common.h:78
Provides buffer management functionality.
Definition: IBuffers.h:13
Vertex element structure used to describe a single data element in a vertex for the input assembler.
Definition: VertexFormat.h:38
Vertex format structure used to describe a single vertex for the input assembler.
Definition: VertexFormat.h:60