| #!amber |
| # Copyright 2020 Google LLC |
| # |
| # 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 |
| # |
| # http://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 vec2 position_in; |
| layout(location = 1) in vec4 color_in0; |
| layout(location = 2) in vec4 color_in1; |
| layout(location = 0) out vec4 color_out0; |
| layout(location = 1) out vec4 color_out1; |
| |
| void main() |
| { |
| gl_Position = vec4(position_in, 0, 1); |
| color_out0 = color_in0; |
| color_out1 = color_in1; |
| } |
| END |
| |
| SHADER fragment frag_shader GLSL |
| #version 430 |
| layout(location = 0) in vec4 color_in0; |
| layout(location = 1) in vec4 color_in1; |
| layout(location = 0) out vec4 frag_out0; |
| layout(location = 1) out vec4 frag_out1; |
| void main() |
| { |
| if (((int(gl_FragCoord.x) / 5) % 2) == ((int(gl_FragCoord.y) / 5) % 2)) |
| { |
| frag_out0 = color_in0; |
| frag_out1 = color_in1; |
| } |
| else |
| { |
| frag_out0 = color_in1; |
| frag_out1 = color_in0; |
| } |
| } |
| END |
| |
| SHADER vertex vert_shader_ref PASSTHROUGH |
| |
| SHADER fragment frag_shader_ref0 GLSL |
| #version 430 |
| layout(location = 0) out vec4 frag_out; |
| void main() |
| { |
| if (((int(gl_FragCoord.x) / 5) % 2) == ((int(gl_FragCoord.y) / 5) % 2)) |
| frag_out = vec4(1, 0, 0, 1); |
| else |
| frag_out = vec4(0, 1, 0, 1); |
| } |
| END |
| |
| SHADER fragment frag_shader_ref1 GLSL |
| #version 430 |
| layout(location = 0) out vec4 frag_out; |
| void main() |
| { |
| if (((int(gl_FragCoord.x) / 5) % 2) == ((int(gl_FragCoord.y) / 5) % 2)) |
| frag_out = vec4(0, 1, 0, 1); |
| else |
| frag_out = vec4(1, 0, 0, 1); |
| } |
| END |
| |
| |
| BUFFER framebuffer0 FORMAT B8G8R8A8_UNORM |
| BUFFER framebuffer1 FORMAT B8G8R8A8_UNORM |
| |
| BUFFER ref0 FORMAT B8G8R8A8_UNORM |
| BUFFER ref1 FORMAT B8G8R8A8_UNORM |
| |
| BUFFER position DATA_TYPE vec2<float> DATA |
| -1.0 -1.0 |
| 1.0 -1.0 |
| 1.0 1.0 |
| -1.0 1.0 |
| END |
| |
| BUFFER color0 DATA_TYPE R8G8B8A8_UNORM DATA |
| 255 0 0 255 |
| 255 0 0 255 |
| 255 0 0 255 |
| 255 0 0 255 |
| END |
| |
| BUFFER color1 DATA_TYPE R8G8B8A8_UNORM DATA |
| 0 255 0 255 |
| 0 255 0 255 |
| 0 255 0 255 |
| 0 255 0 255 |
| END |
| |
| PIPELINE graphics pipeline |
| ATTACH vert_shader |
| ATTACH frag_shader |
| VERTEX_DATA position LOCATION 0 |
| VERTEX_DATA color0 LOCATION 1 |
| VERTEX_DATA color1 LOCATION 2 |
| BIND BUFFER framebuffer0 AS color LOCATION 0 |
| BIND BUFFER framebuffer1 AS color LOCATION 1 |
| FRAMEBUFFER_SIZE 60 60 |
| END |
| |
| PIPELINE graphics pipeline_ref0 |
| ATTACH vert_shader_ref |
| ATTACH frag_shader_ref0 |
| BIND BUFFER ref0 AS color LOCATION 0 |
| FRAMEBUFFER_SIZE 60 60 |
| END |
| |
| PIPELINE graphics pipeline_ref1 |
| ATTACH vert_shader_ref |
| ATTACH frag_shader_ref1 |
| BIND BUFFER ref1 AS color LOCATION 0 |
| FRAMEBUFFER_SIZE 60 60 |
| END |
| |
| RUN pipeline DRAW_ARRAY AS TRIANGLE_FAN START_IDX 0 COUNT 4 |
| RUN pipeline_ref0 DRAW_RECT POS 0 0 SIZE 60 60 |
| RUN pipeline_ref1 DRAW_RECT POS 0 0 SIZE 60 60 |
| EXPECT framebuffer0 EQ_BUFFER ref0 |
| EXPECT framebuffer1 EQ_BUFFER ref1 |