ngfx::Buffer

More...

#include <Buffer.h>

Inherited by ngfx::D3DBuffer, ngfx::MTLBuffer, ngfx::VKBuffer

Public Functions

Name
Buffer * create(GraphicsContext * ctx, const void * data, uint32_t size, BufferUsageFlags usageFlags)
template <typename T >
Buffer *
create(GraphicsContext * ctx, const std::vector< T > & v, BufferUsageFlags usageFlags)
virtual ~Buffer()
virtual void * map() =0
virtual void unmap() =0
virtual void upload(const void * data, uint32_t size, uint32_t offset =0) =0
virtual void download(void * data, uint32_t size, uint32_t offset =0) =0

Detailed Description

class ngfx::Buffer;

This class defines the interface for a graphics buffer. Each backend is responsible for implementing this interface via a subclass. The same buffer object can support multiple usage scenarios, including storing uniform data, vertex buffer data, index buffer data, etc. In addition, on shared memory architectures, it supports shared CPU/GPU access.

Public Functions Documentation

function create

static Buffer * create(
    GraphicsContext * ctx,
    const void * data,
    uint32_t size,
    BufferUsageFlags usageFlags
)

Parameters:

  • ctx The graphics context
  • data The buffer data
  • size The size of input data (in bytes)
  • usageFlags The buffer usage flags

Create a graphics buffer

function create

template <typename T >
static inline Buffer * create(
    GraphicsContext * ctx,
    const std::vector< T > & v,
    BufferUsageFlags usageFlags
)

function ~Buffer

inline virtual ~Buffer()

Destroy the buffer

function map

virtual void * map() =0

Reimplemented by: ngfx::MTLBuffer::map, ngfx::VKBuffer::map, ngfx::D3DBuffer::map

Map the buffer contents for CPU read/write access

function unmap

virtual void unmap() =0

Reimplemented by: ngfx::MTLBuffer::unmap, ngfx::VKBuffer::unmap, ngfx::D3DBuffer::unmap

Unmap the buffer

function upload

virtual void upload(
    const void * data,
    uint32_t size,
    uint32_t offset =0
) =0

Parameters:

  • data The buffer data
  • size The size of the data (in bytes)
  • offset The destination offset (in bytes)

Reimplemented by: ngfx::MTLBuffer::upload, ngfx::VKBuffer::upload, ngfx::D3DBuffer::upload

Upload the CPU data to the GPU buffer

function download

virtual void download(
    void * data,
    uint32_t size,
    uint32_t offset =0
) =0

Parameters:

  • data The destination address
  • size The size of the data to download (in bytes)
  • offset The destination offset (in bytes)

Reimplemented by: ngfx::MTLBuffer::download, ngfx::VKBuffer::download, ngfx::D3DBuffer::download

Download the GPU data to CPU-accessible memory


Updated on 3 April 2021 at 20:21:51 PDT