SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::IDeviceMemory Class Referenceabstract

Describes a chunk of memory on the GPU. More...

#include <DeviceMemory.h>

Inheritance diagram for spark::render::IDeviceMemory:
spark::render::IBuffer spark::render::IImage spark::render::IIndexBuffer spark::render::IVertexBuffer spark::render::vk::IVulkanBuffer spark::render::vk::IVulkanImage spark::render::vk::IVulkanIndexBuffer spark::render::vk::IVulkanVertexBuffer spark::render::vk::IVulkanIndexBuffer spark::render::vk::IVulkanVertexBuffer spark::render::vk::VulkanBuffer spark::render::vk::VulkanImage spark::render::vk::VulkanIndexBuffer spark::render::vk::VulkanVertexBuffer spark::render::vk::VulkanIndexBuffer spark::render::vk::VulkanVertexBuffer spark::render::vk::VulkanIndexBuffer spark::render::vk::VulkanVertexBuffer

Public Member Functions

virtual unsigned int elements () const noexcept=0
 Get the number of sub-resources in the memory chunk.
 
virtual std::size_t size () const noexcept=0
 Gets the size (in bytes) of the memory chunk.
 
virtual std::size_t elementSize () const noexcept=0
 Gets the size (in bytes) of one element in the memory chunk. If there is only one element, this equals the result of IDeviceMemory::size().
 
virtual std::size_t elementAlignment () const =0
 Gets the alignment of one element in the memory chunk.
 
virtual std::size_t alignedElementSize () const noexcept=0
 Gets the real size (in bytes) of the memory chunk.
 
virtual bool writable () const noexcept=0
 Checks if the resource can be bound to a read/write descriptor.
 

Detailed Description

Describes a chunk of memory on the GPU.

Member Function Documentation

◆ alignedElementSize()

virtual std::size_t spark::render::IDeviceMemory::alignedElementSize ( ) const
nodiscardpure virtualnoexcept

Gets the real size (in bytes) of the memory chunk.

Returns
The real size of the memory chunk in bytes.
Note
For images, this method will return a value that equals the result of IDeviceMemory::size(), aligned by IDeviceMemory::elementAlignment().

Implemented in spark::render::vk::VulkanBuffer, and spark::render::vk::VulkanImage.

◆ elementAlignment()

virtual std::size_t spark::render::IDeviceMemory::elementAlignment ( ) const
nodiscardpure virtual

Gets the alignment of one element in the memory chunk.

Returns
The alignment of one element in the memory chunk.

Implemented in spark::render::vk::VulkanBuffer, and spark::render::vk::VulkanImage.

◆ elements()

virtual unsigned int spark::render::IDeviceMemory::elements ( ) const
nodiscardpure virtualnoexcept

Get the number of sub-resources in the memory chunk.

Returns
The number of array elements in the memory chunk.
Note
For buffers, this equals the number of array elements. For images, this equals the product of layers, levels and planes. This number represents the number of states, that can be obtained by calling the IDeviceMemory::state() method.

Implemented in spark::render::vk::VulkanBuffer, and spark::render::vk::VulkanImage.

◆ elementSize()

virtual std::size_t spark::render::IDeviceMemory::elementSize ( ) const
nodiscardpure virtualnoexcept

Gets the size (in bytes) of one element in the memory chunk. If there is only one element, this equals the result of IDeviceMemory::size().

Returns
The size of one element in the memory chunk.
Note
For images, this method will return a value that equals the result of IDeviceMemory::size().

Implemented in spark::render::vk::VulkanBuffer, and spark::render::vk::VulkanImage.

◆ size()

virtual std::size_t spark::render::IDeviceMemory::size ( ) const
nodiscardpure virtualnoexcept

Gets the size (in bytes) of the memory chunk.

Returns
The size of the memory chunk in bytes.
Note
The size of the device memory block depends on different factors. The actual used memory of one element can be obtained by calling by the IDeviceMemory::elementSize(). For different reasons, though, elements may be required to be aligned to a certain size. The size of one aligned element is returned by IDeviceMemory::alignedElementSize(). The size of the memory block, the elements get aligned to is returned by IDeviceMemory::elementAlignment().

Implemented in spark::render::IImage, spark::render::vk::VulkanBuffer, and spark::render::vk::VulkanImage.

◆ writable()

virtual bool spark::render::IDeviceMemory::writable ( ) const
nodiscardpure virtualnoexcept

Checks if the resource can be bound to a read/write descriptor.

Returns
true if the resource can be bound to a read/write descriptor, false otherwise.
Note
If the resource is not writable, attempting to bind it to a writable descriptor will result in an exception.

Implemented in spark::render::vk::VulkanBuffer, and spark::render::vk::VulkanImage.