This page has been translated automatically.
Video Tutorials
Interface
Essentials
Advanced
How To
Basics
Rendering
Professional (SIM)
UnigineEditor
Interface Overview
Assets Workflow
Version Control
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Lighting
Sandworm
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Built-in Node Types
Nodes
Objects
Effects
Decals
Light Sources
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
Materials and Shaders
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

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:

  • USAGE_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.
  • USAGE_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.
  • USAGE_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.
  • USAGE_STAGING specifies a resource that supports direct data transfer from the GPU to CPU.
  • USAGE_SHARED specifies that a resource is accessible by an external graphics API.

See Also#

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

StructuredBuffer Class

Members

void setDebugName ( const char * name ) #

Sets a new friendly name of the structured buffer used for GPU debugging (RenderDoc, NVIDIA Nsight). It can be used to help you determine if the corresponding object interface pointer caused the leak. Memory leaks are reported by the debug software layer by outputting a list of object interface pointers along with their friendly names.

Arguments

  • const char * name - The friendly debug name.

const char * getDebugName() const#

Returns the current friendly name of the structured buffer used for GPU debugging (RenderDoc, NVIDIA Nsight). It can be used to help you determine if the corresponding object interface pointer caused the leak. Memory leaks are reported by the debug software layer by outputting a list of object interface pointers along with their friendly names.

Return value

Current friendly debug name.

int getNumElements() const#

Returns the current number of elements in the structured buffer.

Return value

Current number of elements in the structured buffer.

bool isUsageShared() const#

Returns the current value indicating if the resource has the USAGE_SHARED flag enabled.

Return value

true if the USAGE_SHARED flag is enabled; otherwise false.

bool isUsageStaging() const#

Returns the current value indicating if the resource has the USAGE_STAGING flag enabled.

Return value

true if the USAGE_STAGING flag is enabled; otherwise false.

bool isUsageCPUResource() const#

Returns the current value indicating if the resource has the USAGE_CPU_RESOURCE flag enabled.

Return value

true if the USAGE_CPU_RESOURCE flag is enabled; otherwise false.

bool isUsageImmutable() const#

Returns the current value indicating if the resource has the USAGE_IMMUTABLE flag enabled.

Return value

true if the USAGE_IMMUTABLE flag is enabled; otherwise false.

bool isUsageGPUResource() const#

Returns the current value indicating if the resource has the USAGE_GPU_RESOURCE flag enabled.

Return value

true if the USAGE_GPU_RESOURCE flag is enabled; otherwise false.

static StructuredBufferPtr create ( ) #

Constructor. Creates a new structured buffer.
Source code (C++)
StructuredBufferPtr input_buffer = StructuredBuffer::create();

void * getD3D11ShaderResourceView ( ) const#

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 * getD3D11UnorderedAccessView ( ) const#

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 clear ( ) #

Clears smart pointer.

int create ( int flags, const 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.
  • const 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 the structured buffer.

Return value

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

int create ( int flags, unsigned int structure_size, unsigned int num_elements ) #

Constructor. Creates a new structured buffer with the specified parameters.

Arguments

  • int flags - StructuredBuffer flag.
  • unsigned int structure_size - The size of the structured buffer.
  • unsigned int num_elements - Number of elements in the structured buffer.

Return value

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

void destroy ( ) #

Destroys smart pointer.

void clearBuffer ( ) #

Clears the structured buffer.

void copy ( const Ptr<StructuredBuffer> & src ) #

Copies the data from the specified source structured buffer.

Arguments

  • const Ptr<StructuredBuffer> & src - Source structured buffer to copy data from.

Ptr<ResourceExternalMemory> getResourceExternalMemory ( ) const#

Returns the pointer to the resource in video memory. If the USAGE_SHARED flag is not enabled for the resource, this method returns nullptr.

Return value

The pointer to the resource in video memory. If the USAGE_SHARED flag is not enabled for the resource, this method returns nullptr.
Last update: 2024-08-16
Build: ()