1 diff --git a/configs/darwin b/configs/darwin
2 index 77edf1a..f061500 100644
5 @@ -6,6 +6,8 @@ CONFIG_NAME = darwin
9 +X11_DIR = $(INSTALL_DIR)
14 @@ -21,9 +23,9 @@ DEFINES = -D_DARWIN_C_SOURCE -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L \
15 ARCH_FLAGS += $(RC_CFLAGS)
17 CFLAGS = -ggdb3 -Os -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing \
18 - -I$(INSTALL_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
19 + -I$(INSTALL_DIR)/include -I$(X11_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
20 CXXFLAGS = -ggdb3 -Os -Wall -fno-strict-aliasing \
21 - -I$(INSTALL_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
22 + -I$(INSTALL_DIR)/include -I$(X11_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES)
24 # Library names (actual file names)
25 GL_LIB_NAME = libGL.dylib
26 @@ -39,12 +41,12 @@ GLUT_LIB_GLOB = libglut.*dylib
27 GLW_LIB_GLOB = libGLw.*dylib
28 OSMESA_LIB_GLOB = libOSMesa.*dylib
30 -GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXext -lm -lpthread
31 +GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXext -lm -lpthread
32 OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
33 GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
34 -GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXmu -lXi -lXext
35 -GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXt
36 -APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm
37 +GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXi -lXext
38 +GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXt
39 +APP_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXmu -lXt -lXi -lm
41 # omit glw lib for now:
42 SRC_DIRS = glx/x11 mesa glu glut/glx
43 diff --git a/src/glx/x11/indirect.c b/src/glx/x11/indirect.c
44 index 08d52ae..aea117e 100644
45 --- a/src/glx/x11/indirect.c
46 +++ b/src/glx/x11/indirect.c
47 @@ -5198,9 +5198,13 @@ glDeleteTexturesEXT(GLsizei n, const GLuint * textures)
49 __GLXcontext *const gc = __glXGetCurrentContext();
51 +#ifdef GLX_DIRECT_RENDERING
53 CALL_DeleteTextures(GET_DISPATCH(), (n, textures));
58 __GLXcontext *const gc = __glXGetCurrentContext();
59 Display *const dpy = gc->currentDpy;
60 const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
61 @@ -5266,9 +5270,13 @@ glGenTexturesEXT(GLsizei n, GLuint * textures)
63 __GLXcontext *const gc = __glXGetCurrentContext();
65 +#ifdef GLX_DIRECT_RENDERING
67 CALL_GenTextures(GET_DISPATCH(), (n, textures));
72 __GLXcontext *const gc = __glXGetCurrentContext();
73 Display *const dpy = gc->currentDpy;
74 const GLuint cmdlen = 4;
75 @@ -5328,9 +5336,13 @@ glIsTextureEXT(GLuint texture)
77 __GLXcontext *const gc = __glXGetCurrentContext();
79 +#ifdef GLX_DIRECT_RENDERING
81 return CALL_IsTexture(GET_DISPATCH(), (texture));
86 __GLXcontext *const gc = __glXGetCurrentContext();
87 Display *const dpy = gc->currentDpy;
88 GLboolean retval = (GLboolean) 0;
89 @@ -5641,9 +5653,13 @@ glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid * table)
91 __GLXcontext *const gc = __glXGetCurrentContext();
93 +#ifdef GLX_DIRECT_RENDERING
95 CALL_GetColorTable(GET_DISPATCH(), (target, format, type, table));
100 __GLXcontext *const gc = __glXGetCurrentContext();
101 const __GLXattribute *const state = gc->client_state_private;
102 Display *const dpy = gc->currentDpy;
103 @@ -5714,10 +5730,14 @@ glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat * params)
105 __GLXcontext *const gc = __glXGetCurrentContext();
107 +#ifdef GLX_DIRECT_RENDERING
108 if (gc->driContext) {
109 CALL_GetColorTableParameterfv(GET_DISPATCH(),
110 (target, pname, params));
115 __GLXcontext *const gc = __glXGetCurrentContext();
116 Display *const dpy = gc->currentDpy;
117 const GLuint cmdlen = 8;
118 @@ -5784,10 +5804,14 @@ glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint * params)
120 __GLXcontext *const gc = __glXGetCurrentContext();
122 +#ifdef GLX_DIRECT_RENDERING
123 if (gc->driContext) {
124 CALL_GetColorTableParameteriv(GET_DISPATCH(),
125 (target, pname, params));
130 __GLXcontext *const gc = __glXGetCurrentContext();
131 Display *const dpy = gc->currentDpy;
132 const GLuint cmdlen = 8;
133 @@ -6107,10 +6131,14 @@ gl_dispatch_stub_356(GLenum target, GLenum format, GLenum type,
135 __GLXcontext *const gc = __glXGetCurrentContext();
137 +#ifdef GLX_DIRECT_RENDERING
138 if (gc->driContext) {
139 CALL_GetConvolutionFilter(GET_DISPATCH(),
140 (target, format, type, image));
145 __GLXcontext *const gc = __glXGetCurrentContext();
146 const __GLXattribute *const state = gc->client_state_private;
147 Display *const dpy = gc->currentDpy;
148 @@ -6182,10 +6210,14 @@ gl_dispatch_stub_357(GLenum target, GLenum pname, GLfloat * params)
150 __GLXcontext *const gc = __glXGetCurrentContext();
152 +#ifdef GLX_DIRECT_RENDERING
153 if (gc->driContext) {
154 CALL_GetConvolutionParameterfv(GET_DISPATCH(),
155 (target, pname, params));
160 __GLXcontext *const gc = __glXGetCurrentContext();
161 Display *const dpy = gc->currentDpy;
162 const GLuint cmdlen = 8;
163 @@ -6252,10 +6284,14 @@ gl_dispatch_stub_358(GLenum target, GLenum pname, GLint * params)
165 __GLXcontext *const gc = __glXGetCurrentContext();
167 +#ifdef GLX_DIRECT_RENDERING
168 if (gc->driContext) {
169 CALL_GetConvolutionParameteriv(GET_DISPATCH(),
170 (target, pname, params));
175 __GLXcontext *const gc = __glXGetCurrentContext();
176 Display *const dpy = gc->currentDpy;
177 const GLuint cmdlen = 8;
178 @@ -6329,10 +6365,14 @@ gl_dispatch_stub_361(GLenum target, GLboolean reset, GLenum format,
180 __GLXcontext *const gc = __glXGetCurrentContext();
182 +#ifdef GLX_DIRECT_RENDERING
183 if (gc->driContext) {
184 CALL_GetHistogram(GET_DISPATCH(),
185 (target, reset, format, type, values));
190 __GLXcontext *const gc = __glXGetCurrentContext();
191 const __GLXattribute *const state = gc->client_state_private;
192 Display *const dpy = gc->currentDpy;
193 @@ -6403,9 +6443,13 @@ gl_dispatch_stub_362(GLenum target, GLenum pname, GLfloat * params)
195 __GLXcontext *const gc = __glXGetCurrentContext();
197 +#ifdef GLX_DIRECT_RENDERING
198 if (gc->driContext) {
199 CALL_GetHistogramParameterfv(GET_DISPATCH(), (target, pname, params));
204 __GLXcontext *const gc = __glXGetCurrentContext();
205 Display *const dpy = gc->currentDpy;
206 const GLuint cmdlen = 8;
207 @@ -6471,9 +6515,13 @@ gl_dispatch_stub_363(GLenum target, GLenum pname, GLint * params)
209 __GLXcontext *const gc = __glXGetCurrentContext();
211 +#ifdef GLX_DIRECT_RENDERING
212 if (gc->driContext) {
213 CALL_GetHistogramParameteriv(GET_DISPATCH(), (target, pname, params));
218 __GLXcontext *const gc = __glXGetCurrentContext();
219 Display *const dpy = gc->currentDpy;
220 const GLuint cmdlen = 8;
221 @@ -6543,9 +6591,13 @@ gl_dispatch_stub_364(GLenum target, GLboolean reset, GLenum format,
223 __GLXcontext *const gc = __glXGetCurrentContext();
225 +#ifdef GLX_DIRECT_RENDERING
226 if (gc->driContext) {
227 CALL_GetMinmax(GET_DISPATCH(), (target, reset, format, type, values));
232 __GLXcontext *const gc = __glXGetCurrentContext();
233 const __GLXattribute *const state = gc->client_state_private;
234 Display *const dpy = gc->currentDpy;
235 @@ -6614,9 +6666,13 @@ gl_dispatch_stub_365(GLenum target, GLenum pname, GLfloat * params)
237 __GLXcontext *const gc = __glXGetCurrentContext();
239 +#ifdef GLX_DIRECT_RENDERING
240 if (gc->driContext) {
241 CALL_GetMinmaxParameterfv(GET_DISPATCH(), (target, pname, params));
246 __GLXcontext *const gc = __glXGetCurrentContext();
247 Display *const dpy = gc->currentDpy;
248 const GLuint cmdlen = 8;
249 @@ -6679,9 +6735,13 @@ gl_dispatch_stub_366(GLenum target, GLenum pname, GLint * params)
251 __GLXcontext *const gc = __glXGetCurrentContext();
253 +#ifdef GLX_DIRECT_RENDERING
254 if (gc->driContext) {
255 CALL_GetMinmaxParameteriv(GET_DISPATCH(), (target, pname, params));
260 __GLXcontext *const gc = __glXGetCurrentContext();
261 Display *const dpy = gc->currentDpy;
262 const GLuint cmdlen = 8;
263 diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
264 index ac97bc1..cb837de 100644
265 --- a/src/mesa/main/drawpix.c
266 +++ b/src/mesa/main/drawpix.c
267 @@ -77,28 +77,30 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
270 if (ctx->RenderMode == GL_RENDER) {
271 - /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
272 - GLint x = IROUND(ctx->Current.RasterPos[0]);
273 - GLint y = IROUND(ctx->Current.RasterPos[1]);
275 - if (ctx->Unpack.BufferObj->Name) {
276 - /* unpack from PBO */
277 - if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
278 - format, type, pixels)) {
279 - _mesa_error(ctx, GL_INVALID_OPERATION,
280 - "glDrawPixels(invalid PBO access)");
282 + if (width > 0 && height > 0) {
283 + /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
284 + GLint x = IROUND(ctx->Current.RasterPos[0]);
285 + GLint y = IROUND(ctx->Current.RasterPos[1]);
287 + if (ctx->Unpack.BufferObj->Name) {
288 + /* unpack from PBO */
289 + if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
290 + format, type, pixels)) {
291 + _mesa_error(ctx, GL_INVALID_OPERATION,
292 + "glDrawPixels(invalid PBO access)");
295 + if (ctx->Unpack.BufferObj->Pointer) {
296 + /* buffer is mapped - that's an error */
297 + _mesa_error(ctx, GL_INVALID_OPERATION,
298 + "glDrawPixels(PBO is mapped)");
302 - if (ctx->Unpack.BufferObj->Pointer) {
303 - /* buffer is mapped - that's an error */
304 - _mesa_error(ctx, GL_INVALID_OPERATION,
305 - "glDrawPixels(PBO is mapped)");
310 - ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
311 - &ctx->Unpack, pixels);
312 + ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
313 + &ctx->Unpack, pixels);
316 else if (ctx->RenderMode == GL_FEEDBACK) {
317 /* Feedback the current raster pos info */
318 @@ -159,10 +161,12 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
320 if (ctx->RenderMode == GL_RENDER) {
321 /* Round to satisfy conformance tests (matches SGI's OpenGL) */
322 - GLint destx = IROUND(ctx->Current.RasterPos[0]);
323 - GLint desty = IROUND(ctx->Current.RasterPos[1]);
324 - ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty,
326 + if (width > 0 && height > 0) {
327 + GLint destx = IROUND(ctx->Current.RasterPos[0]);
328 + GLint desty = IROUND(ctx->Current.RasterPos[1]);
329 + ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty,
333 else if (ctx->RenderMode == GL_FEEDBACK) {
334 FLUSH_CURRENT( ctx, 0 );
335 diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
336 index cc1b44d..4321b4c 100644
337 --- a/src/mesa/main/ffvertex_prog.c
338 +++ b/src/mesa/main/ffvertex_prog.c
339 @@ -1104,6 +1104,9 @@ static void build_lighting( struct tnl_program *p )
342 if (!p->state->material_shininess_is_zero) {
343 + /* Note that we negate the back-face specular exponent here.
344 + * The negation will be un-done later in the back-face code below.
346 struct ureg shininess = get_material(p, 1, STATE_SHININESS);
347 emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z,
348 negate(swizzle1(shininess,X)));
349 @@ -1309,6 +1312,11 @@ static void build_lighting( struct tnl_program *p )
353 + /* For the back face we need to negate the X and Y component
354 + * dot products. dots.Z has the negated back-face specular
355 + * exponent. We swizzle that into the W position. This
356 + * negation makes the back-face specular term positive again.
358 dots = negate(swizzle(dots,X,Y,W,Z));
360 if (!is_undef(att)) {
361 @@ -1327,8 +1335,10 @@ static void build_lighting( struct tnl_program *p )
363 emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0);
364 emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1);
365 - /* restore negate flag for next lighting */
366 - dots = negate(dots);
367 + /* restore dots to its original state for subsequent lights
368 + * by negating and swizzling again.
370 + dots = negate(swizzle(dots,X,Y,W,Z));
372 release_temp(p, ambient);
373 release_temp(p, diffuse);
374 diff --git a/src/mesa/main/glheader.h b/src/mesa/main/glheader.h
375 index 626806d..d17be37 100644
376 --- a/src/mesa/main/glheader.h
377 +++ b/src/mesa/main/glheader.h
379 #if defined(__linux__)
380 #include <byteswap.h>
381 #define CPU_TO_LE32( x ) bswap_32( x )
383 +#elif defined(__APPLE__)
384 +#include <CoreFoundation/CFByteOrder.h>
385 +#define CPU_TO_LE32( x ) CFSwapInt32HostToLittle( x )
386 +#else /*__linux__ __APPLE__*/
387 #include <sys/endian.h>
388 #define CPU_TO_LE32( x ) bswap32( x )
390 diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
391 index ce50224..4372f7b 100644
392 --- a/src/mesa/main/light.c
393 +++ b/src/mesa/main/light.c
394 @@ -209,7 +209,6 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
395 _math_matrix_analyse(ctx->ModelviewMatrixStack.Top);
397 TRANSFORM_DIRECTION(temp, params, ctx->ModelviewMatrixStack.Top->m);
398 - NORMALIZE_3FV(temp);
401 case GL_SPOT_EXPONENT:
402 @@ -1137,12 +1136,18 @@ compute_light_positions( GLcontext *ctx )
405 if (light->_Flags & LIGHT_SPOT) {
406 + /* Note: we normalize the spot direction now */
408 if (ctx->_NeedEyeCoords) {
409 COPY_3V( light->_NormDirection, light->EyeDirection );
410 + NORMALIZE_3FV( light->_NormDirection );
413 + GLfloat spotDir[3];
414 + COPY_3V(spotDir, light->EyeDirection);
415 + NORMALIZE_3FV(spotDir);
416 TRANSFORM_NORMAL( light->_NormDirection,
417 - light->EyeDirection,
419 ctx->ModelviewMatrixStack.Top->m);
422 diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c
423 index dfdd297..2326776 100644
424 --- a/src/mesa/main/readpix.c
425 +++ b/src/mesa/main/readpix.c
426 @@ -170,6 +170,9 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
430 + if (width == 0 || height == 0)
431 + return; /* nothing to do */
433 if (ctx->Pack.BufferObj->Name) {
434 if (!_mesa_validate_pbo_access(2, &ctx->Pack, width, height, 1,
435 format, type, pixels)) {
436 diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
437 index be4fc1d..e89bc5f 100644
438 --- a/src/mesa/main/texparam.c
439 +++ b/src/mesa/main/texparam.c
440 @@ -139,8 +139,11 @@ flush(GLcontext *ctx, struct gl_texture_object *texObj)
444 -/** Set an integer-valued texture parameter */
447 + * Set an integer-valued texture parameter
448 + * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
451 set_tex_parameteri(GLcontext *ctx,
452 struct gl_texture_object *texObj,
453 GLenum pname, const GLint *params)
454 @@ -148,13 +151,13 @@ set_tex_parameteri(GLcontext *ctx,
456 case GL_TEXTURE_MIN_FILTER:
457 if (texObj->MinFilter == params[0])
464 texObj->MinFilter = params[0];
467 case GL_NEAREST_MIPMAP_NEAREST:
468 case GL_LINEAR_MIPMAP_NEAREST:
469 case GL_NEAREST_MIPMAP_LINEAR:
470 @@ -162,77 +165,80 @@ set_tex_parameteri(GLcontext *ctx,
471 if (texObj->Target != GL_TEXTURE_RECTANGLE_NV) {
473 texObj->MinFilter = params[0];
479 _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
484 case GL_TEXTURE_MAG_FILTER:
485 if (texObj->MagFilter == params[0])
492 texObj->MagFilter = params[0];
496 _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
501 case GL_TEXTURE_WRAP_S:
502 if (texObj->WrapS == params[0])
505 if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
507 texObj->WrapS = params[0];
513 case GL_TEXTURE_WRAP_T:
514 if (texObj->WrapT == params[0])
517 if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
519 texObj->WrapT = params[0];
525 case GL_TEXTURE_WRAP_R:
526 if (texObj->WrapR == params[0])
529 if (validate_texture_wrap_mode(ctx, texObj->Target, params[0])) {
531 texObj->WrapR = params[0];
537 case GL_TEXTURE_BASE_LEVEL:
538 if (texObj->BaseLevel == params[0])
542 (texObj->Target == GL_TEXTURE_RECTANGLE_ARB && params[0] != 0)) {
543 _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)");
548 texObj->BaseLevel = params[0];
552 case GL_TEXTURE_MAX_LEVEL:
553 if (texObj->MaxLevel == params[0])
556 if (params[0] < 0 || texObj->Target == GL_TEXTURE_RECTANGLE_ARB) {
557 _mesa_error(ctx, GL_INVALID_OPERATION, "glTexParameter(param)");
562 texObj->MaxLevel = params[0];
566 case GL_TEXTURE_COMPARE_SGIX:
567 if (ctx->Extensions.SGIX_shadow) {
568 @@ -243,7 +249,7 @@ set_tex_parameteri(GLcontext *ctx,
569 _mesa_error(ctx, GL_INVALID_ENUM,
570 "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
575 case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
576 if (ctx->Extensions.SGIX_shadow &&
577 @@ -256,20 +262,22 @@ set_tex_parameteri(GLcontext *ctx,
578 _mesa_error(ctx, GL_INVALID_ENUM,
579 "glTexParameter(GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
584 case GL_GENERATE_MIPMAP_SGIS:
585 if (ctx->Extensions.SGIS_generate_mipmap) {
586 if (texObj->GenerateMipmap != params[0]) {
588 texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE;
594 _mesa_error(ctx, GL_INVALID_ENUM,
595 "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
600 case GL_TEXTURE_COMPARE_MODE_ARB:
601 if (ctx->Extensions.ARB_shadow &&
602 @@ -278,24 +286,26 @@ set_tex_parameteri(GLcontext *ctx,
603 if (texObj->CompareMode != params[0]) {
605 texObj->CompareMode = params[0];
611 _mesa_error(ctx, GL_INVALID_ENUM,
612 "glTexParameter(GL_TEXTURE_COMPARE_MODE_ARB)");
617 case GL_TEXTURE_COMPARE_FUNC_ARB:
618 if (ctx->Extensions.ARB_shadow) {
619 if (texObj->CompareFunc == params[0])
626 texObj->CompareFunc = params[0];
632 @@ -305,7 +315,7 @@ set_tex_parameteri(GLcontext *ctx,
633 if (ctx->Extensions.EXT_shadow_funcs) {
635 texObj->CompareFunc = params[0];
641 @@ -316,7 +326,7 @@ set_tex_parameteri(GLcontext *ctx,
643 _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param)");
648 case GL_DEPTH_TEXTURE_MODE_ARB:
649 if (ctx->Extensions.ARB_depth_texture &&
650 @@ -326,13 +336,14 @@ set_tex_parameteri(GLcontext *ctx,
651 if (texObj->DepthMode != params[0]) {
653 texObj->DepthMode = params[0];
658 _mesa_error(ctx, GL_INVALID_ENUM,
659 "glTexParameter(GL_DEPTH_TEXTURE_MODE_ARB)");
664 #ifdef FEATURE_OES_draw_texture
665 case GL_TEXTURE_CROP_RECT_OES:
666 @@ -340,17 +351,21 @@ set_tex_parameteri(GLcontext *ctx,
667 texObj->CropRect[1] = params[1];
668 texObj->CropRect[2] = params[2];
669 texObj->CropRect[3] = params[3];
675 _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
681 -/** Set a float-valued texture parameter */
684 + * Set a float-valued texture parameter
685 + * \return GL_TRUE if legal AND the value changed, GL_FALSE otherwise
688 set_tex_parameterf(GLcontext *ctx,
689 struct gl_texture_object *texObj,
690 GLenum pname, const GLfloat *params)
691 @@ -358,54 +373,56 @@ set_tex_parameterf(GLcontext *ctx,
693 case GL_TEXTURE_MIN_LOD:
694 if (texObj->MinLod == params[0])
698 texObj->MinLod = params[0];
702 case GL_TEXTURE_MAX_LOD:
703 if (texObj->MaxLod == params[0])
707 texObj->MaxLod = params[0];
711 case GL_TEXTURE_PRIORITY:
713 texObj->Priority = CLAMP(params[0], 0.0F, 1.0F);
717 case GL_TEXTURE_MAX_ANISOTROPY_EXT:
718 if (ctx->Extensions.EXT_texture_filter_anisotropic) {
719 if (texObj->MaxAnisotropy == params[0])
722 if (params[0] < 1.0) {
723 _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
728 /* clamp to max, that's what NVIDIA does */
729 texObj->MaxAnisotropy = MIN2(params[0],
730 ctx->Const.MaxTextureMaxAnisotropy);
734 _mesa_error(ctx, GL_INVALID_ENUM,
735 "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
740 case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
741 if (ctx->Extensions.SGIX_shadow_ambient) {
742 if (texObj->ShadowAmbient != params[0]) {
744 texObj->ShadowAmbient = CLAMP(params[0], 0.0F, 1.0F);
749 _mesa_error(ctx, GL_INVALID_ENUM,
750 "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
755 case GL_TEXTURE_LOD_BIAS:
756 /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias */
757 @@ -413,7 +430,9 @@ set_tex_parameterf(GLcontext *ctx,
758 if (texObj->LodBias != params[0]) {
760 texObj->LodBias = params[0];
767 @@ -427,17 +446,19 @@ set_tex_parameterf(GLcontext *ctx,
768 UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[GCOMP], params[1]);
769 UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[BCOMP], params[2]);
770 UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[ACOMP], params[3]);
775 _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(pname=0x%x)", pname);
782 _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
784 + GLboolean need_update;
785 struct gl_texture_object *texObj;
786 GET_CURRENT_CONTEXT(ctx);
787 ASSERT_OUTSIDE_BEGIN_END(ctx);
788 @@ -463,15 +484,15 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
790 /* convert float param to int */
791 GLint p = (GLint) param;
792 - set_tex_parameteri(ctx, texObj, pname, &p);
793 + need_update = set_tex_parameteri(ctx, texObj, pname, &p);
798 /* this will generate an error if pname is illegal */
799 - set_tex_parameterf(ctx, texObj, pname, ¶m);
800 + need_update = set_tex_parameterf(ctx, texObj, pname, ¶m);
803 - if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
804 + if (ctx->Driver.TexParameter && need_update) {
805 ctx->Driver.TexParameter(ctx, target, texObj, pname, ¶m);
808 @@ -480,6 +501,7 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
810 _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
812 + GLboolean need_update;
813 struct gl_texture_object *texObj;
814 GET_CURRENT_CONTEXT(ctx);
815 ASSERT_OUTSIDE_BEGIN_END(ctx);
816 @@ -505,7 +527,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
818 /* convert float param to int */
819 GLint p = (GLint) params[0];
820 - set_tex_parameteri(ctx, texObj, pname, &p);
821 + need_update = set_tex_parameteri(ctx, texObj, pname, &p);
825 @@ -518,17 +540,17 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
826 iparams[1] = (GLint) params[1];
827 iparams[2] = (GLint) params[2];
828 iparams[3] = (GLint) params[3];
829 - set_tex_parameteri(ctx, target, iparams);
830 + need_update = set_tex_parameteri(ctx, target, iparams);
836 /* this will generate an error if pname is illegal */
837 - set_tex_parameterf(ctx, texObj, pname, params);
838 + need_update = set_tex_parameterf(ctx, texObj, pname, params);
841 - if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
842 + if (ctx->Driver.TexParameter && need_update) {
843 ctx->Driver.TexParameter(ctx, target, texObj, pname, params);
846 @@ -537,6 +559,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
848 _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
850 + GLboolean need_update;
851 struct gl_texture_object *texObj;
852 GET_CURRENT_CONTEXT(ctx);
853 ASSERT_OUTSIDE_BEGIN_END(ctx);
854 @@ -555,15 +578,15 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
856 GLfloat fparam = (GLfloat) param;
857 /* convert int param to float */
858 - set_tex_parameterf(ctx, texObj, pname, &fparam);
859 + need_update = set_tex_parameterf(ctx, texObj, pname, &fparam);
863 /* this will generate an error if pname is illegal */
864 - set_tex_parameteri(ctx, texObj, pname, ¶m);
865 + need_update = set_tex_parameteri(ctx, texObj, pname, ¶m);
868 - if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
869 + if (ctx->Driver.TexParameter && need_update) {
870 GLfloat fparam = (GLfloat) param;
871 ctx->Driver.TexParameter(ctx, target, texObj, pname, &fparam);
873 @@ -573,6 +596,7 @@ _mesa_TexParameteri(GLenum target, GLenum pname, GLint param)
875 _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
877 + GLboolean need_update;
878 struct gl_texture_object *texObj;
879 GET_CURRENT_CONTEXT(ctx);
880 ASSERT_OUTSIDE_BEGIN_END(ctx);
881 @@ -590,7 +614,7 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
882 fparams[1] = INT_TO_FLOAT(params[1]);
883 fparams[2] = INT_TO_FLOAT(params[2]);
884 fparams[3] = INT_TO_FLOAT(params[3]);
885 - set_tex_parameterf(ctx, texObj, pname, fparams);
886 + need_update = set_tex_parameterf(ctx, texObj, pname, fparams);
889 case GL_TEXTURE_MIN_LOD:
890 @@ -602,15 +626,15 @@ _mesa_TexParameteriv(GLenum target, GLenum pname, const GLint *params)
892 /* convert int param to float */
893 GLfloat fparam = (GLfloat) params[0];
894 - set_tex_parameterf(ctx, texObj, pname, &fparam);
895 + need_update = set_tex_parameterf(ctx, texObj, pname, &fparam);
899 /* this will generate an error if pname is illegal */
900 - set_tex_parameteri(ctx, texObj, pname, params);
901 + need_update = set_tex_parameteri(ctx, texObj, pname, params);
904 - if (ctx->Driver.TexParameter && ctx->ErrorValue == GL_NO_ERROR) {
905 + if (ctx->Driver.TexParameter && need_update) {
907 fparams[0] = INT_TO_FLOAT(params[0]);
908 if (pname == GL_TEXTURE_BORDER_COLOR ||
909 diff --git a/src/mesa/shader/prog_execute.c b/src/mesa/shader/prog_execute.c
910 index a93733c..6a79cf4 100644
911 --- a/src/mesa/shader/prog_execute.c
912 +++ b/src/mesa/shader/prog_execute.c
913 @@ -1577,8 +1577,8 @@ _mesa_execute_program(GLcontext * ctx,
914 case OPCODE_TXB: /* GL_ARB_fragment_program only */
915 /* Texel lookup with LOD bias */
917 - const struct gl_texture_unit *texUnit
918 - = &ctx->Texture.Unit[inst->TexSrcUnit];
919 + const GLuint unit = machine->Samplers[inst->TexSrcUnit];
920 + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
921 GLfloat texcoord[4], color[4], lodBias;
923 fetch_vector4(&inst->SrcReg[0], machine, texcoord);
924 diff --git a/src/mesa/shader/slang/slang_builtin.c b/src/mesa/shader/slang/slang_builtin.c
925 index c0f4c79..5a67394 100644
926 --- a/src/mesa/shader/slang/slang_builtin.c
927 +++ b/src/mesa/shader/slang/slang_builtin.c
928 @@ -457,28 +457,36 @@ emit_statevars(const char *name, int array_len,
929 tokens[0] = STATE_TEXENV_COLOR;
931 else if (strcmp(name, "gl_EyePlaneS") == 0) {
932 - tokens[0] = STATE_TEXGEN_EYE_S;
933 + tokens[0] = STATE_TEXGEN;
934 + tokens[2] = STATE_TEXGEN_EYE_S;
936 else if (strcmp(name, "gl_EyePlaneT") == 0) {
937 - tokens[0] = STATE_TEXGEN_EYE_T;
938 + tokens[0] = STATE_TEXGEN;
939 + tokens[2] = STATE_TEXGEN_EYE_T;
941 else if (strcmp(name, "gl_EyePlaneR") == 0) {
942 - tokens[0] = STATE_TEXGEN_EYE_R;
943 + tokens[0] = STATE_TEXGEN;
944 + tokens[2] = STATE_TEXGEN_EYE_R;
946 else if (strcmp(name, "gl_EyePlaneQ") == 0) {
947 - tokens[0] = STATE_TEXGEN_EYE_Q;
948 + tokens[0] = STATE_TEXGEN;
949 + tokens[2] = STATE_TEXGEN_EYE_Q;
951 else if (strcmp(name, "gl_ObjectPlaneS") == 0) {
952 - tokens[0] = STATE_TEXGEN_OBJECT_S;
953 + tokens[0] = STATE_TEXGEN;
954 + tokens[2] = STATE_TEXGEN_OBJECT_S;
956 else if (strcmp(name, "gl_ObjectPlaneT") == 0) {
957 - tokens[0] = STATE_TEXGEN_OBJECT_T;
958 + tokens[0] = STATE_TEXGEN;
959 + tokens[2] = STATE_TEXGEN_OBJECT_T;
961 else if (strcmp(name, "gl_ObjectPlaneR") == 0) {
962 - tokens[0] = STATE_TEXGEN_OBJECT_R;
963 + tokens[0] = STATE_TEXGEN;
964 + tokens[2] = STATE_TEXGEN_OBJECT_R;
966 else if (strcmp(name, "gl_ObjectPlaneQ") == 0) {
967 - tokens[0] = STATE_TEXGEN_OBJECT_Q;
968 + tokens[0] = STATE_TEXGEN;
969 + tokens[2] = STATE_TEXGEN_OBJECT_Q;
972 return -1; /* invalid array name */
973 diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
974 index e36c1a4..f07014f 100644
975 --- a/src/mesa/swrast/s_span.c
976 +++ b/src/mesa/swrast/s_span.c
977 @@ -1399,11 +1399,17 @@ _swrast_write_rgba_span( GLcontext *ctx, SWspan *span)
981 - * Write to renderbuffers
982 + * Write to renderbuffers.
983 + * Depending on glDrawBuffer() state and the which color outputs are
984 + * written by the fragment shader, we may either replicate one color to
985 + * all renderbuffers or write a different color to each renderbuffer.
986 + * multiFragOutputs=TRUE for the later case.
989 const GLuint numBuffers = fb->_NumColorDrawBuffers;
990 - const GLboolean multiFragOutputs = numBuffers > 1;
991 + const struct gl_fragment_program *fp = ctx->FragmentProgram._Current;
992 + const GLboolean multiFragOutputs =
993 + (fp && fp->Base.OutputsWritten >= (1 << FRAG_RESULT_DATA0));
996 for (buf = 0; buf < numBuffers; buf++) {