Add tests for struct padding and self-alignment.
This commit is contained in:
parent
7277c7ac46
commit
fc741596d4
19
reference/shaders-msl-no-opt/packing/member-padding.comp
Normal file
19
reference/shaders-msl-no-opt/packing/member-padding.comp
Normal file
@ -0,0 +1,19 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct SSBO
|
||||
{
|
||||
char _m0_pad[16];
|
||||
float a;
|
||||
char _m1_pad[20];
|
||||
float b;
|
||||
};
|
||||
|
||||
kernel void main0(device SSBO& _9 [[buffer(0)]])
|
||||
{
|
||||
_9.a = 10.0;
|
||||
_9.b = 20.0;
|
||||
}
|
||||
|
25
reference/shaders-msl-no-opt/packing/struct-alignment.comp
Normal file
25
reference/shaders-msl-no-opt/packing/struct-alignment.comp
Normal file
@ -0,0 +1,25 @@
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
struct Foo
|
||||
{
|
||||
packed_float3 a;
|
||||
float b;
|
||||
};
|
||||
|
||||
struct SSBO
|
||||
{
|
||||
float2 a;
|
||||
float b;
|
||||
char _m2_pad[4];
|
||||
Foo foo;
|
||||
};
|
||||
|
||||
kernel void main0(device SSBO& _12 [[buffer(0)]])
|
||||
{
|
||||
_12.a.x = 10.0;
|
||||
_12.b = 20.0;
|
||||
}
|
||||
|
14
shaders-msl-no-opt/packing/member-padding.comp
Normal file
14
shaders-msl-no-opt/packing/member-padding.comp
Normal file
@ -0,0 +1,14 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
layout(std140, set = 0, binding = 0) buffer SSBO
|
||||
{
|
||||
layout(offset = 16) float a;
|
||||
layout(offset = 40) float b;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
a = 10.0;
|
||||
b = 20.0;
|
||||
}
|
22
shaders-msl-no-opt/packing/struct-alignment.comp
Normal file
22
shaders-msl-no-opt/packing/struct-alignment.comp
Normal file
@ -0,0 +1,22 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
struct Foo
|
||||
{
|
||||
vec3 a; // <- This one should become packed_float3, and the MSL alignment of the struct is now 4.
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(std140, set = 0, binding = 0) buffer SSBO
|
||||
{
|
||||
vec2 a;
|
||||
float b;
|
||||
// <- We expect 4 bytes of padding here since MSL alignment of Foo must be lowered to 4.
|
||||
Foo foo;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
a.x = 10.0;
|
||||
b = 20.0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user