[Mesa-dev] [PATCH 07/31] mesa: replace VP/FP/ATIfs _Enabled flags with helper functions
Marek Olšák
maraeo at gmail.com
Mon Jun 12 16:55:32 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
These are only used in the GL compatibility profile.
---
src/mesa/drivers/common/meta.c | 2 +-
src/mesa/drivers/dri/i915/intel_pixel.c | 2 +-
src/mesa/drivers/dri/i915/intel_pixel_copy.c | 2 +-
src/mesa/drivers/dri/i965/intel_pixel.c | 2 +-
src/mesa/drivers/dri/i965/intel_pixel_copy.c | 2 +-
src/mesa/drivers/dri/r200/r200_maos_arrays.c | 3 ++-
src/mesa/drivers/dri/r200/r200_state.c | 6 +++--
src/mesa/drivers/dri/r200/r200_state_init.c | 15 +++++++------
src/mesa/drivers/dri/r200/r200_tcl.c | 4 ++--
src/mesa/drivers/dri/r200/r200_texstate.c | 7 +++---
src/mesa/main/api_validate.c | 8 ++++---
src/mesa/main/ff_fragment_shader.cpp | 3 ++-
src/mesa/main/mtypes.h | 3 ---
src/mesa/main/rastpos.c | 2 +-
src/mesa/main/state.c | 33 +++-------------------------
src/mesa/main/state.h | 23 ++++++++++++++++++-
src/mesa/main/texstate.c | 4 +++-
src/mesa/state_tracker/st_cb_drawpixels.c | 3 ++-
src/mesa/swrast/s_context.c | 7 +++---
src/mesa/swrast/s_span.c | 13 ++++++-----
src/mesa/swrast/s_triangle.c | 4 ++--
src/mesa/swrast_setup/ss_context.c | 3 ++-
src/mesa/tnl/t_vb_program.c | 4 +++-
src/mesa/vbo/vbo_save_draw.c | 6 +++--
24 files changed, 85 insertions(+), 76 deletions(-)
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 1ff4651..b8eb266 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -2343,21 +2343,21 @@ _mesa_meta_Bitmap(struct gl_context *ctx,
const struct gl_pixelstore_attrib unpackSave = *unpack;
GLubyte fg, bg;
struct vertex verts[4];
GLboolean newTex;
GLubyte *bitmap8;
/*
* 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 ||
height > tex->MaxSize) {
_swrast_Bitmap(ctx, x, y, width, height, unpack, bitmap1);
return;
}
if (ctx->Color.AlphaEnabled && !alpha_test_raster_color(ctx))
return;
diff --git a/src/mesa/drivers/dri/i915/intel_pixel.c b/src/mesa/drivers/dri/i915/intel_pixel.c
index b536c9b..084b563 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel.c
@@ -55,21 +55,21 @@ effective_func(GLenum func, bool src_alpha_is_one)
/**
* Check if any fragment operations are in effect which might effect
* glDraw/CopyPixels.
*/
bool
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;
}
if (ctx->Color.BlendEnabled &&
(effective_func(ctx->Color.Blend[0].SrcRGB, src_alpha_is_one) != GL_ONE ||
effective_func(ctx->Color.Blend[0].DstRGB, src_alpha_is_one) != GL_ZERO ||
ctx->Color.Blend[0].EquationRGB != GL_FUNC_ADD ||
effective_func(ctx->Color.Blend[0].SrcA, src_alpha_is_one) != GL_ONE ||
effective_func(ctx->Color.Blend[0].DstA, src_alpha_is_one) != GL_ZERO ||
diff --git a/src/mesa/drivers/dri/i915/intel_pixel_copy.c b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
index e447511..b4f9466 100644
--- a/src/mesa/drivers/dri/i915/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i915/intel_pixel_copy.c
@@ -112,21 +112,21 @@ do_blit_copypixels(struct gl_context * ctx,
return false;
}
if (_mesa_stencil_is_enabled(ctx)) {
perf_debug("glCopyPixels(): Unsupported stencil test state\n");
return false;
}
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;
}
if (ctx->Color.AlphaEnabled ||
ctx->Color.BlendEnabled) {
perf_debug("glCopyPixels(): Unsupported blend 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 e2babf8..c69c3cc 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel.c
@@ -52,21 +52,21 @@ effective_func(GLenum func, bool src_alpha_is_one)
/**
* Check if any fragment operations are in effect which might effect
* glDraw/CopyPixels.
*/
bool
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;
}
if (ctx->Color.BlendEnabled &&
(effective_func(ctx->Color.Blend[0].SrcRGB, src_alpha_is_one) != GL_ONE ||
effective_func(ctx->Color.Blend[0].DstRGB, src_alpha_is_one) != GL_ZERO ||
ctx->Color.Blend[0].EquationRGB != GL_FUNC_ADD ||
effective_func(ctx->Color.Blend[0].SrcA, src_alpha_is_one) != GL_ONE ||
effective_func(ctx->Color.Blend[0].DstA, src_alpha_is_one) != GL_ZERO ||
diff --git a/src/mesa/drivers/dri/i965/intel_pixel_copy.c b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
index 986707c..3ffd68c 100644
--- a/src/mesa/drivers/dri/i965/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/i965/intel_pixel_copy.c
@@ -116,21 +116,21 @@ do_blit_copypixels(struct gl_context * ctx,
return false;
}
if (brw->stencil_enabled) {
perf_debug("glCopyPixels(): Unsupported stencil test state\n");
return false;
}
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;
}
if (ctx->Color.AlphaEnabled ||
ctx->Color.BlendEnabled) {
perf_debug("glCopyPixels(): Unsupported blend 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 9b16cf8..60f851b 100644
--- a/src/mesa/drivers/dri/r200/r200_maos_arrays.c
+++ b/src/mesa/drivers/dri/r200/r200_maos_arrays.c
@@ -29,20 +29,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Keith Whitwell <keithw at vmware.com>
*/
#include "main/glheader.h"
#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"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "r200_context.h"
#include "r200_ioctl.h"
#include "r200_state.h"
#include "r200_swtcl.h"
@@ -107,21 +108,21 @@ void r200EmitArrays( struct gl_context *ctx, GLubyte *vimap_rev )
break;
case 2:
assert(attrib == VERT_ATTRIB_NORMAL);
emitsize = 3;
vfmt0 |= R200_VTX_N0;
break;
case 3:
/* 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,
1,
VB->AttribPtr[attrib]->stride,
count);
else
rcommon_emit_vecfog( 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 b157572..2705d22 100644
--- a/src/mesa/drivers/dri/r200/r200_state.c
+++ b/src/mesa/drivers/dri/r200/r200_state.c
@@ -32,20 +32,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Authors:
* Keith Whitwell <keithw at vmware.com>
*/
#include "main/glheader.h"
#include "main/imports.h"
#include "main/enums.h"
#include "main/light.h"
#include "main/framebuffer.h"
#include "main/fbobject.h"
+#include "main/state.h"
#include "main/stencil.h"
#include "main/viewport.h"
#include "swrast/swrast.h"
#include "vbo/vbo.h"
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
#include "swrast_setup/swrast_setup.h"
#include "drivers/common/meta.h"
#include "util/bitscan.h"
@@ -2258,21 +2259,21 @@ GLboolean r200ValidateState( struct gl_context *ctx )
if (ctx->Transform.ClipPlanesEnabled)
r200UpdateClipPlanes( ctx );
}
if (new_state & (_NEW_PROGRAM|
_NEW_PROGRAM_CONSTANTS |
/* need to test for pretty much anything due to possible parameter bindings */
_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);
}
rmesa->radeon.NewGLState = 0;
return GL_TRUE;
}
@@ -2321,21 +2322,22 @@ static void r200WrapRunPipeline( struct gl_context *ctx )
if (0)
fprintf(stderr, "%s, newstate: %x\n", __func__, rmesa->radeon.NewGLState);
/* Validate state:
*/
if (rmesa->radeon.NewGLState)
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 );
}
/* Run the pipeline.
*/
_tnl_run_pipeline( ctx );
if (has_material) {
diff --git a/src/mesa/drivers/dri/r200/r200_state_init.c b/src/mesa/drivers/dri/r200/r200_state_init.c
index 8e14ba7..4f584d3 100644
--- a/src/mesa/drivers/dri/r200/r200_state_init.c
+++ b/src/mesa/drivers/dri/r200/r200_state_init.c
@@ -28,20 +28,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Keith Whitwell <keithw at vmware.com>
*/
#include "main/glheader.h"
#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"
#include "tnl/t_pipeline.h"
#include "swrast_setup/swrast_setup.h"
#include "radeon_common.h"
#include "radeon_mipmap_tree.h"
#include "r200_context.h"
#include "r200_ioctl.h"
@@ -222,47 +223,47 @@ static int check_##NM( struct gl_context *ctx, struct radeon_state_atom *atom) \
{ \
r200ContextPtr rmesa = R200_CONTEXT(ctx); \
(void) rmesa; \
return (FLAG) ? atom->cmd_size + (ADD) : 0; \
}
#define TCL_CHECK( NM, FLAG, ADD ) \
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 ) \
static int check_##NM( struct gl_context *ctx, struct radeon_state_atom *atom ) \
{ \
r200ContextPtr rmesa = R200_CONTEXT(ctx); \
return (!rmesa->radeon.TclFallback && (FLAG)) ? atom->cmd_size + (ADD) : 0; \
}
#define VP_CHECK( NM, FLAG, ADD ) \
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 )
TCL_CHECK( tcl, GL_TRUE, 0 )
TCL_CHECK( tcl_add8, GL_TRUE, 8 )
TCL_CHECK( tcl_add4, GL_TRUE, 4 )
TCL_CHECK( tcl_tex_add4, rmesa->state.texture.unit[atom->idx].unitneeded, 4 )
TCL_CHECK( tcl_lighting_add4, ctx->Light.Enabled, 4 )
TCL_CHECK( tcl_lighting_add6, ctx->Light.Enabled, 6 )
TCL_CHECK( tcl_light_add6, ctx->Light.Enabled && ctx->Light.Light[atom->idx].Enabled, 6 )
diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c
index 26968af..662c041 100644
--- a/src/mesa/drivers/dri/r200/r200_tcl.c
+++ b/src/mesa/drivers/dri/r200/r200_tcl.c
@@ -376,21 +376,21 @@ static GLboolean r200_run_tcl_render( struct gl_context *ctx,
if (VB->Count == 0)
return GL_FALSE;
/* Validate state:
*/
if (rmesa->radeon.NewGLState)
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.
*/
map_rev_fixed[0] = VERT_ATTRIB_POS;
/* technically there is no reason we always need VA_COLOR0. In theory
could disable it depending on lighting, color materials, texturing... */
map_rev_fixed[4] = VERT_ATTRIB_COLOR0;
if (ctx->Light.Enabled) {
map_rev_fixed[2] = VERT_ATTRIB_NORMAL;
@@ -546,21 +546,21 @@ static void transition_to_hwtnl( struct gl_context *ctx )
if ( rmesa->radeon.dma.flush )
rmesa->radeon.dma.flush( &rmesa->radeon.glCtx );
rmesa->radeon.dma.flush = NULL;
R200_STATECHANGE( rmesa, vap );
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;
}
if ( ((rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK)
== R200_FOG_USE_SPEC_ALPHA) &&
(ctx->Fog.FogCoordinateSource == GL_FOG_COORD )) {
R200_STATECHANGE( rmesa, ctx );
rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK;
rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_VTX_FOG;
}
diff --git a/src/mesa/drivers/dri/r200/r200_texstate.c b/src/mesa/drivers/dri/r200/r200_texstate.c
index 441ac73..dcf211f 100644
--- a/src/mesa/drivers/dri/r200/r200_texstate.c
+++ b/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -29,20 +29,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* Authors:
* Keith Whitwell <keithw at vmware.com>
*/
#include "main/glheader.h"
#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"
#include "radeon_common.h"
#include "radeon_mipmap_tree.h"
#include "r200_context.h"
#include "r200_state.h"
#include "r200_ioctl.h"
#include "r200_swtcl.h"
@@ -1473,21 +1474,21 @@ void r200UpdateTextureState( struct gl_context *ctx )
r200ContextPtr rmesa = R200_CONTEXT(ctx);
GLboolean ok;
GLuint dbg;
/* NOTE: must not manipulate rmesa->state.texture.unit[].unitneeded or
rmesa->state.envneeded before a R200_STATECHANGE (or R200_NEWPRIM) since
we use these to determine if we want to emit the corresponding state
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)
rmesa->state.texture.unit[i].unitneeded = 1 << _mesa_tex_target_to_index(ctx, ctx->Texture.Unit[i]._Current->Target);
else
rmesa->state.texture.unit[i].unitneeded = 0;
}
ok = GL_TRUE;
}
else {
@@ -1495,21 +1496,21 @@ void r200UpdateTextureState( struct gl_context *ctx )
}
if (ok) {
ok = (r200UpdateTextureUnit( ctx, 0 ) &&
r200UpdateTextureUnit( ctx, 1 ) &&
r200UpdateTextureUnit( ctx, 2 ) &&
r200UpdateTextureUnit( ctx, 3 ) &&
r200UpdateTextureUnit( ctx, 4 ) &&
r200UpdateTextureUnit( ctx, 5 ));
}
- if (ok && ctx->ATIFragmentShader._Enabled) {
+ if (ok && _mesa_ati_fragment_shader_enabled(ctx)) {
r200UpdateFragmentShader(ctx);
}
FALLBACK( rmesa, R200_FALLBACK_TEXTURE, !ok );
if (rmesa->radeon.TclFallback)
r200ChooseVertexState( ctx );
if (rmesa->radeon.radeonScreen->chip_family == CHIP_FAMILY_R200) {
@@ -1521,21 +1522,21 @@ void r200UpdateTextureState( struct gl_context *ctx )
if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_ENABLE_MASK) == R200_TEX_0_ENABLE &&
(rmesa->hw.tex[0].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) > R200_MIN_FILTER_LINEAR) {
R200_STATECHANGE(rmesa, ctx);
R200_STATECHANGE(rmesa, tex[1]);
rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_1_ENABLE;
if (!(rmesa->hw.cst.cmd[CST_PP_CNTL_X] & R200_PPX_TEX_1_ENABLE))
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]);
rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &= ~R200_TXFORMAT_LOOKUP_DISABLE;
}
}
/* do the same workaround for the first pass of a fragment shader.
* completely unknown if necessary / sufficient.
*/
if ((rmesa->hw.cst.cmd[CST_PP_CNTL_X] & R200_PPX_TEX_ENABLE_MASK) == R200_PPX_TEX_0_ENABLE &&
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 7aa8f9e..6ccb9e7 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -126,29 +126,31 @@ GLboolean
_mesa_valid_to_render(struct gl_context *ctx, const char *where)
{
/* This depends on having up to date derived state (shaders) */
if (ctx->NewState)
_mesa_update_state(ctx);
if (ctx->API == API_OPENGL_COMPAT) {
/* 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;
}
/* If drawing to integer-valued color buffers, there must be an
* active fragment shader (GL_EXT_texture_integer).
*/
if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerBuffers) {
_mesa_error(ctx, GL_INVALID_OPERATION,
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index aac9de7..2b924f6 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -26,20 +26,21 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
#include "main/glheader.h"
#include "main/context.h"
#include "main/imports.h"
#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"
#include "compiler/glsl/ir_builder.h"
#include "compiler/glsl/ir_optimization.h"
#include "compiler/glsl/glsl_parser_extras.h"
#include "compiler/glsl/glsl_symbol_table.h"
#include "compiler/glsl_types.h"
#include "program/ir_to_mesa.h"
#include "program/program.h"
@@ -165,21 +166,21 @@ static GLbitfield filter_fp_input_mask( GLbitfield fp_inputs,
}
if (ctx->RenderMode == GL_FEEDBACK) {
/* _NEW_RENDERMODE */
return fp_inputs & (VARYING_BIT_COL0 | VARYING_BIT_TEX0);
}
/* _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 */
GLbitfield possible_inputs = 0;
/* _NEW_VARYING_VP_INPUTS */
GLbitfield64 varying_inputs = ctx->varying_vp_inputs;
/* These get generated in the setup routine regardless of the
* vertex program:
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8c83944..3c4c9f1 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2177,21 +2177,20 @@ struct gl_program_state
const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_ARB/NV */
};
/**
* Context state for vertex programs.
*/
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 */
/** Currently enabled and valid vertex program (including internal
* programs, user-defined vertex programs and GLSL vertex shaders).
* This is the program we must use when rendering.
*/
struct gl_program *_Current;
@@ -2241,21 +2240,20 @@ struct gl_geometry_program_state
*/
struct gl_program *_Current;
};
/**
* Context state for fragment programs.
*/
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
* programs, user-defined fragment programs and GLSL fragment shaders).
* This is the program we must use when rendering.
*/
struct gl_program *_Current;
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
@@ -2310,21 +2308,20 @@ struct ati_fragment_shader
GLuint swizzlerq;
struct gl_program *Program;
};
/**
* Context state for GL_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;
};
/**
* Shader subroutine function definition
*/
struct gl_subroutine_function
{
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 4fddad1..43f6759 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -365,21 +365,21 @@ compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye
/**
* glRasterPos transformation. Typically called via ctx->Driver.RasterPos().
*
* \param vObj vertex position in object space
*/
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;
}
else {
GLfloat eye[4], clip[4], ndc[3], d;
GLfloat *norm, eyenorm[3];
GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
float scale[3], translate[3];
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 8df03f0..960b538 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -50,43 +50,20 @@
#include "texenvprogram.h"
#include "texobj.h"
#include "texstate.h"
#include "varray.h"
#include "vbo/vbo_context.h"
#include "viewport.h"
#include "blend.h"
/**
- * 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.
*
* Programs may come from 3 sources: GLSL shaders, ARB/NV_vertex/fragment
* programs or programs derived from fixed-function state.
*
* This function needs to be called after texture state validation in case
* we're generating a fragment program from fixed-function texture state.
*
* \return bitfield which will indicate _NEW_PROGRAM state if a new vertex
@@ -131,28 +108,28 @@ update_program(struct gl_context *ctx)
* program (and vice versa) here, but in practice that shouldn't ever
* come up, or matter.
*/
if (fsProg) {
/* Use GLSL fragment shader */
_mesa_reference_program(ctx, &ctx->FragmentProgram._Current, fsProg);
_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,
ctx->ATIFragmentShader.Current->Program);
_mesa_reference_program(ctx, &ctx->FragmentProgram._TexEnvProgram,
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);
@@ -196,21 +173,21 @@ update_program(struct gl_context *ctx)
}
/* Examine vertex program after fragment program as
* _mesa_get_fixed_func_vertex_program() needs to know active
* fragprog inputs.
*/
if (vsProg) {
/* 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);
}
else if (ctx->VertexProgram._MaintainTnlProgram) {
/* Use vertex program generated from fixed-function state */
_mesa_reference_program(ctx, &ctx->VertexProgram._Current,
_mesa_get_fixed_func_vertex_program(ctx));
_mesa_reference_program(ctx, &ctx->VertexProgram._TnlProgram,
ctx->VertexProgram._Current);
@@ -313,24 +290,20 @@ _mesa_update_state_locked( struct gl_context *ctx )
if (ctx->VertexProgram._MaintainTnlProgram) {
prog_flags |= (_NEW_VARYING_VP_INPUTS | _NEW_TEXTURE_OBJECT |
_NEW_TEXTURE_MATRIX | _NEW_TRANSFORM | _NEW_POINT |
_NEW_FOG | _NEW_LIGHT | _NEW_TEXTURE_STATE |
_MESA_NEW_NEED_EYE_COORDS);
}
/*
* 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 );
if (new_state & _NEW_TEXTURE_MATRIX)
_mesa_update_texture_matrices(ctx);
if (new_state & (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE | _NEW_PROGRAM))
_mesa_update_texture_state(ctx);
if (new_state & _NEW_BUFFERS)
diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h
index 6d81c3f..b719f39 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -65,32 +65,53 @@ _mesa_need_secondary_color(const struct gl_context *ctx)
return GL_TRUE;
if (ctx->FragmentProgram._Current &&
(ctx->FragmentProgram._Current != ctx->FragmentProgram._TexEnvProgram) &&
(ctx->FragmentProgram._Current->info.inputs_read & VARYING_BIT_COL1))
return GL_TRUE;
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;
}
/** Return 0=GL_CCW or 1=GL_CW */
static inline bool
_mesa_polygon_get_front_bit(const struct gl_context *ctx)
{
if (ctx->Transform.ClipOrigin == GL_LOWER_LEFT)
return ctx->Polygon.FrontFace == GL_CW;
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 1949ec2..132e231 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -31,20 +31,21 @@
#include <stdio.h>
#include "glheader.h"
#include "bufferobj.h"
#include "context.h"
#include "enums.h"
#include "macros.h"
#include "texobj.h"
#include "teximage.h"
#include "texstate.h"
#include "mtypes.h"
+#include "state.h"
#include "util/bitscan.h"
#include "util/bitset.h"
/**
* Default texture combine environment state. This is used to initialize
* a context's texture units and as the basis for converting "classic"
* texture environmnets to ARB_texture_env_combine style values.
*/
static const struct gl_tex_env_combine_state default_combine_state = {
@@ -814,21 +815,22 @@ _mesa_update_texture_state(struct gl_context *ctx)
BITSET_DECLARE(enabled_texture_units, MAX_COMBINED_TEXTURE_IMAGE_UNITS);
for (i = 0; i < MESA_SHADER_STAGES; i++) {
if (ctx->_Shader->CurrentProgram[i]) {
prog[i] = ctx->_Shader->CurrentProgram[i];
} else {
prog[i] = NULL;
}
}
- 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;
}
/* TODO: only set this if there are actual changes */
ctx->NewState |= _NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE;
ctx->Texture._GenFlags = 0x0;
ctx->Texture._TexMatEnabled = 0x0;
ctx->Texture._TexGenEnabled = 0x0;
ctx->Texture._MaxEnabledTexImageUnit = -1;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 092b418..384f965 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -34,20 +34,21 @@
#include "main/image.h"
#include "main/bufferobj.h"
#include "main/blit.h"
#include "main/format_pack.h"
#include "main/framebuffer.h"
#include "main/macros.h"
#include "main/mtypes.h"
#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"
#include "main/glformats.h"
#include "program/program.h"
#include "program/prog_print.h"
#include "program/prog_instruction.h"
#include "st_atom.h"
#include "st_atom_constbuf.h"
@@ -1312,21 +1313,21 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
ctx->_ImageTransferState == 0x0 &&
!ctx->Color.BlendEnabled &&
!ctx->Color.AlphaEnabled &&
(!ctx->Color.ColorLogicOpEnabled || ctx->Color.LogicOp == GL_COPY) &&
!ctx->Depth.Test &&
!ctx->Fog.Enabled &&
!ctx->Stencil.Enabled &&
!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) {
struct st_renderbuffer *rbRead, *rbDraw;
/*
* Clip the read region against the src buffer bounds.
* We'll still allocate a temporary buffer/texture for the original
* src region size but we'll only read the region which is on-screen.
* This may mean that we draw garbage pixels into the dest region, but
diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c
index 71389c6..9f3d21f 100644
--- a/src/mesa/swrast/s_context.c
+++ b/src/mesa/swrast/s_context.c
@@ -22,20 +22,21 @@
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Keith Whitwell <keithw at vmware.com> Brian Paul
*/
#include "main/imports.h"
#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"
#include "program/prog_statevars.h"
#include "swrast.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_lines.h"
#include "s_points.h"
#include "s_span.h"
@@ -102,21 +103,21 @@ _swrast_update_rasterflags( struct gl_context *ctx )
rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
break;
}
}
if (_swrast_use_fragment_program(ctx)) {
rasterMask |= FRAGPROG_BIT;
}
- if (ctx->ATIFragmentShader._Enabled) {
+ if (_mesa_ati_fragment_shader_enabled(ctx)) {
rasterMask |= ATIFRAGSHADER_BIT;
}
#if CHAN_TYPE == GL_FLOAT
if (ctx->Color.ClampFragmentColor == GL_TRUE) {
rasterMask |= CLAMPING_BIT;
}
#endif
SWRAST_CONTEXT(ctx)->_RasterMask = rasterMask;
@@ -282,21 +283,21 @@ static void
_swrast_update_specular_vertex_add(struct gl_context *ctx)
{
SWcontext *swrast = SWRAST_CONTEXT(ctx);
GLboolean separateSpecular = ctx->Fog.ColorSumEnabled ||
(ctx->Light.Enabled &&
ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR);
swrast->SpecularVertexAdd = (separateSpecular
&& ctx->Texture._MaxEnabledTexImageUnit == -1
&& !_swrast_use_fragment_program(ctx)
- && !ctx->ATIFragmentShader._Enabled);
+ && !_mesa_ati_fragment_shader_enabled(ctx));
}
#define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \
_NEW_PROGRAM_CONSTANTS | \
_NEW_TEXTURE | \
_NEW_HINT | \
_NEW_POLYGON )
/* State referenced by _swrast_choose_triangle, _swrast_choose_line.
@@ -497,21 +498,21 @@ _swrast_update_active_attribs(struct gl_context *ctx)
GLbitfield64 attribsMask;
/*
* Compute _ActiveAttribsMask = which fragment attributes are needed.
*/
if (_swrast_use_fragment_program(ctx)) {
/* fragment program/shader */
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;
}
else {
/* fixed function */
attribsMask = 0x0;
#if CHAN_TYPE == GL_FLOAT
attribsMask |= VARYING_BIT_COL0;
#endif
diff --git a/src/mesa/swrast/s_span.c b/src/mesa/swrast/s_span.c
index 8183563..47a73e9 100644
--- a/src/mesa/swrast/s_span.c
+++ b/src/mesa/swrast/s_span.c
@@ -32,20 +32,21 @@
*/
#include "c99_math.h"
#include "main/glheader.h"
#include "main/format_pack.h"
#include "main/format_unpack.h"
#include "main/macros.h"
#include "main/imports.h"
#include "main/image.h"
#include "main/samplerobj.h"
+#include "main/state.h"
#include "main/stencil.h"
#include "main/teximage.h"
#include "s_atifragshader.h"
#include "s_alpha.h"
#include "s_blend.h"
#include "s_context.h"
#include "s_depth.h"
#include "s_fog.h"
#include "s_logic.h"
@@ -136,21 +137,21 @@ _swrast_span_default_attribs(struct gl_context *ctx, SWspan *span)
span->attrStepY[VARYING_SLOT_FOGC][0] = 0.0;
}
/* texcoords */
{
GLuint i;
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
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) {
/* use (s/q, t/q, r/q, 1) */
span->attrStart[attr][0] = tc[0] / tc[3];
span->attrStart[attr][1] = tc[1] / tc[3];
span->attrStart[attr][2] = tc[2] / tc[3];
span->attrStart[attr][3] = 1.0;
}
else {
@@ -517,21 +518,21 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
else {
/* using a fragment program */
texW = 1.0;
texH = 1.0;
needLambda = GL_FALSE;
}
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;
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
texcoord[i][1] = t * invW;
texcoord[i][2] = r * invW;
texcoord[i][3] = q * invW;
lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy,
@@ -558,21 +559,21 @@ interpolate_texcoords(struct gl_context *ctx, SWspan *span)
t += dtdx;
r += drdx;
q += dqdx;
}
}
span->arrayMask |= SPAN_LAMBDA;
}
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;
for (i = 0; i < span->end; i++) {
const GLfloat invW = 1.0F / w;
texcoord[i][0] = s * invW;
texcoord[i][1] = t * invW;
texcoord[i][2] = r * invW;
texcoord[i][3] = q * invW;
lambda[i] = 0.0;
@@ -970,21 +971,21 @@ convert_color_type(SWspan *span, GLenum srcType, GLenum newType, GLuint output)
/**
* Apply fragment shader, fragment program or normal texturing to span.
*/
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);
}
else {
span->array->rgba = (void *) span->array->attribs[VARYING_SLOT_COL0];
}
if (span->primitive != GL_POINT ||
(span->interpMask & SPAN_RGBA) ||
@@ -1002,21 +1003,21 @@ shade_texture_span(struct gl_context *ctx, SWspan *span)
#else
/* XXX always interpolate wpos so that DDX/DDY work */
#endif
interpolate_wpos(ctx, span);
/* Run fragment program/shader now */
if (_swrast_use_fragment_program(ctx)) {
_swrast_exec_fragment_program(ctx, span);
}
else {
- assert(ctx->ATIFragmentShader._Enabled);
+ assert(_mesa_ati_fragment_shader_enabled(ctx));
_swrast_exec_fragment_shader(ctx, span);
}
}
else if (ctx->Texture._EnabledCoordUnits) {
/* conventional texturing */
#if CHAN_BITS == 32
if ((span->arrayAttribs & VARYING_BIT_COL0) == 0) {
interpolate_int_colors(ctx, span);
}
@@ -1132,21 +1133,21 @@ void
_swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
{
const SWcontext *swrast = SWRAST_CONTEXT(ctx);
const GLuint *colorMask = (GLuint *) ctx->Color.ColorMask;
const GLbitfield origInterpMask = span->interpMask;
const GLbitfield origArrayMask = span->arrayMask;
const GLbitfield64 origArrayAttribs = span->arrayAttribs;
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;
/*
printf("%s() interp 0x%x array 0x%x\n", __func__,
span->interpMask, span->arrayMask);
*/
assert(span->primitive == GL_POINT ||
span->primitive == GL_LINE ||
diff --git a/src/mesa/swrast/s_triangle.c b/src/mesa/swrast/s_triangle.c
index 9e4f81e..a4113e5 100644
--- a/src/mesa/swrast/s_triangle.c
+++ b/src/mesa/swrast/s_triangle.c
@@ -1035,21 +1035,21 @@ _swrast_choose_triangle( struct gl_context *ctx )
return;
}
}
/*
* XXX should examine swrast->_ActiveAttribMask to determine what
* needs to be interpolated.
*/
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 */
const struct gl_texture_object *texObj2D;
const struct gl_sampler_object *samp;
const struct gl_texture_image *texImg;
const struct swrast_texture_image *swImg;
GLenum minFilter, magFilter, envMode;
mesa_format format;
texObj2D = ctx->Texture.Unit[0].CurrentTex[TEXTURE_2D_INDEX];
@@ -1064,21 +1064,21 @@ _swrast_choose_triangle( struct gl_context *ctx )
swImg = swrast_texture_image_const(texImg);
format = texImg ? texImg->TexFormat : MESA_FORMAT_NONE;
minFilter = texObj2D ? samp->MinFilter : GL_NONE;
magFilter = texObj2D ? samp->MagFilter : GL_NONE;
envMode = ctx->Texture.Unit[0].EnvMode;
/* 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
&& samp->WrapT == GL_REPEAT
&& texObj2D->_Swizzle == SWIZZLE_NOOP
&& swImg->_IsPowerOfTwo
&& texImg->Border == 0
&& (_mesa_format_row_stride(format, texImg->Width) ==
swImg->RowStride)
&& (format == MESA_FORMAT_BGR_UNORM8 || format == MESA_FORMAT_A8B8G8R8_UNORM)
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index 74b1da3..ec20d6c 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -21,20 +21,21 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Keith Whitwell <keithw at vmware.com>
*/
#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"
#include "tnl/t_vertex.h"
#include "swrast_setup.h"
#include "ss_context.h"
#include "ss_triangle.h"
/* Need to check lighting state and vertex program state to know
@@ -106,21 +107,21 @@ do { \
* Tell the tnl module how to build SWvertex objects for swrast.
* We'll build the map[] array with that info and pass it to
* _tnl_install_attrs().
*/
static void
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;
if (intColors != swsetup->intColors ||
tnl->render_inputs_bitset != swsetup->last_index_bitset) {
GLbitfield64 index_bitset = tnl->render_inputs_bitset;
struct tnl_attr_map map[_TNL_ATTRIB_MAX];
unsigned int i, e = 0;
swsetup->intColors = intColors;
diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
index 23e09a2..19be5ee 100644
--- a/src/mesa/tnl/t_vb_program.c
+++ b/src/mesa/tnl/t_vb_program.c
@@ -28,20 +28,21 @@
* \file tnl/t_vb_program.c
* \brief Pipeline stage for executing vertex programs.
* \author Brian Paul, Keith Whitwell
*/
#include "main/glheader.h"
#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"
#include "program/prog_execute.h"
#include "swrast/s_context.h"
#include "util/bitscan.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
@@ -155,21 +156,22 @@ do_ndc_cliptest(struct gl_context *ctx, struct vp_stage_data *store)
}
if (store->andmask) {
/* All vertices are outside the frustum */
return GL_FALSE;
}
/* 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,
store->clipmask,
&store->ormask,
&store->andmask );
if (store->andmask) {
return GL_FALSE;
}
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index e718f29..8a4b659 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -286,22 +286,24 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void *data)
*/
vbo_save_loopback_vertex_list( ctx, node );
goto end;
}
if (ctx->NewState)
_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;
}
vbo_bind_vertex_list( ctx, node );
vbo_draw_method(vbo_context(ctx), DRAW_DISPLAY_LIST);
/* Again...
--
2.7.4
More information about the mesa-dev
mailing list