OGRE-Next: Ogre::VulkanRootLayout Class Reference

| OGRE-Next 3.0.0 Object-Oriented Graphics Rendering Engine

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Ogre::VulkanRootLayout Class Referencefinal

`#include <OgreVulkanRootLayout.h>`

Inheritance diagram for Ogre::VulkanRootLayout:
[legend]

## 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.
void | copyFrom (const RootLayout &rootLayout, bool bIncludeArrayBindings=true)
| Copies all our parameters from 'other' Does NOT call validate()
void | copyTo (RootLayout &outRootLayout, bool bIncludeArrayBindings)
| Performs outRootLayout.copyFrom( this ) This function is necessary because RootLayout is a protected base class.
VkPipelineLayout | createVulkanHandles ()
| Creates most of our Vulkan handles required to build a PSO.
void | dump (String &outJson) const
| Dumps the current RootLayout to a JSON string.
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.
bool | findParamsBuffer (uint32 shaderStage, size_t &outSetIdx, size_t &outBindingIdx) const
| Retrieves the set and binding idx of the params buffer.
void | generateRootLayoutMacros (uint32 shaderStage, ShaderSyntax shaderType, String &inOutString) const
| Generates all the macros for compiling shaders, based on our layout.
const DescBindingRange * | getDescBindingRanges (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:
void | validateArrayBindings (const RootLayout &groundTruth, const String &filename) const
| Validates that the array bindings in groundTruth.mArrayRanges are included in this->mArrayRanges.

## Static Public Member Functions
static VulkanRootLayout * | findBest (VulkanRootLayout *a, VulkanRootLayout *b)
| Two root layouts can be incompatible.

## Constructor & Destructor Documentation

## ◆ VulkanRootLayout()

Ogre::VulkanRootLayout::VulkanRootLayout | ( | VulkanGpuProgramManager * | programManager | ) |

Referenced by findBest(), and operator<().

## ◆ ~VulkanRootLayout()

Ogre::VulkanRootLayout::~VulkanRootLayout | ( |  | ) |

References Ogre::RootLayout::dump(), Ogre::RootLayout::findParamsBuffer(), Ogre::RootLayout::getDescBindingRanges(), and Ogre::RootLayout::validateArrayBindings().

## 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 |
  vaoManager | The VaoManager so we can grab new VulkanDescriptorPools shall we need them
  table | The 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 |
  bIncludeArrayBindings | When false, mArrayRanges are not included

References Ogre::RootLayout::RootLayout().

## ◆ copyTo()

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

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

References Ogre::RootLayout::RootLayout().

## ◆ 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 | ( | String & | outJson | ) | const

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

References VulkanRootLayout().

## ◆ 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 | ( | uint32 | shaderStage,
|  | size_t & | outSetIdx,
|  | size_t & | outBindingIdx ) const

Retrieves the set and binding idx of the params buffer.

Parameters

  shaderStage | See 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

  shaderStage | See GpuProgramType
  inOutString | [in/out] String to output our macros

## ◆ getDescBindingRanges()

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

References Ogre::RootLayout::mDescBindingRanges.

## ◆ operator<()

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

References VulkanRootLayout().

## ◆ 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

  rootLayout | JSON string containing root layout
  bCompute | True if this is meant for compute. False for graphics
  filename | Filename for logging purposes if errors are found

## ◆ validateArrayBindings()

void Ogre::RootLayout::validateArrayBindings | ( | const RootLayout & | groundTruth,
|  | const String & | filename ) const

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

Will throw otherwise

Parameters

  groundTruth | Root Layout to compare against. Its data should've been obtrained through reflection
  filename | Filename for logging purposes if errors are found

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

- OgreVulkanRootLayout.h