Merge remote branch 'origin/master' into radeon-rewrite

This commit is contained in:
Dave Airlie 2009-04-22 21:41:57 +10:00
commit 466c78c935
234 changed files with 6851 additions and 3721 deletions

View File

@ -37,6 +37,9 @@ realclean: clean
-name depend -o -name depend.bak ')' -exec rm -f '{}' ';'
distclean: realclean
install:
@for dir in $(SUBDIRS) ; do \
if [ -d $$dir ] ; then \
@ -45,7 +48,7 @@ install:
done
.PHONY: default doxygen clean realclean install linux-directfb-install
.PHONY: default doxygen clean realclean distclean install linux-directfb-install
# If there's no current configuration file
$(TOP)/configs/current:

View File

@ -64,4 +64,4 @@ GALLIUM_WINSYS_DRM_DIRS = intel
GALLIUM_STATE_TRACKERS_DIRS = egl
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
savage sis tdfx trident unichrome ffb
savage sis tdfx trident unichrome ffb swrast

View File

@ -389,7 +389,7 @@ linux*)
;;
*freebsd* | dragonfly*)
case "$host_cpu" in
i*86|x86_64) default_driver="dri";;
i*86|x86_64|powerpc*|sparc*) default_driver="dri";;
esac
;;
esac
@ -417,19 +417,20 @@ WINDOW_SYSTEM=""
GALLIUM_DIRS="auxiliary drivers state_trackers"
GALLIUM_WINSYS_DIRS=""
GALLIUM_WINSYS_DRM_DIRS=""
GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util"
GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util indices"
GALLIUM_DRIVERS_DIRS="softpipe failover trace"
GALLIUM_STATE_TRACKERS_DIRS=""
case "$mesa_driver" in
xlib)
DRIVER_DIRS="x11"
GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib"
;;
dri)
SRC_DIRS="glx/x11 $SRC_DIRS"
DRIVER_DIRS="dri"
WINDOW_SYSTEM="dri"
GALLIUM_WINSYS_DIRS="drm $GALLIUM_WINSYS_DIRS"
GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm"
;;
osmesa)
DRIVER_DIRS="osmesa"
@ -1116,6 +1117,9 @@ no)
yes)
# look at what else is built
case "$mesa_driver" in
xlib)
GALLIUM_STATE_TRACKERS_DIRS=glx
;;
dri)
GALLIUM_STATE_TRACKERS_DIRS=egl
;;

View File

@ -58,6 +58,7 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
<li>GL_NV_texture_env_combine4 extension (software drivers, i965/i915 drivers)
<li>GL_EXT_texture_swizzle extension (software drivers, i965 driver)
<li>Updated SPARC assembly optimizations (David S. Miller)
<li>Initial support for separate compilation units in GLSL compiler.
</ul>
@ -71,6 +72,7 @@ including GL_ATI_separate_stencil, GL_EXT_stencil_two_side and OpenGL 2.0
<ul>
<li>Remove support for GL_SGIX_shadow, GL_SGIX_shadow_ambient and
GL_SGIX_depth_texture extensions. Superseded by the ARB versions.
<li>Omittd some old Mesa demos from the release tarballs, added some others.
</ul>
</body>

View File

@ -659,7 +659,7 @@ struct __DRIbufferRec {
};
#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
#define __DRI_DRI2_LOADER_VERSION 1
#define __DRI_DRI2_LOADER_VERSION 2
struct __DRIdri2LoaderExtensionRec {
__DRIextension base;
@ -667,6 +667,19 @@ struct __DRIdri2LoaderExtensionRec {
int *width, int *height,
unsigned int *attachments, int count,
int *out_count, void *loaderPrivate);
/**
* Flush pending front-buffer rendering
*
* Any rendering that has been performed to the
* \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
* \c __DRI_BUFFER_FRONT_LEFT.
*
* \param driDrawable Drawable whose front-buffer is to be flushed
* \param loaderPrivate Loader's private data that was previously passed
* into __DRIdri2ExtensionRec::createNewDrawable
*/
void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
};
/**

View File

@ -108,13 +108,6 @@ WGLAPI int GLAPIENTRY GetPixelFormat(HDC);
WGLAPI int GLAPIENTRY SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR *);
#endif
#ifndef WGL_ARB_extensions_string
#define WGL_ARB_extensions_string 1
WGLAPI const char * GLAPIENTRY wglGetExtensionsStringARB(HDC hdc);
#endif /* WGL_ARB_extensions_string */
#ifdef _MSC_VER
# pragma warning( pop )

View File

@ -5,10 +5,12 @@ bounce
clearspd
copypix
cubemap
dinoshade
drawpix
engine
extfuncs.h
fbo_firecube
fbotexture
fire
fogcoord
fplight
@ -27,11 +29,9 @@ isosurf
lodbias
morph3d
multiarb
occlude
osdemo
paltex
pixeltex
pointblast
projtex
rain
ray
readpix
@ -61,4 +61,5 @@ trispd
tunnel
tunnel2
vao_demo
Windows
winpos

View File

@ -19,9 +19,11 @@ PROGS = \
clearspd \
copypix \
cubemap \
dinoshade \
drawpix \
engine \
fbo_firecube \
fbotexture \
fire \
fogcoord \
fplight \
@ -32,9 +34,7 @@ PROGS = \
geartrain \
glinfo \
gloss \
glslnoise \
gltestperf \
glutfx \
isosurf \
ipers \
lodbias \
@ -42,6 +42,7 @@ PROGS = \
multiarb \
paltex \
pointblast \
projtex \
rain \
ray \
readpix \
@ -49,7 +50,6 @@ PROGS = \
renormal \
shadowtex \
singlebuffer \
streaming_rect \
spectex \
spriteblast \
stex3d \
@ -57,9 +57,7 @@ PROGS = \
terrain \
tessdemo \
texcyl \
texdown \
texenv \
texobj \
textures \
trispd \
tunnel \

View File

@ -39,11 +39,9 @@ progs = [
'geartrain',
'glinfo',
'gloss',
'glslnoise',
'gltestperf',
'glutfx',
'isosurf',
'ipers',
'isosurf',
'lodbias',
'morph3d',
'multiarb',
@ -55,7 +53,6 @@ progs = [
'renormal',
'shadowtex',
'singlebuffer',
'streaming_rect',
'spectex',
'spriteblast',
'stex3d',
@ -63,15 +60,16 @@ progs = [
'terrain',
'tessdemo',
'texcyl',
'texdown',
'texenv',
'texobj',
'textures',
'trispd',
'tunnel',
'tunnel2',
'vao_demo',
'winpos',
'dinoshade',
'fbotexture',
'projtex',
]
for prog in progs:

View File

@ -165,7 +165,7 @@ enum {
};
/* Create a matrix that will project the desired shadow. */
void
static void
shadowMatrix(GLfloat shadowMat[4][4],
GLfloat groundplane[4],
GLfloat lightpos[4])
@ -201,7 +201,7 @@ shadowMatrix(GLfloat shadowMat[4][4],
}
/* Find the plane equation given 3 points. */
void
static void
findPlane(GLfloat plane[4],
GLfloat v0[3], GLfloat v1[3], GLfloat v2[3])
{
@ -224,7 +224,7 @@ findPlane(GLfloat plane[4],
plane[D] = -(plane[A] * v0[X] + plane[B] * v0[Y] + plane[C] * v0[Z]);
}
void
static void
extrudeSolidFromPolygon(GLfloat data[][2], unsigned int dataSize,
GLdouble thickness, GLuint side, GLuint edge, GLuint whole)
{

View File

@ -20,11 +20,7 @@
#include <math.h>
#include <GL/glew.h>
#include <GL/glut.h>
#if 0
#include "texture.h"
#else
#include "../util/readtex.c"
#endif
#include "readtex.h"
/* Some <math.h> files do not define M_PI... */
@ -67,14 +63,15 @@ GLfloat zoomFactor = 1.0;
/*****************************************************************/
void ActiveTexture(int i)
static void
ActiveTexture(int i)
{
glActiveTextureARB(i);
}
/* matrix = identity */
void
static void
matrixIdentity(GLfloat matrix[16])
{
matrix[0] = 1.0;
@ -96,7 +93,7 @@ matrixIdentity(GLfloat matrix[16])
}
/* matrix2 = transpose(matrix1) */
void
static void
matrixTranspose(GLfloat matrix2[16], GLfloat matrix1[16])
{
matrix2[0] = matrix1[0];
@ -167,7 +164,7 @@ imgLoad(char *filenameIn, int borderIn, GLfloat borderColorIn[4],
/*****************************************************************/
/* Load the image file specified on the command line as the current texture */
void
static void
loadImageTextures(void)
{
GLfloat borderColor[4] =
@ -252,7 +249,7 @@ loadImageTextures(void)
}
/* Create a simple spotlight pattern and make it the current texture */
void
static void
loadSpotlightTexture(void)
{
static int texWidth = 64, texHeight = 64;
@ -302,7 +299,7 @@ loadSpotlightTexture(void)
/*****************************************************************/
void
static void
checkErrors(void)
{
GLenum error;
@ -311,7 +308,7 @@ checkErrors(void)
}
}
void
static void
drawCube(void)
{
glBegin(GL_QUADS);
@ -360,7 +357,7 @@ drawCube(void)
glEnd();
}
void
static void
drawDodecahedron(void)
{
#define A (0.5 * 1.61803) /* (sqrt(5) + 1) / 2 */
@ -446,7 +443,7 @@ drawDodecahedron(void)
}
}
void
static void
drawSphere(void)
{
int numMajor = 24;
@ -573,7 +570,7 @@ drawTextureProjection(void)
/*****************************************************************/
void
static void
initialize(void)
{
GLfloat light0Pos[4] =
@ -670,7 +667,7 @@ initialize(void)
}
}
void
static void
display(void)
{
int i;
@ -755,10 +752,10 @@ display(void)
/*****************************************************************/
/* simple trackball-like motion control */
float lastPos[3];
int lastTime;
static float lastPos[3];
static int lastTime;
void
static void
ptov(int x, int y, int width, int height, float v[3])
{
float d, a;
@ -774,7 +771,7 @@ ptov(int x, int y, int width, int height, float v[3])
v[2] *= a;
}
void
static void
startMotion(int x, int y, int but, int time)
{
if (but == GLUT_LEFT_BUTTON) {
@ -789,13 +786,13 @@ startMotion(int x, int y, int but, int time)
ptov(x, y, winWidth, winHeight, lastPos);
}
void
static void
animate(void)
{
glutPostRedisplay();
}
void
static void
vis(int visible)
{
if (visible == GLUT_VISIBLE) {
@ -807,7 +804,7 @@ vis(int visible)
}
}
void
static void
stopMotion(int but, int time)
{
if ((but == GLUT_LEFT_BUTTON && mode == MoveView) ||
@ -829,7 +826,7 @@ stopMotion(int but, int time)
}
}
void
static void
trackMotion(int x, int y)
{
float curPos[3], dx, dy, dz;
@ -854,7 +851,7 @@ trackMotion(int x, int y)
/*****************************************************************/
void
static void
object(void)
{
static int object;
@ -881,7 +878,7 @@ nop(void)
{
}
void
static void
texture(void)
{
static int texture = 0;
@ -912,7 +909,7 @@ texture(void)
}
}
void
static void
help(void)
{
printf("'h' - help\n");
@ -927,7 +924,7 @@ help(void)
}
/* ARGSUSED1 */
void
static void
key(unsigned char key, int x, int y)
{
switch (key) {
@ -966,7 +963,7 @@ key(unsigned char key, int x, int y)
glutPostRedisplay();
}
void
static void
mouse(int button, int state, int x, int y)
{
if (state == GLUT_DOWN)
@ -976,7 +973,7 @@ mouse(int button, int state, int x, int y)
glutPostRedisplay();
}
void
static void
reshape(int w, int h)
{
winWidth = w;
@ -985,7 +982,7 @@ reshape(int w, int h)
}
void
static void
menu(int selection)
{
if (selection == 666) {
@ -1005,6 +1002,7 @@ main(int argc, char **argv)
assert(NumTextures <= MAX_TEX);
glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE);
glutInitWindowSize(500,500);
(void) glutCreateWindow("projtex");
glewInit();

5
progs/fp/swz3.txt Normal file
View File

@ -0,0 +1,5 @@
!!ARBfp1.0
TEMP R0, R1;
MOV R0, -fragment.color;
SWZ result.color, R0, -y, -x, z, 1;
END

View File

@ -1,3 +1,4 @@
array
bitmap
brick
bump
@ -11,6 +12,7 @@ mandelbrot
multinoise
multitex
noise
noise2
pointcoord
points
readtex.c
@ -21,6 +23,7 @@ shaderutil.c
shaderutil.h
shadow_sampler
skinning
texaaline
texdemo1
toyball
trirast

View File

@ -5,46 +5,69 @@ include $(TOP)/configs/current
INCDIR = $(TOP)/include
LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME)
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 \
bump \
convolutions \
deriv \
identity \
fragcoord \
linktest \
mandelbrot \
multinoise \
multitex \
noise \
points \
pointcoord \
samplers \
samplers_array \
shadow_sampler \
skinning \
texdemo1 \
toyball \
twoside \
trirast \
vert-or-frag-only \
vert-tex
INCLUDE_DIRS = -I$(TOP)/progs/util
DEMO_SOURCES = \
array.c \
bitmap.c \
brick.c \
bump.c \
convolutions.c \
deriv.c \
fragcoord.c \
identity.c \
linktest.c \
mandelbrot.c \
multinoise.c \
multitex.c \
noise.c \
noise2.c \
pointcoord.c \
points.c \
samplers.c \
shadow_sampler.c \
skinning.c \
texaaline.c \
texdemo1.c \
toyball.c \
trirast.c \
twoside.c \
vert-or-frag-only.c \
vert-tex.c
UTIL_HEADERS = \
extfuncs.h \
shaderutil.h \
readtex.h
UTIL_SOURCES = \
shaderutil.c \
readtex.c
UTIL_OBJS = $(UTIL_SOURCES:.c=.o)
PROGS = $(DEMO_SOURCES:%.c=%)
##### RULES #####
.SUFFIXES:
.SUFFIXES: .c
# make .o file from .c file:
.c.o:
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@
# make executable from .c file:
.c: $(LIB_DEP)
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< $(LIBS) -o $@
# make executable from .o files
.o:
$(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(UTIL_OBJS) $(LIBS) -o $@
##### TARGETS #####
@ -52,188 +75,163 @@ PROGS = \
default: $(PROGS)
##### Extra dependencies
extfuncs.h: $(TOP)/progs/util/extfuncs.h
cp $< .
readtex.c: $(TOP)/progs/util/readtex.c
cp $< .
readtex.h: $(TOP)/progs/util/readtex.h
cp $< .
readtex.o: readtex.c readtex.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) readtex.c
shaderutil.c: $(TOP)/progs/util/shaderutil.c
cp $< .
shaderutil.h: $(TOP)/progs/util/shaderutil.h
cp $< .
shaderutil.o: shaderutil.c shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) shaderutil.c
bitmap.o: bitmap.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) bitmap.c
bitmap: bitmap.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bitmap.o shaderutil.o $(LIBS) -o $@
brick.o: brick.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) brick.c
brick: brick.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) brick.o shaderutil.o $(LIBS) -o $@
bump.o: bump.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) bump.c
bump: bump.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) bump.o shaderutil.o $(LIBS) -o $@
convolutions.o: convolutions.c readtex.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) convolutions.c
convolutions: convolutions.o readtex.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) convolutions.o readtex.o $(LIBS) -o $@
deriv.o: deriv.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) deriv.c
deriv: deriv.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@
identity.o: identity.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) identity.c
identity: identity.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) identity.o shaderutil.o $(LIBS) -o $@
fragcoord.o: fragcoord.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c
fragcoord: fragcoord.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@
linktest.o: linktest.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) linktest.c
linktest: linktest.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) linktest.o shaderutil.o $(LIBS) -o $@
mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c
mandelbrot: mandelbrot.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) mandelbrot.o shaderutil.o $(LIBS) -o $@
multitex.o: multitex.c extfuncs.h readtex.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) multitex.c
multitex: multitex.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) multitex.o readtex.o shaderutil.o $(LIBS) -o $@
noise.o: noise.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) noise.c
noise: noise.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) noise.o shaderutil.o $(LIBS) -o $@
points.o: points.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) points.c
points: points.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) points.o shaderutil.o $(LIBS) -o $@
pointcoord.o: pointcoord.c readtex.h extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) pointcoord.c
pointcoord: pointcoord.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) pointcoord.o readtex.o shaderutil.o $(LIBS) -o $@
samplers.o: samplers.c readtex.h extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) samplers.c
samplers: samplers.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers.o readtex.o shaderutil.o $(LIBS) -o $@
samplers_array.o: samplers.c readtex.h extfuncs.h shaderutil.h
$(APP_CC) -c -DSAMPLERS_ARRAY -I$(INCDIR) $(CFLAGS) samplers.c -o samplers_array.o
samplers_array: samplers_array.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) samplers_array.o readtex.o shaderutil.o $(LIBS) -o $@
skinning.o: skinning.c readtex.h extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) skinning.c
skinning: skinning.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) skinning.o readtex.o shaderutil.o $(LIBS) -o $@
texdemo1.o: texdemo1.c readtex.h extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) texdemo1.c
texdemo1: texdemo1.o readtex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) texdemo1.o readtex.o shaderutil.o $(LIBS) -o $@
toyball.o: toyball.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) toyball.c
toyball: toyball.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) toyball.o shaderutil.o $(LIBS) -o $@
twoside.o: twoside.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) twoside.c
twoside: twoside.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) twoside.o shaderutil.o $(LIBS) -o $@
trirast.o: trirast.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) trirast.c
trirast: trirast.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) trirast.o shaderutil.o $(LIBS) -o $@
vert-or-frag-only.o: vert-or-frag-only.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-or-frag-only.c
vert-or-frag-only: vert-or-frag-only.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-or-frag-only.o shaderutil.o $(LIBS) -o $@
vert-tex.o: vert-tex.c extfuncs.h shaderutil.h
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) vert-tex.c
vert-tex: vert-tex.o shaderutil.o
$(APP_CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) vert-tex.o shaderutil.o $(LIBS) -o $@
clean:
-rm -f $(PROGS)
-rm -f *.o *~
-rm -f extfuncs.h
-rm -f shaderutil.*
##### Extra dependencies
extfuncs.h:
cp $(TOP)/progs/util/extfuncs.h .
readtex.c:
cp $(TOP)/progs/util/readtex.c .
readtex.h:
cp $(TOP)/progs/util/readtex.h .
shaderutil.c:
cp $(TOP)/progs/util/shaderutil.c .
shaderutil.h:
cp $(TOP)/progs/util/shaderutil.h .
array.o: $(UTIL_HEADERS)
array: array.o $(UTIL_OBJS)
bitmap.o: $(UTIL_HEADERS)
bitmap: bitmap.o $(UTIL_OBJS)
brick.o: $(UTIL_HEADERS)
brick: brick.o $(UTIL_OBJS)
bump.o: $(UTIL_HEADERS)
bump: bump.o $(UTIL_OBJS)
convolutions.o: $(UTIL_HEADERS)
convolutions: convolutions.o $(UTIL_OBJS)
deriv.o: deriv.c $(UTIL_HEADERS)
deriv: deriv.o $(UTIL_OBJS)
identity.o: $(UTIL_HEADERS)
identity: identity.o $(UTIL_OBJS)
fragcoord.o: $(UTIL_HEADERS)
fragcoord: fragcoord.o $(UTIL_OBJS)
linktest.o: $(UTIL_HEADERS)
linktest: linktest.o $(UTIL_OBJS)
mandelbrot.o: $(UTIL_HEADERS)
mandelbrot: mandelbrot.o $(UTIL_OBJS)
multinoise.o: $(UTIL_HEADERS)
multinoise: multinoise.o $(UTIL_OBJS)
multitex.o: $(UTIL_HEADERS)
multitex: multitex.o $(UTIL_OBJS)
noise.o: $(UTIL_HEADERS)
noise: noise.o $(UTIL_OBJS)
noise2.o: $(UTIL_HEADERS)
noise2: noise2.o $(UTIL_OBJS)
points.o: $(UTIL_HEADERS)
points: points.o $(UTIL_OBJS)
pointcoord.o: $(UTIL_HEADERS)
pointcoord: pointcoord.o $(UTIL_OBJS)
samplers.o: $(UTIL_HEADERS)
samplers: samplers.o $(UTIL_OBJS)
samplers_array.o: $(UTIL_HEADERS)
samplers_array: samplers_array.o $(UTIL_OBJS)
shadow_sampler.o: $(UTIL_HEADERS)
shadow_sampler: shadow_sampler.o $(UTIL_OBJS)
skinning.o: $(UTIL_HEADERS)
skinning: skinning.o $(UTIL_OBJS)
texaaline.o: $(UTIL_HEADERS)
texaaline: texaaline.o $(UTIL_OBJS)
texdemo1.o: $(UTIL_HEADERS)
texdemo1: texdemo1.o $(UTIL_OBJS)
toyball.o: $(UTIL_HEADERS)
toyball: toyball.o $(UTIL_OBJS)
twoside.o: $(UTIL_HEADERS)
twoside: twoside.o $(UTIL_OBJS)
trirast.o: $(UTIL_HEADERS)
trirast: trirast.o $(UTIL_OBJS)
vert-or-frag-only.o: $(UTIL_HEADERS)
vert-or-frag-only: vert-or-frag-only.o $(UTIL_OBJS)
vert-tex.o: $(UTIL_HEADERS)
vert-tex: vert-tex.o $(UTIL_OBJS)

261
progs/glsl/array.c Normal file
View File

@ -0,0 +1,261 @@
/**
* Test variable array indexing in a vertex shader.
* Brian Paul
* 17 April 2009
*/
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include "extfuncs.h"
#include "shaderutil.h"
/**
* The vertex position.z is used as a (variable) index into an
* array which returns a new Z value.
*/
static const char *VertShaderText =
"uniform sampler2D tex1; \n"
"uniform float HeightArray[20]; \n"
"void main() \n"
"{ \n"
" vec4 pos = gl_Vertex; \n"
" int i = int(pos.z * 9.5); \n"
" pos.z = HeightArray[i]; \n"
" gl_Position = gl_ModelViewProjectionMatrix * pos; \n"
" gl_FrontColor = pos; \n"
"} \n";
static const char *FragShaderText =
"void main() \n"
"{ \n"
" gl_FragColor = gl_Color; \n"
"} \n";
static GLuint fragShader;
static GLuint vertShader;
static GLuint program;
static GLint win = 0;
static GLboolean Anim = GL_TRUE;
static GLboolean WireFrame = GL_TRUE;
static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f;
static void
Idle(void)
{
zRot = 90 + glutGet(GLUT_ELAPSED_TIME) * 0.05;
glutPostRedisplay();
}
/** z=f(x,y) */
static float
fz(float x, float y)
{
return fabs(cos(1.5*x) + cos(1.5*y));
}
static void
DrawMesh(void)
{
GLfloat xmin = -2.0, xmax = 2.0;
GLfloat ymin = -2.0, ymax = 2.0;
GLuint xdivs = 20, ydivs = 20;
GLfloat dx = (xmax - xmin) / xdivs;
GLfloat dy = (ymax - ymin) / ydivs;
GLfloat ds = 1.0 / xdivs, dt = 1.0 / ydivs;
GLfloat x, y, s, t;
GLuint i, j;
y = ymin;
t = 0.0;
for (i = 0; i < ydivs; i++) {
x = xmin;
s = 0.0;
glBegin(GL_QUAD_STRIP);
for (j = 0; j < xdivs; j++) {
float z0 = fz(x, y), z1 = fz(x, y + dy);
glTexCoord2f(s, t);
glVertex3f(x, y, z0);
glTexCoord2f(s, t + dt);
glVertex3f(x, y + dy, z1);
x += dx;
s += ds;
}
glEnd();
y += dy;
t += dt;
}
}
static void
Redisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (WireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
else
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glPushMatrix();
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
glPushMatrix();
DrawMesh();
glPopMatrix();
glPopMatrix();
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glutSwapBuffers();
}
static void
Reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -15.0f);
}
static void
CleanUp(void)
{
glDeleteShader_func(fragShader);
glDeleteShader_func(vertShader);
glDeleteProgram_func(program);
glutDestroyWindow(win);
}
static void
Key(unsigned char key, int x, int y)
{
const GLfloat step = 2.0;
(void) x;
(void) y;
switch(key) {
case 'a':
Anim = !Anim;
if (Anim)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'w':
WireFrame = !WireFrame;
break;
case 'z':
zRot += step;
break;
case 'Z':
zRot -= step;
break;
case 27:
CleanUp();
exit(0);
break;
}
glutPostRedisplay();
}
static void
SpecialKey(int key, int x, int y)
{
const GLfloat step = 2.0;
(void) x;
(void) y;
switch(key) {
case GLUT_KEY_UP:
xRot += step;
break;
case GLUT_KEY_DOWN:
xRot -= step;
break;
case GLUT_KEY_LEFT:
yRot -= step;
break;
case GLUT_KEY_RIGHT:
yRot += step;
break;
}
glutPostRedisplay();
}
static void
Init(void)
{
GLfloat HeightArray[20];
GLint u, i;
if (!ShadersSupported())
exit(1);
GetExtensionFuncs();
vertShader = CompileShaderText(GL_VERTEX_SHADER, VertShaderText);
fragShader = CompileShaderText(GL_FRAGMENT_SHADER, FragShaderText);
program = LinkShaders(vertShader, fragShader);
glUseProgram_func(program);
/* Setup the HeightArray[] uniform */
for (i = 0; i < 20; i++)
HeightArray[i] = i / 20.0;
u = glGetUniformLocation_func(program, "HeightArray");
glUniform1fv_func(u, 20, HeightArray);
assert(glGetError() == 0);
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
glEnable(GL_DEPTH_TEST);
glColor3f(1, 1, 1);
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowSize(500, 500);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Redisplay);
Init();
if (Anim)
glutIdleFunc(Idle);
glutMainLoop();
return 0;
}

View File

@ -150,10 +150,11 @@ Redisplay(void)
static void
Reshape(int width, int height)
{
float ar = (float) width / (float) height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
glFrustum(-ar, ar, -1.0, 1.0, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -15.0f);

View File

@ -242,7 +242,7 @@ int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition( 0, 0);
glutInitWindowSize(300, 300);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
Win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);

369
progs/glsl/texaaline.c Normal file
View File

@ -0,0 +1,369 @@
/**
* AA lines with texture mapped quads
*
* Brian Paul
* 9 Feb 2008
*/
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include "extfuncs.h"
static GLint WinWidth = 300, WinHeight = 300;
static GLint win = 0;
static GLfloat Width = 8.;
/*
* Quad strip for line from v0 to v1:
*
1 3 5 7
+---+---------------------+---+
| |
| *v0 v1* |
| |
+---+---------------------+---+
0 2 4 6
*/
static void
QuadLine(const GLfloat *v0, const GLfloat *v1, GLfloat width)
{
GLfloat dx = v1[0] - v0[0];
GLfloat dy = v1[1] - v0[1];
GLfloat len = sqrt(dx*dx + dy*dy);
float dx0, dx1, dx2, dx3, dx4, dx5, dx6, dx7;
float dy0, dy1, dy2, dy3, dy4, dy5, dy6, dy7;
dx /= len;
dy /= len;
width *= 0.5; /* half width */
dx = dx * (width + 0.0);
dy = dy * (width + 0.0);
dx0 = -dx+dy; dy0 = -dy-dx;
dx1 = -dx-dy; dy1 = -dy+dx;
dx2 = 0+dy; dy2 = -dx+0;
dx3 = 0-dy; dy3 = +dx+0;
dx4 = 0+dy; dy4 = -dx+0;
dx5 = 0-dy; dy5 = +dx+0;
dx6 = dx+dy; dy6 = dy-dx;
dx7 = dx-dy; dy7 = dy+dx;
/*
printf("dx, dy = %g, %g\n", dx, dy);
printf(" dx0, dy0: %g, %g\n", dx0, dy0);
printf(" dx1, dy1: %g, %g\n", dx1, dy1);
printf(" dx2, dy2: %g, %g\n", dx2, dy2);
printf(" dx3, dy3: %g, %g\n", dx3, dy3);
*/
glBegin(GL_QUAD_STRIP);
glTexCoord2f(0, 0);
glVertex2f(v0[0] + dx0, v0[1] + dy0);
glTexCoord2f(0, 1);
glVertex2f(v0[0] + dx1, v0[1] + dy1);
glTexCoord2f(0.5, 0);
glVertex2f(v0[0] + dx2, v0[1] + dy2);
glTexCoord2f(0.5, 1);
glVertex2f(v0[0] + dx3, v0[1] + dy3);
glTexCoord2f(0.5, 0);
glVertex2f(v1[0] + dx2, v1[1] + dy2);
glTexCoord2f(0.5, 1);
glVertex2f(v1[0] + dx3, v1[1] + dy3);
glTexCoord2f(1, 0);
glVertex2f(v1[0] + dx6, v1[1] + dy6);
glTexCoord2f(1, 1);
glVertex2f(v1[0] + dx7, v1[1] + dy7);
glEnd();
}
static float Cos(float a)
{
return cos(a * M_PI / 180.);
}
static float Sin(float a)
{
return sin(a * M_PI / 180.);
}
static void
Redisplay(void)
{
int i;
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1, 1, 1);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
for (i = 0; i < 360; i+=5) {
float v0[2], v1[2];
v0[0] = 150 + 40 * Cos(i);
v0[1] = 150 + 40 * Sin(i);
v1[0] = 150 + 130 * Cos(i);
v1[1] = 150 + 130 * Sin(i);
QuadLine(v0, v1, Width);
}
{
float v0[2], v1[2], x;
for (x = 0; x < 1.0; x += 0.2) {
v0[0] = 150 + x;
v0[1] = 150 + x * 40 - 20;
v1[0] = 150 + x + 5.0;
v1[1] = 150 + x * 40 - 20;
QuadLine(v0, v1, Width);
}
}
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
glutSwapBuffers();
}
static void
Reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, width, 0, height, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
CleanUp(void)
{
glutDestroyWindow(win);
}
static void
Key(unsigned char key, int x, int y)
{
(void) x;
(void) y;
switch(key) {
case 'w':
Width -= 0.5;
break;
case 'W':
Width += 0.5;
break;
case 27:
CleanUp();
exit(0);
break;
}
#if 0
if (Width < 3)
Width = 3;
#endif
printf("Width = %g\n", Width);
glutPostRedisplay();
}
static float
ramp4(GLint i, GLint size)
{
float d;
if (i < 4 ) {
d = i / 4.0;
}
else if (i >= size - 5) {
d = 1.0 - (i - (size - 5)) / 4.0;
}
else {
d = 1.0;
}
return d;
}
static float
ramp2(GLint i, GLint size)
{
float d;
if (i < 2 ) {
d = i / 2.0;
}
else if (i >= size - 3) {
d = 1.0 - (i - (size - 3)) / 2.0;
}
else {
d = 1.0;
}
return d;
}
static float
ramp1(GLint i, GLint size)
{
float d;
if (i == 0 || i == size-1) {
d = 0.0;
}
else {
d = 1.0;
}
return d;
}
/**
* Make an alpha texture for antialiasing lines.
* Just a linear fall-off ramp for now.
* Should have a number of different textures for different line widths.
* Could try a bell-like-curve....
*/
static void
MakeTexture(void)
{
#define SZ 8
GLfloat tex[SZ][SZ]; /* alpha tex */
int i, j;
for (i = 0; i < SZ; i++) {
for (j = 0; j < SZ; j++) {
#if 0
float k = (SZ-1) / 2.0;
float dx = fabs(i - k) / k;
float dy = fabs(j - k) / k;
float d;
dx = 1.0 - dx;
dy = 1.0 - dy;
d = dx * dy;
#else
float d = ramp1(i, SZ) * ramp1(j, SZ);
printf("%d, %d: %g\n", i, j, d);
#endif
tex[i][j] = d;
}
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, SZ, SZ, 0, GL_ALPHA, GL_FLOAT, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#undef SZ
}
static void
MakeMipmap(void)
{
#define SZ 64
GLfloat tex[SZ][SZ]; /* alpha tex */
int level;
glPixelStorei(GL_UNPACK_ROW_LENGTH, SZ);
for (level = 0; level < 7; level++) {
int sz = 1 << (6 - level);
int i, j;
for (i = 0; i < sz; i++) {
for (j = 0; j < sz; j++) {
if (level == 6)
tex[i][j] = 1.0;
else if (level == 5)
tex[i][j] = 0.5;
else
tex[i][j] = ramp1(i, sz) * ramp1(j, sz);
}
}
glTexImage2D(GL_TEXTURE_2D, level, GL_ALPHA,
sz, sz, 0, GL_ALPHA, GL_FLOAT, tex);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4);
////glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#undef SZ
}
static void
Init(void)
{
const char *version;
(void) MakeTexture;
(void) ramp4;
(void) ramp2;
version = (const char *) glGetString(GL_VERSION);
if (version[0] != '2' || version[1] != '.') {
printf("This program requires OpenGL 2.x, found %s\n", version);
exit(1);
}
GetExtensionFuncs();
glClearColor(0.3f, 0.3f, 0.3f, 0.0f);
printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER));
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
#if 0
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
#elif 0
MakeTexture();
#else
MakeMipmap();
#endif
}
static void
ParseOptions(int argc, char *argv[])
{
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition( 0, 0);
glutInitWindowSize(WinWidth, WinHeight);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Redisplay);
ParseOptions(argc, argv);
Init();
glutMainLoop();
return 0;
}

View File

@ -100,7 +100,7 @@ static void PrintColorStrings( void )
{
GLubyte ubbuf[3];
int i, xleft, xright;
char colorString[18];
char colorString[100];
xleft = 5 + windW/4;
xright = 5 + windW/2;

View File

@ -37,19 +37,18 @@ SOURCES = \
copypixrate.c \
crossbar.c \
cva.c \
dinoshade.c \
drawbuffers.c \
exactrast.c \
floattex.c \
fbotest1.c \
fbotest2.c \
fbotexture.c \
fillrate.c \
fog.c \
fogcoord.c \
fptest1.c \
fptexture.c \
getprocaddress.c \
glutfx \
interleave.c \
invert.c \
jkrahntest.c \
@ -66,7 +65,6 @@ SOURCES = \
packedpixels.c \
pbo.c \
prog_parameter.c \
projtex.c \
quads.c \
random.c \
readrate.c \
@ -77,12 +75,15 @@ SOURCES = \
stencil_twoside.c \
stencilwrap.c \
stencil_wrap.c \
streaming_rect \
subtex \
subtexrate.c \
tex1d.c \
texcompress2.c \
texdown \
texfilt.c \
texline.c \
texobj.c \
texobjshare.c \
texrect.c \
texwrap.c \
@ -201,10 +202,10 @@ fillrate.o: fillrate.c readtex.h
floattex: floattex.o readtex.o shaderutil.o
$(CC) $(CFLAGS) $(LDFLAGS) floattex.o readtex.o shaderutil.o $(LIBS) -o $@
$(APP_CC) $(CFLAGS) $(LDFLAGS) floattex.o readtex.o shaderutil.o $(LIBS) -o $@
floattex.o: floattex.c readtex.h shaderutil.h
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) floattex.c -o $@
$(APP_CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) floattex.c -o $@
readtex.o: readtex.c
@ -230,7 +231,7 @@ shaderutil.h: $(TOP)/progs/util/shaderutil.h
cp $< .
shaderutil.o: shaderutil.c shaderutil.h
$(CC) -c -I$(INCDIR) $(CFLAGS) shaderutil.c
$(APP_CC) -c -I$(INCDIR) $(INCLUDES) $(CFLAGS) shaderutil.c

View File

@ -42,8 +42,8 @@ progs = [
'arbfptest1',
'arbfptexture',
'arbfptrig',
'arbnpot-mipmap',
'arbnpot',
'arbnpot-mipmap',
'arbvptest1',
'arbvptest3',
'arbvptorus',
@ -61,19 +61,18 @@ progs = [
'copypixrate',
'crossbar',
'cva',
'dinoshade',
'drawbuffers',
'exactrast',
'ext422square',
'fbotest1',
'fbotest2',
'fbotexture',
'fillrate',
'floattex',
'fog',
'fogcoord',
'fptest1',
'fptexture',
'glutfx',
'interleave',
'invert',
'lineclip',
@ -91,7 +90,6 @@ progs = [
'packedpixels',
'pbo',
'prog_parameter',
'projtex',
'quads',
'random',
'readrate',
@ -101,14 +99,17 @@ progs = [
'stencil_twoside',
'stencil_wrap',
'stencilwrap',
'streaming_rect',
'subtex',
'subtexrate',
'tex1d',
'texcmp',
'texcompress2',
'texdown',
'texfilt',
'texgenmix',
'texline',
'texobj',
'texrect',
'texwrap',
'unfilledclip',

View File

@ -442,8 +442,8 @@ int main( int argc, char *argv[] )
glutInitWindowSize( 300, 300 );
glutInitWindowPosition( 0, 0 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glewInit();
glutCreateWindow(argv[0] );
glewInit();
Init( argc, argv );

View File

@ -45,7 +45,7 @@ int main(int argc, char **argv)
if (argc < 2) {
fprintf(stderr, "This program tests GLX context switching.\n");
fprintf(stderr, "Usage: cxbug <n>\n");
fprintf(stderr, "Usage: jkrahntest <n>\n");
fprintf(stderr, "Where n is:\n");
fprintf(stderr, "\t1) Use two contexts and swap only when the context is current (typical case).\n");
fprintf(stderr, "\t2) Use two contexts and swap at the same time.\n");

View File

@ -22,6 +22,7 @@ static int TexWidth = 256, TexHeight = 256;
static int WinWidth = 1044, WinHeight = 900;
static GLfloat Bias = 0.0;
static GLboolean ScaleQuads = GL_FALSE;
static GLboolean Linear = GL_FALSE;
static GLint Win = 0;
@ -53,6 +54,15 @@ Display(void)
glColor3f(1,1,1);
if (Linear) {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
else {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
y = WinHeight - 300;
x = 4;
@ -132,6 +142,9 @@ Key(unsigned char key, int x, int y)
case 'B':
Bias += 10;
break;
case 'l':
Linear = !Linear;
break;
case '0':
case '1':
case '2':
@ -222,8 +235,6 @@ Init(void)
/* mipmapping required for this extension */
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glGetFloatv(GL_MAX_TEXTURE_LOD_BIAS_EXT, &maxBias);

View File

@ -321,10 +321,18 @@ static void run_test(const char *name, void (*callback)(void))
int main(int argc, char **argv)
{
const char *version;
glutInit(&argc, argv);
glutCreateWindow("Mesa bug demo");
glewInit();
version = (const char *) glGetString(GL_VERSION);
if (version[0] == '1') {
printf("Sorry, this test requires OpenGL 2.x GLSL support\n");
exit(0);
}
RUN_TEST(test_uniform_size_type);
RUN_TEST(test_attrib_size_type);
RUN_TEST(test_uniform_array_overflow);

View File

@ -51,7 +51,6 @@ TestSubTex(void)
GLboolean all = 0*GL_TRUE;
GLubyte *buffer;
GLint size, fmt;
int i;
glGetTexLevelParameteriv(Target, 0,
GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB, &size);
@ -82,6 +81,23 @@ TestSubTex(void)
}
static void
TestGetTex(void)
{
GLubyte *buffer;
buffer = (GLubyte *) malloc(3 * ImgWidth * ImgHeight);
glGetTexImage(GL_TEXTURE_2D,
0,
GL_RGB,
GL_UNSIGNED_BYTE,
buffer);
free(buffer);
}
static void
LoadCompressedImage(const char *file)
{
@ -146,7 +162,10 @@ LoadCompressedImage(const char *file)
glTexParameteri(Target, GL_TEXTURE_MIN_FILTER, filter);
glTexParameteri(Target, GL_TEXTURE_MAG_FILTER, filter);
TestSubTex();
if (0)
TestSubTex();
else
TestGetTex();
}

View File

@ -280,9 +280,9 @@ int main(int argc, char **argv)
glutInitWindowPosition(0, 0);
glutInitWindowSize(400, 400);
if (glutCreateWindow("Isosurface") <= 0) {
glewInit();
exit(0);
}
glewInit();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);

View File

@ -128,7 +128,7 @@ static void Init( void )
glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 1,
strlen(prog1),
(const GLubyte *) prog1);
assert(!glIsProgramNV(1));
assert(glIsProgramNV(1));
glLoadProgramNV(GL_VERTEX_PROGRAM_NV, 2,
strlen(prog2),

View File

@ -29,6 +29,20 @@
GLenum doubleBuffer = 1;
int win;
static float tx = 0;
static float ty = 0;
static float tw = 0;
static float th = 0;
static float z = -5;
static float win_width = 250;
static float win_height = 250;
static enum {
ORTHO,
FRUSTUM,
MODE_MAX
} mode = ORTHO;
static void Init(void)
{
@ -37,44 +51,195 @@ static void Init(void)
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
fflush(stderr);
glClearColor(0.3, 0.1, 0.3, 0.0);
glClearColor(0, 0, 0, 0.0);
}
static void Reshape(int width, int height)
{
glViewport(width / -2.0, height / -2.0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
win_width = width;
win_height = height;
glutPostRedisplay();
}
static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
default:
glutPostRedisplay();
return;
case 27:
exit(0);
case 'w':
tw += 1.0;
break;
case 'W':
tw -= 1.0;
break;
case 'h':
th += 1.0;
break;
case 'H':
th -= 1.0;
break;
case 'z':
z += 1.0;
break;
case 'Z':
z -= 1.0;
break;
case 'm':
mode++;
mode %= MODE_MAX;
break;
case ' ':
tw = th = tx = ty = 0;
z = -5;
mode = ORTHO;
break;
default:
break;
}
glutPostRedisplay();
}
static void Draw(void)
{
int i;
float w = tw + win_width;
float h = th + win_height;
fprintf(stderr, "glViewport(%f %f %f %f)\n", tx, ty, w, h);
fprintf(stderr, "mode: %s\n", mode == FRUSTUM ? "FRUSTUM" : "ORTHO");
fprintf(stderr, "z: %f\n", z);
fflush(stderr);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
switch (mode) {
case FRUSTUM:
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
break;
case ORTHO:
default:
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
break;
}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glColor3f(.8,0,0);
glVertex3f(-0.9, 0.9, -30.0);
glColor3f(0,.9,0);
glVertex3f( 0.9, 0.9, -30.0);
glColor3f(0,0,.7);
glVertex3f( 0.0, -0.9, -30.0);
/***********************************************************************
* Should be clipped to be no larger than the triangles:
*/
glViewport(tx, ty, w, h);
glBegin(GL_POLYGON);
glColor3f(1,1,0);
glVertex3f(-100, -100, z);
glVertex3f(-100, 100, z);
glVertex3f(100, 100, z);
glVertex3f(100, -100, z);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0,1,1);
glVertex3f(-10, -10, z);
glVertex3f(-10, 10, z);
glVertex3f(10, 10, z);
glVertex3f(10, -10, z);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1,0,0);
glVertex3f(-2, -2, z);
glVertex3f(-2, 2, z);
glVertex3f(2, 2, z);
glVertex3f(2, -2, z);
glEnd();
glBegin(GL_POLYGON);
glColor3f(.5,.5,1);
glVertex3f(-1, -1, z);
glVertex3f(-1, 1, z);
glVertex3f(1, 1, z);
glVertex3f(1, -1, z);
glEnd();
/***********************************************************************
*/
glViewport(0, 0, win_width, win_height);
glBegin(GL_LINES);
glColor3f(1,1,0);
glVertex3f(-1, 0, z);
glVertex3f(1, 0, z);
glVertex3f(0, -1, z);
glVertex3f(0, 1, z);
glEnd();
/***********************************************************************
*/
glViewport(tx, ty, w, h);
glBegin(GL_TRIANGLES);
glColor3f(1,0,0);
glVertex3f(-1, -1, z);
glVertex3f(0, -1, z);
glVertex3f(-.5, -.5, z);
glColor3f(1,1,1);
glVertex3f(0, -1, z);
glVertex3f(1, -1, z);
glVertex3f(.5, -.5, z);
glVertex3f(-.5, -.5, z);
glVertex3f(.5, -.5, z);
glVertex3f(0, 0, z);
glColor3f(0,1,0);
glVertex3f(1, 1, z);
glVertex3f(0, 1, z);
glVertex3f(.5, .5, z);
glColor3f(1,1,1);
glVertex3f(0, 1, z);
glVertex3f(-1, 1, z);
glVertex3f(-.5, .5, z);
glVertex3f(.5, .5, z);
glVertex3f(-.5, .5, z);
glVertex3f( 0, 0, z);
glEnd();
glViewport(0, 0, win_width, win_height);
glBegin(GL_LINES);
glColor3f(.5,.5,0);
for (i = -10; i < 10; i++) {
float f = i / 10.0;
if (i == 0)
continue;
glVertex3f(-1, f, z);
glVertex3f(1, f, z);
glVertex3f(f, -1, z);
glVertex3f(f, 1, z);
}
glEnd();
glFlush();
if (doubleBuffer) {
@ -86,6 +251,13 @@ static GLenum Args(int argc, char **argv)
{
GLint i;
if (getenv("VPX"))
tx = atof(getenv("VPX"));
if (getenv("VPY"))
ty = atof(getenv("VPY"));
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
doubleBuffer = GL_FALSE;
@ -99,6 +271,30 @@ static GLenum Args(int argc, char **argv)
return GL_TRUE;
}
static void
special(int k, int x, int y)
{
switch (k) {
case GLUT_KEY_UP:
ty += 1.0;
break;
case GLUT_KEY_DOWN:
ty -= 1.0;
break;
case GLUT_KEY_LEFT:
tx -= 1.0;
break;
case GLUT_KEY_RIGHT:
tx += 1.0;
break;
default:
break;
}
glutPostRedisplay();
}
int main(int argc, char **argv)
{
GLenum type;
@ -123,7 +319,8 @@ int main(int argc, char **argv)
Init();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutKeyboardFunc(Key);
glutSpecialFunc(special);
glutDisplayFunc(Draw);
glutMainLoop();
return 0;

View File

@ -21,3 +21,5 @@ for prog in progs:
target = prog,
source = prog + '/' + prog + '.c',
)
env.Program('wglinfo', ['wglinfo.c'])

737
progs/wgl/wglinfo.c Normal file
View File

@ -0,0 +1,737 @@
/*
* Copyright (C) 2009 VMware, Inc.
* Copyright (C) 1999-2006 Brian Paul
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* This program is a work-alike of the GLX glxinfo program.
* Command line options:
* -t print wide table
* -v print verbose information
* -b only print ID of "best" visual on screen 0
* -l print interesting OpenGL limits (added 5 Sep 2002)
*/
#include <windows.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/wglext.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef enum
{
Normal,
Wide,
Verbose
} InfoMode;
/*
* Print a list of extensions, with word-wrapping.
*/
static void
print_extension_list(const char *ext)
{
const char *indentString = " ";
const int indent = 4;
const int max = 79;
int width, i, j;
if (!ext || !ext[0])
return;
width = indent;
printf(indentString);
i = j = 0;
while (1) {
if (ext[j] == ' ' || ext[j] == 0) {
/* found end of an extension name */
const int len = j - i;
if (width + len > max) {
/* start a new line */
printf("\n");
width = indent;
printf(indentString);
}
/* print the extension name between ext[i] and ext[j] */
while (i < j) {
printf("%c", ext[i]);
i++;
}
/* either we're all done, or we'll continue with next extension */
width += len + 1;
if (ext[j] == 0) {
break;
}
else {
i++;
j++;
if (ext[j] == 0)
break;
printf(", ");
width += 2;
}
}
j++;
}
printf("\n");
}
/**
* Print interesting limits for vertex/fragment programs.
*/
static void
print_program_limits(GLenum target)
{
#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program)
struct token_name {
GLenum token;
const char *name;
};
static const struct token_name limits[] = {
{ GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" },
{ GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" },
{ GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" },
{ GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" },
{ GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" },
{ GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" },
{ GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" },
{ GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" },
{ GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" },
{ GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" },
{ GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" },
{ GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" },
{ GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" },
{ GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" },
{ GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" },
{ GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" },
{ GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" },
{ GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" },
{ (GLenum) 0, NULL }
};
PFNGLGETPROGRAMIVARBPROC GetProgramivARB_func = (PFNGLGETPROGRAMIVARBPROC)
wglGetProcAddress("glGetProgramivARB");
GLint max[1];
int i;
if (target == GL_VERTEX_PROGRAM_ARB) {
printf(" GL_VERTEX_PROGRAM_ARB:\n");
}
else if (target == GL_FRAGMENT_PROGRAM_ARB) {
printf(" GL_FRAGMENT_PROGRAM_ARB:\n");
}
else {
return; /* something's wrong */
}
for (i = 0; limits[i].token; i++) {
GetProgramivARB_func(target, limits[i].token, max);
if (glGetError() == GL_NO_ERROR) {
printf(" %s = %d\n", limits[i].name, max[0]);
}
}
#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */
}
/**
* Print interesting limits for vertex/fragment shaders.
*/
static void
print_shader_limits(GLenum target)
{
struct token_name {
GLenum token;
const char *name;
};
#if defined(GL_ARB_vertex_shader)
static const struct token_name vertex_limits[] = {
{ GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" },
{ GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" },
{ GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" },
{ GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
{ GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" },
{ GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" },
{ GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
{ (GLenum) 0, NULL }
};
#endif
#if defined(GL_ARB_fragment_shader)
static const struct token_name fragment_limits[] = {
{ GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" },
{ GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" },
{ GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" },
{ (GLenum) 0, NULL }
};
#endif
GLint max[1];
int i;
#if defined(GL_ARB_vertex_shader)
if (target == GL_VERTEX_SHADER_ARB) {
printf(" GL_VERTEX_SHADER_ARB:\n");
for (i = 0; vertex_limits[i].token; i++) {
glGetIntegerv(vertex_limits[i].token, max);
if (glGetError() == GL_NO_ERROR) {
printf(" %s = %d\n", vertex_limits[i].name, max[0]);
}
}
}
#endif
#if defined(GL_ARB_fragment_shader)
if (target == GL_FRAGMENT_SHADER_ARB) {
printf(" GL_FRAGMENT_SHADER_ARB:\n");
for (i = 0; fragment_limits[i].token; i++) {
glGetIntegerv(fragment_limits[i].token, max);
if (glGetError() == GL_NO_ERROR) {
printf(" %s = %d\n", fragment_limits[i].name, max[0]);
}
}
}
#endif
}
/**
* Print interesting OpenGL implementation limits.
*/
static void
print_limits(const char *extensions)
{
struct token_name {
GLuint count;
GLenum token;
const char *name;
};
static const struct token_name limits[] = {
{ 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH" },
{ 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH" },
{ 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES" },
{ 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH" },
{ 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES" },
{ 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES" },
{ 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER" },
{ 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS" },
{ 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING" },
{ 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH" },
{ 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH" },
{ 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE" },
{ 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH" },
{ 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH" },
{ 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE" },
{ 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE" },
{ 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS" },
{ 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE" },
{ 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE" },
{ 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE" },
{ 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE" },
#if defined(GL_ARB_texture_cube_map)
{ 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB" },
#endif
#if defined(GLX_NV_texture_rectangle)
{ 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV" },
#endif
#if defined(GL_ARB_texture_compression)
{ 1, GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB, "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB" },
#endif
#if defined(GL_ARB_multitexture)
{ 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB" },
#endif
#if defined(GL_EXT_texture_lod_bias)
{ 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT" },
#endif
#if defined(GL_EXT_texture_filter_anisotropic)
{ 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT" },
#endif
#if defined(GL_ARB_draw_buffers)
{ 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB" },
#endif
{ 0, (GLenum) 0, NULL }
};
GLint i, max[2];
printf("OpenGL limits:\n");
for (i = 0; limits[i].count; i++) {
glGetIntegerv(limits[i].token, max);
if (glGetError() == GL_NO_ERROR) {
if (limits[i].count == 1)
printf(" %s = %d\n", limits[i].name, max[0]);
else /* XXX fix if we ever query something with more than 2 values */
printf(" %s = %d, %d\n", limits[i].name, max[0], max[1]);
}
}
#if defined(GL_EXT_convolution)
{
PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC glGetConvolutionParameterivEXT_func =
(PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC)wglGetProcAddress("glGetConvolutionParameterivEXT");
if(glGetConvolutionParameterivEXT_func) {
/* these don't fit into the above mechanism, unfortunately */
glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_WIDTH, max);
glGetConvolutionParameterivEXT_func(GL_CONVOLUTION_2D, GL_MAX_CONVOLUTION_HEIGHT, max+1);
if (glGetError() == GL_NONE) {
printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]);
}
}
}
#endif
#if defined(GL_ARB_vertex_program)
if (strstr(extensions, "GL_ARB_vertex_program")) {
print_program_limits(GL_VERTEX_PROGRAM_ARB);
}
#endif
#if defined(GL_ARB_fragment_program)
if (strstr(extensions, "GL_ARB_fragment_program")) {
print_program_limits(GL_FRAGMENT_PROGRAM_ARB);
}
#endif
#if defined(GL_ARB_vertex_shader)
if (strstr(extensions, "GL_ARB_vertex_shader")) {
print_shader_limits(GL_VERTEX_SHADER_ARB);
}
#endif
#if defined(GL_ARB_fragment_shader)
if (strstr(extensions, "GL_ARB_fragment_shader")) {
print_shader_limits(GL_FRAGMENT_SHADER_ARB);
}
#endif
}
static LRESULT CALLBACK
WndProc(HWND hWnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam )
{
switch (uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
static void
print_screen_info(HDC _hdc, GLboolean limits)
{
WNDCLASS wc;
HWND win;
HGLRC ctx;
int visinfo;
int width = 100, height = 100;
HDC hdc;
PIXELFORMATDESCRIPTOR pfd;
memset(&wc, 0, sizeof wc);
wc.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wc.lpfnWndProc = WndProc;
wc.lpszClassName = "wglinfo";
wc.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wc);
win = CreateWindowEx(0,
wc.lpszClassName,
"wglinfo",
WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
CW_USEDEFAULT,
CW_USEDEFAULT,
width,
height,
NULL,
NULL,
wc.hInstance,
NULL);
if (!win) {
fprintf(stderr, "Couldn't create window");
exit(1);
}
hdc = GetDC(win);
if (!hdc) {
fprintf(stderr, "Couldn't obtain HDC");
return;
}
pfd.cColorBits = 3;
pfd.cRedBits = 1;
pfd.cGreenBits = 1;
pfd.cBlueBits = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;
pfd.iLayerType = PFD_MAIN_PLANE;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
visinfo = ChoosePixelFormat(hdc, &pfd);
if (!visinfo) {
pfd.dwFlags |= PFD_DOUBLEBUFFER;
visinfo = ChoosePixelFormat(hdc, &pfd);
}
if (!visinfo) {
fprintf(stderr, "Error: couldn't find RGB WGL visual\n");
return;
}
SetPixelFormat(hdc, visinfo, &pfd);
ctx = wglCreateContext(hdc);
if (!ctx) {
fprintf(stderr, "Error: wglCreateContext failed\n");
return;
}
if (wglMakeCurrent(hdc, ctx)) {
#if defined(WGL_ARB_extensions_string)
PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB_func =
(PFNWGLGETEXTENSIONSSTRINGARBPROC)wglGetProcAddress("wglGetExtensionsStringARB");
#endif
const char *glVendor = (const char *) glGetString(GL_VENDOR);
const char *glRenderer = (const char *) glGetString(GL_RENDERER);
const char *glVersion = (const char *) glGetString(GL_VERSION);
const char *glExtensions = (const char *) glGetString(GL_EXTENSIONS);
#if defined(WGL_ARB_extensions_string)
if(wglGetExtensionsStringARB_func) {
const char *wglExtensions = wglGetExtensionsStringARB_func(hdc);
if(wglExtensions) {
printf("WGL extensions:\n");
print_extension_list(wglExtensions);
}
}
#endif
printf("OpenGL vendor string: %s\n", glVendor);
printf("OpenGL renderer string: %s\n", glRenderer);
printf("OpenGL version string: %s\n", glVersion);
#ifdef GL_VERSION_2_0
if (glVersion[0] >= '2' && glVersion[1] == '.') {
char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
printf("OpenGL shading language version string: %s\n", v);
}
#endif
printf("OpenGL extensions:\n");
print_extension_list(glExtensions);
if (limits)
print_limits(glExtensions);
}
else {
fprintf(stderr, "Error: wglMakeCurrent failed\n");
}
DestroyWindow(win);
}
static const char *
visual_render_type_name(BYTE iPixelType)
{
switch (iPixelType) {
case PFD_TYPE_RGBA:
return "rgba";
case PFD_TYPE_COLORINDEX:
return "ci";
default:
return "";
}
}
static void
print_visual_attribs_verbose(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
{
printf("Visual ID: %x generic=%d native=%d\n",
iPixelFormat,
ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0);
printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n",
0 /* ppfd->bufferSize */, 0 /* ppfd->level */,
visual_render_type_name(ppfd->dwFlags),
ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
ppfd->dwFlags & PFD_STEREO ? 1 : 0);
printf(" rgba: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
ppfd->cRedBits, ppfd->cGreenBits,
ppfd->cBlueBits, ppfd->cAlphaBits);
printf(" cAuxBuffers=%d cDepthBits=%d cStencilBits=%d\n",
ppfd->cAuxBuffers, ppfd->cDepthBits, ppfd->cStencilBits);
printf(" accum: cRedBits=%d cGreenBits=%d cBlueBits=%d cAlphaBits=%d\n",
ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits);
printf(" multiSample=%d multiSampleBuffers=%d\n",
0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */);
}
static void
print_visual_attribs_short_header(void)
{
printf(" visual x bf lv rg d st colorbuffer ax dp st accumbuffer ms cav\n");
printf(" id gen nat sp sz l ci b ro r g b a bf th cl r g b a ns b eat\n");
printf("-----------------------------------------------------------------------\n");
}
static void
print_visual_attribs_short(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
{
char *caveat = "None";
printf("0x%02x %2d %2d %2d %2d %2d %c%c %c %c %2d %2d %2d %2d %2d %2d %2d",
iPixelFormat,
ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
0,
0 /* ppfd->bufferSize */,
0 /* ppfd->level */,
ppfd->iPixelType == PFD_TYPE_RGBA ? 'r' : ' ',
ppfd->iPixelType == PFD_TYPE_COLORINDEX ? 'c' : ' ',
ppfd->dwFlags & PFD_DOUBLEBUFFER ? 'y' : '.',
ppfd->dwFlags & PFD_STEREO ? 'y' : '.',
ppfd->cRedBits, ppfd->cGreenBits,
ppfd->cBlueBits, ppfd->cAlphaBits,
ppfd->cAuxBuffers,
ppfd->cDepthBits,
ppfd->cStencilBits
);
printf(" %2d %2d %2d %2d %2d %1d %s\n",
ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits,
0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */,
caveat
);
}
static void
print_visual_attribs_long_header(void)
{
printf("Vis Vis Visual Trans buff lev render DB ste r g b a aux dep ste accum buffers MS MS\n");
printf(" ID Depth Type parent size el type reo sz sz sz sz buf th ncl r g b a num bufs\n");
printf("----------------------------------------------------------------------------------------------------\n");
}
static void
print_visual_attribs_long(int iPixelFormat, LPPIXELFORMATDESCRIPTOR ppfd)
{
printf("0x%2x %2d %11d %2d %2d %2d %4s %3d %3d %3d %3d %3d %3d",
iPixelFormat,
ppfd->dwFlags & PFD_GENERIC_FORMAT ? 1 : 0,
ppfd->dwFlags & PFD_DRAW_TO_WINDOW ? 1 : 0,
0,
0 /* ppfd->bufferSize */,
0 /* ppfd->level */,
visual_render_type_name(ppfd->iPixelType),
ppfd->dwFlags & PFD_DOUBLEBUFFER ? 1 : 0,
ppfd->dwFlags & PFD_STEREO ? 1 : 0,
ppfd->cRedBits, ppfd->cGreenBits,
ppfd->cBlueBits, ppfd->cAlphaBits
);
printf(" %3d %4d %2d %3d %3d %3d %3d %2d %2d\n",
ppfd->cAuxBuffers,
ppfd->cDepthBits,
ppfd->cStencilBits,
ppfd->cAccumRedBits, ppfd->cAccumGreenBits,
ppfd->cAccumBlueBits, ppfd->cAccumAlphaBits,
0 /* ppfd->numSamples */, 0 /* ppfd->numMultisample */
);
}
static void
print_visual_info(HDC hdc, InfoMode mode)
{
PIXELFORMATDESCRIPTOR pfd;
int numVisuals, numWglVisuals;
int i;
numVisuals = DescribePixelFormat(hdc, 1, sizeof(PIXELFORMATDESCRIPTOR), NULL);
if (numVisuals == 0)
return;
numWglVisuals = 0;
for (i = 0; i < numVisuals; i++) {
if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
continue;
//if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
// continue;
++numWglVisuals;
}
printf("%d WGL Visuals\n", numWglVisuals);
if (mode == Normal)
print_visual_attribs_short_header();
else if (mode == Wide)
print_visual_attribs_long_header();
for (i = 0; i < numVisuals; i++) {
if(!DescribePixelFormat(hdc, i, sizeof(PIXELFORMATDESCRIPTOR), &pfd))
continue;
//if(!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
// continue;
if (mode == Verbose)
print_visual_attribs_verbose(i, &pfd);
else if (mode == Normal)
print_visual_attribs_short(i, &pfd);
else if (mode == Wide)
print_visual_attribs_long(i, &pfd);
}
printf("\n");
}
/*
* Examine all visuals to find the so-called best one.
* We prefer deepest RGBA buffer with depth, stencil and accum
* that has no caveats.
*/
static int
find_best_visual(HDC hdc)
{
#if 0
XVisualInfo theTemplate;
XVisualInfo *visuals;
int numVisuals;
long mask;
int i;
struct visual_attribs bestVis;
/* get list of all visuals on this screen */
theTemplate.screen = scrnum;
mask = VisualScreenMask;
visuals = XGetVisualInfo(hdc, mask, &theTemplate, &numVisuals);
/* init bestVis with first visual info */
get_visual_attribs(hdc, &visuals[0], &bestVis);
/* try to find a "better" visual */
for (i = 1; i < numVisuals; i++) {
struct visual_attribs vis;
get_visual_attribs(hdc, &visuals[i], &vis);
/* always skip visuals with caveats */
if (vis.visualCaveat != GLX_NONE_EXT)
continue;
/* see if this vis is better than bestVis */
if ((!bestVis.supportsGL && vis.supportsGL) ||
(bestVis.visualCaveat != GLX_NONE_EXT) ||
(bestVis.iPixelType != vis.iPixelType) ||
(!bestVis.doubleBuffer && vis.doubleBuffer) ||
(bestVis.cRedBits < vis.cRedBits) ||
(bestVis.cGreenBits < vis.cGreenBits) ||
(bestVis.cBlueBits < vis.cBlueBits) ||
(bestVis.cAlphaBits < vis.cAlphaBits) ||
(bestVis.cDepthBits < vis.cDepthBits) ||
(bestVis.cStencilBits < vis.cStencilBits) ||
(bestVis.cAccumRedBits < vis.cAccumRedBits)) {
/* found a better visual */
bestVis = vis;
}
}
return bestVis.id;
#else
return 0;
#endif
}
static void
usage(void)
{
printf("Usage: glxinfo [-v] [-t] [-h] [-i] [-b] [-display <dname>]\n");
printf("\t-v: Print visuals info in verbose form.\n");
printf("\t-t: Print verbose table.\n");
printf("\t-h: This information.\n");
printf("\t-b: Find the 'best' visual and print it's number.\n");
printf("\t-l: Print interesting OpenGL limits.\n");
}
int
main(int argc, char *argv[])
{
HDC hdc;
InfoMode mode = Normal;
GLboolean findBest = GL_FALSE;
GLboolean limits = GL_FALSE;
int i;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-t") == 0) {
mode = Wide;
}
else if (strcmp(argv[i], "-v") == 0) {
mode = Verbose;
}
else if (strcmp(argv[i], "-b") == 0) {
findBest = GL_TRUE;
}
else if (strcmp(argv[i], "-l") == 0) {
limits = GL_TRUE;
}
else if (strcmp(argv[i], "-h") == 0) {
usage();
return 0;
}
else {
printf("Unknown option `%s'\n", argv[i]);
usage();
return 0;
}
}
hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL);
if (findBest) {
int b;
b = find_best_visual(hdc);
printf("%d\n", b);
}
else {
print_screen_info(hdc, limits);
printf("\n");
print_visual_info(hdc, mode);
}
return 0;
}

View File

@ -252,21 +252,24 @@ def generate(env):
# http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
'WIN32_LEAN_AND_MEAN',
]
if msvc:
if msvc and env['toolchain'] != 'winddk':
cppdefines += [
'VC_EXTRALEAN',
'_CRT_SECURE_NO_DEPRECATE',
]
if debug:
cppdefines += ['_DEBUG']
if platform == 'winddk':
if env['toolchain'] == 'winddk':
# Mimic WINDDK's builtin flags. See also:
# - WINDDK's bin/makefile.new i386mk.inc for more info.
# - buildchk_wxp_x86.log files, generated by the WINDDK's build
# - http://alter.org.ua/docs/nt_kernel/vc8_proj/
if machine == 'x86':
cppdefines += ['_X86_', 'i386']
if machine == 'x86_64':
cppdefines += ['_AMD64_', 'AMD64']
if platform == 'winddk':
cppdefines += [
('_X86_', '1'),
('i386', '1'),
'STD_CALL',
('CONDITION_HANDLING', '1'),
('NT_INST', '0'),
@ -309,15 +312,6 @@ def generate(env):
cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
env.Append(CPPDEFINES = cppdefines)
# C preprocessor includes
if platform == 'winddk':
env.Append(CPPPATH = [
env['SDK_INC_PATH'],
env['DDK_INC_PATH'],
env['WDM_INC_PATH'],
env['CRT_INC_PATH'],
])
# C compiler options
cflags = []
if gcc:

View File

@ -29,21 +29,105 @@ Based on SCons.Tool.mslib, without the MSVC detection.
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
import os
import tempfile
import string
import SCons.Defaults
import SCons.Tool
import SCons.Util
import SCons.Errors
class TempFileMunge:
"""Same as SCons.Platform.TempFileMunge, but preserves LINK /LIB
together."""
def __init__(self, cmd):
self.cmd = cmd
def __call__(self, target, source, env, for_signature):
if for_signature:
return self.cmd
cmd = env.subst_list(self.cmd, 0, target, source)[0]
try:
maxline = int(env.subst('$MAXLINELENGTH'))
except ValueError:
maxline = 2048
if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline:
return self.cmd
# We do a normpath because mktemp() has what appears to be
# a bug in Windows that will use a forward slash as a path
# delimiter. Windows's link mistakes that for a command line
# switch and barfs.
#
# We use the .lnk suffix for the benefit of the Phar Lap
# linkloc linker, which likes to append an .lnk suffix if
# none is given.
tmp = os.path.normpath(tempfile.mktemp('.lnk'))
native_tmp = SCons.Util.get_native_path(tmp)
if env['SHELL'] and env['SHELL'] == 'sh':
# The sh shell will try to escape the backslashes in the
# path, so unescape them.
native_tmp = string.replace(native_tmp, '\\', r'\\\\')
# In Cygwin, we want to use rm to delete the temporary
# file, because del does not exist in the sh shell.
rm = env.Detect('rm') or 'del'
else:
# Don't use 'rm' if the shell is not sh, because rm won't
# work with the Windows shells (cmd.exe or command.com) or
# Windows path names.
rm = 'del'
prefix = env.subst('$TEMPFILEPREFIX')
if not prefix:
prefix = '@'
if cmd[0:2] == ['link', '/lib']:
split = 2
else:
split = 1
args = map(SCons.Subst.quote_spaces, cmd[split:])
open(tmp, 'w').write(string.join(args, " ") + "\n")
# XXX Using the SCons.Action.print_actions value directly
# like this is bogus, but expedient. This class should
# really be rewritten as an Action that defines the
# __call__() and strfunction() methods and lets the
# normal action-execution logic handle whether or not to
# print/execute the action. The problem, though, is all
# of that is decided before we execute this method as
# part of expanding the $TEMPFILE construction variable.
# Consequently, refactoring this will have to wait until
# we get more flexible with allowing Actions to exist
# independently and get strung together arbitrarily like
# Ant tasks. In the meantime, it's going to be more
# user-friendly to not let obsession with architectural
# purity get in the way of just being helpful, so we'll
# reach into SCons.Action directly.
if SCons.Action.print_actions:
print("Using tempfile "+native_tmp+" for command line:\n"+
" ".join(map(str,cmd)))
return cmd[:split] + [ prefix + native_tmp + '\n' + rm, native_tmp ]
def generate(env):
"""Add Builders and construction variables for lib to an Environment."""
SCons.Tool.createStaticLibBuilder(env)
env['AR'] = 'lib'
if env.Detect('lib'):
env['AR'] = 'lib'
else:
# Recent WINDDK versions do not ship with lib.
env['AR'] = 'link /lib'
env['TEMPFILE'] = TempFileMunge
env['ARFLAGS'] = SCons.Util.CLVar('/nologo')
env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}"
env['LIBPREFIX'] = ''
env['LIBSUFFIX'] = '.lib'
def exists(env):
return env.Detect('lib')
return env.Detect('lib') or env.Detect('link')
# vim:set ts=4 sw=4 et:

View File

@ -44,87 +44,90 @@ import msvc_sa
import mslib_sa
import mslink_sa
def get_winddk_root(env):
try:
return os.environ['BASEDIR']
except KeyError:
pass
versions = [
'6001.18002',
'3790.1830',
]
version = "3790.1830"
if SCons.Util.can_read_reg:
key = r'SOFTWARE\Microsoft\WINDDK\%s\LFNDirectory' % version
try:
path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
except SCons.Util.RegError:
pass
else:
return path
def cpu_bin(target_cpu):
if target_cpu == 'i386':
return 'x86'
else:
return target_cpu
def get_winddk_root(env, version):
default_path = os.path.join(r'C:\WINDDK', version)
if os.path.exists(default_path):
return default_path
return None
def get_winddk_paths(env):
"""Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
of those three environment variables that should be set
in order to execute the MSVC tools properly."""
def get_winddk_paths(env, version, root):
version_major, version_minor = map(int, version.split('.'))
WINDDKdir = None
exe_paths = []
lib_paths = []
include_paths = []
if version_major >= 6000:
target_os = 'wlh'
else:
target_os = 'wxp'
WINDDKdir = get_winddk_root(env)
if WINDDKdir is None:
raise SCons.Errors.InternalError, "WINDDK not found"
if env['machine'] in ('generic', 'x86'):
target_cpu = 'i386'
elif env['machine'] == 'x86_64':
target_cpu = 'amd64'
else:
raise SCons.Errors.InternalError, "Unsupported target machine"
exe_paths.append( os.path.join(WINDDKdir, 'bin') )
exe_paths.append( os.path.join(WINDDKdir, 'bin', 'x86') )
include_paths.append( os.path.join(WINDDKdir, 'inc', 'wxp') )
lib_paths.append( os.path.join(WINDDKdir, 'lib') )
if version_major >= 6000:
# TODO: take in consideration the host cpu
bin_dir = os.path.join(root, 'bin', 'x86', cpu_bin(target_cpu))
else:
if target_cpu == 'i386':
bin_dir = os.path.join(root, 'bin', 'x86')
else:
# TODO: take in consideration the host cpu
bin_dir = os.path.join(root, 'bin', 'win64', 'x86', cpu_bin(target_cpu))
target_os = 'wxp'
target_cpu = 'i386'
env.PrependENVPath('PATH', [bin_dir])
env['SDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', target_os)
env['CRT_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'crt')
env['DDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', target_os)
env['WDM_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', 'wdm', target_os)
crt_inc_dir = os.path.join(root, 'inc', 'crt')
if version_major >= 6000:
sdk_inc_dir = os.path.join(root, 'inc', 'api')
ddk_inc_dir = os.path.join(root, 'inc', 'ddk')
wdm_inc_dir = os.path.join(root, 'inc', 'ddk')
else:
ddk_inc_dir = os.path.join(root, 'inc', 'ddk', target_os)
sdk_inc_dir = os.path.join(root, 'inc', target_os)
wdm_inc_dir = os.path.join(root, 'inc', 'ddk', 'wdm', target_os)
env['SDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
env['CRT_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', 'crt', target_cpu)
env['DDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
env['WDM_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
include_path = string.join( include_paths, os.pathsep )
lib_path = string.join(lib_paths, os.pathsep )
exe_path = string.join(exe_paths, os.pathsep )
return (include_path, lib_path, exe_path)
env.PrependENVPath('INCLUDE', [
wdm_inc_dir,
ddk_inc_dir,
crt_inc_dir,
sdk_inc_dir,
])
env.PrependENVPath('LIB', [
os.path.join(root, 'lib', 'crt', target_cpu),
os.path.join(root, 'lib', target_os, target_cpu),
])
def generate(env):
if not env.has_key('ENV'):
env['ENV'] = {}
for version in versions:
root = get_winddk_root(env, version)
if root is not None:
get_winddk_paths(env, version, root)
break
msvc_sa.generate(env)
mslib_sa.generate(env)
mslink_sa.generate(env)
if not env.has_key('ENV'):
env['ENV'] = {}
try:
include_path, lib_path, exe_path = get_winddk_paths(env)
# since other tools can set these, we just make sure that the
# relevant stuff from WINDDK is in there somewhere.
env.PrependENVPath('INCLUDE', include_path)
env.PrependENVPath('LIB', lib_path)
env.PrependENVPath('PATH', exe_path)
except (SCons.Util.RegError, SCons.Errors.InternalError):
pass
def exists(env):
return get_winddk_root(env) is not None
for version in versions:
if get_winddk_root(env, version) is not None:
return True
return False
# vim:set ts=4 sw=4 et:

View File

@ -77,13 +77,9 @@ def get_vc_paths(env):
raise SCons.Errors.InternalError, "Unsupported target machine"
include_dir = 'include'
exe_path = os.path.join(vc_root, bin_dir)
include_path = os.path.join(vc_root, include_dir)
lib_path = os.path.join(vc_root, lib_dir)
env.PrependENVPath('INCLUDE', include_path)
env.PrependENVPath('LIB', lib_path)
env.PrependENVPath('PATH', exe_path)
env.PrependENVPath('PATH', os.path.join(vc_root, bin_dir))
env.PrependENVPath('INCLUDE', os.path.join(vc_root, include_dir))
env.PrependENVPath('LIB', os.path.join(vc_root, lib_dir))
def get_sdk_root(env):
if SCons.Util.can_read_reg:
@ -108,18 +104,14 @@ def get_sdk_paths(env):
if target_cpu in ('generic', 'x86'):
lib_dir = 'Lib'
elif target_cpu == 'x86_64':
lib_dir = 'Lib/x64'
lib_dir = r'Lib\x64'
else:
raise SCons.Errors.InternalError, "Unsupported target machine"
include_dir = 'Include'
exe_path = os.path.join(sdk_root, bin_dir)
include_path = os.path.join(sdk_root, include_dir)
lib_path = os.path.join(sdk_root, lib_dir)
env.PrependENVPath('INCLUDE', include_path)
env.PrependENVPath('LIB', lib_path)
env.PrependENVPath('PATH', exe_path)
env.PrependENVPath('PATH', os.path.join(sdk_root, bin_dir))
env.PrependENVPath('INCLUDE', os.path.join(sdk_root, include_dir))
env.PrependENVPath('LIB', os.path.join(sdk_root, lib_dir))
def generate(env):
if not env.has_key('ENV'):

View File

@ -64,7 +64,7 @@ $(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS)
-install $(TOP)/$(LIB_DIR) \
$(EGL_LIB_DEPS) $(OBJECTS)
install:
install: default
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
$(INSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR)

View File

@ -114,7 +114,7 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
fetch->translate = translate_cache_find(fetch->cache, &key);
{
static struct vertex_header vh = { 0, 1, 0, 0xffff };
static struct vertex_header vh = { 0, 1, 0, UNDEFINED_VERTEX_ID, { .0f, .0f, .0f, .0f } };
fetch->translate->set_buffer(fetch->translate,
draw->pt.nr_vertex_buffers,
&vh,

View File

@ -9,7 +9,7 @@ static void FUNC(struct draw_pt_front_end *frontend,
unsigned count)
{
struct varray_frontend *varray = (struct varray_frontend *)frontend;
unsigned start = (unsigned)elts;
unsigned start = (unsigned) ((char *) elts - (char *) NULL);
unsigned j;
unsigned first, incr;

View File

@ -74,7 +74,7 @@ void PIPE_CDECL aos_do_lit( struct aos_machine *machine,
{
result[0] = 1.0F;
result[1] = in[0];
result[2] = 1.0;
result[2] = 0.0F;
result[3] = 1.0F;
}
else
@ -108,7 +108,7 @@ static void PIPE_CDECL do_lit_lut( struct aos_machine *machine,
{
result[0] = 1.0F;
result[1] = in[0];
result[2] = 1.0;
result[2] = 0.0F;
result[3] = 1.0F;
return;
}

View File

@ -30,6 +30,7 @@
#include "rtasm_cpu.h"
#if defined(PIPE_ARCH_X86)
static boolean rtasm_sse_enabled(void)
{
static boolean firsttime = 1;
@ -43,6 +44,7 @@ static boolean rtasm_sse_enabled(void)
}
return enabled;
}
#endif
int rtasm_cpu_has_sse(void)
{

View File

@ -1477,6 +1477,7 @@ emit_instruction(
case TGSI_OPCODE_ARL:
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( func, *inst, 0, 0, chan_index );
emit_flr(func, 0, 0);
emit_f2it( func, 0 );
STORE( func, *inst, 0, 0, chan_index );
}
@ -1553,7 +1554,7 @@ emit_instruction(
func,
make_xmm( 2 ),
make_xmm( 0 ),
cc_LessThanEqual );
cc_LessThan );
sse_andps(
func,
make_xmm( 2 ),
@ -2177,32 +2178,83 @@ emit_instruction(
/* 3 or 4-component normalization */
{
uint dims = (inst->Instruction.Opcode == TGSI_OPCODE_NRM) ? 3 : 4;
/* note: cannot use xmm regs 2/3 here (see emit_rsqrt() above) */
FETCH( func, *inst, 4, 0, CHAN_X ); /* xmm4 = src[0].x */
FETCH( func, *inst, 5, 0, CHAN_Y ); /* xmm5 = src[0].y */
FETCH( func, *inst, 6, 0, CHAN_Z ); /* xmm6 = src[0].z */
if (dims == 4) {
FETCH( func, *inst, 7, 0, CHAN_W ); /* xmm7 = src[0].w */
}
emit_MOV( func, 0, 4 ); /* xmm0 = xmm3 */
emit_mul( func, 0, 4 ); /* xmm0 *= xmm3 */
emit_MOV( func, 1, 5 ); /* xmm1 = xmm4 */
emit_mul( func, 1, 5 ); /* xmm1 *= xmm4 */
emit_add( func, 0, 1 ); /* xmm0 += xmm1 */
emit_MOV( func, 1, 6 ); /* xmm1 = xmm5 */
emit_mul( func, 1, 6 ); /* xmm1 *= xmm5 */
emit_add( func, 0, 1 ); /* xmm0 += xmm1 */
if (dims == 4) {
emit_MOV( func, 1, 7 ); /* xmm1 = xmm7 */
emit_mul( func, 1, 7 ); /* xmm1 *= xmm7 */
emit_add( func, 0, 0 ); /* xmm0 += xmm1 */
}
emit_rsqrt( func, 1, 0 ); /* xmm1 = 1/sqrt(xmm0) */
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
if (chan_index < dims) {
emit_mul( func, 4+chan_index, 1); /* xmm[4+ch] *= xmm1 */
STORE( func, *inst, 4+chan_index, 0, chan_index );
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X) ||
IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y) ||
IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z) ||
(IS_DST0_CHANNEL_ENABLED(*inst, CHAN_W) && dims == 4)) {
/* NOTE: Cannot use xmm regs 2/3 here (see emit_rsqrt() above). */
/* xmm4 = src.x */
/* xmm0 = src.x * src.x */
FETCH(func, *inst, 0, 0, CHAN_X);
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X)) {
emit_MOV(func, 4, 0);
}
emit_mul(func, 0, 0);
/* xmm5 = src.y */
/* xmm0 = xmm0 + src.y * src.y */
FETCH(func, *inst, 1, 0, CHAN_Y);
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y)) {
emit_MOV(func, 5, 1);
}
emit_mul(func, 1, 1);
emit_add(func, 0, 1);
/* xmm6 = src.z */
/* xmm0 = xmm0 + src.z * src.z */
FETCH(func, *inst, 1, 0, CHAN_Z);
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z)) {
emit_MOV(func, 6, 1);
}
emit_mul(func, 1, 1);
emit_add(func, 0, 1);
if (dims == 4) {
/* xmm7 = src.w */
/* xmm0 = xmm0 + src.w * src.w */
FETCH(func, *inst, 1, 0, CHAN_W);
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_W)) {
emit_MOV(func, 7, 1);
}
emit_mul(func, 1, 1);
emit_add(func, 0, 1);
}
/* xmm1 = 1 / sqrt(xmm0) */
emit_rsqrt(func, 1, 0);
/* dst.x = xmm1 * src.x */
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X)) {
emit_mul(func, 4, 1);
STORE(func, *inst, 4, 0, CHAN_X);
}
/* dst.y = xmm1 * src.y */
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y)) {
emit_mul(func, 5, 1);
STORE(func, *inst, 5, 0, CHAN_Y);
}
/* dst.z = xmm1 * src.z */
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z)) {
emit_mul(func, 6, 1);
STORE(func, *inst, 6, 0, CHAN_Z);
}
/* dst.w = xmm1 * src.w */
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X) && dims == 4) {
emit_mul(func, 7, 1);
STORE(func, *inst, 7, 0, CHAN_W);
}
}
/* dst0.w = 1.0 */
if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_W) && dims == 3) {
emit_tempf(func, 0, TEMP_ONE_I, TEMP_ONE_C);
STORE(func, *inst, 0, 0, CHAN_W);
}
}
break;

View File

@ -23,6 +23,7 @@ C_SOURCES = \
u_snprintf.c \
u_stream_stdc.c \
u_stream_wd.c \
u_surface.c \
u_tile.c \
u_time.c \
u_timed_winsys.c \

View File

@ -24,6 +24,7 @@ util = env.ConvenienceLibrary(
'u_snprintf.c',
'u_stream_stdc.c',
'u_stream_wd.c',
'u_surface.c',
'u_tile.c',
'u_time.c',
'u_timed_winsys.c',

View File

@ -89,10 +89,6 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso)
/* disabled blending/masking */
memset(&ctx->blend, 0, sizeof(ctx->blend));
ctx->blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
ctx->blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
ctx->blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
ctx->blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
ctx->blend.colormask = PIPE_MASK_RGBA;
/* no-op depth/stencil/alpha */
@ -337,7 +333,6 @@ util_blit_pixels(struct blit_state *ctx,
texTemp.width[0] = srcW;
texTemp.height[0] = srcH;
texTemp.depth[0] = 1;
texTemp.compressed = 0;
pf_get_block(src->format, &texTemp.block);
tex = screen->texture_create(screen, &texTemp);

View File

@ -109,6 +109,7 @@ void _debug_vprintf(const char *format, va_list ap)
}
if(GetConsoleWindow() && !IsDebuggerPresent()) {
fflush(stdout);
vfprintf(stderr, format, ap);
fflush(stderr);
}
@ -145,6 +146,7 @@ void _debug_vprintf(const char *format, va_list ap)
/* TODO */
#else /* !PIPE_SUBSYSTEM_WINDOWS */
#ifdef DEBUG
fflush(stdout);
vfprintf(stderr, format, ap);
#endif
#endif

View File

@ -1278,10 +1278,6 @@ util_create_gen_mipmap(struct pipe_context *pipe,
/* disabled blending/masking */
memset(&ctx->blend, 0, sizeof(ctx->blend));
ctx->blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE;
ctx->blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE;
ctx->blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO;
ctx->blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO;
ctx->blend.colormask = PIPE_MASK_RGBA;
/* no-op depth/stencil/alpha */

View File

@ -0,0 +1,113 @@
/**************************************************************************
*
* Copyright 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/**
* @file
* Surface utility functions.
*
* @author Brian Paul
*/
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_surface.h"
/**
* Helper to quickly create an RGBA rendering surface of a certain size.
* \param textureOut returns the new texture
* \param surfaceOut returns the new surface
* \return TRUE for success, FALSE if failure
*/
boolean
util_create_rgba_surface(struct pipe_screen *screen,
uint width, uint height,
struct pipe_texture **textureOut,
struct pipe_surface **surfaceOut)
{
static const enum pipe_format rgbaFormats[] = {
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_B8G8R8A8_UNORM,
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_NONE
};
const uint target = PIPE_TEXTURE_2D;
const uint usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
enum pipe_format format = PIPE_FORMAT_NONE;
struct pipe_texture templ;
uint i;
/* Choose surface format */
for (i = 0; rgbaFormats[i]; i++) {
if (screen->is_format_supported(screen, rgbaFormats[i],
target, usage, 0)) {
format = rgbaFormats[i];
break;
}
}
if (format == PIPE_FORMAT_NONE)
return FALSE; /* unable to get an rgba format!?! */
/* create texture */
memset(&templ, 0, sizeof(templ));
templ.target = target;
templ.format = format;
templ.last_level = 0;
templ.width[0] = width;
templ.height[0] = height;
templ.depth[0] = 1;
pf_get_block(format, &templ.block);
templ.tex_usage = usage;
*textureOut = screen->texture_create(screen, &templ);
if (!*textureOut)
return FALSE;
/* create surface / view into texture */
*surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
if (!*surfaceOut) {
pipe_texture_reference(textureOut, NULL);
return FALSE;
}
return TRUE;
}
/**
* Release the surface and texture from util_create_rgba_surface().
*/
void
util_destroy_rgba_surface(struct pipe_texture *texture,
struct pipe_surface *surface)
{
pipe_surface_reference(&surface, NULL);
pipe_texture_reference(&texture, NULL);
}

View File

@ -1,8 +1,7 @@
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
*
* Copyright 2009 VMware, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@ -10,26 +9,44 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*
**************************************************************************/
#ifndef WGL_ARBEXTENSIONSSTRING_H
#define WGL_ARBEXTENSIONSSTRING_H
WINGDIAPI const char * APIENTRY
wglGetExtensionsStringARB(
HDC hdc );
#ifndef U_SURFACE_H
#define U_SURFACE_H
#endif /* WGL_ARBEXTENSIONSSTRING_H */
#include "pipe/p_compiler.h"
struct pipe_screen;
struct pipe_texture;
struct pipe_surface;
extern boolean
util_create_rgba_surface(struct pipe_screen *screen,
uint width, uint height,
struct pipe_texture **textureOut,
struct pipe_surface **surfaceOut);
extern void
util_destroy_rgba_surface(struct pipe_texture *texture,
struct pipe_surface *surface);
#endif /* U_SURFACE_H */

View File

@ -99,6 +99,28 @@ static const struct debug_named_value cell_debug_flags[] = {
{NULL, 0}
};
static unsigned int
cell_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
cell_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
cell_create_context(struct pipe_screen *screen,
@ -122,6 +144,9 @@ cell_create_context(struct pipe_screen *screen,
cell->pipe.clear = cell_clear;
cell->pipe.flush = cell_flush;
cell->pipe.is_texture_referenced = cell_is_texture_referenced;
cell->pipe.is_buffer_referenced = cell_is_buffer_referenced;
#if 0
cell->pipe.begin_query = cell_begin_query;
cell->pipe.end_query = cell_end_query;

View File

@ -105,7 +105,28 @@ static boolean failover_draw_arrays( struct pipe_context *pipe,
return failover_draw_elements(pipe, NULL, 0, prim, start, count);
}
static unsigned int
failover_is_texture_referenced( struct pipe_context *_pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
struct failover_context *failover = failover_context( _pipe );
struct pipe_context *pipe = (failover->mode == FO_HW) ?
failover->hw : failover->sw;
return pipe->is_texture_referenced(pipe, texture, face, level);
}
static unsigned int
failover_is_buffer_referenced( struct pipe_context *_pipe,
struct pipe_buffer *buf)
{
struct failover_context *failover = failover_context( _pipe );
struct pipe_context *pipe = (failover->mode == FO_HW) ?
failover->hw : failover->sw;
return pipe->is_buffer_referenced(pipe, buf);
}
struct pipe_context *failover_create( struct pipe_context *hw,
struct pipe_context *sw )
@ -151,6 +172,8 @@ struct pipe_context *failover_create( struct pipe_context *hw,
#endif
failover->pipe.flush = hw->flush;
failover->pipe.is_texture_referenced = failover_is_texture_referenced;
failover->pipe.is_buffer_referenced = failover_is_buffer_referenced;
failover->dirty = 0;

View File

@ -136,6 +136,29 @@ static boolean i915_draw_arrays( struct pipe_context *pipe,
}
static unsigned int
i915_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
i915_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *i915_create_context( struct pipe_screen *screen,
struct pipe_winsys *pipe_winsys,
@ -160,6 +183,9 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen,
i915->pipe.draw_elements = i915_draw_elements;
i915->pipe.draw_range_elements = i915_draw_range_elements;
i915->pipe.is_texture_referenced = i915_is_texture_referenced;
i915->pipe.is_buffer_referenced = i915_is_buffer_referenced;
/*
* Create drawing context and plug our rendering stage into it.
*/

View File

@ -73,6 +73,28 @@ static void brw_clear(struct pipe_context *pipe, struct pipe_surface *ps,
pipe->surface_fill(pipe, ps, x, y, w, h, clearValue);
}
static unsigned int
brw_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
brw_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *brw_create(struct pipe_screen *screen,
struct brw_winsys *brw_winsys,
@ -94,6 +116,9 @@ struct pipe_context *brw_create(struct pipe_screen *screen,
brw->pipe.destroy = brw_destroy;
brw->pipe.clear = brw_clear;
brw->pipe.is_texture_referenced = brw_is_texture_referenced;
brw->pipe.is_buffer_referenced = brw_is_buffer_referenced;
brw_init_surface_functions(brw);
brw_init_texture_functions(brw);
brw_init_state_functions(brw);

View File

@ -240,7 +240,7 @@ static boolean brw_miptree_layout(struct brw_texture *tex)
nblocksx = pf_get_nblocksx(&pt->block, width);
nblocksy = pf_get_nblocksy(&pt->block, height);
if (pt->compressed) {
if (pf_is_compressed(pt->format)) {
pack_y_pitch = (height + 3) / 4;
if (pack_x_pitch > align(width, align_w)) {

View File

@ -64,6 +64,30 @@ nv04_init_hwctx(struct nv04_context *nv04)
return TRUE;
}
static unsigned int
nv04_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv04_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -89,6 +113,9 @@ nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv04->pipe.clear = nv04_clear;
nv04->pipe.flush = nv04_flush;
nv04->pipe.is_texture_referenced = nv04_is_texture_referenced;
nv04->pipe.is_buffer_referenced = nv04_is_buffer_referenced;
nv04_init_surface_functions(nv04);
nv04_init_state_functions(nv04);

View File

@ -43,7 +43,6 @@ nv04_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->nblocksx[0] = pt->nblocksx[level];
template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->compressed = pt->compressed;
template->nr_samples = pt->nr_samples;
template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |

View File

@ -257,6 +257,29 @@ nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
static unsigned int
nv10_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv10_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -282,6 +305,9 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv10->pipe.clear = nv10_clear;
nv10->pipe.flush = nv10_flush;
nv10->pipe.is_texture_referenced = nv10_is_texture_referenced;
nv10->pipe.is_buffer_referenced = nv10_is_buffer_referenced;
nv10_init_surface_functions(nv10);
nv10_init_state_functions(nv10);

View File

@ -43,7 +43,6 @@ nv10_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->nblocksx[0] = pt->nblocksx[level];
template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->compressed = pt->compressed;
template->nr_samples = pt->nr_samples;
template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |

View File

@ -380,6 +380,30 @@ nv20_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
static unsigned int
nv20_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv20_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -405,6 +429,9 @@ nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv20->pipe.clear = nv20_clear;
nv20->pipe.flush = nv20_flush;
nv20->pipe.is_texture_referenced = nv20_is_texture_referenced;
nv20->pipe.is_buffer_referenced = nv20_is_buffer_referenced;
nv20_init_surface_functions(nv20);
nv20_init_state_functions(nv20);

View File

@ -43,7 +43,6 @@ nv20_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->nblocksx[0] = pt->nblocksx[level];
template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->compressed = pt->compressed;
template->nr_samples = pt->nr_samples;
template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |

View File

@ -31,6 +31,29 @@ nv30_destroy(struct pipe_context *pipe)
FREE(nv30);
}
static unsigned int
nv30_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv30_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -55,6 +78,9 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv30->pipe.clear = nv30_clear;
nv30->pipe.flush = nv30_flush;
nv30->pipe.is_texture_referenced = nv30_is_texture_referenced;
nv30->pipe.is_buffer_referenced = nv30_is_buffer_referenced;
nv30_init_query_functions(nv30);
nv30_init_surface_functions(nv30);
nv30_init_state_functions(nv30);

View File

@ -43,7 +43,6 @@ nv30_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->nblocksx[0] = pt->nblocksx[level];
template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->compressed = pt->compressed;
template->nr_samples = pt->nr_samples;
template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |

View File

@ -31,6 +31,29 @@ nv40_destroy(struct pipe_context *pipe)
FREE(nv40);
}
static unsigned int
nv40_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv40_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -55,6 +78,9 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv40->pipe.clear = nv40_clear;
nv40->pipe.flush = nv40_flush;
nv40->pipe.is_texture_referenced = nv40_is_texture_referenced;
nv40->pipe.is_buffer_referenced = nv40_is_buffer_referenced;
nv40_init_query_functions(nv40);
nv40_init_surface_functions(nv40);
nv40_init_state_functions(nv40);

View File

@ -43,7 +43,6 @@ nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned level,
template->nblocksx[0] = pt->nblocksx[level];
template->nblocksy[0] = pt->nblocksx[level];
template->last_level = 0;
template->compressed = pt->compressed;
template->nr_samples = pt->nr_samples;
template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |

View File

@ -27,64 +27,42 @@
#include "nv50_context.h"
void
nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps,
unsigned clearValue)
nv50_clear(struct pipe_context *pipe, unsigned buffers,
const float *rgba, double depth, unsigned stencil)
{
struct nv50_context *nv50 = nv50_context(pipe);
struct nouveau_channel *chan = nv50->screen->nvws->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
struct pipe_framebuffer_state fb, s_fb = nv50->framebuffer;
struct pipe_scissor_state sc, s_sc = nv50->scissor;
unsigned dirty = nv50->dirty;
struct pipe_framebuffer_state *fb = &nv50->framebuffer;
unsigned mode = 0, i;
nv50->dirty = 0;
if (!nv50_state_validate(nv50))
return;
if (ps->format == PIPE_FORMAT_Z24S8_UNORM ||
ps->format == PIPE_FORMAT_Z16_UNORM) {
fb.nr_cbufs = 0;
fb.zsbuf = ps;
} else {
fb.nr_cbufs = 1;
fb.cbufs[0] = ps;
fb.zsbuf = NULL;
}
fb.width = ps->width;
fb.height = ps->height;
pipe->set_framebuffer_state(pipe, &fb);
sc.minx = sc.miny = 0;
sc.maxx = fb.width;
sc.maxy = fb.height;
pipe->set_scissor_state(pipe, &sc);
nv50_state_validate(nv50);
switch (ps->format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
BEGIN_RING(chan, tesla, 0x0d80, 4);
OUT_RINGf (chan, ubyte_to_float((clearValue >> 16) & 0xff));
OUT_RINGf (chan, ubyte_to_float((clearValue >> 8) & 0xff));
OUT_RINGf (chan, ubyte_to_float((clearValue >> 0) & 0xff));
OUT_RINGf (chan, ubyte_to_float((clearValue >> 24) & 0xff));
BEGIN_RING(chan, tesla, 0x19d0, 1);
OUT_RING (chan, 0x3c);
break;
case PIPE_FORMAT_Z24S8_UNORM:
BEGIN_RING(chan, tesla, 0x0d90, 1);
OUT_RINGf (chan, (float)(clearValue >> 8) * (1.0 / 16777215.0));
BEGIN_RING(chan, tesla, 0x0da0, 1);
OUT_RING (chan, clearValue & 0xff);
BEGIN_RING(chan, tesla, 0x19d0, 1);
OUT_RING (chan, 0x03);
break;
default:
pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height,
clearValue);
break;
if (buffers & PIPE_CLEAR_COLOR && fb->nr_cbufs) {
BEGIN_RING(chan, tesla, NV50TCL_CLEAR_COLOR(0), 4);
OUT_RING (chan, fui(rgba[0]));
OUT_RING (chan, fui(rgba[1]));
OUT_RING (chan, fui(rgba[2]));
OUT_RING (chan, fui(rgba[3]));
mode |= 0x3c;
}
pipe->set_framebuffer_state(pipe, &s_fb);
pipe->set_scissor_state(pipe, &s_sc);
nv50->dirty |= dirty;
if (buffers & PIPE_CLEAR_DEPTHSTENCIL) {
BEGIN_RING(chan, tesla, NV50TCL_CLEAR_DEPTH, 1);
OUT_RING (chan, fui(depth));
BEGIN_RING(chan, tesla, NV50TCL_CLEAR_STENCIL, 1);
OUT_RING (chan, stencil & 0xff);
mode |= 0x03;
}
BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1);
OUT_RING (chan, mode);
for (i = 1; i < fb->nr_cbufs; i++) {
BEGIN_RING(chan, tesla, NV50TCL_CLEAR_BUFFERS, 1);
OUT_RING (chan, (i << 6) | 0x3c);
}
}

View File

@ -51,6 +51,29 @@ nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
static unsigned int
nv50_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv50_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -76,6 +99,9 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv50->pipe.flush = nv50_flush;
nv50->pipe.is_texture_referenced = nv50_is_texture_referenced;
nv50->pipe.is_buffer_referenced = nv50_is_buffer_referenced;
nv50_init_surface_functions(nv50);
nv50_init_state_functions(nv50);
nv50_init_query_functions(nv50);

View File

@ -102,6 +102,29 @@ static void r300_destroy_context(struct pipe_context* context) {
FREE(r300);
}
static unsigned int
r300_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
r300_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context* r300_create_context(struct pipe_screen* screen,
struct r300_winsys* r300_winsys)
{
@ -124,6 +147,9 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300->context.draw_elements = r300_draw_elements;
r300->context.draw_range_elements = r300_draw_range_elements;
r300->context.is_texture_referenced = r300_is_texture_referenced;
r300->context.is_buffer_referenced = r300_is_buffer_referenced;
r300->draw = draw_create();
draw_set_rasterize_stage(r300->draw, r300_draw_stage(r300));

View File

@ -60,7 +60,7 @@ struct r300_dsa_state {
};
struct r300_rs_state {
/* XXX icky as fucking hell */
/* Draw-specific rasterizer state */
struct pipe_rasterizer_state rs;
uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */
@ -225,10 +225,11 @@ struct r300_vertex_format {
uint32_t vap_prog_stream_cntl[8];
/* R300_VAP_PROG_STREAK_CNTL_EXT_[0-7] */
uint32_t vap_prog_stream_cntl_ext[8];
/* This is a map of VAP/SW TCL outputs into the GA/RS.
* tab[i] is the location of input i in GA/RS input memory.
* Named tab for historical reasons. */
int tab[16];
/* Map of vertex attributes into PVS memory for HW TCL,
* or GA memory for SW TCL. */
int vs_tab[16];
/* Map of rasterizer attributes from GB through RS to US. */
int fs_tab[16];
};
struct r300_vertex_shader {

View File

@ -340,7 +340,11 @@ void r300_emit_vertex_shader(struct r300_context* r300,
return;
}
BEGIN_CS(13 + (vs->instruction_count * 4) + (constants->count * 4));
if (constants->count) {
BEGIN_CS(16 + (vs->instruction_count * 4) + (constants->count * 4));
} else {
BEGIN_CS(13 + (vs->instruction_count * 4) + (constants->count * 4));
}
OUT_CS_REG(R300_VAP_PVS_CODE_CNTL_0, R300_PVS_FIRST_INST(0) |
R300_PVS_LAST_INST(vs->instruction_count - 1));

View File

@ -234,6 +234,8 @@ static void r300_render_draw(struct vbuf_render* render,
struct pipe_screen* screen = r300->context.screen;
struct pipe_buffer* index_buffer;
void* index_map;
int i;
uint32_t index;
CS_LOCALS(r300);
@ -252,14 +254,24 @@ static void r300_render_draw(struct vbuf_render* render,
pipe_buffer_unmap(screen, index_buffer);
debug_printf("r300: Doing indexbuf render, count %d\n", count);
BEGIN_CS(6);
/*
BEGIN_CS(8);
OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, 0);
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
r300render->hwprim);
OUT_CS_PKT3(R300_PACKET3_INDX_BUFFER, 2);
OUT_CS(R300_INDX_BUFFER_ONE_REG_WR | (R300_VAP_PORT_IDX0 >> 2));
OUT_CS_INDEX_RELOC(index_buffer, 0, count, RADEON_GEM_DOMAIN_GTT, 0, 0);
END_CS; */
BEGIN_CS(2 + count);
OUT_CS_PKT3(R300_PACKET3_3D_DRAW_INDX_2, count);
OUT_CS(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (count << 16) |
r300render->hwprim | R300_VAP_VF_CNTL__INDEX_SIZE_32bit);
for (i = 0; i < count; i++) {
index = indices[i];
OUT_CS(index);
}
END_CS;
}

View File

@ -555,25 +555,41 @@ static void r300_set_viewport_state(struct pipe_context* pipe,
{
struct r300_context* r300 = r300_context(pipe);
r300->viewport_state->xscale = state->scale[0];
r300->viewport_state->yscale = state->scale[1];
r300->viewport_state->zscale = state->scale[2];
r300->viewport_state->xoffset = state->translate[0];
r300->viewport_state->yoffset = state->translate[1];
r300->viewport_state->zoffset = state->translate[2];
r300->viewport_state->vte_control = 0;
if (r300_screen(r300->context.screen)->caps->has_tcl) {
/* Do the transform in HW. */
r300->viewport_state->vte_control |=
R300_VPORT_X_SCALE_ENA | R300_VPORT_X_OFFSET_ENA |
R300_VPORT_Y_SCALE_ENA | R300_VPORT_Y_OFFSET_ENA |
R300_VPORT_Z_SCALE_ENA | R300_VPORT_Z_OFFSET_ENA;
r300->viewport_state->vte_control = R300_VTX_W0_FMT;
if (state->scale[0] != 1.0f) {
r300->viewport_state->xscale = state->scale[0];
r300->viewport_state->vte_control |= R300_VPORT_X_SCALE_ENA;
}
if (state->scale[1] != 1.0f) {
r300->viewport_state->yscale = state->scale[1];
r300->viewport_state->vte_control |= R300_VPORT_Y_SCALE_ENA;
}
if (state->scale[2] != 1.0f) {
r300->viewport_state->zscale = state->scale[2];
r300->viewport_state->vte_control |= R300_VPORT_Z_SCALE_ENA;
}
if (state->translate[0] != 0.0f) {
r300->viewport_state->xoffset = state->translate[0];
r300->viewport_state->vte_control |= R300_VPORT_X_OFFSET_ENA;
}
if (state->translate[1] != 0.0f) {
r300->viewport_state->yoffset = state->translate[1];
r300->viewport_state->vte_control |= R300_VPORT_Y_OFFSET_ENA;
}
if (state->translate[2] != 0.0f) {
r300->viewport_state->zoffset = state->translate[2];
r300->viewport_state->vte_control |= R300_VPORT_Z_OFFSET_ENA;
}
} else {
r300->viewport_state->vte_control = 0;
/* Have Draw do the actual transform. */
draw_set_viewport_state(r300->draw, state);
}
r300->dirty_state |= R300_NEW_VIEWPORT;
}
static void r300_set_vertex_buffers(struct pipe_context* pipe,

View File

@ -25,60 +25,82 @@
/* r300_state_derived: Various bits of state which are dependent upon
* currently bound CSO data. */
/* Update the vertex_info struct in our r300_context.
*
* The vertex_info struct describes the post-TCL format of vertices. It is
* required for Draw when doing SW TCL, and also for describing the
* dreaded RS block on R300 chipsets. */
static void r300_update_vertex_layout(struct r300_context* r300)
/* Set up the vs_tab and routes. */
static void r300_vs_tab_routes(struct r300_context* r300,
struct r300_vertex_format* vformat)
{
struct r300_screen* r300screen = r300_screen(r300->context.screen);
struct r300_vertex_format vformat;
struct vertex_info vinfo;
struct vertex_info* vinfo = &vformat->vinfo;
int* tab = vformat->vs_tab;
boolean pos = FALSE, psize = FALSE, fog = FALSE;
int i, texs = 0, cols = 0;
int tab[16];
struct tgsi_shader_info* info;
struct tgsi_shader_info* info = &r300->fs->info;
memset(&vinfo, 0, sizeof(vinfo));
for (i = 0; i < 16; i++) {
tab[i] = -1;
if (r300screen->caps->has_tcl) {
/* Use vertex shader to determine required routes. */
info = &r300->vs->info;
} else {
/* Use fragment shader to determine required routes. */
info = &r300->fs->info;
}
assert(info->num_inputs <= 16);
for (i = 0; i < info->num_inputs; i++) {
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
pos = TRUE;
tab[i] = 0;
break;
case TGSI_SEMANTIC_COLOR:
tab[i] = 2 + cols++;
break;
case TGSI_SEMANTIC_PSIZE:
psize = TRUE;
tab[i] = 1;
break;
case TGSI_SEMANTIC_FOG:
fog = TRUE;
/* Fall through... */
case TGSI_SEMANTIC_GENERIC:
tab[i] = 6 + texs++;
break;
default:
debug_printf("r300: Unknown vertex input %d\n",
info->input_semantic_name[i]);
break;
}
}
if (r300screen->caps->has_tcl) {
/* Just copy vert attribs over as-is. */
for (i = 0; i < info->num_inputs; i++) {
/* XXX should probably do real lookup with vert shader */
tab[i] = i;
}
for (i = 0; i < info->num_outputs; i++) {
switch (info->output_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
pos = TRUE;
break;
case TGSI_SEMANTIC_COLOR:
cols++;
break;
case TGSI_SEMANTIC_PSIZE:
psize = TRUE;
break;
case TGSI_SEMANTIC_FOG:
fog = TRUE;
case TGSI_SEMANTIC_GENERIC:
texs++;
break;
default:
debug_printf("r300: Unknown vertex output %d\n",
info->output_semantic_name[i]);
break;
}
}
} else {
for (i = 0; i < info->num_inputs; i++) {
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
pos = TRUE;
tab[i] = 0;
break;
case TGSI_SEMANTIC_COLOR:
tab[i] = 2 + cols;
cols++;
break;
case TGSI_SEMANTIC_PSIZE:
psize = TRUE;
tab[i] = 15;
break;
case TGSI_SEMANTIC_FOG:
fog = TRUE;
/* Fall through */
case TGSI_SEMANTIC_GENERIC:
tab[i] = 6 + texs;
texs++;
break;
default:
debug_printf("r300: Unknown vertex input %d\n",
info->input_semantic_name[i]);
break;
}
}
}
/* Do the actual vertex_info setup.
@ -89,7 +111,7 @@ static void r300_update_vertex_layout(struct r300_context* r300)
* vinfo.hwfmt[2] is R300_VAP_OUTPUT_VTX_FMT_0
* vinfo.hwfmt[3] is R300_VAP_OUTPUT_VTX_FMT_1 */
vinfo.hwfmt[0] = 0x5555; /* XXX this is classic Mesa bonghits */
vinfo->hwfmt[0] = 0x5555; /* XXX this is classic Mesa bonghits */
if (!pos) {
debug_printf("r300: Forcing vertex position attribute emit...\n");
@ -99,109 +121,199 @@ static void r300_update_vertex_layout(struct r300_context* r300)
tab[i] = tab[i-1];
}
tab[0] = 0;
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_POS,
draw_find_vs_output(r300->draw, TGSI_SEMANTIC_POSITION, 0));
} else {
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE,
draw_find_vs_output(r300->draw, TGSI_SEMANTIC_POSITION, 0));
}
vinfo.hwfmt[1] |= R300_INPUT_CNTL_POS;
vinfo.hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
draw_find_vs_output(r300->draw, TGSI_SEMANTIC_POSITION, 0));
vinfo->hwfmt[1] |= R300_INPUT_CNTL_POS;
vinfo->hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
if (psize) {
draw_emit_vertex_attr(&vinfo, EMIT_1F_PSIZE, INTERP_POS,
draw_emit_vertex_attr(vinfo, EMIT_1F_PSIZE, INTERP_POS,
draw_find_vs_output(r300->draw, TGSI_SEMANTIC_PSIZE, 0));
vinfo.hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
vinfo->hwfmt[2] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
}
for (i = 0; i < cols; i++) {
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_LINEAR,
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_LINEAR,
draw_find_vs_output(r300->draw, TGSI_SEMANTIC_COLOR, i));
vinfo.hwfmt[1] |= R300_INPUT_CNTL_COLOR;
vinfo.hwfmt[2] |= (R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i);
vinfo->hwfmt[1] |= R300_INPUT_CNTL_COLOR;
vinfo->hwfmt[2] |= (R300_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT << i);
}
for (i = 0; i < texs; i++) {
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE,
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
draw_find_vs_output(r300->draw, TGSI_SEMANTIC_GENERIC, i));
vinfo.hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
vinfo.hwfmt[3] |= (4 << (3 * i));
vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
vinfo->hwfmt[3] |= (4 << (3 * i));
}
if (fog) {
i++;
draw_emit_vertex_attr(&vinfo, EMIT_4F, INTERP_PERSPECTIVE,
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE,
draw_find_vs_output(r300->draw, TGSI_SEMANTIC_FOG, 0));
vinfo.hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
vinfo.hwfmt[3] |= (4 << (3 * i));
vinfo->hwfmt[1] |= (R300_INPUT_CNTL_TC0 << i);
vinfo->hwfmt[3] |= (4 << (3 * i));
}
draw_compute_vertex_size(&vinfo);
draw_compute_vertex_size(vinfo);
}
if (memcmp(&r300->vertex_info, &vinfo, sizeof(struct vertex_info))) {
uint32_t temp;
debug_printf("attrib count: %d, fp input count: %d\n",
vinfo.num_attribs, info->num_inputs);
for (i = 0; i < vinfo.num_attribs; i++) {
debug_printf("attrib: offset %d, interp %d, size %d,"
" tab %d\n", vinfo.attrib[i].src_index,
vinfo.attrib[i].interp_mode, vinfo.attrib[i].emit,
tab[i]);
/* Update the PSC tables. */
static void r300_vertex_psc(struct r300_context* r300,
struct r300_vertex_format* vformat)
{
struct vertex_info* vinfo = &vformat->vinfo;
int* tab = vformat->vs_tab;
uint32_t temp;
int i;
debug_printf("r300: attrib count: %d\n", vinfo->num_attribs);
for (i = 0; i < vinfo->num_attribs; i++) {
debug_printf("r300: attrib: offset %d, interp %d, size %d,"
" tab %d\n", vinfo->attrib[i].src_index,
vinfo->attrib[i].interp_mode, vinfo->attrib[i].emit,
tab[i]);
}
for (i = 0; i < vinfo->num_attribs; i++) {
/* Make sure we have a proper destination for our attribute */
assert(tab[i] != -1);
/* Add the attribute to the PSC table. */
temp = translate_vertex_data_type(vinfo->attrib[i].emit) |
(tab[i] << R300_DST_VEC_LOC_SHIFT);
if (i & 1) {
vformat->vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;
vformat->vap_prog_stream_cntl[i >> 1] |= temp << 16;
vformat->vap_prog_stream_cntl_ext[i >> 1] |=
(R300_VAP_SWIZZLE_XYZW << 16);
} else {
vformat->vap_prog_stream_cntl[i >> 1] &= 0xffff0000;
vformat->vap_prog_stream_cntl[i >> 1] |= temp << 0;
vformat->vap_prog_stream_cntl_ext[i >> 1] |=
(R300_VAP_SWIZZLE_XYZW << 0);
}
}
for (i = 0; i < vinfo.num_attribs; i++) {
/* Make sure we have a proper destination for our attribute */
assert(tab[i] != -1);
/* Set the last vector in the PSC. */
i--;
vformat->vap_prog_stream_cntl[i >> 1] |=
(R300_LAST_VEC << (i & 1 ? 16 : 0));
}
temp = translate_vertex_data_type(vinfo.attrib[i].emit) |
(tab[i] << R300_DST_VEC_LOC_SHIFT);
if (i & 1) {
r300->vertex_info.vap_prog_stream_cntl[i >> 1] &= 0x0000ffff;
r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= temp << 16;
} else {
r300->vertex_info.vap_prog_stream_cntl[i >> 1] &= 0xffff0000;
r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= temp;
}
/* Update the vertex format. */
static void r300_update_vertex_format(struct r300_context* r300)
{
struct r300_screen* r300screen = r300_screen(r300->context.screen);
struct r300_vertex_format vformat;
int i;
r300->vertex_info.vap_prog_stream_cntl_ext[i >> 1] |=
(R300_VAP_SWIZZLE_XYZW << (i & 1 ? 16 : 0));
}
/* Set the last vector. */
i--;
r300->vertex_info.vap_prog_stream_cntl[i >> 1] |= (R300_LAST_VEC <<
(i & 1 ? 16 : 0));
memset(&vformat, 0, sizeof(struct r300_vertex_format));
for (i = 0; i < 16; i++) {
vformat.vs_tab[i] = -1;
vformat.fs_tab[i] = -1;
}
memcpy(r300->vertex_info.tab, tab, sizeof(tab));
memcpy(&r300->vertex_info, &vinfo, sizeof(struct vertex_info));
r300_vs_tab_routes(r300, &vformat);
r300_vertex_psc(r300, &vformat);
if (memcmp(&r300->vertex_info, &vformat,
sizeof(struct r300_vertex_format))) {
memcpy(&r300->vertex_info, &vformat,
sizeof(struct r300_vertex_format));
r300->dirty_state |= R300_NEW_VERTEX_FORMAT;
}
}
/* Set up the mappings from GB to US, for RS block. */
static void r300_update_fs_tab(struct r300_context* r300)
{
struct r300_vertex_format* vformat = &r300->vertex_info;
struct tgsi_shader_info* info = &r300->fs->info;
int i, cols = 0, texs = 0, cols_emitted = 0;
int* tab = vformat->fs_tab;
for (i = 0; i < 16; i++) {
tab[i] = -1;
}
assert(info->num_inputs <= 16);
for (i = 0; i < info->num_inputs; i++) {
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
tab[i] = INTERP_LINEAR;
cols++;
break;
case TGSI_SEMANTIC_POSITION:
case TGSI_SEMANTIC_PSIZE:
debug_printf("r300: Implementation error: Can't use "
"pos attribs in fragshader yet!\n");
/* Pass through for now */
case TGSI_SEMANTIC_FOG:
case TGSI_SEMANTIC_GENERIC:
tab[i] = INTERP_PERSPECTIVE;
break;
default:
debug_printf("r300: Unknown vertex input %d\n",
info->input_semantic_name[i]);
break;
}
}
/* Now that we know where everything is... */
debug_printf("r300: fp input count: %d\n", info->num_inputs);
for (i = 0; i < info->num_inputs; i++) {
switch (tab[i]) {
case INTERP_LINEAR:
debug_printf("r300: attrib: "
"stack offset %d, color, tab %d\n",
i, cols_emitted);
tab[i] = cols_emitted;
cols_emitted++;
break;
case INTERP_PERSPECTIVE:
debug_printf("r300: attrib: "
"stack offset %d, texcoord, tab %d\n",
i, cols + texs);
tab[i] = cols + texs;
texs++;
break;
case -1:
debug_printf("r300: Implementation error: Bad fp interp!\n");
default:
break;
}
}
}
/* Set up the RS block. This is the part of the chipset that actually does
* the rasterization of vertices into fragments. This is also the part of the
* chipset that locks up if any part of it is even slightly wrong. */
static void r300_update_rs_block(struct r300_context* r300)
{
struct r300_rs_block* rs = r300->rs_block;
struct vertex_info* vinfo = &r300->vertex_info.vinfo;
int* tab = r300->vertex_info.tab;
struct tgsi_shader_info* info = &r300->fs->info;
int* tab = r300->vertex_info.fs_tab;
int col_count = 0, fp_offset = 0, i, memory_pos, tex_count = 0;
memset(rs, 0, sizeof(struct r300_rs_block));
if (r300_screen(r300->context.screen)->caps->is_r500) {
for (i = 0; i < vinfo->num_attribs; i++) {
assert(tab[vinfo->attrib[i].src_index] != -1);
memory_pos = tab[vinfo->attrib[i].src_index] * 4;
switch (vinfo->attrib[i].interp_mode) {
case INTERP_LINEAR:
for (i = 0; i < info->num_inputs; i++) {
assert(tab[i] != -1);
memory_pos = tab[i] * 4;
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
rs->ip[col_count] |=
R500_RS_COL_PTR(memory_pos) |
R500_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
col_count++;
break;
case INTERP_PERSPECTIVE:
case TGSI_SEMANTIC_GENERIC:
rs->ip[tex_count] |=
R500_RS_SEL_S(memory_pos) |
R500_RS_SEL_T(memory_pos + 1) |
@ -243,17 +355,17 @@ static void r300_update_rs_block(struct r300_context* r300)
fp_offset++;
}
} else {
for (i = 0; i < vinfo->num_attribs; i++) {
memory_pos = tab[vinfo->attrib[i].src_index] * 4;
assert(tab[vinfo->attrib[i].src_index] != -1);
switch (vinfo->attrib[i].interp_mode) {
case INTERP_LINEAR:
for (i = 0; i < info->num_inputs; i++) {
assert(tab[i] != -1);
memory_pos = tab[i] * 4;
switch (info->input_semantic_name[i]) {
case TGSI_SEMANTIC_COLOR:
rs->ip[col_count] |=
R300_RS_COL_PTR(memory_pos) |
R300_RS_COL_FMT(R300_RS_COL_FMT_RGBA);
col_count++;
break;
case INTERP_PERSPECTIVE:
case TGSI_SEMANTIC_GENERIC:
rs->ip[tex_count] |=
R300_RS_TEX_PTR(memory_pos) |
R300_RS_SEL_S(R300_RS_SEL_C0) |
@ -307,10 +419,11 @@ void r300_update_derived_state(struct r300_context* r300)
{
if (r300->dirty_state &
(R300_NEW_FRAGMENT_SHADER | R300_NEW_VERTEX_SHADER)) {
r300_update_vertex_layout(r300);
r300_update_vertex_format(r300);
}
if (r300->dirty_state & R300_NEW_VERTEX_FORMAT) {
r300_update_fs_tab(r300);
r300_update_rs_block(r300);
}
}

View File

@ -40,6 +40,9 @@ static void r300_vs_declare(struct r300_vs_asm* assembler,
/* XXX multiple? */
assembler->tab[decl->DeclarationRange.First] = 6;
break;
case TGSI_SEMANTIC_PSIZE:
assembler->tab[decl->DeclarationRange.First] = 15;
break;
default:
debug_printf("r300: vs: Bad semantic declaration %d\n",
decl->Semantic.SemanticName);
@ -117,6 +120,9 @@ static INLINE unsigned r300_vs_dst(struct r300_vs_asm* assembler,
static uint32_t r300_vs_op(unsigned op)
{
switch (op) {
case TGSI_OPCODE_DP3:
case TGSI_OPCODE_DP4:
return R300_VE_DOT_PRODUCT;
case TGSI_OPCODE_MUL:
return R300_VE_MULTIPLY;
case TGSI_OPCODE_ADD:
@ -195,6 +201,36 @@ static void r300_vs_instruction(struct r300_vertex_shader* vs,
&inst->FullDstRegisters[0], inst->Instruction.Opcode,
2);
break;
case TGSI_OPCODE_DP3:
/* Set alpha swizzle to zero for src0 and src1 */
if (!inst->FullSrcRegisters[0].SrcRegister.Extended) {
inst->FullSrcRegisters[0].SrcRegister.Extended = TRUE;
inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleX =
inst->FullSrcRegisters[0].SrcRegister.SwizzleX;
inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleY =
inst->FullSrcRegisters[0].SrcRegister.SwizzleY;
inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleZ =
inst->FullSrcRegisters[0].SrcRegister.SwizzleZ;
}
inst->FullSrcRegisters[0].SrcRegisterExtSwz.ExtSwizzleW =
TGSI_EXTSWIZZLE_ZERO;
if (!inst->FullSrcRegisters[1].SrcRegister.Extended) {
inst->FullSrcRegisters[1].SrcRegister.Extended = TRUE;
inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleX =
inst->FullSrcRegisters[1].SrcRegister.SwizzleX;
inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleY =
inst->FullSrcRegisters[1].SrcRegister.SwizzleY;
inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleZ =
inst->FullSrcRegisters[1].SrcRegister.SwizzleZ;
}
inst->FullSrcRegisters[1].SrcRegisterExtSwz.ExtSwizzleW =
TGSI_EXTSWIZZLE_ZERO;
/* Fall through */
case TGSI_OPCODE_DP4:
r300_vs_emit_inst(vs, assembler, inst->FullSrcRegisters,
&inst->FullDstRegisters[0], inst->Instruction.Opcode,
2);
break;
case TGSI_OPCODE_MOV:
case TGSI_OPCODE_SWZ:
inst->FullSrcRegisters[1] = r300_constant_zero;

View File

@ -32,6 +32,7 @@
/* XXX get these to r300_reg */
#define R300_PVS_DST_OPCODE(x) ((x) << 0)
# define R300_VE_DOT_PRODUCT 1
# define R300_VE_MULTIPLY 2
# define R300_VE_ADD 3
#define R300_PVS_DST_MACRO_INST (1 << 7)

View File

@ -121,11 +121,23 @@ static void softpipe_destroy( struct pipe_context *pipe )
FREE( softpipe );
}
static unsigned int
softpipe_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
softpipe_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
softpipe_create( struct pipe_screen *screen,
struct pipe_winsys *pipe_winsys,
void *unused )
softpipe_create( struct pipe_screen *screen )
{
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
uint i;
@ -140,7 +152,7 @@ softpipe_create( struct pipe_screen *screen,
softpipe->dump_fs = debug_get_bool_option( "GALLIUM_DUMP_FS", FALSE );
softpipe->pipe.winsys = pipe_winsys;
softpipe->pipe.winsys = screen->winsys;
softpipe->pipe.screen = screen;
softpipe->pipe.destroy = softpipe_destroy;
@ -190,6 +202,9 @@ softpipe_create( struct pipe_screen *screen,
softpipe->pipe.clear = softpipe_clear;
softpipe->pipe.flush = softpipe_flush;
softpipe->pipe.is_texture_referenced = softpipe_is_texture_referenced;
softpipe->pipe.is_buffer_referenced = softpipe_is_buffer_referenced;
softpipe_init_query_funcs( softpipe );
softpipe_init_texture_funcs( softpipe );

View File

@ -35,31 +35,17 @@
#define SP_WINSYS_H
#include "pipe/p_compiler.h" /* for boolean */
#ifdef __cplusplus
extern "C" {
#endif
enum pipe_format;
struct softpipe_winsys {
/** test if the given format is supported for front/back color bufs */
boolean (*is_format_supported)( struct softpipe_winsys *sws,
enum pipe_format format );
};
struct pipe_screen;
struct pipe_winsys;
struct pipe_context;
struct pipe_context *softpipe_create( struct pipe_screen *,
struct pipe_winsys *,
void *unused );
struct pipe_context *softpipe_create( struct pipe_screen * );
struct pipe_screen *

View File

@ -27,10 +27,10 @@
#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "tr_buffer.h"
struct pipe_buffer *
trace_buffer_create(struct trace_screen *tr_scr,
struct pipe_buffer *buffer)
@ -52,6 +52,8 @@ trace_buffer_create(struct trace_screen *tr_scr,
tr_buf->base.screen = &tr_scr->base;
tr_buf->buffer = buffer;
trace_screen_add_to_list(tr_scr, buffers, tr_buf);
return &tr_buf->base;
error:
@ -64,7 +66,10 @@ void
trace_buffer_destroy(struct trace_screen *tr_scr,
struct pipe_buffer *buffer)
{
struct trace_buffer *tr_buf = trace_buffer(tr_scr, buffer);
struct trace_buffer *tr_buf = trace_buffer(buffer);
trace_screen_remove_from_list(tr_scr, buffers, tr_buf);
pipe_buffer_reference(&tr_buf->buffer, NULL);
FREE(tr_buf);
}

View File

@ -41,19 +41,19 @@ struct trace_buffer
struct pipe_buffer *buffer;
struct tr_list list;
void *map;
boolean range_flushed;
};
static INLINE struct trace_buffer *
trace_buffer(struct trace_screen *tr_scr,
struct pipe_buffer *buffer)
trace_buffer(struct pipe_buffer *buffer)
{
if(!buffer)
return NULL;
assert(tr_scr);
assert(buffer->screen == &tr_scr->base);
(void)trace_screen(buffer->screen);
return (struct trace_buffer *)buffer;
}

View File

@ -26,6 +26,8 @@
**************************************************************************/
#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "pipe/p_screen.h"
#include "tr_dump.h"
@ -46,7 +48,7 @@ trace_buffer_unwrap(struct trace_context *tr_ctx,
if(!buffer)
return NULL;
tr_buf = trace_buffer(tr_scr, buffer);
tr_buf = trace_buffer(buffer);
assert(tr_buf->buffer);
assert(tr_buf->buffer->screen == tr_scr->screen);
@ -142,9 +144,8 @@ trace_context_draw_elements(struct pipe_context *_pipe,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer);
struct trace_buffer *tr_buf = trace_buffer(_indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_buffer *indexBuffer = tr_buf->buffer;
boolean result;
@ -180,9 +181,8 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
unsigned start,
unsigned count)
{
struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer);
struct trace_buffer *tr_buf = trace_buffer(_indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_buffer *indexBuffer = tr_buf->buffer;
boolean result;
@ -1016,20 +1016,67 @@ trace_context_flush(struct pipe_context *_pipe,
static INLINE void
trace_context_destroy(struct pipe_context *_pipe)
{
struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
trace_dump_call_begin("pipe_context", "destroy");
trace_dump_arg(ptr, pipe);
trace_dump_call_end();
trace_screen_remove_from_list(tr_scr, contexts, tr_ctx);
pipe->destroy(pipe);
trace_dump_call_end();
FREE(tr_ctx);
}
static unsigned int
trace_is_texture_referenced( struct pipe_context *_pipe,
struct pipe_texture *_texture,
unsigned face, unsigned level)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct trace_texture *tr_tex = trace_texture(_texture);
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_texture *texture = tr_tex->texture;
unsigned int referenced;
trace_dump_call_begin("pipe_context", "is_texture_referenced");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, texture);
trace_dump_arg(uint, face);
trace_dump_arg(uint, level);
referenced = pipe->is_texture_referenced(pipe, texture, face, level);
trace_dump_ret(uint, referenced);
trace_dump_call_end();
return referenced;
}
static unsigned int
trace_is_buffer_referenced( struct pipe_context *_pipe,
struct pipe_buffer *_buf)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct trace_buffer *tr_buf = trace_buffer(_buf);
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_buffer *buf = tr_buf->buffer;
unsigned int referenced;
trace_dump_call_begin("pipe_context", "is_buffer_referenced");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, buf);
referenced = pipe->is_buffer_referenced(pipe, buf);
trace_dump_ret(uint, referenced);
trace_dump_call_end();
return referenced;
}
struct pipe_context *
trace_context_create(struct pipe_screen *_screen,
@ -1042,7 +1089,7 @@ trace_context_create(struct pipe_screen *_screen,
if(!pipe)
goto error1;
if(!trace_dump_enabled())
if(!trace_dump_trace_enabled())
goto error1;
tr_scr = trace_screen(_screen);
@ -1096,6 +1143,8 @@ trace_context_create(struct pipe_screen *_screen,
tr_ctx->base.surface_fill = trace_context_surface_fill;
tr_ctx->base.clear = trace_context_clear;
tr_ctx->base.flush = trace_context_flush;
tr_ctx->base.is_texture_referenced = trace_is_texture_referenced;
tr_ctx->base.is_buffer_referenced = trace_is_buffer_referenced;
tr_ctx->pipe = pipe;
@ -1104,6 +1153,8 @@ trace_context_create(struct pipe_screen *_screen,
trace_dump_ret(ptr, pipe);
trace_dump_call_end();
trace_screen_add_to_list(tr_scr, contexts, tr_ctx);
return &tr_ctx->base;
error1:

View File

@ -44,6 +44,8 @@ struct trace_context
struct pipe_context base;
struct pipe_context *pipe;
struct tr_list list;
};

View File

@ -61,6 +61,8 @@ static struct util_stream *stream = NULL;
static unsigned refcount = 0;
static pipe_mutex call_mutex;
static long unsigned call_no = 0;
static boolean dumping = FALSE;
static boolean initialized = FALSE;
static INLINE void
@ -226,10 +228,22 @@ trace_dump_trace_close(void)
}
}
void trace_dump_init()
{
if (initialized)
return;
pipe_mutex_init(call_mutex);
dumping = FALSE;
initialized = TRUE;
}
boolean trace_dump_trace_begin()
{
const char *filename;
assert(initialized);
filename = debug_get_option("GALLIUM_TRACE", NULL);
if(!filename)
return FALSE;
@ -240,8 +254,6 @@ boolean trace_dump_trace_begin()
if(!stream)
return FALSE;
pipe_mutex_init(call_mutex);
trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
trace_dump_writes("<trace version='0.1'>\n");
@ -258,7 +270,7 @@ boolean trace_dump_trace_begin()
return TRUE;
}
boolean trace_dump_enabled(void)
boolean trace_dump_trace_enabled(void)
{
return stream ? TRUE : FALSE;
}
@ -270,9 +282,71 @@ void trace_dump_trace_end(void)
trace_dump_trace_close();
}
void trace_dump_call_begin(const char *klass, const char *method)
/*
* Call lock
*/
void trace_dump_call_lock(void)
{
pipe_mutex_lock(call_mutex);
}
void trace_dump_call_unlock(void)
{
pipe_mutex_unlock(call_mutex);
}
/*
* Dumping control
*/
void trace_dumping_start_locked(void)
{
dumping = TRUE;
}
void trace_dumping_stop_locked(void)
{
dumping = FALSE;
}
boolean trace_dumping_enabled_locked(void)
{
return dumping;
}
void trace_dumping_start(void)
{
pipe_mutex_lock(call_mutex);
trace_dumping_start_locked();
pipe_mutex_unlock(call_mutex);
}
void trace_dumping_stop(void)
{
pipe_mutex_lock(call_mutex);
trace_dumping_stop_locked();
pipe_mutex_unlock(call_mutex);
}
boolean trace_dumping_enabled(void)
{
boolean ret;
pipe_mutex_lock(call_mutex);
ret = trace_dumping_enabled_locked();
pipe_mutex_unlock(call_mutex);
return ret;
}
/*
* Dump functions
*/
void trace_dump_call_begin_locked(const char *klass, const char *method)
{
if (!dumping)
return;
++call_no;
trace_dump_indent(1);
trace_dump_writes("<call no=\'");
@ -285,56 +359,94 @@ void trace_dump_call_begin(const char *klass, const char *method)
trace_dump_newline();
}
void trace_dump_call_end(void)
void trace_dump_call_end_locked(void)
{
if (!dumping)
return;
trace_dump_indent(1);
trace_dump_tag_end("call");
trace_dump_newline();
util_stream_flush(stream);
}
void trace_dump_call_begin(const char *klass, const char *method)
{
pipe_mutex_lock(call_mutex);
trace_dump_call_begin_locked(klass, method);
}
void trace_dump_call_end(void)
{
trace_dump_call_end_locked();
pipe_mutex_unlock(call_mutex);
}
void trace_dump_arg_begin(const char *name)
{
if (!dumping)
return;
trace_dump_indent(2);
trace_dump_tag_begin1("arg", "name", name);
}
void trace_dump_arg_end(void)
{
if (!dumping)
return;
trace_dump_tag_end("arg");
trace_dump_newline();
}
void trace_dump_ret_begin(void)
{
if (!dumping)
return;
trace_dump_indent(2);
trace_dump_tag_begin("ret");
}
void trace_dump_ret_end(void)
{
if (!dumping)
return;
trace_dump_tag_end("ret");
trace_dump_newline();
}
void trace_dump_bool(int value)
{
if (!dumping)
return;
trace_dump_writef("<bool>%c</bool>", value ? '1' : '0');
}
void trace_dump_int(long long int value)
{
if (!dumping)
return;
trace_dump_writef("<int>%lli</int>", value);
}
void trace_dump_uint(long long unsigned value)
{
if (!dumping)
return;
trace_dump_writef("<uint>%llu</uint>", value);
}
void trace_dump_float(double value)
{
if (!dumping)
return;
trace_dump_writef("<float>%g</float>", value);
}
@ -344,6 +456,10 @@ void trace_dump_bytes(const void *data,
static const char hex_table[16] = "0123456789ABCDEF";
const uint8_t *p = data;
long unsigned i;
if (!dumping)
return;
trace_dump_writes("<bytes>");
for(i = 0; i < size; ++i) {
uint8_t byte = *p++;
@ -357,6 +473,9 @@ void trace_dump_bytes(const void *data,
void trace_dump_string(const char *str)
{
if (!dumping)
return;
trace_dump_writes("<string>");
trace_dump_escape(str);
trace_dump_writes("</string>");
@ -364,6 +483,9 @@ void trace_dump_string(const char *str)
void trace_dump_enum(const char *value)
{
if (!dumping)
return;
trace_dump_writes("<enum>");
trace_dump_escape(value);
trace_dump_writes("</enum>");
@ -371,51 +493,81 @@ void trace_dump_enum(const char *value)
void trace_dump_array_begin(void)
{
if (!dumping)
return;
trace_dump_writes("<array>");
}
void trace_dump_array_end(void)
{
if (!dumping)
return;
trace_dump_writes("</array>");
}
void trace_dump_elem_begin(void)
{
if (!dumping)
return;
trace_dump_writes("<elem>");
}
void trace_dump_elem_end(void)
{
if (!dumping)
return;
trace_dump_writes("</elem>");
}
void trace_dump_struct_begin(const char *name)
{
if (!dumping)
return;
trace_dump_writef("<struct name='%s'>", name);
}
void trace_dump_struct_end(void)
{
if (!dumping)
return;
trace_dump_writes("</struct>");
}
void trace_dump_member_begin(const char *name)
{
if (!dumping)
return;
trace_dump_writef("<member name='%s'>", name);
}
void trace_dump_member_end(void)
{
if (!dumping)
return;
trace_dump_writes("</member>");
}
void trace_dump_null(void)
{
if (!dumping)
return;
trace_dump_writes("<null/>");
}
void trace_dump_ptr(const void *value)
{
if (!dumping)
return;
if(value)
trace_dump_writef("<ptr>0x%08lx</ptr>", (unsigned long)(uintptr_t)value);
else
@ -424,9 +576,11 @@ void trace_dump_ptr(const void *value)
void trace_dump_buffer_ptr(struct pipe_buffer *_buffer)
{
if (!dumping)
return;
if (_buffer) {
struct trace_screen *tr_scr = trace_screen(_buffer->screen);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct trace_buffer *tr_buf = trace_buffer(_buffer);
trace_dump_ptr(tr_buf->buffer);
} else {
trace_dump_null();
@ -435,6 +589,9 @@ void trace_dump_buffer_ptr(struct pipe_buffer *_buffer)
void trace_dump_texture_ptr(struct pipe_texture *_texture)
{
if (!dumping)
return;
if (_texture) {
struct trace_texture *tr_tex = trace_texture(_texture);
trace_dump_ptr(tr_tex->texture);
@ -445,6 +602,9 @@ void trace_dump_texture_ptr(struct pipe_texture *_texture)
void trace_dump_surface_ptr(struct pipe_surface *_surface)
{
if (!dumping)
return;
if (_surface) {
struct trace_surface *tr_surf = trace_surface(_surface);
trace_dump_ptr(tr_surf->surface);
@ -455,6 +615,9 @@ void trace_dump_surface_ptr(struct pipe_surface *_surface)
void trace_dump_transfer_ptr(struct pipe_transfer *_transfer)
{
if (!dumping)
return;
if (_transfer) {
struct trace_transfer *tr_tran = trace_transfer(_transfer);
trace_dump_ptr(tr_tran->transfer);

View File

@ -42,11 +42,47 @@ struct pipe_texture;
struct pipe_surface;
struct pipe_transfer;
/*
* Call before use.
*/
void trace_dump_init(void);
/*
* Low level dumping controls.
*
* Opening the trace file and checking if that is opened.
*/
boolean trace_dump_trace_begin(void);
boolean trace_dump_enabled(void);
boolean trace_dump_trace_enabled(void);
void trace_dump_trace_end(void);
/*
* Lock and unlock the call mutex.
*
* It used by the none locked version of dumping control
* and begin/end call dump functions.
*
* Begin takes the lock while end unlocks it. Use the _locked
* version to avoid locking/unlocking it.
*/
void trace_dump_call_lock(void);
void trace_dump_call_unlock(void);
/*
* High level dumping control.
*/
void trace_dumping_start_locked(void);
void trace_dumping_stop_locked(void);
boolean trace_dumping_enabled_locked(void);
void trace_dumping_start(void);
void trace_dumping_stop(void);
boolean trace_dumping_enabled(void);
void trace_dump_call_begin_locked(const char *klass, const char *method);
void trace_dump_call_end_locked(void);
void trace_dump_call_begin(const char *klass, const char *method);
void trace_dump_call_end(void);
void trace_dump_arg_begin(const char *name);
void trace_dump_arg_end(void);
void trace_dump_ret_begin(void);

View File

@ -26,6 +26,7 @@
**************************************************************************/
#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "tr_buffer.h"
#include "tr_dump.h"
@ -603,7 +604,7 @@ trace_screen_buffer_map(struct pipe_screen *_screen,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct trace_buffer *tr_buf = trace_buffer(_buffer);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_buffer *buffer = tr_buf->buffer;
void *map;
@ -628,7 +629,7 @@ trace_screen_buffer_map_range(struct pipe_screen *_screen,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct trace_buffer *tr_buf = trace_buffer(_buffer);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_buffer *buffer = tr_buf->buffer;
void *map;
@ -680,7 +681,7 @@ trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen,
unsigned length)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct trace_buffer *tr_buf = trace_buffer(_buffer);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_buffer *buffer = tr_buf->buffer;
@ -696,7 +697,7 @@ trace_screen_buffer_unmap(struct pipe_screen *_screen,
struct pipe_buffer *_buffer)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct trace_buffer *tr_buf = trace_buffer(_buffer);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_buffer *buffer = tr_buf->buffer;
@ -712,7 +713,7 @@ static void
trace_screen_buffer_destroy(struct pipe_buffer *_buffer)
{
struct trace_screen *tr_scr = trace_screen(_buffer->screen);
struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct trace_buffer *tr_buf = trace_buffer(_buffer);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_buffer *buffer = tr_buf->buffer;
@ -734,19 +735,23 @@ trace_screen_buffer_destroy(struct pipe_buffer *_buffer)
static void
trace_screen_fence_reference(struct pipe_screen *_screen,
struct pipe_fence_handle **dst,
struct pipe_fence_handle **pdst,
struct pipe_fence_handle *src)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
struct pipe_fence_handle *dst;
assert(pdst);
dst = *pdst;
trace_dump_call_begin("pipe_screen", "fence_reference");
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, dst);
trace_dump_arg(ptr, src);
screen->fence_reference(screen, dst, src);
screen->fence_reference(screen, pdst, src);
trace_dump_call_end();
}
@ -755,7 +760,7 @@ trace_screen_fence_reference(struct pipe_screen *_screen,
static int
trace_screen_fence_signalled(struct pipe_screen *_screen,
struct pipe_fence_handle *fence,
unsigned flag)
unsigned flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
@ -765,9 +770,9 @@ trace_screen_fence_signalled(struct pipe_screen *_screen,
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, fence);
trace_dump_arg(uint, flag);
trace_dump_arg(uint, flags);
result = screen->fence_signalled(screen, fence, flag);
result = screen->fence_signalled(screen, fence, flags);
trace_dump_ret(int, result);
@ -780,7 +785,7 @@ trace_screen_fence_signalled(struct pipe_screen *_screen,
static int
trace_screen_fence_finish(struct pipe_screen *_screen,
struct pipe_fence_handle *fence,
unsigned flag)
unsigned flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
@ -790,9 +795,9 @@ trace_screen_fence_finish(struct pipe_screen *_screen,
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, fence);
trace_dump_arg(uint, flag);
trace_dump_arg(uint, flags);
result = screen->fence_finish(screen, fence, flag);
result = screen->fence_finish(screen, fence, flags);
trace_dump_ret(int, result);
@ -835,9 +840,13 @@ trace_screen_create(struct pipe_screen *screen)
if(!screen)
goto error1;
trace_dump_init();
if(!trace_dump_trace_begin())
goto error1;
trace_dumping_start();
trace_dump_call_begin("", "pipe_screen_create");
tr_scr = CALLOC_STRUCT(trace_screen);
@ -851,6 +860,12 @@ trace_screen_create(struct pipe_screen *screen)
#else
winsys = screen->winsys;
#endif
pipe_mutex_init(tr_scr->list_mutex);
make_empty_list(&tr_scr->buffers);
make_empty_list(&tr_scr->contexts);
make_empty_list(&tr_scr->textures);
make_empty_list(&tr_scr->surfaces);
make_empty_list(&tr_scr->transfers);
tr_scr->base.winsys = winsys;
tr_scr->base.destroy = trace_screen_destroy;

View File

@ -30,6 +30,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_thread.h"
#ifdef __cplusplus
@ -37,6 +38,11 @@ extern "C" {
#endif
struct tr_list {
struct tr_list *next;
struct tr_list *prev;
};
/**
* It often happens that new data is written directly to the user buffers
* without mapping/unmapping. This flag marks user buffers, so that their
@ -50,6 +56,18 @@ struct trace_screen
struct pipe_screen base;
struct pipe_screen *screen;
pipe_mutex list_mutex;
int num_buffers;
int num_contexts;
int num_textures;
int num_surfaces;
int num_transfers;
struct tr_list buffers;
struct tr_list contexts;
struct tr_list textures;
struct tr_list surfaces;
struct tr_list transfers;
};
@ -65,6 +83,21 @@ void
trace_screen_user_buffer_update(struct pipe_screen *screen,
struct pipe_buffer *buffer);
#define trace_screen_add_to_list(tr_scr, name, obj) \
do { \
pipe_mutex_lock(tr_scr->list_mutex); \
insert_at_head(&tr_scr->name, &obj->list); \
tr_scr->num_##name++; \
pipe_mutex_unlock(tr_scr->list_mutex); \
} while (0)
#define trace_screen_remove_from_list(tr_scr, name, obj) \
do { \
pipe_mutex_lock(tr_scr->list_mutex); \
remove_from_list(&obj->list); \
tr_scr->num_##name--; \
pipe_mutex_unlock(tr_scr->list_mutex); \
} while (0)
#ifdef __cplusplus
}

View File

@ -27,6 +27,7 @@
#include "util/u_hash_table.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "tr_screen.h"
#include "tr_texture.h"
@ -53,6 +54,8 @@ trace_texture_create(struct trace_screen *tr_scr,
tr_tex->base.screen = &tr_scr->base;
tr_tex->texture = texture;
trace_screen_add_to_list(tr_scr, textures, tr_tex);
return &tr_tex->base;
error:
@ -64,6 +67,10 @@ error:
void
trace_texture_destroy(struct trace_texture *tr_tex)
{
struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
trace_screen_remove_from_list(tr_scr, textures, tr_tex);
pipe_texture_reference(&tr_tex->texture, NULL);
FREE(tr_tex);
}
@ -73,6 +80,7 @@ struct pipe_surface *
trace_surface_create(struct trace_texture *tr_tex,
struct pipe_surface *surface)
{
struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
struct trace_surface *tr_surf;
if(!surface)
@ -91,6 +99,8 @@ trace_surface_create(struct trace_texture *tr_tex,
pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
tr_surf->surface = surface;
trace_screen_add_to_list(tr_scr, surfaces, tr_surf);
return &tr_surf->base;
error:
@ -102,6 +112,10 @@ error:
void
trace_surface_destroy(struct trace_surface *tr_surf)
{
struct trace_screen *tr_scr = trace_screen(tr_surf->base.texture->screen);
trace_screen_remove_from_list(tr_scr, surfaces, tr_surf);
pipe_texture_reference(&tr_surf->base.texture, NULL);
pipe_surface_reference(&tr_surf->surface, NULL);
FREE(tr_surf);
@ -112,6 +126,7 @@ struct pipe_transfer *
trace_transfer_create(struct trace_texture *tr_tex,
struct pipe_transfer *transfer)
{
struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
struct trace_transfer *tr_trans;
if(!transfer)
@ -130,6 +145,8 @@ trace_transfer_create(struct trace_texture *tr_tex,
tr_trans->transfer = transfer;
assert(tr_trans->base.texture == &tr_tex->base);
trace_screen_add_to_list(tr_scr, transfers, tr_trans);
return &tr_trans->base;
error:
@ -141,7 +158,11 @@ error:
void
trace_transfer_destroy(struct trace_transfer *tr_trans)
{
struct trace_screen *tr_scr = trace_screen(tr_trans->base.texture->screen);
struct pipe_screen *screen = tr_trans->transfer->texture->screen;
trace_screen_remove_from_list(tr_scr, transfers, tr_trans);
pipe_texture_reference(&tr_trans->base.texture, NULL);
screen->tex_transfer_destroy(tr_trans->transfer);
FREE(tr_trans);

View File

@ -40,6 +40,8 @@ struct trace_texture
struct pipe_texture base;
struct pipe_texture *texture;
struct tr_list list;
};
@ -48,6 +50,8 @@ struct trace_surface
struct pipe_surface base;
struct pipe_surface *surface;
struct tr_list list;
};
@ -57,6 +61,8 @@ struct trace_transfer
struct pipe_transfer *transfer;
struct tr_list list;
void *map;
};

View File

@ -18,58 +18,29 @@ extern "C" {
/* Favor OS-provided implementations.
*
* Where no OS-provided implementation is available, fall back to
* locally coded assembly, compiler intrinsic or ultimately a
* mutex-based implementation.
*/
#define PIPE_ATOMIC_OS_UNLOCKED \
(defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \
defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT))
#define PIPE_ATOMIC_OS_MS_INTERLOCK \
(!defined(PIPE_CC_GCC) && \
!PIPE_ATOMIC_OS_UNLOCKED && \
defined(PIPE_SUBSYSTEM_WINDOWS_USER))
#define PIPE_ATOMIC_OS_PROVIDED \
(PIPE_ATOMIC_OS_UNLOCKED || \
PIPE_ATOMIC_OS_MS_INTERLOCK)
/* Where no OS-provided implementation is available, fall back to
* either locally coded assembly or ultimately a mutex-based
* implementation:
*/
#define PIPE_ATOMIC_ASM_GCC_X86 \
(!PIPE_ATOMIC_OS_PROVIDED && \
defined(PIPE_CC_GCC) && \
defined(PIPE_ARCH_X86))
/* KW: this was originally used when x86 asm wasn't available.
* Maintain that logic here.
*/
#define PIPE_ATOMIC_GCC_INTRINISIC \
(!PIPE_ATOMIC_OS_PROVIDED && \
!PIPE_ATOMIC_ASM_GCC_X86 && \
defined(PIPE_CC_GCC))
#define PIPE_ATOMIC_ASM_MSVC_X86 \
(!PIPE_ATOMIC_OS_PROVIDED && \
defined(PIPE_CC_MSVC) && \
defined(PIPE_ARCH_X86))
#define PIPE_ATOMIC_ASM \
(PIPE_ATOMIC_ASM_GCC_X86 || \
PIPE_ATOMIC_ASM_GCC_INTRINSIC || \
PIPE_ATOMIC_ASM_MSVC_X86)
/* Where no OS-provided or locally-coded assembly implemenation is
* available, use pipe_mutex:
*/
#define PIPE_ATOMIC_MUTEX \
(!PIPE_ATOMIC_OS_PROVIDED && \
!PIPE_ATOMIC_ASM)
#if (defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) || \
defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT))
#define PIPE_ATOMIC_OS_UNLOCKED
#elif (defined(PIPE_CC_MSVC) && defined(PIPE_SUBSYSTEM_WINDOWS_USER))
#define PIPE_ATOMIC_OS_MS_INTERLOCK
#elif (defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86))
#define PIPE_ATOMIC_ASM_MSVC_X86
#elif (defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86))
#define PIPE_ATOMIC_ASM_GCC_X86
#elif defined(PIPE_CC_GCC)
#define PIPE_ATOMIC_GCC_INTRINSIC
#else
#define PIPE_ATOMIC_MUTEX
#endif
#if (PIPE_ATOMIC_ASM_GCC_X86)
#if defined(PIPE_ATOMIC_ASM_GCC_X86)
#define PIPE_ATOMIC "GCC x86 assembly"
@ -115,7 +86,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
/* Implementation using GCC-provided synchronization intrinsics
*/
#if (PIPE_ATOMIC_ASM_GCC_INTRINSIC)
#if defined(PIPE_ATOMIC_GCC_INTRINSIC)
#define PIPE_ATOMIC "GCC Sync Intrinsics"
@ -157,7 +128,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
/* Unlocked version for single threaded environments, such as some
* windows kernel modules.
*/
#if (PIPE_ATOMIC_OS_UNLOCKED)
#if defined(PIPE_ATOMIC_OS_UNLOCKED)
#define PIPE_ATOMIC "Unlocked"
@ -178,7 +149,7 @@ struct pipe_atomic
/* Locally coded assembly for MSVC on x86:
*/
#if (PIPE_ATOMIC_ASM_MSVC_X86)
#if defined(PIPE_ATOMIC_ASM_MSVC_X86)
#define PIPE_ATOMIC "MSVC x86 assembly"
@ -246,7 +217,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
#endif
#if (PIPE_ATOMIC_OS_MS_INTERLOCK)
#if defined(PIPE_ATOMIC_OS_MS_INTERLOCK)
#define PIPE_ATOMIC "MS userspace interlocks"
@ -254,7 +225,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
struct pipe_atomic
{
long count;
volatile long count;
};
#define p_atomic_set(_v, _i) ((_v)->count = (_i))
@ -263,7 +234,7 @@ struct pipe_atomic
static INLINE boolean
p_atomic_dec_zero(struct pipe_atomic *v)
{
return InterlockedDecrement(&v->count);
return InterlockedDecrement(&v->count) == 0;
}
static INLINE void
@ -288,7 +259,7 @@ p_atomic_cmpxchg(struct pipe_atomic *v, int32_t old, int32_t _new)
#if (PIPE_ATOMIC_MUTEX)
#if defined(PIPE_ATOMIC_MUTEX)
#define PIPE_ATOMIC "mutex-based fallback"

View File

@ -42,7 +42,6 @@ struct pipe_state_cache;
struct pipe_query;
struct pipe_winsys;
/**
* Gallium rendering context. Basically:
* - state setting functions
@ -192,14 +191,21 @@ struct pipe_context {
* Surface functions
*/
/*@{*/
/**
* Copy a block of pixels from one surface to another.
* The surfaces must be of the same format.
*/
void (*surface_copy)(struct pipe_context *pipe,
struct pipe_surface *dest,
unsigned destx, unsigned desty,
struct pipe_surface *src, /* don't make this const -
need to map/unmap */
struct pipe_surface *src,
unsigned srcx, unsigned srcy,
unsigned width, unsigned height);
/**
* Fill a region of a surface with a constant value.
*/
void (*surface_fill)(struct pipe_context *pipe,
struct pipe_surface *dst,
unsigned dstx, unsigned dsty,
@ -224,6 +230,34 @@ struct pipe_context {
void (*flush)( struct pipe_context *pipe,
unsigned flags,
struct pipe_fence_handle **fence );
/**
* Check whether a texture is referenced by an unflushed hw command.
* The state-tracker uses this function to optimize away unnecessary
* flushes. It is safe (but wasteful) to always return.
* PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE.
* \param pipe The pipe context whose unflushed hw commands will be
* checked.
* \param level mipmap level.
* \param texture texture to check.
* \param face cubemap face. Use 0 for non-cubemap texture.
*/
unsigned int (*is_texture_referenced) (struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level);
/**
* Check whether a buffer is referenced by an unflushed hw command.
* The state-tracker uses this function to optimize away unnecessary
* flushes. It is safe (but wasteful) to always return
* PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE.
* \param pipe The pipe context whose unflushed hw commands will be
* checked.
* \param buf Buffer to check.
*/
unsigned int (*is_buffer_referenced) (struct pipe_context *pipe,
struct pipe_buffer *buf);
};

View File

@ -200,7 +200,7 @@ enum pipe_texture_target {
enum pipe_transfer_usage {
PIPE_TRANSFER_READ,
PIPE_TRANSFER_WRITE,
PIPE_TRANSFER_READ_WRITE //< Read/modify/write
PIPE_TRANSFER_READ_WRITE /**< Read/modify/write */
};
@ -312,6 +312,13 @@ enum pipe_transfer_usage {
#define PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS 26
/**
* Referenced query flags.
*/
#define PIPE_UNREFERENCED 0
#define PIPE_REFERENCED_FOR_READ (1 << 0)
#define PIPE_REFERENCED_FOR_WRITE (1 << 1)
#ifdef __cplusplus
}

View File

@ -87,7 +87,7 @@ struct pipe_screen {
* Check if the given pipe_format is supported as a texture or
* drawing surface.
* \param tex_usage bitmask of PIPE_TEXTURE_USAGE_*
* \param flags bitmask of PIPE_TEXTURE_GEOM_*
* \param geom_flags bitmask of PIPE_TEXTURE_GEOM_*
*/
boolean (*is_format_supported)( struct pipe_screen *,
enum pipe_format format,
@ -102,7 +102,7 @@ struct pipe_screen {
const struct pipe_texture *templat);
/**
* Create a new texture object, using the given template info, but on top of
* Create a new texture object, using the given template info, but on top of
* existing memory.
*
* It is assumed that the buffer data is layed out according to the expected
@ -144,8 +144,10 @@ struct pipe_screen {
/**
* Buffer management. Buffer attributes are mostly fixed over its lifetime.
*
* Create a new buffer.
* \param alignment buffer start address alignment in bytes
* \param usage bitmask of PIPE_BUFFER_USAGE_x
* \param size size in bytes
*/
struct pipe_buffer *(*buffer_create)( struct pipe_screen *screen,
unsigned alignment,
@ -264,7 +266,7 @@ struct pipe_screen {
*/
int (*fence_signalled)( struct pipe_screen *screen,
struct pipe_fence_handle *fence,
unsigned flag );
unsigned flags );
/**
* Wait for the fence to finish.
@ -273,7 +275,7 @@ struct pipe_screen {
*/
int (*fence_finish)( struct pipe_screen *screen,
struct pipe_fence_handle *fence,
unsigned flag );
unsigned flags );
};

View File

@ -336,7 +336,6 @@ struct pipe_texture
unsigned nblocksy[PIPE_MAX_TEXTURE_LEVELS]; /**< allocated height in blocks */
unsigned last_level:8; /**< Index of last mipmap level present/defined */
unsigned compressed:1;
unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */

View File

@ -426,7 +426,7 @@ struct st_surface
if(!*STRING)
return;
pipe_buffer_read(screen, $self, 0, $self->size, STRING);
pipe_buffer_read(screen, $self, 0, $self->size, *STRING);
}
%cstring_input_binary(const char *STRING, unsigned LENGTH);

View File

@ -32,7 +32,7 @@ import struct
import gallium
import model
import parser
import parse as parser
try:

View File

@ -0,0 +1,392 @@
#!/usr/bin/env python
##########################################################################
#
# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
# All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sub license, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice (including the
# next paragraph) shall be included in all copies or substantial portions
# of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
##########################################################################
import sys
import xml.parsers.expat
import binascii
import optparse
from model import *
ELEMENT_START, ELEMENT_END, CHARACTER_DATA, EOF = range(4)
class XmlToken:
def __init__(self, type, name_or_data, attrs = None, line = None, column = None):
assert type in (ELEMENT_START, ELEMENT_END, CHARACTER_DATA, EOF)
self.type = type
self.name_or_data = name_or_data
self.attrs = attrs
self.line = line
self.column = column
def __str__(self):
if self.type == ELEMENT_START:
return '<' + self.name_or_data + ' ...>'
if self.type == ELEMENT_END:
return '</' + self.name_or_data + '>'
if self.type == CHARACTER_DATA:
return self.name_or_data
if self.type == EOF:
return 'end of file'
assert 0
class XmlTokenizer:
"""Expat based XML tokenizer."""
def __init__(self, fp, skip_ws = True):
self.fp = fp
self.tokens = []
self.index = 0
self.final = False
self.skip_ws = skip_ws
self.character_pos = 0, 0
self.character_data = ''
self.parser = xml.parsers.expat.ParserCreate()
self.parser.StartElementHandler = self.handle_element_start
self.parser.EndElementHandler = self.handle_element_end
self.parser.CharacterDataHandler = self.handle_character_data
def handle_element_start(self, name, attributes):
self.finish_character_data()
line, column = self.pos()
token = XmlToken(ELEMENT_START, name, attributes, line, column)
self.tokens.append(token)
def handle_element_end(self, name):
self.finish_character_data()
line, column = self.pos()
token = XmlToken(ELEMENT_END, name, None, line, column)
self.tokens.append(token)
def handle_character_data(self, data):
if not self.character_data:
self.character_pos = self.pos()
self.character_data += data
def finish_character_data(self):
if self.character_data:
if not self.skip_ws or not self.character_data.isspace():
line, column = self.character_pos
token = XmlToken(CHARACTER_DATA, self.character_data, None, line, column)
self.tokens.append(token)
self.character_data = ''
def next(self):
size = 16*1024
while self.index >= len(self.tokens) and not self.final:
self.tokens = []
self.index = 0
data = self.fp.read(size)
self.final = len(data) < size
data = data.rstrip('\0')
try:
self.parser.Parse(data, self.final)
except xml.parsers.expat.ExpatError, e:
#if e.code == xml.parsers.expat.errors.XML_ERROR_NO_ELEMENTS:
if e.code == 3:
pass
else:
raise e
if self.index >= len(self.tokens):
line, column = self.pos()
token = XmlToken(EOF, None, None, line, column)
else:
token = self.tokens[self.index]
self.index += 1
return token
def pos(self):
return self.parser.CurrentLineNumber, self.parser.CurrentColumnNumber
class TokenMismatch(Exception):
def __init__(self, expected, found):
self.expected = expected
self.found = found
def __str__(self):
return '%u:%u: %s expected, %s found' % (self.found.line, self.found.column, str(self.expected), str(self.found))
class XmlParser:
"""Base XML document parser."""
def __init__(self, fp):
self.tokenizer = XmlTokenizer(fp)
self.consume()
def consume(self):
self.token = self.tokenizer.next()
def match_element_start(self, name):
return self.token.type == ELEMENT_START and self.token.name_or_data == name
def match_element_end(self, name):
return self.token.type == ELEMENT_END and self.token.name_or_data == name
def element_start(self, name):
while self.token.type == CHARACTER_DATA:
self.consume()
if self.token.type != ELEMENT_START:
raise TokenMismatch(XmlToken(ELEMENT_START, name), self.token)
if self.token.name_or_data != name:
raise TokenMismatch(XmlToken(ELEMENT_START, name), self.token)
attrs = self.token.attrs
self.consume()
return attrs
def element_end(self, name):
while self.token.type == CHARACTER_DATA:
self.consume()
if self.token.type != ELEMENT_END:
raise TokenMismatch(XmlToken(ELEMENT_END, name), self.token)
if self.token.name_or_data != name:
raise TokenMismatch(XmlToken(ELEMENT_END, name), self.token)
self.consume()
def character_data(self, strip = True):
data = ''
while self.token.type == CHARACTER_DATA:
data += self.token.name_or_data
self.consume()
if strip:
data = data.strip()
return data
class TraceParser(XmlParser):
def __init__(self, fp):
XmlParser.__init__(self, fp)
self.last_call_no = 0
def parse(self):
self.element_start('trace')
while self.token.type not in (ELEMENT_END, EOF):
call = self.parse_call()
self.handle_call(call)
if self.token.type != EOF:
self.element_end('trace')
def parse_call(self):
attrs = self.element_start('call')
try:
no = int(attrs['no'])
except KeyError:
self.last_call_no += 1
no = self.last_call_no
else:
self.last_call_no = no
klass = attrs['class']
method = attrs['method']
args = []
ret = None
while self.token.type == ELEMENT_START:
if self.token.name_or_data == 'arg':
arg = self.parse_arg()
args.append(arg)
elif self.token.name_or_data == 'ret':
ret = self.parse_ret()
elif self.token.name_or_data == 'call':
# ignore nested function calls
self.parse_call()
else:
raise TokenMismatch("<arg ...> or <ret ...>", self.token)
self.element_end('call')
return Call(no, klass, method, args, ret)
def parse_arg(self):
attrs = self.element_start('arg')
name = attrs['name']
value = self.parse_value()
self.element_end('arg')
return name, value
def parse_ret(self):
attrs = self.element_start('ret')
value = self.parse_value()
self.element_end('ret')
return value
def parse_value(self):
expected_tokens = ('null', 'bool', 'int', 'uint', 'float', 'string', 'enum', 'array', 'struct', 'ptr', 'bytes')
if self.token.type == ELEMENT_START:
if self.token.name_or_data in expected_tokens:
method = getattr(self, 'parse_' + self.token.name_or_data)
return method()
raise TokenMismatch(" or " .join(expected_tokens), self.token)
def parse_null(self):
self.element_start('null')
self.element_end('null')
return Literal(None)
def parse_bool(self):
self.element_start('bool')
value = int(self.character_data())
self.element_end('bool')
return Literal(value)
def parse_int(self):
self.element_start('int')
value = int(self.character_data())
self.element_end('int')
return Literal(value)
def parse_uint(self):
self.element_start('uint')
value = int(self.character_data())
self.element_end('uint')
return Literal(value)
def parse_float(self):
self.element_start('float')
value = float(self.character_data())
self.element_end('float')
return Literal(value)
def parse_enum(self):
self.element_start('enum')
name = self.character_data()
self.element_end('enum')
return NamedConstant(name)
def parse_string(self):
self.element_start('string')
value = self.character_data()
self.element_end('string')
return Literal(value)
def parse_bytes(self):
self.element_start('bytes')
value = binascii.a2b_hex(self.character_data())
self.element_end('bytes')
return Literal(value)
def parse_array(self):
self.element_start('array')
elems = []
while self.token.type != ELEMENT_END:
elems.append(self.parse_elem())
self.element_end('array')
return Array(elems)
def parse_elem(self):
self.element_start('elem')
value = self.parse_value()
self.element_end('elem')
return value
def parse_struct(self):
attrs = self.element_start('struct')
name = attrs['name']
members = []
while self.token.type != ELEMENT_END:
members.append(self.parse_member())
self.element_end('struct')
return Struct(name, members)
def parse_member(self):
attrs = self.element_start('member')
name = attrs['name']
value = self.parse_value()
self.element_end('member')
return name, value
def parse_ptr(self):
self.element_start('ptr')
address = self.character_data()
self.element_end('ptr')
return Pointer(address)
def handle_call(self, call):
pass
class TraceDumper(TraceParser):
def __init__(self, fp):
TraceParser.__init__(self, fp)
self.formatter = format.DefaultFormatter(sys.stdout)
self.pretty_printer = PrettyPrinter(self.formatter)
def handle_call(self, call):
call.visit(self.pretty_printer)
self.formatter.newline()
class Main:
'''Common main class for all retrace command line utilities.'''
def __init__(self):
pass
def main(self):
optparser = self.get_optparser()
(options, args) = optparser.parse_args(sys.argv[1:])
if args:
for arg in args:
if arg.endswith('.gz'):
from gzip import GzipFile
stream = GzipFile(arg, 'rt')
elif arg.endswith('.bz2'):
from bz2 import BZ2File
stream = BZ2File(arg, 'rt')
else:
stream = open(arg, 'rt')
self.process_arg(stream, options)
else:
self.process_arg(stream, options)
def get_optparser(self):
optparser = optparse.OptionParser(
usage="\n\t%prog [options] [traces] ...")
return optparser
def process_arg(self, stream, options):
parser = TraceDumper(stream)
parser.parse()
if __name__ == '__main__':
Main().main()

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