Skip to content

[0026][LongVec] Clear long vector alignment in memory #543

@GinShio

Description

@GinShio

Which proposal does this relate to?
0026-hlsl-long-vector-type

Describe the issue or outstanding question.
As for long vectors, there is no information saying "how long vectors are placed in memory". Specification describes that N-element vectors are loaded and stored from ByteAddressBuffers.

ByteAddressBuffers requires 4 bytes alignment. I'm not sure that means the offset should be always aligned to 4 bytes. And, does StructuredBuffers follows this limitation? (I mean if the offset of each vector is aligned to 4 bytes.)

Additionally, in NV's GLSL cooperative vector extension, vectors must be aligned to 16 bytes in memory.

Please consider we have 2 vector<half, 3>, how to place them in memory:

  • always packed: $\mathtt{offset}=i*\mathtt{sizeof}(\mathit{componentType})*\mathit{numComponent}$.
  • always align to 16 bytes: $\mathtt{offset}=i*\mathtt{roundUpTo16}(\mathtt{sizeof}(\mathit{componentType})*\mathit{numComponent})$
  • always align to 4 bytes: $\mathtt{offset}=i*\mathtt{roundUpTo4}(\mathtt{sizeof}(\mathit{componentType})*\mathit{numComponent})$
  • always align to power by 2 bytes: $\mathtt{offset}=i*\mathtt{roundUpToPow2}(\mathtt{sizeof}(\mathit{componentType})*\mathit{numComponent})$.
  • Align to 4 bytes for ByteAddressBuffers, and packed for StructuredBuffers.

Additional context
GLSL_NV_cooperative_vector

For both coopVecLoadNV and coopVecStoreNV, 'v' can be a cooperative vector
type with any supported type parameters. The 'buf' arrays must be in either
buffer or shared storage, and the array that is passed in can be sized or
unsized. The load or store is done using memory qualifiers taken from the
declaration of 'buf'. offset must be a multiple of 16. For buffer storage,
the start of 'buf' must be 16B aligned.

New Resource Types

A byte address buffer is a buffer whose contents are addressable by a byte offset. Normally, the contents of a buffer are indexed per element using a stride for each element (S) and the element number (N) as given by S*N. A byte address buffer, which can also be called a raw buffer, uses a byte value offset from the beginning of the buffer to access data. The byte value must be a multiple of four so that it is DWORD aligned. If any other value is provided, behavior is undefined.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Triaged

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions