diff options
Diffstat (limited to 'tests/cases/texture_base_mip_level.amber')
-rw-r--r-- | tests/cases/texture_base_mip_level.amber | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/tests/cases/texture_base_mip_level.amber b/tests/cases/texture_base_mip_level.amber new file mode 100644 index 0000000..5b426b9 --- /dev/null +++ b/tests/cases/texture_base_mip_level.amber @@ -0,0 +1,81 @@ +#!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_mipclear PASSTHROUGH + +SHADER vertex vert_shader_tex GLSL +#version 430 + +layout(location = 0) in vec3 position_in; +layout(location = 0) out vec4 color_out; +layout(set = 0, binding = 0) uniform highp sampler2D tex; + +void main() { + gl_Position = vec4(position_in, 1.0); + color_out = vec4(texture(tex, vec2(0.5))); +} +END + +SHADER fragment frag_shader GLSL +#version 430 + +layout(location = 0) in vec4 color_in; +layout(location = 0) out vec4 color_out; + +void main() { + color_out = color_in; +} +END + +BUFFER texture FORMAT B8G8R8A8_UNORM MIP_LEVELS 2 +BUFFER framebuffer FORMAT B8G8R8A8_UNORM +SAMPLER sampler MAX_LOD 2.0 + +PIPELINE graphics mipclear_pipeline0 + ATTACH vert_shader_mipclear + ATTACH frag_shader + BIND BUFFER texture AS color LOCATION 0 BASE_MIP_LEVEL 0 + FRAMEBUFFER_SIZE 512 512 +END + +PIPELINE graphics mipclear_pipeline1 + ATTACH vert_shader_mipclear + ATTACH frag_shader + BIND BUFFER texture AS color LOCATION 0 BASE_MIP_LEVEL 1 + FRAMEBUFFER_SIZE 256 256 +END + +PIPELINE graphics tex_pipeline + ATTACH vert_shader_tex + ATTACH frag_shader + BIND BUFFER texture AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0 BASE_MIP_LEVEL 1 + BIND BUFFER framebuffer AS color LOCATION 0 + FRAMEBUFFER_SIZE 512 512 +END + +CLEAR_COLOR mipclear_pipeline0 255 0 0 255 +CLEAR mipclear_pipeline0 +CLEAR_COLOR mipclear_pipeline1 0 255 0 255 +CLEAR mipclear_pipeline1 + +CLEAR_COLOR tex_pipeline 0 0 0 255 +CLEAR tex_pipeline +RUN tex_pipeline DRAW_RECT POS 0 0 SIZE 512 512 + +# Check corners of the frame buffer: each should have a color from mip level 1 +EXPECT framebuffer IDX 0 511 SIZE 1 1 EQ_RGBA 0 255 0 255 +EXPECT framebuffer IDX 511 0 SIZE 1 1 EQ_RGBA 0 255 0 255 +EXPECT framebuffer IDX 511 511 SIZE 1 1 EQ_RGBA 0 255 0 255 +EXPECT framebuffer IDX 0 0 SIZE 1 1 EQ_RGBA 0 255 0 255 |