OGRE-Next  4.0.0unstable
Object-Oriented Graphics Rendering Engine
Ogre::VulkanRootLayout Class Referencefinal

#include <OgreVulkanRootLayout.h>

+ Inheritance diagram for Ogre::VulkanRootLayout:

Public Member Functions

 VulkanRootLayout (VulkanGpuProgramManager *programManager)
 
 ~VulkanRootLayout ()
 
void bind (VulkanDevice *device, VulkanVaoManager *vaoManager, const VulkanGlobalBindingTable &table)
 Takes an emulated D3D11/Metal-style table and binds it according to this layout's rules. More...
 
void copyFrom (const RootLayout &rootLayout, bool bIncludeArrayBindings=true)
 Copies all our parameters from 'other' Does NOT call validate() More...
 
void copyTo (RootLayout &outRootLayout, bool bIncludeArrayBindings)
 Performs outRootLayout.copyFrom( this ) This function is necessary because RootLayout is a protected base class. More...
 
VkPipelineLayout createVulkanHandles ()
 Creates most of our Vulkan handles required to build a PSO. More...
 
void dump (String &outJson) const
 Dumps the current RootLayout to a JSON string. More...
 
bool findBindingIndex (const uint32 setIdx, const uint32 targetBindingIdx, DescBindingTypes::DescBindingTypes &outType, size_t &outRelativeSlotIndex) const
 O( N ) search to find DescBindingRange via its flattened vulkan binding idx (i.e. More...
 
bool findParamsBuffer (uint32 shaderStage, size_t &outSetIdx, size_t &outBindingIdx) const
 Retrieves the set and binding idx of the params buffer. More...
 
void generateRootLayoutMacros (uint32 shaderStage, ShaderSyntax shaderType, String &inOutString) const
 Generates all the macros for compiling shaders, based on our layout. More...
 
const DescBindingRangegetDescBindingRanges (size_t setIdx) const
 
const DescBindingRangegetDescBindingRanges (size_t setIdx) const
 
bool operator< (const VulkanRootLayout &other) const
 
void parseRootLayout (const char *rootLayout, const bool bCompute, const String &filename)
 Parses a root layout definition from a JSON string The JSON string: More...
 
void validateArrayBindings (const RootLayout &groundTruth, const String &filename) const
 Validates that the array bindings in groundTruth.mArrayRanges are included in this->mArrayRanges. More...
 

Static Public Member Functions

static VulkanRootLayoutfindBest (VulkanRootLayout *a, VulkanRootLayout *b)
 Two root layouts can be incompatible. More...
 

Constructor & Destructor Documentation

◆ VulkanRootLayout()

Ogre::VulkanRootLayout::VulkanRootLayout ( VulkanGpuProgramManager programManager)

◆ ~VulkanRootLayout()

Ogre::VulkanRootLayout::~VulkanRootLayout ( )

Member Function Documentation

◆ bind()

void Ogre::VulkanRootLayout::bind ( VulkanDevice device,
VulkanVaoManager vaoManager,
const VulkanGlobalBindingTable table 
)

Takes an emulated D3D11/Metal-style table and binds it according to this layout's rules.

This updates N descriptors (1 for each set) and binds them

Parameters
device
vaoManagerThe VaoManager so we can grab new VulkanDescriptorPools shall we need them
tableThe emulated table to bind it

◆ copyFrom()

void Ogre::VulkanRootLayout::copyFrom ( const RootLayout rootLayout,
bool  bIncludeArrayBindings = true 
)

Copies all our parameters from 'other' Does NOT call validate()

Parameters
other
bIncludeArrayBindingsWhen false, mArrayRanges are not included

◆ copyTo()

void Ogre::VulkanRootLayout::copyTo ( RootLayout outRootLayout,
bool  bIncludeArrayBindings 
)

Performs outRootLayout.copyFrom( this ) This function is necessary because RootLayout is a protected base class.

◆ createVulkanHandles()

VkPipelineLayout Ogre::VulkanRootLayout::createVulkanHandles ( )

Creates most of our Vulkan handles required to build a PSO.

This function is not called by parseRootLayout because if two Root Layouts are identical, then after calling a->parseRootLayout(), instead of calling a->createVulkanHandles() we first must look for an already existing VulkanRootLayout and reuse it.

Returns
VkPipelineLayout handle for building the PSO.

◆ dump()

void Ogre::RootLayout::dump

Dumps the current RootLayout to a JSON string.

◆ findBest()

static VulkanRootLayout* Ogre::VulkanRootLayout::findBest ( VulkanRootLayout a,
VulkanRootLayout b 
)
static

Two root layouts can be incompatible.

If so, we return nullptr

If a and b are compatible, we return the best one (one that can satisfy both a and b).

a or b can be nullptr

◆ findBindingIndex()

bool Ogre::VulkanRootLayout::findBindingIndex ( const uint32  setIdx,
const uint32  targetBindingIdx,
DescBindingTypes::DescBindingTypes outType,
size_t &  outRelativeSlotIndex 
) const

O( N ) search to find DescBindingRange via its flattened vulkan binding idx (i.e.

reverse search)

Parameters
setIdx
targetBindingIdx
outType[out] The type located. Not touched if not found
outRelativeSlotIndex[out] The slot index expressed in the respective DescBindingTypes. Not touched if not found
Returns
False if not found

◆ findParamsBuffer()

bool Ogre::RootLayout::findParamsBuffer

Retrieves the set and binding idx of the params buffer.

Parameters
shaderStageSee GpuProgramType
outSetIdx[out] Set in which it is located Value will not be modified if we return false
outBindingIdx[out] Binding index in which it is located Value will not be modified if we return false
Returns
True if there is a params buffer False otherwise and output params won't be modified

◆ generateRootLayoutMacros()

void Ogre::VulkanRootLayout::generateRootLayoutMacros ( uint32  shaderStage,
ShaderSyntax  shaderType,
String inOutString 
) const

Generates all the macros for compiling shaders, based on our layout.

e.g. a layout like this:

## ROOT LAYOUT BEGIN
{
"0" :
{
"has_params" : true
"const_buffers" : [2, 4]
"tex_buffers" : [0, 1]
"samplers" : [1, 2],
"textures" : [1, 2]
}
}
## ROOT LAYOUT END

will generate the following:

#define ogre_P0 set = 0, binding = 0 // Params buffer
#define ogre_B2 set = 0, binding = 1 // Const buffer at slot 2
#define ogre_B3 set = 0, binding = 2
#define ogre_T0 set = 0, binding = 3 // Tex buffer at slot 0
#define ogre_t1 set = 0, binding = 4 // Texture at slot 1
// (other APIs share tex buffer & texture slots)
#define ogre_s1 set = 0, binding = 5 // Sampler at slot 1
Parameters
shaderStageSee GpuProgramType
inOutString[in/out] String to output our macros

◆ getDescBindingRanges() [1/2]

const DescBindingRange* Ogre::RootLayout::getDescBindingRanges
inline

◆ getDescBindingRanges() [2/2]

const DescBindingRange* Ogre::VulkanRootLayout::getDescBindingRanges ( size_t  setIdx) const
inline

◆ operator<()

bool Ogre::VulkanRootLayout::operator< ( const VulkanRootLayout other) const

◆ parseRootLayout()

void Ogre::VulkanRootLayout::parseRootLayout ( const char *  rootLayout,
const bool  bCompute,
const String filename 
)

Parses a root layout definition from a JSON string The JSON string:

{
"0" :
{
"has_params" : ["all", "vs", "gs", "hs", "ds", "ps", "cs"],
"const_buffers" : [0, 16],
"tex_buffers" : [1, 16],
"textures" : [0, 1],
"samplers" : [0, 1],
"uav_buffers" : [0, 16]
"uav_textures" : [16, 32],
"baked" : false
},
"arrays" :
{
"tex_buffers" : [[4, 5], [10, 2]],
}
}

has_params can establish which shader stages allow parameters.

  • "all" means all shader stages (vs through ps for graphics, cs for compute)

Note that for compatibility with other APIs, textures and tex_buffers cannot overlap Same with uav_buffers and uav_textures

Parameters
rootLayoutJSON string containing root layout
bComputeTrue if this is meant for compute. False for graphics
filenameFilename for logging purposes if errors are found

◆ validateArrayBindings()

void Ogre::RootLayout::validateArrayBindings

Validates that the array bindings in groundTruth.mArrayRanges are included in this->mArrayRanges.

Will throw otherwise

Parameters
groundTruthRoot Layout to compare against. Its data should've been obtrained through reflection
filenameFilename for logging purposes if errors are found

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