1 From b695c3a3fa3f4cd48c13aa26542110de27075518 Mon Sep 17 00:00:00 2001
2 From: Drew Moseley <drew_moseley@mentor.com>
3 Date: Mon, 12 May 2014 15:22:32 -0400
4 Subject: [PATCH 1/9] mesa-demos: Add missing data files.
6 Add some data files that are present in the git repository:
7 http://cgit.freedesktop.org/mesa/demos/tree/?id=mesa-demos-8.1.0
8 but not in the release tarball
9 ftp://ftp.freedesktop.org/pub/mesa/demos/8.1.0/mesa-demos-8.1.0.tar.bz2
11 Upstream-Status: Backport
12 Signed-off-by: Drew Moseley <drew_moseley@mentor.com>
13 Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
15 src/fpglsl/depth-read.glsl | 4 +
16 src/fpglsl/infinite-loop.glsl | 7 +
17 src/glsl/CH11-bumpmaptex.frag | 47 +++++++
18 src/glsl/blinking-teapot.frag | 31 +++++
19 src/glsl/blinking-teapot.vert | 16 +++
20 src/glsl/convolution.frag | 21 +++
21 src/glsl/simplex-noise.glsl | 279 ++++++++++++++++++++++++++++++++++++++++
22 src/glsl/skinning.vert | 24 ++++
23 src/perf/glslstateschange1.frag | 19 +++
24 src/perf/glslstateschange1.vert | 14 ++
25 src/perf/glslstateschange2.frag | 17 +++
26 src/perf/glslstateschange2.vert | 14 ++
27 src/vpglsl/infinite-loop.glsl | 8 ++
28 13 files changed, 501 insertions(+)
29 create mode 100644 src/fpglsl/depth-read.glsl
30 create mode 100644 src/fpglsl/infinite-loop.glsl
31 create mode 100644 src/glsl/CH11-bumpmaptex.frag
32 create mode 100644 src/glsl/blinking-teapot.frag
33 create mode 100644 src/glsl/blinking-teapot.vert
34 create mode 100644 src/glsl/convolution.frag
35 create mode 100644 src/glsl/simplex-noise.glsl
36 create mode 100644 src/glsl/skinning.vert
37 create mode 100644 src/perf/glslstateschange1.frag
38 create mode 100644 src/perf/glslstateschange1.vert
39 create mode 100644 src/perf/glslstateschange2.frag
40 create mode 100644 src/perf/glslstateschange2.vert
41 create mode 100644 src/vpglsl/infinite-loop.glsl
43 diff --git a/src/fpglsl/depth-read.glsl b/src/fpglsl/depth-read.glsl
45 index 0000000..86d298e
47 +++ b/src/fpglsl/depth-read.glsl
51 + gl_FragColor = gl_FragCoord.zzzz;
53 diff --git a/src/fpglsl/infinite-loop.glsl b/src/fpglsl/infinite-loop.glsl
55 index 0000000..c6dc6ee
57 +++ b/src/fpglsl/infinite-loop.glsl
61 + for (int i = 1; i != 2; i += 2) {
62 + sum += vec4(0.1, 0.1, 0.1, 0.1);
66 diff --git a/src/glsl/CH11-bumpmaptex.frag b/src/glsl/CH11-bumpmaptex.frag
68 index 0000000..b5dabb4
70 +++ b/src/glsl/CH11-bumpmaptex.frag
73 +// Fragment shader for procedural bumps
75 +// Authors: John Kessenich, Randi Rost
77 +// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
79 +// See 3Dlabs-License.txt for license information
81 +// Texture mapping/modulation added by Brian Paul
84 +varying vec3 LightDir;
87 +uniform float BumpDensity; // = 16.0
88 +uniform float BumpSize; // = 0.15
89 +uniform float SpecularFactor; // = 0.5
91 +uniform sampler2D Tex;
95 + vec3 ambient = vec3(0.25);
97 + vec2 c = BumpDensity * gl_TexCoord[0].st;
98 + vec2 p = fract(c) - vec2(0.5);
101 + d = p.x * p.x + p.y * p.y;
102 + f = inversesqrt(d + 1.0);
105 + { p = vec2(0.0); f = 1.0; }
107 + vec3 SurfaceColor = texture2D(Tex, gl_TexCoord[0].st).xyz;
109 + vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
110 + litColor = SurfaceColor * (ambient + max(dot(normDelta, LightDir), 0.0));
111 + vec3 reflectDir = reflect(LightDir, normDelta);
113 + float spec = max(dot(EyeDir, reflectDir), 0.0);
114 + spec *= SpecularFactor;
115 + litColor = min(litColor + spec, vec3(1.0));
117 + gl_FragColor = vec4(litColor, 1.0);
119 diff --git a/src/glsl/blinking-teapot.frag b/src/glsl/blinking-teapot.frag
121 index 0000000..0db060b
123 +++ b/src/glsl/blinking-teapot.frag
125 +#extension GL_ARB_uniform_buffer_object : enable
127 +layout(std140) uniform colors0
137 +varying float NdotL;
138 +varying vec3 ReflectVec;
139 +varying vec3 ViewVec;
144 + vec3 kcool = min(CoolColor + DiffuseCool * SurfaceColor, 1.0);
145 + vec3 kwarm = min(WarmColor + DiffuseWarm * SurfaceColor, 1.0);
146 + vec3 kfinal = mix(kcool, kwarm, NdotL);
148 + vec3 nreflect = normalize(ReflectVec);
149 + vec3 nview = normalize(ViewVec);
151 + float spec = max(dot(nreflect, nview), 0.0);
152 + spec = pow(spec, 32.0);
154 + gl_FragColor = vec4 (min(kfinal + spec, 1.0), 1.0);
156 diff --git a/src/glsl/blinking-teapot.vert b/src/glsl/blinking-teapot.vert
158 index 0000000..397d733
160 +++ b/src/glsl/blinking-teapot.vert
162 +vec3 LightPosition = vec3(0.0, 10.0, 4.0);
164 +varying float NdotL;
165 +varying vec3 ReflectVec;
166 +varying vec3 ViewVec;
170 + vec3 ecPos = vec3 (gl_ModelViewMatrix * gl_Vertex);
171 + vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
172 + vec3 lightVec = normalize(LightPosition - ecPos);
173 + ReflectVec = normalize(reflect(-lightVec, tnorm));
174 + ViewVec = normalize(-ecPos);
175 + NdotL = (dot(lightVec, tnorm) + 1.0) * 0.5;
176 + gl_Position = ftransform();
178 diff --git a/src/glsl/convolution.frag b/src/glsl/convolution.frag
180 index 0000000..e49b8ac
182 +++ b/src/glsl/convolution.frag
185 +const int KernelSize = 9;
188 +uniform vec2 Offset[KernelSize];
189 +//convolution kernel
190 +uniform vec4 KernelValue[KernelSize];
191 +uniform sampler2D srcTex;
192 +uniform vec4 ScaleFactor;
193 +uniform vec4 BaseColor;
198 + vec4 sum = vec4(0.0);
199 + for (i = 0; i < KernelSize; ++i) {
200 + vec4 tmp = texture2D(srcTex, gl_TexCoord[0].st + Offset[i]);
201 + sum += tmp * KernelValue[i];
203 + gl_FragColor = sum * ScaleFactor + BaseColor;
205 diff --git a/src/glsl/simplex-noise.glsl b/src/glsl/simplex-noise.glsl
207 index 0000000..b6833cb
209 +++ b/src/glsl/simplex-noise.glsl
212 +// Description : Array and textureless GLSL 2D/3D/4D simplex
214 +// Author : Ian McEwan, Ashima Arts.
216 +// Lastmod : 20110223
217 +// License : Copyright (C) 2011 Ashima Arts. All rights reserved.
218 +// Distributed under the Artistic License 2.0; See LICENCE file.
221 +#define NORMALIZE_GRADIENTS
223 +#define COLLAPSE_SORTNET
225 +float permute(float x0,vec3 p) {
226 + float x1 = mod(x0 * p.y, p.x);
227 + return floor( mod( (x1 + p.z) *x0, p.x ));
229 +vec2 permute(vec2 x0,vec3 p) {
230 + vec2 x1 = mod(x0 * p.y, p.x);
231 + return floor( mod( (x1 + p.z) *x0, p.x ));
233 +vec3 permute(vec3 x0,vec3 p) {
234 + vec3 x1 = mod(x0 * p.y, p.x);
235 + return floor( mod( (x1 + p.z) *x0, p.x ));
237 +vec4 permute(vec4 x0,vec3 p) {
238 + vec4 x1 = mod(x0 * p.y, p.x);
239 + return floor( mod( (x1 + p.z) *x0, p.x ));
242 +uniform vec4 pParam;
244 +// const vec4 pParam = vec4( 17.* 17., 34., 1., 7.);
246 +float taylorInvSqrt(float r)
248 + return ( 0.83666002653408 + 0.7*0.85373472095314 - 0.85373472095314 * r );
251 +float simplexNoise2(vec2 v)
253 + const vec2 C = vec2(0.211324865405187134, // (3.0-sqrt(3.0))/6.;
254 + 0.366025403784438597); // 0.5*(sqrt(3.0)-1.);
255 + const vec3 D = vec3( 0., 0.5, 2.0) * 3.14159265358979312;
257 + vec2 i = floor(v + dot(v, C.yy) );
258 + vec2 x0 = v - i + dot(i, C.xx);
261 + vec2 i1 = (x0.x > x0.y) ? vec2(1.,0.) : vec2(0.,1.) ;
263 + // x0 = x0 - 0. + 0. * C
264 + vec2 x1 = x0 - i1 + 1. * C.xx ;
265 + vec2 x2 = x0 - 1. + 2. * C.xx ;
268 + i = mod(i, pParam.x);
269 + vec3 p = permute( permute(
270 + i.y + vec3(0., i1.y, 1. ), pParam.xyz)
271 + + i.x + vec3(0., i1.x, 1. ), pParam.xyz);
274 +// ( N points uniformly over a line, mapped onto a diamond.)
275 + vec3 x = fract(p / pParam.w) ;
276 + vec3 h = 0.5 - abs(x) ;
278 + vec3 sx = vec3(lessThan(x,D.xxx)) *2. -1.;
279 + vec3 sh = vec3(lessThan(h,D.xxx));
281 + vec3 a0 = x + sx*sh;
282 + vec2 p0 = vec2(a0.x,h.x);
283 + vec2 p1 = vec2(a0.y,h.y);
284 + vec2 p2 = vec2(a0.z,h.z);
286 +#ifdef NORMALISE_GRADIENTS
287 + p0 *= taylorInvSqrt(dot(p0,p0));
288 + p1 *= taylorInvSqrt(dot(p1,p1));
289 + p2 *= taylorInvSqrt(dot(p2,p2));
292 + vec3 g = 2.0 * vec3( dot(p0, x0), dot(p1, x1), dot(p2, x2) );
294 +// N points around a unit circle.
295 + vec3 phi = D.z * mod(p,pParam.w) /pParam.w ;
296 + vec4 a0 = sin(phi.xxyy+D.xyxy);
297 + vec2 a1 = sin(phi.zz +D.xy);
298 + vec3 g = vec3( dot(a0.xy, x0), dot(a0.zw, x1), dot(a1.xy, x2) );
301 + vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.);
303 + return 1.66666* 70.*dot(m*m, g);
306 +float simplexNoise3(vec3 v)
308 + const vec2 C = vec2(1./6. , 1./3. ) ;
309 + const vec4 D = vec4(0., 0.5, 1.0, 2.0);
312 + vec3 i = floor(v + dot(v, C.yyy) );
313 + vec3 x0 = v - i + dot(i, C.xxx) ;
316 +#ifdef COLLAPSE_SORTNET
317 + vec3 g = vec3( greaterThan( x0.xyz, x0.yzx) );
318 + vec3 l = vec3( lessThanEqual( x0.xyz, x0.yzx) );
320 + vec3 i1 = g.xyz * l.zxy;
321 + vec3 i2 = max( g.xyz, l.zxy);
323 +// Keeping this clean - let the compiler optimize.
325 + q1.x = max(x0.x, x0.y);
326 + q1.y = min(x0.x, x0.y);
330 + q2.x = max(q1.x,q1.z);
331 + q2.z = min(q1.x,q1.z);
335 + q3.y = max(q2.y, q2.z);
336 + q3.z = min(q2.y, q2.z);
339 + vec3 i1 = vec3(equal(q3.xxx, x0));
340 + vec3 i2 = i1 + vec3(equal(q3.yyy, x0));
343 + // x0 = x0 - 0. + 0. * C
344 + vec3 x1 = x0 - i1 + 1. * C.xxx;
345 + vec3 x2 = x0 - i2 + 2. * C.xxx;
346 + vec3 x3 = x0 - 1. + 3. * C.xxx;
349 + i = mod(i, pParam.x );
350 + vec4 p = permute( permute( permute(
351 + i.z + vec4(0., i1.z, i2.z, 1. ), pParam.xyz)
352 + + i.y + vec4(0., i1.y, i2.y, 1. ), pParam.xyz)
353 + + i.x + vec4(0., i1.x, i2.x, 1. ), pParam.xyz);
356 +// ( N*N points uniformly over a square, mapped onto a octohedron.)
357 + float n_ = 1.0/pParam.w ;
358 + vec3 ns = n_ * D.wyz - D.xzx ;
360 + vec4 j = p - pParam.w*pParam.w*floor(p * ns.z *ns.z); // mod(p,N*N)
362 + vec4 x_ = floor(j * ns.z) ;
363 + vec4 y_ = floor(j - pParam.w * x_ ) ; // mod(j,N)
365 + vec4 x = x_ *ns.x + ns.yyyy;
366 + vec4 y = y_ *ns.x + ns.yyyy;
367 + vec4 h = 1. - abs(x) - abs(y);
369 + vec4 b0 = vec4( x.xy, y.xy );
370 + vec4 b1 = vec4( x.zw, y.zw );
372 + vec4 s0 = vec4(lessThan(b0,D.xxxx)) *2. -1.;
373 + vec4 s1 = vec4(lessThan(b1,D.xxxx)) *2. -1.;
374 + vec4 sh = vec4(lessThan(h, D.xxxx));
376 + vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;
377 + vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;
379 + vec3 p0 = vec3(a0.xy,h.x);
380 + vec3 p1 = vec3(a0.zw,h.y);
381 + vec3 p2 = vec3(a1.xy,h.z);
382 + vec3 p3 = vec3(a1.zw,h.w);
384 +#ifdef NORMALISE_GRADIENTS
385 + p0 *= taylorInvSqrt(dot(p0,p0));
386 + p1 *= taylorInvSqrt(dot(p1,p1));
387 + p2 *= taylorInvSqrt(dot(p2,p2));
388 + p3 *= taylorInvSqrt(dot(p3,p3));
392 + vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.);
395 + return 48.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1),
396 + dot(p2,x2), dot(p3,x3) ) );
399 +vec4 grad4(float j, vec4 ip)
401 + const vec4 ones = vec4(1.,1.,1.,-1.);
404 + p.xyz = floor( fract (vec3(j) * ip.xyz) *pParam.w) * ip.z -1.0;
405 + p.w = 1.5 - dot(abs(p.xyz), ones.xyz);
406 + s = vec4(lessThan(p,vec4(0.)));
407 + p.xyz = p.xyz + (s.xyz*2.-1.) * s.www;
412 +float simplexNoise4(vec4 v)
414 + const vec2 C = vec2( 0.138196601125010504, // (5 - sqrt(5))/20 G4
415 + 0.309016994374947451); // (sqrt(5) - 1)/4 F4
417 + vec4 i = floor(v + dot(v, C.yyyy) );
418 + vec4 x0 = v - i + dot(i, C.xxxx);
422 +// Force existance of strict total ordering in sort.
423 + vec4 q0 = floor(x0 * 1024.0) + vec4( 0., 1./4., 2./4. , 3./4.);
425 + q1.xy = max(q0.xy,q0.zw); // x:z y:w
426 + q1.zw = min(q0.xy,q0.zw);
429 + q2.xz = max(q1.xz,q1.yw); // x:y z:w
430 + q2.yw = min(q1.xz,q1.yw);
433 + q3.y = max(q2.y,q2.z); // y:z
434 + q3.z = min(q2.y,q2.z);
437 + vec4 i1 = vec4(lessThanEqual(q3.xxxx, q0));
438 + vec4 i2 = vec4(lessThanEqual(q3.yyyy, q0));
439 + vec4 i3 = vec4(lessThanEqual(q3.zzzz, q0));
441 + // x0 = x0 - 0. + 0. * C
442 + vec4 x1 = x0 - i1 + 1. * C.xxxx;
443 + vec4 x2 = x0 - i2 + 2. * C.xxxx;
444 + vec4 x3 = x0 - i3 + 3. * C.xxxx;
445 + vec4 x4 = x0 - 1. + 4. * C.xxxx;
448 + i = mod(i, pParam.x );
449 + float j0 = permute( permute( permute( permute (
450 + i.w, pParam.xyz) + i.z, pParam.xyz)
451 + + i.y, pParam.xyz) + i.x, pParam.xyz);
452 + vec4 j1 = permute( permute( permute( permute (
453 + i.w + vec4(i1.w, i2.w, i3.w, 1. ), pParam.xyz)
454 + + i.z + vec4(i1.z, i2.z, i3.z, 1. ), pParam.xyz)
455 + + i.y + vec4(i1.y, i2.y, i3.y, 1. ), pParam.xyz)
456 + + i.x + vec4(i1.x, i2.x, i3.x, 1. ), pParam.xyz);
458 +// ( N*N*N points uniformly over a cube, mapped onto a 4-octohedron.)
460 + ip.xy *= pParam.w ;
462 + ip = vec4(1.,1.,1.,2.) / ip ;
464 + vec4 p0 = grad4(j0, ip);
465 + vec4 p1 = grad4(j1.x, ip);
466 + vec4 p2 = grad4(j1.y, ip);
467 + vec4 p3 = grad4(j1.z, ip);
468 + vec4 p4 = grad4(j1.w, ip);
470 +#ifdef NORMALISE_GRADIENTS
471 + p0 *= taylorInvSqrt(dot(p0,p0));
472 + p1 *= taylorInvSqrt(dot(p1,p1));
473 + p2 *= taylorInvSqrt(dot(p2,p2));
474 + p3 *= taylorInvSqrt(dot(p3,p3));
475 + p4 *= taylorInvSqrt(dot(p4,p4));
479 + vec3 m0 = max(0.6 - vec3(dot(x0,x0), dot(x1,x1), dot(x2,x2)), 0.);
480 + vec2 m1 = max(0.6 - vec2(dot(x3,x3), dot(x4,x4) ), 0.);
483 + return 32. * ( dot(m0*m0, vec3( dot( p0, x0 ), dot( p1, x1 ), dot( p2, x2 )))
484 + + dot(m1*m1, vec2( dot( p3, x3 ), dot( p4, x4 ) ) ) ) ;
490 diff --git a/src/glsl/skinning.vert b/src/glsl/skinning.vert
492 index 0000000..28970ee
494 +++ b/src/glsl/skinning.vert
496 +// Vertex weighting/blendin shader
500 +uniform mat4 mat0, mat1;
501 +attribute float weight;
505 + // simple diffuse shading
506 + // Note that we should really transform the normal vector along with
507 + // the postion below... someday.
508 + vec3 lightVec = vec3(0, 0, 1);
509 + vec3 norm = gl_NormalMatrix * gl_Normal;
510 + float dot = 0.2 + max(0.0, dot(norm, lightVec));
511 + gl_FrontColor = vec4(dot);
513 + // compute sum of weighted transformations
514 + vec4 pos0 = mat0 * gl_Vertex;
515 + vec4 pos1 = mat1 * gl_Vertex;
516 + vec4 pos = mix(pos0, pos1, weight);
518 + gl_Position = gl_ModelViewProjectionMatrix * pos;
520 diff --git a/src/perf/glslstateschange1.frag b/src/perf/glslstateschange1.frag
522 index 0000000..0839436
524 +++ b/src/perf/glslstateschange1.frag
526 +// Multi-texture fragment shader
529 +// Composite second texture over first.
530 +// We're assuming the 2nd texture has a meaningful alpha channel.
532 +uniform sampler2D tex1;
533 +uniform sampler2D tex2;
540 + vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy);
541 + vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy);
542 + t3 = mix(t1, t2, t2.w);
543 + gl_FragColor = t3 + UniV1 + UniV2;
545 diff --git a/src/perf/glslstateschange1.vert b/src/perf/glslstateschange1.vert
547 index 0000000..cef50db
549 +++ b/src/perf/glslstateschange1.vert
551 +// Multi-texture vertex shader
555 +attribute vec4 TexCoord0, TexCoord1;
556 +attribute vec4 VertCoord;
560 + gl_TexCoord[0] = TexCoord0;
561 + gl_TexCoord[1] = TexCoord1;
562 + // note: may use gl_Vertex or VertCoord here for testing:
563 + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
565 diff --git a/src/perf/glslstateschange2.frag b/src/perf/glslstateschange2.frag
567 index 0000000..0df0319
569 +++ b/src/perf/glslstateschange2.frag
571 +// Multi-texture fragment shader
574 +// Composite second texture over first.
575 +// We're assuming the 2nd texture has a meaningful alpha channel.
577 +uniform sampler2D tex1;
578 +uniform sampler2D tex2;
584 + vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy);
585 + vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy);
586 + gl_FragColor = t1 + t2 + UniV1 + UniV2;
588 diff --git a/src/perf/glslstateschange2.vert b/src/perf/glslstateschange2.vert
590 index 0000000..cef50db
592 +++ b/src/perf/glslstateschange2.vert
594 +// Multi-texture vertex shader
598 +attribute vec4 TexCoord0, TexCoord1;
599 +attribute vec4 VertCoord;
603 + gl_TexCoord[0] = TexCoord0;
604 + gl_TexCoord[1] = TexCoord1;
605 + // note: may use gl_Vertex or VertCoord here for testing:
606 + gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
608 diff --git a/src/vpglsl/infinite-loop.glsl b/src/vpglsl/infinite-loop.glsl
610 index 0000000..bc7ae4b
612 +++ b/src/vpglsl/infinite-loop.glsl
615 + gl_Position = gl_Vertex;
616 + vec4 sum = vec4(0);
617 + for (int i = 1; i != 2; i += 2) {
618 + sum += vec4(0.1, 0.1, 0.1, 0.1);
620 + gl_FrontColor = sum;