1e5c31af7Sopenharmony_ci# Memory Layout Examples 2e5c31af7Sopenharmony_ci 3e5c31af7Sopenharmony_ciNote, this is how we'll layout the data in Amber. Some of these types don't 4e5c31af7Sopenharmony_ciexist in standard GLSL (they exist in GL_EXT_shader_explicit_arithmetic_types). 5e5c31af7Sopenharmony_ciWe allow them in Amber to give flexibility in the data provided, but attempt to 6e5c31af7Sopenharmony_cifollow the layout rules with all types for consistency. 7e5c31af7Sopenharmony_ci 8e5c31af7Sopenharmony_ciFor the purposes of this document, all scalars are stored in little-endian. The 9e5c31af7Sopenharmony_cilower number components of a vector appear earlier than higher numbered ones. 10e5c31af7Sopenharmony_ciSimilar for columns and rows of matrices. 11e5c31af7Sopenharmony_ci 12e5c31af7Sopenharmony_ciAll type names used in the file are the Amber names. They differ from GLSL but 13e5c31af7Sopenharmony_ciare a bit more explicit, so are used here for clarity. 14e5c31af7Sopenharmony_ci 15e5c31af7Sopenharmony_ci## Scalars 16e5c31af7Sopenharmony_ci 17e5c31af7Sopenharmony_ci| Name | Bytes | 18e5c31af7Sopenharmony_ci|------|-------| 19e5c31af7Sopenharmony_ci| int8 | <kbd>[b]</kbd> | 20e5c31af7Sopenharmony_ci| uint8 | <kbd>[b]</kbd> | 21e5c31af7Sopenharmony_ci| int16 | <kbd>[bb]</kbd> | 22e5c31af7Sopenharmony_ci| uint16 | <kbd>[bb]</kbd> | 23e5c31af7Sopenharmony_ci| float16 | <kbd>[bb]</kbd> | 24e5c31af7Sopenharmony_ci| int32 | <kbd>[bbbb]</kbd> | 25e5c31af7Sopenharmony_ci| uint32 | <kbd>[bbbb]</kbd> | 26e5c31af7Sopenharmony_ci| float | <kbd>[bbbb]</kbd> | 27e5c31af7Sopenharmony_ci| int64 | <kbd>[bbbb][bbbb]</kbd> | 28e5c31af7Sopenharmony_ci| uint64 | <kbd>[bbbb][bbbb]</kbd> | 29e5c31af7Sopenharmony_ci| double | <kbd>[bbbb][bbbb]</kbd> | 30e5c31af7Sopenharmony_ci 31e5c31af7Sopenharmony_ci## Vectors 32e5c31af7Sopenharmony_ci### STD140 & STD430 33e5c31af7Sopenharmony_ci 34e5c31af7Sopenharmony_ci| Name | Bytes | 35e5c31af7Sopenharmony_ci|------|-------| 36e5c31af7Sopenharmony_ci| vec2\<float> | <kbd>[bbbb][bbbb]</kbd> | 37e5c31af7Sopenharmony_ci| vec3\<float> | <kbd>[bbbb][bbbb][bbbb][----]</kbd> | 38e5c31af7Sopenharmony_ci| vec4\<float> | <kbd>[bbbb][bbbb][bbbb][bbbb]</kbd> | 39e5c31af7Sopenharmony_ci| vec2\<int8> | <kbd>[bb]</kbd> | 40e5c31af7Sopenharmony_ci| vec3\<int8> | <kbd>[bbb-]</kbd> | 41e5c31af7Sopenharmony_ci| vec4\<int8> | <kbd>[bbbb]</kbd> | 42e5c31af7Sopenharmony_ci| vec2\<int16> | <kbd>[bbbb]</kbd> | 43e5c31af7Sopenharmony_ci| vec3\<int16> | <kbd>[bbbb][bb--]</kbd> | 44e5c31af7Sopenharmony_ci| vec4\<int16> | <kbd>[bbbb][bbbb]</kbd> | 45e5c31af7Sopenharmony_ci| vec2\<int32> | <kbd>[bbbb][bbbb]</kbd> | 46e5c31af7Sopenharmony_ci| vec3\<int32> | <kbd>[bbbb][bbbb][bbbb][----]</kbd> | 47e5c31af7Sopenharmony_ci| vec4\<int32> | <kbd>[bbbb][bbbb][bbbb][bbbb]</kbd> | 48e5c31af7Sopenharmony_ci 49e5c31af7Sopenharmony_ci 50e5c31af7Sopenharmony_ci## Scalar Arrays 51e5c31af7Sopenharmony_ci### STD140 52e5c31af7Sopenharmony_ci| Name | Bytes | 53e5c31af7Sopenharmony_ci|------|-------| 54e5c31af7Sopenharmony_ci| int8[] | <kbd>[b---][----][----][----]</kbd> | 55e5c31af7Sopenharmony_ci| int16[] | <kbd>[bb--][----][----][----]</kbd> | 56e5c31af7Sopenharmony_ci| int32[] | <kbd>[bbbb][----][----][----]</kbd> | 57e5c31af7Sopenharmony_ci| int64[] | <kbd>[bbbb][bbbb][----][----]</kbd> | 58e5c31af7Sopenharmony_ci| float[] | <kbd>[bbbb][----][----][----]</kbd> | 59e5c31af7Sopenharmony_ci 60e5c31af7Sopenharmony_ci### STD430 61e5c31af7Sopenharmony_ci| Name | Bytes | 62e5c31af7Sopenharmony_ci|------|-------| 63e5c31af7Sopenharmony_ci| int8[] | <kbd>[b]</kbd> | 64e5c31af7Sopenharmony_ci| int16[] | <kbd>[bb]</kbd> | 65e5c31af7Sopenharmony_ci| int32[] | <kbd>[bbbb]</kbd> | 66e5c31af7Sopenharmony_ci| int64[] | <kbd>[bbbb][bbbb]</kbd> | 67e5c31af7Sopenharmony_ci| float[] | <kbd>[bbbb]</kbd> | 68e5c31af7Sopenharmony_ci 69e5c31af7Sopenharmony_ci 70e5c31af7Sopenharmony_ci## Vector Arrays 71e5c31af7Sopenharmony_ci### STD140 72e5c31af7Sopenharmony_ci| Name | Bytes | 73e5c31af7Sopenharmony_ci|------|-------| 74e5c31af7Sopenharmony_ci| vec2\<float>[] | <kbd>[bbbb][bbbb][----][----]</kbd> | 75e5c31af7Sopenharmony_ci| vec3\<float>[] | <kbd>[bbbb][bbbb][bbbb][----]</kbd> | 76e5c31af7Sopenharmony_ci| vec4\<float>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]</kbd> | 77e5c31af7Sopenharmony_ci| vec2\<int8>[] | <kbd>[bb--][----][----][----]</kbd> | 78e5c31af7Sopenharmony_ci| vec2\<int16>[] | <kbd>[bbbb][----][----][----]</kbd> | 79e5c31af7Sopenharmony_ci| vec2\<int32>[] | <kbd>[bbbb][bbbb][----][----]</kbd> | 80e5c31af7Sopenharmony_ci| vec3\<int8>[] | <kbd>[bbb-][----][----][----]</kbd> | 81e5c31af7Sopenharmony_ci| vec3\<int16>[] | <kbd>[bbbb][bb--][----][----]</kbd> | 82e5c31af7Sopenharmony_ci| vec3\<int32>[] | <kbd>[bbbb][bbbb][bbbb][----]</kbd> | 83e5c31af7Sopenharmony_ci| vec4\<int8>[] | <kbd>[bbbb][----][----][----]</kbd> | 84e5c31af7Sopenharmony_ci| vec4\<int16>[] | <kbd>[bbbb][bbbb][----][----]</kbd> | 85e5c31af7Sopenharmony_ci| vec4\<int32>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]</kbd> | 86e5c31af7Sopenharmony_ci 87e5c31af7Sopenharmony_ci### STD430 88e5c31af7Sopenharmony_ci| Name | Bytes | 89e5c31af7Sopenharmony_ci|------|-------| 90e5c31af7Sopenharmony_ci| vec2\<float>[] | <kbd>[bbbb][bbbb]</kbd> | 91e5c31af7Sopenharmony_ci| vec3\<float>[] | <kbd>[bbbb][bbbb][bbbb][----]</kbd> | 92e5c31af7Sopenharmony_ci| vec4\<float>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]</kbd> | 93e5c31af7Sopenharmony_ci| vec2\<int8>[] | <kbd>[bb]</kbd> | 94e5c31af7Sopenharmony_ci| vec2\<int16>[] | <kbd>[bbbb]</kbd> | 95e5c31af7Sopenharmony_ci| vec2\<int32>[] | <kbd>[bbbb][bbbb]</kbd> | 96e5c31af7Sopenharmony_ci| vec3\<int8>[] | <kbd>[bbb-]</kbd> | 97e5c31af7Sopenharmony_ci| vec3\<int16>[] | <kbd>[bbbb][bb--]</kbd> | 98e5c31af7Sopenharmony_ci| vec3\<int32>[] | <kbd>[bbbb][bbbb][bbbb][----]</kbd> | 99e5c31af7Sopenharmony_ci| vec4\<int8>[] | <kbd>[bbbb]</kbd> | 100e5c31af7Sopenharmony_ci| vec4\<int16>[] | <kbd>[bbbb][bbbb]</kbd> | 101e5c31af7Sopenharmony_ci| vec4\<int32>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]</kbd> | 102e5c31af7Sopenharmony_ci 103e5c31af7Sopenharmony_ci 104e5c31af7Sopenharmony_ci## Matrices (All matrices are column-major matrices, format is matCxR) 105e5c31af7Sopenharmony_ci 106e5c31af7Sopenharmony_ciNote, GLSL does not have matrices with integer components although they exist in 107e5c31af7Sopenharmony_ciother shader languages. 108e5c31af7Sopenharmony_ci 109e5c31af7Sopenharmony_ci### STD140 110e5c31af7Sopenharmony_ci| Name | Bytes | 111e5c31af7Sopenharmony_ci|------|-------| 112e5c31af7Sopenharmony_ci| mat2x2\<int8> | <kbd>[bb--][----][----][----]<br/>[bb--][----][----][----]</kbd> | 113e5c31af7Sopenharmony_ci| mat2x2\<fp16> | <kbd>[bbbb][----][----][----]<br/>[bbbb][----][----][----]</kbd> | 114e5c31af7Sopenharmony_ci| mat2x2\<float> | <kbd>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]</kbd> | 115e5c31af7Sopenharmony_ci| mat2x3\<float> | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 116e5c31af7Sopenharmony_ci| mat2x4\<float> | <kbd>[bbbb][bbbb][bbbb][bbbb]<br/>[bbbb][bbbb][bbbb][bbbb]</kbd> | 117e5c31af7Sopenharmony_ci| mat3x2\<float> | <kbd>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]</kbd> | 118e5c31af7Sopenharmony_ci| mat4x2\<float> | <kbd>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]</kbd> | 119e5c31af7Sopenharmony_ci| mat4x3\<float> | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 120e5c31af7Sopenharmony_ci 121e5c31af7Sopenharmony_ci### STD430 122e5c31af7Sopenharmony_ci| Name | Bytes | 123e5c31af7Sopenharmony_ci|------|-------| 124e5c31af7Sopenharmony_ci| mat2x2\<fp16> | <kbd>[bbbb]<br/>[bbbb]</kbd> | 125e5c31af7Sopenharmony_ci| mat2x2\<float> | <kbd>[bbbb][bbbb]<br/>[bbbb][bbbb]</kbd> | 126e5c31af7Sopenharmony_ci| mat2x3\<float> | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 127e5c31af7Sopenharmony_ci| mat2x4\<float> | <kbd>[bbbb][bbbb][bbbb][bbbb]<br/>[bbbb][bbbb][bbbb][bbbb]</kbd> | 128e5c31af7Sopenharmony_ci| mat2x2\<int8> | <kbd>[bb]<br/>[bb]</kbd> | 129e5c31af7Sopenharmony_ci| mat3x2\<float> | <kbd>[bbbb][bbbb]<br/>[bbbb][bbbb]<br/>[bbbb][bbbb]</kbd> | 130e5c31af7Sopenharmony_ci| mat3x3\<float> | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 131e5c31af7Sopenharmony_ci| mat4x2\<float> | <kbd>[bbbb][bbbb][bbbb][bbbb]<br/>[bbbb][bbbb][bbbb][bbbb]</kbd> | 132e5c31af7Sopenharmony_ci| mat4x3\<float> | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 133e5c31af7Sopenharmony_ci 134e5c31af7Sopenharmony_ci 135e5c31af7Sopenharmony_ci## Matrix Array (All matrices are column-major matrices). 136e5c31af7Sopenharmony_ci 137e5c31af7Sopenharmony_ciIn the examples shown the array stride is equal to the base alignment of the matrix 138e5c31af7Sopenharmony_ciso no extra padding is added between elements. 139e5c31af7Sopenharmony_ci 140e5c31af7Sopenharmony_ci### STD140 141e5c31af7Sopenharmony_ci| Name | Bytes | 142e5c31af7Sopenharmony_ci|------|-------| 143e5c31af7Sopenharmony_ci| mat2x2\<int8>[] | <kbd>[bb--][----][----][----]<br/>[bb--][----][----][----]</kbd> | 144e5c31af7Sopenharmony_ci| mat2x2\<fp16>[] | <kbd>[bbbb][----][----][----]<br/>[bbbb][----][----][----]</kbd> | 145e5c31af7Sopenharmony_ci| mat2x2\<float>[] | <kbd>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]</kbd> | 146e5c31af7Sopenharmony_ci| mat2x3\<float>[] | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 147e5c31af7Sopenharmony_ci| mat2x4\<float>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]<br/>[bbbb][bbbb][bbbb][bbbb]</kbd> | 148e5c31af7Sopenharmony_ci| mat3x2\<float>[] | <kbd>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]</kbd> | 149e5c31af7Sopenharmony_ci| mat4x2\<float>[] | <kbd>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]<br/>[bbbb][bbbb][----][----]</kbd> | 150e5c31af7Sopenharmony_ci| mat4x3\<float>[] | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 151e5c31af7Sopenharmony_ci 152e5c31af7Sopenharmony_ci### STD430 153e5c31af7Sopenharmony_ci| Name | Bytes | 154e5c31af7Sopenharmony_ci|------|-------| 155e5c31af7Sopenharmony_ci| mat2x2\<fp16>[] | <kbd>[bbbb]<br/>[bbbb]</kbd> | 156e5c31af7Sopenharmony_ci| mat2x2\<float>[] | <kbd>[bbbb][bbbb]<br/>[bbbb][bbbb]</kbd> | 157e5c31af7Sopenharmony_ci| mat2x3\<float>[] | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 158e5c31af7Sopenharmony_ci| mat2x4\<float>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]<br/>[bbbb][bbbb][bbbb][bbbb]</kbd> | 159e5c31af7Sopenharmony_ci| mat2x2\<int8>[] | <kbd>[bb]<br/>[bb]</kbd> | 160e5c31af7Sopenharmony_ci| mat3x2\<float>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]<br/>[bbbb][bbbb]</kbd> | 161e5c31af7Sopenharmony_ci| mat3x3\<float>[] | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 162e5c31af7Sopenharmony_ci| mat4x2\<float>[] | <kbd>[bbbb][bbbb][bbbb][bbbb]<br/>[bbbb][bbbb][bbbb][bbbb]</kbd> | 163e5c31af7Sopenharmony_ci| mat4x3\<float>[] | <kbd>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]<br/>[bbbb][bbbb][bbbb][----]</kbd> | 164e5c31af7Sopenharmony_ci 165e5c31af7Sopenharmony_ci## Structures 166e5c31af7Sopenharmony_ci``` 167e5c31af7Sopenharmony_cistruct { 168e5c31af7Sopenharmony_ci int32 w; 169e5c31af7Sopenharmony_ci float x; 170e5c31af7Sopenharmony_ci} 171e5c31af7Sopenharmony_ci``` 172e5c31af7Sopenharmony_ci 173e5c31af7Sopenharmony_ciThe STD140 pads 8 bytes at the end to become a multiple of 16 bytes. 174e5c31af7Sopenharmony_ci 175e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 176e5c31af7Sopenharmony_ci|-----|:--------------------:|-------| 177e5c31af7Sopenharmony_ci| 140 | 16 | <kbd>{w [bbbb]}<br/>{x [bbbb]}<br/> [----][----]</kbd> | 178e5c31af7Sopenharmony_ci| 430 | 8 | <kbd>{w [bbbb]}<br/>{x [bbbb]}</kbd> | 179e5c31af7Sopenharmony_ci 180e5c31af7Sopenharmony_ci<hr> 181e5c31af7Sopenharmony_ci 182e5c31af7Sopenharmony_ci``` 183e5c31af7Sopenharmony_cistruct { 184e5c31af7Sopenharmony_ci struct { 185e5c31af7Sopenharmony_ci int32 a; 186e5c31af7Sopenharmony_ci float b; 187e5c31af7Sopenharmony_ci } x; 188e5c31af7Sopenharmony_ci float y; 189e5c31af7Sopenharmony_ci} 190e5c31af7Sopenharmony_ci``` 191e5c31af7Sopenharmony_ci 192e5c31af7Sopenharmony_ciThe STD140 pads 8 bytes at the end to become a multiple of 16 bytes. 193e5c31af7Sopenharmony_ci 194e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 195e5c31af7Sopenharmony_ci|-----|:--------------------:|-------| 196e5c31af7Sopenharmony_ci| 140 | 32 | <kbd>{x {a [bbbb]}<br/> {b [bbbb]}<br/> [----][----]<br/>{y [bbbb][----][----][----]}</kbd> | 197e5c31af7Sopenharmony_ci| 430 | 12 | <kbd>{x {a [bbbb]}<br/> {b [bbbb]}<br/>{y [bbbb]}</kbd> | 198e5c31af7Sopenharmony_ci 199e5c31af7Sopenharmony_ci 200e5c31af7Sopenharmony_ci<hr> 201e5c31af7Sopenharmony_ci 202e5c31af7Sopenharmony_ci``` 203e5c31af7Sopenharmony_cistruct { 204e5c31af7Sopenharmony_ci int32 w; 205e5c31af7Sopenharmony_ci vec2<float> x; 206e5c31af7Sopenharmony_ci float y; 207e5c31af7Sopenharmony_ci} 208e5c31af7Sopenharmony_ci``` 209e5c31af7Sopenharmony_ci 210e5c31af7Sopenharmony_ciFor both cases, the `vec2` is the member with the largest base alignment 211e5c31af7Sopenharmony_cirequirement, so giving a base alignment of 8 bytes. The STD140 cases pads 8 212e5c31af7Sopenharmony_cibytes at the end (in the array element case) to become a multiple of 16. 213e5c31af7Sopenharmony_ci 214e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 215e5c31af7Sopenharmony_ci|-----|:---------------------:|-------| 216e5c31af7Sopenharmony_ci| 140 | 32 | <kbd>{w [bbbb][----]}<br/>{x [bbbb][bbbb]}<br/>{y [bbbb][----]}<br/> [----][----]</kbd> | 217e5c31af7Sopenharmony_ci| 430 | 24 | <kbd>{w [bbbb][----]}<br/>{x [bbbb][bbbb]}<br/>{y [bbbb][----]}</kbd> | 218e5c31af7Sopenharmony_ci 219e5c31af7Sopenharmony_ci<hr> 220e5c31af7Sopenharmony_ci 221e5c31af7Sopenharmony_ci 222e5c31af7Sopenharmony_ci``` 223e5c31af7Sopenharmony_cistruct { 224e5c31af7Sopenharmony_ci int32 w; 225e5c31af7Sopenharmony_ci vec3<float> x; 226e5c31af7Sopenharmony_ci float y; 227e5c31af7Sopenharmony_ci} 228e5c31af7Sopenharmony_ci``` 229e5c31af7Sopenharmony_ci 230e5c31af7Sopenharmony_ciThe `vec3` expands to a `vec4`. This gives a base alignment of 16 bytes. So 231e5c31af7Sopenharmony_cithe `w` pads to 16 bytes. the `float y` is packed into the `vec3` as there is 232e5c31af7Sopenharmony_cispace (effectively making it a vec4). 233e5c31af7Sopenharmony_ci 234e5c31af7Sopenharmony_ci 235e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 236e5c31af7Sopenharmony_ci|-----|:--------------------:|-------| 237e5c31af7Sopenharmony_ci| 140 | 32 | <kbd>{w [bbbb][----][----][----]}<br/>{x [bbbb][bbbb][bbbb]}<br/>{y [bbbb]}</kbd> | 238e5c31af7Sopenharmony_ci| 430 | 32 | <kbd>{w [bbbb][----][----][----]}<br/>{x [bbbb][bbbb][bbbb]}<br/>{y [bbbb]}</kbd> | 239e5c31af7Sopenharmony_ci 240e5c31af7Sopenharmony_ci<hr> 241e5c31af7Sopenharmony_ci 242e5c31af7Sopenharmony_ci 243e5c31af7Sopenharmony_ci``` 244e5c31af7Sopenharmony_cistruct { 245e5c31af7Sopenharmony_ci int32 w; 246e5c31af7Sopenharmony_ci vec3<float> x; 247e5c31af7Sopenharmony_ci vec2<float> y; 248e5c31af7Sopenharmony_ci} 249e5c31af7Sopenharmony_ci``` 250e5c31af7Sopenharmony_ci 251e5c31af7Sopenharmony_ciThe `vec3` expands to a `vec4`. This gives a base alignment of 16 bytes. So 252e5c31af7Sopenharmony_cithe `w` pads to 16 bytes. 253e5c31af7Sopenharmony_ci 254e5c31af7Sopenharmony_ci 255e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 256e5c31af7Sopenharmony_ci|-----|:--------------------:|-------| 257e5c31af7Sopenharmony_ci| 140 | 48 | <kbd>{w [bbbb][----][----][----]}<br/>{x [bbbb][bbbb][bbbb][----]}<br/>{y [bbbb][bbbb]}<br/>[----][----]</kbd> | 258e5c31af7Sopenharmony_ci| 430 | 48 | <kbd>{w [bbbb][----][----][----]}<br/>{x [bbbb][bbbb][bbbb][----]}<br/>{y [bbbb][bbbb]}<br/>[----][----]</kbd> | 259e5c31af7Sopenharmony_ci 260e5c31af7Sopenharmony_ci<hr> 261e5c31af7Sopenharmony_ci 262e5c31af7Sopenharmony_ci 263e5c31af7Sopenharmony_ci``` 264e5c31af7Sopenharmony_cistruct { 265e5c31af7Sopenharmony_ci int32 w; 266e5c31af7Sopenharmony_ci mat2x2<float> x; 267e5c31af7Sopenharmony_ci float y; 268e5c31af7Sopenharmony_ci} 269e5c31af7Sopenharmony_ci``` 270e5c31af7Sopenharmony_ci 271e5c31af7Sopenharmony_ciIn STD140 the `mat2x2<float>` has a base alignment of 16 bytes (the mat2x2 is, effectively, 272e5c31af7Sopenharmony_cian array of vec2's The vec2's have a size of 8 bytes this size rounds up to a vec4, so 16 bytes). 273e5c31af7Sopenharmony_ci 274e5c31af7Sopenharmony_ciIn STD430, the round up doesn't happen, so the base alignment is 8 bytes. 275e5c31af7Sopenharmony_ci 276e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 277e5c31af7Sopenharmony_ci|-----|:---------------------:|-------| 278e5c31af7Sopenharmony_ci| 140 | 64 | <kbd>{w [bbbb][----][----][----]}<br/>{x [bbbb][bbbb][----][----]<br/> [bbbb][bbbb][----][----]}<br/>{y [bbbb][----][----][----]}</kbd> | 279e5c31af7Sopenharmony_ci| 430 | 32 | <kbd>{w [bbbb][----]}<br/>{x [bbbb][bbbb][bbbb][bbbb]}<br/>{y [bbbb][----]}</kbd> | 280e5c31af7Sopenharmony_ci 281e5c31af7Sopenharmony_ci<hr> 282e5c31af7Sopenharmony_ci 283e5c31af7Sopenharmony_ci 284e5c31af7Sopenharmony_ci``` 285e5c31af7Sopenharmony_cistruct { 286e5c31af7Sopenharmony_ci int32 w; 287e5c31af7Sopenharmony_ci struct { 288e5c31af7Sopenharmony_ci int32 a; 289e5c31af7Sopenharmony_ci int32 b; 290e5c31af7Sopenharmony_ci float c; 291e5c31af7Sopenharmony_ci } x; 292e5c31af7Sopenharmony_ci float y; 293e5c31af7Sopenharmony_ci} 294e5c31af7Sopenharmony_ci``` 295e5c31af7Sopenharmony_ci 296e5c31af7Sopenharmony_ciThe base alignment of the largest item is 4 bytes. In STD140, this rounds up to 297e5c31af7Sopenharmony_ci16 bytes because of the substructure. 298e5c31af7Sopenharmony_ci 299e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 300e5c31af7Sopenharmony_ci|-----|:--------------------:|-------| 301e5c31af7Sopenharmony_ci| 140 | 48 | <kbd>{w [bbbb][----][----][----]}<br/>{x a{[bbbb]}<br/> b{[bbbb]}<br/> c{[bbbb]}<br /> [----]<br/>{y [bbbb][----][----][----]}</kbd> | 302e5c31af7Sopenharmony_ci| 430 | 20 | <kbd>{w [bbbb]}<br/>{x a{[bbbb]}<br/> b{[bbbb]}<br/> c{[bbbb]}<br/>{y [bbbb]}</kbd> | 303e5c31af7Sopenharmony_ci 304e5c31af7Sopenharmony_ci<hr> 305e5c31af7Sopenharmony_ci 306e5c31af7Sopenharmony_ci``` 307e5c31af7Sopenharmony_cistruct { 308e5c31af7Sopenharmony_ci int32 w; 309e5c31af7Sopenharmony_ci struct { 310e5c31af7Sopenharmony_ci int32 a; 311e5c31af7Sopenharmony_ci int32 b; 312e5c31af7Sopenharmony_ci float c[3]; 313e5c31af7Sopenharmony_ci } x; 314e5c31af7Sopenharmony_ci float y; 315e5c31af7Sopenharmony_ci} 316e5c31af7Sopenharmony_ci``` 317e5c31af7Sopenharmony_ci 318e5c31af7Sopenharmony_ciThe `int a` and `int b` end up packing together so 16 bytes of padding are added (instead of 24 bytes). 319e5c31af7Sopenharmony_ciThe `float c[3]` has an array stride of 16 bytes in STD140 and 4 bytes in STD430. 320e5c31af7Sopenharmony_ci 321e5c31af7Sopenharmony_ci| STD | Array Stride | Bytes | 322e5c31af7Sopenharmony_ci|-----|:--------------------:|-------| 323e5c31af7Sopenharmony_ci| 140 | 96 | <kbd>{w [bbbb][----][----][----]}<br/>{x {a [bbbb]}<br/> {b [bbbb]}<br/> [----][----]<br/> {c [bbbb][----][----][----]<br/> [bbbb][----][----][----]<br/> [bbbb][----][----][----]}}<br/>{y [bbbb][----][----][----]}</kbd> | 324e5c31af7Sopenharmony_ci| 430 | 28 | <kbd>{w [bbbb]}<br/>{x a{[bbbb]}<br/> {b [bbbb]}<br/> {c [bbbb][bbbb][bbbb] }}<br/>{y [bbbb]}</kbd> | 325