GLSL: implement host-visible memory padding.

Since GLSL ES does not support the offset= attribute, struct members
with explicit @align or @size attributes require adding explicit
padding members.  This in turn requires rewriting any constructor
calls to initialize the new padding to zero, handled in the same
transform.

Note that this is currently overly-verbose, and will add padding where
GLSL doesn't technically need it (e.g., padding a vec3 out to 16 bytes).

Bug: tint:1415
Change-Id: Ia9ba513066a0e84f4c43247fcbbe02f5fadd6630
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101720
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Stephen White
2022-09-13 19:48:51 +00:00
committed by Dawn LUCI CQ
parent 26ffcd1768
commit 05d8b02b0f
146 changed files with 1452 additions and 192 deletions

View File

@@ -19,7 +19,7 @@ struct Outer_std140 {
Inner_std140 a[4];
};
layout(binding = 0) uniform a_block_ubo {
layout(binding = 0, std140) uniform a_block_ubo {
Outer_std140 inner[4];
} a;

View File

@@ -19,7 +19,7 @@ struct Outer_std140 {
Inner_std140 a[4];
};
layout(binding = 0) uniform a_block_ubo {
layout(binding = 0, std140) uniform a_block_ubo {
Outer_std140 inner[4];
} a;

View File

@@ -8,14 +8,16 @@ struct S {
struct S_std140 {
int before;
uint pad;
vec2 m_0;
vec2 m_1;
vec2 m_2;
vec2 m_3;
int after;
uint pad_1;
};
layout(binding = 0) uniform u_block_ubo {
layout(binding = 0, std140) uniform u_block_ubo {
S_std140 inner[4];
} u;

View File

@@ -8,14 +8,16 @@ struct S {
struct S_std140 {
int before;
uint pad;
vec2 m_0;
vec2 m_1;
vec2 m_2;
vec2 m_3;
int after;
uint pad_1;
};
layout(binding = 0) uniform u_block_ubo {
layout(binding = 0, std140) uniform u_block_ubo {
S_std140 inner[4];
} u;

View File

@@ -8,14 +8,16 @@ struct S {
struct S_std140 {
int before;
uint pad;
vec2 m_0;
vec2 m_1;
vec2 m_2;
vec2 m_3;
int after;
uint pad_1;
};
layout(binding = 0) uniform u_block_ubo {
layout(binding = 0, std140) uniform u_block_ubo {
S_std140 inner[4];
} u;

View File

@@ -2,20 +2,24 @@
struct S {
int before;
uint pad;
mat4x2 m;
int after;
uint pad_1;
};
struct S_std140 {
int before;
uint pad_2;
vec2 m_0;
vec2 m_1;
vec2 m_2;
vec2 m_3;
int after;
uint pad_3;
};
layout(binding = 0) uniform u_block_ubo {
layout(binding = 0, std140) uniform u_block_ubo {
S_std140 inner[4];
} u;
@@ -24,12 +28,12 @@ layout(binding = 1, std430) buffer s_block_ssbo {
} s;
S conv_S(S_std140 val) {
S tint_symbol = S(val.before, mat4x2(val.m_0, val.m_1, val.m_2, val.m_3), val.after);
S tint_symbol = S(val.before, 0u, mat4x2(val.m_0, val.m_1, val.m_2, val.m_3), val.after, 0u);
return tint_symbol;
}
S[4] conv_arr_4_S(S_std140 val[4]) {
S arr[4] = S[4](S(0, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0), S(0, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0), S(0, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0), S(0, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0));
S arr[4] = S[4](S(0, 0u, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0, 0u), S(0, 0u, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0, 0u), S(0, 0u, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0, 0u), S(0, 0u, mat4x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), 0, 0u));
{
for(uint i = 0u; (i < 4u); i = (i + 1u)) {
arr[i] = conv_S(val[i]);

View File

@@ -8,14 +8,16 @@ struct S {
struct S_std140 {
int before;
uint pad;
vec2 m_0;
vec2 m_1;
vec2 m_2;
vec2 m_3;
int after;
uint pad_1;
};
layout(binding = 0) uniform u_block_ubo {
layout(binding = 0, std140) uniform u_block_ubo {
S_std140 inner[4];
} u;