GLSL: clean up GLSL output whitespace generation.
More line() and less std::endl.
More automated indents and less manual spacing.
Put a single newline after every struct and function declaration.
Note that this does touch every test result, but only affects whitespace.
Change-Id: I7506b9029b79b91fb335911dba44369b36f09bbe
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/78300
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/test/benchmark/particles.wgsl.expected.glsl b/test/benchmark/particles.wgsl.expected.glsl
index 8319db1..1491dca 100644
--- a/test/benchmark/particles.wgsl.expected.glsl
+++ b/test/benchmark/particles.wgsl.expected.glsl
@@ -20,16 +20,19 @@
vec4 color;
vec2 quad_pos;
};
+
struct VertexOutput {
vec4 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_4 {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_5 {
vec4 color;
vec2 quad_pos;
@@ -51,28 +54,35 @@
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_8 {
vec4 value;
};
+
struct SimulationParams {
float deltaTime;
vec4 seed;
};
+
struct Particle {
vec3 position;
float lifetime;
vec4 color;
vec3 velocity;
};
+
struct tint_symbol_10 {
uvec3 GlobalInvocationID;
};
+
struct UBO {
uint width;
};
+
struct tint_symbol_12 {
uvec3 coord;
};
+
struct tint_symbol_14 {
uvec3 coord;
};
@@ -91,6 +101,8 @@
layout(location = 2) in vec2 quad_pos;
layout(location = 0) out vec4 color;
layout(location = 1) out vec2 quad_pos;
+
+
void main() {
tint_symbol_4 inputs;
inputs.position = position;
@@ -105,9 +117,8 @@
gl_Position.y = -gl_Position.y;
}
-
Error parsing GLSL shader:
-ERROR: 0:90: 'color' : redefinition
+ERROR: 0:100: 'color' : redefinition
ERROR: 1 compilation errors. No code generated.
@@ -120,31 +131,37 @@
vec3 right;
vec3 up;
};
+
struct VertexInput {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct VertexOutput {
vec4 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_4 {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_5 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_7 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_8 {
vec4 value;
};
@@ -159,21 +176,26 @@
float deltaTime;
vec4 seed;
};
+
struct Particle {
vec3 position;
float lifetime;
vec4 color;
vec3 velocity;
};
+
struct tint_symbol_10 {
uvec3 GlobalInvocationID;
};
+
struct UBO {
uint width;
};
+
struct tint_symbol_12 {
uvec3 coord;
};
+
struct tint_symbol_14 {
uvec3 coord;
};
@@ -187,7 +209,9 @@
}
layout(location = 0) in vec4 color;
layout(location = 1) in vec2 quad_pos;
+
layout(location = 0) out vec4 value;
+
void main() {
tint_symbol_7 inputs;
inputs.color = color;
@@ -198,12 +222,10 @@
value = outputs.value;
}
-
#version 310 es
precision mediump float;
vec2 rand_seed = vec2(0.0f, 0.0f);
-
float rand() {
rand_seed.x = frac((cos(dot(rand_seed, vec2(23.140779495f, 232.616897583f))) * 136.816802979f));
rand_seed.y = frac((cos(dot(rand_seed, vec2(54.478565216f, 345.841522217f))) * 534.764526367f));
@@ -215,38 +237,46 @@
vec3 right;
vec3 up;
};
+
struct VertexInput {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct VertexOutput {
vec4 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_4 {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_5 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_7 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_8 {
vec4 value;
};
+
struct SimulationParams {
float deltaTime;
vec4 seed;
};
+
struct Particle {
vec3 position;
float lifetime;
@@ -258,16 +288,15 @@
float deltaTime;
vec4 seed;
} sim_params;
+
layout(binding = 1) buffer Particles_1 {
Particle particles[];
} data;
-
struct tint_symbol_10 {
uvec3 GlobalInvocationID;
};
uniform highp sampler2D tint_symbol_2_1;
-
void simulate_inner(uvec3 GlobalInvocationID) {
rand_seed = ((sim_params.seed.xy + vec2(GlobalInvocationID.xy)) * sim_params.seed.zw);
uint idx = GlobalInvocationID.x;
@@ -302,9 +331,11 @@
struct UBO {
uint width;
};
+
struct tint_symbol_12 {
uvec3 coord;
};
+
struct tint_symbol_14 {
uvec3 coord;
};
@@ -314,16 +345,17 @@
simulate_inner(tint_symbol_9.GlobalInvocationID);
return;
}
+
+
void main() {
tint_symbol_10 inputs;
inputs.GlobalInvocationID = gl_GlobalInvocationID;
simulate(inputs);
}
-
Error parsing GLSL shader:
-ERROR: 0:7: 'frac' : no matching overloaded function found
-ERROR: 0:7: '' : compilation terminated
+ERROR: 0:6: 'frac' : no matching overloaded function found
+ERROR: 0:6: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.
@@ -336,47 +368,57 @@
vec3 right;
vec3 up;
};
+
struct VertexInput {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct VertexOutput {
vec4 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_4 {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_5 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_7 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_8 {
vec4 value;
};
+
struct SimulationParams {
float deltaTime;
vec4 seed;
};
+
struct Particle {
vec3 position;
float lifetime;
vec4 color;
vec3 velocity;
};
+
struct tint_symbol_10 {
uvec3 GlobalInvocationID;
};
+
struct UBO {
uint width;
};
@@ -384,19 +426,18 @@
layout(binding = 3) uniform UBO_1 {
uint width;
} ubo;
+
layout(binding = 4) buffer Buffer_1 {
float weights[];
} buf_in;
layout(binding = 5) buffer Buffer_2 {
float weights[];
} buf_out;
-
struct tint_symbol_12 {
uvec3 coord;
};
uniform highp sampler2D tex_in_1;
-
void import_level_inner(uvec3 coord) {
uint offset = (coord.x + (coord.y * ubo.width));
buf_out.weights[offset] = texelFetch(tex_in_1, ivec2(coord.xy), 0).w;
@@ -411,13 +452,14 @@
import_level_inner(tint_symbol_11.coord);
return;
}
+
+
void main() {
tint_symbol_12 inputs;
inputs.coord = gl_GlobalInvocationID;
import_level(inputs);
}
-
#version 310 es
precision mediump float;
@@ -426,47 +468,57 @@
vec3 right;
vec3 up;
};
+
struct VertexInput {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct VertexOutput {
vec4 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_4 {
vec3 position;
vec4 color;
vec2 quad_pos;
};
+
struct tint_symbol_5 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_7 {
vec4 color;
vec2 quad_pos;
vec4 position;
};
+
struct tint_symbol_8 {
vec4 value;
};
+
struct SimulationParams {
float deltaTime;
vec4 seed;
};
+
struct Particle {
vec3 position;
float lifetime;
vec4 color;
vec3 velocity;
};
+
struct tint_symbol_10 {
uvec3 GlobalInvocationID;
};
+
struct UBO {
uint width;
};
@@ -474,22 +526,22 @@
layout(binding = 3) uniform UBO_1 {
uint width;
} ubo;
+
layout(binding = 4) buffer Buffer_1 {
float weights[];
} buf_in;
layout(binding = 5) buffer Buffer_2 {
float weights[];
} buf_out;
-
struct tint_symbol_12 {
uvec3 coord;
};
+
struct tint_symbol_14 {
uvec3 coord;
};
layout(rgba8) uniform highp writeonly image2D tex_out_1;
-
void export_level_inner(uvec3 coord) {
if (all(lessThan(coord.xy, uvec2(imageSize(tex_out_1))))) {
uint dst_offset = (coord.x + (coord.y * ubo.width));
@@ -510,10 +562,11 @@
export_level_inner(tint_symbol_13.coord);
return;
}
+
+
void main() {
tint_symbol_14 inputs;
inputs.coord = gl_GlobalInvocationID;
export_level(inputs);
}
-