Nameless Engine
Loading...
Searching...
No Matches
UploadBuffer.h
1#pragma once
2
3// Standard.
4#include <memory>
5#include <cstring>
6
7namespace ne {
8 class GpuResource;
9
15 public:
24 std::unique_ptr<GpuResource> pGpuResourceToUse, size_t iElementSizeInBytes, size_t iElementCount);
25
27
28 UploadBuffer() = delete;
29 UploadBuffer(UploadBuffer&) = delete;
30 UploadBuffer& operator=(UploadBuffer&) = delete;
31
39 inline void copyDataToElement(size_t iElementIndex, const void* pData, size_t iDataSize) {
40 std::memcpy(&pMappedResourceData[iElementIndex * iElementSizeInBytes], pData, iDataSize);
41 }
42
48 size_t getElementCount() const;
49
55 size_t getElementSizeInBytes() const;
56
65
66 private:
72 std::unique_ptr<GpuResource> pGpuResource;
73
80 unsigned char* pMappedResourceData = nullptr;
81
84
86 size_t iElementCount = 0;
87 };
88} // namespace ne
Definition: GpuResource.h:16
Definition: UploadBuffer.h:14
void copyDataToElement(size_t iElementIndex, const void *pData, size_t iDataSize)
Definition: UploadBuffer.h:39
std::unique_ptr< GpuResource > pGpuResource
Definition: UploadBuffer.h:72
size_t getElementSizeInBytes() const
Definition: UploadBuffer.cpp:74
unsigned char * pMappedResourceData
Definition: UploadBuffer.h:80
size_t getElementCount() const
Definition: UploadBuffer.cpp:72
size_t iElementSizeInBytes
Definition: UploadBuffer.h:83
size_t iElementCount
Definition: UploadBuffer.h:86
GpuResource * getInternalResource() const
Definition: UploadBuffer.cpp:113