diff options
author | Corbin Simpson <[email protected]> | 2009-07-08 11:30:59 -0700 |
---|---|---|
committer | Corbin Simpson <[email protected]> | 2009-07-08 11:30:59 -0700 |
commit | 1aa38b2c2d80b67fe2eefe468f90aeb44bc20259 (patch) | |
tree | 4e9bce6a43b181587aa554611d284d173cab5ff4 /src/gallium | |
parent | e46d12d39498199e18be70826a2d36028c7b93f3 (diff) |
r300-gallium: Mipmap setup.
(cherry picked from commit 88c01a15da5639dd68a6a0133724994cb66f1316)
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/r300/r300_reg.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_texture.c | 28 |
2 files changed, 19 insertions, 10 deletions
diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index 79c778f9543..6825d998700 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -1478,6 +1478,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. # define R300_TX_PITCH_EN (1 << 31) # define R300_TX_WIDTH(x) ((x) << 0) # define R300_TX_HEIGHT(x) ((x) << 11) +# define R300_TX_NUM_LEVELS(x) ((x) << 26) #define R300_TX_FORMAT1_0 0x44C0 /* The interpretation of the format word by Wladimir van der Laan */ diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c index e006ecf3abe..f9dff037047 100644 --- a/src/gallium/drivers/r300/r300_texture.c +++ b/src/gallium/drivers/r300/r300_texture.c @@ -22,6 +22,8 @@ #include "r300_texture.h" +/* XXX maths need to go to util */ + static int minify(int i) { return MAX2(1, i >> 1); @@ -30,25 +32,29 @@ static int minify(int i) static void r300_setup_texture_state(struct r300_texture* tex, unsigned width, unsigned height, - unsigned pitch) + unsigned pitch, + unsigned levels) { struct r300_texture_state* state = &tex->state; state->format0 = R300_TX_WIDTH((width - 1) & 0x7ff) | - R300_TX_HEIGHT((height - 1) & 0x7ff) | R300_TX_PITCH_EN; + R300_TX_HEIGHT((height - 1) & 0x7ff) | + R300_TX_NUM_LEVELS(levels) | + R300_TX_PITCH_EN; /* XXX */ state->format1 = r300_translate_texformat(tex->tex.format); state->format2 = pitch - 1; - /* XXX + /* Assume (somewhat foolishly) that oversized textures will + * not be permitted by the state tracker. */ if (width > 2048) { - state->pitch |= R300_TXWIDTH_11; + state->format2 |= R500_TXWIDTH_BIT11; } if (height > 2048) { - state->pitch |= R300_TXHEIGHT_11; - } */ + state->format2 |= R500_TXHEIGHT_BIT11; + } } static void r300_setup_miptree(struct r300_texture* tex) @@ -75,6 +81,7 @@ static void r300_setup_miptree(struct r300_texture* tex) tex->offset[i] = (tex->size + 63) & ~63; tex->size = tex->offset[i] + size; + /* Save stride of first level to the texture. */ if (i == 0) { tex->stride = stride; } @@ -98,9 +105,8 @@ static struct pipe_texture* r300_setup_miptree(tex); - /* XXX */ - r300_setup_texture_state(tex, tex->tex.width[0], tex->tex.height[0], - tex->tex.width[0]); + r300_setup_texture_state(tex, template->width[0], template->height[0], + template->width[0], template->last_level); tex->buffer = screen->buffer_create(screen, 64, PIPE_BUFFER_USAGE_PIXEL, @@ -164,6 +170,7 @@ static struct pipe_texture* { struct r300_texture* tex; + /* XXX we should start doing mips now... */ if (base->target != PIPE_TEXTURE_2D || base->last_level != 0 || base->depth[0] != 1) { @@ -181,8 +188,9 @@ static struct pipe_texture* tex->stride = *stride; + /* XXX */ r300_setup_texture_state(tex, tex->tex.width[0], tex->tex.height[0], - tex->stride); + tex->stride, 0); pipe_buffer_reference(&tex->buffer, buffer); |