From df84f788d21d3d2f61a0c5a35b75586d3099cdd4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 10 Nov 2008 10:45:50 -0700 Subject: mesa: fix logic error in GLSL linker when looking for main() shaders --- src/mesa/shader/slang/slang_link.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c index 511e740615..4361efc56e 100644 --- a/src/mesa/shader/slang/slang_link.c +++ b/src/mesa/shader/slang/slang_link.c @@ -465,12 +465,17 @@ _slang_link(GLcontext *ctx, fragProg = NULL; for (i = 0; i < shProg->NumShaders; i++) { struct gl_shader *shader = shProg->Shaders[i]; - if (shader->Type == GL_VERTEX_SHADER && shader->Main) - vertProg = vertex_program(shader->Program); - else if (shader->Type == GL_FRAGMENT_SHADER && shader->Main) - fragProg = fragment_program(shader->Program); - else + if (shader->Type == GL_VERTEX_SHADER) { + if (shader->Main) + vertProg = vertex_program(shader->Program); + } + else if (shader->Type == GL_FRAGMENT_SHADER) { + if (shader->Main) + fragProg = fragment_program(shader->Program); + } + else { _mesa_problem(ctx, "unexpected shader target in slang_link()"); + } } #if FEATURE_es2_glsl -- cgit v1.2.3 From 1dae2be1f67d7367173f32c90f8d98311aa7b102 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 10 Nov 2008 12:37:08 -0700 Subject: dri: alloc __DRIscreen object with calloc() Conflicts: src/mesa/drivers/dri/common/dri_util.c --- src/mesa/drivers/dri/common/dri_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index fff79c36ad..ac6e3cdda8 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -964,7 +964,7 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, api_ver = internal_api_version; - psp = (__DRIscreenPrivate *)_mesa_malloc(sizeof(__DRIscreenPrivate)); + psp = (__DRIscreenPrivate *)_mesa_calloc(sizeof(__DRIscreenPrivate)); if (!psp) { return NULL; } -- cgit v1.2.3 From ff42991c720bc1cfbf72194447fde0bebbd65b85 Mon Sep 17 00:00:00 2001 From: Brian Date: Mon, 10 Nov 2008 20:22:36 -0700 Subject: gallium: fix comment again. A half-closed interval was intended. Never saw the [a,b[ notation before. --- src/gallium/auxiliary/util/u_math.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/util/u_math.c b/src/gallium/auxiliary/util/u_math.c index 9c5f616ceb..d1571cd1fc 100644 --- a/src/gallium/auxiliary/util/u_math.c +++ b/src/gallium/auxiliary/util/u_math.c @@ -30,7 +30,7 @@ #include "util/u_math.h" -/** 2^x, for x in [-1.0, 1.0] */ +/** 2^x, for x in [-1.0, 1.0) */ float pow2_table[POW2_TABLE_SIZE]; @@ -43,7 +43,7 @@ init_pow2_table(void) } -/** log2(x), for x in [1.0, 2.0] */ +/** log2(x), for x in [1.0, 2.0) */ float log2_table[LOG2_TABLE_SIZE]; -- cgit v1.2.3 From 5cfb0a4087352c22a13ca55a98ae3e2e420d4b52 Mon Sep 17 00:00:00 2001 From: "Xiang, Haihao" Date: Tue, 11 Nov 2008 13:36:32 +0800 Subject: mesa: restore the negate flag of dots in build_lighting. Dots is re-used if more than one light is enabled. Previously the negate flag of dots may affect next light. --- src/mesa/main/ffvertex_prog.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c index 9ac8328ef0..b87c443fec 100644 --- a/src/mesa/main/ffvertex_prog.c +++ b/src/mesa/main/ffvertex_prog.c @@ -1318,6 +1318,9 @@ static void build_lighting( struct tnl_program *p ) emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0); emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1); + /* restore negate flag for next lighting */ + dots = negate(dots); + release_temp(p, ambient); release_temp(p, diffuse); release_temp(p, specular); -- cgit v1.2.3 From a983f2a6ac04edc2b3407b44c2a1b5bc970c4ce3 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 12 Nov 2008 17:03:58 +0100 Subject: draw: Add missing include. --- src/gallium/auxiliary/draw/draw_pt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 3c175f31d8..18f24e5980 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -35,6 +35,7 @@ #include "draw/draw_pt.h" #include "draw/draw_vs.h" #include "tgsi/tgsi_dump.h" +#include "util/u_math.h" static unsigned trim( unsigned count, unsigned first, unsigned incr ) { -- cgit v1.2.3 From f447eea4de9cab5de295c717d35824cf92b9f322 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 12 Nov 2008 17:14:07 +0100 Subject: util: Add log2() definition for MSC. --- src/gallium/auxiliary/util/u_math.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index be7303e550..c7bbebc428 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -161,6 +161,11 @@ static INLINE float logf( float f ) return (float) log( (double) f ); } +static INLINE double log2( double x ) +{ + return log( x ) / log( 2.0 ); +} + #else /* Work-around an extra semi-colon in VS 2005 logf definition */ #ifdef logf -- cgit v1.2.3 From 0d8637451b7bf1aac164dba6d269d1a665160ea3 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 12 Nov 2008 19:02:41 +0100 Subject: util: Optimise log2(). --- src/gallium/auxiliary/util/u_math.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index c7bbebc428..aee69ab7ba 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -163,7 +163,8 @@ static INLINE float logf( float f ) static INLINE double log2( double x ) { - return log( x ) / log( 2.0 ); + const double invln2 = 1.442695041; + return log( x ) * invln2; } #else -- cgit v1.2.3 From d04caf2ce47bcf1d9da6e42b749320fce9273390 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 5 Nov 2008 11:31:57 +0000 Subject: trivial: more tests --- progs/trivial/Makefile | 7 ++ progs/trivial/clear-repeat.c | 111 ++++++++++++++++++++++ progs/trivial/tri-fp-const-imm.c | 169 +++++++++++++++++++++++++++++++++ progs/trivial/tri-fp.c | 167 ++++++++++++++++++++++++++++++++ progs/trivial/tri-lit.c | 139 +++++++++++++++++++++++++++ progs/trivial/tri-repeat.c | 118 +++++++++++++++++++++++ progs/trivial/tri-unfilled-tri-lit.c | 178 +++++++++++++++++++++++++++++++++++ progs/trivial/tri-unfilled-tri.c | 175 ++++++++++++++++++++++++++++++++++ 8 files changed, 1064 insertions(+) create mode 100644 progs/trivial/clear-repeat.c create mode 100644 progs/trivial/tri-fp-const-imm.c create mode 100644 progs/trivial/tri-fp.c create mode 100644 progs/trivial/tri-lit.c create mode 100644 progs/trivial/tri-repeat.c create mode 100644 progs/trivial/tri-unfilled-tri-lit.c create mode 100644 progs/trivial/tri-unfilled-tri.c diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index 6c8c9fad90..1b9a50b437 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -15,6 +15,7 @@ SOURCES = \ clear-fbo.c \ clear-scissor.c \ clear-undefined.c \ + clear-repeat.c \ clear.c \ dlist-dangling.c \ dlist-edgeflag-dangling.c \ @@ -92,8 +93,12 @@ SOURCES = \ tri-flat-clip.c \ tri-flat.c \ tri-fog.c \ + tri-fp.c \ + tri-fp-const-imm.c \ + tri-lit.c \ tri-mask-tri.c \ tri-query.c \ + tri-repeat.c \ tri-scissor-tri.c \ tri-stencil.c \ tri-tex.c \ @@ -102,6 +107,8 @@ SOURCES = \ tri-unfilled-edgeflag.c \ tri-unfilled-clip.c \ tri-unfilled-smooth.c \ + tri-unfilled-tri.c \ + tri-unfilled-tri-lit.c \ tri-unfilled-userclip-stip.c \ tri-unfilled-userclip.c \ tri-unfilled.c \ diff --git a/progs/trivial/clear-repeat.c b/progs/trivial/clear-repeat.c new file mode 100644 index 0000000000..9f9490c6c8 --- /dev/null +++ b/progs/trivial/clear-repeat.c @@ -0,0 +1,111 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.3, 0.1, 0.3, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + default: + glutPostRedisplay(); + return; + } +} + +static void Draw(void) +{ + static float f = 0; + while (1) { + f += .1; + glClearColor((sin(f)+1)/2.0,(cos(f)+1)/2.0,0.5,1); + glClear(GL_COLOR_BUFFER_BIT); + glutSwapBuffers(); + } + glutPostRedisplay(); +} + +static GLenum Args(int argc, char **argv) +{ + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= GLUT_DOUBLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fp-const-imm.c b/progs/trivial/tri-fp-const-imm.c new file mode 100644 index 0000000000..71113802ed --- /dev/null +++ b/progs/trivial/tri-fp-const-imm.c @@ -0,0 +1,169 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + GLint errno; + GLuint prognum; + static const char *prog1 = + "!!ARBfp1.0\n" + "TEMP R1;\n" + "MOV R1, state.material.emission;\n" + "MUL R1, R1, {0.9}.x;\n" + "MOV result.color, R1;\n" + "END\n"; + + + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &prognum); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *)prog1); + + errno = glGetError(); + printf("glGetError = 0x%x\n", errno); + if (errno != GL_NO_ERROR) { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */ + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glTexCoord3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glTexCoord3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glTexCoord3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-fp.c b/progs/trivial/tri-fp.c new file mode 100644 index 0000000000..9ff355a4ca --- /dev/null +++ b/progs/trivial/tri-fp.c @@ -0,0 +1,167 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#define GL_GLEXT_PROTOTYPES +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + GLint errno; + GLuint prognum; + static const char *prog1 = + "!!ARBfp1.0\n" + "MOV result.color, fragment.texcoord[1];\n" +// "MOV result.color, fragment.color;\n" + "END\n"; + + + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + /* Setup the fragment program */ + glGenProgramsARB(1, &prognum); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, prognum); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *)prog1); + + errno = glGetError(); + printf("glGetError = 0x%x\n", errno); + if (errno != GL_NO_ERROR) { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n", + (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + glEnable(GL_FRAGMENT_PROGRAM_ARB); + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */ + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glTexCoord3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glTexCoord3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glTexCoord3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-lit.c b/progs/trivial/tri-lit.c new file mode 100644 index 0000000000..22f199c982 --- /dev/null +++ b/progs/trivial/tri-lit.c @@ -0,0 +1,139 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */ + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glNormal3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glNormal3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glNormal3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-repeat.c b/progs/trivial/tri-repeat.c new file mode 100644 index 0000000000..e894269e84 --- /dev/null +++ b/progs/trivial/tri-repeat.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.3, 0.1, 0.3, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + switch (key) { + case 27: + exit(0); + default: + glutPostRedisplay(); + return; + } +} + +static void Draw(void) +{ + static float f = 0; + f += .1; + glClear(GL_COLOR_BUFFER_BIT); + + glBegin(GL_TRIANGLES); + glColor3f((sin(f)+1)/2.0,0,0); + glVertex3f(-0.9, -0.9, -30.0); + glColor3f(0,(cos(f)+1)/2.0,0); + glVertex3f( 0.9, -0.9, -30.0); + glColor3f(0,0,.7); + glVertex3f( 0.0, 0.9, -30.0); + glEnd(); + + glutSwapBuffers(); + glutPostRedisplay(); +} + +static GLenum Args(int argc, char **argv) +{ + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= GLUT_DOUBLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-unfilled-tri-lit.c b/progs/trivial/tri-unfilled-tri-lit.c new file mode 100644 index 0000000000..f9e1d00988 --- /dev/null +++ b/progs/trivial/tri-unfilled-tri-lit.c @@ -0,0 +1,178 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glEnable(GL_LIGHTING); + glEnable(GL_LIGHT0); + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */ + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glNormal3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glNormal3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glNormal3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glNormal3f(0,0,.7); + glVertex3f( 0.8, -0.8, -0.0); + glNormal3f(.8,0,0); + glVertex3f( 0.8, 0.8, -0.0); + glNormal3f(0,.9,0); + glVertex3f(-0.8, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glNormal3f(.8,0,0); + glVertex3f( -0.9, 0.9, -0.0); + glNormal3f(0,0,.7); + glVertex3f( -0.9, -0.9, -0.0); + glNormal3f(0,.9,0); + glVertex3f( 0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glNormal3f(.8,0,0); + glVertex3f( -0.8, 0.8, -0.0); + glNormal3f(0,0,.7); + glVertex3f( -0.8, -0.8, -0.0); + glNormal3f(0,.9,0); + glVertex3f( 0.8, 0.0, -0.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/tri-unfilled-tri.c b/progs/trivial/tri-unfilled-tri.c new file mode 100644 index 0000000000..d9a9faeb9f --- /dev/null +++ b/progs/trivial/tri-unfilled-tri.c @@ -0,0 +1,175 @@ +/* + * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the name of + * Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF + * ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + + +#define CI_OFFSET_1 16 +#define CI_OFFSET_2 32 + + +GLenum doubleBuffer; + +static void Init(void) +{ + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); + fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); + fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); + + glClearColor(0.0, 0.0, 1.0, 0.0); +} + +static void Reshape(int width, int height) +{ + + glViewport(0, 0, (GLint)width, (GLint)height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */ + glMatrixMode(GL_MODELVIEW); +} + +static void Key(unsigned char key, int x, int y) +{ + + switch (key) { + case 27: + exit(1); + default: + return; + } + + glutPostRedisplay(); +} + +static void Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.9, -0.9, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.9, 0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glColor3f(0,0,.7); + glVertex3f( 0.8, -0.8, -0.0); + glColor3f(.8,0,0); + glVertex3f( 0.8, 0.8, -0.0); + glColor3f(0,.9,0); + glVertex3f(-0.8, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_LINE); + glPolygonMode(GL_BACK, GL_LINE); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f( -0.9, 0.9, -0.0); + glColor3f(0,0,.7); + glVertex3f( -0.9, -0.9, -0.0); + glColor3f(0,.9,0); + glVertex3f( 0.9, 0.0, -0.0); + glEnd(); + + glPolygonMode(GL_FRONT, GL_FILL); + glPolygonMode(GL_BACK, GL_FILL); + + glBegin(GL_TRIANGLES); + glColor3f(.8,0,0); + glVertex3f( -0.8, 0.8, -0.0); + glColor3f(0,0,.7); + glVertex3f( -0.8, -0.8, -0.0); + glColor3f(0,.9,0); + glVertex3f( 0.8, 0.0, -0.0); + glEnd(); + + glFlush(); + + if (doubleBuffer) { + glutSwapBuffers(); + } +} + +static GLenum Args(int argc, char **argv) +{ + GLint i; + + doubleBuffer = GL_FALSE; + + for (i = 1; i < argc; i++) { + if (strcmp(argv[i], "-sb") == 0) { + doubleBuffer = GL_FALSE; + } else if (strcmp(argv[i], "-db") == 0) { + doubleBuffer = GL_TRUE; + } else { + fprintf(stderr, "%s (Bad option).\n", argv[i]); + return GL_FALSE; + } + } + return GL_TRUE; +} + +int main(int argc, char **argv) +{ + GLenum type; + + glutInit(&argc, argv); + + if (Args(argc, argv) == GL_FALSE) { + exit(1); + } + + glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); + + type = GLUT_RGB | GLUT_ALPHA; + type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; + glutInitDisplayMode(type); + + if (glutCreateWindow("First Tri") == GL_FALSE) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} -- cgit v1.2.3 From 0557fa72c0e39a3cb4c241690b495ca142c06616 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 14 Nov 2008 17:59:29 +0000 Subject: translate: pull in prefetch and other optimizations from draw_vs_aos.c --- src/gallium/auxiliary/translate/translate.h | 4 +- src/gallium/auxiliary/translate/translate_sse.c | 312 +++++++++++++++--------- 2 files changed, 204 insertions(+), 112 deletions(-) diff --git a/src/gallium/auxiliary/translate/translate.h b/src/gallium/auxiliary/translate/translate.h index 650cd81fa6..34526eb061 100644 --- a/src/gallium/auxiliary/translate/translate.h +++ b/src/gallium/auxiliary/translate/translate.h @@ -48,8 +48,8 @@ struct translate_element { enum pipe_format input_format; enum pipe_format output_format; - unsigned input_buffer; - unsigned input_offset; /* can't really reduce the size of these */ + unsigned input_buffer:8; + unsigned input_offset:24; unsigned output_offset; }; diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c index 7955186e16..b62db8d8f3 100644 --- a/src/gallium/auxiliary/translate/translate_sse.c +++ b/src/gallium/auxiliary/translate/translate_sse.c @@ -29,7 +29,7 @@ #include "pipe/p_config.h" #include "pipe/p_compiler.h" #include "util/u_memory.h" -#include "util/u_simple_list.h" +#include "util/u_math.h" #include "translate.h" @@ -56,6 +56,11 @@ typedef void (PIPE_CDECL *run_elts_func)( struct translate *translate, unsigned count, void *output_buffer ); +struct translate_buffer { + const void *base_ptr; + unsigned stride; + void *ptr; /* updated per vertex */ +}; struct translate_sse { @@ -73,14 +78,20 @@ struct translate_sse { float float_255[4]; float inv_255[4]; - struct { - char *input_ptr; - unsigned input_stride; - } attrib[PIPE_MAX_ATTRIBS]; + struct translate_buffer buffer[PIPE_MAX_ATTRIBS]; + unsigned nr_buffers; run_func gen_run; run_elts_func gen_run_elts; + /* these are actually known values, but putting them in a struct + * like this is helpful to keep them in sync across the file. + */ + struct x86_reg tmp_EAX; + struct x86_reg idx_EBX; /* either start+i or &elt[i] */ + struct x86_reg outbuf_ECX; + struct x86_reg machine_EDX; + struct x86_reg count_ESI; /* decrements to zero */ }; static int get_offset( const void *a, const void *b ) @@ -95,10 +106,6 @@ static struct x86_reg get_identity( struct translate_sse *p ) struct x86_reg reg = x86_make_reg(file_XMM, 6); if (!p->loaded_identity) { - /* Nasty: - */ - struct x86_reg translateESI = x86_make_reg(file_REG32, reg_SI); - p->loaded_identity = TRUE; p->identity[0] = 0; p->identity[1] = 0; @@ -106,7 +113,7 @@ static struct x86_reg get_identity( struct translate_sse *p ) p->identity[3] = 1; sse_movups(p->func, reg, - x86_make_disp(translateESI, + x86_make_disp(p->machine_EDX, get_offset(p, &p->identity[0]))); } @@ -115,11 +122,9 @@ static struct x86_reg get_identity( struct translate_sse *p ) static struct x86_reg get_255( struct translate_sse *p ) { - struct x86_reg reg = x86_make_reg(file_XMM, 6); + struct x86_reg reg = x86_make_reg(file_XMM, 7); if (!p->loaded_255) { - struct x86_reg translateESI = x86_make_reg(file_REG32, reg_SI); - p->loaded_255 = TRUE; p->float_255[0] = p->float_255[1] = @@ -127,12 +132,11 @@ static struct x86_reg get_255( struct translate_sse *p ) p->float_255[3] = 255.0f; sse_movups(p->func, reg, - x86_make_disp(translateESI, + x86_make_disp(p->machine_EDX, get_offset(p, &p->float_255[0]))); } return reg; - return x86_make_reg(file_XMM, 7); } static struct x86_reg get_inv_255( struct translate_sse *p ) @@ -140,8 +144,6 @@ static struct x86_reg get_inv_255( struct translate_sse *p ) struct x86_reg reg = x86_make_reg(file_XMM, 5); if (!p->loaded_inv_255) { - struct x86_reg translateESI = x86_make_reg(file_REG32, reg_SI); - p->loaded_inv_255 = TRUE; p->inv_255[0] = p->inv_255[1] = @@ -149,7 +151,7 @@ static struct x86_reg get_inv_255( struct translate_sse *p ) p->inv_255[3] = 1.0f / 255.0f; sse_movups(p->func, reg, - x86_make_disp(translateESI, + x86_make_disp(p->machine_EDX, get_offset(p, &p->inv_255[0]))); } @@ -283,28 +285,6 @@ static void emit_store_R8G8B8A8_UNORM( struct translate_sse *p, -static void get_src_ptr( struct translate_sse *p, - struct x86_reg srcEAX, - struct x86_reg translateREG, - struct x86_reg eltREG, - unsigned a ) -{ - struct x86_reg input_ptr = - x86_make_disp(translateREG, - get_offset(p, &p->attrib[a].input_ptr)); - - struct x86_reg input_stride = - x86_make_disp(translateREG, - get_offset(p, &p->attrib[a].input_stride)); - - /* Calculate pointer to current attrib: - */ - x86_mov(p->func, srcEAX, input_stride); - x86_imul(p->func, srcEAX, eltREG); - x86_add(p->func, srcEAX, input_ptr); -} - - /* Extended swizzles? Maybe later. */ static void emit_swizzle( struct translate_sse *p, @@ -374,12 +354,126 @@ static boolean translate_attr( struct translate_sse *p, return TRUE; } -/* Build run( struct translate *translate, + +static boolean init_inputs( struct translate_sse *p, + boolean linear ) +{ + unsigned i; + if (linear) { + for (i = 0; i < p->nr_buffers; i++) { + struct x86_reg buf_stride = x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[i].stride)); + struct x86_reg buf_ptr = x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[i].ptr)); + struct x86_reg buf_base_ptr = x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[i].base_ptr)); + struct x86_reg elt = p->idx_EBX; + struct x86_reg tmp = p->tmp_EAX; + + + /* Calculate pointer to first attrib: + */ + x86_mov(p->func, tmp, buf_stride); + x86_imul(p->func, tmp, elt); + x86_add(p->func, tmp, buf_base_ptr); + + + /* In the linear case, keep the buffer pointer instead of the + * index number. + */ + if (p->nr_buffers == 1) + x86_mov( p->func, elt, tmp ); + else + x86_mov( p->func, buf_ptr, tmp ); + } + } + + return TRUE; +} + + +static struct x86_reg get_buffer_ptr( struct translate_sse *p, + boolean linear, + unsigned buf_idx, + struct x86_reg elt ) +{ + if (linear && p->nr_buffers == 1) { + return p->idx_EBX; + } + else if (linear) { + struct x86_reg ptr = p->tmp_EAX; + struct x86_reg buf_ptr = + x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[buf_idx].ptr)); + + x86_mov(p->func, ptr, buf_ptr); + return ptr; + } + else { + struct x86_reg ptr = p->tmp_EAX; + + struct x86_reg buf_stride = + x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[buf_idx].stride)); + + struct x86_reg buf_base_ptr = + x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[buf_idx].base_ptr)); + + + + /* Calculate pointer to current attrib: + */ + x86_mov(p->func, ptr, buf_stride); + x86_imul(p->func, ptr, elt); + x86_add(p->func, ptr, buf_base_ptr); + return ptr; + } +} + + + +static boolean incr_inputs( struct translate_sse *p, + boolean linear ) +{ + if (linear && p->nr_buffers == 1) { + struct x86_reg stride = x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[0].stride)); + + x86_add(p->func, p->idx_EBX, stride); + sse_prefetchnta(p->func, x86_make_disp(p->idx_EBX, 192)); + } + else if (linear) { + unsigned i; + + /* Is this worthwhile?? + */ + for (i = 0; i < p->nr_buffers; i++) { + struct x86_reg buf_ptr = x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[i].ptr)); + struct x86_reg buf_stride = x86_make_disp(p->machine_EDX, + get_offset(p, &p->buffer[i].stride)); + + x86_mov(p->func, p->tmp_EAX, buf_ptr); + x86_add(p->func, p->tmp_EAX, buf_stride); + if (i == 0) sse_prefetchnta(p->func, x86_make_disp(p->tmp_EAX, 192)); + x86_mov(p->func, buf_ptr, p->tmp_EAX); + } + } + else { + x86_lea(p->func, p->idx_EBX, x86_make_disp(p->idx_EBX, 4)); + } + + return TRUE; +} + + +/* Build run( struct translate *machine, * unsigned start, * unsigned count, * void *output_buffer ) * or - * run_elts( struct translate *translate, + * run_elts( struct translate *machine, * unsigned *elts, * unsigned count, * void *output_buffer ) @@ -394,14 +488,15 @@ static boolean build_vertex_emit( struct translate_sse *p, struct x86_function *func, boolean linear ) { - struct x86_reg vertexECX = x86_make_reg(file_REG32, reg_AX); - struct x86_reg idxEBX = x86_make_reg(file_REG32, reg_BX); - struct x86_reg srcEAX = x86_make_reg(file_REG32, reg_CX); - struct x86_reg countEBP = x86_make_reg(file_REG32, reg_BP); - struct x86_reg translateESI = x86_make_reg(file_REG32, reg_SI); int fixup, label; unsigned j; + p->tmp_EAX = x86_make_reg(file_REG32, reg_AX); + p->idx_EBX = x86_make_reg(file_REG32, reg_BX); + p->outbuf_ECX = x86_make_reg(file_REG32, reg_CX); + p->machine_EDX = x86_make_reg(file_REG32, reg_DX); + p->count_ESI = x86_make_reg(file_REG32, reg_SI); + p->func = func; p->loaded_inv_255 = FALSE; p->loaded_255 = FALSE; @@ -411,74 +506,65 @@ static boolean build_vertex_emit( struct translate_sse *p, /* Push a few regs? */ - x86_push(p->func, countEBP); - x86_push(p->func, translateESI); - x86_push(p->func, idxEBX); - - /* Get vertex count, compare to zero - */ - x86_xor(p->func, idxEBX, idxEBX); - x86_mov(p->func, countEBP, x86_fn_arg(p->func, 3)); - x86_cmp(p->func, countEBP, idxEBX); - fixup = x86_jcc_forward(p->func, cc_E); - - /* If linear, idx is the current element, otherwise it is a pointer - * to the current element. - */ - x86_mov(p->func, idxEBX, x86_fn_arg(p->func, 2)); + x86_push(p->func, p->idx_EBX); + x86_push(p->func, p->count_ESI); - /* Initialize destination register. + /* Load arguments into regs: */ - x86_mov(p->func, vertexECX, x86_fn_arg(p->func, 4)); + x86_mov(p->func, p->machine_EDX, x86_fn_arg(p->func, 1)); + x86_mov(p->func, p->idx_EBX, x86_fn_arg(p->func, 2)); + x86_mov(p->func, p->count_ESI, x86_fn_arg(p->func, 3)); + x86_mov(p->func, p->outbuf_ECX, x86_fn_arg(p->func, 4)); - /* Move argument 1 (translate_sse pointer) into a reg: + /* Get vertex count, compare to zero */ - x86_mov(p->func, translateESI, x86_fn_arg(p->func, 1)); + x86_xor(p->func, p->tmp_EAX, p->tmp_EAX); + x86_cmp(p->func, p->count_ESI, p->tmp_EAX); + fixup = x86_jcc_forward(p->func, cc_E); - /* always load, needed or not: */ + init_inputs(p, linear); - /* Note address for loop jump */ + /* Note address for loop jump + */ label = x86_get_label(p->func); - - - for (j = 0; j < p->translate.key.nr_elements; j++) { - const struct translate_element *a = &p->translate.key.element[j]; - - struct x86_reg destEAX = x86_make_disp(vertexECX, - a->output_offset); - - /* Figure out source pointer address: - */ - if (linear) { - get_src_ptr(p, srcEAX, translateESI, idxEBX, j); + { + struct x86_reg elt = linear ? p->idx_EBX : x86_deref(p->idx_EBX); + int last_vb = -1; + struct x86_reg vb; + + for (j = 0; j < p->translate.key.nr_elements; j++) { + const struct translate_element *a = &p->translate.key.element[j]; + + /* Figure out source pointer address: + */ + if (a->input_buffer != last_vb) { + last_vb = a->input_buffer; + vb = get_buffer_ptr(p, linear, a->input_buffer, elt); + } + + if (!translate_attr( p, a, + x86_make_disp(vb, a->input_offset), + x86_make_disp(p->outbuf_ECX, a->output_offset))) + return FALSE; } - else { - get_src_ptr(p, srcEAX, translateESI, x86_deref(idxEBX), j); - } - - if (!translate_attr( p, a, x86_deref(srcEAX), destEAX )) - return FALSE; - } - - /* Next vertex: - */ - x86_lea(p->func, vertexECX, x86_make_disp(vertexECX, p->translate.key.output_stride)); - /* Incr index - */ - if (linear) { - x86_inc(p->func, idxEBX); - } - else { - x86_lea(p->func, idxEBX, x86_make_disp(idxEBX, 4)); + /* Next output vertex: + */ + x86_lea(p->func, + p->outbuf_ECX, + x86_make_disp(p->outbuf_ECX, + p->translate.key.output_stride)); + + /* Incr index + */ + incr_inputs( p, linear ); } /* decr count, loop if not zero */ - x86_dec(p->func, countEBP); - x86_test(p->func, countEBP, countEBP); + x86_dec(p->func, p->count_ESI); x86_jcc(p->func, cc_NZ, label); /* Exit mmx state? @@ -493,9 +579,8 @@ static boolean build_vertex_emit( struct translate_sse *p, /* Pop regs and return */ - x86_pop(p->func, idxEBX); - x86_pop(p->func, translateESI); - x86_pop(p->func, countEBP); + x86_pop(p->func, p->count_ESI); + x86_pop(p->func, p->idx_EBX); x86_ret(p->func); return TRUE; @@ -513,15 +598,16 @@ static void translate_sse_set_buffer( struct translate *translate, unsigned stride ) { struct translate_sse *p = (struct translate_sse *)translate; - unsigned i; - for (i = 0; i < p->translate.key.nr_elements; i++) { - if (p->translate.key.element[i].input_buffer == buf) { - p->attrib[i].input_ptr = ((char *)ptr + - p->translate.key.element[i].input_offset); - p->attrib[i].input_stride = stride; - } + if (buf < p->nr_buffers) { + p->buffer[buf].base_ptr = (char *)ptr; + p->buffer[buf].stride = stride; } + + if (0) debug_printf("%s %d/%d: %p %d\n", + __FUNCTION__, buf, + p->nr_buffers, + ptr, stride); } @@ -565,6 +651,7 @@ static void PIPE_CDECL translate_sse_run( struct translate *translate, struct translate *translate_sse2_create( const struct translate_key *key ) { struct translate_sse *p = NULL; + unsigned i; if (!rtasm_cpu_has_sse() || !rtasm_cpu_has_sse2()) goto fail; @@ -579,6 +666,11 @@ struct translate *translate_sse2_create( const struct translate_key *key ) p->translate.run_elts = translate_sse_run_elts; p->translate.run = translate_sse_run; + for (i = 0; i < key->nr_elements; i++) + p->nr_buffers = MAX2( p->nr_buffers, key->element[i].input_buffer + 1 ); + + if (0) debug_printf("nr_buffers: %d\n", p->nr_buffers); + if (!build_vertex_emit(p, &p->linear_func, TRUE)) goto fail; -- cgit v1.2.3 From 6afab9001e5ebe5a970810b0e12dbfac0d9abe14 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 13 Nov 2008 08:58:47 -0700 Subject: util: Use OpenGL rasterization rules in blits and mipmap generation. --- src/gallium/auxiliary/util/u_blit.c | 1 + src/gallium/auxiliary/util/u_gen_mipmap.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index 9adf72944e..d28201ac8d 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -104,6 +104,7 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) ctx->rasterizer.cull_mode = PIPE_WINDING_NONE; ctx->rasterizer.bypass_clipping = 1; /*ctx->rasterizer.bypass_vs = 1;*/ + ctx->rasterizer.gl_rasterization_rules = 1; /* samplers */ memset(&ctx->sampler, 0, sizeof(ctx->sampler)); diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index b19a649bbc..9d305ad763 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -725,6 +725,7 @@ util_create_gen_mipmap(struct pipe_context *pipe, ctx->rasterizer.cull_mode = PIPE_WINDING_NONE; ctx->rasterizer.bypass_clipping = 1; /*ctx->rasterizer.bypass_vs = 1;*/ + ctx->rasterizer.gl_rasterization_rules = 1; /* sampler state */ memset(&ctx->sampler, 0, sizeof(ctx->sampler)); -- cgit v1.2.3 From 7e584a70c492698be18bf4d6372b50d1a1c38385 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 14 Nov 2008 12:55:05 -0700 Subject: gallium: increase table size for fast log/pow functions The various conformance tests pass now. --- src/gallium/auxiliary/util/u_math.c | 2 +- src/gallium/auxiliary/util/u_math.h | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gallium/auxiliary/util/u_math.c b/src/gallium/auxiliary/util/u_math.c index d1571cd1fc..2811475fa0 100644 --- a/src/gallium/auxiliary/util/u_math.c +++ b/src/gallium/auxiliary/util/u_math.c @@ -52,7 +52,7 @@ init_log2_table(void) { unsigned i; for (i = 0; i < LOG2_TABLE_SIZE; i++) - log2_table[i] = (float) log2(1.0 + i * (1.0 / LOG2_TABLE_SIZE)); + log2_table[i] = (float) log2(1.0 + i * (1.0 / LOG2_TABLE_SCALE)); } diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index aee69ab7ba..ac11d7001b 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -246,8 +246,9 @@ util_fast_exp(float x) } -#define LOG2_TABLE_SIZE_LOG2 8 -#define LOG2_TABLE_SIZE (1 << LOG2_TABLE_SIZE_LOG2) +#define LOG2_TABLE_SIZE_LOG2 16 +#define LOG2_TABLE_SCALE (1 << LOG2_TABLE_SIZE_LOG2) +#define LOG2_TABLE_SIZE (LOG2_TABLE_SCALE + 1) extern float log2_table[LOG2_TABLE_SIZE]; @@ -258,7 +259,8 @@ util_fast_log2(float x) float epart, mpart; num.f = x; epart = (float)(((num.i & 0x7f800000) >> 23) - 127); - mpart = log2_table[(num.i & 0x007fffff) >> (23 - LOG2_TABLE_SIZE_LOG2)]; + /* mpart = log2_table[mantissa*LOG2_TABLE_SCALE + 0.5] */ + mpart = log2_table[((num.i & 0x007fffff) + (1 << (22 - LOG2_TABLE_SIZE_LOG2))) >> (23 - LOG2_TABLE_SIZE_LOG2)]; return epart + mpart; } -- cgit v1.2.3