summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-11-15 22:02:51 +0100
committerMarek Olšák <[email protected]>2018-02-13 01:00:45 +0100
commit07c10cc59c164ddd0109e061dac8edf47437d8ca (patch)
treead38e5e0408a4fe07fb41a77b0bacef2e19a7100 /src/mesa/main
parent79aca14f5f37de32140fb710970133c72886a0f2 (diff)
mesa: separate legacy stuff from gl_texture_unit into gl_fixedfunc_texture_unit
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/attrib.c17
-rw-r--r--src/mesa/main/context.c6
-rw-r--r--src/mesa/main/enable.c23
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp3
-rw-r--r--src/mesa/main/ffvertex_prog.c3
-rw-r--r--src/mesa/main/get.c7
-rw-r--r--src/mesa/main/get_hash_params.py10
-rw-r--r--src/mesa/main/mtypes.h40
-rw-r--r--src/mesa/main/rastpos.c5
-rw-r--r--src/mesa/main/texenv.c40
-rw-r--r--src/mesa/main/texgen.c18
-rw-r--r--src/mesa/main/texstate.c83
-rw-r--r--src/mesa/main/texstate.h15
13 files changed, 164 insertions, 106 deletions
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 8ac5db062fc..398ff653b73 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -374,8 +374,8 @@ _mesa_PushAttrib(GLbitfield mask)
attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne;
attr->SampleCoverage = ctx->Multisample.SampleCoverage;
for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- attr->Texture[i] = ctx->Texture.Unit[i].Enabled;
- attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled;
+ attr->Texture[i] = ctx->Texture.FixedFuncUnit[i].Enabled;
+ attr->TexGen[i] = ctx->Texture.FixedFuncUnit[i].TexGenEnabled;
}
/* GL_ARB_vertex_program */
attr->VertexProgram = ctx->VertexProgram.Enabled;
@@ -718,7 +718,7 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
const GLbitfield enabled = enable->Texture[i];
const GLbitfield genEnabled = enable->TexGen[i];
- if (ctx->Texture.Unit[i].Enabled != enabled) {
+ if (ctx->Texture.FixedFuncUnit[i].Enabled != enabled) {
_mesa_ActiveTexture(GL_TEXTURE0 + i);
_mesa_set_enable(ctx, GL_TEXTURE_1D, !!(enabled & TEXTURE_1D_BIT));
@@ -734,7 +734,7 @@ pop_enable_group(struct gl_context *ctx, const struct gl_enable_attrib *enable)
}
}
- if (ctx->Texture.Unit[i].TexGenEnabled != genEnabled) {
+ if (ctx->Texture.FixedFuncUnit[i].TexGenEnabled != genEnabled) {
_mesa_ActiveTexture(GL_TEXTURE0 + i);
_mesa_set_enable(ctx, GL_TEXTURE_GEN_S, !!(genEnabled & S_BIT));
_mesa_set_enable(ctx, GL_TEXTURE_GEN_T, !!(genEnabled & T_BIT));
@@ -758,7 +758,8 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
_mesa_lock_context_textures(ctx);
for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
- const struct gl_texture_unit *unit = &texstate->Texture.Unit[u];
+ const struct gl_fixedfunc_texture_unit *unit =
+ &texstate->Texture.FixedFuncUnit[u];
GLuint tgt;
_mesa_ActiveTexture(GL_TEXTURE0_ARB + u);
@@ -785,7 +786,9 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
_mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->GenQ.ObjectPlane);
/* Eye plane done differently to avoid re-transformation */
{
- struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u];
+ struct gl_fixedfunc_texture_unit *destUnit =
+ &ctx->Texture.FixedFuncUnit[u];
+
COPY_4FV(destUnit->GenS.EyePlane, unit->GenS.EyePlane);
COPY_4FV(destUnit->GenT.EyePlane, unit->GenT.EyePlane);
COPY_4FV(destUnit->GenR.EyePlane, unit->GenR.EyePlane);
@@ -802,7 +805,7 @@ pop_texture_group(struct gl_context *ctx, struct texture_state *texstate)
_mesa_set_enable(ctx, GL_TEXTURE_GEN_R, !!(unit->TexGenEnabled & R_BIT));
_mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, !!(unit->TexGenEnabled & Q_BIT));
_mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS,
- unit->LodBias);
+ texstate->Texture.Unit[u].LodBias);
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,
unit->Combine.ModeRGB);
_mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 7dbf67871dd..79d3e39e922 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1264,8 +1264,10 @@ _mesa_initialize_context(struct gl_context *ctx,
* GL_OES_texture_cube_map says
* "Initially all texture generation modes are set to REFLECTION_MAP_OES"
*/
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+ for (i = 0; i < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); i++) {
+ struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[i];
+
texUnit->GenS.Mode = GL_REFLECTION_MAP_NV;
texUnit->GenT.Mode = GL_REFLECTION_MAP_NV;
texUnit->GenR.Mode = GL_REFLECTION_MAP_NV;
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 967d23080c7..4c5f9dce5e4 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -186,7 +186,7 @@ _mesa_DisableClientState( GLenum cap )
* Note that we'll set GL_INVALID_OPERATION and return NULL if the active
* texture unit is higher than the number of supported coordinate units.
*/
-static struct gl_texture_unit *
+static struct gl_fixedfunc_texture_unit *
get_texcoord_unit(struct gl_context *ctx)
{
if (ctx->Texture.CurrentUnit >= ctx->Const.MaxTextureCoordUnits) {
@@ -194,7 +194,7 @@ get_texcoord_unit(struct gl_context *ctx)
return NULL;
}
else {
- return &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return &ctx->Texture.FixedFuncUnit[ctx->Texture.CurrentUnit];
}
}
@@ -207,7 +207,9 @@ get_texcoord_unit(struct gl_context *ctx)
static GLboolean
enable_texture(struct gl_context *ctx, GLboolean state, GLbitfield texBit)
{
- struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+ struct gl_fixedfunc_texture_unit *texUnit =
+ _mesa_get_current_fixedfunc_tex_unit(ctx);
+
const GLbitfield newenabled = state
? (texUnit->Enabled | texBit) : (texUnit->Enabled & ~texBit);
@@ -748,7 +750,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
case GL_TEXTURE_GEN_R:
case GL_TEXTURE_GEN_Q:
{
- struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ struct gl_fixedfunc_texture_unit *texUnit = get_texcoord_unit(ctx);
if (ctx->API != API_OPENGL_COMPAT)
goto invalid_enum_error;
@@ -769,7 +771,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
case GL_TEXTURE_GEN_STR_OES:
/* disable S, T, and R at the same time */
{
- struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ struct gl_fixedfunc_texture_unit *texUnit = get_texcoord_unit(ctx);
if (ctx->API != API_OPENGLES)
goto invalid_enum_error;
@@ -1288,8 +1290,9 @@ _mesa_IsEnabledi( GLenum cap, GLuint index )
static GLboolean
is_texture_enabled(struct gl_context *ctx, GLbitfield bit)
{
- const struct gl_texture_unit *const texUnit =
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const struct gl_fixedfunc_texture_unit *const texUnit =
+ _mesa_get_current_fixedfunc_tex_unit(ctx);
+
return (texUnit->Enabled & bit) ? GL_TRUE : GL_FALSE;
}
@@ -1506,7 +1509,8 @@ _mesa_IsEnabled( GLenum cap )
case GL_TEXTURE_GEN_R:
case GL_TEXTURE_GEN_Q:
{
- const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ const struct gl_fixedfunc_texture_unit *texUnit =
+ get_texcoord_unit(ctx);
if (ctx->API != API_OPENGL_COMPAT)
goto invalid_enum_error;
@@ -1519,7 +1523,8 @@ _mesa_IsEnabled( GLenum cap )
return GL_FALSE;
case GL_TEXTURE_GEN_STR_OES:
{
- const struct gl_texture_unit *texUnit = get_texcoord_unit(ctx);
+ const struct gl_fixedfunc_texture_unit *texUnit =
+ get_texcoord_unit(ctx);
if (ctx->API != API_OPENGLES)
goto invalid_enum_error;
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 2be3ae37de3..a698931d99e 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -268,7 +268,8 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key )
i = u_bit_scan(&mask);
const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
const struct gl_texture_object *texObj = texUnit->_Current;
- const struct gl_tex_env_combine_packed *comb = &texUnit->_CurrentCombinePacked;
+ const struct gl_tex_env_combine_packed *comb =
+ &ctx->Texture.FixedFuncUnit[i]._CurrentCombinePacked;
if (!texObj)
continue;
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 6a022b83bdc..976b6f46b9f 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -235,7 +235,8 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
| ctx->Texture._TexMatEnabled | ctx->Point.CoordReplace;
while (mask) {
const int i = u_bit_scan(&mask);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+ struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[i];
if (ctx->Point.PointSprite)
if (ctx->Point.CoordReplace & (1u << i))
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 516e8d174ce..218801791e2 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1390,7 +1390,6 @@ static const struct value_desc *
find_value(const char *func, GLenum pname, void **p, union value *v)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *unit;
int mask, hash;
const struct value_desc *d;
int api;
@@ -1445,8 +1444,10 @@ find_value(const char *func, GLenum pname, void **p, union value *v)
*p = ((char *) ctx->Array.VAO + d->offset);
return d;
case LOC_TEXUNIT:
- unit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- *p = ((char *) unit + d->offset);
+ if (ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->Texture.FixedFuncUnit)) {
+ unsigned index = ctx->Texture.CurrentUnit;
+ *p = ((char *)&ctx->Texture.FixedFuncUnit[index] + d->offset);
+ }
return d;
case LOC_CUSTOM:
find_custom_value(ctx, d, v);
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index df082af2074..e127b6bdb23 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -234,7 +234,7 @@ descriptor=[
# GL_ARB_texture_cube_map
[ "TEXTURE_CUBE_MAP_ARB", "LOC_CUSTOM, TYPE_BOOLEAN, 0, NO_EXTRA" ],
# S, T, and R are always set at the same time
- [ "TEXTURE_GEN_STR_OES", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
+ [ "TEXTURE_GEN_STR_OES", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
# GL_ARB_multisample
[ "MULTISAMPLE_ARB", "CONTEXT_BOOL(Multisample.Enabled), NO_EXTRA" ],
@@ -760,10 +760,10 @@ descriptor=[
[ "TEXTURE_3D", "LOC_CUSTOM, TYPE_BOOLEAN, NO_OFFSET, NO_EXTRA" ],
[ "TEXTURE_BINDING_1D", "LOC_CUSTOM, TYPE_INT, TEXTURE_1D_INDEX, NO_EXTRA" ],
[ "TEXTURE_BINDING_1D_ARRAY", "LOC_CUSTOM, TYPE_INT, TEXTURE_1D_ARRAY_INDEX, extra_EXT_texture_array" ],
- [ "TEXTURE_GEN_S", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
- [ "TEXTURE_GEN_T", "LOC_TEXUNIT, TYPE_BIT_1, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
- [ "TEXTURE_GEN_R", "LOC_TEXUNIT, TYPE_BIT_2, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
- [ "TEXTURE_GEN_Q", "LOC_TEXUNIT, TYPE_BIT_3, offsetof(struct gl_texture_unit, TexGenEnabled), NO_EXTRA" ],
+ [ "TEXTURE_GEN_S", "LOC_TEXUNIT, TYPE_BIT_0, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
+ [ "TEXTURE_GEN_T", "LOC_TEXUNIT, TYPE_BIT_1, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
+ [ "TEXTURE_GEN_R", "LOC_TEXUNIT, TYPE_BIT_2, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
+ [ "TEXTURE_GEN_Q", "LOC_TEXUNIT, TYPE_BIT_3, offsetof(struct gl_fixedfunc_texture_unit, TexGenEnabled), NO_EXTRA" ],
[ "UNPACK_LSB_FIRST", "CONTEXT_BOOL(Unpack.LsbFirst), NO_EXTRA" ],
[ "UNPACK_SWAP_BYTES", "CONTEXT_BOOL(Unpack.SwapBytes), NO_EXTRA" ],
[ "ZOOM_X", "CONTEXT_FLOAT(Pixel.ZoomX), NO_EXTRA" ],
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 46137f5d4ae..562fb17c10f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1275,11 +1275,32 @@ struct gl_texgen
/**
- * Texture unit state. Contains enable flags, texture environment/function/
- * combiners, texgen state, and pointers to current texture objects.
+ * Sampler-related subset of a texture unit, like current texture objects.
*/
struct gl_texture_unit
{
+ GLfloat LodBias; /**< for biasing mipmap levels */
+
+ /** Texture targets that have a non-default texture bound */
+ GLbitfield _BoundTextures;
+
+ /** Current sampler object (GL_ARB_sampler_objects) */
+ struct gl_sampler_object *Sampler;
+
+ /** Current texture object pointers */
+ struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
+
+ /** Points to highest priority, complete and enabled texture object */
+ struct gl_texture_object *_Current;
+};
+
+
+/**
+ * Fixed-function-related subset of a texture unit, like enable flags,
+ * texture environment/function/combiners, and texgen state.
+ */
+struct gl_fixedfunc_texture_unit
+{
GLbitfield Enabled; /**< bitmask of TEXTURE_*_BIT flags */
GLenum16 EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
@@ -1293,14 +1314,6 @@ struct gl_texture_unit
GLbitfield TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
GLbitfield _GenFlags; /**< Bitwise-OR of Gen[STRQ]._ModeBit */
- GLfloat LodBias; /**< for biasing mipmap levels */
-
- /** Texture targets that have a non-default texture bound */
- GLbitfield _BoundTextures;
-
- /** Current sampler object (GL_ARB_sampler_objects) */
- struct gl_sampler_object *Sampler;
-
/**
* \name GL_EXT_texture_env_combine
*/
@@ -1318,12 +1331,6 @@ struct gl_texture_unit
*/
struct gl_tex_env_combine_state *_CurrentCombine;
- /** Current texture object pointers */
- struct gl_texture_object *CurrentTex[NUM_TEXTURE_TARGETS];
-
- /** Points to highest priority, complete and enabled texture object */
- struct gl_texture_object *_Current;
-
/** Current compressed TexEnv & Combine state */
struct gl_tex_env_combine_packed _CurrentCombinePacked;
};
@@ -1363,6 +1370,7 @@ struct gl_texture_attrib
GLint NumCurrentTexUsed;
struct gl_texture_unit Unit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
+ struct gl_fixedfunc_texture_unit FixedFuncUnit[MAX_COMBINED_TEXTURE_IMAGE_UNITS];
};
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 43f67596d1f..dd1042fc8c2 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -266,7 +266,8 @@ static void
compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye[4],
const GLfloat normal[3], GLuint unit, GLfloat texcoord[4])
{
- const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[unit];
/* always compute sphere map terms, just in case */
GLfloat u[3], two_nu, rx, ry, rz, m, mInv;
@@ -464,7 +465,7 @@ _mesa_RasterPos(struct gl_context *ctx, const GLfloat vObj[4])
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
GLfloat tc[4];
COPY_4V(tc, ctx->Current.Attrib[VERT_ATTRIB_TEX0 + u]);
- if (ctx->Texture.Unit[u].TexGenEnabled) {
+ if (ctx->Texture.FixedFuncUnit[u].TexGenEnabled) {
compute_texgen(ctx, vObj, eye, norm, u, tc);
}
TRANSFORM_POINT(ctx->Current.RasterTexCoords[u],
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index 2fcaf7c07e4..9018ce9bc4c 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -48,7 +48,7 @@
/** Set texture env mode */
static void
set_env_mode(struct gl_context *ctx,
- struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *texUnit,
GLenum mode)
{
GLboolean legal;
@@ -88,7 +88,7 @@ set_env_mode(struct gl_context *ctx,
static void
set_env_color(struct gl_context *ctx,
- struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *texUnit,
const GLfloat *color)
{
if (TEST_EQ_4V(color, texUnit->EnvColorUnclamped))
@@ -105,7 +105,7 @@ set_env_color(struct gl_context *ctx,
/** Set an RGB or A combiner mode/function */
static void
set_combiner_mode(struct gl_context *ctx,
- struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *texUnit,
GLenum pname, GLenum mode)
{
GLboolean legal;
@@ -171,7 +171,7 @@ set_combiner_mode(struct gl_context *ctx,
/** Set an RGB or A combiner source term */
static void
set_combiner_source(struct gl_context *ctx,
- struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *texUnit,
GLenum pname, GLenum param)
{
GLuint term;
@@ -261,7 +261,7 @@ set_combiner_source(struct gl_context *ctx,
/** Set an RGB or A combiner operand term */
static void
set_combiner_operand(struct gl_context *ctx,
- struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *texUnit,
GLenum pname, GLenum param)
{
GLuint term;
@@ -342,7 +342,7 @@ set_combiner_operand(struct gl_context *ctx,
static void
set_combiner_scale(struct gl_context *ctx,
- struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *texUnit,
GLenum pname, GLfloat scale)
{
GLuint shift;
@@ -386,7 +386,6 @@ void GLAPIENTRY
_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
{
const GLint iparam0 = (GLint) param[0];
- struct gl_texture_unit *texUnit;
GLuint maxUnit;
GET_CURRENT_CONTEXT(ctx);
@@ -397,9 +396,10 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
-
if (target == GL_TEXTURE_ENV) {
+ struct gl_fixedfunc_texture_unit *texUnit =
+ _mesa_get_current_fixedfunc_tex_unit(ctx);
+
switch (pname) {
case GL_TEXTURE_ENV_MODE:
set_env_mode(ctx, texUnit, (GLenum) iparam0);
@@ -441,6 +441,9 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
}
}
else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+ struct gl_texture_unit *texUnit =
+ _mesa_get_current_tex_unit(ctx);
+
if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
if (texUnit->LodBias == param[0])
return;
@@ -547,7 +550,8 @@ _mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param )
* \return value of queried pname or -1 if error.
*/
static GLint
-get_texenvi(struct gl_context *ctx, const struct gl_texture_unit *texUnit,
+get_texenvi(struct gl_context *ctx,
+ const struct gl_fixedfunc_texture_unit *texUnit,
GLenum pname)
{
switch (pname) {
@@ -632,7 +636,6 @@ void GLAPIENTRY
_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
{
GLuint maxUnit;
- const struct gl_texture_unit *texUnit;
GET_CURRENT_CONTEXT(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
@@ -642,9 +645,10 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
-
if (target == GL_TEXTURE_ENV) {
+ struct gl_fixedfunc_texture_unit *texUnit =
+ _mesa_get_current_fixedfunc_tex_unit(ctx);
+
if (pname == GL_TEXTURE_ENV_COLOR) {
if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
_mesa_update_state(ctx);
@@ -661,6 +665,8 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
}
}
else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+ const struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+
if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
*params = texUnit->LodBias;
}
@@ -698,7 +704,6 @@ void GLAPIENTRY
_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
{
GLuint maxUnit;
- const struct gl_texture_unit *texUnit;
GET_CURRENT_CONTEXT(ctx);
maxUnit = (target == GL_POINT_SPRITE_NV && pname == GL_COORD_REPLACE_NV)
@@ -708,9 +713,10 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
-
if (target == GL_TEXTURE_ENV) {
+ struct gl_fixedfunc_texture_unit *texUnit =
+ _mesa_get_current_fixedfunc_tex_unit(ctx);
+
if (pname == GL_TEXTURE_ENV_COLOR) {
params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] );
params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
@@ -725,6 +731,8 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
}
}
else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+ const struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
+
if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
*params = (GLint) texUnit->LodBias;
}
diff --git a/src/mesa/main/texgen.c b/src/mesa/main/texgen.c
index 1b8d187cd3b..45f86fd911f 100644
--- a/src/mesa/main/texgen.c
+++ b/src/mesa/main/texgen.c
@@ -44,7 +44,7 @@
* Return texgen state for given coordinate
*/
static struct gl_texgen *
-get_texgen(struct gl_context *ctx, struct gl_texture_unit *texUnit,
+get_texgen(struct gl_context *ctx, struct gl_fixedfunc_texture_unit *texUnit,
GLenum coord)
{
if (ctx->API == API_OPENGLES) {
@@ -70,7 +70,7 @@ get_texgen(struct gl_context *ctx, struct gl_texture_unit *texUnit,
void GLAPIENTRY
_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
{
- struct gl_texture_unit *texUnit;
+ struct gl_fixedfunc_texture_unit *texUnit;
struct gl_texgen *texgen;
GET_CURRENT_CONTEXT(ctx);
@@ -86,7 +86,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
+ texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
texgen = get_texgen(ctx, texUnit, coord);
if (!texgen) {
@@ -289,7 +289,7 @@ _mesa_TexGeni( GLenum coord, GLenum pname, GLint param )
void GLAPIENTRY
_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
{
- struct gl_texture_unit *texUnit;
+ struct gl_fixedfunc_texture_unit *texUnit;
struct gl_texgen *texgen;
GET_CURRENT_CONTEXT(ctx);
@@ -298,7 +298,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
+ texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
texgen = get_texgen(ctx, texUnit, coord);
if (!texgen) {
@@ -326,7 +326,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
void GLAPIENTRY
_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
{
- struct gl_texture_unit *texUnit;
+ struct gl_fixedfunc_texture_unit *texUnit;
struct gl_texgen *texgen;
GET_CURRENT_CONTEXT(ctx);
@@ -335,7 +335,7 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
+ texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
texgen = get_texgen(ctx, texUnit, coord);
if (!texgen) {
@@ -371,7 +371,7 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
void GLAPIENTRY
_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
{
- struct gl_texture_unit *texUnit;
+ struct gl_fixedfunc_texture_unit *texUnit;
struct gl_texgen *texgen;
GET_CURRENT_CONTEXT(ctx);
@@ -380,7 +380,7 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
return;
}
- texUnit = _mesa_get_current_tex_unit(ctx);
+ texUnit = _mesa_get_current_fixedfunc_tex_unit(ctx);
texgen = get_texgen(ctx, texUnit, coord);
if (!texgen) {
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index e24b3c494cc..2b05630e619 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -78,19 +78,8 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
/* per-unit state */
for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) {
- dst->Texture.Unit[u].Enabled = src->Texture.Unit[u].Enabled;
- dst->Texture.Unit[u].EnvMode = src->Texture.Unit[u].EnvMode;
- COPY_4V(dst->Texture.Unit[u].EnvColor, src->Texture.Unit[u].EnvColor);
- dst->Texture.Unit[u].TexGenEnabled = src->Texture.Unit[u].TexGenEnabled;
- dst->Texture.Unit[u].GenS = src->Texture.Unit[u].GenS;
- dst->Texture.Unit[u].GenT = src->Texture.Unit[u].GenT;
- dst->Texture.Unit[u].GenR = src->Texture.Unit[u].GenR;
- dst->Texture.Unit[u].GenQ = src->Texture.Unit[u].GenQ;
dst->Texture.Unit[u].LodBias = src->Texture.Unit[u].LodBias;
- /* GL_EXT_texture_env_combine */
- dst->Texture.Unit[u].Combine = src->Texture.Unit[u].Combine;
-
/*
* XXX strictly speaking, we should compare texture names/ids and
* bind textures in the dest context according to id. For now, only
@@ -113,6 +102,20 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
_mesa_unlock_context_textures(dst);
}
}
+
+ for (u = 0; u < src->Const.MaxCombinedTextureImageUnits; u++) {
+ dst->Texture.FixedFuncUnit[u].Enabled = src->Texture.FixedFuncUnit[u].Enabled;
+ dst->Texture.FixedFuncUnit[u].EnvMode = src->Texture.FixedFuncUnit[u].EnvMode;
+ COPY_4V(dst->Texture.FixedFuncUnit[u].EnvColor, src->Texture.FixedFuncUnit[u].EnvColor);
+ dst->Texture.FixedFuncUnit[u].TexGenEnabled = src->Texture.FixedFuncUnit[u].TexGenEnabled;
+ dst->Texture.FixedFuncUnit[u].GenS = src->Texture.FixedFuncUnit[u].GenS;
+ dst->Texture.FixedFuncUnit[u].GenT = src->Texture.FixedFuncUnit[u].GenT;
+ dst->Texture.FixedFuncUnit[u].GenR = src->Texture.FixedFuncUnit[u].GenR;
+ dst->Texture.FixedFuncUnit[u].GenQ = src->Texture.FixedFuncUnit[u].GenQ;
+
+ /* GL_EXT_texture_env_combine */
+ dst->Texture.FixedFuncUnit[u].Combine = src->Texture.FixedFuncUnit[u].Combine;
+ }
}
@@ -122,7 +125,7 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
void
_mesa_print_texunit_state( struct gl_context *ctx, GLuint unit )
{
- const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit;
+ const struct gl_fixedfunc_texture_unit *texUnit = ctx->Texture.FixedFuncUnit + unit;
printf("Texture Unit %d\n", unit);
printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_enum_to_string(texUnit->EnvMode));
printf(" GL_COMBINE_RGB = %s\n", _mesa_enum_to_string(texUnit->Combine.ModeRGB));
@@ -461,7 +464,7 @@ tex_combine_translate_operand(GLenum operand)
static void
-pack_tex_combine(struct gl_texture_unit *texUnit)
+pack_tex_combine(struct gl_fixedfunc_texture_unit *texUnit)
{
struct gl_tex_env_combine_state *state = texUnit->_CurrentCombine;
struct gl_tex_env_combine_packed *packed = &texUnit->_CurrentCombinePacked;
@@ -493,7 +496,9 @@ pack_tex_combine(struct gl_texture_unit *texUnit)
* Examine texture unit's combine/env state to update derived state.
*/
static void
-update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
+update_tex_combine(struct gl_context *ctx,
+ struct gl_texture_unit *texUnit,
+ struct gl_fixedfunc_texture_unit *fftexUnit)
{
struct gl_tex_env_combine_state *combine;
@@ -505,9 +510,9 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
* state, or the combiner state which is derived from traditional texenv
* mode.
*/
- if (texUnit->EnvMode == GL_COMBINE ||
- texUnit->EnvMode == GL_COMBINE4_NV) {
- texUnit->_CurrentCombine = & texUnit->Combine;
+ if (fftexUnit->EnvMode == GL_COMBINE ||
+ fftexUnit->EnvMode == GL_COMBINE4_NV) {
+ fftexUnit->_CurrentCombine = & fftexUnit->Combine;
}
else {
const struct gl_texture_object *texObj = texUnit->_Current;
@@ -516,11 +521,11 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
if (format == GL_DEPTH_COMPONENT || format == GL_DEPTH_STENCIL_EXT) {
format = texObj->DepthMode;
}
- calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);
- texUnit->_CurrentCombine = & texUnit->_EnvMode;
+ calculate_derived_texenv(&fftexUnit->_EnvMode, fftexUnit->EnvMode, format);
+ fftexUnit->_CurrentCombine = & fftexUnit->_EnvMode;
}
- combine = texUnit->_CurrentCombine;
+ combine = fftexUnit->_CurrentCombine;
/* Determine number of source RGB terms in the combiner function */
switch (combine->ModeRGB) {
@@ -529,7 +534,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
break;
case GL_ADD:
case GL_ADD_SIGNED:
- if (texUnit->EnvMode == GL_COMBINE4_NV)
+ if (fftexUnit->EnvMode == GL_COMBINE4_NV)
combine->_NumArgsRGB = 4;
else
combine->_NumArgsRGB = 2;
@@ -561,7 +566,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
break;
case GL_ADD:
case GL_ADD_SIGNED:
- if (texUnit->EnvMode == GL_COMBINE4_NV)
+ if (fftexUnit->EnvMode == GL_COMBINE4_NV)
combine->_NumArgsA = 4;
else
combine->_NumArgsA = 2;
@@ -582,7 +587,7 @@ update_tex_combine(struct gl_context *ctx, struct gl_texture_unit *texUnit)
break;
}
- pack_tex_combine(texUnit);
+ pack_tex_combine(fftexUnit);
}
static void
@@ -592,7 +597,8 @@ update_texgen(struct gl_context *ctx)
/* Setup texgen for those texture coordinate sets that are in use */
for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[unit];
texUnit->_GenFlags = 0x0;
@@ -748,10 +754,12 @@ update_ff_texture_state(struct gl_context *ctx,
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_fixedfunc_texture_unit *fftexUnit =
+ &ctx->Texture.FixedFuncUnit[unit];
GLbitfield mask;
bool complete;
- if (texUnit->Enabled == 0x0)
+ if (fftexUnit->Enabled == 0x0)
continue;
/* If a shader already dictated what texture target was used for this
@@ -788,7 +796,7 @@ update_ff_texture_state(struct gl_context *ctx,
* undefined."
*/
complete = false;
- mask = texUnit->Enabled;
+ mask = fftexUnit->Enabled;
while (mask) {
const int texIndex = u_bit_scan(&mask);
struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
@@ -815,7 +823,7 @@ update_ff_texture_state(struct gl_context *ctx,
ctx->Texture._EnabledCoordUnits |= 1 << unit;
- update_tex_combine(ctx, texUnit);
+ update_tex_combine(ctx, texUnit, fftexUnit);
}
}
@@ -998,6 +1006,19 @@ _mesa_init_texture(struct gl_context *ctx)
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
GLuint tex;
+ /* initialize current texture object ptrs to the shared default objects */
+ for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
+ _mesa_reference_texobj(&texUnit->CurrentTex[tex],
+ ctx->Shared->DefaultTex[tex]);
+ }
+
+ texUnit->_BoundTextures = 0;
+ }
+
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); u++) {
+ struct gl_fixedfunc_texture_unit *texUnit =
+ &ctx->Texture.FixedFuncUnit[u];
+
texUnit->EnvMode = GL_MODULATE;
ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
@@ -1024,14 +1045,6 @@ _mesa_init_texture(struct gl_context *ctx)
ASSIGN_4V( texUnit->GenT.EyePlane, 0.0, 1.0, 0.0, 0.0 );
ASSIGN_4V( texUnit->GenR.EyePlane, 0.0, 0.0, 0.0, 0.0 );
ASSIGN_4V( texUnit->GenQ.EyePlane, 0.0, 0.0, 0.0, 0.0 );
-
- /* initialize current texture object ptrs to the shared default objects */
- for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
- _mesa_reference_texobj(&texUnit->CurrentTex[tex],
- ctx->Shared->DefaultTex[tex]);
- }
-
- texUnit->_BoundTextures = 0;
}
/* After we're done initializing the context's texture state the default
diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h
index 4f515e425a8..cf3f7e5a216 100644
--- a/src/mesa/main/texstate.h
+++ b/src/mesa/main/texstate.h
@@ -54,6 +54,21 @@ _mesa_get_current_tex_unit(struct gl_context *ctx)
return _mesa_get_tex_unit(ctx, ctx->Texture.CurrentUnit);
}
+
+/**
+ * Return pointer to current fixed-func texture unit.
+ * This the texture unit set by glActiveTexture(), not glClientActiveTexture().
+ * \return NULL if the current unit is not a fixed-func texture unit
+ */
+static inline struct gl_fixedfunc_texture_unit *
+_mesa_get_current_fixedfunc_tex_unit(struct gl_context *ctx)
+{
+ unsigned unit = ctx->Texture.CurrentUnit;
+
+ return &ctx->Texture.FixedFuncUnit[unit];
+}
+
+
static inline GLuint
_mesa_max_tex_unit(struct gl_context *ctx)
{