mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 05:48:07 +02:00
i965: align width/height for volume texture
This commit is contained in:
parent
b902a223c4
commit
00b86ecf6f
2 changed files with 34 additions and 13 deletions
|
|
@ -37,6 +37,7 @@
|
|||
#include "intel_tex_layout.h"
|
||||
#include "macros.h"
|
||||
|
||||
#define ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1))
|
||||
|
||||
GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
|
||||
{
|
||||
|
|
@ -53,11 +54,20 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
|
|||
GLuint pack_x_pitch, pack_x_nr;
|
||||
GLuint pack_y_pitch;
|
||||
GLuint level;
|
||||
GLuint align_h = 2;
|
||||
GLuint align_w = 4;
|
||||
|
||||
mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp;
|
||||
mt->total_height = 0;
|
||||
|
||||
if (mt->compressed) {
|
||||
align_w = intel_compressed_alignment(mt->internal_format);
|
||||
mt->pitch = ALIGN(width, align_w);
|
||||
pack_y_pitch = (height + 3) / 4;
|
||||
} else {
|
||||
mt->pitch = ((mt->width0 * mt->cpp + 3) & ~3) / mt->cpp;
|
||||
pack_y_pitch = ALIGN(mt->height0, align_h);
|
||||
}
|
||||
|
||||
pack_y_pitch = MAX2(mt->height0, 2);
|
||||
pack_x_pitch = mt->pitch;
|
||||
pack_x_nr = 1;
|
||||
|
||||
|
|
@ -83,20 +93,30 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
|
|||
|
||||
|
||||
mt->total_height += y;
|
||||
|
||||
if (pack_x_pitch > 4) {
|
||||
pack_x_pitch >>= 1;
|
||||
pack_x_nr <<= 1;
|
||||
assert(pack_x_pitch * pack_x_nr <= mt->pitch);
|
||||
}
|
||||
|
||||
if (pack_y_pitch > 2) {
|
||||
pack_y_pitch >>= 1;
|
||||
}
|
||||
|
||||
width = minify(width);
|
||||
height = minify(height);
|
||||
depth = minify(depth);
|
||||
|
||||
if (mt->compressed) {
|
||||
pack_y_pitch = (height + 3) / 4;
|
||||
|
||||
if (pack_x_pitch > ALIGN(width, align_w)) {
|
||||
pack_x_pitch = ALIGN(width, align_w);
|
||||
pack_x_nr <<= 1;
|
||||
}
|
||||
} else {
|
||||
if (pack_x_pitch > 4) {
|
||||
pack_x_pitch >>= 1;
|
||||
pack_x_nr <<= 1;
|
||||
assert(pack_x_pitch * pack_x_nr <= mt->pitch);
|
||||
}
|
||||
|
||||
if (pack_y_pitch > 2) {
|
||||
pack_y_pitch >>= 1;
|
||||
pack_y_pitch = ALIGN(pack_y_pitch, align_h);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,6 +233,7 @@ GLboolean intel_miptree_image_data(struct intel_context *intel,
|
|||
|
||||
if (dst->compressed) {
|
||||
alignment = intel_compressed_alignment(dst->internal_format);
|
||||
src_row_pitch = ((src_row_pitch + alignment - 1) & ~(alignment - 1));
|
||||
width = ((width + alignment - 1) & ~(alignment - 1));
|
||||
height = (height + 3) / 4;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue