summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFelix Kuehling <fxkuehl@gmx.de>2005-02-04 00:17:21 +0000
committerFelix Kuehling <fxkuehl@gmx.de>2005-02-04 00:17:21 +0000
commitcbff5db516f58304fbc24ae2c4653f426ef68947 (patch)
treec4555a4d2d3928b3f52e5a15a8e33623a063529b /src
parent64b85b456384c22834749a278d073eefd3056611 (diff)
Made subtile upload a template. This speeds up tiled texture uploads by
about a factor 1.3.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/savage/savagetex.c47
1 files changed, 41 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/savage/savagetex.c b/src/mesa/drivers/dri/savage/savagetex.c
index c0185fa831..613a2712ae 100644
--- a/src/mesa/drivers/dri/savage/savagetex.c
+++ b/src/mesa/drivers/dri/savage/savagetex.c
@@ -78,6 +78,42 @@ static const savageTileInfo tileInfo_s3d_s4[5] = {
{32, 16, 8, 2, 4, 8, {0xc0, 0x80}}, /* 32-bit */
};
+/** \brief Template for subtile uploads.
+ * \param h height in pixels
+ * \param w width in bytes
+ */
+#define SUBTILE_FUNC(w,h) \
+static __inline GLubyte *savageUploadSubtile_##w##x##h \
+(GLubyte *dest, GLubyte *src, GLuint srcStride) \
+{ \
+ GLuint y; \
+ for (y = 0; y < h; ++y) { \
+ memcpy (dest, src, w); \
+ src += srcStride; \
+ dest += w; \
+ } \
+ return dest; \
+}
+
+SUBTILE_FUNC(2, 8) /* 4 bits per pixel, 4 pixels wide */
+SUBTILE_FUNC(4, 8)
+SUBTILE_FUNC(8, 8)
+SUBTILE_FUNC(16, 8)
+SUBTILE_FUNC(32, 8) /* 4 bytes per pixel, 8 pixels wide */
+
+/** \brief Table of subtile upload functions
+ *
+ * Indexed by the binary logarithm of the width in bytes.
+ */
+static GLubyte *(*savageSubtileTab[]) (GLubyte *, GLubyte *, GLuint) = {
+ NULL,
+ savageUploadSubtile_2x8,
+ savageUploadSubtile_4x8,
+ savageUploadSubtile_8x8,
+ savageUploadSubtile_16x8,
+ savageUploadSubtile_32x8
+};
+
/** \brief Upload a complete tile from src (srcStride) to dest
*
* \param tileInfo Pointer to tiling information
@@ -102,16 +138,15 @@ static void savageUploadTile (const savageTileInfo *tileInfo,
GLubyte *src, GLuint srcStride, GLubyte *dest) {
GLuint subStride = tileInfo->subWidth * bpp;
GLubyte *srcSRow = src, *srcSTile = src;
- GLuint sx, sy, y;
+ GLubyte *(*subtileFunc) (GLubyte *, GLubyte *, GLuint) =
+ savageSubtileTab[(tileInfo->subWidth == 4 ? 2 : 3) +
+ ((bpp == 1) ? 0 : (bpp == 2) ? 1 : 2)];
+ GLuint sx, sy;
for (sy = 0; sy < hInSub; ++sy) {
srcSTile = srcSRow;
for (sx = 0; sx < wInSub; ++sx) {
src = srcSTile;
- for (y = 0; y < tileInfo->subHeight; ++y) {
- memcpy (dest, src, subStride);
- src += srcStride;
- dest += subStride;
- }
+ dest = subtileFunc (dest, src, srcStride);
srcSTile += subStride;
}
srcSRow += srcStride * tileInfo->subHeight;