dri/nouveau: Rectangle texture fixes.
authorFrancisco Jerez <currojerez@riseup.net>
Mon, 22 Mar 2010 17:10:25 +0000 (18:10 +0100)
committerFrancisco Jerez <currojerez@riseup.net>
Mon, 22 Mar 2010 17:41:23 +0000 (18:41 +0100)
src/mesa/drivers/dri/nouveau/nouveau_state.c
src/mesa/drivers/dri/nouveau/nouveau_texture.c

index 7697090f6a662ae347bab1821e035ddf4263caca..a57df2d9dcd9adf4117958428d1128478782b07b 100644 (file)
@@ -232,6 +232,7 @@ nouveau_enable(GLcontext *ctx, GLenum cap, GLboolean state)
        case GL_TEXTURE_1D:
        case GL_TEXTURE_2D:
        case GL_TEXTURE_3D:
+       case GL_TEXTURE_RECTANGLE:
                context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit);
                context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit);
                break;
index e89018653b1d574f5d127e234b369f0313215dc0..dbf9a5cc613f0469881458e39817c6f631c09854 100644 (file)
@@ -283,7 +283,8 @@ nouveau_texture_validate(GLcontext *ctx, struct gl_texture_object *t)
        struct nouveau_texture *nt = to_nouveau_texture(t);
        int i, last = get_last_level(t);
 
-       if (!nt->surfaces[last].bo)
+       if (!teximage_fits(t, t->BaseLevel) ||
+           !teximage_fits(t, last))
                return GL_FALSE;
 
        if (nt->dirty) {
@@ -420,6 +421,40 @@ nouveau_teximage_3d(GLcontext *ctx, GLenum target, GLint level,
                         packing, t, ti);
 }
 
+static void
+nouveau_texsubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
+                   GLint xoffset, GLint yoffset, GLint zoffset,
+                   GLint width, GLint height, GLint depth,
+                   GLenum format, GLenum type, const void *pixels,
+                   const struct gl_pixelstore_attrib *packing,
+                   struct gl_texture_object *t,
+                   struct gl_texture_image *ti)
+{
+       struct nouveau_surface *s = &to_nouveau_teximage(ti)->surface;
+       int ret;
+
+       pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, depth,
+                                            format, type, pixels, packing,
+                                            "glTexSubImage");
+       if (pixels) {
+               nouveau_teximage_map(ctx, ti);
+
+               ret = _mesa_texstore(ctx, 3, ti->_BaseFormat, ti->TexFormat,
+                                    ti->Data, xoffset, yoffset, zoffset,
+                                    s->pitch, ti->ImageOffsets,
+                                    width, height, depth, format, type,
+                                    pixels, packing);
+               assert(ret);
+
+               nouveau_teximage_unmap(ctx, ti);
+               _mesa_unmap_teximage_pbo(ctx, packing);
+       }
+
+       if (!to_nouveau_texture(t)->dirty)
+               validate_teximage(ctx, t, level, xoffset, yoffset, zoffset,
+                                 width, height, depth);
+}
+
 static void
 nouveau_texsubimage_3d(GLcontext *ctx, GLenum target, GLint level,
                       GLint xoffset, GLint yoffset, GLint zoffset,
@@ -429,15 +464,9 @@ nouveau_texsubimage_3d(GLcontext *ctx, GLenum target, GLint level,
                       struct gl_texture_object *t,
                       struct gl_texture_image *ti)
 {
-       nouveau_teximage_map(ctx, ti);
-       _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
-                                 width, height, depth, format, type, pixels,
-                                 packing, t, ti);
-       nouveau_teximage_unmap(ctx, ti);
-
-       if (!to_nouveau_texture(t)->dirty)
-               validate_teximage(ctx, t, level, xoffset, yoffset, zoffset,
-                                 width, height, depth);
+       nouveau_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset,
+                           width, height, depth, format, type, pixels,
+                           packing, t, ti);
 }
 
 static void
@@ -449,15 +478,9 @@ nouveau_texsubimage_2d(GLcontext *ctx, GLenum target, GLint level,
                       struct gl_texture_object *t,
                       struct gl_texture_image *ti)
 {
-       nouveau_teximage_map(ctx, ti);
-       _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset,
-                                 width, height, format, type, pixels,
-                                 packing, t, ti);
-       nouveau_teximage_unmap(ctx, ti);
-
-       if (!to_nouveau_texture(t)->dirty)
-               validate_teximage(ctx, t, level, xoffset, yoffset, 0,
-                                 width, height, 1);
+       nouveau_texsubimage(ctx, 2, target, level, xoffset, yoffset, 0,
+                           width, height, 1, format, type, pixels,
+                           packing, t, ti);
 }
 
 static void
@@ -468,15 +491,9 @@ nouveau_texsubimage_1d(GLcontext *ctx, GLenum target, GLint level,
                       struct gl_texture_object *t,
                       struct gl_texture_image *ti)
 {
-       nouveau_teximage_map(ctx, ti);
-       _mesa_store_texsubimage1d(ctx, target, level, xoffset,
-                                 width, format, type, pixels,
-                                 packing, t, ti);
-       nouveau_teximage_unmap(ctx, ti);
-
-       if (!to_nouveau_texture(t)->dirty)
-               validate_teximage(ctx, t, level, xoffset, 0, 0,
-                                 width, 1, 1);
+       nouveau_texsubimage(ctx, 1, target, level, xoffset, 0, 0,
+                           width, 1, 1, format, type, pixels,
+                           packing, t, ti);
 }
 
 static void