Skip to content

Commit b331216

Browse files
authored
[SPIR-V] Explicitly state which layout rules require scalar block layout (microsoft#7539)
I was trying to debug a Vulkan Storage Buffer-related memory alignment issue in my application where I was using SPIR-V generated via `dxc` with `-fvk-use-dx-layout`. In `SPIR-V.rst`, I happened to miss the paragraph that follows the list of layout rules (removed in this proposal). That paragraph starts with "To use scalar layout", which given my use of DirectX layout, I did not think was relevant to me. However, the next sentence of that paragraph sneakily and indirectly mentions that `VK_EXT_scalar_block_layout` is required for the DirectX memory layout as well. I have proposed explicitly stating the extension requirement when the relevant layout rules are listed.
1 parent 2da0a54 commit b331216

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/SPIR-V.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,17 +1012,18 @@ right now:
10121012
2. DirectX memory layout rules for uniform buffers and storage buffers:
10131013
they allow packing data on the application side that can be shared with
10141014
DirectX. They can be enabled by ``-fvk-use-dx-layout``.
1015+
1016+
NOTE: This requires ``VK_EXT_scalar_block_layout`` to be enabled on the
1017+
application side.
10151018
3. Strict OpenGL ``std140`` for uniform buffers and strict OpenGL ``std430``
10161019
for storage buffers: they allow packing data on the application side that
10171020
can be shared with OpenGL. They can be enabled by ``-fvk-use-gl-layout``.
10181021
4. Scalar layout rules introduced via `VK_EXT_scalar_block_layout`, which
10191022
basically aligns all aggregrate types according to their elements'
10201023
natural alignment. They can be enabled by ``-fvk-use-scalar-layout``.
1021-
1022-
To use scalar layout, the application side need to request
1023-
``VK_EXT_scalar_block_layout``. This is also true for using DirectX memory
1024-
layout since there is no dedicated DirectX layout extension for Vulkan
1025-
(at least for now). So we must request something more permissive.
1024+
1025+
NOTE: This requires ``VK_EXT_scalar_block_layout`` to be enabled on the
1026+
application side.
10261027

10271028
In the above, "vector-relaxed OpenGL ``std140``/``std430``" rules mean OpenGL
10281029
``std140``/``std430`` rules with the following modification for vector type
@@ -1032,7 +1033,7 @@ alignment:
10321033
2. If the above causes an `improper straddle <https://registry.khronos.org/vulkan/specs/latest/html/vkspec.html#interfaces-resources-layout>`_,
10331034
the alignment will be set to 16 bytes.
10341035

1035-
As an exmaple, for the following HLSL definition:
1036+
As an example, for the following HLSL definition:
10361037

10371038
.. code:: hlsl
10381039

0 commit comments

Comments
 (0)