[Mesa-dev] [PATCH 7/9] mesa: Track a computed _CurrentFragmentProgram for current gl_shader_program
Eric Anholt
eric at anholt.net
Wed Jan 12 14:04:57 PST 2011
This is like how we track FragmentProgram._Current for the computed
ARB fragment program for fixed function texenv, but this gives direct
access to the gl_shader_program for drivers to codegen from, skipping
ARB_fp.
---
src/mesa/main/mtypes.h | 1 +
src/mesa/main/state.c | 13 +++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4fc25a4..de9b81b 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2167,6 +2167,7 @@ struct gl_shader_state
struct gl_shader_program *CurrentVertexProgram;
struct gl_shader_program *CurrentGeometryProgram;
struct gl_shader_program *CurrentFragmentProgram;
+ struct gl_shader_program *_CurrentFragmentProgram;
/**
* Program used by glUniform calls.
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 4287528..57ac7da 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -43,6 +43,7 @@
#include "pixel.h"
#include "program/program.h"
#include "program/prog_parameter.h"
+#include "shaderobj.h"
#include "state.h"
#include "stencil.h"
#include "texenvprogram.h"
@@ -249,7 +250,7 @@ update_program(struct gl_context *ctx)
{
const struct gl_shader_program *vsProg = ctx->Shader.CurrentVertexProgram;
const struct gl_shader_program *gsProg = ctx->Shader.CurrentGeometryProgram;
- const struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram;
+ struct gl_shader_program *fsProg = ctx->Shader.CurrentFragmentProgram;
const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current;
@@ -275,20 +276,22 @@ update_program(struct gl_context *ctx)
/* Use shader programs */
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
fsProg->FragmentProgram);
+ _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
+ fsProg);
}
else if (ctx->FragmentProgram._Enabled) {
/* use user-defined fragment program */
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
ctx->FragmentProgram.Current);
+ _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
+ NULL);
}
else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
/* Use fragment program generated from fixed-function state.
*/
struct gl_shader_program *f = _mesa_get_fixed_func_fragment_program(ctx);
-#if 0
_mesa_reference_shader_program(ctx,
- &ctx->Shader.CurrentFragmentProgram, f);
-#endif
+ &ctx->Shader._CurrentFragmentProgram, f);
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
f->FragmentProgram);
@@ -296,6 +299,8 @@ update_program(struct gl_context *ctx)
else {
/* no fragment program */
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
+ _mesa_reference_shader_program(ctx, &ctx->Shader._CurrentFragmentProgram,
+ NULL);
}
if (gsProg && gsProg->LinkStatus && gsProg->GeometryProgram) {
--
1.7.2.3
More information about the mesa-dev
mailing list