Compare commits

..

74 Commits

Author SHA1 Message Date
Thomas Hellström
9b87fafc91 Use the BATCH_SZ macro where appropriate.
Bump driver date.
2006-09-29 13:15:43 +00:00
Michel Dänzer
7d553984e2 Merge vsync changes from trunk. 2006-09-29 11:00:50 +00:00
Alan Hourihane
d431dd49cb Do some extra checking to avoid segfaults when incorrect AGP is in use. 2006-09-28 15:56:00 +00:00
Keith Whitwell
b25c826e59 Add 'GL_RGBA8' as a supported internalFormat for
get_teximage_source().  Fixes subtexrate demo.
2006-09-28 14:33:04 +00:00
Thomas Hellström
814cae6a45 Update drm expected version. 2006-09-28 09:34:33 +00:00
Thomas Hellström
410673f64c Driver date. 2006-09-28 09:18:45 +00:00
Keith Whitwell
a83a3cfa1c remove duplicate 2006-09-27 20:23:34 +00:00
Keith Whitwell
da89238b13 pull npot mipmap test from trunk 2006-09-27 20:18:36 +00:00
Keith Whitwell
984387b89c Fix mipmap posititioning for 2d ARB_npot textures.
Fix typo in 3D image layout for i915.
2006-09-27 19:01:12 +00:00
Thomas Hellström
93bc5e8402 Fix another single-drawable-multiple-contexts error, that shows up now that the
drm_lock_tranfer() function has been removed from drm.
The error can cause the wrong context number to be used in the lock, but
otherwise should've done no serious harm.
We can probably throw away the i915 lock_mutex now.
2006-09-27 17:17:35 +00:00
Thomas Hellström
43722cae42 Valgrind error fix. 2006-09-26 14:15:08 +00:00
Keith Whitwell
f397a2a1e5 Move get_dirty() call to after reserving space in the batchbuffer as
this may trigger a batchbuffer flush and raise new dirty state.

Add assert_not_dirty() callback required by recent changes.
2006-09-26 11:36:32 +00:00
Keith Whitwell
87a0312068 Add asserts to catch primitives being emitted with state still dirty,
or extended when there is no primitive to extend.

Turn lock/unlock macros into proper functions and add a debug flag to
print out their activity.
2006-09-26 10:44:52 +00:00
Keith Whitwell
ee525436cc Move get_dirty() call to after reserving space in the batchbuffer as
this may trigger a batchbuffer flush and raise new dirty state.
2006-09-26 10:39:42 +00:00
Keith Whitwell
520ba25dc3 Ensure that we don't wrap batchbuffers right at the beginning of a
primitive, otherwise vertices can be emitted without the full-state
preamble.  Fixes gears + texobj lockup.
2006-09-26 09:27:54 +00:00
Thomas Hellström
6f9dc91045 Small COW break on destruction optimization.
Fix a comment.
2006-09-26 09:25:47 +00:00
Thomas Hellström
d17637d47f Fix up buffer object and region refcounting
Sinlence some compilation warnings.
2006-09-26 09:00:03 +00:00
Thomas Hellström
980a25cd92 Make regions screen-based instead of context based. 2006-09-25 18:22:21 +00:00
Keith Whitwell
607c474f2d Import Brian's FBO bugfix from trunk. 2006-09-25 16:11:14 +00:00
Thomas Hellström
2f54146c1f Add some more buffer usage refcounting.
Otherwise these texture buffers will disappear under us.
2006-09-22 18:09:46 +00:00
Keith Whitwell
72aeeef7c3 Remove redundant 3d-state validation prior to blit copypixels. These
were causing some issues.
2006-09-22 16:45:52 +00:00
Keith Whitwell
dadc8e2a50 Fix a longstanding memory leak - intelObj->mt refcount was not deleted
when the texture was deleted.
2006-09-22 16:33:10 +00:00
Keith Whitwell
02d401b475 Turn some printfs into DBG's.
Fix a little mess left by indent.
2006-09-22 16:32:24 +00:00
Keith Whitwell
9d695abcac rationalize debugging flags 2006-09-22 16:05:09 +00:00
Keith Whitwell
e070007d16 Silence warning 2006-09-22 16:03:36 +00:00
Keith Whitwell
39c4c8d54b intel_batch_ioctl() lost its return type somehow 2006-09-22 16:03:06 +00:00
Keith Whitwell
4fa3cf225f Fix initialization of pfPitch - measured in pixels, not bytes. 2006-09-22 15:22:32 +00:00
Thomas Hellström
1c2c1c4560 Another obscure bug causing an infinite loop when multiple contexts are
bound to a drawable.
2006-09-22 14:52:31 +00:00
Keith Whitwell
e3904516bb bring in recent texture swizzle changes from trunk 2006-09-22 14:18:56 +00:00
Keith Whitwell
ceb222798b - Make point_smooth, polygon_smooth fallbacks per-primitive rather than total.
- Also - disable those fallbacks unless INTEL_STRICT_CONFORMANCE is set.
- Gate some FBO debugging on INTEL_DEBUG=fbo
2006-09-22 14:16:33 +00:00
Keith Whitwell
6abcf6a3d3 Fix bug detecting overlapping regions in texture copypixels.
Import code from trunk to allow blit copypixels when scissor is active.
2006-09-22 14:10:39 +00:00
Keith Whitwell
db0ed8942f Check for FragmentProgram._Enabled rather than _Active. _Active is
set when a driver is using an internally generated fragment program to
emulate fixed function behaviour.  For the software rasterizer, we're
better off using the fixed function code directly.
2006-09-22 11:43:19 +00:00
Keith Whitwell
bd9f38ccaa Flush driver, not just tnl module. 2006-09-22 11:39:31 +00:00
Keith Whitwell
b15421c22b resize buffers in MakeCurrent 2006-09-22 11:37:39 +00:00
Thomas Hellström
5db0e131ef Fix intel texture image buffer leak. 2006-09-22 10:55:05 +00:00
Michel Dänzer
b249ff8a86 Fix INTEL_DEBUG=fall. 2006-09-20 16:07:39 +00:00
Michel Dänzer
9d6e0f5d64 Revert INTEL_FIREVERTICES to flush primitives instead of asserting none pending.
The assertion was triggered in some cases, e.g. by the xscreensaver hack
stonerview.
2006-09-20 15:29:36 +00:00
Thomas Hellström
4f8549634e Fix a fencing bug. 2006-09-18 18:55:29 +00:00
Keith Whitwell
3345ab8ccf fix bzflag crashes 2006-09-18 18:11:42 +00:00
Thomas Hellström
cd3c9febda Check for NULL in intelSwapBuffers() 2006-09-18 14:18:14 +00:00
Thomas Hellström
8c58a32360 Fix fencing when submitting empty batchbuffers.
Add a proper buffer waitidle method.
2006-09-18 14:11:00 +00:00
Thomas Hellström
0d646ea3a8 Relax the requirement in pool_takedown in the intel batch buffer pool,
that all allocated buffes should've been handed back before releasing the
pool.
This is to account for the case where whe app calls DestroyScreen() without
first destroying all contexts.
2006-09-18 08:41:22 +00:00
Thomas Hellström
6a33e6d221 Wait for buffer idle unlocked before mapping in some cases.
Greatly improves responsiveness.
Add an MI_FLUSH after each batchbuffer and tell the kernel we're doing so with
the new DRM_I915_FENCE_FLAG_FLUSHED (Requires drm update).
This can be done on a per-batchbuffer basis.
The DRM handles all fence accounting and signals earlier fences that also needs
a flush.
2006-09-15 14:52:31 +00:00
Thomas Hellström
fc4bc6fc97 Adapt to updated libdrm. 2006-09-15 09:22:08 +00:00
Keith Whitwell
4239cfd534 Turn back on zcopy uploads - my timings were incorrect. 2006-09-14 14:48:34 +00:00
Keith Whitwell
b0902a4158 Silence debug, cope with calling intel_region_cow() with lock already held. 2006-09-14 14:48:09 +00:00
Keith Whitwell
269219dc05 Disable zero-copy texturing for now as it isn't such a win with the
newest memory manager code.
2006-09-14 12:11:46 +00:00
Thomas Hellström
5dbadd418c Fix a FBO render offset bug.
The current code failed if the dri drawable was updated before the call to
intelFlush(), and typically rendered into an FBO using the back buffer
cliprects.
2006-09-13 15:10:09 +00:00
Keith Whitwell
71bce51324 update driver date and branch debug 2006-09-13 12:45:42 +00:00
Keith Whitwell
308d377ca8 Bring in writemask + TEX fix from trunk 2006-09-13 12:45:21 +00:00
Thomas Hellström
4f39d22c29 texmem_0_3_branch with adaptations to the drm-ttm-0-2 branch.
Indent the i915 driver directory.
2006-09-12 14:13:36 +00:00
Keith Whitwell
8dab7963b7 Add a demo illustrating various techniques for uploading dynamic (ie
streaming) texture images via PBO's.  Two of these currently seem to
trigger a memory leak in the i915 driver, but at least one
(PBO_PINGPONG) illustrates the good speedups available with PBO's on
the i915 driver, particularly zero-copy uploads.
2006-08-30 20:41:18 +00:00
Keith Whitwell
ec30116c9f Must lock hardware around call to intelEmitCopyBlit() 2006-08-30 20:18:33 +00:00
Keith Whitwell
5ac3ad7722 implement zero-copy uploads for glTexImage from suitable pixel buffer objects 2006-08-30 19:55:32 +00:00
Keith Whitwell
fe239744aa Bring in improved version of the texdown demo from the original texmem branch 2006-08-30 09:15:40 +00:00
Keith Whitwell
137dcd4a46 remove orphan file 2006-08-29 12:11:22 +00:00
Keith Whitwell
0d7755fc73 remove i915_texprog.c as it is no longer needed 2006-08-29 11:58:23 +00:00
Keith Whitwell
c863e63549 remove hashing for bm buffers, use an opaque pointer instead of an integer 2006-08-29 11:45:13 +00:00
Keith Whitwell
62920e2ab2 revert last commit 2006-08-28 15:14:55 +00:00
Keith Whitwell
ce3885fc5f dependent texture read demo 2006-08-28 15:11:10 +00:00
Keith Whitwell
bf0c1ca618 use mesa's texenvprogram in preference to i915 version. Enable tex_env_crossbar 2006-08-28 11:50:10 +00:00
Keith Whitwell
64bc9caa1c various texture tweaks 2006-08-28 11:49:30 +00:00
Keith Whitwell
89a2ea6fd3 Add missing wait for busy buffers in bmMapBuffer() 2006-08-28 11:37:07 +00:00
Keith Whitwell
41123a85ec Fixes for i945 texture layouts 2006-08-28 11:35:20 +00:00
Keith Whitwell
f10469abe8 add dependent texture read test 2006-08-17 13:25:14 +00:00
Keith Whitwell
4a74de797c Make bgra format more explicit 2006-08-17 13:24:57 +00:00
Dave Airlie
c745394242 fix from i965 driver for compressed textures on texman 2006-08-16 03:33:00 +00:00
Keith Whitwell
f9f3de8c31 first pass at texture uploads from pbo's with the blitter 2006-08-03 15:41:10 +00:00
Keith Whitwell
3d0a073a71 trivial test for pbo-based texture uploads 2006-08-03 15:40:19 +00:00
Keith Whitwell
219ee91fa8 Get basic texturing working again on i945 2006-08-03 11:22:09 +00:00
Keith Whitwell
632eae3fec Correct pitch / cpp calculation 2006-08-03 10:31:47 +00:00
Keith Whitwell
f378bcd8bf drmOpen/Close once 2006-08-02 10:24:01 +00:00
Keith Whitwell
ded29089f3 new files from merge of texmem driver 2006-08-02 10:08:58 +00:00
Keith Whitwell
527c05eb2a Pull the texmem i915 driver onto a new branch closer to the current trunk.
Compiles but otherwise untested.
2006-08-02 10:01:03 +00:00
387 changed files with 49808 additions and 87548 deletions

View File

@@ -144,10 +144,6 @@ sunos5-v8-static \
sunos5-v9 \
sunos5-v9-static \
ultrix-gcc:
@ if [ -e configs/current ] ; then \
echo "Please run 'make realclean' before changing configs" ; \
exit 1 ; \
fi
(cd configs && rm -f current && ln -s $@ current)
$(MAKE) default
@@ -164,6 +160,7 @@ MAIN_FILES = \
$(DIRECTORY)/descrip.mms \
$(DIRECTORY)/mms-config. \
$(DIRECTORY)/bin/mklib \
$(DIRECTORY)/bin/installmesa \
$(DIRECTORY)/configs/[a-z]* \
$(DIRECTORY)/docs/*.html \
$(DIRECTORY)/docs/COPYING \
@@ -380,8 +377,8 @@ GLUT_FILES = \
$(DIRECTORY)/src/glut/ggi/*.[ch] \
$(DIRECTORY)/src/glut/ggi/Makefile \
$(DIRECTORY)/src/glut/fbdev/Makefile \
$(DIRECTORY)/src/glut/fbdev/*[ch] \
$(DIRECTORY)/src/glut/mini/*[ch] \
$(DIRECTORY)/src/glut/fbdev/cursors.h \
$(DIRECTORY)/src/glut/fbdev/glut_fbdev.c \
$(DIRECTORY)/windows/VC6/progs/glut/glut.dsp \
$(DIRECTORY)/windows/VC7/progs/glut/glut.vcproj

View File

@@ -62,10 +62,10 @@ fi
set -v
mkdir -p ${INCLUDE_DIR}
mkdir -p ${INCLUDE_DIR}/GL
# NOT YET: mkdir -p ${INCLUDE_DIR}/GLES
mkdir -p ${LIB_DIR}
mkdir ${INCLUDE_DIR}
mkdir ${INCLUDE_DIR}/GL
# NOT YET: mkdir ${INCLUDE_DIR}/GLES
mkdir ${LIB_DIR}
cp -f ${TOP}/include/GL/*.h ${INCLUDE_DIR}/GL
cp -f ${TOP}/src/glw/*.h ${INCLUDE_DIR}/GL
# NOT YET: cp -f ${TOP}/include/GLES/*.h ${INCLUDE_DIR}/GLES

View File

@@ -15,8 +15,7 @@ COPY_LIBS = cp -f
OPT_FLAGS = -O2
PIC_FLAGS = -fPIC
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DUSE_XSHM \
-DHZ=100 -DHAVE_POSIX_MEMALIGN
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DUSE_XSHM -DHZ=100
X11_INCLUDES = -I/usr/X11R6/include

View File

@@ -14,7 +14,7 @@ OPT_FLAGS = -O
EXPAT_INCLUDES = -I/usr/local/include
X11_INCLUDES = -I/usr/X11R6/include
DEFINES = -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS
CFLAGS = -Wmissing-prototypes -g -std=c99 -Wundef -fPIC -ffast-math \
$(ASM_FLAGS) $(X11_INCLUDES) $(DEFINES)
@@ -42,6 +42,6 @@ DRM_SOURCE_PATH=$(TOP)/../drm
# ffb and gamma are missing because they have not been converted to use the new
# interface.
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon tdfx \
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon tdfx \
unichrome savage sis

View File

@@ -17,8 +17,7 @@ PIC_FLAGS = -fPIC
ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE \
-DPTHREADS -DUSE_XSHM -DHAVE_POSIX_MEMALIGN
-D_BSD_SOURCE -DPTHREADS -DUSE_XSHM
X11_INCLUDES = -I/usr/X11R6/include

View File

@@ -22,7 +22,7 @@ ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE \
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS
X11_INCLUDES = -I/usr/X11R6/include
@@ -37,7 +37,6 @@ ASM_SOURCES =
# Library/program dependencies
EXTRA_LIB_PATH=-L/usr/X11R6/lib
LIBDRM_CFLAGS = `pkg-config --cflags libdrm`
LIBDRM_LIB = `pkg-config --libs libdrm`
DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \
@@ -64,5 +63,5 @@ WINDOW_SYSTEM=dri
# gamma are missing because they have not been converted to use the new
# interface.
DRI_DIRS = i810 i915 i965 mach64 mga r128 r200 r300 radeon s3v \
DRI_DIRS = i810 i915 mach64 mga r128 r200 r300 radeon s3v \
savage sis tdfx trident unichrome ffb

View File

@@ -22,7 +22,7 @@ ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE \
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DUSE_XCB -DHAVE_POSIX_MEMALIGN
-DGLX_DIRECT_RENDERING -DHAVE_ALIAS -DUSE_XCB
X11_INCLUDES = `pkg-config --cflags-only-I x11` `pkg-config --cflags-only-I xcb` `pkg-config --cflags-only-I xcb-glx`

View File

@@ -3,18 +3,8 @@
include $(TOP)/configs/linux
CONFIG_NAME = linux-fbdev
DRIVER_DIRS = fbdev
SRC_DIRS = mesa glu glut/fbdev
CFLAGS = -O3 -ffast-math -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS -DUSE_GLFBDEV_DRIVER
SRC_DIRS = mesa glu glut/fbdev
DRIVER_DIRS = fbdev
PROGRAM_DIRS = fbdev demos redbook samples
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lgpm -lm
CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -DUSE_GLFBDEV_DRIVER
PROGRAM_DIRS = fbdev

View File

@@ -23,7 +23,7 @@ ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE \
-DPTHREADS -DHAVE_ALIAS -DHAVE_POSIX_MEMALIGN
-DPTHREADS -DHAVE_ALIAS
X11_INCLUDES = -I/usr/X11R6/include

View File

@@ -16,7 +16,7 @@ PIC_FLAGS = -fPIC
ARCH_FLAGS ?=
DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
-D_BSD_SOURCE -D_GNU_SOURCE -DHAVE_POSIX_MEMALIGN \
-D_BSD_SOURCE -D_GNU_SOURCE \
-DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DDRM_USE_MALLOC -DIN_DRI_DRIVER
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \

View File

@@ -1,9 +1,30 @@
# Configuration for Linux on Sparc
include $(TOP)/configs/linux
include $(TOP)/configs/default
CONFIG_NAME = linux-sparc
#ASM_FLAGS = -DUSE_SPARC_ASM
#ASM_SOURCES = $(SPARC_SOURCES)
#ASM_API = $(SPARC_API)
# Compiler and flags
CC = gcc
CXX = g++
WARN_FLAGS = -Wall
OPT_FLAGS = -O2
PIC_FLAGS = -fPIC
DEFINES = -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM
X11_INCLUDES = -I/usr/X11R6/include
CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
$(ASM_FLAGS) -std=c99 -ffast-math
CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
GLUT_CFLAGS = -fexceptions
EXTRA_LIB_PATH=-L/usr/X11R6/lib
GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11

View File

@@ -1,7 +1,17 @@
# Configuration for Linux on Sparc5
include $(TOP)/configs/linux-sparc
include $(TOP)/configs/default
CONFIG_NAME = linux-sparc5
ARCH_FLAGS += -mcpu=ultrasparc
# Compiler and flags
CC = gcc
CXX = g++
CFLAGS = -mcpu=ultrasparc -O2 -ffast-math -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM
CXXFLAGS = -mcpu=ultrasparc -O2 -ffast-math -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE
GLUT_CFLAGS = -fexceptions
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11

View File

@@ -1,7 +1,17 @@
# Configuration for Linux on UltraSparc
include $(TOP)/configs/linux-sparc
include $(TOP)/configs/default
CONFIG_NAME = linux-ultrasparc
ARCH_FLAGS += -mv8 -mtune=ultrasparc
# Compiler and flags
CC = gcc
CXX = g++
CFLAGS = -mv8 -O2 -mtune=ultrasparc -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM
CXXFLAGS = -mv8 -O2 -mtune=ultrasparc -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE
GLUT_CFLAGS = -fexceptions
GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR)-l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm

View File

@@ -1,60 +0,0 @@
Mesa 6.5.1 Release Notes
Introduction
------------
Mesa uses an even/odd version number scheme like the Linux kernel.
Odd numbered versions (such as 6.5) designate new developmental releases.
Even numbered versions (such as 6.4) designate stable releases.
Mesa 6.5.1 is a 6.5 follow-on development release mostly consisting of
bug fixes (see the VERSIONS file).
New Features
------------
Intel i965 "broadwater" DRI driver
GL_APPLE_vertex_array_object - allows encapsulation of a set of vertex
arrays in an object.
GL_EXT_texture_sRGB - non-linearly mapped texture formats
GL_EXT_gpu_program_parameters - addes a few new functions for setting
multiple vertex/fragment program parameters with one call.
To Do (someday) items
---------------------
Switch to freeglut
Increase MAX_DRAWBUFFERS
Fix linux-glide target/driver.
Fix lambda calculation for frag progs.
Driver Status
---------------------- ----------------------
DRI drivers varies with the driver
XMesa/GLX (on Xlib) implements OpenGL 1.5
OSMesa (off-screen) implements OpenGL 1.5
Glide (3dfx Voodoo1/2) implements OpenGL 1.3
SVGA implements OpenGL 1.3
Wind River UGL implements OpenGL 1.3
Windows/Win32 implements OpenGL 1.5
DJGPP implements OpenGL 1.5
GGI implements OpenGL 1.3
BeOS implements OpenGL 1.5
Allegro needs updating
D3D needs updating
----------------------------------------------------------------------
$Id: RELNOTES-6.5.1,v 1.2 2006/08/18 20:24:54 brianp Exp $

View File

@@ -1471,21 +1471,14 @@ Mesa Version History
- paletted texturing was broken w/ floating point palettes (K. Schultz)
- lots of assorted framebuffer object bug fixes
6.5.1 August 31, 2006
6.5.1 month, day, 2006
New:
- Intel i965 DRI driver
- GL_APPLE_vertex_array_object extension (Ian Romanick)
- GL_EXT_texture_sRGB extension
- GL_EXT_gpu_program_parameters (Ian Romanick)
- "engine" demo
- updated fbdev driver and GLUT for fbdev (Sean D'Epagnier)
- many updates to the DRI drivers
Changes:
- The glVertexAttribARB functions no longer alias the conventional
vertex attributes.
- glxinfo program prints more info with -l option
- GL_FRAGMENT_PROGRAM_NV and GL_FRAGMENT_PROGRAM_ARB are now
compatible, in terms of glBindProgramARB()
Bug fixes:
- fixed broken texture border handling for depth textures (bug 6498)
- removed the test for duplicated framebuffer attachments, per
@@ -1505,10 +1498,3 @@ Mesa Version History
- 'normalized' parameter to glVertexAttribPointerARB didn't work
- disable bogus GLX_SGI_video_sync extension in xlib driver
- fixed R128 driver locking bug (Martijn van Oosterhout)
- using evaluators with vertex programs caused crashes (bug 7564)
- fragment.position wasn't set correctly for point/line primitives
- fixed parser bug for scalar sources for GL_NV_fragment_program
- max fragment program length was incorrectly 128, now 1024
- writes to result.depth in fragment programs weren't clamped to [0,1]
- fixed potential dangling pointer bug in glBindProgram()
- fixed some memory leaks (and potential crashes) in Xlib driver

View File

@@ -9,7 +9,7 @@
<center>
<h1>Mesa Frequently Asked Questions</h1>
Last updated: 21 August 2006
Last updated: 8 June 2006
</center>
<br>
@@ -46,7 +46,7 @@ Mesa 6.x supports the OpenGL 1.5 specification.
<h2>1.2 Does Mesa support/use graphics hardware?</h2>
<p>
Yes. Specifically, Mesa serves as the OpenGL core for the open-source DRI
drivers for XFree86/X.org. See the <a href="http://dri.freedesktop.org/">DRI
drivers for XFree86/X.org. See the <a href="http://dri.sf.net/">DRI
website</a> for more information.
</p>
<p>
@@ -290,8 +290,9 @@ hardware it has detected.
<p>
Make sure the ratio of the far to near clipping planes isn't too great.
Look
<a href="http://www.opengl.org/resources/faq/technical/depthbuffer.htm#0040"
target="_parent"> here</a> for details.
<a href="http://www.sgi.com/software/opengl/advanced97/notes/node18.html"
target="_parent">
here</a> for details.
</p>
<p>
Mesa uses a 16-bit depth buffer by default which is smaller and faster
@@ -340,14 +341,13 @@ will fix the problem.
<a name="part4">
</a><h1><a name="part4">4. Developer Questions</a></h1>
<h2>4.1 How can I contribute?</a></h2>
<h2><a name="part4">4.1 How can I contribute?</a></h2>
<p>
First, join the <a href="http://www.mesa3d.org/lists.html>Mesa3d-dev
mailing list</a>.
That's where Mesa development is discussed.
<a name="part4">First, join the Mesa3d-dev mailing list. That's where Mesa development
is discussed.
</a></p>
<p>
The </a><a href="http://www.opengl.org/documentation" target="_parent">
<a name="part4">The </a><a href="http://www.opengl.org/developers/documentation/specs.html" target="_parent">
OpenGL Specification</a> is the bible for OpenGL implemention work.
You should read it.
</p>

View File

@@ -70,7 +70,7 @@ tty group as well
<h1>4. Using fbdevglut</h1>
Almost all of the programs in the progs directory use glut, and they compile with fbdevglut.
Currently glBlendFunc is not working with glFBDev.
<p>
To compile the redbook sample programs:
<pre>

View File

@@ -9,7 +9,7 @@
<H1>Modelers, Renderers and Viewers</H1>
<ul>
<li><a href="http://www.aqsis.org/" target="_parent">Aqsis</a> - a RenderMan compatible renderer</li>
<li><a href="http://www.aqsis.com/" target="_parent">Aqsis</a> - a RenderMan compatible renderer</li>
<li><a href="http://www.ac3d.org/" target="_parent">AC3D</a> - 3-D modeler
</li><li><a href="http://mesa3d.sourceforge.net/notfound.html">ARCAD</a> - CAD program
</li><li><a href="http://www.mediascape.com/" target="_parent">Artstream</a> - provides

View File

@@ -13,7 +13,6 @@ The release notes summarize what's new or changed in each Mesa release.
</p>
<UL>
<LI><A HREF="RELNOTES-6.5.1">RELNOTES-6.5.1</A>
<LI><A HREF="RELNOTES-6.5">RELNOTES-6.5</A>
<LI><A HREF="RELNOTES-6.4.2">RELNOTES-6.4.2</A>
<LI><A HREF="RELNOTES-6.4.1">RELNOTES-6.4.1</A>

View File

@@ -2152,26 +2152,6 @@ typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLsh
#if GL_ARB_shader_objects
#ifndef GL_MESA_shader_debug
#define GL_MESA_shader_debug 1
#define GL_DEBUG_OBJECT_MESA 0x8759
#define GL_DEBUG_PRINT_MESA 0x875A
#define GL_DEBUG_ASSERT_MESA 0x875B
GLAPI GLhandleARB APIENTRY glCreateDebugObjectMESA (void);
GLAPI GLvoid APIENTRY glClearDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType);
GLAPI GLvoid APIENTRY glGetDebugLogMESA (GLhandleARB obj, GLenum logType, GLenum shaderType, GLsizei maxLength,
GLsizei *length, GLcharARB *debugLog);
GLAPI GLsizei APIENTRY glGetDebugLogLengthMESA (GLhandleARB obj, GLenum logType, GLenum shaderType);
#endif /* GL_MESA_shader_debug */
#endif /* GL_ARB_shader_objects */
/*
* ???. GL_MESA_trace
* XXX obsolete
@@ -2288,7 +2268,8 @@ typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pnam
#define GL_DRAW_FRAMEBUFFER_BINDING_EXT 0x8CA6
#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
GLAPI void GLAPIENTRY glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLAPI void GLAPIENTRY
glBlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
@@ -2312,47 +2293,6 @@ typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC)
#endif /* GL_EXT_packed_depth_stencil */
#ifndef GL_EXT_gpu_program_parameters
#define GL_EXT_gpu_program_parameters 1
GLAPI void GLAPIENTRY glProgramEnvParameters4fvEXT(GLenum target,
GLuint index, GLsizei count, const GLfloat *params);
GLAPI void GLAPIENTRY glProgramLocalParameters4fvEXT(GLenum target,
GLuint index, GLsizei count, const GLfloat *params);
typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC)
(GLenum target, GLuint index, GLsizei count, const GLfloat *params);
typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC)
(GLenum target, GLuint index, GLsizei count, const GLfloat *params);
#endif /* GL_EXT_gpu_program_parameters */
#ifndef GL_EXT_texture_sRGB
#define GL_EXT_texture_sRGB 1
#define GL_SRGB_EXT 0x8C40
#define GL_SRGB8_EXT 0x8C41
#define GL_SRGB_ALPHA_EXT 0x8C42
#define GL_SRGB8_ALPHA8_EXT 0x8C43
#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
#define GL_SLUMINANCE_EXT 0x8C46
#define GL_SLUMINANCE8_EXT 0x8C47
#define GL_COMPRESSED_SRGB_EXT 0x8C48
#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
#endif /* GL_EXT_texture_sRGB */
/**
** NOTE!!!!! If you add new functions to this file, or update
** glext.h be sure to regenerate the gl_mangle.h file. See comments

View File

@@ -98,7 +98,6 @@
#define glBlendFuncSeparateEXT MANGLE(BlendFuncSeparateEXT)
#define glBlendFuncSeparateINGR MANGLE(BlendFuncSeparateINGR)
#define glBlendFuncSeparate MANGLE(BlendFuncSeparate)
#define glBlitFramebufferEXT MANGLE(BlitFramebufferEXT)
#define glBufferDataARB MANGLE(BufferDataARB)
#define glBufferData MANGLE(BufferData)
#define glBufferSubDataARB MANGLE(BufferSubDataARB)
@@ -865,12 +864,10 @@
#define glProgramEnvParameter4dvARB MANGLE(ProgramEnvParameter4dvARB)
#define glProgramEnvParameter4fARB MANGLE(ProgramEnvParameter4fARB)
#define glProgramEnvParameter4fvARB MANGLE(ProgramEnvParameter4fvARB)
#define glProgramEnvParameters4fvEXT MANGLE(ProgramEnvParameters4fvEXT)
#define glProgramLocalParameter4dARB MANGLE(ProgramLocalParameter4dARB)
#define glProgramLocalParameter4dvARB MANGLE(ProgramLocalParameter4dvARB)
#define glProgramLocalParameter4fARB MANGLE(ProgramLocalParameter4fARB)
#define glProgramLocalParameter4fvARB MANGLE(ProgramLocalParameter4fvARB)
#define glProgramLocalParameters4fvEXT MANGLE(ProgramLocalParameters4fvEXT)
#define glProgramNamedParameter4dNV MANGLE(ProgramNamedParameter4dNV)
#define glProgramNamedParameter4dvNV MANGLE(ProgramNamedParameter4dvNV)
#define glProgramNamedParameter4fNV MANGLE(ProgramNamedParameter4fNV)
@@ -1477,5 +1474,6 @@
#define glWindowPos4sMESA MANGLE(WindowPos4sMESA)
#define glWindowPos4svMESA MANGLE(WindowPos4svMESA)
#define glWriteMaskEXT MANGLE(WriteMaskEXT)
gl.h:GLAPI void GLAPIENTRY
#endif /* GL_MANGLE_H */

View File

@@ -49,7 +49,6 @@ typedef struct GLFBDevContextRec *GLFBDevContextPtr;
#define GLFBDEV_STENCIL_SIZE 103
#define GLFBDEV_ACCUM_SIZE 104
#define GLFBDEV_LEVEL 105
#define GLFBDEV_MULTISAMPLE 106
#define GLFBDEV_NONE 0
/* For glFBDevGetString */

View File

@@ -64,18 +64,12 @@ typedef struct __GLinterfaceRec __GLinterface;
** and used by the "operating system".
*/
/**
* Mode and limit information for a context. This information is
* kept around in the context so that values can be used during
* command execution, and for returning information about the
* context to the application.
*
* Instances of this structure are shared by the driver and the loader. To
* maintain binary compatability, new fields \b must be added only to the
* end of the structure.
*
* \sa _gl_context_modes_create
*/
/*
** Mode and limit information for a context. This information is
** kept around in the context so that values can be used during
** command execution, and for returning information about the
** context to the application.
*/
typedef struct __GLcontextModesRec {
struct __GLcontextModesRec * next;

View File

@@ -47,6 +47,7 @@ PROGS = \
renormal \
shadowtex \
singlebuffer \
streaming_rect \
spectex \
spriteblast \
stex3d \

View File

@@ -16,7 +16,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>
@@ -57,16 +56,7 @@ static PFNGLATTACHOBJECTARBPROC glAttachObjectARB = NULL;
static PFNGLLINKPROGRAMARBPROC glLinkProgramARB = NULL;
static PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB = NULL;
static PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB = NULL;
static PFNGLUNIFORM3FVARBPROC glUniform3fvARB = NULL;
static PFNGLUNIFORM3FVARBPROC glUniform4fvARB = NULL;
static void normalize (GLfloat *dst, const GLfloat *src)
{
GLfloat len = sqrtf (src[0] * src[0] + src[1] * src[1] + src[2] * src[2]);
dst[0] = src[0] / len;
dst[1] = src[1] / len;
dst[2] = src[2] / len;
}
static PFNGLUNIFORM4FVARBPROC glUniform4fvARB = NULL;
static void Redisplay (void)
{
@@ -74,11 +64,8 @@ static void Redisplay (void)
if (pixelLight)
{
GLfloat vec[3];
glUseProgramObjectARB (program);
normalize (vec, lightPos);
glUniform3fvARB (uLightPos, 1, vec);
glUniform4fvARB (uLightPos, 1, lightPos);
glDisable(GL_LIGHTING);
}
else
@@ -199,25 +186,24 @@ static void SpecialKey (int key, int x, int y)
static void Init (void)
{
static const char *fragShaderText =
"uniform vec3 lightPos;\n"
"uniform vec4 diffuse;\n"
"uniform vec4 specular;\n"
"varying vec3 normal;\n"
"void main () {\n"
" // Compute dot product of light direction and normal vector\n"
" float dotProd = max (dot (lightPos, normalize (normal)), 0.0);\n"
" // Compute diffuse and specular contributions\n"
" gl_FragColor = diffuse * dotProd + specular * pow (dotProd, 20.0);\n"
"}\n"
;
static const char *vertShaderText =
"varying vec3 normal;\n"
"void main () {\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
" normal = gl_NormalMatrix * gl_Normal;\n"
"}\n"
;
static const char *fragShaderText =
"uniform vec4 lightPos;\n"
"uniform vec4 diffuse;\n"
"uniform vec4 specular;\n"
"void main () {\n"
" // Compute dot product of light direction and normal vector\n"
" float dotProd;\n"
" dotProd = clamp (dot (normalize (lightPos).xyz, normalize (gl_TexCoord[0]).xyz), 0.0, 1.0);\n"
" // Compute diffuse and specular contributions\n"
" gl_FragColor = diffuse * dotProd + specular * pow (dotProd, 20.0);\n"
"}\n"
;
static const char *vertShaderText =
"void main () {\n"
" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
" gl_TexCoord[0] = vec4 (gl_NormalMatrix * gl_Normal, 1.0);\n"
"}\n"
;
if (!glutExtensionSupported ("GL_ARB_fragment_shader"))
{
@@ -248,8 +234,7 @@ static void Init (void)
glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) GETPROCADDRESS ("glLinkProgramARB");
glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) GETPROCADDRESS ("glUseProgramObjectARB");
glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) GETPROCADDRESS ("glGetUniformLocationARB");
glUniform3fvARB = (PFNGLUNIFORM3FVARBPROC) GETPROCADDRESS ("glUniform3fvARB");
glUniform4fvARB = (PFNGLUNIFORM3FVARBPROC) GETPROCADDRESS ("glUniform4fvARB");
glUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) GETPROCADDRESS ("glUniform4fvARB");
fragShader = glCreateShaderObjectARB (GL_FRAGMENT_SHADER_ARB);
glShaderSourceARB (fragShader, 1, &fragShaderText, NULL);
@@ -269,8 +254,8 @@ static void Init (void)
uDiffuse = glGetUniformLocationARB (program, "diffuse");
uSpecular = glGetUniformLocationARB (program, "specular");
glUniform4fvARB (uDiffuse, 1, diffuse);
glUniform4fvARB (uSpecular, 1, specular);
glUniform4fvARB (uDiffuse, 1, diffuse);
glUniform4fvARB (uSpecular, 1, specular);
glClearColor (0.3f, 0.3f, 0.3f, 0.0f);
glEnable (GL_DEPTH_TEST);

View File

@@ -471,11 +471,6 @@ main(int argc, char **argv)
glutAddMenuEntry("Quit", 666);
glutAttachMenu(GLUT_RIGHT_BUTTON);
if (!glutExtensionSupported("GL_ARB_point_parameters")) {
fprintf(stderr, "Sorry, GL_ARB_point_parameters is not supported.\n");
return -1;
}
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_POINT_SMOOTH);

View File

@@ -537,9 +537,6 @@ main(int argc, char **argv)
glutAddMenuEntry("Quit", 666);
glutAttachMenu(GLUT_RIGHT_BUTTON);
makePointList();
makeSprite();
glShadeModel(GL_FLAT);
glEnable(GL_DEPTH_TEST);
glEnable(GL_POINT_SMOOTH);
@@ -549,6 +546,9 @@ main(int argc, char **argv)
glPointParameterfvARB(GL_POINT_DISTANCE_ATTENUATION_ARB, theQuad);
#endif
makePointList();
makeSprite();
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}

View File

@@ -0,0 +1,407 @@
/*
* GL_ARB_multitexture demo
*
* Command line options:
* -info print GL implementation information
*
*
* Brian Paul November 1998 This program is in the public domain.
* Modified on 12 Feb 2002 for > 2 texture units.
*/
#define GL_GLEXT_PROTOTYPES
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <GL/glut.h>
#include "readtex.h"
enum {
WHOLERECT,
RENDER,
SWAPBUF,
UPLOAD_CONVENTIONAL,
UPLOAD_PBO_NAIVE,
UPLOAD_PBO_PINGPONG,
UPLOAD_PBO_WITH_RESET,
UPLOAD_NOOP,
QUIT
};
static GLint upload_style = UPLOAD_CONVENTIONAL;
static GLboolean whole_rect = 1;
static GLboolean do_render = 1;
static GLboolean do_swapbuffers = 1;
static GLuint col = 0x0;
static GLfloat Xrot = 20.0, Yrot = 30.0;
static GLuint Width = 1024;
static GLuint Height = 512;
#define NR_PBO 2
static GLuint texObj, DrawPBO[NR_PBO];
static void Idle( void )
{
col++;
glutPostRedisplay();
}
static int min( int a, int b ) { return a < b ? a : b; }
static void DrawObject()
{
GLint size = Width * Height * 4;
static char *static_image = NULL;
static int current = 0;
switch (upload_style) {
case UPLOAD_PBO_NAIVE:
/* Continually upload from the one pbo without any attempt to
* decouple from hardware trying to access the same data:
*/
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO[0]);
{
char *image = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY_ARB);
memset(image, col&0xff, size);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
}
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, Width, Height, 0,
GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
break;
case UPLOAD_PBO_PINGPONG:
/* Cycle through the available upload buffers to avoid waiting
* on buffers currently enqueued on the hardware. Avoids
* waiting on buffer contents that may still be referenced by
* hardware.
*/
current = (current + 1) % NR_PBO;
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO[current]);
{
char *image = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY_ARB);
memset(image, col&0xff, size);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
}
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, Width, Height, 0,
GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
break;
case UPLOAD_PBO_WITH_RESET:
/* Alternate approach, uses BufferDataARB(NULL) to explicitly
* release the old image contents from the pbo prior to upload.
* Similar effect to double buffering pbos as above, but a
* little more subtle as the implications of the NULL data are
* not entirely clear. I don't know if all drivers will take
* full advantage of the optimization or not.
*/
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO[0]);
/* XXX: This is extremely important - semantically makes the buffer
* contents undefined, but in practice means that the driver can
* release the old copy of the texture and allocate a new one
* without waiting for outstanding rendering to complete.
*/
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, size, NULL, GL_STREAM_DRAW_ARB);
{
char *image = glMapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY_ARB);
memset(image, col&0xff, size);
glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT);
}
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, Width, Height, 0,
GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
break;
case UPLOAD_CONVENTIONAL:
if (static_image == NULL)
static_image = malloc(size);
memset(static_image, col&0xff, size);
/* BGRA should be the fast path for regular uploads as well.
*/
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, Width, Height, 0,
GL_BGRA, GL_UNSIGNED_BYTE, static_image);
break;
case UPLOAD_NOOP:
break;
}
if (do_render)
{
int x,y,w,h;
if (whole_rect) {
x = y = 0;
w = Width;
h = Height;
}
else {
x = y = 0;
w = min(10, Width);
h = min(10, Height);
}
glBegin(GL_QUADS);
glTexCoord2f( x, y);
glVertex2f( x, y );
glTexCoord2f( x, y + h);
glVertex2f( x, y + h);
glTexCoord2f( x + w, y + h);
glVertex2f( x + w, y + h );
glTexCoord2f( x + w, y);
glVertex2f( x + w, y );
glEnd();
}
}
static void Display( void )
{
static GLint T0 = 0;
static GLint Frames = 0;
GLint t;
glClear( GL_COLOR_BUFFER_BIT );
glPushMatrix();
DrawObject();
glPopMatrix();
if (do_swapbuffers)
glutSwapBuffers();
else
glFlush();
Frames++;
t = glutGet(GLUT_ELAPSED_TIME);
if (t - T0 >= 1000) {
GLfloat seconds = (t - T0) / 1000.0;
GLfloat fps = Frames / seconds;
printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps);
T0 = t;
Frames = 0;
}
}
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, 10.0, 100.0 ); */
gluOrtho2D( 0, width, height, 0 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
/* glTranslatef(0.375, 0.375, 0); */
}
static void ModeMenu(int entry)
{
switch (entry) {
case WHOLERECT:
whole_rect = !whole_rect;
break;
case RENDER:
do_render = !do_render;
break;
case SWAPBUF:
do_swapbuffers = !do_swapbuffers;
break;
case UPLOAD_CONVENTIONAL:
case UPLOAD_PBO_NAIVE:
case UPLOAD_PBO_PINGPONG:
case UPLOAD_PBO_WITH_RESET:
case UPLOAD_NOOP:
upload_style = entry;
break;
case QUIT:
exit(0);
break;
}
glutPostRedisplay();
}
static void Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
switch (key) {
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static void SpecialKey( int key, int x, int y )
{
float step = 3.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( int argc, char *argv[] )
{
const char *exten = (const char *) glGetString(GL_EXTENSIONS);
GLint size;
if (!strstr(exten, "GL_ARB_multitexture")) {
printf("Sorry, GL_ARB_multitexture not supported by this renderer.\n");
exit(1);
}
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size);
printf("%d x %d max texture size\n", size, size);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
/* allocate two texture objects */
glGenTextures(1, &texObj);
/* setup the texture objects */
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, texObj);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glGenBuffersARB(NR_PBO, DrawPBO);
{
int i;
for (i = 0; i < NR_PBO; i++) {
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO[i]);
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER_EXT, Width * Height * 4, NULL, GL_STREAM_DRAW_ARB);
}
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
}
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glShadeModel(GL_SMOOTH);
glClearColor(0.3, 0.3, 0.4, 1.0);
if (argc > 1 && strcmp(argv[1], "-info")==0) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
}
}
int main( int argc, char *argv[] )
{
GLint i;
glutInit( &argc, argv );
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-w") == 0) {
Width = atoi(argv[i+1]);
if (Width <= 0) {
printf("Error, bad width\n");
exit(1);
}
i++;
}
else if (strcmp(argv[i], "-h") == 0) {
Height = atoi(argv[i+1]);
if (Height <= 0) {
printf("Error, bad height\n");
exit(1);
}
i++;
}
}
glutInitWindowSize( Width, Height );
glutInitWindowPosition( 0, 0 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow(argv[0] );
Init( argc, argv );
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );
glutDisplayFunc( Display );
glutIdleFunc( Idle );
glutCreateMenu(ModeMenu);
glutAddMenuEntry("Wholerect", WHOLERECT);
glutAddMenuEntry("Render", RENDER);
glutAddMenuEntry("Swapbuf", SWAPBUF);
glutAddMenuEntry("Upload style CONVENTIONAL", UPLOAD_CONVENTIONAL);
glutAddMenuEntry("Upload style PBO_NAIVE", UPLOAD_PBO_NAIVE);
glutAddMenuEntry("Upload style PBO_PINGPONG", UPLOAD_PBO_PINGPONG);
glutAddMenuEntry("Upload style PBO_WITH_RESET", UPLOAD_PBO_WITH_RESET);
glutAddMenuEntry("Upload style NOOP", UPLOAD_NOOP);
glutAddMenuEntry("Quit", QUIT);
glutAttachMenu(GLUT_RIGHT_BUTTON);
glutMainLoop();
return 0;
}

View File

@@ -38,8 +38,8 @@
#include <GL/glut.h>
static GLsizei MaxSize = 1024;
static GLsizei TexWidth = 256, TexHeight = 256, TexBorder = 0;
static GLsizei MaxSize = 2048;
static GLsizei TexWidth = 1024, TexHeight = 1024, TexBorder = 0;
static GLboolean ScaleAndBias = GL_FALSE;
static GLboolean SubImage = GL_FALSE;
static GLdouble DownloadRate = 0.0; /* texels/sec */
@@ -47,6 +47,32 @@ static GLdouble DownloadRate = 0.0; /* texels/sec */
static GLuint Mode = 0;
/* Try and avoid L2 cache effects by cycling through a small number of
* textures.
*
* At the initial size of 1024x1024x4 == 4mbyte, say 8 textures will
* keep us out of most caches at 32mb total.
*
* This turns into a fairly interesting question of what exactly you
* expect to be in cache in normal usage, and what you think should be
* outside. There's no rules for this, no reason to favour one usage
* over another except what the application you care about happens to
* resemble most closely.
*
* - Should the client texture image be in L2 cache? Has it just been
* generated or read from disk?
* - Does the application really use >1 texture, or is it constantly
* updating one image in-place?
*
* Different answers will favour different texture upload mechanisms.
* To upload an image that is purely outside of cache, a DMA-based
* upload will probably win, whereas for small, in-cache textures,
* copying looks good.
*/
#define NR_TEXOBJ 4
static GLuint TexObj[NR_TEXOBJ];
struct FormatRec {
GLenum Format;
GLenum Type;
@@ -116,25 +142,57 @@ TypeStr(GLenum type)
}
}
/* On x86, there is a performance cliff for memcpy to texture memory
* for sources below 64 byte alignment. We do our best with this in
* the driver, but it is better if the images are correctly aligned to
* start with:
*/
#define ALIGN (1<<12)
static unsigned align(unsigned value, unsigned a)
{
return (value + a - 1) & ~(a-1);
}
static int MIN2(int a, int b)
{
return a < b ? a : b;
}
static void
MeasureDownloadRate(void)
{
const int w = TexWidth + 2 * TexBorder;
const int h = TexHeight + 2 * TexBorder;
const int bytes = w * h * BytesPerTexel(Format);
const int image_bytes = align(w * h * BytesPerTexel(Format), ALIGN);
const int bytes = image_bytes * NR_TEXOBJ;
GLubyte *orig_texImage, *orig_getImage;
GLubyte *texImage, *getImage;
GLdouble t0, t1, time;
int count;
int i;
int offset = 0;
GLdouble total = 0; /* ints will tend to overflow */
texImage = (GLubyte *) malloc(bytes);
getImage = (GLubyte *) malloc(bytes);
if (!texImage || !getImage) {
printf("allocating %d bytes for %d %dx%d images\n",
bytes, NR_TEXOBJ, w, h);
orig_texImage = (GLubyte *) malloc(bytes + ALIGN);
orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN);
if (!orig_texImage || !orig_getImage) {
DownloadRate = 0.0;
return;
}
printf("alloc %p %p\n", orig_texImage, orig_getImage);
texImage = (GLubyte *)align((unsigned)orig_texImage, ALIGN);
getImage = (GLubyte *)align((unsigned)orig_getImage, ALIGN);
for (i = 1; !(((unsigned)texImage) & i); i<<=1)
;
printf("texture image alignment: %d bytes (%p)\n", i, texImage);
for (i = 0; i < bytes; i++) {
texImage[i] = i & 0xff;
}
@@ -166,16 +224,50 @@ MeasureDownloadRate(void)
count = 0;
t0 = glutGet(GLUT_ELAPSED_TIME) * 0.001;
do {
int img = count%NR_TEXOBJ;
GLubyte *img_ptr = texImage + img * image_bytes;
glBindTexture(GL_TEXTURE_2D, TexObj[img]);
if (SubImage && count > 0) {
glTexSubImage2D(GL_TEXTURE_2D, 0, -TexBorder, -TexBorder, w, h,
/* Only update a portion of the image each iteration. This
* is presumably why you'd want to use texsubimage, otherwise
* you may as well just call teximage again.
*
* A bigger question is whether to use a pointer that moves
* with each call, ie does the incoming data come from L2
* cache under normal circumstances, or is it pulled from
* uncached memory?
*
* There's a good argument to say L2 cache, ie you'd expect
* the data to have been recently generated. It's possible
* that it could have come from a file read, which may or may
* not have gone through the cpu.
*/
glTexSubImage2D(GL_TEXTURE_2D, 0,
-TexBorder,
-TexBorder + offset * h/8,
w,
h/8,
FormatTable[Format].Format,
FormatTable[Format].Type, texImage);
FormatTable[Format].Type,
#if 1
texImage /* likely in L2$ */
#else
img_ptr + offset * bytes/8 /* unlikely in L2$ */
#endif
);
offset += 1;
offset %= 8;
total += w * h / 8;
}
else {
glTexImage2D(GL_TEXTURE_2D, 0,
FormatTable[Format].IntFormat, w, h, TexBorder,
FormatTable[Format].Format,
FormatTable[Format].Type, texImage);
FormatTable[Format].Type,
img_ptr);
total += w*h;
}
/* draw a tiny polygon to force texture into texram */
@@ -192,25 +284,12 @@ MeasureDownloadRate(void)
glDisable(GL_TEXTURE_2D);
printf("w*h=%d count=%d time=%f\n", w*h, count, time);
DownloadRate = w * h * count / time;
printf("total texels=%f time=%f\n", total, time);
DownloadRate = total / time;
#if 0
if (!ScaleAndBias) {
/* verify texture readback */
glGetTexImage(GL_TEXTURE_2D, 0,
FormatTable[Format].Format,
FormatTable[Format].Type, getImage);
for (i = 0; i < w * h; i++) {
if (texImage[i] != getImage[i]) {
printf("[%d] %d != %d\n", i, texImage[i], getImage[i]);
}
}
}
#endif
free(texImage);
free(getImage);
free(orig_texImage);
free(orig_getImage);
{
GLint err = glGetError();

View File

@@ -46,7 +46,6 @@ SOURCES = \
tri-tex.c \
tri-xpd.c \
tri-position.c \
point-position.c \
tri-depth.c \
tri-depth2.c \
tri-depthwrite.c \

View File

@@ -1,119 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glut.h>
#include "GL/gl.h"
static void Init( void )
{
static const char *modulate2D =
"!!ARBfp1.0\n"
"MUL result.color, fragment.position, {.005}.x; \n"
"END"
;
GLuint modulateProg;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
/* Setup the fragment program */
glGenProgramsARB(1, &modulateProg);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(modulate2D), (const GLubyte *)modulate2D);
printf("glGetError = 0x%x\n", (int) glGetError());
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
glEnable(GL_FRAGMENT_PROGRAM_ARB);
glClearColor(.3, .3, .3, 0);
}
static void Reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(1);
default:
return;
}
glutPostRedisplay();
}
static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
#if 0
glBegin(GL_QUADS);
glTexCoord2f(1,0);
glVertex3f( 0.9, -0.9, -30.0);
glTexCoord2f(1,1);
glVertex3f( 0.9, 0.9, -30.0);
glTexCoord2f(0,1);
glVertex3f(-0.9, 0.9, -30.0);
glTexCoord2f(0,0);
glVertex3f(-0.9, -0.9, -30.0);
glEnd();
#else
glPointSize(100);
glBegin(GL_POINTS);
glColor3f(0,0,1);
glVertex3f( 0, 0, -30.0);
glEnd();
#endif
glFlush();
}
int main(int argc, char **argv)
{
GLenum type;
glutInit(&argc, argv);
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
type = GLUT_RGB;
type |= GLUT_SINGLE;
glutInitDisplayMode(type);
if (glutCreateWindow("First Tri") == GL_FALSE) {
exit(1);
}
Init();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}

View File

@@ -1400,176 +1400,3 @@ true
2.3
2.4
$ /*
$ --------------------------------------------------------------------------------------------------
$ Test vec4 extension operations.
$ */
$program VEC4 EXTENSION OPERATIONS
$attrib gl_Vertex
0.0 0.0 0.0 1.0
$attrib _One
1.1 0.0 0.0 0.0
$attrib _Two4
2.1 2.2 2.3 2.4
$attrib _Three4
3.1 3.2 3.3 3.4
$vertex
$code
attribute float _One;
attribute vec4 _Two4;
attribute vec4 _Three4;
void main () {
gl_Position = gl_ModelViewMatrix * gl_Vertex;
gl_FrontColor = vec4 (1.0);
printMESA (_One);
printMESA (_Two4);
printMESA (_Three4);
printMESA (vec4 (_One));
printMESA (_Two4 + _Three4);
printMESA (_Two4 - _Three4);
printMESA (_Two4 * _Three4);
printMESA (_Two4 / _Three4);
printMESA (_Two4 + _One);
printMESA (_Two4 - _One);
printMESA (_Two4 * _One);
printMESA (_Two4 / _One);
printMESA (_One + _Two4);
printMESA (_One - _Two4);
printMESA (_One * _Two4);
printMESA (_One / _Two4);
printMESA (-_Three4);
printMESA (dot (_Two4.xyz, _Three4.xyz));
printMESA (dot (_Two4, _Three4));
printMESA (length (_Two4.xyz));
printMESA (length (_Three4));
printMESA (normalize (_Two4.xyz));
printMESA (normalize (_Three4));
vec4 tmp = _Two4;
printMESA (tmp);
printMESA (_Two4 == _Three4);
printMESA (_Two4 != _Three4);
printMESA (_Two4 == _Two4);
printMESA (_Three4 != _Three4);
printMESA (_Two4 != vec4 (_Two4.xyz, 999.0));
printMESA (_Two4 != vec4 (999.0, _Two4.yzw));
}
$output
1.1
2.1
2.2
2.3
2.4
3.1
3.2
3.3
3.4
1.1
1.1
1.1
1.1
5.2
5.4
5.6
5.8
-1.0
-1.0
-1.0
-1.0
6.51
7.04
7.59
8.16
0.677419
0.6875
0.69697
0.705882
3.2
3.3
3.4
3.5
1.0
1.1
1.2
1.3
2.31
2.42
2.53
2.64
1.909091
2.0
2.090909
2.181818
3.2
3.3
3.4
3.5
-1.0
-1.1
-1.2
-1.3
2.31
2.42
2.53
2.64
0.52381
0.5
0.478261
0.458333
-3.1
-3.2
-3.3
-3.4
21.14
29.3
3.813135
6.503845
0.550728
0.576953
0.603178
0.476641
0.492017
0.507392
0.522768
2.1
2.2
2.3
2.4
false
true
true
false
true
true

View File

@@ -320,7 +320,7 @@ void RenderScene (void)
break;
}
if (fabs (value - attribs[i].data[j]) > EPSILON)
printf ("*** %s, is %f, should be %f\n", "Values are different", value, attribs[i].data[j]);
printf ("*** %s\n", "Values are different");
p = strchr (p, '\n');
if (p != NULL)
p++;

View File

@@ -50,7 +50,6 @@ SOURCES = \
no_s3tc.c \
packedpixels.c \
pbo.c \
prog_parameter.c \
projtex.c \
readrate.c \
seccolor.c \

View File

@@ -0,0 +1,184 @@
/* Copyright (c) Mark J. Kilgard, 1994. */
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
* and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
*
* US Government Users Restricted Rights
* Use, duplication, or disclosure by the Government is subject to
* restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
* (c)(1)(ii) of the Rights in Technical Data and Computer Software
* clause at DFARS 252.227-7013 and/or in similar or successor
* clauses in the FAR or the DOD or NASA FAR Supplement.
* Unpublished-- rights reserved under the copyright laws of the
* United States. Contractor/manufacturer is Silicon Graphics,
* Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
/* mipmap.c
* This program demonstrates using mipmaps for texture maps.
* To overtly show the effect of mipmaps, each mipmap reduction
* level has a solidly colored, contrasting texture image.
* Thus, the quadrilateral which is drawn is drawn with several
* different colors.
*/
#include <stdlib.h>
#include <stdio.h>
#include <GL/glut.h>
GLubyte mipmapImage32[40][46][3];
GLubyte mipmapImage16[20][23][3];
GLubyte mipmapImage8[10][11][3];
GLubyte mipmapImage4[5][5][3];
GLubyte mipmapImage2[2][2][3];
GLubyte mipmapImage1[1][1][3];
static void makeImages(void)
{
int i, j;
for (i = 0; i < 40; i++) {
for (j = 0; j < 46; j++) {
mipmapImage32[i][j][0] = 255;
mipmapImage32[i][j][1] = 255;
mipmapImage32[i][j][2] = 0;
}
}
for (i = 0; i < 20; i++) {
for (j = 0; j < 23; j++) {
mipmapImage16[i][j][0] = 255;
mipmapImage16[i][j][1] = 0;
mipmapImage16[i][j][2] = 255;
}
}
for (i = 0; i < 10; i++) {
for (j = 0; j < 11; j++) {
mipmapImage8[i][j][0] = 255;
mipmapImage8[i][j][1] = 0;
mipmapImage8[i][j][2] = 0;
}
}
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
mipmapImage4[i][j][0] = 0;
mipmapImage4[i][j][1] = 255;
mipmapImage4[i][j][2] = 0;
}
}
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
mipmapImage2[i][j][0] = 0;
mipmapImage2[i][j][1] = 0;
mipmapImage2[i][j][2] = 255;
}
}
mipmapImage1[0][0][0] = 255;
mipmapImage1[0][0][1] = 255;
mipmapImage1[0][0][2] = 255;
}
static void myinit(void)
{
if (!glutExtensionSupported("GL_ARB_texture_non_power_of_two")) {
printf("Sorry, this program requires GL_ARB_texture_non_power_of_two\n");
exit(1);
}
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glShadeModel(GL_FLAT);
glTranslatef(0.0, 0.0, -3.6);
makeImages();
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, 3, 40, 46, 0,
GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage32[0][0][0]);
glTexImage2D(GL_TEXTURE_2D, 1, 3, 20, 23, 0,
GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage16[0][0][0]);
glTexImage2D(GL_TEXTURE_2D, 2, 3, 10, 11, 0,
GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage8[0][0][0]);
glTexImage2D(GL_TEXTURE_2D, 3, 3, 5, 5, 0,
GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage4[0][0][0]);
glTexImage2D(GL_TEXTURE_2D, 4, 3, 2, 2, 0,
GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage2[0][0][0]);
glTexImage2D(GL_TEXTURE_2D, 5, 3, 1, 1, 0,
GL_RGB, GL_UNSIGNED_BYTE, &mipmapImage1[0][0][0]);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST_MIPMAP_NEAREST);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glEnable(GL_TEXTURE_2D);
}
static void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex3f(-2.0, -1.0, 0.0);
glTexCoord2f(0.0, 8.0); glVertex3f(-2.0, 1.0, 0.0);
glTexCoord2f(8.0, 8.0); glVertex3f(2000.0, 1.0, -6000.0);
glTexCoord2f(8.0, 0.0); glVertex3f(2000.0, -1.0, -6000.0);
glEnd();
glFlush();
}
static void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 1.0*(GLfloat)w/(GLfloat)h, 1.0, 30000.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
static void
key(unsigned char k, int x, int y)
{
switch (k) {
case 27: /* Escape */
exit(0);
break;
default:
return;
}
glutPostRedisplay();
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (500, 500);
glutCreateWindow (argv[0]);
myinit();
glutReshapeFunc (myReshape);
glutDisplayFunc(display);
glutKeyboardFunc(key);
glutMainLoop();
return 0; /* ANSI C requires main to return int. */
}

View File

@@ -28,8 +28,6 @@ struct object
static struct object Objects[NUM_OBJECTS];
static GLuint NumObjects;
static GLuint Win;
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLboolean Anim = GL_TRUE;
@@ -120,14 +118,6 @@ static void Reshape( int width, int height )
}
static void FreeBuffers(void)
{
int i;
for (i = 0; i < NUM_OBJECTS; i++)
glDeleteBuffersARB(1, &Objects[i].BufferID);
}
static void Key( unsigned char key, int x, int y )
{
const GLfloat step = 3.0;
@@ -148,8 +138,6 @@ static void Key( unsigned char key, int x, int y )
Zrot += step;
break;
case 27:
FreeBuffers();
glutDestroyWindow(Win);
exit(0);
break;
}
@@ -358,7 +346,7 @@ int main( int argc, char *argv[] )
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( 600, 300 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
Win = glutCreateWindow(argv[0]);
glutCreateWindow(argv[0]);
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutSpecialFunc( SpecialKey );

View File

@@ -1,285 +0,0 @@
/*
* (C) Copyright IBM Corporation 2006
* 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
* on 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
* IBM AND/OR THEIR 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 prog_parameter.c
*
* Test various aspects of setting (and getting) low-level program parameters.
* This is primarilly intended as a test for GL_EXT_gpu_program_parameters,
* but it turns out that it hits some other functionality along the way.
*
* \author Ian Romanick <idr@us.ibm.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
#ifndef GL_EXT_gpu_program_parameters
typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC)(GLenum,
GLuint, GLsizei, const GLfloat *);
typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC)(GLenum,
GLuint, GLsizei, const GLfloat *);
#endif
static PFNGLPROGRAMLOCALPARAMETER4FVARBPROC program_local_parameter4fv = NULL;
static PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC get_program_local_parameterfv = NULL;
static PFNGLPROGRAMENVPARAMETER4FVARBPROC program_env_parameter4fv = NULL;
static PFNGLGETPROGRAMENVPARAMETERFVARBPROC get_program_env_parameterfv = NULL;
static PFNGLBINDPROGRAMARBPROC bind_program = NULL;
static PFNGLGETPROGRAMIVARBPROC get_program = NULL;
static PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC program_local_parameters4fv = NULL;
static PFNGLPROGRAMENVPARAMETERS4FVEXTPROC program_env_parameters4fv = NULL;
static int Width = 400;
static int Height = 200;
static const GLfloat Near = 5.0, Far = 25.0;
static void Display( void )
{
}
static void Idle( void )
{
}
static void Visible( int vis )
{
if ( vis == GLUT_VISIBLE ) {
glutIdleFunc( Idle );
}
else {
glutIdleFunc( NULL );
}
}
static void Reshape( int width, int height )
{
GLfloat ar = (float) width / (float) height;
Width = width;
Height = height;
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glFrustum( -ar, ar, -1.0, 1.0, Near, Far );
}
static void Key( unsigned char key, int x, int y )
{
(void) x;
(void) y;
switch (key) {
case 27:
exit(0);
break;
}
glutPostRedisplay();
}
static int set_parameter_batch( GLsizei count, GLfloat * param,
const char * name,
PFNGLPROGRAMLOCALPARAMETER4FVARBPROC set_parameter,
PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC set_parameters,
PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC get_parameter
)
{
unsigned i;
int pass = 1;
for ( i = 0 ; i < (4 * count) ; i++ ) {
param[i] = (GLfloat) random() / (GLfloat) random();
}
/* Try using the "classic" interface.
*/
printf("Testing glProgram%sParameter4fvARB (count = %u)...\n", name, count);
for ( i = 0 ; i < count ; i++ ) {
(*set_parameter)(GL_VERTEX_PROGRAM_ARB, i, & param[i * 4]);
}
for ( i = 0 ; i < count ; i++ ) {
GLfloat temp[4];
(*get_parameter)(GL_VERTEX_PROGRAM_ARB, i, temp);
if ( (temp[0] != param[(i * 4) + 0])
|| (temp[1] != param[(i * 4) + 1])
|| (temp[2] != param[(i * 4) + 2])
|| (temp[3] != param[(i * 4) + 3]) ) {
printf("Mismatch in glProgram%sParameter4fvARB index %u!\n", name, i);
printf("Got { %f, %f, %f, %f }, expected { %f, %f, %f, %f }!\n",
temp[0], temp[1],
temp[2], temp[3],
param[(i * 4) + 0], param[(i * 4) + 1],
param[(i * 4) + 2], param[(i * 4) + 3]);
pass = 0;
break;
}
}
if ( set_parameters == NULL ) {
return pass;
}
for ( i = 0 ; i < (4 * count) ; i++ ) {
param[i] = (GLfloat) random() / (GLfloat) random();
}
printf("Testing glProgram%sParameters4fvEXT (count = %u)...\n", name, count);
(*set_parameters)(GL_VERTEX_PROGRAM_ARB, 0, count, param);
for ( i = 0 ; i < count ; i++ ) {
GLfloat temp[4];
(*get_parameter)(GL_VERTEX_PROGRAM_ARB, i, temp);
if ( (temp[0] != param[(i * 4) + 0])
|| (temp[1] != param[(i * 4) + 1])
|| (temp[2] != param[(i * 4) + 2])
|| (temp[3] != param[(i * 4) + 3]) ) {
printf("Mismatch in glProgram%sParameters4fvEXT index %u!\n", name, i);
printf("Got { %f, %f, %f, %f }, expected { %f, %f, %f, %f }!\n",
temp[0], temp[1],
temp[2], temp[3],
param[(i * 4) + 0], param[(i * 4) + 1],
param[(i * 4) + 2], param[(i * 4) + 3]);
pass = 0;
break;
}
}
return pass;
}
static void Init( void )
{
const char * const ver_string = (const char * const)
glGetString( GL_VERSION );
int pass = 1;
GLfloat * params;
GLint max_program_env_parameters;
GLint max_program_local_parameters;
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n\n", ver_string);
if ( !glutExtensionSupported("GL_ARB_vertex_program") ) {
printf("Sorry, this program requires GL_ARB_vertex_program\n");
exit(2);
}
program_local_parameter4fv = glutGetProcAddress( "glProgramLocalParameter4fvARB" );
program_env_parameter4fv = glutGetProcAddress( "glProgramEnvParameter4fvARB" );
get_program_local_parameterfv = glutGetProcAddress( "glGetProgramLocalParameterfvARB" );
get_program_env_parameterfv = glutGetProcAddress( "glGetProgramEnvParameterfvARB" );
bind_program = glutGetProcAddress( "glBindProgramARB" );
get_program = glutGetProcAddress( "glGetProgramivARB" );
if ( glutExtensionSupported("GL_EXT_gpu_program_parameters") ) {
printf("GL_EXT_gpu_program_parameters available, testing that path.\n");
program_local_parameters4fv = glutGetProcAddress( "glProgramLocalParameters4fvEXT" );
program_env_parameters4fv = glutGetProcAddress( "glProgramEnvParameters4fvEXT" );
}
else {
printf("GL_EXT_gpu_program_parameters not available.\n");
program_local_parameters4fv = NULL;
program_env_parameters4fv = NULL;
}
/* Since the test sets program local parameters, a program must be bound.
* Program source, however, is not needed.
*/
(*bind_program)(GL_VERTEX_PROGRAM_ARB, 1);
(*get_program)(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB,
& max_program_env_parameters);
params = malloc(max_program_env_parameters * 4 * sizeof(GLfloat));
pass &= set_parameter_batch(max_program_env_parameters, params, "Env",
program_env_parameter4fv,
program_env_parameters4fv,
get_program_env_parameterfv);
(*get_program)(GL_VERTEX_PROGRAM_ARB, GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB,
& max_program_local_parameters);
if (max_program_local_parameters > max_program_env_parameters) {
params = realloc(params,
max_program_local_parameters * 4 * sizeof(GLfloat));
}
pass &= set_parameter_batch(max_program_local_parameters, params, "Local",
program_local_parameter4fv,
program_local_parameters4fv,
get_program_local_parameterfv);
free(params);
if (! pass) {
printf("FAIL!\n");
exit(1);
}
printf("PASS!\n");
}
int main( int argc, char *argv[] )
{
glutInit( &argc, argv );
glutInitWindowPosition( 0, 0 );
glutInitWindowSize( Width, Height );
glutInitDisplayMode( GLUT_RGB );
glutCreateWindow( "Program Parameters Test" );
glutReshapeFunc( Reshape );
glutKeyboardFunc( Key );
glutDisplayFunc( Display );
glutVisibilityFunc( Visible );
Init();
return 0;
}

View File

@@ -38,7 +38,9 @@ SOURCES = \
quad-offset-unfilled.c \
quad-unfilled.c \
quad-tex-2d.c \
quad-tex-pbo.c \
quad-tex-3d.c \
quad-tex-dep.c \
quad.c \
quads.c \
quadstrip.c \

View File

@@ -0,0 +1,245 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define GL_GLEXT_PROTOTYPES
#include <GL/glut.h>
GLenum doubleBuffer;
/* Demonstrate an equivalent to paletted texturing using fragment
* programs and dependent texturing. This requires at least one
* texture unit to be reserved for the palette lookup.
*/
static void Init( void )
{
static const char *modulate2D =
"!!ARBfp1.0\n"
"TEMP index; \n"
"TEX index, fragment.texcoord[0], texture[0], 2D; \n"
"TEX result.color, index, texture[1], 1D; \n"
"END"
;
GLuint modulateProg;
GLuint Texture;
if (!glutExtensionSupported("GL_ARB_fragment_program")) {
printf("Error: GL_ARB_fragment_program not supported!\n");
exit(1);
}
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
/* Setup the fragment program */
glGenProgramsARB(1, &modulateProg);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
strlen(modulate2D), (const GLubyte *)modulate2D);
printf("glGetError = 0x%x\n", (int) glGetError());
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
assert(glIsProgramARB(modulateProg));
glEnable(GL_FRAGMENT_PROGRAM_ARB);
{
#define HEIGHT 8
#define WIDTH 32
#define B 0
#define G 1
#define R 2
#define A 3
static char texture[HEIGHT * WIDTH + 1] =
" "
" MMM EEEE SSS AAA "
" M M M E S S A A "
" M M M EEEE SS A A "
" M M M E SS AAAAA "
" M M E S S A A "
" M M EEEE SSS A A ";
GLubyte table[256][4];
/* load the color table for each texel-index */
memset(table, 0xff, 256*4);
table[' '][B] = 255;
table[' '][G] = 255;
table[' '][R] = 255;
table[' '][A] = 64;
table['M'][B] = 0;
table['M'][G] = 0;
table['M'][R] = 255;
table['M'][A] = 255;
table['E'][B] = 0;
table['E'][G] = 255;
table['E'][R] = 0;
table['E'][A] = 255;
table['S'][B] = 255;
table['S'][G] = 0;
table['S'][R] = 0;
table['S'][A] = 255;
table['A'][B] = 0;
table['A'][G] = 255;
table['A'][R] = 255;
table['A'][A] = 255;
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
/* Load indexed texture as a 2D I8 texture */
glActiveTextureARB(GL_TEXTURE0_ARB);
glGenTextures(1, &Texture);
glBindTexture(GL_TEXTURE_2D, Texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, /* target */
0, /* level */
GL_INTENSITY, /* internal format */
WIDTH, HEIGHT, /* width, height */
0, /* border */
GL_LUMINANCE, /* texture format */
GL_UNSIGNED_BYTE, /* texture type */
texture); /* the texture */
printf("glGetError = 0x%x\n", (int) glGetError());
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
glEnable(GL_TEXTURE_2D);
/* Load "pallete" as a 1D BGRA8888 texture */
glActiveTextureARB(GL_TEXTURE1_ARB);
glGenTextures(1, &Texture);
glBindTexture(GL_TEXTURE_1D, Texture);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage1D(GL_TEXTURE_1D, /* target */
0, /* level */
GL_RGBA, /* internal format */
256, /* width */
0, /* border */
GL_BGRA, /* texture format */
GL_UNSIGNED_BYTE, /* texture type */
table); /* the texture */
glEnable(GL_TEXTURE_1D);
/* glEnable(GL_BLEND); */
/* glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); */
#undef HEIGHT
#undef WIDTH
}
glClearColor(.3, .3, .3, 0);
}
static void Reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(1);
default:
return;
}
glutPostRedisplay();
}
static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glTexCoord2f(1,1);
glVertex3f( 0.9, -0.9, -30.0);
glTexCoord2f(1,0);
glVertex3f( 0.9, 0.9, -30.0);
glTexCoord2f(0,0);
glVertex3f(-0.9, 0.9, -30.0);
glTexCoord2f(0,1);
glVertex3f(-0.9, -0.9, -30.0);
glEnd();
glFlush();
if (doubleBuffer) {
glutSwapBuffers();
}
}
static GLenum Args(int argc, char **argv)
{
GLint i;
doubleBuffer = GL_FALSE;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
doubleBuffer = GL_FALSE;
} else if (strcmp(argv[i], "-db") == 0) {
doubleBuffer = GL_TRUE;
} else {
fprintf(stderr, "%s (Bad option).\n", argv[i]);
return GL_FALSE;
}
}
return GL_TRUE;
}
int main(int argc, char **argv)
{
GLenum type;
glutInit(&argc, argv);
if (Args(argc, argv) == GL_FALSE) {
exit(1);
}
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
type = GLUT_RGB;
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
if (glutCreateWindow("First Tri") == GL_FALSE) {
exit(1);
}
Init();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}

View File

@@ -0,0 +1,181 @@
/*
* Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that (i) the above copyright notices and this permission notice appear in
* all copies of the software and related documentation, and (ii) the name of
* Silicon Graphics may not be used in any advertising or
* publicity relating to the software without the specific, prior written
* permission of Silicon Graphics.
*
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
* ANY KIND,
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
*
* IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*/
#define GL_GLEXT_PROTOTYPES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <GL/glut.h>
#define CI_OFFSET_1 16
#define CI_OFFSET_2 32
GLenum doubleBuffer;
static GLuint DrawPBO;
static void Init(void)
{
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
glClearColor(0.0, 0.0, 1.0, 0.0);
#define SIZE 16
{
GLubyte tex2d[SIZE][SIZE][4];
GLint s, t;
for (s = 0; s < SIZE; s++) {
for (t = 0; t < SIZE; t++) {
/* bgra:
*/
tex2d[t][s][0] = 0x30;
tex2d[t][s][1] = t*255/(SIZE-1);
tex2d[t][s][2] = s*255/(SIZE-1);
tex2d[t][s][3] = 0xff;
}
}
/* put image into DrawPBO */
glGenBuffersARB(1, &DrawPBO);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, DrawPBO);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_EXT,
SIZE * SIZE * 4, tex2d, GL_STATIC_DRAW);
glBindBufferARB(GL_PIXEL_PACK_BUFFER_EXT, 0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, DrawPBO);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE, SIZE, 0,
GL_BGRA, GL_UNSIGNED_BYTE, NULL);
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glEnable(GL_TEXTURE_2D);
}
}
static void Reshape(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
glMatrixMode(GL_MODELVIEW);
}
static void Key(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(1);
default:
return;
}
glutPostRedisplay();
}
static void Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_QUADS);
glTexCoord2f(1,0);
glVertex3f( 0.9, -0.9, -30.0);
glTexCoord2f(1,1);
glVertex3f( 0.9, 0.9, -30.0);
glTexCoord2f(0,1);
glVertex3f(-0.9, 0.9, -30.0);
glTexCoord2f(0,0);
glVertex3f(-0.9, -0.9, -30.0);
glEnd();
glFlush();
if (doubleBuffer) {
glutSwapBuffers();
}
}
static GLenum Args(int argc, char **argv)
{
GLint i;
doubleBuffer = GL_FALSE;
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
doubleBuffer = GL_FALSE;
} else if (strcmp(argv[i], "-db") == 0) {
doubleBuffer = GL_TRUE;
} else {
fprintf(stderr, "%s (Bad option).\n", argv[i]);
return GL_FALSE;
}
}
return GL_TRUE;
}
int main(int argc, char **argv)
{
GLenum type;
glutInit(&argc, argv);
if (Args(argc, argv) == GL_FALSE) {
exit(1);
}
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
type = GLUT_RGB;
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
if (glutCreateWindow("First Tri") == GL_FALSE) {
exit(1);
}
Init();
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}

View File

@@ -31,10 +31,10 @@
** published by SGI, but has not been independently verified as being
** compliant with the OpenGL(R) version 1.2.1 Specification.
**
** $Date: 2006/08/30 19:02:45 $ $Revision: 1.4 $
** $Date: 2005/10/28 13:09:23 $ $Revision: 1.3 $
*/
/*
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/sampleCompRight.cc,v 1.4 2006/08/30 19:02:45 brianp Exp $
** $Header: /home/krh/git/sync/mesa-cvs-repo/Mesa/src/glu/sgi/libnurbs/nurbtess/sampleCompRight.cc,v 1.3 2005/10/28 13:09:23 brianp Exp $
*/
#include <stdlib.h>
@@ -72,7 +72,7 @@ void sampleCompRight(Real* topVertex, Real* botVertex,
*/
Int midIndex1;
Int midIndex2;
Int gridMidIndex1 = 0, gridMidIndex2 = 0;
Int gridMidIndex1, gridMidIndex2 = 0;
//midIndex1: array[i] <= v, array[i+1] > v
//midIndex2: array[i] >= v, array[i+1] < v
midIndex1 = rightChain->findIndexBelowGen(rightGridChain->get_v_value(gridIndex1),

View File

@@ -24,62 +24,6 @@
#include "internal.h"
/*****************************************************************************/
static int g_ignore_key_repeat = 0;
/*****************************************************************************/
int GLUTAPIENTRY
glutDeviceGet( GLenum type )
{
switch (type) {
case GLUT_HAS_KEYBOARD:
return (keyboard != NULL);
case GLUT_HAS_MOUSE:
return (mouse != NULL);
case GLUT_NUM_MOUSE_BUTTONS:
if (mouse) {
DFBInputDeviceDescription dsc;
mouse->GetDescription( mouse, &dsc );
return dsc.max_button+1;
}
break;
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
return g_ignore_key_repeat;
case GLUT_DEVICE_KEY_REPEAT:
return (g_ignore_key_repeat) ? GLUT_KEY_REPEAT_OFF
: GLUT_KEY_REPEAT_ON;
case GLUT_HAS_JOYSTICK:
case GLUT_OWNS_JOYSTICK:
return (g_game && joystick); /* only available in game mode */
case GLUT_JOYSTICK_BUTTONS:
if (joystick) {
DFBInputDeviceDescription dsc;
joystick->GetDescription( joystick, &dsc );
return dsc.max_button+1;
}
break;
case GLUT_JOYSTICK_AXES:
if (joystick) {
DFBInputDeviceDescription dsc;
joystick->GetDescription( joystick, &dsc );
return dsc.max_axis+1;
}
break;
case GLUT_JOYSTICK_POLL_RATE:
if (joystick)
return 1; /* hack */
break;
default:
break;
}
return 0;
}
int GLUTAPIENTRY
glutGetModifiers( void )
{
@@ -92,14 +36,12 @@ glutGetModifiers( void )
void GLUTAPIENTRY
glutIgnoreKeyRepeat( int ignore )
{
g_ignore_key_repeat = ignore;
}
void GLUTAPIENTRY
glutSetKeyRepeat( int mode )
{
g_ignore_key_repeat = (mode == GLUT_KEY_REPEAT_OFF);
}
@@ -195,7 +137,7 @@ __glutModifiers( DFBInputDeviceModifierMask mask )
static void
__glutWindowEvent( DFBWindowEvent *e, DFBWindowEvent *p )
__glutWindowEvent( DFBWindowEvent *e )
{
__GlutWindow *window;
@@ -206,12 +148,6 @@ __glutWindowEvent( DFBWindowEvent *e, DFBWindowEvent *p )
switch (e->type) {
case DWET_KEYDOWN:
window->modifiers = __glutModifiers( e->modifiers );
if (g_ignore_key_repeat && p) {
if (p->type == DWET_KEYDOWN &&
p->window_id == e->window_id &&
p->key_symbol == e->key_symbol)
break;
}
if (DFB_KEY_IS_ASCII( e->key_symbol )) {
if (keyboard_func) {
__glutSetWindow( window );
@@ -291,18 +227,13 @@ __glutWindowEvent( DFBWindowEvent *e, DFBWindowEvent *p )
static void
__glutInputEvent( DFBInputEvent *e, DFBInputEvent *p )
__glutInputEvent( DFBInputEvent *e )
{
__glutAssert( g_game != NULL );
switch (e->type) {
case DIET_KEYPRESS:
g_game->modifiers = __glutModifiers( e->modifiers );
if (g_ignore_key_repeat && p) {
if (p->type == DIET_KEYPRESS &&
p->key_symbol == e->key_symbol)
break;
}
g_game->modifiers = __glutModifiers( e->modifiers );
if (DFB_KEY_IS_ASCII( e->key_symbol )) {
if (keyboard_func) {
__glutSetWindow( g_game );
@@ -436,37 +367,20 @@ glutMainLoop( void )
__glutAssert( events != NULL );
while (GL_TRUE) {
DFBEvent evt, prev;
DFBEvent evt;
g_idle = GL_TRUE;
__glutHandleTimers();
__glutHandleWindows();
prev.clazz = DFEC_NONE;
while (events->GetEvent( events, &evt ) == DFB_OK) {
g_idle = GL_FALSE;
switch (evt.clazz) {
case DFEC_WINDOW:
if (prev.clazz == DFEC_WINDOW)
__glutWindowEvent( &evt.window, &prev.window );
else
__glutWindowEvent( &evt.window, NULL );
break;
case DFEC_INPUT:
if (prev.clazz == DFEC_INPUT)
__glutInputEvent( &evt.input, &prev.input );
else
__glutInputEvent( &evt.input, NULL );
break;
default:
__glutWarning( "unexpected event class %d!\n", evt.clazz );
break;
}
prev = evt;
if (evt.clazz == DFEC_WINDOW)
__glutWindowEvent( &evt.window );
else
__glutInputEvent( &evt.input );
__glutHandleTimers();
}

View File

@@ -207,6 +207,45 @@ glutLayerGet( GLenum type )
return 0;
}
int GLUTAPIENTRY
glutDeviceGet( GLenum type )
{
switch (type) {
case GLUT_HAS_KEYBOARD:
return (keyboard != NULL);
case GLUT_HAS_MOUSE:
return (mouse != NULL);
case GLUT_NUM_MOUSE_BUTTONS:
if (mouse) {
DFBInputDeviceDescription dsc;
mouse->GetDescription( mouse, &dsc );
return dsc.max_button+1;
}
break;
case GLUT_HAS_JOYSTICK:
return (g_game && joystick); /* only available in game mode */
case GLUT_JOYSTICK_BUTTONS:
if (joystick) {
DFBInputDeviceDescription dsc;
joystick->GetDescription( joystick, &dsc );
return dsc.max_button+1;
}
break;
case GLUT_JOYSTICK_AXES:
if (joystick) {
DFBInputDeviceDescription dsc;
joystick->GetDescription( joystick, &dsc );
return dsc.max_axis+1;
}
break;
default:
break;
}
return 0;
}
void GLUTAPIENTRY
glutReportErrors( void )
{

View File

@@ -4,7 +4,7 @@ TOP = ../../..
include $(TOP)/configs/current
GLX_SHARED = $(TOP)/src/glut/glx
MINI_SHARED = $(TOP)/src/glut/mini
SHAPES = $(TOP)/src/glut/mini
GLUT_MAJOR = 3
GLUT_MINOR = 7
@@ -13,23 +13,13 @@ GLUT_TINY = 1
INCLUDES = -I$(TOP)/include -I$(GLX_SHARED)
CORE_SOURCES = \
fbdev.c \
colormap.c \
cursor.c \
menu.c \
overlay.c \
ext.c \
state.c \
input.c \
callback.c \
gamemode.c \
vidresize.c \
bitmap.c \
stroke.c
glut_fbdev.c
GLX_SHARED_SOURCES = \
$(GLX_SHARED)/glut_8x13.c \
$(GLX_SHARED)/glut_9x15.c \
$(GLX_SHARED)/glut_bwidth.c \
$(GLX_SHARED)/glut_bitmap.c \
$(GLX_SHARED)/glut_hel10.c \
$(GLX_SHARED)/glut_hel12.c \
$(GLX_SHARED)/glut_hel18.c \
@@ -37,12 +27,12 @@ GLX_SHARED_SOURCES = \
$(GLX_SHARED)/glut_tr24.c \
$(GLX_SHARED)/glut_mroman.c \
$(GLX_SHARED)/glut_roman.c \
$(GLX_SHARED)/glut_swidth.c \
$(GLX_SHARED)/glut_stroke.c \
$(TOP)/src/glut/mini/models.c \
$(GLX_SHARED)/glut_teapot.c
MINI_SHARED_SOURCES = \
$(MINI_SHARED)/models.c \
$(MINI_SHARED)/teapot.c
SOURCES = $(CORE_SOURCES) $(GLX_SHARED_SOURCES) $(MINI_SHARED_SOURCES)
SOURCES = $(CORE_SOURCES) $(GLX_SHARED_SOURCES)
OBJECTS = $(SOURCES:.c=.o)
@@ -50,7 +40,7 @@ OBJECTS = $(SOURCES:.c=.o)
##### RULES #####
.c.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
.S.o:
$(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
@@ -68,11 +58,6 @@ $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
$(GLUT_LIB_DEPS) -install $(TOP)/$(LIB_DIR) \
$(MKLIB_OPTIONS) $(OBJECTS)
install:
$(INSTALL) -d $(INSTALL_DIR)/include/GL
$(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
$(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(INSTALL_DIR)/include/GL
$(COPY_LIBS) $(TOP)/$(LIB_DIR)/libglut* $(INSTALL_DIR)/$(LIB_DIR)
# Run 'make -f Makefile.solo dep' to update the dependencies if you change
# what's included by any source file.

View File

@@ -1,78 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*
* To improve on this library, maybe support subwindows or overlays,
* I (sean at depagnier dot com) will do my best to help.
*/
#include "glutbitmap.h"
void glutBitmapCharacter(GLUTbitmapFont font, int c)
{
const BitmapCharRec *ch;
BitmapFontPtr fi = (BitmapFontPtr) font;
if (c < fi->first ||
c >= fi->first + fi->num_chars)
return;
ch = fi->ch[c - fi->first];
if (!ch)
return;
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBitmap(ch->width, ch->height, ch->xorig, ch->yorig,
ch->advance, 0, ch->bitmap);
glPopClientAttrib();
}
int glutBitmapWidth (GLUTbitmapFont font, int c)
{
const BitmapCharRec *ch;
BitmapFontPtr fi = (BitmapFontPtr) font;
if (c < fi->first || c >= fi->first + fi->num_chars)
return 0;
ch = fi->ch[c - fi->first];
if (ch)
return ch->advance;
return 0;
}
int glutBitmapLength(GLUTbitmapFont font, const unsigned char *string)
{
int length = 0;
for (; *string; string++)
length += glutBitmapWidth(font, *string);
return length;
}

View File

@@ -1,172 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <GL/glut.h>
#include "internal.h"
void (*DisplayFunc)(void) = NULL;
void (*ReshapeFunc)(int width, int height) = NULL;
void (*KeyboardFunc)(unsigned char key, int x, int y) = NULL;
void (*KeyboardUpFunc)(unsigned char key, int x, int y) = NULL;
void (*MouseFunc)(int key, int state, int x, int y) = NULL;
void (*MotionFunc)(int x, int y) = NULL;
void (*PassiveMotionFunc)(int x, int y) = NULL;
void (*VisibilityFunc)(int state) = NULL;
void (*SpecialFunc)(int key, int x, int y) = NULL;
void (*SpecialUpFunc)(int key, int x, int y) = NULL;
void (*IdleFunc)(void) = NULL;
void (*MenuStatusFunc)(int state, int x, int y) = NULL;
void (*MenuStateFunc)(int state) = NULL;
void glutDisplayFunc(void (*func)(void))
{
DisplayFunc = func;
}
void glutOverlayDisplayFunc(void (*func)(void))
{
}
void glutWindowStatusFunc(void (*func)(int state))
{
}
void glutReshapeFunc(void (*func)(int width, int height))
{
ReshapeFunc = func;
}
void glutKeyboardFunc(void (*func)(unsigned char key, int x, int y))
{
KeyboardFunc = func;
}
void glutKeyboardUpFunc(void (*func)(unsigned char key, int x, int y))
{
KeyboardUpFunc = func;
}
void glutMouseFunc(void (*func)(int button, int state, int x, int y))
{
MouseEnabled = 1;
MouseFunc = func;
}
void glutMotionFunc(void (*func)(int x, int y))
{
MouseEnabled = 1;
MotionFunc = func;
}
void glutPassiveMotionFunc(void (*func)(int x, int y))
{
MouseEnabled = 1;
PassiveMotionFunc = func;
}
void glutJoystickFunc(void (*func)(unsigned int buttonMask,
int x, int y, int z), int pollInterval)
{
}
void glutVisibilityFunc(void (*func)(int state))
{
VisibilityFunc = func;
}
void glutEntryFunc(void (*func)(int state))
{
}
void glutSpecialFunc(void (*func)(int key, int x, int y))
{
SpecialFunc = func;
}
void glutSpecialUpFunc(void (*func)(int key, int x, int y))
{
SpecialUpFunc = func;
}
void glutSpaceballMotionFunc(void (*func)(int x, int y, int z))
{
}
void glutSpaceballRotateFunc(void (*func)(int x, int y, int z))
{
}
void glutSpaceballButtonFunc(void (*func)(int button, int state))
{
}
void glutButtonBoxFunc(void (*func)(int button, int state))
{
}
void glutDialsFunc(void (*func)(int dial, int value))
{
}
void glutTabletMotionFunc(void (*func)(int x, int y))
{
}
void glutTabletButtonFunc(void (*func)(int button, int state,
int x, int y))
{
}
void glutMenuStatusFunc(void (*func)(int status, int x, int y))
{
MenuStatusFunc = func;
}
void glutMenuStateFunc(void (*func)(int status))
{
MenuStateFunc = func;
}
void glutIdleFunc(void (*func)(void))
{
IdleFunc = func;
}
void glutTimerFunc(unsigned int msecs,
void (*func)(int value), int value)
{
struct GlutTimer **head = &GlutTimers, *timer = malloc(sizeof *timer);
timer->time = glutGet(GLUT_ELAPSED_TIME) + msecs;
timer->func = func;
timer->value = value;
while(*head && (*head)->time < timer->time)
head = &(*head)->next;
timer->next = *head;
*head = timer;
}

View File

@@ -1,170 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <stdlib.h>
#include <linux/fb.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include "internal.h"
#define TOCMAP(x)(unsigned short)((x<0?0:x>1?1:x)*(GLfloat) ((1<<16) - 1))
#define TORMAP(x)(unsigned short)((x<0?0:x>1?1:x)*(GLfloat)(REVERSECMAPSIZE-1))
#define FROMCMAP(x) (GLfloat)x / (GLfloat)((1<<16) - 1)
static struct fb_cmap ColorMap;
unsigned short RedColorMap[256], GreenColorMap[256], BlueColorMap[256];
unsigned char ReverseColorMap[REVERSECMAPSIZE]
[REVERSECMAPSIZE]
[REVERSECMAPSIZE];
static void FindReverseMap(int r, int g, int b)
{
static int count;
int i, shift = 16 - REVERSECMAPSIZELOG;
unsigned int minv = -1, mini = 0;
for(i=0; i<256; i++) {
int val = 0;
val += abs(r-(RedColorMap[i]>>shift));
val += abs(g-(GreenColorMap[i]>>shift));
val += abs(b-(BlueColorMap[i]>>shift));
if(val < minv) {
minv = val;
mini = i;
}
}
ReverseColorMap[r][g][b] = mini;
}
static void FillItemReverseColorMap(int r, int g, int b)
{
FindReverseMap(r, g, b);
if(r > 0)
FindReverseMap(r-1, g, b);
if(r < REVERSECMAPSIZE - 1)
FindReverseMap(r+1, g, b);
if(g > 0)
FindReverseMap(r, g-1, b);
if(g < REVERSECMAPSIZE - 1)
FindReverseMap(r, g+1, b);
if(b > 0)
FindReverseMap(r, g, b-1);
if(b < REVERSECMAPSIZE - 1)
FindReverseMap(r, g, b+1);
}
static void FillReverseColorMap(void)
{
int r, g, b;
for(r = 0; r < REVERSECMAPSIZE; r++)
for(g = 0; g < REVERSECMAPSIZE; g++)
for(b = 0; b < REVERSECMAPSIZE; b++)
FindReverseMap(r, g, b);
}
void RestoreColorMap(void)
{
if (ioctl(FrameBufferFD, FBIOPUTCMAP, (void *) &ColorMap) < 0)
sprintf(exiterror, "ioctl(FBIOPUTCMAP) failed!\n");
}
void LoadColorMap(void)
{
ColorMap.start = 0;
ColorMap.red = RedColorMap;
ColorMap.green = GreenColorMap;
ColorMap.blue = BlueColorMap;
ColorMap.transp = NULL;
if(DisplayMode & GLUT_INDEX) {
ColorMap.len = 256;
if (ioctl(FrameBufferFD, FBIOGETCMAP, (void *) &ColorMap) < 0)
sprintf(exiterror, "ioctl(FBIOGETCMAP) failed!\n");
FillReverseColorMap();
} else {
int rcols = 1 << VarInfo.red.length;
int gcols = 1 << VarInfo.green.length;
int bcols = 1 << VarInfo.blue.length;
int i;
ColorMap.len = gcols;
for (i = 0; i < rcols ; i++)
RedColorMap[i] = (65536/(rcols-1)) * i;
for (i = 0; i < gcols ; i++)
GreenColorMap[i] = (65536/(gcols-1)) * i;
for (i = 0; i < bcols ; i++)
BlueColorMap[i] = (65536/(bcols-1)) * i;
RestoreColorMap();
}
}
void glutSetColor(int cell, GLfloat red, GLfloat green, GLfloat blue)
{
if(cell < 0 || cell >= 256)
return;
RedColorMap[cell] = TOCMAP(red);
GreenColorMap[cell] = TOCMAP(green);
BlueColorMap[cell] = TOCMAP(blue);
RestoreColorMap();
FillItemReverseColorMap(TORMAP(red), TORMAP(green), TORMAP(blue));
}
GLfloat glutGetColor(int cell, int component)
{
if(!(DisplayMode & GLUT_INDEX))
return -1.0;
if(cell < 0 || cell > 256)
return -1.0;
switch(component) {
case GLUT_RED:
return FROMCMAP(RedColorMap[cell]);
case GLUT_GREEN:
return FROMCMAP(GreenColorMap[cell]);
case GLUT_BLUE:
return FROMCMAP(BlueColorMap[cell]);
}
return -1.0;
}
void glutCopyColormap(int win)
{
}

View File

@@ -1,264 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
/* these routines are written to access graphics memory directly, not using mesa
to render the cursor, this is faster, it would be good to use a hardware
cursor if it exists instead */
#include <stdlib.h>
#include <inttypes.h>
#include <linux/fb.h>
#include <GL/glut.h>
#include "internal.h"
#include "cursors.h"
int CurrentCursor = GLUT_CURSOR_LEFT_ARROW;
static int LastMouseX, LastMouseY;
static unsigned char *MouseBuffer;
void InitializeCursor(void)
{
if(!MouseBuffer && (MouseBuffer = malloc(CURSOR_WIDTH * CURSOR_HEIGHT
* VarInfo.bits_per_pixel / 8)) == NULL) {
sprintf(exiterror, "malloc failure\n");
exit(0);
}
MouseX = VarInfo.xres / 2;
MouseY = VarInfo.yres / 2;
}
void EraseCursor(void)
{
int off = LastMouseY * FixedInfo.line_length
+ LastMouseX * VarInfo.bits_per_pixel / 8;
int stride = CURSOR_WIDTH * VarInfo.bits_per_pixel / 8;
int i;
unsigned char *src = MouseBuffer;
for(i = 0; i<CURSOR_HEIGHT; i++) {
memcpy(BackBuffer + off, src, stride);
src += stride;
off += FixedInfo.line_length;
}
}
static void SaveCursor(int x, int y)
{
int bypp, off, stride, i;
unsigned char *src = MouseBuffer;
if(x < 0)
LastMouseX = 0;
else
if(x > (int)VarInfo.xres - CURSOR_WIDTH)
LastMouseX = VarInfo.xres - CURSOR_WIDTH;
else
LastMouseX = x;
if(y < 0)
LastMouseY = 0;
else
if(y > (int)VarInfo.yres - CURSOR_HEIGHT)
LastMouseY = VarInfo.yres - CURSOR_HEIGHT;
else
LastMouseY = y;
bypp = VarInfo.bits_per_pixel / 8;
off = LastMouseY * FixedInfo.line_length + LastMouseX * bypp;
stride = CURSOR_WIDTH * bypp;
for(i = 0; i<CURSOR_HEIGHT; i++) {
memcpy(src, BackBuffer + off, stride);
src += stride;
off += FixedInfo.line_length;
}
}
void DrawCursor(void)
{
int i, j, px, py, xoff, xlen, yoff, ylen, bypp, cstride, dstride;
unsigned char *c;
const unsigned char *d;
if(CurrentCursor < 0 || CurrentCursor >= NUM_CURSORS)
return;
px = MouseX - CursorsXOffset[CurrentCursor];
py = MouseY - CursorsYOffset[CurrentCursor];
SaveCursor(px, py);
xoff = 0;
if(px < 0)
xoff = -px;
xlen = CURSOR_WIDTH;
if(px + CURSOR_WIDTH > VarInfo.xres)
xlen = VarInfo.xres - px;
yoff = 0;
if(py < 0)
yoff = -py;
ylen = CURSOR_HEIGHT;
if(py + CURSOR_HEIGHT > VarInfo.yres)
ylen = VarInfo.yres - py;
bypp = VarInfo.bits_per_pixel / 8;
c = BackBuffer + FixedInfo.line_length * (py + yoff) + (px + xoff) * bypp;
cstride = FixedInfo.line_length - bypp * (xlen - xoff);
d = Cursors[CurrentCursor] + (CURSOR_WIDTH * yoff + xoff)*4;
dstride = (CURSOR_WIDTH - xlen + xoff) * 4;
switch(bypp) {
case 1:
{
const int shift = 8 - REVERSECMAPSIZELOG;
for(i = yoff; i < ylen; i++) {
for(j = xoff; j < xlen; j++) {
if(d[3] < 220)
*c = ReverseColorMap
[(d[0]+(((int)(RedColorMap[c[0]]>>8)*d[3])>>8))>>shift]
[(d[1]+(((int)(GreenColorMap[c[0]]>>8)*d[3])>>8))>>shift]
[(d[2]+(((int)(BlueColorMap[c[0]]>>8)*d[3])>>8))>>shift];
c++;
d+=4;
}
d += dstride;
c += cstride;
}
} break;
case 2:
{
uint16_t *e = (void*)c;
cstride /= 2;
for(i = yoff; i < ylen; i++) {
for(j = xoff; j < xlen; j++) {
if(d[3] < 220)
e[0] = ((((d[0] + (((int)(((e[0] >> 8) & 0xf8)
| ((c[0] >> 11) & 0x7)) * d[3]) >> 8)) & 0xf8) << 8)
| (((d[1] + (((int)(((e[0] >> 3) & 0xfc)
| ((e[0] >> 5) & 0x3)) * d[3]) >> 8)) & 0xfc) << 3)
| ((d[2] + (((int)(((e[0] << 3) & 0xf8)
| (e[0] & 0x7)) * d[3]) >> 8)) >> 3));
e++;
d+=4;
}
d += dstride;
e += cstride;
}
} break;
case 3:
case 4:
for(i = yoff; i < ylen; i++) {
for(j = xoff; j < xlen; j++) {
if(d[3] < 220) {
c[0] = d[0] + (((int)c[0] * d[3]) >> 8);
c[1] = d[1] + (((int)c[1] * d[3]) >> 8);
c[2] = d[2] + (((int)c[2] * d[3]) >> 8);
}
c+=bypp;
d+=4;
}
d += dstride;
c += cstride;
} break;
}
}
#define MIN(x, y) x < y ? x : y
void SwapCursor(void)
{
int px = MouseX - CursorsXOffset[CurrentCursor];
int py = MouseY - CursorsYOffset[CurrentCursor];
int minx = MIN(px, LastMouseX);
int sizex = abs(px - LastMouseX);
int miny = MIN(py, LastMouseY);
int sizey = abs(py - LastMouseY);
DrawCursor();
/* now update the portion of the screen that has changed */
if(DisplayMode & GLUT_DOUBLE && (sizex || sizey)) {
int off, stride, i;
if(minx < 0)
minx = 0;
if(miny < 0)
miny = 0;
if(minx + sizex > VarInfo.xres - CURSOR_WIDTH)
sizex = VarInfo.xres - CURSOR_WIDTH - minx;
if(miny + sizey > VarInfo.yres - CURSOR_HEIGHT)
sizey = VarInfo.yres - CURSOR_HEIGHT - miny;
off = FixedInfo.line_length * miny
+ minx * VarInfo.bits_per_pixel / 8;
stride = (sizex + CURSOR_WIDTH) * VarInfo.bits_per_pixel / 8;
for(i = 0; i< sizey + CURSOR_HEIGHT; i++) {
memcpy(FrameBuffer+off, BackBuffer+off, stride);
off += FixedInfo.line_length;
}
}
}
void glutWarpPointer(int x, int y)
{
if(x < 0)
x = 0;
if(x >= VarInfo.xres)
x = VarInfo.xres - 1;
MouseX = x;
if(y < 0)
y = 0;
if(y >= VarInfo.yres)
y = VarInfo.yres - 1;
MouseY = y;
EraseCursor();
SwapCursor();
}
void glutSetCursor(int cursor)
{
if(cursor == GLUT_CURSOR_FULL_CROSSHAIR)
cursor = GLUT_CURSOR_CROSSHAIR;
CurrentCursor = cursor;
MouseEnabled = 1;
EraseCursor();
SwapCursor();
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,152 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <GL/gl.h>
#include <GL/glut.h>
#include "internal.h"
void glutReportErrors(void)
{
GLenum error;
while ((error = glGetError()) != GL_NO_ERROR)
sprintf(exiterror, "GL error: %s", gluErrorString(error));
}
static struct {
const char *name;
const GLUTproc address;
} glut_functions[] = {
{ "glutInit", (const GLUTproc) glutInit },
{ "glutInitDisplayMode", (const GLUTproc) glutInitDisplayMode },
{ "glutInitWindowPosition", (const GLUTproc) glutInitWindowPosition },
{ "glutInitWindowSize", (const GLUTproc) glutInitWindowSize },
{ "glutMainLoop", (const GLUTproc) glutMainLoop },
{ "glutCreateWindow", (const GLUTproc) glutCreateWindow },
{ "glutCreateSubWindow", (const GLUTproc) glutCreateSubWindow },
{ "glutDestroyWindow", (const GLUTproc) glutDestroyWindow },
{ "glutPostRedisplay", (const GLUTproc) glutPostRedisplay },
{ "glutSwapBuffers", (const GLUTproc) glutSwapBuffers },
{ "glutGetWindow", (const GLUTproc) glutGetWindow },
{ "glutSetWindow", (const GLUTproc) glutSetWindow },
{ "glutSetWindowTitle", (const GLUTproc) glutSetWindowTitle },
{ "glutSetIconTitle", (const GLUTproc) glutSetIconTitle },
{ "glutPositionWindow", (const GLUTproc) glutPositionWindow },
{ "glutReshapeWindow", (const GLUTproc) glutReshapeWindow },
{ "glutPopWindow", (const GLUTproc) glutPopWindow },
{ "glutPushWindow", (const GLUTproc) glutPushWindow },
{ "glutIconifyWindow", (const GLUTproc) glutIconifyWindow },
{ "glutShowWindow", (const GLUTproc) glutShowWindow },
{ "glutHideWindow", (const GLUTproc) glutHideWindow },
{ "glutFullScreen", (const GLUTproc) glutFullScreen },
{ "glutSetCursor", (const GLUTproc) glutSetCursor },
{ "glutWarpPointer", (const GLUTproc) glutWarpPointer },
{ "glutEstablishOverlay", (const GLUTproc) glutEstablishOverlay },
{ "glutRemoveOverlay", (const GLUTproc) glutRemoveOverlay },
{ "glutUseLayer", (const GLUTproc) glutUseLayer },
{ "glutPostOverlayRedisplay", (const GLUTproc) glutPostOverlayRedisplay },
{ "glutShowOverlay", (const GLUTproc) glutShowOverlay },
{ "glutHideOverlay", (const GLUTproc) glutHideOverlay },
{ "glutCreateMenu", (const GLUTproc) glutCreateMenu },
{ "glutDestroyMenu", (const GLUTproc) glutDestroyMenu },
{ "glutGetMenu", (const GLUTproc) glutGetMenu },
{ "glutSetMenu", (const GLUTproc) glutSetMenu },
{ "glutAddMenuEntry", (const GLUTproc) glutAddMenuEntry },
{ "glutAddSubMenu", (const GLUTproc) glutAddSubMenu },
{ "glutChangeToMenuEntry", (const GLUTproc) glutChangeToMenuEntry },
{ "glutChangeToSubMenu", (const GLUTproc) glutChangeToSubMenu },
{ "glutRemoveMenuItem", (const GLUTproc) glutRemoveMenuItem },
{ "glutAttachMenu", (const GLUTproc) glutAttachMenu },
{ "glutDetachMenu", (const GLUTproc) glutDetachMenu },
{ "glutDisplayFunc", (const GLUTproc) glutDisplayFunc },
{ "glutReshapeFunc", (const GLUTproc) glutReshapeFunc },
{ "glutKeyboardFunc", (const GLUTproc) glutKeyboardFunc },
{ "glutMouseFunc", (const GLUTproc) glutMouseFunc },
{ "glutMotionFunc", (const GLUTproc) glutMotionFunc },
{ "glutPassiveMotionFunc", (const GLUTproc) glutPassiveMotionFunc },
{ "glutEntryFunc", (const GLUTproc) glutEntryFunc },
{ "glutVisibilityFunc", (const GLUTproc) glutVisibilityFunc },
{ "glutIdleFunc", (const GLUTproc) glutIdleFunc },
{ "glutTimerFunc", (const GLUTproc) glutTimerFunc },
{ "glutMenuStateFunc", (const GLUTproc) glutMenuStateFunc },
{ "glutSpecialFunc", (const GLUTproc) glutSpecialFunc },
{ "glutSpaceballRotateFunc", (const GLUTproc) glutSpaceballRotateFunc },
{ "glutButtonBoxFunc", (const GLUTproc) glutButtonBoxFunc },
{ "glutDialsFunc", (const GLUTproc) glutDialsFunc },
{ "glutTabletMotionFunc", (const GLUTproc) glutTabletMotionFunc },
{ "glutTabletButtonFunc", (const GLUTproc) glutTabletButtonFunc },
{ "glutMenuStatusFunc", (const GLUTproc) glutMenuStatusFunc },
{ "glutOverlayDisplayFunc", (const GLUTproc) glutOverlayDisplayFunc },
{ "glutSetColor", (const GLUTproc) glutSetColor },
{ "glutGetColor", (const GLUTproc) glutGetColor },
{ "glutCopyColormap", (const GLUTproc) glutCopyColormap },
{ "glutGet", (const GLUTproc) glutGet },
{ "glutDeviceGet", (const GLUTproc) glutDeviceGet },
{ "glutExtensionSupported", (const GLUTproc) glutExtensionSupported },
{ "glutGetModifiers", (const GLUTproc) glutGetModifiers },
{ "glutLayerGet", (const GLUTproc) glutLayerGet },
{ "glutGetProcAddress", (const GLUTproc) glutGetProcAddress },
{ "glutBitmapCharacter", (const GLUTproc) glutBitmapCharacter },
{ "glutBitmapWidth", (const GLUTproc) glutBitmapWidth },
{ "glutStrokeCharacter", (const GLUTproc) glutStrokeCharacter },
{ "glutStrokeWidth", (const GLUTproc) glutStrokeWidth },
{ "glutBitmapLength", (const GLUTproc) glutBitmapLength },
{ "glutStrokeLength", (const GLUTproc) glutStrokeLength },
{ "glutWireSphere", (const GLUTproc) glutWireSphere },
{ "glutSolidSphere", (const GLUTproc) glutSolidSphere },
{ "glutWireCone", (const GLUTproc) glutWireCone },
{ "glutSolidCone", (const GLUTproc) glutSolidCone },
{ "glutWireCube", (const GLUTproc) glutWireCube },
{ "glutSolidCube", (const GLUTproc) glutSolidCube },
{ "glutWireTorus", (const GLUTproc) glutWireTorus },
{ "glutSolidTorus", (const GLUTproc) glutSolidTorus },
{ "glutWireDodecahedron", (const GLUTproc) glutWireDodecahedron },
{ "glutSolidDodecahedron", (const GLUTproc) glutSolidDodecahedron },
{ "glutWireTeapot", (const GLUTproc) glutWireTeapot },
{ "glutSolidTeapot", (const GLUTproc) glutSolidTeapot },
{ "glutWireOctahedron", (const GLUTproc) glutWireOctahedron },
{ "glutSolidOctahedron", (const GLUTproc) glutSolidOctahedron },
{ "glutWireTetrahedron", (const GLUTproc) glutWireTetrahedron },
{ "glutSolidTetrahedron", (const GLUTproc) glutSolidTetrahedron },
{ "glutWireIcosahedron", (const GLUTproc) glutWireIcosahedron },
{ "glutSolidIcosahedron", (const GLUTproc) glutSolidIcosahedron },
{ "glutReportErrors", (const GLUTproc) glutReportErrors },
{ NULL, NULL }
};
GLUTproc glutGetProcAddress(const char *procName)
{
/* Try GLUT functions first */
int i;
for (i = 0; glut_functions[i].name; i++) {
if (strcmp(glut_functions[i].name, procName) == 0)
return glut_functions[i].address;
}
/* Try core GL functions */
return (GLUTproc) glFBDevGetProcAddress(procName);
}

View File

@@ -1,863 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*
* To improve on this library, maybe support subwindows or overlays,
* I (sean at depagnier dot com) will do my best to help.
*/
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <sys/kd.h>
#include <linux/fb.h>
#include <linux/vt.h>
#include <GL/gl.h>
#include <GL/glut.h>
#include "internal.h"
#define FBMODES "/etc/fb.modes"
struct fb_fix_screeninfo FixedInfo;
struct fb_var_screeninfo VarInfo;
static struct fb_var_screeninfo OrigVarInfo;
static int DesiredDepth = 0;
int FrameBufferFD = -1;
unsigned char *FrameBuffer;
unsigned char *BackBuffer = NULL;
int DisplayMode;
struct GlutTimer *GlutTimers = NULL;
struct timeval StartTime;
/* per window data */
GLFBDevContextPtr Context;
GLFBDevBufferPtr Buffer;
GLFBDevVisualPtr Visual;
int Redisplay;
int Visible;
int VisibleSwitch;
int Active;
/* we have to poll to see if we are visible
on a framebuffer that is not active */
int VisiblePoll;
int Swapping, VTSwitch;
static int FramebufferIndex;
static int Initialized;
char exiterror[256];
/* test if the active console is attached to the same framebuffer */
void TestVisible(void) {
struct fb_con2fbmap confb;
struct vt_stat st;
int ret;
ioctl(ConsoleFD, VT_GETSTATE, &st);
confb.console = st.v_active;
ret = ioctl(FrameBufferFD, FBIOGET_CON2FBMAP, &confb);
if(ret == -1 || confb.framebuffer == FramebufferIndex) {
VisibleSwitch = 1;
Visible = 0;
VisiblePoll = 0;
}
}
static void Cleanup(void)
{
if(GameMode)
glutLeaveGameMode();
if(ConsoleFD != -1)
RestoreVT();
/* close mouse */
CloseMouse();
if(Visual)
glutDestroyWindow(1);
/* restore original variable screen info */
if(FrameBufferFD != -1) {
OrigVarInfo.xoffset = 0;
OrigVarInfo.yoffset = 0;
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo))
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
munmap(FrameBuffer, FixedInfo.smem_len);
close(FrameBufferFD);
}
/* free allocated back buffer */
if(DisplayMode & GLUT_DOUBLE)
free(BackBuffer);
/* free menu items */
FreeMenus();
if(exiterror[0])
fprintf(stderr, "[glfbdev glut] %s", exiterror);
}
static void CrashHandler(int sig)
{
sprintf(exiterror, "Caught signal %d, cleaning up\n", sig);
exit(0);
}
static void removeArgs(int *argcp, char **argv, int num)
{
int i;
for (i = 0; argv[i+num]; i++)
argv[i] = argv[i+num];
argv[i] = NULL;
*argcp -= num;
}
#define REQPARAM(PARAM) \
if (i >= *argcp - 1) { \
fprintf(stderr, PARAM" requires a parameter\n"); \
exit(0); \
}
void glutInit (int *argcp, char **argv)
{
int i, nomouse = 0, nokeyboard = 0, usestdin = 0;
int RequiredWidth = 0, RequiredHeight;
char *fbdev;
/* parse out args */
for (i = 1; i < *argcp;) {
if (!strcmp(argv[i], "-geometry")) {
REQPARAM("geometry");
if(sscanf(argv[i+1], "%dx%d", &RequiredWidth,
&RequiredHeight) != 2) {
fprintf(stderr,"Please specify geometry as widthxheight\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-bpp")) {
REQPARAM("bpp");
if(sscanf(argv[i+1], "%d", &DesiredDepth) != 1) {
fprintf(stderr, "Please specify a parameter for bpp\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-vt")) {
REQPARAM("vt");
if(sscanf(argv[i+1], "%d", &CurrentVT) != 1) {
fprintf(stderr, "Please specify a parameter for vt\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-mousespeed")) {
REQPARAM("mousespeed");
if(sscanf(argv[i+1], "%lf", &MouseSpeed) != 1) {
fprintf(stderr, "Please specify a mouse speed, eg: 2.5\n");
exit(0);
}
removeArgs(argcp, &argv[i], 2);
} else
if (!strcmp(argv[i], "-nomouse")) {
nomouse = 1;
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "-nokeyboard")) {
nokeyboard = 1;
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "-stdin")) {
usestdin = 1;
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "-gpmmouse")) {
#ifdef HAVE_GPM
GpmMouse = 1;
#else
fprintf(stderr, "gpm support not compiled\n");
exit(0);
#endif
removeArgs(argcp, &argv[i], 1);
} else
if (!strcmp(argv[i], "--")) {
removeArgs(argcp, &argv[i], 1);
break;
} else
i++;
}
gettimeofday(&StartTime, 0);
atexit(Cleanup);
signal(SIGSEGV, CrashHandler);
signal(SIGINT, CrashHandler);
signal(SIGTERM, CrashHandler);
if(nomouse == 0)
InitializeMouse();
if(nokeyboard == 0)
InitializeVT(usestdin);
fbdev = getenv("FRAMEBUFFER");
if(fbdev) {
#ifdef MULTIHEAD
if(!sscanf(fbdev, "/dev/fb%d", &FramebufferIndex))
if(!sscanf(fbdev, "/dev/fb/%d", &FramebufferIndex))
sprintf(exiterror, "Could not determine Framebuffer index!\n");
#endif
} else {
static char fb[128];
struct fb_con2fbmap confb;
int fd = open("/dev/fb0", O_RDWR);
FramebufferIndex = 0;
confb.console = CurrentVT;
if(ioctl(fd, FBIOGET_CON2FBMAP, &confb) != -1)
FramebufferIndex = confb.framebuffer;
sprintf(fb, "/dev/fb%d", FramebufferIndex);
fbdev = fb;
close(fd);
}
/* open the framebuffer device */
FrameBufferFD = open(fbdev, O_RDWR);
if (FrameBufferFD < 0) {
sprintf(exiterror, "Error opening %s: %s\n", fbdev, strerror(errno));
exit(0);
}
/* Get the fixed screen info */
if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}
/* get the variable screen info */
if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &OrigVarInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}
/* operate on a copy */
VarInfo = OrigVarInfo;
/* set the depth, resolution, etc */
if(RequiredWidth)
if(!ParseFBModes(RequiredWidth, RequiredWidth, RequiredHeight,
RequiredHeight, 0, MAX_VSYNC)) {
sprintf(exiterror, "No mode (%dx%d) found in "FBMODES"\n",
RequiredWidth, RequiredHeight);
exit(0);
}
Initialized = 1;
}
void glutInitDisplayMode (unsigned int mode)
{
DisplayMode = mode;
}
static const char *GetStrVal(const char *p, int *set, int min, int max)
{
char *endptr;
int comp = *p, val;
if(p[1] == '=')
p++;
if(*p == '\0')
return p;
val = strtol(p+1, &endptr, 10);
if(endptr == p+1)
return p;
switch(comp) {
case '!':
if(val == min)
val = max;
else
val = min;
break;
case '<':
val = min;
break;
case '>':
val = max;
break;
}
if(val < min || val > max) {
sprintf(exiterror, "display string value out of range\n");
exit(0);
}
*set = val;
return endptr;
}
static void SetAttrib(int val, int attr)
{
if(val)
DisplayMode |= attr;
else
DisplayMode &= ~attr;
}
void glutInitDisplayString(const char *string)
{
const char *p = string;
int val;
while(*p) {
if(*p == ' ')
p++;
else
if(memcmp(p, "acca", 4) == 0) {
p = GetStrVal(p+4, &AccumSize, 1, 32);
SetAttrib(AccumSize, GLUT_ACCUM);
} else
if(memcmp(p, "acc", 3) == 0) {
p = GetStrVal(p+3, &AccumSize, 1, 32);
SetAttrib(AccumSize, GLUT_ACCUM);
} else
if(memcmp(p, "depth", 5) == 0) {
p = GetStrVal(p+5, &DepthSize, 12, 32);
SetAttrib(DepthSize, GLUT_DEPTH);
} else
if(memcmp(p, "double", 6) == 0) {
val = 1;
p = GetStrVal(p+6, &val, 0, 1);
SetAttrib(val, GLUT_DOUBLE);
} else
if(memcmp(p, "index", 5) == 0) {
val = 1;
p = GetStrVal(p+5, &val, 0, 1);
SetAttrib(val, GLUT_INDEX);
} else
if(memcmp(p, "stencil", 7) == 0) {
p = GetStrVal(p+7, &StencilSize, 0, 1);
SetAttrib(StencilSize, GLUT_STENCIL);
} else
if(memcmp(p, "samples", 7) == 0) {
NumSamples = 1;
p = GetStrVal(p+7, &NumSamples, 0, 16);
SetAttrib(NumSamples, GLUT_MULTISAMPLE);
} else
if(p = strchr(p, ' '))
p++;
else
break;
}
}
void glutInitWindowPosition (int x, int y)
{
}
void glutInitWindowSize (int width, int height)
{
}
static void ProcessTimers(void)
{
if(GlutTimers && GlutTimers->time < glutGet(GLUT_ELAPSED_TIME)) {
struct GlutTimer *timer = GlutTimers;
timer->func(timer->value);
GlutTimers = timer->next;
free(timer);
}
}
void glutMainLoop(void)
{
if(ReshapeFunc)
ReshapeFunc(VarInfo.xres, VarInfo.yres);
if(!DisplayFunc) {
sprintf(exiterror, "Fatal Error: No Display Function registered\n");
exit(0);
}
for(;;) {
ProcessTimers();
if(Active)
ReceiveInput();
else
if(VisiblePoll)
TestVisible();
else
usleep(1);
if(IdleFunc)
IdleFunc();
if(VisibleSwitch) {
VisibleSwitch = 0;
if(VisibilityFunc)
VisibilityFunc(Visible ? GLUT_VISIBLE : GLUT_NOT_VISIBLE);
}
if(Visible && Redisplay) {
Redisplay = 0;
if(MouseEnabled)
EraseCursor();
DisplayFunc();
if(!(DisplayMode & GLUT_DOUBLE)) {
if(ActiveMenu)
DrawMenus();
if(MouseEnabled)
DrawCursor();
}
}
}
}
int ParseFBModes(int minw, int maxw, int minh, int maxh, int minf, int maxf)
{
char buf[1024];
struct fb_var_screeninfo vi = VarInfo;
FILE *fbmodes = fopen(FBMODES, "r");
if(!fbmodes) {
sprintf(exiterror, "Warning: could not open "FBMODES"\n");
return 0;
}
while(fgets(buf, sizeof buf, fbmodes)) {
char *c;
int v, bpp, freq;
if(!(c = strstr(buf, "geometry")))
continue;
v = sscanf(c, "geometry %d %d %d %d %d", &vi.xres, &vi.yres,
&vi.xres_virtual, &vi.yres_virtual, &bpp);
if(v != 5)
continue;
if(maxw < minw) {
if(maxw < vi.xres && minw > vi.xres)
continue;
} else
if(maxw < vi.xres || minw > vi.xres)
continue;
if(maxh < minh) {
if(maxh < vi.yres && minh > vi.yres)
continue;
} else
if(maxh < vi.yres || minh > vi.yres)
continue;
fgets(buf, sizeof buf, fbmodes);
if(!(c = strstr(buf, "timings")))
continue;
v = sscanf(c, "timings %d %d %d %d %d %d %d", &vi.pixclock,
&vi.left_margin, &vi.right_margin, &vi.upper_margin,
&vi.lower_margin, &vi.hsync_len, &vi.vsync_len);
if(v != 7)
continue;
freq = 1E12/vi.pixclock
/(vi.left_margin + vi.xres + vi.right_margin + vi.hsync_len)
/(vi.upper_margin + vi.yres + vi.lower_margin + vi.vsync_len);
if(maxf < minf) {
if(maxf < freq && minf > freq)
continue;
} else
if(maxf < freq || minf > freq)
continue;
VarInfo = vi;
fclose(fbmodes);
return 1;
}
fclose(fbmodes);
return 0;
}
/* ---------- Window Management ----------*/
void SetVideoMode(void)
{
/* set new variable screen info */
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo)) {
sprintf(exiterror, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
exit(0);
}
/* reload the screen info to update offsets */
if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &VarInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}
/* reload the fixed info to update color mode */
if (ioctl(FrameBufferFD, FBIOGET_FSCREENINFO, &FixedInfo)) {
sprintf(exiterror, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
strerror(errno));
exit(0);
}
if (DesiredDepth && DesiredDepth != VarInfo.bits_per_pixel) {
sprintf(exiterror, "error: Could not set set %d bpp\n", DesiredDepth);
exit(0);
}
if(DisplayMode & GLUT_INDEX && FixedInfo.visual == FB_VISUAL_DIRECTCOLOR) {
sprintf(exiterror, "error: Could not set 8 bit color mode\n");
exit(0);
}
/* initialize colormap */
LoadColorMap();
}
void CreateBuffer()
{
int size = VarInfo.xres_virtual * VarInfo.yres_virtual
* VarInfo.bits_per_pixel / 8;
/* mmap the framebuffer into our address space */
if(FrameBuffer)
munmap(FrameBuffer, FixedInfo.smem_len);
FrameBuffer = mmap(0, FixedInfo.smem_len, PROT_READ | PROT_WRITE,
MAP_SHARED, FrameBufferFD, 0);
if (FrameBuffer == MAP_FAILED) {
sprintf(exiterror, "error: unable to mmap framebuffer: %s\n",
strerror(errno));
exit(0);
}
if(DisplayMode & GLUT_DOUBLE) {
free(BackBuffer);
if(!(BackBuffer = malloc(size))) {
sprintf(exiterror, "Failed to allocate double buffer\n");
exit(0);
}
} else
BackBuffer = FrameBuffer;
if(Buffer)
glFBDevDestroyBuffer(Buffer);
if(!(Buffer = glFBDevCreateBuffer( &FixedInfo, &VarInfo, Visual,
FrameBuffer, BackBuffer, size))) {
sprintf(exiterror, "Failure to create Buffer\n");
exit(0);
}
}
void CreateVisual(void)
{
int i, mask = DisplayMode;
int attribs[20];
for(i=0; i<sizeof(attribs)/sizeof(*attribs) && mask; i++) {
if(mask & GLUT_DOUBLE) {
attribs[i] = GLFBDEV_DOUBLE_BUFFER;
mask &= ~GLUT_DOUBLE;
continue;
}
if(mask & GLUT_INDEX) {
attribs[i] = GLFBDEV_COLOR_INDEX;
mask &= ~GLUT_INDEX;
continue;
}
if(mask & GLUT_DEPTH) {
attribs[i] = GLFBDEV_DEPTH_SIZE;
attribs[++i] = DepthSize;
mask &= ~GLUT_DEPTH;
continue;
}
if(mask & GLUT_STENCIL) {
attribs[i] = GLFBDEV_STENCIL_SIZE;
attribs[++i] = StencilSize;
mask &= ~GLUT_STENCIL;
continue;
}
if(mask & GLUT_ACCUM) {
attribs[i] = GLFBDEV_ACCUM_SIZE;
attribs[++i] = AccumSize;
mask &= ~GLUT_ACCUM;
continue;
}
if(mask & GLUT_ALPHA)
if(!(DisplayMode & GLUT_INDEX)) {
mask &= ~GLUT_ALPHA;
i--;
continue;
}
if(mask & GLUT_MULTISAMPLE) {
attribs[i] = GLFBDEV_MULTISAMPLE;
attribs[++i] = NumSamples;
mask &= ~GLUT_MULTISAMPLE;
continue;
}
sprintf(exiterror, "Invalid mode from glutInitDisplayMode\n");
exit(0);
}
attribs[i] = GLFBDEV_NONE;
if(!(Visual = glFBDevCreateVisual( &FixedInfo, &VarInfo, attribs ))) {
sprintf(exiterror, "Failure to create Visual\n");
exit(0);
}
}
int glutCreateWindow (const char *title)
{
if(Initialized == 0) {
int argc = 0;
char *argv[] = {NULL};
glutInit(&argc, argv);
}
if(Context)
return 0;
if(DisplayMode & GLUT_INDEX)
VarInfo.bits_per_pixel = 8;
else
if(VarInfo.bits_per_pixel == 8)
VarInfo.bits_per_pixel = 32;
if (DesiredDepth)
VarInfo.bits_per_pixel = DesiredDepth;
VarInfo.xoffset = 0;
VarInfo.yoffset = 0;
VarInfo.nonstd = 0;
VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */
SetVideoMode();
CreateVisual();
CreateBuffer();
if(!(Context = glFBDevCreateContext(Visual, NULL))) {
sprintf(exiterror, "Failure to create Context\n");
exit(0);
}
if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Current\n");
exit(0);
}
InitializeCursor();
InitializeMenus();
glutSetWindowTitle(title);
Visible = 1;
VisibleSwitch = 1;
Redisplay = 1;
return 1;
}
int glutCreateSubWindow(int win, int x, int y, int width, int height)
{
return 0;
}
void glutSetWindow(int win)
{
}
int glutGetWindow(void)
{
return 1;
}
void glutDestroyWindow(int win)
{
glFBDevMakeCurrent( NULL, NULL, NULL);
glFBDevDestroyContext(Context);
glFBDevDestroyBuffer(Buffer);
glFBDevDestroyVisual(Visual);
Visual = NULL;
}
void glutPostRedisplay(void)
{
Redisplay = 1;
}
void glutPostWindowRedisplay(int win)
{
Redisplay = 1;
}
void glutSwapBuffers(void)
{
glFlush();
if(ActiveMenu)
DrawMenus();
if(MouseEnabled)
DrawCursor();
if(DisplayMode & GLUT_DOUBLE && Visible) {
Swapping = 1;
glFBDevSwapBuffers(Buffer);
Swapping = 0;
}
/* if there was a vt switch while swapping, switch now */
if(VTSwitch) {
if(ioctl(ConsoleFD, VT_ACTIVATE, VTSwitch) < 0)
sprintf(exiterror, "Error switching console\n");
VTSwitch = 0;
}
}
void glutPositionWindow(int x, int y)
{
}
void glutReshapeWindow(int width, int height)
{
if(GameMode)
return;
if(!ParseFBModes(width, width, height, height, 0, MAX_VSYNC))
return;
SetVideoMode();
CreateBuffer();
if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Current\n");
exit(0);
}
InitializeMenus();
if(ReshapeFunc)
ReshapeFunc(VarInfo.xres, VarInfo.yres);
Redisplay = 1;
}
void glutFullScreen(void)
{
}
void glutPopWindow(void)
{
}
void glutPushWindow(void)
{
}
void glutShowWindow(void)
{
Visible = 1;
}
void glutHideWindow(void)
{
Visible = 0;
}
static void UnIconifyWindow(int sig)
{
if(ConsoleFD == 0)
InitializeVT(1);
else
if(ConsoleFD > 0)
InitializeVT(0);
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo)) {
sprintf(exiterror, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
exit(0);
}
Redisplay = 1;
VisibleSwitch = 1;
Visible = 1;
}
void glutIconifyWindow(void)
{
RestoreVT();
signal(SIGCONT, UnIconifyWindow);
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &OrigVarInfo))
fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
strerror(errno));
raise(SIGSTOP);
}
void glutSetWindowTitle(const char *name)
{
/* escape code to set title in screen */
if(getenv("TERM") && memcmp(getenv("TERM"), "screen", 6) == 0)
printf("\033k%s\033\\", name);
}
void glutSetIconTitle(const char *name)
{
}

View File

@@ -1,306 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <stdlib.h>
#include <string.h>
#include <linux/fb.h>
#include <GL/glut.h>
#include "internal.h"
int GameMode;
static int ModePossible, DispChanged;
static struct fb_var_screeninfo NormVarInfo, GameVarInfo;
static GLFBDevContextPtr GameContext;
static GLFBDevVisualPtr NormVisual;
/* storage for non-gamemode callbacks */
void (*KeyFuncs[2])(unsigned char key, int x, int y);
static void (*NormFuncs[8])();
static const char*SetOpers(const char *p, unsigned int *min, unsigned int *max)
{
char *endptr;
int comp = *p, val, neq = 0;
if(p[1] == '=') {
neq = 0;
p++;
}
val = strtol(p+1, &endptr, 10);
if(endptr == p+1)
return p;
switch(comp) {
case '=':
*min = *max = val;
break;
case '!':
*min = val + 1;
*max = val - 1;
break;
case '<':
*max = val - neq;
break;
case '>':
*min = val + neq;
break;
}
return endptr;
}
void glutGameModeString(const char *string)
{
const char *p = string;
unsigned int minb = 15, maxb = 32;
unsigned int minw = 0, maxw = -1;
unsigned int minh, maxh = -1;
unsigned int minf = 0, maxf = MAX_VSYNC;
char *endptr;
int count = -1, val;
ModePossible = 0;
if(DisplayMode & GLUT_INDEX)
minb = maxb = 8;
again:
count++;
if((val = strtol(p, &endptr, 10)) && *endptr=='x') {
maxw = minw = val;
p = endptr + 1;
maxh = minh = strtol(p, &endptr, 10);
p = endptr;
goto again;
}
if(*p == ':') {
minb = strtol(p+1, &endptr, 10);
p = endptr;
if(DisplayMode & GLUT_INDEX) {
if(minb != 8)
return;
} else
if(minb != 15 && minb != 16 && minb != 24 && minb != 32)
return;
maxb = minb;
goto again;
}
if(*p == '@') {
minf = strtol(p+1, &endptr, 10) - 5;
maxf = minf + 10;
p = endptr;
goto again;
}
if(count == 0)
while(*p) {
if(*p == ' ')
p++;
else
if(memcmp(p, "bpp", 3) == 0)
p = SetOpers(p+3, &minb, &maxb);
else
if(memcmp(p, "height", 6) == 0)
p = SetOpers(p+6, &minh, &maxh);
else
if(memcmp(p, "hertz", 5) == 0)
p = SetOpers(p+5, &minf, &maxf);
else
if(memcmp(p, "width", 5) == 0)
p = SetOpers(p+5, &minw, &maxw);
else
if(p = strchr(p, ' '))
p++;
else
break;
}
NormVarInfo = VarInfo;
if(!ParseFBModes(minw, maxw, minh, maxh, minf, maxf))
return;
GameVarInfo = VarInfo;
VarInfo = NormVarInfo;
/* determine optimal bitdepth, make sure we have enough video memory */
if(VarInfo.bits_per_pixel && VarInfo.bits_per_pixel <= maxb)
GameVarInfo.bits_per_pixel = VarInfo.bits_per_pixel;
else
GameVarInfo.bits_per_pixel = maxb;
while(FixedInfo.smem_len < GameVarInfo.xres * GameVarInfo.yres
* GameVarInfo.bits_per_pixel / 8) {
if(GameVarInfo.bits_per_pixel < minb)
return;
GameVarInfo.bits_per_pixel = ((GameVarInfo.bits_per_pixel+1)/8)*8-8;
}
ModePossible = 1;
}
int glutEnterGameMode(void)
{
if(ActiveMenu)
return 0;
if(!ModePossible)
return 0;
if(GameMode) {
if(!memcmp(&GameVarInfo, &VarInfo, sizeof VarInfo)) {
DispChanged = 0;
return 1;
}
glutLeaveGameMode();
}
if (ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &GameVarInfo))
return 0;
NormVarInfo = VarInfo;
VarInfo = GameVarInfo;
NormVisual = Visual;
SetVideoMode();
CreateVisual();
CreateBuffer();
if(!(GameContext = glFBDevCreateContext(Visual, NULL))) {
sprintf(exiterror, "Failure to create Context\n");
exit(0);
}
if(!glFBDevMakeCurrent( GameContext, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Game Current\n");
exit(0);
}
InitializeCursor();
KeyFuncs[0] = KeyboardFunc;
KeyFuncs[1] = KeyboardUpFunc;
NormFuncs[0] = DisplayFunc;
NormFuncs[1] = ReshapeFunc;
NormFuncs[2] = MouseFunc;
NormFuncs[3] = MotionFunc;
NormFuncs[4] = PassiveMotionFunc;
NormFuncs[5] = VisibilityFunc;
NormFuncs[6] = SpecialFunc;
NormFuncs[7] = SpecialUpFunc;
DisplayFunc = NULL;
ReshapeFunc = NULL;
KeyboardFunc = NULL;
KeyboardUpFunc = NULL;
MouseFunc = NULL;
MotionFunc = NULL;
PassiveMotionFunc = NULL;
VisibilityFunc = NULL;
SpecialFunc = SpecialUpFunc = NULL;
DispChanged = 1;
GameMode = 1;
Visible = 1;
VisibleSwitch = 1;
Redisplay = 1;
return 1;
}
void glutLeaveGameMode(void)
{
if(!GameMode)
return;
glFBDevDestroyContext(GameContext);
glFBDevDestroyVisual(Visual);
VarInfo = NormVarInfo;
Visual = NormVisual;
if(Visual) {
SetVideoMode();
CreateBuffer();
if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) {
sprintf(exiterror, "Failure to Make Current\n");
exit(0);
}
Redisplay = 1;
}
KeyboardFunc = KeyFuncs[0];
KeyboardUpFunc = KeyFuncs[1];
DisplayFunc = NormFuncs[0];
ReshapeFunc = NormFuncs[1];
MouseFunc = NormFuncs[2];
MotionFunc = NormFuncs[3];
PassiveMotionFunc = NormFuncs[4];
VisibilityFunc = NormFuncs[5];
SpecialFunc = NormFuncs[6];
SpecialUpFunc = NormFuncs[7];
GameMode = 0;
}
int glutGameModeGet(GLenum mode) {
switch(mode) {
case GLUT_GAME_MODE_ACTIVE:
return GameMode;
case GLUT_GAME_MODE_POSSIBLE:
return ModePossible;
case GLUT_GAME_MODE_DISPLAY_CHANGED:
return DispChanged;
}
if(!ModePossible)
return -1;
switch(mode) {
case GLUT_GAME_MODE_WIDTH:
return GameVarInfo.xres;
case GLUT_GAME_MODE_HEIGHT:
return GameVarInfo.yres;
case GLUT_GAME_MODE_PIXEL_DEPTH:
return GameVarInfo.bits_per_pixel;
case GLUT_GAME_MODE_REFRESH_RATE:
return 1E12/GameVarInfo.pixclock
/ (GameVarInfo.left_margin + GameVarInfo.xres
+ GameVarInfo.right_margin + GameVarInfo.hsync_len)
/ (GameVarInfo.upper_margin + GameVarInfo.yres
+ GameVarInfo.lower_margin + GameVarInfo.vsync_len);
}
}

View File

@@ -1,759 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <termios.h>
#include <inttypes.h>
#include <sys/ioctl.h>
#include <sys/poll.h>
#include <sys/kd.h>
#include <linux/keyboard.h>
#include <linux/fb.h>
#include <linux/vt.h>
#include <GL/glut.h>
#include "internal.h"
#define MOUSEDEV "/dev/gpmdata"
#ifdef HAVE_GPM
#include <gpm.h>
int GpmMouse;
#endif
int CurrentVT;
int ConsoleFD = -1;
int KeyboardModifiers;
int MouseX, MouseY;
int NumMouseButtons;
double MouseSpeed = 0;
int KeyRepeatMode = GLUT_KEY_REPEAT_DEFAULT;
/* only display the mouse if there is a registered callback for it */
int MouseEnabled = 0;
static int OldKDMode = -1;
static int OldMode = KD_TEXT;
static struct vt_mode OldVTMode;
static struct termios OldTermios;
static int KeyboardLedState;
static int MouseFD;
static int kbdpipe[2];
#define MODIFIER(mod) \
KeyboardModifiers = release ? KeyboardModifiers & ~mod \
: KeyboardModifiers | mod;
/* signal handler attached to SIGIO on keyboard input, vt
switching and modifiers is handled in the signal handler
other keypresses read from a pipe that leaves the handler
if a program locks up the glut loop, you can still switch
vts and kill it without Alt-SysRq hack */
static void KeyboardHandler(int sig)
{
int release, labelval;
unsigned char code;
struct kbentry entry;
static int lalt; /* only left alt does vt switch */
if(read(ConsoleFD, &code, 1) != 1)
return;
release = code & 0x80;
entry.kb_index = code & 0x7F;
entry.kb_table = 0;
if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
exit(0);
}
labelval = entry.kb_value;
switch(labelval) {
case K_SHIFT:
case K_SHIFTL:
MODIFIER(GLUT_ACTIVE_SHIFT);
return;
case K_CTRL:
MODIFIER(GLUT_ACTIVE_CTRL);
return;
case K_ALT:
lalt = !release;
case K_ALTGR:
MODIFIER(GLUT_ACTIVE_ALT);
return;
}
if(lalt && !release) {
/* VT switch, we must do it */
int vt = -1;
struct vt_stat st;
if(labelval >= K_F1 && labelval <= K_F12)
vt = labelval - K_F1 + 1;
if(labelval == K_LEFT)
if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
vt = st.v_active - 1;
if(labelval == K_RIGHT)
if(ioctl(ConsoleFD, VT_GETSTATE, &st) >= 0)
vt = st.v_active + 1;
if(vt != -1) {
if(Swapping)
VTSwitch = vt;
else
if(ioctl(ConsoleFD, VT_ACTIVATE, vt) < 0)
sprintf(exiterror, "Error switching console\n");
return;
}
}
write(kbdpipe[1], &code, 1);
}
static void LedModifier(int led, int release)
{
static int releaseflag = K_CAPS | K_NUM | K_HOLD;
if(release)
releaseflag |= led;
else
if(releaseflag & led) {
KeyboardLedState ^= led;
releaseflag &= ~led;
}
ioctl(ConsoleFD, KDSKBLED, KeyboardLedState);
ioctl(ConsoleFD, KDSETLED, 0x80);
}
#define READKEY read(kbdpipe[0], &code, 1)
static int ReadKey(void)
{
int release, labelval, labelvalnoshift;
unsigned char code;
int specialkey = 0;
struct kbentry entry;
if(READKEY != 1)
return 0;
if(code == 0)
return 0;
/* stdin input escape code based */
if(ConsoleFD == 0) {
KeyboardModifiers = 0;
altset:
if(code == 27 && READKEY == 1) {
switch(code) {
case 79: /* function key */
READKEY;
if(code == 50) {
READKEY;
shiftfunc:
KeyboardModifiers |= GLUT_ACTIVE_SHIFT;
specialkey = GLUT_KEY_F1 + code - 53;
READKEY;
} else {
READKEY;
specialkey = GLUT_KEY_F1 + code - 80;
}
break;
case 91:
READKEY;
switch(code) {
case 68:
specialkey = GLUT_KEY_LEFT; break;
case 65:
specialkey = GLUT_KEY_UP; break;
case 67:
specialkey = GLUT_KEY_RIGHT; break;
case 66:
specialkey = GLUT_KEY_DOWN; break;
case 53:
specialkey = GLUT_KEY_PAGE_UP; READKEY; break;
case 54:
specialkey = GLUT_KEY_PAGE_DOWN; READKEY; break;
case 49:
specialkey = GLUT_KEY_HOME; READKEY; break;
case 52:
specialkey = GLUT_KEY_END; READKEY; break;
case 50:
READKEY;
if(code != 126)
goto shiftfunc;
specialkey = GLUT_KEY_INSERT;
break;
case 51:
code = '\b';
goto stdkey;
case 91:
READKEY;
specialkey = GLUT_KEY_F1 + code - 65;
break;
default:
return 0;
}
break;
default:
KeyboardModifiers |= GLUT_ACTIVE_ALT;
goto altset;
}
}
stdkey:
if(specialkey) {
if(SpecialFunc)
SpecialFunc(specialkey, MouseX, MouseY);
} else {
if(code >= 1 && code <= 26 && code != '\r') {
KeyboardModifiers |= GLUT_ACTIVE_CTRL;
code += 'a' - 1;
}
if((code >= 43 && code <= 34) || (code == 60)
|| (code >= 62 && code <= 90) || (code == 94)
|| (code == 95) || (code >= 123 && code <= 126))
KeyboardModifiers |= GLUT_ACTIVE_SHIFT;
if(KeyboardFunc)
KeyboardFunc(code, MouseX, MouseY);
}
return 1;
}
/* linux kbd reading */
release = code & 0x80;
code &= 0x7F;
if(KeyRepeatMode == GLUT_KEY_REPEAT_OFF) {
static char keystates[128];
if(release)
keystates[code] = 0;
else {
if(keystates[code])
return 1;
keystates[code] = 1;
}
}
entry.kb_index = code;
entry.kb_table = 0;
if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
exit(0);
}
labelvalnoshift = entry.kb_value;
if(KeyboardModifiers & GLUT_ACTIVE_SHIFT)
entry.kb_table |= K_SHIFTTAB;
if (ioctl(ConsoleFD, KDGKBENT, &entry) < 0) {
sprintf(exiterror, "ioctl(KDGKBENT) failed.\n");
exit(0);
}
labelval = entry.kb_value;
switch(labelvalnoshift) {
case K_CAPS:
LedModifier(LED_CAP, release);
return 0;
case K_NUM:
LedModifier(LED_NUM, release);
return 0;
case K_HOLD: /* scroll lock suspends glut */
LedModifier(LED_SCR, release);
while(KeyboardLedState & LED_SCR) {
usleep(10000);
ReadKey();
}
return 0;
}
/* we could queue keypresses here */
if(KeyboardLedState & LED_SCR)
return 0;
if(labelvalnoshift >= K_F1 && labelvalnoshift <= K_F12)
specialkey = GLUT_KEY_F1 + labelvalnoshift - K_F1;
else
switch(labelvalnoshift) {
case K_LEFT:
specialkey = GLUT_KEY_LEFT; break;
case K_UP:
specialkey = GLUT_KEY_UP; break;
case K_RIGHT:
specialkey = GLUT_KEY_RIGHT; break;
case K_DOWN:
specialkey = GLUT_KEY_DOWN; break;
case K_PGUP:
specialkey = GLUT_KEY_PAGE_UP; break;
case K_PGDN:
specialkey = GLUT_KEY_PAGE_DOWN; break;
case K_FIND:
specialkey = GLUT_KEY_HOME; break;
case K_SELECT:
specialkey = GLUT_KEY_END; break;
case K_INSERT:
specialkey = GLUT_KEY_INSERT; break;
case K_REMOVE:
labelval = '\b';
break;
case K_ENTER:
case K_ENTER - 1: /* keypad enter */
labelval = '\n'; break;
}
/* dispatch callback */
if(specialkey) {
if(release) {
if(SpecialUpFunc)
SpecialUpFunc(specialkey, MouseX, MouseY);
} else
if(SpecialFunc)
SpecialFunc(specialkey, MouseX, MouseY);
} else {
char c = labelval;
if(KeyboardLedState & LED_CAP) {
if(c >= 'A' && c <= 'Z')
c += 'a' - 'A';
else
if(c >= 'a' && c <= 'z')
c += 'A' - 'a';
}
if(release) {
if(KeyboardUpFunc)
KeyboardUpFunc(c, MouseX, MouseY);
} else
if(KeyboardFunc)
KeyboardFunc(c, MouseX, MouseY);
}
return 1;
}
void glutIgnoreKeyRepeat(int ignore)
{
KeyRepeatMode = ignore ? GLUT_KEY_REPEAT_OFF : GLUT_KEY_REPEAT_ON;
}
void glutSetKeyRepeat(int repeatMode)
{
KeyRepeatMode = repeatMode;
}
void glutForceJoystickFunc(void)
{
}
static void HandleMousePress(int button, int pressed)
{
if(TryMenu(button, pressed))
return;
if(MouseFunc)
MouseFunc(button, pressed ? GLUT_DOWN : GLUT_UP, MouseX, MouseY);
}
static int ReadMouse(void)
{
int l, r, m;
static int ll, lm, lr;
signed char dx, dy;
#ifdef HAVE_GPM
if(GpmMouse) {
Gpm_Event event;
struct pollfd pfd;
pfd.fd = gpm_fd;
pfd.events = POLLIN;
if(poll(&pfd, 1, 1) != 1)
return 0;
if(Gpm_GetEvent(&event) != 1)
return 0;
l = event.buttons & GPM_B_LEFT;
m = event.buttons & GPM_B_MIDDLE;
r = event.buttons & GPM_B_RIGHT;
/* gpm is weird in that it gives a button number when the button
is released, with type set to GPM_UP, this is only a problem
if it is the last button released */
if(event.type & GPM_UP)
if(event.buttons == GPM_B_LEFT || event.buttons == GPM_B_MIDDLE ||
event.buttons == GPM_B_RIGHT || event.buttons == GPM_B_FOURTH)
l = m = r = 0;
dx = event.dx;
dy = event.dy;
} else
#endif
{
char data[4];
if(MouseFD == -1)
return 0;
if(fcntl(MouseFD, F_SETFL, O_NONBLOCK) == -1) {
close(MouseFD);
MouseFD = -1;
return 0;
}
if(read(MouseFD, data, 4) != 4)
return 0;
l = ((data[0] & 0x20) >> 3);
m = ((data[3] & 0x10) >> 3);
r = ((data[0] & 0x10) >> 4);
dx = (((data[0] & 0x03) << 6) | (data[1] & 0x3F));
dy = (((data[0] & 0x0C) << 4) | (data[2] & 0x3F));
}
MouseX += dx * MouseSpeed;
if(MouseX < 0)
MouseX = 0;
else
if(MouseX >= VarInfo.xres)
MouseX = VarInfo.xres - 1;
MouseY += dy * MouseSpeed;
if(MouseY < 0)
MouseY = 0;
else
if(MouseY >= VarInfo.yres)
MouseY = VarInfo.yres - 1;
if(l != ll)
HandleMousePress(GLUT_LEFT_BUTTON, l);
if(m != lm)
HandleMousePress(GLUT_MIDDLE_BUTTON, m);
if(r != lr)
HandleMousePress(GLUT_RIGHT_BUTTON, r);
ll = l, lm = m, lr = r;
if(dx || dy) {
if(l || m || r) {
if(MotionFunc)
MotionFunc(MouseX, MouseY);
} else
if(PassiveMotionFunc)
PassiveMotionFunc(MouseX, MouseY);
EraseCursor();
if(ActiveMenu)
Redisplay = 1;
else
SwapCursor();
}
return 1;
}
void ReceiveInput(void)
{
if(ConsoleFD != -1)
while(ReadKey());
if(MouseEnabled)
while(ReadMouse());
}
static void VTSwitchHandler(int sig)
{
struct vt_stat st;
switch(sig) {
case SIGUSR1:
ioctl(ConsoleFD, VT_RELDISP, 1);
Active = 0;
#ifdef MULTIHEAD
VisiblePoll = 1;
TestVisible();
#else
VisibleSwitch = 1;
Visible = 0;
#endif
break;
case SIGUSR2:
ioctl(ConsoleFD, VT_GETSTATE, &st);
if(st.v_active)
ioctl(ConsoleFD, VT_RELDISP, VT_ACKACQ);
/* this is a hack to turn the cursor off */
ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo);
RestoreColorMap();
Active = 1;
Visible = 1;
VisibleSwitch = 1;
Redisplay = 1;
break;
}
}
void InitializeVT(int usestdin)
{
struct termios tio;
struct vt_mode vt;
char console[128];
signal(SIGIO, SIG_IGN);
/* save old terminos settings */
if (tcgetattr(0, &OldTermios) < 0) {
sprintf(exiterror, "tcgetattr failed\n");
exit(0);
}
tio = OldTermios;
/* terminos settings for straight-through mode */
tio.c_lflag &= ~(ICANON | ECHO | ISIG);
tio.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
tio.c_iflag |= IGNBRK;
tio.c_cc[VMIN] = 0;
tio.c_cc[VTIME] = 0;
if (tcsetattr(0, TCSANOW, &tio) < 0) {
sprintf(exiterror, "tcsetattr failed\n");
exit(0);
}
if(fcntl(0, F_SETFL, O_NONBLOCK | O_ASYNC) < 0) {
sprintf(exiterror, "Failed to set keyboard to non-blocking\n");
exit(0);
}
Active = 1;
if(usestdin) {
ConsoleFD = 0;
return;
}
/* detect the current vt if it was not specified */
if(CurrentVT == 0) {
int fd = open("/dev/tty", O_RDWR | O_NDELAY, 0);
struct vt_stat st;
if(fd == -1) {
sprintf(exiterror, "Failed to open /dev/tty\n");
exit(0);
}
if(ioctl(fd, VT_GETSTATE, &st) == -1) {
fprintf(stderr, "Could not detect current vt, specify with -vt\n");
fprintf(stderr, "Defaulting to stdin input\n");
ConsoleFD = 0;
close(fd);
return;
} else
CurrentVT = st.v_active;
close(fd);
}
/* open the console tty */
sprintf(console, "/dev/tty%d", CurrentVT);
ConsoleFD = open(console, O_RDWR | O_NDELAY, 0);
if (ConsoleFD < 0) {
sprintf(exiterror, "error couldn't open %s,"
" defaulting to stdin \n", console);
ConsoleFD = 0;
return;
}
signal(SIGUSR1, VTSwitchHandler);
signal(SIGUSR2, VTSwitchHandler);
if (ioctl(ConsoleFD, VT_GETMODE, &OldVTMode) < 0) {
sprintf(exiterror,"Failed to grab %s, defaulting to stdin\n", console);
close(ConsoleFD);
ConsoleFD = 0;
return;
}
vt = OldVTMode;
vt.mode = VT_PROCESS;
vt.waitv = 0;
vt.relsig = SIGUSR1;
vt.acqsig = SIGUSR2;
if (ioctl(ConsoleFD, VT_SETMODE, &vt) < 0) {
sprintf(exiterror, "error: ioctl(VT_SETMODE) failed: %s\n",
strerror(errno));
close(ConsoleFD);
ConsoleFD = 0;
exit(1);
}
if (ioctl(ConsoleFD, KDGKBMODE, &OldKDMode) < 0) {
sprintf(exiterror, "Warning: ioctl KDGKBMODE failed!\n");
OldKDMode = K_XLATE;
}
/* use SIGIO so VT switching can work if the program is locked */
signal(SIGIO, KeyboardHandler);
pipe(kbdpipe);
if(fcntl(kbdpipe[0], F_SETFL, O_NONBLOCK | O_ASYNC) < 0) {
sprintf(exiterror, "Failed to set keyboard to non-blocking\n");
exit(0);
}
fcntl(0, F_SETOWN, getpid());
if(ioctl(ConsoleFD, KDGETMODE, &OldMode) < 0)
sprintf(exiterror, "Warning: Failed to get terminal mode\n");
#ifdef HAVE_GPM
if(!GpmMouse)
#endif
if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0)
sprintf(exiterror,"Warning: Failed to set terminal to graphics\n");
if (ioctl(ConsoleFD, KDSKBMODE, K_MEDIUMRAW) < 0) {
sprintf(exiterror, "ioctl KDSKBMODE failed!\n");
tcsetattr(0, TCSANOW, &OldTermios);
exit(0);
}
if( ioctl(ConsoleFD, KDGKBLED, &KeyboardLedState) < 0) {
sprintf(exiterror, "ioctl KDGKBLED failed!\n");
exit(0);
}
}
void RestoreVT(void)
{
if(ConsoleFD < 0)
return;
if (tcsetattr(0, TCSANOW, &OldTermios) < 0)
fprintf(stderr, "tcsetattr failed\n");
/* setting the mode to text from graphics restores the colormap*/
if(
#ifdef HAVE_GPM
GpmMouse ||
#endif
ConsoleFD == 0)
if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) {
sprintf(exiterror,"Warning: Failed to set terminal to graphics\n");
goto skipioctl; /* no need to fail twice */
}
if(ioctl(ConsoleFD, KDSETMODE, OldMode) < 0)
fprintf(stderr, "ioctl KDSETMODE failed!\n");
skipioctl:
if(ConsoleFD == 0)
return;
/* restore keyboard state */
if (ioctl(ConsoleFD, VT_SETMODE, &OldVTMode) < 0)
fprintf(stderr, "Failed to set vtmode\n");
if (ioctl(ConsoleFD, KDSKBMODE, OldKDMode) < 0)
fprintf(stderr, "ioctl KDSKBMODE failed!\n");
close(ConsoleFD);
}
void InitializeMouse(void)
{
#ifdef HAVE_GPM
if(!GpmMouse)
#endif
{
const char *mousedev = getenv("MOUSE");
if(!mousedev)
mousedev = MOUSEDEV;
if((MouseFD = open(mousedev, O_RDONLY)) >= 0) {
if(!MouseSpeed)
MouseSpeed = 1;
NumMouseButtons = 3;
return;
}
}
#ifdef HAVE_GPM
{
Gpm_Connect conn;
int c;
conn.eventMask = ~0; /* Want to know about all the events */
conn.defaultMask = 0; /* don't handle anything by default */
conn.minMod = 0; /* want everything */
conn.maxMod = ~0; /* all modifiers included */
if(Gpm_Open(&conn, 0) != -1) {
if(!MouseSpeed)
MouseSpeed = 8;
NumMouseButtons = 3;
return;
}
fprintf(stderr, "Cannot open gpmctl.\n");
}
#endif
fprintf(stderr,"Cannot open %s.\n"
"Continuing without Mouse\n", MOUSEDEV);
}
void CloseMouse(void)
{
#ifdef HAVE_GPM
if(GpmMouse) {
if(NumMouseButtons)
Gpm_Close();
} else
#endif
if(MouseFD >= 0)
close(MouseFD);
}

View File

@@ -1,175 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <sys/time.h>
#include <linux/fb.h>
#include <GL/glfbdev.h>
#define MULTIHEAD /* enable multihead hacks,
it allows the program to continue drawing
without reading input when a second fbdev
has keyboard focus it can cause
screen corruption that requires C-l to fix */
#define HAVE_GPM
#define MAX_VSYNC 200
/* this causes these symbols to not be exported */
#pragma GCC visibility push(hidden)
/* --------- fbdev ------------ */
extern int Redisplay;
extern int Visible;
extern int VisibleSwitch;
extern int Active;
extern int VisiblePoll;
extern int Swapping, VTSwitch;
void TestVisible(void);
int ParseFBModes(int, int, int, int, int, int);
void CreateVisual(void);
extern int FrameBufferFD;
extern unsigned char *FrameBuffer;
extern unsigned char *BackBuffer;
extern int DisplayMode;
extern char exiterror[256];
extern struct fb_fix_screeninfo FixedInfo;
extern struct fb_var_screeninfo VarInfo;
extern GLFBDevContextPtr Context;
extern GLFBDevBufferPtr Buffer;
extern GLFBDevVisualPtr Visual;
/* --- colormap --- */
#define REVERSECMAPSIZELOG 3
#define REVERSECMAPSIZE (1<<REVERSECMAPSIZELOG)
extern unsigned short RedColorMap[256],
GreenColorMap[256],
BlueColorMap[256];
extern unsigned char ReverseColorMap[REVERSECMAPSIZE]
[REVERSECMAPSIZE]
[REVERSECMAPSIZE];
void LoadOldColorMap(void);
void LoadColorMap(void);
void UnloadColorMap(void);
void RestoreColorMap(void);
/* --- mouse --- */
extern int MouseX, MouseY;
extern int CurrentCursor;
extern int MouseEnabled;
extern int NumMouseButtons;
void InitializeCursor(void);
void EraseCursor(void);
void DrawCursor(void);
void SwapCursor(void);
/* --- menus --- */
struct GlutMenu {
int NumItems;
int x, y;
int width;
int selected;
struct {
int value;
int submenu;
char *name;
} *Items;
void (*func)(int);
};
extern struct GlutMenu *Menus;
extern int ActiveMenu;
extern int CurrentMenu;
void InitializeMenus(void);
void FreeMenus(void);
void DrawMenus(void);
int TryMenu(int, int);
void OpenMenu(void);
void CloseMenu(void);
/* --- state --- */
extern int AccumSize, DepthSize, StencilSize, NumSamples;
extern struct timeval StartTime;
extern int KeyboardModifiers;
/* --- input --- */
#ifdef HAVE_GPM
extern int GpmMouse;
#endif
extern int CurrentVT;
extern int ConsoleFD;
extern double MouseSpeed;
extern int KeyRepeatMode;
void InitializeVT(int);
void RestoreVT(void);
void CloseMouse(void);
void InitializeMouse(void);
void ReceiveInput(void);
/* --- callback --- */
extern void (*DisplayFunc)(void);
extern void (*ReshapeFunc)(int width, int height);
extern void (*KeyboardFunc)(unsigned char key, int x, int y);
extern void (*KeyboardUpFunc)(unsigned char key, int x, int y);
extern void (*MouseFunc)(int key, int state, int x, int y);
extern void (*MotionFunc)(int x, int y);
extern void (*PassiveMotionFunc)(int x, int y);
extern void (*VisibilityFunc)(int state);
extern void (*SpecialFunc)(int key, int x, int y);
extern void (*SpecialUpFunc)(int key, int x, int y);
extern void (*IdleFunc)(void);
extern void (*MenuStatusFunc)(int state, int x, int y);
extern void (*MenuStateFunc)(int state);
/* --- timers --- */
struct GlutTimer {
int time;
void (*func)(int);
int value;
struct GlutTimer *next;
};
extern struct GlutTimer *GlutTimers;
/* ------- Game Mode -------- */
extern int GameMode;
#pragma GCC visibility pop

View File

@@ -1,307 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <stdlib.h>
#include <linux/fb.h>
#include <GL/glut.h>
#include "internal.h"
#define MENU_FONT_WIDTH 9
#define MENU_FONT_HEIGHT 15
#define MENU_FONT GLUT_BITMAP_9_BY_15
#define SUBMENU_OFFSET 20
struct GlutMenu *Menus;
int ActiveMenu;
int CurrentMenu;
static double MenuProjection[16];
static int AttachedMenus[3];
static int NumMenus = 1;
static int SelectedMenu;
void InitializeMenus(void)
{
glPushAttrib(GL_TRANSFORM_BIT);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0.0, VarInfo.xres, VarInfo.yres, 0.0);
glGetDoublev(GL_PROJECTION_MATRIX, MenuProjection);
glPopMatrix();
glPopAttrib();
}
void FreeMenus(void)
{
int i, j;
for(i = 1; i<NumMenus; i++) {
for(j = 0; j<Menus[i].NumItems; j++)
free(Menus[i].Items[j].name);
free(Menus[i].Items);
}
free(Menus);
}
int TryMenu(int button, int pressed)
{
if(ActiveMenu && !pressed) {
ActiveMenu = 0;
CloseMenu();
Redisplay = 1;
return 1;
}
if(AttachedMenus[button] && pressed) {
ActiveMenu = AttachedMenus[button];
OpenMenu();
Redisplay = 1;
return 1;
}
return 0;
}
static int DrawMenu(int menu, int x, int *y)
{
int i;
int ret = 1;
for(i=0; i < Menus[menu].NumItems; i++) {
char *s = Menus[menu].Items[i].name;
int a = 0;
if(MouseY >= *y && MouseY < *y + MENU_FONT_HEIGHT &&
MouseX >= x && MouseX < x + Menus[menu].width) {
a = 1;
SelectedMenu = menu;
ret = 0;
Menus[menu].selected = i;
glColor3f(1,0,0);
} else
glColor3f(1,1,1);
*y += MENU_FONT_HEIGHT;
glRasterPos2i(x, *y);
for(; *s; s++)
glutBitmapCharacter(MENU_FONT, *s);
if(Menus[menu].selected == i)
if(Menus[menu].Items[i].submenu)
if(DrawMenu(Menus[menu].Items[i].submenu, x
+ SUBMENU_OFFSET, y)) {
if(!a)
Menus[menu].selected = -1;
} else
ret = 0;
}
return ret;
}
void DrawMenus(void)
{
int x, y;
if(GameMode)
return;
x = Menus[ActiveMenu].x;
y = Menus[ActiveMenu].y;
/* save old settings */
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT
| GL_ENABLE_BIT | GL_VIEWPORT_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadMatrixd(MenuProjection);
glViewport(0, 0, VarInfo.xres, VarInfo.yres);
glDisable(GL_DEPTH_TEST);
glDisable(GL_ALPHA_TEST);
glDisable(GL_LIGHTING);
glDisable(GL_FOG);
glDisable(GL_TEXTURE_2D);
glEnable(GL_COLOR_LOGIC_OP);
glLogicOp(GL_AND_REVERSE);
if(DrawMenu(ActiveMenu, x, &y))
Menus[ActiveMenu].selected = -1;
/* restore settings */
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
}
void OpenMenu(void)
{
if(MenuStatusFunc)
MenuStatusFunc(GLUT_MENU_IN_USE, MouseX, MouseY);
if(MenuStateFunc)
MenuStateFunc(GLUT_MENU_IN_USE);
Menus[ActiveMenu].x = MouseX-Menus[ActiveMenu].width/2;
if(Menus[ActiveMenu].x < 0)
Menus[ActiveMenu].x = 0;
if(Menus[ActiveMenu].x + Menus[ActiveMenu].width >= VarInfo.xres)
Menus[ActiveMenu].x = VarInfo.xres - Menus[ActiveMenu].width - 1;
Menus[ActiveMenu].y = MouseY-Menus[ActiveMenu].NumItems*MENU_FONT_HEIGHT/2;
Menus[ActiveMenu].selected = -1;
}
void CloseMenu(void)
{
if(MenuStatusFunc)
MenuStatusFunc(GLUT_MENU_NOT_IN_USE, MouseX, MouseY);
if(MenuStateFunc)
MenuStateFunc(GLUT_MENU_NOT_IN_USE);
if(SelectedMenu > 0) {
int selected = Menus[SelectedMenu].selected;
if(selected >= 0)
if(Menus[SelectedMenu].Items[selected].submenu == 0)
Menus[SelectedMenu].func(Menus[SelectedMenu].Items
[selected].value);
}
}
/* glut menu functions */
int glutCreateMenu(void (*func)(int value))
{
MouseEnabled = 1;
CurrentMenu = NumMenus;
NumMenus++;
Menus = realloc(Menus, sizeof(*Menus) * NumMenus);
Menus[CurrentMenu].NumItems = 0;
Menus[CurrentMenu].Items = NULL;
Menus[CurrentMenu].func = func;
Menus[CurrentMenu].width = 0;
return CurrentMenu;
}
void glutSetMenu(int menu)
{
CurrentMenu = menu;
}
int glutGetMenu(void)
{
return CurrentMenu;
}
void glutDestroyMenu(int menu)
{
if(menu == CurrentMenu)
CurrentMenu = 0;
}
static void NameMenuEntry(int entry, const char *name)
{
int cm = CurrentMenu;
if(!(Menus[cm].Items[entry-1].name = realloc(Menus[cm].Items[entry-1].name,
strlen(name) + 1))) {
sprintf(exiterror, "realloc failed in NameMenuEntry\n");
exit(0);
}
strcpy(Menus[cm].Items[entry-1].name, name);
if(strlen(name) * MENU_FONT_WIDTH > Menus[cm].width)
Menus[cm].width = strlen(name) * MENU_FONT_WIDTH;
}
static int AddMenuItem(const char *name)
{
int cm = CurrentMenu;
int item = Menus[cm].NumItems++;
if(!(Menus[cm].Items = realloc(Menus[cm].Items,
Menus[cm].NumItems * sizeof(*Menus[0].Items)))) {
sprintf(exiterror, "realloc failed in AddMenuItem\n");
exit(0);
}
Menus[cm].Items[item].name = NULL;
NameMenuEntry(item+1, name);
return item;
}
void glutAddMenuEntry(const char *name, int value)
{
int item = AddMenuItem(name);
Menus[CurrentMenu].Items[item].value = value;
Menus[CurrentMenu].Items[item].submenu = 0;
}
void glutAddSubMenu(const char *name, int menu)
{
int item = AddMenuItem(name);
if(menu == CurrentMenu) {
sprintf(exiterror, "Recursive menus not supported\n");
exit(0);
}
Menus[CurrentMenu].Items[item].submenu = menu;
}
void glutChangeToMenuEntry(int entry, const char *name, int value)
{
NameMenuEntry(entry, name);
Menus[CurrentMenu].Items[entry-1].value = value;
Menus[CurrentMenu].Items[entry-1].submenu = 0;
}
void glutChangeToSubMenu(int entry, const char *name, int menu)
{
NameMenuEntry(entry, name);
Menus[CurrentMenu].Items[entry-1].submenu = menu;
}
void glutRemoveMenuItem(int entry)
{
memmove(Menus[CurrentMenu].Items + entry - 1,
Menus[CurrentMenu].Items + entry,
sizeof(*Menus[0].Items) * (Menus[CurrentMenu].NumItems - entry));
Menus[CurrentMenu].NumItems--;
}
void glutAttachMenu(int button)
{
AttachedMenus[button] = CurrentMenu;
}
void glutDetachMenu(int button)
{
AttachedMenus[button] = 0;
}

View File

@@ -1,56 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <GL/gl.h>
void glutEstablishOverlay(void)
{
exit(0);
}
void glutUseLayer(GLenum layer)
{
}
void glutRemoveOverlay(void)
{
}
void glutPostOverlayRedisplay(void)
{
}
void glutPostWindowOverlayRedisplay(int win)
{
}
void glutShowOverlay(void)
{
}
void glutHideOverlay(void)
{
}

View File

@@ -1,196 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
#include <sys/time.h>
#include <linux/fb.h>
#include <GL/glut.h>
#include "../../mesa/main/config.h"
#include "internal.h"
int AccumSize = 16; /* per channel size of accumulation buffer */
int DepthSize = DEFAULT_SOFTWARE_DEPTH_BITS;
int StencilSize = STENCIL_BITS;
int NumSamples = 4;
int glutGet(GLenum state)
{
switch(state) {
case GLUT_WINDOW_X:
return 0;
case GLUT_WINDOW_Y:
return 0;
case GLUT_INIT_WINDOW_WIDTH:
case GLUT_WINDOW_WIDTH:
case GLUT_SCREEN_WIDTH:
return VarInfo.xres;
case GLUT_INIT_WINDOW_HEIGHT:
case GLUT_WINDOW_HEIGHT:
case GLUT_SCREEN_HEIGHT:
return VarInfo.yres;
case GLUT_WINDOW_BUFFER_SIZE:
return VarInfo.bits_per_pixel;
case GLUT_WINDOW_STENCIL_SIZE:
return StencilSize;
case GLUT_WINDOW_DEPTH_SIZE:
return DepthSize;
case GLUT_WINDOW_RED_SIZE:
return VarInfo.red.length;
case GLUT_WINDOW_GREEN_SIZE:
return VarInfo.green.length;
case GLUT_WINDOW_BLUE_SIZE:
return VarInfo.green.length;
case GLUT_WINDOW_ALPHA_SIZE:
return VarInfo.transp.length;
case GLUT_WINDOW_ACCUM_RED_SIZE:
case GLUT_WINDOW_ACCUM_GREEN_SIZE:
case GLUT_WINDOW_ACCUM_BLUE_SIZE:
case GLUT_WINDOW_ACCUM_ALPHA_SIZE:
return AccumSize;
case GLUT_WINDOW_DOUBLEBUFFER:
if(DisplayMode & GLUT_DOUBLE)
return 1;
return 0;
case GLUT_WINDOW_RGBA:
if(DisplayMode & GLUT_INDEX)
return 0;
return 1;
case GLUT_WINDOW_PARENT:
return 0;
case GLUT_WINDOW_NUM_CHILDREN:
return 0;
case GLUT_WINDOW_COLORMAP_SIZE:
if(DisplayMode & GLUT_INDEX)
return 256;
return 0;
case GLUT_WINDOW_NUM_SAMPLES:
return NumSamples;
case GLUT_WINDOW_STEREO:
return 0;
case GLUT_WINDOW_CURSOR:
return CurrentCursor;
case GLUT_SCREEN_WIDTH_MM:
return VarInfo.width;
case GLUT_SCREEN_HEIGHT_MM:
return VarInfo.height;
case GLUT_MENU_NUM_ITEMS:
if(CurrentMenu)
return Menus[CurrentMenu].NumItems;
return 0;
case GLUT_DISPLAY_MODE_POSSIBLE:
if((DisplayMode & GLUT_MULTISAMPLE)
|| (DisplayMode & GLUT_STEREO)
|| (DisplayMode & GLUT_LUMINANCE)
|| (DisplayMode & GLUT_ALPHA) && (DisplayMode & GLUT_INDEX))
return 0;
return 1;
case GLUT_INIT_DISPLAY_MODE:
return DisplayMode;
case GLUT_INIT_WINDOW_X:
case GLUT_INIT_WINDOW_Y:
return 0;
case GLUT_ELAPSED_TIME:
{
static struct timeval tv;
gettimeofday(&tv, 0);
return 1000 * (tv.tv_sec - StartTime.tv_sec)
+ (tv.tv_usec - StartTime.tv_usec) / 1000;
}
}
return -1;
}
int glutLayerGet(GLenum info)
{
switch(info) {
case GLUT_OVERLAY_POSSIBLE:
return 0;
case GLUT_LAYER_IN_USE:
return GLUT_NORMAL;
case GLUT_HAS_OVERLAY:
return 0;
case GLUT_TRANSPARENT_INDEX:
return -1;
case GLUT_NORMAL_DAMAGED:
return Redisplay;
case GLUT_OVERLAY_DAMAGED:
return -1;
}
return -1;
}
int glutDeviceGet(GLenum info)
{
switch(info) {
case GLUT_HAS_KEYBOARD:
return ConsoleFD != -1 ? 1 : 0;
case GLUT_HAS_MOUSE:
case GLUT_NUM_MOUSE_BUTTONS:
return NumMouseButtons;
case GLUT_HAS_SPACEBALL:
case GLUT_HAS_DIAL_AND_BUTTON_BOX:
case GLUT_HAS_TABLET:
return 0;
case GLUT_NUM_SPACEBALL_BUTTONS:
case GLUT_NUM_BUTTON_BOX_BUTTONS:
case GLUT_NUM_DIALS:
case GLUT_NUM_TABLET_BUTTONS:
return 0;
case GLUT_DEVICE_IGNORE_KEY_REPEAT:
return KeyRepeatMode == GLUT_KEY_REPEAT_OFF;
case GLUT_DEVICE_KEY_REPEAT:
return KeyRepeatMode;
case GLUT_JOYSTICK_POLL_RATE:
case GLUT_HAS_JOYSTICK:
case GLUT_JOYSTICK_BUTTONS:
case GLUT_JOYSTICK_AXES:
return 0;
}
return -1;
}
int glutGetModifiers(void){
return KeyboardModifiers;
}
int glutExtensionSupported(const char *extension)
{
const char *exts = (const char *) glGetString(GL_EXTENSIONS);
const char *start = exts;
int len = strlen(extension);
for(;;) {
const char *p = strstr(exts, extension);
if(!p)
break;
if((p == start || p[-1] == ' ') && (p[len] == ' ' || p[len] == 0))
return 1;
exts = p + len;
}
return 0;
}

View File

@@ -1,81 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*
* To improve on this library, maybe support subwindows or overlays,
* I (sean at depagnier dot com) will do my best to help.
*/
#include <GL/glut.h>
#include "glutstroke.h"
void glutStrokeCharacter(GLUTstrokeFont font, int c)
{
const StrokeCharRec *ch;
const StrokeRec *stroke;
const CoordRec *coord;
StrokeFontPtr fontinfo = (StrokeFontPtr) font;
int i, j;
if (c < 0 || c >= fontinfo->num_chars)
return;
ch = &(fontinfo->ch[c]);
if (ch) {
for (i = ch->num_strokes, stroke = ch->stroke;
i > 0; i--, stroke++) {
glBegin(GL_LINE_STRIP);
for (j = stroke->num_coords, coord = stroke->coord;
j > 0; j--, coord++) {
glVertex2f(coord->x, coord->y);
}
glEnd();
}
glTranslatef(ch->right, 0.0, 0.0);
}
}
int glutStrokeWidth(GLUTstrokeFont font, int c)
{
StrokeFontPtr fontinfo;
const StrokeCharRec *ch;
fontinfo = (StrokeFontPtr) font;
if (c < 0 || c >= fontinfo->num_chars)
return 0;
ch = &(fontinfo->ch[c]);
if (ch)
return ch->right;
return 0;
}
int glutStrokeLength(GLUTstrokeFont font, const unsigned char *string)
{
int length = 0;
for (; *string; string++)
length += glutStrokeWidth(font, *string);
return length;
}

View File

@@ -1,55 +0,0 @@
/*
* Mesa 3-D graphics library
* Version: 6.5
* Copyright (C) 1995-2006 Brian Paul
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Library for glut using mesa fbdev driver
*
* Written by Sean D'Epagnier (c) 2006
*/
/* Notice, if you know how to implement these functions correctly
please proceed */
#include <stdlib.h>
#include <GL/glut.h>
#include "internal.h"
int glutVideoResizeGet(GLenum param)
{
return 0;
}
void glutSetupVideoResizing(void)
{
}
void glutStopVideoResizing(void)
{
}
void glutVideoResize(int x, int y, int width, int height)
{
}
void glutVideoPan(int x, int y, int width, int height)
{
}

View File

@@ -143,6 +143,7 @@ teapot(GLint grid, GLdouble scale, GLenum type)
float p[4][4][3], q[4][4][3], r[4][4][3], s[4][4][3];
long i, j, k, l;
#if 0
glPushAttrib(GL_ENABLE_BIT | GL_EVAL_BIT);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
@@ -194,6 +195,7 @@ teapot(GLint grid, GLdouble scale, GLenum type)
}
glPopMatrix();
glPopAttrib();
#endif
}
/* CENTRY */

View File

@@ -47,7 +47,7 @@ INCLUDES = -I. \
-I$(TOP)/src/mesa/main \
-I$(TOP)/src/mesa/glapi \
-I$(TOP)/src/mesa/drivers/dri/common \
$(LIBDRM_CFLAGS) \
`pkg-config --cflags libdrm` \
$(X11_INCLUDES)

View File

@@ -37,8 +37,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* THIS IS NOT AN X CONSORTIUM STANDARD */
#ifdef GLX_DIRECT_RENDERING
#define NEED_REPLIES
#include <X11/Xlibint.h>
#include <X11/extensions/Xext.h>
@@ -619,5 +617,3 @@ PUBLIC Bool XF86DRICloseFullScreen(dpy, screen, drawable)
(void) drawable;
return True;
}
#endif /* GLX_DIRECT_RENDERING */

View File

@@ -183,7 +183,6 @@ static const char createNewScreenName[] = "__driCreateNewScreen_20050727";
*/
static __DRIdriver *OpenDriver(const char *driverName)
{
void *glhandle = NULL;
char *libPaths = NULL;
char libDir[1000];
int i;
@@ -197,9 +196,6 @@ static __DRIdriver *OpenDriver(const char *driverName)
}
}
/* Attempt to make sure libGL symbols will be visible to the driver */
glhandle = dlopen("libGL.so.1", RTLD_NOW | RTLD_GLOBAL);
if (geteuid() == getuid()) {
/* don't allow setuid apps to use LIBGL_DRIVERS_PATH */
libPaths = getenv("LIBGL_DRIVERS_PATH");
@@ -233,13 +229,12 @@ static __DRIdriver *OpenDriver(const char *driverName)
/* allocate __DRIdriver struct */
driver = (__DRIdriver *) Xmalloc(sizeof(__DRIdriver));
if (!driver)
break; /* out of memory! */
return NULL; /* out of memory! */
/* init the struct */
driver->name = __glXstrdup(driverName);
if (!driver->name) {
Xfree(driver);
driver = NULL;
break; /* out of memory! */
return NULL; /* out of memory! */
}
driver->createNewScreenFunc = (PFNCREATENEWSCREENFUNC)
@@ -253,7 +248,6 @@ static __DRIdriver *OpenDriver(const char *driverName)
"Your driver may be too old for this libGL.\n",
createNewScreenName, driverName);
Xfree(driver);
driver = NULL;
dlclose(handle);
continue;
}
@@ -261,20 +255,15 @@ static __DRIdriver *OpenDriver(const char *driverName)
/* put at head of linked list */
driver->next = Drivers;
Drivers = driver;
break;
return driver;
}
else {
ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
}
}
if (!driver)
ErrorMessageF("unable to load driver: %s_dri.so\n", driverName);
if (glhandle)
dlclose(glhandle);
return driver;
ErrorMessageF("unable to find driver: %s_dri.so\n", driverName);
return NULL;
}

View File

@@ -687,7 +687,4 @@ extern int __glXGetInternalVersion(void);
/* Get the unadjusted system time */
extern int __glXGetUST( int64_t * ust );
extern Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * numerator, int32_t * denominator);
#endif /* !__GLX_client_h__ */

View File

@@ -1650,10 +1650,18 @@ PUBLIC XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
}
/*
** GLX_SGI_make_current_read
*/
PUBLIC GLX_ALIAS(GLXDrawable, glXGetCurrentReadDrawableSGI, (void), (),
glXGetCurrentReadDrawable)
/*
** GLX_SGI_swap_control
*/
static int __glXSwapIntervalSGI(int interval)
PUBLIC int glXSwapIntervalSGI(int interval)
{
xGLXVendorPrivateReq *req;
GLXContext gc = __glXGetCurrentContext();
@@ -1700,7 +1708,7 @@ static int __glXSwapIntervalSGI(int interval)
req->vendorCode = X_GLXvop_SwapIntervalSGI;
req->contextTag = gc->currentContextTag;
interval_ptr = (CARD32 *) (req + 1);
interval_ptr = (CARD32 *) req + 1;
*interval_ptr = interval;
UnlockDisplay(dpy);
@@ -1714,7 +1722,7 @@ static int __glXSwapIntervalSGI(int interval)
/*
** GLX_MESA_swap_control
*/
static int __glXSwapIntervalMESA(unsigned int interval)
PUBLIC int glXSwapIntervalMESA(unsigned int interval)
{
#ifdef GLX_DIRECT_RENDERING
GLXContext gc = __glXGetCurrentContext();
@@ -1747,7 +1755,7 @@ static int __glXSwapIntervalMESA(unsigned int interval)
}
static int __glXGetSwapIntervalMESA(void)
PUBLIC int glXGetSwapIntervalMESA(void)
{
#ifdef GLX_DIRECT_RENDERING
GLXContext gc = __glXGetCurrentContext();
@@ -1777,7 +1785,7 @@ static int __glXGetSwapIntervalMESA(void)
** GLX_MESA_swap_frame_usage
*/
static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
PUBLIC GLint glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
{
int status = GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -1797,7 +1805,7 @@ static GLint __glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
}
static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
PUBLIC GLint glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
{
int status = GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -1817,8 +1825,8 @@ static GLint __glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
}
static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable,
GLfloat *usage)
PUBLIC GLint glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable,
GLfloat *usage)
{
int status = GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -1844,9 +1852,9 @@ static GLint __glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable,
}
static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable,
int64_t *sbc, int64_t *missedFrames,
GLfloat *lastMissedUsage)
PUBLIC GLint glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable,
int64_t *sbc, int64_t *missedFrames,
GLfloat *lastMissedUsage)
{
int status = GLX_BAD_CONTEXT;
#ifdef GLX_DIRECT_RENDERING
@@ -1876,7 +1884,7 @@ static GLint __glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable,
/*
** GLX_SGI_video_sync
*/
static int __glXGetVideoSyncSGI(unsigned int *count)
PUBLIC int glXGetVideoSyncSGI(unsigned int *count)
{
/* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry,
* FIXME: there should be a GLX encoding for this call. I can find no
@@ -1905,7 +1913,7 @@ static int __glXGetVideoSyncSGI(unsigned int *count)
return GLX_BAD_CONTEXT;
}
static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
PUBLIC int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
{
#ifdef GLX_DIRECT_RENDERING
GLXContext gc = __glXGetCurrentContext();
@@ -1942,6 +1950,33 @@ static int __glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count
}
/*
** GLX_SGIS_video_source
*/
#if defined(_VL_H)
PUBLIC GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX(Display *dpy,
int screen, VLServer server, VLPath path,
int nodeClass, VLNode drainNode)
{
(void) dpy;
(void) screen;
(void) server;
(void) path;
(void) nodeClass;
(void) drainNode;
return 0;
}
PUBLIC void glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
{
(void) dpy;
(void) src;
}
#endif
/*
** GLX_SGIX_fbconfig
** Many of these functions are aliased to GLX 1.3 entry points in the
@@ -2046,11 +2081,100 @@ PUBLIC GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy,
}
/*
** GLX_SGI_cushion
*/
PUBLIC void glXCushionSGI(Display *dpy, Window win, float cushion)
{
(void) dpy;
(void) win;
(void) cushion;
}
/*
** GLX_SGIX_video_resize
*/
PUBLIC int glXBindChannelToWindowSGIX(Display *dpy, int screen,
int channel , Window window)
{
(void) dpy;
(void) screen;
(void) channel;
(void) window;
return 0;
}
PUBLIC int glXChannelRectSGIX(Display *dpy, int screen, int channel,
int x, int y, int w, int h)
{
(void) dpy;
(void) screen;
(void) channel;
(void) x;
(void) y;
(void) w;
(void) h;
return 0;
}
PUBLIC int glXQueryChannelRectSGIX(Display *dpy, int screen, int channel,
int *x, int *y, int *w, int *h)
{
(void) dpy;
(void) screen;
(void) channel;
(void) x;
(void) y;
(void) w;
(void) h;
return 0;
}
int glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel,
int *dx, int *dy, int *dw, int *dh)
{
(void) dpy;
(void) screen;
(void) channel;
(void) dx;
(void) dy;
(void) dw;
(void) dh;
return 0;
}
PUBLIC int glXChannelRectSyncSGIX(Display *dpy, int screen,
int channel, GLenum synctype)
{
(void) dpy;
(void) screen;
(void) channel;
(void) synctype;
return 0;
}
#if defined(_DM_BUFFER_H_)
PUBLIC Bool glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer,
DMparams *params, DMbuffer dmbuffer)
{
(void) dpy;
(void) pbuffer;
(void) params;
(void) dmbuffer;
return False;
}
#endif
/*
** GLX_SGIX_swap_group
*/
static void __glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable,
GLXDrawable member)
PUBLIC void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable,
GLXDrawable member)
{
(void) dpy;
(void) drawable;
@@ -2061,15 +2185,15 @@ static void __glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable,
/*
** GLX_SGIX_swap_barrier
*/
static void __glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable,
int barrier)
PUBLIC void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable,
int barrier)
{
(void) dpy;
(void) drawable;
(void) barrier;
}
static Bool __glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
PUBLIC Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
{
(void) dpy;
(void) screen;
@@ -2078,11 +2202,25 @@ static Bool __glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
}
/*
** GLX_SUN_get_transparent_index
*/
PUBLIC Status glXGetTransparentIndexSUN(Display *dpy, Window overlay,
Window underlay, long *pTransparent)
{
(void) dpy;
(void) overlay;
(void) underlay;
(void) pTransparent;
return 0;
}
/*
** GLX_OML_sync_control
*/
static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
int64_t *ust, int64_t *msc, int64_t *sbc)
PUBLIC Bool glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
int64_t *ust, int64_t *msc, int64_t *sbc)
{
#ifdef GLX_DIRECT_RENDERING
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
@@ -2126,8 +2264,8 @@ static Bool __glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
* when GLX_OML_sync_control appears in the client extension string.
*/
Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * numerator, int32_t * denominator)
PUBLIC Bool glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
int32_t * numerator, int32_t * denominator)
{
#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )
__GLXdisplayPrivate * const priv = __glXInitialize(dpy);
@@ -2200,9 +2338,9 @@ Bool __glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
}
static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor,
int64_t remainder)
PUBLIC int64_t glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor,
int64_t remainder)
{
#ifdef GLX_DIRECT_RENDERING
int screen;
@@ -2235,10 +2373,10 @@ static int64_t __glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
}
static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t *ust,
int64_t *msc, int64_t *sbc)
PUBLIC Bool glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
int64_t target_msc, int64_t divisor,
int64_t remainder, int64_t *ust,
int64_t *msc, int64_t *sbc)
{
#ifdef GLX_DIRECT_RENDERING
int screen;
@@ -2278,9 +2416,9 @@ static Bool __glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
}
static Bool __glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc )
PUBLIC Bool glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
int64_t target_sbc, int64_t *ust,
int64_t *msc, int64_t *sbc )
{
#ifdef GLX_DIRECT_RENDERING
int screen;
@@ -2414,7 +2552,7 @@ PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
* glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow
* glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX
*/
static Bool __glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
PUBLIC Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
{
(void) dpy;
(void) d;
@@ -2431,15 +2569,10 @@ PUBLIC GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
(void) cmap;
return 0;
}
/*@}*/
/**
* GLX_MESA_copy_sub_buffer
*/
#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */
static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height)
PUBLIC void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
int x, int y, int width, int height)
{
xGLXVendorPrivateReq *req;
GLXContext gc;
@@ -2501,15 +2634,17 @@ static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
SyncHandle();
}
PUBLIC Bool glXSet3DfxModeMESA( int mode )
{
(void) mode;
return GL_FALSE;
}
/*@}*/
/**
* GLX_EXT_texture_from_pixmap
*/
/*@{*/
static void __glXBindTexImageEXT(Display *dpy,
GLXDrawable drawable,
int buffer,
const int *attrib_list)
PUBLIC void glXBindTexImageEXT(Display *dpy,
GLXDrawable drawable,
int buffer,
const int *attrib_list)
{
xGLXVendorPrivateReq *req;
GLXContext gc = __glXGetCurrentContext();
@@ -2568,9 +2703,9 @@ static void __glXBindTexImageEXT(Display *dpy,
SyncHandle();
}
static void __glXReleaseTexImageEXT(Display *dpy,
GLXDrawable drawable,
int buffer)
PUBLIC void glXReleaseTexImageEXT(Display *dpy,
GLXDrawable drawable,
int buffer)
{
xGLXVendorPrivateReq *req;
GLXContext gc = __glXGetCurrentContext();
@@ -2606,7 +2741,6 @@ static void __glXReleaseTexImageEXT(Display *dpy,
UnlockDisplay(dpy);
SyncHandle();
}
/*@}*/
/**
* \c strdup is actually not a standard ANSI C or POSIX routine.
@@ -2685,16 +2819,22 @@ static const struct name_address_pair GLX_functions[] = {
GLX_FUNCTION( glXSelectEvent ),
/*** GLX_SGI_swap_control ***/
GLX_FUNCTION2( glXSwapIntervalSGI, __glXSwapIntervalSGI ),
GLX_FUNCTION( glXSwapIntervalSGI ),
/*** GLX_SGI_video_sync ***/
GLX_FUNCTION2( glXGetVideoSyncSGI, __glXGetVideoSyncSGI ),
GLX_FUNCTION2( glXWaitVideoSyncSGI, __glXWaitVideoSyncSGI ),
GLX_FUNCTION( glXGetVideoSyncSGI ),
GLX_FUNCTION( glXWaitVideoSyncSGI ),
/*** GLX_SGI_make_current_read ***/
GLX_FUNCTION2( glXMakeCurrentReadSGI, glXMakeContextCurrent ),
GLX_FUNCTION2( glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable ),
/*** GLX_SGIX_video_source ***/
#if defined(_VL_H)
GLX_FUNCTION( glXCreateGLXVideoSourceSGIX ),
GLX_FUNCTION( glXDestroyGLXVideoSourceSGIX ),
#endif
/*** GLX_EXT_import_context ***/
GLX_FUNCTION( glXFreeContextEXT ),
GLX_FUNCTION( glXGetContextIDEXT ),
@@ -2717,12 +2857,30 @@ static const struct name_address_pair GLX_functions[] = {
GLX_FUNCTION( glXSelectEventSGIX ),
GLX_FUNCTION( glXGetSelectedEventSGIX ),
/*** GLX_SGI_cushion ***/
GLX_FUNCTION( glXCushionSGI ),
/*** GLX_SGIX_video_resize ***/
GLX_FUNCTION( glXBindChannelToWindowSGIX ),
GLX_FUNCTION( glXChannelRectSGIX ),
GLX_FUNCTION( glXQueryChannelRectSGIX ),
GLX_FUNCTION( glXQueryChannelDeltasSGIX ),
GLX_FUNCTION( glXChannelRectSyncSGIX ),
/*** GLX_SGIX_dmbuffer **/
#if defined(_DM_BUFFER_H_)
GLX_FUNCTION( glXAssociateDMPbufferSGIX ),
#endif
/*** GLX_SGIX_swap_group ***/
GLX_FUNCTION2( glXJoinSwapGroupSGIX, __glXJoinSwapGroupSGIX ),
GLX_FUNCTION( glXJoinSwapGroupSGIX ),
/*** GLX_SGIX_swap_barrier ***/
GLX_FUNCTION2( glXBindSwapBarrierSGIX, __glXBindSwapBarrierSGIX ),
GLX_FUNCTION2( glXQueryMaxSwapBarriersSGIX, __glXQueryMaxSwapBarriersSGIX ),
GLX_FUNCTION( glXBindSwapBarrierSGIX ),
GLX_FUNCTION( glXQueryMaxSwapBarriersSGIX ),
/*** GLX_SUN_get_transparent_index ***/
GLX_FUNCTION( glXGetTransparentIndexSUN ),
/*** GLX_MESA_allocate_memory ***/
GLX_FUNCTION( glXAllocateMemoryMESA ),
@@ -2730,23 +2888,26 @@ static const struct name_address_pair GLX_functions[] = {
GLX_FUNCTION( glXGetMemoryOffsetMESA ),
/*** GLX_MESA_copy_sub_buffer ***/
GLX_FUNCTION2( glXCopySubBufferMESA, __glXCopySubBufferMESA ),
GLX_FUNCTION( glXCopySubBufferMESA ),
/*** GLX_MESA_pixmap_colormap ***/
GLX_FUNCTION( glXCreateGLXPixmapMESA ),
/*** GLX_MESA_release_buffers ***/
GLX_FUNCTION2( glXReleaseBuffersMESA, __glXReleaseBuffersMESA ),
GLX_FUNCTION( glXReleaseBuffersMESA ),
/*** GLX_MESA_set_3dfx_mode ***/
GLX_FUNCTION( glXSet3DfxModeMESA ),
/*** GLX_MESA_swap_control ***/
GLX_FUNCTION2( glXSwapIntervalMESA, __glXSwapIntervalMESA ),
GLX_FUNCTION2( glXGetSwapIntervalMESA, __glXGetSwapIntervalMESA ),
GLX_FUNCTION( glXSwapIntervalMESA ),
GLX_FUNCTION( glXGetSwapIntervalMESA ),
/*** GLX_MESA_swap_frame_usage ***/
GLX_FUNCTION2( glXBeginFrameTrackingMESA, __glXBeginFrameTrackingMESA ),
GLX_FUNCTION2( glXEndFrameTrackingMESA, __glXEndFrameTrackingMESA ),
GLX_FUNCTION2( glXGetFrameUsageMESA, __glXGetFrameUsageMESA ),
GLX_FUNCTION2( glXQueryFrameTrackingMESA, __glXQueryFrameTrackingMESA ),
GLX_FUNCTION( glXBeginFrameTrackingMESA ),
GLX_FUNCTION( glXEndFrameTrackingMESA ),
GLX_FUNCTION( glXGetFrameUsageMESA ),
GLX_FUNCTION( glXQueryFrameTrackingMESA ),
/*** GLX_ARB_get_proc_address ***/
GLX_FUNCTION( glXGetProcAddressARB ),
@@ -2755,15 +2916,15 @@ static const struct name_address_pair GLX_functions[] = {
GLX_FUNCTION2( glXGetProcAddress, glXGetProcAddressARB ),
/*** GLX_OML_sync_control ***/
GLX_FUNCTION2( glXWaitForSbcOML, __glXWaitForSbcOML ),
GLX_FUNCTION2( glXWaitForMscOML, __glXWaitForMscOML ),
GLX_FUNCTION2( glXSwapBuffersMscOML, __glXSwapBuffersMscOML ),
GLX_FUNCTION2( glXGetMscRateOML, __glXGetMscRateOML ),
GLX_FUNCTION2( glXGetSyncValuesOML, __glXGetSyncValuesOML ),
GLX_FUNCTION( glXWaitForSbcOML ),
GLX_FUNCTION( glXWaitForMscOML ),
GLX_FUNCTION( glXSwapBuffersMscOML ),
GLX_FUNCTION( glXGetMscRateOML ),
GLX_FUNCTION( glXGetSyncValuesOML ),
/*** GLX_EXT_texture_from_pixmap ***/
GLX_FUNCTION2( glXBindTexImageEXT, __glXBindTexImageEXT ),
GLX_FUNCTION2( glXReleaseTexImageEXT, __glXReleaseTexImageEXT ),
GLX_FUNCTION( glXBindTexImageEXT ),
GLX_FUNCTION( glXReleaseTexImageEXT ),
#ifdef GLX_DIRECT_RENDERING
/*** DRI configuration ***/

View File

@@ -719,9 +719,71 @@ static const __DRIinterfaceMethods interface_methods = {
XF86DRIGetDrawableInfo,
__glXGetUST,
__glXGetMscRateOML,
glXGetMscRateOML,
};
#define DRM_MAX_FDS 16
static struct {
char *BusID;
int fd;
int refcount;
} connection[DRM_MAX_FDS];
static int nr_fds = 0;
int drmOpenOnce(void *unused,
const char *BusID,
int *newlyopened)
{
int i;
int fd;
for (i = 0; i < nr_fds; i++)
if (strcmp(BusID, connection[i].BusID) == 0) {
connection[i].refcount++;
*newlyopened = 0;
return connection[i].fd;
}
fd = drmOpen(unused, BusID);
if (fd <= 0 || nr_fds == DRM_MAX_FDS)
return fd;
connection[nr_fds].BusID = strdup(BusID);
connection[nr_fds].fd = fd;
connection[nr_fds].refcount = 1;
*newlyopened = 1;
fprintf(stderr, "saved connection %d for %s %d\n",
nr_fds, connection[nr_fds].BusID,
strcmp(BusID, connection[nr_fds].BusID));
nr_fds++;
return fd;
}
void drmCloseOnce(int fd)
{
int i;
for (i = 0; i < nr_fds; i++) {
if (fd == connection[i].fd) {
if (--connection[i].refcount == 0) {
drmClose(connection[i].fd);
free(connection[i].BusID);
if (i < --nr_fds)
connection[i] = connection[nr_fds];
return;
}
}
}
}
/**
* Perform the required libGL-side initialization and call the client-side
@@ -773,7 +835,8 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
framebuffer.dev_priv = NULL;
if (XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
fd = drmOpen(NULL,BusID);
int newlyopened;
fd = drmOpenOnce(NULL,BusID, &newlyopened);
Xfree(BusID); /* No longer needed */
err_msg = "open DRM";
@@ -800,7 +863,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
}
err_msg = "XF86DRIAuthConnection";
if (XF86DRIAuthConnection(dpy, scrn, magic)) {
if (!newlyopened || XF86DRIAuthConnection(dpy, scrn, magic)) {
char *driverName;
/*
@@ -904,7 +967,7 @@ CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
}
if ( fd >= 0 ) {
(void)drmClose(fd);
(void)drmCloseOnce(fd);
}
(void)XF86DRICloseConnection(dpy, scrn);

View File

@@ -82,6 +82,7 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(MESA_copy_sub_buffer), VER(0,0), Y, N, N, N },
{ GLX(MESA_pixmap_colormap), VER(0,0), N, N, N, N }, /* Deprecated */
{ GLX(MESA_release_buffers), VER(0,0), N, N, N, N }, /* Deprecated */
{ GLX(MESA_set_3dfx_mode), VER(0,0), N, N, N, N }, /* Deprecated */
{ GLX(MESA_swap_control), VER(0,0), Y, N, N, Y },
{ GLX(MESA_swap_frame_usage), VER(0,0), Y, N, N, Y },
{ GLX(NV_float_buffer), VER(0,0), N, N, N, N },
@@ -90,17 +91,22 @@ static const struct extension_info known_glx_extensions[] = {
{ GLX(NV_vertex_array_range), VER(0,0), N, N, N, Y }, /* Deprecated */
{ GLX(OML_swap_method), VER(0,0), Y, Y, N, N },
{ GLX(OML_sync_control), VER(0,0), Y, N, N, Y },
{ GLX(SGI_cushion), VER(0,0), N, N, N, N },
{ GLX(SGI_make_current_read), VER(1,3), Y, N, N, N },
{ GLX(SGI_swap_control), VER(0,0), Y, N, N, N },
{ GLX(SGI_video_sync), VER(0,0), Y, N, N, Y },
{ GLX(SGIS_blended_overlay), VER(0,0), N, N, N, N },
{ GLX(SGIS_color_range), VER(0,0), N, N, N, N },
{ GLX(SGIS_multisample), VER(0,0), Y, Y, N, N },
{ GLX(SGIX_dm_buffer), VER(0,0), N, N, N, N },
{ GLX(SGIX_fbconfig), VER(1,3), Y, Y, N, N },
{ GLX(SGIX_pbuffer), VER(1,3), Y, N, N, N },
{ GLX(SGIX_swap_barrier), VER(0,0), N, N, N, N },
{ GLX(SGIX_swap_group), VER(0,0), N, N, N, N },
{ GLX(SGIX_video_resize), VER(0,0), N, N, N, N },
{ GLX(SGIX_video_source), VER(0,0), N, N, N, N },
{ GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N },
{ GLX(SUN_get_transparent_index), VER(0,0), N, N, N, N },
{ GLX(EXT_texture_from_pixmap), VER(0,0), Y, N, N, N },
{ NULL }
};
@@ -135,7 +141,7 @@ static const struct extension_info known_gl_extensions[] = {
{ GL(EXT_abgr), VER(0,0), Y, N, N, N },
{ GL(EXT_bgra), VER(1,2), Y, N, N, N },
{ GL(EXT_blend_color), VER(1,4), Y, N, N, N },
{ GL(EXT_blend_equation_separate), VER(0,0), Y, N, N, N },
{ GL(EXT_blend_equation_separate), VER(0,0), N, N, N, N },
{ GL(EXT_blend_func_separate), VER(1,4), Y, N, N, N },
{ GL(EXT_blend_logic_op), VER(1,4), Y, N, N, N },
{ GL(EXT_blend_minmax), VER(1,4), Y, N, N, N },
@@ -220,7 +226,6 @@ static const struct extension_info known_gl_extensions[] = {
{ GL(OES_read_format), VER(0,0), Y, N, N, N },
{ GL(OES_compressed_paletted_texture),VER(0,0), Y, N, N, N },
{ GL(SGI_color_matrix), VER(0,0), Y, N, N, N },
{ GL(SGI_color_table), VER(0,0), Y, N, N, N },
{ GL(SGI_texture_color_table), VER(0,0), Y, N, N, N },
{ GL(SGIS_generate_mipmap), VER(1,4), Y, N, N, N },
{ GL(SGIS_multisample), VER(0,0), Y, N, N, N },

View File

@@ -45,6 +45,7 @@ enum {
MESA_depth_float_bit,
MESA_pixmap_colormap_bit,
MESA_release_buffers_bit,
MESA_set_3dfx_mode_bit,
MESA_swap_control_bit,
MESA_swap_frame_usage_bit,
NV_float_buffer_bit,
@@ -53,17 +54,22 @@ enum {
NV_vertex_array_range_bit,
OML_swap_method_bit,
OML_sync_control_bit,
SGI_cushion_bit,
SGI_make_current_read_bit,
SGI_swap_control_bit,
SGI_video_sync_bit,
SGIS_blended_overlay_bit,
SGIS_color_range_bit,
SGIS_multisample_bit,
SGIX_dm_buffer_bit,
SGIX_fbconfig_bit,
SGIX_pbuffer_bit,
SGIX_swap_barrier_bit,
SGIX_swap_group_bit,
SGIX_video_resize_bit,
SGIX_video_source_bit,
SGIX_visual_select_group_bit,
SUN_get_transparent_index_bit,
EXT_texture_from_pixmap_bit
};
@@ -174,7 +180,6 @@ enum {
GL_OES_compressed_paletted_texture_bit,
GL_OES_read_format_bit,
GL_SGI_color_matrix_bit,
GL_SGI_color_table_bit,
GL_SGI_texture_color_table_bit,
GL_SGIS_generate_mipmap_bit,
GL_SGIS_multisample_bit,

File diff suppressed because it is too large Load Diff

View File

@@ -477,38 +477,96 @@ extern HIDDEN void __indirect_glMultiTexCoord4iARB(GLenum target, GLint s, GLint
extern HIDDEN void __indirect_glMultiTexCoord4ivARB(GLenum target, const GLint * v);
extern HIDDEN void __indirect_glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
extern HIDDEN void __indirect_glMultiTexCoord4svARB(GLenum target, const GLshort * v);
extern HIDDEN void __indirect_glLoadTransposeMatrixdARB(const GLdouble * m);
extern HIDDEN void __indirect_glLoadTransposeMatrixfARB(const GLfloat * m);
extern HIDDEN void __indirect_glMultTransposeMatrixdARB(const GLdouble * m);
extern HIDDEN void __indirect_glLoadTransposeMatrixdARB(const GLdouble * m);
extern HIDDEN void __indirect_glMultTransposeMatrixfARB(const GLfloat * m);
extern HIDDEN void __indirect_glMultTransposeMatrixdARB(const GLdouble * m);
extern HIDDEN void __indirect_glSampleCoverageARB(GLclampf value, GLboolean invert);
extern HIDDEN void __indirect_glCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs);
extern HIDDEN GLboolean __indirect_glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences);
extern HIDDEN void __indirect_glGenTexturesEXT(GLsizei n, GLuint * textures);
extern HIDDEN GLboolean __indirect_glIsTextureEXT(GLuint texture);
extern HIDDEN void __indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert);
extern HIDDEN void __indirect_glSamplePatternSGIS(GLenum pattern);
extern HIDDEN void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean * pointer);
extern HIDDEN void __indirect_glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glPointParameterfEXT(GLenum pname, GLfloat param);
extern HIDDEN void __indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params);
extern HIDDEN void __indirect_glWindowPos2dMESA(GLdouble x, GLdouble y);
extern HIDDEN void __indirect_glWindowPos2dvMESA(const GLdouble * v);
extern HIDDEN void __indirect_glWindowPos2fMESA(GLfloat x, GLfloat y);
extern HIDDEN void __indirect_glWindowPos2fvMESA(const GLfloat * v);
extern HIDDEN void __indirect_glWindowPos2iMESA(GLint x, GLint y);
extern HIDDEN void __indirect_glWindowPos2ivMESA(const GLint * v);
extern HIDDEN void __indirect_glWindowPos2sMESA(GLshort x, GLshort y);
extern HIDDEN void __indirect_glWindowPos2svMESA(const GLshort * v);
extern HIDDEN void __indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z);
extern HIDDEN void __indirect_glWindowPos3dvMESA(const GLdouble * v);
extern HIDDEN void __indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z);
extern HIDDEN void __indirect_glWindowPos3fvMESA(const GLfloat * v);
extern HIDDEN void __indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z);
extern HIDDEN void __indirect_glWindowPos3ivMESA(const GLint * v);
extern HIDDEN void __indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z);
extern HIDDEN void __indirect_glWindowPos3svMESA(const GLshort * v);
extern HIDDEN void __indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
extern HIDDEN void __indirect_glFogCoordfEXT(GLfloat coord);
extern HIDDEN void __indirect_glFogCoordfvEXT(const GLfloat * coord);
extern HIDDEN void __indirect_glFogCoorddEXT(GLdouble coord);
extern HIDDEN void __indirect_glFogCoorddvEXT(const GLdouble * coord);
extern HIDDEN void __indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid * pointer);
extern HIDDEN void __indirect_glCompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data);
extern HIDDEN void __indirect_glGetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img);
extern HIDDEN void __indirect_glDisableVertexAttribArrayARB(GLuint index);
extern HIDDEN void __indirect_glEnableVertexAttribArrayARB(GLuint index);
extern HIDDEN void __indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index, GLdouble * params);
extern HIDDEN void __indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index, GLdouble * params);
extern HIDDEN void __indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string);
extern HIDDEN void __indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue);
extern HIDDEN void __indirect_glSecondaryColor3bvEXT(const GLbyte * v);
extern HIDDEN void __indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue);
extern HIDDEN void __indirect_glSecondaryColor3dvEXT(const GLdouble * v);
extern HIDDEN void __indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue);
extern HIDDEN void __indirect_glSecondaryColor3fvEXT(const GLfloat * v);
extern HIDDEN void __indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue);
extern HIDDEN void __indirect_glSecondaryColor3ivEXT(const GLint * v);
extern HIDDEN void __indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue);
extern HIDDEN void __indirect_glSecondaryColor3svEXT(const GLshort * v);
extern HIDDEN void __indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue);
extern HIDDEN void __indirect_glSecondaryColor3ubvEXT(const GLubyte * v);
extern HIDDEN void __indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue);
extern HIDDEN void __indirect_glSecondaryColor3uivEXT(const GLuint * v);
extern HIDDEN void __indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue);
extern HIDDEN void __indirect_glSecondaryColor3usvEXT(const GLushort * v);
extern HIDDEN void __indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
extern HIDDEN GLboolean __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, GLboolean * residences);
extern HIDDEN void __indirect_glBindProgramNV(GLenum target, GLuint program);
extern HIDDEN void __indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs);
extern HIDDEN void __indirect_glExecuteProgramNV(GLenum target, GLuint id, const GLfloat * params);
extern HIDDEN void __indirect_glGenProgramsNV(GLsizei n, GLuint * programs);
extern HIDDEN void __indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble * params);
extern HIDDEN void __indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte * program);
extern HIDDEN void __indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble * params);
extern HIDDEN void __indirect_glGetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat * params);
extern HIDDEN void __indirect_glGetVertexAttribivARB(GLuint index, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble * params);
extern HIDDEN void __indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat * params);
extern HIDDEN void __indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble * params);
extern HIDDEN void __indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat * params);
extern HIDDEN void __indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid * string);
extern HIDDEN void __indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid ** params);
extern HIDDEN GLboolean __indirect_glIsProgramNV(GLuint program);
extern HIDDEN void __indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte * program);
extern HIDDEN void __indirect_glProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramParameter4dvNV(GLenum target, GLuint index, const GLdouble * params);
extern HIDDEN void __indirect_glProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat * params);
extern HIDDEN void __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params);
extern HIDDEN void __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params);
extern HIDDEN void __indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids);
extern HIDDEN void __indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform);
extern HIDDEN void __indirect_glVertexAttribPointerNV(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
extern HIDDEN void __indirect_glVertexAttrib1dARB(GLuint index, GLdouble x);
extern HIDDEN void __indirect_glVertexAttrib1dvARB(GLuint index, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttrib1fARB(GLuint index, GLfloat x);
@@ -527,115 +585,77 @@ extern HIDDEN void __indirect_glVertexAttrib3fARB(GLuint index, GLfloat x, GLflo
extern HIDDEN void __indirect_glVertexAttrib3fvARB(GLuint index, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z);
extern HIDDEN void __indirect_glVertexAttrib3svARB(GLuint index, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte * v);
extern HIDDEN void __indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v);
extern HIDDEN void __indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
extern HIDDEN void __indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte * v);
extern HIDDEN void __indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v);
extern HIDDEN void __indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v);
extern HIDDEN void __indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v);
extern HIDDEN void __indirect_glVertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glVertexAttrib4dvARB(GLuint index, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glVertexAttrib4fvARB(GLuint index, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v);
extern HIDDEN void __indirect_glVertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
extern HIDDEN void __indirect_glVertexAttrib4svARB(GLuint index, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte * v);
extern HIDDEN void __indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v);
extern HIDDEN void __indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v);
extern HIDDEN void __indirect_glVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer);
extern HIDDEN void __indirect_glBeginQueryARB(GLenum target, GLuint id);
extern HIDDEN void __indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids);
extern HIDDEN void __indirect_glEndQueryARB(GLenum target);
extern HIDDEN void __indirect_glGenQueriesARB(GLsizei n, GLuint * ids);
extern HIDDEN void __indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params);
extern HIDDEN void __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params);
extern HIDDEN GLboolean __indirect_glIsQueryARB(GLuint id);
extern HIDDEN void __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs);
extern HIDDEN void __indirect_glGetColorTableParameterfvSGI(GLenum target, GLenum pname, GLfloat * params);
extern HIDDEN void __indirect_glGetColorTableParameterivSGI(GLenum target, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetColorTableSGI(GLenum target, GLenum format, GLenum type, GLvoid * table);
extern HIDDEN GLboolean __indirect_glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences);
extern HIDDEN void __indirect_glGenTexturesEXT(GLsizei n, GLuint * textures);
extern HIDDEN GLboolean __indirect_glIsTextureEXT(GLuint texture);
extern HIDDEN void __indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert);
extern HIDDEN void __indirect_glSamplePatternSGIS(GLenum pattern);
extern HIDDEN void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean * pointer);
extern HIDDEN void __indirect_glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
extern HIDDEN void __indirect_glPointParameterfEXT(GLenum pname, GLfloat param);
extern HIDDEN void __indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params);
extern HIDDEN void __indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue);
extern HIDDEN void __indirect_glSecondaryColor3bvEXT(const GLbyte * v);
extern HIDDEN void __indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue);
extern HIDDEN void __indirect_glSecondaryColor3dvEXT(const GLdouble * v);
extern HIDDEN void __indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue);
extern HIDDEN void __indirect_glSecondaryColor3fvEXT(const GLfloat * v);
extern HIDDEN void __indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue);
extern HIDDEN void __indirect_glSecondaryColor3ivEXT(const GLint * v);
extern HIDDEN void __indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue);
extern HIDDEN void __indirect_glSecondaryColor3svEXT(const GLshort * v);
extern HIDDEN void __indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue);
extern HIDDEN void __indirect_glSecondaryColor3ubvEXT(const GLubyte * v);
extern HIDDEN void __indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue);
extern HIDDEN void __indirect_glSecondaryColor3uivEXT(const GLuint * v);
extern HIDDEN void __indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue);
extern HIDDEN void __indirect_glSecondaryColor3usvEXT(const GLushort * v);
extern HIDDEN void __indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
extern HIDDEN void __indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
extern HIDDEN void __indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte * v);
extern HIDDEN void __indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v);
extern HIDDEN void __indirect_glPointParameteriNV(GLenum pname, GLint param);
extern HIDDEN void __indirect_glPointParameterivNV(GLenum pname, const GLint * params);
extern HIDDEN void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount);
extern HIDDEN void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount);
extern HIDDEN void __indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid * pointer);
extern HIDDEN void __indirect_glFogCoorddEXT(GLdouble coord);
extern HIDDEN void __indirect_glFogCoorddvEXT(const GLdouble * coord);
extern HIDDEN void __indirect_glFogCoordfEXT(GLfloat coord);
extern HIDDEN void __indirect_glFogCoordfvEXT(const GLfloat * coord);
extern HIDDEN void __indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
extern HIDDEN void __indirect_glWindowPos2dMESA(GLdouble x, GLdouble y);
extern HIDDEN void __indirect_glWindowPos2dvMESA(const GLdouble * v);
extern HIDDEN void __indirect_glWindowPos2fMESA(GLfloat x, GLfloat y);
extern HIDDEN void __indirect_glWindowPos2fvMESA(const GLfloat * v);
extern HIDDEN void __indirect_glWindowPos2iMESA(GLint x, GLint y);
extern HIDDEN void __indirect_glWindowPos2ivMESA(const GLint * v);
extern HIDDEN void __indirect_glWindowPos2sMESA(GLshort x, GLshort y);
extern HIDDEN void __indirect_glWindowPos2svMESA(const GLshort * v);
extern HIDDEN void __indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z);
extern HIDDEN void __indirect_glWindowPos3dvMESA(const GLdouble * v);
extern HIDDEN void __indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z);
extern HIDDEN void __indirect_glWindowPos3fvMESA(const GLfloat * v);
extern HIDDEN void __indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z);
extern HIDDEN void __indirect_glWindowPos3ivMESA(const GLint * v);
extern HIDDEN void __indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z);
extern HIDDEN void __indirect_glWindowPos3svMESA(const GLshort * v);
extern HIDDEN GLboolean __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, GLboolean * residences);
extern HIDDEN void __indirect_glBindProgramNV(GLenum target, GLuint program);
extern HIDDEN void __indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs);
extern HIDDEN void __indirect_glExecuteProgramNV(GLenum target, GLuint id, const GLfloat * params);
extern HIDDEN void __indirect_glGenProgramsNV(GLsizei n, GLuint * programs);
extern HIDDEN void __indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble * params);
extern HIDDEN void __indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte * program);
extern HIDDEN void __indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid ** params);
extern HIDDEN void __indirect_glActiveStencilFaceEXT(GLenum face);
extern HIDDEN void __indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v);
extern HIDDEN void __indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v);
extern HIDDEN void __indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte * v);
extern HIDDEN void __indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v);
extern HIDDEN void __indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v);
extern HIDDEN void __indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte * v);
extern HIDDEN void __indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v);
extern HIDDEN void __indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v);
extern HIDDEN void __indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v);
extern HIDDEN void __indirect_glVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer);
extern HIDDEN void __indirect_glEnableVertexAttribArrayARB(GLuint index);
extern HIDDEN void __indirect_glDisableVertexAttribArrayARB(GLuint index);
extern HIDDEN void __indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid * string);
extern HIDDEN void __indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble * params);
extern HIDDEN void __indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat * params);
extern HIDDEN void __indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble * params);
extern HIDDEN void __indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat * params);
extern HIDDEN void __indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index, GLdouble * params);
extern HIDDEN void __indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index, GLdouble * params);
extern HIDDEN void __indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string);
extern HIDDEN void __indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v);
extern HIDDEN void __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v);
extern HIDDEN void __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params);
extern HIDDEN void __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params);
extern HIDDEN void __indirect_glGenQueriesARB(GLsizei n, GLuint * ids);
extern HIDDEN void __indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids);
extern HIDDEN GLboolean __indirect_glIsQueryARB(GLuint id);
extern HIDDEN void __indirect_glBeginQueryARB(GLenum target, GLuint id);
extern HIDDEN void __indirect_glEndQueryARB(GLenum target);
extern HIDDEN void __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params);
extern HIDDEN void __indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble * params);
extern HIDDEN void __indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params);
extern HIDDEN void __indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params);
extern HIDDEN GLboolean __indirect_glIsProgramNV(GLuint program);
extern HIDDEN void __indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte * program);
extern HIDDEN void __indirect_glProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramParameter4dvNV(GLenum target, GLuint index, const GLdouble * params);
extern HIDDEN void __indirect_glProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat * params);
extern HIDDEN void __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params);
extern HIDDEN void __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params);
extern HIDDEN void __indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids);
extern HIDDEN void __indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform);
extern HIDDEN void __indirect_glVertexAttrib1dNV(GLuint index, GLdouble x);
extern HIDDEN void __indirect_glVertexAttrib1dvNV(GLuint index, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttrib1fNV(GLuint index, GLfloat x);
@@ -662,47 +682,23 @@ extern HIDDEN void __indirect_glVertexAttrib4sNV(GLuint index, GLshort x, GLshor
extern HIDDEN void __indirect_glVertexAttrib4svNV(GLuint index, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
extern HIDDEN void __indirect_glVertexAttrib4ubvNV(GLuint index, const GLubyte * v);
extern HIDDEN void __indirect_glVertexAttribPointerNV(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
extern HIDDEN void __indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v);
extern HIDDEN void __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v);
extern HIDDEN void __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v);
extern HIDDEN void __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v);
extern HIDDEN void __indirect_glPointParameteriNV(GLenum pname, GLint param);
extern HIDDEN void __indirect_glPointParameterivNV(GLenum pname, const GLint * params);
extern HIDDEN void __indirect_glActiveStencilFaceEXT(GLenum face);
extern HIDDEN void __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params);
extern HIDDEN void __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params);
extern HIDDEN void __indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
extern HIDDEN void __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v);
extern HIDDEN void __indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
extern HIDDEN void __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v);
extern HIDDEN void __indirect_glBlendEquationSeparateEXT(GLenum modeRGB, GLenum modeA);
extern HIDDEN void __indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer);
extern HIDDEN GLboolean __indirect_glIsRenderbufferEXT(GLuint renderbuffer);
extern HIDDEN void __indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer);
extern HIDDEN GLenum __indirect_glCheckFramebufferStatusEXT(GLenum target);
extern HIDDEN void __indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers);
extern HIDDEN void __indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers);
extern HIDDEN void __indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
extern HIDDEN void __indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers);
extern HIDDEN void __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
extern HIDDEN void __indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params);
extern HIDDEN GLboolean __indirect_glIsFramebufferEXT(GLuint framebuffer);
extern HIDDEN void __indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer);
extern HIDDEN void __indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers);
extern HIDDEN void __indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers);
extern HIDDEN GLenum __indirect_glCheckFramebufferStatusEXT(GLenum target);
extern HIDDEN void __indirect_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
extern HIDDEN void __indirect_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
extern HIDDEN void __indirect_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
extern HIDDEN void __indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers);
extern HIDDEN void __indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers);
extern HIDDEN void __indirect_glGenerateMipmapEXT(GLenum target);
extern HIDDEN void __indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
extern HIDDEN void __indirect_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params);
extern HIDDEN void __indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params);
extern HIDDEN GLboolean __indirect_glIsFramebufferEXT(GLuint framebuffer);
extern HIDDEN GLboolean __indirect_glIsRenderbufferEXT(GLuint renderbuffer);
extern HIDDEN void __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
extern HIDDEN void __indirect_glGenerateMipmapEXT(GLenum target);
# undef HIDDEN
# undef FASTCALL

View File

@@ -494,10 +494,10 @@ __GLapi * __glXNewIndirectAPI( void )
/* 3. GL_ARB_transpose_matrix */
glAPI->LoadTransposeMatrixdARB = __indirect_glLoadTransposeMatrixdARB;
glAPI->LoadTransposeMatrixfARB = __indirect_glLoadTransposeMatrixfARB;
glAPI->MultTransposeMatrixdARB = __indirect_glMultTransposeMatrixdARB;
glAPI->LoadTransposeMatrixdARB = __indirect_glLoadTransposeMatrixdARB;
glAPI->MultTransposeMatrixfARB = __indirect_glMultTransposeMatrixfARB;
glAPI->MultTransposeMatrixdARB = __indirect_glMultTransposeMatrixdARB;
/* 5. GL_ARB_multisample */
@@ -505,27 +505,30 @@ __GLapi * __glXNewIndirectAPI( void )
/* 12. GL_ARB_texture_compression */
glAPI->CompressedTexImage1DARB = __indirect_glCompressedTexImage1DARB;
glAPI->CompressedTexImage2DARB = __indirect_glCompressedTexImage2DARB;
glAPI->CompressedTexImage3DARB = __indirect_glCompressedTexImage3DARB;
glAPI->CompressedTexSubImage1DARB = __indirect_glCompressedTexSubImage1DARB;
glAPI->CompressedTexSubImage2DARB = __indirect_glCompressedTexSubImage2DARB;
glAPI->CompressedTexImage2DARB = __indirect_glCompressedTexImage2DARB;
glAPI->CompressedTexImage1DARB = __indirect_glCompressedTexImage1DARB;
glAPI->CompressedTexSubImage3DARB = __indirect_glCompressedTexSubImage3DARB;
glAPI->CompressedTexSubImage2DARB = __indirect_glCompressedTexSubImage2DARB;
glAPI->CompressedTexSubImage1DARB = __indirect_glCompressedTexSubImage1DARB;
glAPI->GetCompressedTexImageARB = __indirect_glGetCompressedTexImageARB;
/* 26. GL_ARB_vertex_program */
glAPI->DisableVertexAttribArrayARB = __indirect_glDisableVertexAttribArrayARB;
glAPI->VertexAttrib4bvARB = __indirect_glVertexAttrib4bvARB;
glAPI->VertexAttrib4ivARB = __indirect_glVertexAttrib4ivARB;
glAPI->VertexAttrib4ubvARB = __indirect_glVertexAttrib4ubvARB;
glAPI->VertexAttrib4usvARB = __indirect_glVertexAttrib4usvARB;
glAPI->VertexAttrib4uivARB = __indirect_glVertexAttrib4uivARB;
glAPI->VertexAttrib4NbvARB = __indirect_glVertexAttrib4NbvARB;
glAPI->VertexAttrib4NsvARB = __indirect_glVertexAttrib4NsvARB;
glAPI->VertexAttrib4NivARB = __indirect_glVertexAttrib4NivARB;
glAPI->VertexAttrib4NusvARB = __indirect_glVertexAttrib4NusvARB;
glAPI->VertexAttrib4NuivARB = __indirect_glVertexAttrib4NuivARB;
glAPI->VertexAttribPointerARB = __indirect_glVertexAttribPointerARB;
glAPI->EnableVertexAttribArrayARB = __indirect_glEnableVertexAttribArrayARB;
glAPI->GetProgramEnvParameterdvARB = __indirect_glGetProgramEnvParameterdvARB;
glAPI->GetProgramEnvParameterfvARB = __indirect_glGetProgramEnvParameterfvARB;
glAPI->GetProgramLocalParameterdvARB = __indirect_glGetProgramLocalParameterdvARB;
glAPI->GetProgramLocalParameterfvARB = __indirect_glGetProgramLocalParameterfvARB;
glAPI->GetProgramStringARB = __indirect_glGetProgramStringARB;
glAPI->GetProgramivARB = __indirect_glGetProgramivARB;
glAPI->GetVertexAttribdvARB = __indirect_glGetVertexAttribdvARB;
glAPI->GetVertexAttribfvARB = __indirect_glGetVertexAttribfvARB;
glAPI->GetVertexAttribivARB = __indirect_glGetVertexAttribivARB;
glAPI->DisableVertexAttribArrayARB = __indirect_glDisableVertexAttribArrayARB;
glAPI->ProgramStringARB = __indirect_glProgramStringARB;
glAPI->ProgramEnvParameter4dARB = __indirect_glProgramEnvParameter4dARB;
glAPI->ProgramEnvParameter4dvARB = __indirect_glProgramEnvParameter4dvARB;
glAPI->ProgramEnvParameter4fARB = __indirect_glProgramEnvParameter4fARB;
@@ -534,7 +537,15 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->ProgramLocalParameter4dvARB = __indirect_glProgramLocalParameter4dvARB;
glAPI->ProgramLocalParameter4fARB = __indirect_glProgramLocalParameter4fARB;
glAPI->ProgramLocalParameter4fvARB = __indirect_glProgramLocalParameter4fvARB;
glAPI->ProgramStringARB = __indirect_glProgramStringARB;
glAPI->GetProgramEnvParameterdvARB = __indirect_glGetProgramEnvParameterdvARB;
glAPI->GetProgramEnvParameterfvARB = __indirect_glGetProgramEnvParameterfvARB;
glAPI->GetProgramLocalParameterdvARB = __indirect_glGetProgramLocalParameterdvARB;
glAPI->GetProgramLocalParameterfvARB = __indirect_glGetProgramLocalParameterfvARB;
glAPI->GetProgramivARB = __indirect_glGetProgramivARB;
glAPI->GetProgramStringARB = __indirect_glGetProgramStringARB;
glAPI->GetVertexAttribdvARB = __indirect_glGetVertexAttribdvARB;
glAPI->GetVertexAttribfvARB = __indirect_glGetVertexAttribfvARB;
glAPI->GetVertexAttribivARB = __indirect_glGetVertexAttribivARB;
glAPI->VertexAttrib1dARB = __indirect_glVertexAttrib1dARB;
glAPI->VertexAttrib1dvARB = __indirect_glVertexAttrib1dvARB;
glAPI->VertexAttrib1fARB = __indirect_glVertexAttrib1fARB;
@@ -553,52 +564,35 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->VertexAttrib3fvARB = __indirect_glVertexAttrib3fvARB;
glAPI->VertexAttrib3sARB = __indirect_glVertexAttrib3sARB;
glAPI->VertexAttrib3svARB = __indirect_glVertexAttrib3svARB;
glAPI->VertexAttrib4NbvARB = __indirect_glVertexAttrib4NbvARB;
glAPI->VertexAttrib4NivARB = __indirect_glVertexAttrib4NivARB;
glAPI->VertexAttrib4NsvARB = __indirect_glVertexAttrib4NsvARB;
glAPI->VertexAttrib4NubARB = __indirect_glVertexAttrib4NubARB;
glAPI->VertexAttrib4NubvARB = __indirect_glVertexAttrib4NubvARB;
glAPI->VertexAttrib4NuivARB = __indirect_glVertexAttrib4NuivARB;
glAPI->VertexAttrib4NusvARB = __indirect_glVertexAttrib4NusvARB;
glAPI->VertexAttrib4bvARB = __indirect_glVertexAttrib4bvARB;
glAPI->VertexAttrib4dARB = __indirect_glVertexAttrib4dARB;
glAPI->VertexAttrib4dvARB = __indirect_glVertexAttrib4dvARB;
glAPI->VertexAttrib4fARB = __indirect_glVertexAttrib4fARB;
glAPI->VertexAttrib4fvARB = __indirect_glVertexAttrib4fvARB;
glAPI->VertexAttrib4ivARB = __indirect_glVertexAttrib4ivARB;
glAPI->VertexAttrib4sARB = __indirect_glVertexAttrib4sARB;
glAPI->VertexAttrib4svARB = __indirect_glVertexAttrib4svARB;
glAPI->VertexAttrib4ubvARB = __indirect_glVertexAttrib4ubvARB;
glAPI->VertexAttrib4uivARB = __indirect_glVertexAttrib4uivARB;
glAPI->VertexAttrib4usvARB = __indirect_glVertexAttrib4usvARB;
glAPI->VertexAttribPointerARB = __indirect_glVertexAttribPointerARB;
glAPI->VertexAttrib4NubARB = __indirect_glVertexAttrib4NubARB;
glAPI->VertexAttrib4NubvARB = __indirect_glVertexAttrib4NubvARB;
/* 29. GL_ARB_occlusion_query */
glAPI->BeginQueryARB = __indirect_glBeginQueryARB;
glAPI->DeleteQueriesARB = __indirect_glDeleteQueriesARB;
glAPI->EndQueryARB = __indirect_glEndQueryARB;
glAPI->GenQueriesARB = __indirect_glGenQueriesARB;
glAPI->GetQueryivARB = __indirect_glGetQueryivARB;
glAPI->GetQueryObjectivARB = __indirect_glGetQueryObjectivARB;
glAPI->GetQueryObjectuivARB = __indirect_glGetQueryObjectuivARB;
glAPI->GetQueryivARB = __indirect_glGetQueryivARB;
glAPI->GenQueriesARB = __indirect_glGenQueriesARB;
glAPI->DeleteQueriesARB = __indirect_glDeleteQueriesARB;
glAPI->IsQueryARB = __indirect_glIsQueryARB;
glAPI->BeginQueryARB = __indirect_glBeginQueryARB;
/* 37. GL_ARB_draw_buffers */
glAPI->DrawBuffersARB = __indirect_glDrawBuffersARB;
/* 14. GL_SGI_color_table */
glAPI->GetColorTableParameterfvSGI = __indirect_glGetColorTableParameterfvSGI;
glAPI->GetColorTableParameterivSGI = __indirect_glGetColorTableParameterivSGI;
glAPI->GetColorTableSGI = __indirect_glGetColorTableSGI;
/* 20. GL_EXT_texture_object */
glAPI->AreTexturesResidentEXT = __indirect_glAreTexturesResidentEXT;
glAPI->GenTexturesEXT = __indirect_glGenTexturesEXT;
glAPI->IsTextureEXT = __indirect_glIsTextureEXT;
glAPI->AreTexturesResidentEXT = __indirect_glAreTexturesResidentEXT;
/* 25. GL_SGIS_multisample */
@@ -621,6 +615,8 @@ __GLapi * __glXNewIndirectAPI( void )
/* 145. GL_EXT_secondary_color */
glAPI->SecondaryColor3usvEXT = __indirect_glSecondaryColor3usvEXT;
glAPI->SecondaryColorPointerEXT = __indirect_glSecondaryColorPointerEXT;
glAPI->SecondaryColor3bEXT = __indirect_glSecondaryColor3bEXT;
glAPI->SecondaryColor3bvEXT = __indirect_glSecondaryColor3bvEXT;
glAPI->SecondaryColor3dEXT = __indirect_glSecondaryColor3dEXT;
@@ -636,8 +632,6 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->SecondaryColor3uiEXT = __indirect_glSecondaryColor3uiEXT;
glAPI->SecondaryColor3uivEXT = __indirect_glSecondaryColor3uivEXT;
glAPI->SecondaryColor3usEXT = __indirect_glSecondaryColor3usEXT;
glAPI->SecondaryColor3usvEXT = __indirect_glSecondaryColor3usvEXT;
glAPI->SecondaryColorPointerEXT = __indirect_glSecondaryColorPointerEXT;
/* 148. GL_EXT_multi_draw_arrays */
@@ -646,11 +640,11 @@ __GLapi * __glXNewIndirectAPI( void )
/* 149. GL_EXT_fog_coord */
glAPI->FogCoorddvEXT = __indirect_glFogCoorddvEXT;
glAPI->FogCoordfEXT = __indirect_glFogCoordfEXT;
glAPI->FogCoordfvEXT = __indirect_glFogCoordfvEXT;
glAPI->FogCoordPointerEXT = __indirect_glFogCoordPointerEXT;
glAPI->FogCoorddEXT = __indirect_glFogCoorddEXT;
glAPI->FogCoorddvEXT = __indirect_glFogCoorddvEXT;
glAPI->FogCoordPointerEXT = __indirect_glFogCoordPointerEXT;
/* 173. GL_EXT_blend_func_separate */
@@ -677,6 +671,27 @@ __GLapi * __glXNewIndirectAPI( void )
/* 233. GL_NV_vertex_program */
glAPI->VertexAttribs4svNV = __indirect_glVertexAttribs4svNV;
glAPI->VertexAttribs4ubvNV = __indirect_glVertexAttribs4ubvNV;
glAPI->VertexAttrib3fNV = __indirect_glVertexAttrib3fNV;
glAPI->VertexAttrib3fvNV = __indirect_glVertexAttrib3fvNV;
glAPI->VertexAttrib3sNV = __indirect_glVertexAttrib3sNV;
glAPI->VertexAttrib3svNV = __indirect_glVertexAttrib3svNV;
glAPI->VertexAttrib4dNV = __indirect_glVertexAttrib4dNV;
glAPI->VertexAttrib3dvNV = __indirect_glVertexAttrib3dvNV;
glAPI->VertexAttrib4fNV = __indirect_glVertexAttrib4fNV;
glAPI->VertexAttrib4fvNV = __indirect_glVertexAttrib4fvNV;
glAPI->VertexAttrib4sNV = __indirect_glVertexAttrib4sNV;
glAPI->VertexAttrib4svNV = __indirect_glVertexAttrib4svNV;
glAPI->VertexAttrib4ubNV = __indirect_glVertexAttrib4ubNV;
glAPI->VertexAttrib4ubvNV = __indirect_glVertexAttrib4ubvNV;
glAPI->VertexAttrib1fvNV = __indirect_glVertexAttrib1fvNV;
glAPI->VertexAttrib3dNV = __indirect_glVertexAttrib3dNV;
glAPI->VertexAttrib4dvNV = __indirect_glVertexAttrib4dvNV;
glAPI->VertexAttrib1sNV = __indirect_glVertexAttrib1sNV;
glAPI->VertexAttrib1fNV = __indirect_glVertexAttrib1fNV;
glAPI->VertexAttrib1svNV = __indirect_glVertexAttrib1svNV;
glAPI->VertexAttrib1dvNV = __indirect_glVertexAttrib1dvNV;
glAPI->AreProgramsResidentNV = __indirect_glAreProgramsResidentNV;
glAPI->BindProgramNV = __indirect_glBindProgramNV;
glAPI->DeleteProgramsNV = __indirect_glDeleteProgramsNV;
@@ -684,13 +699,10 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->GenProgramsNV = __indirect_glGenProgramsNV;
glAPI->GetProgramParameterdvNV = __indirect_glGetProgramParameterdvNV;
glAPI->GetProgramParameterfvNV = __indirect_glGetProgramParameterfvNV;
glAPI->GetProgramStringNV = __indirect_glGetProgramStringNV;
glAPI->GetProgramivNV = __indirect_glGetProgramivNV;
glAPI->GetProgramStringNV = __indirect_glGetProgramStringNV;
glAPI->GetTrackMatrixivNV = __indirect_glGetTrackMatrixivNV;
glAPI->GetVertexAttribPointervNV = __indirect_glGetVertexAttribPointervNV;
glAPI->GetVertexAttribdvNV = __indirect_glGetVertexAttribdvNV;
glAPI->GetVertexAttribfvNV = __indirect_glGetVertexAttribfvNV;
glAPI->GetVertexAttribivNV = __indirect_glGetVertexAttribivNV;
glAPI->IsProgramNV = __indirect_glIsProgramNV;
glAPI->LoadProgramNV = __indirect_glLoadProgramNV;
glAPI->ProgramParameter4dNV = __indirect_glProgramParameter4dNV;
@@ -701,33 +713,17 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->ProgramParameters4fvNV = __indirect_glProgramParameters4fvNV;
glAPI->RequestResidentProgramsNV = __indirect_glRequestResidentProgramsNV;
glAPI->TrackMatrixNV = __indirect_glTrackMatrixNV;
glAPI->VertexAttrib1dNV = __indirect_glVertexAttrib1dNV;
glAPI->VertexAttrib1dvNV = __indirect_glVertexAttrib1dvNV;
glAPI->VertexAttrib1fNV = __indirect_glVertexAttrib1fNV;
glAPI->VertexAttrib1fvNV = __indirect_glVertexAttrib1fvNV;
glAPI->VertexAttrib1sNV = __indirect_glVertexAttrib1sNV;
glAPI->VertexAttrib1svNV = __indirect_glVertexAttrib1svNV;
glAPI->VertexAttribPointerNV = __indirect_glVertexAttribPointerNV;
glAPI->VertexAttrib2dNV = __indirect_glVertexAttrib2dNV;
glAPI->VertexAttrib2sNV = __indirect_glVertexAttrib2sNV;
glAPI->VertexAttrib2dvNV = __indirect_glVertexAttrib2dvNV;
glAPI->VertexAttrib2fNV = __indirect_glVertexAttrib2fNV;
glAPI->VertexAttrib2fvNV = __indirect_glVertexAttrib2fvNV;
glAPI->VertexAttrib2sNV = __indirect_glVertexAttrib2sNV;
glAPI->VertexAttrib2svNV = __indirect_glVertexAttrib2svNV;
glAPI->VertexAttrib3dNV = __indirect_glVertexAttrib3dNV;
glAPI->VertexAttrib3dvNV = __indirect_glVertexAttrib3dvNV;
glAPI->VertexAttrib3fNV = __indirect_glVertexAttrib3fNV;
glAPI->VertexAttrib3fvNV = __indirect_glVertexAttrib3fvNV;
glAPI->VertexAttrib3sNV = __indirect_glVertexAttrib3sNV;
glAPI->VertexAttrib3svNV = __indirect_glVertexAttrib3svNV;
glAPI->VertexAttrib4dNV = __indirect_glVertexAttrib4dNV;
glAPI->VertexAttrib4dvNV = __indirect_glVertexAttrib4dvNV;
glAPI->VertexAttrib4fNV = __indirect_glVertexAttrib4fNV;
glAPI->VertexAttrib4fvNV = __indirect_glVertexAttrib4fvNV;
glAPI->VertexAttrib4sNV = __indirect_glVertexAttrib4sNV;
glAPI->VertexAttrib4svNV = __indirect_glVertexAttrib4svNV;
glAPI->VertexAttrib4ubNV = __indirect_glVertexAttrib4ubNV;
glAPI->VertexAttrib4ubvNV = __indirect_glVertexAttrib4ubvNV;
glAPI->VertexAttribPointerNV = __indirect_glVertexAttribPointerNV;
glAPI->VertexAttrib2fvNV = __indirect_glVertexAttrib2fvNV;
glAPI->GetVertexAttribdvNV = __indirect_glGetVertexAttribdvNV;
glAPI->GetVertexAttribfvNV = __indirect_glGetVertexAttribfvNV;
glAPI->GetVertexAttribivNV = __indirect_glGetVertexAttribivNV;
glAPI->VertexAttrib1dNV = __indirect_glVertexAttrib1dNV;
glAPI->VertexAttribs1dvNV = __indirect_glVertexAttribs1dvNV;
glAPI->VertexAttribs1fvNV = __indirect_glVertexAttribs1fvNV;
glAPI->VertexAttribs1svNV = __indirect_glVertexAttribs1svNV;
@@ -739,8 +735,6 @@ __GLapi * __glXNewIndirectAPI( void )
glAPI->VertexAttribs3svNV = __indirect_glVertexAttribs3svNV;
glAPI->VertexAttribs4dvNV = __indirect_glVertexAttribs4dvNV;
glAPI->VertexAttribs4fvNV = __indirect_glVertexAttribs4fvNV;
glAPI->VertexAttribs4svNV = __indirect_glVertexAttribs4svNV;
glAPI->VertexAttribs4ubvNV = __indirect_glVertexAttribs4ubvNV;
/* 262. GL_NV_point_sprite */
@@ -753,36 +747,32 @@ __GLapi * __glXNewIndirectAPI( void )
/* 282. GL_NV_fragment_program */
glAPI->GetProgramNamedParameterdvNV = __indirect_glGetProgramNamedParameterdvNV;
glAPI->GetProgramNamedParameterfvNV = __indirect_glGetProgramNamedParameterfvNV;
glAPI->ProgramNamedParameter4dNV = __indirect_glProgramNamedParameter4dNV;
glAPI->ProgramNamedParameter4dvNV = __indirect_glProgramNamedParameter4dvNV;
glAPI->ProgramNamedParameter4fNV = __indirect_glProgramNamedParameter4fNV;
glAPI->ProgramNamedParameter4dNV = __indirect_glProgramNamedParameter4dNV;
glAPI->ProgramNamedParameter4fvNV = __indirect_glProgramNamedParameter4fvNV;
/* 299. GL_EXT_blend_equation_separate */
glAPI->BlendEquationSeparateEXT = __indirect_glBlendEquationSeparateEXT;
glAPI->ProgramNamedParameter4dvNV = __indirect_glProgramNamedParameter4dvNV;
glAPI->GetProgramNamedParameterfvNV = __indirect_glGetProgramNamedParameterfvNV;
glAPI->GetProgramNamedParameterdvNV = __indirect_glGetProgramNamedParameterdvNV;
/* 310. GL_EXT_framebuffer_object */
glAPI->RenderbufferStorageEXT = __indirect_glRenderbufferStorageEXT;
glAPI->GetRenderbufferParameterivEXT = __indirect_glGetRenderbufferParameterivEXT;
glAPI->IsFramebufferEXT = __indirect_glIsFramebufferEXT;
glAPI->BindFramebufferEXT = __indirect_glBindFramebufferEXT;
glAPI->BindRenderbufferEXT = __indirect_glBindRenderbufferEXT;
glAPI->CheckFramebufferStatusEXT = __indirect_glCheckFramebufferStatusEXT;
glAPI->DeleteFramebuffersEXT = __indirect_glDeleteFramebuffersEXT;
glAPI->DeleteRenderbuffersEXT = __indirect_glDeleteRenderbuffersEXT;
glAPI->FramebufferRenderbufferEXT = __indirect_glFramebufferRenderbufferEXT;
glAPI->GenFramebuffersEXT = __indirect_glGenFramebuffersEXT;
glAPI->CheckFramebufferStatusEXT = __indirect_glCheckFramebufferStatusEXT;
glAPI->FramebufferTexture1DEXT = __indirect_glFramebufferTexture1DEXT;
glAPI->FramebufferTexture2DEXT = __indirect_glFramebufferTexture2DEXT;
glAPI->FramebufferTexture3DEXT = __indirect_glFramebufferTexture3DEXT;
glAPI->GenFramebuffersEXT = __indirect_glGenFramebuffersEXT;
glAPI->GenRenderbuffersEXT = __indirect_glGenRenderbuffersEXT;
glAPI->GenerateMipmapEXT = __indirect_glGenerateMipmapEXT;
glAPI->FramebufferRenderbufferEXT = __indirect_glFramebufferRenderbufferEXT;
glAPI->GetFramebufferAttachmentParameterivEXT = __indirect_glGetFramebufferAttachmentParameterivEXT;
glAPI->GetRenderbufferParameterivEXT = __indirect_glGetRenderbufferParameterivEXT;
glAPI->IsFramebufferEXT = __indirect_glIsFramebufferEXT;
glAPI->GenerateMipmapEXT = __indirect_glGenerateMipmapEXT;
glAPI->IsRenderbufferEXT = __indirect_glIsRenderbufferEXT;
glAPI->RenderbufferStorageEXT = __indirect_glRenderbufferStorageEXT;
glAPI->BindRenderbufferEXT = __indirect_glBindRenderbufferEXT;
glAPI->DeleteRenderbuffersEXT = __indirect_glDeleteRenderbuffersEXT;
glAPI->GenRenderbuffersEXT = __indirect_glGenRenderbuffersEXT;
return glAPI;
}

View File

@@ -32,14 +32,13 @@ default:
elif [ "$(DRIVER_DIRS)" = "beos" ]; then \
$(MAKE) beos ; \
elif [ "$(DRIVER_DIRS)" = "directfb" ]; then \
$(MAKE) directfb ; \
elif [ "$(DRIVER_DIRS)" = "fbdev" ]; then \
$(MAKE) fbdev ; \
$(MAKE) directfb; \
else \
$(MAKE) stand-alone ; \
fi
######################################################################
# BeOS driver target
@@ -67,31 +66,21 @@ linux-solo: depend subdirs libmesa.a
libgl-core: $(CORE_OBJECTS)
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(CORE_OBJECTS) \
$(GL_LIB_DEPS)
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) $(CORE_OBJECTS) $(GL_LIB_DEPS)
directfb: depend subdirs libgl-core
cd drivers/directfb ; $(MAKE)
#####################################################################
# fbdev Mesa driver (libGL.so)
fbdev: $(CORE_OBJECTS) $(FBDEV_DRIVER_OBJECTS) $(COMMON_DRIVER_OBJECTS)
@ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
$(CORE_OBJECTS) $(FBDEV_DRIVER_OBJECTS) \
$(COMMON_DRIVER_OBJECTS) $(GL_LIB_DEPS)
cd drivers/directfb; $(MAKE)
######################################################################
# Stand-alone Mesa libGL and libOSMesa
STAND_ALONE_DRIVER_SOURCES = \
$(COMMON_DRIVER_SOURCES) \
$(X11_DRIVER_SOURCES) \
$(GLIDE_DRIVER_SOURCES) \
$(SVGA_DRIVER_SOURCES)
$(SVGA_DRIVER_SOURCES) \
$(FBDEV_DRIVER_SOURCES)
STAND_ALONE_DRIVER_OBJECTS = $(STAND_ALONE_DRIVER_SOURCES:.c=.o)
@@ -138,6 +127,15 @@ $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECT
######################################################################
# Generic stuff
ALL_SOURCES = \
$(GLAPI_SOURCES) \
$(SOLO_SOURCES) \
$(X86_SOURCES) \
$(COMMON_DRIVER_SOURCES)\
$(X11_DRIVER_SOURCES) \
$(OSMESA_DRIVER_SOURCES)
depend: $(ALL_SOURCES)
@ echo "running $(MKDEP)"
@ touch depend
@@ -159,6 +157,7 @@ install: default
cd drivers/dri ; $(MAKE) install ; \
fi
## NOT YET:
## $(INSTALL) -d $(INSTALL_DIR)/include/GLES
## $(INSTALL) -m 644 include/GLES/*.h $(INSTALL_DIR)/include/GLES
@@ -177,5 +176,4 @@ clean:
(cd x86 ; $(MAKE) clean)
(cd x86-64 ; $(MAKE) clean)
include depend

View File

@@ -9,7 +9,10 @@ COMMON_SOURCES = \
../common/vblank.c \
../common/dri_util.c \
../common/xmlconfig.c \
../common/drirenderbuffer.c
../common/drirenderbuffer.c \
../common/dri_bufmgr.c \
../common/dri_drmpool.c
ifeq ($(WINDOW_SYSTEM),dri)
WINOBJ=

View File

@@ -0,0 +1,493 @@
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
* 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 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
* THE COPYRIGHT HOLDERS, AUTHORS 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.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
**************************************************************************/
/*
* Authors: Thomas Hellstr<74>m <thomas-at-tungstengraphics-dot-com>
* Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
#include <xf86drm.h>
#include <stdlib.h>
#include "glthread.h"
#include "errno.h"
#include "dri_bufmgr.h"
#include "string.h"
#include "imports.h"
#include "dri_bufpool.h"
_glthread_DECLARE_STATIC_MUTEX(bmMutex);
/*
* TODO: Introduce fence pools in the same way as
* buffer object pools.
*/
typedef struct _DriFenceObject
{
int fd;
_glthread_Mutex mutex;
int refCount;
const char *name;
drmFence fence;
} DriFenceObject;
typedef struct _DriBufferObject
{
DriBufferPool *pool;
_glthread_Mutex mutex;
int refCount;
const char *name;
unsigned flags;
unsigned hint;
unsigned alignment;
void *private;
} DriBufferObject;
void
bmError(int val, const char *file, const char *function, int line)
{
_mesa_printf("Fatal video memory manager error \"%s\".\n"
"Check kernel logs or set the LIBGL_DEBUG\n"
"environment variable to \"verbose\" for more info.\n"
"Detected in file %s, line %d, function %s.\n",
strerror(-val), file, line, function);
#ifndef NDEBUG
abort();
#else
abort();
#endif
}
DriFenceObject *
driFenceBuffers(int fd, char *name, unsigned flags)
{
DriFenceObject *fence = (DriFenceObject *) malloc(sizeof(*fence));
int ret;
if (!fence)
BM_CKFATAL(-EINVAL);
_glthread_LOCK_MUTEX(bmMutex);
fence->refCount = 1;
fence->name = name;
fence->fd = fd;
_glthread_INIT_MUTEX(fence->mutex);
ret = drmFenceBuffers(fd, flags, &fence->fence);
_glthread_UNLOCK_MUTEX(bmMutex);
if (ret) {
free(fence);
BM_CKFATAL(ret);
}
return fence;
}
unsigned
driFenceType(DriFenceObject * fence)
{
unsigned ret;
_glthread_LOCK_MUTEX(bmMutex);
ret = fence->fence.flags;
_glthread_UNLOCK_MUTEX(bmMutex);
return ret;
}
DriFenceObject *
driFenceReference(DriFenceObject * fence)
{
_glthread_LOCK_MUTEX(bmMutex);
++fence->refCount;
_glthread_UNLOCK_MUTEX(bmMutex);
return fence;
}
void
driFenceUnReference(DriFenceObject * fence)
{
if (!fence)
return;
_glthread_LOCK_MUTEX(bmMutex);
if (--fence->refCount == 0) {
drmFenceDestroy(fence->fd, &fence->fence);
free(fence);
}
_glthread_UNLOCK_MUTEX(bmMutex);
}
void
driFenceFinish(DriFenceObject * fence, unsigned type, int lazy)
{
int ret;
unsigned flags = (lazy) ? DRM_FENCE_FLAG_WAIT_LAZY : 0;
_glthread_LOCK_MUTEX(fence->mutex);
ret = drmFenceWait(fence->fd, flags, &fence->fence, type);
_glthread_UNLOCK_MUTEX(fence->mutex);
BM_CKFATAL(ret);
}
int
driFenceSignaled(DriFenceObject * fence, unsigned type)
{
int signaled;
int ret;
if (fence == NULL)
return GL_TRUE;
_glthread_LOCK_MUTEX(fence->mutex);
ret = drmFenceSignaled(fence->fd, &fence->fence, type, &signaled);
_glthread_UNLOCK_MUTEX(fence->mutex);
BM_CKFATAL(ret);
return signaled;
}
extern drmBO *
driBOKernel(struct _DriBufferObject *buf)
{
drmBO *ret;
assert(buf->private != NULL);
ret = buf->pool->kernel(buf->pool, buf->private);
if (!ret)
BM_CKFATAL(-EINVAL);
return ret;
}
void
driBOWaitIdle(struct _DriBufferObject *buf, int lazy)
{
assert(buf->private != NULL);
_glthread_LOCK_MUTEX(buf->mutex);
BM_CKFATAL(buf->pool->waitIdle(buf->pool, buf->private, lazy));
_glthread_UNLOCK_MUTEX(buf->mutex);
}
void *
driBOMap(struct _DriBufferObject *buf, unsigned flags, unsigned hint)
{
void *virtual;
assert(buf->private != NULL);
_glthread_LOCK_MUTEX(buf->mutex);
BM_CKFATAL(buf->pool->map(buf->pool, buf->private, flags, hint, &virtual));
_glthread_UNLOCK_MUTEX(buf->mutex);
return virtual;
}
void
driBOUnmap(struct _DriBufferObject *buf)
{
assert(buf->private != NULL);
buf->pool->unmap(buf->pool, buf->private);
}
unsigned long
driBOOffset(struct _DriBufferObject *buf)
{
unsigned long ret;
assert(buf->private != NULL);
_glthread_LOCK_MUTEX(buf->mutex);
ret = buf->pool->offset(buf->pool, buf->private);
_glthread_UNLOCK_MUTEX(buf->mutex);
return ret;
}
unsigned
driBOFlags(struct _DriBufferObject *buf)
{
unsigned ret;
assert(buf->private != NULL);
_glthread_LOCK_MUTEX(buf->mutex);
ret = buf->pool->flags(buf->pool, buf->private);
_glthread_UNLOCK_MUTEX(buf->mutex);
return ret;
}
struct _DriBufferObject *
driBOReference(struct _DriBufferObject *buf)
{
_glthread_LOCK_MUTEX(bmMutex);
if (++buf->refCount == 1) {
BM_CKFATAL(-EINVAL);
}
_glthread_UNLOCK_MUTEX(bmMutex);
return buf;
}
void
driBOUnReference(struct _DriBufferObject *buf)
{
int tmp;
if (!buf)
return;
_glthread_LOCK_MUTEX(bmMutex);
tmp = --buf->refCount;
_glthread_UNLOCK_MUTEX(bmMutex);
if (!tmp) {
buf->pool->destroy(buf->pool, buf->private);
free(buf);
}
}
void
driBOData(struct _DriBufferObject *buf,
unsigned size, const void *data, unsigned flags)
{
void *virtual;
int newBuffer;
struct _DriBufferPool *pool;
_glthread_LOCK_MUTEX(buf->mutex);
pool = buf->pool;
if (!pool->create) {
_mesa_error(NULL, GL_INVALID_OPERATION,
"driBOData called on invalid buffer\n");
BM_CKFATAL(-EINVAL);
}
newBuffer = !buf->private || (pool->size(pool, buf->private) < size) ||
pool->map(pool, buf->private, DRM_BO_FLAG_WRITE,
DRM_BO_HINT_DONT_BLOCK, &virtual);
if (newBuffer) {
if (buf->private)
pool->destroy(pool, buf->private);
if (!flags)
flags = buf->flags;
buf->private = pool->create(pool, size, flags, 0, buf->alignment);
if (!buf->private)
BM_CKFATAL(-ENOMEM);
BM_CKFATAL(pool->map(pool, buf->private,
DRM_BO_FLAG_WRITE,
DRM_BO_HINT_DONT_BLOCK, &virtual));
}
if (data != NULL)
memcpy(virtual, data, size);
BM_CKFATAL(pool->unmap(pool, buf->private));
_glthread_UNLOCK_MUTEX(buf->mutex);
}
void
driBOSubData(struct _DriBufferObject *buf,
unsigned long offset, unsigned long size, const void *data)
{
void *virtual;
_glthread_LOCK_MUTEX(buf->mutex);
if (size && data) {
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
DRM_BO_FLAG_WRITE, 0, &virtual));
memcpy((unsigned char *) virtual + offset, data, size);
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
}
_glthread_UNLOCK_MUTEX(buf->mutex);
}
void
driBOGetSubData(struct _DriBufferObject *buf,
unsigned long offset, unsigned long size, void *data)
{
void *virtual;
_glthread_LOCK_MUTEX(buf->mutex);
if (size && data) {
BM_CKFATAL(buf->pool->map(buf->pool, buf->private,
DRM_BO_FLAG_READ, 0, &virtual));
memcpy(data, (unsigned char *) virtual + offset, size);
BM_CKFATAL(buf->pool->unmap(buf->pool, buf->private));
}
_glthread_UNLOCK_MUTEX(buf->mutex);
}
void
driBOSetStatic(struct _DriBufferObject *buf,
unsigned long offset,
unsigned long size, void *virtual, unsigned flags)
{
_glthread_LOCK_MUTEX(buf->mutex);
if (buf->private != NULL) {
_mesa_error(NULL, GL_INVALID_OPERATION,
"Invalid buffer for setStatic\n");
BM_CKFATAL(-EINVAL);
}
if (buf->pool->setstatic == NULL) {
_mesa_error(NULL, GL_INVALID_OPERATION,
"Invalid buffer pool for setStatic\n");
BM_CKFATAL(-EINVAL);
}
if (!flags)
flags = buf->flags;
buf->private = buf->pool->setstatic(buf->pool, offset, size,
virtual, flags);
if (!buf->private) {
_mesa_error(NULL, GL_OUT_OF_MEMORY,
"Invalid buffer pool for setStatic\n");
BM_CKFATAL(-ENOMEM);
}
_glthread_UNLOCK_MUTEX(buf->mutex);
}
void
driGenBuffers(struct _DriBufferPool *pool,
const char *name,
unsigned n,
struct _DriBufferObject *buffers[],
unsigned alignment, unsigned flags, unsigned hint)
{
struct _DriBufferObject *buf;
int i;
flags = (flags) ? flags : DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_MEM_VRAM |
DRM_BO_FLAG_MEM_LOCAL | DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE;
for (i = 0; i < n; ++i) {
buf = (struct _DriBufferObject *) calloc(1, sizeof(*buf));
if (!buf)
BM_CKFATAL(-ENOMEM);
_glthread_INIT_MUTEX(buf->mutex);
_glthread_LOCK_MUTEX(buf->mutex);
_glthread_LOCK_MUTEX(bmMutex);
buf->refCount = 1;
_glthread_UNLOCK_MUTEX(bmMutex);
buf->flags = flags;
buf->hint = hint;
buf->name = name;
buf->alignment = alignment;
buf->pool = pool;
_glthread_UNLOCK_MUTEX(buf->mutex);
buffers[i] = buf;
}
}
void
driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[])
{
int i;
for (i = 0; i < n; ++i) {
driBOUnReference(buffers[i]);
}
}
void
driInitBufMgr(int fd)
{
;
}
void
driBOCreateList(int target, drmBOList * list)
{
_glthread_LOCK_MUTEX(bmMutex);
BM_CKFATAL(drmBOCreateList(20, list));
_glthread_UNLOCK_MUTEX(bmMutex);
}
void
driBOResetList(drmBOList * list)
{
_glthread_LOCK_MUTEX(bmMutex);
BM_CKFATAL(drmBOResetList(list));
_glthread_UNLOCK_MUTEX(bmMutex);
}
void
driBOAddListItem(drmBOList * list, struct _DriBufferObject *buf,
unsigned flags, unsigned mask)
{
int newItem;
_glthread_LOCK_MUTEX(buf->mutex);
_glthread_LOCK_MUTEX(bmMutex);
BM_CKFATAL(drmAddValidateItem(list, driBOKernel(buf),
flags, mask, &newItem));
_glthread_UNLOCK_MUTEX(bmMutex);
/*
* Tell userspace pools to validate the buffer. This should be a
* noop if the pool is already validated.
* FIXME: We should have a list for this as well.
*/
if (buf->pool->validate) {
BM_CKFATAL(buf->pool->validate(buf->pool, buf->private));
}
_glthread_UNLOCK_MUTEX(buf->mutex);
}
void
driBOFence(struct _DriBufferObject *buf, struct _DriFenceObject *fence)
{
_glthread_LOCK_MUTEX(buf->mutex);
BM_CKFATAL(buf->pool->fence(buf->pool, buf->private, fence));
_glthread_UNLOCK_MUTEX(buf->mutex);
}
void
driBOValidateList(int fd, drmBOList * list)
{
_glthread_LOCK_MUTEX(bmMutex);
BM_CKFATAL(drmBOValidateList(fd, list));
_glthread_UNLOCK_MUTEX(bmMutex);
}
void
driPoolTakeDown(struct _DriBufferPool *pool)
{
pool->takeDown(pool);
}

View File

@@ -0,0 +1,99 @@
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
* 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 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
* THE COPYRIGHT HOLDERS, AUTHORS 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.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
**************************************************************************/
/*
* Authors: Thomas Hellstr<74>m <thomas-at-tungstengraphics-dot-com>
* Keith Whitwell <keithw-at-tungstengraphics-dot-com>
*/
#ifndef _DRI_BUFMGR_H_
#define _DRI_BUFMGR_H_
#include <xf86drm.h>
struct _DriFenceObject;
struct _DriBufferObject;
struct _DriBufferPool;
extern struct _DriFenceObject *driFenceBuffers(int fd, char *name,
unsigned flags);
extern struct _DriFenceObject *driFenceReference(struct _DriFenceObject *fence);
extern void driFenceUnReference(struct _DriFenceObject *fence);
extern void
driFenceFinish(struct _DriFenceObject *fence, unsigned type, int lazy);
extern int driFenceSignaled(struct _DriFenceObject *fence, unsigned type);
extern unsigned driFenceType(struct _DriFenceObject *fence);
/*
* Return a pointer to the libdrm buffer object this DriBufferObject
* uses.
*/
extern drmBO *driBOKernel(struct _DriBufferObject *buf);
extern void *driBOMap(struct _DriBufferObject *buf, unsigned flags,
unsigned hint);
extern void driBOUnmap(struct _DriBufferObject *buf);
extern unsigned long driBOOffset(struct _DriBufferObject *buf);
extern unsigned driBOFlags(struct _DriBufferObject *buf);
extern struct _DriBufferObject *driBOReference(struct _DriBufferObject *buf);
extern void driBOUnReference(struct _DriBufferObject *buf);
extern void driBOData(struct _DriBufferObject *r_buf,
unsigned size, const void *data, unsigned flags);
extern void driBOSubData(struct _DriBufferObject *buf,
unsigned long offset, unsigned long size,
const void *data);
extern void driBOGetSubData(struct _DriBufferObject *buf,
unsigned long offset, unsigned long size,
void *data);
extern void driGenBuffers(struct _DriBufferPool *pool,
const char *name,
unsigned n,
struct _DriBufferObject *buffers[],
unsigned alignment, unsigned flags, unsigned hint);
extern void driDeleteBuffers(unsigned n, struct _DriBufferObject *buffers[]);
extern void driInitBufMgr(int fd);
extern void driBOCreateList(int target, drmBOList * list);
extern void driBOResetList(drmBOList * list);
extern void driBOAddListItem(drmBOList * list, struct _DriBufferObject *buf,
unsigned flags, unsigned mask);
extern void driBOValidateList(int fd, drmBOList * list);
extern void driBOFence(struct _DriBufferObject *buf,
struct _DriFenceObject *fence);
extern void driPoolTakeDown(struct _DriBufferPool *pool);
extern void driBOSetStatic(struct _DriBufferObject *buf,
unsigned long offset,
unsigned long size, void *virtual, unsigned flags);
extern void driBOWaitIdle(struct _DriBufferObject *buf, int lazy);
extern void driPoolTakeDown(struct _DriBufferPool *pool);
#endif

View File

@@ -0,0 +1,86 @@
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
* 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 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
* THE COPYRIGHT HOLDERS, AUTHORS 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.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
**************************************************************************/
/*
* Authors: Thomas Hellstr<74>m <thomas-at-tungstengraphics-dot-com>
*/
#ifndef _DRI_BUFPOOL_H_
#define _DRI_BUFPOOL_H_
#include <xf86drm.h>
struct _DriFenceObject;
typedef struct _DriBufferPool
{
int fd;
int (*map) (struct _DriBufferPool * pool, void *private,
unsigned flags, int hint, void **virtual);
int (*unmap) (struct _DriBufferPool * pool, void *private);
int (*destroy) (struct _DriBufferPool * pool, void *private);
unsigned long (*offset) (struct _DriBufferPool * pool, void *private);
unsigned (*flags) (struct _DriBufferPool * pool, void *private);
unsigned long (*size) (struct _DriBufferPool * pool, void *private);
void *(*create) (struct _DriBufferPool * pool, unsigned long size,
unsigned flags, unsigned hint, unsigned alignment);
int (*fence) (struct _DriBufferPool * pool, void *private,
struct _DriFenceObject * fence);
drmBO *(*kernel) (struct _DriBufferPool * pool, void *private);
int (*validate) (struct _DriBufferPool * pool, void *private);
void *(*setstatic) (struct _DriBufferPool * pool, unsigned long offset,
unsigned long size, void *virtual, unsigned flags);
int (*waitIdle) (struct _DriBufferPool *pool, void *private,
int lazy);
void (*takeDown) (struct _DriBufferPool * pool);
void *data;
} DriBufferPool;
extern void bmError(int val, const char *file, const char *function,
int line);
#define BM_CKFATAL(val) \
do{ \
int tstVal = (val); \
if (tstVal) \
bmError(tstVal, __FILE__, __FUNCTION__, __LINE__); \
} while(0);
/*
* Builtin pools.
*/
/*
* Kernel buffer objects. Size in multiples of page size. Page size aligned.
*/
extern struct _DriBufferPool *driDRMPoolInit(int fd);
extern struct _DriBufferPool *driDRMStaticPoolInit(int fd);
#endif

View File

@@ -0,0 +1,221 @@
/**************************************************************************
*
* Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
* 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 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
* THE COPYRIGHT HOLDERS, AUTHORS 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.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
*
**************************************************************************/
/*
* Authors: Thomas Hellstr<74>m <thomas-at-tungstengraphics-dot-com>
*/
#include <xf86drm.h>
#include <stdlib.h>
#include "dri_bufpool.h"
/*
* Buffer pool implementation using DRM buffer objects as DRI buffer objects.
*/
static void *
pool_create(struct _DriBufferPool *pool,
unsigned long size, unsigned flags, unsigned hint,
unsigned alignment)
{
drmBO *buf = (drmBO *) malloc(sizeof(*buf));
int ret;
if (!buf)
return NULL;
if (alignment && ((4096 % alignment) != 0))
return NULL;
ret = drmBOCreate(pool->fd, NULL, 0, size, NULL, drm_bo_type_dc,
flags, hint, buf);
if (ret) {
free(buf);
return NULL;
}
return (void *) buf;
}
static int
pool_destroy(struct _DriBufferPool *pool, void *private)
{
drmBO *buf = (drmBO *) private;
return drmBODestroy(pool->fd, buf);
}
static int
pool_map(struct _DriBufferPool *pool, void *private, unsigned flags,
int hint, void **virtual)
{
drmBO *buf = (drmBO *) private;
return drmBOMap(pool->fd, buf, flags, hint, virtual);
}
static int
pool_unmap(struct _DriBufferPool *pool, void *private)
{
drmBO *buf = (drmBO *) private;
return drmBOUnmap(pool->fd, buf);
}
static unsigned long
pool_offset(struct _DriBufferPool *pool, void *private)
{
drmBO *buf = (drmBO *) private;
return buf->offset;
}
static unsigned
pool_flags(struct _DriBufferPool *pool, void *private)
{
drmBO *buf = (drmBO *) private;
return buf->flags;
}
static unsigned long
pool_size(struct _DriBufferPool *pool, void *private)
{
drmBO *buf = (drmBO *) private;
return buf->size;
}
static int
pool_fence(struct _DriBufferPool *pool, void *private,
struct _DriFenceObject *fence)
{
/*
* Noop. The kernel handles all fencing.
*/
return 0;
}
static drmBO *
pool_kernel(struct _DriBufferPool *pool, void *private)
{
return (drmBO *) private;
}
static int
pool_waitIdle(struct _DriBufferPool *pool, void *private, int lazy)
{
drmBO *buf = (drmBO *) private;
return drmBOWaitIdle(pool->fd, buf, (lazy) ? DRM_BO_HINT_WAIT_LAZY:0);
}
static void
pool_takedown(struct _DriBufferPool *pool)
{
free(pool);
}
struct _DriBufferPool *
driDRMPoolInit(int fd)
{
struct _DriBufferPool *pool;
pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
if (!pool)
return NULL;
pool->fd = fd;
pool->map = &pool_map;
pool->unmap = &pool_unmap;
pool->destroy = &pool_destroy;
pool->offset = &pool_offset;
pool->flags = &pool_flags;
pool->size = &pool_size;
pool->create = &pool_create;
pool->fence = &pool_fence;
pool->kernel = &pool_kernel;
pool->validate = NULL;
pool->setstatic = NULL;
pool->waitIdle = &pool_waitIdle;
pool->takeDown = &pool_takedown;
pool->data = NULL;
return pool;
}
static void *
pool_setstatic(struct _DriBufferPool *pool, unsigned long offset,
unsigned long size, void *virtual, unsigned flags)
{
drmBO *buf = (drmBO *) malloc(sizeof(*buf));
int ret;
if (!buf)
return NULL;
ret = drmBOCreate(pool->fd, NULL, offset, size, NULL, drm_bo_type_fake,
flags, 0, buf);
if (ret) {
free(buf);
return NULL;
}
buf->virtual = virtual;
return (void *) buf;
}
struct _DriBufferPool *
driDRMStaticPoolInit(int fd)
{
struct _DriBufferPool *pool;
pool = (struct _DriBufferPool *) malloc(sizeof(*pool));
if (!pool)
return NULL;
pool->fd = fd;
pool->map = &pool_map;
pool->unmap = &pool_unmap;
pool->destroy = &pool_destroy;
pool->offset = &pool_offset;
pool->flags = &pool_flags;
pool->size = &pool_size;
pool->create = NULL;
pool->fence = &pool_fence;
pool->kernel = &pool_kernel;
pool->validate = NULL;
pool->setstatic = &pool_setstatic;
pool->waitIdle = &pool_waitIdle;
pool->takeDown = &pool_takedown;
pool->data = NULL;
return pool;
}

View File

@@ -403,8 +403,9 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
__DRIcontextPrivate *pcp = pdp->driContextPriv;
if (!pcp || (pdp != pcp->driDrawablePriv)) {
/* ERROR!!! */
return;
/* ERROR!!!
* ..but we must ignore it. There can be many contexts bound to a drawable.
*/
}
psp = pdp->driScreenPriv;
@@ -435,6 +436,7 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
/* Error -- eg the window may have been destroyed. Keep going
* with no cliprects.
*/
fprintf(stderr, "Drawable destroyed");
pdp->pStamp = &pdp->lastStamp; /* prevent endless loop */
pdp->numClipRects = 0;
pdp->pClipRects = NULL;
@@ -841,7 +843,7 @@ static void driDestroyScreen(__DRInativeDisplay *dpy, int scrn, void *screenPriv
(void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
(void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
_mesa_free(psp->pDevPriv);
(void)drmClose(psp->fd);
(void)drmCloseOnce(psp->fd);
if ( psp->modes != NULL ) {
(*dri_interface->destroyContextModes)( psp->modes );
}

View File

@@ -87,15 +87,15 @@ typedef struct __DRIutilversionRec2 __DRIutilversion2;
#define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp) \
do { \
while (*(pdp->pStamp) != pdp->lastStamp) { \
DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, \
pdp->driContextPriv->hHWContext); \
register unsigned int hwContext = psp->pSAREA->lock.lock & \
~(DRM_LOCK_HELD | DRM_LOCK_CONT); \
DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, hwContext); \
\
DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
\
DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, \
pdp->driContextPriv->hHWContext); \
DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, hwContext); \
} \
} while (0)

File diff suppressed because it is too large Load Diff

View File

@@ -309,17 +309,15 @@ void driInitSingleExtension( GLcontext * ctx,
/* Add each entry-point to the dispatch table.
*/
offset = _glapi_add_dispatch( functions, parameter_signature );
if (offset == -1) {
fprintf(stderr, "DISPATCH ERROR! _glapi_add_dispatch failed "
"to add %s!\n", functions[0]);
if ( ext->functions[i].remap_index != -1 ) {
driDispatchRemapTable[ ext->functions[i].remap_index ] = offset;
}
else if (ext->functions[i].remap_index != -1) {
driDispatchRemapTable[ ext->functions[i].remap_index ] =
offset;
}
else if (ext->functions[i].offset != offset) {
fprintf(stderr, "DISPATCH ERROR! %s -> %u != %u\n",
functions[0], offset, ext->functions[i].offset);
if ( (ext->functions[i].offset != -1)
&& (ext->functions[i].offset != offset) ) {
fprintf(stderr, "DISPATCH ERROR! %s -> %u != %u\n", functions[0],
driDispatchRemapTable[ ext->functions[i].remap_index ],
ext->functions[i].offset);
}
}
}
@@ -421,6 +419,19 @@ driCheckDriDdxDrmVersions2(const char * driver_name,
GLint
driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 )
{
if (rect2.x1 > rect1.x1) rect1.x1 = rect2.x1;
if (rect2.x2 < rect1.x2) rect1.x2 = rect2.x2;
if (rect2.y1 > rect1.y1) rect1.y1 = rect2.y1;
if (rect2.y2 < rect1.y2) rect1.y2 = rect2.y2;
if (rect1.x1 > rect1.x2 || rect1.y1 > rect1.y2) return 0;
return (rect1.x2 - rect1.x1) * (rect1.y2 - rect1.y1);
}
GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
GLint *x, GLint *y,
GLsizei *width, GLsizei *height )

View File

@@ -106,6 +106,8 @@ extern GLboolean driCheckDriDdxDrmVersions3(const char * driver_name,
const __DRIversion * ddxActual, const __DRIutilversion2 * ddxExpected,
const __DRIversion * drmActual, const __DRIversion * drmExpected);
extern GLint driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 );
extern GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
GLint *x, GLint *y,
GLsizei *width, GLsizei *height );

View File

@@ -208,20 +208,6 @@ GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache )
}
/****************************************************************************/
/**
* Sets the default swap interval when the drawable is first bound to a
* direct rendering context.
*/
void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags )
{
if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
priv->pdraw->swap_interval = (flags & VBLANK_FLAG_THROTTLE) != 0 ? 1 : 0;
}
}
/****************************************************************************/
/**
* Wrapper to call \c drmWaitVBlank. The main purpose of this function is to
@@ -260,6 +246,71 @@ static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd )
}
/****************************************************************************/
/**
* Sets the default swap interval when the drawable is first bound to a
* direct rendering context.
*/
void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags,
GLuint *vbl_seq )
{
if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
/* Get current vertical blank sequence */
drmVBlank vbl = { .request={ .type = DRM_VBLANK_RELATIVE, .sequence = 0 } };
do_wait( &vbl, vbl_seq, priv->driScreenPriv->fd );
priv->pdraw->swap_interval = (flags & (VBLANK_FLAG_THROTTLE |
VBLANK_FLAG_SYNC)) != 0 ? 1 : 0;
}
}
/****************************************************************************/
/**
* Returns the current swap interval of the given drawable.
*/
unsigned
driGetVBlankInterval( const __DRIdrawablePrivate *priv, GLuint flags )
{
if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
/* this must have been initialized when the drawable was first bound
* to a direct rendering context. */
assert ( priv->pdraw->swap_interval != (unsigned)-1 );
return priv->pdraw->swap_interval;
}
else if ( (flags & (VBLANK_FLAG_THROTTLE | VBLANK_FLAG_SYNC)) != 0 ) {
return 1;
}
else {
return 0;
}
}
/****************************************************************************/
/**
* Returns the current vertical blank sequence number of the given drawable.
*/
void
driGetCurrentVBlank( const __DRIdrawablePrivate *priv, GLuint flags,
GLuint *vbl_seq )
{
drmVBlank vbl;
vbl.request.type = DRM_VBLANK_RELATIVE;
if ( flags & VBLANK_FLAG_SECONDARY ) {
vbl.request.type |= DRM_VBLANK_SECONDARY;
}
vbl.request.sequence = 0;
(void) do_wait( &vbl, vbl_seq, priv->driScreenPriv->fd );
}
/****************************************************************************/
/**
* Waits for the vertical blank for use with glXSwapBuffers.
@@ -282,7 +333,7 @@ driWaitForVBlank( const __DRIdrawablePrivate *priv, GLuint * vbl_seq,
unsigned original_seq;
unsigned deadline;
unsigned interval;
unsigned diff;
*missed_deadline = GL_FALSE;
if ( (flags & (VBLANK_FLAG_INTERVAL |
@@ -304,44 +355,40 @@ driWaitForVBlank( const __DRIdrawablePrivate *priv, GLuint * vbl_seq,
*/
original_seq = *vbl_seq;
interval = driGetVBlankInterval(priv, flags);
deadline = original_seq + interval;
vbl.request.sequence = ((flags & VBLANK_FLAG_SYNC) != 0) ? 1 : 0;
vbl.request.type = DRM_VBLANK_RELATIVE;
if ( flags & VBLANK_FLAG_SECONDARY ) {
vbl.request.type |= DRM_VBLANK_SECONDARY;
}
vbl.request.sequence = ((flags & VBLANK_FLAG_SYNC) != 0) ? 1 : 0;
if ( do_wait( & vbl, vbl_seq, priv->driScreenPriv->fd ) != 0 ) {
return -1;
}
diff = *vbl_seq - deadline;
/* No need to wait again if we've already reached the target */
if (diff <= (1 << 23)) {
*missed_deadline = (flags & VBLANK_FLAG_SYNC) ? (diff > 0) : GL_TRUE;
return 0;
}
/* Wait until the target vertical blank. */
vbl.request.type = DRM_VBLANK_ABSOLUTE;
if ( flags & VBLANK_FLAG_SECONDARY ) {
vbl.request.type |= DRM_VBLANK_SECONDARY;
}
vbl.request.sequence = deadline;
if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
interval = priv->pdraw->swap_interval;
/* this must have been initialized when the drawable was first bound
* to a direct rendering context. */
assert ( interval != (unsigned)-1 );
}
else if ( (flags & VBLANK_FLAG_THROTTLE) != 0 ) {
interval = 1;
}
else {
interval = 0;
if ( do_wait( & vbl, vbl_seq, priv->driScreenPriv->fd ) != 0 ) {
return -1;
}
/* Wait until the next vertical blank. If the interval is zero, then
* the deadline is one vertical blank after the previous wait.
*/
vbl.request.sequence = original_seq + interval;
if ( *vbl_seq < vbl.request.sequence ) {
if ( do_wait( & vbl, vbl_seq, priv->driScreenPriv->fd ) != 0 ) {
return -1;
}
}
deadline = original_seq + ((interval == 0) ? 1 : interval);
*missed_deadline = ( *vbl_seq > deadline );
diff = *vbl_seq - deadline;
*missed_deadline = diff > 0 && diff <= (1 << 23);
return 0;
}

View File

@@ -42,12 +42,19 @@
*/
#define VBLANK_FLAG_NO_IRQ (1U << 7) /* DRM has no IRQ to wait on.
*/
#define VBLANK_FLAG_SECONDARY (1U << 8) /* Wait for secondary vblank.
*/
extern int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count );
extern int driWaitForMSC32( __DRIdrawablePrivate *priv,
int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc );
extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache );
extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv, GLuint flags );
extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv, GLuint flags,
GLuint *vbl_seq );
extern unsigned driGetVBlankInterval( const __DRIdrawablePrivate *priv,
GLuint flags );
extern void driGetCurrentVBlank( const __DRIdrawablePrivate *priv,
GLuint flags, GLuint *vbl_seq );
extern int driWaitForVBlank( const __DRIdrawablePrivate *priv,
GLuint * vbl_seq, GLuint flags, GLboolean * missed_deadline );

View File

@@ -7,16 +7,6 @@ LIBNAME = i915_dri.so
MINIGLX_SOURCES = server/intel_dri.c
DRIVER_SOURCES = \
i915_context.c \
i915_debug.c \
i915_fragprog.c \
i915_metaops.c \
i915_program.c \
i915_state.c \
i915_tex.c \
i915_texprog.c \
i915_texstate.c \
i915_vtbl.c \
i830_context.c \
i830_metaops.c \
i830_state.c \
@@ -24,19 +14,43 @@ DRIVER_SOURCES = \
i830_tex.c \
i830_texstate.c \
i830_vtbl.c \
intel_render.c \
intel_regions.c \
intel_buffer_objects.c \
intel_batchbuffer.c \
intel_mipmap_tree.c \
i915_tex_layout.c \
intel_tex_image.c \
intel_tex_subimage.c \
intel_tex_copy.c \
intel_tex_validate.c \
intel_tex_format.c \
intel_tex.c \
intel_pixel.c \
intel_pixel_copy.c \
intel_pixel_read.c \
intel_pixel_draw.c \
intel_buffers.c \
intel_blit.c \
i915_tex.c \
i915_texstate.c \
i915_context.c \
i915_debug.c \
i915_fragprog.c \
i915_metaops.c \
i915_program.c \
i915_state.c \
i915_vtbl.c \
intel_context.c \
intel_ioctl.c \
intel_pixel.c \
intel_render.c \
intel_rotate.c \
intel_screen.c \
intel_span.c \
intel_state.c \
intel_tex.c \
intel_texmem.c \
intel_tris.c
intel_tris.c \
intel_fbo.c \
intel_depthstencil.c \
intel_batchpool.c
C_SOURCES = \
$(COMMON_SOURCES) \
$(DRIVER_SOURCES)

View File

@@ -38,37 +38,38 @@
* Mesa's Driver Functions
***************************************/
static const struct dri_extension i830_extensions[] =
{
{ "GL_ARB_texture_env_crossbar", NULL },
{ NULL, NULL }
static const struct dri_extension i830_extensions[] = {
{"GL_ARB_texture_env_crossbar", NULL},
{NULL, NULL}
};
static void i830InitDriverFunctions( struct dd_function_table *functions )
static void
i830InitDriverFunctions(struct dd_function_table *functions)
{
intelInitDriverFunctions( functions );
i830InitStateFuncs( functions );
i830InitTextureFuncs( functions );
intelInitDriverFunctions(functions);
i830InitStateFuncs(functions);
i830InitTextureFuncs(functions);
}
GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
GLboolean
i830CreateContext(const __GLcontextModes * mesaVis,
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate)
{
struct dd_function_table functions;
i830ContextPtr i830 = (i830ContextPtr) CALLOC_STRUCT(i830_context);
intelContextPtr intel = &i830->intel;
struct i830_context *i830 = CALLOC_STRUCT(i830_context);
struct intel_context *intel = &i830->intel;
GLcontext *ctx = &intel->ctx;
GLuint i;
if (!i830) return GL_FALSE;
if (!i830)
return GL_FALSE;
i830InitVtbl( i830 );
i830InitDriverFunctions( &functions );
i830InitVtbl(i830);
i830InitDriverFunctions(&functions);
if (!intelInitContext( intel, mesaVis, driContextPriv,
sharedContextPrivate, &functions )) {
if (!intelInitContext(intel, mesaVis, driContextPriv,
sharedContextPrivate, &functions)) {
FREE(i830);
return GL_FALSE;
}
@@ -77,48 +78,27 @@ GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
intel->ctx.Const.MaxTextureImageUnits = I830_TEX_UNITS;
intel->ctx.Const.MaxTextureCoordUnits = I830_TEX_UNITS;
intel->nr_heaps = 1;
intel->texture_heaps[0] =
driCreateTextureHeap( 0, intel,
intel->intelScreen->tex.size,
12,
I830_NR_TEX_REGIONS,
intel->sarea->texList,
(unsigned *) & intel->sarea->texAge,
& intel->swapped,
sizeof( struct i830_texture_object ),
(destroy_texture_object_t *)intelDestroyTexObj );
/* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are tightly
* FIXME: packed, but they're not in Intel graphics hardware.
/* Advertise the full hardware capabilities. The new memory
* manager should cope much better with overload situations:
*/
intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS;
i = driQueryOptioni( &intel->intelScreen->optionCache, "allow_large_textures");
driCalculateMaxTextureLevels( intel->texture_heaps,
intel->nr_heaps,
&intel->ctx.Const,
4,
11, /* max 2D texture size is 2048x2048 */
8, /* max 3D texture size is 256^3 */
10, /* max CUBE texture size is 1024x1024 */
11, /* max RECT. supported */
12,
GL_FALSE,
i );
ctx->Const.MaxTextureLevels = 12;
ctx->Const.Max3DTextureLevels = 9;
ctx->Const.MaxCubeTextureLevels = 11;
ctx->Const.MaxTextureRectSize = (1 << 11);
ctx->Const.MaxTextureUnits = I830_TEX_UNITS;
_tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
18 * sizeof(GLfloat) );
_tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
18 * sizeof(GLfloat));
intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
driInitExtensions( ctx, i830_extensions, GL_FALSE );
driInitExtensions(ctx, i830_extensions, GL_FALSE);
i830InitState( i830 );
i830InitState(i830);
i830InitMetaFuncs(i830);
_tnl_allow_vertex_fog( ctx, 1 );
_tnl_allow_pixel_fog( ctx, 0 );
_tnl_allow_vertex_fog(ctx, 1);
_tnl_allow_pixel_fog(ctx, 0);
return GL_TRUE;
}

View File

@@ -49,17 +49,15 @@
*/
#define I830_DESTREG_CBUFADDR0 0
#define I830_DESTREG_CBUFADDR1 1
#define I830_DESTREG_CBUFADDR2 2
#define I830_DESTREG_DBUFADDR0 3
#define I830_DESTREG_DBUFADDR1 4
#define I830_DESTREG_DBUFADDR2 5
#define I830_DESTREG_DV0 6
#define I830_DESTREG_DV1 7
#define I830_DESTREG_SENABLE 8
#define I830_DESTREG_SR0 9
#define I830_DESTREG_SR1 10
#define I830_DESTREG_SR2 11
#define I830_DEST_SETUP_SIZE 12
#define I830_DESTREG_DBUFADDR0 2
#define I830_DESTREG_DBUFADDR1 3
#define I830_DESTREG_DV0 4
#define I830_DESTREG_DV1 5
#define I830_DESTREG_SENABLE 6
#define I830_DESTREG_SR0 7
#define I830_DESTREG_SR1 8
#define I830_DESTREG_SR2 9
#define I830_DEST_SETUP_SIZE 10
#define I830_CTXREG_STATE1 0
#define I830_CTXREG_STATE2 1
@@ -73,7 +71,7 @@
#define I830_CTXREG_AA 9
#define I830_CTXREG_FOGCOLOR 10
#define I830_CTXREG_BLENDCOLOR0 11
#define I830_CTXREG_BLENDCOLOR1 12
#define I830_CTXREG_BLENDCOLOR1 12
#define I830_CTXREG_VF 13
#define I830_CTXREG_VF2 14
#define I830_CTXREG_MCSB0 15
@@ -84,17 +82,16 @@
#define I830_STPREG_ST1 1
#define I830_STP_SETUP_SIZE 2
#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
#define I830_TEXREG_TM0S0 1
#define I830_TEXREG_TM0S1 2
#define I830_TEXREG_TM0S2 3
#define I830_TEXREG_TM0S3 4
#define I830_TEXREG_TM0S4 5
#define I830_TEXREG_MCS 6 /* _3DSTATE_MAP_COORD_SETS */
#define I830_TEXREG_CUBE 7 /* _3DSTATE_MAP_SUBE */
#define I830_TEX_SETUP_SIZE 8
#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
#define I830_TEXREG_TM0S1 1
#define I830_TEXREG_TM0S2 2
#define I830_TEXREG_TM0S3 3
#define I830_TEXREG_TM0S4 4
#define I830_TEXREG_MCS 5 /* _3DSTATE_MAP_COORD_SETS */
#define I830_TEXREG_CUBE 6 /* _3DSTATE_MAP_SUBE */
#define I830_TEX_SETUP_SIZE 7
#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
struct i830_texture_object
{
@@ -104,30 +101,39 @@ struct i830_texture_object
#define I830_TEX_UNITS 4
struct i830_hw_state {
struct i830_hw_state
{
GLuint Ctx[I830_CTX_SETUP_SIZE];
GLuint Buffer[I830_DEST_SETUP_SIZE];
GLuint Stipple[I830_STP_SETUP_SIZE];
GLuint Tex[I830_TEX_UNITS][I830_TEX_SETUP_SIZE];
GLuint TexBlend[I830_TEX_UNITS][I830_TEXBLEND_SIZE];
GLuint TexBlendWordsUsed[I830_TEX_UNITS];
GLuint emitted; /* I810_UPLOAD_* */
struct intel_region *draw_region;
struct intel_region *depth_region;
/* Regions aren't actually that appropriate here as the memory may
* be from a PBO or FBO. Just use the buffer id. Will have to do
* this for draw and depth for FBO's...
*/
struct _DriBufferObject *tex_buffer[I830_TEX_UNITS];
GLuint tex_offset[I830_TEX_UNITS];
GLuint emitted; /* I810_UPLOAD_* */
GLuint active;
};
struct i830_context
struct i830_context
{
struct intel_context intel;
DECLARE_RENDERINPUTS(last_index_bitset);
GLuint lodbias_tm0s3[MAX_TEXTURE_UNITS];
DECLARE_RENDERINPUTS(last_index_bitset);
struct i830_hw_state meta, initial, state, *current;
};
typedef struct i830_context *i830ContextPtr;
typedef struct i830_texture_object *i830TextureObjectPtr;
#define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx))
@@ -148,71 +154,55 @@ do { \
/* i830_vtbl.c
*/
extern void
i830InitVtbl( i830ContextPtr i830 );
extern void i830InitVtbl(struct i830_context *i830);
/* i830_context.c
*/
extern GLboolean
i830CreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate);
extern GLboolean
i830CreateContext(const __GLcontextModes * mesaVis,
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate);
/* i830_tex.c, i830_texstate.c
*/
extern void
i830UpdateTextureState( intelContextPtr intel );
extern void i830UpdateTextureState(struct intel_context *intel);
extern void
i830InitTextureFuncs( struct dd_function_table *functions );
extern intelTextureObjectPtr
i830AllocTexObj( struct gl_texture_object *tObj );
extern void i830InitTextureFuncs(struct dd_function_table *functions);
/* i830_texblend.c
*/
extern GLuint i830SetTexEnvCombine(i830ContextPtr i830,
const struct gl_tex_env_combine_state * combine, GLint blendUnit,
GLuint texel_op, GLuint *state, const GLfloat *factor );
extern GLuint i830SetTexEnvCombine(struct i830_context *i830,
const struct gl_tex_env_combine_state
*combine, GLint blendUnit, GLuint texel_op,
GLuint * state, const GLfloat * factor);
extern void
i830EmitTextureBlend( i830ContextPtr i830 );
extern void i830EmitTextureBlend(struct i830_context *i830);
/* i830_state.c
*/
extern void
i830InitStateFuncs( struct dd_function_table *functions );
extern void i830InitStateFuncs(struct dd_function_table *functions);
extern void
i830EmitState( i830ContextPtr i830 );
extern void i830EmitState(struct i830_context *i830);
extern void
i830InitState( i830ContextPtr i830 );
extern void i830InitState(struct i830_context *i830);
/* i830_metaops.c
*/
extern GLboolean
i830TryTextureReadPixels( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *pack,
GLvoid *pixels );
extern GLboolean
i830TryTextureDrawPixels( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels );
extern void
i830ClearWithTris( intelContextPtr intel, GLbitfield mask,
GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch);
extern void i830InitMetaFuncs(struct i830_context *i830);
extern void
i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
i830RotateWindow(struct intel_context *intel, __DRIdrawablePrivate * dPriv,
GLuint srcBuf);
#endif
/*======================================================================
* Inline conversion functions. These are better-typed than the
* macros used previously:
*/
static INLINE struct i830_context *
i830_context(GLcontext * ctx)
{
return (struct i830_context *) ctx;
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -407,7 +407,7 @@
#define LOGICOP_SET 0xf
#define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00))
#define ENABLE_STENCIL_TEST_MASK (1<<17)
#define STENCIL_TEST_MASK(x) ((x)<<8)
#define STENCIL_TEST_MASK(x) (((x)&0xff)<<8)
#define MODE4_ENABLE_STENCIL_WRITE_MASK ((1<<16)|(0x00ff))
#define ENABLE_STENCIL_WRITE_MASK (1<<16)
#define STENCIL_WRITE_MASK(x) ((x)&0xff)
@@ -554,8 +554,8 @@
#define MAPSURF_4BIT_INDEXED (7<<6)
#define TM0S1_MT_FORMAT_MASK (0x7 << 3)
#define TM0S1_MT_FORMAT_SHIFT 3
#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
#define MT_8BIT_IDX_RGB565 (0<<3) /* SURFACE_8BIT_INDEXED */
#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
#define MT_8BIT_IDX_RGB565 (0<<3) /* SURFACE_8BIT_INDEXED */
#define MT_8BIT_IDX_ARGB1555 (1<<3)
#define MT_8BIT_IDX_ARGB4444 (2<<3)
#define MT_8BIT_IDX_AY88 (3<<3)
@@ -563,9 +563,9 @@
#define MT_8BIT_IDX_BUMP_88DVDU (5<<3)
#define MT_8BIT_IDX_BUMP_655LDVDU (6<<3)
#define MT_8BIT_IDX_ARGB8888 (7<<3)
#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
#define MT_8BIT_L8 (1<<3)
#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
#define MT_16BIT_ARGB1555 (1<<3)
#define MT_16BIT_ARGB4444 (2<<3)
#define MT_16BIT_AY88 (3<<3)
@@ -573,16 +573,16 @@
#define MT_16BIT_BUMP_88DVDU (5<<3)
#define MT_16BIT_BUMP_655LDVDU (6<<3)
#define MT_16BIT_DIB_RGB565_8888 (7<<3)
#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
#define MT_32BIT_ABGR8888 (1<<3)
#define MT_32BIT_BUMP_XLDVDU_8888 (6<<3)
#define MT_32BIT_DIB_8888 (7<<3)
#define MT_411_YUV411 (0<<3) /* SURFACE_411 */
#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
#define MT_411_YUV411 (0<<3) /* SURFACE_411 */
#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
#define MT_422_YCRCB_NORMAL (1<<3)
#define MT_422_YCRCB_SWAPUV (2<<3)
#define MT_422_YCRCB_SWAPUVY (3<<3)
#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
#define MT_COMPRESS_DXT2_3 (1<<3)
#define MT_COMPRESS_DXT4_5 (2<<3)
#define MT_COMPRESS_FXT1 (3<<3)

File diff suppressed because it is too large Load Diff

View File

@@ -45,261 +45,13 @@
/**
* Set the texture wrap modes.
*
* The i830M (and related graphics cores) do not support GL_CLAMP. The Intel
* drivers for "other operating systems" implement GL_CLAMP as
* GL_CLAMP_TO_EDGE, so the same is done here.
*
* \param t Texture object whose wrap modes are to be set
* \param swrap Wrap mode for the \a s texture coordinate
* \param twrap Wrap mode for the \a t texture coordinate
*/
static void i830SetTexWrapping(i830TextureObjectPtr tex,
GLenum swrap,
GLenum twrap)
static void
i830TexEnv(GLcontext * ctx, GLenum target,
GLenum pname, const GLfloat * param)
{
tex->Setup[I830_TEXREG_MCS] &= ~(TEXCOORD_ADDR_U_MASK|TEXCOORD_ADDR_V_MASK);
switch( swrap ) {
case GL_REPEAT:
tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP);
break;
case GL_CLAMP:
case GL_CLAMP_TO_EDGE:
tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP);
break;
case GL_CLAMP_TO_BORDER:
tex->Setup[I830_TEXREG_MCS] |=
TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP_BORDER);
break;
case GL_MIRRORED_REPEAT:
tex->Setup[I830_TEXREG_MCS] |=
TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_MIRROR);
break;
default:
break;
}
switch( twrap ) {
case GL_REPEAT:
tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP);
break;
case GL_CLAMP:
case GL_CLAMP_TO_EDGE:
tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP);
break;
case GL_CLAMP_TO_BORDER:
tex->Setup[I830_TEXREG_MCS] |=
TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP_BORDER);
break;
case GL_MIRRORED_REPEAT:
tex->Setup[I830_TEXREG_MCS] |=
TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_MIRROR);
break;
default:
break;
}
}
/**
* Set the texture magnification and minification modes.
*
* \param t Texture whose filter modes are to be set
* \param minf Texture minification mode
* \param magf Texture magnification mode
* \param bias LOD bias for this texture unit.
*/
static void i830SetTexFilter( i830TextureObjectPtr t, GLenum minf, GLenum magf,
GLfloat maxanisotropy )
{
int minFilt = 0, mipFilt = 0, magFilt = 0;
if(INTEL_DEBUG&DEBUG_DRI)
fprintf(stderr, "%s\n", __FUNCTION__);
if ( maxanisotropy > 1.0 ) {
minFilt = FILTER_ANISOTROPIC;
magFilt = FILTER_ANISOTROPIC;
}
else {
switch (minf) {
case GL_NEAREST:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_NONE;
break;
case GL_LINEAR:
minFilt = FILTER_LINEAR;
mipFilt = MIPFILTER_NONE;
break;
case GL_NEAREST_MIPMAP_NEAREST:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_NEAREST;
break;
case GL_LINEAR_MIPMAP_NEAREST:
minFilt = FILTER_LINEAR;
mipFilt = MIPFILTER_NEAREST;
break;
case GL_NEAREST_MIPMAP_LINEAR:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_LINEAR;
break;
case GL_LINEAR_MIPMAP_LINEAR:
minFilt = FILTER_LINEAR;
mipFilt = MIPFILTER_LINEAR;
break;
default:
break;
}
switch (magf) {
case GL_NEAREST:
magFilt = FILTER_NEAREST;
break;
case GL_LINEAR:
magFilt = FILTER_LINEAR;
break;
default:
break;
}
}
t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_FILTER_MASK;
t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIP_FILTER_MASK;
t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAG_FILTER_MASK;
t->Setup[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
(mipFilt << TM0S3_MIP_FILTER_SHIFT) |
(magFilt << TM0S3_MAG_FILTER_SHIFT));
}
static void i830SetTexBorderColor(i830TextureObjectPtr t, GLubyte color[4])
{
if(INTEL_DEBUG&DEBUG_DRI)
fprintf(stderr, "%s\n", __FUNCTION__);
t->Setup[I830_TEXREG_TM0S4] =
INTEL_PACKCOLOR8888(color[0],color[1],color[2],color[3]);
}
/**
* Allocate space for and load the mesa images into the texture memory block.
* This will happen before drawing with a new texture, or drawing with a
* texture after it was swapped out or teximaged again.
*/
intelTextureObjectPtr i830AllocTexObj( struct gl_texture_object *texObj )
{
i830TextureObjectPtr t = CALLOC_STRUCT( i830_texture_object );
if ( !t )
return NULL;
texObj->DriverData = t;
t->intel.base.tObj = texObj;
t->intel.dirty = I830_UPLOAD_TEX_ALL;
make_empty_list( &t->intel.base );
t->Setup[I830_TEXREG_TM0LI] = 0; /* not used */
t->Setup[I830_TEXREG_TM0S0] = 0;
t->Setup[I830_TEXREG_TM0S1] = 0;
t->Setup[I830_TEXREG_TM0S2] = 0;
t->Setup[I830_TEXREG_TM0S3] = 0;
t->Setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
MAP_UNIT(0) |
ENABLE_TEXCOORD_PARAMS |
TEXCOORDS_ARE_NORMAL |
TEXCOORDTYPE_CARTESIAN |
ENABLE_ADDR_V_CNTL |
TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) |
ENABLE_ADDR_U_CNTL |
TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));
i830SetTexWrapping( t, texObj->WrapS, texObj->WrapT );
i830SetTexFilter( t, texObj->MinFilter, texObj->MagFilter,
texObj->MaxAnisotropy );
i830SetTexBorderColor( t, texObj->_BorderChan );
return &t->intel;
}
static void i830TexParameter( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj,
GLenum pname, const GLfloat *params )
{
i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
if (!t)
return;
switch (pname) {
case GL_TEXTURE_MIN_FILTER:
case GL_TEXTURE_MAG_FILTER:
case GL_TEXTURE_MAX_ANISOTROPY_EXT:
i830SetTexFilter( t, tObj->MinFilter, tObj->MagFilter,
tObj->MaxAnisotropy);
break;
case GL_TEXTURE_WRAP_S:
case GL_TEXTURE_WRAP_T:
i830SetTexWrapping( t, tObj->WrapS, tObj->WrapT );
break;
case GL_TEXTURE_BORDER_COLOR:
i830SetTexBorderColor( t, tObj->_BorderChan );
break;
case GL_TEXTURE_BASE_LEVEL:
case GL_TEXTURE_MAX_LEVEL:
case GL_TEXTURE_MIN_LOD:
case GL_TEXTURE_MAX_LOD:
/* The i830 and its successors can do a lot of this without
* reloading the textures. A project for someone?
*/
intelFlush( ctx );
driSwapOutTextureObject( (driTextureObject *) t );
break;
default:
return;
}
t->intel.dirty = I830_UPLOAD_TEX_ALL;
}
static void i830TexEnv( GLcontext *ctx, GLenum target,
GLenum pname, const GLfloat *param )
{
i830ContextPtr i830 = I830_CONTEXT( ctx );
GLuint unit = ctx->Texture.CurrentUnit;
switch (pname) {
case GL_TEXTURE_ENV_COLOR:
#if 0
{
GLubyte r, g, b, a;
GLuint col;
UNCLAMPED_FLOAT_TO_UBYTE(r, param[RCOMP]);
UNCLAMPED_FLOAT_TO_UBYTE(g, param[GCOMP]);
UNCLAMPED_FLOAT_TO_UBYTE(b, param[BCOMP]);
UNCLAMPED_FLOAT_TO_UBYTE(a, param[ACOMP]);
col = ((a << 24) | (r << 16) | (g << 8) | b);
if (col != i830->state.TexEnv[unit][I830_TEXENVREG_COL1]) {
I830_STATECHANGE(i830, I830_UPLOAD_TEXENV);
i830->state.TexEnv[unit][I830_TEXENVREG_COL1] = col;
}
break;
}
#endif
case GL_TEXTURE_ENV_COLOR:
case GL_TEXTURE_ENV_MODE:
case GL_COMBINE_RGB:
case GL_COMBINE_ALPHA:
@@ -319,38 +71,30 @@ static void i830TexEnv( GLcontext *ctx, GLenum target,
case GL_ALPHA_SCALE:
break;
case GL_TEXTURE_LOD_BIAS: {
int b = (int) ((*param) * 16.0);
if (b > 63) b = 63;
if (b < -64) b = -64;
I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
i830->state.Tex[unit][I830_TEXREG_TM0S3] &= ~TM0S3_LOD_BIAS_MASK;
i830->state.Tex[unit][I830_TEXREG_TM0S3] |=
((b << TM0S3_LOD_BIAS_SHIFT) & TM0S3_LOD_BIAS_MASK);
break;
}
case GL_TEXTURE_LOD_BIAS:{
struct i830_context *i830 = i830_context(ctx);
GLuint unit = ctx->Texture.CurrentUnit;
int b = (int) ((*param) * 16.0);
if (b > 63)
b = 63;
if (b < -64)
b = -64;
I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
i830->lodbias_tm0s3[unit] =
((b << TM0S3_LOD_BIAS_SHIFT) & TM0S3_LOD_BIAS_MASK);
break;
}
default:
break;
}
}
static void i830BindTexture( GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj )
void
i830InitTextureFuncs(struct dd_function_table *functions)
{
i830TextureObjectPtr tex;
if (!texObj->DriverData)
i830AllocTexObj( texObj );
tex = (i830TextureObjectPtr)texObj->DriverData;
}
void i830InitTextureFuncs( struct dd_function_table *functions )
{
functions->BindTexture = i830BindTexture;
functions->TexEnv = i830TexEnv;
functions->TexParameter = i830TexParameter;
functions->TexEnv = i830TexEnv;
}

View File

@@ -46,46 +46,42 @@
/* ================================================================
* Texture combine functions
*/
static GLuint pass_through( GLuint *state, GLuint blendUnit )
static GLuint
pass_through(GLuint * state, GLuint blendUnit)
{
state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
TEXPIPE_COLOR |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT |
DISABLE_TEX_CNTRL_STAGE |
TEXOP_SCALE_1X |
TEXOP_MODIFY_PARMS |
TEXBLENDOP_ARG1);
TEXPIPE_COLOR |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT |
DISABLE_TEX_CNTRL_STAGE |
TEXOP_SCALE_1X | TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1);
state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
TEXPIPE_ALPHA |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT |
TEXOP_SCALE_1X |
TEXOP_MODIFY_PARMS |
TEXBLENDOP_ARG1);
TEXPIPE_ALPHA |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT |
TEXOP_SCALE_1X | TEXOP_MODIFY_PARMS | TEXBLENDOP_ARG1);
state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
TEXPIPE_COLOR |
TEXBLEND_ARG1 |
TEXBLENDARG_MODIFY_PARMS |
TEXBLENDARG_CURRENT);
TEXPIPE_COLOR |
TEXBLEND_ARG1 |
TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_CURRENT);
state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
TEXPIPE_ALPHA |
TEXBLEND_ARG1 |
TEXBLENDARG_MODIFY_PARMS |
TEXBLENDARG_CURRENT);
TEXPIPE_ALPHA |
TEXBLEND_ARG1 |
TEXBLENDARG_MODIFY_PARMS | TEXBLENDARG_CURRENT);
return 4;
}
static GLuint emit_factor( GLuint blendUnit, GLuint *state, GLuint count,
const GLfloat *factor )
static GLuint
emit_factor(GLuint blendUnit, GLuint * state, GLuint count,
const GLfloat * factor)
{
GLubyte r, g, b, a;
GLuint col;
if (0)
fprintf(stderr, "emit constant %d: %.2f %.2f %.2f %.2f\n",
blendUnit, factor[0], factor[1], factor[2], factor[3]);
blendUnit, factor[0], factor[1], factor[2], factor[3]);
UNCLAMPED_FLOAT_TO_UBYTE(r, factor[0]);
UNCLAMPED_FLOAT_TO_UBYTE(g, factor[1]);
@@ -94,21 +90,27 @@ static GLuint emit_factor( GLuint blendUnit, GLuint *state, GLuint count,
col = ((a << 24) | (r << 16) | (g << 8) | b);
state[count++] = _3DSTATE_COLOR_FACTOR_N_CMD(blendUnit);
state[count++] = _3DSTATE_COLOR_FACTOR_N_CMD(blendUnit);
state[count++] = col;
return count;
}
static __inline__ GLuint GetTexelOp(GLint unit)
static INLINE GLuint
GetTexelOp(GLint unit)
{
switch(unit) {
case 0: return TEXBLENDARG_TEXEL0;
case 1: return TEXBLENDARG_TEXEL1;
case 2: return TEXBLENDARG_TEXEL2;
case 3: return TEXBLENDARG_TEXEL3;
default: return TEXBLENDARG_TEXEL0;
switch (unit) {
case 0:
return TEXBLENDARG_TEXEL0;
case 1:
return TEXBLENDARG_TEXEL1;
case 2:
return TEXBLENDARG_TEXEL2;
case 3:
return TEXBLENDARG_TEXEL3;
default:
return TEXBLENDARG_TEXEL0;
}
}
@@ -132,12 +134,10 @@ static __inline__ GLuint GetTexelOp(GLint unit)
* partial support for the extension?
*/
GLuint
i830SetTexEnvCombine(i830ContextPtr i830,
const struct gl_tex_env_combine_state * combine,
GLint blendUnit,
GLuint texel_op,
GLuint *state,
const GLfloat *factor )
i830SetTexEnvCombine(struct i830_context * i830,
const struct gl_tex_env_combine_state * combine,
GLint blendUnit,
GLuint texel_op, GLuint * state, const GLfloat * factor)
{
const GLuint numColorArgs = combine->_NumArgsRGB;
const GLuint numAlphaArgs = combine->_NumArgsA;
@@ -162,7 +162,7 @@ i830SetTexEnvCombine(i830ContextPtr i830,
TEXPIPE_ALPHA | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
};
if(INTEL_DEBUG&DEBUG_TEXTURE)
if (INTEL_DEBUG & DEBUG_TEXTURE)
fprintf(stderr, "%s\n", __FUNCTION__);
@@ -188,23 +188,23 @@ i830SetTexEnvCombine(i830ContextPtr i830,
}
switch(combine->ModeRGB) {
case GL_REPLACE:
switch (combine->ModeRGB) {
case GL_REPLACE:
blendop = TEXBLENDOP_ARG1;
break;
case GL_MODULATE:
case GL_MODULATE:
blendop = TEXBLENDOP_MODULATE;
break;
case GL_ADD:
case GL_ADD:
blendop = TEXBLENDOP_ADD;
break;
case GL_ADD_SIGNED:
blendop = TEXBLENDOP_ADDSIGNED;
blendop = TEXBLENDOP_ADDSIGNED;
break;
case GL_INTERPOLATE:
blendop = TEXBLENDOP_BLEND;
blendop = TEXBLENDOP_BLEND;
break;
case GL_SUBTRACT:
case GL_SUBTRACT:
blendop = TEXBLENDOP_SUBTRACT;
break;
case GL_DOT3_RGB_EXT:
@@ -215,55 +215,54 @@ i830SetTexEnvCombine(i830ContextPtr i830,
case GL_DOT3_RGBA:
blendop = TEXBLENDOP_DOT3;
break;
default:
return pass_through( state, blendUnit );
default:
return pass_through(state, blendUnit);
}
blendop |= (rgb_shift << TEXOP_SCALE_SHIFT);
/* Handle RGB args */
for(i = 0; i < 3; i++) {
switch(combine->SourceRGB[i]) {
case GL_TEXTURE:
args_RGB[i] = texel_op;
break;
for (i = 0; i < 3; i++) {
switch (combine->SourceRGB[i]) {
case GL_TEXTURE:
args_RGB[i] = texel_op;
break;
case GL_TEXTURE0:
case GL_TEXTURE1:
case GL_TEXTURE2:
case GL_TEXTURE3:
args_RGB[i] = GetTexelOp( combine->SourceRGB[i] - GL_TEXTURE0 );
break;
args_RGB[i] = GetTexelOp(combine->SourceRGB[i] - GL_TEXTURE0);
break;
case GL_CONSTANT:
args_RGB[i] = TEXBLENDARG_FACTOR_N;
need_factor = 1;
break;
args_RGB[i] = TEXBLENDARG_FACTOR_N;
need_factor = 1;
break;
case GL_PRIMARY_COLOR:
args_RGB[i] = TEXBLENDARG_DIFFUSE;
break;
args_RGB[i] = TEXBLENDARG_DIFFUSE;
break;
case GL_PREVIOUS:
args_RGB[i] = TEXBLENDARG_CURRENT;
break;
default:
return pass_through( state, blendUnit );
args_RGB[i] = TEXBLENDARG_CURRENT;
break;
default:
return pass_through(state, blendUnit);
}
switch(combine->OperandRGB[i]) {
case GL_SRC_COLOR:
args_RGB[i] |= 0;
break;
case GL_ONE_MINUS_SRC_COLOR:
args_RGB[i] |= TEXBLENDARG_INV_ARG;
break;
case GL_SRC_ALPHA:
args_RGB[i] |= TEXBLENDARG_REPLICATE_ALPHA;
break;
case GL_ONE_MINUS_SRC_ALPHA:
args_RGB[i] |= (TEXBLENDARG_REPLICATE_ALPHA |
TEXBLENDARG_INV_ARG);
break;
default:
return pass_through( state, blendUnit );
switch (combine->OperandRGB[i]) {
case GL_SRC_COLOR:
args_RGB[i] |= 0;
break;
case GL_ONE_MINUS_SRC_COLOR:
args_RGB[i] |= TEXBLENDARG_INV_ARG;
break;
case GL_SRC_ALPHA:
args_RGB[i] |= TEXBLENDARG_REPLICATE_ALPHA;
break;
case GL_ONE_MINUS_SRC_ALPHA:
args_RGB[i] |= (TEXBLENDARG_REPLICATE_ALPHA | TEXBLENDARG_INV_ARG);
break;
default:
return pass_through(state, blendUnit);
}
}
@@ -275,76 +274,76 @@ i830SetTexEnvCombine(i830ContextPtr i830,
* Note - the global factor is set up with alpha == .5, so
* the alpha part of the DOT4 calculation should be zero.
*/
if ( combine->ModeRGB == GL_DOT3_RGBA_EXT ||
combine->ModeRGB == GL_DOT3_RGBA ) {
if (combine->ModeRGB == GL_DOT3_RGBA_EXT ||
combine->ModeRGB == GL_DOT3_RGBA) {
ablendop = TEXBLENDOP_DOT4;
args_A[0] = TEXBLENDARG_FACTOR; /* the global factor */
args_A[0] = TEXBLENDARG_FACTOR; /* the global factor */
args_A[1] = TEXBLENDARG_FACTOR;
args_A[2] = TEXBLENDARG_FACTOR;
}
else {
switch(combine->ModeA) {
case GL_REPLACE:
ablendop = TEXBLENDOP_ARG1;
break;
case GL_MODULATE:
ablendop = TEXBLENDOP_MODULATE;
break;
case GL_ADD:
ablendop = TEXBLENDOP_ADD;
break;
switch (combine->ModeA) {
case GL_REPLACE:
ablendop = TEXBLENDOP_ARG1;
break;
case GL_MODULATE:
ablendop = TEXBLENDOP_MODULATE;
break;
case GL_ADD:
ablendop = TEXBLENDOP_ADD;
break;
case GL_ADD_SIGNED:
ablendop = TEXBLENDOP_ADDSIGNED;
break;
ablendop = TEXBLENDOP_ADDSIGNED;
break;
case GL_INTERPOLATE:
ablendop = TEXBLENDOP_BLEND;
break;
case GL_SUBTRACT:
ablendop = TEXBLENDOP_SUBTRACT;
break;
ablendop = TEXBLENDOP_BLEND;
break;
case GL_SUBTRACT:
ablendop = TEXBLENDOP_SUBTRACT;
break;
default:
return pass_through( state, blendUnit );
return pass_through(state, blendUnit);
}
ablendop |= (alpha_shift << TEXOP_SCALE_SHIFT);
/* Handle A args */
for(i = 0; i < 3; i++) {
switch(combine->SourceA[i]) {
case GL_TEXTURE:
args_A[i] = texel_op;
break;
case GL_TEXTURE0:
case GL_TEXTURE1:
case GL_TEXTURE2:
case GL_TEXTURE3:
args_A[i] = GetTexelOp( combine->SourceA[i] - GL_TEXTURE0 );
break;
case GL_CONSTANT:
args_A[i] = TEXBLENDARG_FACTOR_N;
need_factor = 1;
break;
case GL_PRIMARY_COLOR:
args_A[i] = TEXBLENDARG_DIFFUSE;
break;
case GL_PREVIOUS:
args_A[i] = TEXBLENDARG_CURRENT;
break;
default:
return pass_through( state, blendUnit );
}
for (i = 0; i < 3; i++) {
switch (combine->SourceA[i]) {
case GL_TEXTURE:
args_A[i] = texel_op;
break;
case GL_TEXTURE0:
case GL_TEXTURE1:
case GL_TEXTURE2:
case GL_TEXTURE3:
args_A[i] = GetTexelOp(combine->SourceA[i] - GL_TEXTURE0);
break;
case GL_CONSTANT:
args_A[i] = TEXBLENDARG_FACTOR_N;
need_factor = 1;
break;
case GL_PRIMARY_COLOR:
args_A[i] = TEXBLENDARG_DIFFUSE;
break;
case GL_PREVIOUS:
args_A[i] = TEXBLENDARG_CURRENT;
break;
default:
return pass_through(state, blendUnit);
}
switch(combine->OperandA[i]) {
case GL_SRC_ALPHA:
args_A[i] |= 0;
break;
case GL_ONE_MINUS_SRC_ALPHA:
args_A[i] |= TEXBLENDARG_INV_ARG;
break;
default:
return pass_through( state, blendUnit );
}
switch (combine->OperandA[i]) {
case GL_SRC_ALPHA:
args_A[i] |= 0;
break;
case GL_ONE_MINUS_SRC_ALPHA:
args_A[i] |= TEXBLENDARG_INV_ARG;
break;
default:
return pass_through(state, blendUnit);
}
}
}
@@ -363,86 +362,86 @@ i830SetTexEnvCombine(i830ContextPtr i830,
used = 0;
state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
TEXPIPE_COLOR |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT |
DISABLE_TEX_CNTRL_STAGE |
TEXOP_MODIFY_PARMS |
blendop);
TEXPIPE_COLOR |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT |
DISABLE_TEX_CNTRL_STAGE | TEXOP_MODIFY_PARMS | blendop);
state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
TEXPIPE_ALPHA |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT |
TEXOP_MODIFY_PARMS |
ablendop);
TEXPIPE_ALPHA |
ENABLE_TEXOUTPUT_WRT_SEL |
TEXOP_OUTPUT_CURRENT | TEXOP_MODIFY_PARMS | ablendop);
for ( i = 0 ; i < numColorArgs ; i++ ) {
for (i = 0; i < numColorArgs; i++) {
state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
tex_blend_rgb[i] | args_RGB[i]);
tex_blend_rgb[i] | args_RGB[i]);
}
for ( i = 0 ; i < numAlphaArgs ; i++ ) {
for (i = 0; i < numAlphaArgs; i++) {
state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
tex_blend_a[i] | args_A[i]);
tex_blend_a[i] | args_A[i]);
}
if (need_factor)
return emit_factor( blendUnit, state, used, factor );
else
if (need_factor)
return emit_factor(blendUnit, state, used, factor);
else
return used;
}
static void emit_texblend( i830ContextPtr i830, GLuint unit, GLuint blendUnit,
GLboolean last_stage )
static void
emit_texblend(struct i830_context *i830, GLuint unit, GLuint blendUnit,
GLboolean last_stage)
{
struct gl_texture_unit *texUnit = &i830->intel.ctx.Texture.Unit[unit];
GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz;
if (0) fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit);
if (0)
fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit);
/* Update i830->state.TexBlend
*/
tmp_sz = i830SetTexEnvCombine(i830, texUnit->_CurrentCombine, blendUnit,
GetTexelOp(unit), tmp,
texUnit->EnvColor );
*/
tmp_sz = i830SetTexEnvCombine(i830, texUnit->_CurrentCombine, blendUnit,
GetTexelOp(unit), tmp, texUnit->EnvColor);
if (last_stage)
if (last_stage)
tmp[0] |= TEXOP_LAST_STAGE;
if (tmp_sz != i830->state.TexBlendWordsUsed[blendUnit] ||
memcmp( tmp, i830->state.TexBlend[blendUnit], tmp_sz * sizeof(GLuint))) {
I830_STATECHANGE( i830, I830_UPLOAD_TEXBLEND(blendUnit) );
memcpy( i830->state.TexBlend[blendUnit], tmp, tmp_sz * sizeof(GLuint));
memcmp(tmp, i830->state.TexBlend[blendUnit],
tmp_sz * sizeof(GLuint))) {
I830_STATECHANGE(i830, I830_UPLOAD_TEXBLEND(blendUnit));
memcpy(i830->state.TexBlend[blendUnit], tmp, tmp_sz * sizeof(GLuint));
i830->state.TexBlendWordsUsed[blendUnit] = tmp_sz;
}
I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND(blendUnit), GL_TRUE);
}
static void emit_passthrough( i830ContextPtr i830 )
static void
emit_passthrough(struct i830_context *i830)
{
GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz;
GLuint unit = 0;
tmp_sz = pass_through( tmp, unit );
tmp_sz = pass_through(tmp, unit);
tmp[0] |= TEXOP_LAST_STAGE;
if (tmp_sz != i830->state.TexBlendWordsUsed[unit] ||
memcmp( tmp, i830->state.TexBlend[unit], tmp_sz * sizeof(GLuint))) {
I830_STATECHANGE( i830, I830_UPLOAD_TEXBLEND(unit) );
memcpy( i830->state.TexBlend[unit], tmp, tmp_sz * sizeof(GLuint));
memcmp(tmp, i830->state.TexBlend[unit], tmp_sz * sizeof(GLuint))) {
I830_STATECHANGE(i830, I830_UPLOAD_TEXBLEND(unit));
memcpy(i830->state.TexBlend[unit], tmp, tmp_sz * sizeof(GLuint));
i830->state.TexBlendWordsUsed[unit] = tmp_sz;
}
I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND(unit), GL_TRUE);
}
void i830EmitTextureBlend( i830ContextPtr i830 )
void
i830EmitTextureBlend(struct i830_context *i830)
{
GLcontext *ctx = &i830->intel.ctx;
GLuint unit, last_stage = 0, blendunit = 0;
@@ -450,16 +449,15 @@ void i830EmitTextureBlend( i830ContextPtr i830 )
I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND_ALL, GL_FALSE);
if (ctx->Texture._EnabledUnits) {
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++)
if (ctx->Texture.Unit[unit]._ReallyEnabled)
last_stage = unit;
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++)
if (ctx->Texture.Unit[unit]._ReallyEnabled)
last_stage = unit;
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++)
if (ctx->Texture.Unit[unit]._ReallyEnabled)
emit_texblend( i830, unit, blendunit++, last_stage == unit );
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++)
if (ctx->Texture.Unit[unit]._ReallyEnabled)
emit_texblend(i830, unit, blendunit++, last_stage == unit);
}
else {
emit_passthrough( i830 );
emit_passthrough(i830);
}
}

View File

@@ -38,446 +38,279 @@
#include "intel_screen.h"
#include "intel_ioctl.h"
#include "intel_tex.h"
#include "intel_mipmap_tree.h"
#include "intel_regions.h"
#include "i830_context.h"
#include "i830_reg.h"
static const GLint initial_offsets[6][2] = { {0,0},
{0,2},
{1,0},
{1,2},
{1,1},
{1,3} };
static const GLint step_offsets[6][2] = { {0,2},
{0,2},
{-1,2},
{-1,2},
{-1,1},
{-1,1} };
#define I830_TEX_UNIT_ENABLED(unit) (1<<unit)
static GLboolean i830SetTexImages( i830ContextPtr i830,
struct gl_texture_object *tObj )
static GLuint
translate_texture_format(GLuint mesa_format)
{
GLuint total_height, pitch, i, textureFormat;
i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
GLint firstLevel, lastLevel, numLevels;
switch( baseImage->TexFormat->MesaFormat ) {
switch (mesa_format) {
case MESA_FORMAT_L8:
t->intel.texelBytes = 1;
textureFormat = MAPSURF_8BIT | MT_8BIT_L8;
break;
return MAPSURF_8BIT | MT_8BIT_L8;
case MESA_FORMAT_I8:
t->intel.texelBytes = 1;
textureFormat = MAPSURF_8BIT | MT_8BIT_I8;
break;
return MAPSURF_8BIT | MT_8BIT_I8;
case MESA_FORMAT_A8:
t->intel.texelBytes = 1;
textureFormat = MAPSURF_8BIT | MT_8BIT_I8; /* Kludge -- check with conform, glean */
break;
return MAPSURF_8BIT | MT_8BIT_I8; /* Kludge! */
case MESA_FORMAT_AL88:
t->intel.texelBytes = 2;
textureFormat = MAPSURF_16BIT | MT_16BIT_AY88;
break;
return MAPSURF_16BIT | MT_16BIT_AY88;
case MESA_FORMAT_RGB565:
t->intel.texelBytes = 2;
textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
break;
return MAPSURF_16BIT | MT_16BIT_RGB565;
case MESA_FORMAT_ARGB1555:
t->intel.texelBytes = 2;
textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
break;
return MAPSURF_16BIT | MT_16BIT_ARGB1555;
case MESA_FORMAT_ARGB4444:
t->intel.texelBytes = 2;
textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB4444;
break;
return MAPSURF_16BIT | MT_16BIT_ARGB4444;
case MESA_FORMAT_ARGB8888:
t->intel.texelBytes = 4;
textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
break;
return MAPSURF_32BIT | MT_32BIT_ARGB8888;
case MESA_FORMAT_YCBCR_REV:
t->intel.texelBytes = 2;
textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL |
TM0S1_COLORSPACE_CONVERSION);
break;
return (MAPSURF_422 | MT_422_YCRCB_NORMAL);
case MESA_FORMAT_YCBCR:
t->intel.texelBytes = 2;
textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY | /* ??? */
TM0S1_COLORSPACE_CONVERSION);
break;
return (MAPSURF_422 | MT_422_YCRCB_SWAPY);
case MESA_FORMAT_RGB_FXT1:
case MESA_FORMAT_RGBA_FXT1:
t->intel.texelBytes = 2;
textureFormat = MAPSURF_COMPRESSED | MT_COMPRESS_FXT1;
break;
return (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
case MESA_FORMAT_RGBA_DXT1:
case MESA_FORMAT_RGB_DXT1:
/*
* DXTn pitches are Width/4 * blocksize in bytes
* for DXT1: blocksize=8 so Width/4*8 = Width * 2
* for DXT3/5: blocksize=16 so Width/4*16 = Width * 4
*/
t->intel.texelBytes = 2;
textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
break;
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
case MESA_FORMAT_RGBA_DXT3:
t->intel.texelBytes = 4;
textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
break;
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
case MESA_FORMAT_RGBA_DXT5:
t->intel.texelBytes = 4;
textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
break;
return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
default:
fprintf(stderr, "%s: bad image format\n", __FUNCTION__);
fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__, mesa_format);
abort();
return 0;
}
/* Compute which mipmap levels we really want to send to the hardware.
* This depends on the base image size, GL_TEXTURE_MIN_LOD,
* GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
* Yes, this looks overly complicated, but it's all needed.
*/
driCalculateTextureFirstLastLevel( (driTextureObject *) t );
}
/* Figure out the amount of memory required to hold all the mipmap
* levels. Choose the smallest pitch to accomodate the largest
* mipmap:
*/
firstLevel = t->intel.base.firstLevel;
lastLevel = t->intel.base.lastLevel;
numLevels = lastLevel - firstLevel + 1;
/* All images must be loaded at this pitch. Count the number of
* lines required:
*/
switch (tObj->Target) {
case GL_TEXTURE_CUBE_MAP: {
const GLuint dim = tObj->Image[0][firstLevel]->Width;
GLuint face;
pitch = dim * t->intel.texelBytes;
pitch *= 2; /* double pitch for cube layouts */
pitch = (pitch + 3) & ~3;
total_height = dim * 4;
for ( face = 0 ; face < 6 ; face++) {
GLuint x = initial_offsets[face][0] * dim;
GLuint y = initial_offsets[face][1] * dim;
GLuint d = dim;
t->intel.base.dirty_images[face] = ~0;
assert(tObj->Image[face][firstLevel]->Width == dim);
assert(tObj->Image[face][firstLevel]->Height == dim);
for (i = 0; i < numLevels; i++) {
t->intel.image[face][i].image = tObj->Image[face][firstLevel + i];
if (!t->intel.image[face][i].image) {
fprintf(stderr, "no image %d %d\n", face, i);
break; /* can't happen */
}
t->intel.image[face][i].offset =
y * pitch + x * t->intel.texelBytes;
t->intel.image[face][i].internalFormat = baseImage->_BaseFormat;
d >>= 1;
x += step_offsets[face][0] * d;
y += step_offsets[face][1] * d;
}
}
break;
}
/* The i915 (and related graphics cores) do not support GL_CLAMP. The
* Intel drivers for "other operating systems" implement GL_CLAMP as
* GL_CLAMP_TO_EDGE, so the same is done here.
*/
static GLuint
translate_wrap_mode(GLenum wrap)
{
switch (wrap) {
case GL_REPEAT:
return TEXCOORDMODE_WRAP;
case GL_CLAMP:
case GL_CLAMP_TO_EDGE:
return TEXCOORDMODE_CLAMP; /* not really correct */
case GL_CLAMP_TO_BORDER:
return TEXCOORDMODE_CLAMP_BORDER;
case GL_MIRRORED_REPEAT:
return TEXCOORDMODE_MIRROR;
default:
pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes;
pitch = (pitch + 3) & ~3;
t->intel.base.dirty_images[0] = ~0;
for ( total_height = i = 0 ; i < numLevels ; i++ ) {
t->intel.image[0][i].image = tObj->Image[0][firstLevel + i];
if (!t->intel.image[0][i].image)
break;
t->intel.image[0][i].offset = total_height * pitch;
t->intel.image[0][i].internalFormat = baseImage->_BaseFormat;
if (t->intel.image[0][i].image->IsCompressed)
{
if (t->intel.image[0][i].image->Height > 4)
total_height += t->intel.image[0][i].image->Height/4;
else
total_height += 1;
}
else
total_height += MAX2(2, t->intel.image[0][i].image->Height);
}
break;
return TEXCOORDMODE_WRAP;
}
t->intel.Pitch = pitch;
t->intel.base.totalSize = total_height*pitch;
t->intel.max_level = i-1;
t->Setup[I830_TEXREG_TM0S1] =
(((tObj->Image[0][firstLevel]->Height - 1) << TM0S1_HEIGHT_SHIFT) |
((tObj->Image[0][firstLevel]->Width - 1) << TM0S1_WIDTH_SHIFT) |
textureFormat);
t->Setup[I830_TEXREG_TM0S2] =
(((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) |
TM0S2_CUBE_FACE_ENA_MASK;
t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAX_MIP_MASK;
t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_MIP_MASK;
t->Setup[I830_TEXREG_TM0S3] |= ((numLevels - 1)*4) << TM0S3_MIN_MIP_SHIFT;
t->intel.dirty = I830_UPLOAD_TEX_ALL;
return intelUploadTexImages( &i830->intel, &t->intel, 0 );
}
static void i830_import_tex_unit( i830ContextPtr i830,
i830TextureObjectPtr t,
GLuint unit )
/* Recalculate all state from scratch. Perhaps not the most
* efficient, but this has gotten complex enough that we need
* something which is understandable and reliable.
*/
static GLboolean
i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
{
if(INTEL_DEBUG&DEBUG_TEXTURE)
fprintf(stderr, "%s unit(%d)\n", __FUNCTION__, unit);
if (i830->intel.CurrentTexObj[unit])
i830->intel.CurrentTexObj[unit]->base.bound &= ~(1U << unit);
GLcontext *ctx = &intel->ctx;
struct i830_context *i830 = i830_context(ctx);
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
struct intel_texture_object *intelObj = intel_texture_object(tObj);
struct gl_texture_image *firstImage;
GLuint *state = i830->state.Tex[unit];
i830->intel.CurrentTexObj[unit] = (intelTextureObjectPtr)t;
t->intel.base.bound |= (1 << unit);
memset(state, 0, sizeof(state));
I830_STATECHANGE( i830, I830_UPLOAD_TEX(unit) );
i830->state.Tex[unit][I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
(LOAD_TEXTURE_MAP0 << unit) | 4);
i830->state.Tex[unit][I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE |
t->intel.TextureOffset);
i830->state.Tex[unit][I830_TEXREG_TM0S1] = t->Setup[I830_TEXREG_TM0S1];
i830->state.Tex[unit][I830_TEXREG_TM0S2] = t->Setup[I830_TEXREG_TM0S2];
i830->state.Tex[unit][I830_TEXREG_TM0S3] &= TM0S3_LOD_BIAS_MASK;
i830->state.Tex[unit][I830_TEXREG_TM0S3] |= (t->Setup[I830_TEXREG_TM0S3] &
~TM0S3_LOD_BIAS_MASK);
i830->state.Tex[unit][I830_TEXREG_TM0S4] = t->Setup[I830_TEXREG_TM0S4];
i830->state.Tex[unit][I830_TEXREG_MCS] = (t->Setup[I830_TEXREG_MCS] &
~MAP_UNIT_MASK);
i830->state.Tex[unit][I830_TEXREG_CUBE] = t->Setup[I830_TEXREG_CUBE];
i830->state.Tex[unit][I830_TEXREG_MCS] |= MAP_UNIT(unit);
t->intel.dirty &= ~I830_UPLOAD_TEX(unit);
}
static GLboolean enable_tex_common( GLcontext *ctx, GLuint unit )
{
i830ContextPtr i830 = I830_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *tObj = texUnit->_Current;
i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData;
if (0) fprintf(stderr, "%s\n", __FUNCTION__);
/* Fallback if there's a texture border */
if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
fprintf(stderr, "Texture border\n");
if (!intel_finalize_mipmap_tree(intel, unit))
return GL_FALSE;
/* Get first image here, since intelObj->firstLevel will get set in
* the intel_finalize_mipmap_tree() call above.
*/
firstImage = tObj->Image[0][intelObj->firstLevel];
i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0,
intelObj->
firstLevel);
state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
(LOAD_TEXTURE_MAP0 << unit) | 4);
/* state[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | */
/* t->intel.TextureOffset); */
state[I830_TEXREG_TM0S1] =
(((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) |
translate_texture_format(firstImage->TexFormat->MesaFormat));
state[I830_TEXREG_TM0S2] =
(((((intelObj->mt->pitch * intelObj->mt->cpp) / 4) -
1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);
{
if (tObj->Target == GL_TEXTURE_CUBE_MAP)
state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit) |
CUBE_NEGX_ENABLE |
CUBE_POSX_ENABLE |
CUBE_NEGY_ENABLE |
CUBE_POSY_ENABLE |
CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE);
else
state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit));
}
/* Upload teximages (not pipelined)
*/
if (t->intel.base.dirty_images[0]) {
if (!i830SetTexImages( i830, tObj )) {
return GL_FALSE;
{
GLuint minFilt, mipFilt, magFilt;
switch (tObj->MinFilter) {
case GL_NEAREST:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_NONE;
break;
case GL_LINEAR:
minFilt = FILTER_LINEAR;
mipFilt = MIPFILTER_NONE;
break;
case GL_NEAREST_MIPMAP_NEAREST:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_NEAREST;
break;
case GL_LINEAR_MIPMAP_NEAREST:
minFilt = FILTER_LINEAR;
mipFilt = MIPFILTER_NEAREST;
break;
case GL_NEAREST_MIPMAP_LINEAR:
minFilt = FILTER_NEAREST;
mipFilt = MIPFILTER_LINEAR;
break;
case GL_LINEAR_MIPMAP_LINEAR:
minFilt = FILTER_LINEAR;
mipFilt = MIPFILTER_LINEAR;
break;
default:
return GL_FALSE;
}
if (tObj->MaxAnisotropy > 1.0) {
minFilt = FILTER_ANISOTROPIC;
magFilt = FILTER_ANISOTROPIC;
}
else {
switch (tObj->MagFilter) {
case GL_NEAREST:
magFilt = FILTER_NEAREST;
break;
case GL_LINEAR:
magFilt = FILTER_LINEAR;
break;
default:
return GL_FALSE;
}
}
state[I830_TEXREG_TM0S3] = i830->lodbias_tm0s3[unit];
#if 0
/* YUV conversion:
*/
if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR ||
firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV)
state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION;
#endif
state[I830_TEXREG_TM0S3] |= ((intelObj->lastLevel -
intelObj->firstLevel) *
4) << TM0S3_MIN_MIP_SHIFT;
state[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
(mipFilt << TM0S3_MIP_FILTER_SHIFT) |
(magFilt << TM0S3_MAG_FILTER_SHIFT));
}
/* Update state if this is a different texture object to last
* time.
*/
if (i830->intel.CurrentTexObj[unit] != &t->intel ||
(t->intel.dirty & I830_UPLOAD_TEX(unit))) {
i830_import_tex_unit( i830, t, unit);
{
GLenum ws = tObj->WrapS;
GLenum wt = tObj->WrapT;
/* 3D textures not available on i830
*/
if (tObj->Target == GL_TEXTURE_3D)
return GL_FALSE;
state[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
MAP_UNIT(unit) |
ENABLE_TEXCOORD_PARAMS |
ss3 |
ENABLE_ADDR_V_CNTL |
TEXCOORD_ADDR_V_MODE(translate_wrap_mode(wt))
| ENABLE_ADDR_U_CNTL |
TEXCOORD_ADDR_U_MODE(translate_wrap_mode
(ws)));
}
state[I830_TEXREG_TM0S4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0],
tObj->_BorderChan[1],
tObj->_BorderChan[2],
tObj->_BorderChan[3]);
I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE);
return GL_TRUE;
}
static GLboolean enable_tex_rect( GLcontext *ctx, GLuint unit )
{
i830ContextPtr i830 = I830_CONTEXT(ctx);
GLuint mcs = i830->state.Tex[unit][I830_TEXREG_MCS];
mcs &= ~TEXCOORDS_ARE_NORMAL;
mcs |= TEXCOORDS_ARE_IN_TEXELUNITS;
if ((mcs != i830->state.Tex[unit][I830_TEXREG_MCS])
|| (0 != i830->state.Tex[unit][I830_TEXREG_CUBE])) {
I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
i830->state.Tex[unit][I830_TEXREG_MCS] = mcs;
i830->state.Tex[unit][I830_TEXREG_CUBE] = 0;
}
return GL_TRUE;
}
static GLboolean enable_tex_2d( GLcontext *ctx, GLuint unit )
{
i830ContextPtr i830 = I830_CONTEXT(ctx);
GLuint mcs = i830->state.Tex[unit][I830_TEXREG_MCS];
mcs &= ~TEXCOORDS_ARE_IN_TEXELUNITS;
mcs |= TEXCOORDS_ARE_NORMAL;
if ((mcs != i830->state.Tex[unit][I830_TEXREG_MCS])
|| (0 != i830->state.Tex[unit][I830_TEXREG_CUBE])) {
I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
i830->state.Tex[unit][I830_TEXREG_MCS] = mcs;
i830->state.Tex[unit][I830_TEXREG_CUBE] = 0;
}
return GL_TRUE;
}
static GLboolean enable_tex_cube( GLcontext *ctx, GLuint unit )
{
i830ContextPtr i830 = I830_CONTEXT(ctx);
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
struct gl_texture_object *tObj = texUnit->_Current;
i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData;
GLuint mcs = i830->state.Tex[unit][I830_TEXREG_MCS];
const GLuint cube = CUBE_NEGX_ENABLE | CUBE_POSX_ENABLE
| CUBE_NEGY_ENABLE | CUBE_POSY_ENABLE
| CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE;
GLuint face;
mcs &= ~TEXCOORDS_ARE_IN_TEXELUNITS;
mcs |= TEXCOORDS_ARE_NORMAL;
if ((mcs != i830->state.Tex[unit][I830_TEXREG_MCS])
|| (cube != i830->state.Tex[unit][I830_TEXREG_CUBE])) {
I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
i830->state.Tex[unit][I830_TEXREG_MCS] = mcs;
i830->state.Tex[unit][I830_TEXREG_CUBE] = cube;
}
/* Upload teximages (not pipelined)
/* memcmp was already disabled, but definitely won't work as the
* region might now change and that wouldn't be detected:
*/
if ( t->intel.base.dirty_images[0] || t->intel.base.dirty_images[1] ||
t->intel.base.dirty_images[2] || t->intel.base.dirty_images[3] ||
t->intel.base.dirty_images[4] || t->intel.base.dirty_images[5] ) {
i830SetTexImages( i830, tObj );
}
I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
return GL_TRUE;
}
/* upload (per face) */
for (face = 0; face < 6; face++) {
if (t->intel.base.dirty_images[face]) {
if (!intelUploadTexImages( &i830->intel, &t->intel, face )) {
return GL_FALSE;
}
void
i830UpdateTextureState(struct intel_context *intel)
{
struct i830_context *i830 = i830_context(&intel->ctx);
GLboolean ok = GL_TRUE;
GLuint i;
for (i = 0; i < I830_TEX_UNITS && ok; i++) {
switch (intel->ctx.Texture.Unit[i]._ReallyEnabled) {
case TEXTURE_1D_BIT:
case TEXTURE_2D_BIT:
case TEXTURE_CUBE_BIT:
ok = i830_update_tex_unit(intel, i, TEXCOORDS_ARE_NORMAL);
break;
case TEXTURE_RECT_BIT:
ok = i830_update_tex_unit(intel, i, TEXCOORDS_ARE_IN_TEXELUNITS);
break;
case 0:
if (i830->state.active & I830_UPLOAD_TEX(i))
I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(i), GL_FALSE);
break;
case TEXTURE_3D_BIT:
default:
ok = GL_FALSE;
break;
}
}
return GL_TRUE;
}
static GLboolean disable_tex( GLcontext *ctx, GLuint unit )
{
i830ContextPtr i830 = I830_CONTEXT(ctx);
/* This is happening too often. I need to conditionally send diffuse
* state to the card. Perhaps a diffuse dirty flag of some kind.
* Will need to change this logic if more than 2 texture units are
* used. We need to only do this up to the last unit enabled, or unit
* one if nothing is enabled.
*/
if ( i830->intel.CurrentTexObj[unit] != NULL ) {
/* The old texture is no longer bound to this texture unit.
* Mark it as such.
*/
i830->intel.CurrentTexObj[unit]->base.bound &= ~(1U << 0);
i830->intel.CurrentTexObj[unit] = NULL;
}
return GL_TRUE;
}
static GLboolean i830UpdateTexUnit( GLcontext *ctx, GLuint unit )
{
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
if (texUnit->_ReallyEnabled &&
INTEL_CONTEXT(ctx)->intelScreen->tex.size < 2048 * 1024)
return GL_FALSE;
switch(texUnit->_ReallyEnabled) {
case TEXTURE_1D_BIT:
case TEXTURE_2D_BIT:
return (enable_tex_common( ctx, unit ) &&
enable_tex_2d( ctx, unit ));
case TEXTURE_RECT_BIT:
return (enable_tex_common( ctx, unit ) &&
enable_tex_rect( ctx, unit ));
case TEXTURE_CUBE_BIT:
return (enable_tex_common( ctx, unit ) &&
enable_tex_cube( ctx, unit ));
case 0:
return disable_tex( ctx, unit );
default:
return GL_FALSE;
}
}
void i830UpdateTextureState( intelContextPtr intel )
{
i830ContextPtr i830 = I830_CONTEXT(intel);
GLcontext *ctx = &intel->ctx;
GLboolean ok;
if (0) fprintf(stderr, "%s\n", __FUNCTION__);
I830_ACTIVESTATE(i830, I830_UPLOAD_TEX_ALL, GL_FALSE);
ok = (i830UpdateTexUnit( ctx, 0 ) &&
i830UpdateTexUnit( ctx, 1 ) &&
i830UpdateTexUnit( ctx, 2 ) &&
i830UpdateTexUnit( ctx, 3 ));
FALLBACK( intel, I830_FALLBACK_TEXTURE, !ok );
FALLBACK(intel, I830_FALLBACK_TEXTURE, !ok);
if (ok)
i830EmitTextureBlend( i830 );
i830EmitTextureBlend(i830);
}

View File

@@ -28,14 +28,15 @@
#include "i830_context.h"
#include "i830_reg.h"
#include "intel_batchbuffer.h"
#include "intel_regions.h"
#include "tnl/t_context.h"
#include "tnl/t_vertex.h"
static GLboolean i830_check_vertex_size( intelContextPtr intel,
GLuint expected );
#define FILE_DEBUG_FLAG DEBUG_STATE
static GLboolean i830_check_vertex_size(struct intel_context *intel,
GLuint expected);
#define SZ_TO_HW(sz) ((sz-2)&0x3)
#define EMIT_SZ(sz) (EMIT_1F + (sz) - 1)
@@ -59,10 +60,11 @@ do { \
#define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2))
#define TEXBIND_SET(n, x) ((x)<<((n)*4))
static void i830_render_start( intelContextPtr intel )
static void
i830_render_start(struct intel_context *intel)
{
GLcontext *ctx = &intel->ctx;
i830ContextPtr i830 = I830_CONTEXT(intel);
struct i830_context *i830 = i830_context(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
DECLARE_RENDERINPUTS(index_bitset);
@@ -70,7 +72,7 @@ static void i830_render_start( intelContextPtr intel )
GLuint v2 = _3DSTATE_VFT1_CMD;
GLuint mcsb1 = 0;
RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
RENDERINPUTS_COPY(index_bitset, tnl->render_inputs_bitset);
/* Important:
*/
@@ -80,196 +82,215 @@ static void i830_render_start( intelContextPtr intel )
/* EMIT_ATTR's must be in order as they tell t_vertex.c how to
* build up a hardware vertex.
*/
if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VFT0_XYZW );
if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX)) {
EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VFT0_XYZW);
intel->coloroffset = 4;
}
else {
EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VFT0_XYZ );
EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VFT0_XYZ);
intel->coloroffset = 3;
}
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE )) {
EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, VFT0_POINT_WIDTH );
if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_POINTSIZE)) {
EMIT_ATTR(_TNL_ATTRIB_POINTSIZE, EMIT_1F, VFT0_POINT_WIDTH);
}
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VFT0_DIFFUSE );
EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VFT0_DIFFUSE);
intel->specoffset = 0;
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 ) ||
RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR1) ||
RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_FOG)) {
if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_COLOR1)) {
intel->specoffset = intel->coloroffset + 1;
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VFT0_SPEC );
EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VFT0_SPEC);
}
else
EMIT_PAD( 3 );
EMIT_PAD(3);
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG ))
EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VFT0_SPEC );
if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_FOG))
EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F, VFT0_SPEC);
else
EMIT_PAD( 1 );
EMIT_PAD(1);
}
if (RENDERINPUTS_TEST_RANGE( index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX )) {
if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, _TNL_LAST_TEX)) {
int i, count = 0;
for (i = 0; i < I830_TEX_UNITS; i++) {
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
if (RENDERINPUTS_TEST(index_bitset, _TNL_ATTRIB_TEX(i))) {
GLuint sz = VB->TexCoordPtr[i]->size;
GLuint emit;
GLuint mcs = (i830->state.Tex[i][I830_TEXREG_MCS] &
GLuint mcs = (i830->state.Tex[i][I830_TEXREG_MCS] &
~TEXCOORDTYPE_MASK);
switch (sz) {
case 1:
case 2:
emit = EMIT_2F;
sz = 2;
mcs |= TEXCOORDTYPE_CARTESIAN;
break;
case 3:
emit = EMIT_3F;
sz = 3;
mcs |= TEXCOORDTYPE_VECTOR;
break;
case 4:
emit = EMIT_3F_XYW;
sz = 3;
mcs |= TEXCOORDTYPE_HOMOGENEOUS;
break;
default:
continue;
};
switch (sz) {
case 1:
case 2:
emit = EMIT_2F;
sz = 2;
mcs |= TEXCOORDTYPE_CARTESIAN;
break;
case 3:
emit = EMIT_3F;
sz = 3;
mcs |= TEXCOORDTYPE_VECTOR;
break;
case 4:
emit = EMIT_3F_XYW;
sz = 3;
mcs |= TEXCOORDTYPE_HOMOGENEOUS;
break;
default:
continue;
};
EMIT_ATTR( _TNL_ATTRIB_TEX0+i, emit, 0 );
v2 |= VRTX_TEX_SET_FMT(count, SZ_TO_HW(sz));
mcsb1 |= (count+8)<<(i*4);
if (mcs != i830->state.Tex[i][I830_TEXREG_MCS]) {
I830_STATECHANGE(i830, I830_UPLOAD_TEX(i));
i830->state.Tex[i][I830_TEXREG_MCS] = mcs;
}
EMIT_ATTR(_TNL_ATTRIB_TEX0 + i, emit, 0);
v2 |= VRTX_TEX_SET_FMT(count, SZ_TO_HW(sz));
mcsb1 |= (count + 8) << (i * 4);
count++;
}
if (mcs != i830->state.Tex[i][I830_TEXREG_MCS]) {
I830_STATECHANGE(i830, I830_UPLOAD_TEX(i));
i830->state.Tex[i][I830_TEXREG_MCS] = mcs;
}
count++;
}
}
v0 |= VFT0_TEX_COUNT(count);
}
/* Only need to change the vertex emit code if there has been a
* statechange to a new hardware vertex format:
*/
if (v0 != i830->state.Ctx[I830_CTXREG_VF] ||
v2 != i830->state.Ctx[I830_CTXREG_VF2] ||
mcsb1 != i830->state.Ctx[I830_CTXREG_MCSB1] ||
!RENDERINPUTS_EQUAL( index_bitset, i830->last_index_bitset )) {
I830_STATECHANGE( i830, I830_UPLOAD_CTX );
!RENDERINPUTS_EQUAL(index_bitset, i830->last_index_bitset)) {
int k;
I830_STATECHANGE(i830, I830_UPLOAD_CTX);
/* Must do this *after* statechange, so as not to affect
* buffered vertices reliant on the old state:
*/
intel->vertex_size =
_tnl_install_attrs( ctx,
intel->vertex_attrs,
intel->vertex_attr_count,
intel->ViewportMatrix.m, 0 );
intel->vertex_size =
_tnl_install_attrs(ctx,
intel->vertex_attrs,
intel->vertex_attr_count,
intel->ViewportMatrix.m, 0);
intel->vertex_size >>= 2;
i830->state.Ctx[I830_CTXREG_VF] = v0;
i830->state.Ctx[I830_CTXREG_VF2] = v2;
i830->state.Ctx[I830_CTXREG_MCSB1] = mcsb1;
RENDERINPUTS_COPY( i830->last_index_bitset, index_bitset );
RENDERINPUTS_COPY(i830->last_index_bitset, index_bitset);
assert(i830_check_vertex_size( intel, intel->vertex_size ));
k = i830_check_vertex_size(intel, intel->vertex_size);
assert(k);
}
}
static void i830_reduced_primitive_state( intelContextPtr intel,
GLenum rprim )
static void
i830_reduced_primitive_state(struct intel_context *intel, GLenum rprim)
{
i830ContextPtr i830 = I830_CONTEXT(intel);
GLuint st1 = i830->state.Stipple[I830_STPREG_ST1];
struct i830_context *i830 = i830_context(&intel->ctx);
GLuint st1 = i830->state.Stipple[I830_STPREG_ST1];
st1 &= ~ST1_ENABLE;
st1 &= ~ST1_ENABLE;
switch (rprim) {
case GL_TRIANGLES:
if (intel->ctx.Polygon.StippleFlag &&
intel->hw_stipple)
st1 |= ST1_ENABLE;
break;
case GL_LINES:
case GL_POINTS:
default:
break;
}
switch (rprim) {
case GL_TRIANGLES:
if (intel->ctx.Polygon.StippleFlag && intel->hw_stipple)
st1 |= ST1_ENABLE;
break;
case GL_LINES:
case GL_POINTS:
default:
break;
}
i830->intel.reduced_primitive = rprim;
i830->intel.reduced_primitive = rprim;
if (st1 != i830->state.Stipple[I830_STPREG_ST1]) {
I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE);
i830->state.Stipple[I830_STPREG_ST1] = st1;
}
if (st1 != i830->state.Stipple[I830_STPREG_ST1]) {
INTEL_FIREVERTICES(intel);
I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE);
i830->state.Stipple[I830_STPREG_ST1] = st1;
}
}
/* Pull apart the vertex format registers and figure out how large a
* vertex is supposed to be.
*/
static GLboolean i830_check_vertex_size( intelContextPtr intel,
GLuint expected )
static GLboolean
i830_check_vertex_size(struct intel_context *intel, GLuint expected)
{
i830ContextPtr i830 = I830_CONTEXT(intel);
struct i830_context *i830 = i830_context(&intel->ctx);
int vft0 = i830->current->Ctx[I830_CTXREG_VF];
int vft1 = i830->current->Ctx[I830_CTXREG_VF2];
int nrtex = (vft0 & VFT0_TEX_COUNT_MASK) >> VFT0_TEX_COUNT_SHIFT;
int i, sz = 0;
switch (vft0 & VFT0_XYZW_MASK) {
case VFT0_XY: sz = 2; break;
case VFT0_XYZ: sz = 3; break;
case VFT0_XYW: sz = 3; break;
case VFT0_XYZW: sz = 4; break;
default:
case VFT0_XY:
sz = 2;
break;
case VFT0_XYZ:
sz = 3;
break;
case VFT0_XYW:
sz = 3;
break;
case VFT0_XYZW:
sz = 4;
break;
default:
fprintf(stderr, "no xyzw specified\n");
return 0;
}
if (vft0 & VFT0_SPEC) sz++;
if (vft0 & VFT0_DIFFUSE) sz++;
if (vft0 & VFT0_DEPTH_OFFSET) sz++;
if (vft0 & VFT0_POINT_WIDTH) sz++;
for (i = 0 ; i < nrtex ; i++) {
if (vft0 & VFT0_SPEC)
sz++;
if (vft0 & VFT0_DIFFUSE)
sz++;
if (vft0 & VFT0_DEPTH_OFFSET)
sz++;
if (vft0 & VFT0_POINT_WIDTH)
sz++;
for (i = 0; i < nrtex; i++) {
switch (vft1 & VFT1_TEX0_MASK) {
case TEXCOORDFMT_2D: sz += 2; break;
case TEXCOORDFMT_3D: sz += 3; break;
case TEXCOORDFMT_4D: sz += 4; break;
case TEXCOORDFMT_1D: sz += 1; break;
case TEXCOORDFMT_2D:
sz += 2;
break;
case TEXCOORDFMT_3D:
sz += 3;
break;
case TEXCOORDFMT_4D:
sz += 4;
break;
case TEXCOORDFMT_1D:
sz += 1;
break;
}
vft1 >>= VFT1_TEX1_SHIFT;
}
if (sz != expected)
if (sz != expected)
fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected);
return sz == expected;
}
static void i830_emit_invarient_state( intelContextPtr intel )
static void
i830_emit_invarient_state(struct intel_context *intel)
{
BATCH_LOCALS;
BEGIN_BATCH( 40 );
OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(0));
OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(1));
OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(2));
OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(3));
BEGIN_BATCH(40, 0);
OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
OUT_BATCH(0);
@@ -282,37 +303,35 @@ static void i830_emit_invarient_state( intelContextPtr intel )
OUT_BATCH(_3DSTATE_FOG_MODE_CMD);
OUT_BATCH(FOGFUNC_ENABLE |
FOG_LINEAR_CONST |
FOGSRC_INDEX_Z |
ENABLE_FOG_DENSITY);
FOG_LINEAR_CONST | FOGSRC_INDEX_Z | ENABLE_FOG_DENSITY);
OUT_BATCH(0);
OUT_BATCH(0);
OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
MAP_UNIT(0) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(0) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0));
MAP_UNIT(0) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(0) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0));
OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
MAP_UNIT(1) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(1) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1));
MAP_UNIT(1) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(1) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1));
OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
MAP_UNIT(2) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(2) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2));
MAP_UNIT(2) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(2) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2));
OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
MAP_UNIT(3) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(3) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3));
MAP_UNIT(3) |
DISABLE_TEX_STREAM_BUMP |
ENABLE_TEX_STREAM_COORD_SET |
TEX_STREAM_COORD_SET(3) |
ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3));
OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(0));
@@ -324,21 +343,13 @@ static void i830_emit_invarient_state( intelContextPtr intel )
OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(3));
OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
ENABLE_POINT_RASTER_RULE |
OGL_POINT_RASTER_RULE |
ENABLE_LINE_STRIP_PROVOKE_VRTX |
ENABLE_TRI_FAN_PROVOKE_VRTX |
ENABLE_TRI_STRIP_PROVOKE_VRTX |
LINE_STRIP_PROVOKE_VRTX(1) |
TRI_FAN_PROVOKE_VRTX(2) |
TRI_STRIP_PROVOKE_VRTX(2));
OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD |
DISABLE_SCISSOR_RECT);
OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
OUT_BATCH(0);
OUT_BATCH(0);
ENABLE_POINT_RASTER_RULE |
OGL_POINT_RASTER_RULE |
ENABLE_LINE_STRIP_PROVOKE_VRTX |
ENABLE_TRI_FAN_PROVOKE_VRTX |
ENABLE_TRI_STRIP_PROVOKE_VRTX |
LINE_STRIP_PROVOKE_VRTX(1) |
TRI_FAN_PROVOKE_VRTX(2) | TRI_STRIP_PROVOKE_VRTX(2));
OUT_BATCH(_3DSTATE_VERTEX_TRANSFORM);
OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE);
@@ -349,7 +360,7 @@ static void i830_emit_invarient_state( intelContextPtr intel )
OUT_BATCH(_3DSTATE_COLOR_FACTOR_CMD);
OUT_BATCH(0x80808080); /* .5 required in alpha for GL_DOT3_RGBA_EXT */
OUT_BATCH(0x80808080); /* .5 required in alpha for GL_DOT3_RGBA_EXT */
ADVANCE_BATCH();
}
@@ -358,13 +369,16 @@ static void i830_emit_invarient_state( intelContextPtr intel )
#define emit( intel, state, size ) \
do { \
int k; \
BEGIN_BATCH( size / sizeof(GLuint)); \
for (k = 0 ; k < size / sizeof(GLuint) ; k++) \
BEGIN_BATCH(size / sizeof(GLuint), 0); \
for (k = 0 ; k < size / sizeof(GLuint) ; k++) { \
if (0) _mesa_printf(" 0x%08x\n", state[k]); \
OUT_BATCH(state[k]); \
} \
ADVANCE_BATCH(); \
} while (0);
} while (0)
static GLuint get_state_size( struct i830_hw_state *state )
static GLuint
get_state_size(struct i830_hw_state *state)
{
GLuint dirty = state->active & ~state->emitted;
GLuint sz = 0;
@@ -373,21 +387,21 @@ static GLuint get_state_size( struct i830_hw_state *state )
if (dirty & I830_UPLOAD_INVARIENT)
sz += 40 * sizeof(int);
if (dirty & I830_UPLOAD_CTX)
if (dirty & I830_UPLOAD_CTX)
sz += sizeof(state->Ctx);
if (dirty & I830_UPLOAD_BUFFERS)
if (dirty & I830_UPLOAD_BUFFERS)
sz += sizeof(state->Buffer);
if (dirty & I830_UPLOAD_STIPPLE)
if (dirty & I830_UPLOAD_STIPPLE)
sz += sizeof(state->Stipple);
for (i = 0; i < I830_TEX_UNITS; i++) {
if ((dirty & I830_UPLOAD_TEX(i)))
sz += sizeof(state->Tex[i]);
if ((dirty & I830_UPLOAD_TEX(i)))
sz += sizeof(state->Tex[i]);
if (dirty & I830_UPLOAD_TEXBLEND(i))
sz += state->TexBlendWordsUsed[i] * 4;
if (dirty & I830_UPLOAD_TEXBLEND(i))
sz += state->TexBlendWordsUsed[i] * 4;
}
return sz;
@@ -396,139 +410,197 @@ static GLuint get_state_size( struct i830_hw_state *state )
/* Push the state into the sarea and/or texture memory.
*/
static void i830_emit_state( intelContextPtr intel )
static void
i830_emit_state(struct intel_context *intel)
{
i830ContextPtr i830 = I830_CONTEXT(intel);
struct i830_context *i830 = i830_context(&intel->ctx);
struct i830_hw_state *state = i830->current;
int i;
GLuint dirty = state->active & ~state->emitted;
GLuint counter = intel->batch.counter;
GLuint dirty;
BATCH_LOCALS;
if (intel->batch.space < get_state_size(state)) {
intelFlushBatch(intel, GL_TRUE);
dirty = state->active & ~state->emitted;
counter = intel->batch.counter;
}
/* We don't hold the lock at this point, so want to make sure that
* there won't be a buffer wrap.
*
* It might be better to talk about explicit places where
* scheduling is allowed, rather than assume that it is whenever a
* batchbuffer fills up.
*/
intel_batchbuffer_require_space(intel->batch, get_state_size(state), 0);
/* Do this here as we may have flushed the batchbuffer above,
* causing more state to be dirty!
*/
dirty = state->active & ~state->emitted;
if (dirty & I830_UPLOAD_INVARIENT) {
if (VERBOSE) fprintf(stderr, "I830_UPLOAD_INVARIENT:\n");
i830_emit_invarient_state( intel );
DBG("I830_UPLOAD_INVARIENT:\n");
i830_emit_invarient_state(intel);
}
if (dirty & I830_UPLOAD_CTX) {
if (VERBOSE) fprintf(stderr, "I830_UPLOAD_CTX:\n");
emit( i830, state->Ctx, sizeof(state->Ctx) );
DBG("I830_UPLOAD_CTX:\n");
emit(i830, state->Ctx, sizeof(state->Ctx));
}
if (dirty & I830_UPLOAD_BUFFERS) {
if (VERBOSE) fprintf(stderr, "I830_UPLOAD_BUFFERS:\n");
emit( i830, state->Buffer, sizeof(state->Buffer) );
DBG("I830_UPLOAD_BUFFERS:\n");
BEGIN_BATCH(I830_DEST_SETUP_SIZE + 2, 0);
OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR0]);
OUT_BATCH(state->Buffer[I830_DESTREG_CBUFADDR1]);
OUT_RELOC(state->draw_region->buffer,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
if (state->depth_region) {
OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR0]);
OUT_BATCH(state->Buffer[I830_DESTREG_DBUFADDR1]);
OUT_RELOC(state->depth_region->buffer,
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_WRITE,
DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, 0);
}
OUT_BATCH(state->Buffer[I830_DESTREG_DV0]);
OUT_BATCH(state->Buffer[I830_DESTREG_DV1]);
OUT_BATCH(state->Buffer[I830_DESTREG_SENABLE]);
OUT_BATCH(state->Buffer[I830_DESTREG_SR0]);
OUT_BATCH(state->Buffer[I830_DESTREG_SR1]);
OUT_BATCH(state->Buffer[I830_DESTREG_SR2]);
ADVANCE_BATCH();
}
if (dirty & I830_UPLOAD_STIPPLE) {
if (VERBOSE) fprintf(stderr, "I830_UPLOAD_STIPPLE:\n");
emit( i830, state->Stipple, sizeof(state->Stipple) );
DBG("I830_UPLOAD_STIPPLE:\n");
emit(i830, state->Stipple, sizeof(state->Stipple));
}
for (i = 0; i < I830_TEX_UNITS; i++) {
if ((dirty & I830_UPLOAD_TEX(i))) {
if (VERBOSE) fprintf(stderr, "I830_UPLOAD_TEX(%d):\n", i);
emit( i830, state->Tex[i], sizeof(state->Tex[i]));
}
if ((dirty & I830_UPLOAD_TEX(i))) {
DBG("I830_UPLOAD_TEX(%d):\n", i);
BEGIN_BATCH(I830_TEX_SETUP_SIZE + 1, 0);
OUT_BATCH(state->Tex[i][I830_TEXREG_TM0LI]);
if (state->tex_buffer[i]) {
OUT_RELOC(state->tex_buffer[i],
DRM_BO_FLAG_MEM_TT | DRM_BO_FLAG_READ,
DRM_BO_MASK_MEM | DRM_BO_FLAG_READ,
state->tex_offset[i] | TM0S0_USE_FENCE);
}
else {
assert(i == 0);
assert(state == &i830->meta);
OUT_BATCH(0);
}
OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S1]);
OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S2]);
OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S3]);
OUT_BATCH(state->Tex[i][I830_TEXREG_TM0S4]);
OUT_BATCH(state->Tex[i][I830_TEXREG_MCS]);
OUT_BATCH(state->Tex[i][I830_TEXREG_CUBE]);
}
if (dirty & I830_UPLOAD_TEXBLEND(i)) {
if (VERBOSE) fprintf(stderr, "I830_UPLOAD_TEXBLEND(%d):\n", i);
emit( i830, state->TexBlend[i],
state->TexBlendWordsUsed[i] * 4 );
DBG("I830_UPLOAD_TEXBLEND(%d): %d words\n", i,
state->TexBlendWordsUsed[i]);
emit(i830, state->TexBlend[i], state->TexBlendWordsUsed[i] * 4);
}
}
state->emitted |= dirty;
intel->batch.last_emit_state = counter;
assert(counter == intel->batch.counter);
}
static void i830_destroy_context( intelContextPtr intel )
static void
i830_destroy_context(struct intel_context *intel)
{
_tnl_free_vertices(&intel->ctx);
}
static void
i830_set_color_region(intelContextPtr intel, const intelRegion *region)
i830_set_draw_region(struct intel_context *intel,
struct intel_region *draw_region,
struct intel_region *depth_region)
{
i830ContextPtr i830 = I830_CONTEXT(intel);
I830_STATECHANGE( i830, I830_UPLOAD_BUFFERS );
struct i830_context *i830 = i830_context(&intel->ctx);
intel_region_release(intel->intelScreen, &i830->state.draw_region);
intel_region_release(intel->intelScreen, &i830->state.depth_region);
intel_region_reference(&i830->state.draw_region, draw_region);
intel_region_reference(&i830->state.depth_region, depth_region);
/* XXX FBO: Need code from i915_set_draw_region() */
I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
i830->state.Buffer[I830_DESTREG_CBUFADDR1] =
(BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
i830->state.Buffer[I830_DESTREG_CBUFADDR2] = region->offset;
}
static void
i830_set_z_region(intelContextPtr intel, const intelRegion *region)
{
i830ContextPtr i830 = I830_CONTEXT(intel);
I830_STATECHANGE( i830, I830_UPLOAD_BUFFERS );
(BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(draw_region->pitch) |
BUF_3D_USE_FENCE);
i830->state.Buffer[I830_DESTREG_DBUFADDR1] =
(BUF_3D_ID_DEPTH | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
i830->state.Buffer[I830_DESTREG_DBUFADDR2] = region->offset;
(BUF_3D_ID_DEPTH | BUF_3D_PITCH(depth_region->pitch) |
BUF_3D_USE_FENCE);
}
#if 0
static void
i830_update_color_z_regions(intelContextPtr intel,
const intelRegion *colorRegion,
const intelRegion *depthRegion)
const intelRegion * colorRegion,
const intelRegion * depthRegion)
{
i830ContextPtr i830 = I830_CONTEXT(intel);
i830->state.Buffer[I830_DESTREG_CBUFADDR1] =
(BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) | BUF_3D_USE_FENCE);
(BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(colorRegion->pitch) |
BUF_3D_USE_FENCE);
i830->state.Buffer[I830_DESTREG_CBUFADDR2] = colorRegion->offset;
i830->state.Buffer[I830_DESTREG_DBUFADDR1] =
(BUF_3D_ID_DEPTH | BUF_3D_PITCH(depthRegion->pitch) | BUF_3D_USE_FENCE);
i830->state.Buffer[I830_DESTREG_DBUFADDR2] = depthRegion->offset;
}
#endif
/* This isn't really handled at the moment.
*/
static void i830_lost_hardware( intelContextPtr intel )
static void
i830_lost_hardware(struct intel_context *intel)
{
I830_CONTEXT(intel)->state.emitted = 0;
struct i830_context *i830 = i830_context(&intel->ctx);
i830->state.emitted = 0;
}
static void i830_emit_flush( intelContextPtr intel )
static GLuint
i830_flush_cmd(void)
{
BATCH_LOCALS;
BEGIN_BATCH(2);
OUT_BATCH( MI_FLUSH | FLUSH_MAP_CACHE );
OUT_BATCH( 0 );
ADVANCE_BATCH();
return MI_FLUSH | FLUSH_MAP_CACHE;
}
void i830InitVtbl( i830ContextPtr i830 )
static void
i830_assert_not_dirty( struct intel_context *intel )
{
struct i830_context *i830 = i830_context(&intel->ctx);
struct i830_hw_state *state = i830->current;
GLuint dirty = state->active & ~state->emitted;
assert(!dirty);
}
void
i830InitVtbl(struct i830_context *i830)
{
i830->intel.vtbl.alloc_tex_obj = i830AllocTexObj;
i830->intel.vtbl.check_vertex_size = i830_check_vertex_size;
i830->intel.vtbl.clear_with_tris = i830ClearWithTris;
i830->intel.vtbl.rotate_window = i830RotateWindow;
i830->intel.vtbl.destroy = i830_destroy_context;
i830->intel.vtbl.emit_state = i830_emit_state;
i830->intel.vtbl.lost_hardware = i830_lost_hardware;
i830->intel.vtbl.reduced_primitive_state = i830_reduced_primitive_state;
i830->intel.vtbl.set_color_region = i830_set_color_region;
i830->intel.vtbl.set_z_region = i830_set_z_region;
i830->intel.vtbl.update_color_z_regions = i830_update_color_z_regions;
i830->intel.vtbl.set_draw_region = i830_set_draw_region;
i830->intel.vtbl.update_texture_state = i830UpdateTextureState;
i830->intel.vtbl.emit_flush = i830_emit_flush;
i830->intel.vtbl.flush_cmd = i830_flush_cmd;
i830->intel.vtbl.render_start = i830_render_start;
i830->intel.vtbl.assert_not_dirty = i830_assert_not_dirty;
}

View File

@@ -41,77 +41,88 @@
#include "utils.h"
#include "i915_reg.h"
#include "intel_regions.h"
#include "intel_batchbuffer.h"
/***************************************
* Mesa's Driver Functions
***************************************/
static const struct dri_extension i915_extensions[] =
{
{ "GL_ARB_depth_texture", NULL },
{ "GL_ARB_fragment_program", NULL },
{ "GL_ARB_shadow", NULL },
{ "GL_EXT_shadow_funcs", NULL },
/* ARB extn won't work if not enabled */
{ "GL_SGIX_depth_texture", NULL },
{ NULL, NULL }
static const struct dri_extension i915_extensions[] = {
{"GL_ARB_depth_texture", NULL},
{"GL_ARB_fragment_program", NULL},
{"GL_ARB_shadow", NULL},
{"GL_ARB_texture_env_crossbar", NULL},
{"GL_ARB_texture_non_power_of_two", NULL},
{"GL_EXT_shadow_funcs", NULL},
/* ARB extn won't work if not enabled */
{"GL_SGIX_depth_texture", NULL},
{NULL, NULL}
};
/* Override intel default.
*/
static void i915InvalidateState( GLcontext *ctx, GLuint new_state )
static void
i915InvalidateState(GLcontext * ctx, GLuint new_state)
{
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
_ac_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
_tnl_invalidate_vertex_state( ctx, new_state );
INTEL_CONTEXT(ctx)->NewGLState |= new_state;
_swrast_InvalidateState(ctx, new_state);
_swsetup_InvalidateState(ctx, new_state);
_ac_InvalidateState(ctx, new_state);
_tnl_InvalidateState(ctx, new_state);
_tnl_invalidate_vertex_state(ctx, new_state);
intel_context(ctx)->NewGLState |= new_state;
/* Todo: gather state values under which tracked parameters become
* invalidated, add callbacks for things like
* ProgramLocalParameters, etc.
*/
{
struct i915_fragment_program *p =
(struct i915_fragment_program *)ctx->FragmentProgram._Current;
struct i915_fragment_program *p =
(struct i915_fragment_program *) ctx->FragmentProgram._Current;
if (p && p->nr_params)
p->params_uptodate = 0;
p->params_uptodate = 0;
}
if (new_state & (_NEW_FOG|_NEW_HINT|_NEW_PROGRAM))
if (new_state & (_NEW_FOG | _NEW_HINT | _NEW_PROGRAM))
i915_update_fog(ctx);
}
static void i915InitDriverFunctions( struct dd_function_table *functions )
static void
i915InitDriverFunctions(struct dd_function_table *functions)
{
intelInitDriverFunctions( functions );
i915InitStateFunctions( functions );
i915InitTextureFuncs( functions );
i915InitFragProgFuncs( functions );
intelInitDriverFunctions(functions);
i915InitStateFunctions(functions);
i915InitTextureFuncs(functions);
i915InitFragProgFuncs(functions);
functions->UpdateState = i915InvalidateState;
}
GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate)
GLboolean
i915CreateContext(const __GLcontextModes * mesaVis,
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate)
{
struct dd_function_table functions;
i915ContextPtr i915 = (i915ContextPtr) CALLOC_STRUCT(i915_context);
intelContextPtr intel = &i915->intel;
struct i915_context *i915 =
(struct i915_context *) CALLOC_STRUCT(i915_context);
struct intel_context *intel = &i915->intel;
GLcontext *ctx = &intel->ctx;
GLuint i;
if (!i915) return GL_FALSE;
if (!i915)
return GL_FALSE;
i915InitVtbl( i915 );
_mesa_printf("\ntexmem-0-3 branch\n\n");
i915InitDriverFunctions( &functions );
i915InitVtbl(i915);
i915InitMetaFuncs(i915);
if (!intelInitContext( intel, mesaVis, driContextPriv,
sharedContextPrivate, &functions )) {
i915InitDriverFunctions(&functions);
if (!intelInitContext(intel, mesaVis, driContextPriv,
sharedContextPrivate, &functions)) {
FREE(i915);
return GL_FALSE;
}
@@ -120,63 +131,44 @@ GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
ctx->Const.MaxTextureImageUnits = I915_TEX_UNITS;
ctx->Const.MaxTextureCoordUnits = I915_TEX_UNITS;
intel->nr_heaps = 1;
intel->texture_heaps[0] =
driCreateTextureHeap( 0, intel,
intel->intelScreen->tex.size,
12,
I830_NR_TEX_REGIONS,
intel->sarea->texList,
(unsigned *) & intel->sarea->texAge,
& intel->swapped,
sizeof( struct i915_texture_object ),
(destroy_texture_object_t *)intelDestroyTexObj );
/* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are
* tightly packed, but they're not in Intel graphics
* hardware.
/* Advertise the full hardware capabilities. The new memory
* manager should cope much better with overload situations:
*/
ctx->Const.MaxTextureLevels = 12;
ctx->Const.Max3DTextureLevels = 9;
ctx->Const.MaxCubeTextureLevels = 12;
ctx->Const.MaxTextureRectSize = (1 << 11);
ctx->Const.MaxTextureUnits = I915_TEX_UNITS;
i = driQueryOptioni( &intel->intelScreen->optionCache, "allow_large_textures");
driCalculateMaxTextureLevels( intel->texture_heaps,
intel->nr_heaps,
&intel->ctx.Const,
4,
11, /* max 2D texture size is 2048x2048 */
8, /* 3D texture */
11, /* cube texture. */
11, /* rect texture */
12,
GL_FALSE,
i );
/* GL_ARB_fragment_program limits - don't think Mesa actually
* validates programs against these, and in any case one ARB
* instruction can translate to more than one HW instruction, so
* we'll still have to check and fallback each time.
*/
ctx->Const.FragmentProgram.MaxNativeTemps = I915_MAX_TEMPORARY;
ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */
ctx->Const.FragmentProgram.MaxNativeAttribs = 11; /* 8 tex, 2 color, fog */
ctx->Const.FragmentProgram.MaxNativeParameters = I915_MAX_CONSTANT;
ctx->Const.FragmentProgram.MaxNativeAluInstructions = I915_MAX_ALU_INSN;
ctx->Const.FragmentProgram.MaxNativeTexInstructions = I915_MAX_TEX_INSN;
ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN +
I915_MAX_TEX_INSN);
ctx->Const.FragmentProgram.MaxNativeTexIndirections = I915_MAX_TEX_INDIRECT;
ctx->Const.FragmentProgram.MaxNativeInstructions = (I915_MAX_ALU_INSN +
I915_MAX_TEX_INSN);
ctx->Const.FragmentProgram.MaxNativeTexIndirections =
I915_MAX_TEX_INDIRECT;
ctx->Const.FragmentProgram.MaxNativeAddressRegs = 0; /* I don't think we have one */
ctx->_MaintainTexEnvProgram = 1;
ctx->_UseTexEnvProgram = 1;
driInitExtensions( ctx, i915_extensions, GL_FALSE );
driInitExtensions(ctx, i915_extensions, GL_FALSE);
_tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
36 * sizeof(GLfloat) );
_tnl_init_vertices(ctx, ctx->Const.MaxArrayLockSize + 12,
36 * sizeof(GLfloat));
intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
i915InitState( i915 );
i915InitState(i915);
return GL_TRUE;
}

View File

@@ -46,6 +46,7 @@
#define I915_UPLOAD_CONSTANTS 0x10
#define I915_UPLOAD_FOG 0x20
#define I915_UPLOAD_INVARIENT 0x40
#define I915_UPLOAD_DEFAULTS 0x80
#define I915_UPLOAD_TEX(i) (0x00010000<<(i))
#define I915_UPLOAD_TEX_ALL (0x00ff0000)
#define I915_UPLOAD_TEX_0_SHIFT 16
@@ -55,10 +56,8 @@
*/
#define I915_DESTREG_CBUFADDR0 0
#define I915_DESTREG_CBUFADDR1 1
#define I915_DESTREG_CBUFADDR2 2
#define I915_DESTREG_DBUFADDR0 3
#define I915_DESTREG_DBUFADDR1 4
#define I915_DESTREG_DBUFADDR2 5
#define I915_DESTREG_DV0 6
#define I915_DESTREG_DV1 7
#define I915_DESTREG_SENABLE 8
@@ -89,7 +88,6 @@
#define I915_STPREG_ST1 1
#define I915_STP_SETUP_SIZE 2
#define I915_TEXREG_MS2 0
#define I915_TEXREG_MS3 1
#define I915_TEXREG_MS4 2
#define I915_TEXREG_SS2 3
@@ -97,6 +95,15 @@
#define I915_TEXREG_SS4 5
#define I915_TEX_SETUP_SIZE 6
#define I915_DEFREG_C0 0
#define I915_DEFREG_C1 1
#define I915_DEFREG_S0 2
#define I915_DEFREG_S1 3
#define I915_DEFREG_Z0 4
#define I915_DEFREG_Z1 5
#define I915_DEF_SETUP_SIZE 6
#define I915_MAX_CONSTANT 32
#define I915_CONSTANT_SIZE (2+(4*I915_MAX_CONSTANT))
@@ -107,13 +114,14 @@
/* Hardware version of a parsed fragment program. "Derived" from the
* mesa fragment_program struct.
*/
struct i915_fragment_program {
struct i915_fragment_program
{
struct gl_fragment_program FragProg;
GLboolean translated;
GLboolean params_uptodate;
GLboolean on_hardware;
GLboolean error; /* If program is malformed for any reason. */
GLboolean error; /* If program is malformed for any reason. */
GLuint nr_tex_indirect;
GLuint nr_tex_insn;
@@ -135,22 +143,22 @@ struct i915_fragment_program {
GLuint constant_flags[I915_MAX_CONSTANT];
GLuint nr_constants;
GLuint *csr; /* Cursor, points into program.
*/
GLuint *csr; /* Cursor, points into program.
*/
GLuint *decl; /* Cursor, points into declarations.
*/
GLuint decl_s; /* flags for which s regs need to be decl'd */
GLuint decl_t; /* flags for which t regs need to be decl'd */
GLuint *decl; /* Cursor, points into declarations.
*/
GLuint temp_flag; /* Tracks temporary regs which are in
* use.
*/
GLuint decl_s; /* flags for which s regs need to be decl'd */
GLuint decl_t; /* flags for which t regs need to be decl'd */
GLuint utemp_flag; /* Tracks TYPE_U temporary regs which are in
* use.
*/
GLuint temp_flag; /* Tracks temporary regs which are in
* use.
*/
GLuint utemp_flag; /* Tracks TYPE_U temporary regs which are in
* use.
*/
@@ -159,26 +167,25 @@ struct i915_fragment_program {
GLuint wpos_tex;
GLboolean depth_written;
struct {
GLuint reg; /* Hardware constant idx */
const GLfloat *values; /* Pointer to tracked values */
struct
{
GLuint reg; /* Hardware constant idx */
const GLfloat *values; /* Pointer to tracked values */
} param[I915_MAX_CONSTANT];
GLuint nr_params;
/* Helpers for i915_texprog.c:
*/
GLuint src_texture; /* Reg containing sampled texture color,
* else UREG_BAD.
*/
GLuint src_texture; /* Reg containing sampled texture color,
* else UREG_BAD.
*/
GLuint src_previous; /* Reg containing color from previous
* stage. May need to be decl'd.
*/
GLuint src_previous; /* Reg containing color from previous
* stage. May need to be decl'd.
*/
GLuint last_tex_stage; /* Number of last enabled texture unit */
GLuint last_tex_stage; /* Number of last enabled texture unit */
struct vertex_buffer *VB;
};
@@ -188,41 +195,53 @@ struct i915_fragment_program {
struct i915_texture_object
{
struct intel_texture_object intel;
GLenum lastTarget;
GLboolean refs_border_color;
GLuint Setup[I915_TEX_SETUP_SIZE];
};
#define I915_TEX_UNITS 8
struct i915_hw_state {
struct i915_hw_state
{
GLuint Ctx[I915_CTX_SETUP_SIZE];
GLuint Buffer[I915_DEST_SETUP_SIZE];
GLuint Stipple[I915_STP_SETUP_SIZE];
GLuint Fog[I915_FOG_SETUP_SIZE];
GLuint Defaults[I915_DEF_SETUP_SIZE];
GLuint Tex[I915_TEX_UNITS][I915_TEX_SETUP_SIZE];
GLuint Constant[I915_CONSTANT_SIZE];
GLuint ConstantSize;
GLuint Program[I915_PROGRAM_SIZE];
GLuint ProgramSize;
GLuint active; /* I915_UPLOAD_* */
GLuint emitted; /* I915_UPLOAD_* */
/* Region pointers for relocation:
*/
struct intel_region *draw_region;
struct intel_region *depth_region;
/* struct intel_region *tex_region[I915_TEX_UNITS]; */
/* Regions aren't actually that appropriate here as the memory may
* be from a PBO or FBO. Just use the buffer id. Will have to do
* this for draw and depth for FBO's...
*/
struct _DriBufferObject *tex_buffer[I915_TEX_UNITS];
GLuint tex_offset[I915_TEX_UNITS];
GLuint active; /* I915_UPLOAD_* */
GLuint emitted; /* I915_UPLOAD_* */
};
#define I915_FOG_PIXEL 2
#define I915_FOG_VERTEX 1
#define I915_FOG_NONE 0
struct i915_context
struct i915_context
{
struct intel_context intel;
GLuint last_ReallyEnabled;
GLuint vertex_fog;
GLuint lodbias_ss2[MAX_TEXTURE_UNITS];
struct i915_fragment_program tex_program;
struct i915_fragment_program *current_program;
@@ -231,24 +250,14 @@ struct i915_context
};
typedef struct i915_context *i915ContextPtr;
typedef struct i915_texture_object *i915TextureObjectPtr;
#define I915_CONTEXT(ctx) ((i915ContextPtr)(ctx))
#define I915_STATECHANGE(i915, flag) \
do { \
if (0) fprintf(stderr, "I915_STATECHANGE %x in %s\n", flag, __FUNCTION__); \
INTEL_FIREVERTICES( &(i915)->intel ); \
(i915)->state.emitted &= ~(flag); \
} while (0)
#define I915_ACTIVESTATE(i915, flag, mode) \
do { \
if (0) fprintf(stderr, "I915_ACTIVESTATE %x %d in %s\n", \
flag, mode, __FUNCTION__); \
INTEL_FIREVERTICES( &(i915)->intel ); \
if (mode) \
(i915)->state.active |= (flag); \
@@ -260,7 +269,13 @@ do { \
/*======================================================================
* i915_vtbl.c
*/
extern void i915InitVtbl( i915ContextPtr i915 );
extern void i915InitVtbl(struct i915_context *i915);
extern void
i915_state_draw_region(struct intel_context *intel,
struct i915_hw_state *state,
struct intel_region *color_region,
struct intel_region *depth_region);
@@ -289,70 +304,64 @@ do { \
/*======================================================================
* i915_context.c
*/
extern GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
__DRIcontextPrivate *driContextPriv,
void *sharedContextPrivate);
extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis,
__DRIcontextPrivate * driContextPriv,
void *sharedContextPrivate);
/*======================================================================
* i915_texprog.c
*/
extern void i915ValidateTextureProgram( i915ContextPtr i915 );
extern void i915ValidateTextureProgram(struct i915_context *i915);
/*======================================================================
* i915_debug.c
*/
extern void i915_disassemble_program( const GLuint *program, GLuint sz );
extern void i915_print_ureg( const char *msg, GLuint ureg );
extern void i915_disassemble_program(const GLuint * program, GLuint sz);
extern void i915_print_ureg(const char *msg, GLuint ureg);
/*======================================================================
* i915_state.c
*/
extern void i915InitStateFunctions( struct dd_function_table *functions );
extern void i915InitState( i915ContextPtr i915 );
extern void i915_update_fog(GLcontext *ctxx);
extern void i915InitStateFunctions(struct dd_function_table *functions);
extern void i915InitState(struct i915_context *i915);
extern void i915_update_fog(GLcontext * ctx);
/*======================================================================
* i915_tex.c
*/
extern void i915UpdateTextureState( intelContextPtr intel );
extern void i915InitTextureFuncs( struct dd_function_table *functions );
extern intelTextureObjectPtr i915AllocTexObj( struct gl_texture_object *texObj );
extern void i915UpdateTextureState(struct intel_context *intel);
extern void i915InitTextureFuncs(struct dd_function_table *functions);
/*======================================================================
* i915_metaops.c
*/
extern GLboolean
i915TryTextureReadPixels( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *pack,
GLvoid *pixels );
void i915InitMetaFuncs(struct i915_context *i915);
extern GLboolean
i915TryTextureDrawPixels( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels );
extern void
i915ClearWithTris( intelContextPtr intel, GLbitfield mask,
GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch);
extern void
i915RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
GLuint srcBuf);
/*======================================================================
* i915_fragprog.c
*/
extern void i915ValidateFragmentProgram( i915ContextPtr i915 );
extern void i915InitFragProgFuncs( struct dd_function_table *functions );
#endif
extern void i915ValidateFragmentProgram(struct i915_context *i915);
extern void i915InitFragProgFuncs(struct dd_function_table *functions);
/*======================================================================
* Inline conversion functions. These are better-typed than the
* macros used previously:
*/
static INLINE struct i915_context *
i915_context(GLcontext * ctx)
{
return (struct i915_context *) ctx;
}
#define I915_CONTEXT(ctx) i915_context(ctx)
#endif

View File

@@ -67,27 +67,27 @@ static const char *opcodes[0x20] = {
static const int args[0x20] = {
0, /* 0 nop */
2, /* 1 add */
1, /* 2 mov */
2, /* 3 m ul */
3, /* 4 mad */
3, /* 5 dp2add */
2, /* 6 dp3 */
2, /* 7 dp4 */
1, /* 8 frc */
1, /* 9 rcp */
1, /* a rsq */
1, /* b exp */
1, /* c log */
3, /* d cmp */
2, /* e min */
2, /* f max */
1, /* 10 flr */
1, /* 11 mod */
1, /* 12 trc */
2, /* 13 sge */
2, /* 14 slt */
0, /* 0 nop */
2, /* 1 add */
1, /* 2 mov */
2, /* 3 m ul */
3, /* 4 mad */
3, /* 5 dp2add */
2, /* 6 dp3 */
2, /* 7 dp4 */
1, /* 8 frc */
1, /* 9 rcp */
1, /* a rsq */
1, /* b exp */
1, /* c log */
3, /* d cmp */
2, /* e min */
2, /* f max */
1, /* 10 flr */
1, /* 11 mod */
1, /* 12 trc */
2, /* 13 sge */
2, /* 14 slt */
1,
1,
1,
@@ -113,26 +113,35 @@ static const char *regname[0x8] = {
"UNKNOWN",
};
static void print_reg_type_nr( GLuint type, GLuint nr )
static void
print_reg_type_nr(GLuint type, GLuint nr)
{
switch (type) {
case REG_TYPE_T:
switch (nr) {
case T_DIFFUSE: fprintf(stderr, "T_DIFFUSE"); return;
case T_SPECULAR: fprintf(stderr, "T_SPECULAR"); return;
case T_FOG_W: fprintf(stderr, "T_FOG_W"); return;
default: fprintf(stderr, "T_TEX%d", nr); return;
case T_DIFFUSE:
fprintf(stderr, "T_DIFFUSE");
return;
case T_SPECULAR:
fprintf(stderr, "T_SPECULAR");
return;
case T_FOG_W:
fprintf(stderr, "T_FOG_W");
return;
default:
fprintf(stderr, "T_TEX%d", nr);
return;
}
case REG_TYPE_OC:
if (nr == 0) {
fprintf(stderr, "oC");
return;
fprintf(stderr, "oC");
return;
}
break;
case REG_TYPE_OD:
if (nr == 0) {
fprintf(stderr, "oD");
return;
fprintf(stderr, "oD");
return;
}
break;
default:
@@ -151,7 +160,8 @@ static void print_reg_type_nr( GLuint type, GLuint nr )
(SRC_W << A2_SRC2_CHANNEL_W_SHIFT))
static void print_reg_neg_swizzle( GLuint reg )
static void
print_reg_neg_swizzle(GLuint reg)
{
int i;
@@ -161,50 +171,71 @@ static void print_reg_neg_swizzle( GLuint reg )
fprintf(stderr, ".");
for (i = 3 ; i >= 0; i--) {
if (reg & (1<<((i*4)+3)))
fprintf(stderr, "-");
switch ((reg>>(i*4)) & 0x7) {
case 0: fprintf(stderr, "x"); break;
case 1: fprintf(stderr, "y"); break;
case 2: fprintf(stderr, "z"); break;
case 3: fprintf(stderr, "w"); break;
case 4: fprintf(stderr, "0"); break;
case 5: fprintf(stderr, "1"); break;
default: fprintf(stderr, "?"); break;
for (i = 3; i >= 0; i--) {
if (reg & (1 << ((i * 4) + 3)))
fprintf(stderr, "-");
switch ((reg >> (i * 4)) & 0x7) {
case 0:
fprintf(stderr, "x");
break;
case 1:
fprintf(stderr, "y");
break;
case 2:
fprintf(stderr, "z");
break;
case 3:
fprintf(stderr, "w");
break;
case 4:
fprintf(stderr, "0");
break;
case 5:
fprintf(stderr, "1");
break;
default:
fprintf(stderr, "?");
break;
}
}
}
static void print_src_reg( GLuint dword )
static void
print_src_reg(GLuint dword)
{
GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK;
GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK;
print_reg_type_nr( type, nr );
print_reg_neg_swizzle( dword );
print_reg_type_nr(type, nr);
print_reg_neg_swizzle(dword);
}
void i915_print_ureg( const char *msg, GLuint ureg )
void
i915_print_ureg(const char *msg, GLuint ureg)
{
fprintf(stderr, "%s: ", msg);
print_src_reg( ureg >> 8 );
print_src_reg(ureg >> 8);
fprintf(stderr, "\n");
}
static void print_dest_reg( GLuint dword )
static void
print_dest_reg(GLuint dword)
{
GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK;
GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK;
print_reg_type_nr( type, nr );
print_reg_type_nr(type, nr);
if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL)
return;
fprintf(stderr, ".");
if (dword & A0_DEST_CHANNEL_X) fprintf(stderr, "x");
if (dword & A0_DEST_CHANNEL_Y) fprintf(stderr, "y");
if (dword & A0_DEST_CHANNEL_Z) fprintf(stderr, "z");
if (dword & A0_DEST_CHANNEL_W) fprintf(stderr, "w");
if (dword & A0_DEST_CHANNEL_X)
fprintf(stderr, "x");
if (dword & A0_DEST_CHANNEL_Y)
fprintf(stderr, "y");
if (dword & A0_DEST_CHANNEL_Z)
fprintf(stderr, "z");
if (dword & A0_DEST_CHANNEL_W)
fprintf(stderr, "w");
}
@@ -213,14 +244,15 @@ static void print_dest_reg( GLuint dword )
#define GET_SRC2_REG(r) (r)
static void print_arith_op( GLuint opcode, const GLuint *program )
static void
print_arith_op(GLuint opcode, const GLuint * program)
{
if (opcode != A0_NOP) {
print_dest_reg(program[0]);
if (program[0] & A0_DEST_SATURATE)
fprintf(stderr, " = SATURATE ");
fprintf(stderr, " = SATURATE ");
else
fprintf(stderr, " = ");
fprintf(stderr, " = ");
}
fprintf(stderr, "%s ", opcodes[opcode]);
@@ -233,7 +265,7 @@ static void print_arith_op( GLuint opcode, const GLuint *program )
fprintf(stderr, ", ");
print_src_reg(GET_SRC1_REG(program[1], program[2]));
if (args[opcode] == 2) {
if (args[opcode] == 2) {
fprintf(stderr, "\n");
return;
}
@@ -245,22 +277,24 @@ static void print_arith_op( GLuint opcode, const GLuint *program )
}
static void print_tex_op( GLuint opcode, const GLuint *program )
static void
print_tex_op(GLuint opcode, const GLuint * program)
{
print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
fprintf(stderr, " = ");
fprintf(stderr, "%s ", opcodes[opcode]);
fprintf(stderr, "S[%d],",
program[0] & T0_SAMPLER_NR_MASK);
fprintf(stderr, "S[%d],", program[0] & T0_SAMPLER_NR_MASK);
print_reg_type_nr( (program[1]>>T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK,
(program[1]>>T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK );
print_reg_type_nr((program[1] >> T1_ADDRESS_REG_TYPE_SHIFT) &
REG_TYPE_MASK,
(program[1] >> T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK);
fprintf(stderr, "\n");
}
static void print_dcl_op( GLuint opcode, const GLuint *program )
static void
print_dcl_op(GLuint opcode, const GLuint * program)
{
fprintf(stderr, "%s ", opcodes[opcode]);
print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
@@ -268,31 +302,32 @@ static void print_dcl_op( GLuint opcode, const GLuint *program )
}
void i915_disassemble_program( const GLuint *program, GLuint sz )
void
i915_disassemble_program(const GLuint * program, GLuint sz)
{
GLuint size = program[0] & 0x1ff;
GLint i;
fprintf(stderr, "BEGIN\n");
if (size+2 != sz) {
if (size + 2 != sz) {
fprintf(stderr, "%s: program size mismatch %d/%d\n", __FUNCTION__,
size+2, sz);
size + 2, sz);
exit(1);
}
program ++;
for (i = 1 ; i < sz ; i+=3, program+=3) {
GLuint opcode = program[0] & (0x1f<<24);
program++;
for (i = 1; i < sz; i += 3, program += 3) {
GLuint opcode = program[0] & (0x1f << 24);
if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT)
print_arith_op(opcode >> 24, program);
print_arith_op(opcode >> 24, program);
else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL)
print_tex_op(opcode >> 24, program);
print_tex_op(opcode >> 24, program);
else if (opcode == D0_DCL)
print_dcl_op(opcode >> 24, program);
else
fprintf(stderr, "Unknown opcode 0x%x\n", opcode);
print_dcl_op(opcode >> 24, program);
else
fprintf(stderr, "Unknown opcode 0x%x\n", opcode);
}
fprintf(stderr, "END\n\n");

File diff suppressed because it is too large Load Diff

View File

@@ -34,128 +34,170 @@
#include "intel_screen.h"
#include "intel_batchbuffer.h"
#include "intel_ioctl.h"
#include "intel_regions.h"
#include "intel_rotate.h"
#include "i915_context.h"
#include "i915_reg.h"
/* A large amount of state doesn't need to be uploaded.
/* We touch almost everything:
*/
#define ACTIVE (I915_UPLOAD_INVARIENT | \
I915_UPLOAD_PROGRAM | \
I915_UPLOAD_STIPPLE | \
#define ACTIVE (I915_UPLOAD_INVARIENT | \
I915_UPLOAD_CTX | \
I915_UPLOAD_BUFFERS | \
I915_UPLOAD_TEX(0))
I915_UPLOAD_STIPPLE | \
I915_UPLOAD_PROGRAM | \
I915_UPLOAD_FOG | \
I915_UPLOAD_TEX(0))
#define SET_STATE( i915, STATE ) \
#define SET_STATE( i915, STATE ) \
do { \
i915->current->emitted &= ~ACTIVE; \
i915->current = &i915->STATE; \
i915->current = &i915->STATE; \
i915->current->emitted &= ~ACTIVE; \
} while (0)
/* Operations where the 3D engine is decoupled temporarily from the
* current GL state and used for other purposes than simply rendering
* incoming triangles.
*/
static void set_initial_state( i915ContextPtr i915 )
{
memcpy(&i915->meta, &i915->initial, sizeof(i915->meta) );
i915->meta.active = ACTIVE;
i915->meta.emitted = 0;
}
static void set_no_depth_stencil_write( i915ContextPtr i915 )
static void
meta_no_stencil_write(struct intel_context *intel)
{
struct i915_context *i915 = i915_context(&intel->ctx);
/* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE )
*/
i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE |
S5_STENCIL_WRITE_ENABLE);
/* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
*/
i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE |
S6_DEPTH_WRITE_ENABLE);
i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE |
S5_STENCIL_WRITE_ENABLE);
i915->meta.emitted &= ~I915_UPLOAD_CTX;
}
static void
meta_no_depth_write(struct intel_context *intel)
{
struct i915_context *i915 = i915_context(&intel->ctx);
/* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
*/
i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE |
S6_DEPTH_WRITE_ENABLE);
i915->meta.emitted &= ~I915_UPLOAD_CTX;
}
static void
meta_depth_replace(struct intel_context *intel)
{
struct i915_context *i915 = i915_context(&intel->ctx);
/* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_TRUE )
* ctx->Driver.DepthMask( ctx, GL_TRUE )
*/
i915->meta.Ctx[I915_CTXREG_LIS6] |= (S6_DEPTH_TEST_ENABLE |
S6_DEPTH_WRITE_ENABLE);
/* ctx->Driver.DepthFunc( ctx, GL_REPLACE )
*/
i915->meta.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK;
i915->meta.Ctx[I915_CTXREG_LIS6] |=
COMPAREFUNC_ALWAYS << S6_DEPTH_TEST_FUNC_SHIFT;
i915->meta.emitted &= ~I915_UPLOAD_CTX;
}
/* Set stencil unit to replace always with the reference value.
*/
static void set_stencil_replace( i915ContextPtr i915,
GLuint s_mask,
GLuint s_clear)
static void
meta_stencil_replace(struct intel_context *intel,
GLuint s_mask, GLuint s_clear)
{
struct i915_context *i915 = i915_context(&intel->ctx);
GLuint op = STENCILOP_REPLACE;
GLuint func = COMPAREFUNC_ALWAYS;
/* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE )
*/
i915->meta.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE |
S5_STENCIL_WRITE_ENABLE);
/* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
*/
i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE |
S6_DEPTH_WRITE_ENABLE);
i915->meta.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE |
S5_STENCIL_WRITE_ENABLE);
/* ctx->Driver.StencilMask( ctx, s_mask )
*/
i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;
i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |
STENCIL_WRITE_MASK(s_mask));
STENCIL_WRITE_MASK(s_mask));
/* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE )
*/
i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_FAIL_MASK |
S5_STENCIL_PASS_Z_FAIL_MASK |
S5_STENCIL_PASS_Z_PASS_MASK);
S5_STENCIL_PASS_Z_FAIL_MASK |
S5_STENCIL_PASS_Z_PASS_MASK);
i915->meta.Ctx[I915_CTXREG_LIS5] |= ((op << S5_STENCIL_FAIL_SHIFT) |
(op << S5_STENCIL_PASS_Z_FAIL_SHIFT) |
(op << S5_STENCIL_PASS_Z_PASS_SHIFT));
(op << S5_STENCIL_PASS_Z_FAIL_SHIFT) |
(op << S5_STENCIL_PASS_Z_PASS_SHIFT));
/* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_ref, ~0 )
*/
i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;
i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |
STENCIL_TEST_MASK(0xff));
STENCIL_TEST_MASK(0xff));
i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_REF_MASK |
S5_STENCIL_TEST_FUNC_MASK);
i915->meta.Ctx[I915_CTXREG_LIS5] |= ((s_clear << S5_STENCIL_REF_SHIFT) |
(func << S5_STENCIL_TEST_FUNC_SHIFT));
S5_STENCIL_TEST_FUNC_MASK);
i915->meta.Ctx[I915_CTXREG_LIS5] |= ((s_clear << S5_STENCIL_REF_SHIFT) |
(func << S5_STENCIL_TEST_FUNC_SHIFT));
i915->meta.emitted &= ~I915_UPLOAD_CTX;
}
static void set_color_mask( i915ContextPtr i915, GLboolean state )
static void
meta_color_mask(struct intel_context *intel, GLboolean state)
{
struct i915_context *i915 = i915_context(&intel->ctx);
const GLuint mask = (S5_WRITEDISABLE_RED |
S5_WRITEDISABLE_GREEN |
S5_WRITEDISABLE_BLUE |
S5_WRITEDISABLE_ALPHA);
S5_WRITEDISABLE_GREEN |
S5_WRITEDISABLE_BLUE | S5_WRITEDISABLE_ALPHA);
/* Copy colormask state from "regular" hw context.
*/
if (state) {
i915->meta.Ctx[I915_CTXREG_LIS5] &= ~mask;
i915->meta.Ctx[I915_CTXREG_LIS5] |=
(i915->state.Ctx[I915_CTXREG_LIS5] & mask);
i915->meta.Ctx[I915_CTXREG_LIS5] |=
(i915->state.Ctx[I915_CTXREG_LIS5] & mask);
}
else
else
i915->meta.Ctx[I915_CTXREG_LIS5] |= mask;
i915->meta.emitted &= ~I915_UPLOAD_CTX;
}
static void
meta_import_pixel_state(struct intel_context *intel)
{
struct i915_context *i915 = i915_context(&intel->ctx);
memcpy(i915->meta.Fog, i915->state.Fog, I915_FOG_SETUP_SIZE * 4);
i915->meta.Ctx[I915_CTXREG_LIS5] = i915->state.Ctx[I915_CTXREG_LIS5];
i915->meta.Ctx[I915_CTXREG_LIS6] = i915->state.Ctx[I915_CTXREG_LIS6];
i915->meta.Ctx[I915_CTXREG_STATE4] = i915->state.Ctx[I915_CTXREG_STATE4];
i915->meta.Ctx[I915_CTXREG_BLENDCOLOR1] =
i915->state.Ctx[I915_CTXREG_BLENDCOLOR1];
i915->meta.Ctx[I915_CTXREG_IAB] = i915->state.Ctx[I915_CTXREG_IAB];
i915->meta.Buffer[I915_DESTREG_SENABLE] =
i915->state.Buffer[I915_DESTREG_SENABLE];
i915->meta.Buffer[I915_DESTREG_SR1] = i915->state.Buffer[I915_DESTREG_SR1];
i915->meta.Buffer[I915_DESTREG_SR2] = i915->state.Buffer[I915_DESTREG_SR2];
i915->meta.emitted &= ~I915_UPLOAD_FOG;
i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;
i915->meta.emitted &= ~I915_UPLOAD_CTX;
}
@@ -212,69 +254,64 @@ static void set_color_mask( i915ContextPtr i915, GLboolean state )
static void set_no_texture( i915ContextPtr i915 )
static void
meta_no_texture(struct intel_context *intel)
{
struct i915_context *i915 = i915_context(&intel->ctx);
static const GLuint prog[] = {
_3DSTATE_PIXEL_SHADER_PROGRAM,
/* Declare incoming diffuse color:
*/
(D0_DCL |
D0_DECL_REG( REG_T_DIFFUSE ) |
D0_CHANNEL_ALL),
(D0_DCL | D0_DECL_REG(REG_T_DIFFUSE) | D0_CHANNEL_ALL),
D1_MBZ,
D2_MBZ,
/* output-color = mov(t_diffuse)
*/
(A0_MOV |
A0_DEST_REG( REG_OC ) |
A0_DEST_CHANNEL_ALL |
A0_SRC0_REG( REG_T_DIFFUSE )),
A0_DEST_REG(REG_OC) |
A0_DEST_CHANNEL_ALL | A0_SRC0_REG(REG_T_DIFFUSE)),
(A1_SRC0_XYZW),
0,
};
memcpy( i915->meta.Program, prog, sizeof(prog) );
memcpy(i915->meta.Program, prog, sizeof(prog));
i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog);
i915->meta.Program[0] |= i915->meta.ProgramSize - 2;
i915->meta.emitted &= ~I915_UPLOAD_PROGRAM;
}
static void enable_texture_blend_replace( i915ContextPtr i915 )
static void
meta_texture_blend_replace(struct intel_context *intel)
{
struct i915_context *i915 = i915_context(&intel->ctx);
static const GLuint prog[] = {
_3DSTATE_PIXEL_SHADER_PROGRAM,
/* Declare the sampler:
*/
(D0_DCL |
D0_DECL_REG( REG_S(0) ) |
D0_SAMPLE_TYPE_2D |
D0_CHANNEL_NONE),
(D0_DCL | D0_DECL_REG(REG_S(0)) | D0_SAMPLE_TYPE_2D | D0_CHANNEL_NONE),
D1_MBZ,
D2_MBZ,
/* Declare the interpolated texture coordinate:
*/
(D0_DCL |
D0_DECL_REG( REG_T_TEX(0) ) |
D0_CHANNEL_ALL),
(D0_DCL | D0_DECL_REG(REG_T_TEX(0)) | D0_CHANNEL_ALL),
D1_MBZ,
D2_MBZ,
/* output-color = texld(sample0, texcoord0)
*/
(T0_TEXLD |
T0_DEST_REG( REG_OC ) |
T0_SAMPLER( 0 )),
(T0_TEXLD | T0_DEST_REG(REG_OC) | T0_SAMPLER(0)),
T1_ADDRESS_REG(REG_TYPE_T, 0),
T2_MBZ
};
memcpy( i915->meta.Program, prog, sizeof(prog) );
memcpy(i915->meta.Program, prog, sizeof(prog));
i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog);
i915->meta.Program[0] |= i915->meta.ProgramSize - 2;
i915->meta.emitted &= ~I915_UPLOAD_PROGRAM;
@@ -287,415 +324,186 @@ static void enable_texture_blend_replace( i915ContextPtr i915 )
/* Set up an arbitary piece of memory as a rectangular texture
* (including the front or back buffer).
*/
static void set_tex_rect_source( i915ContextPtr i915,
GLuint offset,
GLuint width,
GLuint height,
GLuint pitch, /* in bytes! */
GLuint textureFormat )
static GLboolean
meta_tex_rect_source(struct intel_context *intel,
struct _DriBufferObject *buffer,
GLuint offset,
GLuint pitch, GLuint height, GLenum format, GLenum type)
{
struct i915_context *i915 = i915_context(&intel->ctx);
GLuint unit = 0;
GLint numLevels = 1;
GLuint *state = i915->meta.Tex[0];
GLuint textureFormat;
GLuint cpp;
#if 0
printf("TexRect source offset 0x%x pitch %d\n", offset, pitch);
#endif
/* A full implementation of this would do the upload through
* glTexImage2d, and get all the conversion operations at that
* point. We are restricted, but still at least have access to the
* fragment program swizzle.
*/
switch (format) {
case GL_BGRA:
switch (type) {
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_UNSIGNED_BYTE:
textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888);
cpp = 4;
break;
default:
return GL_FALSE;
}
break;
case GL_RGBA:
switch (type) {
case GL_UNSIGNED_INT_8_8_8_8_REV:
case GL_UNSIGNED_BYTE:
textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888);
cpp = 4;
break;
default:
return GL_FALSE;
}
break;
case GL_BGR:
switch (type) {
case GL_UNSIGNED_SHORT_5_6_5_REV:
textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
cpp = 2;
break;
default:
return GL_FALSE;
}
break;
case GL_RGB:
switch (type) {
case GL_UNSIGNED_SHORT_5_6_5:
textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
cpp = 2;
break;
default:
return GL_FALSE;
}
break;
/* fprintf(stderr, "%s: offset: %x w: %d h: %d pitch %d format %x\n", */
/* __FUNCTION__, offset, width, height, pitch, textureFormat ); */
default:
return GL_FALSE;
}
if ((pitch * cpp) & 3) {
_mesa_printf("%s: texture is not dword pitch\n", __FUNCTION__);
return GL_FALSE;
}
/* intel_region_release(intel, &i915->meta.tex_region[0]); */
/* intel_region_reference(&i915->meta.tex_region[0], region); */
i915->meta.tex_buffer[0] = buffer;
i915->meta.tex_offset[0] = offset;
state[I915_TEXREG_MS2] = offset;
state[I915_TEXREG_MS3] = (((height - 1) << MS3_HEIGHT_SHIFT) |
((width - 1) << MS3_WIDTH_SHIFT) |
textureFormat |
MS3_USE_FENCE_REGS);
((pitch - 1) << MS3_WIDTH_SHIFT) |
textureFormat | MS3_USE_FENCE_REGS);
state[I915_TEXREG_MS4] = ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
((((numLevels-1) * 4)) << MS4_MAX_LOD_SHIFT));
state[I915_TEXREG_MS4] = (((((pitch * cpp) / 4) - 1) << MS4_PITCH_SHIFT) |
MS4_CUBE_FACE_ENA_MASK |
((((numLevels - 1) * 4)) << MS4_MAX_LOD_SHIFT));
state[I915_TEXREG_SS2] = ((FILTER_NEAREST << SS2_MIN_FILTER_SHIFT) |
(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) |
(FILTER_NEAREST << SS2_MAG_FILTER_SHIFT));
(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) |
(FILTER_NEAREST << SS2_MAG_FILTER_SHIFT));
state[I915_TEXREG_SS3] = ((TEXCOORDMODE_WRAP << SS3_TCX_ADDR_MODE_SHIFT) |
(TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT) |
(TEXCOORDMODE_WRAP << SS3_TCZ_ADDR_MODE_SHIFT) |
(unit<<SS3_TEXTUREMAP_INDEX_SHIFT));
(TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT) |
(TEXCOORDMODE_WRAP << SS3_TCZ_ADDR_MODE_SHIFT) |
(unit << SS3_TEXTUREMAP_INDEX_SHIFT));
state[I915_TEXREG_SS4] = 0;
i915->meta.emitted &= ~I915_UPLOAD_TEX(0);
return GL_TRUE;
}
/* Select between front and back draw buffers.
/**
* Set the color and depth drawing region for meta ops.
*/
static void set_draw_region( i915ContextPtr i915, const intelRegion *region )
static void
meta_draw_region(struct intel_context *intel,
struct intel_region *color_region,
struct intel_region *depth_region)
{
#if 0
printf("Rotate into region: offset 0x%x pitch %d\n",
region->offset, region->pitch);
#endif
i915->meta.Buffer[I915_DESTREG_CBUFADDR1] =
(BUF_3D_ID_COLOR_BACK | BUF_3D_PITCH(region->pitch) | BUF_3D_USE_FENCE);
i915->meta.Buffer[I915_DESTREG_CBUFADDR2] = region->offset;
i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;
struct i915_context *i915 = i915_context(&intel->ctx);
i915_state_draw_region(intel, &i915->meta, color_region, depth_region);
}
#if 0
/* Setup an arbitary draw format, useful for targeting texture or agp
* memory.
*/
static void set_draw_format( i915ContextPtr i915,
GLuint format,
GLuint depth_format)
static void
set_vertex_format(struct intel_context *intel)
{
i915->meta.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
DSTORG_VERT_BIAS(0x8) | /* .5 */
format |
LOD_PRECLAMP_OGL |
TEX_DEFAULT_COLOR_OGL |
depth_format);
struct i915_context *i915 = i915_context(&intel->ctx);
i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;
/* fprintf(stderr, "%s: DV1: %x\n", */
/* __FUNCTION__, i915->meta.Buffer[I915_DESTREG_DV1]); */
}
#endif
static void set_vertex_format( i915ContextPtr i915 )
{
i915->meta.Ctx[I915_CTXREG_LIS2] =
i915->meta.Ctx[I915_CTXREG_LIS2] =
(S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) |
S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) |
S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT));
i915->meta.Ctx[I915_CTXREG_LIS4] &= ~S4_VFMT_MASK;
i915->meta.Ctx[I915_CTXREG_LIS4] |=
(S4_VFMT_COLOR |
S4_VFMT_SPEC_FOG |
S4_VFMT_XYZW);
i915->meta.Ctx[I915_CTXREG_LIS4] |= (S4_VFMT_COLOR | S4_VFMT_XYZ);
i915->meta.emitted &= ~I915_UPLOAD_CTX;
}
static void draw_quad(i915ContextPtr i915,
GLfloat x0, GLfloat x1,
GLfloat y0, GLfloat y1,
GLubyte red, GLubyte green,
GLubyte blue, GLubyte alpha,
GLfloat s0, GLfloat s1,
GLfloat t0, GLfloat t1 )
{
GLuint vertex_size = 8;
GLuint *vb = intelEmitInlinePrimitiveLocked( &i915->intel,
PRIM3D_TRIFAN,
4 * vertex_size,
vertex_size );
intelVertex tmp;
int i;
if (0)
fprintf(stderr, "%s: %f,%f-%f,%f 0x%x%x%x%x %f,%f-%f,%f\n",
__FUNCTION__,
x0,y0,x1,y1,red,green,blue,alpha,s0,t0,s1,t1);
/* initial vertex, left bottom */
tmp.v.x = x0;
tmp.v.y = y0;
tmp.v.z = 1.0;
tmp.v.w = 1.0;
tmp.v.color.red = red;
tmp.v.color.green = green;
tmp.v.color.blue = blue;
tmp.v.color.alpha = alpha;
tmp.v.specular.red = 0;
tmp.v.specular.green = 0;
tmp.v.specular.blue = 0;
tmp.v.specular.alpha = 0;
tmp.v.u0 = s0;
tmp.v.v0 = t0;
for (i = 0 ; i < vertex_size ; i++)
vb[i] = tmp.ui[i];
/* right bottom */
vb += vertex_size;
tmp.v.x = x1;
tmp.v.u0 = s1;
for (i = 0 ; i < vertex_size ; i++)
vb[i] = tmp.ui[i];
/* right top */
vb += vertex_size;
tmp.v.y = y1;
tmp.v.v0 = t1;
for (i = 0 ; i < vertex_size ; i++)
vb[i] = tmp.ui[i];
/* left top */
vb += vertex_size;
tmp.v.x = x0;
tmp.v.u0 = s0;
for (i = 0 ; i < vertex_size ; i++)
vb[i] = tmp.ui[i];
}
static void draw_poly(i915ContextPtr i915,
GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha,
GLuint numVerts,
/*const*/ GLfloat verts[][2],
/*const*/ GLfloat texcoords[][2])
{
GLuint vertex_size = 8;
GLuint *vb = intelEmitInlinePrimitiveLocked( &i915->intel,
PRIM3D_TRIFAN,
numVerts * vertex_size,
vertex_size );
intelVertex tmp;
int i, k;
/* initial constant vertex fields */
tmp.v.z = 1.0;
tmp.v.w = 1.0;
tmp.v.color.red = red;
tmp.v.color.green = green;
tmp.v.color.blue = blue;
tmp.v.color.alpha = alpha;
tmp.v.specular.red = 0;
tmp.v.specular.green = 0;
tmp.v.specular.blue = 0;
tmp.v.specular.alpha = 0;
for (k = 0; k < numVerts; k++) {
tmp.v.x = verts[k][0];
tmp.v.y = verts[k][1];
tmp.v.u0 = texcoords[k][0];
tmp.v.v0 = texcoords[k][1];
for (i = 0 ; i < vertex_size ; i++)
vb[i] = tmp.ui[i];
vb += vertex_size;
}
}
void
i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
GLboolean all,
GLint cx, GLint cy, GLint cw, GLint ch)
{
i915ContextPtr i915 = I915_CONTEXT( intel );
__DRIdrawablePrivate *dPriv = intel->driDrawable;
intelScreenPrivate *screen = intel->intelScreen;
int x0, y0, x1, y1;
SET_STATE( i915, meta );
set_initial_state( i915 );
set_no_texture( i915 );
set_vertex_format( i915 );
LOCK_HARDWARE(intel);
if (!all) {
x0 = cx;
y0 = cy;
x1 = x0 + cw;
y1 = y0 + ch;
} else {
x0 = 0;
y0 = 0;
x1 = x0 + dPriv->w;
y1 = y0 + dPriv->h;
}
/* Don't do any clipping to screen - these are window coordinates.
* The active cliprects will be applied as for any other geometry.
*/
if (mask & BUFFER_BIT_FRONT_LEFT) {
set_no_depth_stencil_write( i915 );
set_color_mask( i915, GL_TRUE );
set_draw_region( i915, &screen->front );
draw_quad(i915, x0, x1, y0, y1,
intel->clear_red, intel->clear_green,
intel->clear_blue, intel->clear_alpha,
0, 0, 0, 0);
}
if (mask & BUFFER_BIT_BACK_LEFT) {
set_no_depth_stencil_write( i915 );
set_color_mask( i915, GL_TRUE );
set_draw_region( i915, &screen->back );
draw_quad(i915, x0, x1, y0, y1,
intel->clear_red, intel->clear_green,
intel->clear_blue, intel->clear_alpha,
0, 0, 0, 0);
}
if (mask & BUFFER_BIT_STENCIL) {
set_stencil_replace( i915,
intel->ctx.Stencil.WriteMask[0],
intel->ctx.Stencil.Clear);
set_color_mask( i915, GL_FALSE );
set_draw_region( i915, &screen->front ); /* could be either? */
draw_quad( i915, x0, x1, y0, y1, 0, 0, 0, 0, 0, 0, 0, 0 );
}
UNLOCK_HARDWARE(intel);
SET_STATE( i915, state );
}
/**
* Copy the window contents named by dPriv to the rotated (or reflected)
* color buffer.
* srcBuf is BUFFER_BIT_FRONT_LEFT or BUFFER_BIT_BACK_LEFT to indicate the source.
/* Operations where the 3D engine is decoupled temporarily from the
* current GL state and used for other purposes than simply rendering
* incoming triangles.
*/
void
i915RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv,
GLuint srcBuf)
static void
install_meta_state(struct intel_context *intel)
{
i915ContextPtr i915 = I915_CONTEXT( intel );
intelScreenPrivate *screen = intel->intelScreen;
const GLuint cpp = screen->cpp;
drm_clip_rect_t fullRect;
GLuint textureFormat, srcOffset, srcPitch;
const drm_clip_rect_t *clipRects;
int numClipRects;
int i;
struct i915_context *i915 = i915_context(&intel->ctx);
memcpy(&i915->meta, &i915->initial, sizeof(i915->meta));
i915->meta.active = ACTIVE;
i915->meta.emitted = 0;
int xOrig, yOrig;
int origNumClipRects;
drm_clip_rect_t *origRects;
/*
* set up hardware state
*/
intelFlush( &intel->ctx );
SET_STATE( i915, meta );
set_initial_state( i915 );
set_no_texture( i915 );
set_vertex_format( i915 );
set_no_depth_stencil_write( i915 );
set_color_mask( i915, GL_TRUE );
LOCK_HARDWARE(intel);
/* save current drawing origin and cliprects (restored at end) */
xOrig = intel->drawX;
yOrig = intel->drawY;
origNumClipRects = intel->numClipRects;
origRects = intel->pClipRects;
if (!intel->numClipRects)
goto done;
/*
* set drawing origin, cliprects for full-screen access to rotated screen
*/
fullRect.x1 = 0;
fullRect.y1 = 0;
fullRect.x2 = screen->rotatedWidth;
fullRect.y2 = screen->rotatedHeight;
intel->drawX = 0;
intel->drawY = 0;
intel->numClipRects = 1;
intel->pClipRects = &fullRect;
set_draw_region( i915, &screen->rotated );
if (cpp == 4)
textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
else
textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
if (srcBuf == BUFFER_BIT_FRONT_LEFT) {
srcPitch = screen->front.pitch; /* in bytes */
srcOffset = screen->front.offset; /* bytes */
clipRects = dPriv->pClipRects;
numClipRects = dPriv->numClipRects;
}
else {
srcPitch = screen->back.pitch; /* in bytes */
srcOffset = screen->back.offset; /* bytes */
clipRects = dPriv->pBackClipRects;
numClipRects = dPriv->numBackClipRects;
}
/* set the whole screen up as a texture to avoid alignment issues */
set_tex_rect_source(i915,
srcOffset,
screen->width,
screen->height,
srcPitch,
textureFormat);
enable_texture_blend_replace(i915);
/*
* loop over the source window's cliprects
*/
for (i = 0; i < numClipRects; i++) {
int srcX0 = clipRects[i].x1;
int srcY0 = clipRects[i].y1;
int srcX1 = clipRects[i].x2;
int srcY1 = clipRects[i].y2;
GLfloat verts[4][2], tex[4][2];
int j;
/* build vertices for four corners of clip rect */
verts[0][0] = srcX0; verts[0][1] = srcY0;
verts[1][0] = srcX1; verts[1][1] = srcY0;
verts[2][0] = srcX1; verts[2][1] = srcY1;
verts[3][0] = srcX0; verts[3][1] = srcY1;
/* .. and texcoords */
tex[0][0] = srcX0; tex[0][1] = srcY0;
tex[1][0] = srcX1; tex[1][1] = srcY0;
tex[2][0] = srcX1; tex[2][1] = srcY1;
tex[3][0] = srcX0; tex[3][1] = srcY1;
/* transform coords to rotated screen coords */
for (j = 0; j < 4; j++) {
matrix23TransformCoordf(&screen->rotMatrix,
&verts[j][0], &verts[j][1]);
}
/* draw polygon to map source image to dest region */
draw_poly(i915, 255, 255, 255, 255, 4, verts, tex);
} /* cliprect loop */
intelFlushBatchLocked( intel, GL_FALSE, GL_FALSE, GL_FALSE );
done:
/* restore original drawing origin and cliprects */
intel->drawX = xOrig;
intel->drawY = yOrig;
intel->numClipRects = origNumClipRects;
intel->pClipRects = origRects;
UNLOCK_HARDWARE(intel);
SET_STATE( i915, state );
SET_STATE(i915, meta);
set_vertex_format(intel);
meta_no_texture(intel);
}
static void
leave_meta_state(struct intel_context *intel)
{
struct i915_context *i915 = i915_context(&intel->ctx);
intel_region_release(intel->intelScreen, &i915->meta.draw_region);
intel_region_release(intel->intelScreen, &i915->meta.depth_region);
/* intel_region_release(intel, &i915->meta.tex_region[0]); */
SET_STATE(i915, state);
}
void
i915InitMetaFuncs(struct i915_context *i915)
{
i915->intel.vtbl.install_meta_state = install_meta_state;
i915->intel.vtbl.leave_meta_state = leave_meta_state;
i915->intel.vtbl.meta_no_depth_write = meta_no_depth_write;
i915->intel.vtbl.meta_no_stencil_write = meta_no_stencil_write;
i915->intel.vtbl.meta_stencil_replace = meta_stencil_replace;
i915->intel.vtbl.meta_depth_replace = meta_depth_replace;
i915->intel.vtbl.meta_color_mask = meta_color_mask;
i915->intel.vtbl.meta_no_texture = meta_no_texture;
i915->intel.vtbl.meta_texture_blend_replace = meta_texture_blend_replace;
i915->intel.vtbl.meta_tex_rect_source = meta_tex_rect_source;
i915->intel.vtbl.meta_draw_region = meta_draw_region;
i915->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state;
}

View File

@@ -72,58 +72,62 @@
#define I915_CONSTFLAG_PARAM 0x1f
GLuint i915_get_temp( struct i915_fragment_program *p )
GLuint
i915_get_temp(struct i915_fragment_program *p)
{
int bit = ffs( ~p->temp_flag );
int bit = ffs(~p->temp_flag);
if (!bit) {
fprintf(stderr, "%s: out of temporaries\n", __FILE__);
exit(1);
}
p->temp_flag |= 1<<(bit-1);
return UREG(REG_TYPE_R, (bit-1));
p->temp_flag |= 1 << (bit - 1);
return UREG(REG_TYPE_R, (bit - 1));
}
GLuint i915_get_utemp( struct i915_fragment_program *p )
GLuint
i915_get_utemp(struct i915_fragment_program * p)
{
int bit = ffs( ~p->utemp_flag );
int bit = ffs(~p->utemp_flag);
if (!bit) {
fprintf(stderr, "%s: out of temporaries\n", __FILE__);
exit(1);
}
p->utemp_flag |= 1<<(bit-1);
return UREG(REG_TYPE_U, (bit-1));
p->utemp_flag |= 1 << (bit - 1);
return UREG(REG_TYPE_U, (bit - 1));
}
void i915_release_utemps( struct i915_fragment_program *p )
void
i915_release_utemps(struct i915_fragment_program *p)
{
p->utemp_flag = ~0x7;
}
GLuint i915_emit_decl( struct i915_fragment_program *p,
GLuint type, GLuint nr, GLuint d0_flags )
GLuint
i915_emit_decl(struct i915_fragment_program *p,
GLuint type, GLuint nr, GLuint d0_flags)
{
GLuint reg = UREG(type, nr);
if (type == REG_TYPE_T) {
if (p->decl_t & (1<<nr))
return reg;
if (p->decl_t & (1 << nr))
return reg;
p->decl_t |= (1<<nr);
p->decl_t |= (1 << nr);
}
else if (type == REG_TYPE_S) {
if (p->decl_s & (1<<nr))
return reg;
if (p->decl_s & (1 << nr))
return reg;
p->decl_s |= (1<<nr);
p->decl_s |= (1 << nr);
}
else
else
return reg;
*(p->decl++) = (D0_DCL | D0_DEST( reg ) | d0_flags);
*(p->decl++) = (D0_DCL | D0_DEST(reg) | d0_flags);
*(p->decl++) = D1_MBZ;
*(p->decl++) = D2_MBZ;
@@ -131,24 +135,26 @@ GLuint i915_emit_decl( struct i915_fragment_program *p,
return reg;
}
GLuint i915_emit_arith( struct i915_fragment_program *p,
GLuint op,
GLuint dest,
GLuint mask,
GLuint saturate,
GLuint src0,
GLuint src1,
GLuint src2 )
GLuint
i915_emit_arith(struct i915_fragment_program * p,
GLuint op,
GLuint dest,
GLuint mask,
GLuint saturate, GLuint src0, GLuint src1, GLuint src2)
{
GLuint c[3];
GLuint nr_const = 0;
assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
assert(dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest));
assert(dest);
if (GET_UREG_TYPE(src0) == REG_TYPE_CONST) c[nr_const++] = 0;
if (GET_UREG_TYPE(src1) == REG_TYPE_CONST) c[nr_const++] = 1;
if (GET_UREG_TYPE(src2) == REG_TYPE_CONST) c[nr_const++] = 2;
if (GET_UREG_TYPE(src0) == REG_TYPE_CONST)
c[nr_const++] = 0;
if (GET_UREG_TYPE(src1) == REG_TYPE_CONST)
c[nr_const++] = 1;
if (GET_UREG_TYPE(src2) == REG_TYPE_CONST)
c[nr_const++] = 2;
/* Recursively call this function to MOV additional const values
* into temporary registers. Use utemp registers for this -
@@ -164,31 +170,25 @@ GLuint i915_emit_arith( struct i915_fragment_program *p,
old_utemp_flag = p->utemp_flag;
first = GET_UREG_NR(s[c[0]]);
for (i = 1 ; i < nr_const ; i++) {
if (GET_UREG_NR(s[c[i]]) != first) {
GLuint tmp = i915_get_utemp(p);
for (i = 1; i < nr_const; i++) {
if (GET_UREG_NR(s[c[i]]) != first) {
GLuint tmp = i915_get_utemp(p);
i915_emit_arith( p, A0_MOV, tmp, A0_DEST_CHANNEL_ALL, 0,
s[c[i]], 0, 0 );
s[c[i]] = tmp;
}
i915_emit_arith(p, A0_MOV, tmp, A0_DEST_CHANNEL_ALL, 0,
s[c[i]], 0, 0);
s[c[i]] = tmp;
}
}
src0 = s[0];
src1 = s[1];
src2 = s[2];
p->utemp_flag = old_utemp_flag; /* restore */
p->utemp_flag = old_utemp_flag; /* restore */
}
*(p->csr++) = (op |
A0_DEST( dest ) |
mask |
saturate |
A0_SRC0( src0 ));
*(p->csr++) = (A1_SRC0( src0 ) |
A1_SRC1( src1 ));
*(p->csr++) = (A2_SRC1( src1 ) |
A2_SRC2( src2 ));
*(p->csr++) = (op | A0_DEST(dest) | mask | saturate | A0_SRC0(src0));
*(p->csr++) = (A1_SRC0(src0) | A1_SRC1(src1));
*(p->csr++) = (A2_SRC1(src1) | A2_SRC2(src2));
p->nr_alu_insn++;
return dest;
@@ -239,24 +239,28 @@ GLuint i915_emit_texld( struct i915_fragment_program *p,
}
GLuint i915_emit_const1f( struct i915_fragment_program *p, GLfloat c0 )
GLuint
i915_emit_const1f(struct i915_fragment_program * p, GLfloat c0)
{
GLint reg, idx;
if (c0 == 0.0) return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO);
if (c0 == 1.0) return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE );
if (c0 == 0.0)
return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO);
if (c0 == 1.0)
return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE);
for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
if (p->constant_flags[reg] == I915_CONSTFLAG_PARAM)
continue;
continue;
for (idx = 0; idx < 4; idx++) {
if (!(p->constant_flags[reg] & (1<<idx)) ||
p->constant[reg][idx] == c0) {
p->constant[reg][idx] = c0;
p->constant_flags[reg] |= 1<<idx;
if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
return swizzle(UREG(REG_TYPE_CONST, reg),idx,ZERO,ZERO,ONE);
}
if (!(p->constant_flags[reg] & (1 << idx)) ||
p->constant[reg][idx] == c0) {
p->constant[reg][idx] = c0;
p->constant_flags[reg] |= 1 << idx;
if (reg + 1 > p->nr_constants)
p->nr_constants = reg + 1;
return swizzle(UREG(REG_TYPE_CONST, reg), idx, ZERO, ZERO, ONE);
}
}
}
@@ -265,29 +269,35 @@ GLuint i915_emit_const1f( struct i915_fragment_program *p, GLfloat c0 )
return 0;
}
GLuint i915_emit_const2f( struct i915_fragment_program *p,
GLfloat c0, GLfloat c1 )
GLuint
i915_emit_const2f(struct i915_fragment_program * p, GLfloat c0, GLfloat c1)
{
GLint reg, idx;
if (c0 == 0.0) return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W);
if (c0 == 1.0) return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W);
if (c0 == 0.0)
return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W);
if (c0 == 1.0)
return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W);
if (c1 == 0.0) return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W);
if (c1 == 1.0) return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W);
if (c1 == 0.0)
return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W);
if (c1 == 1.0)
return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W);
for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
if (p->constant_flags[reg] == 0xf ||
p->constant_flags[reg] == I915_CONSTFLAG_PARAM)
continue;
p->constant_flags[reg] == I915_CONSTFLAG_PARAM)
continue;
for (idx = 0; idx < 3; idx++) {
if (!(p->constant_flags[reg] & (3<<idx))) {
p->constant[reg][idx] = c0;
p->constant[reg][idx+1] = c1;
p->constant_flags[reg] |= 3<<idx;
if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
return swizzle(UREG(REG_TYPE_CONST, reg),idx,idx+1,ZERO,ONE);
}
if (!(p->constant_flags[reg] & (3 << idx))) {
p->constant[reg][idx] = c0;
p->constant[reg][idx + 1] = c1;
p->constant_flags[reg] |= 3 << idx;
if (reg + 1 > p->nr_constants)
p->nr_constants = reg + 1;
return swizzle(UREG(REG_TYPE_CONST, reg), idx, idx + 1, ZERO,
ONE);
}
}
}
@@ -298,27 +308,28 @@ GLuint i915_emit_const2f( struct i915_fragment_program *p,
GLuint i915_emit_const4f( struct i915_fragment_program *p,
GLfloat c0, GLfloat c1, GLfloat c2, GLfloat c3 )
GLuint
i915_emit_const4f(struct i915_fragment_program * p,
GLfloat c0, GLfloat c1, GLfloat c2, GLfloat c3)
{
GLint reg;
for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
if (p->constant_flags[reg] == 0xf &&
p->constant[reg][0] == c0 &&
p->constant[reg][1] == c1 &&
p->constant[reg][2] == c2 &&
p->constant[reg][3] == c3) {
return UREG(REG_TYPE_CONST, reg);
p->constant[reg][0] == c0 &&
p->constant[reg][1] == c1 &&
p->constant[reg][2] == c2 && p->constant[reg][3] == c3) {
return UREG(REG_TYPE_CONST, reg);
}
else if (p->constant_flags[reg] == 0) {
p->constant[reg][0] = c0;
p->constant[reg][1] = c1;
p->constant[reg][2] = c2;
p->constant[reg][3] = c3;
p->constant_flags[reg] = 0xf;
if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
return UREG(REG_TYPE_CONST, reg);
p->constant[reg][0] = c0;
p->constant[reg][1] = c1;
p->constant[reg][2] = c2;
p->constant[reg][3] = c3;
p->constant_flags[reg] = 0xf;
if (reg + 1 > p->nr_constants)
p->nr_constants = reg + 1;
return UREG(REG_TYPE_CONST, reg);
}
}
@@ -328,34 +339,36 @@ GLuint i915_emit_const4f( struct i915_fragment_program *p,
}
GLuint i915_emit_const4fv( struct i915_fragment_program *p, const GLfloat *c )
GLuint
i915_emit_const4fv(struct i915_fragment_program * p, const GLfloat * c)
{
return i915_emit_const4f( p, c[0], c[1], c[2], c[3] );
return i915_emit_const4f(p, c[0], c[1], c[2], c[3]);
}
GLuint i915_emit_param4fv( struct i915_fragment_program *p,
const GLfloat *values )
GLuint
i915_emit_param4fv(struct i915_fragment_program * p, const GLfloat * values)
{
GLint reg, i;
for (i = 0; i < p->nr_params; i++) {
if (p->param[i].values == values)
return UREG(REG_TYPE_CONST, p->param[i].reg);
return UREG(REG_TYPE_CONST, p->param[i].reg);
}
for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
if (p->constant_flags[reg] == 0) {
p->constant_flags[reg] = I915_CONSTFLAG_PARAM;
i = p->nr_params++;
p->constant_flags[reg] = I915_CONSTFLAG_PARAM;
i = p->nr_params++;
p->param[i].values = values;
p->param[i].reg = reg;
p->params_uptodate = 0;
p->param[i].values = values;
p->param[i].reg = reg;
p->params_uptodate = 0;
if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
return UREG(REG_TYPE_CONST, reg);
if (reg + 1 > p->nr_constants)
p->nr_constants = reg + 1;
return UREG(REG_TYPE_CONST, reg);
}
}
@@ -367,7 +380,8 @@ GLuint i915_emit_param4fv( struct i915_fragment_program *p,
void i915_program_error( struct i915_fragment_program *p, const char *msg )
void
i915_program_error(struct i915_fragment_program *p, const char *msg)
{
/* XXX we shouldn't print anything to stdout, record GL error or
* call _mesa_problem()
@@ -376,23 +390,24 @@ void i915_program_error( struct i915_fragment_program *p, const char *msg )
p->error = 1;
}
void i915_init_program( i915ContextPtr i915, struct i915_fragment_program *p )
void
i915_init_program(struct i915_context *i915, struct i915_fragment_program *p)
{
GLcontext *ctx = &i915->intel.ctx;
TNLcontext *tnl = TNL_CONTEXT( ctx );
TNLcontext *tnl = TNL_CONTEXT(ctx);
p->translated = 0;
p->params_uptodate = 0;
p->on_hardware = 0;
p->error = 0;
p->nr_tex_indirect = 1; /* correct? */
p->nr_tex_indirect = 1; /* correct? */
p->nr_tex_insn = 0;
p->nr_alu_insn = 0;
p->nr_decl_insn = 0;
p->ctx = ctx;
memset( p->constant_flags, 0, sizeof(p->constant_flags) );
p->ctx = ctx;
memset(p->constant_flags, 0, sizeof(p->constant_flags));
p->nr_constants = 0;
p->csr = p->program;
@@ -414,12 +429,13 @@ void i915_init_program( i915ContextPtr i915, struct i915_fragment_program *p )
}
void i915_fini_program( struct i915_fragment_program *p )
void
i915_fini_program(struct i915_fragment_program *p)
{
GLuint program_size = p->csr - p->program;
GLuint decl_size = p->decl - p->declarations;
if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT)
if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT)
i915_program_error(p, "Exceeded max nr indirect texture lookups");
if (p->nr_tex_insn > I915_MAX_TEX_INSN)
@@ -449,22 +465,24 @@ void i915_fini_program( struct i915_fragment_program *p )
p->declarations[0] |= program_size + decl_size - 2;
}
void i915_upload_program( i915ContextPtr i915, struct i915_fragment_program *p )
void
i915_upload_program(struct i915_context *i915,
struct i915_fragment_program *p)
{
GLuint program_size = p->csr - p->program;
GLuint decl_size = p->decl - p->declarations;
FALLBACK( &i915->intel, I915_FALLBACK_PROGRAM, p->error );
FALLBACK(&i915->intel, I915_FALLBACK_PROGRAM, p->error);
/* Could just go straight to the batchbuffer from here:
*/
if (i915->state.ProgramSize != (program_size + decl_size) ||
memcmp(i915->state.Program + decl_size, p->program,
program_size*sizeof(int)) != 0) {
I915_STATECHANGE( i915, I915_UPLOAD_PROGRAM );
memcpy(i915->state.Program, p->declarations, decl_size*sizeof(int));
memcmp(i915->state.Program + decl_size, p->program,
program_size * sizeof(int)) != 0) {
I915_STATECHANGE(i915, I915_UPLOAD_PROGRAM);
memcpy(i915->state.Program, p->declarations, decl_size * sizeof(int));
memcpy(i915->state.Program + decl_size, p->program,
program_size*sizeof(int));
program_size * sizeof(int));
i915->state.ProgramSize = decl_size + program_size;
}
@@ -473,30 +491,28 @@ void i915_upload_program( i915ContextPtr i915, struct i915_fragment_program *p )
*/
if (p->nr_constants) {
GLuint nr = p->nr_constants;
I915_ACTIVESTATE( i915, I915_UPLOAD_CONSTANTS, 1 );
I915_STATECHANGE( i915, I915_UPLOAD_CONSTANTS );
I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 1);
I915_STATECHANGE(i915, I915_UPLOAD_CONSTANTS);
i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | ((nr) * 4);
i915->state.Constant[1] = (1<<(nr-1)) | ((1<<(nr-1))-1);
memcpy(&i915->state.Constant[2], p->constant, 4*sizeof(int)*(nr));
i915->state.Constant[1] = (1 << (nr - 1)) | ((1 << (nr - 1)) - 1);
memcpy(&i915->state.Constant[2], p->constant, 4 * sizeof(int) * (nr));
i915->state.ConstantSize = 2 + (nr) * 4;
if (0) {
GLuint i;
for (i = 0; i < nr; i++) {
fprintf(stderr, "const[%d]: %f %f %f %f\n", i,
p->constant[i][0],
p->constant[i][1],
p->constant[i][2],
p->constant[i][3]);
}
GLuint i;
for (i = 0; i < nr; i++) {
fprintf(stderr, "const[%d]: %f %f %f %f\n", i,
p->constant[i][0],
p->constant[i][1], p->constant[i][2], p->constant[i][3]);
}
}
}
else {
I915_ACTIVESTATE( i915, I915_UPLOAD_CONSTANTS, 0 );
}
I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0);
}
p->on_hardware = 1;
}

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