Merge branch 'origin'

This commit is contained in:
Eric Anholt 2007-10-29 13:24:27 -07:00
commit b0edb9c38a
128 changed files with 3193 additions and 738 deletions

View File

@ -69,6 +69,7 @@ aix-static \
bluegene-osmesa \
bluegene-xlc-osmesa \
beos \
catamount-osmesa-pgi \
darwin \
darwin-static \
darwin-static-x86ppc \
@ -413,6 +414,9 @@ GLUT_FILES = \
$(DIRECTORY)/src/glut/fbdev/Makefile \
$(DIRECTORY)/src/glut/fbdev/*[ch] \
$(DIRECTORY)/src/glut/mini/*[ch] \
$(DIRECTORY)/src/glut/directfb/Makefile \
$(DIRECTORY)/src/glut/directfb/NOTES \
$(DIRECTORY)/src/glut/directfb/*[ch] \
$(DIRECTORY)/windows/VC6/progs/glut/glut.dsp \
$(DIRECTORY)/windows/VC7/progs/glut/glut.vcproj

View File

@ -0,0 +1,32 @@
# Configuration for building only libOSMesa on Cray Xt3
# for the compute nodes running Catamount using the
# Portland Group compiler. The Portland Group toolchain has to be
# enabled before using "module switch PrgEnv-gnu PrgEnv-pgi" .
# This doesn't really have a lot of dependencies, so it should be usable
# on other similar systems too.
# It uses static linking and disables multithreading.
include $(TOP)/configs/default
CONFIG_NAME = catamount-osmesa-pgi
# Compiler and flags
CC = cc
CXX = CC
CFLAGS = -target=catamount -fastsse -O3 -Mnontemporal -Mprefetch=distance:8,nta -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
CXXFLAGS = -target=catamount -fastsse -O3 -Mnontemporal -Mprefetch=distance:8,nta -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
MKLIB_OPTIONS = -static
OSMESA_LIB_NAME = libOSMesa.a
# Directories
SRC_DIRS = mesa glu
DRIVER_DIRS = osmesa
PROGRAM_DIRS = osdemos
# Dependencies
OSMESA_LIB_DEPS = -lm
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(OSMESA_LIB)
APP_LIB_DEPS = -lOSMesa -lGLU -lm

View File

@ -67,14 +67,16 @@ DRIVER_DIRS = x11 osmesa
PROGRAM_DIRS = demos redbook samples glsl xdemos
# Library/program dependencies
# Library dependencies
#EXTRA_LIB_PATH ?=
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
# Program dependencies - specific GL/glut libraries added in Makefiles
APP_LIB_DEPS = -lm

View File

@ -55,10 +55,10 @@ USING_EGL=0
# Directories
ifeq ($(USING_EGL), 1)
SRC_DIRS = egl glx/x11 mesa glu glut/glx glw
PROGRAM_DIRS = egl
PROGRAM_DIRS = egl xdemos
else
SRC_DIRS = glx/x11 mesa glu glut/glx glw
PROGRAM_DIRS =
PROGRAM_DIRS = xdemos
endif
DRIVER_DIRS = dri

View File

@ -41,8 +41,9 @@ EXTRA_LIB_PATH=`pkg-config --libs-only-L x11`
LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
LIBDRM_LIB = `pkg-config --libs libdrm`
DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \
$(LIBDRM_LIB) `pkg-config --libs xcb` `pkg-config --libs x11-xcb` `pkg-config --libs xcb-glx`
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lXdamage -lXfixes \
-lm -lpthread -ldl $(LIBDRM_LIB) `pkg-config --libs xcb` \
`pkg-config --libs x11-xcb` `pkg-config --libs xcb-glx`
# This is now 0 by default since it seems to confuse the hell out of people
@ -54,10 +55,10 @@ USING_EGL=0
# Directories
ifeq ($(USING_EGL), 1)
SRC_DIRS = egl glx/x11 mesa glu glut/glx glw
PROGRAM_DIRS = egl
PROGRAM_DIRS = egl xdemos
else
SRC_DIRS = glx/x11 mesa glu glut/glx glw
PROGRAM_DIRS =
PROGRAM_DIRS = xdemos
endif
DRIVER_DIRS = dri

View File

@ -21,6 +21,4 @@ GLUT_LIB_DEPS =
GLW_LIB_DEPS =
# Need to specify all libraries we may need
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm \
-L/usr/X11R6/lib/ -lX11 -lXmu -lXi -lpthread
APP_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm

View File

@ -19,5 +19,4 @@ OSMESA_LIB_DEPS =
GLU_LIB_DEPS =
GLUT_LIB_DEPS =
GLW_LIB_DEPS =
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
$(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm
APP_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm

View File

@ -19,5 +19,4 @@ OSMESA_LIB_DEPS =
GLU_LIB_DEPS =
GLUT_LIB_DEPS =
GLW_LIB_DEPS =
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \
$(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm
APP_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lpthread -lstdc++ -lm

View File

@ -170,7 +170,7 @@ struct __DRIframeTrackingExtensionRec {
* Used by drivers that implement the GLX_SGI_video_sync extension.
*/
#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
#define __DRI_MEDIA_STREAM_COUNTER_VERSION 2
struct __DRImediaStreamCounterExtensionRec {
__DRIextension base;
@ -189,6 +189,18 @@ struct __DRImediaStreamCounterExtensionRec {
int (*waitForMSC)(__DRIdrawable *drawable,
int64_t target_msc, int64_t divisor, int64_t remainder,
int64_t * msc, int64_t * sbc);
/**
* Like the screen version of getMSC, but also takes a drawable so that
* the appropriate pipe's counter can be retrieved.
*
* Get the number of vertical refreshes since some point in time before
* this function was first called (i.e., system start up).
*
* \since Internal API version 2
*/
int (*getDrawableMSC)(__DRIscreen *screen, void *drawablePrivate,
int64_t *msc);
};

View File

@ -10,7 +10,9 @@ include $(TOP)/configs/current
#
# Modified by Philippe Houdoin
LDFLAGS += -soname=_APP_ $(APP_LIB_DEPS)
LDFLAGS += -soname=_APP_
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
INCLUDES = -I. -I- -I../../include
@ -21,13 +23,13 @@ clean:
rm -f *.o
demo: demo.o
$(LD) demo.o $(LDFLAGS) -o $@
$(LD) demo.o $(LDFLAGS) $(LIBS) -o $@
sample: sample.o
$(LD) sample.o $(LDFLAGS) -o $@
$(LD) sample.o $(LDFLAGS) $(LIBS) -o $@
GTLInfo: GLInfo.o
$(LD) GLInfo.o $(INCLUDES) $(LDFLAGS) -o $@
$(LD) GLInfo.o $(INCLUDES) $(LDFLAGS) $(LIBS) -o $@
.cpp.o:
$(CC) -c $< $(INCLUDES) $(CFLAGS) -o $@

View File

@ -4,6 +4,7 @@ arbfslight
arbocclude
bounce
clearspd
copypix
cubemap
drawpix
engine

View File

@ -13,6 +13,8 @@ OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(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)
PROGS = \
arbfplight \
arbfslight \
@ -75,7 +77,7 @@ PROGS = \
# make executable from .c file:
.c: $(LIB_DEP) readtex.o
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@
##### TARGETS #####
@ -119,35 +121,35 @@ extfuncs.h: $(TOP)/progs/util/extfuncs.h
reflect: reflect.o showbuffer.o readtex.o
$(CC) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) reflect.o showbuffer.o readtex.o $(LIBS) -o $@
reflect.o: reflect.c showbuffer.h
$(CC) -c -I$(INCDIR) $(CFLAGS) reflect.c
shadowtex: shadowtex.o showbuffer.o
$(CC) $(LDFLAGS) shadowtex.o showbuffer.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) shadowtex.o showbuffer.o $(LIBS) -o $@
shadowtex.o: shadowtex.c showbuffer.h
$(CC) -c -I$(INCDIR) $(CFLAGS) shadowtex.c
gloss: gloss.o trackball.o readtex.o
$(CC) $(LDFLAGS) gloss.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) gloss.o trackball.o readtex.o $(LIBS) -o $@
gloss.o: gloss.c trackball.h
$(CC) -c -I$(INCDIR) $(CFLAGS) gloss.c
engine: engine.o trackball.o readtex.o
$(CC) $(LDFLAGS) engine.o trackball.o readtex.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) engine.o trackball.o readtex.o $(LIBS) -o $@
engine.o: engine.c trackball.h
$(CC) -c -I$(INCDIR) $(CFLAGS) engine.c
fslight: fslight.o
$(CC) $(LDFLAGS) fslight.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) fslight.o $(LIBS) -o $@
fslight.o: fslight.c extfuncs.h
$(CC) -c -I$(INCDIR) $(CFLAGS) fslight.c
@ -155,7 +157,7 @@ fslight.o: fslight.c extfuncs.h
viewdds: viewdds.c
$(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(APP_LIB_DEPS) -L. -lgltc -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $< readtex.o $(LIBS) -L. -lgltc -o $@
clean:

View File

@ -84,6 +84,7 @@ static const char *FragProgNames[] = {
"program with \"OPTION ARB_fragment_program_shadow\"",
};
static GLboolean HaveShadow = GL_FALSE;
static GLboolean HaveFBO = GL_FALSE;
static GLboolean UseFBO = GL_FALSE;
static GLboolean HaveVP = GL_FALSE;
@ -529,7 +530,10 @@ ShowShadowMap(void)
DisableTexgen();
/* interpret texture's depth values as luminance values */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
if (HaveShadow) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
}
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
@ -596,7 +600,9 @@ Display(void)
}
if (DisplayMode == SHOW_DEPTH_MAPPING) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
if (HaveShadow) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_2D);
@ -614,8 +620,10 @@ Display(void)
}
else {
assert(DisplayMode == SHOW_SHADOWS);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
if (HaveShadow) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
}
if (curr_frag > 0) {
glEnable(GL_FRAGMENT_PROGRAM_ARB);
@ -723,6 +731,10 @@ Key(unsigned char key, int x, int y)
break;
case 'M':
curr_frag = (1 + curr_frag) % max_frag;
if (!HaveShadow && (curr_frag == 0)) {
curr_frag = 1;
}
printf("Using fragment %s\n", FragProgNames[curr_frag]);
if (HaveFP) {
@ -740,8 +752,10 @@ Key(unsigned char key, int x, int y)
if (Operator >= 8)
Operator = 0;
printf("Operator: %s\n", OperatorName[Operator]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB,
OperatorFunc[Operator]);
if (HaveShadow) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB,
OperatorFunc[Operator]);
}
}
break;
case 'p':
@ -858,17 +872,31 @@ Init(void)
{
static const GLfloat borderColor[4] = {1.0, 0.0, 0.0, 0.0};
if (!glutExtensionSupported("GL_ARB_depth_texture") ||
!glutExtensionSupported("GL_ARB_shadow")) {
printf("Sorry, this demo requires the GL_ARB_depth_texture and GL_ARB_shadow extensions\n");
if (!glutExtensionSupported("GL_ARB_depth_texture")) {
printf("Sorry, this demo requires the GL_ARB_depth_texture extension\n");
exit(1);
}
printf("Using GL_ARB_depth_texture and GL_ARB_shadow\n");
HaveShadow = glutExtensionSupported("GL_ARB_shadow");
HaveVP = glutExtensionSupported("GL_ARB_vertex_program");
HaveFP = glutExtensionSupported("GL_ARB_fragment_program");
HaveFP_Shadow = glutExtensionSupported("GL_ARB_fragment_program_shadow");
if (!HaveShadow && !HaveFP) {
printf("Sorry, this demo requires either the GL_ARB_shadow extension "
"or the GL_ARB_fragment_program extension\n");
exit(1);
}
printf("Using GL_ARB_depth_texture\n");
if (HaveShadow) {
printf("and GL_ARB_shadow\n");
}
if (HaveFP) {
printf("and GL_ARB_fragment_program\n");
}
HaveShadowAmbient = glutExtensionSupported("GL_ARB_shadow_ambient");
if (HaveShadowAmbient) {
printf("and GL_ARB_shadow_ambient\n");
@ -895,9 +923,12 @@ Init(void)
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
if (HaveShadow) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB,
GL_COMPARE_R_TO_TEXTURE_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
}
if (HaveShadowAmbient) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, 0.3);
@ -954,6 +985,11 @@ Init(void)
max_frag = 3;
}
if (!HaveShadow) {
curr_frag = 1;
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, frag_progs[curr_frag]);
}
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

View File

@ -1,13 +1,9 @@
/*
* GL_ARB_multitexture demo
* GL_ARB_pixel_buffer_object test
*
* Command line options:
* -info print GL implementation information
* -w WIDTH -h HEIGHT sets window size
*
*
* Brian Paul November 1998 This program is in the public domain.
* Modified on 12 Feb 2002 for > 2 texture units.
*/
#define GL_GLEXT_PROTOTYPES
@ -25,6 +21,8 @@
#define PBO 11
#define QUIT 100
static GLuint DrawPBO;
static GLboolean Animate = GL_TRUE;
static GLboolean use_pbo = 1;
static GLboolean whole_rect = 1;
@ -49,7 +47,7 @@ static void Idle( void )
}
}
static int max( int a, int b ) { return a > b ? a : b; }
/*static int max( int a, int b ) { return a > b ? a : b; }*/
static int min( int a, int b ) { return a < b ? a : b; }
static void DrawObject()
@ -62,6 +60,7 @@ static void DrawObject()
* release the old copy of the texture and allocate a new one
* without waiting for outstanding rendering to complete.
*/
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, size, NULL, GL_STREAM_DRAW_ARB);
{
@ -69,7 +68,7 @@ static void DrawObject()
printf("char %d\n", (unsigned char)(Drift * 255));
memset(image, size, (unsigned char)(Drift * 255));
memset(image, (unsigned char)(Drift * 255), size);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
}
@ -86,7 +85,9 @@ static void DrawObject()
if (image == NULL)
image = malloc(size);
memset(image, size, (unsigned char)(Drift * 255));
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
memset(image, (unsigned char)(Drift * 255), size);
/* BGRA should be the fast path for regular uploads as well.
*/
@ -227,12 +228,12 @@ static void SpecialKey( int key, int x, int y )
static void Init( int argc, char *argv[] )
{
const char *exten = (const char *) glGetString(GL_EXTENSIONS);
GLuint texObj, DrawPBO;
GLuint texObj;
GLint size;
if (!strstr(exten, "GL_ARB_multitexture")) {
printf("Sorry, GL_ARB_multitexture not supported by this renderer.\n");
if (!strstr(exten, "GL_ARB_pixel_buffer_object")) {
printf("Sorry, GL_ARB_pixel_buffer_object not supported by this renderer.\n");
exit(1);
}

View File

@ -11,6 +11,8 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME)
CFLAGS += $(shell pkg-config --cflags directfb)
APP_LIB_DEPS += $(shell pkg-config --libs directfb)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
PROGS = df_gears \
df_reflect \
df_morph3d \
@ -22,7 +24,7 @@ PROGS = df_gears \
.SUFFIXES: .c
.c: $(LIB_DEP)
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
##### TARGETS #####

View File

@ -15,6 +15,7 @@ INCLUDES = \
-I. \
-I$(TOP)/include
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
##### RULES #####
@ -22,7 +23,7 @@ INCLUDES = \
.SUFFIXES: .c
.c:
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@

View File

@ -8,7 +8,7 @@ TOP = ../..
include $(TOP)/configs/current
LIBS = $(APP_LIB_DEPS)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
SOURCES = \
tri-abs.c \

View File

@ -1,10 +1,13 @@
bitmap
brick
bump
deriv
extfuncs.h
mandelbrot
noise
points
readtex.c
readtex.h
texdemo1
trirast
toyball

View File

@ -49,14 +49,15 @@ void main()
inorout += dot(distance, vec4(1.0));
distance.x = dot(p, HalfSpace4);
distance.y = StripeWidth - abs(p.z);
// distance.y = StripeWidth - abs(p.z);
distance.y = StripeWidth - abs(p.y);
distance = smoothstep(-FWidth, FWidth, distance);
inorout += distance.x;
inorout = clamp(inorout, 0.0, 1.0);
surfColor = mix(Yellow, Red, inorout);
surfColor = mix(surfColor, Blue, distance.y);
surfColor = mix(Yellow, Blue, distance.y);
surfColor = mix(surfColor, Red, inorout);
// normal = point on surface for sphere at (0,0,0)
normal = p;

View File

@ -14,10 +14,11 @@ uniform vec4 BallCenter; // ball center in modelling coordinates
void main()
{
//orig: ECposition = gl_ModelViewMatrix * gl_Vertex;
ECposition = gl_ModelViewMatrix * gl_Vertex;
ECposition = gl_TextureMatrix[0] * gl_Vertex;
ECposition = gl_ModelViewMatrix * ECposition;
// ECposition = gl_TextureMatrix[0] * gl_Vertex;
// ECposition = gl_MultiTexCoord0 * gl_Vertex;
// ECposition = gl_ModelViewMatrix * ECposition;
ECballCenter = gl_ModelViewMatrix * BallCenter;
gl_Position = ftransform();

View File

@ -7,6 +7,8 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(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)
PROGS = \
bitmap \
brick \
@ -28,7 +30,7 @@ PROGS = \
# make executable from .c file:
.c: $(LIB_DEP)
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
##### TARGETS #####
@ -64,7 +66,7 @@ points.c: extfuncs.h
toyball.c: extfuncs.h
texdemo1: texdemo1.o readtex.o
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o $(LIBS) -o $@
texdemo1.o: texdemo1.c readtex.h extfuncs.h
$(CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c

View File

@ -20,6 +20,8 @@ INCLUDES = \
-I. \
-I$(TOP)/include
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
##### RULES #####
@ -27,7 +29,7 @@ INCLUDES = \
.SUFFIXES: .c
.c:
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
$(CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $< -o $@

View File

@ -13,6 +13,8 @@ OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -lglut -lOSMesa32 -lGLU -lGL $(APP_LIB_DEPS)
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(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)
PROGS = \
osdemo \
ostest1
@ -26,7 +28,7 @@ PROGS = \
# make executable from .c file:
.c: $(LIB_DEP) readtex.o
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@
##### TARGETS #####

View File

@ -7,6 +7,8 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(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)
PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \
bezcurve bezmesh checker clip colormat cube depthcue dof \
double drawf feedback fog fogindex font hello image light \
@ -24,7 +26,7 @@ PROGS = aaindex aapoly aargb accanti accpersp alpha alpha3D anti \
.SUFFIXES: .c
.c: $(LIB_DEP)
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@

View File

@ -7,6 +7,8 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(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)
PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
font line logo nurb olympic overlay point prim quad select \
shape sphere star stencil stretch texture tri wave
@ -18,7 +20,7 @@ PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \
.SUFFIXES: .c
.c: $(LIB_DEP)
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
##### TARGETS #####
@ -27,7 +29,7 @@ default: $(PROGS)
sphere: sphere.o readtex.o
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) sphere.o readtex.o $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) sphere.o readtex.o $(LIBS) -o $@
sphere.o: sphere.c readtex.h
$(CC) -c -I$(INCDIR) $(CFLAGS) sphere.c

View File

@ -8,6 +8,8 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
#
# targets
#
@ -29,13 +31,13 @@ clean:
#
cltest: cltest.o framework.o $(LIB_DEP)
$(CC) $(LDFLAGS) cltest.o framework.o $(APP_LIB_DEPS) -o cltest
$(CC) $(LDFLAGS) cltest.o framework.o $(LIBS) -o cltest
sotest: sotest.o framework.o $(LIB_DEP)
$(CC) $(LDFLAGS) sotest.o framework.o $(APP_LIB_DEPS) -o sotest
$(CC) $(LDFLAGS) sotest.o framework.o $(LIBS) -o sotest
vstest: vstest.o framework.o $(LIB_DEP)
$(CC) $(LDFLAGS) vstest.o framework.o $(APP_LIB_DEPS) -o vstest
$(CC) $(LDFLAGS) vstest.o framework.o $(LIBS) -o vstest
#
# objects

View File

@ -8,7 +8,7 @@ TOP = ../..
include $(TOP)/configs/current
LIBS = $(APP_LIB_DEPS)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
SOURCES = \
afsmultiarb.c \

View File

@ -8,7 +8,7 @@ TOP = ../..
include $(TOP)/configs/current
LIBS = $(APP_LIB_DEPS)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
SOURCES = \
clear.c \

View File

@ -8,7 +8,7 @@ TOP = ../..
include $(TOP)/configs/current
LIBS = $(APP_LIB_DEPS)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
SOURCES = \
vp-tris.c

View File

@ -1,3 +1,4 @@
corender
glthreads
glxcontexts
glxdemo
@ -7,6 +8,7 @@ glxheads
glxinfo
glxpbdemo
glxpixmap
glxsnoop
glxswapcontrol
manywin
offset

View File

@ -8,6 +8,8 @@ INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME)
LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS)
PROGS = \
corender \
glthreads \
@ -41,7 +43,7 @@ PROGS = \
.SUFFIXES: .c
.c: $(LIB_DEP)
$(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(APP_LIB_DEPS) -o $@
$(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
##### TARGETS #####
@ -56,10 +58,10 @@ clean:
# special cases
pbinfo: pbinfo.o pbutil.o
$(CC) $(LDFLAGS) pbinfo.o pbutil.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) pbinfo.o pbutil.o $(LIBS) -o $@
pbdemo: pbdemo.o pbutil.o
$(CC) $(LDFLAGS) pbdemo.o pbutil.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) pbdemo.o pbutil.o $(LIBS) -o $@
pbinfo.o: pbinfo.c pbutil.h
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbinfo.c
@ -71,13 +73,13 @@ pbutil.o: pbutil.c pbutil.h
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) pbutil.c
glxgears_fbconfig: glxgears_fbconfig.o pbutil.o
$(CC) $(LDFLAGS) glxgears_fbconfig.o pbutil.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) glxgears_fbconfig.o pbutil.o $(LIBS) -o $@
glxgears_fbconfig.o: glxgears_fbconfig.c pbutil.h
$(CC) -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) -c -I. $(CFLAGS) glxgears_fbconfig.c
xrotfontdemo: xrotfontdemo.o xuserotfont.o
$(CC) $(LDFLAGS) xrotfontdemo.o xuserotfont.o $(APP_LIB_DEPS) -o $@
$(CC) $(LDFLAGS) xrotfontdemo.o xuserotfont.o $(LIBS) -o $@
xuserotfont.o: xuserotfont.c xuserotfont.h
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xuserotfont.c
@ -86,10 +88,10 @@ xrotfontdemo.o: xrotfontdemo.c xuserotfont.h
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) xrotfontdemo.c
corender: corender.o ipc.o
$(CC) $(CFLAGS) corender.o ipc.o $(APP_LIB_DEPS) -o $@
$(CC) $(CFLAGS) corender.o ipc.o $(LIBS) -o $@
corender.o: corender.c ipc.h
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) corender.c
ipc.o: ipc.c ipc.h
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) ipc.c
$(CC) -c -I. -I$(INCDIR) $(X11_INCLUDES) $(CFLAGS) ipc.c

View File

@ -52,6 +52,13 @@
#define GLX_TRANSPARENT_RGB 0x8008
#endif
#ifndef GLX_RGBA_BIT
#define GLX_RGBA_BIT 0x00000001
#endif
#ifndef GLX_COLOR_INDEX_BIT
#define GLX_COLOR_INDEX_BIT 0x00000002
#endif
typedef enum
{
@ -81,7 +88,7 @@ struct visual_attribs
int transparentIndexValue;
int bufferSize;
int level;
int rgba;
int render_type;
int doubleBuffer;
int stereo;
int auxBuffers;
@ -388,20 +395,61 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
XSetWindowAttributes attr;
unsigned long mask;
Window root;
GLXContext ctx;
GLXContext ctx = NULL;
XVisualInfo *visinfo;
int width = 100, height = 100;
root = RootWindow(dpy, scrnum);
visinfo = glXChooseVisual(dpy, scrnum, attribSingle);
if (!visinfo) {
if (!visinfo)
visinfo = glXChooseVisual(dpy, scrnum, attribDouble);
if (!visinfo) {
fprintf(stderr, "Error: couldn't find RGB GLX visual\n");
return;
if (visinfo)
ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
#ifdef GLX_VERSION_1_3
{
int fbAttribSingle[] = {
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_DOUBLEBUFFER, GL_TRUE,
None };
int fbAttribDouble[] = {
GLX_RENDER_TYPE, GLX_RGBA_BIT,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
None };
GLXFBConfig *configs = NULL;
int nConfigs;
if (!visinfo)
configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs);
if (!visinfo)
configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs);
if (configs) {
visinfo = glXGetVisualFromFBConfig(dpy, configs[0]);
ctx = glXCreateNewContext(dpy, configs[0], GLX_RGBA_TYPE, NULL, allowDirect);
XFree(configs);
}
}
#endif
if (!visinfo) {
fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n");
return;
}
if (!ctx) {
fprintf(stderr, "Error: glXCreateContext failed\n");
XFree(visinfo);
XDestroyWindow(dpy, win);
return;
}
attr.background_pixel = 0;
attr.border_pixel = 0;
@ -412,14 +460,6 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
0, visinfo->depth, InputOutput,
visinfo->visual, mask, &attr);
ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect );
if (!ctx) {
fprintf(stderr, "Error: glXCreateContext failed\n");
XFree(visinfo);
XDestroyWindow(dpy, win);
return;
}
if (glXMakeCurrent(dpy, win, ctx)) {
const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR);
const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION);
@ -541,12 +581,27 @@ visual_class_abbrev(int cls)
}
}
static const char *
visual_render_type_name(int type)
{
switch (type) {
case GLX_RGBA_BIT:
return "rgba";
case GLX_COLOR_INDEX_BIT:
return "ci";
case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT:
return "rgba|ci";
default:
return "";
}
}
static void
static GLboolean
get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
struct visual_attribs *attribs)
{
const char *ext = glXQueryExtensionsString(dpy, vInfo->screen);
int rgba;
memset(attribs, 0, sizeof(struct visual_attribs));
@ -563,11 +618,17 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
attribs->colormapSize = vInfo->colormap_size;
attribs->bitsPerRGB = vInfo->bits_per_rgb;
if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0)
return;
if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 ||
!attribs->supportsGL)
return GL_FALSE;
glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize);
glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level);
glXGetConfig(dpy, vInfo, GLX_RGBA, &attribs->rgba);
glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba);
if (rgba)
attribs->render_type = GLX_RGBA_BIT;
else
attribs->render_type = GLX_COLOR_INDEX_BIT;
glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo);
glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers);
@ -616,8 +677,97 @@ get_visual_attribs(Display *dpy, XVisualInfo *vInfo,
#else
attribs->visualCaveat = 0;
#endif
return GL_TRUE;
}
#ifdef GLX_VERSION_1_3
static int
glx_token_to_visual_class(int visual_type)
{
switch (visual_type) {
case GLX_TRUE_COLOR:
return TrueColor;
case GLX_DIRECT_COLOR:
return DirectColor;
case GLX_PSEUDO_COLOR:
return PseudoColor;
case GLX_STATIC_COLOR:
return StaticColor;
case GLX_GRAY_SCALE:
return GrayScale;
case GLX_STATIC_GRAY:
return StaticGray;
case GLX_NONE:
default:
return None;
}
}
static GLboolean
get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig,
struct visual_attribs *attribs)
{
int visual_type;
memset(attribs, 0, sizeof(struct visual_attribs));
glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id);
#if 0
attribs->depth = vInfo->depth;
attribs->redMask = vInfo->red_mask;
attribs->greenMask = vInfo->green_mask;
attribs->blueMask = vInfo->blue_mask;
attribs->colormapSize = vInfo->colormap_size;
attribs->bitsPerRGB = vInfo->bits_per_rgb;
#endif
glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type);
attribs->klass = glx_token_to_visual_class(visual_type);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize);
/* get transparent pixel stuff */
glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType);
if (attribs->transparentType == GLX_TRANSPARENT_RGB) {
glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue);
}
else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) {
glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue);
}
glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples);
glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat);
return GL_TRUE;
}
#endif
static void
print_visual_attribs_verbose(const struct visual_attribs *attribs)
@ -625,7 +775,8 @@ print_visual_attribs_verbose(const struct visual_attribs *attribs)
printf("Visual ID: %x depth=%d class=%s\n",
attribs->id, attribs->depth, visual_class_name(attribs->klass));
printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
attribs->bufferSize, attribs->level, attribs->rgba ? "rgba" : "ci",
attribs->bufferSize, attribs->level,
visual_render_type_name(attribs->render_type),
attribs->doubleBuffer, attribs->stereo);
printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n",
attribs->redSize, attribs->greenSize,
@ -683,16 +834,17 @@ print_visual_attribs_short(const struct visual_attribs *attribs)
caveat = "None";
#endif
printf("0x%2x %2d %2s %2d %2d %2d %1s %2s %2s %2d %2d %2d %2d %2d %2d %2d",
printf("0x%02x %2d %2s %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d",
attribs->id,
attribs->depth,
visual_class_abbrev(attribs->klass),
attribs->transparentType != GLX_NONE,
attribs->bufferSize,
attribs->level,
attribs->rgba ? "r" : "c",
attribs->doubleBuffer ? "y" : ".",
attribs->stereo ? "y" : ".",
(attribs->render_type & GLX_RGBA_BIT) ? 'r' : ' ',
(attribs->render_type & GLX_COLOR_INDEX_BIT) ? 'c' : ' ',
attribs->doubleBuffer ? 'y' : '.',
attribs->stereo ? 'y' : '.',
attribs->redSize, attribs->greenSize,
attribs->blueSize, attribs->alphaSize,
attribs->auxBuffers,
@ -728,7 +880,7 @@ print_visual_attribs_long(const struct visual_attribs *attribs)
attribs->transparentType != GLX_NONE,
attribs->bufferSize,
attribs->level,
attribs->rgba ? "rgba" : "ci ",
visual_render_type_name(attribs->render_type),
attribs->doubleBuffer,
attribs->stereo,
attribs->redSize, attribs->greenSize,
@ -751,42 +903,86 @@ print_visual_info(Display *dpy, int scrnum, InfoMode mode)
{
XVisualInfo theTemplate;
XVisualInfo *visuals;
int numVisuals;
int numVisuals, numGlxVisuals;
long mask;
int i;
struct visual_attribs attribs;
/* get list of all visuals on this screen */
theTemplate.screen = scrnum;
mask = VisualScreenMask;
visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals);
if (mode == Verbose) {
for (i = 0; i < numVisuals; i++) {
struct visual_attribs attribs;
get_visual_attribs(dpy, &visuals[i], &attribs);
print_visual_attribs_verbose(&attribs);
}
numGlxVisuals = 0;
for (i = 0; i < numVisuals; i++) {
if (get_visual_attribs(dpy, &visuals[i], &attribs))
numGlxVisuals++;
}
else if (mode == Normal) {
if (numGlxVisuals == 0)
return;
printf("%d GLX Visuals\n", numGlxVisuals);
if (mode == Normal)
print_visual_attribs_short_header();
for (i = 0; i < numVisuals; i++) {
struct visual_attribs attribs;
get_visual_attribs(dpy, &visuals[i], &attribs);
print_visual_attribs_short(&attribs);
}
}
else if (mode == Wide) {
else if (mode == Wide)
print_visual_attribs_long_header();
for (i = 0; i < numVisuals; i++) {
struct visual_attribs attribs;
get_visual_attribs(dpy, &visuals[i], &attribs);
for (i = 0; i < numVisuals; i++) {
if (!get_visual_attribs(dpy, &visuals[i], &attribs))
continue;
if (mode == Verbose)
print_visual_attribs_verbose(&attribs);
else if (mode == Normal)
print_visual_attribs_short(&attribs);
else if (mode == Wide)
print_visual_attribs_long(&attribs);
}
}
printf("\n");
XFree(visuals);
}
#ifdef GLX_VERSION_1_3
static void
print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode)
{
int numFBConfigs;
struct visual_attribs attribs;
GLXFBConfig *fbconfigs;
int i;
/* get list of all fbconfigs on this screen */
fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs);
if (numFBConfigs == 0)
return;
printf("%d GLXFBConfigs:\n", numFBConfigs);
if (mode == Normal)
print_visual_attribs_short_header();
else if (mode == Wide)
print_visual_attribs_long_header();
for (i = 0; i < numFBConfigs; i++) {
get_fbconfig_attribs(dpy, fbconfigs[i], &attribs);
if (mode == Verbose)
print_visual_attribs_verbose(&attribs);
else if (mode == Normal)
print_visual_attribs_short(&attribs);
else if (mode == Wide)
print_visual_attribs_long(&attribs);
}
printf("\n");
XFree(fbconfigs);
}
#endif
/*
* Stand-alone Mesa doesn't really implement the GLX protocol so it
@ -860,7 +1056,7 @@ find_best_visual(Display *dpy, int scrnum)
/* see if this vis is better than bestVis */
if ((!bestVis.supportsGL && vis.supportsGL) ||
(bestVis.visualCaveat != GLX_NONE_EXT) ||
(!bestVis.rgba && vis.rgba) ||
(!(bestVis.render_type & GLX_RGBA_BIT) && (vis.render_type & GLX_RGBA_BIT)) ||
(!bestVis.doubleBuffer && vis.doubleBuffer) ||
(bestVis.redSize < vis.redSize) ||
(bestVis.greenSize < vis.greenSize) ||
@ -957,6 +1153,9 @@ main(int argc, char *argv[])
print_screen_info(dpy, scrnum, allowDirect, limits);
printf("\n");
print_visual_info(dpy, scrnum, mode);
#ifdef GLX_VERSION_1_3
print_fbconfig_info(dpy, scrnum, mode);
#endif
if (scrnum + 1 < numScreens)
printf("\n\n");
}

View File

@ -18,12 +18,12 @@
* Test if we pixel buffers are available for a particular X screen.
* Input: dpy - the X display
* screen - screen number
* Return: 0 = pixel buffers not available.
* 1 = pixel buffers are available via GLX 1.3.
* 2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer.
* Return: 0 = fbconfigs not available.
* 1 = fbconfigs are available via GLX 1.3.
* 2 = fbconfigs and pbuffers are available via GLX_SGIX_fbconfig
*/
int
QueryPbuffers(Display *dpy, int screen)
QueryFBConfig(Display *dpy, int screen)
{
#if defined(GLX_VERSION_1_3)
{
@ -40,36 +40,55 @@ QueryPbuffers(Display *dpy, int screen)
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
/* Try the SGIX extensions */
{
char *extensions;
extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
if (!extensions ||
!strstr(extensions,"GLX_SGIX_fbconfig") ||
!strstr(extensions,"GLX_SGIX_pbuffer")) {
return 0;
if (extensions && strstr(extensions,"GLX_SGIX_fbconfig")) {
return 2;
}
return 2;
}
#endif
return 0;
}
/**
* Test if we pixel buffers are available for a particular X screen.
* Input: dpy - the X display
* screen - screen number
* Return: 0 = pixel buffers not available.
* 1 = pixel buffers are available via GLX 1.3.
* 2 = pixel buffers are available via GLX_SGIX_fbconfig/pbuffer.
*/
int
QueryPbuffers(Display *dpy, int screen)
{
int ret;
ret = QueryFBConfig(dpy, screen);
if (ret == 2) {
char *extensions;
extensions = (char *) glXQueryServerString(dpy, screen, GLX_EXTENSIONS);
if (extensions && strstr(extensions, "GLX_SGIX_pbuffer"))
return 2;
else
return 0;
}
else
return ret;
}
FBCONFIG *
ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs)
{
int pbSupport = QueryPbuffers(dpy, screen);
int fbcSupport = QueryPbuffers(dpy, screen);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
if (fbcSupport == 1) {
return glXChooseFBConfig(dpy, screen, attribs, nConfigs);
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
if (fbcSupport == 2) {
return glXChooseFBConfigSGIX(dpy, screen, (int *) attribs, nConfigs);
}
#endif
@ -80,14 +99,14 @@ ChooseFBConfig(Display *dpy, int screen, const int attribs[], int *nConfigs)
FBCONFIG *
GetAllFBConfigs(Display *dpy, int screen, int *nConfigs)
{
int pbSupport = QueryPbuffers(dpy, screen);
int fbcSupport = QueryFBConfig(dpy, screen);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
if (fbcSupport == 1) {
return glXGetFBConfigs(dpy, screen, nConfigs);
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
if (fbcSupport == 2) {
/* The GLX_SGIX_fbconfig extensions says to pass NULL to get list
* of all available configurations.
*/
@ -101,14 +120,14 @@ GetAllFBConfigs(Display *dpy, int screen, int *nConfigs)
XVisualInfo *
GetVisualFromFBConfig(Display *dpy, int screen, FBCONFIG config)
{
int pbSupport = QueryPbuffers(dpy, screen);
int fbcSupport = QueryFBConfig(dpy, screen);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
if (fbcSupport == 1) {
return glXGetVisualFromFBConfig(dpy, config);
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
if (fbcSupport == 2) {
return glXGetVisualFromFBConfigSGIX(dpy, config);
}
#endif
@ -130,11 +149,11 @@ GetFBConfigAttrib(Display *dpy, int screen,
int attrib
)
{
int pbSupport = QueryPbuffers(dpy, screen);
int fbcSupport = QueryFBConfig(dpy, screen);
int value = 0;
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
if (fbcSupport == 1) {
/* ok */
if (glXGetFBConfigAttrib(dpy, config, attrib, &value) != 0) {
value = 0;
@ -145,7 +164,7 @@ GetFBConfigAttrib(Display *dpy, int screen,
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
if (fbcSupport == 2) {
if (glXGetFBConfigAttribSGIX(dpy, config, attrib, &value) != 0) {
value = 0;
}
@ -295,9 +314,9 @@ PrintFBConfigInfo(Display *dpy, int screen, FBCONFIG config, Bool horizFormat)
GLXContext
CreateContext(Display *dpy, int screen, FBCONFIG config)
{
int pbSupport = QueryPbuffers(dpy, screen);
int fbcSupport = QueryFBConfig(dpy, screen);
#if defined(GLX_VERSION_1_3)
if (pbSupport == 1) {
if (fbcSupport == 1) {
/* GLX 1.3 */
GLXContext c;
c = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, True);
@ -309,7 +328,7 @@ CreateContext(Display *dpy, int screen, FBCONFIG config)
}
#endif
#if defined(GLX_SGIX_fbconfig) && defined(GLX_SGIX_pbuffer)
if (pbSupport == 2) {
if (fbcSupport == 2) {
GLXContext c;
c = glXCreateContextWithConfigSGIX(dpy, config, GLX_RGBA_TYPE_SGIX, NULL, True);
if (!c) {

View File

@ -26,6 +26,9 @@
#endif
extern int
QueryFBConfig(Display *dpy, int screen);
extern int
QueryPbuffers(Display *dpy, int screen);

View File

@ -500,9 +500,9 @@ struct __GLXscreenConfigsRec {
#endif
/**
* Linked list of configurations for this screen.
* Linked list of glx visuals and fbconfigs for this screen.
*/
__GLcontextModes *configs;
__GLcontextModes *visuals, *configs;
/**
* Per-screen dynamic GLX extension tracking. The \c direct_support

View File

@ -106,6 +106,7 @@ static void GarbageCollectDRIDrawables(Display *dpy, __GLXscreenConfigs *sc)
} while (__glxHashNext(sc->drawHash, &draw, (void *)&pdraw) == 1);
}
XSync(dpy, GL_FALSE);
XSetErrorHandler(oldXErrorHandler);
}
@ -903,12 +904,12 @@ PUBLIC int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute,
{
__GLXdisplayPrivate *priv;
__GLXscreenConfigs *psc;
__GLcontextModes *modes;
int status;
status = GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc );
if ( status == Success ) {
const __GLcontextModes * const modes = _gl_context_modes_find_visual(
psc->configs, vis->visualid );
modes = _gl_context_modes_find_visual(psc->visuals, vis->visualid);
/* Lookup attribute after first finding a match on the visual */
if ( modes != NULL ) {
@ -1286,7 +1287,7 @@ PUBLIC XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList)
** Compute a score for those that do
** Remember which visual, if any, got the highest score
*/
for ( modes = psc->configs ; modes != NULL ; modes = modes->next ) {
for ( modes = psc->visuals ; modes != NULL ; modes = modes->next ) {
if ( fbconfigs_compatible( & test_config, modes )
&& ((best_config == NULL)
|| (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) {
@ -1654,6 +1655,7 @@ PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
__GLcontextModes ** config = NULL;
int i;
*nelements = 0;
if ( (priv->screenConfigs != NULL)
&& (screen >= 0) && (screen <= ScreenCount(dpy))
&& (priv->screenConfigs[screen].configs != NULL)
@ -1940,13 +1942,24 @@ static int __glXGetVideoSyncSGI(unsigned int *count)
if ( (gc != NULL) && gc->isDirect ) {
__GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
gc->screen );
if (psc->msc != NULL && psc->driScreen.private != NULL) {
int ret;
int64_t temp;
ret = psc->msc->getMSC(&psc->driScreen, &temp);
*count = (unsigned) temp;
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
if ( psc->msc && psc->driScreen.private ) {
__DRIdrawable * const pdraw =
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
int64_t temp;
int ret;
/*
* Try to use getDrawableMSC first so we get the right
* counter...
*/
if (psc->msc->base.version >= 2 && psc->msc->getDrawableMSC)
ret = (*psc->msc->getDrawableMSC)( &psc->driScreen,
pdraw->private,
& temp);
else
ret = (*psc->msc->getMSC)( &psc->driScreen, & temp);
*count = (unsigned) temp;
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
}
}
#else
@ -1969,16 +1982,14 @@ static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count
if (psc->msc != NULL && psc->driScreen.private ) {
__DRIdrawable * const pdraw =
GetDRIDrawable(gc->currentDpy, gc->currentDrawable, NULL);
if (pdraw != NULL) {
int ret;
int64_t msc;
int64_t sbc;
int ret;
int64_t msc;
int64_t sbc;
ret = (*psc->msc->waitForMSC)(pdraw, 0,
divisor, remainder, &msc, &sbc);
*count = (unsigned) msc;
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
}
ret = (*psc->msc->waitForMSC)(pdraw, 0, divisor, remainder, &msc,
&sbc);
*count = (unsigned) msc;
return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
}
}
#else

View File

@ -362,7 +362,8 @@ static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
if (psc->driScreen.private)
(*psc->driScreen.destroyScreen)(&psc->driScreen);
psc->driScreen.private = NULL;
__glxHashDestroy(psc->drawHash);
if (psc->drawHash)
__glxHashDestroy(psc->drawHash);
#endif
}
XFree((char*) priv->screenConfigs);
@ -999,6 +1000,128 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
#endif /* GLX_DIRECT_RENDERING */
static __GLcontextModes *
createConfigsFromProperties(Display *dpy, int nvisuals, int nprops,
int screen, GLboolean tagged_only)
{
INT32 buf[__GLX_TOTAL_CONFIG], *props;
unsigned prop_size;
__GLcontextModes *modes, *m;
int i;
if (nprops == 0)
return NULL;
/* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */
/* Check number of properties */
if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
return NULL;
/* Allocate memory for our config structure */
modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
if (!modes)
return NULL;
prop_size = nprops * __GLX_SIZE_INT32;
if (prop_size <= sizeof(buf))
props = buf;
else
props = Xmalloc(prop_size);
/* Read each config structure and convert it into our format */
m = modes;
for (i = 0; i < nvisuals; i++) {
_XRead(dpy, (char *)props, prop_size);
/* Older X servers don't send this so we default it here. */
m->drawableType = GLX_WINDOW_BIT;
__glXInitializeVisualConfigFromTags(m, nprops, props,
tagged_only, GL_TRUE);
m->screen = screen;
m = m->next;
}
if (props != buf)
Xfree(props);
return modes;
}
static GLboolean
getVisualConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
{
xGLXGetVisualConfigsReq *req;
__GLXscreenConfigs *psc;
xGLXGetVisualConfigsReply reply;
LockDisplay(dpy);
psc = priv->screenConfigs + screen;
psc->visuals = NULL;
GetReq(GLXGetVisualConfigs, req);
req->reqType = priv->majorOpcode;
req->glxCode = X_GLXGetVisualConfigs;
req->screen = screen;
if (!_XReply(dpy, (xReply*) &reply, 0, False))
goto out;
psc->visuals = createConfigsFromProperties(dpy,
reply.numVisuals,
reply.numProps,
screen, GL_FALSE);
out:
UnlockDisplay(dpy);
return psc->visuals != NULL;
}
static GLboolean
getFBConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
{
xGLXGetFBConfigsReq *fb_req;
xGLXGetFBConfigsSGIXReq *sgi_req;
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXGetFBConfigsReply reply;
__GLXscreenConfigs *psc;
psc = priv->screenConfigs + screen;
psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
X_GLXQueryServerString,
screen, GLX_EXTENSIONS);
LockDisplay(dpy);
psc->configs = NULL;
if (atof(priv->serverGLXversion) >= 1.3) {
GetReq(GLXGetFBConfigs, fb_req);
fb_req->reqType = priv->majorOpcode;
fb_req->glxCode = X_GLXGetFBConfigs;
fb_req->screen = screen;
} else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXGetFBConfigsSGIXReq +
sz_xGLXVendorPrivateWithReplyReq, vpreq);
sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
sgi_req->reqType = priv->majorOpcode;
sgi_req->glxCode = X_GLXVendorPrivateWithReply;
sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
sgi_req->screen = screen;
} else
goto out;
if (!_XReply(dpy, (xReply*) &reply, 0, False))
goto out;
psc->configs = createConfigsFromProperties(dpy,
reply.numFBConfigs,
reply.numAttribs * 2,
screen, GL_TRUE);
out:
UnlockDisplay(dpy);
return psc->configs != NULL;
}
/*
** Allocate the memory for the per screen configs for each screen.
@ -1006,17 +1129,8 @@ CallCreateNewScreen(Display *dpy, int scrn, __GLXscreenConfigs *psc,
*/
static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
{
xGLXGetVisualConfigsReq *req;
xGLXGetFBConfigsReq *fb_req;
xGLXVendorPrivateWithReplyReq *vpreq;
xGLXGetFBConfigsSGIXReq *sgi_req;
xGLXGetVisualConfigsReply reply;
__GLXscreenConfigs *psc;
__GLcontextModes *config;
GLint i, j, nprops, screens;
INT32 buf[__GLX_TOTAL_CONFIG], *props;
unsigned supported_request = 0;
unsigned prop_size;
GLint i, screens;
/*
** First allocate memory for the array of per screen configs.
@ -1030,141 +1144,16 @@ static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
priv->screenConfigs = psc;
priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
X_GLXQueryServerString,
0, GLX_VERSION);
X_GLXQueryServerString,
0, GLX_VERSION);
if ( priv->serverGLXversion == NULL ) {
FreeScreenConfigs(priv);
return GL_FALSE;
}
if ( atof( priv->serverGLXversion ) >= 1.3 ) {
supported_request = 1;
}
/*
** Now fetch each screens configs structures. If a screen supports
** GL (by returning a numVisuals > 0) then allocate memory for our
** config structure and then fill it in.
*/
for (i = 0; i < screens; i++, psc++) {
if ( supported_request != 1 ) {
psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
X_GLXQueryServerString,
i, GLX_EXTENSIONS);
if ( strstr( psc->serverGLXexts, "GLX_SGIX_fbconfig" ) != NULL ) {
supported_request = 2;
}
else {
supported_request = 3;
}
}
LockDisplay(dpy);
switch( supported_request ) {
case 1:
GetReq(GLXGetFBConfigs,fb_req);
fb_req->reqType = priv->majorOpcode;
fb_req->glxCode = X_GLXGetFBConfigs;
fb_req->screen = i;
break;
case 2:
GetReqExtra(GLXVendorPrivateWithReply,
sz_xGLXGetFBConfigsSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
sgi_req->reqType = priv->majorOpcode;
sgi_req->glxCode = X_GLXVendorPrivateWithReply;
sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
sgi_req->screen = i;
break;
case 3:
GetReq(GLXGetVisualConfigs,req);
req->reqType = priv->majorOpcode;
req->glxCode = X_GLXGetVisualConfigs;
req->screen = i;
break;
}
if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
/* Something is busted. Punt. */
UnlockDisplay(dpy);
SyncHandle();
FreeScreenConfigs(priv);
return GL_FALSE;
}
if (!reply.numVisuals) {
/* This screen does not support GL rendering */
UnlockDisplay(dpy);
continue;
}
/* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for
* FIXME: FBconfigs?
*/
/* Check number of properties */
nprops = reply.numProps;
if ((nprops < __GLX_MIN_CONFIG_PROPS) ||
(nprops > __GLX_MAX_CONFIG_PROPS)) {
/* Huh? Not in protocol defined limits. Punt */
UnlockDisplay(dpy);
SyncHandle();
FreeScreenConfigs(priv);
return GL_FALSE;
}
/* Allocate memory for our config structure */
psc->configs = _gl_context_modes_create(reply.numVisuals,
sizeof(__GLcontextModes));
if (!psc->configs) {
UnlockDisplay(dpy);
SyncHandle();
FreeScreenConfigs(priv);
return GL_FALSE;
}
/* Allocate memory for the properties, if needed */
if ( supported_request != 3 ) {
nprops *= 2;
}
prop_size = nprops * __GLX_SIZE_INT32;
if (prop_size <= sizeof(buf)) {
props = buf;
} else {
props = (INT32 *) Xmalloc(prop_size);
}
/* Read each config structure and convert it into our format */
config = psc->configs;
for (j = 0; j < reply.numVisuals; j++) {
assert( config != NULL );
_XRead(dpy, (char *)props, prop_size);
if ( supported_request != 3 ) {
config->rgbMode = GL_TRUE;
config->drawableType = GLX_WINDOW_BIT;
}
else {
config->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
}
__glXInitializeVisualConfigFromTags( config, nprops, props,
(supported_request != 3),
GL_TRUE );
if ( config->fbconfigID == GLX_DONT_CARE ) {
config->fbconfigID = config->visualID;
}
config->screen = i;
config = config->next;
}
if (props != buf) {
Xfree((char *)props);
}
UnlockDisplay(dpy);
getVisualConfigs(dpy, priv, i);
getFBConfigs(dpy, priv, i);
#ifdef GLX_DIRECT_RENDERING
psc->scr = i;

View File

@ -153,8 +153,13 @@ depend: $(ALL_SOURCES)
subdirs:
@ (cd x86 ; $(MAKE))
@ (cd x86-64 ; $(MAKE))
@ if echo "$(ASM_FLAGS)" | grep -q USE_X86_ASM ; then \
(cd x86 ; $(MAKE)) ; \
fi
@ if echo "$(ASM_FLAGS)" | grep -q USE_X86_64_ASM ; then \
(cd x86 ; $(MAKE)) ; \
(cd x86-64 ; $(MAKE)) ; \
fi
install: default gl.pc

View File

@ -356,10 +356,18 @@ static void driSwapBuffers(__DRIdrawable *drawable)
&rect, 1, GL_TRUE);
}
static int driDrawableGetMSC( __DRIscreen *screen, void *drawablePrivate,
int64_t *msc )
{
__DRIscreenPrivate *sPriv = screen->private;
return sPriv->DriverAPI.GetDrawableMSC( sPriv, drawablePrivate, msc );
}
/**
* Called directly from a number of higher-level GLX functions.
*/
static int driGetMSC( __DRIscreen *screen, int64_t *msc )
static int driGetMSC( __DRIscreen *screen, void *drawablePrivate, int64_t *msc )
{
__DRIscreenPrivate *sPriv = screen->private;
@ -396,6 +404,7 @@ const __DRImediaStreamCounterExtension driMediaStreamCounterExtension = {
{ __DRI_MEDIA_STREAM_COUNTER, __DRI_MEDIA_STREAM_COUNTER_VERSION },
driGetMSC,
driWaitForMSC,
driDrawableGetMSC,
};
static void driCopySubBuffer(__DRIdrawable *drawable,
@ -471,6 +480,8 @@ static void *driCreateNewDrawable(__DRIscreen *screen,
pdp->numBackClipRects = 0;
pdp->pClipRects = NULL;
pdp->pBackClipRects = NULL;
pdp->vblSeq = 0;
pdp->vblFlags = 0;
psp = (__DRIscreenPrivate *)screen->private;
pdp->driScreenPriv = psp;
@ -485,6 +496,7 @@ static void *driCreateNewDrawable(__DRIscreen *screen,
pdraw->private = pdp;
pdraw->destroyDrawable = driDestroyDrawable;
pdraw->swapBuffers = driSwapBuffers; /* called by glXSwapBuffers() */
pdp->msc_base = 0;
/* This special default value is replaced with the configured
* default value when the drawable is first bound to a direct

View File

@ -206,6 +206,14 @@ struct __DriverAPIRec {
*/
void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch);
/**
* New version of GetMSC so we can pass drawable data to the low level
* DRM driver (e.g. pipe info).
*/
int (*GetDrawableMSC) ( __DRIscreenPrivate * priv,
__DRIdrawablePrivate *drawablePrivate,
int64_t *count);
};
@ -317,6 +325,32 @@ struct __DRIdrawablePrivateRec {
drm_clip_rect_t *pBackClipRects;
/*@}*/
/**
* \name Vertical blank tracking information
* Used for waiting on vertical blank events.
*/
/*@{*/
unsigned int vblSeq;
unsigned int vblFlags;
/*@}*/
/**
* \name Monotonic MSC tracking
*
* Low level driver is responsible for updating msc_base and
* vblSeq values so that higher level code can calculate
* a new msc value or msc target for a WaitMSC call. The new value
* will be:
* msc = msc_base + get_vblank_count() - vblank_base;
*
* And for waiting on a value, core code will use:
* actual_target = target_msc - msc_base + vblank_base;
*/
/*@{*/
int64_t vblank_base;
int64_t msc_base;
/*@}*/
/**
* Pointer to context to which this drawable is currently bound.
*/

View File

@ -35,8 +35,62 @@
#include "vblank.h"
#include "xmlpool.h"
static unsigned int msc_to_vblank(__DRIdrawablePrivate * dPriv, int64_t msc)
{
return (unsigned int)(msc - dPriv->msc_base + dPriv->vblank_base);
}
static int64_t vblank_to_msc(__DRIdrawablePrivate * dPriv, unsigned int vblank)
{
return (int64_t)(vblank - dPriv->vblank_base + dPriv->msc_base);
}
/****************************************************************************/
/**
* Get the current MSC refresh counter.
*
* Stores the 64-bit count of vertical refreshes since some (arbitrary)
* point in time in \c count. Unless the value wraps around, which it
* may, it will never decrease for a given drawable.
*
* \warning This function is called from \c glXGetVideoSyncSGI, which expects
* a \c count of type \c unsigned (32-bit), and \c glXGetSyncValuesOML, which
* expects a \c count of type \c int64_t (signed 64-bit). The kernel ioctl
* currently always returns a \c sequence of type \c unsigned.
*
* \param priv Pointer to the DRI screen private struct.
* \param dPriv Pointer to the DRI drawable private struct
* \param count Storage to hold MSC counter.
* \return Zero is returned on success. A negative errno value
* is returned on failure.
*/
int driDrawableGetMSC32( __DRIscreenPrivate * priv,
__DRIdrawablePrivate * dPriv,
int64_t * count)
{
drmVBlank vbl;
int ret;
/* Don't wait for anything. Just get the current refresh count. */
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 0;
if ( dPriv && dPriv->vblFlags & VBLANK_FLAG_SECONDARY )
vbl.request.type |= DRM_VBLANK_SECONDARY;
ret = drmWaitVBlank( priv->fd, &vbl );
if (dPriv) {
*count = vblank_to_msc(dPriv, vbl.reply.sequence);
} else {
/* Old driver (no knowledge of drawable MSC callback) */
*count = vbl.reply.sequence;
}
return ret;
}
/**
* Get the current MSC refresh counter.
*
@ -49,6 +103,10 @@
* expects a \c count of type \c int64_t (signed 64-bit). The kernel ioctl
* currently always returns a \c sequence of type \c unsigned.
*
* Since this function doesn't take a drawable, it may end up getting the MSC
* value from a pipe not associated with the caller's context, resuling in
* undesired behavior.
*
* \param priv Pointer to the DRI screen private struct.
* \param count Storage to hold MSC counter.
* \return Zero is returned on success. A negative errno value
@ -56,21 +114,9 @@
*/
int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count )
{
drmVBlank vbl;
int ret;
/* Don't wait for anything. Just get the current refresh count. */
vbl.request.type = DRM_VBLANK_RELATIVE;
vbl.request.sequence = 0;
ret = drmWaitVBlank( priv->fd, &vbl );
*count = (int64_t)vbl.reply.sequence;
return ret;
return driDrawableGetMSC32(priv, NULL, count);
}
/****************************************************************************/
/**
* Wait for a specified refresh count. This implements most of the
@ -123,7 +169,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
*/
vbl.request.type = dont_wait ? DRM_VBLANK_RELATIVE :
DRM_VBLANK_ABSOLUTE;
vbl.request.sequence = next;
vbl.request.sequence = next ? msc_to_vblank(priv, next) : 0;
if ( priv->vblFlags & VBLANK_FLAG_SECONDARY )
vbl.request.type |= DRM_VBLANK_SECONDARY;
if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
/* FIXME: This doesn't seem like the right thing to return here.
@ -131,8 +179,10 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
return GLX_BAD_CONTEXT;
}
*msc = vblank_to_msc(priv, vbl.reply.sequence);
dont_wait = 0;
if (target_msc != 0 && vbl.reply.sequence == target)
if (target_msc != 0 && *msc == target)
break;
/* Assuming the wait-done test fails, the next refresh to wait for
@ -142,9 +192,9 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
* If this refresh has already happened, we add divisor to obtain
* the next refresh after the current one that will satisfy it.
*/
r = (vbl.reply.sequence % (unsigned int)divisor);
next = (vbl.reply.sequence - r + (unsigned int)remainder);
if (next <= vbl.reply.sequence) next += (unsigned int)divisor;
r = (*msc % (unsigned int)divisor);
next = (*msc - r + (unsigned int)remainder);
if (next <= *msc) next += (unsigned int)divisor;
} while ( r != (unsigned int)remainder );
}
@ -154,7 +204,10 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
*/
vbl.request.type = DRM_VBLANK_ABSOLUTE;
vbl.request.sequence = target_msc;
vbl.request.sequence = target_msc ? msc_to_vblank(priv, target_msc) : 0;
if ( priv->vblFlags & VBLANK_FLAG_SECONDARY )
vbl.request.type |= DRM_VBLANK_SECONDARY;
if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
/* FIXME: This doesn't seem like the right thing to return here.
@ -163,8 +216,8 @@ int driWaitForMSC32( __DRIdrawablePrivate *priv,
}
}
*msc = (target_msc & 0xffffffff00000000LL);
*msc |= vbl.reply.sequence;
*msc = vblank_to_msc(priv, vbl.reply.sequence);
if ( *msc < target_msc ) {
*msc += 0x0000000100000000LL;
}
@ -252,16 +305,21 @@ static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd )
* direct rendering context.
*/
void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags,
GLuint *vbl_seq )
void driDrawableInitVBlank( __DRIdrawablePrivate *priv )
{
if ( priv->swap_interval == (unsigned)-1 ) {
/* Get current vertical blank sequence */
drmVBlank vbl = { .request={ .type = DRM_VBLANK_RELATIVE, .sequence = 0 } };
do_wait( &vbl, vbl_seq, priv->driScreenPriv->fd );
drmVBlank vbl;
vbl.request.type = DRM_VBLANK_RELATIVE;
if ( priv->vblFlags & VBLANK_FLAG_SECONDARY )
vbl.request.type |= DRM_VBLANK_SECONDARY;
vbl.request.sequence = 0;
do_wait( &vbl, &priv->vblSeq, priv->driScreenPriv->fd );
priv->vblank_base = priv->vblSeq;
priv->swap_interval = (flags & (VBLANK_FLAG_THROTTLE |
VBLANK_FLAG_SYNC)) != 0 ? 1 : 0;
priv->swap_interval =
(priv->vblFlags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) ? 1 : 0;
}
}

View File

@ -46,11 +46,13 @@
*/
extern int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count );
extern int driDrawableGetMSC32( __DRIscreenPrivate * priv,
__DRIdrawablePrivate * drawablePrivate,
int64_t * count);
extern int driWaitForMSC32( __DRIdrawablePrivate *priv,
int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc );
extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache );
extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv, GLuint flags,
GLuint *vbl_seq );
extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv );
extern unsigned driGetVBlankInterval( const __DRIdrawablePrivate *priv,
GLuint flags );
extern void driGetCurrentVBlank( const __DRIdrawablePrivate *priv,

View File

@ -615,6 +615,7 @@ static const struct __DriverAPIRec ffbAPI = {
.UnbindContext = ffbUnbindContext,
.GetSwapInfo = NULL,
.GetMSC = NULL,
.GetDrawableMSC = NULL,
.WaitForMSC = NULL,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL

View File

@ -413,6 +413,7 @@ static const struct __DriverAPIRec i810API = {
.UnbindContext = i810UnbindContext,
.GetSwapInfo = NULL,
.GetMSC = NULL,
.GetDrawableMSC = NULL,
.WaitForMSC = NULL,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL

View File

@ -376,20 +376,25 @@ static void BR13( struct debug_stream *stream,
}
static void BR22( struct debug_stream *stream,
GLuint val )
static void BR2223( struct debug_stream *stream,
GLuint val22, GLuint val23 )
{
PRINTF("\t0x%08x\n", val);
BITS(val, 31, 16, "dest y1");
BITS(val, 15, 0, "dest x1");
}
union { GLuint val; short field[2]; } BR22, BR23;
static void BR23( struct debug_stream *stream,
GLuint val )
{
PRINTF("\t0x%08x\n", val);
BITS(val, 31, 16, "dest y2");
BITS(val, 15, 0, "dest x2");
BR22.val = val22;
BR23.val = val23;
PRINTF("\t0x%08x\n", val22);
BITS(val22, 31, 16, "dest y1");
BITS(val22, 15, 0, "dest x1");
PRINTF("\t0x%08x\n", val23);
BITS(val23, 31, 16, "dest y2");
BITS(val23, 15, 0, "dest x2");
/* The blit engine may produce unexpected results when these aren't met */
assert(BR22.field[0] < BR23.field[0]);
assert(BR22.field[1] < BR23.field[1]);
}
static void BR09( struct debug_stream *stream,
@ -436,8 +441,8 @@ static GLboolean debug_copy_blit( struct debug_stream *stream,
PRINTF("\t0x%08x\n", ptr[j++]);
BR13(stream, ptr[j++]);
BR22(stream, ptr[j++]);
BR23(stream, ptr[j++]);
BR2223(stream, ptr[j], ptr[j+1]);
j += 2;
BR09(stream, ptr[j++]);
BR26(stream, ptr[j++]);
BR11(stream, ptr[j++]);
@ -459,8 +464,8 @@ static GLboolean debug_color_blit( struct debug_stream *stream,
PRINTF("\t0x%08x\n", ptr[j++]);
BR13(stream, ptr[j++]);
BR22(stream, ptr[j++]);
BR23(stream, ptr[j++]);
BR2223(stream, ptr[j], ptr[j+1]);
j += 2;
BR09(stream, ptr[j++]);
BR16(stream, ptr[j++]);

View File

@ -402,6 +402,9 @@ intelClearWithBlit(GLcontext * ctx, GLbitfield mask)
b = *box;
}
if (b.x1 >= b.x2 || b.y1 >= b.y2)
continue;
if (0)
_mesa_printf("clear %d,%d..%d,%d, mask %x\n",
b.x1, b.y1, b.x2, b.y2, mask);

View File

@ -243,7 +243,7 @@ intelWindowMoved(struct intel_context *intel)
.y2 = sarea->planeB_y + sarea->planeB_h };
GLint areaA = driIntersectArea( drw_rect, planeA_rect );
GLint areaB = driIntersectArea( drw_rect, planeB_rect );
GLuint flags = intel_fb->vblank_flags;
GLuint flags = dPriv->vblFlags;
GLboolean pf_active;
GLint pf_planes;
@ -311,19 +311,24 @@ intelWindowMoved(struct intel_context *intel)
/* Update vblank info
*/
if (areaB > areaA || (areaA == areaB && areaB > 0)) {
flags = intel_fb->vblank_flags | VBLANK_FLAG_SECONDARY;
flags = dPriv->vblFlags | VBLANK_FLAG_SECONDARY;
} else {
flags = intel_fb->vblank_flags & ~VBLANK_FLAG_SECONDARY;
flags = dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
}
if (flags != intel_fb->vblank_flags && intel_fb->vblank_flags &&
!(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ)) {
/* Check to see if we changed pipes */
if (flags != dPriv->vblFlags && dPriv->vblFlags &&
!(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ)) {
int64_t count;
drmVBlank vbl;
int i;
/*
* Deal with page flipping
*/
vbl.request.type = DRM_VBLANK_ABSOLUTE;
if ( intel_fb->vblank_flags & VBLANK_FLAG_SECONDARY ) {
if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
vbl.request.type |= DRM_VBLANK_SECONDARY;
}
@ -337,9 +342,19 @@ intelWindowMoved(struct intel_context *intel)
drmWaitVBlank(intel->driFd, &vbl);
}
intel_fb->vblank_flags = flags;
driGetCurrentVBlank(dPriv, intel_fb->vblank_flags, &intel_fb->vbl_seq);
intel_fb->vbl_waited = intel_fb->vbl_seq;
/*
* Update msc_base from old pipe
*/
driDrawableGetMSC32(dPriv->driScreenPriv, dPriv, &count);
dPriv->msc_base = count;
/*
* Then get new vblank_base and vblSeq values
*/
dPriv->vblFlags = flags;
driGetCurrentVBlank(dPriv, dPriv->vblFlags, &dPriv->vblSeq);
dPriv->vblank_base = dPriv->vblSeq;
intel_fb->vbl_waited = dPriv->vblSeq;
for (i = 0; i < intel_fb->pf_num_pages; i++) {
if (intel_fb->color_rb[i])
@ -347,7 +362,7 @@ intelWindowMoved(struct intel_context *intel)
}
}
} else {
intel_fb->vblank_flags &= ~VBLANK_FLAG_SECONDARY;
dPriv->vblFlags &= ~VBLANK_FLAG_SECONDARY;
}
/* Update Mesa's notion of window size */
@ -820,10 +835,10 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv)
*/
static GLboolean
intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target)
intelScheduleSwap(__DRIdrawablePrivate * dPriv, GLboolean *missed_target)
{
struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
unsigned int interval = driGetVBlankInterval(dPriv, intel_fb->vblank_flags);
unsigned int interval = driGetVBlankInterval(dPriv, dPriv->vblFlags);
struct intel_context *intel =
intelScreenContext(dPriv->driScreenPriv->private);
const intelScreenPrivate *intelScreen = intel->intelScreen;
@ -831,24 +846,24 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target)
drm_i915_vblank_swap_t swap;
GLboolean ret;
if (!intel_fb->vblank_flags ||
(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) ||
if (!dPriv->vblFlags ||
(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ) ||
intelScreen->current_rotation != 0 ||
intelScreen->drmMinor < (intel_fb->pf_active ? 9 : 6))
return GL_FALSE;
swap.seqtype = DRM_VBLANK_ABSOLUTE;
if (intel_fb->vblank_flags & VBLANK_FLAG_SYNC) {
if (dPriv->vblFlags & VBLANK_FLAG_SYNC) {
swap.seqtype |= DRM_VBLANK_NEXTONMISS;
} else if (interval == 0) {
return GL_FALSE;
}
swap.drawable = dPriv->hHWDrawable;
target = swap.sequence = intel_fb->vbl_seq + interval;
target = swap.sequence = dPriv->vblSeq + interval;
if ( intel_fb->vblank_flags & VBLANK_FLAG_SECONDARY ) {
if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
swap.seqtype |= DRM_VBLANK_SECONDARY;
}
@ -866,14 +881,14 @@ intelScheduleSwap(const __DRIdrawablePrivate * dPriv, GLboolean *missed_target)
if (!drmCommandWriteRead(intel->driFd, DRM_I915_VBLANK_SWAP, &swap,
sizeof(swap))) {
intel_fb->vbl_seq = swap.sequence;
dPriv->vblSeq = swap.sequence;
swap.sequence -= target;
*missed_target = swap.sequence > 0 && swap.sequence <= (1 << 23);
intel_get_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT)->vbl_pending =
intel_get_renderbuffer(&intel_fb->Base,
BUFFER_FRONT_LEFT)->vbl_pending =
intel_fb->vbl_seq;
dPriv->vblSeq;
if (swap.seqtype & DRM_VBLANK_FLIP) {
intel_flip_renderbuffers(intel_fb);
@ -918,7 +933,7 @@ intelSwapBuffers(__DRIdrawablePrivate * dPriv)
if (screen->current_rotation != 0 ||
!intelScheduleSwap(dPriv, &missed_target)) {
driWaitForVBlank(dPriv, &intel_fb->vbl_seq, intel_fb->vblank_flags,
driWaitForVBlank(dPriv, &dPriv->vblSeq, dPriv->vblFlags,
&missed_target);
if (screen->current_rotation != 0 || !intelPageFlip(dPriv)) {

View File

@ -616,18 +616,17 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
if (driDrawPriv->swap_interval == (unsigned)-1) {
int i;
intel_fb->vblank_flags = (intel->intelScreen->irq_active != 0)
driDrawPriv->vblFlags = (intel->intelScreen->irq_active != 0)
? driGetDefaultVBlankFlags(&intel->optionCache)
: VBLANK_FLAG_NO_IRQ;
(*dri_interface->getUST) (&intel_fb->swap_ust);
driDrawableInitVBlank(driDrawPriv, intel_fb->vblank_flags,
&intel_fb->vbl_seq);
intel_fb->vbl_waited = intel_fb->vbl_seq;
driDrawableInitVBlank(driDrawPriv);
intel_fb->vbl_waited = driDrawPriv->vblSeq;
for (i = 0; i < (intel->intelScreen->third.handle ? 3 : 2); i++) {
if (intel_fb->color_rb[i])
intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_seq;
intel_fb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq;
}
}
intel->driDrawable = driDrawPriv;
@ -731,6 +730,7 @@ intelContendedLock(struct intel_context *intel, GLuint flags)
*/
void LOCK_HARDWARE( struct intel_context *intel )
{
__DRIdrawablePrivate *dPriv = intel->driDrawable;
char __ret=0;
struct intel_framebuffer *intel_fb = NULL;
struct intel_renderbuffer *intel_rb = NULL;
@ -748,14 +748,14 @@ void LOCK_HARDWARE( struct intel_context *intel )
BUFFER_BACK_LEFT);
}
if (intel_rb && intel_fb->vblank_flags &&
!(intel_fb->vblank_flags & VBLANK_FLAG_NO_IRQ) &&
if (intel_rb && dPriv->vblFlags &&
!(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ) &&
(intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
drmVBlank vbl;
vbl.request.type = DRM_VBLANK_ABSOLUTE;
if ( intel_fb->vblank_flags & VBLANK_FLAG_SECONDARY ) {
if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
vbl.request.type |= DRM_VBLANK_SECONDARY;
}

View File

@ -50,8 +50,6 @@ struct intel_framebuffer
/* VBI
*/
GLuint vbl_seq;
GLuint vblank_flags;
GLuint vbl_waited;
int64_t swap_ust;

View File

@ -790,6 +790,7 @@ static const struct __DriverAPIRec intelAPI = {
.UnbindContext = intelUnbindContext,
.GetSwapInfo = intelGetSwapInfo,
.GetMSC = driGetMSC32,
.GetDrawableMSC = driDrawableGetMSC32,
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL,

View File

@ -69,6 +69,7 @@ DRIVER_SOURCES = \
brw_wm_emit.c \
brw_wm_fp.c \
brw_wm_iz.c \
brw_wm_glsl.c \
brw_wm_pass0.c \
brw_wm_pass1.c \
brw_wm_pass2.c \

View File

@ -42,7 +42,7 @@
* up polygon offset and flatshading at this point:
*/
struct brw_clip_prog_key {
GLuint attrs:16;
GLuint attrs:32;
GLuint primitive:4;
GLuint nr_userclip:3;
GLuint do_flat_shading:1;
@ -51,7 +51,7 @@ struct brw_clip_prog_key {
GLuint fill_ccw:2; /* includes cull information */
GLuint offset_cw:1;
GLuint offset_ccw:1;
GLuint pad0:1;
GLuint pad0:17;
GLuint copy_bfc_cw:1;
GLuint copy_bfc_ccw:1;

View File

@ -43,6 +43,8 @@
#include "api_noop.h"
#include "vtxfmt.h"
#include "shader/shader_api.h"
/***************************************
* Mesa's Driver Functions
***************************************/
@ -59,12 +61,37 @@ static const struct dri_extension brw_extensions[] =
{ NULL, NULL }
};
static void brwUseProgram(GLcontext *ctx, GLuint program)
{
struct brw_context *brw = brw_context(ctx);
struct gl_shader_program *sh_prog;
_mesa_use_program(ctx, program);
sh_prog = ctx->Shader.CurrentProgram;
if (sh_prog) {
if (sh_prog->VertexProgram) {
brw->attribs.VertexProgram->Current = sh_prog->VertexProgram;
ctx->VertexProgram.Enabled = GL_TRUE;
}else
ctx->VertexProgram.Enabled = GL_FALSE;
if (sh_prog->FragmentProgram) {
brw->attribs.FragmentProgram->Current = sh_prog->FragmentProgram;
ctx->FragmentProgram.Enabled = GL_TRUE;
} else
ctx->FragmentProgram.Enabled = GL_FALSE;
}
}
static void brwInitProgFuncs( struct dd_function_table *functions )
{
functions->UseProgram = brwUseProgram;
}
static void brwInitDriverFunctions( struct dd_function_table *functions )
{
intelInitDriverFunctions( functions );
brwInitTextureFuncs( functions );
brwInitFragProgFuncs( functions );
brwInitProgFuncs( functions );
}

View File

@ -648,6 +648,11 @@ static __inline struct brw_reg deref_1uw(struct brw_indirect ptr, GLint offset)
return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UW);
}
static __inline struct brw_reg deref_1ud(struct brw_indirect ptr, GLint offset)
{
return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UD);
}
static __inline struct brw_reg get_addr_reg(struct brw_indirect ptr)
{
return brw_address_reg(ptr.addr_subnr);
@ -668,7 +673,10 @@ static __inline struct brw_indirect brw_indirect( GLuint addr_subnr, GLint offse
return ptr;
}
static __inline struct brw_instruction *current_insn( struct brw_compile *p)
{
return &p->store[p->nr_insn];
}
void brw_pop_insn_state( struct brw_compile *p );
void brw_push_insn_state( struct brw_compile *p );
@ -808,9 +816,11 @@ void brw_ENDIF(struct brw_compile *p,
struct brw_instruction *brw_DO(struct brw_compile *p,
GLuint execute_size);
void brw_WHILE(struct brw_compile *p,
struct brw_instruction *brw_WHILE(struct brw_compile *p,
struct brw_instruction *patch_insn);
struct brw_instruction *brw_BREAK(struct brw_compile *p);
struct brw_instruction *brw_CONT(struct brw_compile *p);
/* Forward jumps:
*/
void brw_land_fwd_jump(struct brw_compile *p,
@ -860,5 +870,6 @@ void brw_math_invert( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg src);
void brw_set_src1( struct brw_instruction *insn,
struct brw_reg reg );
#endif

View File

@ -164,7 +164,7 @@ static void brw_set_src0( struct brw_instruction *insn,
}
static void brw_set_src1( struct brw_instruction *insn,
void brw_set_src1( struct brw_instruction *insn,
struct brw_reg reg )
{
assert(reg.file != BRW_MESSAGE_REGISTER_FILE);
@ -186,7 +186,7 @@ static void brw_set_src1( struct brw_instruction *insn,
* in the future:
*/
assert (reg.address_mode == BRW_ADDRESS_DIRECT);
assert (reg.file == BRW_GENERAL_REGISTER_FILE);
//assert (reg.file == BRW_GENERAL_REGISTER_FILE);
if (insn->header.access_mode == BRW_ALIGN_1) {
insn->bits3.da1.src1_subreg_nr = reg.subnr;
@ -597,6 +597,34 @@ void brw_ENDIF(struct brw_compile *p,
}
}
struct brw_instruction *brw_BREAK(struct brw_compile *p)
{
struct brw_instruction *insn;
insn = next_insn(p, BRW_OPCODE_BREAK);
brw_set_dest(insn, brw_ip_reg());
brw_set_src0(insn, brw_ip_reg());
brw_set_src1(insn, brw_imm_d(0x0));
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = BRW_EXECUTE_8;
insn->header.mask_control = BRW_MASK_DISABLE;
insn->bits3.if_else.pad0 = 0;
return insn;
}
struct brw_instruction *brw_CONT(struct brw_compile *p)
{
struct brw_instruction *insn;
insn = next_insn(p, BRW_OPCODE_CONTINUE);
brw_set_dest(insn, brw_ip_reg());
brw_set_src0(insn, brw_ip_reg());
brw_set_src1(insn, brw_imm_d(0x0));
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = BRW_EXECUTE_8;
insn->header.mask_control = BRW_MASK_DISABLE;
insn->bits3.if_else.pad0 = 0;
return insn;
}
/* DO/WHILE loop:
*/
struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
@ -608,13 +636,15 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
/* Override the defaults for this instruction:
*/
brw_set_dest(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
brw_set_src0(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
brw_set_src1(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
brw_set_dest(insn, brw_null_reg());
brw_set_src0(insn, brw_null_reg());
brw_set_src1(insn, brw_null_reg());
insn->header.compression_control = BRW_COMPRESSION_NONE;
insn->header.execution_size = execute_size;
insn->header.predicate_control = BRW_PREDICATE_NONE;
/* insn->header.mask_control = BRW_MASK_ENABLE; */
insn->header.mask_control = BRW_MASK_DISABLE;
return insn;
}
@ -622,7 +652,7 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
void brw_WHILE(struct brw_compile *p,
struct brw_instruction *brw_WHILE(struct brw_compile *p,
struct brw_instruction *do_insn)
{
struct brw_instruction *insn;
@ -653,7 +683,9 @@ void brw_WHILE(struct brw_compile *p,
/* insn->header.mask_control = BRW_MASK_ENABLE; */
insn->header.mask_control = BRW_MASK_DISABLE;
p->current->header.predicate_control = BRW_PREDICATE_NONE;
return insn;
}

View File

@ -40,11 +40,11 @@
#define MAX_GS_VERTS (4)
struct brw_gs_prog_key {
GLuint attrs:32;
GLuint primitive:4;
GLuint attrs:16;
GLuint hint_gs_always:1;
GLuint need_gs_prog:1;
GLuint pad:10;
GLuint pad:26;
};
struct brw_gs_compile {

View File

@ -45,10 +45,10 @@
#define SF_UNFILLED_TRIS 3
struct brw_sf_prog_key {
GLuint attrs:32;
GLuint primitive:2;
GLuint do_twoside_color:1;
GLuint do_flat_shading:1;
GLuint attrs:16;
GLuint frontface_ccw:1;
GLuint do_point_sprite:1;
GLuint pad:10;

View File

@ -67,6 +67,12 @@ struct brw_vs_compile {
struct brw_reg r1;
struct brw_reg regs[PROGRAM_ADDRESS+1][128];
struct brw_reg tmp;
struct brw_reg stack;
struct {
GLboolean used_in_src;
struct brw_reg reg;
} output_regs[128];
struct brw_reg userplane[6];

View File

@ -134,6 +134,16 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
WRITEMASK_X);
reg++;
}
for (i = 0; i < 128; i++) {
if (c->output_regs[i].used_in_src) {
c->output_regs[i].reg = brw_vec8_grf(reg, 0);
reg++;
}
}
c->stack = brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, reg, 0);
reg += 2;
/* Some opcodes need an internal temporary:
@ -213,57 +223,68 @@ static void unalias2( struct brw_vs_compile *c,
}
}
static void emit_sop( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
struct brw_reg arg1,
GLuint cond)
{
brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), cond, arg0, arg1);
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
brw_MOV(p, dst, brw_imm_f(1.0f));
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_MOV(p, dst, brw_imm_f(0.0f));
brw_pop_insn_state(p);
}
static void emit_seq( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
struct brw_reg arg1 )
{
emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_EQ);
}
static void emit_sne( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
struct brw_reg arg1 )
{
emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_NEQ);
}
static void emit_slt( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
struct brw_reg arg1 )
{
/* Could be done with an if/else/endif, but this method uses half
* the instructions. Note that we are careful to reference the
* arguments before writing the dest. That means we emit the
* instructions in an odd order and have to play with the flag
* values.
*/
brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0, arg1);
/* Write all values to 1:
*/
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
brw_MOV(p, dst, brw_imm_f(1.0));
/* Where the test succeeded, overwite with zero:
*/
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_MOV(p, dst, brw_imm_f(0.0));
brw_pop_insn_state(p);
emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_L);
}
static void emit_sle( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
struct brw_reg arg1 )
{
emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_LE);
}
static void emit_sgt( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
struct brw_reg arg1 )
{
emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_G);
}
static void emit_sge( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
struct brw_reg arg1 )
{
brw_push_insn_state(p);
brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0, arg1);
/* Write all values to zero:
*/
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
brw_MOV(p, dst, brw_imm_f(0));
/* Where the test succeeded, overwite with 1:
*/
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_MOV(p, dst, brw_imm_f(1.0));
brw_pop_insn_state(p);
emit_sop(p, dst, arg0, arg1, BRW_CONDITIONAL_GE);
}
static void emit_max( struct brw_compile *p,
struct brw_reg dst,
struct brw_reg arg0,
@ -592,9 +613,13 @@ static struct brw_reg get_reg( struct brw_vs_compile *c,
case PROGRAM_TEMPORARY:
case PROGRAM_INPUT:
case PROGRAM_OUTPUT:
case PROGRAM_STATE_VAR:
assert(c->regs[file][index].nr != 0);
return c->regs[file][index];
case PROGRAM_STATE_VAR:
case PROGRAM_CONSTANT:
case PROGRAM_UNIFORM:
assert(c->regs[PROGRAM_STATE_VAR][index].nr != 0);
return c->regs[PROGRAM_STATE_VAR][index];
case PROGRAM_ADDRESS:
assert(index == 0);
return c->regs[file][index];
@ -668,28 +693,28 @@ static void emit_arl( struct brw_vs_compile *c,
* account.
*/
static struct brw_reg get_arg( struct brw_vs_compile *c,
struct prog_src_register src )
struct prog_src_register *src )
{
struct brw_reg reg;
if (src.File == PROGRAM_UNDEFINED)
if (src->File == PROGRAM_UNDEFINED)
return brw_null_reg();
if (src.RelAddr)
reg = deref(c, c->regs[PROGRAM_STATE_VAR][0], src.Index);
if (src->RelAddr)
reg = deref(c, c->regs[PROGRAM_STATE_VAR][0], src->Index);
else
reg = get_reg(c, src.File, src.Index);
reg = get_reg(c, src->File, src->Index);
/* Convert 3-bit swizzle to 2-bit.
*/
reg.dw1.bits.swizzle = BRW_SWIZZLE4(GET_SWZ(src.Swizzle, 0),
GET_SWZ(src.Swizzle, 1),
GET_SWZ(src.Swizzle, 2),
GET_SWZ(src.Swizzle, 3));
reg.dw1.bits.swizzle = BRW_SWIZZLE4(GET_SWZ(src->Swizzle, 0),
GET_SWZ(src->Swizzle, 1),
GET_SWZ(src->Swizzle, 2),
GET_SWZ(src->Swizzle, 3));
/* Note this is ok for non-swizzle instructions:
*/
reg.negate = src.NegateBase ? 1 : 0;
reg.negate = src->NegateBase ? 1 : 0;
return reg;
}
@ -891,17 +916,50 @@ static void emit_vertex_write( struct brw_vs_compile *c)
}
static void
post_vs_emit( struct brw_vs_compile *c, struct brw_instruction *end_inst )
{
GLuint nr_insns = c->vp->program.Base.NumInstructions;
GLuint insn, target_insn;
struct prog_instruction *inst1, *inst2;
struct brw_instruction *brw_inst1, *brw_inst2;
int offset;
for (insn = 0; insn < nr_insns; insn++) {
inst1 = &c->vp->program.Base.Instructions[insn];
brw_inst1 = inst1->Data;
switch (inst1->Opcode) {
case OPCODE_CAL:
case OPCODE_BRA:
target_insn = inst1->BranchTarget;
inst2 = &c->vp->program.Base.Instructions[target_insn];
brw_inst2 = inst2->Data;
offset = brw_inst2 - brw_inst1;
brw_set_src1(brw_inst1, brw_imm_d(offset*16));
break;
case OPCODE_END:
offset = end_inst - brw_inst1;
brw_set_src1(brw_inst1, brw_imm_d(offset*16));
break;
default:
break;
}
}
}
/* Emit the fragment program instructions here.
*/
void brw_vs_emit( struct brw_vs_compile *c )
void brw_vs_emit(struct brw_vs_compile *c )
{
#define MAX_IFSN 32
struct brw_compile *p = &c->func;
GLuint nr_insns = c->vp->program.Base.NumInstructions;
GLuint insn;
GLuint insn, if_insn = 0;
struct brw_instruction *end_inst;
struct brw_instruction *if_inst[MAX_IFSN];
struct brw_indirect stack_index = brw_indirect(0, 0);
GLuint index;
GLuint file;
if (INTEL_DEBUG & DEBUG_VS) {
_mesa_printf("\n\n\nvs-emit:\n");
@ -912,9 +970,24 @@ void brw_vs_emit( struct brw_vs_compile *c )
brw_set_compression_control(p, BRW_COMPRESSION_NONE);
brw_set_access_mode(p, BRW_ALIGN_16);
/* Message registers can't be read, so copy the output into GRF register
if they are used in source registers */
for (insn = 0; insn < nr_insns; insn++) {
GLuint i;
struct prog_instruction *inst = &c->vp->program.Base.Instructions[insn];
for (i = 0; i < 3; i++) {
struct prog_src_register *src = &inst->SrcReg[i];
GLuint index = src->Index;
GLuint file = src->File;
if (file == PROGRAM_OUTPUT && index != VERT_RESULT_HPOS)
c->output_regs[index].used_in_src = GL_TRUE;
}
}
/* Static register allocation
*/
brw_vs_alloc_regs(c);
brw_MOV(p, get_addr_reg(stack_index), brw_address(c->stack));
for (insn = 0; insn < nr_insns; insn++) {
@ -924,17 +997,29 @@ void brw_vs_emit( struct brw_vs_compile *c )
/* Get argument regs. SWZ is special and does this itself.
*/
inst->Data = &p->store[p->nr_insn];
if (inst->Opcode != OPCODE_SWZ)
for (i = 0; i < 3; i++)
args[i] = get_arg(c, inst->SrcReg[i]);
for (i = 0; i < 3; i++) {
struct prog_src_register *src = &inst->SrcReg[i];
index = src->Index;
file = src->File;
if (file == PROGRAM_OUTPUT&&c->output_regs[index].used_in_src)
args[i] = c->output_regs[index].reg;
else
args[i] = get_arg(c, src);
}
/* Get dest regs. Note that it is possible for a reg to be both
* dst and arg, given the static allocation of registers. So
* care needs to be taken emitting multi-operation instructions.
*/
dst = get_dst(c, inst->DstReg);
*/
index = inst->DstReg.Index;
file = inst->DstReg.File;
if (file == PROGRAM_OUTPUT && c->output_regs[index].used_in_src)
dst = c->output_regs[index].reg;
else
dst = get_dst(c, inst->DstReg);
switch (inst->Opcode) {
case OPCODE_ABS:
brw_MOV(p, dst, brw_abs(args[0]));
@ -1003,12 +1088,25 @@ void brw_vs_emit( struct brw_vs_compile *c )
case OPCODE_RSQ:
emit_math1(c, BRW_MATH_FUNCTION_RSQ, dst, args[0], BRW_MATH_PRECISION_FULL);
break;
case OPCODE_SEQ:
emit_seq(p, dst, args[0], args[1]);
break;
case OPCODE_SNE:
emit_sne(p, dst, args[0], args[1]);
break;
case OPCODE_SGE:
emit_sge(p, dst, args[0], args[1]);
break;
case OPCODE_SGT:
emit_sgt(p, dst, args[0], args[1]);
break;
case OPCODE_SLT:
emit_slt(p, dst, args[0], args[1]);
break;
case OPCODE_SLE:
emit_sle(p, dst, args[0], args[1]);
break;
case OPCODE_SUB:
brw_ADD(p, dst, args[0], negate(args[1]));
break;
@ -1021,21 +1119,60 @@ void brw_vs_emit( struct brw_vs_compile *c )
case OPCODE_XPD:
emit_xpd(p, dst, args[0], args[1]);
break;
case OPCODE_IF:
assert(if_insn < MAX_IFSN);
if_inst[if_insn++] = brw_IF(p, BRW_EXECUTE_8);
break;
case OPCODE_ELSE:
if_inst[if_insn-1] = brw_ELSE(p, if_inst[if_insn-1]);
break;
case OPCODE_ENDIF:
assert(if_insn > 0);
brw_ENDIF(p, if_inst[--if_insn]);
break;
case OPCODE_BRA:
brw_set_predicate_control(p, BRW_PREDICATE_NORMAL);
brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
brw_set_predicate_control_flag_value(p, 0xff);
break;
case OPCODE_CAL:
brw_set_access_mode(p, BRW_ALIGN_1);
brw_ADD(p, deref_1uw(stack_index, 0), brw_ip_reg(), brw_imm_d(3*16));
brw_set_access_mode(p, BRW_ALIGN_16);
brw_ADD(p, get_addr_reg(stack_index),
get_addr_reg(stack_index), brw_imm_d(4));
inst->Data = &p->store[p->nr_insn];
brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
break;
case OPCODE_RET:
brw_ADD(p, get_addr_reg(stack_index),
get_addr_reg(stack_index), brw_imm_d(-4));
brw_set_access_mode(p, BRW_ALIGN_1);
brw_MOV(p, brw_ip_reg(), deref_1uw(stack_index, 0));
brw_set_access_mode(p, BRW_ALIGN_16);
case OPCODE_END:
brw_ADD(p, brw_ip_reg(), brw_ip_reg(), brw_imm_d(1*16));
break;
case OPCODE_PRINT:
case OPCODE_BGNSUB:
case OPCODE_ENDSUB:
break;
default:
_mesa_printf("Unsupport opcode %d in vertex shader\n", inst->Opcode);
break;
}
if (inst->DstReg.File == PROGRAM_OUTPUT
&&inst->DstReg.Index != VERT_RESULT_HPOS
&&c->output_regs[inst->DstReg.Index].used_in_src)
brw_MOV(p, get_dst(c, inst->DstReg), dst);
release_tmps(c);
}
end_inst = &p->store[p->nr_insn];
emit_vertex_write(c);
post_vs_emit(c, end_inst);
for (insn = 0; insn < nr_insns; insn++)
c->vp->program.Base.Instructions[insn].Data = NULL;
}

View File

@ -855,7 +855,7 @@ static struct ureg calculate_light_attenuation( struct tnl_program *p,
struct ureg slt = get_temp(p);
emit_op2(p, OPCODE_DP3, spot, 0, ureg_negate(VPpli), spot_dir_norm);
emit_op2(p, OPCODE_SLT, slt, 0, swizzle1(spot_dir_norm,W), spot);
emit_op2(p, OPCODE_SLT, slt, 0, spot, swizzle1(spot_dir_norm,W));
emit_op2(p, OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W));
emit_op2(p, OPCODE_MUL, att, 0, slt, spot);

View File

@ -66,7 +66,11 @@ GLuint brw_wm_nr_args( GLuint opcode )
case OPCODE_POW:
case OPCODE_SUB:
case OPCODE_SGE:
case OPCODE_SGT:
case OPCODE_SLE:
case OPCODE_SLT:
case OPCODE_SEQ:
case OPCODE_SNE:
case OPCODE_ADD:
case OPCODE_MAX:
case OPCODE_MIN:
@ -150,47 +154,49 @@ static void do_wm_prog( struct brw_context *brw,
c->fp = fp;
c->env_param = brw->intel.ctx.FragmentProgram.Parameters;
/* Augment fragment program. Add instructions for pre- and
* post-fragment-program tasks such as interpolation and fogging.
*/
brw_wm_pass_fp(c);
/* Translate to intermediate representation. Build register usage
* chains.
*/
brw_wm_pass0(c);
/* Dead code removal.
*/
brw_wm_pass1(c);
/* Hal optimization
*/
brw_wm_pass_hal (c);
/* Register allocation.
*/
c->grf_limit = BRW_WM_MAX_GRF/2;
/* This is where we start emitting gen4 code:
*/
brw_init_compile(&c->func);
brw_wm_pass2(c);
c->prog_data.total_grf = c->max_wm_grf;
if (c->last_scratch) {
c->prog_data.total_scratch =
c->last_scratch + 0x40;
if (brw_wm_is_glsl(&c->fp->program)) {
brw_wm_glsl_emit(c);
} else {
c->prog_data.total_scratch = 0;
/* Augment fragment program. Add instructions for pre- and
* post-fragment-program tasks such as interpolation and fogging.
*/
brw_wm_pass_fp(c);
/* Translate to intermediate representation. Build register usage
* chains.
*/
brw_wm_pass0(c);
/* Dead code removal.
*/
brw_wm_pass1(c);
/* Hal optimization
*/
brw_wm_pass_hal (c);
/* Register allocation.
*/
c->grf_limit = BRW_WM_MAX_GRF/2;
/* This is where we start emitting gen4 code:
*/
brw_init_compile(&c->func);
brw_wm_pass2(c);
c->prog_data.total_grf = c->max_wm_grf;
if (c->last_scratch) {
c->prog_data.total_scratch =
c->last_scratch + 0x40;
} else {
c->prog_data.total_scratch = 0;
}
/* Emit GEN4 code.
*/
brw_wm_emit(c);
}
/* Emit GEN4 code.
*/
brw_wm_emit(c);
/* get the program
*/
program = brw_get_program(&c->func, &program_size);

View File

@ -194,6 +194,7 @@ struct brw_wm_compile {
GLuint nr_fp_insns;
GLuint fp_temp;
GLuint fp_interp_emitted;
GLuint fp_deriv_emitted;
struct prog_src_register pixel_xy;
struct prog_src_register delta_xy;
@ -231,6 +232,15 @@ struct brw_wm_compile {
GLuint grf_limit;
GLuint max_wm_grf;
GLuint last_scratch;
struct {
GLboolean inited;
struct brw_reg reg;
} wm_regs[PROGRAM_PAYLOAD+1][256][4];
struct brw_reg stack;
struct brw_reg emit_mask_reg;
GLuint reg_index;
GLuint tmp_index;
};
@ -259,4 +269,6 @@ void brw_wm_lookup_iz( GLuint line_aa,
GLuint lookup,
struct brw_wm_prog_key *key );
GLboolean brw_wm_is_glsl(struct gl_fragment_program *fp);
void brw_wm_glsl_emit(struct brw_wm_compile *c);
#endif

View File

@ -229,20 +229,20 @@ static void emit_cinterp( struct brw_compile *p,
GLuint mask,
const struct brw_reg *arg0 )
{
struct brw_reg interp[4];
GLuint nr = arg0[0].nr;
GLuint i;
struct brw_reg interp[4];
GLuint nr = arg0[0].nr;
GLuint i;
interp[0] = brw_vec1_grf(nr, 0);
interp[1] = brw_vec1_grf(nr, 4);
interp[2] = brw_vec1_grf(nr+1, 0);
interp[3] = brw_vec1_grf(nr+1, 4);
interp[0] = brw_vec1_grf(nr, 0);
interp[1] = brw_vec1_grf(nr, 4);
interp[2] = brw_vec1_grf(nr+1, 0);
interp[3] = brw_vec1_grf(nr+1, 4);
for(i = 0; i < 4; i++ ) {
if (mask & (1<<i)) {
brw_MOV(p, dst[i], suboffset(interp[i],3)); /* TODO: optimize away like other moves */
}
}
for(i = 0; i < 4; i++ ) {
if (mask & (1<<i)) {
brw_MOV(p, dst[i], suboffset(interp[i],3)); /* TODO: optimize away like other moves */
}
}
}
@ -343,7 +343,24 @@ static void emit_lrp( struct brw_compile *p,
}
}
}
static void emit_sop( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
GLuint cond,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
GLuint i;
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
brw_MOV(p, dst[i], brw_imm_f(0));
brw_CMP(p, brw_null_reg(), cond, arg0[i], arg1[i]);
brw_MOV(p, dst[i], brw_imm_f(1.0));
brw_set_predicate_control_flag_value(p, 0xff);
}
}
}
static void emit_slt( struct brw_compile *p,
const struct brw_reg *dst,
@ -351,39 +368,53 @@ static void emit_slt( struct brw_compile *p,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
GLuint i;
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
brw_MOV(p, dst[i], brw_imm_f(0));
brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_L, arg0[i], arg1[i]);
brw_MOV(p, dst[i], brw_imm_f(1.0));
brw_set_predicate_control_flag_value(p, 0xff);
}
}
emit_sop(p, dst, mask, BRW_CONDITIONAL_L, arg0, arg1);
}
static void emit_sle( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_LE, arg0, arg1);
}
static void emit_sgt( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_G, arg0, arg1);
}
/* Isn't this just the same as the above with the args swapped?
*/
static void emit_sge( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
GLuint i;
for (i = 0; i < 4; i++) {
if (mask & (1<<i)) {
brw_MOV(p, dst[i], brw_imm_f(0));
brw_CMP(p, brw_null_reg(), BRW_CONDITIONAL_GE, arg0[i], arg1[i]);
brw_MOV(p, dst[i], brw_imm_f(1.0));
brw_set_predicate_control_flag_value(p, 0xff);
}
}
emit_sop(p, dst, mask, BRW_CONDITIONAL_GE, arg0, arg1);
}
static void emit_seq( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_EQ, arg0, arg1);
}
static void emit_sne( struct brw_compile *p,
const struct brw_reg *dst,
GLuint mask,
const struct brw_reg *arg0,
const struct brw_reg *arg1 )
{
emit_sop(p, dst, mask, BRW_CONDITIONAL_NEQ, arg0, arg1);
}
static void emit_cmp( struct brw_compile *p,
const struct brw_reg *dst,
@ -543,8 +574,8 @@ static void emit_math1( struct brw_compile *p,
GLuint mask,
const struct brw_reg *arg0 )
{
assert((mask & WRITEMASK_XYZW) == WRITEMASK_X ||
function == BRW_MATH_FUNCTION_SINCOS);
//assert((mask & WRITEMASK_XYZW) == WRITEMASK_X ||
// function == BRW_MATH_FUNCTION_SINCOS);
brw_MOV(p, brw_message_reg(2), arg0[0]);
@ -671,6 +702,8 @@ static void emit_tex( struct brw_wm_compile *c,
msgLength,
0);
if (shadow)
brw_MOV(p, dst[3], brw_imm_f(1.0));
}
@ -1208,9 +1241,21 @@ void brw_wm_emit( struct brw_wm_compile *c )
emit_slt(p, dst, dst_flags, args[0], args[1]);
break;
case OPCODE_SLE:
emit_sle(p, dst, dst_flags, args[0], args[1]);
break;
case OPCODE_SGT:
emit_sgt(p, dst, dst_flags, args[0], args[1]);
break;
case OPCODE_SGE:
emit_sge(p, dst, dst_flags, args[0], args[1]);
break;
case OPCODE_SEQ:
emit_seq(p, dst, dst_flags, args[0], args[1]);
break;
case OPCODE_SNE:
emit_sne(p, dst, dst_flags, args[0], args[1]);
break;
case OPCODE_LIT:
emit_lit(p, dst, dst_flags, args[0]);
@ -1231,7 +1276,8 @@ void brw_wm_emit( struct brw_wm_compile *c )
break;
default:
assert(0);
_mesa_printf("unsupport opcode %d in fragment program\n",
inst->opcode);
}
for (i = 0; i < 4; i++)

View File

@ -176,6 +176,7 @@ static struct prog_instruction *emit_insn(struct brw_wm_compile *c,
{
struct prog_instruction *inst = get_fp_inst(c);
*inst = *inst0;
inst->Data = (void *)inst0;
return inst;
}
@ -201,7 +202,6 @@ static struct prog_instruction * emit_op(struct brw_wm_compile *c,
inst->SrcReg[0] = src0;
inst->SrcReg[1] = src1;
inst->SrcReg[2] = src2;
return inst;
}
@ -361,6 +361,37 @@ static void emit_interp( struct brw_wm_compile *c,
c->fp_interp_emitted |= 1<<idx;
}
static void emit_ddx( struct brw_wm_compile *c,
const struct prog_instruction *inst )
{
GLuint idx = inst->SrcReg[0].Index;
struct prog_src_register interp = src_reg(PROGRAM_PAYLOAD, idx);
c->fp_deriv_emitted |= 1<<idx;
emit_op(c,
OPCODE_DDX,
inst->DstReg,
0, 0, 0,
interp,
get_pixel_w(c),
src_undef());
}
static void emit_ddy( struct brw_wm_compile *c,
const struct prog_instruction *inst )
{
GLuint idx = inst->SrcReg[0].Index;
struct prog_src_register interp = src_reg(PROGRAM_PAYLOAD, idx);
c->fp_deriv_emitted |= 1<<idx;
emit_op(c,
OPCODE_DDY,
inst->DstReg,
0, 0, 0,
interp,
get_pixel_w(c),
src_undef());
}
/***********************************************************************
* Hacks to extend the program parameter and constant lists.
@ -957,8 +988,16 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
*/
out->DstReg.WriteMask = 0;
break;
case OPCODE_DDX:
emit_ddx(c, inst);
break;
case OPCODE_DDY:
emit_ddy(c, inst);
break;
case OPCODE_END:
emit_fog(c);
emit_fb_write(c);
break;
case OPCODE_PRINT:
break;
@ -967,15 +1006,11 @@ void brw_wm_pass_fp( struct brw_wm_compile *c )
break;
}
}
emit_fog(c);
emit_fb_write(c);
if (INTEL_DEBUG & DEBUG_WM) {
_mesa_printf("\n\n\npass_fp:\n");
print_insns( c->prog_instructions, c->nr_fp_insns );
_mesa_printf("\n");
_mesa_printf("\n\n\npass_fp:\n");
print_insns( c->prog_instructions, c->nr_fp_insns );
_mesa_printf("\n");
}
}

File diff suppressed because it is too large Load Diff

View File

@ -168,6 +168,7 @@ static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
case PROGRAM_PAYLOAD:
case PROGRAM_TEMPORARY:
case PROGRAM_OUTPUT:
case PROGRAM_VARYING:
break;
case PROGRAM_LOCAL_PARAM:
@ -179,6 +180,8 @@ static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
break;
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
case PROGRAM_CONSTANT:
case PROGRAM_NAMED_PARAM: {
struct gl_program_parameter_list *plist = c->fp->program.Base.Parameters;
@ -197,6 +200,7 @@ static const struct brw_wm_ref *pass0_get_reg( struct brw_wm_compile *c,
break;
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
/* These may change from run to run:
*/
ref = get_param_ref(c, &plist->ParameterValues[idx][component] );

View File

@ -155,7 +155,11 @@ void brw_wm_pass1( struct brw_wm_compile *c )
case OPCODE_SUB:
case OPCODE_SLT:
case OPCODE_SLE:
case OPCODE_SGE:
case OPCODE_SGT:
case OPCODE_SEQ:
case OPCODE_SNE:
case OPCODE_ADD:
case OPCODE_MAX:
case OPCODE_MIN:
@ -257,7 +261,6 @@ void brw_wm_pass1( struct brw_wm_compile *c )
case OPCODE_DST:
case OPCODE_TXP:
default:
assert(0);
break;
}

View File

@ -328,7 +328,7 @@ void brw_wm_pass2( struct brw_wm_compile *c )
c->state = PASS2_DONE;
if (INTEL_DEBUG & DEBUG_WM) {
brw_wm_print_program(c, "pass2/done");
brw_wm_print_program(c, "pass2/done");
}
}

View File

@ -34,6 +34,7 @@
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
#include "brw_wm.h"
#include "bufmgr.h"
/***********************************************************************
@ -134,9 +135,13 @@ static void upload_wm_unit(struct brw_context *brw )
if (fp->UsesKill ||
brw->attribs.Color->AlphaEnabled)
wm.wm5.program_uses_killpixel = 1;
if (brw_wm_is_glsl(fp))
wm.wm5.enable_8_pix = 1;
else
wm.wm5.enable_16_pix = 1;
}
wm.wm5.enable_16_pix = 1;
wm.wm5.thread_dispatch_enable = 1; /* AKA: color_write */
wm.wm5.legacy_line_rast = 0;
wm.wm5.legacy_global_depth_bias = 0;

View File

@ -76,7 +76,8 @@ void intelCopyBuffer( const __DRIdrawablePrivate *dPriv,
if (!rect)
{
UNLOCK_HARDWARE( intel );
driWaitForVBlank( dPriv, &intel->vbl_seq, intel->vblank_flags, & missed_target );
driWaitForVBlank( dPriv, &dPriv->vblSeq, dPriv->vblFlags,
&missed_target );
LOCK_HARDWARE( intel );
}

View File

@ -33,6 +33,8 @@
#include "context.h"
#include "framebuffer.h"
#include "macros.h"
#include "utils.h"
#include "vblank.h"
#include "swrast/swrast.h"
GLboolean intel_intersect_cliprects( drm_clip_rect_t *dst,
@ -190,6 +192,50 @@ void intelWindowMoved( struct intel_context *intel )
}
}
/* Get updated plane info so we sync against the right vblank counter */
if (intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
drmI830Sarea *sarea = intel->sarea;
drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w,
.y1 = dPriv->y, .y2 = dPriv->y + dPriv->h };
drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, .y1 = sarea->planeA_y,
.x2 = sarea->planeA_x + sarea->planeA_w,
.y2 = sarea->planeA_y + sarea->planeA_h };
drm_clip_rect_t planeB_rect = { .x1 = sarea->planeB_x, .y1 = sarea->planeB_y,
.x2 = sarea->planeB_x + sarea->planeB_w,
.y2 = sarea->planeB_y + sarea->planeB_h };
GLint areaA = driIntersectArea( drw_rect, planeA_rect );
GLint areaB = driIntersectArea( drw_rect, planeB_rect );
GLuint flags = dPriv->vblFlags;
/* Update vblank info
*/
if (areaB > areaA || (areaA == areaB && areaB > 0)) {
flags = dPriv->vblFlags | VBLANK_FLAG_SECONDARY;
} else {
flags = dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
}
/* Check to see if we changed pipes */
if (flags != dPriv->vblFlags && dPriv->vblFlags &&
!(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ)) {
int64_t count;
/*
* Update msc_base from old pipe
*/
driDrawableGetMSC32(dPriv->driScreenPriv, dPriv, &count);
dPriv->msc_base = count;
/*
* Then get new vblank_base and vblSeq values
*/
dPriv->vblFlags = flags;
driGetCurrentVBlank(dPriv, dPriv->vblFlags, &dPriv->vblSeq);
dPriv->vblank_base = dPriv->vblSeq;
}
} else {
dPriv->vblFlags &= ~VBLANK_FLAG_SECONDARY;
}
_mesa_resize_framebuffer(&intel->ctx,
(GLframebuffer*)dPriv->driverPrivate,
dPriv->w, dPriv->h);

View File

@ -84,6 +84,11 @@ int INTEL_DEBUG = (0);
#define need_GL_EXT_multi_draw_arrays
#define need_GL_EXT_secondary_color
#define need_GL_EXT_point_parameters
#define need_GL_VERSION_2_0
#define need_GL_VERSION_2_1
#define need_GL_ARB_shader_objects
#define need_GL_ARB_vertex_shader
#include "extension_helper.h"
#ifndef VERBOSE
@ -190,6 +195,13 @@ const struct dri_extension card_extensions[] =
{ "GL_MESA_ycbcr_texture", NULL },
{ "GL_NV_blend_square", NULL },
{ "GL_SGIS_generate_mipmap", NULL },
{ "GL_ARB_shading_language_100", GL_VERSION_2_0_functions},
{ "GL_ARB_shading_language_120", GL_VERSION_2_1_functions},
{ "GL_ARB_shader_objects", GL_ARB_shader_objects_functions},
{ "GL_ARB_vertex_shader", GL_ARB_vertex_shader_functions},
{ "GL_ARB_fragment_shader", NULL },
/* XXX not implement yet, to compile builtin glsl lib */
{ "GL_ARB_draw_buffers", NULL },
{ NULL, NULL }
};
@ -330,8 +342,8 @@ GLboolean intelInitContext( struct intel_context *intel,
GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private;
volatile drmI830Sarea *saPriv = (volatile drmI830Sarea *)
(((GLubyte *)sPriv->pSAREA)+intelScreen->sarea_priv_offset);
volatile drmI830Sarea *saPriv = (drmI830Sarea *)
(((GLubyte *)sPriv->pSAREA)+intelScreen->sarea_priv_offset);
if (!_mesa_initialize_context(&intel->ctx,
mesaVis, shareCtx,
@ -349,9 +361,6 @@ GLboolean intelInitContext( struct intel_context *intel,
driParseConfigFiles (&intel->optionCache, &intelScreen->optionCache,
intel->driScreen->myNum, "i965");
intel->vblank_flags = (intel->intelScreen->irq_active != 0)
? driGetDefaultVBlankFlags(&intel->optionCache) : VBLANK_FLAG_NO_IRQ;
ctx->Const.MaxTextureMaxAnisotropy = 2.0;
if (getenv("INTEL_STRICT_CONFORMANCE")) {
@ -559,6 +568,8 @@ void intelDestroyContext(__DRIcontextPrivate *driContextPriv)
#endif
/* free the Mesa context */
intel->ctx.VertexProgram.Current = NULL;
intel->ctx.FragmentProgram.Current = NULL;
_mesa_destroy_context(&intel->ctx);
}
@ -578,17 +589,19 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
if (driContextPriv) {
struct intel_context *intel = (struct intel_context *) driContextPriv->driverPrivate;
driDrawPriv->vblFlags = (intel->intelScreen->irq_active != 0)
? driGetDefaultVBlankFlags(&intel->optionCache) : VBLANK_FLAG_NO_IRQ;
if (intel->driReadDrawable != driReadPriv) {
intel->driReadDrawable = driReadPriv;
}
if ( intel->driDrawable != driDrawPriv ) {
/* Shouldn't the readbuffer be stored also? */
driDrawableInitVBlank( driDrawPriv, intel->vblank_flags,
&intel->vbl_seq );
intel->driDrawable = driDrawPriv;
intelWindowMoved( intel );
/* Shouldn't the readbuffer be stored also? */
driDrawableInitVBlank( driDrawPriv );
}
_mesa_make_current(&intel->ctx,

View File

@ -231,11 +231,6 @@ struct intel_context
*/
driOptionCache optionCache;
/* VBI
*/
GLuint vbl_seq;
GLuint vblank_flags;
int64_t swap_ust;
int64_t swap_missed_ust;

View File

@ -549,6 +549,7 @@ static const struct __DriverAPIRec intelAPI = {
.UnbindContext = intelUnbindContext,
.GetSwapInfo = intelGetSwapInfo,
.GetMSC = driGetMSC32,
.GetDrawableMSC = driDrawableGetMSC32,
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL,

View File

@ -100,6 +100,7 @@ GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
{
GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *driScreen = driContextPriv->driScreenPriv;
__DRIdrawablePrivate *dPriv = driContextPriv->driDrawablePriv;
struct dd_function_table functions;
mach64ContextPtr mmesa;
mach64ScreenPtr mach64Screen;
@ -253,7 +254,7 @@ GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
mmesa->do_irqs = (mmesa->mach64Screen->irq && !getenv("MACH64_NO_IRQS"));
mmesa->vblank_flags = (mmesa->do_irqs)
dPriv->vblFlags = (mmesa->do_irqs)
? driGetDefaultVBlankFlags(&mmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
driContextPriv->driverPrivate = (void *)mmesa;
@ -330,8 +331,7 @@ mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
}
driDrawableInitVBlank( driDrawPriv, newMach64Ctx->vblank_flags,
&newMach64Ctx->vbl_seq );
driDrawableInitVBlank( driDrawPriv );
if ( newMach64Ctx->driDrawable != driDrawPriv ) {
newMach64Ctx->driDrawable = driDrawPriv;

View File

@ -263,8 +263,6 @@ struct mach64_context {
/* VBI
*/
GLuint vbl_seq;
GLuint vblank_flags;
GLuint do_irqs;
/* Configuration cache

View File

@ -279,7 +279,7 @@ static int mach64WaitForFrameCompletion( mach64ContextPtr mmesa )
/* Copy the back color buffer to the front color buffer.
*/
void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv )
void mach64CopyBuffer( __DRIdrawablePrivate *dPriv )
{
mach64ContextPtr mmesa;
GLint nbox, i, ret;
@ -320,7 +320,7 @@ void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv )
#endif
UNLOCK_HARDWARE( mmesa );
driWaitForVBlank( dPriv, &mmesa->vbl_seq, mmesa->vblank_flags, &missed_target );
driWaitForVBlank( dPriv, &dPriv->vblSeq, dPriv->vblFlags, &missed_target );
LOCK_HARDWARE( mmesa );
/* use front buffer cliprects */

View File

@ -78,7 +78,7 @@ extern void mach64FireBlitLocked( mach64ContextPtr mmesa, void *buffer,
GLint offset, GLint pitch, GLint format,
GLint x, GLint y, GLint width, GLint height );
extern void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv );
extern void mach64CopyBuffer( __DRIdrawablePrivate *dPriv );
#if ENABLE_PERF_BOXES
extern void mach64PerformanceCounters( mach64ContextPtr mmesa );
extern void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa );

View File

@ -484,6 +484,7 @@ static struct __DriverAPIRec mach64API = {
.UnbindContext = mach64UnbindContext,
.GetSwapInfo = NULL,
.GetMSC = driGetMSC32,
.GetDrawableMSC = driDrawableGetMSC32,
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL

View File

@ -75,11 +75,13 @@
#define need_GL_ARB_vertex_buffer_object
#define need_GL_ARB_vertex_program
#define need_GL_EXT_fog_coord
#define need_GL_EXT_gpu_program_parameters
#define need_GL_EXT_multi_draw_arrays
#define need_GL_EXT_secondary_color
#if 0
#define need_GL_EXT_paletted_texture
#endif
#define need_GL_APPLE_vertex_array_object
#define need_GL_NV_vertex_program
#include "extension_helper.h"
@ -411,13 +413,15 @@ static const struct dri_extension card_extensions[] =
#endif
{ "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
{ "GL_EXT_stencil_wrap", NULL },
{ "GL_APPLE_vertex_array_object", GL_APPLE_vertex_array_object_functions },
{ "GL_MESA_ycbcr_texture", NULL },
{ "GL_SGIS_generate_mipmap", NULL },
{ NULL, NULL }
};
static const struct dri_extension ARB_vp_extension[] = {
static const struct dri_extension ARB_vp_extensions[] = {
{ "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
{ "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions },
{ NULL, NULL }
};
@ -448,6 +452,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
GLcontext *ctx, *shareCtx;
mgaContextPtr mmesa;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
__DRIdrawablePrivate *dPriv = driContextPriv->driDrawablePriv;
mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
drm_mga_sarea_t *saPriv = (drm_mga_sarea_t *)(((char*)sPriv->pSAREA)+
mgaScreen->sarea_priv_offset);
@ -622,7 +627,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
}
if ( driQueryOptionb( &mmesa->optionCache, "arb_vertex_program" ) ) {
driInitSingleExtension( ctx, ARB_vp_extension );
driInitExtensions(ctx, ARB_vp_extensions, GL_FALSE);
}
if ( driQueryOptionb( &mmesa->optionCache, "nv_vertex_program" ) ) {
@ -646,7 +651,7 @@ mgaCreateContext( const __GLcontextModes *mesaVis,
debug_control );
#endif
mmesa->vblank_flags = (mmesa->mgaScreen->irq == 0)
dPriv->vblFlags = (mmesa->mgaScreen->irq == 0)
? VBLANK_FLAG_NO_IRQ : driGetDefaultVBlankFlags(&mmesa->optionCache);
(*dri_interface->getUST)( & mmesa->swap_ust );
@ -878,8 +883,8 @@ mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
if (mmesa->driDrawable != driDrawPriv) {
driDrawableInitVBlank( driDrawPriv, mmesa->vblank_flags,
&mmesa->vbl_seq );
driDrawableInitVBlank( driDrawPriv );
mmesa->driDrawable = driDrawPriv;
mmesa->dirty = ~0;
mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
@ -944,6 +949,7 @@ static const struct __DriverAPIRec mgaAPI = {
.UnbindContext = mgaUnbindContext,
.GetSwapInfo = getSwapInfo,
.GetMSC = driGetMSC32,
.GetDrawableMSC = driDrawableGetMSC32,
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL
@ -985,7 +991,7 @@ __GLcontextModes *__driDriverInitScreen(__DRIscreenPrivate *psp)
driInitExtensions( NULL, card_extensions, GL_FALSE );
driInitExtensions( NULL, g400_extensions, GL_FALSE );
driInitSingleExtension( NULL, ARB_vp_extension );
driInitExtensions(NULL, ARB_vp_extensions, GL_FALSE);
driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
if (!mgaInitDriver(psp))

View File

@ -258,11 +258,6 @@ struct mga_context_t {
drmBufPtr vertex_dma_buffer;
drmBufPtr iload_buffer;
/* VBI
*/
GLuint vbl_seq;
GLuint vblank_flags;
int64_t swap_ust;
int64_t swap_missed_ust;

View File

@ -41,7 +41,7 @@
#include "mga_xmesa.h"
#include "utils.h"
#define DRIVER_DATE "20061030"
#define DRIVER_DATE "20071017"
/***************************************

View File

@ -428,8 +428,7 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
FLUSH_BATCH( mmesa );
mgaWaitForFrameCompletion( mmesa );
driWaitForVBlank( dPriv, & mmesa->vbl_seq, mmesa->vblank_flags,
& missed_target );
driWaitForVBlank( dPriv, & dPriv->vblSeq, dPriv->vblFlags, & missed_target );
if ( missed_target ) {
mmesa->swap_missed_count++;
(void) (*dri_interface->getUST)( & mmesa->swap_missed_ust );

View File

@ -283,7 +283,7 @@ GLboolean nouveauMakeCurrent( __DRIcontextPrivate *driContextPriv,
struct gl_framebuffer *read_fb =
(struct gl_framebuffer*)driReadPriv->driverPrivate;
driDrawableInitVBlank(driDrawPriv, nmesa->vblank_flags, &nmesa->vblank_seq );
driDrawableInitVBlank(driDrawPriv);
nmesa->driDrawable = driDrawPriv;
_mesa_resize_framebuffer(nmesa->glCtx, draw_fb,

View File

@ -182,10 +182,6 @@ typedef struct nouveau_context {
/* Configuration cache */
driOptionCache optionCache;
/* vblank stuff */
uint32_t vblank_flags;
uint32_t vblank_seq;
GLuint new_state;
GLuint new_render_state;
GLuint render_index;

View File

@ -205,6 +205,7 @@ static const struct __DriverAPIRec nouveauAPI = {
.UnbindContext = nouveauUnbindContext,
.GetSwapInfo = nouveauGetSwapInfo,
.GetMSC = driGetMSC32,
.GetDrawableMSC = driDrawableGetMSC32,
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL,

View File

@ -113,6 +113,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
{
GLcontext *ctx, *shareCtx;
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
__DRIdrawablePrivate *dPriv = driContextPriv->driDrawablePriv;
struct dd_function_table functions;
r128ContextPtr rmesa;
r128ScreenPtr r128scrn;
@ -262,7 +263,7 @@ GLboolean r128CreateContext( const __GLcontextModes *glVisual,
r128DDInitSpanFuncs( ctx );
r128DDInitState( rmesa );
rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
dPriv->vblFlags = (rmesa->r128Screen->irq != 0)
? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
driContextPriv->driverPrivate = (void *)rmesa;
@ -347,8 +348,7 @@ r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
newR128Ctx->dirty = R128_UPLOAD_ALL;
}
driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags,
&newR128Ctx->vbl_seq );
driDrawableInitVBlank( driDrawPriv );
newR128Ctx->driDrawable = driDrawPriv;
_mesa_make_current( newR128Ctx->glCtx,

View File

@ -210,11 +210,6 @@ struct r128_context {
GLuint c_textureBytes;
GLuint c_vertexBuffers;
/* VBI
*/
GLuint vbl_seq;
GLuint vblank_flags;
/* Configuration cache
*/
driOptionCache optionCache;

View File

@ -249,7 +249,7 @@ static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
/* Copy the back color buffer to the front color buffer.
*/
void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
void r128CopyBuffer( __DRIdrawablePrivate *dPriv )
{
r128ContextPtr rmesa;
GLint nbox, i, ret;
@ -282,7 +282,7 @@ void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
}
UNLOCK_HARDWARE( rmesa );
driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
driWaitForVBlank( dPriv, &dPriv->vblSeq, dPriv->vblFlags, &missed_target );
LOCK_HARDWARE( rmesa );
nbox = dPriv->numClipRects; /* must be in locked region */
@ -328,7 +328,7 @@ void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
#endif
}
void r128PageFlip( const __DRIdrawablePrivate *dPriv )
void r128PageFlip( __DRIdrawablePrivate *dPriv )
{
r128ContextPtr rmesa;
GLint ret;
@ -359,7 +359,7 @@ void r128PageFlip( const __DRIdrawablePrivate *dPriv )
}
UNLOCK_HARDWARE( rmesa );
driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
driWaitForVBlank( dPriv, &dPriv->vblSeq, dPriv->vblFlags, &missed_target );
LOCK_HARDWARE( rmesa );
/* The kernel will have been initialized to perform page flipping

View File

@ -86,8 +86,8 @@ extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
const GLint x[], const GLint y[] );
extern void r128CopyBuffer( const __DRIdrawablePrivate *dPriv );
extern void r128PageFlip( const __DRIdrawablePrivate *dPriv );
extern void r128CopyBuffer( __DRIdrawablePrivate *dPriv );
extern void r128PageFlip( __DRIdrawablePrivate *dPriv );
void r128WaitForVBlank( r128ContextPtr rmesa );
extern void r128WaitForIdleLocked( r128ContextPtr rmesa );

View File

@ -411,6 +411,7 @@ static struct __DriverAPIRec r128API = {
.UnbindContext = r128UnbindContext,
.GetSwapInfo = NULL,
.GetMSC = driGetMSC32,
.GetDrawableMSC = driDrawableGetMSC32,
.WaitForMSC = driWaitForMSC32,
.WaitForSBC = NULL,
.SwapBuffersMSC = NULL

View File

@ -248,6 +248,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
void *sharedContextPrivate)
{
__DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
__DRIdrawablePrivate *dPriv = driContextPriv->driDrawablePriv;
radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
struct dd_function_table functions;
r200ContextPtr rmesa;
@ -499,7 +500,7 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual,
fthrottle_mode,
rmesa->r200Screen->irq);
rmesa->vblank_flags = (rmesa->r200Screen->irq != 0)
dPriv->vblFlags = (rmesa->r200Screen->irq != 0)
? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
rmesa->prefer_gart_client_texturing =
@ -667,8 +668,7 @@ r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)newCtx->glCtx);
if ( newCtx->dri.drawable != driDrawPriv ) {
driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags,
&newCtx->vbl_seq );
driDrawableInitVBlank( driDrawPriv );
}
newCtx->dri.readable = driReadPriv;

View File

@ -893,11 +893,8 @@ struct r200_context {
GLuint TexGenCompSel;
GLmatrix tmpmat;
/* VBI / buffer swap
/* buffer swap
*/
GLuint vbl_seq;
GLuint vblank_flags;
int64_t swap_ust;
int64_t swap_missed_ust;

View File

@ -419,7 +419,7 @@ static void r200WaitForFrameCompletion( r200ContextPtr rmesa )
/* Copy the back color buffer to the front color buffer.
*/
void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
void r200CopyBuffer( __DRIdrawablePrivate *dPriv,
const drm_clip_rect_t *rect)
{
r200ContextPtr rmesa;
@ -449,7 +449,7 @@ void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
if (!rect)
{
UNLOCK_HARDWARE( rmesa );
driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
driWaitForVBlank( dPriv, & dPriv->vblSeq, dPriv->vblFlags, & missed_target );
LOCK_HARDWARE( rmesa );
}
@ -513,7 +513,7 @@ void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
}
}
void r200PageFlip( const __DRIdrawablePrivate *dPriv )
void r200PageFlip( __DRIdrawablePrivate *dPriv )
{
r200ContextPtr rmesa;
GLint ret;
@ -553,7 +553,7 @@ void r200PageFlip( const __DRIdrawablePrivate *dPriv )
*/
r200WaitForFrameCompletion( rmesa );
UNLOCK_HARDWARE( rmesa );
driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
driWaitForVBlank( dPriv, & dPriv->vblSeq, dPriv->vblFlags, & missed_target );
if ( missed_target ) {
rmesa->swap_missed_count++;
(void) (*dri_interface->getUST)( & rmesa->swap_missed_ust );

View File

@ -89,9 +89,9 @@ extern void r200ReleaseDmaRegion( r200ContextPtr rmesa,
struct r200_dma_region *region,
const char *caller );
extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable,
extern void r200CopyBuffer( __DRIdrawablePrivate *drawable,
const drm_clip_rect_t *rect);
extern void r200PageFlip( const __DRIdrawablePrivate *drawable );
extern void r200PageFlip( __DRIdrawablePrivate *drawable );
extern void r200Flush( GLcontext *ctx );
extern void r200Finish( GLcontext *ctx );
extern void r200WaitForIdleLocked( r200ContextPtr rmesa );

View File

@ -93,6 +93,8 @@ int hw_tcl_on = 1;
const struct dri_extension card_extensions[] = {
/* *INDENT-OFF* */
{"GL_ARB_depth_texture", NULL},
{"GL_ARB_fragment_program", NULL},
{"GL_ARB_multisample", GL_ARB_multisample_functions},
{"GL_ARB_multitexture", NULL},
{"GL_ARB_texture_border_clamp", NULL},
@ -105,7 +107,6 @@ const struct dri_extension card_extensions[] = {
{"GL_ARB_texture_mirrored_repeat", NULL},
{"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
{"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
{"GL_ARB_fragment_program", NULL},
{"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
{"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
{"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
@ -130,6 +131,7 @@ const struct dri_extension card_extensions[] = {
{"GL_NV_blend_square", NULL},
{"GL_NV_vertex_program", GL_NV_vertex_program_functions},
{"GL_SGIS_generate_mipmap", NULL},
{"GL_SGIX_depth_texture", NULL},
{NULL, NULL}
/* *INDENT-ON* */
};

View File

@ -886,6 +886,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
# define R300_TX_FORMAT_A8R8G8B8 0x13 /* no swizzle */
# define R300_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */
# define R300_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */
/* These two values are wrong, but they're the only values that
* produce any even vaguely correct results. Can r300 only do 16-bit
* depth textures?
*/
# define R300_TX_FORMAT_X24_Y8 0x1e
# define R300_TX_FORMAT_X32 0x1e
/* 0x16 - some 16 bit green format.. ?? */
# define R300_TX_FORMAT_UNK25 (1 << 25) /* no swizzle */
# define R300_TX_FORMAT_CUBIC_MAP (1 << 26)

View File

@ -482,6 +482,25 @@ static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
case GL_RGBA32F_ARB:
return &_mesa_texformat_rgba_float32;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT16:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
#if 0
switch (type) {
case GL_UNSIGNED_BYTE:
case GL_UNSIGNED_SHORT:
return &_mesa_texformat_z16;
case GL_UNSIGNED_INT:
return &_mesa_texformat_z32;
case GL_UNSIGNED_INT_24_8_EXT:
default:
return &_mesa_texformat_z24_s8;
}
#else
return &_mesa_texformat_z16;
#endif
default:
_mesa_problem(ctx,
"unexpected internalFormat 0x%x in r300ChooseTextureFormat",
@ -1057,6 +1076,19 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
driSwapOutTextureObject((driTextureObject *) t);
break;
case GL_DEPTH_TEXTURE_MODE:
if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
== GL_DEPTH_COMPONENT) {
r300SetDepthTexMode(texObj);
break;
} else {
/* If the texture isn't a depth texture, changing this
* state won't cause any changes to the hardware.
* Don't force a flush of texture state.
*/
return;
}
default:
return;
}

View File

@ -35,6 +35,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef __r300_TEX_H__
#define __r300_TEX_H__
extern void r300SetDepthTexMode(struct gl_texture_object *tObj);
extern void r300SetTexOffset(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth,
GLuint pitch);

View File

@ -115,11 +115,80 @@ static const struct tx_table {
_ASSIGN(LUMINANCE_ALPHA_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, Y, FL_I16A16)),
_ASSIGN(INTENSITY_FLOAT32, R300_EASY_TX_FORMAT(X, X, X, X, FL_I32)),
_ASSIGN(INTENSITY_FLOAT16, R300_EASY_TX_FORMAT(X, X, X, X, FL_I16)),
_ASSIGN(Z16, R300_EASY_TX_FORMAT(X, X, X, X, X16)),
_ASSIGN(Z24_S8, R300_EASY_TX_FORMAT(X, X, X, X, X24_Y8)),
_ASSIGN(Z32, R300_EASY_TX_FORMAT(X, X, X, X, X32)),
/* *INDENT-ON* */
};
#undef _ASSIGN
void r300SetDepthTexMode(struct gl_texture_object *tObj)
{
static const GLuint formats[3][3] = {
{
R300_EASY_TX_FORMAT(X, X, X, X, X16),
R300_EASY_TX_FORMAT(X, X, X, ONE, X16),
R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X16),
},
{
R300_EASY_TX_FORMAT(X, X, X, X, X24_Y8),
R300_EASY_TX_FORMAT(X, X, X, ONE, X24_Y8),
R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X24_Y8),
},
{
R300_EASY_TX_FORMAT(X, X, X, X, X32),
R300_EASY_TX_FORMAT(X, X, X, ONE, X32),
R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X32),
},
};
const GLuint *format;
r300TexObjPtr t;
if (!tObj)
return;
t = (r300TexObjPtr) tObj->DriverData;
switch (tObj->Image[0][tObj->BaseLevel]->TexFormat->MesaFormat) {
case MESA_FORMAT_Z16:
format = formats[0];
break;
case MESA_FORMAT_Z24_S8:
format = formats[1];
break;
case MESA_FORMAT_Z32:
format = formats[2];
break;
default:
/* Error...which should have already been caught by higher
* levels of Mesa.
*/
ASSERT(0);
return;
}
switch (tObj->DepthMode) {
case GL_LUMINANCE:
t->format = format[0];
break;
case GL_INTENSITY:
t->format = format[1];
break;
case GL_ALPHA:
t->format = format[2];
break;
default:
/* Error...which should have already been caught by higher
* levels of Mesa.
*/
ASSERT(0);
return;
}
}
/**
* This function computes the number of bytes of storage needed for
* the given texture object (all mipmap levels, all cube faces).
@ -146,7 +215,12 @@ static void r300SetTexImages(r300ContextPtr rmesa,
*/
if (!t->image_override
&& VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
t->format = tx_table[baseImage->TexFormat->MesaFormat].format;
if (baseImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
r300SetDepthTexMode(tObj);
} else {
t->format = tx_table[baseImage->TexFormat->MesaFormat].format;
}
t->filter |= tx_table[baseImage->TexFormat->MesaFormat].filter;
} else if (!t->image_override) {
_mesa_problem(NULL, "unexpected texture format in %s",

Some files were not shown because too many files have changed in this diff Show More