aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-06-09 23:27:41 +0200
committerMarek Olšák <[email protected]>2017-06-22 01:51:02 +0200
commit68a0e15f44cf351eab97a734b1cffeade1873fdf (patch)
tree99162f29dc09f7f0c11e89d5508d9f7c337f6892 /src/mesa
parent585c5cf8a514783d9ed31dba3aa432797dd5f0e8 (diff)
mesa: replace VP/FP/ATIfs _Enabled flags with helper functions
These are only used in the GL compatibility profile. Reviewed-by: Nicolai Hähnle <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/common/meta.c2
-rw-r--r--src/mesa/drivers/dri/i915/intel_pixel.c2
-rw-r--r--src/mesa/drivers/dri/i915/intel_pixel_copy.c2
-rw-r--r--src/mesa/drivers/dri/i965/intel_pixel.c2
-rw-r--r--src/mesa/drivers/dri/i965/intel_pixel_copy.c2
-rw-r--r--src/mesa/drivers/dri/r200/r200_maos_arrays.c3
-rw-r--r--src/mesa/drivers/dri/r200/r200_state.c6
-rw-r--r--src/mesa/drivers/dri/r200/r200_state_init.c15
-rw-r--r--src/mesa/drivers/dri/r200/r200_tcl.c4
-rw-r--r--src/mesa/drivers/dri/r200/r200_texstate.c7
-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
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c3
-rw-r--r--src/mesa/swrast/s_context.c7
-rw-r--r--src/mesa/swrast/s_span.c13
-rw-r--r--src/mesa/swrast/s_triangle.c4
-rw-r--r--src/mesa/swrast_setup/ss_context.c3
-rw-r--r--src/mesa/tnl/t_vb_program.c4
-rw-r--r--src/mesa/vbo/vbo_save_draw.c6
24 files changed, 85 insertions, 76 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 87f656062bd..73143842485 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2350,7 +2350,7 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
* Check if swrast fallback is needed.
*/
if (ctx->_ImageTransferState ||
- ctx->FragmentProgram._Enabled ||
+ _mesa_arb_fragment_program_enabled(ctx) ||
ctx->Fog.Enabled ||
ctx->Texture._MaxEnabledTexImageUnit != -1 ||
width > tex->MaxSize ||
diff --git a/src/mesa/drivers/dri/i915/intel_pixel.c b/src/mesa/drivers/dri/i915/intel_pixel.c
index b536c9b56d5..084b5636b48 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel.c
@@ -62,7 +62,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
if (ctx->NewState)
_mesa_update_state(ctx);
- if (ctx->FragmentProgram._Enabled) {
+ if (_mesa_arb_fragment_program_enabled(ctx)) {
DBG("fallback due to fragment program\n");
return false;
}
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
index e447511f587..b4f94666035 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
@@ -119,7 +119,7 @@ do_blit_copypixels(struct gl_context * ctx,
if (ctx->Fog.Enabled ||
ctx->Texture._MaxEnabledTexImageUnit != -1 ||
- ctx->FragmentProgram._Enabled) {
+ _mesa_arb_fragment_program_enabled(ctx)) {
perf_debug("glCopyPixels(): Unsupported fragment shader state\n");
return false;
}
diff --git a/src/mesa/drivers/dri/i965/intel_pixel.c b/src/mesa/drivers/dri/i965/intel_pixel.c
index e2babf83c47..c69c3cc7dce 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel.c
@@ -59,7 +59,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
if (ctx->NewState)
_mesa_update_state(ctx);
- if (ctx->FragmentProgram._Enabled) {
+ if (_mesa_arb_fragment_program_enabled(ctx)) {
DBG("fallback due to fragment program\n");
return false;
}
diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
index 986707c9d80..3ffd68c048e 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
@@ -123,7 +123,7 @@ do_blit_copypixels(struct gl_context * ctx,
if (ctx->Fog.Enabled ||
ctx->Texture._MaxEnabledTexImageUnit != -1 ||
- ctx->FragmentProgram._Enabled) {
+ _mesa_arb_fragment_program_enabled(ctx)) {
perf_debug("glCopyPixels(): Unsupported fragment shader state\n");
return false;
}
diff --git a/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
index 9b16cf84cf5..60f851be56c 100644
--- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c
+++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
@@ -36,6 +36,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/mtypes.h"
#include "main/imports.h"
#include "main/macros.h"
+#include "main/state.h"
#include "swrast_setup/swrast_setup.h"
#include "math/m_translate.h"
@@ -114,7 +115,7 @@ void r200EmitArrays( struct gl_context *ctx, GLubyte *vimap_rev )
/* special handling to fix up fog. Will get us into trouble with vbos...*/
assert(attrib == VERT_ATTRIB_FOG);
if (!rmesa->radeon.tcl.aos[i].bo) {
- if (ctx->VertexProgram._Enabled)
+ if (_mesa_arb_vertex_program_enabled(ctx))
rcommon_emit_vector( ctx,
&(rmesa->radeon.tcl.aos[nr]),
(char *)VB->AttribPtr[attrib]->data,
diff --git a/src/mesa/drivers/dri/r200/r200_state.c b/src/mesa/drivers/dri/r200/r200_state.c
index b157572832c..2705d224b95 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/light.h"
#include "main/framebuffer.h"
#include "main/fbobject.h"
+#include "main/state.h"
#include "main/stencil.h"
#include "main/viewport.h"
@@ -2265,7 +2266,7 @@ GLboolean r200ValidateState( struct gl_context *ctx )
_NEW_MODELVIEW|_NEW_PROJECTION|_NEW_TRANSFORM|
_NEW_LIGHT|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX|
_NEW_FOG|_NEW_POINT|_NEW_TRACK_MATRIX)) {
- if (ctx->VertexProgram._Enabled) {
+ if (_mesa_arb_vertex_program_enabled(ctx)) {
r200SetupVertexProg( ctx );
}
else TCL_FALLBACK(ctx, R200_TCL_FALLBACK_VERTEX_PROGRAM, 0);
@@ -2328,7 +2329,8 @@ static void r200WrapRunPipeline( struct gl_context *ctx )
if (!r200ValidateState( ctx ))
FALLBACK(rmesa, RADEON_FALLBACK_TEXTURE, GL_TRUE);
- has_material = !ctx->VertexProgram._Enabled && ctx->Light.Enabled && check_material( ctx );
+ has_material = !_mesa_arb_vertex_program_enabled(ctx) &&
+ ctx->Light.Enabled && check_material( ctx );
if (has_material) {
TCL_FALLBACK( ctx, R200_TCL_FALLBACK_MATERIAL, GL_TRUE );
diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c
index 8e14ba73ff9..4f584d3677b 100644
--- a/src/mesa/drivers/dri/r200/r200_state_init.c
+++ b/src/mesa/drivers/dri/r200/r200_state_init.c
@@ -35,6 +35,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/imports.h"
#include "main/enums.h"
#include "main/api_arrayelt.h"
+#include "main/state.h"
#include "swrast/swrast.h"
#include "vbo/vbo.h"
@@ -229,7 +230,7 @@ static int check_##NM( struct gl_context *ctx, struct radeon_state_atom *atom) \
static int check_##NM( struct gl_context *ctx, struct radeon_state_atom *atom) \
{ \
r200ContextPtr rmesa = R200_CONTEXT(ctx); \
- return (!rmesa->radeon.TclFallback && !ctx->VertexProgram._Enabled && (FLAG)) ? atom->cmd_size + (ADD) : 0; \
+ return (!rmesa->radeon.TclFallback && !_mesa_arb_vertex_program_enabled(ctx) && (FLAG)) ? atom->cmd_size + (ADD) : 0; \
}
#define TCL_OR_VP_CHECK( NM, FLAG, ADD ) \
@@ -244,18 +245,18 @@ static int check_##NM( struct gl_context *ctx, struct radeon_state_atom *atom )
{ \
r200ContextPtr rmesa = R200_CONTEXT(ctx); \
(void) atom; \
- return (!rmesa->radeon.TclFallback && ctx->VertexProgram._Enabled && (FLAG)) ? atom->cmd_size + (ADD) : 0; \
+ return (!rmesa->radeon.TclFallback && _mesa_arb_vertex_program_enabled(ctx) && (FLAG)) ? atom->cmd_size + (ADD) : 0; \
}
CHECK( always, GL_TRUE, 0 )
CHECK( always_add4, GL_TRUE, 4 )
CHECK( never, GL_FALSE, 0 )
CHECK( tex_any, ctx->Texture._MaxEnabledTexImageUnit != -1, 0 )
-CHECK( tf, (ctx->Texture._MaxEnabledTexImageUnit != -1 && !ctx->ATIFragmentShader._Enabled), 0 );
-CHECK( pix_zero, !ctx->ATIFragmentShader._Enabled, 0 )
-CHECK( texenv, (rmesa->state.envneeded & (1 << (atom->idx)) && !ctx->ATIFragmentShader._Enabled), 0 )
-CHECK( afs_pass1, (ctx->ATIFragmentShader._Enabled && (ctx->ATIFragmentShader.Current->NumPasses > 1)), 0 )
-CHECK( afs, ctx->ATIFragmentShader._Enabled, 0 )
+CHECK( tf, (ctx->Texture._MaxEnabledTexImageUnit != -1 && !_mesa_ati_fragment_shader_enabled(ctx)), 0 );
+CHECK( pix_zero, !_mesa_ati_fragment_shader_enabled(ctx), 0 )
+CHECK( texenv, (rmesa->state.envneeded & (1 << (atom->idx)) && !_mesa_ati_fragment_shader_enabled(ctx)), 0 )
+CHECK( afs_pass1, (_mesa_ati_fragment_shader_enabled(ctx) && (ctx->ATIFragmentShader.Current->NumPasses > 1)), 0 )
+CHECK( afs, _mesa_ati_fragment_shader_enabled(ctx), 0 )
CHECK( tex_cube, rmesa->state.texture.unit[atom->idx].unitneeded & TEXTURE_CUBE_BIT, 3 + 3*5 - CUBE_STATE_SIZE )
CHECK( tex_cube_cs, rmesa->state.texture.unit[atom->idx].unitneeded & TEXTURE_CUBE_BIT, 2 + 4*5 - CUBE_STATE_SIZE )
TCL_CHECK( tcl_fog_add4, ctx->Fog.Enabled, 4 )
diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c
index 26968afc644..662c041c79f 100644
--- a/src/mesa/drivers/dri/r200/r200_tcl.c
+++ b/src/mesa/drivers/dri/r200/r200_tcl.c
@@ -383,7 +383,7 @@ static GLboolean r200_run_tcl_render( struct gl_context *ctx,
if (!r200ValidateState( ctx ))
return GL_TRUE; /* fallback to sw t&l */
- if (!ctx->VertexProgram._Enabled) {
+ if (!_mesa_arb_vertex_program_enabled(ctx)) {
/* NOTE: inputs != tnl->render_inputs - these are the untransformed
* inputs.
*/
@@ -553,7 +553,7 @@ static void transition_to_hwtnl( struct gl_context *ctx )
rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_TCL_ENABLE;
rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~R200_VAP_FORCE_W_TO_ONE;
- if (ctx->VertexProgram._Enabled) {
+ if (_mesa_arb_vertex_program_enabled(ctx)) {
rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_PROG_VTX_SHADER_ENABLE;
}
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index 441ac730d4c..dcf211f521e 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -36,6 +36,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "main/imports.h"
#include "main/context.h"
#include "main/macros.h"
+#include "main/state.h"
#include "main/teximage.h"
#include "main/texobj.h"
#include "main/enums.h"
@@ -1480,7 +1481,7 @@ void r200UpdateTextureState( struct gl_context *ctx )
atoms. */
R200_NEWPRIM( rmesa );
- if (ctx->ATIFragmentShader._Enabled) {
+ if (_mesa_ati_fragment_shader_enabled(ctx)) {
GLuint i;
for (i = 0; i < R200_MAX_TEXTURE_UNITS; i++) {
if (ctx->Texture.Unit[i]._Current)
@@ -1502,7 +1503,7 @@ void r200UpdateTextureState( struct gl_context *ctx )
r200UpdateTextureUnit( ctx, 5 ));
}
- if (ok && ctx->ATIFragmentShader._Enabled) {
+ if (ok && _mesa_ati_fragment_shader_enabled(ctx)) {
r200UpdateFragmentShader(ctx);
}
@@ -1528,7 +1529,7 @@ void r200UpdateTextureState( struct gl_context *ctx )
rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] |= R200_TXFORMAT_LOOKUP_DISABLE;
}
- else if (!ctx->ATIFragmentShader._Enabled) {
+ else if (!_mesa_ati_fragment_shader_enabled(ctx)) {
if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_1_ENABLE) &&
(rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] & R200_TXFORMAT_LOOKUP_DISABLE)) {
R200_STATECHANGE(rmesa, tex[1]);
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;
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 092b4181225..384f965474a 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -41,6 +41,7 @@
#include "main/pack.h"
#include "main/pbo.h"
#include "main/readpix.h"
+#include "main/state.h"
#include "main/texformat.h"
#include "main/teximage.h"
#include "main/texstore.h"
@@ -1319,7 +1320,7 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
!ctx->FragmentProgram.Enabled &&
!ctx->VertexProgram.Enabled &&
!ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT] &&
- !ctx->ATIFragmentShader._Enabled &&
+ !_mesa_ati_fragment_shader_enabled(ctx) &&
ctx->DrawBuffer->_NumColorDrawBuffers == 1 &&
!ctx->Query.CondRenderQuery &&
!ctx->Query.CurrentOcclusionObject) {
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 71389c698f2..9f3d21f91d1 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -29,6 +29,7 @@
#include "main/bufferobj.h"
#include "main/mtypes.h"
#include "main/samplerobj.h"
+#include "main/state.h"
#include "main/stencil.h"
#include "main/teximage.h"
#include "program/prog_parameter.h"
@@ -109,7 +110,7 @@ _swrast_update_rasterflags( struct gl_context *ctx )
rasterMask |= FRAGPROG_BIT;
}
- if (ctx->ATIFragmentShader._Enabled) {
+ if (_mesa_ati_fragment_shader_enabled(ctx)) {
rasterMask |= ATIFRAGSHADER_BIT;
}
@@ -289,7 +290,7 @@ _swrast_update_specular_vertex_add(struct gl_context *ctx)
swrast->SpecularVertexAdd = (separateSpecular
&& ctx->Texture._MaxEnabledTexImageUnit == -1
&& !_swrast_use_fragment_program(ctx)
- && !ctx->ATIFragmentShader._Enabled);
+ && !_mesa_ati_fragment_shader_enabled(ctx));
}
@@ -504,7 +505,7 @@ _swrast_update_active_attribs(struct gl_context *ctx)
attribsMask = ctx->FragmentProgram._Current->info.inputs_read;
attribsMask &= ~VARYING_BIT_POS; /* WPOS is always handled specially */
}
- else if (ctx->ATIFragmentShader._Enabled) {
+ else if (_mesa_ati_fragment_shader_enabled(ctx)) {
attribsMask = VARYING_BIT_COL0 | VARYING_BIT_COL1 |
VARYING_BIT_FOGC | VARYING_BITS_TEX_ANY;
}
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 81835636a57..47a73e99f3d 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -39,6 +39,7 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/samplerobj.h"
+#include "main/state.h"
#include "main/stencil.h"
#include "main/teximage.h"
@@ -143,7 +144,7 @@ _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span)
const GLuint attr = VARYING_SLOT_TEX0 + i;
const GLfloat *tc = ctx->Current.RasterTexCoords[i];
if (_swrast_use_fragment_program(ctx) ||
- ctx->ATIFragmentShader._Enabled) {
+ _mesa_ati_fragment_shader_enabled(ctx)) {
COPY_4V(span->attrStart[attr], tc);
}
else if (tc[3] > 0.0F) {
@@ -524,7 +525,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
if (needLambda) {
GLuint i;
if (_swrast_use_fragment_program(ctx)
- || ctx->ATIFragmentShader._Enabled) {
+ || _mesa_ati_fragment_shader_enabled(ctx)) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
GLfloat w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dwdx;
@@ -565,7 +566,7 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
else {
GLuint i;
if (_swrast_use_fragment_program(ctx) ||
- ctx->ATIFragmentShader._Enabled) {
+ _mesa_ati_fragment_shader_enabled(ctx)) {
/* do perspective correction but don't divide s, t, r by q */
const GLfloat dwdx = span->attrStepX[VARYING_SLOT_POS][3];
GLfloat w = span->attrStart[VARYING_SLOT_POS][3] + span->leftClip * dwdx;
@@ -977,7 +978,7 @@ static inline void
shade_texture_span(struct gl_context *ctx, SWspan *span)
{
if (_swrast_use_fragment_program(ctx) ||
- ctx->ATIFragmentShader._Enabled) {
+ _mesa_ati_fragment_shader_enabled(ctx)) {
/* programmable shading */
if (span->primitive == GL_BITMAP && span->array->ChanType != GL_FLOAT) {
convert_color_type(span, span->array->ChanType, GL_FLOAT, 0);
@@ -1009,7 +1010,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span)
_swrast_exec_fragment_program(ctx, span);
}
else {
- assert(ctx->ATIFragmentShader._Enabled);
+ assert(_mesa_ati_fragment_shader_enabled(ctx));
_swrast_exec_fragment_shader(ctx, span);
}
}
@@ -1139,7 +1140,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
const GLenum origChanType = span->array->ChanType;
void * const origRgba = span->array->rgba;
const GLboolean shader = (_swrast_use_fragment_program(ctx)
- || ctx->ATIFragmentShader._Enabled);
+ || _mesa_ati_fragment_shader_enabled(ctx));
const GLboolean shaderOrTexture = shader || ctx->Texture._EnabledCoordUnits;
struct gl_framebuffer *fb = ctx->DrawBuffer;
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 9e4f81e0e0a..a4113e5582b 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1042,7 +1042,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
*/
if (ctx->Texture._EnabledCoordUnits ||
_swrast_use_fragment_program(ctx) ||
- ctx->ATIFragmentShader._Enabled ||
+ _mesa_ati_fragment_shader_enabled(ctx) ||
_mesa_need_secondary_color(ctx) ||
swrast->_FogEnabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
@@ -1071,7 +1071,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
/* First see if we can use an optimized 2-D texture function */
if (ctx->Texture._EnabledCoordUnits == 0x1
&& !_swrast_use_fragment_program(ctx)
- && !ctx->ATIFragmentShader._Enabled
+ && !_mesa_ati_fragment_shader_enabled(ctx)
&& ctx->Texture._MaxEnabledTexImageUnit == 0
&& ctx->Texture.Unit[0]._Current->Target == GL_TEXTURE_2D
&& samp->WrapS == GL_REPEAT
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index 74b1da342c7..ec20d6c35a1 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -28,6 +28,7 @@
#include "main/glheader.h"
#include "main/imports.h"
#include "main/macros.h"
+#include "main/state.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
@@ -113,7 +114,7 @@ setup_vertex_format(struct gl_context *ctx)
TNLcontext *tnl = TNL_CONTEXT(ctx);
SScontext *swsetup = SWSETUP_CONTEXT(ctx);
GLboolean intColors = !ctx->FragmentProgram._Current
- && !ctx->ATIFragmentShader._Enabled
+ && !_mesa_ati_fragment_shader_enabled(ctx)
&& ctx->RenderMode == GL_RENDER
&& CHAN_TYPE != GL_FLOAT;
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 23e09a2ae1d..19be5eed63a 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -35,6 +35,7 @@
#include "main/macros.h"
#include "main/imports.h"
#include "main/samplerobj.h"
+#include "main/state.h"
#include "math/m_xform.h"
#include "program/prog_instruction.h"
#include "program/prog_statevars.h"
@@ -162,7 +163,8 @@ do_ndc_cliptest(struct gl_context *ctx, struct vp_stage_data *store)
/* Test userclip planes. This contributes to VB->ClipMask.
*/
/** XXX NEW_SLANG _Enabled ??? */
- if (ctx->Transform.ClipPlanesEnabled && (!ctx->VertexProgram._Enabled ||
+ if (ctx->Transform.ClipPlanesEnabled &&
+ (!_mesa_arb_vertex_program_enabled(ctx) ||
ctx->VertexProgram.Current->arb.IsPositionInvariant)) {
userclip( ctx,
VB->ClipPtr,
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index e718f29496a..8a4b6599554 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -293,8 +293,10 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data)
_mesa_update_state( ctx );
/* XXX also need to check if shader enabled, but invalid */
- if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
- (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
+ if ((ctx->VertexProgram.Enabled &&
+ !_mesa_arb_vertex_program_enabled(ctx)) ||
+ (ctx->FragmentProgram.Enabled &&
+ !_mesa_arb_fragment_program_enabled(ctx))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glBegin (invalid vertex/fragment program)");
return;