Test implicit packing of struct members.
This commit is contained in:
parent
46e757b278
commit
978253c804
27
reference/shaders-msl-no-opt/packing/struct-packing.comp
Normal file
27
reference/shaders-msl-no-opt/packing/struct-packing.comp
Normal file
@ -0,0 +1,27 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct Foo
|
||||
{
|
||||
packed_float3 a;
|
||||
};
|
||||
|
||||
struct Bar
|
||||
{
|
||||
packed_float3 a;
|
||||
};
|
||||
|
||||
struct SSBOScalar
|
||||
{
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
};
|
||||
|
||||
kernel void main0(device SSBOScalar& buffer_scalar [[buffer(0)]])
|
||||
{
|
||||
buffer_scalar.foo.a[0u] = 10.0;
|
||||
buffer_scalar.bar.a[0u] = 20.0;
|
||||
}
|
||||
|
27
shaders-msl-no-opt/packing/struct-packing.comp
Normal file
27
shaders-msl-no-opt/packing/struct-packing.comp
Normal file
@ -0,0 +1,27 @@
|
||||
#version 450
|
||||
#extension GL_EXT_scalar_block_layout : require
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
// Foo will be marked packed_float3 because offset of bar is just 12 bytes after foo.
|
||||
struct Foo
|
||||
{
|
||||
vec3 a;
|
||||
};
|
||||
|
||||
// Bar will be marked as packed due to alignment of the struct itself cannot work without packed.
|
||||
struct Bar
|
||||
{
|
||||
vec3 a;
|
||||
};
|
||||
|
||||
layout(scalar, set = 0, binding = 0) buffer SSBOScalar
|
||||
{
|
||||
Foo foo;
|
||||
Bar bar;
|
||||
} buffer_scalar;
|
||||
|
||||
void main()
|
||||
{
|
||||
buffer_scalar.foo.a.x = 10.0;
|
||||
buffer_scalar.bar.a.x = 20.0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user