- img->format = st_mesa_format_to_pipe_format(st, u->_ActualFormat);
-
- switch (u->Access) {
- case GL_READ_ONLY:
- img->access = PIPE_IMAGE_ACCESS_READ;
- break;
- case GL_WRITE_ONLY:
- img->access = PIPE_IMAGE_ACCESS_WRITE;
- break;
- case GL_READ_WRITE:
- img->access = PIPE_IMAGE_ACCESS_READ_WRITE;
- break;
- default:
- unreachable("bad gl_image_unit::Access");
- }
-
- if (stObj->pt->target == PIPE_BUFFER) {
- unsigned base, size;
-
- base = stObj->base.BufferOffset;
- assert(base < stObj->pt->width0);
- size = MIN2(stObj->pt->width0 - base, (unsigned)stObj->base.BufferSize);
-
- img->u.buf.offset = base;
- img->u.buf.size = size;
- } else {
- img->u.tex.level = u->Level + stObj->base.MinLevel;
- if (stObj->pt->target == PIPE_TEXTURE_3D) {
- if (u->Layered) {
- img->u.tex.first_layer = 0;
- img->u.tex.last_layer = u_minify(stObj->pt->depth0, img->u.tex.level) - 1;
- } else {
- img->u.tex.first_layer = u->_Layer;
- img->u.tex.last_layer = u->_Layer;
- }
+ img->u.tex.level = u->Level + stObj->base.MinLevel;
+ assert(img->u.tex.level <= img->resource->last_level);
+ if (stObj->pt->target == PIPE_TEXTURE_3D) {
+ if (u->Layered) {
+ img->u.tex.first_layer = 0;
+ img->u.tex.last_layer = u_minify(stObj->pt->depth0, img->u.tex.level) - 1;