rendered paste bodydiff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index 5fe0ad0..9ce61cb 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -190,10 +190,11 @@ static GLboolean
teximage_fits(struct gl_texture_object *t, int level)
{
struct nouveau_surface *s = &to_nouveau_texture(t)->surfaces[level];
- struct gl_texture_image *ti = t->Image[0][level];
+ GLuint face = _mesa_tex_target_to_face(t->Target);
+ struct gl_texture_image *ti = t->Image[face][level];
return ti && to_nouveau_teximage(ti)->surface.bo &&
- (t->Target == GL_TEXTURE_RECTANGLE ||
+ (t->Target == GL_TEXTURE_RECTANGLE || t->Target == GL_TEXTURE_CUBE_MAP ||
(s->bo && s->format == ti->TexFormat &&
s->width == ti->Width && s->height == ti->Height));
}
@@ -203,7 +204,8 @@ validate_teximage(GLcontext *ctx, struct gl_texture_object *t,
int level, int x, int y, int z,
int width, int height, int depth)
{
- struct gl_texture_image *ti = t->Image[0][level];
+ GLuint face = _mesa_tex_target_to_face(t->Target);
+ struct gl_texture_image *ti = t->Image[face][level];
if (teximage_fits(t, level)) {
struct nouveau_surface *ss = to_nouveau_texture(t)->surfaces;
@@ -348,6 +350,7 @@ nouveau_teximage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
struct gl_texture_image *ti)
{
struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
+ GLuint face = _mesa_tex_target_to_face(target);
int ret;
/* Allocate a new bo for the image. */
@@ -580,23 +583,31 @@ nouveau_set_texbuffer(__DRIcontext *dri_ctx,
static void
nouveau_texture_map(GLcontext *ctx, struct gl_texture_object *t)
{
- int i;
+ int i, face;
+ int nr_faces = (t->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+
+ for (face = 0; face < nr_faces; face++) {
for (i = t->BaseLevel; i < t->_MaxLevel; i++) {
- if (t->Image[0][i])
+ if (t->Image[face][i])
nouveau_teximage_map(ctx, t->Image[0][i]);
}
+ }
}
static void
nouveau_texture_unmap(GLcontext *ctx, struct gl_texture_object *t)
{
- int i;
+ int i, face;
+ int nr_faces = (t->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+
+ for (face = 0; face < nr_faces; face++) {
for (i = t->BaseLevel; i < t->_MaxLevel; i++) {
- if (t->Image[0][i])
+ if (t->Image[face][i])
nouveau_teximage_unmap(ctx, t->Image[0][i]);
}
+ }
}
static void
@@ -609,13 +620,18 @@ store_mipmap(GLcontext *ctx, GLenum target, int first, int last,
};
GLenum format = t->Image[0][first]->TexFormat;
unsigned base_format, type, comps;
- int i;
+ int i, nr_faces, face;
+
+ nr_faces = (t->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+
base_format = _mesa_get_format_base_format(format);
_mesa_format_to_type_and_comps(format, &type, &comps);
+ for (face = 0; face < nr_faces; face++) {
+
for (i = first; i <= last; i++) {
- struct gl_texture_image *ti = t->Image[0][i];
+ struct gl_texture_image *ti = t->Image[face][i];
void *data = ti->Data;
nouveau_teximage(ctx, 3, target, i, ti->InternalFormat,
@@ -625,14 +641,21 @@ store_mipmap(GLcontext *ctx, GLenum target, int first, int last,
_mesa_free_texmemory(data);
}
+ }
}
static void
nouveau_generate_mipmap(GLcontext *ctx, GLenum target,
struct gl_texture_object *t)
+
{
+ int nr_faces, face;
+ nr_faces = (t->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+
+
+ for (face = 0; face < nr_faces; face++) {
if (_mesa_meta_check_generate_mipmap_fallback(ctx, target, t)) {
- struct gl_texture_image *base = t->Image[0][t->BaseLevel];
+ struct gl_texture_image *base = t->Image[face][t->BaseLevel];
nouveau_teximage_map(ctx, base);
_mesa_generate_mipmap(ctx, target, t);
@@ -644,6 +667,7 @@ nouveau_generate_mipmap(GLcontext *ctx, GLenum target,
} else {
_mesa_meta_GenerateMipmap(ctx, target, t);
}
+ }
}
void