[Mesa-dev] [PATCH] glsl: uniform sampler should occupy 1 location

2014-08-21 Thread Micael Dias
---
If samplers occupy zero locations we can run into a lot of issues. See #82921.
I briefly tested this with my own code (which was previously crashing and
misbehaving) and also ran other apps and everything seems to work fine.
I'm not used to contributing code in this fashion, so please forgive me if I'm
making some mistake. Thanks.

 src/glsl/glsl_types.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/glsl/glsl_types.cpp b/src/glsl/glsl_types.cpp
index 66e9b13..cc05193 100644
--- a/src/glsl/glsl_types.cpp
+++ b/src/glsl/glsl_types.cpp
@@ -691,6 +691,8 @@ glsl_type::uniform_locations() const
   return size;
case GLSL_TYPE_ARRAY:
   return this-length * this-fields.array-uniform_locations();
+   case GLSL_TYPE_SAMPLER:
+  return 1;
default:
   break;
}
-- 
2.1.0

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH] Implement HW accelerated GL_SELECT

2011-08-04 Thread Micael Dias
);
-  draw_set_rasterize_stage(draw, st-selection_stage);
-  /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  if (hw_acc_path) {
+ if (st_select_emul_begin(ctx)) {
+vbo_set_draw_func(ctx, st_select_draw_func);
+ }
+ else {
+hw_acc_path = false;
+ }
+  }
+  if (!hw_acc_path) {
+ if (!st-selection_stage)
+st-selection_stage = draw_glselect_stage(ctx, draw);
+ draw_set_rasterize_stage(draw, st-selection_stage);
+ /* Plug in new vbo draw function */
+ vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  }
}
else {
   if (!st-feedback_stage)
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index 0a32202..8a8e11a 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -207,6 +207,16 @@ struct st_context
 
int32_t draw_stamp;
int32_t read_stamp;
+
+   /* data related to hw accelerated GL_SELECT */
+   struct gl_selection_emul
+   {
+  GLboolean hw_unsupported;
+  struct gl_framebuffer *fbo;
+  GLuint rb_depth_name;
+  GLuint rb_color_name;
+  void *fs;
+   } select_emul;
 };
 
 
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index a7b50ce..d27e321 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -87,5 +87,22 @@ pointer_to_offset(const void *ptr)
return (unsigned) (((unsigned long) ptr)  0xUL);
 }
 
+/* Functions used by the hw accelerated GL_SELECT emulator
+ */
+extern bool
+st_select_emul_begin(struct gl_context *ctx);
+
+extern void
+st_select_emul_end(struct gl_context *ctx);
+
+extern void
+st_select_draw_func(struct gl_context *ctx,
+const struct gl_client_array **arrays,
+const struct _mesa_prim *prims,
+GLuint nr_prims,
+const struct _mesa_index_buffer *ib,
+GLboolean index_bounds_valid,
+GLuint min_index,
+GLuint max_index);
 
 #endif
diff --git a/src/mesa/state_tracker/st_draw_select_emul.c 
b/src/mesa/state_tracker/st_draw_select_emul.c
new file mode 100644
index 000..5e15298
--- /dev/null
+++ b/src/mesa/state_tracker/st_draw_select_emul.c
@@ -0,0 +1,468 @@
+/**
+ * 
+ * Copyright 2011 Micael Dias kam1kaz3 (at) gmail (dot) com,
+ *Pierre-Eric Pelloux-Prayer
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * Software), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **/
+
+/**
+ * This file contains code that attempts to accelerate GL_SELECT rendering.
+ * It was created with the intent of solving the following bug:
+ * https://bugs.freedesktop.org/show_bug.cgi?id=34495
+ *
+ * This code is a rewritten version of the patch GL_SELECT hw support v5
+ * posted by user Pierre-Eric Pelloux-Prayer in the previously mentioned bug.
+ *
+ * In order to test this code, the env. variable MESA_HW_SELECT should be
+ * exported.
+ *
+ * How this algorithm works:
+ * - When in GL_SELECT mode, draw calls are redirected to st_select_draw_func()
+ * which configures states in a way that makes the rendered primitives draw
+ * to a custom FBO that stores depth values (both min and max values) and
+ * emits these values through _mesa_update_hitflag().
+ */
+
+#include main/imports.h
+#include main/image.h
+#include main/macros.h
+#include main/mfeatures.h
+#include main/hash.h
+
+#include main/context.h
+#include main/enable.h
+#include main/fbobject.h
+#include main/depth.h
+#include main/state.h
+#include main/scissor.h
+#include main/viewport.h
+#include main/framebuffer.h
+#include main/feedback.h
+
+#include vbo/vbo.h
+
+#include st_context.h
+#include st_atom.h
+#include st_cb_bufferobjects.h

[Mesa-dev] [PATCH] Implement HW accelerated GL_SELECT

2011-08-04 Thread Micael Dias
);
-  draw_set_rasterize_stage(draw, st-selection_stage);
-  /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  if (hw_acc_path) {
+ if (st_select_emul_begin(ctx)) {
+vbo_set_draw_func(ctx, st_select_draw_func);
+ }
+ else {
+hw_acc_path = false;
+ }
+  }
+  if (!hw_acc_path) {
+ if (!st-selection_stage)
+st-selection_stage = draw_glselect_stage(ctx, draw);
+ draw_set_rasterize_stage(draw, st-selection_stage);
+ /* Plug in new vbo draw function */
+ vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  }
}
else {
   if (!st-feedback_stage)
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index 0a32202..8a8e11a 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -207,6 +207,16 @@ struct st_context
 
int32_t draw_stamp;
int32_t read_stamp;
+
+   /* data related to hw accelerated GL_SELECT */
+   struct gl_selection_emul
+   {
+  GLboolean hw_unsupported;
+  struct gl_framebuffer *fbo;
+  GLuint rb_depth_name;
+  GLuint rb_color_name;
+  void *fs;
+   } select_emul;
 };
 
 
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index a7b50ce..d27e321 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -87,5 +87,22 @@ pointer_to_offset(const void *ptr)
return (unsigned) (((unsigned long) ptr)  0xUL);
 }
 
+/* Functions used by the hw accelerated GL_SELECT emulator
+ */
+extern bool
+st_select_emul_begin(struct gl_context *ctx);
+
+extern void
+st_select_emul_end(struct gl_context *ctx);
+
+extern void
+st_select_draw_func(struct gl_context *ctx,
+const struct gl_client_array **arrays,
+const struct _mesa_prim *prims,
+GLuint nr_prims,
+const struct _mesa_index_buffer *ib,
+GLboolean index_bounds_valid,
+GLuint min_index,
+GLuint max_index);
 
 #endif
diff --git a/src/mesa/state_tracker/st_draw_select_emul.c 
b/src/mesa/state_tracker/st_draw_select_emul.c
new file mode 100644
index 000..d6bb244
--- /dev/null
+++ b/src/mesa/state_tracker/st_draw_select_emul.c
@@ -0,0 +1,490 @@
+/**
+ * 
+ * Copyright 2011 Micael Dias kam1kaz3 (at) gmail (dot) com,
+ *Pierre-Eric Pelloux-Prayer
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * Software), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **/
+
+/**
+ * This file contains code that attempts to accelerate GL_SELECT rendering.
+ * It was created with the intent of solving the following bug:
+ * https://bugs.freedesktop.org/show_bug.cgi?id=34495
+ *
+ * This code is a rewritten version of the patch GL_SELECT hw support v5
+ * posted by user Pierre-Eric Pelloux-Prayer in the previously mentioned bug.
+ *
+ * In order to test this code, the env. variable MESA_HW_SELECT should be
+ * exported.
+ *
+ * How this algorithm works:
+ * - When in GL_SELECT mode, draw calls are redirected to st_select_draw_func()
+ * which configures states in a way that makes the rendered primitives draw
+ * to a custom FBO that stores depth values (both min and max values) and
+ * emits these values through _mesa_update_hitflag().
+ */
+
+#include main/imports.h
+#include main/image.h
+#include main/macros.h
+#include main/mfeatures.h
+#include main/hash.h
+
+#include main/context.h
+#include main/enable.h
+#include main/fbobject.h
+#include main/depth.h
+#include main/state.h
+#include main/scissor.h
+#include main/viewport.h
+#include main/framebuffer.h
+#include main/feedback.h
+
+#include vbo/vbo.h
+
+#include st_context.h
+#include st_atom.h
+#include st_cb_bufferobjects.h

[Mesa-dev] [PATCH] Implement HW accelerated GL_SELECT

2011-08-02 Thread Micael Dias
---
 src/mesa/main/mtypes.h   |7 +
 src/mesa/state_tracker/st_cb_feedback.c  |   21 +-
 src/mesa/state_tracker/st_draw.h |   17 +
 src/mesa/state_tracker/st_draw_select_emul.c |  463 ++
 src/mesa/SConscript  |1 +
 src/mesa/sources.mak |1 +
 6 files changed, 505 insertions(+), 5 deletions(-)
 create mode 100644 src/mesa/state_tracker/st_draw_select_emul.c

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b881183..10222d8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1721,6 +1721,13 @@ struct gl_selection
GLboolean HitFlag;  /** hit flag */
GLfloat HitMinZ;/** minimum hit depth */
GLfloat HitMaxZ;/** maximum hit depth */
+   struct gl_selection_emul /* data related to hw accelerated GL_SELECT */
+   {
+  GLboolean hw_unsupported;
+  struct gl_framebuffer *fbo;
+  GLuint renderBuffer_depth;
+  GLuint renderBuffer_color;
+   } emul;
 };
 
 
diff --git a/src/mesa/state_tracker/st_cb_feedback.c 
b/src/mesa/state_tracker/st_cb_feedback.c
index 9b85a39..9382895 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -276,17 +276,28 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
 {
struct st_context *st = st_context(ctx);
struct draw_context *draw = st-draw;
+   bool hw_acc_path = _mesa_getenv(MESA_HW_SELECT)  
!ctx-Select.emul.hw_unsupported;
 
if (newMode == GL_RENDER) {
   /* restore normal VBO draw function */
   vbo_set_draw_func(ctx, st_draw_vbo);
}
else if (newMode == GL_SELECT) {
-  if (!st-selection_stage)
- st-selection_stage = draw_glselect_stage(ctx, draw);
-  draw_set_rasterize_stage(draw, st-selection_stage);
-  /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  if (hw_acc_path) {
+ if (st_select_emul_begin(ctx)) {
+vbo_set_draw_func(ctx, st_select_draw_func);
+ }
+ else {
+hw_acc_path = false;
+ }
+  }
+  if (!hw_acc_path) {
+ if (!st-selection_stage)
+st-selection_stage = draw_glselect_stage(ctx, draw);
+ draw_set_rasterize_stage(draw, st-selection_stage);
+ /* Plug in new vbo draw function */
+ vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  }
}
else {
   if (!st-feedback_stage)
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index a7b50ce..d27e321 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -87,5 +87,22 @@ pointer_to_offset(const void *ptr)
return (unsigned) (((unsigned long) ptr)  0xUL);
 }
 
+/* Functions used by the hw accelerated GL_SELECT emulator
+ */
+extern bool
+st_select_emul_begin(struct gl_context *ctx);
+
+extern void
+st_select_emul_end(struct gl_context *ctx);
+
+extern void
+st_select_draw_func(struct gl_context *ctx,
+const struct gl_client_array **arrays,
+const struct _mesa_prim *prims,
+GLuint nr_prims,
+const struct _mesa_index_buffer *ib,
+GLboolean index_bounds_valid,
+GLuint min_index,
+GLuint max_index);
 
 #endif
diff --git a/src/mesa/state_tracker/st_draw_select_emul.c 
b/src/mesa/state_tracker/st_draw_select_emul.c
new file mode 100644
index 000..78065dd
--- /dev/null
+++ b/src/mesa/state_tracker/st_draw_select_emul.c
@@ -0,0 +1,463 @@
+/**
+ * 
+ * Copyright .
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * Software), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ * 
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * 
+ **/
+
+#include main/imports.h
+#include main/image.h
+#include 

[Mesa-dev] [PATCH] Implement HW accelerated GL_SELECT

2011-08-02 Thread Micael Dias
---
 src/mesa/SConscript  |1 +
 src/mesa/main/mtypes.h   |7 +
 src/mesa/sources.mak |1 +
 src/mesa/state_tracker/st_cb_feedback.c  |   21 +-
 src/mesa/state_tracker/st_draw.h |   17 +
 src/mesa/state_tracker/st_draw_select_emul.c |  475 ++
 6 files changed, 517 insertions(+), 5 deletions(-)
 create mode 100644 src/mesa/state_tracker/st_draw_select_emul.c

diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index 24e2155..288b162 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -262,6 +262,7 @@ statetracker_sources = [
 'state_tracker/st_debug.c',
 'state_tracker/st_draw.c',
 'state_tracker/st_draw_feedback.c',
+'state_tracker/st_draw_select_emul.c',
 'state_tracker/st_extensions.c',
 'state_tracker/st_format.c',
 'state_tracker/st_gen_mipmap.c',
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b881183..10222d8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1721,6 +1721,13 @@ struct gl_selection
GLboolean HitFlag;  /** hit flag */
GLfloat HitMinZ;/** minimum hit depth */
GLfloat HitMaxZ;/** maximum hit depth */
+   struct gl_selection_emul /* data related to hw accelerated GL_SELECT */
+   {
+  GLboolean hw_unsupported;
+  struct gl_framebuffer *fbo;
+  GLuint renderBuffer_depth;
+  GLuint renderBuffer_color;
+   } emul;
 };
 
 
diff --git a/src/mesa/sources.mak b/src/mesa/sources.mak
index 4b2ec08..9af4079 100644
--- a/src/mesa/sources.mak
+++ b/src/mesa/sources.mak
@@ -229,6 +229,7 @@ STATETRACKER_SOURCES = \
state_tracker/st_debug.c \
state_tracker/st_draw.c \
state_tracker/st_draw_feedback.c \
+   state_tracker/st_draw_select_emul.c \
state_tracker/st_extensions.c \
state_tracker/st_format.c \
state_tracker/st_gen_mipmap.c \
diff --git a/src/mesa/state_tracker/st_cb_feedback.c 
b/src/mesa/state_tracker/st_cb_feedback.c
index 9b85a39..9382895 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -276,17 +276,28 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
 {
struct st_context *st = st_context(ctx);
struct draw_context *draw = st-draw;
+   bool hw_acc_path = _mesa_getenv(MESA_HW_SELECT)  
!ctx-Select.emul.hw_unsupported;
 
if (newMode == GL_RENDER) {
   /* restore normal VBO draw function */
   vbo_set_draw_func(ctx, st_draw_vbo);
}
else if (newMode == GL_SELECT) {
-  if (!st-selection_stage)
- st-selection_stage = draw_glselect_stage(ctx, draw);
-  draw_set_rasterize_stage(draw, st-selection_stage);
-  /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  if (hw_acc_path) {
+ if (st_select_emul_begin(ctx)) {
+vbo_set_draw_func(ctx, st_select_draw_func);
+ }
+ else {
+hw_acc_path = false;
+ }
+  }
+  if (!hw_acc_path) {
+ if (!st-selection_stage)
+st-selection_stage = draw_glselect_stage(ctx, draw);
+ draw_set_rasterize_stage(draw, st-selection_stage);
+ /* Plug in new vbo draw function */
+ vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  }
}
else {
   if (!st-feedback_stage)
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index a7b50ce..d27e321 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -87,5 +87,22 @@ pointer_to_offset(const void *ptr)
return (unsigned) (((unsigned long) ptr)  0xUL);
 }
 
+/* Functions used by the hw accelerated GL_SELECT emulator
+ */
+extern bool
+st_select_emul_begin(struct gl_context *ctx);
+
+extern void
+st_select_emul_end(struct gl_context *ctx);
+
+extern void
+st_select_draw_func(struct gl_context *ctx,
+const struct gl_client_array **arrays,
+const struct _mesa_prim *prims,
+GLuint nr_prims,
+const struct _mesa_index_buffer *ib,
+GLboolean index_bounds_valid,
+GLuint min_index,
+GLuint max_index);
 
 #endif
diff --git a/src/mesa/state_tracker/st_draw_select_emul.c 
b/src/mesa/state_tracker/st_draw_select_emul.c
new file mode 100644
index 000..ea54f22
--- /dev/null
+++ b/src/mesa/state_tracker/st_draw_select_emul.c
@@ -0,0 +1,475 @@
+/**
+ * 
+ * Copyright 2011 Micael Dias kam1kaz3 (at) gmail (dot) com.
+ * All Rights Reserved.
+ * 
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * Software), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software

[Mesa-dev] [PATCH] Gallium: fix buffer overflow

2011-07-01 Thread Micael Dias
---
 src/gallium/auxiliary/draw/draw_llvm.c |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c 
b/src/gallium/auxiliary/draw/draw_llvm.c
index 56c26f5..19134f3 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1163,6 +1163,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant)
struct lp_build_loop_state lp_loop;
const int max_vertices = 4;
LLVMValueRef outputs[PIPE_MAX_SHADER_OUTPUTS][NUM_CHANNELS];
+   LLVMValueRef fetch_max;
void *code;
struct lp_build_sampler_soa *sampler = 0;
LLVMValueRef ret, ret_ptr;
@@ -1234,6 +1235,10 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant)
   draw_llvm_variant_key_samplers(variant-key),
   context_ptr);
 
+   fetch_max = LLVMBuildSub(builder, count,
+lp_build_const_int32(gallivm, 1),
+fetch_max);
+
 #if DEBUG_STORE
lp_build_printf(builder, start = %d, end = %d, step = %d\n,
start, end, step);
@@ -1257,6 +1262,13 @@ draw_llvm_generate(struct draw_llvm *llvm, struct 
draw_llvm_variant *variant)
 builder,
 lp_loop.counter,
 lp_build_const_int32(gallivm, i), );
+ LLVMValueRef fetch_ptr;
+
+ /* make sure we're not out of bounds which can happen
+  * if fetch_count % 4 != 0, because on the last iteration
+  * a few of the 4 vertex fetches will be out of bounds */
+ true_index = lp_build_min(bld, true_index, fetch_max);
+ 
  for (j = 0; j  draw-pt.nr_vertex_elements; ++j) {
 struct pipe_vertex_element *velem = draw-pt.vertex_element[j];
 LLVMValueRef vb_index = lp_build_const_int32(gallivm, 
velem-vertex_buffer_index);
-- 
1.7.6

___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev