+/*
+ Copyright (C) Intel Corp. 2006. All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice (including the
+ next paragraph) shall be included in all copies or substantial
+ portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ **********************************************************************/
#include "pipe/p_format.h"
#include "brw_screen.h"
#include "brw_debug.h"
+#include "brw_winsys.h"
+
+/* Code to layout images in a mipmap tree for i965.
+ */
static int
brw_tex_pitch_align (struct brw_texture *tex,
GLuint x, GLuint y,
GLuint w, GLuint h, GLuint d)
{
- assert(tex->base.width[level] == w);
- assert(tex->base.height[level] == h);
- assert(tex->base.depth[level] == d);
- assert(tex->image_offset[level] == NULL);
- assert(nr_images >= 1);
if (BRW_DEBUG & DEBUG_TEXTURE)
debug_printf("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
level, w, h, d, x, y, tex->level_offset[level]);
+ assert(tex->image_offset[level] == NULL);
+ assert(nr_images >= 1);
tex->level_offset[level] = (x + y * tex->pitch) * tex->cpp;
tex->nr_images[level] = nr_images;
GLuint level;
GLuint x = 0;
GLuint y = 0;
- GLuint width = tex->base.width[0];
- GLuint height = tex->base.height[0];
+ GLuint width = tex->base.width0;
+ GLuint height = tex->base.height0;
- tex->pitch = tex->base.width[0];
+ tex->pitch = tex->base.width0;
brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
if (tex->compressed) {
- tex->pitch = align(tex->base.width[0], align_w);
+ tex->pitch = align(tex->base.width0, align_w);
}
/* May need to adjust pitch to accomodate the placement of
GLuint mip1_width;
if (tex->compressed) {
- mip1_width = align(minify(tex->base.width[0]), align_w)
- + align(minify(minify(tex->base.width[0])), align_w);
+ mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
+ align(u_minify(tex->base.width0, 2), align_w));
} else {
- mip1_width = align(minify(tex->base.width[0]), align_w)
- + minify(minify(tex->base.width[0]));
+ mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
+ u_minify(tex->base.width0, 2));
}
if (mip1_width > tex->pitch) {
y += img_height;
}
- width = minify(width);
- height = minify(height);
+ width = u_minify(width, 1);
+ height = u_minify(height, 1);
}
}
GLuint level;
GLuint x = 0;
GLuint y = 0;
- GLuint width = tex->base.width[0];
- GLuint height = tex->base.height[0];
+ GLuint width = tex->base.width0;
+ GLuint height = tex->base.height0;
GLuint qpitch = 0;
GLuint y_pitch = 0;
- tex->pitch = tex->base.width[0];
+ tex->pitch = tex->base.width0;
brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
y_pitch = align(height, align_h);
if (tex->compressed) {
- tex->pitch = align(tex->base.width[0], align_w);
+ tex->pitch = align(tex->base.width0, align_w);
}
if (tex->base.last_level != 0) {
GLuint mip1_width;
if (tex->compressed) {
- mip1_width = (align(minify(tex->base.width[0]), align_w) +
- align(minify(minify(tex->base.width[0])), align_w));
+ mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
+ align(u_minify(tex->base.width0, 2), align_w));
} else {
- mip1_width = (align(minify(tex->base.width[0]), align_w) +
- minify(minify(tex->base.width[0])));
+ mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
+ u_minify(tex->base.width0, 2));
}
if (mip1_width > tex->pitch) {
if (tex->compressed) {
qpitch = ((y_pitch +
- align(minify(y_pitch), align_h) +
+ align(u_minify(y_pitch, 1), align_h) +
11 * align_h) / 4) * tex->pitch * tex->cpp;
tex->total_height = ((y_pitch +
- align(minify(y_pitch), align_h) +
+ align(u_minify(y_pitch, 1), align_h) +
11 * align_h) / 4) * 6;
} else {
qpitch = (y_pitch +
- align(minify(y_pitch), align_h) +
+ align(u_minify(y_pitch, 1), align_h) +
11 * align_h) * tex->pitch * tex->cpp;
tex->total_height = (y_pitch +
- align(minify(y_pitch), align_h) +
+ align(u_minify(y_pitch, 1), align_h) +
11 * align_h) * 6;
}
y += img_height;
}
- width = minify(width);
- height = minify(height);
+ width = u_minify(width, 1);
+ height = u_minify(height, 1);
}
return TRUE;
static boolean
brw_layout_3d_cube( struct brw_texture *tex )
{
- GLuint width = tex->base.width[0];
- GLuint height = tex->base.height[0];
- GLuint depth = tex->base.depth[0];
+ GLuint width = tex->base.width0;
+ GLuint height = tex->base.height0;
+ GLuint depth = tex->base.depth0;
GLuint pack_x_pitch, pack_x_nr;
GLuint pack_y_pitch;
GLuint level;
tex->pitch = align(width, align_w);
pack_y_pitch = (height + 3) / 4;
} else {
- tex->pitch = brw_tex_pitch_align(tex, tex->base.width[0]);
- pack_y_pitch = align(tex->base.height[0], align_h);
+ tex->pitch = brw_tex_pitch_align(tex, tex->base.width0);
+ pack_y_pitch = align(tex->base.height0, align_h);
}
pack_x_pitch = width;
tex->total_height += y;
- width = minify(width);
- height = minify(height);
- depth = minify(depth);
+ width = u_minify(width, 1);
+ height = u_minify(height, 1);
+ depth = u_minify(depth, 1);
if (tex->compressed) {
pack_y_pitch = (height + 3) / 4;