Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
GenericVertexData.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2018 DIVIDE-Studio
3 Copyright (c) 2009 Ionut Cava
4
5 This file is part of DIVIDE Framework.
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software
9 and associated documentation files (the "Software"), to deal in the Software
10 without restriction,
11 including without limitation the rights to use, copy, modify, merge, publish,
12 distribute, sublicense,
13 and/or sell copies of the Software, and to permit persons to whom the
14 Software is furnished to do so,
15 subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 IMPLIED,
22 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
23 PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25 DAMAGES OR OTHER LIABILITY,
26 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
27 IN CONNECTION WITH THE SOFTWARE
28 OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29
30 */
31
32#pragma once
33#ifndef DVD_GENERIC_VERTEX_DATA_H
34#define DVD_GENERIC_VERTEX_DATA_H
35
39
43
44namespace Divide {
45
47 public RingBuffer
48{
49 public:
51 {
52 bufferPtr data{ nullptr };
53 size_t count{ 0u };
54 U8 id{ 0u };
55 bool smallIndices{ false };
56 bool indicesNeedCast{ false };
57 bool dynamic{ false };
58
60 };
61
63 {
64 static constexpr size_t INVALID_ELEMENT_STRIDE = SIZE_MAX;
65
67 U16 _bufferIdx{ 0u };
68 U16 _bindIdx{ 0u };
69 };
70
71 BufferParams _bufferParams{._flags = {._usageType = BufferUsageType::VERTEX_BUFFER }};
72 BufferBindConfig _bindConfig{};
73 size_t _elementStride{ INVALID_ELEMENT_STRIDE };
74 std::pair<bufferPtr, size_t> _initialData{nullptr, 0};
75 bool _useRingBuffer{ false };
76 };
77
78 public:
79 GenericVertexData(GFXDevice& context, U16 ringBufferLength, const std::string_view name);
80
81 virtual BufferLock setIndexBuffer(const IndexBuffer& indices) = 0;
82
83 virtual void reset() = 0;
84
87 [[nodiscard]] virtual BufferLock setBuffer(const SetBufferParams& params) = 0;
88
89 [[nodiscard]] virtual BufferLock updateBuffer(U32 buffer,
90 U32 elementCountOffset,
91 U32 elementCountRange,
92 bufferPtr data) = 0;
93
94 protected:
96};
97
98}; // namespace Divide
99
100#endif //DVD_GENERIC_VERTEX_DATA_H
#define NOINITVTABLE
Rough around the edges Adapter pattern abstracting the actual rendering API and access to the GPU.
Definition: GFXDevice.h:215
virtual BufferLock updateBuffer(U32 buffer, U32 elementCountOffset, U32 elementCountRange, bufferPtr data)=0
virtual BufferLock setIndexBuffer(const IndexBuffer &indices)=0
virtual void reset()=0
Also clears GPU memory.
virtual BufferLock setBuffer(const SetBufferParams &params)=0
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint8_t U8
eastl::vector< Type > vector
Definition: Vector.h:42
uint16_t U16
uint32_t U32
void * bufferPtr
BufferUsageType _usageType
Definition: BufferParams.h:41
BufferFlags _flags
Definition: BufferParams.h:48