aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjarisiru <53901722+jarisiru@users.noreply.github.com>2020-02-28 16:55:53 +0200
committerGitHub <noreply@github.com>2020-02-28 09:55:53 -0500
commitcab3a3159c067976a36f32ae98644c1b838dcaca (patch)
tree5a458b2c729195c93f4eb14e49abfe18a368389b /tests
parent626a61a39cd48b6812302ddc2d193f6ffd06c84f (diff)
downloadamber-cab3a3159c067976a36f32ae98644c1b838dcaca.tar.gz
Implement DRAW_GRID (#791)
Add support for draw_grid, which is fairly similar to draw_rect, except it also takes parameters to split the rectangle into desired number of columns and rows of cells. This functionality is meant for the testing of vertex shaders, giving an easy way to produce a lot of vertices. The implementation is based on draw_rect. Dawn rendering is not implemented.
Diffstat (limited to 'tests')
-rw-r--r--tests/cases/draw_grid.amber54
-rw-r--r--tests/cases/draw_grid_multiple_color_attachment.amber40
-rw-r--r--tests/cases/draw_grid_multiple_pipeline.amber44
-rw-r--r--tests/cases/draw_grid_with_buffer.amber63
-rw-r--r--tests/cases/draw_grid_with_two_vertex_data_attached.expect_fail.amber74
-rw-r--r--tests/cases/draw_grids.amber78
-rwxr-xr-xtests/run_tests.py8
7 files changed, 361 insertions, 0 deletions
diff --git a/tests/cases/draw_grid.amber b/tests/cases/draw_grid.amber
new file mode 100644
index 0000000..8d24a11
--- /dev/null
+++ b/tests/cases/draw_grid.amber
@@ -0,0 +1,54 @@
+#!amber
+# Copyright 2020 The Amber Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SHADER vertex vert_shader GLSL
+#version 430
+
+layout(location = 0) in vec4 position;
+layout(location = 1) flat out vec4 frag_color;
+
+void main() {
+ gl_Position = position;
+ frag_color = position;
+}
+END
+
+SHADER fragment frag_shader GLSL
+#version 430
+layout(location = 0) out vec4 color_out;
+layout(location = 1) flat in vec4 frag_color;
+void main() {
+ ivec2 iv = ivec2(frag_color.xy * 256);
+ if ((iv.x & 64) + ((iv.y / 2) & 64) == 64)
+ color_out = vec4(1, 0, 0, 1);
+ else
+ color_out = vec4(0, 1, 1, 1);
+}
+END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics my_pipeline
+ ATTACH vert_shader
+ ATTACH frag_shader
+ BIND BUFFER framebuffer AS color LOCATION 0
+END
+
+RUN my_pipeline DRAW_GRID POS 0 0 SIZE 250 250 CELLS 8 4
+EXPECT framebuffer IDX 0 0 SIZE 30 60 EQ_RGBA 0 255 255 255
+EXPECT framebuffer IDX 32 64 SIZE 30 60 EQ_RGBA 0 255 255 255
+EXPECT framebuffer IDX 32 0 SIZE 30 60 EQ_RGBA 255 0 0 255
+EXPECT framebuffer IDX 0 64 SIZE 30 60 EQ_RGBA 255 0 0 255
+
diff --git a/tests/cases/draw_grid_multiple_color_attachment.amber b/tests/cases/draw_grid_multiple_color_attachment.amber
new file mode 100644
index 0000000..4707f88
--- /dev/null
+++ b/tests/cases/draw_grid_multiple_color_attachment.amber
@@ -0,0 +1,40 @@
+#!amber
+# Copyright 2020 The Amber Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SHADER vertex vert_shader PASSTHROUGH
+SHADER fragment frag_shader GLSL
+#version 430
+layout(location = 0) out vec4 color_out;
+layout(location = 1) out vec4 color_out1;
+void main() {
+ color_out = vec4(0.0, 0.499, 0.0, 0.8);
+ color_out1 = vec4(1.0, 1.0, 1.0, 1.0);
+}
+END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+BUFFER framebuffer1 FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics my_pipeline
+ ATTACH vert_shader
+ ATTACH frag_shader
+ FRAMEBUFFER_SIZE 800 600
+ BIND BUFFER framebuffer AS color LOCATION 0
+ BIND BUFFER framebuffer1 AS color LOCATION 1
+END
+
+RUN my_pipeline DRAW_GRID POS 0 0 SIZE 800 600 CELLS 91 37
+EXPECT framebuffer IDX 0 0 SIZE 800 600 EQ_RGBA 0 127 0 204
+EXPECT framebuffer1 IDX 0 0 SIZE 800 600 EQ_RGBA 255 255 255 255
diff --git a/tests/cases/draw_grid_multiple_pipeline.amber b/tests/cases/draw_grid_multiple_pipeline.amber
new file mode 100644
index 0000000..169b95e
--- /dev/null
+++ b/tests/cases/draw_grid_multiple_pipeline.amber
@@ -0,0 +1,44 @@
+#!amber
+# Copyright 2019 The Amber Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SHADER vertex vert_shader PASSTHROUGH
+SHADER fragment frag_shader GLSL
+#version 430
+layout(location = 0) out vec4 color_out;
+void main() {
+ color_out = vec4(0.0, 0.5, 0.0, 0.8);
+}
+END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics my_pipeline
+ ATTACH vert_shader
+ ATTACH frag_shader
+ FRAMEBUFFER_SIZE 800 600
+ BIND BUFFER framebuffer AS color LOCATION 0
+END
+DERIVE_PIPELINE pipeline2 FROM my_pipeline
+END
+DERIVE_PIPELINE pipeline3 FROM my_pipeline
+END
+
+RUN my_pipeline DRAW_GRID POS 0 0 SIZE 250 250 CELLS 1 2
+RUN pipeline2 DRAW_GRID POS 250 250 SIZE 250 250 CELLS 3 4
+RUN pipeline3 DRAW_GRID POS 0 250 SIZE 250 250 CELLS 5 6
+
+EXPECT framebuffer IDX 250 250 SIZE 250 250 EQ_RGBA 0 127 0 204 TOLERANCE 0 1 0 1
+EXPECT framebuffer IDX 0 0 SIZE 250 250 EQ_RGBA 0 127 0 204 TOLERANCE 0 1 0 1
+EXPECT framebuffer IDX 0 250 SIZE 250 250 EQ_RGBA 0 127 0 204 TOLERANCE 0 1 0 1
diff --git a/tests/cases/draw_grid_with_buffer.amber b/tests/cases/draw_grid_with_buffer.amber
new file mode 100644
index 0000000..a540744
--- /dev/null
+++ b/tests/cases/draw_grid_with_buffer.amber
@@ -0,0 +1,63 @@
+#!amber
+#
+# Copyright 2020 The Amber Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+DEVICE_FEATURE vertexPipelineStoresAndAtomics
+
+SHADER vertex vtex_shader GLSL
+#version 430
+
+layout(location = 0) in vec4 position;
+layout(location = 0) out vec4 frag_color;
+
+layout(set = 0, binding = 0) readonly buffer block1 {
+ vec4 in_color;
+};
+
+void main() {
+ gl_Position = position;
+ frag_color = in_color;
+}
+END
+
+SHADER fragment frag_shader GLSL
+#version 430
+
+layout(location = 0) in vec4 frag_color;
+layout(location = 0) out vec4 final_color;
+
+void main() {
+ final_color = frag_color;
+}
+END
+
+BUFFER data_buf1 DATA_TYPE vec4<float> DATA 1 1 0 1 END
+
+
+BUFFER frame FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics pipeline1
+ ATTACH vtex_shader
+ ATTACH frag_shader
+
+ FRAMEBUFFER_SIZE 800 600
+ BIND BUFFER frame AS color LOCATION 0
+ BIND BUFFER data_buf1 AS storage DESCRIPTOR_SET 0 BINDING 0
+END
+
+CLEAR pipeline1
+RUN pipeline1 DRAW_GRID POS 0 0 SIZE 400 300 CELLS 128 128
+
+EXPECT frame IDX 0 0 SIZE 400 300 EQ_RGBA 255 255 0 255
diff --git a/tests/cases/draw_grid_with_two_vertex_data_attached.expect_fail.amber b/tests/cases/draw_grid_with_two_vertex_data_attached.expect_fail.amber
new file mode 100644
index 0000000..56479de
--- /dev/null
+++ b/tests/cases/draw_grid_with_two_vertex_data_attached.expect_fail.amber
@@ -0,0 +1,74 @@
+#!amber
+# Copyright 2020 The Amber Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SHADER vertex vtex_shader GLSL
+#version 430
+
+layout(location = 0) in vec3 position;
+layout(location = 1) in vec4 ver_color;
+layout(location = 0) out vec4 frag_color;
+
+
+void main() {
+ gl_Position = vec4(position, 1.0);
+ frag_color = ver_color;
+}
+END
+
+SHADER fragment frag_shader GLSL
+#version 430
+
+layout(location = 0) in vec4 frag_color;
+layout(location = 0) out vec4 final_color;
+
+void main() {
+ final_color = frag_color;
+}
+END
+
+BUFFER position_buf DATA_TYPE vec3<float> DATA
+-1 1 0
+-1 -1 0
+ 1 1 0
+ 1 -1 0
+-1 -1 0
+ 1 1 0
+END
+
+BUFFER vert_color_buf DATA_TYPE R8G8B8A8_UNORM DATA
+255 0 0 255
+255 0 0 255
+255 0 0 255
+255 0 0 255
+255 0 0 255
+255 0 0 255
+END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics pipeline
+ ATTACH vtex_shader
+ ATTACH frag_shader
+
+ VERTEX_DATA position_buf LOCATION 0
+ VERTEX_DATA vert_color_buf LOCATION 1
+
+ FRAMEBUFFER_SIZE 250 250
+ BIND BUFFER framebuffer AS color LOCATION 0
+
+END
+
+RUN pipeline DRAW_GRID POS 100 100 SIZE 100 100 CELLS 10 10
+EXPECT framebuffer IDX 100 100 SIZE 100 100 EQ_RGBA 255 0 0 255
diff --git a/tests/cases/draw_grids.amber b/tests/cases/draw_grids.amber
new file mode 100644
index 0000000..eaf383d
--- /dev/null
+++ b/tests/cases/draw_grids.amber
@@ -0,0 +1,78 @@
+#!amber
+#
+# Copyright 2020 The Amber Authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SHADER vertex vtex_shader GLSL
+#version 430
+
+layout(location = 0) in vec4 position;
+layout(location = 0) out vec4 frag_color;
+
+layout(set = 0, binding = 0) readonly buffer block1 {
+ vec4 in_color;
+};
+
+void main() {
+ gl_Position = position;
+ frag_color = in_color;
+}
+END
+
+SHADER fragment frag_shader GLSL
+#version 430
+
+layout(location = 0) in vec4 frag_color;
+layout(location = 0) out vec4 final_color;
+
+void main() {
+ final_color = frag_color;
+}
+END
+
+BUFFER data_buf1 DATA_TYPE vec4<float> DATA 1 0 0 1 END
+BUFFER data_buf2 DATA_TYPE vec4<float> DATA 0 1 0 1 END
+BUFFER data_buf3 DATA_TYPE vec4<float> DATA 0 0 1 1 END
+BUFFER data_buf4 DATA_TYPE vec4<float> DATA .5 0 .5 1 END
+
+BUFFER frame FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics pipeline1
+ ATTACH vtex_shader
+ ATTACH frag_shader
+
+ FRAMEBUFFER_SIZE 800 600
+ BIND BUFFER frame AS color LOCATION 0
+ BIND BUFFER data_buf1 AS storage DESCRIPTOR_SET 0 BINDING 0
+END
+DERIVE_PIPELINE pipeline2 FROM pipeline1
+ BIND BUFFER data_buf2 AS storage DESCRIPTOR_SET 0 BINDING 0
+END
+DERIVE_PIPELINE pipeline3 FROM pipeline1
+ BIND BUFFER data_buf3 AS storage DESCRIPTOR_SET 0 BINDING 0
+END
+DERIVE_PIPELINE pipeline4 FROM pipeline1
+ BIND BUFFER data_buf4 AS storage DESCRIPTOR_SET 0 BINDING 0
+END
+
+CLEAR pipeline1
+RUN pipeline1 DRAW_GRID POS 0 0 SIZE 400 300 CELLS 2 3
+RUN pipeline2 DRAW_GRID POS 0 300 SIZE 400 300 CELLS 1 1
+RUN pipeline3 DRAW_GRID POS 400 0 SIZE 400 300 CELLS 100 100
+RUN pipeline4 DRAW_GRID POS 400 300 SIZE 400 300 CELLS 1 71
+
+EXPECT frame IDX 0 0 SIZE 400 300 EQ_RGBA 255 0 0 255
+EXPECT frame IDX 0 300 SIZE 400 300 EQ_RGBA 0 255 0 255
+EXPECT frame IDX 400 0 SIZE 400 300 EQ_RGBA 0 0 255 255
+EXPECT frame IDX 400 300 SIZE 400 300 EQ_RGBA 127 0 127 255 TOLERANCE 1 0 1 0
diff --git a/tests/run_tests.py b/tests/run_tests.py
index 63edf75..7138bf0 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -156,6 +156,14 @@ SUPPRESSIONS_DAWN = [
"multiple_ssbo_update_with_graphics_pipeline.vkscript",
# Currently not working, under investigation
"draw_triangle_list_with_depth.vkscript",
+ # draw_grid not implemented for dawn yet
+ "draw_grid.amber",
+ "draw_grid_multiple_color_attachment.amber",
+ "draw_grid_multiple_pipeline.amber",
+ "draw_grids.amber",
+ "draw_grid.vkscript",
+ "draw_grid_with_buffer.amber",
+ "draw_grid_with_two_vertex_data_attached.expect_fail.amber",
]
class TestCase: