Mesa (master): swrast: fix delayed texel buffer allocation regression

Brian Paul brianp at kemper.freedesktop.org
Mon Oct 3 16:52:20 PDT 2011


Module: Mesa
Branch: master
Commit: 9119269ca14ed42b51c7d8e2e662500311b29fa3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9119269ca14ed42b51c7d8e2e662500311b29fa3

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Oct  3 17:48:53 2011 -0600

swrast: fix delayed texel buffer allocation regression

Commit 617cdcd4c7b1cffb584c829c35bdf9c9bf04627b delayed the texel
buffer allocation until texture_combine() is called.  But the
texel buffer is needed sooner in _swrast_texture_span() at line 649.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=41433

---

 src/mesa/swrast/s_texcombine.c |   40 ++++++++++++++++++++--------------------
 1 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/mesa/swrast/s_texcombine.c b/src/mesa/swrast/s_texcombine.c
index de15772..c67c356 100644
--- a/src/mesa/swrast/s_texcombine.c
+++ b/src/mesa/swrast/s_texcombine.c
@@ -93,26 +93,6 @@ texture_combine( struct gl_context *ctx, GLuint unit, GLuint n,
    float4_array ccolor[4], rgba;
    GLuint i, term;
 
-   if (!swrast->TexelBuffer) {
-#ifdef _OPENMP
-      const GLint maxThreads = omp_get_max_threads();
-#else
-      const GLint maxThreads = 1;
-#endif
-
-      /* TexelBuffer is also global and normally shared by all SWspan
-       * instances; when running with multiple threads, create one per
-       * thread.
-       */
-      swrast->TexelBuffer =
-	 (GLfloat *) MALLOC(ctx->Const.MaxTextureImageUnits * maxThreads *
-			    MAX_WIDTH * 4 * sizeof(GLfloat));
-      if (!swrast->TexelBuffer) {
-	 _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine");
-	 return;
-      }
-   }
-
    /* alloc temp pixel buffers */
    rgba = (float4_array) malloc(4 * n * sizeof(GLfloat));
    if (!rgba) {
@@ -610,6 +590,26 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span )
    float4_array primary_rgba;
    GLuint unit;
 
+   if (!swrast->TexelBuffer) {
+#ifdef _OPENMP
+      const GLint maxThreads = omp_get_max_threads();
+#else
+      const GLint maxThreads = 1;
+#endif
+
+      /* TexelBuffer is also global and normally shared by all SWspan
+       * instances; when running with multiple threads, create one per
+       * thread.
+       */
+      swrast->TexelBuffer =
+	 (GLfloat *) MALLOC(ctx->Const.MaxTextureImageUnits * maxThreads *
+			    MAX_WIDTH * 4 * sizeof(GLfloat));
+      if (!swrast->TexelBuffer) {
+	 _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture_combine");
+	 return;
+      }
+   }
+
    primary_rgba = (float4_array) malloc(span->end * 4 * sizeof(GLfloat));
 
    if (!primary_rgba) {



More information about the mesa-commit mailing list