diff options
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_context.h | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_texmem.c | 22 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r300/r300_texstate.c | 32 |
4 files changed, 55 insertions, 7 deletions
diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 08293a00ae..46d64443c3 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -76,6 +76,7 @@ int hw_tcl_on=1; #define need_GL_ARB_vertex_buffer_object #define need_GL_ARB_vertex_program #define need_GL_EXT_blend_minmax +//#define need_GL_EXT_fog_coord #define need_GL_EXT_secondary_color #define need_GL_EXT_blend_equation_separate #define need_GL_EXT_blend_func_separate @@ -100,6 +101,7 @@ const struct dri_extension card_extensions[] = { {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions}, {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions}, {"GL_EXT_blend_subtract", NULL}, +// {"GL_EXT_fog_coord", GL_EXT_fog_coord_functions }, {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions}, {"GL_EXT_stencil_wrap", NULL}, {"GL_EXT_texture_edge_clamp", NULL}, @@ -189,6 +191,8 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, driParseConfigFiles(&r300->radeon.optionCache, &screen->optionCache, screen->driScreen->myNum, "r300"); + //r300->texmicrotile = GL_TRUE; + /* Init default driver functions then plug in our R300-specific functions * (the texture functions are especially important) */ diff --git a/src/mesa/drivers/dri/r300/r300_context.h b/src/mesa/drivers/dri/r300/r300_context.h index 03c2e6612f..6aa3caf8de 100644 --- a/src/mesa/drivers/dri/r300/r300_context.h +++ b/src/mesa/drivers/dri/r300/r300_context.h @@ -199,6 +199,8 @@ struct r300_tex_obj { GLboolean border_fallback; + + GLuint tile_bits; /* hw texture tile bits used on this texture */ }; struct r300_texture_env_state { @@ -884,6 +886,8 @@ struct r300_context { int mm_sem_id; struct radeon_memory_manager *rmm; #endif + + GLboolean texmicrotile; }; struct r300_buffer_object { diff --git a/src/mesa/drivers/dri/r300/r300_texmem.c b/src/mesa/drivers/dri/r300/r300_texmem.c index f334880f27..d78ec3b12c 100644 --- a/src/mesa/drivers/dri/r300/r300_texmem.c +++ b/src/mesa/drivers/dri/r300/r300_texmem.c @@ -261,8 +261,11 @@ static void r300UploadRectSubImage(r300ContextPtr rmesa, r300EmitBlit(rmesa, blit_format, dstPitch, GET_START(®ion), - dstPitch, t->bufAddr, - 0, 0, 0, done, width, lines); + dstPitch | (t->tile_bits >> 16), + t->bufAddr, + 0, 0, + 0, done, + width, lines); r300EmitWait(rmesa, R300_WAIT_2D); @@ -390,8 +393,8 @@ static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t, tex.pitch = MAX2((texImage->Width * texImage->TexFormat->TexelBytes) / 64, 1); tex.offset += tmp.x & ~1023; tmp.x = tmp.x % 1024; -#if 0 - if (t->tile_bits & R200_TXO_MICRO_TILE) { +#if 1 + if (t->tile_bits & R300_TXO_MICRO_TILE) { /* need something like "tiled coordinates" ? */ tmp.y = tmp.x / (tex.pitch * 128) * 2; tmp.x = tmp.x % (tex.pitch * 128) / 2 / texImage->TexFormat->TexelBytes; @@ -402,10 +405,10 @@ static void uploadSubImage( r300ContextPtr rmesa, r300TexObjPtr t, { tmp.x = tmp.x >> (texImage->TexFormat->TexelBytes >> 1); } -#if 0 - if ((t->tile_bits & R200_TXO_MACRO_TILE) && +#if 1 + if ((t->tile_bits & R300_TXO_MACRO_TILE) && (texImage->Width * texImage->TexFormat->TexelBytes >= 256) && - ((!(t->tile_bits & R200_TXO_MICRO_TILE) && (texImage->Height >= 8)) || + ((!(t->tile_bits & R300_TXO_MICRO_TILE) && (texImage->Height >= 8)) || (texImage->Height >= 16))) { /* weird: R200 disables macro tiling if mip width is smaller than 256 bytes, OR if height is smaller than 8 automatically, but if micro tiling is active @@ -502,6 +505,11 @@ int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face) + t->base.memBlock->ofs; t->offset = t->bufAddr; + if (!(t->base.tObj->Image[0][0]->IsClientData)) { + /* hope it's safe to add that here... */ + t->offset |= t->tile_bits; + } + /* Mark this texobj as dirty on all units: */ t->dirty_state = TEX_ALL; diff --git a/src/mesa/drivers/dri/r300/r300_texstate.c b/src/mesa/drivers/dri/r300/r300_texstate.c index ca42afdc1f..32f87d2d95 100644 --- a/src/mesa/drivers/dri/r300/r300_texstate.c +++ b/src/mesa/drivers/dri/r300/r300_texstate.c @@ -214,6 +214,31 @@ static void r300SetTexImages(r300ContextPtr rmesa, */ curOffset = 0; blitWidth = BLIT_WIDTH_BYTES; + t->tile_bits = 0; + + /* figure out if this texture is suitable for tiling. */ +#if 0 /* Disabled for now */ + if (texelBytes) { + if (rmesa->texmicrotile && (tObj->Target != GL_TEXTURE_RECTANGLE_NV) && + /* texrect might be able to use micro tiling too in theory? */ + (baseImage->Height > 1)) { + + /* allow 32 (bytes) x 1 mip (which will use two times the space + the non-tiled version would use) max if base texture is large enough */ + if ((numLevels == 1) || + (((baseImage->Width * texelBytes / baseImage->Height) <= 32) && + (baseImage->Width * texelBytes > 64)) || + ((baseImage->Width * texelBytes / baseImage->Height) <= 16)) { + t->tile_bits |= R300_TXO_MICRO_TILE; + } + } + + if (tObj->Target != GL_TEXTURE_RECTANGLE_NV) { + /* we can set macro tiling even for small textures, they will be untiled anyway */ + t->tile_bits |= R300_TXO_MACRO_TILE; + } + } +#endif for (i = 0; i < numLevels; i++) { const struct gl_texture_image *texImage; @@ -244,6 +269,13 @@ static void r300SetTexImages(r300ContextPtr rmesa, } else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) { size = ((texImage->Width * texelBytes + 63) & ~63) * texImage->Height; blitWidth = 64 / texelBytes; + } else if (t->tile_bits & R300_TXO_MICRO_TILE) { + /* tile pattern is 16 bytes x2. mipmaps stay 32 byte aligned, + though the actual offset may be different (if texture is less than + 32 bytes width) to the untiled case */ + int w = (texImage->Width * texelBytes * 2 + 31) & ~31; + size = (w * ((texImage->Height + 1) / 2)) * texImage->Depth; + blitWidth = MAX2(texImage->Width, 64 / texelBytes); } else { int w = (texImage->Width * texelBytes + 31) & ~31; size = w * texImage->Height * texImage->Depth; |