update_texture_state( GLcontext *ctx )
{
GLuint unit;
- struct gl_fragment_program *fprog;
+ struct gl_fragment_program *fprog = NULL;
+ struct gl_vertex_program *vprog = NULL;
if (ctx->Shader.CurrentProgram &&
ctx->Shader.CurrentProgram->LinkStatus) {
fprog = ctx->Shader.CurrentProgram->FragmentProgram;
- }
- else if (ctx->FragmentProgram._Enabled) {
- fprog = ctx->FragmentProgram.Current;
+ vprog = ctx->Shader.CurrentProgram->VertexProgram;
}
else {
- fprog = NULL;
+ if (ctx->FragmentProgram._Enabled) {
+ fprog = ctx->FragmentProgram.Current;
+ }
+ if (ctx->VertexProgram._Enabled) {
+ /* XXX enable this if/when non-shader vertex programs get
+ * texture fetches:
+ vprog = ctx->VertexProgram.Current;
+ */
+ }
}
ctx->NewState |= _NEW_TEXTURE; /* TODO: only set this if there are
* by a fragment shader/program. When multiple flags are set, we'll
* settle on the one with highest priority (see texture_override below).
*/
- if (fprog) {
- enableBits = fprog->Base.TexturesUsed[unit];
+ if (fprog || vprog) {
+ enableBits = 0x0;
+ if (fprog)
+ enableBits |= fprog->Base.TexturesUsed[unit];
+ if (vprog)
+ enableBits |= vprog->Base.TexturesUsed[unit];
}
else {
if (!texUnit->Enabled)
/**
* \file tnl/t_vb_program.c
- * \brief Pipeline stage for executing NVIDIA vertex programs.
+ * \brief Pipeline stage for executing vertex programs.
* \author Brian Paul, Keith Whitwell
*/
#include "glheader.h"
+#include "colormac.h"
#include "context.h"
#include "macros.h"
#include "imports.h"
#include "t_context.h"
#include "t_pipeline.h"
+#include "swrast/s_context.h"
+#include "swrast/s_texfilter.h"
+
+/**
+ * XXX the texture sampling code in this module is a bit of a hack.
+ * The texture sampling code is in swrast, though it doesn't have any
+ * real dependencies on the rest of swrast. It should probably be
+ * moved into main/ someday.
+ */
+
+static void
+vp_fetch_texel(GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
+ GLuint unit, GLfloat color[4])
+{
+ GLchan rgba[4];
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* XXX use a float-valued TextureSample routine here!!! */
+ swrast->TextureSample[unit](ctx, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat (*)[4]) texcoord,
+ &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
/**
/* init call stack */
machine->StackDepth = 0;
+
+ machine->FetchTexelLod = vp_fetch_texel;
+ machine->FetchTexelDeriv = NULL; /* not used by vertex programs */
}
GLuint outputs[VERT_RESULT_MAX], numOutputs;
GLuint i, j;
-#define FORCE_PROG_EXECUTE_C 1
-#if FORCE_PROG_EXECUTE_C
if (!program)
return GL_TRUE;
-#else
- if (!program || !program->IsNVProgram)
- return GL_TRUE;
-#endif
if (program->IsNVProgram) {
_mesa_load_tracked_matrices(ctx);
}
else {
+ /* ARB program or vertex shader */
_mesa_load_state_parameters(ctx, program->Base.Parameters);
}
* Called the first time stage->run is called. In effect, don't
* allocate data until the first time the stage is run.
*/
-static GLboolean init_vp( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
+static GLboolean
+init_vp(GLcontext *ctx, struct tnl_pipeline_stage *stage)
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &(tnl->vb);
/**
* Destructor for this pipeline stage.
*/
-static void dtr( struct tnl_pipeline_stage *stage )
+static void
+dtr(struct tnl_pipeline_stage *stage)
{
struct vp_stage_data *store = VP_STAGE_DATA(stage);
}
+static void
+validate_vp_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ if (ctx->VertexProgram._Current) {
+ _swrast_update_texture_samplers(ctx);
+ }
+}
+
+
+
/**
* Public description of this pipeline stage.
*/
NULL, /* private_data */
init_vp, /* create */
dtr, /* destroy */
- NULL, /* validate */
+ validate_vp_stage, /* validate */
run_vp /* run -- initially set to ctr */
};