VPP  0.8
A high-level modern C++ API for Vulkan
vpp::Pointer< ScalarT > Class Template Reference

Shader (GPU-side) data type for pointers to workgroup and global scoped variables. More...

#include <vppLangScalarTypes.hpp>

Public Member Functions

ScalarT Load () const
 Reads the target variable. More...
 
void Store (const ScalarT &value) const
 Stores specified value to the target variable. More...
 
ScalarT Exchange (const ScalarT &value) const
 Atomically exchanges specified value with the target variable. Returns previous value. More...
 
ScalarT CompareExchange (const ScalarT &newValue, const ScalarT &oldValue) const
 Atomically exchanges specified value with the target variable, but only if current value is equal to the oldValue parameter. Returns previous value. More...
 
ScalarT Increment () const
 Atomically increments the target variable. More...
 
ScalarT Decrement () const
 Atomically decrements the target variable. More...
 
ScalarT Add (const ScalarT &value) const
 Atomically adds specified value to the target variable. Returns previous value. More...
 
ScalarT Sub (const ScalarT &value) const
 Atomically subtracts specified value from the target variable. Returns previous value. More...
 
ScalarT Min (const ScalarT &value) const
 Atomically computes minimum of specified value and the target variable and stores it to the target variable. Returns previous value. More...
 
ScalarT Max (const ScalarT &value) const
 Atomically computes maximum of specified value and the target variable and stores it to the target variable. Returns previous value. More...
 
ScalarT And (const ScalarT &value) const
 Atomically computes bitwise AND of specified value and the target variable and stores it to the target variable. Returns previous value. More...
 
ScalarT Or (const ScalarT &value) const
 Atomically computes bitwise OR of specified value and the target variable and stores it to the target variable. Returns previous value. More...
 
ScalarT Xor (const ScalarT &value) const
 Atomically computes bitwise XOR of specified value and the target variable and stores it to the target variable. Returns previous value. More...
 

Detailed Description

template<class ScalarT>
class vpp::Pointer< ScalarT >

Shader (GPU-side) data type for pointers to workgroup and global scoped variables.

Use this type inside shader code as a counterpart of CPU-side pointer type.

This is a r-value type. You do not construct the object directly, but rather use the & operator to take a pointer to specified variable of simple type or array element.

The & operator can be applied to workgroup-scoped variable or element of array (with arbitrary number of dimensions). The type pointed to must be an integer or floating point scalar. Some operations are restricted to integers.

There can be also pointers to scalar image elements, constructed by ioImage::GetPointer method instead of & operator.

Pointers can also be taken for uniform buffer variables and array elements.

Pointers are used mainly for atomic operations. This allows implementation of many lock-free parallel algorithms.

Pointers in the Vulkan compute model are abstract and cannot be subject to any arithmetic. A pointer variable always points to the same object and can be only dereferenced.

Example of using:

WArray< UInt > workArea ( 256 );
// ...
const UInt prevValue = ( & ( workArea [ index ] ) ).Increment();

Member Function Documentation

◆ Add()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Add ( const ScalarT &  value) const

Atomically adds specified value to the target variable. Returns previous value.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ And()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::And ( const ScalarT &  value) const

Atomically computes bitwise AND of specified value and the target variable and stores it to the target variable. Returns previous value.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ CompareExchange()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::CompareExchange ( const ScalarT &  newValue,
const ScalarT &  oldValue 
) const

Atomically exchanges specified value with the target variable, but only if current value is equal to the oldValue parameter. Returns previous value.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ Decrement()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Decrement ( ) const

Atomically decrements the target variable.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ Exchange()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Exchange ( const ScalarT &  value) const

Atomically exchanges specified value with the target variable. Returns previous value.

Types allowed: Int, UInt, Float. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ Increment()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Increment ( ) const

Atomically increments the target variable.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ Load()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Load ( ) const

Reads the target variable.

Types allowed: Int, UInt, Float.

◆ Max()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Max ( const ScalarT &  value) const

Atomically computes maximum of specified value and the target variable and stores it to the target variable. Returns previous value.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ Min()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Min ( const ScalarT &  value) const

Atomically computes minimum of specified value and the target variable and stores it to the target variable. Returns previous value.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ Or()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Or ( const ScalarT &  value) const

Atomically computes bitwise OR of specified value and the target variable and stores it to the target variable. Returns previous value.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().

◆ Store()

template<class ScalarT>
void vpp::Pointer< ScalarT >::Store ( const ScalarT &  value) const

Stores specified value to the target variable.

Types allowed: Int, UInt, Float.

◆ Sub()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Sub ( const ScalarT &  value) const

Atomically subtracts specified value from the target variable. Returns previous value.

Restricted to Int or UInt type.

◆ Xor()

template<class ScalarT>
ScalarT vpp::Pointer< ScalarT >::Xor ( const ScalarT &  value) const

Atomically computes bitwise XOR of specified value and the target variable and stores it to the target variable. Returns previous value.

Restricted to Int or UInt type. Also available for Int64 and UInt64 if fShaderBufferInt64Atomics and/or fShaderSharedInt64Atomics extension is enabled by calling to DeviceFeatures::enableIfSupported().


The documentation for this class was generated from the following file: