API Documentation
Public Types | Public Member Functions | List of all members
nkGraphics::ShaderPassMemorySlot Class Reference

A memory slot that fits into a ConstantBuffer. The slot fills entries within the buffer. More...

Inheritance diagram for nkGraphics::ShaderPassMemorySlot:
nkGraphics::ShaderMemorySlot nkExport::Exportable

Public Types

enum  DATA_TYPE {
  DATA_TYPE::UNKNOWN = 0, DATA_TYPE::VECTOR, DATA_TYPE::MATRIX, DATA_TYPE::CAM_CORNERS_WORLD,
  DATA_TYPE::CAM_CORNERS_VIEW, DATA_TYPE::TARGET_SIZE, DATA_TYPE::PROJECTION_PARAMS, DATA_TYPE::TEXTURE_SIZE,
  DATA_TYPE::VIEW_MATRIX, DATA_TYPE::VIEW_MATRIX_INV, DATA_TYPE::PROJ_MATRIX, DATA_TYPE::PROJ_MATRIX_INV,
  DATA_TYPE::CAM_POSITION, DATA_TYPE::CAM_DIRECTION_WORLD, DATA_TYPE::TIME, DATA_TYPE::CUSTOM
}
 

Public Member Functions

 ShaderPassMemorySlot (System *system) noexcept
 
virtual ~ShaderPassMemorySlot ()
 
void * getData () const
 
virtual unsigned int getDataSize () const
 
virtual nkMemory::StringView getDataTypeAsString () const override
 
DATA_TYPE getType () const
 
nkMaths::VectorgetDataAsVector () const
 
nkMaths::MatrixgetDataAsMatrix () const
 
void setFromVector (const nkMaths::Vector &data)
 
void setFromMatrix (const nkMaths::Matrix &data)
 
void setAsCamCornersWorld (Camera *forcedCamera=nullptr)
 
void setAsCamCornersView (Camera *forcedCamera=nullptr)
 
void setAsTargetSize ()
 
void setAsProjectionParameters (Camera *forcedCamera=nullptr)
 
void setAsViewMatrix (Camera *forcedCamera=nullptr)
 
void setAsViewMatrixInv (Camera *forcedCamera=nullptr)
 
void setAsProjectionMatrix (Camera *forcedCamera=nullptr)
 
void setAsProjectionMatrixInv (Camera *forcedCamera=nullptr)
 
void setAsCameraPosition (Camera *forcedCamera=nullptr)
 
void setAsCameraDirectionWorld (Camera *forcedCamera=nullptr)
 
void setAsTextureSize (Texture *tex)
 
void setAsTime (unsigned int modulo)
 
void setAsCustom (nkMemory::UniquePtr< ShaderPassCustomSlot > slot)
 
virtual void exportClassToTree (nkExport::Node *rootNode) override
 
virtual void importClassFromTree (nkExport::Node *rootNode) override
 
- Public Member Functions inherited from nkGraphics::ShaderMemorySlot
 ShaderMemorySlot () noexcept
 
virtual ~ShaderMemorySlot ()
 
nkMemory::StringView getSlotType () const
 
- Public Member Functions inherited from nkExport::Exportable
 Exportable () noexcept
 
virtual ~Exportable ()
 

Detailed Description

A memory slot that fits into a ConstantBuffer. The slot fills entries within the buffer.

This is done per pass. This means that these slots are made to be called before a full pass rendering is done. It is opposed to the ShaderInstanceMemorySlot, which is called once per renderable during a pass.

Member Enumeration Documentation

◆ DATA_TYPE

Available filling type for the slots.

Enumerator
UNKNOWN 

Unknown place holder.

VECTOR 

Writes a vector (float4).

MATRIX 

Writes a matrix (float4x4).

CAM_CORNERS_WORLD 

Writes the cam corners direction in world space (float4 [4]).

CAM_CORNERS_VIEW 

Writes the cam corners direction in view space (float4 [4]).

TARGET_SIZE 

Writes the active render target size (int4).

PROJECTION_PARAMS 

Writes the projection parameters (float4).

TEXTURE_SIZE 

Writes a given texture's size (int4).

VIEW_MATRIX 

Writes the active view matrix (float4x4).

VIEW_MATRIX_INV 

Writes the active inverse view matrix (float4x4).

PROJ_MATRIX 

Writes the active projection matrix (float4x4).

PROJ_MATRIX_INV 

Writes the active inverse projection matrix (float4x4).

CAM_POSITION 

Writes the active camera position (float4).

CAM_DIRECTION_WORLD 

Writes the active camera direction (float4).

TIME 

Writes information about time (float4).

CUSTOM 

Uses a custom slot made by external code.

Constructor & Destructor Documentation

◆ ShaderPassMemorySlot()

nkGraphics::ShaderPassMemorySlot::ShaderPassMemorySlot ( System system)
noexcept

Constructor. See ConstantBuffer::addPassMemorySlot().

Parameters
systemThe system the resource should live in.

◆ ~ShaderPassMemorySlot()

virtual nkGraphics::ShaderPassMemorySlot::~ShaderPassMemorySlot ( )
virtual

Destructor.

Member Function Documentation

◆ getData()

void* nkGraphics::ShaderPassMemorySlot::getData ( ) const
Returns
The data allocated for the tracking.

◆ getDataSize()

virtual unsigned int nkGraphics::ShaderPassMemorySlot::getDataSize ( ) const
virtual
Returns
The written size, in bytes.

◆ getDataTypeAsString()

virtual nkMemory::StringView nkGraphics::ShaderPassMemorySlot::getDataTypeAsString ( ) const
overridevirtual
Returns
The slot data type, already translated as a string.

Implements nkGraphics::ShaderMemorySlot.

◆ getType()

DATA_TYPE nkGraphics::ShaderPassMemorySlot::getType ( ) const
Returns
The type of slot.

◆ getDataAsVector()

nkMaths::Vector* nkGraphics::ShaderPassMemorySlot::getDataAsVector ( ) const
Returns
The data already casted as a vector. To be used when the slot type is DATA_TYPE::VECTOR.

◆ getDataAsMatrix()

nkMaths::Matrix* nkGraphics::ShaderPassMemorySlot::getDataAsMatrix ( ) const
Returns
The data already casted as a matrix. To be used when the slot type is DATA_TYPE::MATRIX.

◆ setFromVector()

void nkGraphics::ShaderPassMemorySlot::setFromVector ( const nkMaths::Vector data)

Changes the slot to fill a vector. In hlsl, can be received in a float4.

Parameters
dataThe vector to feed.

◆ setFromMatrix()

void nkGraphics::ShaderPassMemorySlot::setFromMatrix ( const nkMaths::Matrix data)

Changes the slot to fill a matrix. In hlsl, can be received in a float4x4.

Parameters
dataThe matrix to feed.

◆ setAsCamCornersWorld()

void nkGraphics::ShaderPassMemorySlot::setAsCamCornersWorld ( Camera forcedCamera = nullptr)

Changes the slot to fill the camera corners directions, in world space. The directions are non normalized and goes from the near to the far. In hlsl, can be received in a float4 [4].

Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsCamCornersView()

void nkGraphics::ShaderPassMemorySlot::setAsCamCornersView ( Camera forcedCamera = nullptr)

Changes the slot to fill the camera corners directions, in view space. The directions are Z normalized, which means the Z component will be 1.0, and the other components will be expressed relative to that. In hlsl, can be received in a float4 [4].

Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsTargetSize()

void nkGraphics::ShaderPassMemorySlot::setAsTargetSize ( )

Changes the slot to fill the active render target size, in pixels. In hlsl, can be received in a int4.

cbuffer MyConstantBuffer : register(b0)
{
  int4 targetSize ;
}

#define TARGET_WIDTH targetSize.x
#define TARGET_HEIGHT targetSize.y
#define TARGET_DEPTH targetSize.z
#define TARGET_MIPS targetSize.w

◆ setAsProjectionParameters()

void nkGraphics::ShaderPassMemorySlot::setAsProjectionParameters ( Camera forcedCamera = nullptr)

Changes the slot to fill the projection parameters of a camera. In hlsl, can be received in a float4.

cbuffer MyConstantBuffer : register(b0)
{
  float4 projectionParams ;
}

#define PROJ_A projectionParams.x
#define PROJ_B projectionParams.y
#define PROJ_NEAR projectionParams.z
#define PROJ_FAR projectionParams.w

The projection parameter A corresponds to far / (far - near).
The projection parameter B corresponds to (-far * near) / (far - near).
Together, they allow to reconstruct the linear depth from the standard written depth, using : PROJ_B / (depth - PROJ_A).

Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsViewMatrix()

void nkGraphics::ShaderPassMemorySlot::setAsViewMatrix ( Camera forcedCamera = nullptr)

Changes the slot to fill the view matrix of a camera. In hlsl, can be received in a float4x4.

The view and projection matrix are provided as row-major, meaning they can be used like :

float4x4 mvp = mul(projection, mul(view, world)) ;
Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsViewMatrixInv()

void nkGraphics::ShaderPassMemorySlot::setAsViewMatrixInv ( Camera forcedCamera = nullptr)

Changes the slot to fill the inverse view matrix of a camera. in hlsl, can be received in a float4x4.

Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsProjectionMatrix()

void nkGraphics::ShaderPassMemorySlot::setAsProjectionMatrix ( Camera forcedCamera = nullptr)

Changes the slot to fill the projection matrix of a camera. In hlsl, can be received in a float4x4.

The view and projection matrix are provided as row-major, meaning they can be used like :

float4x4 mvp = mul(projection, mul(view, world)) ;
Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsProjectionMatrixInv()

void nkGraphics::ShaderPassMemorySlot::setAsProjectionMatrixInv ( Camera forcedCamera = nullptr)

Changes the slot to fill the inverse projection matrix of a camera. In hlsl, can be received in a float4x4.

Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsCameraPosition()

void nkGraphics::ShaderPassMemorySlot::setAsCameraPosition ( Camera forcedCamera = nullptr)

Changes the slot to fill the position of a camera, in world space. In hlsl, can be received in a float4.

Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsCameraDirectionWorld()

void nkGraphics::ShaderPassMemorySlot::setAsCameraDirectionWorld ( Camera forcedCamera = nullptr)

Changes the slot to fill the direction of the camera in world space. In hlsl, can be received in a float4.

Parameters
forcedCameraThe camera to retrieve information from. If left nullptr, will fetch the active camera.

◆ setAsTextureSize()

void nkGraphics::ShaderPassMemorySlot::setAsTextureSize ( Texture tex)

Changes the slot to fill a texture size, in pixels. In hlsl, can be received in a int4.

cbuffer MyConstantBuffer : register(b0)
{
  int4 texSize ;
}

#define TEX_WIDTH texSize.x
#define TEX_HEIGHT texSize.y
#define TEX_DEPTH texSize.z
#define TEX_MIPS texSize.w

◆ setAsTime()

void nkGraphics::ShaderPassMemorySlot::setAsTime ( unsigned int  modulo)

Changes the slot to fill time information. In hlsl, can be received in a float4.

cbuffer MyConstantBuffer : register(b0)
{
  float4 timeInfo ;
}

#define TIME_MODULO_VAL timeInfo.x
#define TIME timeInfo.y
#define TIME_DELTA timeInfo.z
#define TIME_UNUSED timeInfo.w
Parameters
moduloThe modulo looping time of the timer.

◆ setAsCustom()

void nkGraphics::ShaderPassMemorySlot::setAsCustom ( nkMemory::UniquePtr< ShaderPassCustomSlot slot)

Changes the slot to request the data to be filled by a custom pass.

Parameters
slotThe slot to delegate to.

◆ exportClassToTree()

virtual void nkGraphics::ShaderPassMemorySlot::exportClassToTree ( nkExport::Node rootNode)
overridevirtual

Exports an item into a tree describing its structure and its data.

Parameters
rootNodeThe node into which the object has to write its related information.

Reimplemented from nkGraphics::ShaderMemorySlot.

◆ importClassFromTree()

virtual void nkGraphics::ShaderPassMemorySlot::importClassFromTree ( nkExport::Node rootNode)
overridevirtual

Imports information from a tree which is supposed to describe its structure and data.

Parameters
rootNodeThe root node of the tree holding the information.

Implements nkExport::Exportable.


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