From 32e9cb0275fe33628d0081af0f47a28f8bb5e897 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Sat, 2 Dec 2006 23:46:07 +0000 Subject: Update to new upstream release (6.5.2). --- Makefile | 1 - configs/linux-dri-x86-64 | 2 +- configs/linux-fbdev | 10 +- debian/changelog | 7 + docs/README.directfb | 2 +- docs/news.html | 8 +- docs/relnotes-6.5.1.html | 2 +- docs/relnotes-6.5.2.html | 6 +- include/GL/directfbgl.h | 89 ------- include/GL/internal/glcore.h | 3 - src/glut/fbdev/callback.c | 3 - src/glut/fbdev/colormap.c | 6 + src/glut/fbdev/cursor.c | 22 +- src/glut/fbdev/fbdev.c | 91 ++++--- src/glut/fbdev/input.c | 282 +++++++++++++-------- src/glut/fbdev/internal.h | 5 +- src/glut/fbdev/menu.c | 2 +- src/glut/fbdev/overlay.c | 1 + src/mesa/Makefile | 4 +- src/mesa/drivers/directfb/idirectfbgl_mesa.c | 187 ++++++++------ src/mesa/drivers/dri/common/dri_util.c | 9 +- src/mesa/drivers/dri/i915/i830_metaops.c | 2 - src/mesa/drivers/dri/i915tex/i830_state.c | 3 +- src/mesa/drivers/dri/i915tex/i830_texstate.c | 32 ++- src/mesa/drivers/dri/i915tex/i830_vtbl.c | 8 +- src/mesa/drivers/dri/i915tex/server/i830_common.h | 8 + src/mesa/drivers/dri/i915tex/server/i830_dri.h | 42 ++- src/mesa/drivers/dri/i915tex/server/intel.h | 5 +- src/mesa/drivers/dri/i915tex/server/intel_dri.c | 81 ++++-- src/mesa/drivers/dri/i965/brw_context.c | 2 + src/mesa/drivers/dri/i965/brw_context.h | 6 +- src/mesa/drivers/dri/i965/brw_fallback.c | 3 + src/mesa/drivers/dri/i965/brw_metaops.c | 100 +++++++- src/mesa/drivers/dri/i965/brw_tex.c | 32 +++ src/mesa/drivers/dri/i965/brw_vtbl.c | 1 + src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 + src/mesa/drivers/dri/i965/intel_context.c | 5 + src/mesa/drivers/dri/i965/intel_context.h | 7 +- src/mesa/drivers/dri/i965/intel_pixel_copy.c | 105 +++++++- src/mesa/drivers/dri/i965/intel_tex_validate.c | 3 + src/mesa/drivers/dri/mga/mgatex.c | 3 + src/mesa/drivers/dri/r200/r200_context.h | 2 + src/mesa/drivers/dri/r200/r200_maos_arrays.c | 111 +++++++- src/mesa/drivers/dri/r200/r200_sanity.c | 2 +- src/mesa/drivers/dri/r200/r200_vertprog.c | 7 + src/mesa/main/context.c | 2 +- src/mesa/shader/arbprogram.c | 10 +- src/mesa/shader/atifragshader.c | 2 + src/mesa/shader/program.c | 4 + src/mesa/shader/slang/slang_assemble_assignment.c | 184 +++++++------- src/mesa/shader/slang/slang_assemble_assignment.h | 17 +- src/mesa/shader/slang/slang_assemble_constructor.c | 43 ++-- src/mesa/shader/slang/slang_assemble_constructor.h | 7 +- src/mesa/shader/slang/slang_compile.c | 52 +--- src/mesa/shader/slang/slang_compile_function.h | 4 +- src/mesa/shader/slang/slang_compile_operation.c | 125 +++++---- src/mesa/shader/slang/slang_compile_operation.h | 23 +- src/mesa/shader/slang/slang_compile_variable.c | 26 ++ src/mesa/shader/slang/slang_compile_variable.h | 3 + src/mesa/tnl/t_vb_arbprogram.c | 2 +- 60 files changed, 1171 insertions(+), 651 deletions(-) delete mode 100644 include/GL/directfbgl.h diff --git a/Makefile b/Makefile index b95cedda8d8..74784888981 100644 --- a/Makefile +++ b/Makefile @@ -174,7 +174,6 @@ MAIN_FILES = \ $(DIRECTORY)/include/GL/internal/glcore.h \ $(DIRECTORY)/include/GL/amesa.h \ $(DIRECTORY)/include/GL/dmesa.h \ - $(DIRECTORY)/include/GL/directfbgl.h \ $(DIRECTORY)/include/GL/fxmesa.h \ $(DIRECTORY)/include/GL/ggimesa.h \ $(DIRECTORY)/include/GL/gl.h \ diff --git a/configs/linux-dri-x86-64 b/configs/linux-dri-x86-64 index 4fbd0a0876d..821ab3e3366 100644 --- a/configs/linux-dri-x86-64 +++ b/configs/linux-dri-x86-64 @@ -20,5 +20,5 @@ EXTRA_LIB_PATH=-L/usr/X11R6/lib64 # the new interface. i810 are missing because there is no x86-64 # system where they could *ever* be used. # -DRI_DIRS = i915 mach64 mga r128 r200 radeon tdfx unichrome savage r300 +DRI_DIRS = i915tex i915 i965 mach64 mga r128 r200 radeon tdfx unichrome savage r300 diff --git a/configs/linux-fbdev b/configs/linux-fbdev index 7a5d1b600f9..e36d20a702c 100644 --- a/configs/linux-fbdev +++ b/configs/linux-fbdev @@ -4,17 +4,13 @@ include $(TOP)/configs/linux CONFIG_NAME = linux-fbdev -DRIVER_DIRS = fbdev +CFLAGS = -O3 -ffast-math -ansi -pedantic -fPIC -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DPTHREADS -DUSE_GLFBDEV_DRIVER 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 +DRIVER_DIRS = fbdev osmesa PROGRAM_DIRS = fbdev demos redbook samples GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread +OSMESA_LIB_DEPS = -lm -lpthread GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lgpm -lm diff --git a/debian/changelog b/debian/changelog index 342741b5a05..b24e4e7f845 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +mesa (6.5.2-0.1) experimental; urgency=low + + * Non-maintainer upload. + * New upstream release. + + -- Thierry Reding Sun, 3 Dec 2006 00:45:09 +0100 + mesa (6.5.2~rc3-0.1) experimental; urgency=low * Non-maintainer upload. diff --git a/docs/README.directfb b/docs/README.directfb index 169ebe486ee..e3bada4888b 100644 --- a/docs/README.directfb +++ b/docs/README.directfb @@ -6,7 +6,7 @@ Requirements ============ To build Mesa with DirectFB (DirectFBGL) support you need: - - DirectFB at least 0.9.21 (http://directfb.org) + - DirectFB at least 1.0.0 (http://directfb.org) - pkg-config at least 0.9 (http://pkgconfig.sf.net) diff --git a/docs/news.html b/docs/news.html index 9cd622fe227..c5f68a6e231 100644 --- a/docs/news.html +++ b/docs/news.html @@ -11,6 +11,12 @@

News

+

December 2, 2006

+

+Mesa 6.5.2 has been released. +This is a new development release. +

+

September 15, 2006

Mesa 6.5.1 has been released. @@ -1070,6 +1076,6 @@ source code.


-$Id: news.html,v 3.32 2006/09/21 22:51:16 brianp Exp $ +$Id: news.html,v 3.33 2006/12/02 18:18:41 brianp Exp $ diff --git a/docs/relnotes-6.5.1.html b/docs/relnotes-6.5.1.html index b053203f72a..0f03f931e02 100644 --- a/docs/relnotes-6.5.1.html +++ b/docs/relnotes-6.5.1.html @@ -12,7 +12,7 @@

Mesa 6.5.1 is a 6.5 follow-on development release mostly consisting of -bug fixes. +bug fixes.

diff --git a/docs/relnotes-6.5.2.html b/docs/relnotes-6.5.2.html index a8eb970cd24..c4597c9d1a1 100644 --- a/docs/relnotes-6.5.2.html +++ b/docs/relnotes-6.5.2.html @@ -8,11 +8,11 @@ -

Mesa 6.5.2 Release Notes / (in progress)

+

Mesa 6.5.2 Release Notes / December 2, 2006

-Mesa 6.5.2 is a 6.5 follow-on development release mostly consisting of -bug fixes. +Mesa 6.5.2 is a 6.5 follow-on development release with a few new features +but mostly consisting of bug fixes.

diff --git a/include/GL/directfbgl.h b/include/GL/directfbgl.h deleted file mode 100644 index 984c4b14279..00000000000 --- a/include/GL/directfbgl.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - (c) Copyright 2001 convergence integrated media GmbH. - All rights reserved. - - Written by Denis Oliver Kropp and - Andreas Hundt . - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. -*/ - -#ifndef __DIRECTFBGL_H__ -#define __DIRECTFBGL_H__ - -#include - -#ifdef __cplusplus -extern "C" -{ -#endif - - -typedef struct { - int buffer_size; - int depth_size; - int stencil_size; - int aux_buffers; - - int red_size; - int green_size; - int blue_size; - int alpha_size; - - int accum_red_size; - int accum_green_size; - int accum_blue_size; - int accum_alpha_size; - - DFBBoolean double_buffer; - DFBBoolean stereo; -} DFBGLAttributes; - - -DEFINE_INTERFACE( IDirectFBGL, - - /** Context handling **/ - - /* - * Acquire the hardware lock. - */ - DFBResult (*Lock) ( - IDirectFBGL *thiz - ); - - /* - * Release the lock. - */ - DFBResult (*Unlock) ( - IDirectFBGL *thiz - ); - - /* - * Query the OpenGL attributes. - */ - DFBResult (*GetAttributes) ( - IDirectFBGL *thiz, - DFBGLAttributes *attributes - ); -) - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/include/GL/internal/glcore.h b/include/GL/internal/glcore.h index d5cbd3b2a5c..ca3cf5be572 100644 --- a/include/GL/internal/glcore.h +++ b/include/GL/internal/glcore.h @@ -1,4 +1,3 @@ -/* $XFree86: xc/lib/GL/include/GL/internal/glcore.h,v 1.7 2001/03/25 05:32:00 tsi Exp $ */ #ifndef __gl_core_h_ #define __gl_core_h_ @@ -37,9 +36,7 @@ ** */ -#ifndef XFree86LOADER #include -#endif #ifdef CAPI #undef CAPI diff --git a/src/glut/fbdev/callback.c b/src/glut/fbdev/callback.c index 946c8d8c133..8c039f530be 100644 --- a/src/glut/fbdev/callback.c +++ b/src/glut/fbdev/callback.c @@ -74,19 +74,16 @@ void glutKeyboardUpFunc(void (*func)(unsigned char key, int x, int y)) 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; } diff --git a/src/glut/fbdev/colormap.c b/src/glut/fbdev/colormap.c index 3a81f93657d..3e72a7b0513 100644 --- a/src/glut/fbdev/colormap.c +++ b/src/glut/fbdev/colormap.c @@ -92,12 +92,18 @@ static void FillReverseColorMap(void) void RestoreColorMap(void) { + if(FixedInfo.visual == FB_VISUAL_TRUECOLOR) + return; + if (ioctl(FrameBufferFD, FBIOPUTCMAP, (void *) &ColorMap) < 0) sprintf(exiterror, "ioctl(FBIOPUTCMAP) failed!\n"); } void LoadColorMap(void) { + if(FixedInfo.visual == FB_VISUAL_TRUECOLOR) + return; + ColorMap.start = 0; ColorMap.red = RedColorMap; ColorMap.green = GreenColorMap; diff --git a/src/glut/fbdev/cursor.c b/src/glut/fbdev/cursor.c index 6cd087e93c8..4bb2b7fba01 100644 --- a/src/glut/fbdev/cursor.c +++ b/src/glut/fbdev/cursor.c @@ -66,6 +66,9 @@ void EraseCursor(void) unsigned char *src = MouseBuffer; + if(!MouseVisible || CurrentCursor < 0 || CurrentCursor >= NUM_CURSORS) + return; + for(i = 0; i= NUM_CURSORS) + if(!MouseVisible || CurrentCursor < 0 || CurrentCursor >= NUM_CURSORS) return; px = MouseX - CursorsXOffset[CurrentCursor]; @@ -212,10 +215,12 @@ void SwapCursor(void) int miny = MIN(py, LastMouseY); int sizey = abs(py - LastMouseY); - DrawCursor(); - /* now update the portion of the screen that has changed */ + if(MouseVisible) + DrawCursor(); - if(DisplayMode & GLUT_DOUBLE && (sizex || sizey)) { + /* now update the portion of the screen that has changed, this is also + used to hide the mouse if MouseVisible is 0 */ + if(DisplayMode & GLUT_DOUBLE && ((sizex || sizey) || !MouseVisible)) { int off, stride, i; if(minx < 0) minx = 0; @@ -230,7 +235,7 @@ void SwapCursor(void) + minx * VarInfo.bits_per_pixel / 8; stride = (sizex + CURSOR_WIDTH) * VarInfo.bits_per_pixel / 8; - for(i = 0; i< sizey + CURSOR_HEIGHT; i++) { + for(i = 0; i < sizey + CURSOR_HEIGHT; i++) { memcpy(FrameBuffer+off, BackBuffer+off, stride); off += FixedInfo.line_length; } @@ -260,11 +265,8 @@ void glutSetCursor(int cursor) if(cursor == GLUT_CURSOR_FULL_CROSSHAIR) cursor = GLUT_CURSOR_CROSSHAIR; - if(CurrentCursor >= 0 && CurrentCursor < NUM_CURSORS) - EraseCursor(); - + EraseCursor(); + MouseVisible = 1; CurrentCursor = cursor; - - MouseEnabled = 1; SwapCursor(); } diff --git a/src/glut/fbdev/fbdev.c b/src/glut/fbdev/fbdev.c index 7b46d545920..3b63cd70ea1 100644 --- a/src/glut/fbdev/fbdev.c +++ b/src/glut/fbdev/fbdev.c @@ -74,6 +74,7 @@ int Redisplay; int Visible; int VisibleSwitch; int Active; +static int Resized; /* we have to poll to see if we are visible on a framebuffer that is not active */ int VisiblePoll; @@ -127,8 +128,10 @@ static void Cleanup(void) fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n", strerror(errno)); - munmap(FrameBuffer, FixedInfo.smem_len); + if(FrameBuffer) + munmap(FrameBuffer, FixedInfo.smem_len); close(FrameBufferFD); + } /* free allocated back buffer */ @@ -424,6 +427,8 @@ static void ProcessTimers(void) void glutMainLoop(void) { + int idleiters; + if(ReshapeFunc) ReshapeFunc(VarInfo.xres, VarInfo.yres); @@ -440,8 +445,6 @@ void glutMainLoop(void) else if(VisiblePoll) TestVisible(); - else - usleep(1); if(IdleFunc) IdleFunc(); @@ -452,17 +455,48 @@ void glutMainLoop(void) VisibilityFunc(Visible ? GLUT_VISIBLE : GLUT_NOT_VISIBLE); } + if(Resized) { + 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; + Resized = 0; + } + if(Visible && Redisplay) { Redisplay = 0; - if(MouseEnabled) - EraseCursor(); + EraseCursor(); DisplayFunc(); if(!(DisplayMode & GLUT_DOUBLE)) { if(ActiveMenu) DrawMenus(); - if(MouseEnabled) - DrawCursor(); + DrawCursor(); } + idleiters = 0; + } else { + /* we sleep if not receiving redisplays, and + the main loop is running faster than 2khz */ + + static int lasttime; + int time = glutGet(GLUT_ELAPSED_TIME); + if(time > lasttime) { + if(idleiters >= 2) + usleep(100); + + idleiters = 0; + lasttime = time; + } + idleiters++; } } } @@ -536,17 +570,16 @@ int ParseFBModes(int minw, int maxw, int minh, int maxh, int minf, int maxf) 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)); + sprintf(exiterror, "FBIOPUT_VSCREENINFO failed: %s\n", strerror(errno)); + strcat(exiterror, "Perhaps the device does not support the selected mode\n"); exit(0); } - /* reload the screen info to update offsets */ + /* reload the screen info to update rgb bits */ if (ioctl(FrameBufferFD, FBIOGET_VSCREENINFO, &VarInfo)) { sprintf(exiterror, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n", strerror(errno)); @@ -571,11 +604,10 @@ void SetVideoMode(void) } /* initialize colormap */ - if(FixedInfo.visual != FB_VISUAL_TRUECOLOR) - LoadColorMap(); + LoadColorMap(); } -void CreateBuffer() +void CreateBuffer(void) { int size = VarInfo.xres_virtual * VarInfo.yres_virtual * VarInfo.bits_per_pixel / 8; @@ -674,20 +706,6 @@ void CreateVisual(void) } } -static void ResizeVisual(void) -{ - if(!glFBDevMakeCurrent( Context, Buffer, Buffer )) { - sprintf(exiterror, "Failure to Make Current\n"); - exit(0); - } - - InitializeMenus(); - - if(ReshapeFunc) - ReshapeFunc(VarInfo.xres, VarInfo.yres); - Redisplay = 1; -} - static void SignalWinch(int arg) { /* we can't change bitdepth without destroying the visual */ @@ -709,10 +727,7 @@ static void SignalWinch(int arg) VarInfo.blue = blue; VarInfo.transp = transp; - SetVideoMode(); - CreateBuffer(); - - ResizeVisual(); + Resized = 1; } int glutCreateWindow (const char *title) @@ -805,12 +820,14 @@ void glutSwapBuffers(void) { glFlush(); + if(!(DisplayMode & GLUT_DOUBLE)) + return; + if(ActiveMenu) DrawMenus(); - if(MouseEnabled) - DrawCursor(); + DrawCursor(); - if(DisplayMode & GLUT_DOUBLE && Visible) { + if(Visible) { Swapping = 1; glFBDevSwapBuffers(Buffer); Swapping = 0; @@ -839,10 +856,8 @@ void glutReshapeWindow(int width, int height) signal(SIGWINCH, SIG_IGN); SetVideoMode(); - CreateBuffer(); - - ResizeVisual(); signal(SIGWINCH, SignalWinch); + Resized = 1; } void glutFullScreen(void) diff --git a/src/glut/fbdev/input.c b/src/glut/fbdev/input.c index d09de22ed7e..044aa50fd86 100644 --- a/src/glut/fbdev/input.c +++ b/src/glut/fbdev/input.c @@ -65,8 +65,8 @@ double MouseSpeed = 0; int KeyRepeatMode = GLUT_KEY_REPEAT_DEFAULT; -/* only display the mouse if there is a registered callback for it */ -int MouseEnabled = 0; +int MouseVisible = 0; +int LastMouseTime = 0; static int OldKDMode = -1; static int OldMode = KD_TEXT; @@ -79,6 +79,8 @@ static int MouseFD; static int kbdpipe[2]; +static int LastStdinKeyTime, LastStdinSpecialKey = -1, LastStdinCode = -1; + #define MODIFIER(mod) \ KeyboardModifiers = release ? KeyboardModifiers & ~mod \ : KeyboardModifiers | mod; @@ -93,7 +95,6 @@ static void KeyboardHandler(int sig) unsigned char code; while(read(ConsoleFD, &code, 1) == 1) { - int release, labelval; struct kbentry entry; static int lalt; /* only left alt does vt switch */ @@ -163,10 +164,47 @@ static void LedModifier(int led, int release) KeyboardLedState ^= led; releaseflag &= ~led; } + ioctl(ConsoleFD, KDSKBLED, KeyboardLedState); ioctl(ConsoleFD, KDSETLED, 0x80); } +static void HandleKeyPress(unsigned char key, int up) +{ + if(up) { + if(KeyboardUpFunc) + KeyboardUpFunc(key, MouseX, MouseY); + } else + if(KeyboardFunc) + KeyboardFunc(key, MouseX, MouseY); + + /* there was no keyboard handler to provide a way to exit the program */ + if(key == 27) + exit(0); +} + +static void HandleSpecialPress(int key, int up) +{ + if(up) { + if(SpecialUpFunc) + SpecialUpFunc(key, MouseX, MouseY); + } else + if(SpecialFunc) + SpecialFunc(key, MouseX, MouseY); +} + +static void ReleaseStdinKey(void) +{ + if(LastStdinSpecialKey != -1) { + HandleSpecialPress(LastStdinSpecialKey, 1); + LastStdinSpecialKey = -1; + } + if(LastStdinCode != -1) { + HandleKeyPress(LastStdinCode, 1); + LastStdinCode = -1; + } +} + #define READKEY read(kbdpipe[0], &code, 1) static int ReadKey(void) { @@ -175,8 +213,14 @@ static int ReadKey(void) int specialkey = 0; struct kbentry entry; - if(READKEY != 1) + if(READKEY != 1) { + /* if we are reading from stdin, we detect key releases when the key + does not repeat after a given timeout */ + if(ConsoleFD == 0 && LastStdinKeyTime + 100 < glutGet(GLUT_ELAPSED_TIME)) + ReleaseStdinKey(); return 0; + } + if(code == 0) return 0; @@ -185,65 +229,82 @@ static int ReadKey(void) 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: + if(code != 91) { KeyboardModifiers |= GLUT_ACTIVE_ALT; goto altset; } + 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 52: + specialkey = GLUT_KEY_END; READKEY; break; + case 53: + specialkey = GLUT_KEY_PAGE_UP; READKEY; break; + case 54: + specialkey = GLUT_KEY_PAGE_DOWN; READKEY; break; + case 49: + READKEY; + if(code == 126) + specialkey = GLUT_KEY_HOME; + else { + specialkey = GLUT_KEY_F1 + code - 50; + READKEY; + } + break; + case 50: + READKEY; + if(code == 126) + specialkey = GLUT_KEY_INSERT; + else { + if(code > '1') + code--; + if(code > '6') + code--; + if(code > '3') { + KeyboardModifiers |= GLUT_ACTIVE_SHIFT; + code -= 12; + } + specialkey = GLUT_KEY_F1 + code - 40; + READKEY; + } + break; + case 51: + READKEY; + if(code == 126) { + code = '\b'; + goto stdkey; + } + KeyboardModifiers |= GLUT_ACTIVE_SHIFT; + specialkey = GLUT_KEY_F1 + code - 45; + READKEY; + break; + case 91: + READKEY; + specialkey = GLUT_KEY_F1 + code - 65; + break; + default: + return 0; + } } if(specialkey) { - if(SpecialFunc) - SpecialFunc(specialkey, MouseX, MouseY); + LastStdinKeyTime = glutGet(GLUT_ELAPSED_TIME); + + if(LastStdinSpecialKey != specialkey) { + ReleaseStdinKey(); + HandleSpecialPress(specialkey, 0); + LastStdinSpecialKey = specialkey; + LastStdinKeyTime += 200; /* initial repeat */ + } else + if(KeyRepeatMode != GLUT_KEY_REPEAT_OFF) + HandleSpecialPress(specialkey, 0); } else { if(code >= 1 && code <= 26 && code != '\r') { KeyboardModifiers |= GLUT_ACTIVE_CTRL; @@ -255,8 +316,15 @@ static int ReadKey(void) KeyboardModifiers |= GLUT_ACTIVE_SHIFT; stdkey: - if(KeyboardFunc) - KeyboardFunc(code, MouseX, MouseY); + LastStdinKeyTime = glutGet(GLUT_ELAPSED_TIME); + if(LastStdinCode != code) { + ReleaseStdinKey(); + HandleKeyPress(code, 0); + LastStdinCode = code; + LastStdinKeyTime += 200; /* initial repeat */ + } else + if(KeyRepeatMode != GLUT_KEY_REPEAT_OFF) + HandleSpecialPress(code, 0); } return 1; } @@ -348,12 +416,7 @@ static int ReadKey(void) /* dispatch callback */ if(specialkey) { - if(release) { - if(SpecialUpFunc) - SpecialUpFunc(specialkey, MouseX, MouseY); - } else - if(SpecialFunc) - SpecialFunc(specialkey, MouseX, MouseY); + HandleSpecialPress(specialkey, release); } else { char c = labelval; @@ -364,12 +427,7 @@ static int ReadKey(void) if(c >= 'a' && c <= 'z') c += 'A' - 'a'; } - if(release) { - if(KeyboardUpFunc) - KeyboardUpFunc(c, MouseX, MouseY); - } else - if(KeyboardFunc) - KeyboardFunc(c, MouseX, MouseY); + HandleKeyPress(c, release); } return 1; } @@ -432,28 +490,22 @@ static int ReadMouse(void) dy = event.dy; } else #endif - { - char data[4]; - - if(MouseFD == -1) - return 0; + { + char data[4]; - if(fcntl(MouseFD, F_SETFL, O_NONBLOCK) == -1) { - close(MouseFD); - MouseFD = -1; - return 0; - } + if(MouseFD == -1) + return 0; - if(read(MouseFD, data, 4) != 4) - 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); + 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)); - } + dx = (((data[0] & 0x03) << 6) | (data[1] & 0x3F)); + dy = (((data[0] & 0x0C) << 4) | (data[2] & 0x3F)); + } MouseX += dx * MouseSpeed; if(MouseX < 0) @@ -478,7 +530,7 @@ static int ReadMouse(void) ll = l, lm = m, lr = r; - if(dx || dy) { + if(dx || dy || !MouseVisible) { if(l || m || r) { if(MotionFunc) MotionFunc(MouseX, MouseY); @@ -488,12 +540,16 @@ static int ReadMouse(void) EraseCursor(); + MouseVisible = 1; + if(ActiveMenu) Redisplay = 1; else SwapCursor(); } + LastMouseTime = glutGet(GLUT_ELAPSED_TIME); + return 1; } @@ -502,8 +558,14 @@ void ReceiveInput(void) if(ConsoleFD != -1) while(ReadKey()); - if(MouseEnabled) - while(ReadMouse()); + while(ReadMouse()); + + /* implement a 2 second timeout on the mouse */ + if(MouseVisible && glutGet(GLUT_ELAPSED_TIME) - LastMouseTime > 2000) { + EraseCursor(); + MouseVisible = 0; + SwapCursor(); + } } static void VTSwitchHandler(int sig) @@ -526,11 +588,7 @@ static void VTSwitchHandler(int sig) if(st.v_active) ioctl(ConsoleFD, VT_RELDISP, VT_ACKACQ); - /* this is a hack to turn the cursor off */ - ioctl(FrameBufferFD, FBIOPUT_VSCREENINFO, &VarInfo); - - if(FixedInfo.visual != FB_VISUAL_TRUECOLOR) - RestoreColorMap(); + RestoreColorMap(); Active = 1; Visible = 1; @@ -570,11 +628,6 @@ void InitializeVT(int usestdin) 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) { @@ -582,6 +635,12 @@ void InitializeVT(int usestdin) return; } + /* enable sigio for input */ + if(fcntl(0, F_SETFL, O_ASYNC) < 0) { + sprintf(exiterror, "Failed to set O_ASYNC mode on fd 0\n"); + exit(0); + } + /* detect the current vt if it was not specified */ if(CurrentVT == 0) { int fd = open("/dev/tty", O_RDWR | O_NDELAY, 0); @@ -590,15 +649,16 @@ void InitializeVT(int usestdin) 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; + } + CurrentVT = st.v_active; close(fd); } @@ -686,10 +746,10 @@ void RestoreVT(void) if (tcsetattr(0, TCSANOW, &OldTermios) < 0) fprintf(stderr, "tcsetattr failed\n"); - /* setting the mode to text from graphics restores the colormap*/ + /* setting the mode to text from graphics restores the colormap */ if( #ifdef HAVE_GPM - GpmMouse || + !GpmMouse || #endif ConsoleFD == 0) if(ioctl(ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) @@ -725,11 +785,11 @@ void InitializeMouse(void) const char *mousedev = getenv("MOUSE"); if(!mousedev) mousedev = MOUSEDEV; - if((MouseFD = open(mousedev, O_RDONLY)) >= 0) { - if(!MouseSpeed) - MouseSpeed = 1; - NumMouseButtons = 3; - return; + if((MouseFD = open(mousedev, O_RDONLY | O_NONBLOCK)) >= 0) { + if(!MouseSpeed) + MouseSpeed = 1; + NumMouseButtons = 3; + return; } } #ifdef HAVE_GPM diff --git a/src/glut/fbdev/internal.h b/src/glut/fbdev/internal.h index 8801cc9f6c3..0a159d96b0a 100644 --- a/src/glut/fbdev/internal.h +++ b/src/glut/fbdev/internal.h @@ -51,6 +51,8 @@ extern int Swapping, VTSwitch; void TestVisible(void); int ParseFBModes(int, int, int, int, int, int); +void SetVideoMode(void); +void CreateBuffer(void); void CreateVisual(void); extern int FrameBufferFD; @@ -84,7 +86,8 @@ void RestoreColorMap(void); /* --- mouse --- */ extern int MouseX, MouseY; extern int CurrentCursor; -extern int MouseEnabled; +extern int MouseVisible; +extern int LastMouseTime; extern int NumMouseButtons; void InitializeCursor(void); diff --git a/src/glut/fbdev/menu.c b/src/glut/fbdev/menu.c index 18cd58d6a2d..4ab4eb30d46 100644 --- a/src/glut/fbdev/menu.c +++ b/src/glut/fbdev/menu.c @@ -71,6 +71,7 @@ void FreeMenus(void) free(Menus[i].Items[j].name); free(Menus[i].Items); } + free(Menus); } @@ -206,7 +207,6 @@ void CloseMenu(void) int glutCreateMenu(void (*func)(int value)) { - MouseEnabled = 1; CurrentMenu = NumMenus; NumMenus++; Menus = realloc(Menus, sizeof(*Menus) * NumMenus); diff --git a/src/glut/fbdev/overlay.c b/src/glut/fbdev/overlay.c index 8bd207155c0..374cf30e7df 100644 --- a/src/glut/fbdev/overlay.c +++ b/src/glut/fbdev/overlay.c @@ -24,6 +24,7 @@ * Written by Sean D'Epagnier (c) 2006 */ +#include #include void glutEstablishOverlay(void) diff --git a/src/mesa/Makefile b/src/mesa/Makefile index 3f65ecf5cc9..1cd9e5b2bb7 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -33,8 +33,8 @@ default: $(MAKE) beos ; \ elif [ "$(DRIVER_DIRS)" = "directfb" ]; then \ $(MAKE) directfb ; \ - elif [ "$(DRIVER_DIRS)" = "fbdev" ]; then \ - $(MAKE) fbdev ; \ + elif [ "$(DRIVER_DIRS)" = "fbdev osmesa" ]; then \ + $(MAKE) fbdev ; $(MAKE) osmesa-only ; \ else \ $(MAKE) stand-alone ; \ fi diff --git a/src/mesa/drivers/directfb/idirectfbgl_mesa.c b/src/mesa/drivers/directfb/idirectfbgl_mesa.c index 323cdd67913..3c8c6c256e6 100644 --- a/src/mesa/drivers/directfb/idirectfbgl_mesa.c +++ b/src/mesa/drivers/directfb/idirectfbgl_mesa.c @@ -25,24 +25,16 @@ #include -#include -#include -#include - #include #include -#define VERSION_CODE( M, m, r ) (((M) * 1000) + ((m) * 100) + ((r))) -#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ - DIRECTFB_MINOR_VERSION, \ - DIRECTFB_MICRO_VERSION ) +#include +#include +#include +#include -#ifdef CLAMP -# undef CLAMP -#endif - -#include "GL/directfbgl.h" +#undef CLAMP #include "glheader.h" #include "buffers.h" #include "context.h" @@ -62,6 +54,12 @@ #include "drivers/common/driverfuncs.h" +#define VERSION_CODE( M, m, r ) (((M) * 1000) + ((m) * 100) + ((r))) +#define DIRECTFB_VERSION_CODE VERSION_CODE( DIRECTFB_MAJOR_VERSION, \ + DIRECTFB_MINOR_VERSION, \ + DIRECTFB_MICRO_VERSION ) + + static DFBResult Probe( void *data ); @@ -79,7 +77,7 @@ DIRECT_INTERFACE_IMPLEMENTATION( IDirectFBGL, Mesa ) typedef struct { int ref; /* reference counter */ - DFBBoolean locked; + int locked; IDirectFBSurface *surface; DFBSurfacePixelFormat format; @@ -87,8 +85,8 @@ typedef struct { int height; struct { - __u8 *start; - __u8 *end; + GLubyte *start; + GLubyte *end; int pitch; } video; @@ -185,12 +183,14 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) IDirectFBSurface *surface; int width = 0; int height = 0; - DFBResult err; + DFBResult ret; DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); - if (data->locked) - return DFB_LOCKED; + if (data->locked) { + data->locked++; + return DFB_OK; + } if (directfbgl_lock()) return DFB_LOCKED; @@ -198,11 +198,12 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) surface = data->surface; surface->GetSize( surface, &width, &height ); - err = surface->Lock( surface, DSLF_READ | DSLF_WRITE, + ret = surface->Lock( surface, DSLF_READ | DSLF_WRITE, (void*)&data->video.start, &data->video.pitch ); - if (err != DFB_OK) { + if (ret) { D_ERROR( "DirectFBGL/Mesa: couldn't lock surface.\n" ); - return err; + directfbgl_unlock(); + return ret; } data->video.end = data->video.start + (height-1) * data->video.pitch; @@ -212,13 +213,13 @@ IDirectFBGL_Mesa_Lock( IDirectFBGL *thiz ) &data->framebuffer, &data->framebuffer ); if (data->width != width || data->height != height) { + _mesa_resize_framebuffer( &data->context, + &data->framebuffer, width, height ); data->width = width; - data->height = height; - _mesa_resize_framebuffer(&data->context, - &data->framebuffer, width, height); + data->height = height; } - data->locked = DFB_TRUE; + data->locked++; return DFB_OK; } @@ -230,14 +231,14 @@ IDirectFBGL_Mesa_Unlock( IDirectFBGL *thiz ) if (!data->locked) return DFB_OK; - - _mesa_make_current( NULL, NULL, NULL ); + + if (--data->locked == 0) { + _mesa_make_current( NULL, NULL, NULL ); - data->surface->Unlock( data->surface ); - - directfbgl_unlock(); + data->surface->Unlock( data->surface ); - data->locked = DFB_FALSE; + directfbgl_unlock(); + } return DFB_OK; } @@ -270,12 +271,32 @@ IDirectFBGL_Mesa_GetAttributes( IDirectFBGL *thiz, attributes->accum_green_size = visual->accumGreenBits; attributes->accum_blue_size = visual->accumBlueBits; attributes->accum_alpha_size = visual->accumAlphaBits; - attributes->double_buffer = (caps & DSCAPS_FLIPPING) ? 1 : 0; + attributes->double_buffer = ((caps & DSCAPS_FLIPPING) != 0); attributes->stereo = (visual->stereoMode != 0); return DFB_OK; } +#if DIRECTFBGL_INTERFACE_VERSION >= 1 +static DFBResult +IDirectFBGL_Mesa_GetProcAddress( IDirectFBGL *thiz, + const char *name, + void **ret_address ) +{ + DIRECT_INTERFACE_GET_DATA( IDirectFBGL ); + + if (!name) + return DFB_INVARG; + + if (!ret_address) + return DFB_INVARG; + + *ret_address = _glapi_get_proc_address( name ); + + return (*ret_address) ? DFB_OK : DFB_UNSUPPORTED; +} +#endif + /* exported symbols */ @@ -288,6 +309,8 @@ Probe( void *data ) static DFBResult Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) { + DFBResult ret; + /* Initialize global resources. */ if (directfbgl_init()) return DFB_INIT; @@ -296,12 +319,17 @@ Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) DIRECT_ALLOCATE_INTERFACE_DATA( thiz, IDirectFBGL ); /* Initialize interface data. */ - data->ref = 1; - data->surface = surface; + data->ref = 1; - surface->AddRef( surface ); - surface->GetPixelFormat( surface, &data->format ); - surface->GetSize( surface, &data->width, &data->height ); + /* Duplicate destination surface. */ + ret = surface->GetSubSurface( surface, NULL, &data->surface ); + if (ret) { + IDirectFBGL_Mesa_Destruct( thiz ); + return ret; + } + + data->surface->GetPixelFormat( data->surface, &data->format ); + data->surface->GetSize( data->surface, &data->width, &data->height ); /* Configure visual. */ if (!directfbgl_init_visual( &data->visual, data->format )) { @@ -319,11 +347,14 @@ Construct( IDirectFBGL *thiz, IDirectFBSurface *surface ) } /* Assign interface pointers. */ - thiz->AddRef = IDirectFBGL_Mesa_AddRef; - thiz->Release = IDirectFBGL_Mesa_Release; - thiz->Lock = IDirectFBGL_Mesa_Lock; - thiz->Unlock = IDirectFBGL_Mesa_Unlock; - thiz->GetAttributes = IDirectFBGL_Mesa_GetAttributes; + thiz->AddRef = IDirectFBGL_Mesa_AddRef; + thiz->Release = IDirectFBGL_Mesa_Release; + thiz->Lock = IDirectFBGL_Mesa_Lock; + thiz->Unlock = IDirectFBGL_Mesa_Unlock; + thiz->GetAttributes = IDirectFBGL_Mesa_GetAttributes; +#if DIRECTFBGL_INTERFACE_VERSION >= 1 + thiz->GetProcAddress = IDirectFBGL_Mesa_GetProcAddress; +#endif return DFB_OK; } @@ -363,71 +394,54 @@ dfbGetBufferSize( GLframebuffer *buffer, GLuint *width, GLuint *height ) static void dfbSetViewport( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h ) { - GLuint newWidth, newHeight; - GLframebuffer *buffer = ctx->WinSysDrawBuffer; - dfbGetBufferSize( buffer, &newWidth, &newHeight ); - if (buffer->Width != newWidth || buffer->Height != newHeight) { - _mesa_resize_framebuffer(ctx, buffer, newWidth, newHeight ); - } + /* Nothing to do (the surface can't be resized while it's locked). */ + return; } static void dfbClear( GLcontext *ctx, GLbitfield mask ) { IDirectFBGL_data *data = (IDirectFBGL_data*) ctx->DriverCtx; - int x = ctx->DrawBuffer->_Xmin; - int y = ctx->DrawBuffer->_Ymin; - int width = ctx->DrawBuffer->_Xmax - x; - int height = ctx->DrawBuffer->_Ymax - y; - GLboolean all = (width == ctx->DrawBuffer->Width && height == ctx->DrawBuffer->height) - - if (mask & BUFFER_BIT_FRONT_LEFT && - ctx->Color.ColorMask[0] && - ctx->Color.ColorMask[1] && - ctx->Color.ColorMask[2] && + +#define BUFFER_BIT_MASK (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT | \ + BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT ) + if (mask & BUFFER_BIT_MASK && + ctx->Color.ColorMask[0] && + ctx->Color.ColorMask[1] && + ctx->Color.ColorMask[2] && ctx->Color.ColorMask[3]) { DFBRegion clip; - __u8 a, r, g, b; + GLubyte a, r, g, b; UNCLAMPED_FLOAT_TO_UBYTE( a, ctx->Color.ClearColor[ACOMP] ); UNCLAMPED_FLOAT_TO_UBYTE( r, ctx->Color.ClearColor[RCOMP] ); UNCLAMPED_FLOAT_TO_UBYTE( g, ctx->Color.ClearColor[GCOMP] ); UNCLAMPED_FLOAT_TO_UBYTE( b, ctx->Color.ClearColor[BCOMP] ); - data->surface->Unlock( data->surface ); - -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,25) - data->surface->GetClip( data->surface, &clip ); -#else - (void)clip; -#endif + clip.x1 = ctx->DrawBuffer->_Xmin; + clip.y1 = ctx->DrawBuffer->_Ymin; + clip.x2 = ctx->DrawBuffer->_Xmax - 1; + clip.y2 = ctx->DrawBuffer->_Ymax - 1; + data->surface->SetClip( data->surface, &clip ); - if (all) { - data->surface->SetClip( data->surface, NULL ); - } - else { - DFBRegion reg = { x1:x, y1:y, x2:x+width-1, y2:y+height-1 }; - data->surface->SetClip( data->surface, ® ); - } + data->surface->Unlock( data->surface ); data->surface->Clear( data->surface, r, g, b, a ); - -#if DIRECTFB_VERSION_CODE >= VERSION_CODE(0,9,25) - data->surface->SetClip( data->surface, &clip ); -#endif data->surface->Lock( data->surface, DSLF_READ | DSLF_WRITE, (void*)&data->video.start, &data->video.pitch ); + data->video.end = data->video.start + (data->height-1) * data->video.pitch; + data->render.Data = data->video.start; - mask &= ~BUFFER_BIT_FRONT_LEFT; + mask &= ~BUFFER_BIT_MASK; } +#undef BUFFER_BIT_MASK if (mask) _swrast_Clear( ctx, mask ); -} - - +} + /************************ RenderBuffer functions *****************************/ @@ -790,6 +804,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB332; data->render.GetValues = get_values_RGB332; data->render.PutRow = put_row_RGB332; + data->render.PutRowRGB = put_row_rgb_RGB332; data->render.PutMonoRow = put_mono_row_RGB332; data->render.PutValues = put_values_RGB332; data->render.PutMonoValues = put_mono_values_RGB332; @@ -798,6 +813,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB4444; data->render.GetValues = get_values_ARGB4444; data->render.PutRow = put_row_ARGB4444; + data->render.PutRowRGB = put_row_rgb_ARGB4444; data->render.PutMonoRow = put_mono_row_ARGB4444; data->render.PutValues = put_values_ARGB4444; data->render.PutMonoValues = put_mono_values_ARGB4444; @@ -806,6 +822,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB2554; data->render.GetValues = get_values_ARGB2554; data->render.PutRow = put_row_ARGB2554; + data->render.PutRowRGB = put_row_rgb_ARGB2554; data->render.PutMonoRow = put_mono_row_ARGB2554; data->render.PutValues = put_values_ARGB2554; data->render.PutMonoValues = put_mono_values_ARGB2554; @@ -814,6 +831,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB1555; data->render.GetValues = get_values_ARGB1555; data->render.PutRow = put_row_ARGB1555; + data->render.PutRowRGB = put_row_rgb_ARGB1555; data->render.PutMonoRow = put_mono_row_ARGB1555; data->render.PutValues = put_values_ARGB1555; data->render.PutMonoValues = put_mono_values_ARGB1555; @@ -822,6 +840,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB16; data->render.GetValues = get_values_RGB16; data->render.PutRow = put_row_RGB16; + data->render.PutRowRGB = put_row_rgb_RGB16; data->render.PutMonoRow = put_mono_row_RGB16; data->render.PutValues = put_values_RGB16; data->render.PutMonoValues = put_mono_values_RGB16; @@ -830,6 +849,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB24; data->render.GetValues = get_values_RGB24; data->render.PutRow = put_row_RGB24; + data->render.PutRowRGB = put_row_rgb_RGB24; data->render.PutMonoRow = put_mono_row_RGB24; data->render.PutValues = put_values_RGB24; data->render.PutMonoValues = put_mono_values_RGB24; @@ -838,6 +858,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_RGB32; data->render.GetValues = get_values_RGB32; data->render.PutRow = put_row_RGB32; + data->render.PutRowRGB = put_row_rgb_RGB32; data->render.PutMonoRow = put_mono_row_RGB32; data->render.PutValues = put_values_RGB32; data->render.PutMonoValues = put_mono_values_RGB32; @@ -846,6 +867,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_ARGB; data->render.GetValues = get_values_ARGB; data->render.PutRow = put_row_ARGB; + data->render.PutRowRGB = put_row_rgb_ARGB; data->render.PutMonoRow = put_mono_row_ARGB; data->render.PutValues = put_values_ARGB; data->render.PutMonoValues = put_mono_values_ARGB; @@ -854,6 +876,7 @@ directfbgl_create_context( GLcontext *context, data->render.GetRow = get_row_AiRGB; data->render.GetValues = get_values_AiRGB; data->render.PutRow = put_row_AiRGB; + data->render.PutRowRGB = put_row_rgb_AiRGB; data->render.PutMonoRow = put_mono_row_AiRGB; data->render.PutValues = put_values_AiRGB; data->render.PutMonoValues = put_mono_values_AiRGB; diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index e7f07569f4e..ba251a81430 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -411,13 +411,18 @@ __driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp) if (!pcp || ((pdp != pcp->driDrawablePriv) && (pdp != pcp->driReadablePriv))) { - /* ERROR!!! */ - return; + /* ERROR!!! + * ...but we must ignore it. There can be many contexts bound to a + * drawable. + */ } psp = pdp->driScreenPriv; if (!psp) { /* ERROR!!! */ + _mesa_problem("Warning! Possible infinite loop due to bug " + "in file %s, line %d\n", + __FILE__, __LINE__); return; } diff --git a/src/mesa/drivers/dri/i915/i830_metaops.c b/src/mesa/drivers/dri/i915/i830_metaops.c index dbf5f043498..c1d7fe349c0 100644 --- a/src/mesa/drivers/dri/i915/i830_metaops.c +++ b/src/mesa/drivers/dri/i915/i830_metaops.c @@ -50,7 +50,6 @@ #define SET_STATE( i830, STATE ) \ do { \ - assert(!i830->intel.prim.flush); \ i830->current->emitted = 0; \ i830->current = &i830->STATE; \ i830->current->emitted = 0; \ @@ -907,7 +906,6 @@ i830RotateWindow(intelContextPtr intel, __DRIdrawablePrivate *dPriv, } /* cliprect loop */ - assert(!intel->prim.flush); intelFlushBatchLocked( intel, GL_FALSE, GL_FALSE, GL_FALSE ); done: diff --git a/src/mesa/drivers/dri/i915tex/i830_state.c b/src/mesa/drivers/dri/i915tex/i830_state.c index c0673363f32..812daa65246 100644 --- a/src/mesa/drivers/dri/i915tex/i830_state.c +++ b/src/mesa/drivers/dri/i915tex/i830_state.c @@ -1042,6 +1042,7 @@ i830_init_packets(struct i830_context *i830) i830->state.Buffer[I830_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD; +#if 0 switch (screen->fbFormat) { case DV_PF_565: i830->state.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */ @@ -1058,7 +1059,7 @@ i830_init_packets(struct i830_context *i830) DEPTH_FRMT_24_FIXED_8_OTHER); break; } - +#endif i830->state.Buffer[I830_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT); i830->state.Buffer[I830_DESTREG_SR0] = _3DSTATE_SCISSOR_RECT_0_CMD; diff --git a/src/mesa/drivers/dri/i915tex/i830_texstate.c b/src/mesa/drivers/dri/i915tex/i830_texstate.c index ba79cf94599..e3f34e3944a 100644 --- a/src/mesa/drivers/dri/i915tex/i830_texstate.c +++ b/src/mesa/drivers/dri/i915tex/i830_texstate.c @@ -25,21 +25,13 @@ * **************************************************************************/ -#include "glheader.h" -#include "macros.h" #include "mtypes.h" -#include "simple_list.h" #include "enums.h" #include "texformat.h" -#include "texstore.h" +#include "dri_bufmgr.h" -#include "mm.h" - -#include "intel_screen.h" -#include "intel_ioctl.h" -#include "intel_tex.h" #include "intel_mipmap_tree.h" -#include "intel_regions.h" +#include "intel_tex.h" #include "i830_context.h" #include "i830_reg.h" @@ -129,6 +121,13 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) memset(state, 0, sizeof(state)); + /*We need to refcount these. */ + + if (i830->state.tex_buffer[unit] != NULL) { + driBOUnReference(i830->state.tex_buffer[unit]); + i830->state.tex_buffer[unit] = NULL; + } + if (!intel_finalize_mipmap_tree(intel, unit)) return GL_FALSE; @@ -137,7 +136,7 @@ i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3) */ firstImage = tObj->Image[0][intelObj->firstLevel]; - i830->state.tex_buffer[unit] = intelObj->mt->region->buffer; + i830->state.tex_buffer[unit] = driBOReference(intelObj->mt->region->buffer); i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt, 0, intelObj-> firstLevel); @@ -298,10 +297,17 @@ i830UpdateTextureState(struct intel_context *intel) 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)) + case 0:{ + struct i830_context *i830 = i830_context(&intel->ctx); + if (i830->state.active & I830_UPLOAD_TEX(i)) I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(i), GL_FALSE); + + if (i830->state.tex_buffer[i] != NULL) { + driBOUnReference(i830->state.tex_buffer[i]); + i830->state.tex_buffer[i] = NULL; + } break; + } case TEXTURE_3D_BIT: default: ok = GL_FALSE; diff --git a/src/mesa/drivers/dri/i915tex/i830_vtbl.c b/src/mesa/drivers/dri/i915tex/i830_vtbl.c index 18fc6d4b91f..dd0670dec37 100644 --- a/src/mesa/drivers/dri/i915tex/i830_vtbl.c +++ b/src/mesa/drivers/dri/i915tex/i830_vtbl.c @@ -451,14 +451,16 @@ i830_emit_state(struct intel_context *intel) 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); + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, + state->draw_region->draw_offset); 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); + DRM_BO_MASK_MEM | DRM_BO_FLAG_WRITE, + state->depth_region->draw_offset); } OUT_BATCH(state->Buffer[I830_DESTREG_DV0]); @@ -469,7 +471,7 @@ i830_emit_state(struct intel_context *intel) OUT_BATCH(state->Buffer[I830_DESTREG_SR2]); ADVANCE_BATCH(); } - + if (dirty & I830_UPLOAD_STIPPLE) { DBG("I830_UPLOAD_STIPPLE:\n"); emit(i830, state->Stipple, sizeof(state->Stipple)); diff --git a/src/mesa/drivers/dri/i915tex/server/i830_common.h b/src/mesa/drivers/dri/i915tex/server/i830_common.h index fb6ceaa52d4..06f28ed19a4 100644 --- a/src/mesa/drivers/dri/i915tex/server/i830_common.h +++ b/src/mesa/drivers/dri/i915tex/server/i830_common.h @@ -52,6 +52,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define DRM_I830_INIT_HEAP 0x0a #define DRM_I830_CMDBUFFER 0x0b #define DRM_I830_DESTROY_HEAP 0x0c +#define DRM_I830_SET_VBLANK_PIPE 0x0d +#define DRM_I830_GET_VBLANK_PIPE 0x0e typedef struct { enum { @@ -208,5 +210,11 @@ typedef struct { int region; } drmI830MemDestroyHeap; +#define DRM_I830_VBLANK_PIPE_A 1 +#define DRM_I830_VBLANK_PIPE_B 2 + +typedef struct { + int pipe; +} drmI830VBlankPipe; #endif /* _I830_DRM_H_ */ diff --git a/src/mesa/drivers/dri/i915tex/server/i830_dri.h b/src/mesa/drivers/dri/i915tex/server/i830_dri.h index 6c9a7090215..c2a3af8cbf7 100644 --- a/src/mesa/drivers/dri/i915tex/server/i830_dri.h +++ b/src/mesa/drivers/dri/i915tex/server/i830_dri.h @@ -9,8 +9,8 @@ #define I830_MAX_DRAWABLES 256 #define I830_MAJOR_VERSION 1 -#define I830_MINOR_VERSION 3 -#define I830_PATCHLEVEL 0 +#define I830_MINOR_VERSION 7 +#define I830_PATCHLEVEL 2 #define I830_REG_SIZE 0x80000 @@ -18,20 +18,20 @@ typedef struct _I830DRIRec { drm_handle_t regs; drmSize regsSize; - drmSize backbufferSize; - drm_handle_t backbuffer; + drmSize unused1; /* backbufferSize */ + drm_handle_t unused2; /* backbuffer */ - drmSize depthbufferSize; - drm_handle_t depthbuffer; + drmSize unused3; /* depthbufferSize */ + drm_handle_t unused4; /* depthbuffer */ - drmSize rotatedSize; - drm_handle_t rotatedbuffer; + drmSize unused5; /* rotatedSize */ + drm_handle_t unused6; /* rotatedbuffer */ - drm_handle_t textures; - int textureSize; + drm_handle_t unused7; /* textures */ + int unused8; /* textureSize */ - drm_handle_t agp_buffers; - drmSize agp_buf_size; + drm_handle_t unused9; /* agp_buffers */ + drmSize unused10; /* agp_buf_size */ int deviceID; int width; @@ -40,20 +40,10 @@ typedef struct _I830DRIRec { int cpp; int bitsPerPixel; - int fbOffset; - int fbStride; - - int backOffset; - int backPitch; - - int depthOffset; - int depthPitch; - - int rotatedOffset; - int rotatedPitch; - - int logTextureGranularity; - int textureOffset; + int unused11[8]; /* was front/back/depth/rotated offset/pitch */ + + int unused12; /* logTextureGranularity */ + int unused13; /* textureOffset */ int irq; int sarea_priv_offset; diff --git a/src/mesa/drivers/dri/i915tex/server/intel.h b/src/mesa/drivers/dri/i915tex/server/intel.h index d7858a20c8d..6ea72499c1c 100644 --- a/src/mesa/drivers/dri/i915tex/server/intel.h +++ b/src/mesa/drivers/dri/i915tex/server/intel.h @@ -75,6 +75,9 @@ #define I830_GMCH_CTRL 0x52 +#define I830_GMCH_MEM_MASK 0x1 +#define I830_GMCH_MEM_64M 0x1 +#define I830_GMCH_MEM_128M 0 #define I830_GMCH_GMS_MASK 0x70 #define I830_GMCH_GMS_DISABLED 0x00 @@ -141,7 +144,7 @@ typedef struct _I830Rec { unsigned char *MMIOBase; unsigned char *FbBase; int cpp; - + uint32_t aper_size; unsigned int bios_version; /* These are set in PreInit and never changed. */ diff --git a/src/mesa/drivers/dri/i915tex/server/intel_dri.c b/src/mesa/drivers/dri/i915tex/server/intel_dri.c index 169fdbece30..4d1ac09f644 100644 --- a/src/mesa/drivers/dri/i915tex/server/intel_dri.c +++ b/src/mesa/drivers/dri/i915tex/server/intel_dri.c @@ -292,15 +292,43 @@ static void I830SetupMemoryTiling(const DRIDriverContext *ctx, I830Rec *pI830) static int I830DetectMemory(const DRIDriverContext *ctx, I830Rec *pI830) { - struct pci_device host_bridge; + struct pci_device host_bridge, ig_dev; uint32_t gmch_ctrl; int memsize = 0; int range; - + uint32_t aper_size; + uint32_t membase2 = 0; + memset(&host_bridge, 0, sizeof(host_bridge)); + memset(&ig_dev, 0, sizeof(ig_dev)); + + ig_dev.dev = 2; pci_device_cfg_read_u32(&host_bridge, &gmch_ctrl, I830_GMCH_CTRL); - + + if (IS_I830(pI830) || IS_845G(pI830)) { + if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_128M) { + aper_size = 0x80000000; + } else { + aper_size = 0x40000000; + } + } else { + if (IS_I9XX(pI830)) { + int ret; + ret = pci_device_cfg_read_u32(&ig_dev, &membase2, 0x18); + if (membase2 & 0x08000000) + aper_size = 0x8000000; + else + aper_size = 0x10000000; + + fprintf(stderr,"aper size is %08X %08x %d\n", aper_size, membase2, ret); + } else + aper_size = 0x8000000; + } + + pI830->aper_size = aper_size; + + /* We need to reduce the stolen size, by the GTT and the popup. * The GTT varying according the the FbMapSize and the popup is 4KB */ range = (ctx->shared.fbSize / (1024*1024)) + 4; @@ -576,7 +604,8 @@ I830AllocateMemory(const DRIDriverContext *ctx, I830Rec *pI830) fprintf(stderr,"unable to allocate context buffer %ld\n", ret); return FALSE; } - + +#if 0 memset(&(pI830->TexMem), 0, sizeof(pI830->TexMem)); pI830->TexMem.Key = -1; @@ -587,6 +616,7 @@ I830AllocateMemory(const DRIDriverContext *ctx, I830Rec *pI830) fprintf(stderr,"unable to allocate texture memory %ld\n", ret); return FALSE; } +#endif return TRUE; } @@ -604,12 +634,29 @@ I830BindMemory(const DRIDriverContext *ctx, I830Rec *pI830) return FALSE; if (!BindAgpRange(ctx, &pI830->ContextMem)) return FALSE; +#if 0 if (!BindAgpRange(ctx, &pI830->TexMem)) return FALSE; - +#endif return TRUE; } +static void SetupDRIMM(const DRIDriverContext *ctx, I830Rec *pI830) +{ + unsigned long aperEnd = ROUND_DOWN_TO(pI830->aper_size, GTT_PAGE_SIZE) / GTT_PAGE_SIZE; + unsigned long aperStart = ROUND_TO(pI830->aper_size - KB(32768), GTT_PAGE_SIZE) / GTT_PAGE_SIZE; + + fprintf(stderr, "aper size is %08X\n", ctx->shared.fbSize); + if (drmMMInit(ctx->drmFD, aperStart, aperEnd - aperStart, DRM_BO_MEM_TT)) { + fprintf(stderr, + "DRM MM Initialization Failed\n"); + } else { + fprintf(stderr, + "DRM MM Initialized at offset 0x%lx length %d page\n", aperStart, aperEnd-aperStart); + } + +} + static Bool I830CleanupDma(const DRIDriverContext *ctx) { @@ -809,6 +856,7 @@ I830DRIMapScreenRegions(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sar fprintf(stderr, "[drm] Depth Buffer = 0x%08x\n", sarea->depth_handle); +#if 0 if (drmAddMap(ctx->drmFD, (drm_handle_t)sarea->tex_offset, sarea->tex_size, DRM_AGP, 0, @@ -819,7 +867,7 @@ I830DRIMapScreenRegions(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sar } fprintf(stderr, "[drm] textures = 0x%08x\n", sarea->tex_handle); - +#endif return TRUE; } @@ -847,6 +895,7 @@ I830DRIUnmapScreenRegions(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sa } } +#if 0 static void I830InitTextureHeap(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea) { @@ -869,6 +918,7 @@ I830InitTextureHeap(const DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *s sarea->log_tex_granularity); } } +#endif static Bool I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea) @@ -891,8 +941,11 @@ I830DRIDoMappings(DRIDriverContext *ctx, I830Rec *pI830, drmI830Sarea *sarea) /* init to zero to be safe */ I830DRIMapScreenRegions(ctx, pI830, sarea); - I830InitTextureHeap(ctx, pI830, sarea); + SetupDRIMM(ctx, pI830); +#if 0 + I830InitTextureHeap(ctx, pI830, sarea); +#endif if (ctx->pciDevice != PCI_CHIP_845_G && ctx->pciDevice != PCI_CHIP_I830_M) { I830SetParam(ctx, I830_SETPARAM_USE_MI_BATCHBUFFER_START, 1 ); @@ -1083,6 +1136,10 @@ I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830) return FALSE; } + pSAREAPriv->rotated_offset = -1; + pSAREAPriv->rotated_size = 0; + pSAREAPriv->rotated_pitch = ctx->shared.virtualWidth; + pSAREAPriv->front_offset = pI830->FrontBuffer.Start; pSAREAPriv->front_size = pI830->FrontBuffer.Size; pSAREAPriv->width = ctx->shared.virtualWidth; @@ -1094,8 +1151,10 @@ I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830) pSAREAPriv->back_size = pI830->BackBuffer.Size; pSAREAPriv->depth_offset = pI830->DepthBuffer.Start; pSAREAPriv->depth_size = pI830->DepthBuffer.Size; +#if 0 pSAREAPriv->tex_offset = pI830->TexMem.Start; pSAREAPriv->tex_size = pI830->TexMem.Size; +#endif pSAREAPriv->log_tex_granularity = pI830->TexGranularity; ctx->driverClientMsg = malloc(sizeof(I830DRIRec)); @@ -1107,14 +1166,6 @@ I830ScreenInit(DRIDriverContext *ctx, I830Rec *pI830) pI830DRI->height = ctx->shared.virtualHeight; pI830DRI->mem = ctx->shared.fbSize; pI830DRI->cpp = ctx->cpp; - pI830DRI->backOffset = pI830->BackBuffer.Start; - pI830DRI->backPitch = pI830->BackBuffer.Pitch; - - pI830DRI->depthOffset = pI830->DepthBuffer.Start; - pI830DRI->depthPitch = pI830->DepthBuffer.Pitch; - - pI830DRI->fbOffset = pI830->FrontBuffer.Start; - pI830DRI->fbStride = pI830->FrontBuffer.Pitch; pI830DRI->bitsPerPixel = ctx->bpp; pI830DRI->sarea_priv_offset = sizeof(drm_sarea_t); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index c1f6617f3fd..bc422c1a50b 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -156,6 +156,8 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, brw_ProgramCacheInit( ctx ); + brw_FrameBufferTexInit( brw ); + /* Hook our functions into exec and compile dispatch tables. Only * fallback on out-of-memory situations. */ diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 1137bfd2c76..a57c794834f 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -485,7 +485,7 @@ struct brw_context */ struct brw_state_pointers attribs; struct gl_vertex_program *vp; - struct gl_fragment_program *fp; + struct gl_fragment_program *fp, *fp_tex; struct gl_buffer_object *vbo; @@ -493,6 +493,8 @@ struct brw_context struct intel_region *saved_depth_region; GLuint restore_draw_mask; + struct gl_fragment_program *restore_fp; + GLboolean active; } metaops; @@ -672,6 +674,8 @@ void brw_destroy_state( struct brw_context *brw ); */ void brwUpdateTextureState( struct intel_context *intel ); void brwInitTextureFuncs( struct dd_function_table *functions ); +void brw_FrameBufferTexInit( struct brw_context *brw ); +void brw_FrameBufferTexDestroy( struct brw_context *brw ); /*====================================================================== * brw_metaops.c diff --git a/src/mesa/drivers/dri/i965/brw_fallback.c b/src/mesa/drivers/dri/i965/brw_fallback.c index 4d84ba88137..56e21e339ef 100644 --- a/src/mesa/drivers/dri/i965/brw_fallback.c +++ b/src/mesa/drivers/dri/i965/brw_fallback.c @@ -280,6 +280,9 @@ void brw_loopback_vertex_list( GLcontext *ctx, GLuint i, nr = 0; for (i = 0 ; i <= BRW_ATTRIB_TEX7 ; i++) { + if (i == BRW_ATTRIB_INDEX || i == BRW_ATTRIB_EDGEFLAG) + continue; + if (attrsz[i]) { la[nr].target = i; la[nr].sz = attrsz[i]; diff --git a/src/mesa/drivers/dri/i965/brw_metaops.c b/src/mesa/drivers/dri/i965/brw_metaops.c index 18ca7b13412..2deec5eae3d 100644 --- a/src/mesa/drivers/dri/i965/brw_metaops.c +++ b/src/mesa/drivers/dri/i965/brw_metaops.c @@ -27,6 +27,7 @@ /* * Authors: * Keith Whitwell + * frame buffer texture by Gary Wong */ @@ -144,6 +145,15 @@ static const char *fp_prog = "MOV result.color, fragment.color;\n" "END\n"; +static const char *fp_tex_prog = + "!!ARBfp1.0\n" + "TEMP a;\n" + "ADD a, fragment.position, program.local[0];\n" + "MUL a, a, program.local[1];\n" + "TEX result.color, a, texture[0], 2D;\n" + "MOV result.depth.z, fragment.position;\n" + "END\n"; + /* Derived values of importance: * * FragmentProgram->_Current @@ -170,6 +180,9 @@ static void init_metaops_state( struct brw_context *brw ) brw->metaops.fp = (struct gl_fragment_program *) ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 1 ); + brw->metaops.fp_tex = (struct gl_fragment_program *) + ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 1 ); + brw->metaops.vp = (struct gl_vertex_program *) ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 1 ); @@ -177,6 +190,10 @@ static void init_metaops_state( struct brw_context *brw ) fp_prog, strlen(fp_prog), brw->metaops.fp); + _mesa_parse_arb_fragment_program(ctx, GL_FRAGMENT_PROGRAM_ARB, + fp_tex_prog, strlen(fp_tex_prog), + brw->metaops.fp_tex); + _mesa_parse_arb_vertex_program(ctx, GL_VERTEX_PROGRAM_ARB, vp_prog, strlen(vp_prog), brw->metaops.vp); @@ -267,7 +284,76 @@ static void meta_color_mask( struct intel_context *intel, GLboolean state ) static void meta_no_texture( struct intel_context *intel ) { - /* Nothing to do */ + struct brw_context *brw = brw_context(&intel->ctx); + + brw->metaops.attribs.FragmentProgram->_Current = brw->metaops.fp; + + brw->metaops.attribs.Texture->CurrentUnit = 0; + brw->metaops.attribs.Texture->_EnabledUnits = 0; + brw->metaops.attribs.Texture->_EnabledCoordUnits = 0; + brw->metaops.attribs.Texture->Unit[ 0 ].Enabled = 0; + brw->metaops.attribs.Texture->Unit[ 0 ]._ReallyEnabled = 0; + + brw->state.dirty.mesa |= _NEW_TEXTURE | _NEW_PROGRAM; +} + +static void meta_texture_blend_replace(struct intel_context *intel) +{ + struct brw_context *brw = brw_context(&intel->ctx); + + brw->metaops.attribs.Texture->CurrentUnit = 0; + brw->metaops.attribs.Texture->_EnabledUnits = 1; + brw->metaops.attribs.Texture->_EnabledCoordUnits = 1; + brw->metaops.attribs.Texture->Unit[ 0 ].Enabled = TEXTURE_2D_BIT; + brw->metaops.attribs.Texture->Unit[ 0 ]._ReallyEnabled = TEXTURE_2D_BIT; + brw->metaops.attribs.Texture->Unit[ 0 ].Current2D = + intel->frame_buffer_texobj; + brw->metaops.attribs.Texture->Unit[ 0 ]._Current = + intel->frame_buffer_texobj; + + brw->state.dirty.mesa |= _NEW_TEXTURE | _NEW_PROGRAM; +} + +static void meta_import_pixel_state(struct intel_context *intel) +{ + struct brw_context *brw = brw_context(&intel->ctx); + + RESTORE(brw, Color, _NEW_COLOR); + RESTORE(brw, Depth, _NEW_DEPTH); + RESTORE(brw, Fog, _NEW_FOG); + RESTORE(brw, Scissor, _NEW_SCISSOR); + RESTORE(brw, Stencil, _NEW_STENCIL); + RESTORE(brw, Texture, _NEW_TEXTURE); + RESTORE(brw, FragmentProgram, _NEW_PROGRAM); +} + +static void meta_frame_buffer_texture( struct intel_context *intel, + GLint xoff, GLint yoff ) +{ + struct brw_context *brw = brw_context(&intel->ctx); + struct intel_region *region = intel_drawbuf_region( intel ); + + INSTALL(brw, FragmentProgram, _NEW_PROGRAM); + + brw->metaops.attribs.FragmentProgram->_Current = brw->metaops.fp_tex; + /* This is unfortunate, but seems to be necessary, since later on we + will end up calling _mesa_load_state_parameters to lookup the + local params (below), and that will want to look in ctx.FragmentProgram + instead of brw->attribs.FragmentProgram. */ + intel->ctx.FragmentProgram.Current = brw->metaops.fp_tex; + + brw->metaops.fp_tex->Base.LocalParams[ 0 ][ 0 ] = xoff; + brw->metaops.fp_tex->Base.LocalParams[ 0 ][ 1 ] = yoff; + brw->metaops.fp_tex->Base.LocalParams[ 0 ][ 2 ] = 0.0; + brw->metaops.fp_tex->Base.LocalParams[ 0 ][ 3 ] = 0.0; + brw->metaops.fp_tex->Base.LocalParams[ 1 ][ 0 ] = + 1.0 / region->pitch; + brw->metaops.fp_tex->Base.LocalParams[ 1 ][ 1 ] = + -1.0 / region->height; + brw->metaops.fp_tex->Base.LocalParams[ 1 ][ 2 ] = 0.0; + brw->metaops.fp_tex->Base.LocalParams[ 1 ][ 3 ] = 1.0; + + brw->state.dirty.mesa |= _NEW_PROGRAM; } @@ -406,7 +492,8 @@ static void meta_draw_quad(struct intel_context *intel, } -static void install_meta_state( struct intel_context *intel ) +static void install_meta_state( struct intel_context *intel, + GLenum state ) { GLcontext *ctx = &intel->ctx; struct brw_context *brw = brw_context(ctx); @@ -416,9 +503,11 @@ static void install_meta_state( struct intel_context *intel ) } install_attribs(brw); + meta_no_texture(&brw->intel); meta_flat_shade(&brw->intel); brw->metaops.restore_draw_mask = ctx->DrawBuffer->_ColorDrawBufferMask[0]; + brw->metaops.restore_fp = ctx->FragmentProgram.Current; /* This works without adjusting refcounts. Fix later? */ @@ -437,6 +526,7 @@ static void leave_meta_state( struct intel_context *intel ) restore_attribs(brw); ctx->DrawBuffer->_ColorDrawBufferMask[0] = brw->metaops.restore_draw_mask; + ctx->FragmentProgram.Current = brw->metaops.restore_fp; brw->state.draw_region = brw->metaops.saved_draw_region; brw->state.depth_region = brw->metaops.saved_depth_region; @@ -463,10 +553,11 @@ void brw_init_metaops( struct brw_context *brw ) brw->intel.vtbl.meta_depth_replace = meta_depth_replace; brw->intel.vtbl.meta_color_mask = meta_color_mask; brw->intel.vtbl.meta_no_texture = meta_no_texture; + brw->intel.vtbl.meta_import_pixel_state = meta_import_pixel_state; + brw->intel.vtbl.meta_frame_buffer_texture = meta_frame_buffer_texture; brw->intel.vtbl.meta_draw_region = meta_draw_region; brw->intel.vtbl.meta_draw_quad = meta_draw_quad; - -/* brw->intel.vtbl.meta_texture_blend_replace = meta_texture_blend_replace; */ + brw->intel.vtbl.meta_texture_blend_replace = meta_texture_blend_replace; /* brw->intel.vtbl.meta_tex_rect_source = meta_tex_rect_source; */ /* brw->intel.vtbl.meta_draw_format = set_draw_format; */ } @@ -479,5 +570,6 @@ void brw_destroy_metaops( struct brw_context *brw ) ctx->Driver.DeleteBuffer( ctx, brw->metaops.vbo ); /* ctx->Driver.DeleteProgram( ctx, brw->metaops.fp ); */ +/* ctx->Driver.DeleteProgram( ctx, brw->metaops.fp_tex ); */ /* ctx->Driver.DeleteProgram( ctx, brw->metaops.vp ); */ } diff --git a/src/mesa/drivers/dri/i965/brw_tex.c b/src/mesa/drivers/dri/i965/brw_tex.c index 8332d869e1d..c3ffa9e6577 100644 --- a/src/mesa/drivers/dri/i965/brw_tex.c +++ b/src/mesa/drivers/dri/i965/brw_tex.c @@ -36,11 +36,14 @@ #include "simple_list.h" #include "enums.h" #include "image.h" +#include "teximage.h" #include "texstore.h" #include "texformat.h" #include "texmem.h" +#include "intel_context.h" #include "intel_ioctl.h" +#include "intel_regions.h" #include "brw_context.h" #include "brw_defines.h" @@ -179,3 +182,32 @@ void brwInitTextureFuncs( struct dd_function_table *functions ) { functions->ChooseTextureFormat = brwChooseTextureFormat; } + +void brw_FrameBufferTexInit( struct brw_context *brw ) +{ + struct intel_context *intel = &brw->intel; + GLcontext *ctx = &intel->ctx; + struct intel_region *region = intel->front_region; + struct gl_texture_object *obj; + struct gl_texture_image *img; + + intel->frame_buffer_texobj = obj = + ctx->Driver.NewTextureObject( ctx, (GLuint) -1, GL_TEXTURE_2D ); + + obj->MinFilter = GL_NEAREST; + obj->MagFilter = GL_NEAREST; + + img = ctx->Driver.NewTextureImage( ctx ); + + _mesa_init_teximage_fields( ctx, GL_TEXTURE_2D, img, + region->pitch, region->height, 1, 0, + region->cpp == 4 ? GL_RGBA : GL_RGB ); + + _mesa_set_tex_image( obj, GL_TEXTURE_2D, 0, img ); +} + +void brw_FrameBufferTexDestroy( struct brw_context *brw ) +{ + brw->intel.ctx.Driver.DeleteTexture( &brw->intel.ctx, + brw->intel.frame_buffer_texobj ); +} diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c index 4896882034b..ac09754e3ae 100644 --- a/src/mesa/drivers/dri/i965/brw_vtbl.c +++ b/src/mesa/drivers/dri/i965/brw_vtbl.c @@ -72,6 +72,7 @@ static void brw_destroy_context( struct intel_context *intel ) brw_save_destroy( ctx ); brw_ProgramCacheDestroy( ctx ); + brw_FrameBufferTexDestroy( brw ); } /* called from intelDrawBuffer() diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index 5c7dc500cab..d24c618a668 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -239,6 +239,12 @@ static void upload_wm_surfaces(struct brw_context *brw ) brw->wm.bind.surf_ss_offset[i+1] = brw_cache_data( &brw->cache[BRW_SS_SURFACE], &surf ); brw->wm.nr_surfaces = i+2; } + else if( texUnit->_ReallyEnabled && + texUnit->_Current == intel->frame_buffer_texobj ) + { + brw->wm.bind.surf_ss_offset[i+1] = brw->wm.bind.surf_ss_offset[0]; + brw->wm.nr_surfaces = i+2; + } else { brw->wm.bind.surf_ss_offset[i+1] = 0; } diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c index 36edd7db7f5..d13e287fa76 100644 --- a/src/mesa/drivers/dri/i965/intel_context.c +++ b/src/mesa/drivers/dri/i965/intel_context.c @@ -320,6 +320,11 @@ GLboolean intelInitContext( struct intel_context *intel, ctx->Const.MaxPointSizeAA = 3.0; ctx->Const.PointSizeGranularity = 1.0; + /* reinitialize the context point state. + * It depend on constants in __GLcontextRec::Const + */ + _mesa_init_point(ctx); + /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); _ac_CreateContext( ctx ); diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h index 2df8faef28e..8367a957109 100644 --- a/src/mesa/drivers/dri/i965/intel_context.h +++ b/src/mesa/drivers/dri/i965/intel_context.h @@ -86,7 +86,6 @@ struct intel_texture_object - struct intel_context { GLcontext ctx; /* the parent class */ @@ -148,9 +147,14 @@ struct intel_context void (*meta_depth_replace)( struct intel_context *intel ); + void (*meta_texture_blend_replace) (struct intel_context * intel); + void (*meta_no_stencil_write)( struct intel_context *intel ); void (*meta_no_depth_write)( struct intel_context *intel ); void (*meta_no_texture)( struct intel_context *intel ); + void (*meta_import_pixel_state) (struct intel_context * intel); + void (*meta_frame_buffer_texture)( struct intel_context *intel, + GLint xoff, GLint yoff ); void (*meta_draw_quad)(struct intel_context *intel, GLfloat x0, GLfloat x1, @@ -218,6 +222,7 @@ struct intel_context int drawY; GLuint numClipRects; /* cliprects for that buffer */ drm_clip_rect_t *pClipRects; + struct gl_texture_object *frame_buffer_texobj; GLboolean scissor; drm_clip_rect_t draw_rect; diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c index 55b58a8f670..58dc49505fe 100644 --- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c @@ -80,8 +80,6 @@ intel_check_blit_fragment_ops(GLcontext * ctx) if (ctx->NewState) _mesa_update_state(ctx); - /* Could do logicop with the blitter: - */ return !(ctx->_ImageTransferState || ctx->RenderMode != GL_RENDER || ctx->Color.AlphaEnabled || @@ -97,7 +95,107 @@ intel_check_blit_fragment_ops(GLcontext * ctx) ctx->Color.BlendEnabled); } +/* Doesn't work for overlapping regions. Could do a double copy or + * just fallback. + */ +static GLboolean +do_texture_copypixels(GLcontext * ctx, + GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint dstx, GLint dsty, GLenum type) +{ + struct intel_context *intel = intel_context(ctx); + struct intel_region *dst = intel_drawbuf_region(intel); + struct intel_region *src = copypix_src_region(intel, type); + GLenum src_format; + GLenum src_type; + + DBG("%s %d,%d %dx%d --> %d,%d\n", __FUNCTION__, + srcx, srcy, width, height, dstx, dsty); + + if (!src || !dst || type != GL_COLOR || + ctx->_ImageTransferState || + ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F || + ctx->RenderMode != GL_RENDER || + ctx->Texture._EnabledUnits || + ctx->FragmentProgram._Enabled || + src != dst ) + return GL_FALSE; + + /* Can't handle overlapping regions. Don't have sufficient control + * over rasterization to pull it off in-place. Punt on these for + * now. + * + * XXX: do a copy to a temporary. + */ + if (src->buffer == dst->buffer) { + drm_clip_rect_t srcbox; + drm_clip_rect_t dstbox; + drm_clip_rect_t tmp; + + srcbox.x1 = srcx; + srcbox.y1 = srcy; + srcbox.x2 = srcx + width - 1; + srcbox.y2 = srcy + height - 1; + + dstbox.x1 = dstx; + dstbox.y1 = dsty; + dstbox.x2 = dstx + width - 1; + dstbox.y2 = dsty + height - 1; + + DBG("src %d,%d %d,%d\n", srcbox.x1, srcbox.y1, srcbox.x2, srcbox.y2); + DBG("dst %d,%d %d,%d (%dx%d) (%f,%f)\n", dstbox.x1, dstbox.y1, dstbox.x2, dstbox.y2, + width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY); + + if (intel_intersect_cliprects(&tmp, &srcbox, &dstbox)) { + DBG("%s: regions overlap\n", __FUNCTION__); + return GL_FALSE; + } + } + intelFlush(&intel->ctx); + + intel->vtbl.install_meta_state(intel); + + /* Is this true? Also will need to turn depth testing on according + * to state: + */ + intel->vtbl.meta_no_stencil_write(intel); + intel->vtbl.meta_no_depth_write(intel); + + /* Set the 3d engine to draw into the destination region: + */ + intel->vtbl.meta_draw_region(intel, dst, intel->depth_region); + + intel->vtbl.meta_import_pixel_state(intel); + + if (src->cpp == 2) { + src_format = GL_RGB; + src_type = GL_UNSIGNED_SHORT_5_6_5; + } + else { + src_format = GL_BGRA; + src_type = GL_UNSIGNED_BYTE; + } + + /* Set the frontbuffer up as a large rectangular texture. + */ + intel->vtbl.meta_frame_buffer_texture( intel, srcx - dstx, srcy - dsty ); + + intel->vtbl.meta_texture_blend_replace(intel); + + if (intel->driDrawable->numClipRects) + intel->vtbl.meta_draw_quad( intel, + dstx, dstx + width, + dsty, dsty + height, + ctx->Current.RasterPos[ 2 ], + 0, 0, 0, 0, 0.0, 0.0, 0.0, 0.0 ); + + intel->vtbl.leave_meta_state( intel ); + + DBG("%s: success\n", __FUNCTION__); + return GL_TRUE; +} /** * CopyPixels with the blitter. Don't support zooming, pixel transfer, etc. @@ -235,6 +333,9 @@ intelCopyPixels(GLcontext * ctx, if (do_blit_copypixels(ctx, srcx, srcy, width, height, destx, desty, type)) return; + if (do_texture_copypixels(ctx, srcx, srcy, width, height, destx, desty, type)) + return; + if (INTEL_DEBUG & DEBUG_PIXEL) _mesa_printf("fallback to _swrast_CopyPixels\n"); diff --git a/src/mesa/drivers/dri/i965/intel_tex_validate.c b/src/mesa/drivers/dri/i965/intel_tex_validate.c index 91ae0970a04..cb23b9dd879 100644 --- a/src/mesa/drivers/dri/i965/intel_tex_validate.c +++ b/src/mesa/drivers/dri/i965/intel_tex_validate.c @@ -133,6 +133,9 @@ GLuint intel_finalize_mipmap_tree( struct intel_context *intel, GLuint nr_faces = 0; struct gl_texture_image *firstImage; + if( tObj == intel->frame_buffer_texobj ) + return GL_FALSE; + /* We know/require this is true by now: */ assert(intelObj->base.Complete); diff --git a/src/mesa/drivers/dri/mga/mgatex.c b/src/mesa/drivers/dri/mga/mgatex.c index 8caa1f8580f..a7d74317a5b 100644 --- a/src/mesa/drivers/dri/mga/mgatex.c +++ b/src/mesa/drivers/dri/mga/mgatex.c @@ -502,6 +502,9 @@ mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj ) driDestroyTextureObject( t ); } + + /* Free mipmap images and the texture object itself */ + _mesa_delete_texture_object(ctx, tObj); } diff --git a/src/mesa/drivers/dri/r200/r200_context.h b/src/mesa/drivers/dri/r200/r200_context.h index 9f109e07ff5..fa38a78e263 100644 --- a/src/mesa/drivers/dri/r200/r200_context.h +++ b/src/mesa/drivers/dri/r200/r200_context.h @@ -107,6 +107,8 @@ struct r200_vertex_program { VERTEX_SHADER_INSTRUCTION instr[R200_VSF_MAX_INST + 6]; int pos_end; int inputs[VERT_ATTRIB_MAX]; + int rev_inputs[16]; + int gen_inputs_mapped; int native; int fogpidx; int fogmode; diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c index f6ab2f00746..39c1f68911f 100644 --- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c +++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c @@ -385,6 +385,14 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) GLuint vfmt0 = 0, vfmt1 = 0; GLuint count = VB->Count; GLuint i; + GLuint generic_in_mapped = 0; + struct r200_vertex_program *vp = NULL; + + /* this looks way more complicated than necessary... */ + if (ctx->VertexProgram._Enabled) { + vp = rmesa->curr_vp_hw; + generic_in_mapped = vp->gen_inputs_mapped; + } if (inputs & VERT_BIT_POS) { if (!rmesa->tcl.obj.buf) @@ -404,6 +412,19 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) } component[nr++] = &rmesa->tcl.obj; } + else if (generic_in_mapped & (1 << 0)) { + int geninput = vp->rev_inputs[0] - VERT_ATTRIB_GENERIC0; + if (!rmesa->tcl.generic[geninput].buf) { + emit_vector( ctx, + &(rmesa->tcl.generic[geninput]), + (char *)VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->data, + 4, + VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->stride, + count ); + } + component[nr++] = &rmesa->tcl.generic[geninput]; + vfmt0 |= R200_VTX_W0 | R200_VTX_Z0; + } if (inputs & VERT_BIT_NORMAL) { if (!rmesa->tcl.norm.buf) @@ -463,6 +484,23 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) component[nr++] = &rmesa->tcl.rgba; } +/* vfmt0 |= R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT; + emit_ubyte_rgba( ctx, &rmesa->tcl.rgba, + (char *)VB->ColorPtr[0]->data, 4, + VB->ColorPtr[0]->stride, count);*/ + else if (generic_in_mapped & (1 << 2)) { + int geninput = vp->rev_inputs[2] - VERT_ATTRIB_GENERIC0; + if (!rmesa->tcl.generic[geninput].buf) { + emit_vector( ctx, + &(rmesa->tcl.generic[geninput]), + (char *)VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->data, + 4, + VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->stride, + count ); + } + component[nr++] = &rmesa->tcl.generic[geninput]; + vfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT; + } if (inputs & VERT_BIT_COLOR1) { @@ -480,8 +518,49 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) vfmt0 |= R200_VTX_FP_RGB << R200_VTX_COLOR_1_SHIFT; component[nr++] = &rmesa->tcl.spec; } + else if (generic_in_mapped & (1 << 3)) { + int geninput = vp->rev_inputs[3] - VERT_ATTRIB_GENERIC0; + if (!rmesa->tcl.generic[geninput].buf) { + emit_vector( ctx, + &(rmesa->tcl.generic[geninput]), + (char *)VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->data, + 4, + VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->stride, + count ); + } + component[nr++] = &rmesa->tcl.generic[geninput]; + vfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT; + } - for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) { + if (generic_in_mapped & (1 << 4)) { + int geninput = vp->rev_inputs[4] - VERT_ATTRIB_GENERIC0; + if (!rmesa->tcl.generic[geninput].buf) { + emit_vector( ctx, + &(rmesa->tcl.generic[geninput]), + (char *)VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->data, + 4, + VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->stride, + count ); + } + component[nr++] = &rmesa->tcl.generic[geninput]; + vfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_2_SHIFT; + } + + if (generic_in_mapped & (1 << 5)) { + int geninput = vp->rev_inputs[5] - VERT_ATTRIB_GENERIC0; + if (!rmesa->tcl.generic[geninput].buf) { + emit_vector( ctx, + &(rmesa->tcl.generic[geninput]), + (char *)VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->data, + 4, + VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->stride, + count ); + } + component[nr++] = &rmesa->tcl.generic[geninput]; + vfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_3_SHIFT; + } + + for ( i = 0 ; i < 6 ; i++ ) { if (inputs & (VERT_BIT_TEX0 << i)) { if (!rmesa->tcl.tex[i].buf) emit_vector( ctx, @@ -494,8 +573,37 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) vfmt1 |= VB->TexCoordPtr[i]->size << (i * 3); component[nr++] = &rmesa->tcl.tex[i]; } + else if (generic_in_mapped & (1 << (i + 6))) { + int geninput = vp->rev_inputs[i + 6] - VERT_ATTRIB_GENERIC0; + if (!rmesa->tcl.generic[geninput].buf) { + emit_vector( ctx, + &(rmesa->tcl.generic[geninput]), + (char *)VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->data, + 4, + VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->stride, + count ); + } + component[nr++] = &rmesa->tcl.generic[geninput]; + vfmt1 |= 4 << (R200_VTX_TEX0_COMP_CNT_SHIFT + (i * 3)); + } } + if (generic_in_mapped & (1 << 13)) { + int geninput = vp->rev_inputs[13] - VERT_ATTRIB_GENERIC0; + if (!rmesa->tcl.generic[geninput].buf) { + emit_vector( ctx, + &(rmesa->tcl.generic[geninput]), + (char *)VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->data, + 4, + VB->AttribPtr[geninput + VERT_ATTRIB_GENERIC0]->stride, + count ); + } + component[nr++] = &rmesa->tcl.generic[geninput]; + vfmt0 |= R200_VTX_XY1 | R200_VTX_Z1 | R200_VTX_W1; + } + +/* doesn't work. Wrong order with mixed generic & conventional! */ +/* if (ctx->VertexProgram._Enabled) { int *vp_inputs = rmesa->curr_vp_hw->inputs; for ( i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++ ) { @@ -539,6 +647,7 @@ void r200EmitArrays( GLcontext *ctx, GLuint inputs ) } } } +*/ if (vfmt0 != rmesa->hw.vtx.cmd[VTX_VTXFMT_0] || vfmt1 != rmesa->hw.vtx.cmd[VTX_VTXFMT_1]) { diff --git a/src/mesa/drivers/dri/r200/r200_sanity.c b/src/mesa/drivers/dri/r200/r200_sanity.c index ca5b926a944..3f2a8665309 100644 --- a/src/mesa/drivers/dri/r200/r200_sanity.c +++ b/src/mesa/drivers/dri/r200/r200_sanity.c @@ -978,7 +978,7 @@ static int radeon_emit_veclinear( } } else if ((start >= 0x180) && (start < 0x1c0)) { - for (i = start ; (i < start + sz) ; i += 4) { + for (i = 0 ; i < sz ; i += 4) { fprintf(stderr, "R200_VS_PROG %d OPDST %08x\n", (i >> 2) + start - 0x180 + 0x40, data[i]); fprintf(stderr, "R200_VS_PROG %d SRC1 %08x\n", (i >> 2) + start - 0x180 + 0x40, data[i+1]); fprintf(stderr, "R200_VS_PROG %d SRC2 %08x\n", (i >> 2) + start - 0x180 + 0x40, data[i+2]); diff --git a/src/mesa/drivers/dri/r200/r200_vertprog.c b/src/mesa/drivers/dri/r200/r200_vertprog.c index b5afe51d824..899e84caa0f 100644 --- a/src/mesa/drivers/dri/r200/r200_vertprog.c +++ b/src/mesa/drivers/dri/r200/r200_vertprog.c @@ -405,6 +405,7 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte int dofogfix = 0; int fog_temp_i = 0; int free_inputs; + int free_inputs_conv; int array_count = 0; vp->native = GL_FALSE; @@ -530,6 +531,7 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte array_count++; } } + free_inputs_conv = free_inputs; /* using VERT_ATTRIB_TEX6/7 would be illegal */ /* completely ignore aliasing? */ for (i = VERT_ATTRIB_GENERIC0; i < VERT_ATTRIB_MAX; i++) { @@ -548,11 +550,13 @@ static GLboolean r200_translate_vertex_program(GLcontext *ctx, struct r200_verte if (free_inputs & (1 << j)) { free_inputs &= ~(1 << j); vp->inputs[i] = j; + vp->rev_inputs[j] = i; break; } } } } + vp->gen_inputs_mapped = free_inputs ^ free_inputs_conv; if (!(mesa_vp->Base.OutputsWritten & (1 << VERT_RESULT_HPOS))) { if (R200_DEBUG & DEBUG_FALLBACKS) { @@ -1205,6 +1209,9 @@ r200ProgramStringNotify(GLcontext *ctx, GLenum target, struct gl_program *prog) r200_translate_vertex_program(ctx, vp); rmesa->curr_vp_hw = NULL; break; + case GL_FRAGMENT_SHADER_ATI: + rmesa->afs_loaded = NULL; + break; } /* need this for tcl fallbacks */ _tnl_program_string(ctx, target, prog); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 44ee0465690..7ff45cffe8b 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1086,7 +1086,7 @@ _mesa_init_constants( GLcontext *ctx ) /* If we're running in the X server, do bounds checking to prevent * segfaults and server crashes! */ -#if defined(XFree86LOADER) && defined(IN_MODULE) +#if defined(XFree86Server) ctx->Const.CheckArrayBounds = GL_TRUE; #else ctx->Const.CheckArrayBounds = GL_FALSE; diff --git a/src/mesa/shader/arbprogram.c b/src/mesa/shader/arbprogram.c index 91fb6910381..bff80d7ee3a 100644 --- a/src/mesa/shader/arbprogram.c +++ b/src/mesa/shader/arbprogram.c @@ -195,13 +195,15 @@ _mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer) GLboolean GLAPIENTRY _mesa_IsProgramARB(GLuint id) { + struct gl_program *prog = NULL; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); if (id == 0) return GL_FALSE; - if (_mesa_lookup_program(ctx, id)) + prog = _mesa_lookup_program(ctx, id); + if (prog && (prog != &_mesa_DummyProgram)) return GL_TRUE; else return GL_FALSE; @@ -765,6 +767,7 @@ void GLAPIENTRY _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string) { const struct gl_program *prog; + char *dst = (char *) string; GET_CURRENT_CONTEXT(ctx); if (!ctx->_CurrentProgram) @@ -788,5 +791,8 @@ _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string) return; } - _mesa_memcpy(string, prog->String, _mesa_strlen((char *) prog->String)); + if (prog->String) + _mesa_memcpy(dst, prog->String, _mesa_strlen((char *) prog->String)); + else + *dst = '\0'; } diff --git a/src/mesa/shader/atifragshader.c b/src/mesa/shader/atifragshader.c index d349a496dc7..4727c1a4365 100644 --- a/src/mesa/shader/atifragshader.c +++ b/src/mesa/shader/atifragshader.c @@ -400,6 +400,8 @@ _mesa_EndFragmentShaderATI(void) } } #endif + if (ctx->Driver.ProgramStringNotify) + ctx->Driver.ProgramStringNotify( ctx, GL_FRAGMENT_SHADER_ATI, NULL ); } void GLAPIENTRY diff --git a/src/mesa/shader/program.c b/src/mesa/shader/program.c index 789d36eba02..ddfad47b894 100644 --- a/src/mesa/shader/program.c +++ b/src/mesa/shader/program.c @@ -207,6 +207,7 @@ _mesa_init_program_struct( GLcontext *ctx, struct gl_program *prog, prog->Target = target; prog->Resident = GL_TRUE; prog->RefCount = 1; + prog->Format = GL_PROGRAM_FORMAT_ASCII_ARB; } return prog; @@ -284,6 +285,9 @@ _mesa_delete_program(GLcontext *ctx, struct gl_program *prog) (void) ctx; ASSERT(prog); + if (prog == &_mesa_DummyProgram) + return; + if (prog->String) _mesa_free(prog->String); diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c index d894a8db18c..a1038671c41 100644 --- a/src/mesa/shader/slang/slang_assemble_assignment.c +++ b/src/mesa/shader/slang/slang_assemble_assignment.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.2 * * Copyright (C) 2005-2006 Brian Paul All Rights Reserved. * @@ -53,8 +53,11 @@ * +------------------+ */ + + static GLboolean -assign_basic (slang_assemble_ctx *A, slang_storage_type type, GLuint *index, GLuint size) +assign_basic(slang_assemble_ctx * A, slang_storage_type type, GLuint * index, + GLuint size) { GLuint dst_offset, dst_addr_loc; slang_assembly_type ty; @@ -85,22 +88,25 @@ assign_basic (slang_assemble_ctx *A, slang_storage_type type, GLuint *index, GLu ty = slang_asm_none; } - /* Calculate the distance from top of the stack to the destination address. As the - * copy operation progresses, components of the source are being successively popped - * off the stack by the amount of *index increase step. - */ + /* Calculate the distance from top of the stack to the destination + * address. As the copy operation progresses, components of the + * source are being successively popped off the stack by the amount + * of *index increase step. + */ dst_addr_loc = size - *index; - if (!slang_assembly_file_push_label2 (A->file, ty, dst_addr_loc, dst_offset)) + if (!slang_assembly_file_push_label2 + (A->file, ty, dst_addr_loc, dst_offset)) return GL_FALSE; - *index += _slang_sizeof_type (type); + *index += _slang_sizeof_type(type); return GL_TRUE; } + static GLboolean -assign_aggregate (slang_assemble_ctx *A, const slang_storage_aggregate *agg, GLuint *index, - GLuint size) +assign_aggregate(slang_assemble_ctx * A, const slang_storage_aggregate * agg, + GLuint * index, GLuint size) { GLuint i; @@ -110,25 +116,26 @@ assign_aggregate (slang_assemble_ctx *A, const slang_storage_aggregate *agg, GLu for (j = 0; j < arr->length; j++) { if (arr->type == slang_stor_aggregate) { - if (!assign_aggregate (A, arr->aggregate, index, size)) + if (!assign_aggregate(A, arr->aggregate, index, size)) return GL_FALSE; } else { - /* When the destination is swizzled, we are forced to do float_copy, even if - * vec4 extension is enabled with vec4_copy operation. + /* When the destination is swizzled, we are forced to do + * float_copy, even if vec4 extension is enabled with + * vec4_copy operation. */ if (A->swz.num_components != 0 && arr->type == slang_stor_vec4) { - if (!assign_basic (A, slang_stor_float, index, size)) + if (!assign_basic(A, slang_stor_float, index, size)) return GL_FALSE; - if (!assign_basic (A, slang_stor_float, index, size)) + if (!assign_basic(A, slang_stor_float, index, size)) return GL_FALSE; - if (!assign_basic (A, slang_stor_float, index, size)) + if (!assign_basic(A, slang_stor_float, index, size)) return GL_FALSE; - if (!assign_basic (A, slang_stor_float, index, size)) + if (!assign_basic(A, slang_stor_float, index, size)) return GL_FALSE; } else { - if (!assign_basic (A, arr->type, index, size)) + if (!assign_basic(A, arr->type, index, size)) return GL_FALSE; } } @@ -138,80 +145,79 @@ assign_aggregate (slang_assemble_ctx *A, const slang_storage_aggregate *agg, GLu return GL_TRUE; } -GLboolean _slang_assemble_assignment (slang_assemble_ctx *A, slang_operation *op) + +GLboolean +_slang_assemble_assignment(slang_assemble_ctx * A, const slang_operation * op) { - slang_assembly_typeinfo ti; - GLboolean result = GL_FALSE; - slang_storage_aggregate agg; - GLuint index, size; - - if (!slang_assembly_typeinfo_construct (&ti)) - return GL_FALSE; - if (!_slang_typeof_operation (A, op, &ti)) - goto end1; - - if (!slang_storage_aggregate_construct (&agg)) - goto end1; - if (!_slang_aggregate_variable (&agg, &ti.spec, 0, A->space.funcs, A->space.structs, - A->space.vars, A->mach, A->file, A->atoms)) - goto end; - - index = 0; - size = _slang_sizeof_aggregate (&agg); - result = assign_aggregate (A, &agg, &index, size); - -end1: - slang_storage_aggregate_destruct (&agg); -end: - slang_assembly_typeinfo_destruct (&ti); - return result; + slang_assembly_typeinfo ti; + GLboolean result = GL_FALSE; + slang_storage_aggregate agg; + GLuint index, size; + + if (!slang_assembly_typeinfo_construct(&ti)) + return GL_FALSE; + if (!_slang_typeof_operation(A, op, &ti)) + goto end1; + + if (!slang_storage_aggregate_construct(&agg)) + goto end1; + if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, + A->space.structs, A->space.vars, + A->mach, A->file, A->atoms)) + goto end; + + index = 0; + size = _slang_sizeof_aggregate(&agg); + result = assign_aggregate(A, &agg, &index, size); + + end1: + slang_storage_aggregate_destruct(&agg); + end: + slang_assembly_typeinfo_destruct(&ti); + return result; } -/* - * _slang_assemble_assign() - * - * Performs unary (pre ++ and --) or binary (=, +=, -=, *=, /=) assignment on the operation's - * children. - */ -GLboolean _slang_assemble_assign (slang_assemble_ctx *A, slang_operation *op, const char *oper, - slang_ref_type ref) +/** + * Performs unary (pre ++ and --) or binary (=, +=, -=, *=, /=) + * assignment on the operation's children. + */ +GLboolean +_slang_assemble_assign(slang_assemble_ctx * A, slang_operation * op, + const char *oper, slang_ref_type ref) { - slang_swizzle swz; - - if (ref == slang_ref_forbid) - { - if (!slang_assembly_file_push_label2 (A->file, slang_asm_local_addr, A->local.addr_tmp, 4)) - return GL_FALSE; - } - - if (slang_string_compare ("=", oper) == 0) - { - if (!_slang_assemble_operation (A, &op->children[0], slang_ref_force)) - return GL_FALSE; - swz = A->swz; - if (!_slang_assemble_operation (A, &op->children[1], slang_ref_forbid)) - return GL_FALSE; - A->swz = swz; - if (!_slang_assemble_assignment (A, op->children)) - return GL_FALSE; - } - else - { - if (!_slang_assemble_function_call_name (A, oper, op->children, op->num_children, GL_TRUE)) - return GL_FALSE; - } - - if (ref == slang_ref_forbid) - { - if (!slang_assembly_file_push (A->file, slang_asm_addr_copy)) - return GL_FALSE; - if (!slang_assembly_file_push_label (A->file, slang_asm_local_free, 4)) - return GL_FALSE; - if (!_slang_dereference (A, op->children)) - return GL_FALSE; - } - - return GL_TRUE; -} + slang_swizzle swz; + + if (ref == slang_ref_forbid) { + if (!slang_assembly_file_push_label2 + (A->file, slang_asm_local_addr, A->local.addr_tmp, 4)) + return GL_FALSE; + } + + if (slang_string_compare("=", oper) == 0) { + if (!_slang_assemble_operation(A, &op->children[0], slang_ref_force)) + return GL_FALSE; + swz = A->swz; + if (!_slang_assemble_operation(A, &op->children[1], slang_ref_forbid)) + return GL_FALSE; + A->swz = swz; + if (!_slang_assemble_assignment(A, op->children)) + return GL_FALSE; + } + else { + if (!_slang_assemble_function_call_name + (A, oper, op->children, op->num_children, GL_TRUE)) + return GL_FALSE; + } + + if (ref == slang_ref_forbid) { + if (!slang_assembly_file_push(A->file, slang_asm_addr_copy)) + return GL_FALSE; + if (!slang_assembly_file_push_label(A->file, slang_asm_local_free, 4)) + return GL_FALSE; + if (!_slang_dereference(A, op->children)) + return GL_FALSE; + } + return GL_TRUE; +} diff --git a/src/mesa/shader/slang/slang_assemble_assignment.h b/src/mesa/shader/slang/slang_assemble_assignment.h index 7b993b543b1..3c1ecdedab8 100644 --- a/src/mesa/shader/slang/slang_assemble_assignment.h +++ b/src/mesa/shader/slang/slang_assemble_assignment.h @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.2 * * Copyright (C) 2005-2006 Brian Paul All Rights Reserved. * @@ -22,21 +22,24 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H +#ifndef SLANG_ASSEMBLE_ASSIGNMENT_H #define SLANG_ASSEMBLE_ASSIGNMENT_H #if defined __cplusplus extern "C" { #endif -GLboolean _slang_assemble_assignment (slang_assemble_ctx *, struct slang_operation_ *); -GLboolean _slang_assemble_assign (slang_assemble_ctx *, struct slang_operation_ *, const char *, - slang_ref_type); +extern GLboolean +_slang_assemble_assignment(slang_assemble_ctx *, const struct slang_operation_ *); + +extern GLboolean +_slang_assemble_assign(slang_assemble_ctx *, struct slang_operation_ *, + const char *, slang_ref_type); + #ifdef __cplusplus } #endif -#endif - +#endif /* SLANG_ASSEMBLE_ASSIGNMENT_H */ diff --git a/src/mesa/shader/slang/slang_assemble_constructor.c b/src/mesa/shader/slang/slang_assemble_constructor.c index 8b5458f7661..6cd320d4466 100644 --- a/src/mesa/shader/slang/slang_assemble_constructor.c +++ b/src/mesa/shader/slang/slang_assemble_constructor.c @@ -171,9 +171,9 @@ sizeof_argument(slang_assemble_ctx * A, GLuint * size, slang_operation * op) if (!slang_storage_aggregate_construct(&agg)) goto end1; - if (!_slang_aggregate_variable - (&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, + A->space.structs, A->space.vars, + A->mach, A->file, A->atoms)) goto end; *size = _slang_sizeof_aggregate(&agg); @@ -186,6 +186,7 @@ sizeof_argument(slang_assemble_ctx * A, GLuint * size, slang_operation * op) return result; } + static GLboolean constructor_aggregate(slang_assemble_ctx * A, const slang_storage_aggregate * flat, @@ -202,9 +203,9 @@ constructor_aggregate(slang_assemble_ctx * A, if (!slang_storage_aggregate_construct(&agg)) goto end1; - if (!_slang_aggregate_variable - (&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, + A->space.structs, A->space.vars, + A->mach, A->file, A->atoms)) goto end2; if (!slang_storage_aggregate_construct(&flat_agg)) @@ -245,8 +246,9 @@ constructor_aggregate(slang_assemble_ctx * A, return result; } + GLboolean -_slang_assemble_constructor(slang_assemble_ctx * A, slang_operation * op) +_slang_assemble_constructor(slang_assemble_ctx * A, const slang_operation * op) { slang_assembly_typeinfo ti; GLboolean result = GL_FALSE; @@ -263,9 +265,9 @@ _slang_assemble_constructor(slang_assemble_ctx * A, slang_operation * op) /* create an aggregate of the constructor */ if (!slang_storage_aggregate_construct(&agg)) goto end1; - if (!_slang_aggregate_variable - (&agg, &ti.spec, 0, A->space.funcs, A->space.structs, A->space.vars, - A->mach, A->file, A->atoms)) + if (!_slang_aggregate_variable(&agg, &ti.spec, 0, A->space.funcs, + A->space.structs, A->space.vars, + A->mach, A->file, A->atoms)) goto end2; /* calculate size of the constructor */ @@ -334,12 +336,12 @@ _slang_assemble_constructor(slang_assemble_ctx * A, slang_operation * op) GLboolean _slang_assemble_constructor_from_swizzle(slang_assemble_ctx * A, const slang_swizzle * swz, - slang_type_specifier * spec, - slang_type_specifier * master_spec) + const slang_type_specifier * spec, + const slang_type_specifier * master_spec) { - GLuint master_rows, i; + const GLuint master_rows = _slang_type_dim(master_spec->type); + GLuint i; - master_rows = _slang_type_dim(master_spec->type); for (i = 0; i < master_rows; i++) { switch (_slang_type_base(master_spec->type)) { case slang_spec_bool: @@ -361,19 +363,22 @@ _slang_assemble_constructor_from_swizzle(slang_assemble_ctx * A, break; } } + if (!slang_assembly_file_push_label(A->file, slang_asm_local_free, 4)) return GL_FALSE; + for (i = swz->num_components; i > 0; i--) { - GLuint n = i - 1; + const GLuint n = i - 1; - if (!slang_assembly_file_push_label2 - (A->file, slang_asm_local_addr, A->local.swizzle_tmp, 16)) + if (!slang_assembly_file_push_label2(A->file, slang_asm_local_addr, + A->local.swizzle_tmp, 16)) return GL_FALSE; - if (!slang_assembly_file_push_label - (A->file, slang_asm_addr_push, swz->swizzle[n] * 4)) + if (!slang_assembly_file_push_label(A->file, slang_asm_addr_push, + swz->swizzle[n] * 4)) return GL_FALSE; if (!slang_assembly_file_push(A->file, slang_asm_addr_add)) return GL_FALSE; + switch (_slang_type_base(master_spec->type)) { case slang_spec_bool: if (!slang_assembly_file_push(A->file, slang_asm_bool_deref)) diff --git a/src/mesa/shader/slang/slang_assemble_constructor.h b/src/mesa/shader/slang/slang_assemble_constructor.h index c7aedf3af81..c0deb913448 100644 --- a/src/mesa/shader/slang/slang_assemble_constructor.h +++ b/src/mesa/shader/slang/slang_assemble_constructor.h @@ -41,13 +41,14 @@ _slang_multiply_swizzles(slang_swizzle *, const slang_swizzle *, const slang_swizzle *); extern GLboolean -_slang_assemble_constructor(slang_assemble_ctx *, struct slang_operation_ *); +_slang_assemble_constructor(slang_assemble_ctx *, + const struct slang_operation_ *); extern GLboolean _slang_assemble_constructor_from_swizzle(slang_assemble_ctx *, const slang_swizzle *, - slang_type_specifier *, - slang_type_specifier *); + const slang_type_specifier *, + const slang_type_specifier *); #ifdef __cplusplus } diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 77a293ea45e..c49ab4a68dc 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.6 + * Version: 6.5.2 * * Copyright (C) 2005-2006 Brian Paul All Rights Reserved. * @@ -42,14 +42,16 @@ * may be accepted resulting in undefined behaviour. */ -/* slang_var_pool */ + +/** + * Allocate storage for a variable of 'size' bytes from given pool. + * Return the allocated address for the variable. + */ static GLuint slang_var_pool_alloc(slang_var_pool * pool, unsigned int size) { - GLuint addr; - - addr = pool->next_addr; + const GLuint addr = pool->next_addr; pool->next_addr += size; return addr; } @@ -432,22 +434,11 @@ parse_struct_field(slang_parse_ctx * C, slang_output_ctx * O, return 0; do { - slang_variable *var; - - st->fields->variables = - (slang_variable *) slang_alloc_realloc(st->fields->variables, - st->fields->num_variables * - sizeof(slang_variable), - (st->fields->num_variables + - 1) * sizeof(slang_variable)); - if (st->fields->variables == NULL) { + slang_variable *var = slang_variable_scope_grow(st->fields); + if (!var) { slang_info_log_memory(C->L); return 0; } - var = &st->fields->variables[st->fields->num_variables]; - if (!slang_variable_construct(var)) - return 0; - st->fields->num_variables++; if (!parse_struct_field_var(C, &o, var, sp)) return 0; } @@ -1222,6 +1213,7 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O, if (!parse_child_operation(C, O, op, 0)) return 0; C->I++; + if (!C->parsing_builtin && !slang_function_scope_find_by_name(O->funs, op->a_id, 1)) { const char *id; @@ -1479,20 +1471,11 @@ parse_function_prototype(slang_parse_ctx * C, slang_output_ctx * O, /* parse function parameters */ while (*C->I++ == PARAMETER_NEXT) { - slang_variable *p; - - func->parameters->variables = (slang_variable *) - slang_alloc_realloc(func->parameters->variables, - func->parameters->num_variables * sizeof(slang_variable), - (func->parameters->num_variables + 1) * sizeof(slang_variable)); - if (func->parameters->variables == NULL) { + slang_variable *p = slang_variable_scope_grow(func->parameters); + if (!p) { slang_info_log_memory(C->L); return 0; } - p = &func->parameters->variables[func->parameters->num_variables]; - if (!slang_variable_construct(p)) - return 0; - func->parameters->num_variables++; if (!parse_parameter_declaration(C, O, p)) return 0; } @@ -1662,18 +1645,11 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O, return 1; /* make room for the new variable and initialize it */ - O->vars->variables = (slang_variable *) - slang_alloc_realloc(O->vars->variables, - O->vars->num_variables * sizeof(slang_variable), - (O->vars->num_variables + 1) * sizeof(slang_variable)); - if (O->vars->variables == NULL) { + var = slang_variable_scope_grow(O->vars); + if (!var) { slang_info_log_memory(C->L); return 0; } - var = &O->vars->variables[O->vars->num_variables]; - if (!slang_variable_construct(var)) - return 0; - O->vars->num_variables++; /* copy the declarator qualifier type, parse the identifier */ var->global = C->global_scope; diff --git a/src/mesa/shader/slang/slang_compile_function.h b/src/mesa/shader/slang/slang_compile_function.h index 1a7302f29aa..c05c6f4d850 100644 --- a/src/mesa/shader/slang/slang_compile_function.h +++ b/src/mesa/shader/slang/slang_compile_function.h @@ -64,8 +64,8 @@ typedef struct slang_function_ { slang_function_kind kind; slang_variable header; /**< The function's name and return type */ - slang_variable_scope *parameters; /**< array [param_count] */ - unsigned int param_count; + slang_variable_scope *parameters; /**< formal parameters AND local vars */ + unsigned int param_count; /**< number of formal params (no locals) */ slang_operation *body; /**< The instruction tree */ unsigned int address; /**< Address of this func in memory */ slang_fixup_table fixups; /**< Mem locations which need func's address */ diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c index 7e920135597..73f57bfb123 100644 --- a/src/mesa/shader/slang/slang_compile_operation.c +++ b/src/mesa/shader/slang/slang_compile_operation.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 6.5.2 * * Copyright (C) 2005-2006 Brian Paul All Rights Reserved. * @@ -31,68 +31,85 @@ #include "imports.h" #include "slang_compile.h" -/* slang_operation */ -int slang_operation_construct (slang_operation *oper) +/** + * Init a slang_operation object + */ +GLboolean +slang_operation_construct(slang_operation * oper) { - oper->type = slang_oper_none; - oper->children = NULL; - oper->num_children = 0; - oper->literal = (float) 0; - oper->a_id = SLANG_ATOM_NULL; - oper->locals = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope)); - if (oper->locals == NULL) - return 0; - _slang_variable_scope_ctr (oper->locals); - return 1; + oper->type = slang_oper_none; + oper->children = NULL; + oper->num_children = 0; + oper->literal = (float) 0; + oper->a_id = SLANG_ATOM_NULL; + oper->locals = + (slang_variable_scope *) + slang_alloc_malloc(sizeof(slang_variable_scope)); + if (oper->locals == NULL) + return GL_FALSE; + _slang_variable_scope_ctr(oper->locals); + return GL_TRUE; } -void slang_operation_destruct (slang_operation *oper) +void +slang_operation_destruct(slang_operation * oper) { - unsigned int i; + GLuint i; - for (i = 0; i < oper->num_children; i++) - slang_operation_destruct (oper->children + i); - slang_alloc_free (oper->children); - slang_variable_scope_destruct (oper->locals); - slang_alloc_free (oper->locals); + for (i = 0; i < oper->num_children; i++) + slang_operation_destruct(oper->children + i); + slang_alloc_free(oper->children); + slang_variable_scope_destruct(oper->locals); + slang_alloc_free(oper->locals); } -int slang_operation_copy (slang_operation *x, const slang_operation *y) +/** + * Recursively copy a slang_operation node. + * \return GL_TRUE for success, GL_FALSE if failure + */ +GLboolean +slang_operation_copy(slang_operation * x, const slang_operation * y) { - slang_operation z; - unsigned int i; + slang_operation z; + GLuint i; - if (!slang_operation_construct (&z)) - return 0; - z.type = y->type; - z.children = (slang_operation *) slang_alloc_malloc (y->num_children * sizeof (slang_operation)); - if (z.children == NULL) - { - slang_operation_destruct (&z); - return 0; - } - for (z.num_children = 0; z.num_children < y->num_children; z.num_children++) - if (!slang_operation_construct (&z.children[z.num_children])) - { - slang_operation_destruct (&z); - return 0; - } - for (i = 0; i < z.num_children; i++) - if (!slang_operation_copy (&z.children[i], &y->children[i])) - { - slang_operation_destruct (&z); - return 0; - } - z.literal = y->literal; - z.a_id = y->a_id; - if (!slang_variable_scope_copy (z.locals, y->locals)) - { - slang_operation_destruct (&z); - return 0; - } - slang_operation_destruct (x); - *x = z; - return 1; + if (!slang_operation_construct(&z)) + return GL_FALSE; + z.type = y->type; + z.children = (slang_operation *) + slang_alloc_malloc(y->num_children * sizeof(slang_operation)); + if (z.children == NULL) { + slang_operation_destruct(&z); + return GL_FALSE; + } + for (z.num_children = 0; z.num_children < y->num_children; + z.num_children++) { + if (!slang_operation_construct(&z.children[z.num_children])) { + slang_operation_destruct(&z); + return GL_FALSE; + } + } + for (i = 0; i < z.num_children; i++) { + if (!slang_operation_copy(&z.children[i], &y->children[i])) { + slang_operation_destruct(&z); + return GL_FALSE; + } + } + z.literal = y->literal; + z.a_id = y->a_id; + if (!slang_variable_scope_copy(z.locals, y->locals)) { + slang_operation_destruct(&z); + return GL_FALSE; + } + slang_operation_destruct(x); + *x = z; + return GL_TRUE; } + +slang_operation * +slang_operation_new(GLuint count) +{ + return (slang_operation *) _mesa_calloc(count * sizeof(slang_operation)); +} diff --git a/src/mesa/shader/slang/slang_compile_operation.h b/src/mesa/shader/slang/slang_compile_operation.h index f3c45de3c2a..a9376ec945f 100644 --- a/src/mesa/shader/slang/slang_compile_operation.h +++ b/src/mesa/shader/slang/slang_compile_operation.h @@ -32,7 +32,7 @@ extern "C" { /** * Types of slang operations. - * These are the basic intermediate code representations. + * These are the types of the AST (abstract syntax tree) nodes. * [foo] indicates a sub-tree or reference to another type of node */ typedef enum slang_operation_type_ @@ -105,6 +105,7 @@ typedef enum slang_operation_type_ /** * A slang_operation is basically a compiled instruction (such as assignment, * a while-loop, a conditional, a multiply, a function call, etc). + * The AST (abstract syntax tree) is built from these nodes. * NOTE: This structure could have been implemented as a union of simpler * structs which would correspond to the operation types above. */ @@ -112,16 +113,24 @@ typedef struct slang_operation_ { slang_operation_type type; struct slang_operation_ *children; - unsigned int num_children; - float literal; /**< Used for float, int and bool values */ - slang_atom a_id; /**< type: asm, identifier, call, field */ + GLuint num_children; + GLfloat literal; /**< Used for float, int and bool values */ + slang_atom a_id; /**< type: asm, identifier, call, field */ slang_variable_scope *locals; /**< local vars for scope */ } slang_operation; -extern int slang_operation_construct(slang_operation *); -extern void slang_operation_destruct(slang_operation *); -extern int slang_operation_copy(slang_operation *, const slang_operation *); +extern GLboolean +slang_operation_construct(slang_operation *); + +extern void +slang_operation_destruct(slang_operation *); + +extern GLboolean +slang_operation_copy(slang_operation *, const slang_operation *); + +extern slang_operation * +slang_operation_new(GLuint count); #ifdef __cplusplus diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index 92951b85bbc..a8a2d6aa6a0 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -181,6 +181,32 @@ slang_variable_scope_copy(slang_variable_scope * x, return 1; } + +/** + * Grow the variable list by one. + * \return pointer to space for the new variable (will be initialized) + */ +slang_variable * +slang_variable_scope_grow(slang_variable_scope *scope) +{ + const int n = scope->num_variables; + scope->variables = (slang_variable *) + slang_alloc_realloc(scope->variables, + n * sizeof(slang_variable), + (n + 1) * sizeof(slang_variable)); + if (!scope->variables) + return NULL; + + scope->num_variables++; + + if (!slang_variable_construct(scope->variables + n)) + return NULL; + + return scope->variables + n; +} + + + /* slang_variable */ int diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h index 2f358860f82..b0910e855ea 100644 --- a/src/mesa/shader/slang/slang_compile_variable.h +++ b/src/mesa/shader/slang/slang_compile_variable.h @@ -81,6 +81,7 @@ typedef struct slang_variable_ GLuint address2; /**< Storage location */ GLuint size; /**< Variable's size in bytes */ GLboolean global; /**< A global var? */ + void *aux; /**< Used during code gen */ } slang_variable; @@ -104,6 +105,8 @@ extern int slang_variable_scope_copy(slang_variable_scope *, const slang_variable_scope *); +slang_variable * +slang_variable_scope_grow(slang_variable_scope *); extern int slang_variable_construct(slang_variable *); diff --git a/src/mesa/tnl/t_vb_arbprogram.c b/src/mesa/tnl/t_vb_arbprogram.c index 71fb45dd95c..bf4c1d52237 100644 --- a/src/mesa/tnl/t_vb_arbprogram.c +++ b/src/mesa/tnl/t_vb_arbprogram.c @@ -1529,7 +1529,7 @@ const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage = void _tnl_program_string(GLcontext *ctx, GLenum target, struct gl_program *program) { - if (program->Target == GL_VERTEX_PROGRAM_ARB) { + if (target == GL_VERTEX_PROGRAM_ARB) { /* free any existing tnl data hanging off the program */ struct gl_vertex_program *vprog = (struct gl_vertex_program *) program; if (vprog->TnlData) { -- cgit v1.2.3