aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2008-09-18 18:57:46 +0100
committerKeith Whitwell <[email protected]>2008-09-18 19:03:02 +0100
commit89ab66448e1bcd78caab6678261c2885dcff741c (patch)
treebe36d7e3eba3f64e54da34ff7ba64b3eb14e56aa /src/mesa
parent1074e8e4e47bb4af73c7ef730d0fec40e826cc7e (diff)
parent5e530d8384b0d9bb867d6407315587c84a443902 (diff)
Merge commit 'origin/master' into gallium-0.2
Conflicts: progs/trivial/Makefile src/mesa/glapi/glthread.c
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i915/i915_debug.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c8
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c7
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.c16
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.h10
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.h1
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c8
-rw-r--r--src/mesa/drivers/dri/tdfx/tdfx_screen.c77
-rw-r--r--src/mesa/glapi/glthread.c3
-rw-r--r--src/mesa/main/bufferobj.c5
-rw-r--r--src/mesa/main/dlist.c7
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/state.c8
-rw-r--r--src/mesa/main/texformat_tmp.h1
-rw-r--r--src/mesa/shader/shader_api.c62
-rw-r--r--src/mesa/shader/slang/slang_link.c141
-rw-r--r--src/mesa/shader/slang/slang_link.h8
-rw-r--r--src/mesa/swrast/s_texfilter.c2
-rw-r--r--src/mesa/vbo/vbo_save_api.c26
21 files changed, 218 insertions, 186 deletions
diff --git a/src/mesa/drivers/dri/i915/i915_debug.c b/src/mesa/drivers/dri/i915/i915_debug.c
index 8eb1c5b49e1..eb1a052b9e2 100644
--- a/src/mesa/drivers/dri/i915/i915_debug.c
+++ b/src/mesa/drivers/dri/i915/i915_debug.c
@@ -177,7 +177,7 @@ static GLboolean debug_variable_length_prim( struct debug_stream *stream )
#define BITS( dw, hi, lo, ... ) \
do { \
- unsigned himask = ~0UL >> (31 - (hi)); \
+ unsigned himask = 0xffffffffU >> (31 - (hi)); \
PRINTF("\t\t "); \
PRINTF(__VA_ARGS__); \
PRINTF(": 0x%x\n", ((dw) & himask) >> (lo)); \
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 7065bb35ee8..2ca57326066 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -233,6 +233,9 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
&count,
drawable->loaderPrivate);
+ if (buffers == NULL)
+ return;
+
drawable->x = 0;
drawable->y = 0;
drawable->backX = 0;
@@ -298,8 +301,9 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
}
else
region = intel_region_alloc_for_handle(intel, buffers[i].cpp,
- buffers[i].pitch / buffers[i].cpp,
+ drawable->w,
drawable->h,
+ buffers[i].pitch / buffers[i].cpp,
buffers[i].name,
region_name);
@@ -818,8 +822,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
/* free the Mesa context */
_mesa_free_context_data(&intel->ctx);
-
- dri_bufmgr_destroy(intel->bufmgr);
}
}
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 5bd2ebfdcf6..6570f6e69b7 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -296,7 +296,7 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width,
height, pitch);
- irb->region = intel_region_alloc(intel, cpp, pitch, height);
+ irb->region = intel_region_alloc(intel, cpp, width, height, pitch);
if (!irb->region)
return GL_FALSE; /* out of memory? */
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 9be7e02eff1..f28fac8394b 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -117,7 +117,10 @@ intel_miptree_create(struct intel_context *intel,
return NULL;
mt->region = intel_region_alloc(intel,
- mt->cpp, mt->pitch, mt->total_height);
+ mt->cpp,
+ mt->pitch,
+ mt->total_height,
+ mt->pitch);
if (!mt->region) {
free(mt);
@@ -141,7 +144,7 @@ intel_miptree_create_for_region(struct intel_context *intel,
mt = intel_miptree_create_internal(intel, target, internal_format,
first_level, last_level,
- region->pitch, region->height, depth0,
+ region->width, region->height, 1,
region->cpp, compress_byte);
if (!mt)
return mt;
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index 1cfc8ddd64c..cb0f4ba083b 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -105,7 +105,8 @@ intel_set_region_tiling_gem(struct intel_context *intel,
static struct intel_region *
intel_region_alloc_internal(struct intel_context *intel,
- GLuint cpp, GLuint pitch, GLuint height,
+ GLuint cpp,
+ GLuint width, GLuint height, GLuint pitch,
dri_bo *buffer)
{
struct intel_region *region;
@@ -117,8 +118,9 @@ intel_region_alloc_internal(struct intel_context *intel,
region = calloc(sizeof(*region), 1);
region->cpp = cpp;
+ region->width = width;
+ region->height = height;
region->pitch = pitch;
- region->height = height; /* needed? */
region->refcount = 1;
region->buffer = buffer;
@@ -131,19 +133,20 @@ intel_region_alloc_internal(struct intel_context *intel,
struct intel_region *
intel_region_alloc(struct intel_context *intel,
- GLuint cpp, GLuint pitch, GLuint height)
+ GLuint cpp, GLuint width, GLuint height, GLuint pitch)
{
dri_bo *buffer;
buffer = dri_bo_alloc(intel->bufmgr, "region",
pitch * cpp * height, 64);
- return intel_region_alloc_internal(intel, cpp, pitch, height, buffer);
+ return intel_region_alloc_internal(intel, cpp, width, height, pitch, buffer);
}
struct intel_region *
intel_region_alloc_for_handle(struct intel_context *intel,
- GLuint cpp, GLuint pitch, GLuint height,
+ GLuint cpp,
+ GLuint width, GLuint height, GLuint pitch,
GLuint handle, const char *name)
{
struct intel_region *region;
@@ -151,7 +154,8 @@ intel_region_alloc_for_handle(struct intel_context *intel,
buffer = intel_bo_gem_create_from_name(intel->bufmgr, name, handle);
- region = intel_region_alloc_internal(intel, cpp, pitch, height, buffer);
+ region = intel_region_alloc_internal(intel, cpp,
+ width, height, pitch, buffer);
if (region == NULL)
return region;
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index a561de485e2..62eb049fbaf 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -55,8 +55,9 @@ struct intel_region
dri_bo *buffer; /**< buffer manager's buffer */
GLuint refcount; /**< Reference count for region */
GLuint cpp; /**< bytes per pixel */
- GLuint pitch; /**< in pixels */
+ GLuint width; /**< in pixels */
GLuint height; /**< in pixels */
+ GLuint pitch; /**< in pixels */
GLubyte *map; /**< only non-NULL when region is actually mapped */
GLuint map_refcount; /**< Reference count for mapping */
@@ -72,12 +73,13 @@ struct intel_region
* copied by calling intel_reference_region().
*/
struct intel_region *intel_region_alloc(struct intel_context *intel,
- GLuint cpp,
- GLuint pitch, GLuint height);
+ GLuint cpp, GLuint width,
+ GLuint height, GLuint pitch);
struct intel_region *
intel_region_alloc_for_handle(struct intel_context *intel,
- GLuint cpp, GLuint pitch, GLuint height,
+ GLuint cpp,
+ GLuint width, GLuint height, GLuint pitch,
unsigned int handle, const char *name);
void intel_region_reference(struct intel_region **dst,
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 1de1ac49ea5..373e0e155ee 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -298,11 +298,6 @@ static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
&intelScreen->irq_active))
return GL_FALSE;
- /* Determine if batchbuffers are allowed */
- if (!intel_get_param(sPriv, I915_PARAM_ALLOW_BATCHBUFFER,
- &intelScreen->allow_batchbuffer))
- return GL_FALSE;
-
sPriv->extensions = intelScreenExtensions;
return GL_TRUE;
@@ -314,6 +309,7 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv)
{
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
+ dri_bufmgr_destroy(intelScreen->bufmgr);
intelUnmapScreenRegions(intelScreen);
FREE(intelScreen);
diff --git a/src/mesa/drivers/dri/intel/intel_screen.h b/src/mesa/drivers/dri/intel/intel_screen.h
index daf2ab4c582..fc913da5bfe 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.h
+++ b/src/mesa/drivers/dri/intel/intel_screen.h
@@ -74,7 +74,6 @@ typedef struct
int drmMinor;
int irq_active;
- int allow_batchbuffer;
GLboolean no_hw;
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index d1f540b0f17..1820d3dc058 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -733,6 +733,12 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
intel_update_renderbuffers(pDRICtx, dPriv);
rb = intel_fb->color_rb[0];
+ /* If the region isn't set, then intel_update_renderbuffers was unable
+ * to get the buffers for the drawable.
+ */
+ if (rb->region == NULL)
+ return;
+
type = GL_BGRA;
format = GL_UNSIGNED_BYTE;
internalFormat = (rb->region->cpp == 3 ? 3 : 4);
@@ -751,7 +757,7 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
intelObj->mt = mt;
texImage = _mesa_get_tex_image(&intel->ctx, texObj, target, level);
_mesa_init_teximage_fields(&intel->ctx, target, texImage,
- rb->region->pitch, rb->region->height, 1,
+ rb->region->width, rb->region->height, 1,
0, internalFormat);
intelImage = intel_texture_image(texImage);
diff --git a/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
index 4e67b5d2035..cdfc8a002d9 100644
--- a/src/mesa/drivers/dri/tdfx/tdfx_screen.c
+++ b/src/mesa/drivers/dri/tdfx/tdfx_screen.c
@@ -64,6 +64,7 @@ DRI_CONF_END;
static const __DRIextension *tdfxExtensions[] = {
&driReadDrawableExtension,
+ NULL
};
static const GLuint __driNConfigOptions = 1;
@@ -349,12 +350,7 @@ tdfxFillInModes(__DRIscreenPrivate *psp,
unsigned stencil_bits,
GLboolean have_back_buffer)
{
- __DRIconfig **configs, **c;
- __GLcontextModes *m;
- unsigned num_modes;
- unsigned vis[2] = { GLX_TRUE_COLOR, GLX_DIRECT_COLOR };
unsigned deep = (depth_bits > 17);
- unsigned i, db, depth, accum, stencil;
/* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
* enough to add support. Basically, if a context is created with an
@@ -362,55 +358,32 @@ tdfxFillInModes(__DRIscreenPrivate *psp,
* will never be used.
*/
- num_modes = (depth_bits == 16) ? 32 : 16;
-
- configs = _mesa_malloc(num_modes * sizeof *configs);
- c = configs;
-
- for (i = 0; i <= 1; i++) {
- for (db = 0; db <= 1; db++) {
- for (depth = 0; depth <= 1; depth++) {
- for (accum = 0; accum <= 1; accum++) {
- for (stencil = 0; stencil <= !deep; stencil++) {
- *c = _mesa_malloc(sizeof **c);
- m = &(*c++)->modes;
- if (deep) stencil = depth;
- m->redBits = deep ? 8 : 5;
- m->greenBits = deep ? 8 : 6;
- m->blueBits = deep ? 8 : 5;
- m->alphaBits = deep ? 8 : 0;
- m->redMask = deep ?0xFF000000 :0x0000F800;
- m->greenMask = deep ?0x00FF0000 :0x000007E0;
- m->blueMask = deep ?0x0000FF00 :0x0000001F;
- m->alphaMask = deep ? 0x000000FF : 0;
- m->rgbBits = m->redBits + m->greenBits +
- m->blueBits + m->alphaBits;
- m->accumRedBits = accum ? 16 : 0;
- m->accumGreenBits = accum ? 16 : 0;
- m->accumBlueBits = accum ? 16 : 0;
- m->accumAlphaBits = (accum && deep) ? 16 : 0;
- m->stencilBits = stencil ? 8 : 0;
- m->depthBits = deep
- ? (depth ? 24 : 0)
- : (depth ? 0 : depth_bits);
- m->visualType = vis[i];
- m->renderType = GLX_RGBA_BIT;
- m->drawableType = GLX_WINDOW_BIT;
- m->rgbMode = GL_TRUE;
- m->doubleBufferMode = db ? GL_TRUE : GL_FALSE;
- if (db)
- m->swapMethod = GLX_SWAP_UNDEFINED_OML;
- m->visualRating = ((stencil && !deep) || accum)
- ? GLX_SLOW_CONFIG
- : GLX_NONE;
- if (deep) stencil = 0;
- }
- }
- }
- }
+ static const GLenum db_modes[2] = { GLX_NONE, GLX_SWAP_UNDEFINED_OML };
+ uint8_t depth_bits_array[4];
+ uint8_t stencil_bits_array[4];
+ if(deep) {
+ depth_bits_array[0] = 0;
+ depth_bits_array[1] = 24;
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = 8;
+ } else {
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = 0;
+ depth_bits_array[2] = depth_bits;
+ depth_bits_array[3] = 0;
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = 0;
+ stencil_bits_array[2] = 8;
+ stencil_bits_array[3] = 8;
}
- return (const __DRIconfig **) configs;
+ return driCreateConfigs(
+ deep ? GL_RGBA : GL_RGB,
+ deep ? GL_UNSIGNED_INT_8_8_8_8 : GL_UNSIGNED_SHORT_5_6_5,
+ depth_bits_array,
+ stencil_bits_array,
+ deep ? 2 : 4,
+ db_modes, 2);
}
/**
diff --git a/src/mesa/glapi/glthread.c b/src/mesa/glapi/glthread.c
index 09cc8cfcde2..56ddf7c25ac 100644
--- a/src/mesa/glapi/glthread.c
+++ b/src/mesa/glapi/glthread.c
@@ -28,6 +28,9 @@
* truly reusable outside of Mesa. First, the glheader.h include must go.
*/
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
#include "main/glheader.h"
#include "glthread.h"
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 11e1fd6b2b2..68491359e84 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -205,11 +205,14 @@ _mesa_reference_buffer_object(GLcontext *ctx,
if (deleteFlag) {
/* some sanity checking: don't delete a buffer still in use */
+#if 0
+ /* unfortunately, these tests are invalid during context tear-down */
ASSERT(ctx->Array.ArrayBufferObj != bufObj);
ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
ASSERT(ctx->Array.ArrayObj->Vertex.BufferObj != bufObj);
- ASSERT(ctx->Driver.DeleteBuffer);
+#endif
+ ASSERT(ctx->Driver.DeleteBuffer);
ctx->Driver.DeleteBuffer(ctx, oldObj);
}
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index cafe8072ee0..f7660930a9c 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -6796,6 +6796,11 @@ _mesa_EndList(void)
_mesa_error(ctx, GL_INVALID_OPERATION, "glEndList");
return;
}
+
+ /* Call before emitting END_OF_LIST, in case the driver wants to
+ * emit opcodes itself.
+ */
+ ctx->Driver.EndList(ctx);
(void) ALLOC_INSTRUCTION(ctx, OPCODE_END_OF_LIST, 0);
@@ -6809,8 +6814,6 @@ _mesa_EndList(void)
if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
mesa_print_display_list(ctx->ListState.CurrentListNum);
- ctx->Driver.EndList(ctx);
-
ctx->ListState.CurrentList = NULL;
ctx->ListState.CurrentListNum = 0;
ctx->ListState.CurrentListPtr = NULL;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 300010c3732..4cb895e486b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2123,12 +2123,14 @@ struct gl_shader_program
GLuint NumShaders; /**< number of attached shaders */
struct gl_shader **Shaders; /**< List of attached the shaders */
+ /** User-defined attribute bindings (glBindAttribLocation) */
+ struct gl_program_parameter_list *Attributes;
+
/* post-link info: */
struct gl_vertex_program *VertexProgram; /**< Linked vertex program */
struct gl_fragment_program *FragmentProgram; /**< Linked fragment prog */
struct gl_uniform_list *Uniforms;
struct gl_program_parameter_list *Varying;
- struct gl_program_parameter_list *Attributes; /**< Vertex attributes */
GLboolean LinkStatus; /**< GL_LINK_STATUS */
GLboolean Validated;
GLchar *InfoLog;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index e340cd66866..030c43365fe 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -317,10 +317,10 @@ static void
update_multisample(GLcontext *ctx)
{
ctx->Multisample._Enabled = GL_FALSE;
- if (ctx->DrawBuffer) {
- if (ctx->DrawBuffer->Visual.sampleBuffers)
- ctx->Multisample._Enabled = GL_TRUE;
- }
+ if (ctx->Multisample.Enabled &&
+ ctx->DrawBuffer &&
+ ctx->DrawBuffer->Visual.sampleBuffers)
+ ctx->Multisample._Enabled = GL_TRUE;
}
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index 63939f40111..7499ba7b36e 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -1117,6 +1117,7 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage,
break;;
default:
_mesa_problem(ctx, "Bad palette format in fetch_texel_ci8");
+ return;
}
#if CHAN_TYPE == GL_UNSIGNED_BYTE
COPY_4UBV(texel, texelUB);
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index d8b210be539..0d65af9738f 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.2
*
* Copyright (C) 2004-2008 Brian Paul All Rights Reserved.
*
@@ -497,10 +497,14 @@ _mesa_get_attrib_location(GLcontext *ctx, GLuint program,
if (!name)
return -1;
- if (shProg->Attributes) {
- GLint i = _mesa_lookup_parameter_index(shProg->Attributes, -1, name);
- if (i >= 0) {
- return shProg->Attributes->Parameters[i].StateIndexes[0];
+ if (shProg->VertexProgram) {
+ const struct gl_program_parameter_list *attribs =
+ shProg->VertexProgram->Base.Attributes;
+ if (attribs) {
+ GLint i = _mesa_lookup_parameter_index(attribs, -1, name);
+ if (i >= 0) {
+ return attribs->Parameters[i].StateIndexes[0];
+ }
}
}
return -1;
@@ -513,7 +517,7 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index,
{
struct gl_shader_program *shProg;
const GLint size = -1; /* unknown size */
- GLint i, oldIndex;
+ GLint i;
GLenum datatype = GL_FLOAT_VEC4;
shProg = _mesa_lookup_shader_program_err(ctx, program,
@@ -536,14 +540,6 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index,
return;
}
- if (shProg->LinkStatus) {
- /* get current index/location for the attribute */
- oldIndex = _mesa_get_attrib_location(ctx, program, name);
- }
- else {
- oldIndex = -1;
- }
-
/* this will replace the current value if it's already in the list */
i = _mesa_add_attribute(shProg->Attributes, name, size, datatype, index);
if (i < 0) {
@@ -551,12 +547,10 @@ _mesa_bind_attrib_location(GLcontext *ctx, GLuint program, GLuint index,
return;
}
- if (shProg->VertexProgram && oldIndex >= 0 && oldIndex != index) {
- /* If the index changed, need to search/replace references to that attribute
- * in the vertex program.
- */
- _slang_remap_attribute(&shProg->VertexProgram->Base, oldIndex, index);
- }
+ /*
+ * Note that this attribute binding won't go into effect until
+ * glLinkProgram is called again.
+ */
}
@@ -798,24 +792,29 @@ _mesa_get_active_attrib(GLcontext *ctx, GLuint program, GLuint index,
GLsizei maxLength, GLsizei *length, GLint *size,
GLenum *type, GLchar *nameOut)
{
+ const struct gl_program_parameter_list *attribs = NULL;
struct gl_shader_program *shProg;
shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveAttrib");
if (!shProg)
return;
- if (!shProg->Attributes || index >= shProg->Attributes->NumParameters) {
+ if (shProg->VertexProgram)
+ attribs = shProg->VertexProgram->Base.Attributes;
+
+ if (!attribs || index >= attribs->NumParameters) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetActiveAttrib(index)");
return;
}
- copy_string(nameOut, maxLength, length,
- shProg->Attributes->Parameters[index].Name);
+ copy_string(nameOut, maxLength, length, attribs->Parameters[index].Name);
+
if (size)
- *size = shProg->Attributes->Parameters[index].Size
- / sizeof_glsl_type(shProg->Attributes->Parameters[index].DataType);
+ *size = attribs->Parameters[index].Size
+ / sizeof_glsl_type(attribs->Parameters[index].DataType);
+
if (type)
- *type = shProg->Attributes->Parameters[index].DataType;
+ *type = attribs->Parameters[index].DataType;
}
@@ -937,6 +936,7 @@ static void
_mesa_get_programiv(GLcontext *ctx, GLuint program,
GLenum pname, GLint *params)
{
+ const struct gl_program_parameter_list *attribs;
struct gl_shader_program *shProg
= _mesa_lookup_shader_program(ctx, program);
@@ -945,6 +945,11 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program,
return;
}
+ if (shProg->VertexProgram)
+ attribs = shProg->VertexProgram->Base.Attributes;
+ else
+ attribs = NULL;
+
switch (pname) {
case GL_DELETE_STATUS:
*params = shProg->DeletePending;
@@ -962,11 +967,10 @@ _mesa_get_programiv(GLcontext *ctx, GLuint program,
*params = shProg->NumShaders;
break;
case GL_ACTIVE_ATTRIBUTES:
- *params = shProg->Attributes ? shProg->Attributes->NumParameters : 0;
+ *params = attribs ? attribs->NumParameters : 0;
break;
case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
- *params = _mesa_longest_parameter_name(shProg->Attributes,
- PROGRAM_INPUT) + 1;
+ *params = _mesa_longest_parameter_name(attribs, PROGRAM_INPUT) + 1;
break;
case GL_ACTIVE_UNIFORMS:
*params = shProg->Uniforms ? shProg->Uniforms->NumUniforms : 0;
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 57dbfc23885..a6390846b26 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
+ * Version: 7.2
*
- * Copyright (C) 2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -215,74 +215,112 @@ link_uniform_vars(struct gl_shader_program *shProg,
* For example, if the vertex shader declared "attribute vec4 foobar" we'll
* allocate a generic vertex attribute for "foobar" and plug that value into
* the vertex program instructions.
+ * But if the user called glBindAttributeLocation(), those bindings will
+ * have priority.
*/
static GLboolean
_slang_resolve_attributes(struct gl_shader_program *shProg,
- struct gl_program *prog)
+ const struct gl_program *origProg,
+ struct gl_program *linkedProg)
{
+ GLint attribMap[MAX_VERTEX_ATTRIBS];
GLuint i, j;
GLbitfield usedAttributes;
- assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
+ assert(origProg != linkedProg);
+ assert(origProg->Target == GL_VERTEX_PROGRAM_ARB);
+ assert(linkedProg->Target == GL_VERTEX_PROGRAM_ARB);
if (!shProg->Attributes)
shProg->Attributes = _mesa_new_parameter_list();
+ if (linkedProg->Attributes) {
+ _mesa_free_parameter_list(linkedProg->Attributes);
+ }
+ linkedProg->Attributes = _mesa_new_parameter_list();
+
+
/* Build a bitmask indicating which attribute indexes have been
* explicitly bound by the user with glBindAttributeLocation().
*/
usedAttributes = 0x0;
for (i = 0; i < shProg->Attributes->NumParameters; i++) {
GLint attr = shProg->Attributes->Parameters[i].StateIndexes[0];
- usedAttributes |= attr;
+ usedAttributes |= (1 << attr);
+ }
+
+ /* initialize the generic attribute map entries to -1 */
+ for (i = 0; i < MAX_VERTEX_ATTRIBS; i++) {
+ attribMap[i] = -1;
}
/*
* Scan program for generic attribute references
*/
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
+ for (i = 0; i < linkedProg->NumInstructions; i++) {
+ struct prog_instruction *inst = linkedProg->Instructions + i;
for (j = 0; j < 3; j++) {
if (inst->SrcReg[j].File == PROGRAM_INPUT &&
inst->SrcReg[j].Index >= VERT_ATTRIB_GENERIC0) {
- /* this is a generic attrib */
- const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0;
- const char *name = prog->Attributes->Parameters[k].Name;
- /* See if this attrib name is in the program's attribute list
- * (i.e. was bound by the user).
+ /*
+ * OK, we've found a generic vertex attribute reference.
*/
- GLint index = _mesa_lookup_parameter_index(shProg->Attributes,
- -1, name);
- GLint attr;
- if (index >= 0) {
- /* found, user must have specified a binding */
- attr = shProg->Attributes->Parameters[index].StateIndexes[0];
- }
- else {
- /* Not found, choose our own attribute number.
- * Start at 1 since generic attribute 0 always aliases
- * glVertex/position.
+ const GLint k = inst->SrcReg[j].Index - VERT_ATTRIB_GENERIC0;
+
+ GLint attr = attribMap[k];
+
+ if (attr < 0) {
+ /* Need to figure out attribute mapping now.
+ */
+ const char *name = origProg->Attributes->Parameters[k].Name;
+ const GLint size = origProg->Attributes->Parameters[k].Size;
+ const GLenum type =origProg->Attributes->Parameters[k].DataType;
+ GLint index;
+
+ /* See if there's a user-defined attribute binding for
+ * this name.
*/
- GLint size = prog->Attributes->Parameters[k].Size;
- GLenum datatype = prog->Attributes->Parameters[k].DataType;
- for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) {
- if (((1 << attr) & usedAttributes) == 0)
- break;
+ index = _mesa_lookup_parameter_index(shProg->Attributes,
+ -1, name);
+ if (index >= 0) {
+ /* Found a user-defined binding */
+ attr = shProg->Attributes->Parameters[index].StateIndexes[0];
}
- if (attr == MAX_VERTEX_ATTRIBS) {
- /* too many! XXX record error log */
- return GL_FALSE;
+ else {
+ /* No user-defined binding, choose our own attribute number.
+ * Start at 1 since generic attribute 0 always aliases
+ * glVertex/position.
+ */
+ for (attr = 1; attr < MAX_VERTEX_ATTRIBS; attr++) {
+ if (((1 << attr) & usedAttributes) == 0)
+ break;
+ }
+ if (attr == MAX_VERTEX_ATTRIBS) {
+ link_error(shProg, "Too many vertex attributes");
+ return GL_FALSE;
+ }
+
+ /* mark this attribute as used */
+ usedAttributes |= (1 << attr);
}
- _mesa_add_attribute(shProg->Attributes, name, size, datatype,attr);
- /* set the attribute as used */
- usedAttributes |= 1<<attr;
+ attribMap[k] = attr;
+
+ /* Save the final name->attrib binding so it can be queried
+ * with glGetAttributeLocation().
+ */
+ _mesa_add_attribute(linkedProg->Attributes, name,
+ size, type, attr);
}
+ assert(attr >= 0);
+
+ /* update the instruction's src reg */
inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + attr;
}
}
}
+
return GL_TRUE;
}
@@ -344,36 +382,6 @@ _slang_update_inputs_outputs(struct gl_program *prog)
}
-/**
- * Scan a vertex program looking for instances of
- * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + oldAttrib) and replace with
- * (PROGRAM_INPUT, VERT_ATTRIB_GENERIC0 + newAttrib).
- * This is used when the user calls glBindAttribLocation on an already linked
- * shader program.
- */
-void
-_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib, GLuint newAttrib)
-{
- GLuint i, j;
-
- assert(prog->Target == GL_VERTEX_PROGRAM_ARB);
-
- for (i = 0; i < prog->NumInstructions; i++) {
- struct prog_instruction *inst = prog->Instructions + i;
- for (j = 0; j < 3; j++) {
- if (inst->SrcReg[j].File == PROGRAM_INPUT) {
- if (inst->SrcReg[j].Index == VERT_ATTRIB_GENERIC0 + oldAttrib) {
- inst->SrcReg[j].Index = VERT_ATTRIB_GENERIC0 + newAttrib;
- }
- }
- }
- }
-
- _slang_update_inputs_outputs(prog);
-}
-
-
-
/** cast wrapper */
static struct gl_vertex_program *
vertex_program(struct gl_program *prog)
@@ -492,9 +500,8 @@ _slang_link(GLcontext *ctx,
/*_mesa_print_uniforms(shProg->Uniforms);*/
if (shProg->VertexProgram) {
- if (!_slang_resolve_attributes(shProg, &shProg->VertexProgram->Base)) {
- /*goto cleanup;*/
- _mesa_problem(ctx, "_slang_resolve_attributes() failed");
+ if (!_slang_resolve_attributes(shProg, &vertProg->Base,
+ &shProg->VertexProgram->Base)) {
return;
}
}
diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h
index 8ef8a6b4b3e..2b44d20787a 100644
--- a/src/mesa/shader/slang/slang_link.h
+++ b/src/mesa/shader/slang/slang_link.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
+ * Version: 7.2
*
- * Copyright (C) 2007 Brian Paul All Rights Reserved.
+ * Copyright (C) 2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -32,10 +32,6 @@ extern void
_slang_link(GLcontext *ctx, GLhandleARB h,
struct gl_shader_program *shProg);
-extern void
-_slang_remap_attribute(struct gl_program *prog, GLuint oldAttrib,
- GLuint newAttrib);
-
#endif
diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
index 1b44fddc413..a9e17d4c019 100644
--- a/src/mesa/swrast/s_texfilter.c
+++ b/src/mesa/swrast/s_texfilter.c
@@ -342,6 +342,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c,
break; \
default: \
_mesa_problem(ctx, "Bad wrap mode"); \
+ return; \
} \
}
@@ -462,6 +463,7 @@ lerp_rgba_3d(GLchan result[4], GLfloat a, GLfloat b, GLfloat c,
break; \
default: \
_mesa_problem(ctx, "Bad wrap mode"); \
+ return; \
} \
}
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 88d573f1283..f69a33d8176 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1045,6 +1045,32 @@ void vbo_save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
void vbo_save_EndList( GLcontext *ctx )
{
struct vbo_save_context *save = &vbo_context(ctx)->save;
+
+ /* EndList called inside a (saved) Begin/End pair?
+ */
+ if (ctx->Driver.CurrentSavePrimitive != PRIM_OUTSIDE_BEGIN_END) {
+
+ if (save->prim_count > 0) {
+ GLint i = save->prim_count - 1;
+ ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
+ save->prim[i].end = 0;
+ save->prim[i].count = (save->vert_count -
+ save->prim[i].start);
+ }
+
+ /* Make sure this vertex list gets replayed by the "loopback"
+ * mechanism:
+ */
+ save->dangling_attr_ref = 1;
+ vbo_save_SaveFlushVertices( ctx );
+
+ /* Swap out this vertex format while outside begin/end. Any color,
+ * etc. received between here and the next begin will be compiled
+ * as opcodes.
+ */
+ _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
+ }
+
unmap_vertex_store( ctx, save->vertex_store );
assert(save->vertex_size == 0);