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) {
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,
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
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
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