From 69cbc26173cbc47a7fd0c92ce58745406aa28384 Mon Sep 17 00:00:00 2001 From: Rua Date: Sun, 7 Jan 2024 16:14:17 +0100 Subject: [PATCH] Rewrite Mesh Shader Output size calculation --- chapters/VK_NV_mesh_shader/mesh.adoc | 57 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/chapters/VK_NV_mesh_shader/mesh.adoc b/chapters/VK_NV_mesh_shader/mesh.adoc index a0c7c2a2f..e774ff942 100644 --- a/chapters/VK_NV_mesh_shader/mesh.adoc +++ b/chapters/VK_NV_mesh_shader/mesh.adoc @@ -169,31 +169,38 @@ These resulting primitives are then further processed as described in <>. ifdef::VK_EXT_mesh_shader[] -With the exception of primitive indices, all output built-ins and custom -attributes count towards the total storage size occupied by output variables -in mesh shaders. -This size can be calculated as follows, taking into account the fact that -the number of effective scalar attributes is 4 times the number of effective -locations used according to the <>. -Let latexmath:[v] be the number of views, latexmath:[n_v] be the number of -effective scalar per-vertex attributes not dependent on code:ViewIndex, -latexmath:[n_{vpv}] be the number of effective scalar per-vertex attributes -dependent on code:ViewIndex, latexmath:[m_v] be the maximum number of -vertices specified by the code:OutputVertices {ExecutionMode}, -latexmath:[g_v] be pname:meshOutputPerVertexGranularity, latexmath:[n_p] be -the number of effective scalar per-primitive attributes not dependent on -code:ViewIndex, latexmath:[n_{ppv}] be the number of effective scalar -per-primitive attributes dependent on code:ViewIndex, latexmath:[m_p] be the -maximum number of primitives specified by the code:OutputPrimitivesEXT -{ExecutionMode} and latexmath:[g_p] be -pname:meshOutputPerPrimitiveGranularity: - -[latexmath] -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -(n_v + (n_{vpv} \times v)) \times 4 \times \mathrm{align}(m_v, g_v) + -(n_p + (n_{ppv} \times v)) \times 4 \times \mathrm{align}(m_p, g_p) -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +With the exception of primitive indices, all built-in and user-defined +output variables count towards the total storage size occupied by output +variables in mesh shaders. +This size can be calculated as follows, where the effective number of +components is 4 times the number of locations used according to the +<>. + + * Let code:viewCount be the number of views. + * Let code:perVertexComponents and code:perPrimitiveComponents respectively be + the effective number of per-vertex and per-primitive components that are + not dependent on code:ViewIndex. + * Let code:perVertexPerViewComponents and code:perPrimitivePerViewComponents + respectively be the effective number of per-vertex and per-primitive + components that are dependent on code:ViewIndex. + * code:OutputVertices and code:OutputPrimitives are the values specified by + the respective {ExecutionMode}. + * pname:meshOutputPerVertexGranularity and + pname:meshOutputPerPrimitiveGranularity are the respective device + properties. + +Then the total output memory size is calculated as follows: + +[source,c] +---- +perVertexTotalComponents = perVertexComponents + (perVertexPerViewComponents * viewCount); +perVertexMemorySize = perVertexTotalComponents * 4 * align(OutputVertices, meshOutputPerVertexGranularity); + +perPrimitiveTotalComponents = perPrimitiveComponents + (perPrimitivePerViewComponents * viewCount) +perPrimitiveMemorySize = perPrimitiveTotalComponents * 4 * align(OutputPrimitives, meshOutputPerPrimitiveGranularity); + +memorySize = perVertexMemorySize + perPrimitiveMemorySize; +---- endif::VK_EXT_mesh_shader[]