yes
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
#!amber
|
||||
|
||||
# Copyright 2019 Google LLC.
|
||||
# Copyright 2019 The Khronos Group Inc.
|
||||
#
|
||||
# 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_lod 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);
|
||||
// Pick a color from the center of a mipmap. Each corner point gets its own mip level.
|
||||
color_out = vec4(textureLod(tex, vec2(0.5), float(gl_VertexIndex % 4)));
|
||||
}
|
||||
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 4
|
||||
BUFFER framebuffer FORMAT B8G8R8A8_UNORM
|
||||
SAMPLER sampler MAX_LOD 4.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 mipclear_pipeline2
|
||||
ATTACH vert_shader_mipclear
|
||||
ATTACH frag_shader
|
||||
BIND BUFFER texture AS color LOCATION 0 BASE_MIP_LEVEL 2
|
||||
FRAMEBUFFER_SIZE 128 128
|
||||
END
|
||||
|
||||
PIPELINE graphics mipclear_pipeline3
|
||||
ATTACH vert_shader_mipclear
|
||||
ATTACH frag_shader
|
||||
BIND BUFFER texture AS color LOCATION 0 BASE_MIP_LEVEL 3
|
||||
FRAMEBUFFER_SIZE 64 64
|
||||
END
|
||||
|
||||
PIPELINE graphics lod_pipeline
|
||||
ATTACH vert_shader_lod
|
||||
ATTACH frag_shader
|
||||
BIND BUFFER texture AS combined_image_sampler SAMPLER sampler DESCRIPTOR_SET 0 BINDING 0
|
||||
BIND BUFFER framebuffer AS color LOCATION 0
|
||||
FRAMEBUFFER_SIZE 512 512
|
||||
END
|
||||
|
||||
# Clear all mip levels to different color.
|
||||
CLEAR_COLOR mipclear_pipeline0 255 0 0 255
|
||||
CLEAR mipclear_pipeline0
|
||||
CLEAR_COLOR mipclear_pipeline1 0 255 0 255
|
||||
CLEAR mipclear_pipeline1
|
||||
CLEAR_COLOR mipclear_pipeline2 0 0 255 255
|
||||
CLEAR mipclear_pipeline2
|
||||
CLEAR_COLOR mipclear_pipeline3 255 255 0 255
|
||||
CLEAR mipclear_pipeline3
|
||||
|
||||
CLEAR_COLOR lod_pipeline 0 0 0 255
|
||||
CLEAR lod_pipeline
|
||||
RUN lod_pipeline DRAW_RECT POS 0 0 SIZE 512 512
|
||||
|
||||
# Check corners of the frame buffer: each should have a color from a different mip level.
|
||||
EXPECT framebuffer IDX 0 511 SIZE 1 1 EQ_RGBA 255 0 0 255
|
||||
EXPECT framebuffer IDX 511 0 SIZE 1 1 EQ_RGBA 255 255 0 255
|
||||
EXPECT framebuffer IDX 511 511 SIZE 1 1 EQ_RGBA 0 0 255 255
|
||||
EXPECT framebuffer IDX 0 0 SIZE 1 1 EQ_RGBA 0 255 0 255
|
||||
Reference in New Issue
Block a user