Merge commit 'origin/master' into gallium-0.2

Conflicts:

	progs/trivial/Makefile
	src/mesa/glapi/glthread.c
This commit is contained in:
Keith Whitwell
2008-09-18 18:57:46 +01:00
37 changed files with 399 additions and 205 deletions

View File

@@ -114,7 +114,7 @@ static void calcposobs(void)
rainParticle::setRainingArea(obs[0]-7.0f,-0.2f,obs[2]-7.0f,obs[0]+7.0f,8.0f,obs[2]+7.0f);
}
static void printstring(void *font, char *string)
static void printstring(void *font, const char *string)
{
int len,i;

View File

@@ -19,6 +19,7 @@ SOURCES = \
dlist-dangling.c \
dlist-edgeflag-dangling.c \
dlist-edgeflag.c \
dlist-degenerate.c \
drawarrays.c \
drawelements.c \
drawrange.c \
@@ -74,7 +75,6 @@ SOURCES = \
quadstrip-cont.c \
quadstrip-flat.c \
quadstrip.c \
tri-orig.c \
tri-alpha.c \
tri-blend-color.c \
tri-blend-max.c \
@@ -93,6 +93,7 @@ SOURCES = \
tri-flat.c \
tri-fog.c \
tri-mask-tri.c \
tri-orig.c \
tri-query.c \
tri-scissor-tri.c \
tri-stencil.c \

View File

@@ -0,0 +1,153 @@
/**
* Test display list corner cases.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <GL/glut.h>
static int Win;
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLboolean Anim = GL_FALSE;
static GLuint List1 = 0, List2 = 0;
static void
Idle(void)
{
Xrot += 3.0;
Yrot += 4.0;
Zrot += 2.0;
glutPostRedisplay();
}
static void
Draw(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glRotatef(Xrot, 1, 0, 0);
glRotatef(Yrot, 0, 1, 0);
glRotatef(Zrot, 0, 0, 1);
glCallList(List1);
glCallList(List2);
glPopMatrix();
glutSwapBuffers();
}
static void
Reshape(int width, int height)
{
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0, 0.0, -15.0);
}
static void
Key(unsigned char key, int x, int y)
{
const GLfloat step = 3.0;
(void) x;
(void) y;
switch (key) {
case 'a':
Anim = !Anim;
if (Anim)
glutIdleFunc(Idle);
else
glutIdleFunc(NULL);
break;
case 'z':
Zrot -= step;
break;
case 'Z':
Zrot += step;
break;
case 27:
glutDestroyWindow(Win);
exit(0);
break;
}
glutPostRedisplay();
}
static void
SpecialKey(int key, int x, int y)
{
const GLfloat step = 3.0;
(void) x;
(void) y;
switch (key) {
case GLUT_KEY_UP:
Xrot -= step;
break;
case GLUT_KEY_DOWN:
Xrot += step;
break;
case GLUT_KEY_LEFT:
Yrot -= step;
break;
case GLUT_KEY_RIGHT:
Yrot += step;
break;
}
glutPostRedisplay();
}
static void
Init(void)
{
/* List1: start of primitive */
List1 = glGenLists(1);
glNewList(List1, GL_COMPILE);
glBegin(GL_POLYGON);
glVertex2f(-1, -1);
glVertex2f( 1, -1);
glEndList();
/* List2: end of primitive */
List2 = glGenLists(1);
glNewList(List2, GL_COMPILE);
glVertex2f( 1, 1);
glVertex2f(-1, 1);
glEnd();
glEndList();
glEnable(GL_DEPTH_TEST);
}
int
main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
glutInitWindowSize(400, 400);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
Win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutSpecialFunc(SpecialKey);
glutDisplayFunc(Draw);
if (Anim)
glutIdleFunc(Idle);
Init();
glutMainLoop();
return 0;
}

View File

@@ -447,7 +447,6 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits)
if (!ctx) {
fprintf(stderr, "Error: glXCreateContext failed\n");
XFree(visinfo);
XDestroyWindow(dpy, win);
return;
}

View File

@@ -41,7 +41,7 @@
#define __glumystdio_h_
#ifdef STANDALONE
inline void _glu_dprintf( char *, ... ) { }
inline void _glu_dprintf( const char *, ... ) { }
#endif
#ifdef LIBRARYBUILD
@@ -49,12 +49,12 @@ inline void _glu_dprintf( char *, ... ) { }
#include <stdio.h>
#define _glu_dprintf printf
#else
inline void _glu_dprintf( char *, ... ) { }
inline void _glu_dprintf( const char *, ... ) { }
#endif
#endif
#ifdef GLBUILD
inline void _glu_dprintf( char *, ... ) { }
inline void _glu_dprintf( const char *, ... ) { }
#endif
#ifndef NULL

View File

@@ -244,7 +244,7 @@ Backend::evalVStrip(int n_left, REAL u_left, REAL* left_val,
*-------------------------------------------------------------------------
*/
void
Backend::bgntmesh( char * )
Backend::bgntmesh( const char * )
{
#ifndef NOWIREFRAME

View File

@@ -63,7 +63,7 @@ public:
void surfbbox( long, REAL *, REAL * );
void surfgrid( REAL, REAL, long, REAL, REAL, long );
void surfmesh( long, long, long, long );
void bgntmesh( char * );
void bgntmesh( const char * );
void endtmesh( void );
void swaptmesh( void );
void tmeshvert( GridTrimVertex * );

View File

@@ -46,7 +46,7 @@
* Pool - allocate a new pool of buffers
*-----------------------------------------------------------------------------
*/
Pool::Pool( int _buffersize, int initpoolsize, char *n )
Pool::Pool( int _buffersize, int initpoolsize, const char *n )
{
if((unsigned)_buffersize < sizeof(Buffer))
buffersize = sizeof(Buffer);

View File

@@ -53,7 +53,7 @@ class Buffer {
class Pool {
public:
Pool( int, int, char * );
Pool( int, int, const char * );
~Pool( void );
inline void* new_buffer( void );
inline void free_buffer( void * );
@@ -72,7 +72,7 @@ protected:
int nextfree; /* byte offset past next free buffer */
int initsize;
enum Magic { is_allocated = 0xf3a1, is_free = 0xf1a2 };
char *name; /* name of the pool */
const char *name; /* name of the pool */
Magic magic; /* marker for valid pool */
};

View File

@@ -126,7 +126,7 @@ int Knotvector::validate( void )
return 0;
}
void Knotvector::show( char *msg )
void Knotvector::show( const char *msg )
{
#ifndef NDEBUG
_glu_dprintf( "%s\n", msg );

View File

@@ -47,7 +47,7 @@ struct Knotvector { /* a knot vector */
~Knotvector( void );
void init( long, long, long, INREAL * );
int validate( void );
void show( char * );
void show( const char * );
long order; /* order of spline */
long knotcount; /* number of knots */

View File

@@ -675,7 +675,7 @@ NurbsTessellator::do_nurbserror( int msg )
}
int
NurbsTessellator::do_check_knots( Knotvector *knots, char *msg )
NurbsTessellator::do_check_knots( Knotvector *knots, const char *msg )
{
int status = knots->validate();
if( status ) {

View File

@@ -112,7 +112,7 @@ protected:
private:
void resetObjects( void );
int do_check_knots( Knotvector *, char * );
int do_check_knots( Knotvector *, const char * );
void do_nurbserror( int );
void do_bgncurve( O_curve * );
void do_endcurve( void );

View File

@@ -122,7 +122,7 @@ SRCS = \
glut_dstr.c \
glut_event.c \
glut_ext.c \
glut_fbc.c \
glut_fcb.c \
glut_fullscrn.c \
glut_gamemode.c \
glut_get.c \

View File

@@ -211,6 +211,9 @@ dri2GetBuffers(__DRIdrawable *driDrawable,
buffers = DRI2GetBuffers(pdraw->base.psc->dpy, pdraw->base.xDrawable,
width, height, attachments, count, out_count);
if (buffers == NULL)
return NULL;
pdraw->width = *width;
pdraw->height = *height;

View File

@@ -193,7 +193,13 @@ void __indirect_glGetVertexAttribivARB( GLuint index, GLenum pname,
get_vertex_attrib( gc, 1303, index, pname, (xReply *) & reply );
if ( reply.size != 0 ) {
if ( ! get_attrib_array_data( state, index, pname, params ) ) {
GLintptr data;
if ( get_attrib_array_data( state, index, pname, & data ) ) {
*params = (GLint) data;
}
else {
if (reply.size == 1) {
*params = (GLint) reply.pad3;
}

View File

@@ -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)); \

View File

@@ -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);
}
}

View File

@@ -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? */

View File

@@ -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;

View File

@@ -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;

View File

@@ -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,

View File

@@ -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);

View File

@@ -74,7 +74,6 @@ typedef struct
int drmMinor;
int irq_active;
int allow_batchbuffer;
GLboolean no_hw;

View File

@@ -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);

View File

@@ -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);
}
/**

View File

@@ -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"

View File

@@ -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);
}

View File

@@ -6797,6 +6797,11 @@ _mesa_EndList(void)
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);
/* Destroy old list, if any */
@@ -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;

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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.
*/
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;
}
if (attr == MAX_VERTEX_ATTRIBS) {
/* too many! XXX record error log */
return GL_FALSE;
}
_mesa_add_attribute(shProg->Attributes, name, size, datatype,attr);
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;
/* set the attribute as used */
usedAttributes |= 1<<attr;
/* See if there's a user-defined attribute binding for
* this name.
*/
index = _mesa_lookup_parameter_index(shProg->Attributes,
-1, name);
if (index >= 0) {
/* Found a user-defined binding */
attr = shProg->Attributes->Parameters[index].StateIndexes[0];
}
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);
}
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;
}
}

View File

@@ -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

View File

@@ -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; \
} \
}

View File

@@ -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);