CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
GPUBufferObject.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
10#include "GPUBuffer.hpp"
11#include "GPUCommandBuffer.hpp"
12#include "GPUDevice.hpp"
13#include "GPUResourceSet.hpp"
14
17
22
23#include <cstring>
24
25namespace CeresEngine {
26
28 protected:
31
34
37
38 public:
40 GPUBufferObject() = default;
41
47
49 explicit GPUBufferObject(GPUBuffer& buffer, const GPUBufferSize offset = 0, const GPUBufferSize length = GPUBuffer::whole)
50 : GPUBufferObject(&buffer, offset, length) {}
51
56 explicit GPUBufferObject(GPUDevice& device, const GPUBufferDescriptor& descriptor);
57
59 GPUBufferObject(std::nullptr_t) {} // NOLINT
60
63 GPUBufferObject& operator=(std::nullptr_t) {
64 mBuffer = nullptr;
65 mOffset = 0;
66 return *this;
67 }
68
72
76
79
82
85
86 public:
92
98
99 public:
102
105
108
109 public:
111 explicit operator bool() const noexcept { return mBuffer != nullptr; }
112
113 [[nodiscard]] friend bool operator==(const GPUBufferObject& lhs, const GPUBufferObject& rhs) noexcept {
114 return lhs.getBuffer() == rhs.getBuffer() && lhs.getOffset() == rhs.getOffset() && lhs.getLength() == rhs.getLength();
115 }
116 [[nodiscard]] friend bool operator==(const GPUBufferObject& lhs, std::nullptr_t) noexcept { return lhs.getBuffer() == nullptr; }
117 [[nodiscard]] friend bool operator==(std::nullptr_t, const GPUBufferObject& rhs) noexcept { return rhs.getBuffer() == nullptr; }
118
119 [[nodiscard]] friend bool operator!=(const GPUBufferObject& lhs, const GPUBufferObject& rhs) noexcept {
120 return lhs.getBuffer() != rhs.getBuffer() && lhs.getOffset() != rhs.getOffset() && lhs.getLength() != rhs.getLength();
121 }
122 [[nodiscard]] friend bool operator!=(const GPUBufferObject& lhs, std::nullptr_t) noexcept { return lhs.getBuffer() != nullptr; }
123 [[nodiscard]] friend bool operator!=(std::nullptr_t, const GPUBufferObject& rhs) noexcept { return rhs.getBuffer() != nullptr; }
124 };
125
127 public:
129 GPUVertexBuffer() = default;
130
135
137 explicit GPUVertexBuffer(GPUBuffer& buffer, const GPUBufferSize offset = 0, const GPUBufferSize length = GPUBuffer::whole)
138 : GPUVertexBuffer(&buffer, offset, length) {}
139
146 String name = "");
147
149 GPUVertexBuffer(std::nullptr_t) {} // NOLINT
150
154
158
161
164
167 };
168
172
173 public:
175 GPUIndexBuffer() = default;
176
182
184 explicit GPUIndexBuffer(GPUBuffer& buffer, const GPUBufferSize offset = 0, const IndexType indexType = IndexType::UInt32, const GPUBufferSize length = GPUBuffer::whole)
185 : GPUIndexBuffer(&buffer, offset, indexType, length) {}
186
194 const GPUMemoryProperties& memoryProperty = GPUMemoryProperty::DeviceLocal, String name = "");
195
197 GPUIndexBuffer(std::nullptr_t) {} // NOLINT
198
202
206
209
212
215
216 public:
219 };
220
222 public:
224 GPUUniformBuffer() = default;
225
231
233 explicit GPUUniformBuffer(GPUBuffer& buffer, const GPUBufferSize offset = 0, const GPUBufferSize length = GPUBuffer::whole)
234 : GPUUniformBuffer(&buffer, offset, length) {}
235
242 String name = "");
243
246
248 GPUUniformBuffer(std::nullptr_t) {} // NOLINT
249
253
257
260
263
266 };
267
269 public:
271 GPUStorageBuffer() = default;
272
277
279 explicit GPUStorageBuffer(GPUBuffer& buffer, const GPUBufferSize offset = 0, const GPUBufferSize length = GPUBuffer::whole)
280 : GPUStorageBuffer(&buffer, offset, length) {}
281
288 String name = "");
289
291 explicit GPUStorageBuffer(const GPUUniformBuffer& uniformBuffer);
292
294 GPUStorageBuffer(std::nullptr_t) {} // NOLINT
295
299
303
306
309
312 };
313
315 public:
317 GPUIndirectBuffer() = default;
318
323
325 explicit GPUIndirectBuffer(GPUBuffer& buffer, const GPUBufferSize offset = 0, const GPUBufferSize length = GPUBuffer::whole)
326 : GPUIndirectBuffer(&buffer, offset, length) {}
327
334 String name = "");
335
337 GPUIndirectBuffer(std::nullptr_t) {} // NOLINT
338
342
346
349
352
355 };
356
360 public:
362 GPUStagingBuffer() = default;
363
368
370 explicit GPUStagingBuffer(GPUBuffer& buffer, const GPUBufferSize offset = 0, const GPUBufferSize length = GPUBuffer::whole)
371 : GPUStagingBuffer(&buffer, offset, length) {}
372
379 String name = "");
380
386 explicit GPUStagingBuffer(GPUDevice& device, const void* data, GPUBufferSize size,
387 const GPUMemoryProperties& memoryProperty = GPUMemoryProperty::HostVisible, String name = "");
388
395 const GPUMemoryProperties& memoryProperty = GPUMemoryProperty::HostVisible, String name = "");
396
398 GPUStagingBuffer(std::nullptr_t) {} // NOLINT
399
403
407
410
413
416
417 public:
423 void copy(const void* ptr, UInt64 size);
424
428 void copy(InputStream stream);
429
432 void fill(uint8_t byte = 0);
433
439
448 void upload(GPUCommandBuffer& commandBuffer, GPUBuffer& dstBuffer, UInt64 dstOffset = 0, UInt64 srcOffset = 0, UInt64 size = ~0u);
449
455
465
470 void upload(GPUImage& dstImage, const GPUImageRegion& dstRegion = {}, UInt64 srcOffset = 0, bool generateMips = true, UInt32 rowStride = 0,
471 UInt32 layerStride = 0);
472
488 void upload(GPUCommandBuffer& commandBuffer, GPUImage& dstImage, const GPUImageRegion& dstRegion = {}, UInt64 srcOffset = 0, bool generateMips = true,
490
496
512 };
513
517 public:
519 GPUBindlessBuffer() = default;
520
525
527 explicit GPUBindlessBuffer(GPUBuffer& buffer, const GPUBufferSize offset = 0, const GPUBufferSize length = GPUBuffer::whole)
528 : GPUBindlessBuffer(&buffer, offset, length) {}
529
536 String name = "");
537
539 GPUBindlessBuffer(std::nullptr_t) {} // NOLINT
540
544
548
551
554
557 };
558
559 // ---------------------------------------------------------------------------------------------
560 // ---------------------------------------------------------------------------------------------
561
562 template<typename P, typename T, std::size_t BaseAlignment = 1> class GPUDynamicBuffer final : public P {
564 T* mData = nullptr;
565
566 public:
568 GPUDynamicBuffer() = default;
569
573 explicit GPUDynamicBuffer(GPUBufferPtr buffer, GPUBufferSize offset = 0) : P(std::move(buffer), offset, sizeof(T)) {
574 mData = reinterpret_cast<T*>(reinterpret_cast<UInt8*>(P::getBuffer()->map()) + P::getOffset());
575 }
576
581 template<typename... Args>
582 explicit GPUDynamicBuffer(GPUDevice& device, String name = "", Args&&... args)
583 : P(device, sizeof(T), args..., GPUMemoryProperty::HostVisible | GPUMemoryProperty::HostCached, name) {
584 mData = reinterpret_cast<T*>(reinterpret_cast<UInt8*>(P::getBuffer()->map()) + P::getOffset());
585 }
586
592 mData = reinterpret_cast<T*>(reinterpret_cast<UInt8*>(P::getBuffer()->map()) + P::getOffset());
593 }
594
595 GPUDynamicBuffer(const GPUDynamicBuffer& value) = default;
596 GPUDynamicBuffer(GPUDynamicBuffer&& value) noexcept = default;
597
599 if(const GPUBufferPtr& buffer = P::getBuffer()) {
600 buffer->unmap();
601 }
602 }
603
605 GPUDynamicBuffer& operator=(GPUDynamicBuffer&& value) noexcept = default;
606
610 GPUDynamicBuffer& operator=(const T& value) {
611 *mData = value;
612 return *this;
613 }
614
615 public:
617 [[nodiscard]] T* get() noexcept { return mData; }
618
620 [[nodiscard]] const T* get() const noexcept { return mData; }
621
623 void update(const T& data) { memcpy(mData, &data, sizeof(T)); }
624
626 void commit() { P::flush(); }
627
628 public:
633
637 [[nodiscard]] const T* operator->() const noexcept { return mData; }
638
641 [[nodiscard]] T& operator*() noexcept { return *mData; }
642
645 [[nodiscard]] const T& operator*() const noexcept { return *mData; }
646 };
647
648 template<typename P, typename T, std::size_t BaseAlignment> class GPUDynamicBuffer<P, T[], BaseAlignment> : public P { // NOLINT
649 public:
651 static constexpr GPUBufferSize byteStride = ((sizeof(T) + BaseAlignment - 1) / BaseAlignment) * BaseAlignment;
652
654 static constexpr bool isStrided = byteStride == sizeof(T);
655
657 using MemoryViewType = std::conditional_t<isStrided, StridedMemoryView<T>, MemoryView<T>>;
658
661 using IteratorType = typename MemoryViewType::Iterator;
662
665 using ConstIteratorType = typename MemoryViewType::ConstIterator;
666
667 private:
670
671 public:
673 GPUDynamicBuffer() = default;
674
678 explicit GPUDynamicBuffer(GPUBufferPtr buffer, GPUBufferSize offset = 0) : P(std::move(buffer), offset) {
679 const GPUBufferData ptr = P::getBuffer()->map() + offset;
680 if constexpr(isStrided) {
681 mData = make_strided_memory_view(static_cast<T*>(ptr), P::getLength() / byteStride, byteStride);
682 } else {
683 mData = make_memory_view(static_cast<T*>(ptr), P::getLength() / byteStride);
684 }
685 }
686
692 template<typename... Args>
693 explicit GPUDynamicBuffer(GPUDevice& device, const size_t size, String name, Args&&... args)
694 : P(device, size * byteStride, args..., GPUMemoryProperty::HostVisible | GPUMemoryProperty::HostCached, name) {
695 const GPUBufferData ptr = P::getBuffer()->map();
696 if constexpr(isStrided) {
697 mData = make_strided_memory_view(static_cast<T*>(ptr), P::getLength() / byteStride, byteStride);
698 } else {
699 mData = make_memory_view(static_cast<T*>(ptr), P::getLength() / byteStride);
700 }
701 }
702
704 if(const GPUBufferPtr& buffer = P::getBuffer()) {
705 buffer->unmap();
706 }
707 }
708
709 public:
710 [[nodiscard]] T* data() noexcept { return mData.data(); }
711 [[nodiscard]] const T* data() const noexcept { return mData.data(); }
712
713 void update(const T* data, const size_t length) { update(data, 0, length); }
714 void update(const T* data, const size_t offset, const size_t length) {
715 for(const size_t index : range(length)) {
716 mData[offset + index] = data[index];
717 }
718 }
719
720 [[nodiscard]] GPUDynamicBuffer<P, T> get(const size_t index) const { return GPUDynamicBuffer<P, T>{P::getBuffer(), P::getOffset() + align(index)}; }
721 void set(size_t i, const T& value) noexcept { mData[i] = value; }
722
723 [[nodiscard]] std::size_t size() const noexcept { return mData.size(); }
724 [[nodiscard]] size_t stride() const noexcept requires(isStrided) { return mData.stride(); }
725
726 [[nodiscard]] P slice(const size_t index) const { return P{P::getBuffer(), P::getOffset() + align(index), sizeof(T)}; }
727
728 public:
729 [[nodiscard]] IteratorType begin() noexcept { return mData.begin(); }
731
732 [[nodiscard]] IteratorType end() noexcept { return mData.end(); }
734
735 public:
736 [[nodiscard]] GPUDynamicBuffer<P, T> operator[](const size_t index) const noexcept { return GPUDynamicBuffer<P, T>(slice(index)); }
737
738 private:
739 [[nodiscard]] size_t align(const size_t index) const noexcept { return byteStride * index; }
740 };
741
742 template<typename P, typename T> class GPUDynamicBuffer<P, T[], 0> : public P { // NOLINT
743 public:
745 static constexpr bool isStrided = true;
746
749
753
757
758 private:
761
762 public:
764 GPUDynamicBuffer() = default;
765
769 explicit GPUDynamicBuffer(GPUBufferPtr buffer, const GPUBufferSize baseAlignment = sizeof(T), GPUBufferSize offset = 0) : P(std::move(buffer), offset) {
770 const GPUBufferSize stride = ((sizeof(T) + baseAlignment - 1) / baseAlignment) * baseAlignment;
771 const GPUBufferData ptr = P::getBuffer()->map() + offset;
772 mData = make_strided_memory_view(static_cast<T*>(ptr), P::getLength() / stride, stride);
773 }
774
780 template<typename... Args>
781 explicit GPUDynamicBuffer(GPUDevice& device, const size_t size, const size_t baseAlignment, String name, Args&&... args)
782 : P(device, size * ((sizeof(T) + baseAlignment - 1) / baseAlignment) * baseAlignment, args...,
784 const GPUBufferSize stride = ((sizeof(T) + baseAlignment - 1) / baseAlignment) * baseAlignment;
785 const GPUBufferData ptr = P::getBuffer()->map();
786 mData = make_strided_memory_view(static_cast<T*>(ptr), P::getLength() / stride, stride);
787 }
788
790 if(const GPUBufferPtr& buffer = P::getBuffer()) {
791 buffer->unmap();
792 }
793 }
794
795 public:
796 [[nodiscard]] T* data() noexcept { return mData.data(); }
797 [[nodiscard]] const T* data() const noexcept { return mData.data(); }
798
799 void update(const T* data, const size_t length) { update(data, 0, length); }
800 void update(const T* data, const size_t offset, const size_t length) {
801 for(const size_t index : range(length)) {
802 mData[offset + index] = data[index];
803 }
804 }
805
806 [[nodiscard]] GPUDynamicBuffer<P, T> get(const size_t index) const { return GPUDynamicBuffer<P, T>{P::getBuffer(), P::getOffset() + align(index)}; }
807 void set(size_t i, const T& value) noexcept { mData[i] = value; }
808
809 [[nodiscard]] std::size_t size() const noexcept { return mData.size(); }
810 [[nodiscard]] size_t stride() const noexcept { return mData.stride(); }
811
812 [[nodiscard]] P slice(const size_t index) const { return P{P::getBuffer(), P::getOffset() + align(index), sizeof(T)}; }
813
814 public:
815 [[nodiscard]] IteratorType begin() noexcept { return mData.begin(); }
817
818 [[nodiscard]] IteratorType end() noexcept { return mData.end(); }
820
821 public:
822 [[nodiscard]] GPUDynamicBuffer<P, T> operator[](const size_t index) const noexcept { return GPUDynamicBuffer<P, T>(slice(index)); }
823
824 private:
825 [[nodiscard]] size_t align(const size_t index) const noexcept { return stride() * index; }
826 };
827
828 template<typename P, typename T, size_t N, std::size_t BaseAlignment>
829 class GPUDynamicBuffer<P, T[N], BaseAlignment> : public GPUDynamicBuffer<P, T[], BaseAlignment> { // NOLINT
831
832 public:
834 GPUDynamicBuffer() = default;
835
839 explicit GPUDynamicBuffer(GPUBufferPtr buffer, GPUBufferSize offset = 0) : super(buffer, offset) { CE_ASSERT(super::size() == N); }
840
845 template<typename... Args>
846 explicit GPUDynamicBuffer(GPUDevice& device, String name = "", Args&&... args) : super(device, N, name, std::forward<Args>(args)...) {
847 CE_ASSERT(super::size() == N);
848 }
849
851 if(const GPUBufferPtr& buffer = P::getBuffer()) {
852 buffer->unmap();
853 }
854 }
855 };
856
859
862
864 template<typename T> using GPUDynamicIndexBuffer = GPUDynamicBuffer<GPUIndexBuffer, T[]>; // NOLINT
865
868
871
873 template<typename T, std::size_t BaseAlignment = sizeof(T)>
875
878
881
883 template<typename T, std::size_t BaseAlignment = sizeof(T)>
885
888
891
893 template<typename T, std::size_t BaseAlignment = sizeof(T)>
895
898
901
903 template<typename T, std::size_t BaseAlignment = sizeof(T)>
905
908
909 // ---------------------------------------------------------------------------------------------
910 // ---------------------------------------------------------------------------------------------
911
917 template<template<typename> class B> class GPUBufferPool final {
918 public:
920 using RawBuffer = B<UInt8[]>; // NOLINT
921
922 private:
925
929
932
935
936 private: // Parameters
938 const GPUBufferSize baseAlignment = 256; // TODO query this from the device
939
941 const GPUBufferSize baseAllocationSize = 4 * 1024 * 1024;
942
943 public:
947
953
954 public:
958
961 template<typename T> [[nodiscard]] B<T> allocate() {
962 const size_t alignment = ((sizeof(T) + baseAlignment - 1) / baseAlignment) * baseAlignment;
963
964 // If the required alignment is very large (i.e. larger than half
965 // the allocation size) we skip any pooling and allocate an entire
966 // new buffer for this allocation.
967 //
968 if(alignment > baseAllocationSize / 2) {
969 return B<T>{*device};
970 }
971
972 if(length < next + alignment) {
973 reserve(length * 2 + 1);
974 }
975
978 next += alignment;
979
980 CE_ASSERT(buffers.size() > bufferIndex);
981 RawBuffer& buffer = buffers[bufferIndex];
982 return B<T>(buffer.getBuffer(), buffer.getOffset() + static_cast<GPUBufferSize>(bufferOffset));
983 }
984
988 void reset() noexcept { next = 0; }
989
993 [[nodiscard]] bool empty() const noexcept { return next == 0; }
994
995 public:
1000 void flush(const GPUBufferSize offset = 0, const GPUBufferSize size = GPUBuffer::whole) {
1002 const GPUBufferSize endBufferIndex = std::min<GPUBufferSize>(((offset + size) / baseAllocationSize) + 1, buffers.size());
1003
1005 RawBuffer& buffer = buffers[bufferIndex];
1006 buffer.flush();
1007 }
1008 }
1009
1014 void invalidate(const GPUBufferSize offset = 0, const GPUBufferSize size = GPUBuffer::whole) {
1016 const GPUBufferSize endBufferIndex = std::min(((offset + size) / baseAllocationSize) + 1, buffers.size());
1017
1019 RawBuffer& buffer = buffers[bufferIndex];
1020 buffer.invalidate();
1021 }
1022 }
1023
1024 private:
1025 void allocateBuffers(const size_t newLength) {
1029 return;
1030 }
1031
1033 for(GPUBufferSize i = 0; i < numBuffersToAllocate; i++) {
1034 buffers.emplace_back(*device, baseAllocationSize, "");
1035 }
1037 }
1038 };
1039
1044
1049
1054
1059 template<typename T, template<typename> class B = GPUDynamicUniformBufferArray> class TGPUBufferPool final {
1060 static_assert(std::is_trivially_copyable_v<T>);
1061
1062 public:
1065
1066 private:
1069
1073
1074 private: // Parameters
1076 static constexpr size_t alignment = ((sizeof(T) + 256 - 1) / 256) * 256;
1077
1079 const size_t baseAllocationSize = 4 * 1024 * 1024;
1080
1081 private: // State
1082 size_t mLength = 0;
1083
1084 public:
1088
1089 public:
1092 void reserve(const size_t length) { allocateBuffers(length * alignment); }
1093
1097 [[nodiscard]] T& operator[](const size_t index) {
1098 if(mLength <= index) {
1099 reserve(index * 2 + 1);
1100 }
1101
1102 const size_t offset = alignment * index;
1103 size_t bufferIndex = offset / baseAllocationSize;
1104 size_t bufferOffset = offset - bufferIndex * baseAllocationSize;
1105
1106 BufferType& buffer = buffers[bufferIndex];
1107 return reinterpret_cast<T&>(buffer[bufferOffset]);
1108 }
1109
1110 public:
1115 void flush(const GPUBufferSize offset = 0, const GPUBufferSize size = GPUBuffer::whole) {
1116 const size_t startBufferIndex = offset / baseAllocationSize;
1117 const size_t endBufferIndex = std::min(((offset + size) / baseAllocationSize) + 1, buffers.size());
1118
1120 BufferType& buffer = buffers[bufferIndex];
1121 buffer.flush();
1122 }
1123 }
1124
1129 void invalidate(const GPUBufferSize offset = 0, const GPUBufferSize size = GPUBuffer::whole) {
1130 const size_t startBufferIndex = offset / baseAllocationSize;
1131 const size_t endBufferIndex = std::min(((offset + size) / baseAllocationSize) + 1, buffers.size());
1132
1134 BufferType& buffer = buffers[bufferIndex];
1135 buffer.invalidate();
1136 }
1137 }
1138
1139 private:
1140 void allocateBuffers(const size_t length) {
1141 const size_t numBuffers = (length + baseAllocationSize - 1) / baseAllocationSize;
1142 const size_t currentNumBuffers = buffers.size();
1144 return;
1145 }
1146
1148 for(size_t i = 0; i < numBuffersToAllocate; i++) {
1149 buffers.emplace_back(*device, baseAllocationSize, "");
1150 }
1152 }
1153 };
1154
1159
1164
1169
1174
1177
1178} // namespace CeresEngine
#define CE_ASSERT(...)
Definition Macros.hpp:323
A retain-release type of smart pointer.
Definition SmartPtr.hpp:132
A GPU bindless buffer.
Definition GPUBufferObject.hpp:516
GPUBindlessBuffer & operator=(GPUBindlessBuffer &&)=default
Assigns a BindlessBuffer by moving another.
GPUBindlessBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0, GPUBufferSize length=GPUBuffer::whole)
Creates a new BindlessBuffer from an existing GPU buffer.
GPUBindlessBuffer()=default
Creates a new empty BindlessBuffer.
GPUBindlessBuffer & operator=(const GPUBindlessBuffer &)=default
Assigns the BindlessBuffer by copying another.
~GPUBindlessBuffer()
Destroys the BindlessBuffer.
GPUBindlessBuffer(const GPUBindlessBuffer &)=default
Creates a new BindlessBuffer by copying another.
GPUBindlessBuffer(GPUBuffer &buffer, const GPUBufferSize offset=0, const GPUBufferSize length=GPUBuffer::whole)
Definition GPUBufferObject.hpp:527
GPUBindlessBuffer(GPUDevice &device, GPUBufferSize size, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::DeviceLocal, String name="")
Creates a new BindlessBuffer.
GPUBindlessBuffer(std::nullptr_t)
Creates a new empty BindlessBuffer.
Definition GPUBufferObject.hpp:539
GPUBindlessBuffer(GPUBindlessBuffer &&)=default
Creates a new BindlessBuffer by moving another.
Definition GPUBuffer.hpp:124
static const constexpr GPUBufferSize whole
A constant the represents the whole buffer length.
Definition GPUBuffer.hpp:127
Definition GPUBufferObject.hpp:27
friend bool operator==(const GPUBufferObject &lhs, const GPUBufferObject &rhs) noexcept
Definition GPUBufferObject.hpp:113
GPUBufferSize getOffset() const noexcept
Definition GPUBufferObject.hpp:104
GPUBufferSize mOffset
The offset to the beginning of the buffer object data.
Definition GPUBufferObject.hpp:33
GPUBufferSize getLength() const noexcept
Definition GPUBufferObject.hpp:107
GPUBufferObject(GPUBuffer &buffer, const GPUBufferSize offset=0, const GPUBufferSize length=GPUBuffer::whole)
Definition GPUBufferObject.hpp:49
friend bool operator==(std::nullptr_t, const GPUBufferObject &rhs) noexcept
Definition GPUBufferObject.hpp:117
friend bool operator==(const GPUBufferObject &lhs, std::nullptr_t) noexcept
Definition GPUBufferObject.hpp:116
GPUBufferSize mLength
The length of the buffer data.
Definition GPUBufferObject.hpp:36
void invalidate(GPUBufferSize offset=0, GPUBufferSize size=GPUBuffer::whole)
Invalidates the cached memory data starting at offset with size bytes.
GPUBufferPtr getBuffer() const noexcept
Definition GPUBufferObject.hpp:101
friend bool operator!=(std::nullptr_t, const GPUBufferObject &rhs) noexcept
Definition GPUBufferObject.hpp:123
GPUBufferObject & operator=(const GPUBufferObject &)=default
Assigns the BufferObject by copying another.
GPUBufferObject(GPUBufferPtr buffer, GPUBufferSize offset=0, GPUBufferSize length=GPUBuffer::whole)
Creates a new BufferObject from an existing GPU buffer.
~GPUBufferObject()
Destroys the BufferObject.
GPUBufferObject()=default
Creates a new empty BufferObject.
friend bool operator!=(const GPUBufferObject &lhs, const GPUBufferObject &rhs) noexcept
Definition GPUBufferObject.hpp:119
GPUBufferObject & operator=(std::nullptr_t)
Assigns the BufferObject an empty value.
Definition GPUBufferObject.hpp:63
GPUBufferObject & operator=(GPUBufferObject &&)=default
Assigns a BufferObject by moving another.
GPUBufferPtr mBuffer
A pointer to the GPU allocated buffer.
Definition GPUBufferObject.hpp:30
GPUBufferObject(const GPUBufferObject &)=default
Creates a new BufferObject by copying another.
GPUBufferObject(GPUBufferObject &&)=default
Creates a new BufferObject by moving another.
friend bool operator!=(const GPUBufferObject &lhs, std::nullptr_t) noexcept
Definition GPUBufferObject.hpp:122
void flush(GPUBufferSize offset=0, GPUBufferSize size=GPUBuffer::whole)
Flushes the cached memory data starting at offset with size bytes.
GPUBufferObject(GPUDevice &device, const GPUBufferDescriptor &descriptor)
Creates a new BufferObject.
GPUBufferObject(std::nullptr_t)
Creates a new empty BufferObject.
Definition GPUBufferObject.hpp:59
A template class that automatically manages a buffer pool.
Definition GPUBufferObject.hpp:917
Vector< RawBuffer > buffers
A vector of allocated buffers.
Definition GPUBufferObject.hpp:928
B< T > allocate()
Allocates a new object from the pool.
Definition GPUBufferObject.hpp:961
GPUBufferPool(GPUDevice &device)
Creates a new BufferPool object.
Definition GPUBufferObject.hpp:946
void reset() noexcept
Resets the buffer pool.
Definition GPUBufferObject.hpp:988
void invalidate(const GPUBufferSize offset=0, const GPUBufferSize size=GPUBuffer::whole)
Invalidates the cached memory data starting at offset with size bytes.
Definition GPUBufferObject.hpp:1014
bool empty() const noexcept
Checks if the buffer pool is empty.
Definition GPUBufferObject.hpp:993
const GPUBufferSize baseAlignment
The base alignment to be used for each object in pool.
Definition GPUBufferObject.hpp:938
B< UInt8[]> RawBuffer
The buffer type.
Definition GPUBufferObject.hpp:920
GPUBufferPool(GPUDevice &device, const GPUBufferSize baseAllocationSize)
Creates a new BufferPool object.
Definition GPUBufferObject.hpp:952
const GPUBufferSize baseAllocationSize
The base allocation size used by the pool.
Definition GPUBufferObject.hpp:941
GPUBufferSize next
The offset of the next allocated object.
Definition GPUBufferObject.hpp:931
GPUBufferSize length
The maximum buffer length.
Definition GPUBufferObject.hpp:934
GPUDevicePtr device
The device to be used when allocating memory.
Definition GPUBufferObject.hpp:924
void allocateBuffers(const size_t newLength)
Definition GPUBufferObject.hpp:1025
void reserve(const GPUBufferSize length)
Reserves space in the pool.
Definition GPUBufferObject.hpp:957
void flush(const GPUBufferSize offset=0, const GPUBufferSize size=GPUBuffer::whole)
Flushes the cached memory data starting at offset with size bytes.
Definition GPUBufferObject.hpp:1000
Definition GPUCommandBuffer.hpp:77
Definition GPUDevice.hpp:357
GPUDynamicBuffer(GPUDevice &device, const size_t size, const size_t baseAlignment, String name, Args &&... args)
Creates a new DynamicBuffer.
Definition GPUBufferObject.hpp:781
T * data() noexcept
Definition GPUBufferObject.hpp:796
~GPUDynamicBuffer()
Definition GPUBufferObject.hpp:789
typename MemoryViewType::ConstIterator ConstIteratorType
The type that represents the iterator for each element in the dynamic buffer.
Definition GPUBufferObject.hpp:756
ConstIteratorType begin() const noexcept
Definition GPUBufferObject.hpp:816
size_t stride() const noexcept
Definition GPUBufferObject.hpp:810
GPUDynamicBuffer< P, T > get(const size_t index) const
Definition GPUBufferObject.hpp:806
MemoryViewType mData
A memory view to the buffer data mapped on host memory.
Definition GPUBufferObject.hpp:760
GPUDynamicBuffer()=default
Creates a new empty DynamicBuffer.
const T * data() const noexcept
Definition GPUBufferObject.hpp:797
IteratorType end() noexcept
Definition GPUBufferObject.hpp:818
void set(size_t i, const T &value) noexcept
Definition GPUBufferObject.hpp:807
std::size_t size() const noexcept
Definition GPUBufferObject.hpp:809
GPUDynamicBuffer< P, T > operator[](const size_t index) const noexcept
Definition GPUBufferObject.hpp:822
GPUDynamicBuffer(GPUBufferPtr buffer, const GPUBufferSize baseAlignment=sizeof(T), GPUBufferSize offset=0)
Creates a new DynamicBuffer from an existing GPU buffer.
Definition GPUBufferObject.hpp:769
P slice(const size_t index) const
Definition GPUBufferObject.hpp:812
ConstIteratorType end() const noexcept
Definition GPUBufferObject.hpp:819
void update(const T *data, const size_t length)
Definition GPUBufferObject.hpp:799
typename MemoryViewType::Iterator IteratorType
The type that represents the iterator for each element in the dynamic buffer.
Definition GPUBufferObject.hpp:752
size_t align(const size_t index) const noexcept
Definition GPUBufferObject.hpp:825
IteratorType begin() noexcept
Definition GPUBufferObject.hpp:815
void update(const T *data, const size_t offset, const size_t length)
Definition GPUBufferObject.hpp:800
P slice(const size_t index) const
Definition GPUBufferObject.hpp:726
IteratorType begin() noexcept
Definition GPUBufferObject.hpp:729
std::conditional_t< isStrided, StridedMemoryView< T >, MemoryView< T > > MemoryViewType
The type of memory view used to view the host-mapped buffer.
Definition GPUBufferObject.hpp:657
size_t stride() const noexcept
Definition GPUBufferObject.hpp:724
T * data() noexcept
Definition GPUBufferObject.hpp:710
~GPUDynamicBuffer()
Definition GPUBufferObject.hpp:703
void set(size_t i, const T &value) noexcept
Definition GPUBufferObject.hpp:721
typename MemoryViewType::Iterator IteratorType
The type that represents the iterator for each element in the dynamic buffer.
Definition GPUBufferObject.hpp:661
GPUDynamicBuffer()=default
Creates a new empty DynamicBuffer.
typename MemoryViewType::ConstIterator ConstIteratorType
The type that represents the iterator for each element in the dynamic buffer.
Definition GPUBufferObject.hpp:665
GPUDynamicBuffer(GPUDevice &device, const size_t size, String name, Args &&... args)
Creates a new DynamicBuffer.
Definition GPUBufferObject.hpp:693
std::size_t size() const noexcept
Definition GPUBufferObject.hpp:723
GPUDynamicBuffer< P, T > get(const size_t index) const
Definition GPUBufferObject.hpp:720
GPUDynamicBuffer< P, T > operator[](const size_t index) const noexcept
Definition GPUBufferObject.hpp:736
GPUDynamicBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0)
Creates a new DynamicBuffer from an existing GPU buffer.
Definition GPUBufferObject.hpp:678
IteratorType end() noexcept
Definition GPUBufferObject.hpp:732
ConstIteratorType begin() const noexcept
Definition GPUBufferObject.hpp:730
void update(const T *data, const size_t offset, const size_t length)
Definition GPUBufferObject.hpp:714
size_t align(const size_t index) const noexcept
Definition GPUBufferObject.hpp:739
MemoryViewType mData
A memory view to the buffer data mapped on host memory.
Definition GPUBufferObject.hpp:669
void update(const T *data, const size_t length)
Definition GPUBufferObject.hpp:713
ConstIteratorType end() const noexcept
Definition GPUBufferObject.hpp:733
const T * data() const noexcept
Definition GPUBufferObject.hpp:711
GPUDynamicBuffer(GPUDevice &device, String name="", Args &&... args)
Creates a new DynamicBuffer.
Definition GPUBufferObject.hpp:846
~GPUDynamicBuffer()
Definition GPUBufferObject.hpp:850
GPUDynamicBuffer()=default
Creates a new empty DynamicBuffer.
GPUDynamicBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0)
Creates a new DynamicBuffer from an existing GPU buffer.
Definition GPUBufferObject.hpp:839
Definition GPUBufferObject.hpp:562
GPUDynamicBuffer(P &&rawBuffer)
Creates a new DynamicBuffer.
Definition GPUBufferObject.hpp:591
GPUDynamicBuffer(GPUDynamicBuffer &&value) noexcept=default
GPUDynamicBuffer()=default
Creates a new empty DynamicBuffer.
T * get() noexcept
Gets a pointer to the buffer object.
Definition GPUBufferObject.hpp:617
T * operator->() noexcept
Arrow operator overload that will access the members of the GPU buffer data.
Definition GPUBufferObject.hpp:632
GPUDynamicBuffer & operator=(const T &value)
Assigns a new value to the dynamic buffer.
Definition GPUBufferObject.hpp:610
GPUDynamicBuffer(GPUDevice &device, String name="", Args &&... args)
Creates a new DynamicBuffer.
Definition GPUBufferObject.hpp:582
GPUDynamicBuffer & operator=(const GPUDynamicBuffer &value)=default
const T * operator->() const noexcept
Arrow operator overload that will access the members of the GPU buffer data.
Definition GPUBufferObject.hpp:637
GPUDynamicBuffer & operator=(GPUDynamicBuffer &&value) noexcept=default
const T & operator*() const noexcept
Dereferences the GPU buffer data.
Definition GPUBufferObject.hpp:645
T * mData
A pointer to the buffer data mapped on host memory.
Definition GPUBufferObject.hpp:564
T & operator*() noexcept
Dereferences the GPU buffer data.
Definition GPUBufferObject.hpp:641
~GPUDynamicBuffer()
Definition GPUBufferObject.hpp:598
void commit()
Commits changes made to the buffer.
Definition GPUBufferObject.hpp:626
GPUDynamicBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0)
Creates a new DynamicBuffer from an existing GPU buffer.
Definition GPUBufferObject.hpp:573
void update(const T &data)
Updates the buffer data with a new value.
Definition GPUBufferObject.hpp:623
GPUDynamicBuffer(const GPUDynamicBuffer &value)=default
const T * get() const noexcept
Gets a pointer to the buffer object.
Definition GPUBufferObject.hpp:620
Definition GPUImage.hpp:331
Definition GPUBufferObject.hpp:169
GPUIndexBuffer(GPUDevice &device, GPUBufferSize size, IndexType indexType=IndexType::UInt32, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::DeviceLocal, String name="")
Creates a new IndexBuffer.
GPUIndexBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0, IndexType indexType=IndexType::UInt32, GPUBufferSize length=GPUBuffer::whole)
Creates a new IndexBuffer from an existing GPU buffer.
GPUIndexBuffer(std::nullptr_t)
Creates a new empty IndexBuffer.
Definition GPUBufferObject.hpp:197
GPUIndexBuffer & operator=(const GPUIndexBuffer &)=default
Assigns the IndexBuffer by copying another.
~GPUIndexBuffer()
Destroys the IndexBuffer.
GPUIndexBuffer(const GPUIndexBuffer &)=default
Creates a new IndexBuffer by copying another.
IndexType getIndexType() const noexcept
Definition GPUBufferObject.hpp:218
GPUIndexBuffer()=default
Creates a new empty IndexBuffer.
GPUIndexBuffer(GPUBuffer &buffer, const GPUBufferSize offset=0, const IndexType indexType=IndexType::UInt32, const GPUBufferSize length=GPUBuffer::whole)
Definition GPUBufferObject.hpp:184
GPUIndexBuffer & operator=(GPUIndexBuffer &&)=default
Assigns a IndexBuffer by moving another.
GPUIndexBuffer(GPUIndexBuffer &&)=default
Creates a new IndexBuffer by moving another.
IndexType mIndexType
The index type to be used when rendering.
Definition GPUBufferObject.hpp:171
Definition GPUBufferObject.hpp:314
GPUIndirectBuffer(GPUIndirectBuffer &&)=default
Creates a new IndirectBuffer by moving another.
GPUIndirectBuffer(std::nullptr_t)
Creates a new empty IndirectBuffer.
Definition GPUBufferObject.hpp:337
GPUIndirectBuffer & operator=(const GPUIndirectBuffer &)=default
Assigns the IndirectBuffer by copying another.
GPUIndirectBuffer(GPUBuffer &buffer, const GPUBufferSize offset=0, const GPUBufferSize length=GPUBuffer::whole)
Definition GPUBufferObject.hpp:325
GPUIndirectBuffer & operator=(GPUIndirectBuffer &&)=default
Assigns a IndirectBuffer by moving another.
GPUIndirectBuffer(const GPUIndirectBuffer &)=default
Creates a new IndirectBuffer by copying another.
~GPUIndirectBuffer()
Destroys the IndirectBuffer.
GPUIndirectBuffer(GPUDevice &device, GPUBufferSize size, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::DeviceLocal, String name="")
Creates a new IndirectBuffer.
GPUIndirectBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0, GPUBufferSize length=GPUBuffer::whole)
Creates a new IndirectBuffer from an existing GPU buffer.
GPUIndirectBuffer()=default
Creates a new empty IndirectBuffer.
A special buffer type that can be used a staging buffer to upload and download data to the GPU.
Definition GPUBufferObject.hpp:359
void download(GPUCommandBuffer &commandBuffer, GPUImage &srcImage, const GPUImageRegion &srcImageRegion={}, UInt64 dstOffset=0, UInt32 rowStride=0, UInt32 layerStride=0)
Starts a download operation from srcImage to the staging buffer.
GPUStagingBuffer(GPUDevice &device, const GPUImageDescriptor &imageDescriptor, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::HostVisible, String name="")
Creates a new StagingBuffer.
void download(GPUBuffer &srcBuffer, UInt64 srcOffset=0, UInt64 dstOffset=0, UInt64 size=~0u)
Similar to download(CommandBuffer&, Buffer&, UInt64, UInt64, UInt64) but creates a temporary command ...
void upload(GPUBuffer &dstBuffer, UInt64 dstOffset=0, UInt64 srcOffset=0, UInt64 size=~0u)
Similar to upload(CommandBuffer&, Buffer&, UInt64, UInt64, UInt64) but creates a temporary command bu...
GPUStagingBuffer(std::nullptr_t)
Creates a new empty StagingBuffer.
Definition GPUBufferObject.hpp:398
void fill(uint8_t byte=0)
Fills the GPU buffer with bytes.
void upload(GPUCommandBuffer &commandBuffer, GPUBuffer &dstBuffer, UInt64 dstOffset=0, UInt64 srcOffset=0, UInt64 size=~0u)
Starts a upload operation from the staging buffer to dstBuffer.
GPUStagingBuffer(GPUDevice &device, const void *data, GPUBufferSize size, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::HostVisible, String name="")
Creates a new StagingBuffer.
GPUStagingBuffer & operator=(const GPUStagingBuffer &)=default
Assigns the StagingBuffer by copying another.
GPUStagingBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0, GPUBufferSize length=GPUBuffer::whole)
Creates a new StagingBuffer from an existing GPU buffer.
GPUStagingBuffer(const GPUStagingBuffer &)=default
Creates a new StagingBuffer by copying another.
GPUStagingBuffer(GPUBuffer &buffer, const GPUBufferSize offset=0, const GPUBufferSize length=GPUBuffer::whole)
Definition GPUBufferObject.hpp:370
GPUStagingBuffer(GPUStagingBuffer &&)=default
Creates a new StagingBuffer by moving another.
void download(GPUImage &srcImage, const GPUImageRegion &srcImageRegion={}, UInt64 dstOffset=0, UInt32 rowStride=0, UInt32 layerStride=0)
Similar to download(CommandBuffer&, Image&, const ImageRegion&, UInt64, bool, UInt32,...
GPUStagingBuffer()=default
Creates a new empty StagingBuffer.
void download(GPUCommandBuffer &commandBuffer, GPUBuffer &srcBuffer, UInt64 srcOffset=0, UInt64 dstOffset=0, UInt64 size=~0u)
Starts a download operation from srcBuffer to the staging buffer.
void upload(GPUImage &dstImage, const GPUImageRegion &dstRegion={}, UInt64 srcOffset=0, bool generateMips=true, UInt32 rowStride=0, UInt32 layerStride=0)
Similar to upload(CommandBuffer&, Image&, const ImageRegion&, UInt64, bool, UInt32,...
void upload(GPUCommandBuffer &commandBuffer, GPUImage &dstImage, const GPUImageRegion &dstRegion={}, UInt64 srcOffset=0, bool generateMips=true, UInt32 rowStride=0, UInt32 layerStride=0)
Starts a upload operation from the staging buffer to the given image.
GPUStagingBuffer & operator=(GPUStagingBuffer &&)=default
Assigns a StagingBuffer by moving another.
GPUStagingBuffer(GPUDevice &device, GPUBufferSize size, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::HostVisible, String name="")
Creates a new StagingBuffer.
void copy(const void *ptr, UInt64 size)
Copies a the raw bytes from ptr into the GPU staging buffer.
~GPUStagingBuffer()
Destroys the StagingBuffer.
void copy(InputStream stream)
Copies a the raw bytes from stream into the GPU staging buffer.
Definition GPUBufferObject.hpp:268
GPUStorageBuffer & operator=(GPUStorageBuffer &&)=default
Assigns a StorageBuffer by moving another.
GPUStorageBuffer & operator=(const GPUStorageBuffer &)=default
Assigns the StorageBuffer by copying another.
GPUStorageBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0, GPUBufferSize length=GPUBuffer::whole)
Creates a new StorageBuffer from an existing GPU buffer.
~GPUStorageBuffer()
Destroys the StorageBuffer.
GPUStorageBuffer(GPUStorageBuffer &&)=default
Creates a new StorageBuffer by moving another.
GPUStorageBuffer()=default
Creates a new empty StorageBuffer.
GPUStorageBuffer(GPUDevice &device, GPUBufferSize size, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::DeviceLocal, String name="")
Creates a new StorageBuffer.
GPUStorageBuffer(std::nullptr_t)
Creates a new empty StorageBuffer.
Definition GPUBufferObject.hpp:294
GPUStorageBuffer(GPUBuffer &buffer, const GPUBufferSize offset=0, const GPUBufferSize length=GPUBuffer::whole)
Storage buffer resource.
Definition GPUBufferObject.hpp:279
GPUStorageBuffer(const GPUStorageBuffer &)=default
Creates a new StorageBuffer by copying another.
GPUStorageBuffer(const GPUUniformBuffer &uniformBuffer)
Creates a new GPUStorageBuffer by converting from a GPUUniformBuffer.
Definition GPUBufferObject.hpp:221
~GPUUniformBuffer()
Destroys the UniformBuffer.
GPUUniformBuffer(const GPUUniformBuffer &)=default
Creates a new UniformBuffer by copying another.
GPUUniformBuffer & operator=(const GPUUniformBuffer &)=default
Assigns the UniformBuffer by copying another.
GPUUniformBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0, GPUBufferSize length=GPUBuffer::whole)
Creates a new UniformBuffer from an existing GPU buffer.
GPUUniformBuffer(GPUUniformBuffer &&)=default
Creates a new UniformBuffer by moving another.
GPUUniformBuffer(const GPUStorageBuffer &storageBuffer)
Creates a new GPUUniformBuffer by converting from a GPUStorageBuffer.
GPUUniformBuffer(GPUBuffer &buffer, const GPUBufferSize offset=0, const GPUBufferSize length=GPUBuffer::whole)
Uniform buffer (or constant buffer) resource.
Definition GPUBufferObject.hpp:233
GPUUniformBuffer(std::nullptr_t)
Creates a new empty UniformBuffer.
Definition GPUBufferObject.hpp:248
GPUUniformBuffer()=default
Creates a new empty UniformBuffer.
GPUUniformBuffer(GPUDevice &device, GPUBufferSize length, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::DeviceLocal, String name="")
Creates a new UniformBuffer.
GPUUniformBuffer & operator=(GPUUniformBuffer &&)=default
Assigns a UniformBuffer by moving another.
Definition GPUBufferObject.hpp:126
GPUVertexBuffer()=default
Creates a new empty VertexBuffer.
GPUVertexBuffer(const GPUVertexBuffer &)=default
Creates a new VertexBuffer by copying another.
GPUVertexBuffer(GPUBufferPtr buffer, GPUBufferSize offset=0, GPUBufferSize length=GPUBuffer::whole)
Creates a new VertexBuffer from an existing GPU buffer.
GPUVertexBuffer & operator=(GPUVertexBuffer &&)=default
Assigns a VertexBuffer by moving another.
GPUVertexBuffer(GPUVertexBuffer &&)=default
Creates a new VertexBuffer by moving another.
GPUVertexBuffer & operator=(const GPUVertexBuffer &)=default
Assigns the VertexBuffer by copying another.
GPUVertexBuffer(GPUBuffer &buffer, const GPUBufferSize offset=0, const GPUBufferSize length=GPUBuffer::whole)
Definition GPUBufferObject.hpp:137
~GPUVertexBuffer()
Destroys the VertexBuffer.
GPUVertexBuffer(std::nullptr_t)
Creates a new empty VertexBuffer.
Definition GPUBufferObject.hpp:149
GPUVertexBuffer(GPUDevice &device, GPUBufferSize size, const GPUMemoryProperties &memoryProperty=GPUMemoryProperty::DeviceLocal, String name="")
Creates a new VertexBuffer.
A stream that provides read-only stream functionality.
Definition Stream.hpp:210
A memory view is a class which attaches to an chunk of memory and provides a view to it (optionally c...
Definition MemoryView.hpp:62
A memory view is a class which attaches to an chunk of memory and provides a view to it (optionally c...
Definition MemoryView.hpp:439
A template class that automatically manages a uniform buffer pool.
Definition GPUBufferObject.hpp:1059
TGPUBufferPool(GPUDevice &device)
Creates a new TBufferPool object.
Definition GPUBufferObject.hpp:1087
void flush(const GPUBufferSize offset=0, const GPUBufferSize size=GPUBuffer::whole)
Flushes the cached memory data starting at offset with size bytes.
Definition GPUBufferObject.hpp:1115
void reserve(const size_t length)
Reserves space in the pool.
Definition GPUBufferObject.hpp:1092
const size_t baseAllocationSize
The base allocation size used by the pool.
Definition GPUBufferObject.hpp:1079
static constexpr size_t alignment
The alignment to be used for each object in pool.
Definition GPUBufferObject.hpp:1076
void allocateBuffers(const size_t length)
Definition GPUBufferObject.hpp:1140
void invalidate(const GPUBufferSize offset=0, const GPUBufferSize size=GPUBuffer::whole)
Invalidates the cached memory data starting at offset with size bytes.
Definition GPUBufferObject.hpp:1129
size_t mLength
Definition GPUBufferObject.hpp:1082
GPUDevicePtr device
The device to be used when allocating memory.
Definition GPUBufferObject.hpp:1068
T & operator[](const size_t index)
Gets a reference to the Uniform Buffer block stored at index.
Definition GPUBufferObject.hpp:1097
Vector< BufferType > buffers
A vector of allocated buffers.
Definition GPUBufferObject.hpp:1072
B< UInt8 > BufferType
The buffer type.
Definition GPUBufferObject.hpp:1064
Definition Application.hpp:19
std::uint64_t UInt64
Definition DataTypes.hpp:26
auto range()
Returns an iterator that increases it's value from 0 to end by 1 for each step.
Definition Iterator.hpp:350
GPUMemoryData GPUBufferData
A pointer type that represents the buffer raw data.
Definition GPUBuffer.hpp:89
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
GPUMemoryProperty
Flag specifying properties for a memory type.
Definition GPUMemory.hpp:18
@ HostCached
Specifies that memory allocated with this type is cached on the host.
@ HostVisible
Specifies that memory allocated with this type can be mapped for host access.
@ DeviceLocal
Specifies that memory allocated with this type is the most efficient for device access.
auto move(Vector3 position)
Moves a entity to the given position.
Definition Helpers.hpp:22
std::uint8_t UInt8
Definition DataTypes.hpp:17
GPUMemorySize GPUBufferSize
A type that represents a buffer size.
Definition GPUBuffer.hpp:86
MemoryView< T > make_memory_view(T *ptr, size_t size)
Makes a new memory from a raw pointer and length.
Definition MemoryView.hpp:359
StridedMemoryView< T > make_strided_memory_view(T *ptr, size_t size, size_t stride=StridedMemoryView< T >::defaultStride)
Makes a new strided memory from a raw pointer and length.
Definition MemoryView.hpp:768
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
Definition Span.hpp:668
Hardware buffer descriptor structure.
Definition GPUBuffer.hpp:92
Definition GPUImage.hpp:247
Image region structure: Subresource (MIP-map level and array layer range), offset,...
Definition GPUImage.hpp:156
Definition IndexType.hpp:20
@ UInt32
The index buffer is represented as a 32-bit unsigned integer.
Definition IndexType.hpp:26