This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::StructuredBuffer Class

Header:#include <UnigineTextures.h>

StructuredBuffer is a buffer for structures: it represents a uniform array of structures.

StructuredBuffer resource can specified via the following flags:

  • GPU_RESOURCE specifies a resource that can be read and written by the GPU. It also creates a temporary direct staging buffer to copy the data from the main buffer and gets the data by the CPU.
  • IMMUTABLE specifies a resources that can only be read by the GPU. It also creates a temporary direct staging buffer to copy the data from the main buffer and gets the data by the CPU.
  • CPU_RESOURCE specifies a resource that is accessible by both the GPU (read only mode) and the CPU (write only mode). It also creates a temporary direct staging buffer to copy the data from the main buffer and gets the data by the CPU.
  • STAGING specifies a resource that supports direct data transfer from the GPU to CPU.

See Also

  • StructuredBuffer C++ sample provided in the Samples (Samples -> C++ -> Render) section of Unigine SDK Browser.

StructuredBuffer Class

Members


void clear()

Clears smart pointer.

Ptr<StructuredBuffer> create()

Creates a smart pointer to the StructuredBuffer.
Source code (C++)
StructuredBufferPtr input_buffer = StructuredBuffer::create();

void destroy()

Destroys smart pointer.

void unbindCompute(int unit)

Unbinds the StructuredBuffer from the compute shader type.

Arguments

  • int unit - The number of the slot.

int create(int flags, void * data, unsigned int structure_size, unsigned int num_elements)

Creates a StructuredBuffer instance with specified parameters.
Source code (C++)
#define NUMBERS_COUNT 4096 * 8192

// Input data structure
struct InputDataStructure {
	vec4 vector0;
	vec4 vector1;
};

// Source data
InputDataStructure *source_data = new InputDataStructure[NUMBERS_COUNT];

// Create immutable structure buffer (gpu_read-only) and store initial values
StructuredBufferPtr input_buffer = StructuredBuffer::create();
input_buffer->create(StructuredBuffer::IMMUTABLE, source_data, sizeof(InputDataStructure), NUMBERS_COUNT);

Arguments

  • int flags - StructuredBuffer flag.
  • void * data - Pointer to the source data.
  • unsigned int structure_size - The size of the structured buffer.
  • unsigned int num_elements - Number of elements in structured buffer.

Return value

1 if the StructuredBuffer was created successfully; otherwise, 0.

int getGLBufferID()

Returns the Id of buffer.

Return value

An Id of the buffer.

void * getD3D11UnorderedAccessView()

Gets a view for an unordered access resource that specifies the parts of a resource the pipeline can access during rendering.

Return value

A pointer to a D3D11 unordered access view.

int getData(void * data)

Gets the data from StructuredBuffer instance.

Arguments

  • void * data - A pointer to the data.

Return value

1 if StructuredBuffer data was returned; otherwise, 0.

void bindFragment(int unit)

Binds the StructuredBuffer to the fragment shader type.

Arguments

  • int unit - The number of the slot.

void bindCompute(int unit)

Binds the StructuredBuffer to the compute shader type.

Arguments

  • int unit - The number of the slot.

void unbindVertex(int unit)

Unbinds the StructuredBuffer from the vertex shader type.

Arguments

  • int unit - The number of the slot.

void bindVertex(int unit)

Binds the StructuredBuffer to the vertex shader type.

Arguments

  • int unit - The number of the slot.

void * getD3D11ShaderResourceView()

Gets a shader-resource view that specifies the subresources a shader can access during rendering.

Return value

A pointer to D3D11 shader resource view.

void unbindFragment(int unit)

Unbinds the StructuredBuffer from the fragment shader type.

Arguments

  • int unit - The number of the slot.

int GPU_RESOURCE

Description

GPU read / write + copy staging buffer.

int IMMUTABLE

Description

GPU read-only + copy staging buffer.

int CPU_RESOURCE

Description

GPU read-only, CPU write-only + copy staging buffer.

int STAGING

Description

GPU no access + CPU read-only + direct staging buffer.
Last update: 2017-07-03
Build: ()