Lines Matching refs:ctx

132 _mesa_print_texunit_state( struct gl_context *ctx, GLuint unit )
134 const struct gl_fixedfunc_texture_unit *texUnit = ctx->Texture.FixedFuncUnit + unit;
298 GET_CURRENT_CONTEXT(ctx);
301 _mesa_debug(ctx, "glActiveTexture %s\n",
304 if (ctx->Texture.CurrentUnit == texUnit)
308 GLuint k = _mesa_max_tex_unit(ctx);
310 assert(k <= ARRAY_SIZE(ctx->Texture.Unit));
313 _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)",
330 FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE, GL_TEXTURE_BIT);
332 ctx->Texture.CurrentUnit = texUnit;
333 if (ctx->Transform.MatrixMode == GL_TEXTURE) {
335 ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit];
358 GET_CURRENT_CONTEXT(ctx);
362 _mesa_debug(ctx, "glClientActiveTexture %s\n",
365 if (ctx->Array.ActiveTexture == texUnit)
368 if (texUnit >= ctx->Const.MaxTextureCoordUnits) {
369 _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(texture=%s)",
375 ctx->Array.ActiveTexture = texUnit;
391 * \param ctx GL context.
394 _mesa_update_texture_matrices(struct gl_context *ctx)
397 GLbitfield old_texmat_enabled = ctx->Texture._TexMatEnabled;
399 ctx->Texture._TexMatEnabled = 0x0;
401 for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
402 assert(u < ARRAY_SIZE(ctx->TextureMatrixStack));
403 if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) {
404 _math_matrix_analyse( ctx->TextureMatrixStack[u].Top );
406 if (ctx->Texture.Unit[u]._Current &&
407 ctx->TextureMatrixStack[u].Top->type != MATRIX_IDENTITY)
408 ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(u);
412 if (old_texmat_enabled != ctx->Texture._TexMatEnabled)
524 update_tex_combine(struct gl_context *ctx,
583 _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state");
611 _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state");
619 update_texgen(struct gl_context *ctx)
624 for (unit = 0; unit < ctx->Const.MaxTextureCoordUnits; unit++) {
626 &ctx->Texture.FixedFuncUnit[unit];
630 if (!(ctx->Texture._EnabledCoordUnits & (1 << unit)))
647 ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit);
648 ctx->Texture._GenFlags |= texUnit->_GenFlags;
651 assert(unit < ARRAY_SIZE(ctx->TextureMatrixStack));
652 if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
653 ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
658 update_single_program_texture(struct gl_context *ctx, struct gl_program *prog,
666 texUnit = &ctx->Texture.Unit[unit];
686 ctx->Const.ForceIntegerTexNearest))
689 _mesa_test_texobj_completeness(ctx, texObj);
691 ctx->Const.ForceIntegerTexNearest))
707 texObj = _mesa_get_fallback_texture(ctx, target_index);
714 update_single_program_texture_state(struct gl_context *ctx,
721 texObj = update_single_program_texture(ctx, prog, unit);
723 _mesa_reference_texobj(&ctx->Texture.Unit[unit]._Current, texObj);
725 ctx->Texture._MaxEnabledTexImageUnit =
726 MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
730 update_program_texture_state(struct gl_context *ctx, struct gl_program **prog,
747 update_single_program_texture_state(ctx, prog[i],
762 update_single_program_texture_state(ctx, prog[i], sampler->unit,
770 ctx->Texture._EnabledCoordUnits |=
777 update_ff_texture_state(struct gl_context *ctx,
782 for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
783 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
785 &ctx->Texture.FixedFuncUnit[unit];
834 ctx->Const.ForceIntegerTexNearest)) {
835 _mesa_test_texobj_completeness(ctx, texObj);
838 ctx->Const.ForceIntegerTexNearest)) {
850 ctx->Texture._MaxEnabledTexImageUnit =
851 MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
853 ctx->Texture._EnabledCoordUnits |= 1 << unit;
855 update_tex_combine(ctx, texUnit, fftexUnit);
860 fix_missing_textures_for_atifs(struct gl_context *ctx,
871 if (!ctx->Texture.Unit[unit]._Current) {
873 _mesa_get_fallback_texture(ctx, target_index);
874 _mesa_reference_texobj(&ctx->Texture.Unit[unit]._Current, texObj);
876 ctx->Texture._MaxEnabledTexImageUnit =
877 MAX2(ctx->Texture._MaxEnabledTexImageUnit, (int)unit);
889 * \param ctx GL context.
892 _mesa_update_texture_state(struct gl_context *ctx)
896 int old_max_unit = ctx->Texture._MaxEnabledTexImageUnit;
899 memcpy(prog, ctx->_Shader->CurrentProgram, sizeof(prog));
902 _mesa_arb_fragment_program_enabled(ctx)) {
903 prog[MESA_SHADER_FRAGMENT] = ctx->FragmentProgram.Current;
907 ctx->NewState |= _NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE;
909 GLbitfield old_genflags = ctx->Texture._GenFlags;
910 GLbitfield old_enabled_coord_units = ctx->Texture._EnabledCoordUnits;
911 GLbitfield old_texgen_enabled = ctx->Texture._TexGenEnabled;
912 GLbitfield old_texmat_enabled = ctx->Texture._TexMatEnabled;
914 ctx->Texture._GenFlags = 0x0;
915 ctx->Texture._TexMatEnabled = 0x0;
916 ctx->Texture._TexGenEnabled = 0x0;
917 ctx->Texture._MaxEnabledTexImageUnit = -1;
918 ctx->Texture._EnabledCoordUnits = 0x0;
927 update_program_texture_state(ctx, prog, enabled_texture_units);
932 update_ff_texture_state(ctx, enabled_texture_units);
935 for (i = 0; i <= ctx->Texture._MaxEnabledTexImageUnit; i++) {
937 _mesa_reference_texobj(&ctx->Texture.Unit[i]._Current, NULL);
939 for (i = ctx->Texture._MaxEnabledTexImageUnit + 1; i <= old_max_unit; i++) {
940 _mesa_reference_texobj(&ctx->Texture.Unit[i]._Current, NULL);
944 if (_mesa_ati_fragment_shader_enabled(ctx) &&
945 ctx->ATIFragmentShader.Current->Program)
946 fix_missing_textures_for_atifs(ctx,
947 ctx->ATIFragmentShader.Current->Program,
951 update_texgen(ctx);
955 if (old_enabled_coord_units != ctx->Texture._EnabledCoordUnits ||
956 old_texgen_enabled != ctx->Texture._TexGenEnabled ||
957 old_texmat_enabled != ctx->Texture._TexMatEnabled) {
961 if (old_genflags != ctx->Texture._GenFlags)
975 * \param ctx the context to allocate proxies for.
983 alloc_proxy_textures( struct gl_context *ctx )
1009 if (!(ctx->Texture.ProxyTex[tgt]
1010 = _mesa_new_texture_object(ctx, 0, targets[tgt]))) {
1013 _mesa_delete_texture_object(ctx, ctx->Texture.ProxyTex[tgt]);
1019 assert(ctx->Texture.ProxyTex[0]->RefCount == 1); /* sanity check */
1028 _mesa_init_texture(struct gl_context *ctx)
1033 ctx->Texture.CurrentUnit = 0; /* multitexture */
1042 * the driver has already computed and set ctx->Version, however drivers
1050 ctx->Texture.CubeMapSeamless = ctx->API == API_OPENGLES2;
1052 for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
1053 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
1059 ctx->Shared->DefaultTex[tex]);
1065 for (u = 0; u < ARRAY_SIZE(ctx->Texture.FixedFuncUnit); u++) {
1067 &ctx->Texture.FixedFuncUnit[u];
1101 assert(ctx->Shared->DefaultTex[TEXTURE_1D_INDEX]->RefCount
1105 if (!alloc_proxy_textures( ctx ))
1109 _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
1111 ctx->Texture.NumCurrentTexUsed = 0;
1121 _mesa_free_texture_data(struct gl_context *ctx)
1126 for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
1128 _mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL);
1131 _mesa_reference_texobj(&ctx->Texture.Unit[u].CurrentTex[tgt], NULL);
1137 _mesa_delete_texture_object(ctx, ctx->Texture.ProxyTex[tgt]);
1140 _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
1142 for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
1143 _mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL);
1154 _mesa_update_default_objects_texture(struct gl_context *ctx)
1158 for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
1159 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
1162 ctx->Shared->DefaultTex[tex]);