mesa: Make GenerateMipmap check the target before finding an object.