-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored old Buffer into new DataBuffer class
- Loading branch information
Showing
12 changed files
with
114 additions
and
113 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include <vulkan/vulkan.h> | ||
|
||
class Context; | ||
|
||
/* | ||
* The data buffer class is used to store Vulkan data buffers, namely the uniform buffer and the vertex/index buffer. It | ||
* is unrelated to Vulkan image buffers used for the depth buffer for example. Note that is good for performance to keep | ||
* Vulkan buffers mapped until destruction. This class offers functionality to do so, but doesn't enforce the principle. | ||
*/ | ||
class DataBuffer final | ||
{ | ||
public: | ||
DataBuffer(const Context* context, | ||
VkBufferUsageFlags bufferUsageFlags, | ||
VkMemoryPropertyFlags memoryProperties, | ||
VkDeviceSize size); | ||
~DataBuffer(); | ||
|
||
bool copyTo(const DataBuffer& target, VkCommandBuffer commandBuffer, VkQueue queue) const; | ||
void* map() const; | ||
void unmap() const; | ||
|
||
bool isValid() const; | ||
VkBuffer getBuffer() const; | ||
|
||
private: | ||
bool valid = true; | ||
|
||
const Context* context = nullptr; | ||
VkBuffer buffer = nullptr; | ||
VkDeviceMemory deviceMemory = nullptr; | ||
VkDeviceSize size = 0u; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.