[Mesa-dev] [PATCH 07/14] mesa: Create the default (name==0) buffer texture.

Eric Anholt eric at anholt.net
Wed Mar 28 10:58:51 PDT 2012


All that should be needed is that it exists.  Fixes segfaults on first
_mesa_update_context() with a samplerBuffer-using shader active but
without a particular buffer texture enabled.
---
 src/glsl/builtins/tools/texture_builtins.py |    4 +---
 src/mesa/main/texobj.c                      |    5 +++++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/glsl/builtins/tools/texture_builtins.py b/src/glsl/builtins/tools/texture_builtins.py
index 3a4943a..bbbbd0b 100755
--- a/src/glsl/builtins/tools/texture_builtins.py
+++ b/src/glsl/builtins/tools/texture_builtins.py
@@ -73,9 +73,7 @@ def generate_sigs(g, tex_inst, sampler_type, variant = 0, unused_fields = 0):
         print "\n       (declare (in) " + vec_type("i" if tex_inst == "txf" else "", coord_dim + extra_dim) + " P)",
     if tex_inst == "txl":
         print "\n       (declare (in) float lod)",
-    elif (tex_inst == "txf" and "Buffer" not in sampler_type):
-        print "\n       (declare (in) int lod)",
-    elif (tex_inst == "txs" and "Rect" not in sampler_type):
+    elif ((tex_inst == "txf" or tex_inst == "txs") and "Buffer" not in sampler_type and "Rect" not in sampler_type):
         print "\n       (declare (in) int lod)",
     elif tex_inst == "txd":
         grad_type = vec_type("", coord_dim)
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index d7dee4f..88dc3b1 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -756,6 +756,9 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
          target = GL_TEXTURE_1D;
          break;
       case TEXTURE_BUFFER_INDEX:
+         dims = 0;
+         target = GL_TEXTURE_BUFFER;
+         break;
       case TEXTURE_EXTERNAL_INDEX:
       default:
          /* no-op */
@@ -794,6 +797,8 @@ _mesa_get_fallback_texture(struct gl_context *ctx, gl_texture_index tex)
                                     GL_RGBA, texFormat);
 
          switch (dims) {
+	 case 0:
+	    break;
          case 1:
             ctx->Driver.TexImage1D(ctx, texImage, GL_RGBA,
                                    width, 0,
-- 
1.7.9.1



More information about the mesa-dev mailing list