Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Mesh Shader Output size calculation #2292

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions chapters/VK_NV_mesh_shader/mesh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -169,31 +169,38 @@ These resulting primitives are then further processed as described in
<<primsrast>>.

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 <<interfaces-iointerfaces-locations,location
assignment rules>>.
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
<<interfaces-iointerfaces-locations,location assignment rules>>.

* 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[]

Expand Down