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 Reference
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
Rendering-Related Classes
VR-Related Classes
Content Creation
Content Optimization
Materials
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine::CPUShaderCallable Class

Header: #include <UnigineThread.h>

CPUShaderCallable is a template class that provides a simplified way to execute custom multithreaded logic using the CPUShader class.

Typically, to use a CPUShader, you need to inherit from the base CPUShader class and manually implement the process() method. However, CPUShaderCallable allows you to pass in the processing logic and optional cleanup logic directly as function objects without writing a custom class or managing inheritance.

It also supports an internal shared state that is accessible from all threads and can be cleaned up automatically after execution.

Template Parameters:

  • State - user-defined type that stores shared state between threads.
  • Process - function called per thread.
    Signature: void(int thread_num, int num_threads)
  • Destroy - optional function called once after all threads are finished.
    Signature: void(State state)

CPUShaderCallable Class

Members


CPUShaderCallable ( Process func_process_, Destroy func_destroy_ ) #

Creates a new shader task with execution and destruction logic.

Arguments

  • Process func_process_ - Function executed on each thread.
  • Destroy func_destroy_ - Function executed once after all threads are done.

void process ( int thread_num, int num_threads ) #

Overridden from CPUShader. Called once per thread during execution. Invokes the provided processing function.

Arguments

  • int thread_num - Index of the current thread.
  • int num_threads - Total number of threads assigned to this task.

The information on this page is valid for UNIGINE 2.20 SDK.

Last update: 2025-07-10
Build: ()