summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-10-15 13:21:11 +1100
committerBen Skeggs <skeggsb@gmail.com>2008-10-15 13:21:11 +1100
commit295d6f8e8f03192320aa8d4ed767427dd06071a5 (patch)
treeca8d7949d700d96b7d123366aa57b80894d1757f /src/mesa/main
parent2882a2db7a766c60bb231978ea829632438dd8a4 (diff)
parent41ccdde767e7aba6e8e6a9a035eacd6338c03a95 (diff)
Merge remote branch 'origin/gallium-0.2' into gallium-0.2
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_exec.c4
-rw-r--r--src/mesa/main/api_loopback.c1
-rw-r--r--src/mesa/main/blend.c1
-rw-r--r--src/mesa/main/colormac.h24
-rw-r--r--src/mesa/main/depthstencil.c4
-rw-r--r--src/mesa/main/descrip.mms32
-rw-r--r--src/mesa/main/dlist.c1
-rw-r--r--src/mesa/main/extensions.c3
-rw-r--r--src/mesa/main/ffvertex_prog.c18
-rw-r--r--src/mesa/main/getstring.c1
-rw-r--r--src/mesa/main/mfeatures.h2
-rw-r--r--src/mesa/main/mtypes.h4
-rw-r--r--src/mesa/main/queryobj.c7
-rw-r--r--src/mesa/main/queryobj.h2
-rw-r--r--src/mesa/main/shaders.c25
-rw-r--r--src/mesa/main/state.c48
-rw-r--r--src/mesa/main/state.h3
-rw-r--r--src/mesa/main/texenvprogram.c137
-rw-r--r--src/mesa/main/texformat.c9
-rw-r--r--src/mesa/main/teximage.c18
-rw-r--r--src/mesa/main/texparam.c15
-rw-r--r--src/mesa/main/texstore.c50
22 files changed, 279 insertions, 130 deletions
diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
index 0c3c9c4de4..bae3bf11cb 100644
--- a/src/mesa/main/api_exec.c
+++ b/src/mesa/main/api_exec.c
@@ -58,7 +58,7 @@
#include "colortab.h"
#endif
#include "context.h"
-#if FEATURE_convolution
+#if FEATURE_convolve
#include "convolve.h"
#endif
#include "depth.h"
@@ -402,7 +402,7 @@ _mesa_init_exec_table(struct _glapi_table *exec)
SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv);
#endif
-#if FEATURE_convolution
+#if FEATURE_convolve
SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D);
SET_ConvolutionFilter2D(exec, _mesa_ConvolutionFilter2D);
SET_ConvolutionParameterf(exec, _mesa_ConvolutionParameterf);
diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c
index 924d7134a2..0e3f5ff957 100644
--- a/src/mesa/main/api_loopback.c
+++ b/src/mesa/main/api_loopback.c
@@ -31,7 +31,6 @@
#include "glheader.h"
#include "macros.h"
-#include "colormac.h"
#include "api_loopback.h"
#include "mtypes.h"
#include "glapi/glapi.h"
diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c
index 4d4a897141..39cf6153e2 100644
--- a/src/mesa/main/blend.c
+++ b/src/mesa/main/blend.c
@@ -31,7 +31,6 @@
#include "glheader.h"
#include "blend.h"
-#include "colormac.h"
#include "context.h"
#include "enums.h"
#include "macros.h"
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index a19521fc85..a34bd2ed38 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 7.3
*
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -180,20 +180,20 @@ do { \
*/
/*@{*/
-#define PACK_COLOR_8888( R, G, B, A ) \
- (((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
+#define PACK_COLOR_8888( X, Y, Z, W ) \
+ (((X) << 24) | ((Y) << 16) | ((Z) << 8) | (W))
-#define PACK_COLOR_8888_REV( R, G, B, A ) \
- (((A) << 24) | ((B) << 16) | ((G) << 8) | (R))
+#define PACK_COLOR_8888_REV( X, Y, Z, W ) \
+ (((W) << 24) | ((Z) << 16) | ((Y) << 8) | (X))
-#define PACK_COLOR_888( R, G, B ) \
- (((R) << 16) | ((G) << 8) | (B))
+#define PACK_COLOR_888( X, Y, Z ) \
+ (((X) << 16) | ((Y) << 8) | (Z))
-#define PACK_COLOR_565( R, G, B ) \
- ((((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | (((B) & 0xf8) >> 3))
+#define PACK_COLOR_565( X, Y, Z ) \
+ ((((X) & 0xf8) << 8) | (((Y) & 0xfc) << 3) | (((Z) & 0xf8) >> 3))
-#define PACK_COLOR_565_REV( R, G, B ) \
- (((R) & 0xf8) | ((G) & 0xe0) >> 5 | (((G) & 0x1c) << 11) | (((B) & 0xf8) << 5))
+#define PACK_COLOR_565_REV( X, Y, Z ) \
+ (((X) & 0xf8) | ((Y) & 0xe0) >> 5 | (((Y) & 0x1c) << 11) | (((Z) & 0xf8) << 5))
#define PACK_COLOR_1555( A, B, G, R ) \
((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
index fb54d6184d..9d208e2997 100644
--- a/src/mesa/main/depthstencil.c
+++ b/src/mesa/main/depthstencil.c
@@ -282,8 +282,8 @@ _mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx,
z24rb->RefCount = 1;
z24rb->Width = dsrb->Width;
z24rb->Height = dsrb->Height;
- z24rb->InternalFormat = GL_DEPTH_COMPONENT24_ARB;
- z24rb->_ActualFormat = GL_DEPTH_COMPONENT24_ARB;
+ z24rb->InternalFormat = GL_DEPTH_COMPONENT24;
+ z24rb->_ActualFormat = GL_DEPTH_COMPONENT24;
z24rb->_BaseFormat = GL_DEPTH_COMPONENT;
z24rb->DataType = GL_UNSIGNED_INT;
z24rb->DepthBits = 24;
diff --git a/src/mesa/main/descrip.mms b/src/mesa/main/descrip.mms
index 3ef215f47f..e49ec65d42 100644
--- a/src/mesa/main/descrip.mms
+++ b/src/mesa/main/descrip.mms
@@ -1,6 +1,6 @@
# Makefile for core library for VMS
# contributed by Jouk Jansen joukj@hrem.nano.tudelft.nl
-# Last revision : 2 October 2007
+# Last revision : 29 September 2008
.first
define gl [---.include.gl]
@@ -21,6 +21,7 @@ CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)/float=ie
SOURCES =accum.c \
api_arrayelt.c \
+ api_exec.c \
api_loopback.c \
api_noop.c \
api_validate.c \
@@ -29,6 +30,7 @@ SOURCES =accum.c \
blend.c \
bufferobj.c \
buffers.c \
+ clear.c \
clip.c \
colortab.c \
context.c \
@@ -46,6 +48,7 @@ SOURCES =accum.c \
extensions.c \
fbobject.c \
feedback.c \
+ ffvertex_prog.c \
fog.c \
framebuffer.c \
get.c \
@@ -60,22 +63,29 @@ SOURCES =accum.c \
matrix.c \
mipmap.c \
mm.c \
+ multisample.c \
pixel.c \
+ pixelstore.c \
points.c \
polygon.c \
rastpos.c \
rbadaptors.c \
+ readpix.c \
renderbuffer.c \
+ scissor.c \
shaders.c \
state.c \
stencil.c \
texcompress.c \
texcompress_fxt1.c \
texcompress_s3tc.c \
+ texenv.c \
texenvprogram.c \
texformat.c \
+ texgen.c \
teximage.c \
texobj.c \
+ texparam.c \
texrender.c \
texstate.c \
texstore.c \
@@ -86,6 +96,7 @@ SOURCES =accum.c \
OBJECTS=accum.obj,\
api_arrayelt.obj,\
+api_exec.obj,\
api_loopback.obj,\
api_noop.obj,\
api_validate.obj,\
@@ -94,6 +105,7 @@ attrib.obj,\
blend.obj,\
bufferobj.obj,\
buffers.obj,\
+clear.obj,\
clip.obj,\
colortab.obj,\
context.obj,\
@@ -111,6 +123,7 @@ execmem.obj,\
extensions.obj,\
fbobject.obj,\
feedback.obj,\
+ffvertex_prog.obj,\
fog.obj,\
framebuffer.obj,\
get.obj,\
@@ -125,21 +138,28 @@ lines.obj,\
matrix.obj,\
mipmap.obj,\
mm.obj,\
+multisample.obj,\
pixel.obj,\
+pixelstore.obj,\
points.obj,\
polygon.obj,\
rastpos.obj,\
+readpix.obj,\
renderbuffer.obj,\
+scissor.obj,\
shaders.obj,\
state.obj,\
stencil.obj,\
texcompress.obj,\
texcompress_fxt1.obj,\
texcompress_s3tc.obj,\
+texenv.obj,\
texenvprogram.obj,\
texformat.obj,\
+texgen.obj,\
teximage.obj,\
texobj.obj,\
+texparam.obj,\
texrender.obj,\
texstate.obj,\
texstore.obj,\
@@ -226,3 +246,13 @@ vtxfmt.obj : vtxfmt.c
shaders.obj : shaders.c
queryobj.obj : queryobj.c
rbadaptors.obj : rbadaptors.c
+clear.obj : clear.c
+multisample.obj : multisample.c
+scissor.obj : scissor.c
+texenv.obj : texenv.c
+texgen.obj : texgen.c
+texparam.obj : texparam.c
+readpix.obj : readpix.c
+ffvertex_prog.obj : ffvertex_prog.c
+api_exec.obj : api_exec.c
+pixelstore.obj : pixelstore.c
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index f7660930a9..c7db435506 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -41,7 +41,6 @@
#endif
#include "arrayobj.h"
#include "clip.h"
-#include "colormac.h"
#include "colortab.h"
#include "context.h"
#include "convolve.h"
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 8dfbfeb62e..95bf1165f4 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -165,7 +165,7 @@ static const struct {
{ OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
{ ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
{ ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
- { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) },
+ { OFF, "GL_SGIX_depth_texture", F(ARB_depth_texture) },
{ OFF, "GL_SGIX_shadow", F(SGIX_shadow) },
{ OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) },
{ OFF, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
@@ -292,7 +292,6 @@ _mesa_enable_sw_extensions(GLcontext *ctx)
ctx->Extensions.SGI_texture_color_table = GL_TRUE;
ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
- ctx->Extensions.SGIX_depth_texture = GL_TRUE;
ctx->Extensions.SGIX_shadow = GL_TRUE;
ctx->Extensions.SGIX_shadow_ambient = GL_TRUE;
#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 787672be9f..308b4ef711 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -178,12 +178,12 @@ static GLboolean check_active_shininess( GLcontext *ctx,
-static struct state_key *make_state_key( GLcontext *ctx )
+static void make_state_key( GLcontext *ctx, struct state_key *key )
{
const struct gl_fragment_program *fp;
- struct state_key *key = CALLOC_STRUCT(state_key);
GLuint i;
+ memset(key, 0, sizeof(struct state_key));
fp = ctx->FragmentProgram._Current;
/* This now relies on texenvprogram.c being active:
@@ -301,8 +301,6 @@ static struct state_key *make_state_key( GLcontext *ctx )
texUnit->GenModeQ );
}
}
-
- return key;
}
@@ -1714,16 +1712,16 @@ struct gl_vertex_program *
_mesa_get_fixed_func_vertex_program(GLcontext *ctx)
{
struct gl_vertex_program *prog;
- struct state_key *key;
+ struct state_key key;
/* Grab all the relevent state and put it in a single structure:
*/
- key = make_state_key(ctx);
+ make_state_key(ctx, &key);
/* Look for an already-prepared program for this state:
*/
prog = (struct gl_vertex_program *)
- _mesa_search_program_cache(ctx->VertexProgram.Cache, key, sizeof(*key));
+ _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, sizeof(key));
if (!prog) {
/* OK, we'll have to build a new one */
@@ -1735,7 +1733,7 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
if (!prog)
return NULL;
- create_new_program( key, prog,
+ create_new_program( &key, prog,
ctx->Const.VertexProgram.MaxTemps );
#if 0
@@ -1744,10 +1742,8 @@ _mesa_get_fixed_func_vertex_program(GLcontext *ctx)
&prog->Base );
#endif
_mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache,
- key, sizeof(*key), &prog->Base);
+ &key, sizeof(key), &prog->Base);
}
- _mesa_free(key);
-
return prog;
}
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 1a82ccce59..94bf5de1e8 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -25,7 +25,6 @@
#include "glheader.h"
-#include "colormac.h"
#include "context.h"
#include "get.h"
#include "version.h"
diff --git a/src/mesa/main/mfeatures.h b/src/mesa/main/mfeatures.h
index ed78f57edf..3819da3d68 100644
--- a/src/mesa/main/mfeatures.h
+++ b/src/mesa/main/mfeatures.h
@@ -39,7 +39,7 @@
#define FEATURE_accum _HAVE_FULL_GL
#define FEATURE_attrib_stack _HAVE_FULL_GL
#define FEATURE_colortable _HAVE_FULL_GL
-#define FEATURE_convolution _HAVE_FULL_GL
+#define FEATURE_convolve _HAVE_FULL_GL
#define FEATURE_dispatch _HAVE_FULL_GL
#define FEATURE_dlist _HAVE_FULL_GL
#define FEATURE_draw_read_buffer _HAVE_FULL_GL
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8e4f6a2e66..052da2c18e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2628,7 +2628,6 @@ struct gl_extensions
GLboolean SGIS_generate_mipmap;
GLboolean SGIS_texture_edge_clamp;
GLboolean SGIS_texture_lod;
- GLboolean SGIX_depth_texture;
GLboolean SGIX_shadow;
GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
GLboolean TDFX_texture_compression_FXT1;
@@ -2722,6 +2721,7 @@ struct gl_matrix_stack
#define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
#define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
#define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
+#define _NEW_CURRENT_ATTRIB 0x10000000 /**< __GLcontextRec::Current */
#define _NEW_ALL ~0
/*@}*/
@@ -3049,6 +3049,8 @@ struct __GLcontextRec
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
GLbitfield NewState; /**< bitwise-or of _NEW_* flags */
+ GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
+
/** \name Derived state */
/*@{*/
/** Bitwise-or of DD_* flags. Note that this bitfield may be used before
diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c
index a1e32e70ba..554e0b0d18 100644
--- a/src/mesa/main/queryobj.c
+++ b/src/mesa/main/queryobj.c
@@ -90,12 +90,11 @@ _mesa_wait_query(GLcontext *ctx, struct gl_query_object *q)
/**
- * Delete an occlusion query object.
+ * Delete a query object. Called via ctx->Driver.DeleteQuery().
* Not removed from hash table here.
- * XXX maybe add Delete() method to gl_query_object class and call that instead
*/
void
-_mesa_delete_query(struct gl_query_object *q)
+_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q)
{
_mesa_free(q);
}
@@ -546,6 +545,6 @@ delete_queryobj_cb(GLuint id, void *data, void *userData)
void
_mesa_free_query_data(GLcontext *ctx)
{
- _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, NULL);
+ _mesa_HashDeleteAll(ctx->Query.QueryObjects, delete_queryobj_cb, ctx);
_mesa_DeleteHashTable(ctx->Query.QueryObjects);
}
diff --git a/src/mesa/main/queryobj.h b/src/mesa/main/queryobj.h
index c05a1f3da8..9a9774641b 100644
--- a/src/mesa/main/queryobj.h
+++ b/src/mesa/main/queryobj.h
@@ -37,7 +37,7 @@ extern void
_mesa_free_query_data(GLcontext *ctx);
extern void
-_mesa_delete_query(struct gl_query_object *q);
+_mesa_delete_query(GLcontext *ctx, struct gl_query_object *q);
extern void
_mesa_begin_query(GLcontext *ctx, struct gl_query_object *q);
diff --git a/src/mesa/main/shaders.c b/src/mesa/main/shaders.c
index f0db0d2a81..e5c54bb10d 100644
--- a/src/mesa/main/shaders.c
+++ b/src/mesa/main/shaders.c
@@ -233,13 +233,32 @@ _mesa_GetObjectParameterivARB(GLhandleARB object, GLenum pname, GLint *params)
GET_CURRENT_CONTEXT(ctx);
/* Implement in terms of GetProgramiv, GetShaderiv */
if (ctx->Driver.IsProgram(ctx, object)) {
- ctx->Driver.GetProgramiv(ctx, object, pname, params);
+ if (pname == GL_OBJECT_TYPE_ARB) {
+ *params = GL_PROGRAM_OBJECT_ARB;
+ } else {
+ ctx->Driver.GetProgramiv(ctx, object, pname, params);
+ }
}
else if (ctx->Driver.IsShader(ctx, object)) {
- ctx->Driver.GetShaderiv(ctx, object, pname, params);
+ if (pname == GL_OBJECT_TYPE_ARB) {
+ *params = GL_SHADER_OBJECT_ARB;
+ } else {
+ ctx->Driver.GetShaderiv(ctx, object, pname, params);
+ }
}
else {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ /* error code depends on pname */
+ GLenum err;
+ switch (pname) {
+ case GL_OBJECT_TYPE_ARB:
+ case GL_OBJECT_DELETE_STATUS_ARB:
+ case GL_OBJECT_INFO_LOG_LENGTH_ARB:
+ err = GL_INVALID_OPERATION;
+ break;
+ default:
+ err = GL_INVALID_VALUE;
+ }
+ _mesa_error(ctx, err, "glGetObjectParameterivARB");
}
}
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 5913019bc1..2f0e7cc368 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -258,12 +258,6 @@ update_program(GLcontext *ctx)
}
}
- if (ctx->VertexProgram._Current)
- assert(ctx->VertexProgram._Current->Base.Parameters);
- if (ctx->FragmentProgram._Current)
- assert(ctx->FragmentProgram._Current->Base.Parameters);
-
-
/* XXX: get rid of _Active flag.
*/
#if 1
@@ -447,6 +441,9 @@ _mesa_update_state_locked( GLcontext *ctx )
GLbitfield new_state = ctx->NewState;
GLbitfield prog_flags = _NEW_PROGRAM;
+ if (new_state == _NEW_CURRENT_ATTRIB)
+ goto out;
+
if (MESA_VERBOSE & VERBOSE_STATE)
_mesa_print_state("_mesa_update_state", new_state);
@@ -510,7 +507,8 @@ _mesa_update_state_locked( GLcontext *ctx )
_mesa_update_tnl_spaces( ctx, new_state );
if (ctx->FragmentProgram._MaintainTexEnvProgram) {
- prog_flags |= (_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
+ prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE_MATRIX | _NEW_LIGHT |
+ _NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
}
if (ctx->VertexProgram._MaintainTnlProgram) {
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
@@ -532,6 +530,7 @@ _mesa_update_state_locked( GLcontext *ctx )
* Set ctx->NewState to zero to avoid recursion if
* Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
*/
+ out:
new_state = ctx->NewState;
ctx->NewState = 0;
ctx->Driver.UpdateState(ctx, new_state);
@@ -548,3 +547,38 @@ _mesa_update_state( GLcontext *ctx )
_mesa_update_state_locked(ctx);
_mesa_unlock_context_textures(ctx);
}
+
+
+
+
+/* Want to figure out which fragment program inputs are actually
+ * constant/current values from ctx->Current. These should be
+ * referenced as a tracked state variable rather than a fragment
+ * program input, to save the overhead of putting a constant value in
+ * every submitted vertex, transferring it to hardware, interpolating
+ * it across the triangle, etc...
+ *
+ * When there is a VP bound, just use vp->outputs. But when we're
+ * generating vp from fixed function state, basically want to
+ * calculate:
+ *
+ * vp_out_2_fp_in( vp_in_2_vp_out( varying_inputs ) |
+ * potential_vp_outputs )
+ *
+ * Where potential_vp_outputs is calculated by looking at enabled
+ * texgen, etc.
+ *
+ * The generated fragment program should then only declare inputs that
+ * may vary or otherwise differ from the ctx->Current values.
+ * Otherwise, the fp should track them as state values instead.
+ */
+void
+_mesa_set_varying_vp_inputs( GLcontext *ctx,
+ GLbitfield varying_inputs )
+{
+ if (ctx->varying_vp_inputs != varying_inputs) {
+ ctx->varying_vp_inputs = varying_inputs;
+ ctx->NewState |= _NEW_ARRAY;
+ //_mesa_printf("%s %x\n", __FUNCTION__, varying_inputs);
+ }
+}
diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h
index bb7cb8f32a..79f2f6beb0 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -37,5 +37,8 @@ _mesa_update_state( GLcontext *ctx );
extern void
_mesa_update_state_locked( GLcontext *ctx );
+void
+_mesa_set_varying_vp_inputs( GLcontext *ctx,
+ GLbitfield varying_inputs );
#endif
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index 2bce93eef1..c23173014d 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -55,15 +55,17 @@ struct texenvprog_cache_item
#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
struct mode_opt {
- GLuint Source:4;
- GLuint Operand:3;
+ GLubyte Source:4;
+ GLubyte Operand:3;
};
struct state_key {
- GLbitfield enabled_units;
+ GLuint nr_enabled_units:8;
+ GLuint enabled_units:8;
GLuint separate_specular:1;
GLuint fog_enabled:1;
GLuint fog_mode:2;
+ GLuint inputs_available:12;
struct {
GLuint enabled:1;
@@ -74,10 +76,10 @@ struct state_key {
GLuint NumArgsRGB:2;
GLuint ModeRGB:4;
- struct mode_opt OptRGB[3];
-
GLuint NumArgsA:2;
GLuint ModeA:4;
+
+ struct mode_opt OptRGB[3];
struct mode_opt OptA[3];
} unit[8];
};
@@ -199,6 +201,66 @@ static GLuint translate_tex_src_bit( GLbitfield bit )
}
}
+#define VERT_BIT_TEX_ANY (0xff << VERT_ATTRIB_TEX0)
+#define VERT_RESULT_TEX_ANY (0xff << VERT_RESULT_TEX0)
+
+/**
+ * Identify all possible varying inputs. The fragment program will
+ * never reference non-varying inputs, but will track them via state
+ * constants instead.
+ *
+ * This function figures out all the inputs that the fragment program
+ * has access to. The bitmask is later reduced to just those which
+ * are actually referenced.
+ */
+static GLbitfield get_fp_input_mask( GLcontext *ctx )
+{
+ GLbitfield fp_inputs = 0x0;
+
+ if (!ctx->VertexProgram._Enabled ||
+ !ctx->VertexProgram._Current) {
+
+ /* Fixed function logic */
+ GLbitfield varying_inputs = ctx->varying_vp_inputs;
+
+ /* First look at what values may be computed by the generated
+ * vertex program:
+ */
+ if (ctx->Light.Enabled) {
+ fp_inputs |= FRAG_BIT_COL0;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ fp_inputs |= FRAG_BIT_COL1;
+ }
+
+ fp_inputs |= (ctx->Texture._TexGenEnabled |
+ ctx->Texture._TexMatEnabled) << FRAG_ATTRIB_TEX0;
+
+ /* Then look at what might be varying as a result of enabled
+ * arrays, etc:
+ */
+ if (varying_inputs & VERT_BIT_COLOR0) fp_inputs |= FRAG_BIT_COL0;
+ if (varying_inputs & VERT_BIT_COLOR1) fp_inputs |= FRAG_BIT_COL1;
+
+ fp_inputs |= (((varying_inputs & VERT_BIT_TEX_ANY) >> VERT_ATTRIB_TEX0)
+ << FRAG_ATTRIB_TEX0);
+
+ }
+ else {
+ /* calculate from vp->outputs */
+ GLbitfield vp_outputs = ctx->VertexProgram._Current->Base.OutputsWritten;
+
+ if (vp_outputs & (1 << VERT_RESULT_COL0)) fp_inputs |= FRAG_BIT_COL0;
+ if (vp_outputs & (1 << VERT_RESULT_COL1)) fp_inputs |= FRAG_BIT_COL1;
+
+ fp_inputs |= (((vp_outputs & VERT_RESULT_TEX_ANY) >> VERT_RESULT_TEX0)
+ << FRAG_ATTRIB_TEX0);
+ }
+
+ return fp_inputs;
+}
+
+
/**
* Examine current texture environment state and generate a unique
* key to identify it.
@@ -206,7 +268,9 @@ static GLuint translate_tex_src_bit( GLbitfield bit )
static void make_state_key( GLcontext *ctx, struct state_key *key )
{
GLuint i, j;
-
+ GLbitfield inputs_referenced = FRAG_BIT_COL0;
+ GLbitfield inputs_available = get_fp_input_mask( ctx );
+
memset(key, 0, sizeof(*key));
for (i=0;i<MAX_TEXTURE_UNITS;i++) {
@@ -217,6 +281,8 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
key->unit[i].enabled = 1;
key->enabled_units |= (1<<i);
+ key->nr_enabled_units = i+1;
+ inputs_referenced |= FRAG_BIT_TEX(i);
key->unit[i].source_index =
translate_tex_src_bit(texUnit->_ReallyEnabled);
@@ -245,16 +311,22 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
}
}
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
key->separate_specular = 1;
+ inputs_referenced |= FRAG_BIT_COL1;
+ }
if (ctx->Fog.Enabled) {
key->fog_enabled = 1;
key->fog_mode = translate_fog_mode(ctx->Fog.Mode);
+ inputs_referenced |= FRAG_BIT_FOGC; /* maybe */
}
+
+ key->inputs_available = (inputs_available & inputs_referenced);
}
-/* Use uregs to represent registers internally, translate to Mesa's
+/**
+ * Use uregs to represent registers internally, translate to Mesa's
* expected formats on emit.
*
* NOTE: These are passed by value extensively in this file rather
@@ -287,16 +359,16 @@ static const struct ureg undef = {
};
-/* State used to build the fragment program:
+/** State used to build the fragment program:
*/
struct texenv_fragment_program {
struct gl_fragment_program *program;
GLcontext *ctx;
struct state_key *state;
- GLbitfield alu_temps; /* Track texture indirections, see spec. */
- GLbitfield temps_output; /* Track texture indirections, see spec. */
- GLbitfield temp_in_use; /* Tracks temporary regs which are in use. */
+ GLbitfield alu_temps; /**< Track texture indirections, see spec. */
+ GLbitfield temps_output; /**< Track texture indirections, see spec. */
+ GLbitfield temp_in_use; /**< Tracks temporary regs which are in use. */
GLboolean error;
struct ureg src_texture[MAX_TEXTURE_UNITS];
@@ -304,11 +376,11 @@ struct texenv_fragment_program {
* else undef.
*/
- struct ureg src_previous; /* Reg containing color from previous
+ struct ureg src_previous; /**< Reg containing color from previous
* stage. May need to be decl'd.
*/
- GLuint last_tex_stage; /* Number of last enabled texture unit */
+ GLuint last_tex_stage; /**< Number of last enabled texture unit */
struct ureg half;
struct ureg one;
@@ -411,6 +483,14 @@ static struct ureg get_tex_temp( struct texenv_fragment_program *p )
}
+/** Mark a temp reg as being no longer allocatable. */
+static void reserve_temp( struct texenv_fragment_program *p, struct ureg r )
+{
+ if (r.file == PROGRAM_TEMPORARY)
+ p->temps_output |= (1 << r.idx);
+}
+
+
static void release_temps(GLcontext *ctx, struct texenv_fragment_program *p )
{
GLuint max_temp = ctx->Const.FragmentProgram.MaxTemps;
@@ -449,11 +529,29 @@ static struct ureg register_param5( struct texenv_fragment_program *p,
#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
+static GLuint frag_to_vert_attrib( GLuint attrib )
+{
+ switch (attrib) {
+ case FRAG_ATTRIB_COL0: return VERT_ATTRIB_COLOR0;
+ case FRAG_ATTRIB_COL1: return VERT_ATTRIB_COLOR1;
+ default:
+ assert(attrib >= FRAG_ATTRIB_TEX0);
+ assert(attrib <= FRAG_ATTRIB_TEX7);
+ return attrib - FRAG_ATTRIB_TEX0 + VERT_ATTRIB_TEX0;
+ }
+}
+
static struct ureg register_input( struct texenv_fragment_program *p, GLuint input )
{
- p->program->Base.InputsRead |= (1 << input);
- return make_ureg(PROGRAM_INPUT, input);
+ if (p->state->inputs_available & (1<<input)) {
+ p->program->Base.InputsRead |= (1 << input);
+ return make_ureg(PROGRAM_INPUT, input);
+ }
+ else {
+ GLuint idx = frag_to_vert_attrib( input );
+ return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, idx );
+ }
}
@@ -504,10 +602,12 @@ emit_op(struct texenv_fragment_program *p,
emit_dst( &inst->DstReg, dest, mask );
+#if 0
/* Accounting for indirection tracking:
*/
if (dest.file == PROGRAM_TEMPORARY)
p->temps_output |= 1 << dest.idx;
+#endif
return inst;
}
@@ -562,6 +662,10 @@ static struct ureg emit_texld( struct texenv_fragment_program *p,
p->program->Base.NumTexInstructions++;
+ /* Accounting for indirection tracking:
+ */
+ reserve_temp(p, dest);
+
/* Is this a texture indirection?
*/
if ((coord.file == PROGRAM_TEMPORARY &&
@@ -1079,6 +1183,7 @@ create_new_program(GLcontext *ctx, struct state_key *key,
for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++)
if (key->enabled_units & (1<<unit)) {
p.src_previous = emit_texenv( &p, unit );
+ reserve_temp(&p, p.src_previous); /* don't re-use this temp reg */
release_temps(ctx, &p); /* release all temps */
}
}
diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c
index 60f36c4a87..ce2772c299 100644
--- a/src/mesa/main/texformat.c
+++ b/src/mesa/main/texformat.c
@@ -1420,14 +1420,13 @@ _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
; /* fallthrough */
}
- if (ctx->Extensions.SGIX_depth_texture ||
- ctx->Extensions.ARB_depth_texture) {
+ if (ctx->Extensions.ARB_depth_texture) {
switch (internalFormat) {
case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT24_SGIX:
- case GL_DEPTH_COMPONENT32_SGIX:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
return &_mesa_texformat_z32;
- case GL_DEPTH_COMPONENT16_SGIX:
+ case GL_DEPTH_COMPONENT16:
return &_mesa_texformat_z16;
default:
; /* fallthrough */
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 91c41f38c3..bf23a1f290 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -241,13 +241,12 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
}
}
- if (ctx->Extensions.SGIX_depth_texture ||
- ctx->Extensions.ARB_depth_texture) {
+ if (ctx->Extensions.ARB_depth_texture) {
switch (internalFormat) {
case GL_DEPTH_COMPONENT:
- case GL_DEPTH_COMPONENT16_SGIX:
- case GL_DEPTH_COMPONENT24_SGIX:
- case GL_DEPTH_COMPONENT32_SGIX:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
return GL_DEPTH_COMPONENT;
default:
; /* fallthrough */
@@ -526,9 +525,9 @@ static GLboolean
is_depth_format(GLenum format)
{
switch (format) {
- case GL_DEPTH_COMPONENT16_ARB:
- case GL_DEPTH_COMPONENT24_ARB:
- case GL_DEPTH_COMPONENT32_ARB:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
case GL_DEPTH_COMPONENT:
return GL_TRUE;
default:
@@ -2308,8 +2307,7 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
return;
}
- if (!ctx->Extensions.SGIX_depth_texture &&
- !ctx->Extensions.ARB_depth_texture && is_depth_format(format)) {
+ if (!ctx->Extensions.ARB_depth_texture && is_depth_format(format)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
return;
}
diff --git a/src/mesa/main/texparam.c b/src/mesa/main/texparam.c
index 664adadfb9..a9e752a637 100644
--- a/src/mesa/main/texparam.c
+++ b/src/mesa/main/texparam.c
@@ -642,8 +642,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
*params = 0;
break;
case GL_TEXTURE_DEPTH_SIZE_ARB:
- if (ctx->Extensions.SGIX_depth_texture ||
- ctx->Extensions.ARB_depth_texture)
+ if (ctx->Extensions.ARB_depth_texture)
*params = img->TexFormat->DepthBits;
else
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -903,9 +902,9 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
#ifdef FEATURE_OES_draw_texture
case GL_TEXTURE_CROP_RECT_OES:
params[0] = obj->CropRect[0];
- params[0] = obj->CropRect[1];
- params[0] = obj->CropRect[2];
- params[0] = obj->CropRect[3];
+ params[1] = obj->CropRect[1];
+ params[2] = obj->CropRect[2];
+ params[3] = obj->CropRect[3];
break;
#endif
default:
@@ -1053,9 +1052,9 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
#ifdef FEATURE_OES_draw_texture
case GL_TEXTURE_CROP_RECT_OES:
params[0] = obj->CropRect[0];
- params[0] = obj->CropRect[1];
- params[0] = obj->CropRect[2];
- params[0] = obj->CropRect[3];
+ params[1] = obj->CropRect[1];
+ params[2] = obj->CropRect[2];
+ params[3] = obj->CropRect[3];
break;
#endif
default:
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 76b785ab0e..3639a914c4 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.3
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -1536,10 +1536,10 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
GLuint *d4 = (GLuint *) dstRow;
for (col = 0; col < srcWidth; col++) {
- d4[col] = ((0xff << 24) |
- (srcRow[col * 3 + RCOMP] << 16) |
- (srcRow[col * 3 + GCOMP] << 8) |
- (srcRow[col * 3 + BCOMP] << 0));
+ d4[col] = PACK_COLOR_8888(0xff,
+ srcRow[col * 3 + RCOMP],
+ srcRow[col * 3 + GCOMP],
+ srcRow[col * 3 + BCOMP]);
}
dstRow += dstRowStride;
srcRow += srcRowStride;
@@ -1551,8 +1551,7 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
dstFormat == &_mesa_texformat_argb8888 &&
srcFormat == GL_RGBA &&
baseInternalFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE &&
- littleEndian) {
+ srcType == GL_UNSIGNED_BYTE) {
/* same as above case, but src data has alpha too */
GLint img, row, col;
/* For some reason, streaming copies to write-combined regions
@@ -1573,39 +1572,10 @@ _mesa_texstore_argb8888(TEXSTORE_PARAMS)
for (row = 0; row < srcHeight; row++) {
GLuint *d4 = (GLuint *) dstRow;
for (col = 0; col < srcWidth; col++) {
- d4[col] = ((srcRow[col * 4 + ACOMP] << 24) |
- (srcRow[col * 4 + RCOMP] << 16) |
- (srcRow[col * 4 + GCOMP] << 8) |
- (srcRow[col * 4 + BCOMP] << 0));
- }
- dstRow += dstRowStride;
- srcRow += srcRowStride;
- }
- }
- }
- else if (!ctx->_ImageTransferState &&
- !srcPacking->SwapBytes &&
- dstFormat == &_mesa_texformat_argb8888 &&
- srcFormat == GL_RGBA &&
- baseInternalFormat == GL_RGBA &&
- srcType == GL_UNSIGNED_BYTE) {
-
- GLint img, row, col;
- for (img = 0; img < srcDepth; img++) {
- const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
- srcWidth, srcFormat, srcType);
- GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
- srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
- GLubyte *dstRow = (GLubyte *) dstAddr
- + dstImageOffsets[dstZoffset + img] * dstFormat->TexelBytes
- + dstYoffset * dstRowStride
- + dstXoffset * dstFormat->TexelBytes;
- for (row = 0; row < srcHeight; row++) {
- for (col = 0; col < srcWidth; col++) {
- dstRow[col * 4 + 0] = srcRow[col * 4 + BCOMP];
- dstRow[col * 4 + 1] = srcRow[col * 4 + GCOMP];
- dstRow[col * 4 + 2] = srcRow[col * 4 + RCOMP];
- dstRow[col * 4 + 3] = srcRow[col * 4 + ACOMP];
+ d4[col] = PACK_COLOR_8888(srcRow[col * 4 + ACOMP],
+ srcRow[col * 4 + RCOMP],
+ srcRow[col * 4 + GCOMP],
+ srcRow[col * 4 + BCOMP]);
}
dstRow += dstRowStride;
srcRow += srcRowStride;