aboutsummaryrefslogtreecommitdiff
path: root/tests/cases
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cases')
-rw-r--r--tests/cases/compute_descriptor_array_ssbo.amber21
-rw-r--r--tests/cases/compute_descriptor_array_storagetexelbuffer.amber23
-rw-r--r--tests/cases/compute_dynamic_buffers.amber9
-rw-r--r--tests/cases/compute_dynamic_buffers_descriptor_array.amber17
-rw-r--r--tests/cases/compute_one_buffer_in_multiple_bindings.amber94
-rw-r--r--tests/cases/debugger_hlsl_basic_compute.amber2
-rw-r--r--tests/cases/debugger_hlsl_basic_vertex.amber6
-rw-r--r--tests/cases/debugger_hlsl_function_call.amber2
-rw-r--r--tests/cases/debugger_hlsl_shadowed_vars.amber7
-rw-r--r--tests/cases/debugger_spirv_line_stepping.amber6
-rw-r--r--tests/cases/draw_rect_blend.amber46
-rw-r--r--tests/cases/float16.amber4
-rw-r--r--tests/cases/graphics_descriptor_array_combined_image_sampler.amber13
-rw-r--r--tests/cases/graphics_descriptor_array_sampled_image.amber14
-rw-r--r--tests/cases/multisample_resolve.amber50
-rw-r--r--tests/cases/non_default_entry_point.amber2
-rw-r--r--tests/cases/shader_specialization.amber2
-rw-r--r--tests/cases/storage16.amber1
-rw-r--r--tests/cases/tessellation_isolines.amber130
-rw-r--r--tests/cases/viewport.amber59
-rw-r--r--tests/cases/viewport_depth.amber61
21 files changed, 550 insertions, 19 deletions
diff --git a/tests/cases/compute_descriptor_array_ssbo.amber b/tests/cases/compute_descriptor_array_ssbo.amber
index bd4c773..0eb6b7d 100644
--- a/tests/cases/compute_descriptor_array_ssbo.amber
+++ b/tests/cases/compute_descriptor_array_ssbo.amber
@@ -20,12 +20,19 @@ layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(binding = 0) buffer block0
{
int data;
-} ssbo_array[2];
+} ssbo_array_0[2];
+
+layout(binding = 1) buffer block1
+{
+ int data;
+} ssbo_array_1[2];
void main()
{
- ssbo_array[0].data = 1;
- ssbo_array[1].data = 2;
+ ssbo_array_0[0].data = 1;
+ ssbo_array_0[1].data = 2;
+ ssbo_array_1[0].data = 3;
+ ssbo_array_1[1].data = 4;
}
END
@@ -37,13 +44,21 @@ BUFFER buf1 DATA_TYPE int32 DATA
0
END
+# The Vulkan spec lists the maximum value of minStorageBufferOffsetAlignment
+# (i.e. the maximum possible alignment requirement) as 256 bytes, so we will use
+# buffer with size of 65 int32 values = 260 bytes.
+BUFFER buf2 DATA_TYPE int32 SIZE 65 FILL 0
+
PIPELINE compute pipeline
ATTACH compute_shader
BIND BUFFER_ARRAY buf0 buf1 AS storage DESCRIPTOR_SET 0 BINDING 0
+ BIND BUFFER_ARRAY buf2 buf2 AS storage DESCRIPTOR_SET 0 BINDING 1 DESCRIPTOR_OFFSET 0 256 DESCRIPTOR_RANGE 256 4
END
RUN pipeline 1 1 1
EXPECT buf0 IDX 0 EQ 1
EXPECT buf1 IDX 0 EQ 2
+EXPECT buf2 IDX 0 EQ 3
+EXPECT buf2 IDX 256 EQ 4
diff --git a/tests/cases/compute_descriptor_array_storagetexelbuffer.amber b/tests/cases/compute_descriptor_array_storagetexelbuffer.amber
index d4a1994..3ddae3c 100644
--- a/tests/cases/compute_descriptor_array_storagetexelbuffer.amber
+++ b/tests/cases/compute_descriptor_array_storagetexelbuffer.amber
@@ -17,13 +17,20 @@ SHADER compute compute_shader GLSL
#version 430
layout(local_size_x=4,local_size_y=1) in;
uniform layout(set=0, binding=0) samplerBuffer texelsIn;
-uniform layout(set=0, binding=1, rgba32f) imageBuffer texelsOut[2];
+uniform layout(set=0, binding=1, rgba32f) imageBuffer texelsOut_0[2];
+uniform layout(set=0, binding=2, rgba32f) imageBuffer texelsOut_1[2];
void main ()
{
vec4 color = texelFetch(texelsIn, int(gl_GlobalInvocationID));
- imageStore(texelsOut[0], int(gl_GlobalInvocationID), color);
- imageStore(texelsOut[1], int(gl_GlobalInvocationID), color * 2.0);
+ imageStore(texelsOut_0[0], int(gl_GlobalInvocationID), color);
+ imageStore(texelsOut_0[1], int(gl_GlobalInvocationID), color * 2.0);
+ if (int(gl_GlobalInvocationID) < 2) {
+ imageStore(texelsOut_1[0], int(gl_GlobalInvocationID), color * 3.0);
+ }
+ else {
+ imageStore(texelsOut_1[1], int(gl_GlobalInvocationID), color * 4.0);
+ }
}
END
@@ -36,6 +43,7 @@ END
BUFFER texel_buffer_out0 DATA_TYPE R32G32B32A32_SFLOAT SIZE 4 FILL 0
BUFFER texel_buffer_out1 DATA_TYPE R32G32B32A32_SFLOAT SIZE 4 FILL 0
+BUFFER texel_buffer_out2 DATA_TYPE R32G32B32A32_SFLOAT SIZE 4 FILL 0
BUFFER ref0 DATA_TYPE R32G32B32A32_SFLOAT DATA
1.0 0.0 0.0 1.0
@@ -51,13 +59,22 @@ BUFFER ref1 DATA_TYPE R32G32B32A32_SFLOAT DATA
0.0 2.0 2.0 2.0
END
+BUFFER ref2 DATA_TYPE R32G32B32A32_SFLOAT DATA
+3.0 0.0 0.0 3.0
+0.0 3.0 0.0 3.0
+0.0 0.0 4.0 4.0
+0.0 4.0 4.0 4.0
+END
+
PIPELINE compute pipeline
ATTACH compute_shader
BIND BUFFER texel_buffer_in AS uniform_texel_buffer DESCRIPTOR_SET 0 BINDING 0
BIND BUFFER_ARRAY texel_buffer_out0 texel_buffer_out1 AS storage_texel_buffer DESCRIPTOR_SET 0 BINDING 1
+ BIND BUFFER_ARRAY texel_buffer_out2 texel_buffer_out2 AS storage_texel_buffer DESCRIPTOR_SET 0 BINDING 2
END
RUN pipeline 1 1 1
EXPECT texel_buffer_out0 EQ_BUFFER ref0
EXPECT texel_buffer_out1 EQ_BUFFER ref1
+EXPECT texel_buffer_out2 EQ_BUFFER ref2
diff --git a/tests/cases/compute_dynamic_buffers.amber b/tests/cases/compute_dynamic_buffers.amber
index 9412e30..9dd4149 100644
--- a/tests/cases/compute_dynamic_buffers.amber
+++ b/tests/cases/compute_dynamic_buffers.amber
@@ -25,11 +25,16 @@ layout(set = 0, binding = 1) buffer block1
{
vec4 data1;
};
+layout(set = 0, binding = 2) buffer block2
+{
+ vec4 data2;
+};
void main()
{
data0 = vec4(1, 2, 3, 4);
data1 = vec4(5, 6, 7, 8);
+ data2 = vec4(9, 10, 11, 12);
}
END
@@ -39,6 +44,7 @@ END
# after the alignment (256 / 16 + 1).
BUFFER buf0 DATA_TYPE vec4<float> SIZE 17 FILL 0.0
BUFFER buf1 DATA_TYPE vec4<float> SIZE 17 FILL 0.0
+BUFFER buf2 DATA_TYPE vec4<float> SIZE 33 FILL 0.0
PIPELINE compute pipeline
ATTACH compute_shader
@@ -46,9 +52,12 @@ PIPELINE compute pipeline
BIND BUFFER buf0 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 0 OFFSET 0
# Using the maximum possible required offset alignment of 256 bytes to support all implementations.
BIND BUFFER buf1 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 1 OFFSET 256
+ # Same as above, but with buffer offset of 256 bytes (total offset of 512).
+ BIND BUFFER buf2 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 2 OFFSET 256 DESCRIPTOR_OFFSET 256
END
RUN pipeline 1 1 1
EXPECT buf0 IDX 0 EQ 1.0 2.0 3.0 4.0
EXPECT buf1 IDX 256 EQ 5.0 6.0 7.0 8.0
+EXPECT buf2 IDX 512 EQ 9.0 10.0 11.0 12.0
diff --git a/tests/cases/compute_dynamic_buffers_descriptor_array.amber b/tests/cases/compute_dynamic_buffers_descriptor_array.amber
index fe07b6c..ccc4c42 100644
--- a/tests/cases/compute_dynamic_buffers_descriptor_array.amber
+++ b/tests/cases/compute_dynamic_buffers_descriptor_array.amber
@@ -19,12 +19,18 @@ SHADER compute compute_shader GLSL
layout(set = 0, binding = 0) buffer block0
{
vec4 data;
-} ssbo_array[2];
+} ssbo_array_0[2];
+layout(set = 0, binding = 1) buffer block1
+{
+ int data;
+} ssbo_array_1[2];
void main()
{
- ssbo_array[0].data = vec4(1, 2, 3, 4);
- ssbo_array[1].data = vec4(5, 6, 7, 8);
+ ssbo_array_0[0].data = vec4(1, 2, 3, 4);
+ ssbo_array_0[1].data = vec4(5, 6, 7, 8);
+ ssbo_array_1[0].data = 9;
+ ssbo_array_1[1].data = 10;
}
END
@@ -34,15 +40,20 @@ END
# after the alignment (256 / 16 + 1).
BUFFER buf0 DATA_TYPE vec4<float> SIZE 17 FILL 0.0
BUFFER buf1 DATA_TYPE vec4<float> SIZE 17 FILL 0.0
+# Same as above, but with int32 and double size: 512 / 4 + 1
+BUFFER buf2 DATA_TYPE int32 SIZE 129 FILL 0
PIPELINE compute pipeline
ATTACH compute_shader
# Using the maximum possible required offset alignment of 256 bytes to support all implementations.
BIND BUFFER_ARRAY buf0 buf1 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 0 OFFSET 0 256
+ BIND BUFFER_ARRAY buf2 buf2 AS storage_dynamic DESCRIPTOR_SET 0 BINDING 1 OFFSET 0 256 DESCRIPTOR_OFFSET 0 256
END
RUN pipeline 1 1 1
EXPECT buf0 IDX 0 EQ 1.0 2.0 3.0 4.0
EXPECT buf1 IDX 256 EQ 5.0 6.0 7.0 8.0
+EXPECT buf2 IDX 0 EQ 9
+EXPECT buf2 IDX 512 EQ 10
diff --git a/tests/cases/compute_one_buffer_in_multiple_bindings.amber b/tests/cases/compute_one_buffer_in_multiple_bindings.amber
new file mode 100644
index 0000000..d16bda5
--- /dev/null
+++ b/tests/cases/compute_one_buffer_in_multiple_bindings.amber
@@ -0,0 +1,94 @@
+#!amber
+# Copyright 2021 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 compute compute_shader GLSL
+#version 430
+
+layout(set = 0, binding = 0) uniform uniform_0 {
+ vec4 uniform_data_0;
+};
+layout(set = 0, binding = 1) buffer block_0 {
+ vec4 storage_data_0;
+};
+
+layout(set = 1, binding = 0) uniform uniform_1 {
+ vec4 uniform_data_1;
+};
+layout(set = 1, binding = 1) buffer block_1 {
+ vec4 storage_data_1;
+};
+
+uniform layout(set = 2, binding = 0, rgba32f) imageBuffer texelBuffer;
+uniform layout(set = 2, binding = 1) samplerBuffer texelsIn;
+
+void main() {
+ // Verify that the uniform and storage buffers have the same contents and multiply by 2 if true)
+ if (uniform_data_0 == storage_data_0) {
+ storage_data_0 = storage_data_0 * 2;
+ }
+ if (uniform_data_1 == storage_data_1) {
+ storage_data_1 = storage_data_1 * 2;
+ }
+
+ // Load values from index 1 using storage texel buffer.
+ vec4 texel = imageLoad(texelBuffer, 1);
+
+ // Load values from index 2 using uniform texel buffer.
+ vec4 color = texelFetch(texelsIn, 2);
+
+ // Store values to index 3.
+ imageStore(texelBuffer, 3, texel + color);
+}
+END
+
+# The Vulkan spec lists the maximum value of minStorageBufferOffsetAlignment
+# (i.e. the maximum possible alignment requirement) as 256 bytes.
+# Meaningful data is placed at this offset.
+BUFFER buf0 DATA_TYPE R32G32B32A32_SFLOAT DATA
+1.0 2.0 3.0 4.0
+0.1 0.2 0.3 0.4
+0.5 0.6 0.7 0.8
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0
+5.0 6.0 7.0 8.0
+END
+
+PIPELINE compute pipeline
+ ATTACH compute_shader
+
+ BIND BUFFER buf0 AS uniform DESCRIPTOR_SET 0 BINDING 0
+ BIND BUFFER buf0 AS storage DESCRIPTOR_SET 0 BINDING 1
+ BIND BUFFER buf0 AS uniform DESCRIPTOR_SET 1 BINDING 0 DESCRIPTOR_OFFSET 256
+ BIND BUFFER buf0 AS storage DESCRIPTOR_SET 1 BINDING 1 DESCRIPTOR_OFFSET 256
+ BIND BUFFER buf0 AS storage_texel_buffer DESCRIPTOR_SET 2 BINDING 0
+ BIND BUFFER buf0 AS uniform_texel_buffer DESCRIPTOR_SET 2 BINDING 1
+END
+
+RUN pipeline 1 1 1
+
+EXPECT buf0 IDX 0 EQ 2.0 4.0 6.0 8.0 # Values written to the first storage buffer binding
+EXPECT buf0 IDX 48 EQ 0.6 0.8 1.0 1.2 # Values written to the storage texel buffer binding
+EXPECT buf0 IDX 256 EQ 10.0 12.0 14.0 16.0 # Values written to the second storage buffer binding
diff --git a/tests/cases/debugger_hlsl_basic_compute.amber b/tests/cases/debugger_hlsl_basic_compute.amber
index 84db5df..f1572b3 100644
--- a/tests/cases/debugger_hlsl_basic_compute.amber
+++ b/tests/cases/debugger_hlsl_basic_compute.amber
@@ -18,7 +18,7 @@ SET ENGINE_DATA fence_timeout_ms 1000000
VIRTUAL_FILE "compute.hlsl"
[[vk::binding(0)]]
-StructuredBuffer<int> data;
+RWStructuredBuffer<int> data;
[numthreads(1,1,1)]
void main() {
diff --git a/tests/cases/debugger_hlsl_basic_vertex.amber b/tests/cases/debugger_hlsl_basic_vertex.amber
index 86d0381..79ea512 100644
--- a/tests/cases/debugger_hlsl_basic_vertex.amber
+++ b/tests/cases/debugger_hlsl_basic_vertex.amber
@@ -106,6 +106,12 @@ CLEAR pipeline
DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6
THREAD VERTEX_INDEX 0
+ EXPECT LOCATION "vs.hlsl" 6 "VS_OUTPUT main(float4 pos : POSITION,"
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 7 " float4 color : COLOR) {"
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 8 " VS_OUTPUT vout;"
+ STEP_IN
EXPECT LOCATION "vs.hlsl" 9 " vout.pos = pos;"
EXPECT LOCAL "pos.x" EQ -1.000000
EXPECT LOCAL "pos.y" EQ -1.000000
diff --git a/tests/cases/debugger_hlsl_function_call.amber b/tests/cases/debugger_hlsl_function_call.amber
index 9504b03..3542b15 100644
--- a/tests/cases/debugger_hlsl_function_call.amber
+++ b/tests/cases/debugger_hlsl_function_call.amber
@@ -18,7 +18,7 @@ SET ENGINE_DATA fence_timeout_ms 1000000
VIRTUAL_FILE "compute.hlsl"
[[vk::binding(0)]]
-StructuredBuffer<int> data;
+RWStructuredBuffer<int> data;
int C(int x)
{
diff --git a/tests/cases/debugger_hlsl_shadowed_vars.amber b/tests/cases/debugger_hlsl_shadowed_vars.amber
index bf8a790..d1f75a5 100644
--- a/tests/cases/debugger_hlsl_shadowed_vars.amber
+++ b/tests/cases/debugger_hlsl_shadowed_vars.amber
@@ -99,7 +99,8 @@ BUFFER framebuffer FORMAT B8G8R8A8_UNORM
PIPELINE graphics pipeline
ATTACH vtex_shader
SHADER_OPTIMIZATION vtex_shader
- --legalize-hlsl
+ --inline-entry-points-exhaustive
+ --eliminate-dead-functions
END
ATTACH frag_shader
@@ -117,6 +118,10 @@ CLEAR pipeline
DEBUG pipeline DRAW_ARRAY AS TRIANGLE_LIST START_IDX 0 COUNT 6
THREAD VERTEX_INDEX 0
+ EXPECT LOCATION "vs.hlsl" 5 "VS_OUTPUT main(float4 pos : POSITION,"
+ STEP_IN
+ EXPECT LOCATION "vs.hlsl" 6 " float4 color : COLOR) {"
+ STEP_IN
EXPECT LOCATION "vs.hlsl" 7 " float a = 1.0;"
STEP_IN
EXPECT LOCATION "vs.hlsl" 8 " float b = 2.0;"
diff --git a/tests/cases/debugger_spirv_line_stepping.amber b/tests/cases/debugger_spirv_line_stepping.amber
index 1d3e33b..478e4fd 100644
--- a/tests/cases/debugger_spirv_line_stepping.amber
+++ b/tests/cases/debugger_spirv_line_stepping.amber
@@ -94,10 +94,16 @@ DEBUG pipeline 1 1 1
END
EXPECT LOCATION "ComputeShader0.spvasm" 20 "%5 = OpVariable %11 Uniform"
STEP_IN
+ EXPECT LOCATION "ComputeShader0.spvasm" 21 "%12 = OpConstant %9 0"
+ STEP_IN
+ EXPECT LOCATION "ComputeShader0.spvasm" 22 "%13 = OpConstant %10 0"
+ STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 25 "%2 = OpVariable %15 Input"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 27 "%6 = OpVariable %11 Uniform"
STEP_IN
+ EXPECT LOCATION "ComputeShader0.spvasm" 29 "%1 = OpFunction %7 None %8"
+ STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 31 "%19 = OpAccessChain %16 %2 %13"
STEP_IN
EXPECT LOCATION "ComputeShader0.spvasm" 32 "%20 = OpLoad %10 %19"
diff --git a/tests/cases/draw_rect_blend.amber b/tests/cases/draw_rect_blend.amber
new file mode 100644
index 0000000..c47b93f
--- /dev/null
+++ b/tests/cases/draw_rect_blend.amber
@@ -0,0 +1,46 @@
+#!amber
+# Copyright 2021 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(1.0, 0.0, 0.0, 0.5);
+}
+END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics pipeline
+ ATTACH vert_shader
+ ATTACH frag_shader
+ BIND BUFFER framebuffer AS color LOCATION 0
+
+ BLEND
+ SRC_COLOR_FACTOR src_alpha
+ DST_COLOR_FACTOR one_minus_src_alpha
+ COLOR_OP add
+ SRC_ALPHA_FACTOR one
+ DST_ALPHA_FACTOR one
+ ALPHA_OP max
+ END
+END
+
+CLEAR_COLOR pipeline 0 255 0 255
+CLEAR pipeline
+RUN pipeline DRAW_RECT POS 0 0 SIZE 250 250
+EXPECT framebuffer IDX 0 0 SIZE 250 250 EQ_RGBA 128 128 0 255 TOLERANCE 5%
diff --git a/tests/cases/float16.amber b/tests/cases/float16.amber
index 88baf13..0a8fd04 100644
--- a/tests/cases/float16.amber
+++ b/tests/cases/float16.amber
@@ -13,9 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-INSTANCE_EXTENSION VK_KHR_get_physical_device_properties2
DEVICE_EXTENSION VK_KHR_shader_float16_int8
+DEVICE_EXTENSION VK_KHR_16bit_storage
+DEVICE_EXTENSION VK_KHR_storage_buffer_storage_class
DEVICE_FEATURE Float16Int8Features.shaderFloat16
+DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
SHADER compute f16 GLSL
#version 450
diff --git a/tests/cases/graphics_descriptor_array_combined_image_sampler.amber b/tests/cases/graphics_descriptor_array_combined_image_sampler.amber
index d7fe3c0..e80ca1e 100644
--- a/tests/cases/graphics_descriptor_array_combined_image_sampler.amber
+++ b/tests/cases/graphics_descriptor_array_combined_image_sampler.amber
@@ -40,10 +40,16 @@ SHADER fragment frag_shader_tex GLSL
#version 430
layout(location = 0) in vec2 texcoords_in;
layout(location = 0) out vec4 color_out;
-uniform layout(set=0, binding=0) sampler2D tex_sampler[2];
+uniform layout(set=0, binding=0) sampler2D tex_sampler_0[2];
+uniform layout(set=0, binding=1) sampler2D tex_sampler_1[2];
void main() {
- color_out = texture(tex_sampler[0], texcoords_in);
- color_out = color_out + texture(tex_sampler[1], texcoords_in);
+ vec4 tex_0_color = texture(tex_sampler_0[0], texcoords_in);
+ color_out = tex_0_color + texture(tex_sampler_0[1], texcoords_in);
+ // tex_sampler_1[0] and tex_sampler_1[1] should be equal to tex_sampler_0[0]
+ if (tex_0_color != texture(tex_sampler_1[0], texcoords_in) ||
+ tex_0_color != texture(tex_sampler_1[1], texcoords_in)) {
+ color_out = vec4(1.0);
+ }
}
END
@@ -75,6 +81,7 @@ PIPELINE graphics pipeline
ATTACH vert_shader_tex
ATTACH frag_shader_tex
BIND BUFFER_ARRAY texture0 texture1 AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0
+ BIND BUFFER_ARRAY texture0 texture0 AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 1
VERTEX_DATA position LOCATION 0
VERTEX_DATA texcoords LOCATION 1
BIND BUFFER framebuffer AS color LOCATION 0
diff --git a/tests/cases/graphics_descriptor_array_sampled_image.amber b/tests/cases/graphics_descriptor_array_sampled_image.amber
index 497f6da..3342054 100644
--- a/tests/cases/graphics_descriptor_array_sampled_image.amber
+++ b/tests/cases/graphics_descriptor_array_sampled_image.amber
@@ -40,11 +40,18 @@ SHADER fragment frag_shader_tex GLSL
#version 430
layout(location = 0) in vec2 texcoords_in;
layout(location = 0) out vec4 color_out;
-uniform layout(set=0, binding=0) texture2D tex[2];
+uniform layout(set=0, binding=0) texture2D tex_0[2];
uniform layout(set=0, binding=1) sampler tex_sampler;
+uniform layout(set=0, binding=2) texture2D tex_1[2];
void main() {
- color_out = texture(sampler2D(tex[0], tex_sampler), texcoords_in);
- color_out += texture(sampler2D(tex[1], tex_sampler), texcoords_in);
+ vec4 tex_0_color = texture(sampler2D(tex_0[0], tex_sampler), texcoords_in);
+ color_out = tex_0_color;
+ color_out += texture(sampler2D(tex_0[1], tex_sampler), texcoords_in);
+ // tex_1[0] and tex_1[1] should be equal to tex_0[0].
+ if (tex_0_color != texture(sampler2D(tex_1[0], tex_sampler), texcoords_in) ||
+ tex_0_color != texture(sampler2D(tex_1[1], tex_sampler), texcoords_in)) {
+ color_out = vec4(1.0);
+ }
}
END
@@ -77,6 +84,7 @@ PIPELINE graphics pipeline
ATTACH frag_shader_tex
BIND BUFFER_ARRAY texture0 texture1 AS sampled_image DESCRIPTOR_SET 0 BINDING 0
BIND SAMPLER sampler DESCRIPTOR_SET 0 BINDING 1
+ BIND BUFFER_ARRAY texture0 texture0 AS sampled_image DESCRIPTOR_SET 0 BINDING 2
VERTEX_DATA position LOCATION 0
VERTEX_DATA texcoords LOCATION 1
BIND BUFFER framebuffer AS color LOCATION 0
diff --git a/tests/cases/multisample_resolve.amber b/tests/cases/multisample_resolve.amber
new file mode 100644
index 0000000..594f9bb
--- /dev/null
+++ b/tests/cases/multisample_resolve.amber
@@ -0,0 +1,50 @@
+#!amber
+# Copyright 2021 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 sampleRateShading
+
+SHADER vertex vert_shader PASSTHROUGH
+
+SHADER fragment frag_shader GLSL
+#version 440
+layout(location = 0) out vec4 color;
+
+void main (void)
+{
+ if (gl_SampleID == 0)
+ color = vec4(1, 0, 0, 1);
+ else if (gl_SampleID == 1)
+ color = vec4(0, 1, 0, 1);
+ else if (gl_SampleID == 2)
+ color = vec4(0, 0, 1, 1);
+ else
+ color = vec4(1, 1, 1, 1);
+}
+END
+
+IMAGE framebuffer_ms FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64 SAMPLES 4
+IMAGE framebuffer FORMAT R8G8B8A8_UNORM DIM_2D WIDTH 64 HEIGHT 64
+
+PIPELINE graphics pipeline
+ ATTACH vert_shader
+ ATTACH frag_shader
+ FRAMEBUFFER_SIZE 64 64
+ BIND BUFFER framebuffer_ms AS color LOCATION 0
+ BIND BUFFER framebuffer AS resolve
+END
+
+RUN pipeline DRAW_RECT POS 0 0 SIZE 64 64
+
+EXPECT framebuffer IDX 0 0 SIZE 64 64 EQ_RGBA 128 128 128 255 TOLERANCE 5%
diff --git a/tests/cases/non_default_entry_point.amber b/tests/cases/non_default_entry_point.amber
index 36b2135..3a0892f 100644
--- a/tests/cases/non_default_entry_point.amber
+++ b/tests/cases/non_default_entry_point.amber
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+DEVICE_EXTENSION VK_KHR_storage_buffer_storage_class
+
SHADER compute my_shader SPIRV-ASM
OpCapability Shader
OpExtension "SPV_KHR_storage_buffer_storage_class"
diff --git a/tests/cases/shader_specialization.amber b/tests/cases/shader_specialization.amber
index 1db2a4f..4514b6f 100644
--- a/tests/cases/shader_specialization.amber
+++ b/tests/cases/shader_specialization.amber
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+DEVICE_EXTENSION VK_KHR_storage_buffer_storage_class
+
SHADER compute my_compute SPIRV-ASM
OpCapability Shader
OpExtension "SPV_KHR_storage_buffer_storage_class"
diff --git a/tests/cases/storage16.amber b/tests/cases/storage16.amber
index 5cf8113..36a62dc 100644
--- a/tests/cases/storage16.amber
+++ b/tests/cases/storage16.amber
@@ -19,6 +19,7 @@ DEVICE_EXTENSION VK_KHR_16bit_storage
DEVICE_FEATURE shaderInt16
DEVICE_FEATURE Storage16BitFeatures.uniformAndStorageBuffer16BitAccess
DEVICE_FEATURE Storage16BitFeatures.storagePushConstant16
+DEVICE_FEATURE Storage16BitFeatures.storageBuffer16BitAccess
SHADER compute comp_shader GLSL
#version 450
diff --git a/tests/cases/tessellation_isolines.amber b/tests/cases/tessellation_isolines.amber
new file mode 100644
index 0000000..dd3f298
--- /dev/null
+++ b/tests/cases/tessellation_isolines.amber
@@ -0,0 +1,130 @@
+#!amber
+# Copyright 2021 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 tessellationShader
+
+SHADER vertex vert GLSL
+#version 450
+
+layout (location = 0) in vec3 inPosition;
+
+void main(void)
+{
+ gl_Position = vec4(inPosition, 1.0);
+}
+END
+
+SHADER tessellation_control tesc GLSL
+#version 450
+
+layout (vertices = 4) out;
+
+void main(void)
+{
+ gl_TessLevelOuter[0] = 6.0;
+ gl_TessLevelOuter[1] = 2.0;
+
+ gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
+}
+END
+
+SHADER tessellation_evaluation tese GLSL
+#version 450
+
+layout (isolines, equal_spacing, cw) in;
+
+void main(void)
+{
+ vec4 p1 = mix(gl_in[0].gl_Position,
+ gl_in[1].gl_Position,
+ gl_TessCoord.x);
+
+ vec4 p2 = mix(gl_in[2].gl_Position,
+ gl_in[3].gl_Position,
+ gl_TessCoord.x);
+
+ gl_Position = mix(p1, p2, gl_TessCoord.y);
+}
+END
+
+SHADER fragment frag GLSL
+#version 450
+
+layout (location = 0) out vec4 outColor;
+
+void main(void)
+{
+ outColor = vec4(1, 0, 0, 1);
+}
+END
+
+SHADER compute comp_shader GLSL
+#version 450
+layout(local_size_x=10,local_size_y=10) in;
+uniform layout(set=0, binding=0, rgba8) image2D resultImage;
+
+layout(set = 0, binding = 1) buffer block0
+{
+ int counter;
+};
+
+void main()
+{
+ ivec2 uv = ivec2(gl_GlobalInvocationID.xy);
+ vec4 color = imageLoad(resultImage, uv);
+ if(color.r > 0.0) atomicAdd(counter, 1);
+}
+END
+
+BUFFER vertexPosition DATA_TYPE vec3<float> DATA
+-1.0 -1.0 0.0
+ 1.0 -1.0 0.0
+-1.0 1.0 0.0
+ 1.0 1.0 0.0
+END
+
+BUFFER counter DATA_TYPE int32 DATA 0 END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics pipeline
+ ATTACH vert
+ ATTACH tesc
+ ATTACH tese
+ ATTACH frag
+
+ PATCH_CONTROL_POINTS 4
+
+ FRAMEBUFFER_SIZE 100 100
+ VERTEX_DATA vertexPosition LOCATION 0
+ BIND BUFFER framebuffer AS color LOCATION 0
+END
+
+CLEAR_COLOR pipeline 0 0 0 255
+CLEAR pipeline
+
+RUN pipeline DRAW_ARRAY AS PATCH_LIST START_IDX 0 COUNT 4
+
+PIPELINE compute verify_pipeline
+ ATTACH comp_shader
+ BIND BUFFER framebuffer AS storage_image DESCRIPTOR_SET 0 BINDING 0
+ BIND BUFFER counter AS storage DESCRIPTOR_SET 0 BINDING 1
+ FRAMEBUFFER_SIZE 100 100
+END
+
+# Count the number of red pixels as the line position might differ between implementations.
+RUN verify_pipeline 10 10 1
+
+EXPECT counter IDX 0 TOLERANCE 50 EQ 500
diff --git a/tests/cases/viewport.amber b/tests/cases/viewport.amber
new file mode 100644
index 0000000..ca9b0a5
--- /dev/null
+++ b/tests/cases/viewport.amber
@@ -0,0 +1,59 @@
+#!amber
+#
+# Copyright 2021 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;
+
+void main() {
+ gl_Position = vec4(position.xy, 0.5, 1.0);
+}
+END
+
+SHADER fragment frag_shader GLSL
+#version 430
+
+layout(location = 0) out vec4 final_color;
+
+void main() {
+ final_color = vec4(0, 1, 0, 1);
+}
+END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+
+PIPELINE graphics pipeline1
+ ATTACH vert_shader
+ ATTACH frag_shader
+
+ FRAMEBUFFER_SIZE 256 256
+ VIEWPORT 10.0 10.0 SIZE 100.0 100.0
+
+ BIND BUFFER framebuffer AS color LOCATION 0
+END
+
+CLEAR_COLOR pipeline1 255 255 255 255
+CLEAR pipeline1
+RUN pipeline1 DRAW_RECT POS 0 0 SIZE 256 256
+
+# Check within the viewport
+EXPECT framebuffer IDX 10 10 SIZE 100 100 EQ_RGBA 0 255 0 255
+# Check the borders were untouched
+EXPECT framebuffer IDX 0 0 SIZE 10 256 EQ_RGBA 255 255 255 255
+EXPECT framebuffer IDX 110 0 SIZE 146 256 EQ_RGBA 255 255 255 255
+EXPECT framebuffer IDX 10 0 SIZE 100 10 EQ_RGBA 255 255 255 255
+EXPECT framebuffer IDX 10 110 SIZE 100 146 EQ_RGBA 255 255 255 255
diff --git a/tests/cases/viewport_depth.amber b/tests/cases/viewport_depth.amber
new file mode 100644
index 0000000..2bf7a9e
--- /dev/null
+++ b/tests/cases/viewport_depth.amber
@@ -0,0 +1,61 @@
+#!amber
+#
+# Copyright 2021 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;
+
+void main() {
+ gl_Position = vec4(position.xy, 0.5, 1.0);
+}
+END
+
+SHADER fragment frag_shader GLSL
+#version 430
+
+layout(location = 0) out vec4 final_color;
+
+void main() {
+ final_color = vec4(0, 1, 0, 1);
+}
+END
+
+BUFFER framebuffer FORMAT B8G8R8A8_UNORM
+BUFFER depth FORMAT D32_SFLOAT
+
+PIPELINE graphics pipeline1
+ ATTACH vert_shader
+ ATTACH frag_shader
+
+ DEPTH
+ TEST on
+ WRITE on
+ END
+
+ FRAMEBUFFER_SIZE 256 256
+ VIEWPORT 0.0 0.0 SIZE 256.0 256.0 MIN_DEPTH 0.3 MAX_DEPTH 0.9
+
+ BIND BUFFER framebuffer AS color LOCATION 0
+ BIND BUFFER depth AS depth_stencil
+END
+
+CLEAR_DEPTH pipeline1 1.0
+CLEAR_COLOR pipeline1 255 255 255 255
+CLEAR pipeline1
+RUN pipeline1 DRAW_RECT POS 0 0 SIZE 256 256
+
+EXPECT depth IDX 0 TOLERANCE 1.0e-6 EQ 0.6