summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/api_validate.c8
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp3
-rw-r--r--src/mesa/main/mtypes.h3
-rw-r--r--src/mesa/main/rastpos.c2
-rw-r--r--src/mesa/main/state.c33
-rw-r--r--src/mesa/main/state.h23
-rw-r--r--src/mesa/main/texstate.c4
7 files changed, 36 insertions, 40 deletions
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 7aa8f9e837f..6ccb9e7ab21 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -133,15 +133,17 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
/* Any shader stages that are not supplied by the GLSL shader and have
* assembly shaders enabled must now be validated.
*/
- if (!ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX]
- && ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) {
+ if (!ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] &&
+ ctx->VertexProgram.Enabled &&
+ !_mesa_arb_vertex_program_enabled(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(vertex program not valid)", where);
return GL_FALSE;
}
if (!ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT]) {
- if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
+ if (ctx->FragmentProgram.Enabled &&
+ !_mesa_arb_fragment_program_enabled(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"%s(fragment program not valid)", where);
return GL_FALSE;
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index aac9de78ca6..2b924f6d101 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -33,6 +33,7 @@
#include "main/macros.h"
#include "main/samplerobj.h"
#include "main/shaderobj.h"
+#include "main/state.h"
#include "main/texenvprogram.h"
#include "main/texobj.h"
#include "main/uniforms.h"
@@ -172,7 +173,7 @@ static GLbitfield filter_fp_input_mask( GLbitfield fp_inputs,
/* _NEW_PROGRAM */
const GLboolean vertexShader =
ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] != NULL;
- const GLboolean vertexProgram = ctx->VertexProgram._Enabled;
+ const GLboolean vertexProgram = _mesa_arb_vertex_program_enabled(ctx);
if (!(vertexProgram || vertexShader)) {
/* Fixed function vertex logic */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 61c5a7519d9..edefd784a64 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2251,7 +2251,6 @@ struct gl_program_state
struct gl_vertex_program_state
{
GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
- GLboolean _Enabled; /**< Enabled and _valid_ user program? */
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
struct gl_program *Current; /**< User-bound vertex program */
@@ -2315,7 +2314,6 @@ struct gl_geometry_program_state
struct gl_fragment_program_state
{
GLboolean Enabled; /**< User-set fragment program enable flag */
- GLboolean _Enabled; /**< Enabled and _valid_ user program? */
struct gl_program *Current; /**< User-bound fragment program */
/** Currently enabled and valid fragment program (including internal
@@ -2384,7 +2382,6 @@ struct ati_fragment_shader
struct gl_ati_fragment_shader_state
{
GLboolean Enabled;
- GLboolean _Enabled; /**< enabled and valid shader? */
GLboolean Compiling;
GLfloat GlobalConstants[8][4];
struct ati_fragment_shader *Current;
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 4fddad16f1b..43f67596d1f 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -372,7 +372,7 @@ compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye
void
_mesa_RasterPos(struct gl_context *ctx, const GLfloat vObj[4])
{
- if (ctx->VertexProgram._Enabled) {
+ if (_mesa_arb_vertex_program_enabled(ctx)) {
/* XXX implement this */
_mesa_problem(ctx, "Vertex programs not implemented for glRasterPos");
return;
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 8df03f075fd..960b5381e9b 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -57,29 +57,6 @@
/**
- * Update the following fields:
- * ctx->VertexProgram._Enabled
- * ctx->FragmentProgram._Enabled
- * ctx->ATIFragmentShader._Enabled
- * This needs to be done before texture state validation.
- */
-static void
-update_program_enables(struct gl_context *ctx)
-{
- /* These _Enabled flags indicate if the user-defined ARB/NV vertex/fragment
- * program is enabled AND valid. Similarly for ATI fragment shaders.
- * GLSL shaders not relevant here.
- */
- ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
- && ctx->VertexProgram.Current->arb.Instructions;
- ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
- && ctx->FragmentProgram.Current->arb.Instructions;
- ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
- && ctx->ATIFragmentShader.Current->Instructions[0];
-}
-
-
-/**
* Update the ctx->*Program._Current pointers to point to the
* current/active programs.
*
@@ -138,14 +115,14 @@ update_program(struct gl_context *ctx)
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
NULL);
}
- else if (ctx->FragmentProgram._Enabled) {
+ else if (_mesa_arb_fragment_program_enabled(ctx)) {
/* Use user-defined fragment program */
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
ctx->FragmentProgram.Current);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
NULL);
}
- else if (ctx->ATIFragmentShader._Enabled &&
+ else if (_mesa_ati_fragment_shader_enabled(ctx) &&
ctx->ATIFragmentShader.Current->Program) {
/* Use the enabled ATI fragment shader's associated program */
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current,
@@ -203,7 +180,7 @@ update_program(struct gl_context *ctx)
/* Use GLSL vertex shader */
_mesa_reference_program(ctx, &ctx->VertexProgram._Current, vsProg);
}
- else if (ctx->VertexProgram._Enabled) {
+ else if (_mesa_arb_vertex_program_enabled(ctx)) {
/* Use user-defined vertex program */
_mesa_reference_program(ctx, &ctx->VertexProgram._Current,
ctx->VertexProgram.Current);
@@ -320,10 +297,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
/*
* Now update derived state info
*/
-
- if (new_state & prog_flags)
- update_program_enables( ctx );
-
if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
_mesa_update_modelview_project( ctx, new_state );
diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h
index 6d81c3f421b..b719f392965 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -72,12 +72,19 @@ _mesa_need_secondary_color(const struct gl_context *ctx)
return GL_FALSE;
}
+static inline bool
+_mesa_arb_vertex_program_enabled(const struct gl_context *ctx)
+{
+ return ctx->VertexProgram.Enabled &&
+ ctx->VertexProgram.Current->arb.Instructions;
+}
+
/** Compute two sided lighting state for fixed function or programs. */
static inline bool
_mesa_vertex_program_two_side_enabled(const struct gl_context *ctx)
{
if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX] ||
- ctx->VertexProgram._Enabled)
+ _mesa_arb_vertex_program_enabled(ctx))
return ctx->VertexProgram.TwoSideEnabled;
return ctx->Light.Enabled && ctx->Light.Model.TwoSide;
@@ -93,4 +100,18 @@ _mesa_polygon_get_front_bit(const struct gl_context *ctx)
return ctx->Polygon.FrontFace == GL_CCW;
}
+static inline bool
+_mesa_arb_fragment_program_enabled(const struct gl_context *ctx)
+{
+ return ctx->FragmentProgram.Enabled &&
+ ctx->FragmentProgram.Current->arb.Instructions;
+}
+
+static inline bool
+_mesa_ati_fragment_shader_enabled(const struct gl_context *ctx)
+{
+ return ctx->ATIFragmentShader.Enabled &&
+ ctx->ATIFragmentShader.Current->Instructions[0];
+}
+
#endif
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index b3411a87ef9..1e90bf87dac 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -38,6 +38,7 @@
#include "teximage.h"
#include "texstate.h"
#include "mtypes.h"
+#include "state.h"
#include "util/bitscan.h"
#include "util/bitset.h"
@@ -847,7 +848,8 @@ _mesa_update_texture_state(struct gl_context *ctx)
}
}
- if (prog[MESA_SHADER_FRAGMENT] == NULL && ctx->FragmentProgram._Enabled) {
+ if (prog[MESA_SHADER_FRAGMENT] == NULL &&
+ _mesa_arb_fragment_program_enabled(ctx)) {
prog[MESA_SHADER_FRAGMENT] = ctx->FragmentProgram.Current;
}