diff options
59 files changed, 540 insertions, 594 deletions
@@ -208,9 +208,7 @@ MAIN_FILES = \ $(DIRECTORY)/docs/RELNOTES* \ $(DIRECTORY)/docs/*.spec \ $(DIRECTORY)/include/GL/internal/glcore.h \ - $(DIRECTORY)/include/GL/amesa.h \ $(DIRECTORY)/include/GL/dmesa.h \ - $(DIRECTORY)/include/GL/fxmesa.h \ $(DIRECTORY)/include/GL/ggimesa.h \ $(DIRECTORY)/include/GL/gl.h \ $(DIRECTORY)/include/GL/glext.h \ @@ -225,19 +223,15 @@ MAIN_FILES = \ $(DIRECTORY)/include/GL/mglmesa.h \ $(DIRECTORY)/include/GL/osmesa.h \ $(DIRECTORY)/include/GL/svgamesa.h \ - $(DIRECTORY)/include/GL/ugl*.h \ $(DIRECTORY)/include/GL/vms_x_fix.h \ $(DIRECTORY)/include/GL/wmesa.h \ - $(DIRECTORY)/include/GL/xmesa.h \ - $(DIRECTORY)/include/GL/xmesa_x.h \ - $(DIRECTORY)/include/GL/xmesa_xf86.h \ - $(DIRECTORY)/include/GLView.h \ $(DIRECTORY)/src/Makefile \ $(DIRECTORY)/src/descrip.mms \ $(DIRECTORY)/src/mesa/Makefile* \ $(DIRECTORY)/src/mesa/sources \ $(DIRECTORY)/src/mesa/descrip.mms \ $(DIRECTORY)/src/mesa/gl.pc.in \ + $(DIRECTORY)/src/mesa/osmesa.pc.in \ $(DIRECTORY)/src/mesa/depend \ $(DIRECTORY)/src/mesa/main/*.[chS] \ $(DIRECTORY)/src/mesa/main/descrip.mms \ diff --git a/configure.ac b/configure.ac index 97cb298d39..33c107266a 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ AC_CONFIG_AUX_DIR([bin]) AC_CANONICAL_HOST dnl Versions for external dependencies -LIBDRM_REQUIRED=2.3.1 +LIBDRM_REQUIRED=2.4.3 DRI2PROTO_REQUIRED=1.99.3 dnl Check for progs @@ -83,11 +83,8 @@ dnl Compiler macros DEFINES="" AC_SUBST([DEFINES]) case "$host_os" in -*-gnu) -if test "x$GCC" = xyes; then - DEFINES="$DEFINES -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE" -fi - DEFINES="$DEFINES -D_SVID_SOURCE -D_GNU_SOURCE -DPTHREADS" +*-gnu*) + DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS" ;; solaris*) DEFINES="$DEFINES -DPTHREADS -DSVR4" diff --git a/docs/MESA_copy_sub_buffer.spec b/docs/MESA_copy_sub_buffer.spec index 43424a5f46..752a014b35 100644 --- a/docs/MESA_copy_sub_buffer.spec +++ b/docs/MESA_copy_sub_buffer.spec @@ -16,7 +16,7 @@ Status Version - Last Modified Date: 8 June 2000 + Last Modified Date: 12 January 2009 Number @@ -69,6 +69,12 @@ Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors) <width> and <height> indicate the size in pixels. Coordinate (0,0) corresponds to the lower-left pixel of the window, like glReadPixels. + If dpy and drawable are the display and drawable for the calling + thread's current context, glXCopySubBufferMESA performs an + implicit glFlush before it returns. Subsequent OpenGL commands + may be issued immediately after calling glXCopySubBufferMESA, but + are not executed until the copy is completed. + GLX Protocol None at this time. The extension is implemented in terms of ordinary @@ -84,5 +90,7 @@ New State Revision History - 8 June 2000 - initial specification + 12 January 2009 Ian Romanick - Added language about implicit flush + and command completion. + 8 June 2000 Brian Paul - initial specification diff --git a/docs/install.html b/docs/install.html index d740477c13..be61ef3043 100644 --- a/docs/install.html +++ b/docs/install.html @@ -39,9 +39,10 @@ The following are required for DRI-based hardware acceleration with Mesa 7.3: <ul> <li><a href="http://xorg.freedesktop.org/releases/individual/proto/">dri2proto</a> version 1.99.3 or later -<li><a href="http://dri.freedesktop.org/libdrm/" target="_parent">DRM</a> +<li>Linux 2.6.28 +<li><a href="http://dri.freedesktop.org/libdrm/" target="_parent">libDRM</a> version 2.4.3 or later -<li>Xorg server version 1.4 or 1.5. +<li>Xorg server version 1.5 or later </ul> </p> diff --git a/docs/relnotes-7.3.html b/docs/relnotes-7.3.html index 5cb7dc20fd..d46a509884 100644 --- a/docs/relnotes-7.3.html +++ b/docs/relnotes-7.3.html @@ -21,8 +21,8 @@ glGetString(GL_VERSION) depends on the particular driver being used. Some drivers don't support all the features required in OpenGL 2.1. </p> <p> -<p> -DRM version 2.4.3 or later should be used with Mesa 7.3 +See the <a href="install.html">Compiling/Installing page</a> for prerequisites +for DRI ardware acceleration. </p> @@ -43,10 +43,19 @@ tbd <ul> <li>Assorted GLSL bug fixes <li>Assorted i965 driver fixes +<li>Fix for wglCreateLayerContext() in WGL/Windows driver +<li>Build fixes for OpenBSD and gcc 2.95 +<li>GLSL preprocessor handles #pragma now +<li>Fix incorrect transformation of GL_SPOT_DIRECTION </ul> <h2>Changes</h2> <ul> +<li>Deprecated the "XMesa" interface (include/GL/xmesa*.h files) +<li>Deprecated the "FXMesa" interface (include/GL/fxmesa.h file) +<li>Deprecated the "Allegro" interface (include/GL/amesa.h file) +<li>Removed include/GL/uglmesa.h header +<li>Removed include/GLView.h header for BeOS </ul> diff --git a/include/GL/Makefile.am b/include/GL/Makefile.am index 199bd5c8f3..ca528f606d 100644 --- a/include/GL/Makefile.am +++ b/include/GL/Makefile.am @@ -2,17 +2,12 @@ GLincludedir = $(includedir)/GL -INC_FX = fxmesa.h INC_GGI = ggimesa.h INC_OSMESA = osmesa.h INC_SVGA = svgamesa.h -INC_X11 = glx.h glxext.h glx_mangle.h xmesa.h xmesa_x.h xmesa_xf86.h +INC_X11 = glx.h glxext.h glx_mangle.h INC_GLUT = glut.h glutf90.h -if HAVE_FX -sel_inc_fx = $(INC_FX) -endif - if HAVE_GGI sel_inc_ggi = $(INC_GGI) endif @@ -35,9 +30,9 @@ endif EXTRA_HEADERS = amesa.h dosmesa.h foomesa.h glut_h.dja mesa_wgl.h mglmesa.h \ vms_x_fix.h wmesa.h \ - $(INC_FX) $(INC_GGI) $(INC_OSMESA) $(INC_SVGA) $(INC_X11) $(INC_GLUT) + $(INC_GGI) $(INC_OSMESA) $(INC_SVGA) $(INC_X11) $(INC_GLUT) GLinclude_HEADERS = gl.h glext.h gl_mangle.h glu.h glu_mangle.h \ - $(sel_inc_fx) $(sel_inc_ggi) $(sel_inc_osmesa) $(sel_inc_svga) \ + $(sel_inc_ggi) $(sel_inc_osmesa) $(sel_inc_svga) \ $(sel_inc_x11) $(sel_inc_glut) include $(top_srcdir)/common_rules.make diff --git a/include/GL/uglglutshapes.h b/include/GL/uglglutshapes.h deleted file mode 100644 index 28192de2d5..0000000000 --- a/include/GL/uglglutshapes.h +++ /dev/null @@ -1,45 +0,0 @@ -/* uglglutshapes.h - Public header GLUT Shapes */ - -/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */ - -/* This program is freely distributable without licensing fees and is - provided without guarantee or warrantee expressed or implied. This - program is -not- in the public domain. */ - -#ifndef GLUTSHAPES_H -#define GLUTSHAPES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <GL/gl.h> - -void glutWireSphere (GLdouble radius, GLint slices, GLint stacks); -void glutSolidSphere (GLdouble radius, GLint slices, GLint stacks); -void glutWireCone (GLdouble base, GLdouble height, - GLint slices, GLint stacks); -void glutSolidCone (GLdouble base, GLdouble height, - GLint slices, GLint stacks); -void glutWireCube (GLdouble size); -void glutSolidCube (GLdouble size); -void glutWireTorus (GLdouble innerRadius, GLdouble outerRadius, - GLint sides, GLint rings); -void glutSolidTorus (GLdouble innerRadius, GLdouble outerRadius, - GLint sides, GLint rings); -void glutWireDodecahedron (void); -void glutSolidDodecahedron (void); -void glutWireOctahedron (void); -void glutSolidOctahedron (void); -void glutWireTetrahedron (void); -void glutSolidTetrahedron (void); -void glutWireIcosahedron (void); -void glutSolidIcosahedron (void); -void glutWireTeapot (GLdouble size); -void glutSolidTeapot (GLdouble size); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/include/GL/uglmesa.h b/include/GL/uglmesa.h deleted file mode 100644 index 7ef5843504..0000000000 --- a/include/GL/uglmesa.h +++ /dev/null @@ -1,155 +0,0 @@ -/* uglmesa.h - Public header UGL/Mesa */ - -/* Copyright (C) 2001 by Wind River Systems, Inc */ - -/* - * Mesa 3-D graphics library - * Version: 4.0 - * - * The MIT License - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -/* - * Author: - * Stephane Raimbault <stephane.raimbault@windriver.com> - */ - -#ifndef UGLMESA_H -#define UGLMESA_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define UGL_MESA_MAJOR_VERSION 4 -#define UGL_MESA_MINOR_VERSION 0 - -#include <GL/gl.h> -#include <ugl/ugl.h> - -/* - * Values for display mode of uglMesaCreateContext () - */ - -/* - * With these mask values, it's possible to test double buffer mode - * with UGL_MESA_DOUBLE mask - * - * SINGLE 0000 0001 - * DOUBLE 0000 0110 - * - SOFT 0000 0010 - * - HARD 0000 0100 - * WINDML 0001 0000 - * - * - */ -#define UGL_MESA_SINGLE 0x01 -#define UGL_MESA_DOUBLE 0x06 -#define UGL_MESA_DOUBLE_SOFTWARE 0x02 -#define UGL_MESA_DOUBLE_HARDWARE 0x04 - -#define UGL_MESA_WINDML_EXCLUSIVE 0x10 - -#define UGL_MESA_FULLSCREEN_WIDTH 0x0 -#define UGL_MESA_FULLSCREEN_HEIGHT 0x0 - -/* - * uglMesaPixelStore() parameters: - */ - -#define UGL_MESA_ROW_LENGTH 0x20 -#define UGL_MESA_Y_UP 0x21 - -/* - * Accepted by uglMesaGetIntegerv: - */ - -#define UGL_MESA_LEFT_X 0x01 -#define UGL_MESA_TOP_Y 0x02 -#define UGL_MESA_WIDTH 0x03 -#define UGL_MESA_HEIGHT 0x04 -#define UGL_MESA_DISPLAY_WIDTH 0x05 -#define UGL_MESA_DISPLAY_HEIGHT 0x06 -#define UGL_MESA_COLOR_FORMAT 0x07 -#define UGL_MESA_COLOR_MODEL 0x08 -#define UGL_MESA_PIXEL_FORMAT 0x09 -#define UGL_MESA_TYPE 0x0A -#define UGL_MESA_RGB 0x0B -#define UGL_MESA_COLOR_INDEXED 0x0C -#define UGL_MESA_SINGLE_BUFFER 0x0D -#define UGL_MESA_DOUBLE_BUFFER 0x0E -#define UGL_MESA_DOUBLE_BUFFER_SOFTWARE 0x0F -#define UGL_MESA_DOUBLE_BUFFER_HARDWARE 0x10 - -/* - * typedefs - */ - -typedef struct uglMesaContext * UGL_MESA_CONTEXT; - -UGL_MESA_CONTEXT uglMesaCreateNewContext (GLenum mode, - UGL_MESA_CONTEXT share_list); - -UGL_MESA_CONTEXT uglMesaCreateNewContextExt (GLenum mode, - GLint depth_bits, - GLint stencil_bits, - GLint accum_red_bits, - GLint accum_green_bits, - GLint accum_blue_bits, - GLint accum_alpha_bits, - UGL_MESA_CONTEXT share_list); - -GLboolean uglMesaMakeCurrentContext (UGL_MESA_CONTEXT umc, - GLsizei left, GLsizei top, - GLsizei width, GLsizei height); - -GLboolean uglMesaMoveWindow (GLsizei dx, GLsizei dy); - -GLboolean uglMesaMoveToWindow (GLsizei left, GLsizei top); - -GLboolean uglMesaResizeWindow (GLsizei dw, GLsizei dh); - -GLboolean uglMesaResizeToWindow (GLsizei width, GLsizei height); - -void uglMesaDestroyContext (void); - -UGL_MESA_CONTEXT uglMesaGetCurrentContext (void); - -void uglMesaSwapBuffers (void); - -void uglMesaPixelStore (GLint pname, GLint value); - -void uglMesaGetIntegerv (GLint pname, GLint *value); - -GLboolean uglMesaGetDepthBuffer (GLint *width, GLint *height, - GLint *bytesPerValue, void **buffer); - -GLboolean uglMesaGetColorBuffer (GLint *width, GLint *height, - GLint *format, void **buffer); - -GLboolean uglMesaSetColor (GLubyte index, GLfloat red, - GLfloat green, GLfloat blue); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/include/GLView.h b/include/GLView.h deleted file mode 100644 index 8d9d25bb1c..0000000000 --- a/include/GLView.h +++ /dev/null @@ -1,192 +0,0 @@ -/******************************************************************************* -/ -/ File: GLView.h -/ -/ Copyright 1993-98, Be Incorporated, All Rights Reserved. -/ -*******************************************************************************/ - -#ifndef BGLVIEW_H -#define BGLVIEW_H - -#include <GL/gl.h> - -#define BGL_RGB 0 -#define BGL_INDEX 1 -#define BGL_SINGLE 0 -#define BGL_DOUBLE 2 -#define BGL_DIRECT 0 -#define BGL_INDIRECT 4 -#define BGL_ACCUM 8 -#define BGL_ALPHA 16 -#define BGL_DEPTH 32 -#define BGL_OVERLAY 64 -#define BGL_UNDERLAY 128 -#define BGL_STENCIL 512 - -#ifdef __cplusplus - - -#include <AppKit.h> -#include <interface/Window.h> -#include <interface/View.h> -#include <interface/Bitmap.h> -#include <game/WindowScreen.h> -#include <game/DirectWindow.h> - -class BGLView : public BView { -public: - - BGLView(BRect rect, char *name, - ulong resizingMode, ulong mode, - ulong options); -virtual ~BGLView(); - - void LockGL(); - void UnlockGL(); - void SwapBuffers(); - void SwapBuffers( bool vSync ); - BView * EmbeddedView(); - status_t CopyPixelsOut(BPoint source, BBitmap *dest); - status_t CopyPixelsIn(BBitmap *source, BPoint dest); -virtual void ErrorCallback(unsigned long errorCode); // Mesa's GLenum is uint where Be's ones was ulong! - -virtual void Draw(BRect updateRect); - -virtual void AttachedToWindow(); -virtual void AllAttached(); -virtual void DetachedFromWindow(); -virtual void AllDetached(); - -virtual void FrameResized(float width, float height); -virtual status_t Perform(perform_code d, void *arg); - - /* The public methods below, for the moment, - are just pass-throughs to BView */ - -virtual status_t Archive(BMessage *data, bool deep = true) const; - -virtual void MessageReceived(BMessage *msg); -virtual void SetResizingMode(uint32 mode); - -virtual void Show(); -virtual void Hide(); - -virtual BHandler *ResolveSpecifier(BMessage *msg, int32 index, - BMessage *specifier, int32 form, - const char *property); -virtual status_t GetSupportedSuites(BMessage *data); - -/* New public functions */ - void DirectConnected( direct_buffer_info *info ); - void EnableDirectMode( bool enabled ); - - void * getGC() { return m_gc; } - -private: - -virtual void _ReservedGLView1(); -virtual void _ReservedGLView2(); -virtual void _ReservedGLView3(); -virtual void _ReservedGLView4(); -virtual void _ReservedGLView5(); -virtual void _ReservedGLView6(); -virtual void _ReservedGLView7(); -virtual void _ReservedGLView8(); - - BGLView(const BGLView &); - BGLView &operator=(const BGLView &); - - void dither_front(); - bool confirm_dither(); - void draw(BRect r); - - void * m_gc; - uint32 m_options; - uint32 m_ditherCount; - BLocker m_drawLock; - BLocker m_displayLock; - void * m_clip_info; - void * _Unused1; - - BBitmap * m_ditherMap; - BRect m_bounds; - int16 * m_errorBuffer[2]; - uint64 _reserved[8]; - - /* Direct Window stuff */ -private: - void drawScanline( int x1, int x2, int y, void *data ); -static void scanlineHandler(struct rasStateRec *state, GLint x1, GLint x2); - - void lock_draw(); - void unlock_draw(); - bool validateView(); -}; - - - -class BGLScreen : public BWindowScreen { -public: - BGLScreen(char *name, - ulong screenMode, ulong options, - status_t *error, bool debug=false); - ~BGLScreen(); - - void LockGL(); - void UnlockGL(); - void SwapBuffers(); - virtual void ErrorCallback(GLenum errorCode); - - virtual void ScreenConnected(bool connected); - virtual void FrameResized(float width, float height); - virtual status_t Perform(perform_code d, void *arg); - - /* The public methods below, for the moment, - are just pass-throughs to BWindowScreen */ - - virtual status_t Archive(BMessage *data, bool deep = true) const; - virtual void MessageReceived(BMessage *msg); - - virtual void Show(); - virtual void Hide(); - - virtual BHandler *ResolveSpecifier(BMessage *msg, - int32 index, - BMessage *specifier, - int32 form, - const char *property); - virtual status_t GetSupportedSuites(BMessage *data); - -private: - - virtual void _ReservedGLScreen1(); - virtual void _ReservedGLScreen2(); - virtual void _ReservedGLScreen3(); - virtual void _ReservedGLScreen4(); - virtual void _ReservedGLScreen5(); - virtual void _ReservedGLScreen6(); - virtual void _ReservedGLScreen7(); - virtual void _ReservedGLScreen8(); - - BGLScreen(const BGLScreen &); - BGLScreen &operator=(const BGLScreen &); - - void * m_gc; - long m_options; - BLocker m_drawLock; - - int32 m_colorSpace; - uint32 m_screen_mode; - - uint64 _reserved[7]; -}; - -#endif // __cplusplus - -#endif // BGLVIEW_H - - - - - diff --git a/src/glx/x11/drisw_glx.c b/src/glx/x11/drisw_glx.c index fee45952b3..35bbd9151c 100644 --- a/src/glx/x11/drisw_glx.c +++ b/src/glx/x11/drisw_glx.c @@ -113,7 +113,7 @@ swrastGetDrawableInfo(__DRIdrawable * draw, int *x, int *y, int *w, int *h, void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base);; + __GLXDRIdrawable *pdraw = &(pdp->base); Display *dpy = pdraw->psc->dpy; Drawable drawable; @@ -141,7 +141,7 @@ swrastPutImage(__DRIdrawable * draw, int op, int x, int y, int w, int h, char *data, void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base);; + __GLXDRIdrawable *pdraw = &(pdp->base); Display *dpy = pdraw->psc->dpy; Drawable drawable; XImage *ximage; @@ -176,7 +176,7 @@ swrastGetImage(__DRIdrawable * draw, int x, int y, int w, int h, char *data, void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base);; + __GLXDRIdrawable *pdraw = &(pdp->base); Display *dpy = pdraw->psc->dpy; Drawable drawable; XImage *ximage; diff --git a/src/glx/x11/glx_pbuffer.c b/src/glx/x11/glx_pbuffer.c index c63d53439d..a602cd2881 100644 --- a/src/glx/x11/glx_pbuffer.c +++ b/src/glx/x11/glx_pbuffer.c @@ -220,14 +220,14 @@ GetDrawableAttribute(Display * dpy, GLXDrawable drawable, unsigned int length; unsigned int i; unsigned int num_attributes; + GLboolean use_glx_1_3; if ((dpy == NULL) || (drawable == 0)) { return 0; } priv = __glXInitialize(dpy); - GLboolean use_glx_1_3 = ((priv->majorVersion > 1) - || (priv->minorVersion >= 3)); + use_glx_1_3 = ((priv->majorVersion > 1) || (priv->minorVersion >= 3)); *value = 0; diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c index f3eb045d9f..5af46cf0ba 100644 --- a/src/glx/x11/glxcurrent.c +++ b/src/glx/x11/glxcurrent.c @@ -365,7 +365,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext)) ? opcode : __glXSetupForCommand(oldGC->currentDpy); Bool bindReturnValue; - + __GLXattribute *state; if (!opcode || !oldOpcode) { return GL_FALSE; @@ -489,8 +489,7 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, } while (0); #endif - __GLXattribute *state = - (__GLXattribute *) (gc->client_state_private); + state = (__GLXattribute *) (gc->client_state_private); gc->currentContextTag = reply.contextTag; if (state->array_state == NULL) { diff --git a/src/mesa/drivers/allegro/amesa.c b/src/mesa/drivers/allegro/amesa.c index ade6251848..a9d8f62f92 100644 --- a/src/mesa/drivers/allegro/amesa.c +++ b/src/mesa/drivers/allegro/amesa.c @@ -26,7 +26,7 @@ #include "main/imports.h" #include "main/matrix.h" #include "main/mtypes.h" -#include "GL/amesa.h" +#include "amesa.h" struct amesa_visual diff --git a/include/GL/amesa.h b/src/mesa/drivers/allegro/amesa.h index 852d34cf4f..852d34cf4f 100644 --- a/include/GL/amesa.h +++ b/src/mesa/drivers/allegro/amesa.h diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index a415e378ff..d7a2bd95ee 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -143,6 +143,9 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis, ctx->Const.MaxCubeTextureLevels = 12; ctx->Const.MaxTextureRectSize = (1<<11); + /* if conformance mode is set, swrast can handle any size AA point */ + ctx->Const.MaxPointSizeAA = 255.0; + /* ctx->Const.MaxNativeVertexProgramTemps = 32; */ brw_init_attribs( brw ); diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index a18dee85e8..0c86911044 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -111,9 +111,15 @@ static void brwProgramStringNotify( GLcontext *ctx, struct gl_program *prog ) { if (target == GL_FRAGMENT_PROGRAM_ARB) { + struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; struct brw_context *brw = brw_context(ctx); struct brw_fragment_program *p = (struct brw_fragment_program *)prog; struct brw_fragment_program *fp = (struct brw_fragment_program *)brw->fragment_program; + if (fprog->FogOption) { + _mesa_append_fog_code(ctx, fprog); + fprog->FogOption = GL_NONE; + } + if (p == fp) brw->state.dirty.brw |= BRW_NEW_FRAGMENT_PROGRAM; p->id = brw->program_id++; diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index 9dce6cd8e6..1a11d54621 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -73,10 +73,12 @@ static void compile_sf_prog( struct brw_context *brw, c.attr_to_idx[i] = idx; c.idx_to_attr[idx] = i; if (i >= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) { - c.point_attrs[i].CoordReplace = - brw->attribs.Point->CoordReplace[i - VERT_RESULT_TEX0]; - } else - c.point_attrs[i].CoordReplace = GL_FALSE; + c.point_attrs[i].CoordReplace = + brw->attribs.Point->CoordReplace[i - VERT_RESULT_TEX0]; + } + else { + c.point_attrs[i].CoordReplace = GL_FALSE; + } idx++; } @@ -106,7 +108,6 @@ static void compile_sf_prog( struct brw_context *brw, assert(0); return; } - /* get the program */ diff --git a/src/mesa/drivers/dri/i965/brw_sf_state.c b/src/mesa/drivers/dri/i965/brw_sf_state.c index 506126fcfb..741a7c53c4 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_state.c +++ b/src/mesa/drivers/dri/i965/brw_sf_state.c @@ -229,7 +229,7 @@ sf_unit_create_from_key(struct brw_context *brw, struct brw_sf_unit_key *key, /* XXX clamp max depends on AA vs. non-AA */ sf.sf7.sprite_point = key->point_sprite; - sf.sf7.point_size = CLAMP(nearbyint(key->point_size), 1, 255) * (1<<3); + sf.sf7.point_size = CLAMP(rint(key->point_size), 1, 255) * (1<<3); sf.sf7.use_point_size_state = !key->point_attenuated; sf.sf7.aa_line_distance_mode = 0; diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index f4583877aa..1a00b69825 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -811,57 +811,6 @@ static void precalc_txp( struct brw_wm_compile *c, - - -/*********************************************************************** - * Add instructions to perform fog blending - */ - -static void fog_blend( struct brw_wm_compile *c, - struct prog_src_register fog_factor ) -{ - struct prog_dst_register outcolor = dst_reg(PROGRAM_OUTPUT, FRAG_RESULT_COLR); - struct prog_src_register fogcolor = search_or_add_param5( c, STATE_FOG_COLOR, 0,0,0,0 ); - - /* color.xyz = LRP fog_factor.xxxx, output_color, fog_color */ - - emit_op(c, - OPCODE_LRP, - dst_mask(outcolor, WRITEMASK_XYZ), - 0, 0, 0, - fog_factor, - src_reg_from_dst(outcolor), - fogcolor); -} - - - -/* This one is simple - just take the interpolated fog coordinate and - * use it as the fog blend factor. - */ -static void fog_interpolated( struct brw_wm_compile *c ) -{ - struct prog_src_register fogc = src_reg(PROGRAM_INPUT, FRAG_ATTRIB_FOGC); - - if (!(c->fp_interp_emitted & (1<<FRAG_ATTRIB_FOGC))) - emit_interp(c, FRAG_ATTRIB_FOGC); - - fog_blend( c, src_swizzle1(fogc, GET_SWZ(fogc.Swizzle,X))); -} - -static void emit_fog( struct brw_wm_compile *c ) -{ - if (!c->fp->program.FogOption) - return; - - if (1) - fog_interpolated( c ); - else { - /* TODO: per-pixel fog */ - assert(0); - } -} - static void emit_fb_write( struct brw_wm_compile *c ) { struct prog_src_register payload_r0_depth = src_reg(PROGRAM_PAYLOAD, PAYLOAD_DEPTH); @@ -1059,7 +1008,6 @@ void brw_wm_pass_fp( struct brw_wm_compile *c ) emit_ddy(c, inst); break; case OPCODE_END: - emit_fog(c); emit_fb_write(c); break; case OPCODE_PRINT: diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 942ebe1ed4..8fd776ac39 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -892,15 +892,19 @@ static void emit_lrp(struct brw_wm_compile *c, } } +/** + * For GLSL shaders, this KIL will be unconditional. + * It may be contained inside an IF/ENDIF structure of course. + */ static void emit_kil(struct brw_wm_compile *c) { - struct brw_compile *p = &c->func; - struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW); - brw_push_insn_state(p); - brw_set_mask_control(p, BRW_MASK_DISABLE); - brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK - brw_AND(p, depth, c->emit_mask_reg, depth); - brw_pop_insn_state(p); + struct brw_compile *p = &c->func; + struct brw_reg depth = retype(brw_vec1_grf(0, 0), BRW_REGISTER_TYPE_UW); + brw_push_insn_state(p); + brw_set_mask_control(p, BRW_MASK_DISABLE); + brw_NOT(p, c->emit_mask_reg, brw_mask_reg(1)); //IMASK + brw_AND(p, depth, c->emit_mask_reg, depth); + brw_pop_insn_state(p); } static void emit_mad(struct brw_wm_compile *c, diff --git a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c index f12ef47a7d..8c9cb78945 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_sampler_state.c @@ -244,7 +244,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw, entry->minfilter = texObj->MinFilter; entry->magfilter = texObj->MagFilter; entry->comparemode = texObj->CompareMode; - entry->comparefunc = texObj->CompareFunc; + entry->comparefunc = texObj->CompareFunc; dri_bo_unreference(brw->wm.sdc_bo[unit]); if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) { 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 63e14cc390..06e71e6d69 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -192,21 +192,27 @@ brw_create_texture_surface( struct brw_context *brw, if (key->bo) surf.ss0.surface_format = translate_tex_format(key->format, key->depthmode); else { - switch(key->depth) { - case 32: surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM; break; - default: - case 24: surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8X8_UNORM; break; - case 16: surf.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM; break; - } + switch (key->depth) { + case 32: + surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM; + break; + default: + case 24: + surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8X8_UNORM; + break; + case 16: + surf.ss0.surface_format = BRW_SURFACEFORMAT_B5G6R5_UNORM; + break; + } } /* This is ok for all textures with channel width 8bit or less: */ /* surf.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */ if (key->bo) - surf.ss1.base_addr = key->bo->offset; /* reloc */ + surf.ss1.base_addr = key->bo->offset; /* reloc */ else - surf.ss1.base_addr = key->offset; + surf.ss1.base_addr = key->offset; surf.ss2.mip_count = key->last_level - key->first_level; surf.ss2.width = key->width - 1; diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 44b276a123..7b7f7d8c14 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -95,7 +95,7 @@ int INTEL_DEBUG = (0); #include "extension_helper.h" -#define DRIVER_DATE "20080716" +#define DRIVER_DATE "20090114" #define DRIVER_DATE_GEM "GEM " DRIVER_DATE static const GLubyte * diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c index 1d7f15f10a..3a01f63dc7 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c @@ -204,6 +204,14 @@ do_blit_bitmap( GLcontext *ctx, /* Update draw buffer bounds */ _mesa_update_state(ctx); + if (ctx->Depth.Test) { + /* The blit path produces incorrect results when depth testing is on. + * It seems the blit Z coord is always 1.0 (the far plane) so fragments + * will likely be obscured by other, closer geometry. + */ + return GL_FALSE; + } + if (!dst) return GL_FALSE; @@ -357,6 +365,7 @@ intel_texture_bitmap(GLcontext * ctx, GLubyte *unpacked_bitmap; GLubyte *a8_bitmap; int x, y; + GLfloat dst_z; /* We need a fragment program for the KIL effect */ if (!ctx->Extensions.ARB_fragment_program || @@ -456,21 +465,24 @@ intel_texture_bitmap(GLcontext * ctx, intel_meta_set_passthrough_vertex_program(intel); intel_meta_set_passthrough_transform(intel); + /* convert rasterpos Z from [0,1] to NDC coord in [-1,1] */ + dst_z = -1.0 + 2.0 * ctx->Current.RasterPos[2]; + vertices[0][0] = dst_x; vertices[0][1] = dst_y; - vertices[0][2] = ctx->Current.RasterPos[2]; + vertices[0][2] = dst_z; vertices[0][3] = 1.0; vertices[1][0] = dst_x + width; vertices[1][1] = dst_y; - vertices[1][2] = ctx->Current.RasterPos[2]; + vertices[1][2] = dst_z; vertices[1][3] = 1.0; vertices[2][0] = dst_x + width; vertices[2][1] = dst_y + height; - vertices[2][2] = ctx->Current.RasterPos[2]; + vertices[2][2] = dst_z; vertices[2][3] = 1.0; vertices[3][0] = dst_x; vertices[3][1] = dst_y + height; - vertices[3][2] = ctx->Current.RasterPos[2]; + vertices[3][2] = dst_z; vertices[3][3] = 1.0; texcoords[0][0] = 0.0; diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c index 2af839b803..0e83afa645 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c @@ -71,6 +71,7 @@ intel_texture_drawpixels(GLcontext * ctx, GLuint texname; GLfloat vertices[4][4]; GLfloat texcoords[4][2]; + GLfloat z; /* We're going to mess with texturing with no regard to existing texture * state, so if there is some set up we have to bail. @@ -140,6 +141,9 @@ intel_texture_drawpixels(GLcontext * ctx, intel_meta_set_passthrough_transform(intel); + /* convert rasterpos Z from [0,1] to NDC coord in [-1,1] */ + z = -1.0 + 2.0 * ctx->Current.RasterPos[2]; + /* Create the vertex buffer based on the current raster pos. The x and y * we're handed are ctx->Current.RasterPos[0,1] rounded to integers. * We also apply the depth. However, the W component is already multiplied @@ -147,19 +151,19 @@ intel_texture_drawpixels(GLcontext * ctx, */ vertices[0][0] = x; vertices[0][1] = y; - vertices[0][2] = ctx->Current.RasterPos[2]; + vertices[0][2] = z; vertices[0][3] = 1.0; vertices[1][0] = x + width * ctx->Pixel.ZoomX; vertices[1][1] = y; - vertices[1][2] = ctx->Current.RasterPos[2]; + vertices[1][2] = z; vertices[1][3] = 1.0; vertices[2][0] = x + width * ctx->Pixel.ZoomX; vertices[2][1] = y + height * ctx->Pixel.ZoomY; - vertices[2][2] = ctx->Current.RasterPos[2]; + vertices[2][2] = z; vertices[2][3] = 1.0; vertices[3][0] = x; vertices[3][1] = y + height * ctx->Pixel.ZoomY; - vertices[3][2] = ctx->Current.RasterPos[2]; + vertices[3][2] = z; vertices[3][3] = 1.0; texcoords[0][0] = 0.0; diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c index 8f4e681ffe..d9315043e6 100644 --- a/src/mesa/drivers/dri/intel/intel_span.c +++ b/src/mesa/drivers/dri/intel/intel_span.c @@ -633,7 +633,7 @@ intelSpanRenderStart(GLcontext * ctx) intelFlush(&intel->ctx); LOCK_HARDWARE(intel); - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { if (ctx->Texture.Unit[i]._ReallyEnabled) { struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; intel_tex_map_images(intel, intel_texture_object(texObj)); @@ -655,7 +655,7 @@ intelSpanRenderFinish(GLcontext * ctx) _swrast_flush(ctx); - for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) { + for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) { if (ctx->Texture.Unit[i]._ReallyEnabled) { struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current; intel_tex_unmap_images(intel, intel_texture_object(texObj)); diff --git a/src/mesa/drivers/dri/mach64/mach64_context.h b/src/mesa/drivers/dri/mach64/mach64_context.h index 55e0618ff8..854751626d 100644 --- a/src/mesa/drivers/dri/mach64/mach64_context.h +++ b/src/mesa/drivers/dri/mach64/mach64_context.h @@ -294,7 +294,13 @@ extern GLboolean mach64UnbindContext( __DRIcontextPrivate *driContextPriv ); #define LE32_OUT( x, y ) do { *(GLuint *)(x) = (y); } while (0) #define LE32_OUT_FLOAT( x, y ) do { *(GLfloat *)(x) = (y); } while (0) #else +#ifndef __OpenBSD__ #include <byteswap.h> +#else +#include <machine/endian.h> +#define bswap_32 bswap32 +#endif + #define LE32_IN( x ) bswap_32( *(GLuint *)(x) ) #define LE32_IN_FLOAT( x ) \ ({ \ diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index 49f1b8b9ee..15b57244dc 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -66,6 +66,7 @@ #define need_GL_ARB_vertex_program #define need_GL_APPLE_vertex_array_object #define need_GL_ATI_fragment_shader +#define need_GL_ATI_separate_stencil #define need_GL_EXT_depth_bounds_test #define need_GL_EXT_framebuffer_object #define need_GL_EXT_framebuffer_blit @@ -96,6 +97,7 @@ const struct dri_extension card_extensions[] = { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }, { "GL_APPLE_vertex_array_object", GL_APPLE_vertex_array_object_functions }, { "GL_ATI_fragment_shader", GL_ATI_fragment_shader_functions }, + { "GL_ATI_separate_stencil", GL_ATI_separate_stencil_functions }, { "GL_EXT_depth_bounds_test", GL_EXT_depth_bounds_test_functions }, { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions }, { "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions }, diff --git a/src/mesa/drivers/windows/gdi/wgl.c b/src/mesa/drivers/windows/gdi/wgl.c index 9f0bb9122a..8d8087067f 100644 --- a/src/mesa/drivers/windows/gdi/wgl.c +++ b/src/mesa/drivers/windows/gdi/wgl.c @@ -601,8 +601,9 @@ WINGDIAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc, WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc, int iLayerPlane) { - (void) hdc; (void) iLayerPlane; SetLastError(0); + if (iLayerPlane == 0) + return wglCreateContext( hdc ); return(NULL); } diff --git a/src/mesa/drivers/x11/fakeglx.c b/src/mesa/drivers/x11/fakeglx.c index 827d39f995..ea3585258d 100644 --- a/src/mesa/drivers/x11/fakeglx.c +++ b/src/mesa/drivers/x11/fakeglx.c @@ -42,7 +42,6 @@ #include "glxheader.h" #include "glxapi.h" -#include "GL/xmesa.h" #include "main/context.h" #include "main/config.h" #include "main/macros.h" diff --git a/include/GL/fxmesa.h b/src/mesa/drivers/x11/fxmesa.h index f8e9661f9c..f8e9661f9c 100644 --- a/include/GL/fxmesa.h +++ b/src/mesa/drivers/x11/fxmesa.h diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index c9009bad03..18aa8bcc09 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -63,7 +63,6 @@ #endif #include "glxheader.h" -#include "GL/xmesa.h" #include "xmesaP.h" #include "main/context.h" #include "main/extensions.h" diff --git a/src/mesa/drivers/x11/xm_buffer.c b/src/mesa/drivers/x11/xm_buffer.c index f104d44d05..7ad67bc34d 100644 --- a/src/mesa/drivers/x11/xm_buffer.c +++ b/src/mesa/drivers/x11/xm_buffer.c @@ -30,7 +30,6 @@ #include "glxheader.h" -#include "GL/xmesa.h" #include "xmesaP.h" #include "main/imports.h" #include "main/framebuffer.h" diff --git a/include/GL/xmesa.h b/src/mesa/drivers/x11/xmesa.h index 98139af833..98139af833 100644 --- a/include/GL/xmesa.h +++ b/src/mesa/drivers/x11/xmesa.h diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 98867ac710..65e747d7b9 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -27,10 +27,10 @@ #define XMESAP_H -#include "GL/xmesa.h" +#include "xmesa.h" #include "main/mtypes.h" #if defined(FX) -#include "GL/fxmesa.h" +#include "fxmesa.h" #include "xm_glide.h" #endif #ifdef XFree86Server diff --git a/include/GL/xmesa_x.h b/src/mesa/drivers/x11/xmesa_x.h index 865bab4313..865bab4313 100644 --- a/include/GL/xmesa_x.h +++ b/src/mesa/drivers/x11/xmesa_x.h diff --git a/include/GL/xmesa_xf86.h b/src/mesa/drivers/x11/xmesa_xf86.h index 10f93c3ab6..10f93c3ab6 100644 --- a/include/GL/xmesa_xf86.h +++ b/src/mesa/drivers/x11/xmesa_xf86.h diff --git a/src/mesa/glapi/glthread.h b/src/mesa/glapi/glthread.h index ad2a63584b..ae2f79f37d 100644 --- a/src/mesa/glapi/glthread.h +++ b/src/mesa/glapi/glthread.h @@ -338,6 +338,10 @@ _glthread_GetTSD(_glthread_TSD *); extern void _glthread_SetTSD(_glthread_TSD *, void *); +#if !defined __GNUC__ || __GNUC__ < 3 +# define __builtin_expect(x, y) x +#endif + #if defined(GLX_USE_TLS) extern __thread struct _glapi_table * _glapi_tls_Dispatch diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h index d69c7bbb21..5657976711 100644 --- a/src/mesa/main/glheader.h +++ b/src/mesa/main/glheader.h @@ -157,7 +157,8 @@ #include <byteswap.h> #define CPU_TO_LE32( x ) bswap_32( x ) #else /*__linux__*/ -#define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */ +#include <sys/endian.h> +#define CPU_TO_LE32( x ) bswap32( x ) #endif /*__linux__*/ #define MESA_BIG_ENDIAN 1 #else diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index d4db960f1b..a15c1f0be0 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -208,7 +208,8 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params ) if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) { _math_matrix_analyse(ctx->ModelviewMatrixStack.Top); } - TRANSFORM_NORMAL(temp, params, ctx->ModelviewMatrixStack.Top->inv); + TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m); + NORMALIZE_3FV(temp); params = temp; break; case GL_SPOT_EXPONENT: diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 25dee52ad0..a61f970685 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2097,6 +2097,13 @@ struct gl_query_state }; +/** Set by #pragma directives */ +struct gl_sl_pragmas +{ + GLboolean Optimize; /**< defaults on */ + GLboolean Debug; /**< defaults off */ +}; + /** * A GLSL vertex or fragment shader object. @@ -2107,12 +2114,12 @@ struct gl_shader GLuint Name; /**< AKA the handle */ GLint RefCount; /**< Reference count */ GLboolean DeletePending; - - const GLchar *Source; /**< Source code string */ GLboolean CompileStatus; + GLboolean Main; /**< shader defines main() */ + const GLchar *Source; /**< Source code string */ struct gl_program *Program; /**< Post-compile assembly code */ GLchar *InfoLog; - GLboolean Main; /**< shader defines main() */ + struct gl_sl_pragmas Pragmas; }; diff --git a/src/mesa/math/m_matrix.h b/src/mesa/math/m_matrix.h index e8303f3ac5..a8d9000e89 100644 --- a/src/mesa/math/m_matrix.h +++ b/src/mesa/math/m_matrix.h @@ -189,6 +189,18 @@ do { \ } while (0) +/** + * Transform a direction by a matrix. + */ +#define TRANSFORM_DIRECTION( TO, DIR, MAT ) \ +do { \ + TO[0] = DIR[0] * MAT[0] + DIR[1] * MAT[4] + DIR[2] * MAT[8]; \ + TO[1] = DIR[0] * MAT[1] + DIR[1] * MAT[5] + DIR[2] * MAT[9]; \ + TO[2] = DIR[0] * MAT[2] + DIR[1] * MAT[6] + DIR[2] * MAT[10];\ +} while (0) + + + /*@}*/ diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index 536404bf97..5b80d99d49 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -979,6 +979,8 @@ parse_output_color_num (GLcontext * ctx, const GLubyte ** inst, /** + * Validate the index of a texture coordinate + * * \param coord The texture unit index * \return 0 on sucess, 1 on error */ @@ -988,8 +990,30 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst, { GLint i = parse_integer (inst, Program); - if ((i < 0) || (i >= (int)ctx->Const.MaxTextureUnits)) { - program_error(ctx, Program->Position, "Invalid texture unit index"); + if ((i < 0) || (i >= (int)ctx->Const.MaxTextureCoordUnits)) { + program_error(ctx, Program->Position, "Invalid texture coordinate index"); + return 1; + } + + *coord = (GLuint) i; + return 0; +} + + +/** + * Validate the index of a texture image unit + * + * \param coord The texture unit index + * \return 0 on sucess, 1 on error + */ +static GLuint +parse_teximage_num (GLcontext * ctx, const GLubyte ** inst, + struct arb_program *Program, GLuint * coord) +{ + GLint i = parse_integer (inst, Program); + + if ((i < 0) || (i >= (int)ctx->Const.MaxTextureImageUnits)) { + program_error(ctx, Program->Position, "Invalid texture image index"); return 1; } @@ -997,6 +1021,7 @@ parse_texcoord_num (GLcontext * ctx, const GLubyte ** inst, return 0; } + /** * \param coord The weight index * \return 0 on sucess, 1 on error @@ -3035,7 +3060,7 @@ parse_fp_instruction (GLcontext * ctx, const GLubyte ** inst, return 1; /* texImageUnit */ - if (parse_texcoord_num (ctx, inst, Program, &texcoord)) + if (parse_teximage_num (ctx, inst, Program, &texcoord)) return 1; fp->TexSrcUnit = texcoord; diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c index f5c0a498fb..4a6d0d670a 100644 --- a/src/mesa/shader/prog_instruction.c +++ b/src/mesa/shader/prog_instruction.c @@ -1,8 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.3 * - * Copyright (C) 1999-2005 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -157,7 +158,7 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = { { OPCODE_AND, "AND", 2, 1 }, { OPCODE_ARA, "ARA", 1, 1 }, { OPCODE_ARL, "ARL", 1, 1 }, - { OPCODE_ARL_NV, "ARL", 1, 1 }, + { OPCODE_ARL_NV, "ARL_NV", 1, 1 }, { OPCODE_ARR, "ARL", 1, 1 }, { OPCODE_BGNLOOP,"BGNLOOP", 0, 0 }, { OPCODE_BGNSUB, "BGNSUB", 0, 0 }, @@ -186,7 +187,7 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = { { OPCODE_FRC, "FRC", 1, 1 }, { OPCODE_IF, "IF", 1, 0 }, { OPCODE_KIL, "KIL", 1, 0 }, - { OPCODE_KIL_NV, "KIL", 0, 0 }, + { OPCODE_KIL_NV, "KIL_NV", 0, 0 }, { OPCODE_LG2, "LG2", 1, 1 }, { OPCODE_LIT, "LIT", 1, 1 }, { OPCODE_LOG, "LOG", 1, 1 }, @@ -235,7 +236,7 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = { { OPCODE_TXD, "TXD", 3, 1 }, { OPCODE_TXL, "TXL", 1, 1 }, { OPCODE_TXP, "TXP", 1, 1 }, - { OPCODE_TXP_NV, "TXP", 1, 1 }, + { OPCODE_TXP_NV, "TXP_NV", 1, 1 }, { OPCODE_TRUNC, "TRUNC", 1, 1 }, { OPCODE_UP2H, "UP2H", 1, 1 }, { OPCODE_UP2US, "UP2US", 1, 1 }, diff --git a/src/mesa/shader/slang/library/slang_pp_directives.syn b/src/mesa/shader/slang/library/slang_pp_directives.syn index d4a321034d..b51d168cc0 100644 --- a/src/mesa/shader/slang/library/slang_pp_directives.syn +++ b/src/mesa/shader/slang/library/slang_pp_directives.syn @@ -79,6 +79,12 @@ .emtcode BEHAVIOR_WARN 3 .emtcode BEHAVIOR_DISABLE 4 +/* + * The PRAGMA_* symbols follow TOKEN_PRAGMA + */ +.emtcode PRAGMA_NO_PARAM 0 +.emtcode PRAGMA_PARAM 1 + source optional_directive .and .loop source_element .and '\0' .emit ESCAPE_TOKEN .emit TOKEN_END; @@ -153,6 +159,7 @@ directive dir_elif .emit TOKEN_ELIF .or dir_endif .emit TOKEN_ENDIF .or dir_ext .emit TOKEN_EXTENSION .or + dir_pragma .emit TOKEN_PRAGMA .or dir_line .emit TOKEN_LINE; dir_define @@ -187,6 +194,19 @@ dir_ext dir_line optional_space .and '#' .and optional_space .and "line" .and expression; +dir_pragma + optional_space .and '#' .and optional_space .and "pragma" .and symbol .and opt_pragma_param; + + +opt_pragma_param + pragma_param .or .true .emit PRAGMA_NO_PARAM; + +pragma_param + optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')'; + +symbol_no_space + symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0'; + symbol space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\0'; diff --git a/src/mesa/shader/slang/library/slang_pp_directives_syn.h b/src/mesa/shader/slang/library/slang_pp_directives_syn.h index 35e7bc2761..430f8d8217 100644 --- a/src/mesa/shader/slang/library/slang_pp_directives_syn.h +++ b/src/mesa/shader/slang/library/slang_pp_directives_syn.h @@ -20,6 +20,8 @@ ".emtcode BEHAVIOR_ENABLE 2\n" ".emtcode BEHAVIOR_WARN 3\n" ".emtcode BEHAVIOR_DISABLE 4\n" +".emtcode PRAGMA_NO_PARAM 0\n" +".emtcode PRAGMA_PARAM 1\n" "source\n" " optional_directive .and .loop source_element .and '\\0' .emit ESCAPE_TOKEN .emit TOKEN_END;\n" "source_element\n" @@ -76,6 +78,7 @@ " dir_elif .emit TOKEN_ELIF .or\n" " dir_endif .emit TOKEN_ENDIF .or\n" " dir_ext .emit TOKEN_EXTENSION .or\n" +" dir_pragma .emit TOKEN_PRAGMA .or\n" " dir_line .emit TOKEN_LINE;\n" "dir_define\n" " optional_space .and '#' .and optional_space .and \"define\" .and symbol .and opt_parameters .and\n" @@ -99,6 +102,14 @@ " optional_space .and ':' .and optional_space .and extension_behavior;\n" "dir_line\n" " optional_space .and '#' .and optional_space .and \"line\" .and expression;\n" +"dir_pragma\n" +" optional_space .and '#' .and optional_space .and \"pragma\" .and symbol .and opt_pragma_param;\n" +"opt_pragma_param\n" +" pragma_param .or .true .emit PRAGMA_NO_PARAM;\n" +"pragma_param\n" +" optional_space .and '(' .emit PRAGMA_PARAM .and optional_space .and symbol_no_space .and optional_space .and ')';\n" +"symbol_no_space\n" +" symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n" "symbol\n" " space .and symbol_character .emit * .and .loop symbol_character2 .emit * .and .true .emit '\\0';\n" "opt_parameters\n" diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn index 0ad4a1cba6..cc5c70a02f 100644 --- a/src/mesa/shader/slang/library/slang_shader.syn +++ b/src/mesa/shader/slang/library/slang_shader.syn @@ -1162,13 +1162,6 @@ compound_statement_3 lbrace .and statement_list .and rbrace; /* - * <statement_no_new_scope> ::= <compound_statement_no_new_scope> - * | <simple_statement> - */ -statement_no_new_scope - compound_statement_no_new_scope .or simple_statement; - -/* * <compound_statement_no_new_scope> ::= "{" "}" * | "{" <statement_list> "}" */ @@ -1181,6 +1174,7 @@ compound_statement_no_new_scope_2 compound_statement_no_new_scope_3 lbrace .and statement_list .and rbrace; + /* * <statement_list> ::= <statement> * | <statement_list> <statement> @@ -1242,8 +1236,7 @@ condition_3 /* * <iteration_statement> ::= "while" "(" <condition> ")" <statement> * | "do" <statement> "while" "(" <expression> ")" ";" - * | "for" "(" <for_init_statement> <for_rest_statement> ")" - * <statement_no_new_scope> + * | "for" "(" <for_init_statement> <for_rest_statement> ")" <statement> */ iteration_statement iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3; @@ -1255,7 +1248,7 @@ iteration_statement_2 expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon; iteration_statement_3 "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and - for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope; + for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement; /* * <for_init_statement> ::= <expression_statement> diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h index e1705dfe19..6a382970e1 100644 --- a/src/mesa/shader/slang/library/slang_shader_syn.h +++ b/src/mesa/shader/slang/library/slang_shader_syn.h @@ -566,8 +566,6 @@ " lbrace .and rbrace;\n" "compound_statement_3\n" " lbrace .and statement_list .and rbrace;\n" -"statement_no_new_scope\n" -" compound_statement_no_new_scope .or simple_statement;\n" "compound_statement_no_new_scope\n" " compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;\n" "compound_statement_no_new_scope_1\n" @@ -617,7 +615,7 @@ " expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;\n" "iteration_statement_3\n" " \"for\" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and\n" -" for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;\n" +" for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement;\n" "for_init_statement\n" " expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;\n" "conditionopt\n" diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 5cb472bed0..51eb4c9c11 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -228,7 +228,14 @@ _slang_sizeof_type_specifier(const slang_type_specifier *spec) break; case SLANG_SPEC_STRUCT: sz = _slang_field_offset(spec, 0); /* special use */ - if (sz > 4) { + if (sz == 1) { + /* 1-float structs are actually troublesome to deal with since they + * might get placed at R.x, R.y, R.z or R.z. Return size=2 to + * ensure the object is placed at R.x + */ + sz = 2; + } + else if (sz > 4) { sz = (sz + 3) & ~0x3; /* round up to multiple of four */ } break; @@ -4286,7 +4293,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, #endif { GLint sampNum = _mesa_add_sampler(prog->Parameters, varName, datatype); - store = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, texIndex); + store = _slang_new_ir_storage_sampler(sampNum, texIndex, totalSize); /* If we have a sampler array, then we need to allocate the * additional samplers to ensure we don't allocate them elsewhere. @@ -4486,7 +4493,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, n = _slang_gen_var_decl(A, var, var->initializer); /* emit GPU instructions */ - success = _slang_emit_code(n, A->vartable, A->program, GL_FALSE, A->log); + success = _slang_emit_code(n, A->vartable, A->program, A->pragmas, GL_FALSE, A->log); _slang_free_ir_tree(n); } @@ -4596,7 +4603,7 @@ _slang_codegen_function(slang_assemble_ctx * A, slang_function * fun) #endif /* Emit program instructions */ - success = _slang_emit_code(n, A->vartable, A->program, GL_TRUE, A->log); + success = _slang_emit_code(n, A->vartable, A->program, A->pragmas, GL_TRUE, A->log); _slang_free_ir_tree(n); /* free codegen context */ diff --git a/src/mesa/shader/slang/slang_codegen.h b/src/mesa/shader/slang/slang_codegen.h index 9489033d7b..f2daa034e4 100644 --- a/src/mesa/shader/slang/slang_codegen.h +++ b/src/mesa/shader/slang/slang_codegen.h @@ -36,6 +36,7 @@ typedef struct slang_assemble_ctx_ slang_atom_pool *atoms; slang_name_space space; struct gl_program *program; + struct gl_sl_pragmas *pragmas; slang_var_table *vartable; slang_info_log *log; struct slang_label_ *curFuncEndLabel; diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 0a527f3220..6667138cdd 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -144,6 +144,7 @@ typedef struct slang_output_ctx_ slang_function_scope *funs; slang_struct_scope *structs; struct gl_program *program; + struct gl_sl_pragmas *pragmas; slang_var_table *vartable; GLuint default_precision[TYPE_SPECIFIER_COUNT]; GLboolean allow_precision; @@ -1005,7 +1006,7 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O, /* parse child statements, do not create new variable scope */ oper->type = SLANG_OPER_BLOCK_NO_NEW_SCOPE; while (*C->I != OP_END) - if (!parse_child_operation(C, O, oper, 1)) + if (!parse_child_operation(C, O, oper, GL_TRUE)) RETURN0; C->I++; break; @@ -1017,7 +1018,7 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O, oper->type = SLANG_OPER_BLOCK_NEW_SCOPE; o.vars = oper->locals; while (*C->I != OP_END) - if (!parse_child_operation(C, &o, oper, 1)) + if (!parse_child_operation(C, &o, oper, GL_TRUE)) RETURN0; C->I++; } @@ -1074,7 +1075,7 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O, if (oper->a_id == SLANG_ATOM_NULL) RETURN0; while (*C->I != OP_END) { - if (!parse_child_operation(C, O, oper, 0)) + if (!parse_child_operation(C, O, oper, GL_FALSE)) RETURN0; } C->I++; @@ -1090,21 +1091,21 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O, break; case OP_RETURN: oper->type = SLANG_OPER_RETURN; - if (!parse_child_operation(C, O, oper, 0)) + if (!parse_child_operation(C, O, oper, GL_FALSE)) RETURN0; break; case OP_EXPRESSION: oper->type = SLANG_OPER_EXPRESSION; - if (!parse_child_operation(C, O, oper, 0)) + if (!parse_child_operation(C, O, oper, GL_FALSE)) RETURN0; break; case OP_IF: oper->type = SLANG_OPER_IF; - if (!parse_child_operation(C, O, oper, 0)) + if (!parse_child_operation(C, O, oper, GL_FALSE)) RETURN0; - if (!parse_child_operation(C, O, oper, 1)) + if (!parse_child_operation(C, O, oper, GL_TRUE)) RETURN0; - if (!parse_child_operation(C, O, oper, 1)) + if (!parse_child_operation(C, O, oper, GL_TRUE)) RETURN0; break; case OP_WHILE: @@ -1113,17 +1114,17 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O, oper->type = SLANG_OPER_WHILE; o.vars = oper->locals; - if (!parse_child_operation(C, &o, oper, 1)) + if (!parse_child_operation(C, &o, oper, GL_TRUE)) RETURN0; - if (!parse_child_operation(C, &o, oper, 1)) + if (!parse_child_operation(C, &o, oper, GL_TRUE)) RETURN0; } break; case OP_DO: oper->type = SLANG_OPER_DO; - if (!parse_child_operation(C, O, oper, 1)) + if (!parse_child_operation(C, O, oper, GL_TRUE)) RETURN0; - if (!parse_child_operation(C, O, oper, 0)) + if (!parse_child_operation(C, O, oper, GL_FALSE)) RETURN0; break; case OP_FOR: @@ -1132,13 +1133,13 @@ parse_statement(slang_parse_ctx * C, slang_output_ctx * O, oper->type = SLANG_OPER_FOR; o.vars = oper->locals; - if (!parse_child_operation(C, &o, oper, 1)) + if (!parse_child_operation(C, &o, oper, GL_TRUE)) RETURN0; - if (!parse_child_operation(C, &o, oper, 1)) + if (!parse_child_operation(C, &o, oper, GL_TRUE)) RETURN0; - if (!parse_child_operation(C, &o, oper, 0)) + if (!parse_child_operation(C, &o, oper, GL_FALSE)) RETURN0; - if (!parse_child_operation(C, &o, oper, 1)) + if (!parse_child_operation(C, &o, oper, GL_TRUE)) RETURN0; } break; @@ -1429,7 +1430,7 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O, C->I++; while (*C->I != OP_END) - if (!parse_child_operation(C, O, op, 0)) + if (!parse_child_operation(C, O, op, GL_FALSE)) RETURN0; C->I++; #if 0 @@ -1494,7 +1495,7 @@ parse_expression(slang_parse_ctx * C, slang_output_ctx * O, RETURN0; } while (*C->I != OP_END) - if (!parse_child_operation(C, O, op, 0)) + if (!parse_child_operation(C, O, op, GL_FALSE)) RETURN0; C->I++; @@ -2059,6 +2060,7 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O, A.space.structs = O->structs; A.space.vars = O->vars; A.program = O->program; + A.pragmas = O->pragmas; A.vartable = O->vartable; A.log = C->L; A.curFuncEndLabel = NULL; @@ -2349,6 +2351,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit, o.structs = &unit->structs; o.vars = &unit->vars; o.program = shader ? shader->Program : NULL; + o.pragmas = shader ? &shader->Pragmas : NULL; o.vartable = _slang_new_var_table(maxRegs); _slang_push_var_table(o.vartable); @@ -2417,6 +2420,7 @@ parse_code_unit(slang_parse_ctx * C, slang_code_unit * unit, A.space.structs = o.structs; A.space.vars = o.vars; A.program = o.program; + A.pragmas = &shader->Pragmas; A.vartable = o.vartable; A.log = C->L; @@ -2475,7 +2479,8 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, slang_unit_type type, slang_info_log * infolog, slang_code_unit * builtin, struct gl_shader *shader, - const struct gl_extensions *extensions) + const struct gl_extensions *extensions, + struct gl_sl_pragmas *pragmas) { byte *prod; GLuint size, start, version; @@ -2504,7 +2509,7 @@ compile_with_grammar(grammar id, const char *source, slang_code_unit * unit, /* Now preprocess the source string. */ slang_string_init(&preprocessed); if (!_slang_preprocess_directives(&preprocessed, &source[start], - infolog, extensions)) { + infolog, extensions, pragmas)) { slang_string_free(&preprocessed); slang_info_log_error(infolog, "failed to preprocess the source."); return GL_FALSE; @@ -2578,7 +2583,8 @@ static GLboolean compile_object(grammar * id, const char *source, slang_code_object * object, slang_unit_type type, slang_info_log * infolog, struct gl_shader *shader, - const struct gl_extensions *extensions) + const struct gl_extensions *extensions, + struct gl_sl_pragmas *pragmas) { slang_code_unit *builtins = NULL; GLuint base_version = 110; @@ -2677,7 +2683,7 @@ compile_object(grammar * id, const char *source, slang_code_object * object, /* compile the actual shader - pass-in built-in library for external shader */ return compile_with_grammar(*id, source, &object->unit, type, infolog, - builtins, shader, extensions); + builtins, shader, extensions, pragmas); } @@ -2701,7 +2707,7 @@ compile_shader(GLcontext *ctx, slang_code_object * object, _slang_code_object_ctr(object); success = compile_object(&id, shader->Source, object, type, infolog, shader, - &ctx->Extensions); + &ctx->Extensions, &shader->Pragmas); if (id != 0) grammar_destroy(id); if (!success) diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 08b7d519a5..6b744d72c8 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -1300,14 +1300,10 @@ emit_tex(slang_emit_info *emitInfo, slang_ir_node *n) NULL, NULL); - /* Store->Index is the sampler index */ + /* Store->Index is the uniform/sampler index */ assert(n->Children[0]->Store->Index >= 0); - /* Store->Size is the texture target */ - assert(n->Children[0]->Store->Size >= TEXTURE_1D_INDEX); - assert(n->Children[0]->Store->Size <= TEXTURE_RECT_INDEX); - - inst->TexSrcTarget = n->Children[0]->Store->Size; - inst->TexSrcUnit = n->Children[0]->Store->Index; /* i.e. uniform's index */ + inst->TexSrcUnit = n->Children[0]->Store->Index; + inst->TexSrcTarget = n->Children[0]->Store->TexTarget; /* mark the sampler as being used */ _mesa_use_uniform(emitInfo->prog->Parameters, @@ -2381,10 +2377,20 @@ _slang_resolve_subroutines(slang_emit_info *emitInfo) - +/** + * Convert the IR tree into GPU instructions. + * \param n root of IR tree + * \param vt variable table + * \param prog program to put GPU instructions into + * \param pragmas controls codegen options + * \param withEnd if true, emit END opcode at end + * \param log log for emitting errors/warnings/info + */ GLboolean _slang_emit_code(slang_ir_node *n, slang_var_table *vt, - struct gl_program *prog, GLboolean withEnd, + struct gl_program *prog, + const struct gl_sl_pragmas *pragmas, + GLboolean withEnd, slang_info_log *log) { GET_CURRENT_CONTEXT(ctx); @@ -2401,7 +2407,7 @@ _slang_emit_code(slang_ir_node *n, slang_var_table *vt, emitInfo.EmitHighLevelInstructions = ctx->Shader.EmitHighLevelInstructions; emitInfo.EmitCondCodes = ctx->Shader.EmitCondCodes; - emitInfo.EmitComments = ctx->Shader.EmitComments; + emitInfo.EmitComments = ctx->Shader.EmitComments || pragmas->Debug; emitInfo.EmitBeginEndSub = GL_TRUE; if (!emitInfo.EmitCondCodes) { diff --git a/src/mesa/shader/slang/slang_emit.h b/src/mesa/shader/slang/slang_emit.h index 59fb2fa890..8ff52bf605 100644 --- a/src/mesa/shader/slang/slang_emit.h +++ b/src/mesa/shader/slang/slang_emit.h @@ -46,7 +46,9 @@ _slang_var_swizzle(GLint size, GLint comp); extern GLboolean _slang_emit_code(slang_ir_node *n, slang_var_table *vartable, - struct gl_program *prog, GLboolean withEnd, + struct gl_program *prog, + const struct gl_sl_pragmas *pragmas, + GLboolean withEnd, slang_info_log *log); diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c index c33c80da99..e4c6e0ea51 100644 --- a/src/mesa/shader/slang/slang_ir.c +++ b/src/mesa/shader/slang/slang_ir.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 7.1 * * Copyright (C) 2005-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -216,6 +216,26 @@ _slang_new_ir_storage_indirect(enum register_file file, } +/** + * Allocate IR storage for a texture sampler. + * \param sampNum the sampler number/index + * \param texTarget one of TEXTURE_x_INDEX values + * \param size number of samplers (in case of sampler array) + */ +slang_ir_storage * +_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size) +{ + slang_ir_storage *st; + assert(texTarget < NUM_TEXTURE_TARGETS); + st = _slang_new_ir_storage(PROGRAM_SAMPLER, sampNum, size); + if (st) { + st->TexTarget = texTarget; + } + return st; +} + + + /* XXX temporary function */ void _slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src) diff --git a/src/mesa/shader/slang/slang_ir.h b/src/mesa/shader/slang/slang_ir.h index a258e92e06..644269d491 100644 --- a/src/mesa/shader/slang/slang_ir.h +++ b/src/mesa/shader/slang/slang_ir.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 * - * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2005-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -168,8 +168,8 @@ typedef enum struct slang_ir_storage_ { enum register_file File; /**< PROGRAM_TEMPORARY, PROGRAM_INPUT, etc */ - GLint Index; /**< -1 means unallocated */ - GLint Size; /**< number of floats */ + GLint Index; /**< -1 means unallocated */ + GLint Size; /**< number of floats or ints */ GLuint Swizzle; /**< Swizzle AND writemask info */ GLint RefCount; /**< Used during IR tree delete */ @@ -179,6 +179,7 @@ struct slang_ir_storage_ enum register_file IndirectFile; GLint IndirectIndex; GLuint IndirectSwizzle; + GLuint TexTarget; /**< If File==PROGRAM_SAMPLER, one of TEXTURE_x_INDEX */ /** If Parent is non-null, Index is relative to parent. * The other fields are ignored. @@ -254,6 +255,10 @@ _slang_new_ir_storage_indirect(enum register_file file, GLint indirectIndex, GLuint indirectSwizzle); +extern slang_ir_storage * +_slang_new_ir_storage_sampler(GLint sampNum, GLuint texTarget, GLint size); + + extern void _slang_copy_ir_storage(slang_ir_storage *dst, const slang_ir_storage *src); diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index 76e757cb38..d6b5253511 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -51,6 +51,9 @@ grammar_error_to_log (slang_info_log *log) GLint pos; grammar_get_last_error ((byte *) (buf), sizeof (buf), &pos); + if (buf[0] == 0) { + _mesa_snprintf(buf, sizeof(buf), "Preprocessor error"); + } slang_info_log_error (log, buf); } @@ -528,6 +531,56 @@ pp_ext_set(pp_ext *self, const char *name, GLboolean enable) } +static void +pp_pragmas_init(struct gl_sl_pragmas *pragmas) +{ + pragmas->Optimize = GL_TRUE; + pragmas->Debug = GL_FALSE; +} + + +/** + * Called in response to #pragma. For example, "#pragma debug(on)" would + * call this function as pp_pragma("debug", "on"). + * \return GL_TRUE if pragma is valid, GL_FALSE if invalid + */ +static GLboolean +pp_pragma(struct gl_sl_pragmas *pragmas, const char *pragma, const char *param) +{ +#if 0 + printf("#pragma %s %s\n", pragma, param); +#endif + if (_mesa_strcmp(pragma, "optimize") == 0) { + if (!param) + return GL_FALSE; /* missing required param */ + if (_mesa_strcmp(param, "on") == 0) { + pragmas->Optimize = GL_TRUE; + } + else if (_mesa_strcmp(param, "off") == 0) { + pragmas->Optimize = GL_FALSE; + } + else { + return GL_FALSE; /* invalid param */ + } + } + else if (_mesa_strcmp(pragma, "debug") == 0) { + if (!param) + return GL_FALSE; /* missing required param */ + if (_mesa_strcmp(param, "on") == 0) { + pragmas->Debug = GL_TRUE; + } + else if (_mesa_strcmp(param, "off") == 0) { + pragmas->Debug = GL_FALSE; + } + else { + return GL_FALSE; /* invalid param */ + } + } + /* all other pragmas are silently ignored */ + return GL_TRUE; +} + + /** * The state of preprocessor: current line, file and version number, list * of all defined macros and the #if/#endif context. @@ -862,11 +915,20 @@ parse_if (slang_string *output, const byte *prod, GLuint *pi, GLint *result, pp_ #define BEHAVIOR_WARN 3 #define BEHAVIOR_DISABLE 4 +#define PRAGMA_NO_PARAM 0 +#define PRAGMA_PARAM 1 + + static GLboolean preprocess_source (slang_string *output, const char *source, grammar pid, grammar eid, slang_info_log *elog, +<<<<<<< HEAD:src/mesa/shader/slang/slang_preprocess.c const struct gl_extensions *extensions) +======= + const struct gl_extensions *extensions, + struct gl_sl_pragmas *pragmas) +>>>>>>> origin/master:src/mesa/shader/slang/slang_preprocess.c { static const char *predefined[] = { "__FILE__", @@ -888,6 +950,10 @@ preprocess_source (slang_string *output, const char *source, } pp_state_init (&state, elog, extensions); +<<<<<<< HEAD:src/mesa/shader/slang/slang_preprocess.c +======= + pp_pragmas_init (pragmas); +>>>>>>> origin/master:src/mesa/shader/slang/slang_preprocess.c /* add the predefined symbols to the symbol table */ for (i = 0; predefined[i]; i++) { @@ -940,9 +1006,11 @@ preprocess_source (slang_string *output, const char *source, else { const char *id; GLuint idlen; + GLubyte token; i++; - switch (prod[i++]) { + token = prod[i++]; + switch (token) { case TOKEN_END: /* End of source string. @@ -1159,6 +1227,25 @@ preprocess_source (slang_string *output, const char *source, } break; + case TOKEN_PRAGMA: + { + GLint have_param; + const char *pragma, *param; + + pragma = (const char *) (&prod[i]); + i += _mesa_strlen(pragma) + 1; + have_param = (prod[i++] == PRAGMA_PARAM); + if (have_param) { + param = (const char *) (&prod[i]); + i += _mesa_strlen(param) + 1; + } + else { + param = NULL; + } + pp_pragma(pragmas, pragma, param); + } + break; + case TOKEN_LINE: id = (const char *) (&prod[i]); i += _mesa_strlen (id) + 1; @@ -1223,7 +1310,12 @@ GLboolean _slang_preprocess_directives(slang_string *output, const char *input, slang_info_log *elog, +<<<<<<< HEAD:src/mesa/shader/slang/slang_preprocess.c const struct gl_extensions *extensions) +======= + const struct gl_extensions *extensions, + struct gl_sl_pragmas *pragmas) +>>>>>>> origin/master:src/mesa/shader/slang/slang_preprocess.c { grammar pid, eid; GLboolean success; @@ -1239,7 +1331,11 @@ _slang_preprocess_directives(slang_string *output, grammar_destroy (pid); return GL_FALSE; } +<<<<<<< HEAD:src/mesa/shader/slang/slang_preprocess.c success = preprocess_source (output, input, pid, eid, elog, extensions); +======= + success = preprocess_source (output, input, pid, eid, elog, extensions, pragmas); +>>>>>>> origin/master:src/mesa/shader/slang/slang_preprocess.c grammar_destroy (eid); grammar_destroy (pid); return success; diff --git a/src/mesa/shader/slang/slang_preprocess.h b/src/mesa/shader/slang/slang_preprocess.h index dd996a6314..f344820dae 100644 --- a/src/mesa/shader/slang/slang_preprocess.h +++ b/src/mesa/shader/slang/slang_preprocess.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 * - * Copyright (C) 2005-2007 Brian Paul All Rights Reserved. + * Copyright (C) 2005-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -35,6 +35,7 @@ _slang_preprocess_version (const char *, GLuint *, GLuint *, slang_info_log *); extern GLboolean _slang_preprocess_directives(slang_string *output, const char *input, slang_info_log *, - const struct gl_extensions *extensions); + const struct gl_extensions *extensions, + struct gl_sl_pragmas *pragmas); #endif /* SLANG_PREPROCESS_H */ diff --git a/windows/VC8/mesa/mesa/mesa.vcproj b/windows/VC8/mesa/mesa/mesa.vcproj index 91e1849669..13029af143 100644 --- a/windows/VC8/mesa/mesa/mesa.vcproj +++ b/windows/VC8/mesa/mesa/mesa.vcproj @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="8,00"
Name="mesa"
ProjectGUID="{2120C974-2717-4709-B44F-D6E6D0A56448}"
+ RootNamespace="mesa"
>
<Platforms>
<Platform
@@ -180,6 +181,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\api_exec.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\api_loopback.c"
>
</File>
@@ -224,6 +229,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\clear.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\clip.c"
>
</File>
@@ -260,6 +269,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\dlopen.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\drawpix.c"
>
</File>
@@ -292,6 +305,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\ffvertex_prog.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\fog.c"
>
</File>
@@ -328,6 +345,10 @@ </FileConfiguration>
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\glapi\glapi_getproc.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\glapi\glthread.c"
>
</File>
@@ -466,6 +487,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\multisample.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.c"
>
</File>
@@ -482,6 +507,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\pixelstore.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\points.c"
>
</File>
@@ -490,6 +519,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\shader\prog_cache.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\shader\prog_debug.c"
>
</File>
@@ -558,6 +591,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\readpix.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\renderbuffer.c"
>
</File>
@@ -678,6 +715,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\scissor.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\shader\shader_api.c"
>
</File>
@@ -858,6 +899,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_rasterpos.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\tnl\t_vb_cull.c"
>
</File>
@@ -922,6 +967,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\texenv.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c"
>
</File>
@@ -930,6 +979,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\texgen.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\teximage.c"
>
</File>
@@ -938,6 +991,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\texparam.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\texrender.c"
>
</File>
@@ -1051,6 +1108,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\api_exec.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\api_loopback.h"
>
</File>
@@ -1075,6 +1136,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\arrayobj.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\shader\atifragshader.h"
>
</File>
@@ -1083,6 +1148,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\bitset.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\blend.h"
>
</File>
@@ -1095,6 +1164,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\clear.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\clip.h"
>
</File>
@@ -1139,6 +1212,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\dlopen.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\drawpix.h"
>
</File>
@@ -1167,6 +1244,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\ffvertex_prog.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\fog.h"
>
</File>
@@ -1315,6 +1396,18 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\mcompiler.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\mfeatures.h"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\mipmap.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\mm.h"
>
</File>
@@ -1323,6 +1416,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\multisample.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.h"
>
</File>
@@ -1339,6 +1436,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\pixelstore.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\points.h"
>
</File>
@@ -1399,6 +1500,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\readpix.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\renderbuffer.h"
>
</File>
@@ -1519,6 +1624,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\scissor.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\shader\shader_api.h"
>
</File>
@@ -1675,6 +1784,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\texenv.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h"
>
</File>
@@ -1687,6 +1800,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\texgen.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\teximage.h"
>
</File>
@@ -1695,6 +1812,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\mesa\main\texparam.h"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\mesa\main\texrender.h"
>
</File>
diff --git a/windows/VC8/progs/glut/glut.vcproj b/windows/VC8/progs/glut/glut.vcproj index 72b3266b1e..8d03c37841 100644 --- a/windows/VC8/progs/glut/glut.vcproj +++ b/windows/VC8/progs/glut/glut.vcproj @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="8,00"
Name="glut"
ProjectGUID="{0234F0D2-C8A6-4C4D-93E7-0E2248049C67}"
+ RootNamespace="glut"
>
<Platforms>
<Platform
@@ -79,6 +80,7 @@ SuppressStartupBanner="true"
AdditionalLibraryDirectories="../../mesa/Debug"
IgnoreAllDefaultLibraries="true"
+ ModuleDefinitionFile="..\..\..\..\src\glut\glx\glut.def"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/GLUT32.pdb"
ImportLibrary=".\Debug/GLUT32.lib"
@@ -175,6 +177,7 @@ SuppressStartupBanner="true"
AdditionalLibraryDirectories="../../mesa/Release"
IgnoreAllDefaultLibraries="true"
+ ModuleDefinitionFile="..\..\..\..\src\glut\glx\glut.def"
ProgramDatabaseFile=".\Release/GLUT32.pdb"
ImportLibrary=".\Release/GLUT32.lib"
/>
@@ -325,6 +328,10 @@ >
</File>
<File
+ RelativePath="..\..\..\..\src\glut\glx\glut_ppm.c"
+ >
+ </File>
+ <File
RelativePath="..\..\..\..\src\glut\glx\glut_roman.c"
>
</File>
|