summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/i965')
-rw-r--r--src/mesa/drivers/dri/i965/Makefile14
-rw-r--r--src/mesa/drivers/dri/i965/brw_attrib.h114
-rw-r--r--src/mesa/drivers/dri/i965/brw_attrib_tmp.h485
-rw-r--r--src/mesa/drivers/dri/i965/brw_clip.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_clip.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c8
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h27
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c173
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.h57
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_current.c103
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c130
-rw-r--r--src/mesa/drivers/dri/i965/brw_eu.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_eu_emit.c155
-rw-r--r--src/mesa/drivers/dri/i965/brw_exec.c125
-rw-r--r--src/mesa/drivers/dri/i965/brw_exec.h150
-rw-r--r--src/mesa/drivers/dri/i965/brw_exec_api.c716
-rw-r--r--src/mesa/drivers/dri/i965/brw_exec_array.c283
-rw-r--r--src/mesa/drivers/dri/i965/brw_exec_draw.c227
-rw-r--r--src/mesa/drivers/dri/i965/brw_exec_eval.c255
-rw-r--r--src/mesa/drivers/dri/i965/brw_fallback.c349
-rw-r--r--src/mesa/drivers/dri/i965/brw_fallback.h4
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs.h1
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs_emit.c10
-rw-r--r--src/mesa/drivers/dri/i965/brw_metaops.c73
-rw-r--r--src/mesa/drivers/dri/i965/brw_save.c126
-rw-r--r--src/mesa/drivers/dri/i965/brw_save.h171
-rw-r--r--src/mesa/drivers/dri/i965/brw_save_api.c1170
-rw-r--r--src/mesa/drivers/dri/i965/brw_save_draw.c221
-rw-r--r--src/mesa/drivers/dri/i965/brw_structs.h22
-rw-r--r--src/mesa/drivers/dri/i965/brw_tex_layout.c55
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_constval.c7
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_emit.c6
-rw-r--r--src/mesa/drivers/dri/i965/brw_vs_tnl.c47
-rw-r--r--src/mesa/drivers/dri/i965/brw_vtbl.c10
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_state.c4
-rw-r--r--src/mesa/drivers/dri/i965/bufmgr.h2
-rw-r--r--src/mesa/drivers/dri/i965/bufmgr_fake.c18
-rw-r--r--src/mesa/drivers/dri/i965/intel_blit.c4
-rw-r--r--src/mesa/drivers/dri/i965/intel_context.c81
-rw-r--r--src/mesa/drivers/dri/i965/intel_context.h3
-rw-r--r--src/mesa/drivers/dri/i965/intel_ioctl.c35
-rw-r--r--src/mesa/drivers/dri/i965/intel_regions.c2
-rw-r--r--src/mesa/drivers/dri/i965/intel_regions.h1
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.c12
-rw-r--r--src/mesa/drivers/dri/i965/intel_screen.h1
l---------src/mesa/drivers/dri/i965/intel_tex_layout.c1
-rw-r--r--src/mesa/drivers/dri/i965/server/i830_common.h19
49 files changed, 513 insertions, 4983 deletions
diff --git a/src/mesa/drivers/dri/i965/Makefile b/src/mesa/drivers/dri/i965/Makefile
index 213eac895c..9e4ff112dc 100644
--- a/src/mesa/drivers/dri/i965/Makefile
+++ b/src/mesa/drivers/dri/i965/Makefile
@@ -20,6 +20,7 @@ DRIVER_SOURCES = \
intel_pixel_bitmap.c \
intel_state.c \
intel_tex.c \
+ intel_tex_layout.c \
intel_tex_validate.c \
brw_aub.c \
brw_aub_playback.c \
@@ -34,17 +35,11 @@ DRIVER_SOURCES = \
brw_context.c \
brw_curbe.c \
brw_draw.c \
- brw_draw_current.c \
brw_draw_upload.c \
brw_eu.c \
brw_eu_debug.c \
brw_eu_emit.c \
brw_eu_util.c \
- brw_exec.c \
- brw_exec_api.c \
- brw_exec_array.c \
- brw_exec_draw.c \
- brw_exec_eval.c \
brw_fallback.c \
brw_gs.c \
brw_gs_emit.c \
@@ -53,9 +48,6 @@ DRIVER_SOURCES = \
brw_metaops.c \
brw_misc_state.c \
brw_program.c \
- brw_save.c \
- brw_save_api.c \
- brw_save_draw.c \
brw_sf.c \
brw_sf_emit.c \
brw_sf_state.c \
@@ -92,8 +84,10 @@ C_SOURCES = \
ASM_SOURCES =
-
+DRIVER_DEFINES = -I../intel
include ../Makefile.template
+intel_tex_layout.o: ../intel/intel_tex_layout.c
+
symlinks:
diff --git a/src/mesa/drivers/dri/i965/brw_attrib.h b/src/mesa/drivers/dri/i965/brw_attrib.h
deleted file mode 100644
index 12659bd1cf..0000000000
--- a/src/mesa/drivers/dri/i965/brw_attrib.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef BRW_ATTRIB_H
-#define BRW_ATTRIB_H
-
-
-/*
- * Note: The first attributes match the VERT_ATTRIB_* definitions
- * in mtypes.h. However, the tnl module has additional attributes
- * for materials, color indexes, edge flags, etc.
- */
-/* Although it's nice to use these as bit indexes in a DWORD flag, we
- * could manage without if necessary. Another limit currently is the
- * number of bits allocated for these numbers in places like vertex
- * program instruction formats and register layouts.
- */
-enum {
- BRW_ATTRIB_POS = 0,
- BRW_ATTRIB_WEIGHT = 1,
- BRW_ATTRIB_NORMAL = 2,
- BRW_ATTRIB_COLOR0 = 3,
- BRW_ATTRIB_COLOR1 = 4,
- BRW_ATTRIB_FOG = 5,
- BRW_ATTRIB_INDEX = 6,
- BRW_ATTRIB_EDGEFLAG = 7,
- BRW_ATTRIB_TEX0 = 8,
- BRW_ATTRIB_TEX1 = 9,
- BRW_ATTRIB_TEX2 = 10,
- BRW_ATTRIB_TEX3 = 11,
- BRW_ATTRIB_TEX4 = 12,
- BRW_ATTRIB_TEX5 = 13,
- BRW_ATTRIB_TEX6 = 14,
- BRW_ATTRIB_TEX7 = 15,
-
- BRW_ATTRIB_GENERIC0 = 16, /* Not used? */
- BRW_ATTRIB_GENERIC1 = 17,
- BRW_ATTRIB_GENERIC2 = 18,
- BRW_ATTRIB_GENERIC3 = 19,
- BRW_ATTRIB_GENERIC4 = 20,
- BRW_ATTRIB_GENERIC5 = 21,
- BRW_ATTRIB_GENERIC6 = 22,
- BRW_ATTRIB_GENERIC7 = 23,
- BRW_ATTRIB_GENERIC8 = 24,
- BRW_ATTRIB_GENERIC9 = 25,
- BRW_ATTRIB_GENERIC10 = 26,
- BRW_ATTRIB_GENERIC11 = 27,
- BRW_ATTRIB_GENERIC12 = 28,
- BRW_ATTRIB_GENERIC13 = 29,
- BRW_ATTRIB_GENERIC14 = 30,
- BRW_ATTRIB_GENERIC15 = 31,
-
- BRW_ATTRIB_MAT_FRONT_AMBIENT = 32,
- BRW_ATTRIB_MAT_BACK_AMBIENT = 33,
- BRW_ATTRIB_MAT_FRONT_DIFFUSE = 34,
- BRW_ATTRIB_MAT_BACK_DIFFUSE = 35,
- BRW_ATTRIB_MAT_FRONT_SPECULAR = 36,
- BRW_ATTRIB_MAT_BACK_SPECULAR = 37,
- BRW_ATTRIB_MAT_FRONT_EMISSION = 38,
- BRW_ATTRIB_MAT_BACK_EMISSION = 39,
- BRW_ATTRIB_MAT_FRONT_SHININESS = 40,
- BRW_ATTRIB_MAT_BACK_SHININESS = 41,
- BRW_ATTRIB_MAT_FRONT_INDEXES = 42,
- BRW_ATTRIB_MAT_BACK_INDEXES = 43,
-
- BRW_ATTRIB_MAX = 44
-} ;
-
-#define BRW_ATTRIB_FIRST_MATERIAL BRW_ATTRIB_MAT_FRONT_AMBIENT
-#define BRW_ATTRIB_LAST_MATERIAL BRW_ATTRIB_MAT_BACK_INDEXES
-
-#define BRW_MAX_COPIED_VERTS 3
-
-
-static inline GLuint64EXT brw_translate_inputs( GLboolean vp_enabled,
- GLuint mesa_inputs )
-{
- GLuint64EXT inputs = mesa_inputs;
- if (vp_enabled)
- return inputs;
- else
- return (inputs & 0xffff) | ((inputs & 0xffff0000) << 16);
-}
-
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/brw_attrib_tmp.h b/src/mesa/drivers/dri/i965/brw_attrib_tmp.h
deleted file mode 100644
index 3089bd6cac..0000000000
--- a/src/mesa/drivers/dri/i965/brw_attrib_tmp.h
+++ /dev/null
@@ -1,485 +0,0 @@
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-#define ATTR1FV( A, V ) ATTR( A, 1, (V)[0], 0, 0, 1 )
-#define ATTR2FV( A, V ) ATTR( A, 2, (V)[0], (V)[1], 0, 1 )
-#define ATTR3FV( A, V ) ATTR( A, 3, (V)[0], (V)[1], (V)[2], 1 )
-#define ATTR4FV( A, V ) ATTR( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
-
-#define ATTR1F( A, X ) ATTR( A, 1, X, 0, 0, 1 )
-#define ATTR2F( A, X, Y ) ATTR( A, 2, X, Y, 0, 1 )
-#define ATTR3F( A, X, Y, Z ) ATTR( A, 3, X, Y, Z, 1 )
-#define ATTR4F( A, X, Y, Z, W ) ATTR( A, 4, X, Y, Z, W )
-
-#define MAT_ATTR( A, N, V ) ATTR( A, N, (V)[0], (V)[1], (V)[2], (V)[3] )
-
-static void GLAPIENTRY TAG(Vertex2f)( GLfloat x, GLfloat y )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR2F( BRW_ATTRIB_POS, x, y );
-}
-
-static void GLAPIENTRY TAG(Vertex2fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR2FV( BRW_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY TAG(Vertex3f)( GLfloat x, GLfloat y, GLfloat z )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3F( BRW_ATTRIB_POS, x, y, z );
-}
-
-static void GLAPIENTRY TAG(Vertex3fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3FV( BRW_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY TAG(Vertex4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR4F( BRW_ATTRIB_POS, x, y, z, w );
-}
-
-static void GLAPIENTRY TAG(Vertex4fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR4FV( BRW_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY TAG(TexCoord1f)( GLfloat x )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR1F( BRW_ATTRIB_TEX0, x );
-}
-
-static void GLAPIENTRY TAG(TexCoord1fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR1FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY TAG(TexCoord2f)( GLfloat x, GLfloat y )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR2F( BRW_ATTRIB_TEX0, x, y );
-}
-
-static void GLAPIENTRY TAG(TexCoord2fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR2FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY TAG(TexCoord3f)( GLfloat x, GLfloat y, GLfloat z )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3F( BRW_ATTRIB_TEX0, x, y, z );
-}
-
-static void GLAPIENTRY TAG(TexCoord3fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY TAG(TexCoord4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR4F( BRW_ATTRIB_TEX0, x, y, z, w );
-}
-
-static void GLAPIENTRY TAG(TexCoord4fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR4FV( BRW_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY TAG(Normal3f)( GLfloat x, GLfloat y, GLfloat z )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3F( BRW_ATTRIB_NORMAL, x, y, z );
-}
-
-static void GLAPIENTRY TAG(Normal3fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3FV( BRW_ATTRIB_NORMAL, v );
-}
-
-static void GLAPIENTRY TAG(FogCoordfEXT)( GLfloat x )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR1F( BRW_ATTRIB_FOG, x );
-}
-
-static void GLAPIENTRY TAG(FogCoordfvEXT)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR1FV( BRW_ATTRIB_FOG, v );
-}
-
-static void GLAPIENTRY TAG(Color3f)( GLfloat x, GLfloat y, GLfloat z )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3F( BRW_ATTRIB_COLOR0, x, y, z );
-}
-
-static void GLAPIENTRY TAG(Color3fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3FV( BRW_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY TAG(Color4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR4F( BRW_ATTRIB_COLOR0, x, y, z, w );
-}
-
-static void GLAPIENTRY TAG(Color4fv)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR4FV( BRW_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY TAG(SecondaryColor3fEXT)( GLfloat x, GLfloat y, GLfloat z )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3F( BRW_ATTRIB_COLOR1, x, y, z );
-}
-
-static void GLAPIENTRY TAG(SecondaryColor3fvEXT)( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR3FV( BRW_ATTRIB_COLOR1, v );
-}
-
-
-static void GLAPIENTRY TAG(EdgeFlag)( GLboolean b )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR1F( BRW_ATTRIB_EDGEFLAG, (GLfloat)b );
-}
-
-static void GLAPIENTRY TAG(Indexf)( GLfloat f )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR1F( BRW_ATTRIB_INDEX, f );
-}
-
-static void GLAPIENTRY TAG(Indexfv)( const GLfloat *f )
-{
- GET_CURRENT_CONTEXT( ctx );
- ATTR1FV( BRW_ATTRIB_INDEX, f );
-}
-
-
-static void GLAPIENTRY TAG(MultiTexCoord1f)( GLenum target, GLfloat x )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR1F( attr, x );
-}
-
-static void GLAPIENTRY TAG(MultiTexCoord1fv)( GLenum target, const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR1FV( attr, v );
-}
-
-static void GLAPIENTRY TAG(MultiTexCoord2f)( GLenum target, GLfloat x, GLfloat y )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR2F( attr, x, y );
-}
-
-static void GLAPIENTRY TAG(MultiTexCoord2fv)( GLenum target, const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR2FV( attr, v );
-}
-
-static void GLAPIENTRY TAG(MultiTexCoord3f)( GLenum target, GLfloat x, GLfloat y,
- GLfloat z)
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR3F( attr, x, y, z );
-}
-
-static void GLAPIENTRY TAG(MultiTexCoord3fv)( GLenum target, const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR3FV( attr, v );
-}
-
-static void GLAPIENTRY TAG(MultiTexCoord4f)( GLenum target, GLfloat x, GLfloat y,
- GLfloat z, GLfloat w )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR4F( attr, x, y, z, w );
-}
-
-static void GLAPIENTRY TAG(MultiTexCoord4fv)( GLenum target, const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLuint attr = (target & 0x7) + BRW_ATTRIB_TEX0;
- ATTR4FV( attr, v );
-}
-
-
-static void GLAPIENTRY TAG(VertexAttrib1fARB)( GLuint index, GLfloat x )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR1F(0, x);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR1F(BRW_ATTRIB_GENERIC0 + index, x);
- else
- ERROR();
-}
-
-static void GLAPIENTRY TAG(VertexAttrib1fvARB)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR1FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR1FV(BRW_ATTRIB_GENERIC0 + index, v);
- else
- ERROR();
-}
-
-static void GLAPIENTRY TAG(VertexAttrib2fARB)( GLuint index, GLfloat x,
- GLfloat y )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR2F(0, x, y);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR2F(BRW_ATTRIB_GENERIC0 + index, x, y);
- else
- ERROR();
-}
-
-static void GLAPIENTRY TAG(VertexAttrib2fvARB)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR2FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR2FV(BRW_ATTRIB_GENERIC0 + index, v);
- else
- ERROR();
-}
-
-static void GLAPIENTRY TAG(VertexAttrib3fARB)( GLuint index, GLfloat x,
- GLfloat y, GLfloat z )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR3F(0, x, y, z);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR3F(BRW_ATTRIB_GENERIC0 + index, x, y, z);
- else
- ERROR();
-}
-
-static void GLAPIENTRY TAG(VertexAttrib3fvARB)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR3FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR3FV(BRW_ATTRIB_GENERIC0 + index, v);
- else
- ERROR();
-}
-
-static void GLAPIENTRY TAG(VertexAttrib4fARB)( GLuint index, GLfloat x,
- GLfloat y, GLfloat z,
- GLfloat w )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR4F(0, x, y, z, w);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR4F(BRW_ATTRIB_GENERIC0 + index, x, y, z, w);
- else
- ERROR();
-}
-
-static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index == 0)
- ATTR4FV(0, v);
- else if (index < MAX_VERTEX_ATTRIBS)
- ATTR4FV(BRW_ATTRIB_GENERIC0 + index, v);
- else
- ERROR();
-}
-
-
-/* Although we don't export NV_vertex_program, these entrypoints are
- * used by the display list and other code specifically because of
- * their property of aliasing with other attributes.
- */
-static void GLAPIENTRY TAG(VertexAttrib1fNV)( GLuint index, GLfloat x )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR1F(index, x);
-}
-
-static void GLAPIENTRY TAG(VertexAttrib1fvNV)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR1FV(index, v);
-}
-
-static void GLAPIENTRY TAG(VertexAttrib2fNV)( GLuint index, GLfloat x,
- GLfloat y )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR2F(index, x, y);
-}
-
-static void GLAPIENTRY TAG(VertexAttrib2fvNV)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR2FV(index, v);
-}
-
-static void GLAPIENTRY TAG(VertexAttrib3fNV)( GLuint index, GLfloat x,
- GLfloat y, GLfloat z )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR3F(index, x, y, z);
-}
-
-static void GLAPIENTRY TAG(VertexAttrib3fvNV)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR3FV(index, v);
-}
-
-static void GLAPIENTRY TAG(VertexAttrib4fNV)( GLuint index, GLfloat x,
- GLfloat y, GLfloat z,
- GLfloat w )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR4F(index, x, y, z, w);
-}
-
-static void GLAPIENTRY TAG(VertexAttrib4fvNV)( GLuint index,
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- if (index < BRW_ATTRIB_MAX)
- ATTR4FV(index, v);
-}
-
-
-#define MAT( ATTR, N, face, params ) \
-do { \
- if (face != GL_BACK) \
- MAT_ATTR( ATTR, N, params ); /* front */ \
- if (face != GL_FRONT) \
- MAT_ATTR( ATTR + 1, N, params ); /* back */ \
-} while (0)
-
-
-/* Colormaterial conflicts are dealt with later.
- */
-static void GLAPIENTRY TAG(Materialfv)( GLenum face, GLenum pname,
- const GLfloat *params )
-{
- GET_CURRENT_CONTEXT( ctx );
- switch (pname) {
- case GL_EMISSION:
- MAT( BRW_ATTRIB_MAT_FRONT_EMISSION, 4, face, params );
- break;
- case GL_AMBIENT:
- MAT( BRW_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
- break;
- case GL_DIFFUSE:
- MAT( BRW_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
- break;
- case GL_SPECULAR:
- MAT( BRW_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params );
- break;
- case GL_SHININESS:
- MAT( BRW_ATTRIB_MAT_FRONT_SHININESS, 1, face, params );
- break;
- case GL_COLOR_INDEXES:
- MAT( BRW_ATTRIB_MAT_FRONT_INDEXES, 3, face, params );
- break;
- case GL_AMBIENT_AND_DIFFUSE:
- MAT( BRW_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
- MAT( BRW_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
- break;
- default:
- ERROR();
- return;
- }
-}
-
-
-#undef ATTR1FV
-#undef ATTR2FV
-#undef ATTR3FV
-#undef ATTR4FV
-
-#undef ATTR1F
-#undef ATTR2F
-#undef ATTR3F
-#undef ATTR4F
-
-#undef MAT
-#undef MAT_ATTR
diff --git a/src/mesa/drivers/dri/i965/brw_clip.c b/src/mesa/drivers/dri/i965/brw_clip.c
index 0e8591aaa8..3bec153075 100644
--- a/src/mesa/drivers/dri/i965/brw_clip.c
+++ b/src/mesa/drivers/dri/i965/brw_clip.c
@@ -62,6 +62,8 @@ static void compile_clip_prog( struct brw_context *brw,
*/
brw_init_compile(&c.func);
+ c.func.single_program_flow = 1;
+
c.key = *key;
diff --git a/src/mesa/drivers/dri/i965/brw_clip.h b/src/mesa/drivers/dri/i965/brw_clip.h
index c3967c8c61..49b2770a51 100644
--- a/src/mesa/drivers/dri/i965/brw_clip.h
+++ b/src/mesa/drivers/dri/i965/brw_clip.h
@@ -116,7 +116,7 @@ struct brw_clip_compile {
GLuint last_mrf;
GLuint header_position_offset;
- GLuint offset[BRW_ATTRIB_MAX];
+ GLuint offset[VERT_ATTRIB_MAX];
};
#define ATTR_SIZE (4*4)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index bc422c1a50..6faee65542 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -34,8 +34,6 @@
#include "brw_aub.h"
#include "brw_defines.h"
#include "brw_draw.h"
-#include "brw_exec.h"
-#include "brw_save.h"
#include "brw_vs.h"
#include "imports.h"
#include "intel_tex.h"
@@ -158,12 +156,6 @@ GLboolean brwCreateContext( const __GLcontextModes *mesaVis,
brw_FrameBufferTexInit( brw );
- /* Hook our functions into exec and compile dispatch tables. Only
- * fallback on out-of-memory situations.
- */
- brw_exec_init( ctx );
- brw_save_init( ctx );
-
{
const char *filename = getenv("INTEL_REPLAY");
if (filename) {
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index cac4d86d3a..08fdc54520 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -36,7 +36,6 @@
#include "intel_context.h"
#include "brw_structs.h"
#include "imports.h"
-#include "brw_attrib.h"
/* Glossary:
@@ -215,7 +214,7 @@ struct brw_vs_prog_data {
GLuint total_grf;
GLuint outputs_written;
- GLuint64EXT inputs_read;
+ GLuint inputs_read;
/* Used for calculating urb partitions:
*/
@@ -382,10 +381,10 @@ struct brw_cached_batch_item {
-/* Protect against a future where BRW_ATTRIB_MAX > 32. Wouldn't life
+/* Protect against a future where VERT_ATTRIB_MAX > 32. Wouldn't life
* be easier if C allowed arrays of packed elements?
*/
-#define ATTRIB_BIT_DWORDS ((BRW_ATTRIB_MAX+31)/32)
+#define ATTRIB_BIT_DWORDS ((VERT_ATTRIB_MAX+31)/32)
struct brw_vertex_element {
const struct gl_client_array *glarray;
@@ -401,8 +400,8 @@ struct brw_vertex_element {
struct brw_vertex_info {
- GLuint64EXT varying; /* varying:1[BRW_ATTRIB_MAX] */
- GLuint sizes[ATTRIB_BIT_DWORDS * 2]; /* sizes:2[BRW_ATTRIB_MAX] */
+ GLuint varying; /* varying:1[VERT_ATTRIB_MAX] */
+ GLuint sizes[ATTRIB_BIT_DWORDS * 2]; /* sizes:2[VERT_ATTRIB_MAX] */
};
@@ -449,14 +448,13 @@ struct brw_context
struct brw_cached_batch_item *cached_batch_items;
struct {
- /* Fallback values for inputs not supplied:
- */
- struct gl_client_array current_values[BRW_ATTRIB_MAX];
/* Arrays with buffer objects to copy non-bufferobj arrays into
* for upload:
*/
- struct gl_client_array vbo_array[BRW_ATTRIB_MAX];
+ struct gl_client_array vbo_array[VERT_ATTRIB_MAX];
+
+ struct brw_vertex_element inputs[VERT_ATTRIB_MAX];
#define BRW_NR_UPLOAD_BUFS 17
#define BRW_UPLOAD_INIT_SIZE (128*1024)
@@ -469,11 +467,6 @@ struct brw_context
GLuint wrap;
} upload;
- /* Currenly bound arrays, including fallbacks to current_values
- * above:
- */
- struct brw_vertex_element inputs[BRW_ATTRIB_MAX];
-
/* Summary of size and varying of active arrays, so we can check
* for changes to this state:
*/
@@ -505,8 +498,8 @@ struct brw_context
/* Active vertex program:
*/
- struct gl_vertex_program *vertex_program;
- struct gl_fragment_program *fragment_program;
+ const struct gl_vertex_program *vertex_program;
+ const struct gl_fragment_program *fragment_program;
/* For populating the gtt:
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 471fda9f7e..092c6bafc2 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -35,7 +35,6 @@
#include "brw_draw.h"
#include "brw_defines.h"
-#include "brw_attrib.h"
#include "brw_context.h"
#include "brw_aub.h"
#include "brw_state.h"
@@ -45,7 +44,8 @@
#include "intel_batchbuffer.h"
#include "intel_buffer_objects.h"
-
+#include "tnl/tnl.h"
+#include "vbo/vbo_context.h"
@@ -143,7 +143,7 @@ static void brw_emit_cliprect( struct brw_context *brw,
static void brw_emit_prim( struct brw_context *brw,
- const struct brw_draw_prim *prim )
+ const struct _mesa_prim *prim )
{
struct brw_3d_primitive prim_packet;
@@ -170,34 +170,9 @@ static void brw_emit_prim( struct brw_context *brw,
}
}
-
-
-static void update_current_size( struct gl_client_array *array)
-{
- const GLfloat *ptr = (const GLfloat *)array->Ptr;
-
- assert(array->StrideB == 0);
- assert(array->Type == GL_FLOAT || array->Type == GL_UNSIGNED_BYTE);
-
- if (ptr[3] != 1.0)
- array->Size = 4;
- else if (ptr[2] != 0.0)
- array->Size = 3;
- else if (ptr[1] != 0.0)
- array->Size = 2;
- else
- array->Size = 1;
-}
-
-
-
-/* Fill in any gaps in passed arrays with pointers to current
- * attributes:
- */
static void brw_merge_inputs( struct brw_context *brw,
const struct gl_client_array *arrays[])
{
- struct gl_client_array *current_values = brw->vb.current_values;
struct brw_vertex_element *inputs = brw->vb.inputs;
struct brw_vertex_info old = brw->vb.info;
GLuint i;
@@ -205,19 +180,16 @@ static void brw_merge_inputs( struct brw_context *brw,
memset(inputs, 0, sizeof(*inputs));
memset(&brw->vb.info, 0, sizeof(brw->vb.info));
- for (i = 0; i < BRW_ATTRIB_MAX; i++) {
- if (arrays[i] && arrays[i]->Enabled)
- {
- brw->vb.inputs[i].glarray = arrays[i];
- brw->vb.info.varying |= (GLuint64EXT) 1 << i;
- }
- else
- {
- brw->vb.inputs[i].glarray = &current_values[i];
- update_current_size(&current_values[i]);
- }
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ brw->vb.inputs[i].glarray = arrays[i];
+
+ /* XXX: metaops passes null arrays */
+ if (arrays[i]) {
+ if (arrays[i]->StrideB != 0)
+ brw->vb.info.varying |= 1 << i;
- brw->vb.info.sizes[i/16] |= (inputs[i].glarray->Size - 1) << ((i%16) * 2);
+ brw->vb.info.sizes[i/16] |= (inputs[i].glarray->Size - 1) << ((i%16) * 2);
+ }
}
/* Raise statechanges if input sizes and varying have changed:
@@ -229,8 +201,11 @@ static void brw_merge_inputs( struct brw_context *brw,
brw->state.dirty.brw |= BRW_NEW_INPUT_VARYING;
}
+/* XXX: could split the primitive list to fallback only on the
+ * non-conformant primitives.
+ */
static GLboolean check_fallbacks( struct brw_context *brw,
- const struct brw_draw_prim *prim,
+ const struct _mesa_prim *prim,
GLuint nr_prims )
{
GLuint i;
@@ -281,15 +256,16 @@ static GLboolean check_fallbacks( struct brw_context *brw,
return GL_FALSE;
}
-
+/* May fail if out of video memory for texture or vbo upload, or on
+ * fallback conditions.
+ */
static GLboolean brw_try_draw_prims( GLcontext *ctx,
const struct gl_client_array *arrays[],
- const struct brw_draw_prim *prim,
+ const struct _mesa_prim *prim,
GLuint nr_prims,
- const struct brw_draw_index_buffer *ib,
+ const struct _mesa_index_buffer *ib,
GLuint min_index,
- GLuint max_index,
- GLuint flags )
+ GLuint max_index )
{
struct intel_context *intel = intel_context(ctx);
struct brw_context *brw = brw_context(ctx);
@@ -298,11 +274,11 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
if (ctx->NewState)
_mesa_update_state( ctx );
-
+
/* Bind all inputs, derive varying and size information:
*/
brw_merge_inputs( brw, arrays );
-
+
/* Have to validate state quite late. Will rebuild tnl_program,
* which depends on varying information.
*
@@ -319,10 +295,6 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
}
{
- assert(intel->locked);
-
-
-
/* Set the first primitive early, ahead of validate_state:
*/
brw_set_prim(brw, prim[0].mode);
@@ -411,44 +383,88 @@ static GLboolean brw_try_draw_prims( GLcontext *ctx,
return retval;
}
+static GLboolean brw_need_rebase( GLcontext *ctx,
+ const struct gl_client_array *arrays[],
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index )
+{
+ if (min_index == 0)
+ return GL_FALSE;
-GLboolean brw_draw_prims( GLcontext *ctx,
- const struct gl_client_array *arrays[],
- const struct brw_draw_prim *prim,
- GLuint nr_prims,
- const struct brw_draw_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint flags )
+ if (ib) {
+ if (!vbo_all_varyings_in_vbos(arrays))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+ }
+ else {
+ /* Hmm. This isn't quite what I wanted. BRW can actually
+ * handle the mixed case well enough that we shouldn't need to
+ * rebase. However, it's probably not very common, nor hugely
+ * expensive to do it this way:
+ */
+ if (!vbo_all_varyings_in_vbos(arrays))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+ }
+}
+
+
+void brw_draw_prims( GLcontext *ctx,
+ const struct gl_client_array *arrays[],
+ const struct _mesa_prim *prim,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index )
{
struct intel_context *intel = intel_context(ctx);
GLboolean retval;
- retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, flags);
+ /* Decide if we want to rebase. If so we end up recursing once
+ * only into this function.
+ */
+ if (brw_need_rebase( ctx, arrays, ib, min_index )) {
+ vbo_rebase_prims( ctx, arrays,
+ prim, nr_prims,
+ ib, min_index, max_index,
+ brw_draw_prims );
+
+ return;
+ }
-
- if (!retval && bmError(intel)) {
- DBG("retrying\n");
- /* This looks like out-of-memory but potentially we have
- * situation where there is enough memory but it has become
- * fragmented. Clear out all heaps and start from scratch by
- * faking a contended lock event: (done elsewhere)
- */
+ /* Make a first attempt at drawing:
+ */
+ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
+
+ /* This looks like out-of-memory but potentially we have
+ * situation where there is enough memory but it has become
+ * fragmented. Clear out all heaps and start from scratch by
+ * faking a contended lock event: (done elsewhere)
+ */
+ if (!retval && !intel->Fallback && bmError(intel)) {
+ DBG("retrying\n");
/* Then try a second time only to upload textures and draw the
* primitives:
*/
- retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index, flags);
+ retval = brw_try_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
+ }
+
+ /* Otherwise, we really are out of memory. Pass the drawing
+ * command to the software tnl module and which will in turn call
+ * swrast to do the drawing.
+ */
+ if (!retval) {
+ _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib, min_index, max_index);
}
if (intel->aub_file && (INTEL_DEBUG & DEBUG_SYNC)) {
intelFinish( &intel->ctx );
intel->aub_wrap = 1;
}
-
-
- return retval;
}
@@ -461,21 +477,25 @@ static void brw_invalidate_vbo_cb( struct intel_context *intel, void *ptr )
void brw_draw_init( struct brw_context *brw )
{
GLcontext *ctx = &brw->intel.ctx;
+ struct vbo_context *vbo = vbo_context(ctx);
GLuint i;
+ /* Register our drawing function:
+ */
+ vbo->draw_prims = brw_draw_prims;
+
brw->vb.upload.size = BRW_UPLOAD_INIT_SIZE;
for (i = 0; i < BRW_NR_UPLOAD_BUFS; i++) {
brw->vb.upload.vbo[i] = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB);
- /* XXX: Set these to no-backing-store
+ /* NOTE: These are set to no-backing-store.
*/
bmBufferSetInvalidateCB(&brw->intel,
intel_bufferobj_buffer(intel_buffer_object(brw->vb.upload.vbo[i])),
brw_invalidate_vbo_cb,
&brw->intel,
GL_TRUE);
-
}
ctx->Driver.BufferData( ctx,
@@ -484,9 +504,6 @@ void brw_draw_init( struct brw_context *brw )
NULL,
GL_DYNAMIC_DRAW_ARB,
brw->vb.upload.vbo[0] );
-
-
- brw_init_current_values(ctx, brw->vb.current_values);
}
void brw_draw_destroy( struct brw_context *brw )
diff --git a/src/mesa/drivers/dri/i965/brw_draw.h b/src/mesa/drivers/dri/i965/brw_draw.h
index 92640bf725..0f7b738310 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.h
+++ b/src/mesa/drivers/dri/i965/brw_draw.h
@@ -29,44 +29,18 @@
#define BRW_DRAW_H
#include "mtypes.h" /* for GLcontext... */
-#include "brw_attrib.h"
+#include "vbo/vbo.h"
struct brw_context;
-struct brw_draw_prim {
- GLuint mode:8;
- GLuint indexed:1;
- GLuint begin:1;
- GLuint end:1;
- GLuint weak:1;
- GLuint pad:20;
- GLuint start;
- GLuint count;
-};
-
-struct brw_draw_index_buffer {
- GLuint count;
- GLenum type;
- struct gl_buffer_object *obj;
- const void *ptr;
- GLuint rebase;
-};
-
-
-#define BRW_DRAW_SORTED 0x1
-#define BRW_DRAW_ALL_INTERLEAVED 0x2
-#define BRW_DRAW_NON_INTERLEAVED 0x4
-#define BRW_DRAW_LOCKED 0x8
-
-GLboolean brw_draw_prims( GLcontext *ctx,
- const struct gl_client_array *arrays[],
- const struct brw_draw_prim *prims,
- GLuint nr_prims,
- const struct brw_draw_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint flags );
+void brw_draw_prims( GLcontext *ctx,
+ const struct gl_client_array *arrays[],
+ const struct _mesa_prim *prims,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index );
void brw_draw_init( struct brw_context *brw );
void brw_draw_destroy( struct brw_context *brw );
@@ -80,25 +54,12 @@ void brw_init_current_values(GLcontext *ctx,
/* brw_draw_upload.c
*/
void brw_upload_indices( struct brw_context *brw,
- const struct brw_draw_index_buffer *index_buffer);
+ const struct _mesa_index_buffer *index_buffer);
GLboolean brw_upload_vertices( struct brw_context *brw,
GLuint min_index,
GLuint max_index );
-/* Helpers for save, exec. Should probably have their own file:
- */
-struct brw_exec_context;
-struct brw_save_context;
-
-struct brw_exec_save {
- struct brw_exec_context *exec;
- struct brw_save_context *save;
-};
-
-/* Doesn't really belong here:
- */
-#define IMM_CONTEXT(ctx) ((struct brw_exec_save *)((ctx)->swtnl_im))
#endif
diff --git a/src/mesa/drivers/dri/i965/brw_draw_current.c b/src/mesa/drivers/dri/i965/brw_draw_current.c
deleted file mode 100644
index 98d930738e..0000000000
--- a/src/mesa/drivers/dri/i965/brw_draw_current.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * 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"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <stdlib.h>
-
-#include "glheader.h"
-#include "context.h"
-#include "state.h"
-#include "api_validate.h"
-#include "enums.h"
-
-#include "brw_context.h"
-#include "brw_draw.h"
-
-#include "bufmgr.h"
-#include "intel_buffer_objects.h"
-
-
-void brw_init_current_values(GLcontext *ctx,
- struct gl_client_array *arrays)
-{
- GLuint i;
-
- memset(arrays, 0, sizeof(*arrays) * BRW_ATTRIB_MAX);
-
- /* Set up a constant (StrideB == 0) array for each current
- * attribute:
- */
- for (i = 0; i < BRW_ATTRIB_MAX; i++) {
- struct gl_client_array *cl = &arrays[i];
-
- switch (i) {
- case BRW_ATTRIB_MAT_FRONT_SHININESS:
- case BRW_ATTRIB_MAT_BACK_SHININESS:
- case BRW_ATTRIB_INDEX:
- case BRW_ATTRIB_EDGEFLAG:
- cl->Size = 1;
- break;
- case BRW_ATTRIB_MAT_FRONT_INDEXES:
- case BRW_ATTRIB_MAT_BACK_INDEXES:
- cl->Size = 3;
- break;
- default:
- /* This is fixed for the material attributes, for others will
- * be determined at runtime:
- */
- if (i >= BRW_ATTRIB_MAT_FRONT_AMBIENT)
- cl->Size = 4;
- else
- cl->Size = 1;
- break;
- }
-
- switch (i) {
- case BRW_ATTRIB_EDGEFLAG:
- cl->Type = GL_UNSIGNED_BYTE;
- cl->Ptr = (const void *)&ctx->Current.EdgeFlag;
- break;
- case BRW_ATTRIB_INDEX:
- cl->Type = GL_FLOAT;
- cl->Ptr = (const void *)&ctx->Current.Index;
- break;
- default:
- cl->Type = GL_FLOAT;
- if (i < BRW_ATTRIB_FIRST_MATERIAL)
- cl->Ptr = (const void *)ctx->Current.Attrib[i];
- else
- cl->Ptr = (const void *)ctx->Light.Material.Attrib[i - BRW_ATTRIB_FIRST_MATERIAL];
- break;
- }
-
- cl->Stride = 0;
- cl->StrideB = 0;
- cl->Enabled = 1;
- cl->Flags = 0;
- cl->BufferObj = ctx->Array.NullBufferObj;
- }
-}
-
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index 57ee294f0c..6150cac4aa 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -35,7 +35,6 @@
#include "brw_draw.h"
#include "brw_defines.h"
-#include "brw_attrib.h"
#include "brw_context.h"
#include "brw_aub.h"
#include "brw_state.h"
@@ -310,7 +309,6 @@ copy_array_to_vbo_array( struct brw_context *brw,
GLuint i,
const struct gl_client_array *array,
GLuint element_size,
- GLuint min_index,
GLuint count)
{
GLcontext *ctx = &brw->intel.ctx;
@@ -337,7 +335,6 @@ copy_array_to_vbo_array( struct brw_context *brw,
vbo_array->Enabled = 1;
vbo_array->Normalized = array->Normalized;
vbo_array->_MaxElement = array->_MaxElement; /* ? */
- vbo_array->Flags = array->Flags; /* ? */
vbo_array->BufferObj = vbo;
{
@@ -349,7 +346,7 @@ copy_array_to_vbo_array( struct brw_context *brw,
map += offset;
copy_strided_array( map,
- array->Ptr + min_index * array->StrideB,
+ array->Ptr,
element_size,
array->StrideB,
count);
@@ -380,7 +377,6 @@ interleaved_vbo_array( struct brw_context *brw,
vbo_array->Enabled = 1;
vbo_array->Normalized = array->Normalized;
vbo_array->_MaxElement = array->_MaxElement;
- vbo_array->Flags = array->Flags; /* ? */
vbo_array->BufferObj = uploaded_array->BufferObj;
return vbo_array;
@@ -393,17 +389,17 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
{
GLcontext *ctx = &brw->intel.ctx;
struct intel_context *intel = intel_context(ctx);
- GLuint64EXT tmp = brw->vs.prog_data->inputs_read;
+ GLuint tmp = brw->vs.prog_data->inputs_read;
struct brw_vertex_element_packet vep;
struct brw_array_state vbp;
GLuint i;
const void *ptr = NULL;
GLuint interleave = 0;
- struct brw_vertex_element *enabled[BRW_ATTRIB_MAX];
+ struct brw_vertex_element *enabled[VERT_ATTRIB_MAX];
GLuint nr_enabled = 0;
- struct brw_vertex_element *upload[BRW_ATTRIB_MAX];
+ struct brw_vertex_element *upload[VERT_ATTRIB_MAX];
GLuint nr_uploads = 0;
@@ -412,17 +408,19 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
/* First build an array of pointers to ve's in vb.inputs_read
*/
+ if (0)
+ _mesa_printf("%s %d..%d\n", __FUNCTION__, min_index, max_index);
while (tmp) {
- GLuint i = ffsll(tmp)-1;
+ GLuint i = _mesa_ffsll(tmp)-1;
struct brw_vertex_element *input = &brw->vb.inputs[i];
- tmp &= ~((GLuint64EXT)1<<i);
+ tmp &= ~(1<<i);
enabled[nr_enabled++] = input;
input->index = i;
input->element_size = get_size(input->glarray->Type) * input->glarray->Size;
- input->count = input->glarray->StrideB ? max_index - min_index : 1;
+ input->count = input->glarray->StrideB ? max_index + 1 - min_index : 1;
if (!input->glarray->BufferObj->Name) {
if (i == 0) {
@@ -441,10 +439,16 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
}
upload[nr_uploads++] = input;
- input->vbo_rebase_offset = 0;
+
+ /* We rebase drawing to start at element zero only when
+ * varyings are not in vbos, which means we can end up
+ * uploading non-varying arrays (stride != 0) when min_index
+ * is zero. This doesn't matter as the amount to upload is
+ * the same for these arrays whether the draw call is rebased
+ * or not - we just have to upload the one element.
+ */
+ assert(min_index == 0 || input->glarray->StrideB == 0);
}
- else
- input->vbo_rebase_offset = min_index * input->glarray->StrideB;
}
/* Upload interleaved arrays if all uploads are interleaved
@@ -457,7 +461,6 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
input0->glarray = copy_array_to_vbo_array(brw, 0,
input0->glarray,
interleave,
- min_index,
input0->count);
for (i = 1; i < nr_uploads; i++) {
@@ -475,7 +478,6 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
input->glarray = copy_array_to_vbo_array(brw, i,
input->glarray,
input->element_size,
- min_index,
input->count);
}
@@ -523,9 +525,9 @@ GLboolean brw_upload_vertices( struct brw_context *brw,
vbp.vb[i].vb0.bits.pad = 0;
vbp.vb[i].vb0.bits.access_type = BRW_VERTEXBUFFER_ACCESS_VERTEXDATA;
vbp.vb[i].vb0.bits.vb_index = i;
- vbp.vb[i].offset = (GLuint)input->glarray->Ptr + input->vbo_rebase_offset;
+ vbp.vb[i].offset = (GLuint)input->glarray->Ptr;
vbp.vb[i].buffer = array_buffer(input->glarray);
- vbp.vb[i].max_index = max_index - min_index;
+ vbp.vb[i].max_index = max_index;
}
@@ -566,94 +568,32 @@ static GLuint element_size( GLenum type )
-
-static void rebase_indices_to_vbo_indices( struct brw_context *brw,
- const struct brw_draw_index_buffer *index_buffer,
- struct gl_buffer_object **vbo_return,
- GLuint *offset_return )
+void brw_upload_indices( struct brw_context *brw,
+ const struct _mesa_index_buffer *index_buffer )
{
GLcontext *ctx = &brw->intel.ctx;
- GLuint min_index = index_buffer->rebase;
- const void *indices = index_buffer->ptr;
- GLsizei count = index_buffer->count;
- GLenum type = index_buffer->type;
- GLuint size = element_size(type) * count;
- struct gl_buffer_object *bufferobj;
- GLuint offset;
- GLuint i;
-
- get_space(brw, size, &bufferobj, &offset);
+ struct intel_context *intel = &brw->intel;
+ GLuint ib_size = get_size(index_buffer->type) * index_buffer->count;
+ struct gl_buffer_object *bufferobj = index_buffer->obj;
+ GLuint offset = (GLuint)index_buffer->ptr;
- *vbo_return = bufferobj;
- *offset_return = offset;
+ /* Turn into a proper VBO:
+ */
+ if (!bufferobj->Name) {
+
+ /* Get new bufferobj, offset:
+ */
+ get_space(brw, ib_size, &bufferobj, &offset);
- if (min_index == 0) {
/* Straight upload
*/
ctx->Driver.BufferSubData( ctx,
GL_ELEMENT_ARRAY_BUFFER_ARB,
offset,
- size,
- indices,
+ ib_size,
+ index_buffer->ptr,
bufferobj);
}
- else {
- void *map = ctx->Driver.MapBuffer(ctx,
- GL_ELEMENT_ARRAY_BUFFER_ARB,
- GL_DYNAMIC_DRAW_ARB,
- bufferobj);
-
- map += offset;
-
- switch (type) {
- case GL_UNSIGNED_INT: {
- GLuint *ui_map = (GLuint *)map;
- const GLuint *ui_indices = (const GLuint *)indices;
-
- for (i = 0; i < count; i++)
- ui_map[i] = ui_indices[i] - min_index;
- break;
- }
- case GL_UNSIGNED_SHORT: {
- GLushort *us_map = (GLushort *)map;
- const GLushort *us_indices = (const GLushort *)indices;
-
- for (i = 0; i < count; i++)
- us_map[i] = us_indices[i] - min_index;
- break;
- }
- case GL_UNSIGNED_BYTE: {
- GLubyte *ub_map = (GLubyte *)map;
- const GLubyte *ub_indices = (const GLubyte *)indices;
-
- for (i = 0; i < count; i++)
- ub_map[i] = ub_indices[i] - min_index;
- break;
- }
- }
-
- ctx->Driver.UnmapBuffer(ctx,
- GL_ELEMENT_ARRAY_BUFFER_ARB,
- bufferobj);
-
- }
-}
-
-
-
-void brw_upload_indices( struct brw_context *brw,
- const struct brw_draw_index_buffer *index_buffer)
-{
- struct intel_context *intel = &brw->intel;
- GLuint ib_size = get_size(index_buffer->type) * index_buffer->count;
- struct gl_buffer_object *bufferobj = index_buffer->obj;
- GLuint offset = (GLuint)index_buffer->ptr;
-
- /* Already turned into a proper VBO:
- */
- if (!index_buffer->obj->Name) {
- rebase_indices_to_vbo_indices(brw, index_buffer, &bufferobj, &offset );
- }
/* Emit the indexbuffer packet:
*/
diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h
index 1afa0f816b..d4dbcf38a7 100644
--- a/src/mesa/drivers/dri/i965/brw_eu.h
+++ b/src/mesa/drivers/dri/i965/brw_eu.h
@@ -104,6 +104,7 @@ struct brw_compile {
struct brw_instruction *current;
GLuint flag_value;
+ GLboolean single_program_flow;
};
diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c
index 6425c91450..9992b47d8a 100644
--- a/src/mesa/drivers/dri/i965/brw_eu_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c
@@ -464,7 +464,6 @@ struct brw_instruction *brw_JMPI(struct brw_compile *p,
return insn;
}
-
/* EU takes the value from the flag register and pushes it onto some
* sort of a stack (presumably merging with any flag value already on
* the stack). Within an if block, the flags at the top of the stack
@@ -482,7 +481,16 @@ struct brw_instruction *brw_JMPI(struct brw_compile *p,
*/
struct brw_instruction *brw_IF(struct brw_compile *p, GLuint execute_size)
{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_IF);
+ struct brw_instruction *insn;
+
+ if (p->single_program_flow) {
+ assert(execute_size == BRW_EXECUTE_1);
+
+ insn = next_insn(p, BRW_OPCODE_ADD);
+ insn->header.predicate_inverse = 1;
+ } else {
+ insn = next_insn(p, BRW_OPCODE_IF);
+ }
/* Override the defaults for this instruction:
*/
@@ -504,7 +512,13 @@ struct brw_instruction *brw_IF(struct brw_compile *p, GLuint execute_size)
struct brw_instruction *brw_ELSE(struct brw_compile *p,
struct brw_instruction *if_insn)
{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_ELSE);
+ struct brw_instruction *insn;
+
+ if (p->single_program_flow) {
+ insn = next_insn(p, BRW_OPCODE_ADD);
+ } else {
+ insn = next_insn(p, BRW_OPCODE_ELSE);
+ }
brw_set_dest(insn, brw_ip_reg());
brw_set_src0(insn, brw_ip_reg());
@@ -516,11 +530,17 @@ struct brw_instruction *brw_ELSE(struct brw_compile *p,
/* Patch the if instruction to point at this instruction.
*/
- assert(if_insn->header.opcode == BRW_OPCODE_IF);
+ if (p->single_program_flow) {
+ assert(if_insn->header.opcode == BRW_OPCODE_ADD);
- if_insn->bits3.if_else.jump_count = insn - if_insn;
- if_insn->bits3.if_else.pop_count = 1;
- if_insn->bits3.if_else.pad0 = 0;
+ if_insn->bits3.ud = (insn - if_insn + 1) * 16;
+ } else {
+ assert(if_insn->header.opcode == BRW_OPCODE_IF);
+
+ if_insn->bits3.if_else.jump_count = insn - if_insn;
+ if_insn->bits3.if_else.pop_count = 1;
+ if_insn->bits3.if_else.pad0 = 0;
+ }
return insn;
}
@@ -528,63 +548,76 @@ struct brw_instruction *brw_ELSE(struct brw_compile *p,
void brw_ENDIF(struct brw_compile *p,
struct brw_instruction *patch_insn)
{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_ENDIF);
+ if (p->single_program_flow) {
+ /* In single program flow mode, there's no need to execute an ENDIF,
+ * since we don't need to do any stack operations, and if we're executing
+ * currently, we want to just continue executing.
+ */
+ struct brw_instruction *next = &p->store[p->nr_insn];
- brw_set_dest(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src0(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src1(insn, brw_imm_d(0x0));
+ assert(patch_insn->header.opcode == BRW_OPCODE_ADD);
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = patch_insn->header.execution_size;
- insn->header.mask_control = BRW_MASK_ENABLE;
+ patch_insn->bits3.ud = (next - patch_insn) * 16;
+ } else {
+ struct brw_instruction *insn = next_insn(p, BRW_OPCODE_ENDIF);
- assert(patch_insn->bits3.if_else.jump_count == 0);
-
- /* Patch the if or else instructions to point at this or the next
- * instruction respectively.
- */
- if (patch_insn->header.opcode == BRW_OPCODE_IF) {
- /* Automagically turn it into an IFF:
+ brw_set_dest(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
+ brw_set_src0(insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD));
+ brw_set_src1(insn, brw_imm_d(0x0));
+
+ insn->header.compression_control = BRW_COMPRESSION_NONE;
+ insn->header.execution_size = patch_insn->header.execution_size;
+ insn->header.mask_control = BRW_MASK_ENABLE;
+
+ assert(patch_insn->bits3.if_else.jump_count == 0);
+
+ /* Patch the if or else instructions to point at this or the next
+ * instruction respectively.
*/
- patch_insn->header.opcode = BRW_OPCODE_IFF;
- patch_insn->bits3.if_else.jump_count = insn - patch_insn + 1;
- patch_insn->bits3.if_else.pop_count = 0;
- patch_insn->bits3.if_else.pad0 = 0;
+ if (patch_insn->header.opcode == BRW_OPCODE_IF) {
+ /* Automagically turn it into an IFF:
+ */
+ patch_insn->header.opcode = BRW_OPCODE_IFF;
+ patch_insn->bits3.if_else.jump_count = insn - patch_insn + 1;
+ patch_insn->bits3.if_else.pop_count = 0;
+ patch_insn->bits3.if_else.pad0 = 0;
+ } else if (patch_insn->header.opcode == BRW_OPCODE_ELSE) {
+ patch_insn->bits3.if_else.jump_count = insn - patch_insn + 1;
+ patch_insn->bits3.if_else.pop_count = 1;
+ patch_insn->bits3.if_else.pad0 = 0;
+ } else {
+ assert(0);
+ }
+ /* Also pop item off the stack in the endif instruction:
+ */
+ insn->bits3.if_else.jump_count = 0;
+ insn->bits3.if_else.pop_count = 1;
+ insn->bits3.if_else.pad0 = 0;
}
- else if (patch_insn->header.opcode == BRW_OPCODE_ELSE) {
- patch_insn->bits3.if_else.jump_count = insn - patch_insn + 1;
- patch_insn->bits3.if_else.pop_count = 1;
- patch_insn->bits3.if_else.pad0 = 0;
- }
- else {
- assert(0);
- }
-
- /* Also pop item off the stack in the endif instruction:
- */
- insn->bits3.if_else.jump_count = 0;
- insn->bits3.if_else.pop_count = 1;
- insn->bits3.if_else.pad0 = 0;
}
/* DO/WHILE loop:
*/
struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_DO);
+ if (p->single_program_flow) {
+ return &p->store[p->nr_insn];
+ } else {
+ struct brw_instruction *insn = next_insn(p, BRW_OPCODE_DO);
- /* Override the defaults for this instruction:
- */
- brw_set_dest(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src0(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
- brw_set_src1(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
+ /* Override the defaults for this instruction:
+ */
+ brw_set_dest(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
+ brw_set_src0(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
+ brw_set_src1(insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD));
- insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = execute_size;
-/* insn->header.mask_control = BRW_MASK_ENABLE; */
+ insn->header.compression_control = BRW_COMPRESSION_NONE;
+ insn->header.execution_size = execute_size;
+ /* insn->header.mask_control = BRW_MASK_ENABLE; */
- return insn;
+ return insn;
+ }
}
@@ -592,19 +625,31 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
void brw_WHILE(struct brw_compile *p,
struct brw_instruction *do_insn)
{
- struct brw_instruction *insn = next_insn(p, BRW_OPCODE_WHILE);
+ struct brw_instruction *insn;
+
+ if (p->single_program_flow)
+ insn = next_insn(p, BRW_OPCODE_ADD);
+ else
+ insn = next_insn(p, BRW_OPCODE_WHILE);
brw_set_dest(insn, brw_ip_reg());
brw_set_src0(insn, brw_ip_reg());
brw_set_src1(insn, brw_imm_d(0x0));
insn->header.compression_control = BRW_COMPRESSION_NONE;
- insn->header.execution_size = do_insn->header.execution_size;
- assert(do_insn->header.opcode == BRW_OPCODE_DO);
- insn->bits3.if_else.jump_count = do_insn - insn;
- insn->bits3.if_else.pop_count = 0;
- insn->bits3.if_else.pad0 = 0;
+ if (p->single_program_flow) {
+ insn->header.execution_size = BRW_EXECUTE_1;
+
+ insn->bits3.d = (do_insn - insn) * 16;
+ } else {
+ insn->header.execution_size = do_insn->header.execution_size;
+
+ assert(do_insn->header.opcode == BRW_OPCODE_DO);
+ insn->bits3.if_else.jump_count = do_insn - insn;
+ insn->bits3.if_else.pop_count = 0;
+ insn->bits3.if_else.pad0 = 0;
+ }
/* insn->header.mask_control = BRW_MASK_ENABLE; */
diff --git a/src/mesa/drivers/dri/i965/brw_exec.c b/src/mesa/drivers/dri/i965/brw_exec.c
deleted file mode 100644
index fc06c3c361..0000000000
--- a/src/mesa/drivers/dri/i965/brw_exec.c
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "api_arrayelt.h"
-#include "glheader.h"
-#include "imports.h"
-#include "context.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "dlist.h"
-#include "vtxfmt.h"
-
-#include "brw_exec.h"
-
-
-void brw_exec_init( GLcontext *ctx )
-{
- struct brw_exec_context *exec = CALLOC_STRUCT(brw_exec_context);
-
- if (ctx->swtnl_im == NULL) {
- ctx->swtnl_im = CALLOC_STRUCT(brw_exec_save);
- }
-
- exec->ctx = ctx;
- IMM_CONTEXT(ctx)->exec = exec;
-
- /* Initialize the arrayelt helper
- */
- if (!ctx->aelt_context &&
- !_ae_create_context( ctx ))
- return;
-
- brw_exec_vtx_init( exec );
- brw_exec_array_init( exec );
-
- ctx->Driver.NeedFlush = 0;
- ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
- ctx->Driver.FlushVertices = brw_exec_FlushVertices;
-
- exec->eval.recalculate_maps = 1;
-}
-
-
-void brw_exec_destroy( GLcontext *ctx )
-{
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
-
- if (ctx->aelt_context) {
- _ae_destroy_context( ctx );
- ctx->aelt_context = NULL;
- }
-
- brw_exec_vtx_destroy( exec );
- brw_exec_array_destroy( exec );
-
- if (exec) {
- FREE(exec);
- IMM_CONTEXT(ctx)->exec = NULL;
- }
-
- if (IMM_CONTEXT(ctx)->exec == NULL &&
- IMM_CONTEXT(ctx)->save == NULL) {
- FREE(IMM_CONTEXT(ctx));
- ctx->swtnl_im = NULL;
- }
-}
-
-/* Really want to install these callbacks to a central facility to be
- * invoked according to the state flags. That will have to wait for a
- * mesa rework:
- */
-void brw_exec_invalidate_state( GLcontext *ctx, GLuint new_state )
-{
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
-
- if (new_state & (_NEW_PROGRAM|_NEW_EVAL))
- exec->eval.recalculate_maps = 1;
-
- _ae_invalidate_state(ctx, new_state);
-}
-
-
-void brw_exec_wakeup( GLcontext *ctx )
-{
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
-
- ctx->Driver.FlushVertices = brw_exec_FlushVertices;
- ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
-
- /* Hook our functions into exec and compile dispatch tables.
- */
- _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt );
-
- /* Assume we haven't been getting state updates either:
- */
- brw_exec_invalidate_state( ctx, ~0 );
-}
-
-
-
diff --git a/src/mesa/drivers/dri/i965/brw_exec.h b/src/mesa/drivers/dri/i965/brw_exec.h
deleted file mode 100644
index f07b448587..0000000000
--- a/src/mesa/drivers/dri/i965/brw_exec.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- *
- */
-
-#ifndef __BRW_EXEC_H__
-#define __BRW_EXEC_H__
-
-#include "mtypes.h"
-#include "brw_attrib.h"
-#include "brw_draw.h"
-
-
-#define BRW_MAX_PRIM 64
-
-/* Wierd implementation stuff:
- */
-#define BRW_VERT_BUFFER_SIZE (1024*16) /* dwords == 64k */
-#define BRW_MAX_ATTR_CODEGEN 16
-#define ERROR_ATTRIB 16
-
-
-
-
-struct brw_exec_eval1_map {
- struct gl_1d_map *map;
- GLuint sz;
-};
-
-struct brw_exec_eval2_map {
- struct gl_2d_map *map;
- GLuint sz;
-};
-
-
-
-struct brw_exec_copied_vtx {
- GLfloat buffer[BRW_ATTRIB_MAX * 4 * BRW_MAX_COPIED_VERTS];
- GLuint nr;
-};
-
-
-typedef void (*brw_attrfv_func)( const GLfloat * );
-
-
-struct brw_exec_context
-{
- GLcontext *ctx;
- GLvertexformat vtxfmt;
-
- struct {
- struct gl_buffer_object *bufferobj;
- GLubyte *buffer_map;
-
- GLuint vertex_size;
-
- struct brw_draw_prim prim[BRW_MAX_PRIM];
- GLuint prim_count;
-
- GLfloat *vbptr; /* cursor, points into buffer */
- GLfloat vertex[BRW_ATTRIB_MAX*4]; /* current vertex */
-
- GLfloat *current[BRW_ATTRIB_MAX]; /* points into ctx->Current, ctx->Light.Material */
- GLfloat CurrentFloatEdgeFlag;
-
- GLuint vert_count;
- GLuint max_vert;
- struct brw_exec_copied_vtx copied;
-
- GLubyte attrsz[BRW_ATTRIB_MAX];
- GLubyte active_sz[BRW_ATTRIB_MAX];
-
- GLfloat *attrptr[BRW_ATTRIB_MAX];
- struct gl_client_array arrays[BRW_ATTRIB_MAX];
- const struct gl_client_array *inputs[BRW_ATTRIB_MAX];
- } vtx;
-
-
- struct {
- GLboolean recalculate_maps;
- struct brw_exec_eval1_map map1[BRW_ATTRIB_MAX];
- struct brw_exec_eval2_map map2[BRW_ATTRIB_MAX];
- } eval;
-
- struct {
- const struct gl_client_array *inputs[BRW_ATTRIB_MAX];
-
- struct gl_buffer_object *index_obj;
- } array;
-};
-
-
-
-/* External API:
- */
-void brw_exec_init( GLcontext *ctx );
-void brw_exec_destroy( GLcontext *ctx );
-void brw_exec_invalidate_state( GLcontext *ctx, GLuint new_state );
-void brw_exec_FlushVertices( GLcontext *ctx, GLuint flags );
-void brw_exec_wakeup( GLcontext *ctx );
-
-
-/* Internal functions:
- */
-void brw_exec_array_init( struct brw_exec_context *exec );
-void brw_exec_array_destroy( struct brw_exec_context *exec );
-
-
-void brw_exec_vtx_init( struct brw_exec_context *exec );
-void brw_exec_vtx_destroy( struct brw_exec_context *exec );
-void brw_exec_vtx_flush( struct brw_exec_context *exec );
-void brw_exec_vtx_wrap( struct brw_exec_context *exec );
-
-void brw_exec_eval_update( struct brw_exec_context *exec );
-
-void brw_exec_do_EvalCoord2f( struct brw_exec_context *exec,
- GLfloat u, GLfloat v );
-
-void brw_exec_do_EvalCoord1f( struct brw_exec_context *exec,
- GLfloat u);
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/brw_exec_api.c b/src/mesa/drivers/dri/i965/brw_exec_api.c
deleted file mode 100644
index 470fa6f417..0000000000
--- a/src/mesa/drivers/dri/i965/brw_exec_api.c
+++ /dev/null
@@ -1,716 +0,0 @@
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "vtxfmt.h"
-#include "dlist.h"
-#include "state.h"
-#include "light.h"
-#include "api_arrayelt.h"
-#include "api_noop.h"
-#include "dispatch.h"
-
-#include "brw_exec.h"
-
-static void reset_attrfv( struct brw_exec_context *exec );
-
-
-/* Close off the last primitive, execute the buffer, restart the
- * primitive.
- */
-static void brw_exec_wrap_buffers( struct brw_exec_context *exec )
-{
- if (exec->vtx.prim_count == 0) {
- exec->vtx.copied.nr = 0;
- exec->vtx.vert_count = 0;
- exec->vtx.vbptr = (GLfloat *)exec->vtx.buffer_map;
- }
- else {
- GLuint last_begin = exec->vtx.prim[exec->vtx.prim_count-1].begin;
- GLuint last_count;
-
- if (exec->ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
- GLint i = exec->vtx.prim_count - 1;
- assert(i >= 0);
- exec->vtx.prim[i].count = (exec->vtx.vert_count -
- exec->vtx.prim[i].start);
- }
-
- last_count = exec->vtx.prim[exec->vtx.prim_count-1].count;
-
- /* Execute the buffer and save copied vertices.
- */
- if (exec->vtx.vert_count)
- brw_exec_vtx_flush( exec );
- else {
- exec->vtx.prim_count = 0;
- exec->vtx.copied.nr = 0;
- }
-
- /* Emit a glBegin to start the new list.
- */
- assert(exec->vtx.prim_count == 0);
-
- if (exec->ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
- exec->vtx.prim[0].mode = exec->ctx->Driver.CurrentExecPrimitive;
- exec->vtx.prim[0].start = 0;
- exec->vtx.prim[0].count = 0;
- exec->vtx.prim_count++;
-
- if (exec->vtx.copied.nr == last_count)
- exec->vtx.prim[0].begin = last_begin;
- }
- }
-}
-
-
-/* Deal with buffer wrapping where provoked by the vertex buffer
- * filling up, as opposed to upgrade_vertex().
- */
-void brw_exec_vtx_wrap( struct brw_exec_context *exec )
-{
- GLfloat *data = exec->vtx.copied.buffer;
- GLuint i;
-
- /* Run pipeline on current vertices, copy wrapped vertices
- * to exec->vtx.copied.
- */
- brw_exec_wrap_buffers( exec );
-
- /* Copy stored stored vertices to start of new list.
- */
- assert(exec->vtx.max_vert - exec->vtx.vert_count > exec->vtx.copied.nr);
-
- for (i = 0 ; i < exec->vtx.copied.nr ; i++) {
- _mesa_memcpy( exec->vtx.vbptr, data,
- exec->vtx.vertex_size * sizeof(GLfloat));
- exec->vtx.vbptr += exec->vtx.vertex_size;
- data += exec->vtx.vertex_size;
- exec->vtx.vert_count++;
- }
-
- exec->vtx.copied.nr = 0;
-}
-
-
-/*
- * Copy the active vertex's values to the ctx->Current fields.
- */
-static void brw_exec_copy_to_current( struct brw_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
- GLuint i;
-
- for (i = BRW_ATTRIB_POS+1 ; i < BRW_ATTRIB_MAX ; i++) {
- if (exec->vtx.attrsz[i]) {
- /* Note: the exec->vtx.current[i] pointers point into the
- * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays.
- */
- COPY_CLEAN_4V(exec->vtx.current[i],
- exec->vtx.attrsz[i],
- exec->vtx.attrptr[i]);
-
- /* This triggers rather too much recalculation of Mesa state
- * that doesn't get used (eg light positions).
- */
- if (i >= BRW_ATTRIB_MAT_FRONT_AMBIENT &&
- i <= BRW_ATTRIB_MAT_BACK_INDEXES)
- ctx->NewState |= _NEW_LIGHT;
- }
- }
-
- /* color index is special (it's not a float[4] so COPY_CLEAN_4V above
- * will trash adjacent memory!)
- */
- if (exec->vtx.attrsz[BRW_ATTRIB_INDEX]) {
- ctx->Current.Index = exec->vtx.attrptr[BRW_ATTRIB_INDEX][0];
- }
-
- /* Edgeflag requires additional treatment:
- */
- if (exec->vtx.attrsz[BRW_ATTRIB_EDGEFLAG]) {
- ctx->Current.EdgeFlag = (exec->vtx.CurrentFloatEdgeFlag == 1.0);
- }
-
- /* Colormaterial -- this kindof sucks.
- */
- if (ctx->Light.ColorMaterialEnabled &&
- exec->vtx.attrsz[BRW_ATTRIB_COLOR0]) {
- _mesa_update_color_material(ctx,
- ctx->Current.Attrib[BRW_ATTRIB_COLOR0]);
- }
-
- ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
-}
-
-
-static void brw_exec_copy_from_current( struct brw_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
- GLint i;
-
- /* Edgeflag requires additional treatment:
- */
- exec->vtx.CurrentFloatEdgeFlag =
- (GLfloat)ctx->Current.EdgeFlag;
-
- for (i = BRW_ATTRIB_POS+1 ; i < BRW_ATTRIB_MAX ; i++)
- switch (exec->vtx.attrsz[i]) {
- case 4: exec->vtx.attrptr[i][3] = exec->vtx.current[i][3];
- case 3: exec->vtx.attrptr[i][2] = exec->vtx.current[i][2];
- case 2: exec->vtx.attrptr[i][1] = exec->vtx.current[i][1];
- case 1: exec->vtx.attrptr[i][0] = exec->vtx.current[i][0];
- break;
- }
-
- ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
-}
-
-
-/* Flush existing data, set new attrib size, replay copied vertices.
- */
-static void brw_exec_wrap_upgrade_vertex( struct brw_exec_context *exec,
- GLuint attr,
- GLuint newsz )
-{
- GLcontext *ctx = exec->ctx;
- GLint lastcount = exec->vtx.vert_count;
- GLfloat *tmp;
- GLuint oldsz;
- GLuint i;
-
- /* Run pipeline on current vertices, copy wrapped vertices
- * to exec->vtx.copied.
- */
- brw_exec_wrap_buffers( exec );
-
-
- /* Do a COPY_TO_CURRENT to ensure back-copying works for the case
- * when the attribute already exists in the vertex and is having
- * its size increased.
- */
- brw_exec_copy_to_current( exec );
-
-
- /* Heuristic: Attempt to isolate attributes received outside
- * begin/end so that they don't bloat the vertices.
- */
- if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END &&
- exec->vtx.attrsz[attr] == 0 &&
- lastcount > 8 &&
- exec->vtx.vertex_size) {
- reset_attrfv( exec );
- }
-
- /* Fix up sizes:
- */
- oldsz = exec->vtx.attrsz[attr];
- exec->vtx.attrsz[attr] = newsz;
-
- exec->vtx.vertex_size += newsz - oldsz;
- exec->vtx.max_vert = BRW_VERT_BUFFER_SIZE / exec->vtx.vertex_size;
- exec->vtx.vert_count = 0;
- exec->vtx.vbptr = (GLfloat *)exec->vtx.buffer_map;
-
-
- /* Recalculate all the attrptr[] values
- */
- for (i = 0, tmp = exec->vtx.vertex ; i < BRW_ATTRIB_MAX ; i++) {
- if (exec->vtx.attrsz[i]) {
- exec->vtx.attrptr[i] = tmp;
- tmp += exec->vtx.attrsz[i];
- }
- else
- exec->vtx.attrptr[i] = NULL; /* will not be dereferenced */
- }
-
- /* Copy from current to repopulate the vertex with correct values.
- */
- brw_exec_copy_from_current( exec );
-
- /* Replay stored vertices to translate them
- * to new format here.
- *
- * -- No need to replay - just copy piecewise
- */
- if (exec->vtx.copied.nr)
- {
- GLfloat *data = exec->vtx.copied.buffer;
- GLfloat *dest = exec->vtx.vbptr;
- GLuint j;
-
- assert(exec->vtx.vbptr == (GLfloat *)exec->vtx.buffer_map);
-
- for (i = 0 ; i < exec->vtx.copied.nr ; i++) {
- for (j = 0 ; j < BRW_ATTRIB_MAX ; j++) {
- if (exec->vtx.attrsz[j]) {
- if (j == attr) {
- if (oldsz) {
- COPY_CLEAN_4V( dest, oldsz, data );
- data += oldsz;
- dest += newsz;
- } else {
- COPY_SZ_4V( dest, newsz, exec->vtx.current[j] );
- dest += newsz;
- }
- }
- else {
- GLuint sz = exec->vtx.attrsz[j];
- COPY_SZ_4V( dest, sz, data );
- dest += sz;
- data += sz;
- }
- }
- }
- }
-
- exec->vtx.vbptr = dest;
- exec->vtx.vert_count += exec->vtx.copied.nr;
- exec->vtx.copied.nr = 0;
- }
-}
-
-
-static void brw_exec_fixup_vertex( GLcontext *ctx,
- GLuint attr, GLuint sz )
-{
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
- int i;
-
- if (sz > exec->vtx.attrsz[attr]) {
- /* New size is larger. Need to flush existing vertices and get
- * an enlarged vertex format.
- */
- brw_exec_wrap_upgrade_vertex( exec, attr, sz );
- }
- else if (sz < exec->vtx.active_sz[attr]) {
- static const GLfloat id[4] = { 0, 0, 0, 1 };
-
- /* New size is smaller - just need to fill in some
- * zeros. Don't need to flush or wrap.
- */
- for (i = sz ; i <= exec->vtx.attrsz[attr] ; i++)
- exec->vtx.attrptr[attr][i-1] = id[i-1];
- }
-
- exec->vtx.active_sz[attr] = sz;
-
- /* Does setting NeedFlush belong here? Necessitates resetting
- * vtxfmt on each flush (otherwise flags won't get reset
- * afterwards).
- */
- if (attr == 0)
- exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
- else
- exec->ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
-}
-
-
-
-
-/*
- */
-#define ATTR( A, N, V0, V1, V2, V3 ) \
-do { \
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec; \
- \
- if (exec->vtx.active_sz[A] != N) \
- brw_exec_fixup_vertex(ctx, A, N); \
- \
- { \
- GLfloat *dest = exec->vtx.attrptr[A]; \
- if (N>0) dest[0] = V0; \
- if (N>1) dest[1] = V1; \
- if (N>2) dest[2] = V2; \
- if (N>3) dest[3] = V3; \
- } \
- \
- if ((A) == 0) { \
- GLuint i; \
- \
- for (i = 0; i < exec->vtx.vertex_size; i++) \
- exec->vtx.vbptr[i] = exec->vtx.vertex[i]; \
- \
- exec->vtx.vbptr += exec->vtx.vertex_size; \
- exec->ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES; \
- \
- if (++exec->vtx.vert_count >= exec->vtx.max_vert) \
- brw_exec_vtx_wrap( exec ); \
- } \
-} while (0)
-
-
-#define ERROR() _mesa_error( ctx, GL_INVALID_ENUM, __FUNCTION__ )
-#define TAG(x) brw_##x
-
-#include "brw_attrib_tmp.h"
-
-
-
-
-
-/* Eval
- */
-static void GLAPIENTRY brw_exec_EvalCoord1f( GLfloat u )
-{
- GET_CURRENT_CONTEXT( ctx );
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
-
- {
- GLint i;
- if (exec->eval.recalculate_maps)
- brw_exec_eval_update( exec );
-
- for (i = 0 ; i <= BRW_ATTRIB_INDEX ; i++) {
- if (exec->eval.map1[i].map)
- if (exec->vtx.active_sz[i] != exec->eval.map1[i].sz)
- brw_exec_fixup_vertex( ctx, i, exec->eval.map1[i].sz );
- }
- }
-
-
- _mesa_memcpy( exec->vtx.copied.buffer, exec->vtx.vertex,
- exec->vtx.vertex_size * sizeof(GLfloat));
-
- brw_exec_do_EvalCoord1f( exec, u );
-
- _mesa_memcpy( exec->vtx.vertex, exec->vtx.copied.buffer,
- exec->vtx.vertex_size * sizeof(GLfloat));
-}
-
-static void GLAPIENTRY brw_exec_EvalCoord2f( GLfloat u, GLfloat v )
-{
- GET_CURRENT_CONTEXT( ctx );
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
-
- {
- GLint i;
- if (exec->eval.recalculate_maps)
- brw_exec_eval_update( exec );
-
- for (i = 0 ; i <= BRW_ATTRIB_INDEX ; i++) {
- if (exec->eval.map2[i].map)
- if (exec->vtx.active_sz[i] != exec->eval.map2[i].sz)
- brw_exec_fixup_vertex( ctx, i, exec->eval.map2[i].sz );
- }
-
- if (ctx->Eval.AutoNormal)
- if (exec->vtx.active_sz[BRW_ATTRIB_NORMAL] != 3)
- brw_exec_fixup_vertex( ctx, BRW_ATTRIB_NORMAL, 3 );
- }
-
- _mesa_memcpy( exec->vtx.copied.buffer, exec->vtx.vertex,
- exec->vtx.vertex_size * sizeof(GLfloat));
-
- brw_exec_do_EvalCoord2f( exec, u, v );
-
- _mesa_memcpy( exec->vtx.vertex, exec->vtx.copied.buffer,
- exec->vtx.vertex_size * sizeof(GLfloat));
-}
-
-static void GLAPIENTRY brw_exec_EvalCoord1fv( const GLfloat *u )
-{
- brw_exec_EvalCoord1f( u[0] );
-}
-
-static void GLAPIENTRY brw_exec_EvalCoord2fv( const GLfloat *u )
-{
- brw_exec_EvalCoord2f( u[0], u[1] );
-}
-
-static void GLAPIENTRY brw_exec_EvalPoint1( GLint i )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLfloat du = ((ctx->Eval.MapGrid1u2 - ctx->Eval.MapGrid1u1) /
- (GLfloat) ctx->Eval.MapGrid1un);
- GLfloat u = i * du + ctx->Eval.MapGrid1u1;
-
- brw_exec_EvalCoord1f( u );
-}
-
-
-static void GLAPIENTRY brw_exec_EvalPoint2( GLint i, GLint j )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLfloat du = ((ctx->Eval.MapGrid2u2 - ctx->Eval.MapGrid2u1) /
- (GLfloat) ctx->Eval.MapGrid2un);
- GLfloat dv = ((ctx->Eval.MapGrid2v2 - ctx->Eval.MapGrid2v1) /
- (GLfloat) ctx->Eval.MapGrid2vn);
- GLfloat u = i * du + ctx->Eval.MapGrid2u1;
- GLfloat v = j * dv + ctx->Eval.MapGrid2v1;
-
- brw_exec_EvalCoord2f( u, v );
-}
-
-
-/* Build a list of primitives on the fly. Keep
- * ctx->Driver.CurrentExecPrimitive uptodate as well.
- */
-static void GLAPIENTRY brw_exec_Begin( GLenum mode )
-{
- GET_CURRENT_CONTEXT( ctx );
-
- if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) {
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
- int i;
-
- if (ctx->NewState) {
- _mesa_update_state( ctx );
-
- if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
- (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBegin (invalid vertex/fragment program)");
- return;
- }
-
- CALL_Begin(ctx->Exec, (mode));
- return;
- }
-
- /* Heuristic: attempt to isolate attributes occuring outside
- * begin/end pairs.
- */
- if (exec->vtx.vertex_size && !exec->vtx.attrsz[0])
- brw_exec_FlushVertices( ctx, ~0 );
-
- i = exec->vtx.prim_count++;
- exec->vtx.prim[i].mode = mode;
- exec->vtx.prim[i].begin = 1;
- exec->vtx.prim[i].end = 0;
- exec->vtx.prim[i].indexed = 0;
- exec->vtx.prim[i].weak = 0;
- exec->vtx.prim[i].pad = 0;
- exec->vtx.prim[i].start = exec->vtx.vert_count;
- exec->vtx.prim[i].count = 0;
-
- ctx->Driver.CurrentExecPrimitive = mode;
- }
- else
- _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
-
-}
-
-static void GLAPIENTRY brw_exec_End( void )
-{
- GET_CURRENT_CONTEXT( ctx );
-
- if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
- int idx = exec->vtx.vert_count;
- int i = exec->vtx.prim_count - 1;
-
- exec->vtx.prim[i].end = 1;
- exec->vtx.prim[i].count = idx - exec->vtx.prim[i].start;
-
- ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
-
- if (exec->vtx.prim_count == BRW_MAX_PRIM)
- brw_exec_vtx_flush( exec );
- }
- else
- _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
-}
-
-
-static void brw_exec_vtxfmt_init( struct brw_exec_context *exec )
-{
- GLvertexformat *vfmt = &exec->vtxfmt;
-
- vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
- vfmt->Begin = brw_exec_Begin;
- vfmt->CallList = _mesa_CallList;
- vfmt->CallLists = _mesa_CallLists;
- vfmt->End = brw_exec_End;
- vfmt->EvalCoord1f = brw_exec_EvalCoord1f;
- vfmt->EvalCoord1fv = brw_exec_EvalCoord1fv;
- vfmt->EvalCoord2f = brw_exec_EvalCoord2f;
- vfmt->EvalCoord2fv = brw_exec_EvalCoord2fv;
- vfmt->EvalPoint1 = brw_exec_EvalPoint1;
- vfmt->EvalPoint2 = brw_exec_EvalPoint2;
-
- vfmt->Rectf = _mesa_noop_Rectf;
- vfmt->EvalMesh1 = _mesa_noop_EvalMesh1;
- vfmt->EvalMesh2 = _mesa_noop_EvalMesh2;
-
-
- /* from attrib_tmp.h:
- */
- vfmt->Color3f = brw_Color3f;
- vfmt->Color3fv = brw_Color3fv;
- vfmt->Color4f = brw_Color4f;
- vfmt->Color4fv = brw_Color4fv;
- vfmt->FogCoordfEXT = brw_FogCoordfEXT;
- vfmt->FogCoordfvEXT = brw_FogCoordfvEXT;
- vfmt->MultiTexCoord1fARB = brw_MultiTexCoord1f;
- vfmt->MultiTexCoord1fvARB = brw_MultiTexCoord1fv;
- vfmt->MultiTexCoord2fARB = brw_MultiTexCoord2f;
- vfmt->MultiTexCoord2fvARB = brw_MultiTexCoord2fv;
- vfmt->MultiTexCoord3fARB = brw_MultiTexCoord3f;
- vfmt->MultiTexCoord3fvARB = brw_MultiTexCoord3fv;
- vfmt->MultiTexCoord4fARB = brw_MultiTexCoord4f;
- vfmt->MultiTexCoord4fvARB = brw_MultiTexCoord4fv;
- vfmt->Normal3f = brw_Normal3f;
- vfmt->Normal3fv = brw_Normal3fv;
- vfmt->SecondaryColor3fEXT = brw_SecondaryColor3fEXT;
- vfmt->SecondaryColor3fvEXT = brw_SecondaryColor3fvEXT;
- vfmt->TexCoord1f = brw_TexCoord1f;
- vfmt->TexCoord1fv = brw_TexCoord1fv;
- vfmt->TexCoord2f = brw_TexCoord2f;
- vfmt->TexCoord2fv = brw_TexCoord2fv;
- vfmt->TexCoord3f = brw_TexCoord3f;
- vfmt->TexCoord3fv = brw_TexCoord3fv;
- vfmt->TexCoord4f = brw_TexCoord4f;
- vfmt->TexCoord4fv = brw_TexCoord4fv;
- vfmt->Vertex2f = brw_Vertex2f;
- vfmt->Vertex2fv = brw_Vertex2fv;
- vfmt->Vertex3f = brw_Vertex3f;
- vfmt->Vertex3fv = brw_Vertex3fv;
- vfmt->Vertex4f = brw_Vertex4f;
- vfmt->Vertex4fv = brw_Vertex4fv;
-
- vfmt->VertexAttrib1fARB = brw_VertexAttrib1fARB;
- vfmt->VertexAttrib1fvARB = brw_VertexAttrib1fvARB;
- vfmt->VertexAttrib2fARB = brw_VertexAttrib2fARB;
- vfmt->VertexAttrib2fvARB = brw_VertexAttrib2fvARB;
- vfmt->VertexAttrib3fARB = brw_VertexAttrib3fARB;
- vfmt->VertexAttrib3fvARB = brw_VertexAttrib3fvARB;
- vfmt->VertexAttrib4fARB = brw_VertexAttrib4fARB;
- vfmt->VertexAttrib4fvARB = brw_VertexAttrib4fvARB;
-
- vfmt->VertexAttrib1fNV = brw_VertexAttrib1fNV;
- vfmt->VertexAttrib1fvNV = brw_VertexAttrib1fvNV;
- vfmt->VertexAttrib2fNV = brw_VertexAttrib2fNV;
- vfmt->VertexAttrib2fvNV = brw_VertexAttrib2fvNV;
- vfmt->VertexAttrib3fNV = brw_VertexAttrib3fNV;
- vfmt->VertexAttrib3fvNV = brw_VertexAttrib3fvNV;
- vfmt->VertexAttrib4fNV = brw_VertexAttrib4fNV;
- vfmt->VertexAttrib4fvNV = brw_VertexAttrib4fvNV;
-
- vfmt->Materialfv = brw_Materialfv;
-
- vfmt->EdgeFlag = brw_EdgeFlag;
- vfmt->Indexf = brw_Indexf;
- vfmt->Indexfv = brw_Indexfv;
-
-}
-
-
-static void brw_exec_current_init( struct brw_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
- GLint i;
-
- /* setup the pointers for the typical 16 vertex attributes */
- for (i = 0; i < BRW_ATTRIB_FIRST_MATERIAL; i++)
- exec->vtx.current[i] = ctx->Current.Attrib[i];
-
- /* setup pointers for the 12 material attributes */
- for (i = 0; i < MAT_ATTRIB_MAX; i++)
- exec->vtx.current[BRW_ATTRIB_FIRST_MATERIAL + i] =
- ctx->Light.Material.Attrib[i];
-
- exec->vtx.current[BRW_ATTRIB_INDEX] = &ctx->Current.Index;
- exec->vtx.current[BRW_ATTRIB_EDGEFLAG] = &exec->vtx.CurrentFloatEdgeFlag;
-}
-
-void brw_exec_vtx_init( struct brw_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
- GLuint i;
-
- /* Allocate a buffer object. Will just reuse this object
- * continuously.
- */
- exec->vtx.bufferobj = ctx->Array.NullBufferObj;
- exec->vtx.buffer_map = ALIGN_MALLOC(BRW_VERT_BUFFER_SIZE * sizeof(GLfloat), 64);
-
- brw_exec_current_init( exec );
- brw_exec_vtxfmt_init( exec );
-
- /* Hook our functions into the dispatch table.
- */
- _mesa_install_exec_vtxfmt( exec->ctx, &exec->vtxfmt );
-
- for (i = 0 ; i < BRW_ATTRIB_MAX ; i++) {
- exec->vtx.attrsz[i] = 0;
- exec->vtx.active_sz[i] = 0;
- exec->vtx.inputs[i] = &exec->vtx.arrays[i];
- }
-
- exec->vtx.vertex_size = 0;
-}
-
-
-void brw_exec_vtx_destroy( struct brw_exec_context *exec )
-{
- if (exec->vtx.buffer_map) {
- ALIGN_FREE(exec->vtx.buffer_map);
- exec->vtx.buffer_map = NULL;
- }
-}
-
-
-void brw_exec_FlushVertices( GLcontext *ctx, GLuint flags )
-{
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
-
- if (exec->ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END)
- return;
-
- if (exec->vtx.vert_count) {
- brw_exec_vtx_flush( exec );
- }
-
- if (exec->vtx.vertex_size) {
- brw_exec_copy_to_current( exec );
- reset_attrfv( exec );
- }
-
- exec->ctx->Driver.NeedFlush = 0;
-}
-
-
-static void reset_attrfv( struct brw_exec_context *exec )
-{
- GLuint i;
-
- for (i = 0 ; i < BRW_ATTRIB_MAX ; i++) {
- exec->vtx.attrsz[i] = 0;
- exec->vtx.active_sz[i] = 0;
- }
-
- exec->vtx.vertex_size = 0;
-}
-
diff --git a/src/mesa/drivers/dri/i965/brw_exec_array.c b/src/mesa/drivers/dri/i965/brw_exec_array.c
deleted file mode 100644
index ca19a19837..0000000000
--- a/src/mesa/drivers/dri/i965/brw_exec_array.c
+++ /dev/null
@@ -1,283 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
- * 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"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "glheader.h"
-#include "context.h"
-#include "state.h"
-#include "api_validate.h"
-#include "api_noop.h"
-#include "dispatch.h"
-
-#include "brw_attrib.h"
-#include "brw_draw.h"
-#include "brw_exec.h"
-#include "brw_fallback.h"
-
-static GLuint get_max_index( GLuint count, GLuint type,
- const GLvoid *indices )
-{
- GLint i;
-
- /* Compute max element. This is only needed for upload of non-VBO,
- * non-constant data elements.
- *
- * XXX: Postpone this calculation until it is known that it is
- * needed. Otherwise could scan this pointlessly in the all-vbo
- * case.
- */
- switch(type) {
- case GL_UNSIGNED_INT: {
- const GLuint *ui_indices = (const GLuint *)indices;
- GLuint max_ui = 0;
- for (i = 0; i < count; i++)
- if (ui_indices[i] > max_ui)
- max_ui = ui_indices[i];
- return max_ui;
- }
- case GL_UNSIGNED_SHORT: {
- const GLushort *us_indices = (const GLushort *)indices;
- GLuint max_us = 0;
- for (i = 0; i < count; i++)
- if (us_indices[i] > max_us)
- max_us = us_indices[i];
- return max_us;
- }
- case GL_UNSIGNED_BYTE: {
- const GLubyte *ub_indices = (const GLubyte *)indices;
- GLuint max_ub = 0;
- for (i = 0; i < count; i++)
- if (ub_indices[i] > max_ub)
- max_ub = ub_indices[i];
- return max_ub;
- }
- default:
- return 0;
- }
-}
-
-
-
-
-/***********************************************************************
- * API functions.
- */
-
-static void GLAPIENTRY
-brw_exec_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
- struct brw_draw_prim prim[1];
- GLboolean ok;
-
- if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
- return;
-
- FLUSH_CURRENT( ctx, 0 );
-
- if (ctx->NewState)
- _mesa_update_state( ctx );
-
- prim[0].begin = 1;
- prim[0].end = 1;
- prim[0].weak = 0;
- prim[0].pad = 0;
-
- if (exec->array.inputs[0]->BufferObj->Name) {
- /* Use vertex attribute as a hint to tell us if we expect all
- * arrays to be in VBO's and if so, don't worry about avoiding
- * the upload of elements < start.
- */
- prim[0].mode = mode;
- prim[0].start = start;
- prim[0].count = count;
- prim[0].indexed = 0;
-
- ok = brw_draw_prims( ctx, exec->array.inputs, prim, 1, NULL, 0, start + count, 0 );
- }
- else {
- /* If not using VBO's, we don't want to upload any more elements
- * than necessary from the arrays as they will not be valid next
- * time the application tries to draw with them.
- */
- prim[0].mode = mode;
- prim[0].start = 0;
- prim[0].count = count;
- prim[0].indexed = 0;
-
- ok = brw_draw_prims( ctx, exec->array.inputs, prim, 1, NULL, start, start + count, 0 );
- }
-
- if (!ok) {
- brw_fallback(ctx);
- CALL_DrawArrays(ctx->Exec, ( mode, start, count ));
- brw_unfallback(ctx);
- }
-}
-
-
-
-static void GLAPIENTRY
-brw_exec_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type, const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct brw_exec_context *exec = IMM_CONTEXT(ctx)->exec;
- struct brw_draw_index_buffer ib;
- struct brw_draw_prim prim[1];
-
- if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count, type, indices ))
- return;
-
- FLUSH_CURRENT( ctx, 0 );
-
- if (ctx->NewState)
- _mesa_update_state( ctx );
-
- ib.count = count;
- ib.type = type;
- ib.obj = ctx->Array.ElementArrayBufferObj;
- ib.ptr = indices;
-
- if (ctx->Array.ElementArrayBufferObj->Name) {
- /* Use the fact that indices are in a VBO as a hint that the
- * program has put all the arrays in VBO's and we don't have to
- * worry about performance implications of start > 0.
- *
- * XXX: consider passing start as min_index to draw_prims instead.
- */
- ib.rebase = 0;
- }
- else {
- ib.rebase = start;
- }
-
- prim[0].begin = 1;
- prim[0].end = 1;
- prim[0].weak = 0;
- prim[0].pad = 0;
- prim[0].mode = mode;
- prim[0].start = 0;
- prim[0].count = count;
- prim[0].indexed = 1;
-
- if (!brw_draw_prims( ctx, exec->array.inputs, prim, 1, &ib, ib.rebase, end+1, 0 )) {
- brw_fallback(ctx);
- CALL_DrawRangeElements(ctx->Exec, (mode, start, end, count, type, indices));
- brw_unfallback(ctx);
- }
-}
-
-
-static void GLAPIENTRY
-brw_exec_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLuint max_index;
-
- if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
- return;
-
- if (ctx->Array.ElementArrayBufferObj->Name) {
- const GLvoid *map = ctx->Driver.MapBuffer(ctx,
- GL_ELEMENT_ARRAY_BUFFER_ARB,
- GL_DYNAMIC_READ_ARB,
- ctx->Array.ElementArrayBufferObj);
-
- max_index = get_max_index(count, type, ADD_POINTERS(map, indices));
-
- ctx->Driver.UnmapBuffer(ctx,
- GL_ELEMENT_ARRAY_BUFFER_ARB,
- ctx->Array.ElementArrayBufferObj);
- }
- else {
- max_index = get_max_index(count, type, indices);
- }
-
- brw_exec_DrawRangeElements(mode, 0, max_index, count, type, indices);
-}
-
-
-/***********************************************************************
- * Initialization
- */
-
-
-static void init_arrays( GLcontext *ctx,
- const struct gl_client_array *arrays[] )
-{
- struct gl_array_object *obj = ctx->Array.ArrayObj;
- GLuint i;
-
- memset(arrays, 0, sizeof(*arrays) * BRW_ATTRIB_MAX);
-
- arrays[BRW_ATTRIB_POS] = &obj->Vertex;
- arrays[BRW_ATTRIB_NORMAL] = &obj->Normal;
- arrays[BRW_ATTRIB_COLOR0] = &obj->Color;
- arrays[BRW_ATTRIB_COLOR1] = &obj->SecondaryColor;
- arrays[BRW_ATTRIB_FOG] = &obj->FogCoord;
-
- for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
- arrays[BRW_ATTRIB_TEX0 + i] = &obj->TexCoord[i];
-
- arrays[BRW_ATTRIB_INDEX] = &obj->Index;
- arrays[BRW_ATTRIB_EDGEFLAG] = &obj->EdgeFlag;
-
- for (i = BRW_ATTRIB_GENERIC0; i <= BRW_ATTRIB_GENERIC15; i++)
- arrays[i] = &obj->VertexAttrib[i - BRW_ATTRIB_GENERIC0];
-}
-
-
-
-
-void brw_exec_array_init( struct brw_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
-
- init_arrays(ctx, exec->array.inputs);
-
-#if 1
- exec->vtxfmt.DrawArrays = brw_exec_DrawArrays;
- exec->vtxfmt.DrawElements = brw_exec_DrawElements;
- exec->vtxfmt.DrawRangeElements = brw_exec_DrawRangeElements;
-#else
- exec->vtxfmt.DrawArrays = _mesa_noop_DrawArrays;
- exec->vtxfmt.DrawElements = _mesa_noop_DrawElements;
- exec->vtxfmt.DrawRangeElements = _mesa_noop_DrawRangeElements;
-#endif
-
- exec->array.index_obj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB);
-}
-
-
-void brw_exec_array_destroy( struct brw_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
-
- ctx->Driver.DeleteBuffer(ctx, exec->array.index_obj);
-}
diff --git a/src/mesa/drivers/dri/i965/brw_exec_draw.c b/src/mesa/drivers/dri/i965/brw_exec_draw.c
deleted file mode 100644
index 62bda9845b..0000000000
--- a/src/mesa/drivers/dri/i965/brw_exec_draw.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * Copyright (C) 1999-2003 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "enums.h"
-#include "state.h"
-#include "macros.h"
-
-#include "brw_exec.h"
-#include "brw_draw.h"
-#include "brw_fallback.h"
-
-
-static void brw_exec_debug_verts( struct brw_exec_context *exec )
-{
- GLuint count = exec->vtx.vert_count;
- GLuint i;
-
- _mesa_printf("%s: %u vertices %d primitives, %d vertsize\n",
- __FUNCTION__,
- count,
- exec->vtx.prim_count,
- exec->vtx.vertex_size);
-
- for (i = 0 ; i < exec->vtx.prim_count ; i++) {
- struct brw_draw_prim *prim = &exec->vtx.prim[i];
- _mesa_printf(" prim %d: %s%s %d..%d %s %s\n",
- i,
- _mesa_lookup_enum_by_nr(prim->mode),
- prim->weak ? " (weak)" : "",
- prim->start,
- prim->start + prim->count,
- prim->begin ? "BEGIN" : "(wrap)",
- prim->end ? "END" : "(wrap)");
- }
-}
-
-
-/*
- * NOTE: Need to have calculated primitives by this point -- do it on the fly.
- * NOTE: Old 'parity' issue is gone.
- */
-static GLuint brw_copy_vertices( struct brw_exec_context *exec )
-{
- GLuint nr = exec->vtx.prim[exec->vtx.prim_count-1].count;
- GLuint ovf, i;
- GLuint sz = exec->vtx.vertex_size;
- GLfloat *dst = exec->vtx.copied.buffer;
- GLfloat *src = ((GLfloat *)exec->vtx.buffer_map +
- exec->vtx.prim[exec->vtx.prim_count-1].start *
- exec->vtx.vertex_size);
-
-
- switch( exec->ctx->Driver.CurrentExecPrimitive )
- {
- case GL_POINTS:
- return 0;
- case GL_LINES:
- ovf = nr&1;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_TRIANGLES:
- ovf = nr%3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_QUADS:
- ovf = nr&3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_LINE_STRIP:
- if (nr == 0)
- return 0;
- else {
- _mesa_memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) );
- return 1;
- }
- case GL_LINE_LOOP:
- case GL_TRIANGLE_FAN:
- case GL_POLYGON:
- if (nr == 0)
- return 0;
- else if (nr == 1) {
- _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
- return 1;
- } else {
- _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
- _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) );
- return 2;
- }
- case GL_TRIANGLE_STRIP:
- case GL_QUAD_STRIP:
- switch (nr) {
- case 0: ovf = 0; break;
- case 1: ovf = 1; break;
- default: ovf = 2 + (nr&1); break;
- }
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_POLYGON+1:
- return 0;
- default:
- assert(0);
- return 0;
- }
-}
-
-
-/* TODO: populate these as the vertex is defined:
- */
-static void brw_exec_bind_arrays( struct brw_exec_context *exec )
-{
- struct gl_client_array *arrays = exec->vtx.arrays;
- GLuint count = exec->vtx.vert_count;
- GLubyte *data = exec->vtx.buffer_map;
- GLuint attr;
-
- memset(arrays, 0, BRW_ATTRIB_MAX * sizeof(arrays[0]));
-
- /* Make all active attributes (including edgeflag) available as
- * arrays of floats.
- */
- for (attr = 0; attr < BRW_ATTRIB_MAX ; attr++) {
- if (exec->vtx.attrsz[attr]) {
- arrays[attr].Ptr = (void *)data;
- arrays[attr].Size = exec->vtx.attrsz[attr];
- arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
- arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
- arrays[attr].Type = GL_FLOAT;
- arrays[attr].Enabled = 1;
- arrays[attr].BufferObj = exec->vtx.bufferobj; /* NullBufferObj */
- arrays[attr]._MaxElement = count; /* ??? */
-
- data += exec->vtx.attrsz[attr] * sizeof(GLfloat);
- }
- }
-}
-
-
-static
-void brw_exec_loopback_vertex_list( GLcontext *ctx,
- struct brw_exec_context *exec )
-{
- const GLfloat *buffer = (const GLfloat *)exec->vtx.buffer_map;
-
- brw_fallback(ctx);
-
- brw_loopback_vertex_list( ctx,
- buffer,
- exec->vtx.attrsz,
- exec->vtx.prim,
- exec->vtx.prim_count,
- 0, /* XXX - copied.nr */
- exec->vtx.vertex_size);
-
-
- brw_unfallback(ctx);
-}
-
-
-/**
- * Execute the buffer and save copied verts.
- */
-void brw_exec_vtx_flush( struct brw_exec_context *exec )
-{
- if (0)
- brw_exec_debug_verts( exec );
-
-
- if (exec->vtx.prim_count &&
- exec->vtx.vert_count) {
-
- exec->vtx.copied.nr = brw_copy_vertices( exec );
-
- if (exec->vtx.copied.nr != exec->vtx.vert_count) {
- GLcontext *ctx = exec->ctx;
-
- brw_exec_bind_arrays( exec );
-
-
- if (!brw_draw_prims( ctx,
- exec->vtx.inputs,
- exec->vtx.prim,
- exec->vtx.prim_count,
- NULL,
- 0,
- exec->vtx.vert_count,
- 0 )) {
- /* Fallback path:
- */
- brw_exec_loopback_vertex_list(ctx, exec);
- }
- }
- }
-
- exec->vtx.prim_count = 0;
- exec->vtx.vert_count = 0;
- exec->vtx.vbptr = (GLfloat *)exec->vtx.buffer_map;
-}
diff --git a/src/mesa/drivers/dri/i965/brw_exec_eval.c b/src/mesa/drivers/dri/i965/brw_exec_eval.c
deleted file mode 100644
index 9dbeb1b58e..0000000000
--- a/src/mesa/drivers/dri/i965/brw_exec_eval.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "api_eval.h"
-#include "context.h"
-#include "macros.h"
-#include "math/m_eval.h"
-#include "brw_exec.h"
-#include "dispatch.h"
-
-
-static void clear_active_eval1( struct brw_exec_context *exec, GLuint attr )
-{
- exec->eval.map1[attr].map = NULL;
-}
-
-static void clear_active_eval2( struct brw_exec_context *exec, GLuint attr )
-{
- exec->eval.map2[attr].map = NULL;
-}
-
-static void set_active_eval1( struct brw_exec_context *exec, GLuint attr, GLuint dim,
- struct gl_1d_map *map )
-{
- if (!exec->eval.map1[attr].map) {
- exec->eval.map1[attr].map = map;
- exec->eval.map1[attr].sz = dim;
- }
-}
-
-static void set_active_eval2( struct brw_exec_context *exec, GLuint attr, GLuint dim,
- struct gl_2d_map *map )
-{
- if (!exec->eval.map2[attr].map) {
- exec->eval.map2[attr].map = map;
- exec->eval.map2[attr].sz = dim;
- }
-}
-
-void brw_exec_eval_update( struct brw_exec_context *exec )
-{
- GLcontext *ctx = exec->ctx;
- GLuint attr;
-
- /* Vertex program maps have priority over conventional attribs */
-
- for (attr = 0; attr < BRW_ATTRIB_FIRST_MATERIAL; attr++) {
- clear_active_eval1( exec, attr );
- clear_active_eval2( exec, attr );
- }
-
- /* _NEW_PROGRAM */
- if (ctx->VertexProgram._Enabled) {
- for (attr = 0; attr < BRW_ATTRIB_FIRST_MATERIAL; attr++) {
- /* _NEW_EVAL */
- if (ctx->Eval.Map1Attrib[attr])
- set_active_eval1( exec, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
-
- if (ctx->Eval.Map2Attrib[attr])
- set_active_eval2( exec, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
- }
- }
-
- if (ctx->Eval.Map1Color4)
- set_active_eval1( exec, BRW_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map1Color4 );
-
- if (ctx->Eval.Map2Color4)
- set_active_eval2( exec, BRW_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map2Color4 );
-
- if (ctx->Eval.Map1TextureCoord4)
- set_active_eval1( exec, BRW_ATTRIB_TEX0, 4, &ctx->EvalMap.Map1Texture4 );
- else if (ctx->Eval.Map1TextureCoord3)
- set_active_eval1( exec, BRW_ATTRIB_TEX0, 3, &ctx->EvalMap.Map1Texture3 );
- else if (ctx->Eval.Map1TextureCoord2)
- set_active_eval1( exec, BRW_ATTRIB_TEX0, 2, &ctx->EvalMap.Map1Texture2 );
- else if (ctx->Eval.Map1TextureCoord1)
- set_active_eval1( exec, BRW_ATTRIB_TEX0, 1, &ctx->EvalMap.Map1Texture1 );
-
- if (ctx->Eval.Map2TextureCoord4)
- set_active_eval2( exec, BRW_ATTRIB_TEX0, 4, &ctx->EvalMap.Map2Texture4 );
- else if (ctx->Eval.Map2TextureCoord3)
- set_active_eval2( exec, BRW_ATTRIB_TEX0, 3, &ctx->EvalMap.Map2Texture3 );
- else if (ctx->Eval.Map2TextureCoord2)
- set_active_eval2( exec, BRW_ATTRIB_TEX0, 2, &ctx->EvalMap.Map2Texture2 );
- else if (ctx->Eval.Map2TextureCoord1)
- set_active_eval2( exec, BRW_ATTRIB_TEX0, 1, &ctx->EvalMap.Map2Texture1 );
-
- if (ctx->Eval.Map1Normal)
- set_active_eval1( exec, BRW_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map1Normal );
-
- if (ctx->Eval.Map2Normal)
- set_active_eval2( exec, BRW_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map2Normal );
-
- if (ctx->Eval.Map1Vertex4)
- set_active_eval1( exec, BRW_ATTRIB_POS, 4, &ctx->EvalMap.Map1Vertex4 );
- else if (ctx->Eval.Map1Vertex3)
- set_active_eval1( exec, BRW_ATTRIB_POS, 3, &ctx->EvalMap.Map1Vertex3 );
-
- if (ctx->Eval.Map2Vertex4)
- set_active_eval2( exec, BRW_ATTRIB_POS, 4, &ctx->EvalMap.Map2Vertex4 );
- else if (ctx->Eval.Map2Vertex3)
- set_active_eval2( exec, BRW_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 );
-
- exec->eval.recalculate_maps = 0;
-}
-
-
-
-void brw_exec_do_EvalCoord1f(struct brw_exec_context *exec, GLfloat u)
-{
- GLuint attr;
-
- for (attr = 1; attr <= BRW_ATTRIB_INDEX; attr++) {
- struct gl_1d_map *map = exec->eval.map1[attr].map;
- if (map) {
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat data[4];
-
- ASSIGN_4V(data, 0, 0, 0, 1);
-
- _math_horner_bezier_curve(map->Points, data, uu,
- exec->eval.map1[attr].sz,
- map->Order);
-
- COPY_SZ_4V( exec->vtx.attrptr[attr],
- exec->vtx.attrsz[attr],
- data );
- }
- }
-
- /** Vertex -- EvalCoord1f is a noop if this map not enabled:
- **/
- if (exec->eval.map1[0].map) {
- struct gl_1d_map *map = exec->eval.map1[0].map;
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat vertex[4];
-
- ASSIGN_4V(vertex, 0, 0, 0, 1);
-
- _math_horner_bezier_curve(map->Points, vertex, uu,
- exec->eval.map1[0].sz,
- map->Order);
-
- if (exec->eval.map1[0].sz == 4)
- CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
- else
- CALL_Vertex3fv(GET_DISPATCH(), ( vertex ));
- }
-}
-
-
-
-void brw_exec_do_EvalCoord2f( struct brw_exec_context *exec,
- GLfloat u, GLfloat v )
-{
- GLuint attr;
-
- for (attr = 1; attr <= BRW_ATTRIB_INDEX; attr++) {
- struct gl_2d_map *map = exec->eval.map2[attr].map;
- if (map) {
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat vv = (v - map->v1) * map->dv;
- GLfloat data[4];
-
- ASSIGN_4V(data, 0, 0, 0, 1);
-
- _math_horner_bezier_surf(map->Points,
- data,
- uu, vv,
- exec->eval.map2[attr].sz,
- map->Uorder, map->Vorder);
-
- COPY_SZ_4V( exec->vtx.attrptr[attr],
- exec->vtx.attrsz[attr],
- data );
- }
- }
-
- /** Vertex -- EvalCoord2f is a noop if this map not enabled:
- **/
- if (exec->eval.map2[0].map) {
- struct gl_2d_map *map = exec->eval.map2[0].map;
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat vv = (v - map->v1) * map->dv;
- GLfloat vertex[4];
-
- ASSIGN_4V(vertex, 0, 0, 0, 1);
-
- if (exec->ctx->Eval.AutoNormal) {
- GLfloat normal[4];
- GLfloat du[4], dv[4];
-
- _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv,
- exec->eval.map2[0].sz,
- map->Uorder, map->Vorder);
-
- if (exec->eval.map2[0].sz == 4) {
- du[0] = du[0]*vertex[3] - du[3]*vertex[0];
- du[1] = du[1]*vertex[3] - du[3]*vertex[1];
- du[2] = du[2]*vertex[3] - du[3]*vertex[2];
-
- dv[0] = dv[0]*vertex[3] - dv[3]*vertex[0];
- dv[1] = dv[1]*vertex[3] - dv[3]*vertex[1];
- dv[2] = dv[2]*vertex[3] - dv[3]*vertex[2];
- }
-
-
- CROSS3(normal, du, dv);
- NORMALIZE_3FV(normal);
- normal[3] = 1.0;
-
- COPY_SZ_4V( exec->vtx.attrptr[BRW_ATTRIB_NORMAL],
- exec->vtx.attrsz[BRW_ATTRIB_NORMAL],
- normal );
-
- }
- else {
- _math_horner_bezier_surf(map->Points, vertex, uu, vv,
- exec->eval.map2[0].sz,
- map->Uorder, map->Vorder);
- }
-
- if (exec->vtx.attrsz[0] == 4)
- CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
- else
- CALL_Vertex3fv(GET_DISPATCH(), ( vertex ));
- }
-}
-
-
diff --git a/src/mesa/drivers/dri/i965/brw_fallback.c b/src/mesa/drivers/dri/i965/brw_fallback.c
index 56e21e339e..86464b2ec5 100644
--- a/src/mesa/drivers/dri/i965/brw_fallback.c
+++ b/src/mesa/drivers/dri/i965/brw_fallback.c
@@ -30,8 +30,6 @@
#include "tnl/tnl.h"
#include "context.h"
#include "brw_context.h"
-#include "brw_exec.h"
-#include "brw_save.h"
#include "brw_fallback.h"
#include "glheader.h"
@@ -40,297 +38,6 @@
#include "imports.h"
#include "macros.h"
#include "mtypes.h"
-#include "dispatch.h"
-
-
-typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * );
-
-
-/* Wrapper functions in case glVertexAttrib*fvNV doesn't exist */
-static void VertexAttrib1fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib1fvNV(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib2fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib2fvNV(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib3fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib3fvNV(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib4fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib4fvNV(ctx->Exec, (target, v));
-}
-
-static attr_func vert_attrfunc[4] = {
- VertexAttrib1fvNV,
- VertexAttrib2fvNV,
- VertexAttrib3fvNV,
- VertexAttrib4fvNV
-};
-
-#if 0
-static void VertexAttrib1fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib1fvARB(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib2fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib2fvARB(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib3fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib3fvARB(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib4fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib4fvARB(ctx->Exec, (target, v));
-}
-
-
-static attr_func vert_attrfunc_arb[4] = {
- VertexAttrib1fvARB,
- VertexAttrib2fvARB,
- VertexAttrib3fvARB,
- VertexAttrib4fvARB
-};
-#endif
-
-
-
-
-
-
-static void mat_attr1fv( GLcontext *ctx, GLint target, const GLfloat *v )
-{
- switch (target) {
- case BRW_ATTRIB_MAT_FRONT_SHININESS:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SHININESS, v ));
- break;
- case BRW_ATTRIB_MAT_BACK_SHININESS:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SHININESS, v ));
- break;
- }
-}
-
-
-static void mat_attr3fv( GLcontext *ctx, GLint target, const GLfloat *v )
-{
- switch (target) {
- case BRW_ATTRIB_MAT_FRONT_INDEXES:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_COLOR_INDEXES, v ));
- break;
- case BRW_ATTRIB_MAT_BACK_INDEXES:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_COLOR_INDEXES, v ));
- break;
- }
-}
-
-
-static void mat_attr4fv( GLcontext *ctx, GLint target, const GLfloat *v )
-{
- switch (target) {
- case BRW_ATTRIB_MAT_FRONT_EMISSION:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_EMISSION, v ));
- break;
- case BRW_ATTRIB_MAT_BACK_EMISSION:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_EMISSION, v ));
- break;
- case BRW_ATTRIB_MAT_FRONT_AMBIENT:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_AMBIENT, v ));
- break;
- case BRW_ATTRIB_MAT_BACK_AMBIENT:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_AMBIENT, v ));
- break;
- case BRW_ATTRIB_MAT_FRONT_DIFFUSE:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_DIFFUSE, v ));
- break;
- case BRW_ATTRIB_MAT_BACK_DIFFUSE:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_DIFFUSE, v ));
- break;
- case BRW_ATTRIB_MAT_FRONT_SPECULAR:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SPECULAR, v ));
- break;
- case BRW_ATTRIB_MAT_BACK_SPECULAR:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SPECULAR, v ));
- break;
- }
-}
-
-
-static attr_func mat_attrfunc[4] = {
- mat_attr1fv,
- NULL,
- mat_attr3fv,
- mat_attr4fv
-};
-
-
-static void index_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- (void) target;
- CALL_Indexf(ctx->Exec, (v[0]));
-}
-
-static void edgeflag_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- (void) target;
- CALL_EdgeFlag(ctx->Exec, ((GLboolean)(v[0] == 1.0)));
-}
-
-struct loopback_attr {
- GLint target;
- GLint sz;
- attr_func func;
-};
-
-/* Don't emit ends and begins on wrapped primitives. Don't replay
- * wrapped vertices. If we get here, it's probably because the the
- * precalculated wrapping is wrong.
- */
-static void loopback_prim( GLcontext *ctx,
- const GLfloat *buffer,
- const struct brw_draw_prim *prim,
- GLuint wrap_count,
- GLuint vertex_size,
- const struct loopback_attr *la, GLuint nr )
-{
- GLint start = prim->start;
- GLint end = start + prim->count;
- const GLfloat *data;
- GLint j;
- GLuint k;
-
- if (0)
- _mesa_printf("loopback prim %s(%s,%s) verts %d..%d\n",
- _mesa_lookup_enum_by_nr(prim->mode),
- prim->begin ? "begin" : "..",
- prim->end ? "end" : "..",
- start,
- end);
-
- if (prim->begin) {
- CALL_Begin(GET_DISPATCH(), ( prim->mode ));
- }
- else {
- assert(start == 0);
- start += wrap_count;
- }
-
- data = buffer + start * vertex_size;
-
- for (j = start ; j < end ; j++) {
- const GLfloat *tmp = data + la[0].sz;
-
- for (k = 1 ; k < nr ; k++) {
- la[k].func( ctx, la[k].target, tmp );
- tmp += la[k].sz;
- }
-
- /* Fire the vertex
- */
- la[0].func( ctx, BRW_ATTRIB_POS, data );
- data = tmp;
- }
-
- if (prim->end) {
- CALL_End(GET_DISPATCH(), ());
- }
-}
-
-/* Primitives generated by DrawArrays/DrawElements/Rectf may be
- * caught here. If there is no primitive in progress, execute them
- * normally, otherwise need to track and discard the generated
- * primitives.
- */
-static void loopback_weak_prim( GLcontext *ctx,
- const struct brw_draw_prim *prim )
-{
- /* Use the prim_weak flag to ensure that if this primitive
- * wraps, we don't mistake future vertex_lists for part of the
- * surrounding primitive.
- *
- * While this flag is set, we are simply disposing of data
- * generated by an operation now known to be a noop.
- */
- if (prim->begin)
- ctx->Driver.CurrentExecPrimitive |= BRW_SAVE_PRIM_WEAK;
- if (prim->end)
- ctx->Driver.CurrentExecPrimitive &= ~BRW_SAVE_PRIM_WEAK;
-}
-
-
-void brw_loopback_vertex_list( GLcontext *ctx,
- const GLfloat *buffer,
- const GLubyte *attrsz,
- const struct brw_draw_prim *prim,
- GLuint prim_count,
- GLuint wrap_count,
- GLuint vertex_size)
-{
- struct loopback_attr la[BRW_ATTRIB_MAX];
- GLuint i, nr = 0;
-
- for (i = 0 ; i <= BRW_ATTRIB_TEX7 ; i++) {
- if (i == BRW_ATTRIB_INDEX || i == BRW_ATTRIB_EDGEFLAG)
- continue;
-
- if (attrsz[i]) {
- la[nr].target = i;
- la[nr].sz = attrsz[i];
- la[nr].func = vert_attrfunc[attrsz[i]-1];
- nr++;
- }
- }
-
- for (i = BRW_ATTRIB_MAT_FRONT_AMBIENT ;
- i <= BRW_ATTRIB_MAT_BACK_INDEXES ;
- i++) {
- if (attrsz[i]) {
- la[nr].target = i;
- la[nr].sz = attrsz[i];
- la[nr].func = mat_attrfunc[attrsz[i]-1];
- nr++;
- }
- }
-
- if (attrsz[BRW_ATTRIB_EDGEFLAG]) {
- la[nr].target = BRW_ATTRIB_EDGEFLAG;
- la[nr].sz = attrsz[BRW_ATTRIB_EDGEFLAG];
- la[nr].func = edgeflag_attr1fv;
- nr++;
- }
-
- if (attrsz[BRW_ATTRIB_INDEX]) {
- la[nr].target = BRW_ATTRIB_INDEX;
- la[nr].sz = attrsz[BRW_ATTRIB_INDEX];
- la[nr].func = index_attr1fv;
- nr++;
- }
-
- /* XXX ARB vertex attribs */
-
- for (i = 0 ; i < prim_count ; i++) {
- if ((prim[i].mode & BRW_SAVE_PRIM_WEAK) &&
- (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END))
- {
- loopback_weak_prim( ctx, &prim[i] );
- }
- else
- {
- loopback_prim( ctx, buffer, &prim[i], wrap_count, vertex_size, la, nr );
- }
- }
-}
-
@@ -405,62 +112,6 @@ const struct brw_tracked_state brw_check_fallback = {
-/* If there is a fallback, fallback to software rasterization and
- * transformation together. There is never a requirement to have
- * software t&l but hardware rasterization.
- *
- * Further, all fallbacks are based on GL state, not on eg. primitive
- * or vertex data.
- */
-
-static void do_fallback( struct brw_context *brw,
- GLboolean fallback )
-{
- GLcontext *ctx = &brw->intel.ctx;
-
- /* flush:
- */
- ctx->Driver.Flush( ctx );
-
- if (fallback) {
- _swsetup_Wakeup( ctx );
- _tnl_wakeup_exec( ctx );
-
- /* Need this because tnl_wakeup_exec does too much:
- */
- brw_save_wakeup(ctx);
- brw_save_fallback(ctx, GL_TRUE);
- }
- else {
- /* Flush vertices and copy-to-current:
- */
- FLUSH_CURRENT(ctx, 0);
-
- _swrast_flush( ctx );
-
- brw_exec_wakeup(ctx);
-
- /* Need this because tnl_wakeup_exec does too much:
- */
- brw_save_wakeup(ctx);
- brw_save_fallback(ctx, GL_FALSE);
- }
-}
-
-
-void brw_fallback( GLcontext *ctx )
-{
- struct brw_context *brw = brw_context(ctx);
- do_fallback(brw, 1);
-}
-
-
-void brw_unfallback( GLcontext *ctx )
-{
- struct brw_context *brw = brw_context(ctx);
- do_fallback(brw, 0);
-}
-
/* Not used:
*/
void intelFallback( struct intel_context *intel, GLuint bit, GLboolean mode )
diff --git a/src/mesa/drivers/dri/i965/brw_fallback.h b/src/mesa/drivers/dri/i965/brw_fallback.h
index 81a2d344b8..684a46cd17 100644
--- a/src/mesa/drivers/dri/i965/brw_fallback.h
+++ b/src/mesa/drivers/dri/i965/brw_fallback.h
@@ -31,7 +31,7 @@
#include "mtypes.h" /* for GLcontext... */
struct brw_context;
-struct brw_draw_prim;
+struct vbo_prim;
void brw_fallback( GLcontext *ctx );
void brw_unfallback( GLcontext *ctx );
@@ -39,7 +39,7 @@ void brw_unfallback( GLcontext *ctx );
void brw_loopback_vertex_list( GLcontext *ctx,
const GLfloat *buffer,
const GLubyte *attrsz,
- const struct brw_draw_prim *prim,
+ const struct vbo_prim *prim,
GLuint prim_count,
GLuint wrap_count,
GLuint vertex_size);
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index 7d3f9dd5e3..73263a5fff 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -66,7 +66,9 @@ static void compile_gs_prog( struct brw_context *brw,
/* Begin the compilation:
*/
brw_init_compile(&c.func);
-
+
+ c.func.single_program_flow = 1;
+
/* For some reason the thread is spawned with only 4 channels
* unmasked.
*/
@@ -80,6 +82,9 @@ static void compile_gs_prog( struct brw_context *brw,
case GL_QUADS:
brw_gs_quads( &c );
break;
+ case GL_QUAD_STRIP:
+ brw_gs_quad_strip( &c );
+ break;
case GL_LINE_LOOP:
brw_gs_lines( &c );
break;
@@ -143,7 +148,7 @@ static const GLenum gs_prim[GL_POLYGON+1] = {
GL_TRIANGLES,
GL_TRIANGLES,
GL_QUADS,
- GL_QUADS,
+ GL_QUAD_STRIP,
GL_TRIANGLES
};
diff --git a/src/mesa/drivers/dri/i965/brw_gs.h b/src/mesa/drivers/dri/i965/brw_gs.h
index f9aa71d919..29a4e80ce1 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.h
+++ b/src/mesa/drivers/dri/i965/brw_gs.h
@@ -67,6 +67,7 @@ struct brw_gs_compile {
#define ATTR_SIZE (4*4)
void brw_gs_quads( struct brw_gs_compile *c );
+void brw_gs_quad_strip( struct brw_gs_compile *c );
void brw_gs_tris( struct brw_gs_compile *c );
void brw_gs_lines( struct brw_gs_compile *c );
void brw_gs_points( struct brw_gs_compile *c );
diff --git a/src/mesa/drivers/dri/i965/brw_gs_emit.c b/src/mesa/drivers/dri/i965/brw_gs_emit.c
index e4eed36a46..9abb94d82e 100644
--- a/src/mesa/drivers/dri/i965/brw_gs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_gs_emit.c
@@ -116,6 +116,16 @@ void brw_gs_quads( struct brw_gs_compile *c )
brw_gs_emit_vue(c, c->reg.vertex[2], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
}
+void brw_gs_quad_strip( struct brw_gs_compile *c )
+{
+ brw_gs_alloc_regs(c, 4);
+
+ brw_gs_emit_vue(c, c->reg.vertex[2], 0, ((_3DPRIM_POLYGON << 2) | R02_PRIM_START));
+ brw_gs_emit_vue(c, c->reg.vertex[3], 0, (_3DPRIM_POLYGON << 2));
+ brw_gs_emit_vue(c, c->reg.vertex[0], 0, (_3DPRIM_POLYGON << 2));
+ brw_gs_emit_vue(c, c->reg.vertex[1], 1, ((_3DPRIM_POLYGON << 2) | R02_PRIM_END));
+}
+
void brw_gs_tris( struct brw_gs_compile *c )
{
brw_gs_alloc_regs(c, 3);
diff --git a/src/mesa/drivers/dri/i965/brw_metaops.c b/src/mesa/drivers/dri/i965/brw_metaops.c
index 2deec5eae3..1579762b6d 100644
--- a/src/mesa/drivers/dri/i965/brw_metaops.c
+++ b/src/mesa/drivers/dri/i965/brw_metaops.c
@@ -47,7 +47,6 @@
#include "brw_context.h"
#include "brw_defines.h"
#include "brw_draw.h"
-#include "brw_attrib.h"
#include "brw_fallback.h"
#define INIT(brw, STRUCT, ATTRIB) \
@@ -388,8 +387,8 @@ static void meta_draw_quad(struct intel_context *intel,
struct brw_context *brw = brw_context(&intel->ctx);
struct gl_client_array pos_array;
struct gl_client_array color_array;
- struct gl_client_array *attribs[BRW_ATTRIB_MAX];
- struct brw_draw_prim prim[1];
+ struct gl_client_array *attribs[VERT_ATTRIB_MAX];
+ struct _mesa_prim prim[1];
GLfloat pos[4][3];
GLubyte color[4];
@@ -439,29 +438,29 @@ static void meta_draw_quad(struct intel_context *intel,
/* Ignoring texture coords.
*/
- memset(attribs, 0, BRW_ATTRIB_MAX * sizeof(*attribs));
-
- attribs[BRW_ATTRIB_POS] = &pos_array;
- attribs[BRW_ATTRIB_POS]->Ptr = 0;
- attribs[BRW_ATTRIB_POS]->Type = GL_FLOAT;
- attribs[BRW_ATTRIB_POS]->Enabled = 1;
- attribs[BRW_ATTRIB_POS]->Size = 3;
- attribs[BRW_ATTRIB_POS]->StrideB = 3 * sizeof(GLfloat);
- attribs[BRW_ATTRIB_POS]->Stride = 3 * sizeof(GLfloat);
- attribs[BRW_ATTRIB_POS]->_MaxElement = 4;
- attribs[BRW_ATTRIB_POS]->Normalized = 0;
- attribs[BRW_ATTRIB_POS]->BufferObj = brw->metaops.vbo;
-
- attribs[BRW_ATTRIB_COLOR0] = &color_array;
- attribs[BRW_ATTRIB_COLOR0]->Ptr = (const GLubyte *)sizeof(pos);
- attribs[BRW_ATTRIB_COLOR0]->Type = GL_UNSIGNED_BYTE;
- attribs[BRW_ATTRIB_COLOR0]->Enabled = 1;
- attribs[BRW_ATTRIB_COLOR0]->Size = 4;
- attribs[BRW_ATTRIB_COLOR0]->StrideB = 0;
- attribs[BRW_ATTRIB_COLOR0]->Stride = 0;
- attribs[BRW_ATTRIB_COLOR0]->_MaxElement = 1;
- attribs[BRW_ATTRIB_COLOR0]->Normalized = 1;
- attribs[BRW_ATTRIB_COLOR0]->BufferObj = brw->metaops.vbo;
+ memset(attribs, 0, VERT_ATTRIB_MAX * sizeof(*attribs));
+
+ attribs[VERT_ATTRIB_POS] = &pos_array;
+ attribs[VERT_ATTRIB_POS]->Ptr = 0;
+ attribs[VERT_ATTRIB_POS]->Type = GL_FLOAT;
+ attribs[VERT_ATTRIB_POS]->Enabled = 1;
+ attribs[VERT_ATTRIB_POS]->Size = 3;
+ attribs[VERT_ATTRIB_POS]->StrideB = 3 * sizeof(GLfloat);
+ attribs[VERT_ATTRIB_POS]->Stride = 3 * sizeof(GLfloat);
+ attribs[VERT_ATTRIB_POS]->_MaxElement = 4;
+ attribs[VERT_ATTRIB_POS]->Normalized = 0;
+ attribs[VERT_ATTRIB_POS]->BufferObj = brw->metaops.vbo;
+
+ attribs[VERT_ATTRIB_COLOR0] = &color_array;
+ attribs[VERT_ATTRIB_COLOR0]->Ptr = (const GLubyte *)sizeof(pos);
+ attribs[VERT_ATTRIB_COLOR0]->Type = GL_UNSIGNED_BYTE;
+ attribs[VERT_ATTRIB_COLOR0]->Enabled = 1;
+ attribs[VERT_ATTRIB_COLOR0]->Size = 4;
+ attribs[VERT_ATTRIB_COLOR0]->StrideB = 0;
+ attribs[VERT_ATTRIB_COLOR0]->Stride = 0;
+ attribs[VERT_ATTRIB_COLOR0]->_MaxElement = 1;
+ attribs[VERT_ATTRIB_COLOR0]->Normalized = 1;
+ attribs[VERT_ATTRIB_COLOR0]->BufferObj = brw->metaops.vbo;
/* Just ignoring texture coordinates for now.
*/
@@ -476,24 +475,16 @@ static void meta_draw_quad(struct intel_context *intel,
prim[0].start = 0;
prim[0].count = 4;
- if (!brw_draw_prims(&brw->intel.ctx,
- (const struct gl_client_array **)attribs,
- prim, 1,
- NULL,
- 0,
- 4,
- BRW_DRAW_LOCKED ))
- {
- /* This should not be possible:
- */
- _mesa_printf("brw_draw_prims failed in metaops!\n");
- assert(0);
- }
+ brw_draw_prims(&brw->intel.ctx,
+ (const struct gl_client_array **)attribs,
+ prim, 1,
+ NULL,
+ 0,
+ 3 );
}
-static void install_meta_state( struct intel_context *intel,
- GLenum state )
+static void install_meta_state( struct intel_context *intel )
{
GLcontext *ctx = &intel->ctx;
struct brw_context *brw = brw_context(ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_save.c b/src/mesa/drivers/dri/i965/brw_save.c
deleted file mode 100644
index 1af7791c4d..0000000000
--- a/src/mesa/drivers/dri/i965/brw_save.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "mtypes.h"
-#include "api_arrayelt.h"
-#include "dlist.h"
-#include "vtxfmt.h"
-#include "imports.h"
-
-#include "brw_save.h"
-
-
-
-void brw_save_init( GLcontext *ctx )
-{
- struct brw_save_context *save = CALLOC_STRUCT(brw_save_context);
-
- if (ctx->swtnl_im == NULL) {
- ctx->swtnl_im = CALLOC_STRUCT(brw_exec_save);
- }
-
- save->ctx = ctx;
- IMM_CONTEXT(ctx)->save = save;
-
- /* Initialize the arrayelt helper
- */
- if (!ctx->aelt_context &&
- !_ae_create_context( ctx ))
- return;
-
- brw_save_api_init( save );
- brw_save_wakeup(ctx);
-
- ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
-}
-
-
-void brw_save_destroy( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- if (save) {
- FREE(save);
- IMM_CONTEXT(ctx)->save = NULL;
- }
-
- if (ctx->aelt_context) {
- _ae_destroy_context( ctx );
- ctx->aelt_context = NULL;
- }
-
- if (IMM_CONTEXT(ctx)->exec == NULL &&
- IMM_CONTEXT(ctx)->save == NULL) {
- FREE(IMM_CONTEXT(ctx));
- ctx->swtnl_im = NULL;
- }
-}
-
-
-void brw_save_invalidate_state( GLcontext *ctx, GLuint new_state )
-{
- _ae_invalidate_state(ctx, new_state);
-}
-
-
-/* Note that this can occur during the playback of a display list:
- */
-void brw_save_fallback( GLcontext *ctx, GLboolean fallback )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- if (fallback)
- save->replay_flags |= BRW_SAVE_FALLBACK;
- else
- save->replay_flags &= ~BRW_SAVE_FALLBACK;
-}
-
-
-/* I don't see any reason to swap this code out on fallbacks. It
- * wouldn't really mean anything to do so anyway as the old lists are
- * still around from pre-fallback. Instead, the above code ensures
- * that vertices are routed back through immediate mode dispatch on
- * fallback.
- *
- * The below can be moved into init or removed:
- */
-void brw_save_wakeup( GLcontext *ctx )
-{
- ctx->Driver.NewList = brw_save_NewList;
- ctx->Driver.EndList = brw_save_EndList;
- ctx->Driver.SaveFlushVertices = brw_save_SaveFlushVertices;
- ctx->Driver.BeginCallList = brw_save_BeginCallList;
- ctx->Driver.EndCallList = brw_save_EndCallList;
- ctx->Driver.NotifySaveBegin = brw_save_NotifyBegin;
-
- /* Assume we haven't been getting state updates either:
- */
- brw_save_invalidate_state( ctx, ~0 );
-}
-
-
-
diff --git a/src/mesa/drivers/dri/i965/brw_save.h b/src/mesa/drivers/dri/i965/brw_save.h
deleted file mode 100644
index 41cabe6508..0000000000
--- a/src/mesa/drivers/dri/i965/brw_save.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- *
- */
-
-#ifndef BRW_SAVE_H
-#define BRW_SAVE_H
-
-#include "mtypes.h"
-#include "brw_attrib.h"
-#include "brw_draw.h"
-
-
-struct brw_save_copied_vtx {
- GLfloat buffer[BRW_ATTRIB_MAX * 4 * BRW_MAX_COPIED_VERTS];
- GLuint nr;
-};
-
-
-/* For display lists, this structure holds a run of vertices of the
- * same format, and a strictly well-formed set of begin/end pairs,
- * starting on the first vertex and ending at the last. Vertex
- * copying on buffer breaks is precomputed according to these
- * primitives, though there are situations where the copying will need
- * correction at execute-time, perhaps by replaying the list as
- * immediate mode commands.
- *
- * On executing this list, the 'current' values may be updated with
- * the values of the final vertex, and often no fixup of the start of
- * the vertex list is required.
- *
- * Eval and other commands that don't fit into these vertex lists are
- * compiled using the fallback opcode mechanism provided by dlist.c.
- */
-struct brw_save_vertex_list {
- GLubyte attrsz[BRW_ATTRIB_MAX];
- GLuint vertex_size;
-
- GLuint buffer_offset;
- GLuint count;
- GLuint wrap_count; /* number of copied vertices at start */
- GLboolean dangling_attr_ref; /* current attr implicitly referenced
- outside the list */
-
- struct brw_draw_prim *prim;
- GLuint prim_count;
-
- struct brw_save_vertex_store *vertex_store;
- struct brw_save_primitive_store *prim_store;
-};
-
-/* These buffers should be a reasonable size to support upload to
- * hardware. Current brw implementation will re-upload on any
- * changes, so don't make too big or apps which dynamically create
- * dlists and use only a few times will suffer.
- *
- * Consider stategy of uploading regions from the VBO on demand in the
- * case of dynamic vbos. Then make the dlist code signal that
- * likelyhood as it occurs. No reason we couldn't change usage
- * internally even though this probably isn't allowed for client VBOs?
- */
-#define BRW_SAVE_BUFFER_SIZE (8*1024) /* dwords */
-#define BRW_SAVE_PRIM_SIZE 128
-#define BRW_SAVE_PRIM_WEAK 0x40
-
-#define BRW_SAVE_FALLBACK 0x10000000
-
-/* Storage to be shared among several vertex_lists.
- */
-struct brw_save_vertex_store {
- struct gl_buffer_object *bufferobj;
- GLfloat *buffer;
- GLuint used;
- GLuint refcount;
-};
-
-struct brw_save_primitive_store {
- struct brw_draw_prim buffer[BRW_SAVE_PRIM_SIZE];
- GLuint used;
- GLuint refcount;
-};
-
-
-struct brw_save_context {
- GLcontext *ctx;
- GLvertexformat vtxfmt;
- struct gl_client_array arrays[BRW_ATTRIB_MAX];
- const struct gl_client_array *inputs[BRW_ATTRIB_MAX];
-
- GLubyte attrsz[BRW_ATTRIB_MAX];
- GLubyte active_sz[BRW_ATTRIB_MAX];
- GLuint vertex_size;
-
- GLfloat *buffer;
- GLuint count;
- GLuint wrap_count;
- GLuint replay_flags;
-
- struct brw_draw_prim *prim;
- GLuint prim_count, prim_max;
-
- struct brw_save_vertex_store *vertex_store;
- struct brw_save_primitive_store *prim_store;
-
- GLfloat *vbptr; /* cursor, points into buffer */
- GLfloat vertex[BRW_ATTRIB_MAX*4]; /* current values */
- GLfloat *attrptr[BRW_ATTRIB_MAX];
- GLuint vert_count;
- GLuint max_vert;
- GLboolean dangling_attr_ref;
- GLboolean have_materials;
-
- GLuint opcode_vertex_list;
-
- struct brw_save_copied_vtx copied;
-
- GLfloat CurrentFloatEdgeFlag;
-
- GLfloat *current[BRW_ATTRIB_MAX]; /* points into ctx->ListState */
- GLubyte *currentsz[BRW_ATTRIB_MAX];
-};
-
-
-void brw_save_init( GLcontext *ctx );
-void brw_save_destroy( GLcontext *ctx );
-void brw_save_wakeup( GLcontext *ctx );
-void brw_save_invalidate_state( GLcontext *ctx, GLuint new_state );
-void brw_save_fallback( GLcontext *ctx, GLboolean fallback );
-
-/* Callbacks:
- */
-void brw_save_EndList( GLcontext *ctx );
-void brw_save_NewList( GLcontext *ctx, GLuint list, GLenum mode );
-void brw_save_EndCallList( GLcontext *ctx );
-void brw_save_BeginCallList( GLcontext *ctx, struct mesa_display_list *list );
-void brw_save_SaveFlushVertices( GLcontext *ctx );
-GLboolean brw_save_NotifyBegin( GLcontext *ctx, GLenum mode );
-
-void brw_save_playback_vertex_list( GLcontext *ctx, void *data );
-
-void brw_save_api_init( struct brw_save_context *save );
-
-#endif
diff --git a/src/mesa/drivers/dri/i965/brw_save_api.c b/src/mesa/drivers/dri/i965/brw_save_api.c
deleted file mode 100644
index 06ed1d23aa..0000000000
--- a/src/mesa/drivers/dri/i965/brw_save_api.c
+++ /dev/null
@@ -1,1170 +0,0 @@
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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"),
-to deal in the Software without restriction, including without limitation
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, and/or sell copies of the Software, and to permit persons to whom
-the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice (including the next
-paragraph) shall be included in all copies or substantial portions of the
-Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-
-/* Display list compiler attempts to store lists of vertices with the
- * same vertex layout. Additionally it attempts to minimize the need
- * for execute-time fixup of these vertex lists, allowing them to be
- * cached on hardware.
- *
- * There are still some circumstances where this can be thwarted, for
- * example by building a list that consists of one very long primitive
- * (eg Begin(Triangles), 1000 vertices, End), and calling that list
- * from inside a different begin/end object (Begin(Lines), CallList,
- * End).
- *
- * In that case the code will have to replay the list as individual
- * commands through the Exec dispatch table, or fix up the copied
- * vertices at execute-time.
- *
- * The other case where fixup is required is when a vertex attribute
- * is introduced in the middle of a primitive. Eg:
- * Begin(Lines)
- * TexCoord1f() Vertex2f()
- * TexCoord1f() Color3f() Vertex2f()
- * End()
- *
- * If the current value of Color isn't known at compile-time, this
- * primitive will require fixup.
- *
- *
- * The list compiler currently doesn't attempt to compile lists
- * containing EvalCoord or EvalPoint commands. On encountering one of
- * these, compilation falls back to opcodes.
- *
- * This could be improved to fallback only when a mix of EvalCoord and
- * Vertex commands are issued within a single primitive.
- */
-
-
-#include "glheader.h"
-#include "context.h"
-#include "dlist.h"
-#include "enums.h"
-#include "macros.h"
-#include "api_validate.h"
-#include "api_arrayelt.h"
-#include "vtxfmt.h"
-#include "dispatch.h"
-
-#include "brw_save.h"
-#include "brw_fallback.h"
-
-
-
-
-/*
- * NOTE: Old 'parity' issue is gone, but copying can still be
- * wrong-footed on replay.
- */
-static GLuint _save_copy_vertices( GLcontext *ctx,
- const struct brw_save_vertex_list *node,
- const GLfloat *src_buffer)
-{
- struct brw_save_context *save = IMM_CONTEXT( ctx )->save;
- const struct brw_draw_prim *prim = &node->prim[node->prim_count-1];
- GLuint nr = prim->count;
- GLuint sz = save->vertex_size;
- const GLfloat *src = src_buffer + prim->start * sz;
- GLfloat *dst = save->copied.buffer;
- GLuint ovf, i;
-
- if (prim->end)
- return 0;
-
- switch( prim->mode )
- {
- case GL_POINTS:
- return 0;
- case GL_LINES:
- ovf = nr&1;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- case GL_TRIANGLES:
- ovf = nr%3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- case GL_QUADS:
- ovf = nr&3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- case GL_LINE_STRIP:
- if (nr == 0)
- return 0;
- else {
- _mesa_memcpy( dst, src+(nr-1)*sz, sz*sizeof(GLfloat) );
- return 1;
- }
- case GL_LINE_LOOP:
- case GL_TRIANGLE_FAN:
- case GL_POLYGON:
- if (nr == 0)
- return 0;
- else if (nr == 1) {
- _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) );
- return 1;
- } else {
- _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) );
- _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz*sizeof(GLfloat) );
- return 2;
- }
- case GL_TRIANGLE_STRIP:
- case GL_QUAD_STRIP:
- switch (nr) {
- case 0: ovf = 0; break;
- case 1: ovf = 1; break;
- default: ovf = 2 + (nr&1); break;
- }
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- default:
- assert(0);
- return 0;
- }
-}
-
-
-static struct brw_save_vertex_store *alloc_vertex_store( GLcontext *ctx )
-{
- struct brw_save_vertex_store *vertex_store = CALLOC_STRUCT(brw_save_vertex_store);
-
- /* obj->Name needs to be non-zero, but won't ever be examined more
- * closely than that. In particular these buffers won't be entered
- * into the hash and can never be confused with ones visible to the
- * user. Perhaps there could be a special number for internal
- * buffers:
- */
- vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB);
-
- ctx->Driver.BufferData( ctx,
- GL_ARRAY_BUFFER_ARB,
- BRW_SAVE_BUFFER_SIZE * sizeof(GLfloat),
- NULL,
- GL_STATIC_DRAW_ARB,
- vertex_store->bufferobj);
-
- vertex_store->buffer = NULL;
- vertex_store->used = 0;
- vertex_store->refcount = 1;
-
- return vertex_store;
-}
-
-static void free_vertex_store( GLcontext *ctx, struct brw_save_vertex_store *vertex_store )
-{
- assert(!vertex_store->buffer);
-
- if (vertex_store->bufferobj)
- ctx->Driver.DeleteBuffer( ctx, vertex_store->bufferobj );
-
- FREE( vertex_store );
-}
-
-static GLfloat *map_vertex_store( GLcontext *ctx, struct brw_save_vertex_store *vertex_store )
-{
- assert(vertex_store->bufferobj);
- assert(!vertex_store->buffer);
- vertex_store->buffer = (GLfloat *)ctx->Driver.MapBuffer(ctx,
- GL_ARRAY_BUFFER_ARB, /* not used */
- GL_STATIC_DRAW_ARB, /* not used */
- vertex_store->bufferobj);
-
- assert(vertex_store->buffer);
- return vertex_store->buffer + vertex_store->used;
-}
-
-static void unmap_vertex_store( GLcontext *ctx, struct brw_save_vertex_store *vertex_store )
-{
- ctx->Driver.UnmapBuffer( ctx, GL_ARRAY_BUFFER_ARB, vertex_store->bufferobj );
- vertex_store->buffer = NULL;
-}
-
-
-static struct brw_save_primitive_store *alloc_prim_store( GLcontext *ctx )
-{
- struct brw_save_primitive_store *store = CALLOC_STRUCT(brw_save_primitive_store);
- (void) ctx;
- store->used = 0;
- store->refcount = 1;
- return store;
-}
-
-static void _save_reset_counters( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- save->prim = save->prim_store->buffer + save->prim_store->used;
- save->buffer = (save->vertex_store->buffer +
- save->vertex_store->used);
-
- assert(save->buffer == save->vbptr);
-
- if (save->vertex_size)
- save->max_vert = ((BRW_SAVE_BUFFER_SIZE - save->vertex_store->used) /
- save->vertex_size);
- else
- save->max_vert = 0;
-
- save->vert_count = 0;
- save->prim_count = 0;
- save->prim_max = BRW_SAVE_PRIM_SIZE - save->prim_store->used;
- save->dangling_attr_ref = 0;
-}
-
-
-/* Insert the active immediate struct onto the display list currently
- * being built.
- */
-static void _save_compile_vertex_list( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- struct brw_save_vertex_list *node;
-
- /* Allocate space for this structure in the display list currently
- * being compiled.
- */
- node = (struct brw_save_vertex_list *)
- _mesa_alloc_instruction(ctx, save->opcode_vertex_list, sizeof(*node));
-
- if (!node)
- return;
-
- /* Duplicate our template, increment refcounts to the storage structs:
- */
- _mesa_memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz));
- node->vertex_size = save->vertex_size;
- node->buffer_offset = (save->buffer - save->vertex_store->buffer) * sizeof(GLfloat);
- node->count = save->vert_count;
- node->wrap_count = save->copied.nr;
- node->dangling_attr_ref = save->dangling_attr_ref;
- node->prim = save->prim;
- node->prim_count = save->prim_count;
- node->vertex_store = save->vertex_store;
- node->prim_store = save->prim_store;
-
- node->vertex_store->refcount++;
- node->prim_store->refcount++;
-
- assert(node->attrsz[BRW_ATTRIB_POS] != 0 ||
- node->count == 0);
-
- if (save->dangling_attr_ref)
- ctx->ListState.CurrentList->flags |= MESA_DLIST_DANGLING_REFS;
-
- save->vertex_store->used += save->vertex_size * node->count;
- save->prim_store->used += node->prim_count;
-
-
- /* Copy duplicated vertices
- */
- save->copied.nr = _save_copy_vertices( ctx, node, save->buffer );
-
-
- /* Deal with GL_COMPILE_AND_EXECUTE:
- */
- if (ctx->ExecuteFlag) {
- struct _glapi_table *dispatch = GET_DISPATCH();
-
- _glapi_set_dispatch(ctx->Exec);
-
- brw_loopback_vertex_list( ctx,
- (const GLfloat *)((const char *)save->vertex_store->buffer +
- node->buffer_offset),
- node->attrsz,
- node->prim,
- node->prim_count,
- node->wrap_count,
- node->vertex_size);
-
- _glapi_set_dispatch(dispatch);
- }
-
-
- /* Decide whether the storage structs are full, or can be used for
- * the next vertex lists as well.
- */
- if (save->vertex_store->used >
- BRW_SAVE_BUFFER_SIZE - 16 * (save->vertex_size + 4)) {
-
- /* Unmap old store:
- */
- unmap_vertex_store( ctx, save->vertex_store );
-
- /* Release old reference:
- */
- save->vertex_store->refcount--;
- assert(save->vertex_store->refcount != 0);
- save->vertex_store = NULL;
-
- /* Allocate and map new store:
- */
- save->vertex_store = alloc_vertex_store( ctx );
- save->vbptr = map_vertex_store( ctx, save->vertex_store );
- }
-
- if (save->prim_store->used > BRW_SAVE_PRIM_SIZE - 6) {
- save->prim_store->refcount--;
- assert(save->prim_store->refcount != 0);
- save->prim_store = alloc_prim_store( ctx );
- }
-
- /* Reset our structures for the next run of vertices:
- */
- _save_reset_counters( ctx );
-}
-
-
-/* TODO -- If no new vertices have been stored, don't bother saving
- * it.
- */
-static void _save_wrap_buffers( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLint i = save->prim_count - 1;
- GLenum mode;
- GLboolean weak;
-
- assert(i < (GLint) save->prim_max);
- assert(i >= 0);
-
- /* Close off in-progress primitive.
- */
- save->prim[i].count = (save->vert_count -
- save->prim[i].start);
- mode = save->prim[i].mode;
- weak = save->prim[i].weak;
-
- /* store the copied vertices, and allocate a new list.
- */
- _save_compile_vertex_list( ctx );
-
- /* Restart interrupted primitive
- */
- save->prim[0].mode = mode;
- save->prim[0].weak = weak;
- save->prim[0].begin = 0;
- save->prim[0].end = 0;
- save->prim[0].pad = 0;
- save->prim[0].start = 0;
- save->prim[0].count = 0;
- save->prim_count = 1;
-}
-
-
-
-/* Called only when buffers are wrapped as the result of filling the
- * vertex_store struct.
- */
-static void _save_wrap_filled_vertex( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLfloat *data = save->copied.buffer;
- GLuint i;
-
- /* Emit a glEnd to close off the last vertex list.
- */
- _save_wrap_buffers( ctx );
-
- /* Copy stored stored vertices to start of new list.
- */
- assert(save->max_vert - save->vert_count > save->copied.nr);
-
- for (i = 0 ; i < save->copied.nr ; i++) {
- _mesa_memcpy( save->vbptr, data, save->vertex_size * sizeof(GLfloat));
- data += save->vertex_size;
- save->vbptr += save->vertex_size;
- save->vert_count++;
- }
-}
-
-
-static void _save_copy_to_current( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLuint i;
-
- for (i = BRW_ATTRIB_POS+1 ; i < BRW_ATTRIB_MAX ; i++) {
- if (save->attrsz[i]) {
- save->currentsz[i][0] = save->attrsz[i];
- COPY_CLEAN_4V(save->current[i],
- save->attrsz[i],
- save->attrptr[i]);
- }
- }
-
- /* Edgeflag requires special treatment:
- *
- * TODO: change edgeflag to GLfloat in Mesa.
- */
- if (save->attrsz[BRW_ATTRIB_EDGEFLAG]) {
- ctx->ListState.ActiveEdgeFlag = 1;
- save->CurrentFloatEdgeFlag =
- save->attrptr[BRW_ATTRIB_EDGEFLAG][0];
- ctx->ListState.CurrentEdgeFlag =
- (save->CurrentFloatEdgeFlag == 1.0);
- }
-}
-
-
-static void _save_copy_from_current( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLint i;
-
- for (i = BRW_ATTRIB_POS+1 ; i < BRW_ATTRIB_MAX ; i++)
- switch (save->attrsz[i]) {
- case 4: save->attrptr[i][3] = save->current[i][3];
- case 3: save->attrptr[i][2] = save->current[i][2];
- case 2: save->attrptr[i][1] = save->current[i][1];
- case 1: save->attrptr[i][0] = save->current[i][0];
- case 0: break;
- }
-
- /* Edgeflag requires special treatment:
- */
- if (save->attrsz[BRW_ATTRIB_EDGEFLAG]) {
- save->CurrentFloatEdgeFlag = (GLfloat)ctx->ListState.CurrentEdgeFlag;
- save->attrptr[BRW_ATTRIB_EDGEFLAG][0] = save->CurrentFloatEdgeFlag;
- }
-}
-
-
-
-
-/* Flush existing data, set new attrib size, replay copied vertices.
- */
-static void _save_upgrade_vertex( GLcontext *ctx,
- GLuint attr,
- GLuint newsz )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLuint oldsz;
- GLuint i;
- GLfloat *tmp;
-
- /* Store the current run of vertices, and emit a GL_END. Emit a
- * BEGIN in the new buffer.
- */
- if (save->vert_count)
- _save_wrap_buffers( ctx );
- else
- assert( save->copied.nr == 0 );
-
- /* Do a COPY_TO_CURRENT to ensure back-copying works for the case
- * when the attribute already exists in the vertex and is having
- * its size increased.
- */
- _save_copy_to_current( ctx );
-
- /* Fix up sizes:
- */
- oldsz = save->attrsz[attr];
- save->attrsz[attr] = newsz;
-
- save->vertex_size += newsz - oldsz;
- save->max_vert = ((BRW_SAVE_BUFFER_SIZE - save->vertex_store->used) /
- save->vertex_size);
- save->vert_count = 0;
-
- /* Recalculate all the attrptr[] values:
- */
- for (i = 0, tmp = save->vertex ; i < BRW_ATTRIB_MAX ; i++) {
- if (save->attrsz[i]) {
- save->attrptr[i] = tmp;
- tmp += save->attrsz[i];
- }
- else
- save->attrptr[i] = NULL; /* will not be dereferenced. */
- }
-
- /* Copy from current to repopulate the vertex with correct values.
- */
- _save_copy_from_current( ctx );
-
- /* Replay stored vertices to translate them to new format here.
- *
- * If there are copied vertices and the new (upgraded) attribute
- * has not been defined before, this list is somewhat degenerate,
- * and will need fixup at runtime.
- */
- if (save->copied.nr)
- {
- GLfloat *data = save->copied.buffer;
- GLfloat *dest = save->buffer;
- GLuint j;
-
- /* Need to note this and fix up at runtime (or loopback):
- */
- if (attr != BRW_ATTRIB_POS && save->currentsz[attr][0] == 0) {
- assert(oldsz == 0);
- save->dangling_attr_ref = GL_TRUE;
- }
-
- for (i = 0 ; i < save->copied.nr ; i++) {
- for (j = 0 ; j < BRW_ATTRIB_MAX ; j++) {
- if (save->attrsz[j]) {
- if (j == attr) {
- if (oldsz) {
- COPY_CLEAN_4V( dest, oldsz, data );
- data += oldsz;
- dest += newsz;
- }
- else {
- COPY_SZ_4V( dest, newsz, save->current[attr] );
- dest += newsz;
- }
- }
- else {
- GLint sz = save->attrsz[j];
- COPY_SZ_4V( dest, sz, data );
- data += sz;
- dest += sz;
- }
- }
- }
- }
-
- save->vbptr = dest;
- save->vert_count += save->copied.nr;
- }
-}
-
-static void save_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- if (sz > save->attrsz[attr]) {
- /* New size is larger. Need to flush existing vertices and get
- * an enlarged vertex format.
- */
- _save_upgrade_vertex( ctx, attr, sz );
- }
- else if (sz < save->active_sz[attr]) {
- static GLfloat id[4] = { 0, 0, 0, 1 };
- GLuint i;
-
- /* New size is equal or smaller - just need to fill in some
- * zeros.
- */
- for (i = sz ; i <= save->attrsz[attr] ; i++)
- save->attrptr[attr][i-1] = id[i-1];
- }
-
- save->active_sz[attr] = sz;
-}
-
-static void _save_reset_vertex( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLuint i;
-
- for (i = 0 ; i < BRW_ATTRIB_MAX ; i++) {
- save->attrsz[i] = 0;
- save->active_sz[i] = 0;
- }
-
- save->vertex_size = 0;
-}
-
-
-
-#define ERROR() _mesa_compile_error( ctx, GL_INVALID_ENUM, __FUNCTION__ );
-
-
-/* Only one size for each attribute may be active at once. Eg. if
- * Color3f is installed/active, then Color4f may not be, even if the
- * vertex actually contains 4 color coordinates. This is because the
- * 3f version won't otherwise set color[3] to 1.0 -- this is the job
- * of the chooser function when switching between Color4f and Color3f.
- */
-#define ATTR( A, N, V0, V1, V2, V3 ) \
-do { \
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save; \
- \
- if (save->active_sz[A] != N) \
- save_fixup_vertex(ctx, A, N); \
- \
- { \
- GLfloat *dest = save->attrptr[A]; \
- if (N>0) dest[0] = V0; \
- if (N>1) dest[1] = V1; \
- if (N>2) dest[2] = V2; \
- if (N>3) dest[3] = V3; \
- } \
- \
- if ((A) == 0) { \
- GLuint i; \
- \
- for (i = 0; i < save->vertex_size; i++) \
- save->vbptr[i] = save->vertex[i]; \
- \
- save->vbptr += save->vertex_size; \
- \
- if (++save->vert_count >= save->max_vert) \
- _save_wrap_filled_vertex( ctx ); \
- } \
-} while (0)
-
-#define TAG(x) _save_##x
-
-#include "brw_attrib_tmp.h"
-
-
-
-
-/* Cope with EvalCoord/CallList called within a begin/end object:
- * -- Flush current buffer
- * -- Fallback to opcodes for the rest of the begin/end object.
- */
-#define DO_FALLBACK(ctx) \
-do { \
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save; \
- \
- if (save->vert_count || save->prim_count) \
- _save_compile_vertex_list( ctx ); \
- \
- _save_copy_to_current( ctx ); \
- _save_reset_vertex( ctx ); \
- _save_reset_counters( ctx ); \
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); \
- ctx->Driver.SaveNeedFlush = 0; \
-} while (0)
-
-static void GLAPIENTRY _save_EvalCoord1f( GLfloat u )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->EvalCoord1f( u );
-}
-
-static void GLAPIENTRY _save_EvalCoord1fv( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->EvalCoord1fv( v );
-}
-
-static void GLAPIENTRY _save_EvalCoord2f( GLfloat u, GLfloat v )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->EvalCoord2f( u, v );
-}
-
-static void GLAPIENTRY _save_EvalCoord2fv( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->EvalCoord2fv( v );
-}
-
-static void GLAPIENTRY _save_EvalPoint1( GLint i )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->EvalPoint1( i );
-}
-
-static void GLAPIENTRY _save_EvalPoint2( GLint i, GLint j )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->EvalPoint2( i, j );
-}
-
-static void GLAPIENTRY _save_CallList( GLuint l )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->CallList( l );
-}
-
-static void GLAPIENTRY _save_CallLists( GLsizei n, GLenum type, const GLvoid *v )
-{
- GET_CURRENT_CONTEXT(ctx);
- DO_FALLBACK(ctx);
- ctx->Save->CallLists( n, type, v );
-}
-
-
-
-
-/* This begin is hooked into ... Updating of
- * ctx->Driver.CurrentSavePrimitive is already taken care of.
- */
-GLboolean brw_save_NotifyBegin( GLcontext *ctx, GLenum mode )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- GLuint i = save->prim_count++;
-
- assert(i < save->prim_max);
- save->prim[i].mode = mode & ~BRW_SAVE_PRIM_WEAK;
- save->prim[i].begin = 1;
- save->prim[i].end = 0;
- save->prim[i].weak = (mode & BRW_SAVE_PRIM_WEAK) ? 1 : 0;
- save->prim[i].pad = 0;
- save->prim[i].start = save->vert_count;
- save->prim[i].count = 0;
-
- _mesa_install_save_vtxfmt( ctx, &save->vtxfmt );
- ctx->Driver.SaveNeedFlush = 1;
- return GL_TRUE;
-}
-
-
-
-static void GLAPIENTRY _save_End( void )
-{
- GET_CURRENT_CONTEXT( ctx );
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLint i = save->prim_count - 1;
-
- ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
- save->prim[i].end = 1;
- save->prim[i].count = (save->vert_count -
- save->prim[i].start);
-
- if (i == (GLint) save->prim_max - 1) {
- _save_compile_vertex_list( ctx );
- assert(save->copied.nr == 0);
- }
-
- /* Swap out this vertex format while outside begin/end. Any color,
- * etc. received between here and the next begin will be compiled
- * as opcodes.
- */
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
-}
-
-
-/* These are all errors as this vtxfmt is only installed inside
- * begin/end pairs.
- */
-static void GLAPIENTRY _save_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) count; (void) type; (void) indices;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawElements" );
-}
-
-
-static void GLAPIENTRY _save_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) start; (void) end; (void) count; (void) type; (void) indices;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawRangeElements" );
-}
-
-static void GLAPIENTRY _save_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) start; (void) count;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawArrays" );
-}
-
-static void GLAPIENTRY _save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) x1; (void) y1; (void) x2; (void) y2;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glRectf" );
-}
-
-static void GLAPIENTRY _save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) i1; (void) i2;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh1" );
-}
-
-static void GLAPIENTRY _save_EvalMesh2( GLenum mode, GLint i1, GLint i2,
- GLint j1, GLint j2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) i1; (void) i2; (void) j1; (void) j2;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh2" );
-}
-
-static void GLAPIENTRY _save_Begin( GLenum mode )
-{
- GET_CURRENT_CONTEXT( ctx );
- (void) mode;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "Recursive glBegin" );
-}
-
-
-/* Unlike the functions above, these are to be hooked into the vtxfmt
- * maintained in ctx->ListState, active when the list is known or
- * suspected to be outside any begin/end primitive.
- */
-static void GLAPIENTRY _save_OBE_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- brw_save_NotifyBegin( ctx, GL_QUADS | BRW_SAVE_PRIM_WEAK );
- CALL_Vertex2f(GET_DISPATCH(), ( x1, y1 ));
- CALL_Vertex2f(GET_DISPATCH(), ( x2, y1 ));
- CALL_Vertex2f(GET_DISPATCH(), ( x2, y2 ));
- CALL_Vertex2f(GET_DISPATCH(), ( x1, y2 ));
- CALL_End(GET_DISPATCH(), ());
-}
-
-
-static void GLAPIENTRY _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i;
-
- if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
- return;
-
- _ae_map_vbos( ctx );
-
- brw_save_NotifyBegin( ctx, mode | BRW_SAVE_PRIM_WEAK );
- for (i = 0; i < count; i++)
- CALL_ArrayElement(GET_DISPATCH(), (start + i));
- CALL_End(GET_DISPATCH(), ());
-
- _ae_unmap_vbos( ctx );
-}
-
-/* Could do better by copying the arrays and element list intact and
- * then emitting an indexed prim at runtime.
- */
-static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i;
-
- if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
- return;
-
- _ae_map_vbos( ctx );
-
- brw_save_NotifyBegin( ctx, mode | BRW_SAVE_PRIM_WEAK );
-
- switch (type) {
- case GL_UNSIGNED_BYTE:
- for (i = 0 ; i < count ; i++)
- CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] ));
- break;
- case GL_UNSIGNED_SHORT:
- for (i = 0 ; i < count ; i++)
- CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] ));
- break;
- case GL_UNSIGNED_INT:
- for (i = 0 ; i < count ; i++)
- CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] ));
- break;
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
- break;
- }
-
- CALL_End(GET_DISPATCH(), ());
-
- _ae_unmap_vbos( ctx );
-}
-
-static void GLAPIENTRY _save_OBE_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- if (_mesa_validate_DrawRangeElements( ctx, mode,
- start, end,
- count, type, indices ))
- _save_OBE_DrawElements( mode, count, type, indices );
-}
-
-
-
-
-
-static void _save_vtxfmt_init( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLvertexformat *vfmt = &save->vtxfmt;
-
- vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
- vfmt->Begin = _save_Begin;
- vfmt->Color3f = _save_Color3f;
- vfmt->Color3fv = _save_Color3fv;
- vfmt->Color4f = _save_Color4f;
- vfmt->Color4fv = _save_Color4fv;
- vfmt->EdgeFlag = _save_EdgeFlag;
- vfmt->End = _save_End;
- vfmt->FogCoordfEXT = _save_FogCoordfEXT;
- vfmt->FogCoordfvEXT = _save_FogCoordfvEXT;
- vfmt->Indexf = _save_Indexf;
- vfmt->Indexfv = _save_Indexfv;
- vfmt->Materialfv = _save_Materialfv;
- vfmt->MultiTexCoord1fARB = _save_MultiTexCoord1f;
- vfmt->MultiTexCoord1fvARB = _save_MultiTexCoord1fv;
- vfmt->MultiTexCoord2fARB = _save_MultiTexCoord2f;
- vfmt->MultiTexCoord2fvARB = _save_MultiTexCoord2fv;
- vfmt->MultiTexCoord3fARB = _save_MultiTexCoord3f;
- vfmt->MultiTexCoord3fvARB = _save_MultiTexCoord3fv;
- vfmt->MultiTexCoord4fARB = _save_MultiTexCoord4f;
- vfmt->MultiTexCoord4fvARB = _save_MultiTexCoord4fv;
- vfmt->Normal3f = _save_Normal3f;
- vfmt->Normal3fv = _save_Normal3fv;
- vfmt->SecondaryColor3fEXT = _save_SecondaryColor3fEXT;
- vfmt->SecondaryColor3fvEXT = _save_SecondaryColor3fvEXT;
- vfmt->TexCoord1f = _save_TexCoord1f;
- vfmt->TexCoord1fv = _save_TexCoord1fv;
- vfmt->TexCoord2f = _save_TexCoord2f;
- vfmt->TexCoord2fv = _save_TexCoord2fv;
- vfmt->TexCoord3f = _save_TexCoord3f;
- vfmt->TexCoord3fv = _save_TexCoord3fv;
- vfmt->TexCoord4f = _save_TexCoord4f;
- vfmt->TexCoord4fv = _save_TexCoord4fv;
- vfmt->Vertex2f = _save_Vertex2f;
- vfmt->Vertex2fv = _save_Vertex2fv;
- vfmt->Vertex3f = _save_Vertex3f;
- vfmt->Vertex3fv = _save_Vertex3fv;
- vfmt->Vertex4f = _save_Vertex4f;
- vfmt->Vertex4fv = _save_Vertex4fv;
- vfmt->VertexAttrib1fARB = _save_VertexAttrib1fARB;
- vfmt->VertexAttrib1fvARB = _save_VertexAttrib1fvARB;
- vfmt->VertexAttrib2fARB = _save_VertexAttrib2fARB;
- vfmt->VertexAttrib2fvARB = _save_VertexAttrib2fvARB;
- vfmt->VertexAttrib3fARB = _save_VertexAttrib3fARB;
- vfmt->VertexAttrib3fvARB = _save_VertexAttrib3fvARB;
- vfmt->VertexAttrib4fARB = _save_VertexAttrib4fARB;
- vfmt->VertexAttrib4fvARB = _save_VertexAttrib4fvARB;
-
- vfmt->VertexAttrib1fNV = _save_VertexAttrib1fNV;
- vfmt->VertexAttrib1fvNV = _save_VertexAttrib1fvNV;
- vfmt->VertexAttrib2fNV = _save_VertexAttrib2fNV;
- vfmt->VertexAttrib2fvNV = _save_VertexAttrib2fvNV;
- vfmt->VertexAttrib3fNV = _save_VertexAttrib3fNV;
- vfmt->VertexAttrib3fvNV = _save_VertexAttrib3fvNV;
- vfmt->VertexAttrib4fNV = _save_VertexAttrib4fNV;
- vfmt->VertexAttrib4fvNV = _save_VertexAttrib4fvNV;
-
- /* This will all require us to fallback to saving the list as opcodes:
- */
- vfmt->CallList = _save_CallList; /* inside begin/end */
- vfmt->CallLists = _save_CallLists; /* inside begin/end */
- vfmt->EvalCoord1f = _save_EvalCoord1f;
- vfmt->EvalCoord1fv = _save_EvalCoord1fv;
- vfmt->EvalCoord2f = _save_EvalCoord2f;
- vfmt->EvalCoord2fv = _save_EvalCoord2fv;
- vfmt->EvalPoint1 = _save_EvalPoint1;
- vfmt->EvalPoint2 = _save_EvalPoint2;
-
- /* These are all errors as we at least know we are in some sort of
- * begin/end pair:
- */
- vfmt->EvalMesh1 = _save_EvalMesh1;
- vfmt->EvalMesh2 = _save_EvalMesh2;
- vfmt->Begin = _save_Begin;
- vfmt->Rectf = _save_Rectf;
- vfmt->DrawArrays = _save_DrawArrays;
- vfmt->DrawElements = _save_DrawElements;
- vfmt->DrawRangeElements = _save_DrawRangeElements;
-
-}
-
-
-void brw_save_SaveFlushVertices( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- /* Noop when we are actually active:
- */
- if (ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM ||
- ctx->Driver.CurrentSavePrimitive <= GL_POLYGON)
- return;
-
- if (save->vert_count ||
- save->prim_count)
- _save_compile_vertex_list( ctx );
-
- _save_copy_to_current( ctx );
- _save_reset_vertex( ctx );
- _save_reset_counters( ctx );
- ctx->Driver.SaveNeedFlush = 0;
-}
-
-void brw_save_NewList( GLcontext *ctx, GLuint list, GLenum mode )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- (void) list; (void) mode;
-
- if (!save->prim_store)
- save->prim_store = alloc_prim_store( ctx );
-
- if (!save->vertex_store)
- save->vertex_store = alloc_vertex_store( ctx );
-
- save->vbptr = map_vertex_store( ctx, save->vertex_store );
-
- _save_reset_vertex( ctx );
- _save_reset_counters( ctx );
- ctx->Driver.SaveNeedFlush = 0;
-}
-
-void brw_save_EndList( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- unmap_vertex_store( ctx, save->vertex_store );
-
- assert(save->vertex_size == 0);
-}
-
-void brw_save_BeginCallList( GLcontext *ctx, struct mesa_display_list *dlist )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- save->replay_flags |= dlist->flags;
-}
-
-void brw_save_EndCallList( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- if (ctx->ListState.CallDepth == 1) {
- /* This is correct: want to keep only the BRW_SAVE_FALLBACK
- * flag, if it is set:
- */
- save->replay_flags &= BRW_SAVE_FALLBACK;
- }
-}
-
-
-static void brw_destroy_vertex_list( GLcontext *ctx, void *data )
-{
- struct brw_save_vertex_list *node = (struct brw_save_vertex_list *)data;
- (void) ctx;
-
- if ( --node->vertex_store->refcount == 0 )
- free_vertex_store( ctx, node->vertex_store );
-
- if ( --node->prim_store->refcount == 0 )
- FREE( node->prim_store );
-}
-
-
-static void brw_print_vertex_list( GLcontext *ctx, void *data )
-{
- struct brw_save_vertex_list *node = (struct brw_save_vertex_list *)data;
- GLuint i;
- (void) ctx;
-
- _mesa_debug(NULL, "BRW-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n",
- node->count,
- node->prim_count,
- node->vertex_size);
-
- for (i = 0 ; i < node->prim_count ; i++) {
- struct brw_draw_prim *prim = &node->prim[i];
- _mesa_debug(NULL, " prim %d: %s%s %d..%d %s %s\n",
- i,
- _mesa_lookup_enum_by_nr(prim->mode),
- prim->weak ? " (weak)" : "",
- prim->start,
- prim->start + prim->count,
- (prim->begin) ? "BEGIN" : "(wrap)",
- (prim->end) ? "END" : "(wrap)");
- }
-}
-
-
-static void _save_current_init( GLcontext *ctx )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLint i;
-
- for (i = 0; i < BRW_ATTRIB_FIRST_MATERIAL; i++) {
- save->currentsz[i] = &ctx->ListState.ActiveAttribSize[i];
- save->current[i] = ctx->ListState.CurrentAttrib[i];
- }
-
- for (i = BRW_ATTRIB_FIRST_MATERIAL; i <= BRW_ATTRIB_LAST_MATERIAL; i++) {
- const GLuint j = i - BRW_ATTRIB_FIRST_MATERIAL;
- ASSERT(j < MAT_ATTRIB_MAX);
- save->currentsz[i] = &ctx->ListState.ActiveMaterialSize[j];
- save->current[i] = ctx->ListState.CurrentMaterial[j];
- }
-
- save->currentsz[BRW_ATTRIB_INDEX] = &ctx->ListState.ActiveIndex;
- save->current[BRW_ATTRIB_INDEX] = &ctx->ListState.CurrentIndex;
-
- save->currentsz[BRW_ATTRIB_EDGEFLAG] = &ctx->ListState.ActiveEdgeFlag;
- save->current[BRW_ATTRIB_EDGEFLAG] = &save->CurrentFloatEdgeFlag;
-}
-
-/**
- * Initialize the display list compiler
- */
-void brw_save_api_init( struct brw_save_context *save )
-{
- GLcontext *ctx = save->ctx;
- GLuint i;
-
- save->opcode_vertex_list =
- _mesa_alloc_opcode( ctx,
- sizeof(struct brw_save_vertex_list),
- brw_save_playback_vertex_list,
- brw_destroy_vertex_list,
- brw_print_vertex_list );
-
- ctx->Driver.NotifySaveBegin = brw_save_NotifyBegin;
-
- _save_vtxfmt_init( ctx );
- _save_current_init( ctx );
-
- for (i = 0; i < BRW_ATTRIB_MAX; i++)
- save->inputs[i] = &save->arrays[i];
-
- /* Hook our array functions into the outside-begin-end vtxfmt in
- * ctx->ListState.
- */
- ctx->ListState.ListVtxfmt.Rectf = _save_OBE_Rectf;
- ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays;
- ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements;
- ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements;
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
-}
-
diff --git a/src/mesa/drivers/dri/i965/brw_save_draw.c b/src/mesa/drivers/dri/i965/brw_save_draw.c
deleted file mode 100644
index cebdd8d060..0000000000
--- a/src/mesa/drivers/dri/i965/brw_save_draw.c
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "light.h"
-#include "state.h"
-
-#include "brw_save.h"
-#include "brw_draw.h"
-#include "brw_fallback.h"
-
-/*
- * After playback, copy everything but the position from the
- * last vertex to the saved state
- */
-static void _playback_copy_to_current( GLcontext *ctx,
- const struct brw_save_vertex_list *node )
-{
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
- GLfloat vertex[BRW_ATTRIB_MAX * 4], *data = vertex;
- GLuint i, offset;
-
- if (node->count)
- offset = (node->buffer_offset +
- (node->count-1) * node->vertex_size * sizeof(GLfloat));
- else
- offset = node->buffer_offset;
-
- ctx->Driver.GetBufferSubData( ctx, 0, offset,
- node->vertex_size * sizeof(GLfloat),
- data, node->vertex_store->bufferobj );
-
- for (i = 0 ; i < BRW_ATTRIB_MAX ; i++) {
- if (node->attrsz[i]) {
- if (i != BRW_ATTRIB_POS)
- COPY_CLEAN_4V(save->current[i], node->attrsz[i], data);
-
- if (i >= BRW_ATTRIB_MAT_FRONT_AMBIENT &&
- i <= BRW_ATTRIB_MAT_BACK_INDEXES)
- ctx->NewState |= _NEW_LIGHT;
-
- /* Edgeflag requires special treatment:
- */
- if (i == BRW_ATTRIB_EDGEFLAG)
- ctx->Current.EdgeFlag = (data[0] == 1.0);
-
- data += node->attrsz[i] * sizeof(GLfloat);
- }
- }
-
- /* Edgeflag requires special treatment:
- */
- if (node->attrsz[BRW_ATTRIB_EDGEFLAG]) {
- ctx->Current.EdgeFlag = (data[0] == 1.0);
- }
-
-
-#if 1
- /* Colormaterial -- this kindof sucks.
- */
- if (ctx->Light.ColorMaterialEnabled) {
- _mesa_update_color_material(ctx, ctx->Current.Attrib[BRW_ATTRIB_COLOR0]);
- }
-#endif
-
- /* CurrentExecPrimitive
- */
- if (node->prim_count) {
- const struct brw_draw_prim *prim = &node->prim[node->prim_count - 1];
- if (prim->end)
- ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
- else
- ctx->Driver.CurrentExecPrimitive = prim->mode;
- }
-}
-
-
-
-/* Treat the vertex storage as a VBO, define vertex arrays pointing
- * into it:
- */
-static void brw_bind_vertex_list( struct brw_save_context *save,
- const struct brw_save_vertex_list *node )
-{
- struct gl_client_array *arrays = save->arrays;
- GLuint data = node->buffer_offset;
- GLuint attr;
-
- memset(arrays, 0, BRW_ATTRIB_MAX * sizeof(arrays[0]));
-
- for (attr = 0; attr < BRW_ATTRIB_MAX; attr++) {
- if (node->attrsz[attr]) {
- arrays[attr].Ptr = (const GLubyte *)data;
- arrays[attr].Size = node->attrsz[attr];
- arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat);
- arrays[attr].Stride = node->vertex_size * sizeof(GLfloat);
- arrays[attr].Type = GL_FLOAT;
- arrays[attr].Enabled = 1;
- arrays[attr].BufferObj = node->vertex_store->bufferobj;
- arrays[attr]._MaxElement = node->count; /* ??? */
-
- assert(arrays[attr].BufferObj->Name);
-
- data += node->attrsz[attr] * sizeof(GLfloat);
- }
- }
-}
-
-static void brw_save_loopback_vertex_list( GLcontext *ctx,
- const struct brw_save_vertex_list *list )
-{
- const char *buffer = ctx->Driver.MapBuffer(ctx,
- GL_ARRAY_BUFFER_ARB,
- GL_DYNAMIC_READ_ARB, /* ? */
- list->vertex_store->bufferobj);
-
- brw_loopback_vertex_list( ctx,
- (const GLfloat *)(buffer + list->buffer_offset),
- list->attrsz,
- list->prim,
- list->prim_count,
- list->wrap_count,
- list->vertex_size);
-
- ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER_ARB,
- list->vertex_store->bufferobj);
-}
-
-
-/**
- * Execute the buffer and save copied verts.
- */
-void brw_save_playback_vertex_list( GLcontext *ctx, void *data )
-{
- const struct brw_save_vertex_list *node = (const struct brw_save_vertex_list *) data;
- struct brw_save_context *save = IMM_CONTEXT(ctx)->save;
-
- FLUSH_CURRENT(ctx, 0);
-
- if (node->prim_count > 0 && node->count > 0) {
-
- if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END &&
- node->prim[0].begin) {
-
- /* Degenerate case: list is called inside begin/end pair and
- * includes operations such as glBegin or glDrawArrays.
- */
- if (0)
- _mesa_printf("displaylist recursive begin");
-
- brw_save_loopback_vertex_list( ctx, node );
- return;
- }
- else if (save->replay_flags) {
- /* Various degnerate cases: translate into immediate mode
- * calls rather than trying to execute in place.
- */
- brw_save_loopback_vertex_list( ctx, node );
- return;
- }
-
- if (ctx->NewState)
- _mesa_update_state( ctx );
-
- if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
- (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBegin (invalid vertex/fragment program)");
- return;
- }
-
- brw_bind_vertex_list( save, node );
-
- if (!brw_draw_prims( save->ctx,
- save->inputs,
- node->prim,
- node->prim_count,
- NULL,
- 0, /* Node is a VBO, so this is ok */
- node->count,
- 0 )) {
- brw_fallback(ctx);
- brw_save_loopback_vertex_list( ctx, node );
- brw_unfallback(ctx);
- return;
- }
- }
-
- /* Copy to current?
- */
- _playback_copy_to_current( ctx, node );
-}
diff --git a/src/mesa/drivers/dri/i965/brw_structs.h b/src/mesa/drivers/dri/i965/brw_structs.h
index 25acdcfe94..10fee944e8 100644
--- a/src/mesa/drivers/dri/i965/brw_structs.h
+++ b/src/mesa/drivers/dri/i965/brw_structs.h
@@ -519,7 +519,22 @@ struct thread3
struct brw_clip_unit_state
{
struct thread0 thread0;
- struct thread1 thread1;
+ struct
+ {
+ GLuint pad0:7;
+ GLuint sw_exception_enable:1;
+ GLuint pad1:3;
+ GLuint mask_stack_exception_enable:1;
+ GLuint pad2:1;
+ GLuint illegal_op_exception_enable:1;
+ GLuint pad3:2;
+ GLuint floating_point_mode:1;
+ GLuint thread_priority:1;
+ GLuint binding_table_entry_count:8;
+ GLuint pad4:5;
+ GLuint single_program_flow:1;
+ } thread1;
+
struct thread2 thread2;
struct thread3 thread3;
@@ -532,8 +547,8 @@ struct brw_clip_unit_state
GLuint pad1:1;
GLuint urb_entry_allocation_size:5;
GLuint pad2:1;
- GLuint max_threads:6; /* may be less */
- GLuint pad3:1;
+ GLuint max_threads:1; /* may be less */
+ GLuint pad3:6;
} thread4;
struct
@@ -1322,6 +1337,7 @@ struct brw_instruction
GLuint end_of_thread:1;
} generic;
+ GLint d;
GLuint ud;
} bits3;
};
diff --git a/src/mesa/drivers/dri/i965/brw_tex_layout.c b/src/mesa/drivers/dri/i965/brw_tex_layout.c
index 1353325aff..af1ad0f1ef 100644
--- a/src/mesa/drivers/dri/i965/brw_tex_layout.c
+++ b/src/mesa/drivers/dri/i965/brw_tex_layout.c
@@ -34,21 +34,15 @@
*/
#include "intel_mipmap_tree.h"
+#include "intel_tex_layout.h"
#include "macros.h"
-static GLuint minify( GLuint d )
-{
- return MAX2(1, d>>1);
-}
-
GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
{
/* XXX: these vary depending on image format:
*/
/* GLint align_w = 4; */
- GLint align_h = 2;
-
switch (mt->target) {
case GL_TEXTURE_CUBE_MAP:
@@ -107,53 +101,10 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
break;
}
- default: {
- GLuint level;
- GLuint x = 0;
- GLuint y = 0;
- GLuint width = mt->width0;
- GLuint height = mt->height0;
-
- mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp;
- mt->total_height = 0;
-
- for ( level = mt->first_level ; level <= mt->last_level ; level++ ) {
- GLuint img_height;
-
- intel_miptree_set_level_info(mt, level, 1,
- x, y,
- width,
- mt->compressed ? height/4 : height, 1);
-
- if (mt->compressed)
- img_height = MAX2(1, height/4);
- else
- img_height = MAX2(align_h, height);
-
-
- /* Because the images are packed better, the final offset
- * might not be the maximal one:
- */
- mt->total_height = MAX2(mt->total_height, y + img_height);
-
- /* Layout_below: step right after second mipmap.
- */
- if (level == mt->first_level + 1) {
- x += mt->pitch / 2;
- x = (x + 3) & ~ 3;
- }
- else {
- y += img_height;
- y += align_h - 1;
- y &= ~(align_h - 1);
- }
-
- width = minify(width);
- height = minify(height);
- }
+ default:
+ i945_miptree_layout_2d(mt);
break;
}
- }
DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__,
mt->pitch,
mt->total_height,
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index e5a28b96e3..74c9d88e46 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -54,12 +54,11 @@ static void do_vs_prog( struct brw_context *brw,
c.vp = vp;
c.prog_data.outputs_written = vp->program.Base.OutputsWritten;
- c.prog_data.inputs_read = brw_translate_inputs(brw->intel.ctx.VertexProgram._Enabled,
- vp->program.Base.InputsRead);
+ c.prog_data.inputs_read = vp->program.Base.InputsRead;
if (c.key.copy_edgeflag) {
c.prog_data.outputs_written |= 1<<VERT_RESULT_EDGE;
- c.prog_data.inputs_read |= 1<<BRW_ATTRIB_EDGEFLAG;
+ c.prog_data.inputs_read |= 1<<VERT_ATTRIB_EDGEFLAG;
}
if (0)
diff --git a/src/mesa/drivers/dri/i965/brw_vs_constval.c b/src/mesa/drivers/dri/i965/brw_vs_constval.c
index 502d828397..528e164db8 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_constval.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_constval.c
@@ -162,6 +162,7 @@ static GLuint get_input_size(struct brw_context *brw,
GLuint sizes_dword = brw->vb.info.sizes[attr/16];
GLuint sizes_bits = (sizes_dword>>((attr%16)*2)) & 0x3;
return sizes_bits + 1;
+/* return brw->vb.inputs[attr].glarray->Size; */
}
/* Calculate sizes of vertex program outputs. Size is the largest
@@ -176,8 +177,6 @@ static void calc_wm_input_sizes( struct brw_context *brw )
struct tracker t;
GLuint insn;
GLuint i;
- GLuint64EXT inputs = brw_translate_inputs(brw->intel.ctx.VertexProgram._Enabled,
- vp->program.Base.InputsRead);
memset(&t, 0, sizeof(t));
@@ -185,8 +184,8 @@ static void calc_wm_input_sizes( struct brw_context *brw )
if (brw->attribs.Light->Model.TwoSide)
t.twoside = 1;
- for (i = 0; i < BRW_ATTRIB_MAX; i++)
- if (inputs & (1<<i))
+ for (i = 0; i < VERT_ATTRIB_MAX; i++)
+ if (vp->program.Base.InputsRead & (1<<i))
set_active_component(&t, PROGRAM_INPUT, i,
szflag[get_input_size(brw, i)]);
diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c
index 8403e1bd7b..ffdb843e85 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_emit.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c
@@ -77,8 +77,8 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c )
/* Allocate input regs:
*/
c->nr_inputs = 0;
- for (i = 0; i < BRW_ATTRIB_MAX; i++) {
- if (c->prog_data.inputs_read & ((GLuint64EXT)1<<i)) {
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ if (c->prog_data.inputs_read & (1<<i)) {
c->nr_inputs++;
c->regs[PROGRAM_INPUT][i] = brw_vec8_grf(reg, 0);
reg++;
@@ -791,7 +791,7 @@ static void emit_vertex_write( struct brw_vs_compile *c)
if (c->key.copy_edgeflag) {
brw_MOV(p,
get_reg(c, PROGRAM_OUTPUT, VERT_RESULT_EDGE),
- get_reg(c, PROGRAM_INPUT, BRW_ATTRIB_EDGEFLAG));
+ get_reg(c, PROGRAM_INPUT, VERT_ATTRIB_EDGEFLAG));
}
diff --git a/src/mesa/drivers/dri/i965/brw_vs_tnl.c b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
index b7893ca3e5..0d61092247 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_tnl.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_tnl.c
@@ -114,7 +114,7 @@ static GLuint translate_texgen( GLboolean enabled, GLenum mode )
static void make_state_key( GLcontext *ctx, struct state_key *key )
{
struct brw_context *brw = brw_context(ctx);
- struct gl_fragment_program *fp = brw->fragment_program;
+ const struct gl_fragment_program *fp = brw->fragment_program;
GLuint i;
/* This now relies on texenvprogram.c being active:
@@ -146,9 +146,13 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
}
/* BRW_NEW_INPUT_VARYING */
- for (i = BRW_ATTRIB_MAT_FRONT_AMBIENT ; i < BRW_ATTRIB_MAX ; i++)
- if (brw->vb.info.varying & ((GLuint64EXT)1<<i))
- key->light_material_mask |= 1<<(i-BRW_ATTRIB_MAT_FRONT_AMBIENT);
+
+ /* For these programs, material values are stuffed into the
+ * generic slots:
+ */
+ for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
+ if (brw->vb.info.varying & (1<<(VERT_ATTRIB_GENERIC0 + i)))
+ key->light_material_mask |= 1<<i;
for (i = 0; i < MAX_LIGHTS; i++) {
struct gl_light *light = &brw->attribs.Light->Light[i];
@@ -374,17 +378,10 @@ static void release_temps( struct tnl_program *p )
static struct ureg register_input( struct tnl_program *p, GLuint input )
{
- GLuint orig_input = input;
- /* Cram the material flags into the generic range. We'll translate
- * them back later.
- */
- if (input >= BRW_ATTRIB_MAT_FRONT_AMBIENT)
- input -= BRW_ATTRIB_MAT_FRONT_AMBIENT - BRW_ATTRIB_GENERIC0;
-
assert(input < 32);
p->program->Base.InputsRead |= (1<<input);
- return make_ureg(PROGRAM_INPUT, orig_input);
+ return make_ureg(PROGRAM_INPUT, input);
}
static struct ureg register_output( struct tnl_program *p, GLuint output )
@@ -647,7 +644,7 @@ static void emit_passthrough( struct tnl_program *p,
static struct ureg get_eye_position( struct tnl_program *p )
{
if (is_undef(p->eye_position)) {
- struct ureg pos = register_input( p, BRW_ATTRIB_POS );
+ struct ureg pos = register_input( p, VERT_ATTRIB_POS );
struct ureg modelview[4];
p->eye_position = reserve_temp(p);
@@ -710,7 +707,7 @@ static struct ureg get_eye_position_normalized( struct tnl_program *p )
static struct ureg get_eye_normal( struct tnl_program *p )
{
if (is_undef(p->eye_normal)) {
- struct ureg normal = register_input(p, BRW_ATTRIB_NORMAL );
+ struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
struct ureg mvinv[3];
register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 2,
@@ -743,7 +740,7 @@ static struct ureg get_eye_normal( struct tnl_program *p )
static void build_hpos( struct tnl_program *p )
{
- struct ureg pos = register_input( p, BRW_ATTRIB_POS );
+ struct ureg pos = register_input( p, VERT_ATTRIB_POS );
struct ureg hpos = register_output( p, VERT_RESULT_HPOS );
struct ureg mvp[4];
@@ -787,9 +784,9 @@ static struct ureg get_material( struct tnl_program *p, GLuint side,
GLuint attrib = material_attrib(side, property);
if (p->color_materials & (1<<attrib))
- return register_input(p, BRW_ATTRIB_COLOR0);
+ return register_input(p, VERT_ATTRIB_COLOR0);
else if (p->materials & (1<<attrib))
- return register_input( p, attrib + BRW_ATTRIB_MAT_FRONT_AMBIENT );
+ return register_input( p, attrib + _TNL_ATTRIB_MAT_FRONT_AMBIENT );
else
return register_param3( p, STATE_MATERIAL, side, property );
}
@@ -1157,7 +1154,7 @@ static void build_fog( struct tnl_program *p )
input = swizzle1(get_eye_position(p), Z);
}
else {
- input = swizzle1(register_input(p, BRW_ATTRIB_FOG), X);
+ input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
}
if (p->state->fog_option &&
@@ -1299,7 +1296,7 @@ static void build_texture_transform( struct tnl_program *p )
for (j = 0; j < 4; j++) {
switch (modes[j]) {
case TXG_OBJ_LINEAR: {
- struct ureg obj = register_input(p, BRW_ATTRIB_POS);
+ struct ureg obj = register_input(p, VERT_ATTRIB_POS);
struct ureg plane =
register_param3(p, STATE_TEXGEN, i,
STATE_TEXGEN_OBJECT_S + j);
@@ -1348,7 +1345,7 @@ static void build_texture_transform( struct tnl_program *p )
}
if (copy_mask) {
- struct ureg in = register_input(p, BRW_ATTRIB_TEX0+i);
+ struct ureg in = register_input(p, VERT_ATTRIB_TEX0+i);
emit_op1(p, OPCODE_MOV, out_texgen, copy_mask, in );
}
}
@@ -1357,7 +1354,7 @@ static void build_texture_transform( struct tnl_program *p )
struct ureg texmat[4];
struct ureg in = (!is_undef(out_texgen) ?
out_texgen :
- register_input(p, BRW_ATTRIB_TEX0+i));
+ register_input(p, VERT_ATTRIB_TEX0+i));
if (PREFER_DP4) {
register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
0, 3, STATE_MATRIX, texmat );
@@ -1373,7 +1370,7 @@ static void build_texture_transform( struct tnl_program *p )
release_temps(p);
}
else {
- emit_passthrough(p, BRW_ATTRIB_TEX0+i, VERT_RESULT_TEX0+i);
+ emit_passthrough(p, VERT_ATTRIB_TEX0+i, VERT_RESULT_TEX0+i);
}
}
}
@@ -1425,10 +1422,10 @@ static void build_tnl_program( struct tnl_program *p )
build_lighting(p);
else {
if (p->state->fragprog_inputs_read & FRAG_BIT_COL0)
- emit_passthrough(p, BRW_ATTRIB_COLOR0, VERT_RESULT_COL0);
+ emit_passthrough(p, VERT_ATTRIB_COLOR0, VERT_RESULT_COL0);
if (p->state->fragprog_inputs_read & FRAG_BIT_COL1)
- emit_passthrough(p, BRW_ATTRIB_COLOR1, VERT_RESULT_COL1);
+ emit_passthrough(p, VERT_ATTRIB_COLOR1, VERT_RESULT_COL1);
}
}
@@ -1628,7 +1625,7 @@ const struct brw_tracked_state brw_tnl_vertprog = {
static void update_active_vertprog( struct brw_context *brw )
{
- struct gl_vertex_program *prev = brw->vertex_program;
+ const struct gl_vertex_program *prev = brw->vertex_program;
/* NEW_PROGRAM */
if (brw->attribs.VertexProgram->_Enabled) {
diff --git a/src/mesa/drivers/dri/i965/brw_vtbl.c b/src/mesa/drivers/dri/i965/brw_vtbl.c
index ac09754e3a..786f30e641 100644
--- a/src/mesa/drivers/dri/i965/brw_vtbl.c
+++ b/src/mesa/drivers/dri/i965/brw_vtbl.c
@@ -46,8 +46,6 @@
#include "brw_state.h"
#include "brw_draw.h"
-#include "brw_exec.h"
-#include "brw_save.h"
#include "brw_state.h"
#include "brw_aub.h"
#include "brw_fallback.h"
@@ -68,9 +66,6 @@ static void brw_destroy_context( struct intel_context *intel )
brw_destroy_state(brw);
brw_draw_destroy( brw );
- brw_exec_destroy( ctx );
- brw_save_destroy( ctx );
-
brw_ProgramCacheDestroy( ctx );
brw_FrameBufferTexDestroy( brw );
}
@@ -166,10 +161,7 @@ static GLuint brw_flush_cmd( void )
static void brw_invalidate_state( struct intel_context *intel, GLuint new_state )
{
- GLcontext *ctx = &intel->ctx;
-
- brw_exec_invalidate_state(ctx, new_state);
- brw_save_invalidate_state(ctx, new_state);
+ /* nothing */
}
diff --git a/src/mesa/drivers/dri/i965/brw_wm_state.c b/src/mesa/drivers/dri/i965/brw_wm_state.c
index 4707a709e7..ff5cb31bdd 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_state.c
@@ -122,7 +122,7 @@ static void upload_wm_unit(struct brw_context *brw )
/* BRW_NEW_FRAGMENT_PROGRAM */
{
- struct gl_fragment_program *fp = brw->fragment_program;
+ const struct gl_fragment_program *fp = brw->fragment_program;
if (fp->Base.InputsRead & (1<<FRAG_ATTRIB_WPOS))
wm.wm5.program_uses_depth = 1; /* as far as we can tell */
@@ -168,7 +168,7 @@ static void upload_wm_unit(struct brw_context *brw )
wm.wm5.line_stipple = 1;
}
- if (INTEL_DEBUG & DEBUG_STATS)
+ if (INTEL_DEBUG & DEBUG_STATS || intel->stats_wm)
wm.wm4.stats_enable = 1;
brw->wm.state_gs_offset = brw_cache_data( &brw->cache[BRW_WM_UNIT], &wm );
diff --git a/src/mesa/drivers/dri/i965/bufmgr.h b/src/mesa/drivers/dri/i965/bufmgr.h
index 6932522d3d..e748c0d6d0 100644
--- a/src/mesa/drivers/dri/i965/bufmgr.h
+++ b/src/mesa/drivers/dri/i965/bufmgr.h
@@ -199,9 +199,11 @@ void *bmFindVirtual( struct intel_context *intel,
* For now they can stay, but will likely change/move before final:
*/
unsigned bmSetFence( struct intel_context * );
+unsigned bmSetFenceLock( struct intel_context * );
unsigned bmLockAndFence( struct intel_context *intel );
int bmTestFence( struct intel_context *, unsigned fence );
void bmFinishFence( struct intel_context *, unsigned fence );
+void bmFinishFenceLock( struct intel_context *, unsigned fence );
void bm_fake_NotifyContendedLockTake( struct intel_context * );
diff --git a/src/mesa/drivers/dri/i965/bufmgr_fake.c b/src/mesa/drivers/dri/i965/bufmgr_fake.c
index ed88ab3797..24ee11edd8 100644
--- a/src/mesa/drivers/dri/i965/bufmgr_fake.c
+++ b/src/mesa/drivers/dri/i965/bufmgr_fake.c
@@ -338,7 +338,6 @@ static int evict_mru( struct intel_context *intel, GLuint *pool )
}
-
static int check_fenced( struct intel_context *intel )
{
struct bufmgr *bm = intel->bm;
@@ -1328,11 +1327,21 @@ unsigned bmSetFence( struct intel_context *intel )
return intel->bm->last_fence;
}
+unsigned bmSetFenceLock( struct intel_context *intel )
+{
+ unsigned last;
+ LOCK(intel->bm);
+ last = bmSetFence(intel);
+ UNLOCK(intel->bm);
+ return last;
+}
unsigned bmLockAndFence( struct intel_context *intel )
{
if (intel->bm->need_fence) {
LOCK_HARDWARE(intel);
+ LOCK(intel->bm);
bmSetFence(intel);
+ UNLOCK(intel->bm);
UNLOCK_HARDWARE(intel);
}
@@ -1350,7 +1359,12 @@ void bmFinishFence( struct intel_context *intel, unsigned fence )
check_fenced(intel);
}
-
+void bmFinishFenceLock( struct intel_context *intel, unsigned fence )
+{
+ LOCK(intel->bm);
+ bmFinishFence(intel, fence);
+ UNLOCK(intel->bm);
+}
/* Specifically ignore texture memory sharing.
diff --git a/src/mesa/drivers/dri/i965/intel_blit.c b/src/mesa/drivers/dri/i965/intel_blit.c
index c8c5bf93c9..173d1d5b6c 100644
--- a/src/mesa/drivers/dri/i965/intel_blit.c
+++ b/src/mesa/drivers/dri/i965/intel_blit.c
@@ -66,7 +66,7 @@ void intelCopyBuffer( const __DRIdrawablePrivate *dPriv,
intelFlush( &intel->ctx );
- bmFinishFence(intel, intel->last_swap_fence);
+ bmFinishFenceLock(intel, intel->last_swap_fence);
/* The LOCK_HARDWARE is required for the cliprects. Buffer offsets
* should work regardless.
@@ -155,7 +155,7 @@ void intelCopyBuffer( const __DRIdrawablePrivate *dPriv,
intel_batchbuffer_flush( intel->batch );
intel->second_last_swap_fence = intel->last_swap_fence;
- intel->last_swap_fence = bmSetFence( intel );
+ intel->last_swap_fence = bmSetFenceLock( intel );
UNLOCK_HARDWARE( intel );
if (!rect)
diff --git a/src/mesa/drivers/dri/i965/intel_context.c b/src/mesa/drivers/dri/i965/intel_context.c
index d13e287fa7..34560e4353 100644
--- a/src/mesa/drivers/dri/i965/intel_context.c
+++ b/src/mesa/drivers/dri/i965/intel_context.c
@@ -33,11 +33,12 @@
#include "extensions.h"
#include "framebuffer.h"
#include "imports.h"
+#include "points.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
#include "tnl/tnl.h"
-#include "array_cache/acache.h"
+#include "vbo/vbo.h"
#include "tnl/t_pipeline.h"
#include "tnl/t_vertex.h"
@@ -60,6 +61,7 @@
#include "bufmgr.h"
#include "utils.h"
+#include "vblank.h"
#ifndef INTEL_DEBUG
int INTEL_DEBUG = (0);
#endif
@@ -70,6 +72,7 @@ int INTEL_DEBUG = (0);
#define need_GL_ARB_vertex_buffer_object
#define need_GL_ARB_vertex_program
#define need_GL_ARB_window_pos
+#define need_GL_ARB_occlusion_query
#define need_GL_EXT_blend_color
#define need_GL_EXT_blend_equation_separate
#define need_GL_EXT_blend_func_separate
@@ -84,11 +87,6 @@ int INTEL_DEBUG = (0);
int VERBOSE = 0;
#endif
-#if DEBUG_LOCKING
-char *prevLockFile;
-int prevLockLine;
-#endif
-
/***************************************
* Mesa's Driver Functions
***************************************/
@@ -182,7 +180,16 @@ const struct dri_extension card_extensions[] =
{ NULL, NULL }
};
+const struct dri_extension arb_oc_extension =
+ { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions};
+void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging)
+{
+ struct intel_context *intel = ctx?intel_context(ctx):NULL;
+ driInitExtensions(ctx, card_extensions, enable_imaging);
+ if (!ctx || intel->intelScreen->drmMinor >= 8)
+ driInitSingleExtension (ctx, &arb_oc_extension);
+}
static const struct dri_debug_control debug_control[] =
{
@@ -216,7 +223,7 @@ static void intelInvalidateState( GLcontext *ctx, GLuint new_state )
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
- _ac_InvalidateState( ctx, new_state );
+ _vbo_InvalidateState( ctx, new_state );
_tnl_InvalidateState( ctx, new_state );
_tnl_invalidate_vertex_state( ctx, new_state );
@@ -241,6 +248,37 @@ void intelFinish( GLcontext *ctx )
bmFinishFence(intel, bmLockAndFence(intel));
}
+static void
+intelBeginQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+{
+ struct intel_context *intel = intel_context( ctx );
+ drmI830MMIO io = {
+ .read_write = MMIO_READ,
+ .reg = MMIO_REGS_PS_DEPTH_COUNT,
+ .data = &q->Result
+ };
+ intel->stats_wm++;
+ intelFinish(&intel->ctx);
+ drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
+}
+
+static void
+intelEndQuery(GLcontext *ctx, GLenum target, struct gl_query_object *q)
+{
+ struct intel_context *intel = intel_context( ctx );
+ GLuint64EXT tmp;
+ drmI830MMIO io = {
+ .read_write = MMIO_READ,
+ .reg = MMIO_REGS_PS_DEPTH_COUNT,
+ .data = &tmp
+ };
+ intelFinish(&intel->ctx);
+ drmCommandRead(intel->driFd, DRM_I830_MMIO, &io, sizeof(io));
+ q->Result = tmp - q->Result;
+ q->Ready = GL_TRUE;
+ intel->stats_wm--;
+}
+
void intelInitDriverFunctions( struct dd_function_table *functions )
{
@@ -250,6 +288,8 @@ void intelInitDriverFunctions( struct dd_function_table *functions )
functions->Finish = intelFinish;
functions->GetString = intelGetString;
functions->UpdateState = intelInvalidateState;
+ functions->BeginQuery = intelBeginQuery;
+ functions->EndQuery = intelEndQuery;
/* CopyPixels can be accelerated even with the current memory
* manager:
@@ -292,6 +332,11 @@ GLboolean intelInitContext( struct intel_context *intel,
intel->driScreen = sPriv;
intel->sarea = saPriv;
+ driParseConfigFiles (&intel->optionCache, &intelScreen->optionCache,
+ intel->driScreen->myNum, "i965");
+
+ intel->vblank_flags = (intel->intelScreen->irq_active != 0)
+ ? driGetDefaultVBlankFlags(&intel->optionCache) : VBLANK_FLAG_NO_IRQ;
ctx->Const.MaxTextureMaxAnisotropy = 2.0;
@@ -327,7 +372,7 @@ GLboolean intelInitContext( struct intel_context *intel,
/* Initialize the software rasterizer and helper modules. */
_swrast_CreateContext( ctx );
- _ac_CreateContext( ctx );
+ _vbo_CreateContext( ctx );
_tnl_CreateContext( ctx );
_swsetup_CreateContext( ctx );
@@ -374,9 +419,7 @@ GLboolean intelInitContext( struct intel_context *intel,
_mesa_printf("IRQs not active. Exiting\n");
exit(1);
}
-
- driInitExtensions( ctx, card_extensions,
- GL_TRUE );
+ intelInitExtensions(ctx, GL_TRUE);
INTEL_DEBUG = driParseDebugString( getenv( "INTEL_DEBUG" ),
debug_control );
@@ -403,8 +446,8 @@ GLboolean intelInitContext( struct intel_context *intel,
intelScreen->cpp,
intelScreen->front.pitch / intelScreen->cpp,
intelScreen->height,
- GL_FALSE);
-
+ intelScreen->front.size,
+ intelScreen->front.tiled != 0);
intel->back_region =
intel_region_create_static(intel,
@@ -414,7 +457,8 @@ GLboolean intelInitContext( struct intel_context *intel,
intelScreen->cpp,
intelScreen->back.pitch / intelScreen->cpp,
intelScreen->height,
- (INTEL_DEBUG & DEBUG_TILE) ? 0 : 1);
+ intelScreen->back.size,
+ intelScreen->back.tiled != 0);
/* Still assuming front.cpp == depth.cpp
*
@@ -430,7 +474,8 @@ GLboolean intelInitContext( struct intel_context *intel,
intelScreen->cpp,
intelScreen->depth.pitch / intelScreen->cpp,
intelScreen->height,
- (INTEL_DEBUG & DEBUG_TILE) ? 0 : 1);
+ intelScreen->depth.size,
+ intelScreen->depth.tiled != 0);
intel_bufferobj_init( intel );
intel->batch = intel_batchbuffer_alloc( intel );
@@ -472,7 +517,7 @@ void intelDestroyContext(__DRIcontextPrivate *driContextPriv)
release_texture_heaps = (intel->ctx.Shared->RefCount == 1);
_swsetup_DestroyContext (&intel->ctx);
_tnl_DestroyContext (&intel->ctx);
- _ac_DestroyContext (&intel->ctx);
+ _vbo_DestroyContext (&intel->ctx);
_swrast_DestroyContext (&intel->ctx);
intel->Fallback = 0; /* don't call _swrast_Flush later */
@@ -521,6 +566,9 @@ GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
if ( intel->driDrawable != driDrawPriv ) {
/* Shouldn't the readbuffer be stored also? */
+ driDrawableInitVBlank( driDrawPriv, intel->vblank_flags,
+ &intel->vbl_seq );
+
intel->driDrawable = driDrawPriv;
intelWindowMoved( intel );
}
@@ -655,3 +703,4 @@ void UNLOCK_HARDWARE( struct intel_context *intel )
_glthread_UNLOCK_MUTEX(lockMutex);
}
+
diff --git a/src/mesa/drivers/dri/i965/intel_context.h b/src/mesa/drivers/dri/i965/intel_context.h
index 8367a95710..a0f392f935 100644
--- a/src/mesa/drivers/dri/i965/intel_context.h
+++ b/src/mesa/drivers/dri/i965/intel_context.h
@@ -177,6 +177,7 @@ struct intel_context
GLuint second_last_swap_fence;
GLboolean aub_wrap;
+ GLuint stats_wm;
struct intel_batchbuffer *batch;
@@ -499,6 +500,7 @@ void intelBitmap(GLcontext * ctx,
const struct gl_pixelstore_attrib *unpack,
const GLubyte * pixels);
+void intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging);
#define _NEW_WINDOW_POS 0x40000000
@@ -521,6 +523,5 @@ static inline struct intel_texture_image *intel_texture_image( struct gl_texture
return (struct intel_texture_image *)img;
}
-
#endif
diff --git a/src/mesa/drivers/dri/i965/intel_ioctl.c b/src/mesa/drivers/dri/i965/intel_ioctl.c
index f3b76db215..0a8e976f70 100644
--- a/src/mesa/drivers/dri/i965/intel_ioctl.c
+++ b/src/mesa/drivers/dri/i965/intel_ioctl.c
@@ -43,6 +43,26 @@
#include "drm.h"
#include "bufmgr.h"
+static int intelWaitIdleLocked( struct intel_context *intel )
+{
+ static int in_wait_idle = 0;
+ unsigned int fence;
+
+ if (!in_wait_idle) {
+ if (INTEL_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "waiting for idle\n");
+ }
+
+ in_wait_idle = 1;
+ fence = bmSetFence(intel);
+ intelWaitIrq(intel, fence);
+ in_wait_idle = 0;
+
+ return bmTestFence(intel, fence);
+ } else {
+ return 1;
+ }
+}
int intelEmitIrqLocked( struct intel_context *intel )
{
@@ -88,7 +108,8 @@ void intelWaitIrq( struct intel_context *intel, int seq )
/* This seems quite often to return before it should!?!
*/
- } while (ret == -EAGAIN || ret == -EINTR || (ret == -EBUSY && lastdispatch != intel->sarea->last_dispatch) || (ret == 0 && seq > intel->sarea->last_dispatch));
+ } while (ret == -EAGAIN || ret == -EINTR || (ret == -EBUSY && lastdispatch != intel->sarea->last_dispatch) || (ret == 0 && seq > intel->sarea->last_dispatch)
+ || (ret == 0 && intel->sarea->last_dispatch - seq >= (1 << 24)));
if ( ret ) {
@@ -140,7 +161,11 @@ void intel_batch_ioctl( struct intel_context *intel,
UNLOCK_HARDWARE(intel);
exit(1);
}
- }
+
+ if (INTEL_DEBUG & DEBUG_SYNC) {
+ intelWaitIdleLocked(intel);
+ }
+ }
}
void intel_cmd_ioctl( struct intel_context *intel,
@@ -172,5 +197,9 @@ void intel_cmd_ioctl( struct intel_context *intel,
UNLOCK_HARDWARE(intel);
exit(1);
}
- }
+
+ if (INTEL_DEBUG & DEBUG_SYNC) {
+ intelWaitIdleLocked(intel);
+ }
+ }
}
diff --git a/src/mesa/drivers/dri/i965/intel_regions.c b/src/mesa/drivers/dri/i965/intel_regions.c
index 398b0a0a3b..835ecdd725 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.c
+++ b/src/mesa/drivers/dri/i965/intel_regions.c
@@ -122,10 +122,10 @@ struct intel_region *intel_region_create_static( struct intel_context *intel,
GLuint cpp,
GLuint pitch,
GLuint height,
+ GLuint size,
GLboolean tiled )
{
struct intel_region *region = calloc(sizeof(*region), 1);
- GLuint size = cpp * pitch * height;
GLint pool;
DBG("%s\n", __FUNCTION__);
diff --git a/src/mesa/drivers/dri/i965/intel_regions.h b/src/mesa/drivers/dri/i965/intel_regions.h
index 2413f0de33..d2235f1275 100644
--- a/src/mesa/drivers/dri/i965/intel_regions.h
+++ b/src/mesa/drivers/dri/i965/intel_regions.h
@@ -78,6 +78,7 @@ struct intel_region *intel_region_create_static( struct intel_context *intel,
GLuint cpp,
GLuint pitch,
GLuint height,
+ GLuint size,
GLboolean tiled );
/* Map/unmap regions. This is refcounted also:
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 56e6a792fa..08f0bb340f 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -38,6 +38,7 @@
#include "intel_screen.h"
+#include "intel_context.h"
#include "intel_tex.h"
#include "intel_span.h"
#include "intel_ioctl.h"
@@ -61,8 +62,6 @@ const GLuint __driNConfigOptions = 4;
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
#endif /*USE_NEW_INTERFACE*/
-extern const struct dri_extension card_extensions[];
-
/**
* Map all the memory regions described by the screen.
* \return GL_TRUE if success, GL_FALSE if error.
@@ -230,16 +229,19 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen,
intelScreen->front.pitch = sarea->pitch * intelScreen->cpp;
intelScreen->front.handle = sarea->front_handle;
intelScreen->front.size = sarea->front_size;
+ intelScreen->front.tiled = sarea->front_tiled;
intelScreen->back.offset = sarea->back_offset;
intelScreen->back.pitch = sarea->pitch * intelScreen->cpp;
intelScreen->back.handle = sarea->back_handle;
intelScreen->back.size = sarea->back_size;
-
+ intelScreen->back.tiled = sarea->back_tiled;
+
intelScreen->depth.offset = sarea->depth_offset;
intelScreen->depth.pitch = sarea->pitch * intelScreen->cpp;
intelScreen->depth.handle = sarea->depth_handle;
intelScreen->depth.size = sarea->depth_size;
+ intelScreen->depth.tiled = sarea->depth_tiled;
intelScreen->tex.offset = sarea->tex_offset;
intelScreen->logTextureGranularity = sarea->log_tex_granularity;
@@ -249,6 +251,7 @@ intelUpdateScreenFromSAREA(intelScreenPrivate *intelScreen,
intelScreen->rotated.offset = sarea->rotated_offset;
intelScreen->rotated.pitch = sarea->rotated_pitch * intelScreen->cpp;
intelScreen->rotated.size = sarea->rotated_size;
+ intelScreen->rotated.tiled = sarea->rotated_tiled;
intelScreen->current_rotation = sarea->rotation;
#if 0
matrix23Rotate(&intelScreen->rotMatrix,
@@ -683,7 +686,6 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
(dri_priv->cpp == 2) ? 16 : 24,
(dri_priv->cpp == 2) ? 0 : 8,
GL_TRUE );
-
/* Calling driInitExtensions here, with a NULL context pointer, does not actually
* enable the extensions. It just makes sure that all the dispatch offsets for all
* the extensions that *might* be enables are known. This is needed because the
@@ -692,7 +694,7 @@ void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIsc
*
* Hello chicken. Hello egg. How are you two today?
*/
- driInitExtensions( NULL, card_extensions, GL_FALSE );
+ intelInitExtensions(NULL, GL_FALSE);
}
return (void *) psp;
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h
index 094158afd8..bf9a716082 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -42,6 +42,7 @@ typedef struct {
char *map; /* memory map */
int offset; /* from start of video mem, in bytes */
int pitch; /* row stride, in pixels */
+ unsigned int tiled;
} intelRegion;
typedef struct
diff --git a/src/mesa/drivers/dri/i965/intel_tex_layout.c b/src/mesa/drivers/dri/i965/intel_tex_layout.c
new file mode 120000
index 0000000000..fe61b44194
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/intel_tex_layout.c
@@ -0,0 +1 @@
+../intel/intel_tex_layout.c \ No newline at end of file
diff --git a/src/mesa/drivers/dri/i965/server/i830_common.h b/src/mesa/drivers/dri/i965/server/i830_common.h
index e3bbdc7907..f320378c2a 100644
--- a/src/mesa/drivers/dri/i965/server/i830_common.h
+++ b/src/mesa/drivers/dri/i965/server/i830_common.h
@@ -52,6 +52,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DRM_I830_INIT_HEAP 0x0a
#define DRM_I830_CMDBUFFER 0x0b
#define DRM_I830_DESTROY_HEAP 0x0c
+#define DRM_I830_MMIO 0x10
typedef struct {
enum {
@@ -199,5 +200,23 @@ typedef struct {
int region;
} drmI830MemDestroyHeap;
+#define MMIO_READ 0
+#define MMIO_WRITE 1
+
+#define MMIO_REGS_IA_PRIMATIVES_COUNT 0
+#define MMIO_REGS_IA_VERTICES_COUNT 1
+#define MMIO_REGS_VS_INVOCATION_COUNT 2
+#define MMIO_REGS_GS_PRIMITIVES_COUNT 3
+#define MMIO_REGS_GS_INVOCATION_COUNT 4
+#define MMIO_REGS_CL_PRIMITIVES_COUNT 5
+#define MMIO_REGS_CL_INVOCATION_COUNT 6
+#define MMIO_REGS_PS_INVOCATION_COUNT 7
+#define MMIO_REGS_PS_DEPTH_COUNT 8
+
+typedef struct {
+ unsigned int read_write:1;
+ unsigned int reg:31;
+ void __user *data;
+} drmI830MMIO;
#endif /* _I830_DRM_H_ */