mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-27 01:10:25 +01:00
r300: Indented r300_texstate.[ch]
This commit is contained in:
parent
dcc8e5f4c1
commit
bb97694fad
1 changed files with 61 additions and 43 deletions
|
|
@ -46,7 +46,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include "r300_tex.h"
|
||||
#include "r300_reg.h"
|
||||
|
||||
|
||||
#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5 \
|
||||
|| ((f) >= MESA_FORMAT_RGBA_FLOAT32 && \
|
||||
(f) <= MESA_FORMAT_INTENSITY_FLOAT16)) \
|
||||
|
|
@ -152,7 +151,6 @@ static const struct {
|
|||
|
||||
#undef _ASSIGN
|
||||
|
||||
|
||||
/**
|
||||
* This function computes the number of bytes of storage needed for
|
||||
* the given texture object (all mipmap levels, all cube faces).
|
||||
|
|
@ -180,14 +178,18 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
if (VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
|
||||
if (_mesa_little_endian()) {
|
||||
t->format =
|
||||
tx_table_le[baseImage->TexFormat->MesaFormat].format;
|
||||
tx_table_le[baseImage->TexFormat->MesaFormat].
|
||||
format;
|
||||
t->filter |=
|
||||
tx_table_le[baseImage->TexFormat->MesaFormat].filter;
|
||||
tx_table_le[baseImage->TexFormat->MesaFormat].
|
||||
filter;
|
||||
} else {
|
||||
t->format =
|
||||
tx_table_be[baseImage->TexFormat->MesaFormat].format;
|
||||
tx_table_be[baseImage->TexFormat->MesaFormat].
|
||||
format;
|
||||
t->filter |=
|
||||
tx_table_be[baseImage->TexFormat->MesaFormat].filter;
|
||||
tx_table_be[baseImage->TexFormat->MesaFormat].
|
||||
filter;
|
||||
}
|
||||
} else {
|
||||
_mesa_problem(NULL, "unexpected texture format in %s",
|
||||
|
|
@ -217,18 +219,22 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
t->tile_bits = 0;
|
||||
|
||||
/* figure out if this texture is suitable for tiling. */
|
||||
#if 0 /* Disabled for now */
|
||||
#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)) {
|
||||
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)) {
|
||||
(((baseImage->Width * texelBytes /
|
||||
baseImage->Height) <= 32)
|
||||
&& (baseImage->Width * texelBytes > 64))
|
||||
||
|
||||
((baseImage->Width * texelBytes /
|
||||
baseImage->Height) <= 16)) {
|
||||
t->tile_bits |= R300_TXO_MICRO_TILE;
|
||||
}
|
||||
}
|
||||
|
|
@ -250,9 +256,10 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
|
||||
/* find image size in bytes */
|
||||
if (texImage->IsCompressed) {
|
||||
if ((t->format & R300_TX_FORMAT_DXT1) == R300_TX_FORMAT_DXT1) {
|
||||
if ((t->format & R300_TX_FORMAT_DXT1) ==
|
||||
R300_TX_FORMAT_DXT1) {
|
||||
// fprintf(stderr,"DXT 1 %d %08X\n", texImage->Width, t->format);
|
||||
if ((texImage->Width + 3) < 8) /* width one block */
|
||||
if ((texImage->Width + 3) < 8) /* width one block */
|
||||
size = texImage->CompressedSize * 4;
|
||||
else if ((texImage->Width + 3) < 16)
|
||||
size = texImage->CompressedSize * 2;
|
||||
|
|
@ -260,7 +267,8 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
size = texImage->CompressedSize;
|
||||
} else {
|
||||
/* DXT3/5, 16 bytes per block */
|
||||
WARN_ONCE("DXT 3/5 suffers from multitexturing problems!\n");
|
||||
WARN_ONCE
|
||||
("DXT 3/5 suffers from multitexturing problems!\n");
|
||||
// fprintf(stderr,"DXT 3/5 %d\n", texImage->Width);
|
||||
if ((texImage->Width + 3) < 8)
|
||||
size = texImage->CompressedSize * 2;
|
||||
|
|
@ -268,14 +276,18 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
size = texImage->CompressedSize;
|
||||
}
|
||||
} else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
size = ((texImage->Width * texelBytes + 63) & ~63) * texImage->Height;
|
||||
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 */
|
||||
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;
|
||||
size =
|
||||
(w * ((texImage->Height + 1) / 2)) *
|
||||
texImage->Depth;
|
||||
blitWidth = MAX2(texImage->Width, 64 / texelBytes);
|
||||
} else {
|
||||
int w = (texImage->Width * texelBytes + 31) & ~31;
|
||||
|
|
@ -284,11 +296,12 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
}
|
||||
assert(size > 0);
|
||||
|
||||
if(0)
|
||||
if (0)
|
||||
fprintf(stderr, "w=%d h=%d d=%d tb=%d intFormat=%d\n",
|
||||
texImage->Width, texImage->Height,
|
||||
texImage->Depth, texImage->TexFormat->TexelBytes,
|
||||
texImage->InternalFormat);
|
||||
texImage->Width, texImage->Height,
|
||||
texImage->Depth,
|
||||
texImage->TexFormat->TexelBytes,
|
||||
texImage->InternalFormat);
|
||||
|
||||
/* Align to 32-byte offset. It is faster to do this unconditionally
|
||||
* (no branch penalty).
|
||||
|
|
@ -300,22 +313,25 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
/* fix x and y coords up later together with offset */
|
||||
t->image[0][i].x = curOffset;
|
||||
t->image[0][i].y = 0;
|
||||
t->image[0][i].width = MIN2(size / texelBytes, blitWidth);
|
||||
t->image[0][i].height = (size / texelBytes) / t->image[0][i].width;
|
||||
t->image[0][i].width =
|
||||
MIN2(size / texelBytes, blitWidth);
|
||||
t->image[0][i].height =
|
||||
(size / texelBytes) / t->image[0][i].width;
|
||||
} else {
|
||||
t->image[0][i].x = curOffset % R300_BLIT_WIDTH_BYTES;
|
||||
t->image[0][i].y = curOffset / R300_BLIT_WIDTH_BYTES;
|
||||
t->image[0][i].width = MIN2(size, R300_BLIT_WIDTH_BYTES);
|
||||
t->image[0][i].width =
|
||||
MIN2(size, R300_BLIT_WIDTH_BYTES);
|
||||
t->image[0][i].height = size / t->image[0][i].width;
|
||||
}
|
||||
|
||||
if (0)
|
||||
fprintf(stderr,
|
||||
"level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
|
||||
i, texImage->Width, texImage->Height,
|
||||
t->image[0][i].x, t->image[0][i].y,
|
||||
t->image[0][i].width, t->image[0][i].height,
|
||||
size, curOffset);
|
||||
"level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
|
||||
i, texImage->Width, texImage->Height,
|
||||
t->image[0][i].x, t->image[0][i].y,
|
||||
t->image[0][i].width, t->image[0][i].height,
|
||||
size, curOffset);
|
||||
|
||||
curOffset += size;
|
||||
}
|
||||
|
|
@ -345,9 +361,12 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
t->format |= R300_TX_FORMAT_CUBIC_MAP;
|
||||
}
|
||||
|
||||
t->size = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << R300_TX_WIDTHMASK_SHIFT)
|
||||
|((tObj->Image[0][t->base.firstLevel]->Height - 1) << R300_TX_HEIGHTMASK_SHIFT))
|
||||
|((numLevels - 1) << R300_TX_MAX_MIP_LEVEL_SHIFT);
|
||||
t->size =
|
||||
(((tObj->Image[0][t->base.firstLevel]->Width -
|
||||
1) << R300_TX_WIDTHMASK_SHIFT)
|
||||
| ((tObj->Image[0][t->base.firstLevel]->Height - 1) <<
|
||||
R300_TX_HEIGHTMASK_SHIFT))
|
||||
| ((numLevels - 1) << R300_TX_MAX_MIP_LEVEL_SHIFT);
|
||||
|
||||
/* Only need to round to nearest 32 for textures, but the blitter
|
||||
* requires 64-byte aligned pitches, and we may/may not need the
|
||||
|
|
@ -356,15 +375,15 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
if (baseImage->IsCompressed) {
|
||||
t->pitch =
|
||||
(tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
|
||||
}
|
||||
else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
} else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
|
||||
unsigned int align = blitWidth - 1;
|
||||
t->pitch = ((tObj->Image[0][t->base.firstLevel]->Width *
|
||||
texelBytes) + 63) & ~(63);
|
||||
texelBytes) + 63) & ~(63);
|
||||
t->size |= R300_TX_SIZE_TXPITCH_EN;
|
||||
t->pitch_reg = (((tObj->Image[0][t->base.firstLevel]->Width) + align) & ~align) - 1;
|
||||
}
|
||||
else {
|
||||
t->pitch_reg =
|
||||
(((tObj->Image[0][t->base.firstLevel]->Width) +
|
||||
align) & ~align) - 1;
|
||||
} else {
|
||||
t->pitch =
|
||||
((tObj->Image[0][t->base.firstLevel]->Width *
|
||||
texelBytes) + 63) & ~(63);
|
||||
|
|
@ -375,7 +394,6 @@ static void r300SetTexImages(r300ContextPtr rmesa,
|
|||
/* FYI: r300UploadTexImages( rmesa, t ) used to be called here */
|
||||
}
|
||||
|
||||
|
||||
/* ================================================================
|
||||
* Texture unit state management
|
||||
*/
|
||||
|
|
@ -540,7 +558,7 @@ static GLboolean r300UpdateTextureUnit(GLcontext * ctx, int unit)
|
|||
return GL_FALSE;
|
||||
} else {
|
||||
return GL_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void r300UpdateTextureState(GLcontext * ctx)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue