From 2adef553f2549e30b4a1894e7f9077ac339ea61c Mon Sep 17 00:00:00 2001 From: Eric Anholt <eric@anholt.net> Date: Thu, 13 Nov 2008 18:32:44 -0800 Subject: i915: Don't overwrite i915's Viewport function from generic code. Instead, have i965 and i915 both call the generic function from their Viewport. --- src/mesa/drivers/dri/i915/intel_state.c | 2 ++ src/mesa/drivers/dri/i965/brw_context.c | 2 ++ src/mesa/drivers/dri/intel/intel_context.c | 8 +++++--- src/mesa/drivers/dri/intel/intel_context.h | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i915/intel_state.c b/src/mesa/drivers/dri/i915/intel_state.c index 09aa62da36..4aa43e5f3a 100644 --- a/src/mesa/drivers/dri/i915/intel_state.c +++ b/src/mesa/drivers/dri/i915/intel_state.c @@ -267,6 +267,8 @@ intelViewport(GLcontext * ctx, GLint x, GLint y, GLsizei width, GLsizei height) { intelCalcViewport(ctx); + + intel_viewport(ctx, x, y, width, height); } static void diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index e2bc08a6cb..1d6ac2cea6 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -71,6 +71,8 @@ static void brwInitDriverFunctions( struct dd_function_table *functions ) brwInitFragProgFuncs( functions ); brwInitProgFuncs( functions ); brw_init_queryobj_functions(functions); + + functions->Viewport = intel_viewport; } diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c index 9ac18e6960..6c625b428c 100644 --- a/src/mesa/drivers/dri/intel/intel_context.c +++ b/src/mesa/drivers/dri/intel/intel_context.c @@ -317,11 +317,13 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable) driUpdateFramebufferSize(&intel->ctx, drawable); } -static void +void intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) { struct intel_context *intel = intel_context(ctx); __DRIcontext *driContext = intel->driContext; + void (*old_viewport)(GLcontext *ctx, GLint x, GLint y, + GLsizei w, GLsizei h); if (!driContext->driScreenPriv->dri2.enabled) return; @@ -330,11 +332,12 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) if (driContext->driDrawablePriv != driContext->driReadablePriv) intel_update_renderbuffers(driContext, driContext->driReadablePriv); + old_viewport = ctx->Driver.Viewport; ctx->Driver.Viewport = NULL; intel->driDrawable = driContext->driDrawablePriv; intelWindowMoved(intel); intel_draw_buffer(ctx, intel->ctx.DrawBuffer); - ctx->Driver.Viewport = intel_viewport; + ctx->Driver.Viewport = old_viewport; } /** @@ -544,7 +547,6 @@ intelInitDriverFunctions(struct dd_function_table *functions) functions->Finish = intelFinish; functions->GetString = intelGetString; functions->UpdateState = intelInvalidateState; - functions->Viewport = intel_viewport; functions->CopyColorTable = _swrast_CopyColorTable; functions->CopyColorSubTable = _swrast_CopyColorSubTable; diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h index 3938af4c72..60028f090a 100644 --- a/src/mesa/drivers/dri/intel/intel_context.h +++ b/src/mesa/drivers/dri/intel/intel_context.h @@ -495,6 +495,9 @@ extern int intel_translate_stencil_op(GLenum op); extern int intel_translate_blend_factor(GLenum factor); extern int intel_translate_logic_op(GLenum opcode); +void intel_viewport(GLcontext * ctx, GLint x, GLint y, + GLsizei width, GLsizei height); + void intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable); -- cgit v1.2.3 From a6aa926e3f0b6237679db0d3331690d2a96adbc2 Mon Sep 17 00:00:00 2001 From: Eric Anholt <eric@anholt.net> Date: Fri, 21 Nov 2008 12:05:21 +0800 Subject: intel: Don't glBitmap fallback with scissoring enabled. The blit bitmap code already handles scissoring. This is a 15-100% speedup on blender benchmark.blend thanks to avoiding fallbacks. Bug #17951. --- src/mesa/drivers/dri/intel/intel_pixel.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_pixel.c b/src/mesa/drivers/dri/intel/intel_pixel.c index b267ffd890..5702ad9bb5 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel.c +++ b/src/mesa/drivers/dri/intel/intel_pixel.c @@ -112,12 +112,6 @@ intel_check_blit_fragment_ops(GLcontext * ctx, GLboolean src_alpha_is_one) return GL_FALSE; } - if (ctx->Scissor.Enabled) { - /* XXX Note: Scissor could be done with the blitter */ - DBG("fallback due to image scissor\n"); - return GL_FALSE; - } - if (ctx->RenderMode != GL_RENDER) { DBG("fallback due to render mode\n"); return GL_FALSE; -- cgit v1.2.3 From 3e0164aabb48a99fce58964cad99fd3978ee84f6 Mon Sep 17 00:00:00 2001 From: Eric Anholt <eric@anholt.net> Date: Fri, 21 Nov 2008 17:09:47 +0800 Subject: i965: Add support for accelerated CopyTexSubImage. There were hacks in EmitCopyBlit before to adjust offsets so that y=0 after the offsets had been adjusted for a negative pitch. It appears that those hacks were due to an unclear and surprising aspect of the hardware: inverting the pitch results in the blit into the specified rectangle being inverted, without the user needing to adjust y and base offset. Tested with piglit copytexsubimage test on 915GM and GM965. Should fix serious performance issues with ETQW and other applications. --- src/mesa/drivers/dri/intel/intel_blit.c | 64 +++++++++-------------------- src/mesa/drivers/dri/intel/intel_tex.c | 7 ---- src/mesa/drivers/dri/intel/intel_tex_copy.c | 38 +++++++++-------- 3 files changed, 41 insertions(+), 68 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index e1046f4a5d..ab12aae6c7 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -40,6 +40,7 @@ #include "intel_reg.h" #include "intel_regions.h" #include "intel_batchbuffer.h" +#include "intel_chipset.h" #define FILE_DEBUG_FLAG DEBUG_BLIT @@ -359,51 +360,24 @@ intelEmitCopyBlit(struct intel_context *intel, return; } - /* Initial y values don't seem to work with negative pitches. If - * we adjust the offsets manually (below), it seems to work fine. - * - * On the other hand, if we always adjust, the hardware doesn't - * know which blit directions to use, so overlapping copypixels get - * the wrong result. - */ - if (dst_pitch > 0 && src_pitch > 0) { - assert(dst_x < dst_x2); - assert(dst_y < dst_y2); - - BEGIN_BATCH(8, NO_LOOP_CLIPRECTS); - OUT_BATCH(CMD); - OUT_BATCH(BR13 | dst_pitch); - OUT_BATCH((dst_y << 16) | dst_x); - OUT_BATCH((dst_y2 << 16) | dst_x2); - OUT_RELOC(dst_buffer, - I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, - dst_offset); - OUT_BATCH((src_y << 16) | src_x); - OUT_BATCH(src_pitch); - OUT_RELOC(src_buffer, - I915_GEM_DOMAIN_RENDER, 0, - src_offset); - ADVANCE_BATCH(); - } - else { - assert(dst_x < dst_x2); - assert(h > 0); - - BEGIN_BATCH(8, NO_LOOP_CLIPRECTS); - OUT_BATCH(CMD); - OUT_BATCH(BR13 | ((uint16_t)dst_pitch)); - OUT_BATCH((0 << 16) | dst_x); - OUT_BATCH((h << 16) | dst_x2); - OUT_RELOC(dst_buffer, - I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, - dst_offset + dst_y * dst_pitch); - OUT_BATCH((0 << 16) | src_x); - OUT_BATCH(src_pitch); - OUT_RELOC(src_buffer, - I915_GEM_DOMAIN_RENDER, 0, - src_offset + src_y * src_pitch); - ADVANCE_BATCH(); - } + assert(dst_x < dst_x2); + assert(dst_y < dst_y2); + + BEGIN_BATCH(8, NO_LOOP_CLIPRECTS); + OUT_BATCH(CMD); + OUT_BATCH(BR13 | (uint16_t)dst_pitch); + OUT_BATCH((dst_y << 16) | dst_x); + OUT_BATCH((dst_y2 << 16) | dst_x2); + OUT_RELOC(dst_buffer, + I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, + dst_offset); + OUT_BATCH((src_y << 16) | src_x); + OUT_BATCH((uint16_t)src_pitch); + OUT_RELOC(src_buffer, + I915_GEM_DOMAIN_RENDER, 0, + src_offset); + ADVANCE_BATCH(); + intel_batchbuffer_emit_mi_flush(intel->batch); } diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c index 23455a4c74..82f8b87009 100644 --- a/src/mesa/drivers/dri/intel/intel_tex.c +++ b/src/mesa/drivers/dri/intel/intel_tex.c @@ -222,17 +222,10 @@ intelInitTextureFuncs(struct dd_function_table *functions) functions->TexSubImage1D = intelTexSubImage1D; functions->TexSubImage2D = intelTexSubImage2D; functions->TexSubImage3D = intelTexSubImage3D; -#ifdef I915 functions->CopyTexImage1D = intelCopyTexImage1D; functions->CopyTexImage2D = intelCopyTexImage2D; functions->CopyTexSubImage1D = intelCopyTexSubImage1D; functions->CopyTexSubImage2D = intelCopyTexSubImage2D; -#else - functions->CopyTexImage1D = _swrast_copy_teximage1d; - functions->CopyTexImage2D = _swrast_copy_teximage2d; - functions->CopyTexSubImage1D = _swrast_copy_texsubimage1d; - functions->CopyTexSubImage2D = _swrast_copy_texsubimage2d; -#endif functions->GetTexImage = intelGetTexImage; functions->GenerateMipmap = intelGenerateMipmap; diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c index f4cb4a781c..36446efde7 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_copy.c +++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c @@ -114,43 +114,49 @@ do_copy_texsubimage(struct intel_context *intel, if (_mesa_clip_to_region(fb->_Xmin, fb->_Ymin, fb->_Xmax, fb->_Ymax, &x, &y, &width, &height)) { + GLshort src_pitch; + /* Update dst for clipped src. Need to also clip the source rect. */ dstx += x - orig_x; dsty += y - orig_y; + /* image_offset may be non-page-aligned, but that's illegal for tiling. + */ + assert(intelImage->mt->region->tiling == I915_TILING_NONE); + if (ctx->ReadBuffer->Name == 0) { /* reading from a window, adjust x, y */ __DRIdrawablePrivate *dPriv = intel->driDrawable; - GLuint window_y; - /* window_y = position of window on screen if y=0=bottom */ - window_y = intel->intelScreen->height - (dPriv->y + dPriv->h); - y = window_y + y; + y = dPriv->y + (dPriv->h - (y + height)); x += dPriv->x; + + /* Invert the data coming from the source rectangle due to GL + * and hardware disagreeing on where y=0 is. + * + * It appears that our offsets and pitches get mangled + * appropriately by the hardware, and we don't need to adjust them + * on our own. + */ + src_pitch = -src->pitch; } else { - /* reading from a FBO */ - /* invert Y */ - y = ctx->ReadBuffer->Height - y - 1; + /* reading from a FBO, y is already oriented the way we like */ + src_pitch = src->pitch; } - - /* A bit of fiddling to get the blitter to work with -ve - * pitches. But we get a nice inverted blit this way, so it's - * worth it: - */ intelEmitCopyBlit(intel, intelImage->mt->cpp, - -src->pitch, + src_pitch, src->buffer, - src->height * src->pitch * src->cpp, + 0, src->tiling, intelImage->mt->pitch, intelImage->mt->region->buffer, image_offset, intelImage->mt->region->tiling, - x, y + height, dstx, dsty, width, height, - GL_COPY); /* ? */ + x, y, dstx, dsty, width, height, + GL_COPY); } } -- cgit v1.2.3 From c45c5c4ca42c29ab73e89449a41a843c24fbe159 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Fri, 21 Nov 2008 10:03:19 -0700 Subject: added progs/demos/fragcoord.c - tests gl_FragCoord attribute in fragment shader Fragment's red/greenb/blue is a function gl_FragCoord.xyz --- progs/glsl/Makefile | 8 +++ progs/glsl/fragcoord.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 193 insertions(+) create mode 100644 progs/glsl/fragcoord.c diff --git a/progs/glsl/Makefile b/progs/glsl/Makefile index 41d5849919..7c3e750882 100644 --- a/progs/glsl/Makefile +++ b/progs/glsl/Makefile @@ -15,6 +15,7 @@ PROGS = \ bump \ convolutions \ deriv \ + fragcoord \ mandelbrot \ multitex \ noise \ @@ -106,6 +107,13 @@ deriv: deriv.o shaderutil.o $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) deriv.o shaderutil.o $(LIBS) -o $@ +fragcoord.o: fragcoord.c extfuncs.h shaderutil.h + $(CC) -c -I$(INCDIR) $(CFLAGS) fragcoord.c + +fragcoord: fragcoord.o shaderutil.o + $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) fragcoord.o shaderutil.o $(LIBS) -o $@ + + mandelbrot.o: mandelbrot.c extfuncs.h shaderutil.h $(CC) -c -I$(INCDIR) $(CFLAGS) mandelbrot.c diff --git a/progs/glsl/fragcoord.c b/progs/glsl/fragcoord.c new file mode 100644 index 0000000000..0b7561f3e4 --- /dev/null +++ b/progs/glsl/fragcoord.c @@ -0,0 +1,185 @@ +/** + * Test GLSL gl_FragCoord fragment program attribute. + * Color the quad's fragments according to their window position. + * + * Brian Paul + * 20 Nov 2008 + */ + + +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/gl.h> +#include <GL/glut.h> +#include <GL/glext.h> +#include "extfuncs.h" +#include "shaderutil.h" + + +static GLint WinWidth = 200, WinHeight = 200; +static char *FragProgFile = NULL; +static char *VertProgFile = NULL; +static GLuint fragShader; +static GLuint vertShader; +static GLuint program; +static GLint win = 0; +static GLboolean Anim = GL_TRUE; +static GLfloat PosX = 0.0, PosY = 0.0; + + +static void +Idle(void) +{ + float r = (WinWidth < WinHeight) ? WinWidth : WinHeight; + float a = glutGet(GLUT_ELAPSED_TIME) * 0.001; + r *= 0.25; + PosX = WinWidth / 2 + r * cos(a); + PosY = WinHeight / 2 + r * sin(a); + + glutPostRedisplay(); +} + + +static void +Redisplay(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + glTranslatef(PosX, PosY, 0.0); +#if 0 + glBegin(GL_POLYGON); + glVertex2f(-50, -50); + glVertex2f( 50, -50); + glVertex2f( 50, 50); + glVertex2f(-50, 50); + glEnd(); +#else + glutSolidSphere(50, 20, 10); +#endif + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, width, 0, height, -55, 55); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + WinWidth = width; + WinHeight = height; +} + + +static void +CleanUp(void) +{ + glDeleteShader_func(fragShader); + glDeleteShader_func(vertShader); + glDeleteProgram_func(program); + glutDestroyWindow(win); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + + switch(key) { + case ' ': + case 'a': + Anim = !Anim; + glutIdleFunc(Anim ? Idle : NULL); + break; + case 27: + CleanUp(); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +Init(void) +{ + static const char *fragShaderText = + "void main() { \n" + " vec4 scale = vec4(.005, 0.005, 0.5, 1.0);\n" + " gl_FragColor = gl_FragCoord * scale; \n" + "}\n"; + static const char *vertShaderText = + "void main() {\n" + " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" + "}\n"; + + if (!ShadersSupported()) + exit(1); + + GetExtensionFuncs(); + + vertShader = CompileShaderText(GL_VERTEX_SHADER, vertShaderText); + fragShader = CompileShaderText(GL_FRAGMENT_SHADER, fragShaderText); + program = LinkShaders(vertShader, fragShader); + + glUseProgram_func(program); + + /*assert(glGetError() == 0);*/ + + glClearColor(0.3f, 0.3f, 0.3f, 0.0f); + + printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); + + assert(glIsProgram_func(program)); + assert(glIsShader_func(fragShader)); + assert(glIsShader_func(vertShader)); + + glColor3f(1, 0, 0); +} + + +static void +ParseOptions(int argc, char *argv[]) +{ + int i; + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-fs") == 0) { + FragProgFile = argv[i+1]; + } + else if (strcmp(argv[i], "-vs") == 0) { + VertProgFile = argv[i+1]; + } + } +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition( 0, 0); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + win = glutCreateWindow(argv[0]); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Redisplay); + ParseOptions(argc, argv); + Init(); + glutIdleFunc(Anim ? Idle : NULL); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From b63a31b36f2e1a198c214f41e0518991b1a8fa49 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Fri, 21 Nov 2008 14:24:28 -0700 Subject: mesa: better variable name: s/aux/store/ --- src/mesa/shader/slang/slang_codegen.c | 14 +++++++------- src/mesa/shader/slang/slang_compile_variable.c | 2 +- src/mesa/shader/slang/slang_compile_variable.h | 5 ++++- src/mesa/shader/slang/slang_emit.c | 2 +- src/mesa/shader/slang/slang_vartable.c | 4 ++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 851335d9c5..882a6534e5 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -238,9 +238,9 @@ _slang_attach_storage(slang_ir_node *n, slang_variable *var) if (!n->Store) { /* need to setup storage */ - if (n->Var && n->Var->aux) { + if (n->Var && n->Var->store) { /* node storage info = var storage info */ - n->Store = (slang_ir_storage *) n->Var->aux; + n->Store = n->Var->store; } else { /* alloc new storage info */ @@ -251,8 +251,8 @@ _slang_attach_storage(slang_ir_node *n, slang_variable *var) (void*) n->Store, n->Store->Size); #endif if (n->Var) - n->Var->aux = n->Store; - assert(n->Var->aux); + n->Var->store = n->Store; + assert(n->Var->store); } } } @@ -2430,8 +2430,8 @@ _slang_gen_var_decl(slang_assemble_ctx *A, slang_variable *var) n = new_node0(IR_VAR_DECL); if (n) { _slang_attach_storage(n, var); - assert(var->aux); - assert(n->Store == var->aux); + assert(var->store); + assert(n->Store == var->store); assert(n->Store); assert(n->Store->Index < 0); @@ -3890,7 +3890,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, store ? store->Index : -2); if (store) - var->aux = store; /* save var's storage info */ + var->store = store; /* save var's storage info */ var->declared = GL_TRUE; diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index 3428b49e16..37fb2eedb1 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -266,7 +266,7 @@ slang_variable_construct(slang_variable * var) var->address = ~0; var->size = 0; var->isTemp = GL_FALSE; - var->aux = NULL; + var->store = NULL; var->declared = 0; return 1; } diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h index c6db16fcfa..8e30728ab8 100644 --- a/src/mesa/shader/slang/slang_compile_variable.h +++ b/src/mesa/shader/slang/slang_compile_variable.h @@ -30,6 +30,9 @@ extern "C" { #endif +struct slang_ir_storage_; + + typedef enum slang_type_variant_ { SLANG_VARIANT, /* the default */ @@ -107,7 +110,7 @@ typedef struct slang_variable_ GLuint size; /**< Variable's size in bytes */ GLboolean isTemp; /**< a named temporary (__resultTmp) */ GLboolean declared; /**< for debug */ - void *aux; /**< Used during code gen */ + struct slang_ir_storage_ *store; /**< Storage for this var */ } slang_variable; diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c index 0a3ab39eb1..f31e9b4e6c 100644 --- a/src/mesa/shader/slang/slang_emit.c +++ b/src/mesa/shader/slang/slang_emit.c @@ -2025,7 +2025,7 @@ emit_var_decl(slang_emit_info *emitInfo, slang_ir_node *n) printf("IR_VAR_DECL %s %d store %p\n", (char*) n->Var->a_name, n->Store->Index, (void*) n->Store); */ - assert(n->Var->aux == n->Store); + assert(n->Var->store == n->Store); } if (emitInfo->EmitComments) { /* emit NOP with comment describing the variable's storage location */ diff --git a/src/mesa/shader/slang/slang_vartable.c b/src/mesa/shader/slang/slang_vartable.c index 95971a70a9..de0c93957b 100644 --- a/src/mesa/shader/slang/slang_vartable.c +++ b/src/mesa/shader/slang/slang_vartable.c @@ -107,7 +107,7 @@ _slang_pop_var_table(slang_var_table *vt) /* free the storage allocated for each variable */ for (i = 0; i < t->NumVars; i++) { - slang_ir_storage *store = (slang_ir_storage *) t->Vars[i]->aux; + slang_ir_storage *store = t->Vars[i]->store; GLint j; GLuint comp; if (dbg) printf(" Free var %s, size %d at %d.%s\n", @@ -165,7 +165,7 @@ _slang_add_variable(slang_var_table *vt, slang_variable *v) assert(vt); t = vt->Top; assert(t); - if (dbg) printf("Adding var %s, store %p\n", (char *) v->a_name, v->aux); + if (dbg) printf("Adding var %s, store %p\n", (char *) v->a_name, (void *) v->store); t->Vars = (slang_variable **) _slang_realloc(t->Vars, t->NumVars * sizeof(slang_variable *), -- cgit v1.2.3 From 4f05893415a2d6f29b29f4daf991ea95a1891a81 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Fri, 21 Nov 2008 17:22:16 -0700 Subject: mesa: issue error, don't crash, when calling a prototyped, but undefined function Bug #18659. --- src/mesa/shader/slang/slang_codegen.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 882a6534e5..0dacfee1da 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -2020,6 +2020,13 @@ _slang_gen_function_call_name(slang_assemble_ctx *A, const char *name, name); return NULL; } + if (!fun->body) { + slang_info_log_error(A->log, + "Function '%s' prototyped but not defined. " + "Separate compilation units not supported.", + name); + return NULL; + } n = _slang_gen_function_call(A, fun, oper, dest); -- cgit v1.2.3 From 54646678742dc45a382387c8ac2ef95b474a847e Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 08:14:28 -0700 Subject: docs: update webmaster email addr --- docs/webmaster.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/webmaster.html b/docs/webmaster.html index e645b90ba1..16f4dc8030 100644 --- a/docs/webmaster.html +++ b/docs/webmaster.html @@ -11,7 +11,7 @@ <p> If you have problems, edits or additions for this website send them to Brian -(<em>b</em><em>r</em><em>i</em><em>a</em><em>n</em><em>_</em><em>e</em><em>_</em><em>p</em><em>a</em><em>u</em><em>l</em><em>@</em><em>y</em><em>a</em><em>h</em><em>o</em><em>o</em><em>.</em><em>c</em><em>o</em><em>m</em>)</a>. +(<em>b</em><em>r</em><em>i</em><em>a</em><em>n</em><em>.</em><em>e</em><em>.</em><em>p</em><em>a</em><em>u</em><em>l</em><em> </em><em>g</em><em>m</em><em>a</em><em>i</em><em>l</em><em>.</em><em>c</em><em>o</em><em>m</em>)</a>. </p> <p> @@ -21,4 +21,4 @@ Brian's modified it a lot since then. </body> -</html> \ No newline at end of file +</html> -- cgit v1.2.3 From 0f228d7ab3b7c03328df369b8db50c469ac5dcd6 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 08:33:49 -0700 Subject: mesa: add Flags field to gl_program_parameter Only one flag defined so far: PROG_PARAM_CENTROID_BIT --- src/mesa/shader/prog_parameter.c | 31 +++++++++++++++++-------------- src/mesa/shader/prog_parameter.h | 24 ++++++++++++++++-------- src/mesa/shader/slang/slang_codegen.c | 4 +++- src/mesa/shader/slang/slang_link.c | 3 ++- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index 29c5b33f6c..3a36b05a0f 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.3 * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-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"), @@ -80,7 +80,8 @@ GLint _mesa_add_parameter(struct gl_program_parameter_list *paramList, enum register_file type, const char *name, GLuint size, GLenum datatype, const GLfloat *values, - const gl_state_index state[STATE_LENGTH]) + const gl_state_index state[STATE_LENGTH], + GLbitfield flags) { const GLuint oldNum = paramList->NumParameters; const GLuint sz4 = (size + 3) / 4; /* no. of new param slots needed */ @@ -125,6 +126,7 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, p->Type = type; p->Size = size; p->DataType = datatype; + p->Flags = flags; if (values) { COPY_4V(paramList->ParameterValues[oldNum + i], values); values += 4; @@ -156,7 +158,7 @@ _mesa_add_named_parameter(struct gl_program_parameter_list *paramList, const char *name, const GLfloat values[4]) { return _mesa_add_parameter(paramList, PROGRAM_NAMED_PARAM, name, - 4, GL_NONE, values, NULL); + 4, GL_NONE, values, NULL, 0x0); } @@ -187,7 +189,7 @@ _mesa_add_named_constant(struct gl_program_parameter_list *paramList, #endif size = 4; /** XXX fix */ return _mesa_add_parameter(paramList, PROGRAM_CONSTANT, name, - size, GL_NONE, values, NULL); + size, GL_NONE, values, NULL, 0x0); } @@ -239,7 +241,7 @@ _mesa_add_unnamed_constant(struct gl_program_parameter_list *paramList, /* add a new parameter to store this constant */ pos = _mesa_add_parameter(paramList, PROGRAM_CONSTANT, NULL, - size, GL_NONE, values, NULL); + size, GL_NONE, values, NULL, 0x0); if (pos >= 0 && swizzleOut) { if (size == 1) *swizzleOut = SWIZZLE_XXXX; @@ -273,7 +275,7 @@ _mesa_add_uniform(struct gl_program_parameter_list *paramList, } else { i = _mesa_add_parameter(paramList, PROGRAM_UNIFORM, name, - size, datatype, values, NULL); + size, datatype, values, NULL, 0x0); return i; } } @@ -328,7 +330,7 @@ _mesa_add_sampler(struct gl_program_parameter_list *paramList, } value = (GLfloat) numSamplers; (void) _mesa_add_parameter(paramList, PROGRAM_SAMPLER, name, - size, datatype, &value, NULL); + size, datatype, &value, NULL, 0x0); return numSamplers; } } @@ -339,7 +341,7 @@ _mesa_add_sampler(struct gl_program_parameter_list *paramList, */ GLint _mesa_add_varying(struct gl_program_parameter_list *paramList, - const char *name, GLuint size) + const char *name, GLuint size, GLbitfield flags) { GLint i = _mesa_lookup_parameter_index(paramList, -1, name); if (i >= 0 && paramList->Parameters[i].Type == PROGRAM_VARYING) { @@ -349,7 +351,7 @@ _mesa_add_varying(struct gl_program_parameter_list *paramList, else { /*assert(size == 4);*/ i = _mesa_add_parameter(paramList, PROGRAM_VARYING, name, - size, GL_NONE, NULL, NULL); + size, GL_NONE, NULL, NULL, flags); return i; } } @@ -378,7 +380,7 @@ _mesa_add_attribute(struct gl_program_parameter_list *paramList, if (size < 0) size = 4; i = _mesa_add_parameter(paramList, PROGRAM_INPUT, name, - size, datatype, NULL, state); + size, datatype, NULL, state, 0x0); } return i; } @@ -445,7 +447,7 @@ _mesa_add_state_reference(struct gl_program_parameter_list *paramList, name = _mesa_program_state_string(stateTokens); index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name, size, GL_NONE, - NULL, (gl_state_index *) stateTokens); + NULL, (gl_state_index *) stateTokens, 0x0); paramList->StateFlags |= _mesa_program_state_flags(stateTokens); /* free name string here since we duplicated it in add_parameter() */ @@ -616,7 +618,7 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list) struct gl_program_parameter *pCopy; GLuint size = MIN2(p->Size, 4); GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType, - list->ParameterValues[i], NULL); + list->ParameterValues[i], NULL, 0x0); ASSERT(j >= 0); pCopy = clone->Parameters + j; pCopy->Used = p->Used; @@ -657,7 +659,8 @@ _mesa_combine_parameter_lists(const struct gl_program_parameter_list *listA, _mesa_add_parameter(list, param->Type, param->Name, param->Size, param->DataType, listB->ParameterValues[i], - param->StateIndexes); + param->StateIndexes, + param->Flags); } } } diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h index 0c35198de7..829fd25d55 100644 --- a/src/mesa/shader/prog_parameter.h +++ b/src/mesa/shader/prog_parameter.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.3 * - * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * Copyright (C) 1999-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"), @@ -35,12 +35,18 @@ #include "prog_statevars.h" +/** + * Program parameter flags + */ +/*@{*/ +#define PROG_PARAM_CENTROID_BIT 0x1 +/*@}*/ + + + /** * Program parameter. - * Used for NV_fragment_program for "DEFINE"d constants and "DECLARE"d - * parameters. - * Also used by ARB_vertex/fragment_programs for state variables, etc. - * Used by shaders for uniforms, constants, varying vars, etc. + * Used by shaders/programs for uniforms, constants, varying vars, etc. */ struct gl_program_parameter { @@ -50,6 +56,7 @@ struct gl_program_parameter GLuint Size; /**< Number of components (1..4) */ GLboolean Used; /**< Helper flag for GLSL uniform tracking */ GLboolean Initialized; /**< Has the ParameterValue[] been set? */ + GLbitfield Flags; /**< Bitmask of PROG_PARAM_*_BIT */ /** * A sequence of STATE_* tokens and integers to identify GL state. */ @@ -94,7 +101,8 @@ extern GLint _mesa_add_parameter(struct gl_program_parameter_list *paramList, enum register_file type, const char *name, GLuint size, GLenum datatype, const GLfloat *values, - const gl_state_index state[STATE_LENGTH]); + const gl_state_index state[STATE_LENGTH], + GLbitfield flags); extern GLint _mesa_add_named_parameter(struct gl_program_parameter_list *paramList, @@ -125,7 +133,7 @@ _mesa_add_sampler(struct gl_program_parameter_list *paramList, extern GLint _mesa_add_varying(struct gl_program_parameter_list *paramList, - const char *name, GLuint size); + const char *name, GLuint size, GLbitfield flags); extern GLint _mesa_add_attribute(struct gl_program_parameter_list *paramList, diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index 0dacfee1da..dc5fbf5c4a 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3779,7 +3779,9 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, if (prog) { /* user-defined varying */ - GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, totalSize); + GLbitfield flags = 0x0; + GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, + totalSize, flags); GLuint swizzle = _slang_var_swizzle(size, 0); store = _slang_new_ir_storage_swz(PROGRAM_VARYING, varyingLoc, totalSize, swizzle); diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 79fd9a064f..fcd7fbf3ca 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -103,7 +103,8 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog) } else { /* not already in linked list */ - j = _mesa_add_varying(shProg->Varying, var->Name, var->Size); + j = _mesa_add_varying(shProg->Varying, var->Name, var->Size, + var->Flags); } /* map varying[i] to varying[j]. -- cgit v1.2.3 From 777a5c4f2e7c6c6ec0227a239b1af6c6b86dfab2 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 08:43:38 -0700 Subject: mesa: added PROG_PARAM_ bits for invariant, flat/linear interpolation Plus, update the print/debug code. --- src/mesa/shader/prog_parameter.h | 5 ++++- src/mesa/shader/prog_print.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h index 829fd25d55..a8ef0561f7 100644 --- a/src/mesa/shader/prog_parameter.h +++ b/src/mesa/shader/prog_parameter.h @@ -39,7 +39,10 @@ * Program parameter flags */ /*@{*/ -#define PROG_PARAM_CENTROID_BIT 0x1 +#define PROG_PARAM_CENTROID_BIT 0x1 /**< for varying vars (GLSL 1.20) */ +#define PROG_PARAM_INVARIANT_BIT 0x2 /**< for varying vars (GLSL 1.20) */ +#define PROG_PARAM_FLAT_BIT 0x4 /**< for varying vars (GLSL 1.30) */ +#define PROG_PARAM_LINEAR_BIT 0x8 /**< for varying vars (GLSL 1.30) */ /*@}*/ diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index baa4ef85e9..ded79b4959 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -799,9 +799,18 @@ _mesa_print_parameter_list(const struct gl_program_parameter_list *list) for (i = 0; i < list->NumParameters; i++){ struct gl_program_parameter *param = list->Parameters + i; const GLfloat *v = list->ParameterValues[i]; - _mesa_printf("param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g};\n", + _mesa_printf("param[%d] sz=%d %s %s = {%.3g, %.3g, %.3g, %.3g}", i, param->Size, file_string(list->Parameters[i].Type, mode), param->Name, v[0], v[1], v[2], v[3]); + if (param->Flags & PROG_PARAM_CENTROID_BIT) + _mesa_printf(" Centroid"); + if (param->Flags & PROG_PARAM_INVARIANT_BIT) + _mesa_printf(" Invariant"); + if (param->Flags & PROG_PARAM_FLAT_BIT) + _mesa_printf(" Flat"); + if (param->Flags & PROG_PARAM_LINEAR_BIT) + _mesa_printf(" Linear"); + _mesa_printf("\n"); } } -- cgit v1.2.3 From 3f6668a4bf28109eb806be019fb235663572b7da Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 09:03:47 -0700 Subject: mesa: dump/debug varying vars list --- src/mesa/shader/slang/slang_link.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index fcd7fbf3ca..aaa8859a63 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -606,6 +606,11 @@ _slang_link(GLcontext *ctx, } } + if (MESA_VERBOSE & VERBOSE_GLSL_DUMP) { + printf("Varying vars:\n"); + _mesa_print_parameter_list(shProg->Varying); + } + shProg->LinkStatus = (shProg->VertexProgram || shProg->FragmentProgram); } -- cgit v1.2.3 From 08b825a77179a9e7ed902c9c57387f127cd007bc Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 09:04:11 -0700 Subject: mesa: copy Flags in _mesa_clone_parameter_list() --- src/mesa/shader/prog_parameter.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/shader/prog_parameter.c b/src/mesa/shader/prog_parameter.c index 3a36b05a0f..32f8860a14 100644 --- a/src/mesa/shader/prog_parameter.c +++ b/src/mesa/shader/prog_parameter.c @@ -622,6 +622,7 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list) ASSERT(j >= 0); pCopy = clone->Parameters + j; pCopy->Used = p->Used; + pCopy->Flags = p->Flags; /* copy state indexes */ if (p->Type == PROGRAM_STATE_VAR) { GLint k; -- cgit v1.2.3 From f490ec9797a396da9d182f1ad4393f1c5c2df440 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 09:04:52 -0700 Subject: mesa: rename program parameter flags to match other Mesa conventions --- src/mesa/shader/prog_parameter.h | 8 ++++---- src/mesa/shader/prog_print.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mesa/shader/prog_parameter.h b/src/mesa/shader/prog_parameter.h index a8ef0561f7..200f2c0045 100644 --- a/src/mesa/shader/prog_parameter.h +++ b/src/mesa/shader/prog_parameter.h @@ -39,10 +39,10 @@ * Program parameter flags */ /*@{*/ -#define PROG_PARAM_CENTROID_BIT 0x1 /**< for varying vars (GLSL 1.20) */ -#define PROG_PARAM_INVARIANT_BIT 0x2 /**< for varying vars (GLSL 1.20) */ -#define PROG_PARAM_FLAT_BIT 0x4 /**< for varying vars (GLSL 1.30) */ -#define PROG_PARAM_LINEAR_BIT 0x8 /**< for varying vars (GLSL 1.30) */ +#define PROG_PARAM_BIT_CENTROID 0x1 /**< for varying vars (GLSL 1.20) */ +#define PROG_PARAM_BIT_INVARIANT 0x2 /**< for varying vars (GLSL 1.20) */ +#define PROG_PARAM_BIT_FLAT 0x4 /**< for varying vars (GLSL 1.30) */ +#define PROG_PARAM_BIT_LINEAR 0x8 /**< for varying vars (GLSL 1.30) */ /*@}*/ diff --git a/src/mesa/shader/prog_print.c b/src/mesa/shader/prog_print.c index ded79b4959..9215ed7abf 100644 --- a/src/mesa/shader/prog_print.c +++ b/src/mesa/shader/prog_print.c @@ -803,13 +803,13 @@ _mesa_print_parameter_list(const struct gl_program_parameter_list *list) i, param->Size, file_string(list->Parameters[i].Type, mode), param->Name, v[0], v[1], v[2], v[3]); - if (param->Flags & PROG_PARAM_CENTROID_BIT) + if (param->Flags & PROG_PARAM_BIT_CENTROID) _mesa_printf(" Centroid"); - if (param->Flags & PROG_PARAM_INVARIANT_BIT) + if (param->Flags & PROG_PARAM_BIT_INVARIANT) _mesa_printf(" Invariant"); - if (param->Flags & PROG_PARAM_FLAT_BIT) + if (param->Flags & PROG_PARAM_BIT_FLAT) _mesa_printf(" Flat"); - if (param->Flags & PROG_PARAM_LINEAR_BIT) + if (param->Flags & PROG_PARAM_BIT_LINEAR) _mesa_printf(" Linear"); _mesa_printf("\n"); } -- cgit v1.2.3 From 3197954554bfc492283c7db009d10ab408664cad Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 09:05:49 -0700 Subject: mesa: set flags for varying vars --- src/mesa/shader/slang/slang_codegen.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c index dc5fbf5c4a..f2cb75f872 100644 --- a/src/mesa/shader/slang/slang_codegen.c +++ b/src/mesa/shader/slang/slang_codegen.c @@ -3779,10 +3779,19 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, if (prog) { /* user-defined varying */ - GLbitfield flags = 0x0; - GLint varyingLoc = _mesa_add_varying(prog->Varying, varName, - totalSize, flags); - GLuint swizzle = _slang_var_swizzle(size, 0); + GLbitfield flags; + GLint varyingLoc; + GLuint swizzle; + + flags = 0x0; + if (var->type.centroid == SLANG_CENTROID) + flags |= PROG_PARAM_BIT_CENTROID; + if (var->type.variant == SLANG_INVARIANT) + flags |= PROG_PARAM_BIT_INVARIANT; + + varyingLoc = _mesa_add_varying(prog->Varying, varName, + totalSize, flags); + swizzle = _slang_var_swizzle(size, 0); store = _slang_new_ir_storage_swz(PROGRAM_VARYING, varyingLoc, totalSize, swizzle); } -- cgit v1.2.3 From 0e2f757413a68f0edb6643ea23ad8d879d077f11 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 09:13:14 -0700 Subject: mesa: copy precision/variant/centroid info in slang_fully_specified_type_copy() --- src/mesa/shader/slang/slang_compile_variable.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c index 37fb2eedb1..abe9c55d79 100644 --- a/src/mesa/shader/slang/slang_compile_variable.c +++ b/src/mesa/shader/slang/slang_compile_variable.c @@ -122,6 +122,9 @@ slang_fully_specified_type_copy(slang_fully_specified_type * x, if (!slang_fully_specified_type_construct(&z)) return 0; z.qualifier = y->qualifier; + z.precision = y->precision; + z.variant = y->variant; + z.centroid = y->centroid; if (!slang_type_specifier_copy(&z.specifier, &y->specifier)) { slang_fully_specified_type_destruct(&z); return 0; -- cgit v1.2.3 From dc1107c08d0ccbeeb063f2e46be598f16cbe9f21 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 09:25:05 -0700 Subject: mesa: check that varying variable qualifiers agree --- src/mesa/shader/slang/slang_link.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index aaa8859a63..6b895013af 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -75,6 +75,16 @@ link_error(struct gl_shader_program *shProg, const char *msg) +/** + * Check if the given bit is either set or clear in both bitfields. + */ +static GLboolean +bits_agree(GLbitfield flags1, GLbitfield flags2, GLbitfield bit) +{ + return (flags1 & bit) == (flags2 & bit); +} + + /** * Linking varying vars involves rearranging varying vars so that the * vertex program's output varyings matches the order of the fragment @@ -94,12 +104,27 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog) const struct gl_program_parameter *var = prog->Varying->Parameters + i; GLint j = _mesa_lookup_parameter_index(shProg->Varying, -1, var->Name); if (j >= 0) { - /* already in list, check size */ - if (var->Size != shProg->Varying->Parameters[j].Size) { - /* error */ + /* varying is already in list, do some error checking */ + const struct gl_program_parameter *v = + &shProg->Varying->Parameters[j]; + if (var->Size != v->Size) { link_error(shProg, "mismatched varying variable types"); return GL_FALSE; } + if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_CENTROID)) { + char msg[100]; + snprintf(msg, sizeof(msg), + "centroid modifier mismatch for '%s'", var->Name); + link_error(shProg, msg); + return GL_FALSE; + } + if (!bits_agree(var->Flags, v->Flags, PROG_PARAM_BIT_INVARIANT)) { + char msg[100]; + snprintf(msg, sizeof(msg), + "invariant modifier mismatch for '%s'", var->Name); + link_error(shProg, msg); + return GL_FALSE; + } } else { /* not already in linked list */ -- cgit v1.2.3 From a2037137385671c0673d1de6eb1c36dbd3cd78f3 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 09:28:25 -0700 Subject: mesa: copy centroid/invariance/precision info in parse_init_declarator() --- src/mesa/shader/slang/slang_compile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index 07c40eaa32..f684f6cc1d 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -1799,8 +1799,11 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O, RETURN0; } - /* copy the declarator qualifier type, parse the identifier */ + /* copy the declarator type qualifier/etc info, parse the identifier */ var->type.qualifier = type->qualifier; + var->type.centroid = type->centroid; + var->type.precision = type->precision; + var->type.variant = type->variant; var->a_name = a_name; if (var->a_name == SLANG_ATOM_NULL) RETURN0; -- cgit v1.2.3 From 153cc70ddb52a2acc5a4790adc6d7a7b2ddf0d43 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 11:10:58 -0700 Subject: windows: replace free() with _mesa_unreference_framebuffer() Fixes invalid memory reference bug when exiting. --- src/mesa/drivers/windows/gdi/wmesa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 9dafb74723..1ddea33e35 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -60,7 +60,7 @@ wmesa_free_framebuffer(HDC hdc) FirstFramebuffer = pwfb->next; else prev->next = pwfb->next; - free(pwfb); + _mesa_unreference_framebuffer(&pwfb->Base); } } -- cgit v1.2.3 From d52e8543b61ec5b8b8d9b1574a28ae2472fe4c56 Mon Sep 17 00:00:00 2001 From: Bernd Buschinski <b.buschinski@web.de> Date: Mon, 24 Nov 2008 11:39:07 -0800 Subject: glx: Add missing include for XCB, fixing crash on 64-bit. Bug #18689 --- src/glx/x11/single2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/glx/x11/single2.c b/src/glx/x11/single2.c index b008c6996c..83a2505222 100644 --- a/src/glx/x11/single2.c +++ b/src/glx/x11/single2.c @@ -40,6 +40,7 @@ #ifdef USE_XCB #include <xcb/xcb.h> #include <xcb/glx.h> +#include <X11/Xlib-xcb.h> #endif /* USE_XCB */ -- cgit v1.2.3 From b730d0d3e9b202b17a0815cb820fc9905f35cb98 Mon Sep 17 00:00:00 2001 From: Brian Paul <brian.paul@tungstengraphics.com> Date: Mon, 24 Nov 2008 13:04:04 -0700 Subject: mesa: add gl_program::Input/OutputFlags[] array These arrays will indicate per-input or per-output options for vertex/fragment programs such as centroid-sampling and invariance. --- src/mesa/main/config.h | 2 ++ src/mesa/main/mtypes.h | 3 +++ src/mesa/shader/prog_execute.h | 6 ++---- src/mesa/shader/slang/slang_link.c | 42 +++++++++++++++++++++++--------------- 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/mesa/main/config.h b/src/mesa/main/config.h index 882e2f224a..f1f12b8a0e 100644 --- a/src/mesa/main/config.h +++ b/src/mesa/main/config.h @@ -193,6 +193,8 @@ #define MAX_UNIFORMS 128 /**< number of float components */ #define MAX_VARYING 8 /**< number of float[4] vectors */ #define MAX_SAMPLERS 8 +#define MAX_PROGRAM_INPUTS 32 +#define MAX_PROGRAM_OUTPUTS 32 /*@}*/ /** For GL_NV_vertex_program */ diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 284f81b7cf..9b40d8fb6c 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1873,10 +1873,13 @@ struct gl_program GLbitfield InputsRead; /**< Bitmask of which input regs are read */ GLbitfield OutputsWritten; /**< Bitmask of which output regs are written to */ + GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */ + GLbitfield OutputFlags[MAX_PROGRAM_OUTPUTS]; /**< PROG_PARAM_BIT_x flags */ GLbitfield TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_BIT bitmask */ GLbitfield SamplersUsed; /**< Bitfield of which samplers are used */ GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ + /** Named parameters, constants, etc. from program text */ struct gl_program_parameter_list *Parameters; /** Numbered local parameters */ diff --git a/src/mesa/shader/prog_execute.h b/src/mesa/shader/prog_execute.h index 18b13e11a4..8ceb7b092e 100644 --- a/src/mesa/shader/prog_execute.h +++ b/src/mesa/shader/prog_execute.h @@ -25,6 +25,8 @@ #ifndef PROG_EXECUTE_H #define PROG_EXECUTE_H +#include "main/config.h" + typedef void (*FetchTexelLodFunc)(GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda, GLuint unit, GLfloat color[4]); @@ -36,10 +38,6 @@ typedef void (*FetchTexelDerivFunc)(GLcontext *ctx, const GLfloat texcoord[4], GLuint unit, GLfloat color[4]); -/** The larger of VERT_RESULT_MAX, FRAG_RESULT_MAX */ -#define MAX_PROGRAM_OUTPUTS VERT_RESULT_MAX - - /** * Virtual machine state used during execution of vertex/fragment programs. */ diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 6b895013af..08d7540372 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -89,16 +89,39 @@ bits_agree(GLbitfield flags1, GLbitfield flags2, GLbitfield bit) * Linking varying vars involves rearranging varying vars so that the * vertex program's output varyings matches the order of the fragment * program's input varyings. + * We'll then rewrite instructions to replace PROGRAM_VARYING with either + * PROGRAM_INPUT or PROGRAM_OUTPUT depending on whether it's a vertex or + * fragment shader. + * This is also where we set program Input/OutputFlags to indicate + * which inputs are centroid-sampled, invariant, etc. */ static GLboolean link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog) { GLuint *map, i, firstVarying, newFile; + GLbitfield *inOutFlags; map = (GLuint *) malloc(prog->Varying->NumParameters * sizeof(GLuint)); if (!map) return GL_FALSE; + /* Varying variables are treated like other vertex program outputs + * (and like other fragment program inputs). The position of the + * first varying differs for vertex/fragment programs... + * Also, replace File=PROGRAM_VARYING with File=PROGRAM_INPUT/OUTPUT. + */ + if (prog->Target == GL_VERTEX_PROGRAM_ARB) { + firstVarying = VERT_RESULT_VAR0; + newFile = PROGRAM_OUTPUT; + inOutFlags = prog->OutputFlags; + } + else { + assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB); + firstVarying = FRAG_ATTRIB_VAR0; + newFile = PROGRAM_INPUT; + inOutFlags = prog->InputFlags; + } + for (i = 0; i < prog->Varying->NumParameters; i++) { /* see if this varying is in the linked varying list */ const struct gl_program_parameter *var = prog->Varying->Parameters + i; @@ -132,12 +155,14 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog) var->Flags); } - /* map varying[i] to varying[j]. + /* Map varying[i] to varying[j]. + * Plus, set prog->Input/OutputFlags[] as described above. * Note: the loop here takes care of arrays or large (sz>4) vars. */ { GLint sz = var->Size; while (sz > 0) { + inOutFlags[firstVarying + j] = var->Flags; /*printf("Link varying from %d to %d\n", i, j);*/ map[i++] = j++; sz -= 4; @@ -147,21 +172,6 @@ link_varying_vars(struct gl_shader_program *shProg, struct gl_program *prog) } - /* Varying variables are treated like other vertex program outputs - * (and like other fragment program inputs). The position of the - * first varying differs for vertex/fragment programs... - * Also, replace File=PROGRAM_VARYING with File=PROGRAM_INPUT/OUTPUT. - */ - if (prog->Target == GL_VERTEX_PROGRAM_ARB) { - firstVarying = VERT_RESULT_VAR0; - newFile = PROGRAM_OUTPUT; - } - else { - assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB); - firstVarying = FRAG_ATTRIB_VAR0; - newFile = PROGRAM_INPUT; - } - /* OK, now scan the program/shader instructions looking for varying vars, * replacing the old index with the new index. */ -- cgit v1.2.3