Compare commits
84 Commits
mesa_7_5_r
...
intel_2009
Author | SHA1 | Date | |
---|---|---|---|
|
022e8e582e | ||
|
1c1307e7c5 | ||
|
cff2126f52 | ||
|
a79586ce18 | ||
|
f01af4dbd2 | ||
|
762c1d11ff | ||
|
baa7ff47d5 | ||
|
ca1b71b78d | ||
|
6ff1a5385e | ||
|
cade071d52 | ||
|
fcd3572edf | ||
|
78af70be37 | ||
|
c86b076668 | ||
|
abdb0fdcc0 | ||
|
36e906aad6 | ||
|
4adc9b4a5b | ||
|
7b861b9b9e | ||
|
71633abafc | ||
|
25b492b976 | ||
|
96601ec8e0 | ||
|
a4d952358d | ||
|
7fb4becf98 | ||
|
1068c15c61 | ||
|
6f4167c8a2 | ||
|
5470a67335 | ||
|
fc6e02ce62 | ||
|
c30f23c123 | ||
|
94e1117c9b | ||
|
f580494bef | ||
|
b928d18398 | ||
|
aa98575ebb | ||
|
cffe7c8bd0 | ||
|
2a2236606f | ||
|
588c862571 | ||
|
798cd2a98d | ||
|
1668a679c4 | ||
|
b3e8e1cd4c | ||
|
1fa4cde757 | ||
|
70ae7ba818 | ||
|
c48c01c9e7 | ||
|
1ca836f0de | ||
|
d6c2347d79 | ||
|
09a3a28fc8 | ||
|
7e91d035b9 | ||
|
2e570be852 | ||
|
1730eaa2a2 | ||
|
4147bb24d4 | ||
|
6af783bea0 | ||
|
a9ae89d104 | ||
|
6dfb89e4a0 | ||
|
cea259f039 | ||
|
79047cc1dd | ||
|
f6c8ca06f6 | ||
|
4c31632817 | ||
|
fa5b0364f9 | ||
|
52f895df51 | ||
|
14a2b5445a | ||
|
6e09c1fd08 | ||
|
18a6f0f1a7 | ||
|
4ffe2844a4 | ||
|
578230dbbf | ||
|
a4fd94a54a | ||
|
ba7f45ac0c | ||
|
f2de2d5f37 | ||
|
e2a8ef4430 | ||
|
6c913411d3 | ||
|
1c04731b87 | ||
|
e8c4663c11 | ||
|
c72261f2a8 | ||
|
57955451f8 | ||
|
e5cb11adda | ||
|
53f8dccd0c | ||
|
00438bb94a | ||
|
0846c88ec3 | ||
|
aa688d1579 | ||
|
8d24160a40 | ||
|
47173cf67f | ||
|
4e43126a59 | ||
|
b1f2f92d9b | ||
|
9014f475ff | ||
|
b799af91d5 | ||
|
9a5ee12434 | ||
|
bb8f3090ba | ||
|
72ad039d19 |
@@ -642,7 +642,7 @@ dnl Which drivers to build - default is chosen by platform
|
||||
AC_ARG_WITH([dri-drivers],
|
||||
[AS_HELP_STRING([--with-dri-drivers@<:@=DIRS...@:>@],
|
||||
[comma delimited DRI drivers list, e.g.
|
||||
"swrast,i965,radeon,nouveau" @<:@default=auto@:>@])],
|
||||
"swrast,i965,radeon" @<:@default=auto@:>@])],
|
||||
[with_dri_drivers="$withval"],
|
||||
[with_dri_drivers=yes])
|
||||
if test "x$with_dri_drivers" = x; then
|
||||
|
@@ -70,6 +70,8 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
|
||||
<li>Initial support for separate compilation units in GLSL compiler.
|
||||
<li>Increased max number of generic GLSL varying variables to 16 (formerly 8).
|
||||
<li>GLSL linker now detects when too many varying variables are used.
|
||||
<li>Optimize-out redundant glMaterial and glShadeModel calls in display lists
|
||||
<li>Fixed gl_TextureMatrix[i][j] array indexing bug in GLSL compiler.
|
||||
</ul>
|
||||
|
||||
|
||||
|
@@ -1,6 +1,7 @@
|
||||
SConscript([
|
||||
'util/SConscript',
|
||||
'demos/SConscript',
|
||||
'glsl/SConscript',
|
||||
'redbook/SConscript',
|
||||
'samples/SConscript',
|
||||
'tests/SConscript',
|
||||
|
@@ -514,12 +514,27 @@ static void draw_surface( unsigned int with_state )
|
||||
break;
|
||||
|
||||
case (GLVERTEX|STRIPS):
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
glNormal3fv( &data[i][3] );
|
||||
glVertex3fv( &data[i][0] );
|
||||
if (with_state & MATERIALS) {
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
if (i % 600 == 0 && i != 0) {
|
||||
unsigned j = i / 600;
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, col[j]);
|
||||
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, col[j]);
|
||||
}
|
||||
glNormal3fv( &data[i][3] );
|
||||
glVertex3fv( &data[i][0] );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
else {
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
for (i=0;i<numverts;i++) {
|
||||
glNormal3fv( &data[i][3] );
|
||||
glVertex3fv( &data[i][0] );
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
glEnd();
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -10,7 +10,7 @@ LIB_DEP = \
|
||||
$(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \
|
||||
$(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
|
||||
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/progs/util
|
||||
|
||||
|
55
progs/glsl/SConscript
Normal file
55
progs/glsl/SConscript
Normal file
@@ -0,0 +1,55 @@
|
||||
Import('*')
|
||||
|
||||
if not env['GLUT']:
|
||||
Return()
|
||||
|
||||
env = env.Clone()
|
||||
|
||||
env.Prepend(CPPPATH = [
|
||||
'../util',
|
||||
])
|
||||
|
||||
env.Prepend(LIBS = [
|
||||
util,
|
||||
'$GLUT_LIB'
|
||||
])
|
||||
|
||||
if env['platform'] == 'windows':
|
||||
env.Append(CPPDEFINES = ['NOMINMAX'])
|
||||
env.Prepend(LIBS = ['winmm'])
|
||||
|
||||
progs = [
|
||||
'array',
|
||||
'bitmap',
|
||||
'brick',
|
||||
'bump',
|
||||
'convolutions',
|
||||
'deriv',
|
||||
'fragcoord',
|
||||
'identity',
|
||||
'linktest',
|
||||
'mandelbrot',
|
||||
'multinoise',
|
||||
'multitex',
|
||||
'noise',
|
||||
'noise2',
|
||||
'pointcoord',
|
||||
'points',
|
||||
'samplers',
|
||||
'shadow_sampler',
|
||||
'skinning',
|
||||
'texaaline',
|
||||
'texdemo1',
|
||||
'toyball',
|
||||
'trirast',
|
||||
'twoside',
|
||||
'vert-or-frag-only',
|
||||
'vert-tex',
|
||||
]
|
||||
|
||||
for prog in progs:
|
||||
env.Program(
|
||||
target = prog,
|
||||
source = prog + '.c',
|
||||
)
|
||||
|
@@ -9,9 +9,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
|
||||
@@ -248,6 +248,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(500, 500);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -309,6 +310,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -191,6 +192,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -288,6 +288,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -5,6 +5,8 @@
|
||||
* Author: Zack Rusin
|
||||
*/
|
||||
|
||||
#include <GL/glew.h>
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include "readtex.h"
|
||||
|
||||
@@ -455,6 +457,7 @@ int main(int argc, char **argv)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
init();
|
||||
|
||||
glutReshapeFunc(reshape);
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -228,6 +229,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(200, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -174,6 +175,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -195,6 +196,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(200, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -245,6 +246,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(300, 300);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -206,6 +207,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -270,6 +271,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
@@ -334,6 +335,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(500, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutCreateWindow(Demo);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(specialkey);
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -207,6 +208,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -195,6 +196,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -248,6 +249,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -11,6 +11,7 @@ void main()
|
||||
float two_n_dot_u = 2.0 * dot(n, u);
|
||||
vec4 f;
|
||||
f.xyz = u - n * two_n_dot_u;
|
||||
f.w = 1.0;
|
||||
|
||||
// outputs
|
||||
normal = n;
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
@@ -357,6 +358,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(500, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
glutCreateWindow(Demo);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(specialkey);
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -329,6 +330,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 300);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -266,6 +267,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(500, 500);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -359,6 +360,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
#include "extfuncs.h"
|
||||
@@ -426,6 +427,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(500, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(Demo);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(key);
|
||||
glutSpecialFunc(specialkey);
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -212,6 +213,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -247,6 +248,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -12,6 +12,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -293,6 +294,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -181,6 +182,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(400, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Redisplay);
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glut.h>
|
||||
#include <GL/glext.h>
|
||||
@@ -266,6 +267,7 @@ main(int argc, char *argv[])
|
||||
glutInitWindowSize(500, 500);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
|
2
progs/tests/.gitignore
vendored
2
progs/tests/.gitignore
vendored
@@ -55,6 +55,7 @@ multipal
|
||||
no_s3tc
|
||||
packedpixels
|
||||
pbo
|
||||
prim
|
||||
prog_parameter
|
||||
quads
|
||||
random
|
||||
@@ -77,6 +78,7 @@ subtex
|
||||
subtexrate
|
||||
tex1d
|
||||
texcompress2
|
||||
texcompsub
|
||||
texdown
|
||||
texfilt
|
||||
texline
|
||||
|
@@ -83,6 +83,7 @@ SOURCES = \
|
||||
subtexrate.c \
|
||||
tex1d.c \
|
||||
texcompress2.c \
|
||||
texcompsub.c \
|
||||
texdown \
|
||||
texfilt.c \
|
||||
texline.c \
|
||||
|
@@ -108,6 +108,7 @@ progs = [
|
||||
'tex1d',
|
||||
'texcmp',
|
||||
'texcompress2',
|
||||
'texcompsub',
|
||||
'texdown',
|
||||
'texfilt',
|
||||
'texgenmix',
|
||||
|
4100
progs/tests/texcomp_image.h
Normal file
4100
progs/tests/texcomp_image.h
Normal file
File diff suppressed because it is too large
Load Diff
165
progs/tests/texcompsub.c
Normal file
165
progs/tests/texcompsub.c
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Test texture compression.
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
#include "texcomp_image.h"
|
||||
|
||||
static int ImgWidth = 512;
|
||||
static int ImgHeight = 512;
|
||||
static GLenum CompFormat = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
||||
static GLfloat EyeDist = 5.0;
|
||||
static GLfloat Rot = 0.0;
|
||||
const GLenum Target = GL_TEXTURE_2D;
|
||||
|
||||
|
||||
static void
|
||||
CheckError(int line)
|
||||
{
|
||||
GLenum err = glGetError();
|
||||
if (err) {
|
||||
printf("GL Error %d at line %d\n", (int) err, line);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
LoadCompressedImage(void)
|
||||
{
|
||||
const GLenum filter = GL_LINEAR;
|
||||
glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
/* bottom half */
|
||||
glCompressedTexSubImage2DARB(Target, 0,
|
||||
0, 0, /* pos */
|
||||
ImgWidth, ImgHeight / 2,
|
||||
CompFormat, ImgSize / 2, ImgData + ImgSize / 2);
|
||||
/* top half */
|
||||
glCompressedTexSubImage2DARB(Target, 0,
|
||||
0, ImgHeight / 2, /* pos */
|
||||
ImgWidth, ImgHeight / 2,
|
||||
CompFormat, ImgSize / 2, ImgData);
|
||||
|
||||
glTexParameteri(Target, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(Target, GL_TEXTURE_MAG_FILTER, filter);
|
||||
}
|
||||
|
||||
static void
|
||||
Init()
|
||||
{
|
||||
GLint numFormats, formats[100];
|
||||
GLint p;
|
||||
|
||||
if (!glutExtensionSupported("GL_ARB_texture_compression")) {
|
||||
printf("Sorry, GL_ARB_texture_compression is required.\n");
|
||||
exit(1);
|
||||
}
|
||||
if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) {
|
||||
printf("Sorry, GL_EXT_texture_compression_s3tc is required.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, &numFormats);
|
||||
glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS_ARB, formats);
|
||||
printf("%d supported compression formats: ", numFormats);
|
||||
for (p = 0; p < numFormats; p++)
|
||||
printf("0x%x ", formats[p]);
|
||||
printf("\n");
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
|
||||
LoadCompressedImage();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape( int width, int height )
|
||||
{
|
||||
glViewport( 0, 0, width, height );
|
||||
glMatrixMode( GL_PROJECTION );
|
||||
glLoadIdentity();
|
||||
glFrustum(-1, 1, -1, 1, 4, 100);
|
||||
glMatrixMode( GL_MODELVIEW );
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key( unsigned char key, int x, int y )
|
||||
{
|
||||
(void) x;
|
||||
(void) y;
|
||||
switch (key) {
|
||||
case 'd':
|
||||
EyeDist -= 1.0;
|
||||
if (EyeDist < 4.0)
|
||||
EyeDist = 4.0;
|
||||
break;
|
||||
case 'D':
|
||||
EyeDist += 1.0;
|
||||
break;
|
||||
case 'z':
|
||||
Rot += 5.0;
|
||||
break;
|
||||
case 'Z':
|
||||
Rot -= 5.0;
|
||||
break;
|
||||
case 27:
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Draw( void )
|
||||
{
|
||||
glClearColor(0.3, 0.3, .8, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
CheckError(__LINE__);
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0, -(EyeDist+0.01));
|
||||
glRotatef(Rot, 0, 0, 1);
|
||||
glBegin(GL_POLYGON);
|
||||
glTexCoord2f(0, 0); glVertex2f(-1, -1);
|
||||
glTexCoord2f(1, 0); glVertex2f( 1, -1);
|
||||
glTexCoord2f(1, 1); glVertex2f( 1, 1);
|
||||
glTexCoord2f(0, 1); glVertex2f(-1, 1);
|
||||
glEnd();
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main( int argc, char *argv[] )
|
||||
{
|
||||
glutInit( &argc, argv );
|
||||
glutInitWindowSize( 600, 600 );
|
||||
|
||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE);
|
||||
|
||||
glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
|
||||
glutReshapeFunc( Reshape );
|
||||
glutKeyboardFunc( Key );
|
||||
glutDisplayFunc( Draw );
|
||||
|
||||
Init();
|
||||
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -19,6 +19,12 @@ SOURCES = \
|
||||
clear-random.c \
|
||||
clear.c \
|
||||
dlist-dangling.c \
|
||||
dlist-flat-tri.c \
|
||||
dlist-mat-tri.c \
|
||||
dlist-tri-flat-tri.c \
|
||||
dlist-tri-mat-tri.c \
|
||||
dlist-recursive-call.c \
|
||||
dlist-begin-call-end.c \
|
||||
dlist-edgeflag-dangling.c \
|
||||
dlist-edgeflag.c \
|
||||
dlist-degenerate.c \
|
||||
@@ -105,6 +111,7 @@ SOURCES = \
|
||||
tri-fp.c \
|
||||
tri-fp-const-imm.c \
|
||||
tri-lit.c \
|
||||
tri-lit-material.c \
|
||||
tri-mask-tri.c \
|
||||
tri-orig.c \
|
||||
tri-query.c \
|
||||
|
159
progs/trivial/dlist-begin-call-end.c
Normal file
159
progs/trivial/dlist-begin-call-end.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||
* ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
GLint first_list, list;
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
/* First list will disrupt state which might potentially be
|
||||
* short-circuited in calling list:
|
||||
*/
|
||||
first_list = glGenLists(1);
|
||||
glNewList(first_list, GL_COMPILE);
|
||||
// glColor3f(0,1,0);
|
||||
glEndList();
|
||||
|
||||
|
||||
/* List that looks like it might have redundant state:
|
||||
*/
|
||||
list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( -0.9, 0.9, -30.0);
|
||||
glVertex3f( -0.9, -0.9, -30.0);
|
||||
glCallList( first_list );
|
||||
glVertex3f( 0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
glEndList();
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
glCallList(list);
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_ALPHA;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
171
progs/trivial/dlist-flat-tri.c
Normal file
171
progs/trivial/dlist-flat-tri.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||
* ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
GLint list;
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
|
||||
/* XXX: this state-change will only be executed if list is called
|
||||
* from outside a begin/end pair:
|
||||
*/
|
||||
glShadeModel( GL_FLAT );
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,.7);
|
||||
glVertex3f( -0.9, 0.9, -30.0);
|
||||
glColor3f(0,.9,0);
|
||||
glVertex3f( -0.9, -0.9, -30.0);
|
||||
glColor3f(.8,0,0);
|
||||
glVertex3f( 0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
/* This statechange is potentially NOT redundant:
|
||||
*/
|
||||
glShadeModel( GL_FLAT );
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f( -0.5, 0.5, -30.0);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( -0.5, -0.5, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.5, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
/* Note: call the list from inside a begin/end pair. The end is
|
||||
* provided by the display list...
|
||||
*/
|
||||
glCallList(list);
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_ALPHA;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
182
progs/trivial/dlist-mat-tri.c
Normal file
182
progs/trivial/dlist-mat-tri.c
Normal file
@@ -0,0 +1,182 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||
* ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
GLint list;
|
||||
|
||||
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
||||
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
||||
/*static GLfloat blue[4] = {0.2, 0.2, .7, 1.0};*/
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
|
||||
/* XXX: this state-change will be executed regardless of whether
|
||||
* the list is called from outside a begin/end pair:
|
||||
*/
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT, red);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f( -0.9, 0.9, -30.0);
|
||||
glVertex3f( -0.9, -0.9, -30.0);
|
||||
glVertex3f( 0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_DIFFUSE, red);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f( -0.7, 0.7, -30.0);
|
||||
glVertex3f( -0.7, -0.7, -30.0);
|
||||
glVertex3f( 0.7, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
/* This statechange is redundant:
|
||||
*/
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f( -0.5, 0.5, -30.0);
|
||||
glVertex3f( -0.5, -0.5, -30.0);
|
||||
glVertex3f( 0.5, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
|
||||
/* Note: call the list from inside a begin/end pair. The end is
|
||||
* provided by the display list...
|
||||
*/
|
||||
glCallList(list);
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_ALPHA;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
190
progs/trivial/dlist-recursive-call.c
Normal file
190
progs/trivial/dlist-recursive-call.c
Normal file
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||
* ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
GLint first_list, list;
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
/* First list will disrupt state which might potentially be
|
||||
* short-circuited in calling list:
|
||||
*/
|
||||
first_list = glGenLists(1);
|
||||
glNewList(first_list, GL_COMPILE);
|
||||
glShadeModel( GL_SMOOTH );
|
||||
glEndList();
|
||||
|
||||
|
||||
/* List that looks like it might have redundant state:
|
||||
*/
|
||||
list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,.7);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(.8,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,.9,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glShadeModel( GL_FLAT );
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,.7);
|
||||
glVertex3f( -0.9, 0.9, -30.0);
|
||||
glColor3f(0,.9,0);
|
||||
glVertex3f( -0.9, -0.9, -30.0);
|
||||
glColor3f(.8,0,0);
|
||||
glVertex3f( 0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glCallList( first_list );
|
||||
|
||||
/* Do a quick begin/end to ensure we are not inside a dangling
|
||||
* primitive from the called list:
|
||||
*/
|
||||
glBegin( GL_POINTS );
|
||||
glEnd();
|
||||
|
||||
/* This statechange is NOT redundant:
|
||||
*/
|
||||
glShadeModel( GL_FLAT );
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( -0.5, 0.5, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f( -0.5, -0.5, -30.0);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.5, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
glCallList(list);
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_ALPHA;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
171
progs/trivial/dlist-tri-flat-tri.c
Normal file
171
progs/trivial/dlist-tri-flat-tri.c
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||
* ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
GLint list;
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,.7);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(.8,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,.9,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glShadeModel( GL_FLAT );
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,.7);
|
||||
glVertex3f( -0.9, 0.9, -30.0);
|
||||
glColor3f(0,.9,0);
|
||||
glVertex3f( -0.9, -0.9, -30.0);
|
||||
glColor3f(.8,0,0);
|
||||
glVertex3f( 0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
/* This statechange is redundant:
|
||||
*/
|
||||
glShadeModel( GL_FLAT );
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( -0.5, 0.5, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f( -0.5, -0.5, -30.0);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.5, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
glCallList(list);
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_ALPHA;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
174
progs/trivial/dlist-tri-mat-tri.c
Normal file
174
progs/trivial/dlist-tri-mat-tri.c
Normal file
@@ -0,0 +1,174 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||
* ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
GLint list;
|
||||
|
||||
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
||||
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
||||
static GLfloat blue[4] = {0.2, 0.2, .9, 1.0};
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
|
||||
list = glGenLists(1);
|
||||
glNewList(list, GL_COMPILE);
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glNormal3f(0,0,.7);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f( -0.9, 0.9, -30.0);
|
||||
glVertex3f( -0.9, -0.9, -30.0);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
glVertex3f( 0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f( -0.5, 0.5, -30.0);
|
||||
glVertex3f( -0.5, -0.5, -30.0);
|
||||
glVertex3f( 0.5, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glEndList();
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glShadeModel( GL_SMOOTH );
|
||||
glCallList(list);
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_ALPHA;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
149
progs/trivial/tri-lit-material.c
Normal file
149
progs/trivial/tri-lit-material.c
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this software and
|
||||
* its documentation for any purpose is hereby granted without fee, provided
|
||||
* that (i) the above copyright notices and this permission notice appear in
|
||||
* all copies of the software and related documentation, and (ii) the name of
|
||||
* Silicon Graphics may not be used in any advertising or
|
||||
* publicity relating to the software without the specific, prior written
|
||||
* permission of Silicon Graphics.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
|
||||
* ANY KIND,
|
||||
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
||||
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
|
||||
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
||||
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
||||
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
||||
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
||||
* OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
#define CI_OFFSET_1 16
|
||||
#define CI_OFFSET_2 32
|
||||
|
||||
|
||||
GLenum doubleBuffer;
|
||||
|
||||
static void Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
|
||||
glClearColor(0.0, 0.0, 1.0, 0.0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
static GLfloat red[4] = {0.8, 0.1, 0.0, 1.0};
|
||||
static GLfloat green[4] = {0.0, 0.8, 0.2, 1.0};
|
||||
static GLfloat blue[4] = {0.2, 0.2, .9, 1.0};
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
|
||||
glNormal3f(0,0,.7);
|
||||
glVertex3f( 0.9, -0.9, -0.0);
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
glNormal3f(0,0,.8);
|
||||
glVertex3f( 0.9, 0.9, -0.0);
|
||||
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
glNormal3f(0,0,.9);
|
||||
glVertex3f(-0.9, 0.0, -0.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
if (doubleBuffer) {
|
||||
glutSwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
static GLenum Args(int argc, char **argv)
|
||||
{
|
||||
GLint i;
|
||||
|
||||
doubleBuffer = GL_FALSE;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-sb") == 0) {
|
||||
doubleBuffer = GL_FALSE;
|
||||
} else if (strcmp(argv[i], "-db") == 0) {
|
||||
doubleBuffer = GL_TRUE;
|
||||
} else {
|
||||
fprintf(stderr, "%s (Bad option).\n", argv[i]);
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
if (Args(argc, argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB | GLUT_ALPHA;
|
||||
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow(*argv) == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
@@ -9,6 +9,7 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
#include "extfuncs.h"
|
||||
#include "shaderutil.h"
|
||||
@@ -78,8 +79,12 @@ CompileShaderFile(GLenum shaderType, const char *filename)
|
||||
int n;
|
||||
char *buffer = (char*) malloc(max);
|
||||
GLuint shader;
|
||||
FILE *f;
|
||||
|
||||
FILE *f = fopen(filename, "r");
|
||||
Init();
|
||||
|
||||
|
||||
f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Unable to open shader file %s\n", filename);
|
||||
return 0;
|
||||
|
@@ -26,7 +26,7 @@
|
||||
* -p Open a display connection for each thread
|
||||
* -l Enable application-side locking
|
||||
* -n <num threads> Number of threads to create (default is 2)
|
||||
* -display <display name> Specify X display (default is :0.0)
|
||||
* -display <display name> Specify X display (default is $DISPLAY)
|
||||
* -t Use texture mapping
|
||||
*
|
||||
* Brian Paul 20 July 2000
|
||||
@@ -573,7 +573,7 @@ usage(void)
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *displayName = ":0.0";
|
||||
char *displayName = NULL;
|
||||
int numThreads = 2;
|
||||
Display *dpy = NULL;
|
||||
int i;
|
||||
|
@@ -39,6 +39,12 @@
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
#ifndef GLX_MESA_swap_control
|
||||
#define GLX_MESA_swap_control 1
|
||||
typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
|
||||
#endif
|
||||
|
||||
|
||||
static int is_glx_extension_supported(Display *dpy, const char *query);
|
||||
|
||||
static void query_vsync(Display *dpy);
|
||||
@@ -592,31 +598,22 @@ query_vsync(Display *dpy)
|
||||
int interval = 0;
|
||||
|
||||
|
||||
#ifdef GLX_MESA_swap_control
|
||||
if ((interval <= 0)
|
||||
&& is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
|
||||
if (is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) {
|
||||
PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA =
|
||||
(PFNGLXGETSWAPINTERVALMESAPROC)
|
||||
glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA");
|
||||
|
||||
interval = (*pglXGetSwapIntervalMESA)();
|
||||
} else if (is_glx_extension_supported(dpy, "GLX_SGI_swap_control")) {
|
||||
/* The default swap interval with this extension is 1. Assume that it
|
||||
* is set to the default.
|
||||
*
|
||||
* Many Mesa-based drivers default to 0, but all of these drivers also
|
||||
* export GLX_MESA_swap_control. In that case, this branch will never
|
||||
* be taken, and the correct result should be reported.
|
||||
*/
|
||||
interval = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef GLX_SGI_video_sync
|
||||
if ((interval <= 0)
|
||||
&& is_glx_extension_supported(dpy, "GLX_SGI_video_sync")) {
|
||||
PFNGLXGETVIDEOSYNCSGIPROC pglXGetVideoSyncSGI =
|
||||
(PFNGLXGETVIDEOSYNCSGIPROC)
|
||||
glXGetProcAddressARB((const GLubyte *) "glXGetVideoSyncSGI");
|
||||
unsigned count;
|
||||
|
||||
if ((*pglXGetVideoSyncSGI)(& count) == 0) {
|
||||
interval = (int) count;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (interval > 0) {
|
||||
|
@@ -267,7 +267,8 @@ main(int argc, char *argv[])
|
||||
printf(" glxheads xdisplayname ...\n");
|
||||
printf("Example:\n");
|
||||
printf(" glxheads :0 mars:0 venus:1\n");
|
||||
h = AddHead(":0");
|
||||
|
||||
h = AddHead(XDisplayName(NULL));
|
||||
if (h)
|
||||
PrintInfo(h);
|
||||
}
|
||||
|
@@ -759,7 +759,7 @@ main(int argc, char *argv[])
|
||||
Display *dpy;
|
||||
Window win;
|
||||
GLXContext ctx;
|
||||
char *dpyName = ":0";
|
||||
char *dpyName = NULL;
|
||||
int swap_interval = 1;
|
||||
GLboolean do_swap_interval = GL_FALSE;
|
||||
GLboolean force_get_rate = GL_FALSE;
|
||||
|
@@ -158,7 +158,7 @@ main(int argc, char *argv[])
|
||||
Display *dpy;
|
||||
Window win;
|
||||
GLXContext ctx;
|
||||
char *dpyName = ":0";
|
||||
char *dpyName = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
|
@@ -40,10 +40,11 @@ def get_dxsdk_root(env):
|
||||
except KeyError:
|
||||
return None
|
||||
|
||||
def get_dxsdk_paths(env):
|
||||
def generate(env):
|
||||
dxsdk_root = get_dxsdk_root(env)
|
||||
if dxsdk_root is None:
|
||||
raise SCons.Errors.InternalError, "DirectX SDK not found"
|
||||
# DirectX SDK not found
|
||||
return
|
||||
|
||||
if env['machine'] in ('generic', 'x86'):
|
||||
target_cpu = 'x86'
|
||||
@@ -57,9 +58,6 @@ def get_dxsdk_paths(env):
|
||||
env.Prepend(CPPPATH = [os.path.join(dxsdk_root, 'Include')])
|
||||
env.Prepend(LIBPATH = [os.path.join(dxsdk_root, 'Lib', target_cpu)])
|
||||
|
||||
def generate(env):
|
||||
get_dxsdk_paths(env)
|
||||
|
||||
def exists(env):
|
||||
return get_dxsdk_root(env) is not None
|
||||
|
||||
|
@@ -324,8 +324,10 @@ def generate(env):
|
||||
if gcc:
|
||||
if debug:
|
||||
ccflags += ['-O0', '-g3']
|
||||
elif env['toolchain'] == 'crossmingw':
|
||||
ccflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
|
||||
elif env['CCVERSION'].startswith('4.2.'):
|
||||
# gcc 4.2.x optimizer is broken
|
||||
print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
|
||||
ccflags += ['-O0', '-g3']
|
||||
else:
|
||||
ccflags += ['-O3', '-g3']
|
||||
if env['profile']:
|
||||
@@ -448,11 +450,15 @@ def generate(env):
|
||||
|
||||
# Linker options
|
||||
linkflags = []
|
||||
shlinkflags = []
|
||||
if gcc:
|
||||
if env['machine'] == 'x86':
|
||||
linkflags += ['-m32']
|
||||
if env['machine'] == 'x86_64':
|
||||
linkflags += ['-m64']
|
||||
shlinkflags += [
|
||||
'-Wl,-Bsymbolic',
|
||||
]
|
||||
if platform == 'windows' and msvc:
|
||||
# See also:
|
||||
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
|
||||
@@ -500,6 +506,7 @@ def generate(env):
|
||||
'/entry:_DllMainCRTStartup',
|
||||
]
|
||||
env.Append(LINKFLAGS = linkflags)
|
||||
env.Append(SHLINKFLAGS = shlinkflags)
|
||||
|
||||
# Default libs
|
||||
env.Append(LIBS = [])
|
||||
|
@@ -139,8 +139,8 @@ tgsi_build_declaration(
|
||||
{
|
||||
struct tgsi_declaration declaration;
|
||||
|
||||
assert( file <= TGSI_FILE_IMMEDIATE );
|
||||
assert( interpolate <= TGSI_INTERPOLATE_PERSPECTIVE );
|
||||
assert( file < TGSI_FILE_COUNT );
|
||||
assert( interpolate < TGSI_INTERPOLATE_COUNT );
|
||||
|
||||
declaration = tgsi_default_declaration();
|
||||
declaration.File = file;
|
||||
@@ -584,6 +584,7 @@ tgsi_build_full_instruction(
|
||||
*dst_register = tgsi_build_dst_register(
|
||||
reg->DstRegister.File,
|
||||
reg->DstRegister.WriteMask,
|
||||
reg->DstRegister.Indirect,
|
||||
reg->DstRegister.Index,
|
||||
instruction,
|
||||
header );
|
||||
@@ -631,6 +632,28 @@ tgsi_build_full_instruction(
|
||||
header );
|
||||
prev_token = (struct tgsi_token *) dst_register_ext_modulate;
|
||||
}
|
||||
|
||||
if( reg->DstRegister.Indirect ) {
|
||||
struct tgsi_src_register *ind;
|
||||
|
||||
if( maxsize <= size )
|
||||
return 0;
|
||||
ind = (struct tgsi_src_register *) &tokens[size];
|
||||
size++;
|
||||
|
||||
*ind = tgsi_build_src_register(
|
||||
reg->DstRegisterInd.File,
|
||||
reg->DstRegisterInd.SwizzleX,
|
||||
reg->DstRegisterInd.SwizzleY,
|
||||
reg->DstRegisterInd.SwizzleZ,
|
||||
reg->DstRegisterInd.SwizzleW,
|
||||
reg->DstRegisterInd.Negate,
|
||||
reg->DstRegisterInd.Indirect,
|
||||
reg->DstRegisterInd.Dimension,
|
||||
reg->DstRegisterInd.Index,
|
||||
instruction,
|
||||
header );
|
||||
}
|
||||
}
|
||||
|
||||
for( i = 0; i < full_inst->Instruction.NumSrcRegs; i++ ) {
|
||||
@@ -973,7 +996,7 @@ tgsi_build_src_register(
|
||||
{
|
||||
struct tgsi_src_register src_register;
|
||||
|
||||
assert( file <= TGSI_FILE_IMMEDIATE );
|
||||
assert( file < TGSI_FILE_COUNT );
|
||||
assert( swizzle_x <= TGSI_SWIZZLE_W );
|
||||
assert( swizzle_y <= TGSI_SWIZZLE_W );
|
||||
assert( swizzle_z <= TGSI_SWIZZLE_W );
|
||||
@@ -1194,13 +1217,14 @@ struct tgsi_dst_register
|
||||
tgsi_build_dst_register(
|
||||
unsigned file,
|
||||
unsigned mask,
|
||||
unsigned indirect,
|
||||
int index,
|
||||
struct tgsi_instruction *instruction,
|
||||
struct tgsi_header *header )
|
||||
{
|
||||
struct tgsi_dst_register dst_register;
|
||||
|
||||
assert( file <= TGSI_FILE_IMMEDIATE );
|
||||
assert( file < TGSI_FILE_COUNT );
|
||||
assert( mask <= TGSI_WRITEMASK_XYZW );
|
||||
assert( index >= -32768 && index <= 32767 );
|
||||
|
||||
@@ -1208,6 +1232,7 @@ tgsi_build_dst_register(
|
||||
dst_register.File = file;
|
||||
dst_register.WriteMask = mask;
|
||||
dst_register.Index = index;
|
||||
dst_register.Indirect = indirect;
|
||||
|
||||
instruction_grow( instruction, header );
|
||||
|
||||
@@ -1220,6 +1245,7 @@ tgsi_default_full_dst_register( void )
|
||||
struct tgsi_full_dst_register full_dst_register;
|
||||
|
||||
full_dst_register.DstRegister = tgsi_default_dst_register();
|
||||
full_dst_register.DstRegisterInd = tgsi_default_src_register();
|
||||
full_dst_register.DstRegisterExtConcode =
|
||||
tgsi_default_dst_register_ext_concode();
|
||||
full_dst_register.DstRegisterExtModulate =
|
||||
|
@@ -289,6 +289,7 @@ struct tgsi_dst_register
|
||||
tgsi_build_dst_register(
|
||||
unsigned file,
|
||||
unsigned mask,
|
||||
unsigned indirect,
|
||||
int index,
|
||||
struct tgsi_instruction *instruction,
|
||||
struct tgsi_header *header );
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_string.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "tgsi_dump.h"
|
||||
#include "tgsi_info.h"
|
||||
#include "tgsi_iterate.h"
|
||||
@@ -108,7 +109,8 @@ static const char *semantic_names[] =
|
||||
"FOG",
|
||||
"PSIZE",
|
||||
"GENERIC",
|
||||
"NORMAL"
|
||||
"NORMAL",
|
||||
"FACE"
|
||||
};
|
||||
|
||||
static const char *immediate_type_names[] =
|
||||
@@ -224,6 +226,9 @@ iter_declaration(
|
||||
{
|
||||
struct dump_ctx *ctx = (struct dump_ctx *)iter;
|
||||
|
||||
assert(Elements(semantic_names) == TGSI_SEMANTIC_COUNT);
|
||||
assert(Elements(interpolate_names) == TGSI_INTERPOLATE_COUNT);
|
||||
|
||||
TXT( "DCL " );
|
||||
|
||||
_dump_register(
|
||||
@@ -355,11 +360,22 @@ iter_instruction(
|
||||
CHR( ',' );
|
||||
CHR( ' ' );
|
||||
|
||||
_dump_register(
|
||||
ctx,
|
||||
dst->DstRegister.File,
|
||||
dst->DstRegister.Index,
|
||||
dst->DstRegister.Index );
|
||||
if (dst->DstRegister.Indirect) {
|
||||
_dump_register_ind(
|
||||
ctx,
|
||||
dst->DstRegister.File,
|
||||
dst->DstRegister.Index,
|
||||
dst->DstRegisterInd.File,
|
||||
dst->DstRegisterInd.Index,
|
||||
dst->DstRegisterInd.SwizzleX );
|
||||
}
|
||||
else {
|
||||
_dump_register(
|
||||
ctx,
|
||||
dst->DstRegister.File,
|
||||
dst->DstRegister.Index,
|
||||
dst->DstRegister.Index );
|
||||
}
|
||||
ENM( dst->DstRegisterExtModulate.Modulate, modulate_names );
|
||||
_dump_writemask( ctx, dst->DstRegister.WriteMask );
|
||||
|
||||
|
@@ -1395,28 +1395,69 @@ store_dest(
|
||||
union tgsi_exec_channel null;
|
||||
union tgsi_exec_channel *dst;
|
||||
uint execmask = mach->ExecMask;
|
||||
int offset = 0; /* indirection offset */
|
||||
int index;
|
||||
|
||||
#ifdef DEBUG
|
||||
check_inf_or_nan(chan);
|
||||
#endif
|
||||
|
||||
/* There is an extra source register that indirectly subscripts
|
||||
* a register file. The direct index now becomes an offset
|
||||
* that is being added to the indirect register.
|
||||
*
|
||||
* file[ind[2].x+1],
|
||||
* where:
|
||||
* ind = DstRegisterInd.File
|
||||
* [2] = DstRegisterInd.Index
|
||||
* .x = DstRegisterInd.SwizzleX
|
||||
*/
|
||||
if (reg->DstRegister.Indirect) {
|
||||
union tgsi_exec_channel index;
|
||||
union tgsi_exec_channel indir_index;
|
||||
uint swizzle;
|
||||
|
||||
/* which address register (always zero for now) */
|
||||
index.i[0] =
|
||||
index.i[1] =
|
||||
index.i[2] =
|
||||
index.i[3] = reg->DstRegisterInd.Index;
|
||||
|
||||
/* get current value of address register[swizzle] */
|
||||
swizzle = tgsi_util_get_src_register_swizzle( ®->DstRegisterInd, CHAN_X );
|
||||
|
||||
/* fetch values from the address/indirection register */
|
||||
fetch_src_file_channel(
|
||||
mach,
|
||||
reg->DstRegisterInd.File,
|
||||
swizzle,
|
||||
&index,
|
||||
&indir_index );
|
||||
|
||||
/* save indirection offset */
|
||||
offset = (int) indir_index.f[0];
|
||||
}
|
||||
|
||||
switch (reg->DstRegister.File) {
|
||||
case TGSI_FILE_NULL:
|
||||
dst = &null;
|
||||
break;
|
||||
|
||||
case TGSI_FILE_OUTPUT:
|
||||
dst = &mach->Outputs[mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
|
||||
+ reg->DstRegister.Index].xyzw[chan_index];
|
||||
index = mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]
|
||||
+ reg->DstRegister.Index;
|
||||
dst = &mach->Outputs[offset + index].xyzw[chan_index];
|
||||
break;
|
||||
|
||||
case TGSI_FILE_TEMPORARY:
|
||||
assert( reg->DstRegister.Index < TGSI_EXEC_NUM_TEMPS );
|
||||
dst = &mach->Temps[reg->DstRegister.Index].xyzw[chan_index];
|
||||
index = reg->DstRegister.Index;
|
||||
assert( index < TGSI_EXEC_NUM_TEMPS );
|
||||
dst = &mach->Temps[offset + index].xyzw[chan_index];
|
||||
break;
|
||||
|
||||
case TGSI_FILE_ADDRESS:
|
||||
dst = &mach->Addrs[reg->DstRegister.Index].xyzw[chan_index];
|
||||
index = reg->DstRegister.Index;
|
||||
dst = &mach->Addrs[index].xyzw[chan_index];
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -219,7 +219,6 @@ tgsi_parse_token(
|
||||
/*
|
||||
* No support for indirect or multi-dimensional addressing.
|
||||
*/
|
||||
assert( !inst->FullDstRegisters[i].DstRegister.Indirect );
|
||||
assert( !inst->FullDstRegisters[i].DstRegister.Dimension );
|
||||
|
||||
extended = inst->FullDstRegisters[i].DstRegister.Extended;
|
||||
@@ -246,6 +245,17 @@ tgsi_parse_token(
|
||||
|
||||
extended = token.Extended;
|
||||
}
|
||||
|
||||
if( inst->FullDstRegisters[i].DstRegister.Indirect ) {
|
||||
next_token( ctx, &inst->FullDstRegisters[i].DstRegisterInd );
|
||||
|
||||
/*
|
||||
* No support for indirect or multi-dimensional addressing.
|
||||
*/
|
||||
assert( !inst->FullDstRegisters[i].DstRegisterInd.Indirect );
|
||||
assert( !inst->FullDstRegisters[i].DstRegisterInd.Dimension );
|
||||
assert( !inst->FullDstRegisters[i].DstRegisterInd.Extended );
|
||||
}
|
||||
}
|
||||
|
||||
assert( inst->Instruction.NumSrcRegs <= TGSI_FULL_MAX_SRC_REGISTERS );
|
||||
|
@@ -48,6 +48,7 @@ struct tgsi_full_header
|
||||
struct tgsi_full_dst_register
|
||||
{
|
||||
struct tgsi_dst_register DstRegister;
|
||||
struct tgsi_src_register DstRegisterInd;
|
||||
struct tgsi_dst_register_ext_concode DstRegisterExtConcode;
|
||||
struct tgsi_dst_register_ext_modulate DstRegisterExtModulate;
|
||||
};
|
||||
|
@@ -26,6 +26,7 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "tgsi_text.h"
|
||||
#include "tgsi_build.h"
|
||||
#include "tgsi_info.h"
|
||||
@@ -927,7 +928,8 @@ static const char *semantic_names[TGSI_SEMANTIC_COUNT] =
|
||||
"FOG",
|
||||
"PSIZE",
|
||||
"GENERIC",
|
||||
"NORMAL"
|
||||
"NORMAL",
|
||||
"FACE"
|
||||
};
|
||||
|
||||
static const char *interpolate_names[TGSI_INTERPOLATE_COUNT] =
|
||||
@@ -947,6 +949,9 @@ static boolean parse_declaration( struct translate_ctx *ctx )
|
||||
const char *cur;
|
||||
uint advance;
|
||||
|
||||
assert(Elements(semantic_names) == TGSI_SEMANTIC_COUNT);
|
||||
assert(Elements(interpolate_names) == TGSI_INTERPOLATE_COUNT);
|
||||
|
||||
if (!eat_white( &ctx->cur )) {
|
||||
report_error( ctx, "Syntax error" );
|
||||
return FALSE;
|
||||
|
@@ -97,10 +97,8 @@ void _debug_vprintf(const char *format, va_list ap)
|
||||
buf[0] = '\0';
|
||||
}
|
||||
#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
|
||||
/* EngDebugPrint does not handle float point arguments, so we need to use
|
||||
* our own vsnprintf implementation. It is also very slow, so buffer until
|
||||
* we find a newline. */
|
||||
static char buf[512 + 1] = {'\0'};
|
||||
/* OutputDebugStringA can be very slow, so buffer until we find a newline. */
|
||||
static char buf[4096] = {'\0'};
|
||||
size_t len = strlen(buf);
|
||||
int ret = util_vsnprintf(buf + len, sizeof(buf) - len, format, ap);
|
||||
if(ret > (int)(sizeof(buf) - len - 1) || util_strchr(buf + len, '\n')) {
|
||||
|
@@ -1202,6 +1202,19 @@ pipe_put_tile_z(struct pipe_transfer *pt,
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
{
|
||||
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
||||
assert(pt->usage == PIPE_TRANSFER_READ_WRITE);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
/* convert 32-bit Z to 24-bit Z, preserve stencil */
|
||||
pDest[j] = (pDest[j] & 0xff000000) | ptrc[j] >> 8;
|
||||
}
|
||||
pDest += pt->stride/4;
|
||||
ptrc += srcStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
{
|
||||
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
||||
@@ -1216,13 +1229,26 @@ pipe_put_tile_z(struct pipe_transfer *pt,
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
{
|
||||
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
||||
assert(pt->usage == PIPE_TRANSFER_READ_WRITE);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
/* convert 32-bit Z to 24-bit Z, preserve stencil */
|
||||
pDest[j] = (pDest[j] & 0xff) | (ptrc[j] & 0xffffff00);
|
||||
}
|
||||
pDest += pt->stride/4;
|
||||
ptrc += srcStride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24X8_UNORM:
|
||||
{
|
||||
uint *pDest = (uint *) (map + y * pt->stride + x*4);
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
/* convert 32-bit Z to 24-bit Z (0 stencil) */
|
||||
pDest[j] = ptrc[j] << 8;
|
||||
pDest[j] = ptrc[j] & 0xffffff00;
|
||||
}
|
||||
pDest += pt->stride/4;
|
||||
ptrc += srcStride;
|
||||
|
@@ -83,7 +83,9 @@ my_buffer_write(struct pipe_screen *screen,
|
||||
assert(dirty_size >= size);
|
||||
assert(size);
|
||||
|
||||
map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE);
|
||||
map = pipe_buffer_map_range(screen, buf, offset, size,
|
||||
PIPE_BUFFER_USAGE_CPU_WRITE |
|
||||
PIPE_BUFFER_USAGE_FLUSH_EXPLICIT);
|
||||
if (map == NULL)
|
||||
return PIPE_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
|
@@ -785,11 +785,10 @@ static void setup_tri_coefficients( struct setup_context *setup )
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
|
||||
/* FOG.y = front/back facing XXX fix this */
|
||||
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
|
||||
setup->coef[fragSlot].dadx[1] = 0.0;
|
||||
setup->coef[fragSlot].dady[1] = 0.0;
|
||||
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
|
||||
setup->coef[fragSlot].a0[0] = 1.0f - setup->quad.input.facing;
|
||||
setup->coef[fragSlot].dadx[0] = 0.0;
|
||||
setup->coef[fragSlot].dady[0] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1096,11 +1095,10 @@ setup_line_coefficients(struct setup_context *setup,
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
|
||||
/* FOG.y = front/back facing XXX fix this */
|
||||
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
|
||||
setup->coef[fragSlot].dadx[1] = 0.0;
|
||||
setup->coef[fragSlot].dady[1] = 0.0;
|
||||
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
|
||||
setup->coef[fragSlot].a0[0] = 1.0f - setup->quad.input.facing;
|
||||
setup->coef[fragSlot].dadx[0] = 0.0;
|
||||
setup->coef[fragSlot].dady[0] = 0.0;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@@ -1342,11 +1340,10 @@ setup_point( struct setup_context *setup,
|
||||
assert(0);
|
||||
}
|
||||
|
||||
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
|
||||
/* FOG.y = front/back facing XXX fix this */
|
||||
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
|
||||
setup->coef[fragSlot].dadx[1] = 0.0;
|
||||
setup->coef[fragSlot].dady[1] = 0.0;
|
||||
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FACE) {
|
||||
setup->coef[fragSlot].a0[0] = 1.0f - setup->quad.input.facing;
|
||||
setup->coef[fragSlot].dadx[0] = 0.0;
|
||||
setup->coef[fragSlot].dady[0] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -110,6 +110,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
|
||||
break;
|
||||
|
||||
case TGSI_SEMANTIC_GENERIC:
|
||||
case TGSI_SEMANTIC_FACE:
|
||||
/* this includes texcoords and varying vars */
|
||||
src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_GENERIC,
|
||||
spfs->info.input_semantic_index[i]);
|
||||
|
@@ -217,6 +217,7 @@ enum pipe_transfer_usage {
|
||||
#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7)
|
||||
#define PIPE_BUFFER_USAGE_DISCARD (1 << 8)
|
||||
#define PIPE_BUFFER_USAGE_DONTBLOCK (1 << 9)
|
||||
#define PIPE_BUFFER_USAGE_FLUSH_EXPLICIT (1 << 10) /**< See pipe_screen::buffer_flush_mapped_range */
|
||||
/** Pipe driver custom usage flags should be greater or equal to this value */
|
||||
#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
|
||||
|
||||
|
@@ -117,7 +117,9 @@ pipe_buffer_write(struct pipe_screen *screen,
|
||||
assert(offset + size <= buf->size);
|
||||
assert(size);
|
||||
|
||||
map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_WRITE);
|
||||
map = pipe_buffer_map_range(screen, buf, offset, size,
|
||||
PIPE_BUFFER_USAGE_CPU_WRITE |
|
||||
PIPE_BUFFER_USAGE_FLUSH_EXPLICIT);
|
||||
assert(map);
|
||||
if(map) {
|
||||
memcpy(map + offset, data, size);
|
||||
|
@@ -221,23 +221,31 @@ struct pipe_screen {
|
||||
/**
|
||||
* Notify a range that was actually written into.
|
||||
*
|
||||
* Can only be used if the buffer was mapped with the
|
||||
* PIPE_BUFFER_USAGE_CPU_WRITE and PIPE_BUFFER_USAGE_FLUSH_EXPLICIT flags
|
||||
* set.
|
||||
*
|
||||
* The range is relative to the buffer start, regardless of the range
|
||||
* specified to buffer_map_range. This is different from the
|
||||
* ARB_map_buffer_range semantics because we don't forbid multiple mappings
|
||||
* of the same buffer (yet).
|
||||
*
|
||||
* If the buffer was mapped for writing and no buffer_flush_mapped_range
|
||||
* call was done until the buffer_unmap is called then the pipe driver will
|
||||
* assumed that the whole buffer was written. This is for backward
|
||||
* compatibility purposes and may affect performance -- the state tracker
|
||||
* should always specify exactly what got written while the buffer was
|
||||
* mapped.
|
||||
*/
|
||||
void (*buffer_flush_mapped_range)( struct pipe_screen *screen,
|
||||
struct pipe_buffer *buf,
|
||||
unsigned offset,
|
||||
unsigned length);
|
||||
|
||||
/**
|
||||
* Unmap buffer.
|
||||
*
|
||||
* If the buffer was mapped with PIPE_BUFFER_USAGE_CPU_WRITE flag but not
|
||||
* PIPE_BUFFER_USAGE_FLUSH_EXPLICIT then the pipe driver will
|
||||
* assume that the whole buffer was written. This is mostly for backward
|
||||
* compatibility purposes and may affect performance -- the state tracker
|
||||
* should always specify exactly what got written while the buffer was
|
||||
* mapped.
|
||||
*/
|
||||
void (*buffer_unmap)( struct pipe_screen *screen,
|
||||
struct pipe_buffer *buf );
|
||||
|
||||
|
@@ -131,7 +131,8 @@ struct tgsi_declaration_range
|
||||
#define TGSI_SEMANTIC_PSIZE 4
|
||||
#define TGSI_SEMANTIC_GENERIC 5
|
||||
#define TGSI_SEMANTIC_NORMAL 6
|
||||
#define TGSI_SEMANTIC_COUNT 7 /**< number of semantic values */
|
||||
#define TGSI_SEMANTIC_FACE 7
|
||||
#define TGSI_SEMANTIC_COUNT 8 /**< number of semantic values */
|
||||
|
||||
struct tgsi_declaration_semantic
|
||||
{
|
||||
|
@@ -27,6 +27,7 @@ if env['platform'] in ['windows']:
|
||||
'shared/stw_framebuffer.c',
|
||||
'shared/stw_pixelformat.c',
|
||||
'shared/stw_extensionsstring.c',
|
||||
'shared/stw_extswapinterval.c',
|
||||
'shared/stw_getprocaddress.c',
|
||||
'shared/stw_arbpixelformat.c',
|
||||
'shared/stw_tls.c',
|
||||
|
@@ -60,8 +60,14 @@ stw_context(GLcontext *glctx)
|
||||
static INLINE struct stw_context *
|
||||
stw_current_context(void)
|
||||
{
|
||||
GET_CURRENT_CONTEXT( glctx );
|
||||
return stw_context(glctx);
|
||||
/* We must check if multiple threads are being used or GET_CURRENT_CONTEXT
|
||||
* might return the current context of the thread first seen. */
|
||||
_glapi_check_multithread();
|
||||
|
||||
{
|
||||
GET_CURRENT_CONTEXT( glctx );
|
||||
return stw_context(glctx);
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
@@ -74,7 +80,7 @@ stw_copy_context(
|
||||
struct stw_context *dst;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
|
||||
src = stw_lookup_context_locked( hglrcSrc );
|
||||
dst = stw_lookup_context_locked( hglrcDst );
|
||||
@@ -87,7 +93,7 @@ stw_copy_context(
|
||||
(void) mask;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->ctx_mutex );
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -101,7 +107,7 @@ stw_share_lists(
|
||||
struct stw_context *ctx2;
|
||||
BOOL ret = FALSE;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
|
||||
ctx1 = stw_lookup_context_locked( hglrc1 );
|
||||
ctx2 = stw_lookup_context_locked( hglrc2 );
|
||||
@@ -111,7 +117,7 @@ stw_share_lists(
|
||||
ret = _mesa_share_state(ctx2->st->ctx, ctx1->st->ctx);
|
||||
}
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->ctx_mutex );
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -124,8 +130,10 @@ stw_viewport(GLcontext * glctx, GLint x, GLint y,
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
fb = stw_framebuffer_from_hdc( ctx->hdc );
|
||||
if(fb)
|
||||
if(fb) {
|
||||
stw_framebuffer_update(fb);
|
||||
stw_framebuffer_release(fb);
|
||||
}
|
||||
}
|
||||
|
||||
UINT_PTR
|
||||
@@ -189,9 +197,9 @@ stw_create_layer_context(
|
||||
ctx->st->ctx->DriverCtx = ctx;
|
||||
ctx->st->ctx->Driver.Viewport = stw_viewport;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
ctx->hglrc = handle_table_add(stw_dev->ctx_table, ctx);
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->ctx_mutex );
|
||||
if (!ctx->hglrc)
|
||||
goto no_hglrc;
|
||||
|
||||
@@ -218,10 +226,10 @@ stw_delete_context(
|
||||
if (!stw_dev)
|
||||
return FALSE;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
ctx = stw_lookup_context_locked(hglrc);
|
||||
handle_table_remove(stw_dev->ctx_table, hglrc);
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->ctx_mutex );
|
||||
|
||||
if (ctx) {
|
||||
struct stw_context *curctx = stw_current_context();
|
||||
@@ -248,9 +256,9 @@ stw_release_context(
|
||||
if (!stw_dev)
|
||||
return FALSE;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
ctx = stw_lookup_context_locked( hglrc );
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->ctx_mutex );
|
||||
|
||||
if (!ctx)
|
||||
return FALSE;
|
||||
@@ -298,9 +306,9 @@ stw_make_current(
|
||||
HDC hdc,
|
||||
UINT_PTR hglrc )
|
||||
{
|
||||
struct stw_context *curctx;
|
||||
struct stw_context *ctx;
|
||||
struct stw_framebuffer *fb;
|
||||
struct stw_context *curctx = NULL;
|
||||
struct stw_context *ctx = NULL;
|
||||
struct stw_framebuffer *fb = NULL;
|
||||
|
||||
if (!stw_dev)
|
||||
goto fail;
|
||||
@@ -322,13 +330,13 @@ stw_make_current(
|
||||
return st_make_current( NULL, NULL, NULL );
|
||||
}
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
ctx = stw_lookup_context_locked( hglrc );
|
||||
pipe_mutex_unlock( stw_dev->ctx_mutex );
|
||||
if(!ctx)
|
||||
goto fail;
|
||||
|
||||
fb = stw_framebuffer_from_hdc_locked( hdc );
|
||||
fb = stw_framebuffer_from_hdc( hdc );
|
||||
if(!fb) {
|
||||
/* Applications should call SetPixelFormat before creating a context,
|
||||
* but not all do, and the opengl32 runtime seems to use a default pixel
|
||||
@@ -336,13 +344,11 @@ stw_make_current(
|
||||
*/
|
||||
int iPixelFormat = GetPixelFormat(hdc);
|
||||
if(iPixelFormat)
|
||||
fb = stw_framebuffer_create_locked( hdc, iPixelFormat );
|
||||
fb = stw_framebuffer_create( hdc, iPixelFormat );
|
||||
if(!fb)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
|
||||
if(fb->iPixelFormat != ctx->iPixelFormat)
|
||||
goto fail;
|
||||
|
||||
@@ -361,12 +367,16 @@ stw_make_current(
|
||||
|
||||
success:
|
||||
assert(fb);
|
||||
if(fb)
|
||||
if(fb) {
|
||||
stw_framebuffer_update(fb);
|
||||
stw_framebuffer_release(fb);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
if(fb)
|
||||
stw_framebuffer_release(fb);
|
||||
st_make_current( NULL, NULL, NULL );
|
||||
return FALSE;
|
||||
}
|
||||
|
@@ -69,8 +69,6 @@ stw_flush_frontbuffer(struct pipe_screen *screen,
|
||||
fb = stw_framebuffer_from_hdc( hdc );
|
||||
/* fb can be NULL if window was destroyed already */
|
||||
if (fb) {
|
||||
pipe_mutex_lock( fb->mutex );
|
||||
|
||||
#if DEBUG
|
||||
{
|
||||
struct pipe_surface *surface2;
|
||||
@@ -94,8 +92,7 @@ stw_flush_frontbuffer(struct pipe_screen *screen,
|
||||
|
||||
if(fb) {
|
||||
stw_framebuffer_update(fb);
|
||||
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
stw_framebuffer_release(fb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +135,8 @@ stw_init(const struct stw_winsys *stw_winsys)
|
||||
|
||||
stw_dev->screen->flush_frontbuffer = &stw_flush_frontbuffer;
|
||||
|
||||
pipe_mutex_init( stw_dev->mutex );
|
||||
pipe_mutex_init( stw_dev->ctx_mutex );
|
||||
pipe_mutex_init( stw_dev->fb_mutex );
|
||||
|
||||
stw_dev->ctx_table = handle_table_create();
|
||||
if (!stw_dev->ctx_table) {
|
||||
@@ -179,7 +177,7 @@ stw_cleanup(void)
|
||||
if (!stw_dev)
|
||||
return;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->ctx_mutex );
|
||||
{
|
||||
/* Ensure all contexts are destroyed */
|
||||
i = handle_table_get_first_handle(stw_dev->ctx_table);
|
||||
@@ -189,11 +187,12 @@ stw_cleanup(void)
|
||||
}
|
||||
handle_table_destroy(stw_dev->ctx_table);
|
||||
}
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->ctx_mutex );
|
||||
|
||||
stw_framebuffer_cleanup();
|
||||
|
||||
pipe_mutex_destroy( stw_dev->mutex );
|
||||
pipe_mutex_destroy( stw_dev->fb_mutex );
|
||||
pipe_mutex_destroy( stw_dev->ctx_mutex );
|
||||
|
||||
stw_dev->screen->destroy(stw_dev->screen);
|
||||
|
||||
|
@@ -57,10 +57,10 @@ struct stw_device
|
||||
unsigned pixelformat_count;
|
||||
unsigned pixelformat_extended_count;
|
||||
|
||||
pipe_mutex mutex;
|
||||
|
||||
pipe_mutex ctx_mutex;
|
||||
struct handle_table *ctx_table;
|
||||
|
||||
pipe_mutex fb_mutex;
|
||||
struct stw_framebuffer *fb_head;
|
||||
|
||||
#ifdef DEBUG
|
||||
|
@@ -38,6 +38,7 @@ static const char *stw_extension_string =
|
||||
"WGL_ARB_extensions_string "
|
||||
"WGL_ARB_multisample "
|
||||
"WGL_ARB_pixel_format "
|
||||
/* "WGL_EXT_swap_interval " */
|
||||
"WGL_EXT_extensions_string";
|
||||
|
||||
|
||||
|
57
src/gallium/state_trackers/wgl/shared/stw_extswapinterval.c
Normal file
57
src/gallium/state_trackers/wgl/shared/stw_extswapinterval.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2009 VMware, Inc.
|
||||
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#define WGL_WGLEXT_PROTOTYPES
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/wglext.h>
|
||||
#include "util/u_debug.h"
|
||||
|
||||
/* A dummy implementation of this extension.
|
||||
*
|
||||
* Required as some applications retrieve and call these functions
|
||||
* regardless of the fact that we don't advertise the extension and
|
||||
* further more the results of wglGetProcAddress are NULL.
|
||||
*/
|
||||
WINGDIAPI BOOL APIENTRY
|
||||
wglSwapIntervalEXT(int interval)
|
||||
{
|
||||
(void) interval;
|
||||
debug_printf("%s: %d\n", __FUNCTION__, interval);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WINGDIAPI int APIENTRY
|
||||
wglGetSwapIntervalEXT(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -45,6 +45,10 @@
|
||||
#include "stw_tls.h"
|
||||
|
||||
|
||||
/**
|
||||
* Search the framebuffer with the matching HWND while holding the
|
||||
* stw_dev::fb_mutex global lock.
|
||||
*/
|
||||
static INLINE struct stw_framebuffer *
|
||||
stw_framebuffer_from_hwnd_locked(
|
||||
HWND hwnd )
|
||||
@@ -52,13 +56,20 @@ stw_framebuffer_from_hwnd_locked(
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
|
||||
if (fb->hWnd == hwnd)
|
||||
if (fb->hWnd == hwnd) {
|
||||
pipe_mutex_lock(fb->mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroy this framebuffer. Both stw_dev::fb_mutex and stw_framebuffer::mutex
|
||||
* must be held, by this order. Obviously no further access to fb can be done
|
||||
* after this.
|
||||
*/
|
||||
static INLINE void
|
||||
stw_framebuffer_destroy_locked(
|
||||
struct stw_framebuffer *fb )
|
||||
@@ -74,68 +85,24 @@ stw_framebuffer_destroy_locked(
|
||||
|
||||
st_unreference_framebuffer(fb->stfb);
|
||||
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
|
||||
pipe_mutex_destroy( fb->mutex );
|
||||
|
||||
FREE( fb );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
|
||||
* @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
|
||||
*/
|
||||
LRESULT CALLBACK
|
||||
stw_call_window_proc(
|
||||
int nCode,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
void
|
||||
stw_framebuffer_release(
|
||||
struct stw_framebuffer *fb)
|
||||
{
|
||||
struct stw_tls_data *tls_data;
|
||||
PCWPSTRUCT pParams = (PCWPSTRUCT)lParam;
|
||||
|
||||
tls_data = stw_tls_get_data();
|
||||
if(!tls_data)
|
||||
return 0;
|
||||
|
||||
if (nCode < 0)
|
||||
return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
|
||||
|
||||
if (pParams->message == WM_SIZE && pParams->wParam != SIZE_MINIMIZED) {
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
|
||||
if(fb) {
|
||||
unsigned width = LOWORD( pParams->lParam );
|
||||
unsigned height = HIWORD( pParams->lParam );
|
||||
|
||||
pipe_mutex_lock( fb->mutex );
|
||||
fb->must_resize = TRUE;
|
||||
fb->width = width;
|
||||
fb->height = height;
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
}
|
||||
}
|
||||
|
||||
if (pParams->message == WM_DESTROY) {
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
|
||||
fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
|
||||
if(fb)
|
||||
stw_framebuffer_destroy_locked(fb);
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
}
|
||||
|
||||
return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
|
||||
assert(fb);
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
static INLINE void
|
||||
stw_framebuffer_get_size( struct stw_framebuffer *fb )
|
||||
{
|
||||
unsigned width, height;
|
||||
@@ -161,10 +128,57 @@ stw_framebuffer_get_size( struct stw_framebuffer *fb )
|
||||
|
||||
|
||||
/**
|
||||
* Create a new framebuffer object which will correspond to the given HDC.
|
||||
* @sa http://msdn.microsoft.com/en-us/library/ms644975(VS.85).aspx
|
||||
* @sa http://msdn.microsoft.com/en-us/library/ms644960(VS.85).aspx
|
||||
*/
|
||||
LRESULT CALLBACK
|
||||
stw_call_window_proc(
|
||||
int nCode,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
struct stw_tls_data *tls_data;
|
||||
PCWPSTRUCT pParams = (PCWPSTRUCT)lParam;
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
tls_data = stw_tls_get_data();
|
||||
if(!tls_data)
|
||||
return 0;
|
||||
|
||||
if (nCode < 0)
|
||||
return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
|
||||
|
||||
if (pParams->message == WM_WINDOWPOSCHANGED) {
|
||||
/* We handle WM_WINDOWPOSCHANGED instead of WM_SIZE because according to
|
||||
* http://blogs.msdn.com/oldnewthing/archive/2008/01/15/7113860.aspx
|
||||
* WM_SIZE is generated from WM_WINDOWPOSCHANGED by DefWindowProc so it
|
||||
* can be masked out by the application. */
|
||||
LPWINDOWPOS lpWindowPos = (LPWINDOWPOS)pParams->lParam;
|
||||
if((lpWindowPos->flags & SWP_SHOWWINDOW) ||
|
||||
!(lpWindowPos->flags & SWP_NOSIZE)) {
|
||||
fb = stw_framebuffer_from_hwnd( pParams->hwnd );
|
||||
if(fb) {
|
||||
/* Size in WINDOWPOS includes the window frame, so get the size
|
||||
* of the client area via GetClientRect. */
|
||||
stw_framebuffer_get_size(fb);
|
||||
stw_framebuffer_release(fb);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (pParams->message == WM_DESTROY) {
|
||||
pipe_mutex_lock( stw_dev->fb_mutex );
|
||||
fb = stw_framebuffer_from_hwnd_locked( pParams->hwnd );
|
||||
if(fb)
|
||||
stw_framebuffer_destroy_locked(fb);
|
||||
pipe_mutex_unlock( stw_dev->fb_mutex );
|
||||
}
|
||||
|
||||
return CallNextHookEx(tls_data->hCallWndProcHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_create_locked(
|
||||
stw_framebuffer_create(
|
||||
HDC hdc,
|
||||
int iPixelFormat )
|
||||
{
|
||||
@@ -193,8 +207,16 @@ stw_framebuffer_create_locked(
|
||||
|
||||
pipe_mutex_init( fb->mutex );
|
||||
|
||||
/* This is the only case where we lock the stw_framebuffer::mutex before
|
||||
* stw_dev::fb_mutex, since no other thread can know about this framebuffer
|
||||
* and we must prevent any other thread from destroying it before we return.
|
||||
*/
|
||||
pipe_mutex_lock( fb->mutex );
|
||||
|
||||
pipe_mutex_lock( stw_dev->fb_mutex );
|
||||
fb->next = stw_dev->fb_head;
|
||||
stw_dev->fb_head = fb;
|
||||
pipe_mutex_unlock( stw_dev->fb_mutex );
|
||||
|
||||
return fb;
|
||||
}
|
||||
@@ -204,8 +226,8 @@ BOOL
|
||||
stw_framebuffer_allocate(
|
||||
struct stw_framebuffer *fb)
|
||||
{
|
||||
pipe_mutex_lock( fb->mutex );
|
||||
|
||||
assert(fb);
|
||||
|
||||
if(!fb->stfb) {
|
||||
const struct stw_pixelformat_info *pfi = fb->pfi;
|
||||
enum pipe_format colorFormat, depthFormat, stencilFormat;
|
||||
@@ -241,8 +263,6 @@ stw_framebuffer_allocate(
|
||||
fb->must_resize = TRUE;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
|
||||
return fb->stfb ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
@@ -279,32 +299,47 @@ stw_framebuffer_cleanup( void )
|
||||
struct stw_framebuffer *fb;
|
||||
struct stw_framebuffer *next;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->fb_mutex );
|
||||
|
||||
fb = stw_dev->fb_head;
|
||||
while (fb) {
|
||||
next = fb->next;
|
||||
|
||||
pipe_mutex_lock(fb->mutex);
|
||||
stw_framebuffer_destroy_locked(fb);
|
||||
|
||||
fb = next;
|
||||
}
|
||||
stw_dev->fb_head = NULL;
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->fb_mutex );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given an hdc, return the corresponding stw_framebuffer.
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
static INLINE struct stw_framebuffer *
|
||||
stw_framebuffer_from_hdc_locked(
|
||||
HDC hdc )
|
||||
{
|
||||
HWND hwnd;
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
/*
|
||||
* Some applications create and use several HDCs for the same window, so
|
||||
* looking up the framebuffer by the HDC is not reliable. Use HWND whenever
|
||||
* possible.
|
||||
*/
|
||||
hwnd = WindowFromDC(hdc);
|
||||
if(hwnd)
|
||||
return stw_framebuffer_from_hwnd_locked(hwnd);
|
||||
|
||||
for (fb = stw_dev->fb_head; fb != NULL; fb = fb->next)
|
||||
if (fb->hDC == hdc)
|
||||
if (fb->hDC == hdc) {
|
||||
pipe_mutex_lock(fb->mutex);
|
||||
break;
|
||||
}
|
||||
|
||||
return fb;
|
||||
}
|
||||
@@ -319,9 +354,26 @@ stw_framebuffer_from_hdc(
|
||||
{
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
pipe_mutex_lock( stw_dev->fb_mutex );
|
||||
fb = stw_framebuffer_from_hdc_locked(hdc);
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
pipe_mutex_unlock( stw_dev->fb_mutex );
|
||||
|
||||
return fb;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Given an hdc, return the corresponding stw_framebuffer.
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hwnd(
|
||||
HWND hwnd )
|
||||
{
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
pipe_mutex_lock( stw_dev->fb_mutex );
|
||||
fb = stw_framebuffer_from_hwnd_locked(hwnd);
|
||||
pipe_mutex_unlock( stw_dev->fb_mutex );
|
||||
|
||||
return fb;
|
||||
}
|
||||
@@ -341,22 +393,19 @@ stw_pixelformat_set(
|
||||
if (index >= count)
|
||||
return FALSE;
|
||||
|
||||
pipe_mutex_lock( stw_dev->mutex );
|
||||
|
||||
fb = stw_framebuffer_from_hdc_locked(hdc);
|
||||
if(fb) {
|
||||
/* SetPixelFormat must be called only once */
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
stw_framebuffer_release( fb );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fb = stw_framebuffer_create_locked(hdc, iPixelFormat);
|
||||
fb = stw_framebuffer_create(hdc, iPixelFormat);
|
||||
if(!fb) {
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock( stw_dev->mutex );
|
||||
stw_framebuffer_release( fb );
|
||||
|
||||
/* Some applications mistakenly use the undocumented wglSetPixelFormat
|
||||
* function instead of SetPixelFormat, so we call SetPixelFormat here to
|
||||
@@ -373,13 +422,16 @@ int
|
||||
stw_pixelformat_get(
|
||||
HDC hdc )
|
||||
{
|
||||
int iPixelFormat = 0;
|
||||
struct stw_framebuffer *fb;
|
||||
|
||||
fb = stw_framebuffer_from_hdc(hdc);
|
||||
if(!fb)
|
||||
return 0;
|
||||
if(fb) {
|
||||
iPixelFormat = fb->iPixelFormat;
|
||||
stw_framebuffer_release(fb);
|
||||
}
|
||||
|
||||
return fb->iPixelFormat;
|
||||
return iPixelFormat;
|
||||
}
|
||||
|
||||
|
||||
@@ -395,10 +447,10 @@ stw_swap_buffers(
|
||||
if (fb == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER))
|
||||
if (!(fb->pfi->pfd.dwFlags & PFD_DOUBLEBUFFER)) {
|
||||
stw_framebuffer_release(fb);
|
||||
return TRUE;
|
||||
|
||||
pipe_mutex_lock( fb->mutex );
|
||||
}
|
||||
|
||||
/* If we're swapping the buffer associated with the current context
|
||||
* we have to flush any pending rendering commands first.
|
||||
@@ -409,7 +461,7 @@ stw_swap_buffers(
|
||||
|
||||
if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_BACK_LEFT, &surface )) {
|
||||
/* FIXME: this shouldn't happen, but does on glean */
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
stw_framebuffer_release(fb);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -423,8 +475,7 @@ stw_swap_buffers(
|
||||
stw_dev->stw_winsys->flush_frontbuffer( screen, surface, hdc );
|
||||
|
||||
stw_framebuffer_update(fb);
|
||||
|
||||
pipe_mutex_unlock( fb->mutex );
|
||||
stw_framebuffer_release(fb);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@@ -41,6 +41,23 @@ struct stw_pixelformat_info;
|
||||
*/
|
||||
struct stw_framebuffer
|
||||
{
|
||||
/**
|
||||
* This mutex has two purposes:
|
||||
* - protect the access to the mutable data members below
|
||||
* - prevent the the framebuffer from being deleted while being accessed.
|
||||
*
|
||||
* It is OK to lock this mutex while holding the stw_device::fb_mutex lock,
|
||||
* but the opposite must never happen.
|
||||
*/
|
||||
pipe_mutex mutex;
|
||||
|
||||
/*
|
||||
* Immutable members.
|
||||
*
|
||||
* Note that even access to immutable members implies acquiring the mutex
|
||||
* above, to prevent the framebuffer from being destroyed.
|
||||
*/
|
||||
|
||||
HDC hDC;
|
||||
HWND hWnd;
|
||||
|
||||
@@ -48,7 +65,10 @@ struct stw_framebuffer
|
||||
const struct stw_pixelformat_info *pfi;
|
||||
GLvisual visual;
|
||||
|
||||
pipe_mutex mutex;
|
||||
/*
|
||||
* Mutable members.
|
||||
*/
|
||||
|
||||
struct st_framebuffer *stfb;
|
||||
|
||||
/* FIXME: Make this work for multiple contexts bound to the same framebuffer */
|
||||
@@ -56,15 +76,52 @@ struct stw_framebuffer
|
||||
unsigned width;
|
||||
unsigned height;
|
||||
|
||||
/** This is protected by stw_device::mutex, not the mutex above */
|
||||
/**
|
||||
* This is protected by stw_device::fb_mutex, not the mutex above.
|
||||
*
|
||||
* Deletions must be done by first acquiring stw_device::fb_mutex, and then
|
||||
* acquiring the stw_framebuffer::mutex of the framebuffer to be deleted.
|
||||
* This ensures that nobody else is reading/writing to the.
|
||||
*
|
||||
* It is not necessary to aquire the mutex above to navigate the linked list
|
||||
* given that deletions are done with stw_device::fb_mutex held, so no other
|
||||
* thread can delete.
|
||||
*/
|
||||
struct stw_framebuffer *next;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create a new framebuffer object which will correspond to the given HDC.
|
||||
*
|
||||
* This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
|
||||
* must be called when done
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_create_locked(
|
||||
stw_framebuffer_create(
|
||||
HDC hdc,
|
||||
int iPixelFormat );
|
||||
|
||||
/**
|
||||
* Search a framebuffer with a matching HWND.
|
||||
*
|
||||
* This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
|
||||
* must be called when done
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hwnd(
|
||||
HWND hwnd );
|
||||
|
||||
/**
|
||||
* Search a framebuffer with a matching HDC.
|
||||
*
|
||||
* This function will acquire stw_framebuffer::mutex. stw_framebuffer_release
|
||||
* must be called when done
|
||||
*/
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hdc(
|
||||
HDC hdc );
|
||||
|
||||
BOOL
|
||||
stw_framebuffer_allocate(
|
||||
struct stw_framebuffer *fb );
|
||||
@@ -73,15 +130,19 @@ void
|
||||
stw_framebuffer_update(
|
||||
struct stw_framebuffer *fb);
|
||||
|
||||
/**
|
||||
* Release stw_framebuffer::mutex lock. This framebuffer must not be accessed
|
||||
* after calling this function, as it may have been deleted by another thread
|
||||
* in the meanwhile.
|
||||
*/
|
||||
void
|
||||
stw_framebuffer_release(
|
||||
struct stw_framebuffer *fb);
|
||||
|
||||
/**
|
||||
* Cleanup any existing framebuffers when exiting application.
|
||||
*/
|
||||
void
|
||||
stw_framebuffer_cleanup(void);
|
||||
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hdc_locked(
|
||||
HDC hdc );
|
||||
|
||||
struct stw_framebuffer *
|
||||
stw_framebuffer_from_hdc(
|
||||
HDC hdc );
|
||||
|
||||
#endif /* STW_FRAMEBUFFER_H */
|
||||
|
@@ -56,6 +56,10 @@ static const struct stw_extension_entry stw_extension_entries[] = {
|
||||
/* WGL_EXT_extensions_string */
|
||||
STW_EXTENSION_ENTRY( wglGetExtensionsStringEXT ),
|
||||
|
||||
/* WGL_EXT_swap_interval */
|
||||
STW_EXTENSION_ENTRY( wglGetSwapIntervalEXT ),
|
||||
STW_EXTENSION_ENTRY( wglSwapIntervalEXT ),
|
||||
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
@@ -65,13 +69,13 @@ stw_get_proc_address(
|
||||
{
|
||||
const struct stw_extension_entry *entry;
|
||||
|
||||
PROC p = (PROC) _glapi_get_proc_address( lpszProc );
|
||||
if (p)
|
||||
return p;
|
||||
if (lpszProc[0] == 'w' && lpszProc[1] == 'g' && lpszProc[2] == 'l')
|
||||
for (entry = stw_extension_entries; entry->name; entry++)
|
||||
if (strcmp( lpszProc, entry->name ) == 0)
|
||||
return entry->proc;
|
||||
|
||||
for (entry = stw_extension_entries; entry->name; entry++)
|
||||
if (strcmp( lpszProc, entry->name ) == 0)
|
||||
return entry->proc;
|
||||
if (lpszProc[0] == 'g' && lpszProc[1] == 'l')
|
||||
return (PROC) _glapi_get_proc_address( lpszProc );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -305,6 +305,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
|
||||
drm_handle_t hFB;
|
||||
int junk;
|
||||
const __DRIconfig **driver_configs;
|
||||
__GLcontextModes *visual;
|
||||
|
||||
/* DRI protocol version. */
|
||||
dri_version.major = driDpy->driMajor;
|
||||
@@ -417,6 +418,28 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
|
||||
psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
|
||||
psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
|
||||
|
||||
/* Visuals with depth != screen depth are subject to automatic compositing
|
||||
* in the X server, so DRI1 can't render to them properly. Mark them as
|
||||
* non-conformant to prevent apps from picking them up accidentally.
|
||||
*/
|
||||
for (visual = psc->visuals; visual; visual = visual->next) {
|
||||
XVisualInfo template;
|
||||
XVisualInfo *visuals;
|
||||
int num_visuals;
|
||||
long mask;
|
||||
|
||||
template.visualid = visual->visualID;
|
||||
mask = VisualIDMask;
|
||||
visuals = XGetVisualInfo(dpy, mask, &template, &num_visuals);
|
||||
|
||||
if (visuals) {
|
||||
if (num_visuals > 0 && visuals->depth != DefaultDepth(dpy, scrn))
|
||||
visual->visualRating = GLX_NON_CONFORMANT_CONFIG;
|
||||
|
||||
XFree(visuals);
|
||||
}
|
||||
}
|
||||
|
||||
return psp;
|
||||
|
||||
handle_error:
|
||||
|
@@ -401,6 +401,8 @@ driCreateScreen(__GLXscreenConfigs * psc, int screen,
|
||||
psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
|
||||
psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
|
||||
|
||||
free(driver_configs);
|
||||
|
||||
psp->destroyScreen = driDestroyScreen;
|
||||
psp->createContext = driCreateContext;
|
||||
psp->createDrawable = driCreateDrawable;
|
||||
|
@@ -164,7 +164,7 @@ GetGLXScreenConfigs(Display *dpy, int scrn)
|
||||
{
|
||||
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
|
||||
|
||||
return (priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
|
||||
return (priv && priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -855,12 +855,10 @@ void brw_math( struct brw_compile *p,
|
||||
|
||||
void brw_dp_READ_16( struct brw_compile *p,
|
||||
struct brw_reg dest,
|
||||
GLuint msg_reg_nr,
|
||||
GLuint scratch_offset );
|
||||
|
||||
void brw_dp_READ_4( struct brw_compile *p,
|
||||
struct brw_reg dest,
|
||||
GLuint msg_reg_nr,
|
||||
GLboolean relAddr,
|
||||
GLuint location,
|
||||
GLuint bind_table_index );
|
||||
@@ -875,7 +873,6 @@ void brw_dp_READ_4_vs( struct brw_compile *p,
|
||||
|
||||
void brw_dp_WRITE_16( struct brw_compile *p,
|
||||
struct brw_reg src,
|
||||
GLuint msg_reg_nr,
|
||||
GLuint scratch_offset );
|
||||
|
||||
/* If/else/endif. Works by manipulating the execution flags on each
|
||||
|
@@ -865,9 +865,9 @@ void brw_math_16( struct brw_compile *p,
|
||||
*/
|
||||
void brw_dp_WRITE_16( struct brw_compile *p,
|
||||
struct brw_reg src,
|
||||
GLuint msg_reg_nr,
|
||||
GLuint scratch_offset )
|
||||
{
|
||||
GLuint msg_reg_nr = 1;
|
||||
{
|
||||
brw_push_insn_state(p);
|
||||
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
||||
@@ -877,7 +877,7 @@ void brw_dp_WRITE_16( struct brw_compile *p,
|
||||
brw_MOV(p,
|
||||
retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),
|
||||
brw_imm_d(scratch_offset));
|
||||
|
||||
|
||||
brw_pop_insn_state(p);
|
||||
}
|
||||
|
||||
@@ -912,9 +912,9 @@ void brw_dp_WRITE_16( struct brw_compile *p,
|
||||
*/
|
||||
void brw_dp_READ_16( struct brw_compile *p,
|
||||
struct brw_reg dest,
|
||||
GLuint msg_reg_nr,
|
||||
GLuint scratch_offset )
|
||||
{
|
||||
GLuint msg_reg_nr = 1;
|
||||
{
|
||||
brw_push_insn_state(p);
|
||||
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
||||
@@ -924,7 +924,7 @@ void brw_dp_READ_16( struct brw_compile *p,
|
||||
brw_MOV(p,
|
||||
retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D),
|
||||
brw_imm_d(scratch_offset));
|
||||
|
||||
|
||||
brw_pop_insn_state(p);
|
||||
}
|
||||
|
||||
@@ -958,21 +958,26 @@ void brw_dp_READ_16( struct brw_compile *p,
|
||||
*/
|
||||
void brw_dp_READ_4( struct brw_compile *p,
|
||||
struct brw_reg dest,
|
||||
GLuint msg_reg_nr,
|
||||
GLboolean relAddr,
|
||||
GLuint location,
|
||||
GLuint bind_table_index )
|
||||
{
|
||||
/* XXX: relAddr not implemented */
|
||||
GLuint msg_reg_nr = 1;
|
||||
{
|
||||
struct brw_reg b;
|
||||
brw_push_insn_state(p);
|
||||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
|
||||
brw_set_mask_control(p, BRW_MASK_DISABLE);
|
||||
|
||||
/* set message header global offset field (reg 0, element 2) */
|
||||
/* Note that grf[0] will be copied to mrf[1] implicitly by the SEND instr */
|
||||
brw_MOV(p,
|
||||
retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_UD),
|
||||
brw_imm_d(location));
|
||||
/* Setup MRF[1] with location/offset into const buffer */
|
||||
b = brw_message_reg(msg_reg_nr);
|
||||
b = retype(b, BRW_REGISTER_TYPE_UD);
|
||||
/* XXX I think we're setting all the dwords of MRF[1] to 'location'.
|
||||
* when the docs say only dword[2] should be set. Hmmm. But it works.
|
||||
*/
|
||||
brw_MOV(p, b, brw_imm_ud(location));
|
||||
brw_pop_insn_state(p);
|
||||
}
|
||||
|
||||
@@ -988,7 +993,7 @@ void brw_dp_READ_4( struct brw_compile *p,
|
||||
dest = retype(vec8(dest), BRW_REGISTER_TYPE_UW);
|
||||
|
||||
brw_set_dest(insn, dest);
|
||||
brw_set_src0(insn, retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW));
|
||||
brw_set_src0(insn, brw_null_reg());
|
||||
|
||||
brw_set_dp_read_message(insn,
|
||||
bind_table_index,
|
||||
|
@@ -1044,7 +1044,6 @@ static void emit_spill( struct brw_wm_compile *c,
|
||||
*/
|
||||
brw_dp_WRITE_16(p,
|
||||
retype(vec16(brw_vec8_grf(0, 0)), BRW_REGISTER_TYPE_UW),
|
||||
1,
|
||||
slot);
|
||||
}
|
||||
|
||||
@@ -1072,7 +1071,6 @@ static void emit_unspill( struct brw_wm_compile *c,
|
||||
|
||||
brw_dp_READ_16(p,
|
||||
retype(vec16(reg), BRW_REGISTER_TYPE_UW),
|
||||
1,
|
||||
slot);
|
||||
}
|
||||
|
||||
|
@@ -294,23 +294,20 @@ static void fetch_constants(struct brw_wm_compile *c,
|
||||
if (src->File == PROGRAM_STATE_VAR ||
|
||||
src->File == PROGRAM_CONSTANT ||
|
||||
src->File == PROGRAM_UNIFORM) {
|
||||
if (c->current_const[i].index != src->Index) {
|
||||
c->current_const[i].index = src->Index;
|
||||
c->current_const[i].index = src->Index;
|
||||
|
||||
#if 0
|
||||
printf(" fetch const[%d] for arg %d into reg %d\n",
|
||||
src->Index, i, c->current_const[i].reg.nr);
|
||||
printf(" fetch const[%d] for arg %d into reg %d\n",
|
||||
src->Index, i, c->current_const[i].reg.nr);
|
||||
#endif
|
||||
|
||||
/* need to fetch the constant now */
|
||||
brw_dp_READ_4(p,
|
||||
c->current_const[i].reg, /* writeback dest */
|
||||
1, /* msg_reg */
|
||||
src->RelAddr, /* relative indexing? */
|
||||
16 * src->Index, /* byte offset */
|
||||
SURF_INDEX_FRAG_CONST_BUFFER/* binding table index */
|
||||
);
|
||||
}
|
||||
/* need to fetch the constant now */
|
||||
brw_dp_READ_4(p,
|
||||
c->current_const[i].reg, /* writeback dest */
|
||||
src->RelAddr, /* relative indexing? */
|
||||
16 * src->Index, /* byte offset */
|
||||
SURF_INDEX_FRAG_CONST_BUFFER/* binding table index */
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -265,7 +265,10 @@ intel_bufferobj_unmap(GLcontext * ctx,
|
||||
struct intel_buffer_object *intel_obj = intel_buffer_object(obj);
|
||||
|
||||
assert(intel_obj);
|
||||
if (intel_obj->buffer != NULL) {
|
||||
if (intel_obj->sys_buffer != NULL) {
|
||||
assert(obj->Pointer);
|
||||
obj->Pointer = NULL;
|
||||
} else if (intel_obj->buffer != NULL) {
|
||||
assert(obj->Pointer);
|
||||
if (intel_obj->mapped_gtt) {
|
||||
drm_intel_gem_bo_unmap_gtt(intel_obj->buffer);
|
||||
|
@@ -67,7 +67,7 @@ int INTEL_DEBUG = (0);
|
||||
#endif
|
||||
|
||||
|
||||
#define DRIVER_DATE "20090114"
|
||||
#define DRIVER_DATE "20090712 2009Q2 RC3"
|
||||
#define DRIVER_DATE_GEM "GEM " DRIVER_DATE
|
||||
|
||||
|
||||
@@ -537,7 +537,7 @@ intelFinish(GLcontext * ctx)
|
||||
|
||||
irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
|
||||
|
||||
if (irb->region)
|
||||
if (irb && irb->region)
|
||||
dri_bo_wait_rendering(irb->region->buffer);
|
||||
}
|
||||
if (fb->_DepthBuffer) {
|
||||
|
@@ -515,6 +515,7 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
|
||||
irb->Base.BlueBits = texImage->TexFormat->BlueBits;
|
||||
irb->Base.AlphaBits = texImage->TexFormat->AlphaBits;
|
||||
irb->Base.DepthBits = texImage->TexFormat->DepthBits;
|
||||
irb->Base.StencilBits = texImage->TexFormat->StencilBits;
|
||||
|
||||
irb->Base.Delete = intel_delete_renderbuffer;
|
||||
irb->Base.AllocStorage = intel_nop_alloc_storage;
|
||||
|
@@ -110,6 +110,29 @@ const char *_mesa_lookup_enum_by_nr( int nr )
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the name of an enum given that it is a primitive type. Avoids
|
||||
* GL_FALSE/GL_POINTS ambiguity and others.
|
||||
*/
|
||||
const char *_mesa_lookup_prim_by_nr( int nr )
|
||||
{
|
||||
switch (nr) {
|
||||
case GL_POINTS: return "GL_POINTS";
|
||||
case GL_LINES: return "GL_LINES";
|
||||
case GL_LINE_STRIP: return "GL_LINE_STRIP";
|
||||
case GL_LINE_LOOP: return "GL_LINE_LOOP";
|
||||
case GL_TRIANGLES: return "GL_TRIANGLES";
|
||||
case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP";
|
||||
case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN";
|
||||
case GL_QUADS: return "GL_QUADS";
|
||||
case GL_QUAD_STRIP: return "GL_QUAD_STRIP";
|
||||
case GL_POLYGON: return "GL_POLYGON";
|
||||
case GL_POLYGON+1: return "OUTSIDE_BEGIN_END";
|
||||
default: return "<invalid>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int _mesa_lookup_enum_by_name( const char *symbol )
|
||||
{
|
||||
enum_elt * f = NULL;
|
||||
|
@@ -957,6 +957,20 @@ save_BlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
|
||||
}
|
||||
}
|
||||
|
||||
static void invalidate_saved_current_state( GLcontext *ctx )
|
||||
{
|
||||
GLint i;
|
||||
|
||||
for (i = 0; i < VERT_ATTRIB_MAX; i++)
|
||||
ctx->ListState.ActiveAttribSize[i] = 0;
|
||||
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++)
|
||||
ctx->ListState.ActiveMaterialSize[i] = 0;
|
||||
|
||||
memset(&ctx->ListState.Current, 0, sizeof ctx->ListState.Current);
|
||||
|
||||
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
_mesa_save_CallList(GLuint list)
|
||||
@@ -970,9 +984,10 @@ _mesa_save_CallList(GLuint list)
|
||||
n[1].ui = list;
|
||||
}
|
||||
|
||||
/* After this, we don't know what begin/end state we're in:
|
||||
/* After this, we don't know what state we're in. Invalidate all
|
||||
* cached information previously gathered:
|
||||
*/
|
||||
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
|
||||
invalidate_saved_current_state( ctx );
|
||||
|
||||
if (ctx->ExecuteFlag) {
|
||||
_mesa_CallList(list);
|
||||
@@ -1015,9 +1030,10 @@ _mesa_save_CallLists(GLsizei n, GLenum type, const GLvoid * lists)
|
||||
}
|
||||
}
|
||||
|
||||
/* After this, we don't know what begin/end state we're in:
|
||||
/* After this, we don't know what state we're in. Invalidate all
|
||||
* cached information previously gathered:
|
||||
*/
|
||||
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
|
||||
invalidate_saved_current_state( ctx );
|
||||
|
||||
if (ctx->ExecuteFlag) {
|
||||
CALL_CallLists(ctx->Exec, (n, type, lists));
|
||||
@@ -3177,14 +3193,26 @@ save_ShadeModel(GLenum mode)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
Node *n;
|
||||
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
|
||||
ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx);
|
||||
|
||||
if (ctx->ExecuteFlag) {
|
||||
CALL_ShadeModel(ctx->Exec, (mode));
|
||||
}
|
||||
|
||||
if (ctx->ListState.Current.ShadeModel == mode)
|
||||
return;
|
||||
|
||||
SAVE_FLUSH_VERTICES(ctx);
|
||||
|
||||
/* Only save the value if we know the statechange will take effect:
|
||||
*/
|
||||
if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END)
|
||||
ctx->ListState.Current.ShadeModel = mode;
|
||||
|
||||
n = ALLOC_INSTRUCTION(ctx, OPCODE_SHADE_MODEL, 1);
|
||||
if (n) {
|
||||
n[1].e = mode;
|
||||
}
|
||||
if (ctx->ExecuteFlag) {
|
||||
CALL_ShadeModel(ctx->Exec, (mode));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5146,14 +5174,21 @@ save_EdgeFlag(GLboolean x)
|
||||
save_Attr1fNV(VERT_ATTRIB_EDGEFLAG, x ? (GLfloat)1.0 : (GLfloat)0.0);
|
||||
}
|
||||
|
||||
static INLINE GLboolean compare4fv( const GLfloat *a,
|
||||
const GLfloat *b,
|
||||
GLuint count )
|
||||
{
|
||||
return memcmp( a, b, count * sizeof(GLfloat) ) == 0;
|
||||
}
|
||||
|
||||
|
||||
static void GLAPIENTRY
|
||||
save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
Node *n;
|
||||
int args, i;
|
||||
|
||||
SAVE_FLUSH_VERTICES(ctx);
|
||||
GLuint bitmask;
|
||||
|
||||
switch (face) {
|
||||
case GL_BACK:
|
||||
@@ -5183,6 +5218,36 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
|
||||
_mesa_compile_error(ctx, GL_INVALID_ENUM, "material(pname)");
|
||||
return;
|
||||
}
|
||||
|
||||
if (ctx->ExecuteFlag) {
|
||||
CALL_Materialfv(ctx->Exec, (face, pname, param));
|
||||
}
|
||||
|
||||
bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
|
||||
|
||||
/* Try to eliminate redundant statechanges. Because it is legal to
|
||||
* call glMaterial even inside begin/end calls, don't need to worry
|
||||
* about ctx->Driver.CurrentSavePrimitive here.
|
||||
*/
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++) {
|
||||
if (bitmask & (1 << i)) {
|
||||
if (ctx->ListState.ActiveMaterialSize[i] == args &&
|
||||
compare4fv(ctx->ListState.CurrentMaterial[i], param, args)) {
|
||||
bitmask &= ~(1 << i);
|
||||
}
|
||||
else {
|
||||
ctx->ListState.ActiveMaterialSize[i] = args;
|
||||
COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If this call has effect, return early:
|
||||
*/
|
||||
if (bitmask == 0)
|
||||
return;
|
||||
|
||||
SAVE_FLUSH_VERTICES(ctx);
|
||||
|
||||
n = ALLOC_INSTRUCTION(ctx, OPCODE_MATERIAL, 6);
|
||||
if (n) {
|
||||
@@ -5191,19 +5256,6 @@ save_Materialfv(GLenum face, GLenum pname, const GLfloat * param)
|
||||
for (i = 0; i < args; i++)
|
||||
n[3 + i].f = param[i];
|
||||
}
|
||||
|
||||
{
|
||||
GLuint bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, NULL);
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++)
|
||||
if (bitmask & (1 << i)) {
|
||||
ctx->ListState.ActiveMaterialSize[i] = args;
|
||||
COPY_SZ_4V(ctx->ListState.CurrentMaterial[i], args, param);
|
||||
}
|
||||
}
|
||||
|
||||
if (ctx->ExecuteFlag) {
|
||||
CALL_Materialfv(ctx->Exec, (face, pname, param));
|
||||
}
|
||||
}
|
||||
|
||||
static void GLAPIENTRY
|
||||
@@ -6771,7 +6823,6 @@ void GLAPIENTRY
|
||||
_mesa_NewList(GLuint name, GLenum mode)
|
||||
{
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
GLint i;
|
||||
|
||||
FLUSH_CURRENT(ctx, 0); /* must be called before assert */
|
||||
ASSERT_OUTSIDE_BEGIN_END(ctx);
|
||||
@@ -6799,20 +6850,15 @@ _mesa_NewList(GLuint name, GLenum mode)
|
||||
ctx->CompileFlag = GL_TRUE;
|
||||
ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
|
||||
|
||||
/* Reset acumulated list state:
|
||||
*/
|
||||
invalidate_saved_current_state( ctx );
|
||||
|
||||
/* Allocate new display list */
|
||||
ctx->ListState.CurrentList = make_list(name, BLOCK_SIZE);
|
||||
ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->Head;
|
||||
ctx->ListState.CurrentPos = 0;
|
||||
|
||||
/* Reset acumulated list state:
|
||||
*/
|
||||
for (i = 0; i < VERT_ATTRIB_MAX; i++)
|
||||
ctx->ListState.ActiveAttribSize[i] = 0;
|
||||
|
||||
for (i = 0; i < MAT_ATTRIB_MAX; i++)
|
||||
ctx->ListState.ActiveMaterialSize[i] = 0;
|
||||
|
||||
ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
|
||||
ctx->Driver.NewList(ctx, name, mode);
|
||||
|
||||
ctx->CurrentDispatch = ctx->Save;
|
||||
|
@@ -5059,6 +5059,28 @@ const char *_mesa_lookup_enum_by_nr( int nr )
|
||||
}
|
||||
}
|
||||
|
||||
/* Get the name of an enum given that it is a primitive type. Avoids
|
||||
* GL_FALSE/GL_POINTS ambiguity and others.
|
||||
*/
|
||||
const char *_mesa_lookup_prim_by_nr( int nr )
|
||||
{
|
||||
switch (nr) {
|
||||
case GL_POINTS: return "GL_POINTS";
|
||||
case GL_LINES: return "GL_LINES";
|
||||
case GL_LINE_STRIP: return "GL_LINE_STRIP";
|
||||
case GL_LINE_LOOP: return "GL_LINE_LOOP";
|
||||
case GL_TRIANGLES: return "GL_TRIANGLES";
|
||||
case GL_TRIANGLE_STRIP: return "GL_TRIANGLE_STRIP";
|
||||
case GL_TRIANGLE_FAN: return "GL_TRIANGLE_FAN";
|
||||
case GL_QUADS: return "GL_QUADS";
|
||||
case GL_QUAD_STRIP: return "GL_QUAD_STRIP";
|
||||
case GL_POLYGON: return "GL_POLYGON";
|
||||
case GL_POLYGON+1: return "OUTSIDE_BEGIN_END";
|
||||
default: return "<invalid>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int _mesa_lookup_enum_by_name( const char *symbol )
|
||||
{
|
||||
enum_elt * f = NULL;
|
||||
|
@@ -40,6 +40,12 @@
|
||||
#if defined(_HAVE_FULL_GL) && _HAVE_FULL_GL
|
||||
|
||||
extern const char *_mesa_lookup_enum_by_nr( int nr );
|
||||
|
||||
/* Get the name of an enum given that it is a primitive type. Avoids
|
||||
* GL_FALSE/GL_POINTS ambiguity and others.
|
||||
*/
|
||||
const char *_mesa_lookup_prim_by_nr( int nr );
|
||||
|
||||
extern int _mesa_lookup_enum_by_name( const char *symbol );
|
||||
|
||||
#else
|
||||
|
@@ -1,8 +1,8 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
*
|
||||
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -10,11 +10,11 @@
|
||||
* distribute, sub license, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
|
||||
@@ -22,7 +22,7 @@
|
||||
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/**
|
||||
@@ -48,20 +48,16 @@
|
||||
|
||||
struct state_key {
|
||||
unsigned light_color_material_mask:12;
|
||||
unsigned light_material_mask:12;
|
||||
unsigned light_global_enabled:1;
|
||||
unsigned light_local_viewer:1;
|
||||
unsigned light_twoside:1;
|
||||
unsigned light_color_material:1;
|
||||
unsigned material_shininess_is_zero:1;
|
||||
unsigned need_eye_coords:1;
|
||||
unsigned normalize:1;
|
||||
unsigned rescale_normals:1;
|
||||
|
||||
unsigned fog_source_is_depth:1;
|
||||
unsigned tnl_do_vertex_fog:1;
|
||||
unsigned separate_specular:1;
|
||||
unsigned fog_mode:2;
|
||||
unsigned point_attenuated:1;
|
||||
unsigned point_array:1;
|
||||
unsigned texture_enabled_global:1;
|
||||
@@ -73,7 +69,7 @@ struct state_key {
|
||||
unsigned light_enabled:1;
|
||||
unsigned light_eyepos3_is_zero:1;
|
||||
unsigned light_spotcutoff_is_180:1;
|
||||
unsigned light_attenuated:1;
|
||||
unsigned light_attenuated:1;
|
||||
unsigned texunit_really_enabled:1;
|
||||
unsigned texmat_enabled:1;
|
||||
unsigned texgen_enabled:4;
|
||||
@@ -85,23 +81,6 @@ struct state_key {
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define FOG_NONE 0
|
||||
#define FOG_LINEAR 1
|
||||
#define FOG_EXP 2
|
||||
#define FOG_EXP2 3
|
||||
|
||||
static GLuint translate_fog_mode( GLenum mode )
|
||||
{
|
||||
switch (mode) {
|
||||
case GL_LINEAR: return FOG_LINEAR;
|
||||
case GL_EXP: return FOG_EXP;
|
||||
case GL_EXP2: return FOG_EXP2;
|
||||
default: return FOG_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define TXG_NONE 0
|
||||
#define TXG_OBJ_LINEAR 1
|
||||
#define TXG_EYE_LINEAR 2
|
||||
@@ -125,42 +104,6 @@ static GLuint translate_texgen( GLboolean enabled, GLenum mode )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns bitmask of flags indicating which materials are set per-vertex
|
||||
* in the current VB.
|
||||
* XXX get these from the VBO...
|
||||
*/
|
||||
static GLbitfield
|
||||
tnl_get_per_vertex_materials(GLcontext *ctx)
|
||||
{
|
||||
GLbitfield mask = 0x0;
|
||||
#if 0
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &tnl->vb;
|
||||
GLuint i;
|
||||
|
||||
for (i = _TNL_FIRST_MAT; i <= _TNL_LAST_MAT; i++)
|
||||
if (VB->AttribPtr[i] && VB->AttribPtr[i]->stride)
|
||||
mask |= 1 << (i - _TNL_FIRST_MAT);
|
||||
#endif
|
||||
return mask;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should fog be computed per-vertex?
|
||||
*/
|
||||
static GLboolean
|
||||
tnl_get_per_vertex_fog(GLcontext *ctx)
|
||||
{
|
||||
#if 0
|
||||
TNLcontext *tnl = TNL_CONTEXT(ctx);
|
||||
return tnl->_DoVertexFog;
|
||||
#else
|
||||
return GL_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static GLboolean check_active_shininess( GLcontext *ctx,
|
||||
const struct state_key *key,
|
||||
@@ -168,10 +111,11 @@ static GLboolean check_active_shininess( GLcontext *ctx,
|
||||
{
|
||||
GLuint bit = 1 << (MAT_ATTRIB_FRONT_SHININESS + side);
|
||||
|
||||
if (key->light_color_material_mask & bit)
|
||||
if ((key->varying_vp_inputs & VERT_BIT_COLOR0) &&
|
||||
(key->light_color_material_mask & bit))
|
||||
return GL_TRUE;
|
||||
|
||||
if (key->light_material_mask & bit)
|
||||
if (key->varying_vp_inputs & (bit << 16))
|
||||
return GL_TRUE;
|
||||
|
||||
if (ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS + side][0] != 0.0F)
|
||||
@@ -216,12 +160,9 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
|
||||
key->light_twoside = 1;
|
||||
|
||||
if (ctx->Light.ColorMaterialEnabled) {
|
||||
key->light_color_material = 1;
|
||||
key->light_color_material_mask = ctx->Light.ColorMaterialBitmask;
|
||||
}
|
||||
|
||||
key->light_material_mask = tnl_get_per_vertex_materials(ctx);
|
||||
|
||||
for (i = 0; i < MAX_LIGHTS; i++) {
|
||||
struct gl_light *light = &ctx->Light.Light[i];
|
||||
|
||||
@@ -230,7 +171,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
|
||||
|
||||
if (light->EyePosition[3] == 0.0)
|
||||
key->unit[i].light_eyepos3_is_zero = 1;
|
||||
|
||||
|
||||
if (light->SpotCutoff == 180.0)
|
||||
key->unit[i].light_spotcutoff_is_180 = 1;
|
||||
|
||||
@@ -259,12 +200,8 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
|
||||
if (ctx->Transform.RescaleNormals)
|
||||
key->rescale_normals = 1;
|
||||
|
||||
key->fog_mode = translate_fog_mode(fp->FogOption);
|
||||
|
||||
if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
|
||||
key->fog_source_is_depth = 1;
|
||||
|
||||
key->tnl_do_vertex_fog = tnl_get_per_vertex_fog(ctx);
|
||||
|
||||
if (ctx->Point._Attenuated)
|
||||
key->point_attenuated = 1;
|
||||
@@ -278,29 +215,29 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
|
||||
ctx->Texture._TexMatEnabled ||
|
||||
ctx->Texture._EnabledUnits)
|
||||
key->texture_enabled_global = 1;
|
||||
|
||||
|
||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
|
||||
|
||||
if (texUnit->_ReallyEnabled)
|
||||
key->unit[i].texunit_really_enabled = 1;
|
||||
|
||||
if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
|
||||
if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
|
||||
key->unit[i].texmat_enabled = 1;
|
||||
|
||||
|
||||
if (texUnit->TexGenEnabled) {
|
||||
key->unit[i].texgen_enabled = 1;
|
||||
|
||||
key->unit[i].texgen_mode0 =
|
||||
|
||||
key->unit[i].texgen_mode0 =
|
||||
translate_texgen( texUnit->TexGenEnabled & (1<<0),
|
||||
texUnit->GenS.Mode );
|
||||
key->unit[i].texgen_mode1 =
|
||||
key->unit[i].texgen_mode1 =
|
||||
translate_texgen( texUnit->TexGenEnabled & (1<<1),
|
||||
texUnit->GenT.Mode );
|
||||
key->unit[i].texgen_mode2 =
|
||||
key->unit[i].texgen_mode2 =
|
||||
translate_texgen( texUnit->TexGenEnabled & (1<<2),
|
||||
texUnit->GenR.Mode );
|
||||
key->unit[i].texgen_mode3 =
|
||||
key->unit[i].texgen_mode3 =
|
||||
translate_texgen( texUnit->TexGenEnabled & (1<<3),
|
||||
texUnit->GenQ.Mode );
|
||||
}
|
||||
@@ -308,7 +245,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Very useful debugging tool - produces annotated listing of
|
||||
* generated program with line/function references for each
|
||||
* instruction back into this file:
|
||||
@@ -317,7 +254,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
|
||||
|
||||
|
||||
/* Use uregs to represent registers internally, translate to Mesa's
|
||||
* expected formats on emit.
|
||||
* expected formats on emit.
|
||||
*
|
||||
* NOTE: These are passed by value extensively in this file rather
|
||||
* than as usual by pointer reference. If this disturbs you, try
|
||||
@@ -343,10 +280,10 @@ struct tnl_program {
|
||||
struct gl_vertex_program *program;
|
||||
GLint max_inst; /** number of instructions allocated for program */
|
||||
GLboolean mvp_with_dp4;
|
||||
|
||||
|
||||
GLuint temp_in_use;
|
||||
GLuint temp_reserved;
|
||||
|
||||
|
||||
struct ureg eye_position;
|
||||
struct ureg eye_position_z;
|
||||
struct ureg eye_position_normalized;
|
||||
@@ -450,7 +387,7 @@ static void release_temps( struct tnl_program *p )
|
||||
}
|
||||
|
||||
|
||||
static struct ureg register_param5(struct tnl_program *p,
|
||||
static struct ureg register_param5(struct tnl_program *p,
|
||||
GLint s0,
|
||||
GLint s1,
|
||||
GLint s2,
|
||||
@@ -481,9 +418,9 @@ static struct ureg register_param5(struct tnl_program *p,
|
||||
*/
|
||||
static struct ureg register_input( struct tnl_program *p, GLuint input )
|
||||
{
|
||||
/* Material attribs are passed here as inputs >= 32
|
||||
*/
|
||||
if (input >= 32 || (p->state->varying_vp_inputs & (1<<input))) {
|
||||
assert(input < 32);
|
||||
|
||||
if (p->state->varying_vp_inputs & (1<<input)) {
|
||||
p->program->Base.InputsRead |= (1<<input);
|
||||
return make_ureg(PROGRAM_INPUT, input);
|
||||
}
|
||||
@@ -503,7 +440,7 @@ static struct ureg register_output( struct tnl_program *p, GLuint output )
|
||||
}
|
||||
|
||||
|
||||
static struct ureg register_const4f( struct tnl_program *p,
|
||||
static struct ureg register_const4f( struct tnl_program *p,
|
||||
GLfloat s0,
|
||||
GLfloat s1,
|
||||
GLfloat s2,
|
||||
@@ -535,7 +472,7 @@ static GLboolean is_undef( struct ureg reg )
|
||||
|
||||
static struct ureg get_identity_param( struct tnl_program *p )
|
||||
{
|
||||
if (is_undef(p->identity))
|
||||
if (is_undef(p->identity))
|
||||
p->identity = register_const4f(p, 0,0,0,1);
|
||||
|
||||
return p->identity;
|
||||
@@ -554,7 +491,7 @@ static void register_matrix_param5( struct tnl_program *p,
|
||||
/* This is a bit sad as the support is there to pull the whole
|
||||
* matrix out in one go:
|
||||
*/
|
||||
for (i = 0; i <= s3 - s2; i++)
|
||||
for (i = 0; i <= s3 - s2; i++)
|
||||
matrix[i] = register_param5( p, s0, s1, i, i, s4 );
|
||||
}
|
||||
|
||||
@@ -579,7 +516,7 @@ static void emit_dst( struct prog_dst_register *dst,
|
||||
dst->File = reg.file;
|
||||
dst->Index = reg.idx;
|
||||
/* allow zero as a shorthand for xyzw */
|
||||
dst->WriteMask = mask ? mask : WRITEMASK_XYZW;
|
||||
dst->WriteMask = mask ? mask : WRITEMASK_XYZW;
|
||||
dst->CondMask = COND_TR; /* always pass cond test */
|
||||
dst->CondSwizzle = SWIZZLE_NOOP;
|
||||
dst->CondSrc = 0;
|
||||
@@ -594,12 +531,12 @@ static void debug_insn( struct prog_instruction *inst, const char *fn,
|
||||
{
|
||||
if (DISASSEM) {
|
||||
static const char *last_fn;
|
||||
|
||||
|
||||
if (fn != last_fn) {
|
||||
last_fn = fn;
|
||||
_mesa_printf("%s:\n", fn);
|
||||
}
|
||||
|
||||
|
||||
_mesa_printf("%d:\t", line);
|
||||
_mesa_print_instruction(inst);
|
||||
}
|
||||
@@ -618,7 +555,7 @@ static void emit_op3fn(struct tnl_program *p,
|
||||
{
|
||||
GLuint nr;
|
||||
struct prog_instruction *inst;
|
||||
|
||||
|
||||
assert((GLint) p->program->Base.NumInstructions <= p->max_inst);
|
||||
|
||||
if (p->program->Base.NumInstructions == p->max_inst) {
|
||||
@@ -643,16 +580,16 @@ static void emit_op3fn(struct tnl_program *p,
|
||||
|
||||
p->program->Base.Instructions = newInst;
|
||||
}
|
||||
|
||||
|
||||
nr = p->program->Base.NumInstructions++;
|
||||
|
||||
inst = &p->program->Base.Instructions[nr];
|
||||
inst->Opcode = (enum prog_opcode) op;
|
||||
inst->Opcode = (enum prog_opcode) op;
|
||||
inst->Data = 0;
|
||||
|
||||
|
||||
emit_arg( &inst->SrcReg[0], src0 );
|
||||
emit_arg( &inst->SrcReg[1], src1 );
|
||||
emit_arg( &inst->SrcReg[2], src2 );
|
||||
emit_arg( &inst->SrcReg[2], src2 );
|
||||
|
||||
emit_dst( &inst->DstReg, dest, mask );
|
||||
|
||||
@@ -672,7 +609,7 @@ static void emit_op3fn(struct tnl_program *p,
|
||||
|
||||
static struct ureg make_temp( struct tnl_program *p, struct ureg reg )
|
||||
{
|
||||
if (reg.file == PROGRAM_TEMPORARY &&
|
||||
if (reg.file == PROGRAM_TEMPORARY &&
|
||||
!(p->temp_reserved & (1<<reg.idx)))
|
||||
return reg;
|
||||
else {
|
||||
@@ -753,19 +690,19 @@ static void emit_normalize_vec3( struct tnl_program *p,
|
||||
}
|
||||
|
||||
|
||||
static void emit_passthrough( struct tnl_program *p,
|
||||
static void emit_passthrough( struct tnl_program *p,
|
||||
GLuint input,
|
||||
GLuint output )
|
||||
{
|
||||
struct ureg out = register_output(p, output);
|
||||
emit_op1(p, OPCODE_MOV, out, 0, register_input(p, input));
|
||||
emit_op1(p, OPCODE_MOV, out, 0, register_input(p, input));
|
||||
}
|
||||
|
||||
|
||||
static struct ureg get_eye_position( struct tnl_program *p )
|
||||
{
|
||||
if (is_undef(p->eye_position)) {
|
||||
struct ureg pos = register_input( p, VERT_ATTRIB_POS );
|
||||
struct ureg pos = register_input( p, VERT_ATTRIB_POS );
|
||||
struct ureg modelview[4];
|
||||
|
||||
p->eye_position = reserve_temp(p);
|
||||
@@ -783,18 +720,18 @@ static struct ureg get_eye_position( struct tnl_program *p )
|
||||
emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return p->eye_position;
|
||||
}
|
||||
|
||||
|
||||
static struct ureg get_eye_position_z( struct tnl_program *p )
|
||||
{
|
||||
if (!is_undef(p->eye_position))
|
||||
if (!is_undef(p->eye_position))
|
||||
return swizzle1(p->eye_position, Z);
|
||||
|
||||
if (is_undef(p->eye_position_z)) {
|
||||
struct ureg pos = register_input( p, VERT_ATTRIB_POS );
|
||||
struct ureg pos = register_input( p, VERT_ATTRIB_POS );
|
||||
struct ureg modelview[4];
|
||||
|
||||
p->eye_position_z = reserve_temp(p);
|
||||
@@ -804,10 +741,10 @@ static struct ureg get_eye_position_z( struct tnl_program *p )
|
||||
|
||||
emit_op2(p, OPCODE_DP4, p->eye_position_z, 0, pos, modelview[2]);
|
||||
}
|
||||
|
||||
|
||||
return p->eye_position_z;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static struct ureg get_eye_position_normalized( struct tnl_program *p )
|
||||
{
|
||||
@@ -816,7 +753,7 @@ static struct ureg get_eye_position_normalized( struct tnl_program *p )
|
||||
p->eye_position_normalized = reserve_temp(p);
|
||||
emit_normalize_vec3(p, p->eye_position_normalized, eye);
|
||||
}
|
||||
|
||||
|
||||
return p->eye_position_normalized;
|
||||
}
|
||||
|
||||
@@ -830,7 +767,7 @@ static struct ureg get_transformed_normal( struct tnl_program *p )
|
||||
{
|
||||
p->transformed_normal = register_input(p, VERT_ATTRIB_NORMAL );
|
||||
}
|
||||
else if (is_undef(p->transformed_normal))
|
||||
else if (is_undef(p->transformed_normal))
|
||||
{
|
||||
struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
|
||||
struct ureg mvinv[3];
|
||||
@@ -861,7 +798,7 @@ static struct ureg get_transformed_normal( struct tnl_program *p )
|
||||
emit_op2( p, OPCODE_MUL, transformed_normal, 0, normal, rescale );
|
||||
normal = transformed_normal;
|
||||
}
|
||||
|
||||
|
||||
assert(normal.file == PROGRAM_TEMPORARY);
|
||||
p->transformed_normal = normal;
|
||||
}
|
||||
@@ -872,17 +809,17 @@ static struct ureg get_transformed_normal( struct tnl_program *p )
|
||||
|
||||
static void build_hpos( struct tnl_program *p )
|
||||
{
|
||||
struct ureg pos = register_input( p, VERT_ATTRIB_POS );
|
||||
struct ureg pos = register_input( p, VERT_ATTRIB_POS );
|
||||
struct ureg hpos = register_output( p, VERT_RESULT_HPOS );
|
||||
struct ureg mvp[4];
|
||||
|
||||
if (p->mvp_with_dp4) {
|
||||
register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3,
|
||||
register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3,
|
||||
0, mvp );
|
||||
emit_matrix_transform_vec4( p, hpos, mvp, pos );
|
||||
}
|
||||
else {
|
||||
register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3,
|
||||
register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3,
|
||||
STATE_MATRIX_TRANSPOSE, mvp );
|
||||
emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos );
|
||||
}
|
||||
@@ -903,27 +840,28 @@ static void set_material_flags( struct tnl_program *p )
|
||||
p->color_materials = 0;
|
||||
p->materials = 0;
|
||||
|
||||
if (p->state->light_color_material) {
|
||||
p->materials =
|
||||
if (p->state->varying_vp_inputs & VERT_BIT_COLOR0) {
|
||||
p->materials =
|
||||
p->color_materials = p->state->light_color_material_mask;
|
||||
}
|
||||
|
||||
p->materials |= p->state->light_material_mask;
|
||||
p->materials |= (p->state->varying_vp_inputs >> 16);
|
||||
}
|
||||
|
||||
|
||||
/* XXX temporary!!! */
|
||||
#define _TNL_ATTRIB_MAT_FRONT_AMBIENT 32
|
||||
|
||||
static struct ureg get_material( struct tnl_program *p, GLuint side,
|
||||
static struct ureg get_material( struct tnl_program *p, GLuint side,
|
||||
GLuint property )
|
||||
{
|
||||
GLuint attrib = material_attrib(side, property);
|
||||
|
||||
if (p->color_materials & (1<<attrib))
|
||||
return register_input(p, VERT_ATTRIB_COLOR0);
|
||||
else if (p->materials & (1<<attrib))
|
||||
return register_input( p, attrib + _TNL_ATTRIB_MAT_FRONT_AMBIENT );
|
||||
else if (p->materials & (1<<attrib)) {
|
||||
/* Put material values in the GENERIC slots -- they are not used
|
||||
* for anything in fixed function mode.
|
||||
*/
|
||||
return register_input( p, attrib + VERT_ATTRIB_GENERIC0 );
|
||||
}
|
||||
else
|
||||
return register_param3( p, STATE_MATERIAL, side, property );
|
||||
}
|
||||
@@ -952,7 +890,7 @@ static struct ureg get_scenecolor( struct tnl_program *p, GLuint side )
|
||||
struct ureg material_ambient = get_material(p, side, STATE_AMBIENT);
|
||||
struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE);
|
||||
struct ureg tmp = make_temp(p, material_diffuse);
|
||||
emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient,
|
||||
emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient,
|
||||
material_ambient, material_emission);
|
||||
return tmp;
|
||||
}
|
||||
@@ -961,12 +899,12 @@ static struct ureg get_scenecolor( struct tnl_program *p, GLuint side )
|
||||
}
|
||||
|
||||
|
||||
static struct ureg get_lightprod( struct tnl_program *p, GLuint light,
|
||||
static struct ureg get_lightprod( struct tnl_program *p, GLuint light,
|
||||
GLuint side, GLuint property )
|
||||
{
|
||||
GLuint attrib = material_attrib(side, property);
|
||||
if (p->materials & (1<<attrib)) {
|
||||
struct ureg light_value =
|
||||
struct ureg light_value =
|
||||
register_param3(p, STATE_LIGHT, light, property);
|
||||
struct ureg material_value = get_material(p, side, property);
|
||||
struct ureg tmp = get_temp(p);
|
||||
@@ -979,7 +917,7 @@ static struct ureg get_lightprod( struct tnl_program *p, GLuint light,
|
||||
|
||||
|
||||
static struct ureg calculate_light_attenuation( struct tnl_program *p,
|
||||
GLuint i,
|
||||
GLuint i,
|
||||
struct ureg VPpli,
|
||||
struct ureg dist )
|
||||
{
|
||||
@@ -1008,27 +946,27 @@ static struct ureg calculate_light_attenuation( struct tnl_program *p,
|
||||
*/
|
||||
if (p->state->unit[i].light_attenuated) {
|
||||
/* 1/d,d,d,1/d */
|
||||
emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist);
|
||||
emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist);
|
||||
/* 1,d,d*d,1/d */
|
||||
emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y));
|
||||
emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y));
|
||||
/* 1/dist-atten */
|
||||
emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist);
|
||||
emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist);
|
||||
|
||||
if (!p->state->unit[i].light_spotcutoff_is_180) {
|
||||
/* dist-atten */
|
||||
emit_op1(p, OPCODE_RCP, dist, 0, dist);
|
||||
emit_op1(p, OPCODE_RCP, dist, 0, dist);
|
||||
/* spot-atten * dist-atten */
|
||||
emit_op2(p, OPCODE_MUL, att, 0, dist, att);
|
||||
emit_op2(p, OPCODE_MUL, att, 0, dist, att);
|
||||
}
|
||||
else {
|
||||
/* dist-atten */
|
||||
emit_op1(p, OPCODE_RCP, att, 0, dist);
|
||||
emit_op1(p, OPCODE_RCP, att, 0, dist);
|
||||
}
|
||||
}
|
||||
|
||||
return att;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Compute:
|
||||
@@ -1047,7 +985,7 @@ static void emit_degenerate_lit( struct tnl_program *p,
|
||||
|
||||
/* MAX lit, id, dots;
|
||||
*/
|
||||
emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots);
|
||||
emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots);
|
||||
|
||||
/* result[2] = (in > 0 ? 1 : 0)
|
||||
* SLT lit.z, id.z, dots; # lit.z = (0 < dots.z) ? 1 : 0
|
||||
@@ -1080,10 +1018,10 @@ static void build_lighting( struct tnl_program *p )
|
||||
* dots.w = front.shininess
|
||||
*/
|
||||
|
||||
for (i = 0; i < MAX_LIGHTS; i++)
|
||||
for (i = 0; i < MAX_LIGHTS; i++)
|
||||
if (p->state->unit[i].light_enabled)
|
||||
nr_lights++;
|
||||
|
||||
|
||||
set_material_flags(p);
|
||||
|
||||
{
|
||||
@@ -1106,7 +1044,7 @@ static void build_lighting( struct tnl_program *p )
|
||||
* The negation will be un-done later in the back-face code below.
|
||||
*/
|
||||
struct ureg shininess = get_material(p, 1, STATE_SHININESS);
|
||||
emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z,
|
||||
emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z,
|
||||
negate(swizzle1(shininess,X)));
|
||||
release_temp(p, shininess);
|
||||
}
|
||||
@@ -1134,12 +1072,12 @@ static void build_lighting( struct tnl_program *p )
|
||||
struct ureg res0 = register_output( p, VERT_RESULT_BFC0 );
|
||||
emit_op1(p, OPCODE_MOV, res0, 0, _bfc0);
|
||||
}
|
||||
|
||||
|
||||
if (twoside && separate) {
|
||||
struct ureg res1 = register_output( p, VERT_RESULT_BFC1 );
|
||||
emit_op1(p, OPCODE_MOV, res1, 0, _bfc1);
|
||||
}
|
||||
|
||||
|
||||
if (nr_lights == 0) {
|
||||
release_temps(p);
|
||||
return;
|
||||
@@ -1149,16 +1087,16 @@ static void build_lighting( struct tnl_program *p )
|
||||
if (p->state->unit[i].light_enabled) {
|
||||
struct ureg half = undef;
|
||||
struct ureg att = undef, VPpli = undef;
|
||||
|
||||
|
||||
count++;
|
||||
|
||||
if (p->state->unit[i].light_eyepos3_is_zero) {
|
||||
/* Can used precomputed constants in this case.
|
||||
* Attenuation never applies to infinite lights.
|
||||
*/
|
||||
VPpli = register_param3(p, STATE_INTERNAL,
|
||||
STATE_LIGHT_POSITION_NORMALIZED, i);
|
||||
|
||||
VPpli = register_param3(p, STATE_INTERNAL,
|
||||
STATE_LIGHT_POSITION_NORMALIZED, i);
|
||||
|
||||
if (!p->state->material_shininess_is_zero) {
|
||||
if (p->state->light_local_viewer) {
|
||||
struct ureg eye_hat = get_eye_position_normalized(p);
|
||||
@@ -1167,22 +1105,22 @@ static void build_lighting( struct tnl_program *p )
|
||||
emit_normalize_vec3(p, half, half);
|
||||
}
|
||||
else {
|
||||
half = register_param3(p, STATE_INTERNAL,
|
||||
half = register_param3(p, STATE_INTERNAL,
|
||||
STATE_LIGHT_HALF_VECTOR, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
struct ureg Ppli = register_param3(p, STATE_INTERNAL,
|
||||
STATE_LIGHT_POSITION, i);
|
||||
struct ureg Ppli = register_param3(p, STATE_INTERNAL,
|
||||
STATE_LIGHT_POSITION, i);
|
||||
struct ureg V = get_eye_position(p);
|
||||
struct ureg dist = get_temp(p);
|
||||
|
||||
VPpli = get_temp(p);
|
||||
|
||||
VPpli = get_temp(p);
|
||||
|
||||
/* Calculate VPpli vector
|
||||
*/
|
||||
emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V);
|
||||
emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V);
|
||||
|
||||
/* Normalize VPpli. The dist value also used in
|
||||
* attenuation below.
|
||||
@@ -1192,7 +1130,7 @@ static void build_lighting( struct tnl_program *p )
|
||||
emit_op2(p, OPCODE_MUL, VPpli, 0, VPpli, dist);
|
||||
|
||||
/* Calculate attenuation:
|
||||
*/
|
||||
*/
|
||||
if (!p->state->unit[i].light_spotcutoff_is_180 ||
|
||||
p->state->unit[i].light_attenuated) {
|
||||
att = calculate_light_attenuation(p, i, VPpli, dist);
|
||||
@@ -1208,7 +1146,7 @@ static void build_lighting( struct tnl_program *p )
|
||||
emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat);
|
||||
}
|
||||
else {
|
||||
struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z);
|
||||
struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z);
|
||||
emit_op2(p, OPCODE_ADD, half, 0, VPpli, z_dir);
|
||||
}
|
||||
|
||||
@@ -1277,7 +1215,7 @@ static void build_lighting( struct tnl_program *p )
|
||||
|
||||
emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0);
|
||||
emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1);
|
||||
|
||||
|
||||
release_temp(p, ambient);
|
||||
release_temp(p, diffuse);
|
||||
release_temp(p, specular);
|
||||
@@ -1291,7 +1229,7 @@ static void build_lighting( struct tnl_program *p )
|
||||
struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR);
|
||||
struct ureg res0, res1;
|
||||
GLuint mask0, mask1;
|
||||
|
||||
|
||||
if (count == nr_lights) {
|
||||
if (separate) {
|
||||
mask0 = WRITEMASK_XYZ;
|
||||
@@ -1368,52 +1306,10 @@ static void build_fog( struct tnl_program *p )
|
||||
input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
|
||||
}
|
||||
|
||||
if (p->state->fog_mode && p->state->tnl_do_vertex_fog) {
|
||||
struct ureg params = register_param2(p, STATE_INTERNAL,
|
||||
STATE_FOG_PARAMS_OPTIMIZED);
|
||||
struct ureg tmp = get_temp(p);
|
||||
GLboolean useabs = (p->state->fog_mode != FOG_EXP2);
|
||||
|
||||
if (useabs) {
|
||||
emit_op1(p, OPCODE_ABS, tmp, 0, input);
|
||||
}
|
||||
|
||||
switch (p->state->fog_mode) {
|
||||
case FOG_LINEAR: {
|
||||
struct ureg id = get_identity_param(p);
|
||||
emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
|
||||
swizzle1(params,X), swizzle1(params,Y));
|
||||
emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
|
||||
emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
|
||||
break;
|
||||
}
|
||||
case FOG_EXP:
|
||||
emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
|
||||
swizzle1(params,Z));
|
||||
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
|
||||
break;
|
||||
case FOG_EXP2:
|
||||
emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
|
||||
emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
|
||||
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
|
||||
break;
|
||||
}
|
||||
|
||||
release_temp(p, tmp);
|
||||
}
|
||||
else {
|
||||
/* results = incoming fog coords (compute fog per-fragment later)
|
||||
*
|
||||
* KW: Is it really necessary to do anything in this case?
|
||||
* BP: Yes, we always need to compute the absolute value, unless
|
||||
* we want to push that down into the fragment program...
|
||||
*/
|
||||
GLboolean useabs = GL_TRUE;
|
||||
emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input);
|
||||
}
|
||||
emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void build_reflect_texgen( struct tnl_program *p,
|
||||
struct ureg dest,
|
||||
GLuint writemask )
|
||||
@@ -1423,9 +1319,9 @@ static void build_reflect_texgen( struct tnl_program *p,
|
||||
struct ureg tmp = get_temp(p);
|
||||
|
||||
/* n.u */
|
||||
emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat);
|
||||
emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat);
|
||||
/* 2n.u */
|
||||
emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp);
|
||||
emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp);
|
||||
/* (-2n.u)n + u */
|
||||
emit_op3(p, OPCODE_MAD, dest, writemask, negate(tmp), normal, eye_hat);
|
||||
|
||||
@@ -1454,22 +1350,22 @@ static void build_sphere_texgen( struct tnl_program *p,
|
||||
*/
|
||||
|
||||
/* n.u */
|
||||
emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat);
|
||||
emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat);
|
||||
/* 2n.u */
|
||||
emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp);
|
||||
emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp);
|
||||
/* (-2n.u)n + u */
|
||||
emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat);
|
||||
emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat);
|
||||
/* r + 0,0,1 */
|
||||
emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z));
|
||||
emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z));
|
||||
/* rx^2 + ry^2 + (rz+1)^2 */
|
||||
emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp);
|
||||
emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp);
|
||||
/* 2/m */
|
||||
emit_op1(p, OPCODE_RSQ, tmp, 0, tmp);
|
||||
emit_op1(p, OPCODE_RSQ, tmp, 0, tmp);
|
||||
/* 1/m */
|
||||
emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half);
|
||||
emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half);
|
||||
/* r/m + 1/2 */
|
||||
emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half);
|
||||
|
||||
emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half);
|
||||
|
||||
release_temp(p, tmp);
|
||||
release_temp(p, r);
|
||||
release_temp(p, inv_m);
|
||||
@@ -1484,10 +1380,10 @@ static void build_texture_transform( struct tnl_program *p )
|
||||
|
||||
if (!(p->state->fragprog_inputs_read & FRAG_BIT_TEX(i)))
|
||||
continue;
|
||||
|
||||
if (p->state->unit[i].texgen_enabled ||
|
||||
|
||||
if (p->state->unit[i].texgen_enabled ||
|
||||
p->state->unit[i].texmat_enabled) {
|
||||
|
||||
|
||||
GLuint texmat_enabled = p->state->unit[i].texmat_enabled;
|
||||
struct ureg out = register_output(p, VERT_RESULT_TEX0 + i);
|
||||
struct ureg out_texgen = undef;
|
||||
@@ -1498,8 +1394,8 @@ static void build_texture_transform( struct tnl_program *p )
|
||||
GLuint reflect_mask = 0;
|
||||
GLuint normal_mask = 0;
|
||||
GLuint modes[4];
|
||||
|
||||
if (texmat_enabled)
|
||||
|
||||
if (texmat_enabled)
|
||||
out_texgen = get_temp(p);
|
||||
else
|
||||
out_texgen = out;
|
||||
@@ -1513,31 +1409,31 @@ static void build_texture_transform( struct tnl_program *p )
|
||||
switch (modes[j]) {
|
||||
case TXG_OBJ_LINEAR: {
|
||||
struct ureg obj = register_input(p, VERT_ATTRIB_POS);
|
||||
struct ureg plane =
|
||||
struct ureg plane =
|
||||
register_param3(p, STATE_TEXGEN, i,
|
||||
STATE_TEXGEN_OBJECT_S + j);
|
||||
|
||||
emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j,
|
||||
emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j,
|
||||
obj, plane );
|
||||
break;
|
||||
}
|
||||
case TXG_EYE_LINEAR: {
|
||||
struct ureg eye = get_eye_position(p);
|
||||
struct ureg plane =
|
||||
register_param3(p, STATE_TEXGEN, i,
|
||||
struct ureg plane =
|
||||
register_param3(p, STATE_TEXGEN, i,
|
||||
STATE_TEXGEN_EYE_S + j);
|
||||
|
||||
emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j,
|
||||
emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j,
|
||||
eye, plane );
|
||||
break;
|
||||
}
|
||||
case TXG_SPHERE_MAP:
|
||||
case TXG_SPHERE_MAP:
|
||||
sphere_mask |= WRITEMASK_X << j;
|
||||
break;
|
||||
case TXG_REFLECTION_MAP:
|
||||
reflect_mask |= WRITEMASK_X << j;
|
||||
break;
|
||||
case TXG_NORMAL_MAP:
|
||||
case TXG_NORMAL_MAP:
|
||||
normal_mask |= WRITEMASK_X << j;
|
||||
break;
|
||||
case TXG_NONE:
|
||||
@@ -1566,8 +1462,8 @@ static void build_texture_transform( struct tnl_program *p )
|
||||
|
||||
if (texmat_enabled) {
|
||||
struct ureg texmat[4];
|
||||
struct ureg in = (!is_undef(out_texgen) ?
|
||||
out_texgen :
|
||||
struct ureg in = (!is_undef(out_texgen) ?
|
||||
out_texgen :
|
||||
register_input(p, VERT_ATTRIB_TEX0+i));
|
||||
if (p->mvp_with_dp4) {
|
||||
register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3,
|
||||
@@ -1628,17 +1524,6 @@ static void build_atten_pointsize( struct tnl_program *p )
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Emit constant point size.
|
||||
*/
|
||||
static void build_constant_pointsize( struct tnl_program *p )
|
||||
{
|
||||
struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
|
||||
struct ureg out = register_output(p, VERT_RESULT_PSIZ);
|
||||
emit_op1(p, OPCODE_MOV, out, WRITEMASK_X, state_size);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pass-though per-vertex point size, from user's point size array.
|
||||
*/
|
||||
@@ -1670,8 +1555,7 @@ static void build_tnl_program( struct tnl_program *p )
|
||||
}
|
||||
}
|
||||
|
||||
if ((p->state->fragprog_inputs_read & FRAG_BIT_FOGC) ||
|
||||
p->state->fog_mode != FOG_NONE)
|
||||
if (p->state->fragprog_inputs_read & FRAG_BIT_FOGC)
|
||||
build_fog(p);
|
||||
|
||||
if (p->state->fragprog_inputs_read & FRAG_BITS_TEX_ANY)
|
||||
@@ -1681,12 +1565,6 @@ static void build_tnl_program( struct tnl_program *p )
|
||||
build_atten_pointsize(p);
|
||||
else if (p->state->point_array)
|
||||
build_array_pointsize(p);
|
||||
#if 0
|
||||
else
|
||||
build_constant_pointsize(p);
|
||||
#else
|
||||
(void) build_constant_pointsize;
|
||||
#endif
|
||||
|
||||
/* Finish up:
|
||||
*/
|
||||
@@ -1718,7 +1596,7 @@ create_new_program( const struct state_key *key,
|
||||
p.identity = undef;
|
||||
p.temp_in_use = 0;
|
||||
p.mvp_with_dp4 = mvp_with_dp4;
|
||||
|
||||
|
||||
if (max_temps >= sizeof(int) * 8)
|
||||
p.temp_reserved = 0;
|
||||
else
|
||||
@@ -1761,14 +1639,14 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
|
||||
*/
|
||||
prog = (struct gl_vertex_program *)
|
||||
_mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key));
|
||||
|
||||
|
||||
if (!prog) {
|
||||
/* OK, we'll have to build a new one */
|
||||
if (0)
|
||||
_mesa_printf("Build new TNL program\n");
|
||||
|
||||
|
||||
prog = (struct gl_vertex_program *)
|
||||
ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
|
||||
ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
|
||||
if (!prog)
|
||||
return NULL;
|
||||
|
||||
@@ -1778,7 +1656,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
|
||||
|
||||
#if 0
|
||||
if (ctx->Driver.ProgramStringNotify)
|
||||
ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
|
||||
ctx->Driver.ProgramStringNotify( ctx, GL_VERTEX_PROGRAM_ARB,
|
||||
&prog->Base );
|
||||
#endif
|
||||
_mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache,
|
||||
|
@@ -83,28 +83,28 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
|
||||
|
||||
|
||||
/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */
|
||||
#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F))
|
||||
#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0))
|
||||
|
||||
/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */
|
||||
#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0F))
|
||||
#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
|
||||
|
||||
|
||||
/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */
|
||||
#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0F))
|
||||
#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0))
|
||||
|
||||
/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */
|
||||
/* causes overflow:
|
||||
#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 )
|
||||
#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0 * (X))) - 1) / 2 )
|
||||
*/
|
||||
/* a close approximation: */
|
||||
#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0F * (X)) )
|
||||
#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
|
||||
|
||||
|
||||
/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */
|
||||
#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0F))
|
||||
#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0))
|
||||
|
||||
/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */
|
||||
#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0F * (X)) )
|
||||
#define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0 * (X)) )
|
||||
|
||||
|
||||
#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b)))
|
||||
|
@@ -2806,6 +2806,13 @@ struct gl_dlist_state
|
||||
|
||||
GLubyte ActiveEdgeFlag;
|
||||
GLboolean CurrentEdgeFlag;
|
||||
|
||||
struct {
|
||||
/* State known to have been set by the currently-compiling display
|
||||
* list. Used to eliminate some redundant state changes.
|
||||
*/
|
||||
GLenum ShadeModel;
|
||||
} Current;
|
||||
};
|
||||
|
||||
|
||||
|
@@ -561,13 +561,19 @@ update_texture_state( GLcontext *ctx )
|
||||
}
|
||||
|
||||
if (!texUnit->_ReallyEnabled) {
|
||||
/* If we get here it means the shader (or fixed-function state)
|
||||
* is expecting a texture object, but there isn't one (or it's
|
||||
* incomplete). Use the fallback texture.
|
||||
*/
|
||||
struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx);
|
||||
texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX;
|
||||
_mesa_reference_texobj(&texUnit->_Current, texObj);
|
||||
if (fprog) {
|
||||
/* If we get here it means the shader is expecting a texture
|
||||
* object, but there isn't one (or it's incomplete). Use the
|
||||
* fallback texture.
|
||||
*/
|
||||
struct gl_texture_object *texObj = _mesa_get_fallback_texture(ctx);
|
||||
texUnit->_ReallyEnabled = 1 << TEXTURE_2D_INDEX;
|
||||
_mesa_reference_texobj(&texUnit->_Current, texObj);
|
||||
}
|
||||
else {
|
||||
/* fixed-function: texture unit is really disabled */
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* if we get here, we know this texture unit is enabled */
|
||||
|
@@ -3922,6 +3922,13 @@ _mesa_parse_arb_fragment_program(GLcontext* ctx, GLenum target,
|
||||
|
||||
if (program->FogOption)
|
||||
program->Base.InputsRead |= FRAG_BIT_FOGC;
|
||||
|
||||
/* XXX: assume that ARB fragment programs don't have access to the
|
||||
* FrontFacing and PointCoord values stuffed into the fog
|
||||
* coordinate in GLSL shaders.
|
||||
*/
|
||||
if (program->Base.InputsRead & FRAG_BIT_FOGC)
|
||||
program->UsesFogFragCoord = GL_TRUE;
|
||||
|
||||
if (program->Base.Instructions)
|
||||
_mesa_free(program->Base.Instructions);
|
||||
|
@@ -396,6 +396,7 @@ _mesa_append_fog_code(GLcontext *ctx, struct gl_fragment_program *fprog)
|
||||
fprog->Base.Instructions = newInst;
|
||||
fprog->Base.NumInstructions = inst - newInst;
|
||||
fprog->Base.InputsRead |= FRAG_BIT_FOGC;
|
||||
fprog->UsesFogFragCoord = GL_TRUE;
|
||||
/* XXX do this? fprog->FogOption = GL_NONE; */
|
||||
}
|
||||
|
||||
|
@@ -85,7 +85,7 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
|
||||
{ "gl_TextureMatrixTranspose", STATE_TEXTURE_MATRIX, 0 },
|
||||
{ "gl_TextureMatrixInverseTranspose", STATE_TEXTURE_MATRIX, STATE_MATRIX_INVERSE },
|
||||
|
||||
{ "gl_NormalMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_TRANSPOSE },
|
||||
{ "gl_NormalMatrix", STATE_MODELVIEW_MATRIX, STATE_MATRIX_INVERSE },
|
||||
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
@@ -111,10 +111,9 @@ lookup_statevar(const char *var, GLint index1, GLint index2, const char *field,
|
||||
|
||||
if (isMatrix) {
|
||||
if (tokens[0] == STATE_TEXTURE_MATRIX) {
|
||||
if (index1 >= 0) {
|
||||
tokens[1] = index1; /* which texture matrix */
|
||||
index1 = 0; /* prevent extra addition at end of function */
|
||||
}
|
||||
/* texture_matrix[index1][index2] */
|
||||
tokens[1] = index1 >= 0 ? index1 : 0; /* which texture matrix */
|
||||
index1 = index2; /* move matrix row value to index1 */
|
||||
}
|
||||
if (index1 < 0) {
|
||||
/* index1 is unused: prevent extra addition at end of function */
|
||||
@@ -682,7 +681,9 @@ _slang_alloc_statevar(slang_ir_node *n,
|
||||
if (n->Opcode == IR_ELEMENT) {
|
||||
/* XXX can only handle constant indexes for now */
|
||||
if (n->Children[1]->Opcode == IR_FLOAT) {
|
||||
index2 = (GLint) n->Children[1]->Value[0];
|
||||
/* two-dimensional array index: mat[i][j] */
|
||||
index2 = index1;
|
||||
index1 = (GLint) n->Children[1]->Value[0];
|
||||
}
|
||||
else {
|
||||
*direct = GL_FALSE;
|
||||
|
@@ -1417,8 +1417,9 @@ slang_inline_function_call(slang_assemble_ctx * A, slang_function *fun,
|
||||
}
|
||||
else if (p->type.qualifier == SLANG_QUAL_CONST) {
|
||||
/* a constant input param */
|
||||
if (args[i].type == SLANG_OPER_IDENTIFIER ||
|
||||
args[i].type == SLANG_OPER_LITERAL_FLOAT) {
|
||||
if (args[i].type == SLANG_OPER_IDENTIFIER ||
|
||||
args[i].type == SLANG_OPER_LITERAL_FLOAT ||
|
||||
args[i].type == SLANG_OPER_SUBSCRIPT) {
|
||||
/* replace all occurances of this parameter variable with the
|
||||
* actual argument variable or a literal.
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user