File: fs-dfdy-accuracy.shader_test

package info (click to toggle)
piglit 0~git20200212-f4710c51b-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 106,972 kB
  • sloc: ansic: 263,763; xml: 48,941; python: 29,918; lisp: 19,789; cpp: 12,142; sh: 22; makefile: 20; pascal: 5
file content (38 lines) | stat: -rw-r--r-- 968 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# The spec allows considerable leeway in how dFdy() is calculated,
# however the expected implementation is via forward or backward
# differencing.  (Implementations are permitted, for instance, to use
# forward differencing for some pixels and backward differencing for
# other pixels).
#
# This test computes dFdy(x*y), which should exactly equal x at every
# pixel, regardless of whether forward or backward differencing is
# used.
#
# The test expects that GL_FRAGMENT_SHADER_DERIVATIVE_HINT is not ignored.

[require]
GLSL >= 1.10

[vertex shader]
void main()
{
	gl_Position = gl_Vertex;
}

[fragment shader]
void main()
{
	float x = gl_FragCoord.x;
	float y = gl_FragCoord.y;
	float xy = x * y;
	float dxydy = dFdy(xy);
	if (distance(dxydy, x) > 1.0e-3)
		gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
	else
		gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
}

[test]
hint GL_FRAGMENT_SHADER_DERIVATIVE_HINT GL_NICEST
draw rect -1 -1 2 2
probe warn all rgba 0.0 1.0 0.0 1.0