aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/texstore.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-02-14 01:03:55 +0100
committerMarek Olšák <[email protected]>2013-02-18 17:57:41 +0100
commit0a1479c829ed34a65e60c6619a8164e1b079aaee (patch)
tree35ccf42db1ba7490db4442fc3324ccf93faab30e /src/mesa/main/texstore.c
parenta6e0ac95716ca933558c70e45798ddc67e6ad5ad (diff)
st/mesa: implement blit-based TexImage and TexSubImage
A temporary texture is created such that it matches the format and type combination and pixels are copied to it using memcpy. Then the blit is used to copy the temporary texture to the texture image being modified by TexImage or TexSubImage. The blit takes care of the format and type conversion and swizzling. The result is a very fast texture upload involving as little CPU as possible. This improves performance in apps which upload textures during rendering. An example is the Wine OpenGL backend for DirectDraw, which I used to test the game StarCraft. Profiling had shown that TexSubImage was taking 50% of CPU time without this patch, which was the main motivation for this work, and now TexSubImage only takes 14% of CPU time. I had to underclock my CPU to see any difference in the game and this patch does make the game a lot faster if the CPU is slow (or using the powersave cpufreq profile). Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa/main/texstore.c')
-rw-r--r--src/mesa/main/texstore.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/mesa/main/texstore.c b/src/mesa/main/texstore.c
index 9281aa9eafb..77222d6dfb6 100644
--- a/src/mesa/main/texstore.c
+++ b/src/mesa/main/texstore.c
@@ -3791,8 +3791,11 @@ _mesa_get_texstore_func(gl_format format)
}
-static GLboolean
-_mesa_texstore_memcpy(TEXSTORE_PARAMS)
+GLboolean
+_mesa_texstore_can_use_memcpy(struct gl_context *ctx,
+ GLenum baseInternalFormat, gl_format dstFormat,
+ GLenum srcFormat, GLenum srcType,
+ const struct gl_pixelstore_attrib *srcPacking)
{
GLenum dstType;
@@ -3834,6 +3837,17 @@ _mesa_texstore_memcpy(TEXSTORE_PARAMS)
return GL_FALSE;
}
+ return GL_TRUE;
+}
+
+static GLboolean
+_mesa_texstore_memcpy(TEXSTORE_PARAMS)
+{
+ if (!_mesa_texstore_can_use_memcpy(ctx, baseInternalFormat, dstFormat,
+ srcFormat, srcType, srcPacking)) {
+ return GL_FALSE;
+ }
+
memcpy_texture(ctx, dims,
dstFormat,
dstRowStride, dstSlices,