return false;
}
+ assert(tex_obj->Target != 0);
+ assert(tex_obj->TargetIndex < NUM_TEXTURE_TARGETS);
+
view_tex_obj->Target = tex_obj->Target;
+ view_tex_obj->TargetIndex = tex_obj->TargetIndex;
*view_tex_image = _mesa_get_tex_image(ctx, view_tex_obj, tex_obj->Target, 0);
view_tex_obj->NumLayers = tex_obj->NumLayers;
view_tex_obj->Immutable = tex_obj->Immutable;
view_tex_obj->ImmutableLevels = tex_obj->ImmutableLevels;
- view_tex_obj->Target = tex_obj->Target;
if (ctx->Driver.TextureView != NULL &&
!ctx->Driver.TextureView(ctx, view_tex_obj, tex_obj)) {
};
STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS);
shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]);
+ /* Need to explicitly set/overwrite the TargetIndex field here since
+ * the call to _mesa_tex_target_to_index() in NewTextureObject() may
+ * fail if the texture target is not supported.
+ */
+ shared->DefaultTex[i]->TargetIndex = i;
}
/* sanity check */
obj->RefCount = 1;
obj->Name = name;
obj->Target = target;
+ if (target != 0) {
+ obj->TargetIndex = _mesa_tex_target_to_index(ctx, target);
+ }
+ else {
+ obj->TargetIndex = NUM_TEXTURE_TARGETS; /* invalid/error value */
+ }
obj->Priority = 1.0F;
obj->BaseLevel = 0;
obj->MaxLevel = 1000;
GLenum filter = GL_LINEAR;
assert(obj->Target == 0);
+ obj->Target = target;
+ obj->TargetIndex = _mesa_tex_target_to_index(ctx, target);
+ assert(obj->TargetIndex < NUM_TEXTURE_TARGETS);
+
switch (target) {
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
GLuint first;
GLint i;
const char *func = dsa ? "Create" : "Gen";
- const GLint targetIndex = _mesa_tex_target_to_index(ctx, target);
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
_mesa_debug(ctx, "gl%sTextures %d\n", func, n);
return;
}
- /* Initialize the target index if target is non-zero. */
- if (target != 0) {
- texObj->TargetIndex = targetIndex;
- }
-
/* insert into hash table */
_mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);
const gl_texture_index index = texObj->TargetIndex;
GLuint u;
- if (texObj->Target == 0)
+ if (texObj->Target == 0) {
+ /* texture was never bound */
return;
+ }
+
+ assert(index < NUM_TEXTURE_TARGETS);
for (u = 0; u < ctx->Texture.NumCurrentTexUsed; u++) {
struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
_mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj);
mtx_unlock(&ctx->Shared->Mutex);
}
- newTexObj->Target = target;
- newTexObj->TargetIndex = targetIndex;
}
+ assert(newTexObj->Target == target);
+ assert(newTexObj->TargetIndex == targetIndex);
+
bind_texture(ctx, ctx->Texture.CurrentUnit, newTexObj);
}
texObj->Immutable = GL_TRUE;
texObj->ImmutableLevels = origTexObj->ImmutableLevels;
texObj->Target = target;
+ texObj->TargetIndex = _mesa_tex_target_to_index(ctx, target);
+ assert(texObj->TargetIndex < NUM_TEXTURE_TARGETS);
if (ctx->Driver.TextureView != NULL &&
!ctx->Driver.TextureView(ctx, texObj, origTexObj)) {