1#!amber 2DEVICE_FEATURE sampleRateShading 3SHADER vertex vert_shader GLSL 4#version 440 5layout(location = 0) in vec4 vs_in_position_ndc; 6layout(location = 1) in float vs_in_position_screen; 7layout(location = 0) out float vs_out_pos_screen; 8void main (void) 9{ 10 gl_Position = vs_in_position_ndc; 11 vs_out_pos_screen = vs_in_position_screen; 12} 13END 14SHADER fragment frag_shader GLSL 15#version 440 16layout(location = 0) sample in float fs_in_pos_screen; 17layout(location = 0) out vec4 fs_out_color; 18void main (void) 19{ 20 const float threshold = 0.0005; 21 const float a = interpolateAtSample(fs_in_pos_screen, gl_SampleID); 22 const float b = fs_in_pos_screen; 23 const bool valuesEqual = (abs(a - b) < threshold); 24 if (valuesEqual) 25 fs_out_color = vec4(0.0, 1.0, 0.0, 1.0); 26 else 27 fs_out_color = vec4(1.0, 0.0, 0.0, 1.0); 28} 29END 30BUFFER position DATA_TYPE vec4<float> DATA 31 1.0 -1.0 0.0 1.0 32 1.0 1.0 0.0 1.0 33-1.0 -1.0 0.0 1.0 34-1.0 1.0 0.0 1.0 35END 36BUFFER position_screen DATA_TYPE float DATA 3764.0 3864.0 39 0.0 40 0.0 41END 42BUFFER framebuffer FORMAT B8G8R8A8_UNORM 43PIPELINE graphics pipeline 44 ATTACH vert_shader 45 ATTACH frag_shader 46 VERTEX_DATA position LOCATION 0 47 VERTEX_DATA position_screen LOCATION 1 48 BIND BUFFER framebuffer AS color LOCATION 0 49 FRAMEBUFFER_SIZE 64 64 50END 51RUN pipeline DRAW_ARRAY AS TRIANGLE_STRIP START_IDX 0 COUNT 4 52EXPECT framebuffer IDX 0 0 SIZE 64 64 EQ_RGBA 0 255 0 255 53