Mesa (master): mesa: Make sure that imm draws are flushed before other draws execute.

2018-06-04 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 1ac4439d6278e6c5f9da5499bbc50362f0c6759b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ac4439d6278e6c5f9da5499bbc50362f0c6759b

Author: Mathias Fröhlich 
Date:   Fri Jun  1 19:10:08 2018 +0200

mesa: Make sure that imm draws are flushed before other draws execute.

The recent patch

mesa: Remove FLUSH_VERTICES from VAO state changes.

Pending draw calls on immediate mode or display list calls do
not depend on changes of the VAO state. So, remove calls to
FLUSH_VERTICES and flag _NEW_ARRAY as appropriate.

uncovered a problem that non immediate mode draw calls do only
flush outstanding immediate mode draws if FLUSH_UPDATE_CURRENT
is set in ctx->Driver.NeedFlush.
In that case, due to the sequence of _mesa_set_draw_vao commands
we could end up with the VAO from the FLUSH_VERTICES call set
into gl_context::Array._DrawVAO when the array draw is executed.
So the change pulls FLUSH_CURRENT out of _mesa_validate_* calls
into the array draw calls being validated.
The change introduces a new macro FLUSH_FOR_DRAW beside FLUSH_VERTICES
and FLUSH_CURRENT that flushes on changed current attributes as well
as on outstanding immediate mode draw calls. Use FLUSH_FOR_DRAW
in the non immediate mode draw code paths.

Reviewed-by: Marek Olšák 
Tested-by: Kai Wasserbäch 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106594
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/context.h   | 16 +
 src/mesa/main/draw_validate.c | 26 ---
 src/mesa/vbo/vbo_exec_array.c | 77 ++-
 src/mesa/vbo/vbo_save_draw.c  |  2 +-
 4 files changed, 56 insertions(+), 65 deletions(-)

diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 77520f678f..d50438fd7f 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -233,6 +233,22 @@ do {   
\
 } while (0)
 
 /**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ *
+ * Checks if dd_function_table::NeedFlush is marked to flush stored vertices
+ * or current state and calls dd_function_table::FlushVertices if so.
+ */
+#define FLUSH_FOR_DRAW(ctx) \
+do {\
+   if (MESA_VERBOSE & VERBOSE_STATE)\
+  _mesa_debug(ctx, "FLUSH_FOR_DRAW in %s\n", __func__); \
+   if (ctx->Driver.NeedFlush)   \
+  vbo_exec_FlushVertices(ctx, ctx->Driver.NeedFlush);   \
+} while (0)
+
+/**
  * Macro to assert that the API call was made outside the
  * glBegin()/glEnd() pair, with return value.
  * 
diff --git a/src/mesa/main/draw_validate.c b/src/mesa/main/draw_validate.c
index bcb2d91306..352263c5c7 100644
--- a/src/mesa/main/draw_validate.c
+++ b/src/mesa/main/draw_validate.c
@@ -696,8 +696,6 @@ _mesa_validate_DrawElements(struct gl_context *ctx,
 GLenum mode, GLsizei count, GLenum type,
 const GLvoid *indices)
 {
-   FLUSH_CURRENT(ctx, 0);
-
return validate_DrawElements_common(ctx, mode, count, type, indices,
"glDrawElements");
 }
@@ -716,8 +714,6 @@ _mesa_validate_MultiDrawElements(struct gl_context *ctx,
 {
GLsizei i;
 
-   FLUSH_CURRENT(ctx, 0);
-
/*
 * Section 2.3.1 (Errors) of the OpenGL 4.5 (Core Profile) spec says:
 *
@@ -780,8 +776,6 @@ _mesa_validate_DrawRangeElements(struct gl_context *ctx, 
GLenum mode,
  GLsizei count, GLenum type,
  const GLvoid *indices)
 {
-   FLUSH_CURRENT(ctx, 0);
-
if (end < start) {
   _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(endArray.VAO, enabled_filter(ctx));
 
   if (ctx->NewState)
@@ -568,10 +568,9 @@ vbo_exec_DrawArraysInstanced(GLenum mode, GLint start, 
GLsizei count,
   _mesa_debug(ctx, "glDrawArraysInstanced(%s, %d, %d, %d)\n",
   _mesa_enum_to_string(mode), start, count, numInstances);
 
+   FLUSH_FOR_DRAW(ctx);
 
if (_mesa_is_no_error_enabled(ctx)) {
-  FLUSH_CURRENT(ctx, 0);
-
   _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx));
 
   if (ctx->NewState)
@@ -610,9 +609,9 @@ vbo_exec_DrawArraysInstancedBaseInstance(GLenum mode, GLint 
first,
   _mesa_enum_to_string(mode), first, count,
   numInstances, baseInstance);
 
-   if (_mesa_is_no_error_enabled(ctx)) {
-  FLUSH_CURRENT(ctx, 0);
+   FLUSH_FOR_DRAW(ctx);
 
+   if (_mesa_is_no_error_enabled(ctx)) {
   _mesa_set_draw_vao(ctx, ctx->Array.VAO, enabled_filter(ctx));
 
   if (ctx->NewState)
@@ -650,9 +649,9 @@ vbo_exec_MultiDrawArrays(GLenum mode, const GLint *first,
   "glMultiDrawArrays(%s, %p, %p, %d)\n",
   _mesa_enum_to_str

Mesa (master): mesa: Flag _NEW_ARRAY only if we are changing ctx->Array.VAO.

2018-05-17 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 984cb4e512f47fe6682f51985a0722c95e21f446
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=984cb4e512f47fe6682f51985a0722c95e21f446

Author: Mathias Fröhlich 
Date:   Sun May 13 09:18:57 2018 +0200

mesa: Flag _NEW_ARRAY only if we are changing ctx->Array.VAO.

For the VAO internal helper functions that may be called
with a non current VAO, flag the _NEW_ARRAY state only
if it is the current ctx->Array.VAO.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/varray.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 4859f16050..a3e1aebb76 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -178,7 +178,8 @@ _mesa_vertex_attrib_binding(struct gl_context *ctx,
   array->BufferBindingIndex = bindingIndex;
 
   vao->NewArrays |= vao->_Enabled & array_bit;
-  ctx->NewState |= _NEW_ARRAY;
+  if (vao == ctx->Array.VAO)
+ ctx->NewState |= _NEW_ARRAY;
}
 }
 
@@ -213,7 +214,8 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
  vao->VertexAttribBufferMask |= binding->_BoundArrays;
 
   vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
-  ctx->NewState |= _NEW_ARRAY;
+  if (vao == ctx->Array.VAO)
+ ctx->NewState |= _NEW_ARRAY;
}
 }
 
@@ -235,7 +237,8 @@ vertex_binding_divisor(struct gl_context *ctx,
if (binding->InstanceDivisor != divisor) {
   binding->InstanceDivisor = divisor;
   vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
-  ctx->NewState |= _NEW_ARRAY;
+  if (vao == ctx->Array.VAO)
+ ctx->NewState |= _NEW_ARRAY;
}
 }
 
@@ -345,7 +348,8 @@ _mesa_update_array_format(struct gl_context *ctx,
array->_ElementSize = elementSize;
 
vao->NewArrays |= vao->_Enabled & VERT_BIT(attrib);
-   ctx->NewState |= _NEW_ARRAY;
+   if (vao == ctx->Array.VAO)
+  ctx->NewState |= _NEW_ARRAY;
 }
 
 /**
@@ -1080,7 +1084,9 @@ _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
   const GLbitfield array_bit = VERT_BIT(attrib);
   vao->_Enabled |= array_bit;
   vao->NewArrays |= array_bit;
-  ctx->NewState |= _NEW_ARRAY;
+
+  if (vao == ctx->Array.VAO)
+ ctx->NewState |= _NEW_ARRAY;
 
   /* Update the map mode if needed */
   if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0))
@@ -1165,7 +1171,9 @@ _mesa_disable_vertex_array_attrib(struct gl_context *ctx,
   const GLbitfield array_bit = VERT_BIT(attrib);
   vao->_Enabled &= ~array_bit;
   vao->NewArrays |= array_bit;
-  ctx->NewState |= _NEW_ARRAY;
+
+  if (vao == ctx->Array.VAO)
+ ctx->NewState |= _NEW_ARRAY;
 
   /* Update the map mode if needed */
   if (array_bit & (VERT_BIT_POS|VERT_BIT_GENERIC0))

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Remove flush_vertices argument from VAO methods.

2018-05-17 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 5c7e3a90edf81000b8295ad9bb1029b8a24c6007
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c7e3a90edf81000b8295ad9bb1029b8a24c6007

Author: Mathias Fröhlich 
Date:   Sun May 13 09:18:57 2018 +0200

mesa: Remove flush_vertices argument from VAO methods.

The flush_vertices argument is now unused, remove it.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/common/meta.c   | 32 ++-
 src/mesa/main/bufferobj.c|  2 +-
 src/mesa/main/enable.c   |  4 +--
 src/mesa/main/varray.c   | 44 +++-
 src/mesa/main/varray.h   |  8 +++---
 src/mesa/state_tracker/st_cb_rasterpos.c |  4 +--
 src/mesa/vbo/vbo_context.c   |  2 +-
 src/mesa/vbo/vbo_exec_draw.c |  6 ++---
 src/mesa/vbo/vbo_save_api.c  |  6 ++---
 9 files changed, 51 insertions(+), 57 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 830d82ad49..6b1713e3b1 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -348,18 +348,18 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x));
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
-  *buf_obj, 0, sizeof(struct vertex), true);
+  *buf_obj, 0, sizeof(struct vertex));
  _mesa_enable_vertex_array_attrib(ctx, array_obj,
-  VERT_ATTRIB_GENERIC(0), true);
+  VERT_ATTRIB_GENERIC(0));
  if (texcoord_size > 0) {
 _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
   texcoord_size, GL_FLOAT, GL_RGBA,
   GL_FALSE, GL_FALSE, GL_FALSE,
   offsetof(struct vertex, tex));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
- *buf_obj, 0, sizeof(struct vertex), true);
+ *buf_obj, 0, sizeof(struct vertex));
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
- VERT_ATTRIB_GENERIC(1), true);
+ VERT_ATTRIB_GENERIC(1));
  }
   } else {
  _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS,
@@ -367,9 +367,8 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x));
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
-  *buf_obj, 0, sizeof(struct vertex), true);
- _mesa_enable_vertex_array_attrib(ctx, array_obj,
-  VERT_ATTRIB_POS, true);
+  *buf_obj, 0, sizeof(struct vertex));
+ _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
 
  if (texcoord_size > 0) {
 _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(0),
@@ -377,9 +376,9 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE,
   offsetof(struct vertex, tex));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
- *buf_obj, 0, sizeof(struct vertex), true);
+ *buf_obj, 0, sizeof(struct vertex));
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
- VERT_ATTRIB_TEX(0), true);
+ VERT_ATTRIB_TEX(0));
  }
 
  if (color_size > 0) {
@@ -388,9 +387,9 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE,
   offsetof(struct vertex, r));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
- *buf_obj, 0, sizeof(struct vertex), true);
+ *buf_obj, 0, sizeof(struct vertex));
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
- VERT_ATTRIB_COLOR0, true);
+ VERT_ATTRIB_COLOR0);
  }
   }
} else {
@@ -3347,9 +3346,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
 GL_FALSE, GL_FALSE,
 offsetof(struct vertex, x));
   _mesa_bind_vertex_b

Mesa (master): mesa: The glArrayElement api is independent of the current program.

2018-05-17 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 6fac626193a077cba3154acf3820b30fc6f3e874
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6fac626193a077cba3154acf3820b30fc6f3e874

Author: Mathias Fröhlich 
Date:   Sun May 13 09:18:57 2018 +0200

mesa: The glArrayElement api is independent of the current program.

All the shader program dependent handling is done on the level
of the gl_Context::Array._DrawVAO/_DrawVAOEnabledAttribs.
So, skip array element invalidation on _NEW_PROGRAM.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/api_arrayelt.c | 2 +-
 src/mesa/vbo/vbo_context.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/api_arrayelt.c b/src/mesa/main/api_arrayelt.c
index 2dfa74f64b..afa3012021 100644
--- a/src/mesa/main/api_arrayelt.c
+++ b/src/mesa/main/api_arrayelt.c
@@ -1823,7 +1823,7 @@ _ae_invalidate_state(struct gl_context *ctx)
 * Luckily, neither the drivers nor tnl muck with the state that
 * concerns us here:
 */
-   assert(ctx->NewState & (_NEW_ARRAY | _NEW_PROGRAM));
+   assert(ctx->NewState & _NEW_ARRAY);
 
assert(!actx->mapped_vbos);
actx->dirty_state = true;
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index ee2e31ab7a..cf9405df3d 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -157,7 +157,7 @@ vbo_exec_invalidate_state(struct gl_context *ctx)
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
 
-   if (ctx->NewState & (_NEW_PROGRAM | _NEW_ARRAY)) {
+   if (ctx->NewState & _NEW_ARRAY) {
   _ae_invalidate_state(ctx);
}
if (ctx->NewState & _NEW_EVAL)

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Remove FLUSH_VERTICES from VAO state changes.

2018-05-17 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 9c7be67968aaba224d518dee86dff736a4b599c6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c7be67968aaba224d518dee86dff736a4b599c6

Author: Mathias Fröhlich 
Date:   Sun May 13 09:18:57 2018 +0200

mesa: Remove FLUSH_VERTICES from VAO state changes.

Pending draw calls on immediate mode or display list calls do
not depend on changes of the VAO state. So, remove calls to
FLUSH_VERTICES and flag _NEW_ARRAY as appropriate.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/varray.c | 65 +-
 1 file changed, 6 insertions(+), 59 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index d16807b406..2ced74a76c 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -172,16 +172,13 @@ _mesa_vertex_attrib_binding(struct gl_context *ctx,
   else
  vao->VertexAttribBufferMask &= ~array_bit;
 
-  if (flush_vertices) {
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
-  }
-
   vao->BufferBinding[array->BufferBindingIndex]._BoundArrays &= ~array_bit;
   vao->BufferBinding[bindingIndex]._BoundArrays |= array_bit;
 
   array->BufferBindingIndex = bindingIndex;
 
   vao->NewArrays |= vao->_Enabled & array_bit;
+  ctx->NewState |= _NEW_ARRAY;
}
 }
 
@@ -204,9 +201,6 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
if (binding->BufferObj != vbo ||
binding->Offset != offset ||
binding->Stride != stride) {
-  if (flush_vertices) {
- FLUSH_VERTICES(ctx, _NEW_ARRAY);
-  }
 
   _mesa_reference_buffer_object(ctx, &binding->BufferObj, vbo);
 
@@ -219,6 +213,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
  vao->VertexAttribBufferMask |= binding->_BoundArrays;
 
   vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
+  ctx->NewState |= _NEW_ARRAY;
}
 }
 
@@ -238,9 +233,9 @@ vertex_binding_divisor(struct gl_context *ctx,
assert(!vao->SharedAndImmutable);
 
if (binding->InstanceDivisor != divisor) {
-  FLUSH_VERTICES(ctx, _NEW_ARRAY);
   binding->InstanceDivisor = divisor;
   vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
+  ctx->NewState |= _NEW_ARRAY;
}
 }
 
@@ -322,8 +317,6 @@ get_array_format(const struct gl_context *ctx, GLint 
sizeMax, GLint *size)
  * \param doublesDouble values not reduced to floats
  * \param relativeOffset Offset of the first element relative to the binding
  *   offset.
- * \param flush_verties  Should \c FLUSH_VERTICES be invoked before updating
- *   state?
  */
 void
 _mesa_update_array_format(struct gl_context *ctx,
@@ -623,7 +616,6 @@ _mesa_VertexPointer_no_error(GLint size, GLenum type, 
GLsizei stride,
  const GLvoid *ptr)
 {
GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
update_array(ctx, VERT_ATTRIB_POS, GL_RGBA, 4, size, type, stride,
 GL_FALSE, GL_FALSE, GL_FALSE, ptr);
@@ -635,8 +627,6 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei 
stride, const GLvoid *ptr)
 {
GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
GLenum format = GL_RGBA;
GLbitfield legalTypes = (ctx->API == API_OPENGLES)
   ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT)
@@ -660,7 +650,6 @@ void GLAPIENTRY
 _mesa_NormalPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr )
 {
GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
update_array(ctx, VERT_ATTRIB_NORMAL, GL_RGBA, 3, 3, type, stride, GL_TRUE,
 GL_FALSE, GL_FALSE, ptr);
@@ -672,8 +661,6 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const 
GLvoid *ptr )
 {
GET_CURRENT_CONTEXT(ctx);
 
-   FLUSH_VERTICES(ctx, 0);
-
GLenum format = GL_RGBA;
const GLbitfield legalTypes = (ctx->API == API_OPENGLES)
   ? (BYTE_BIT | SHORT_BIT | FLOAT_BIT | FIXED_ES_BIT)
@@ -698,7 +685,6 @@ _mesa_ColorPointer_no_error(GLint size, GLenum type, 
GLsizei stride,
 const GLvoid *ptr)
 {
GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 
GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
update_array(ctx, VERT_ATTRIB_COLOR0, format, BGRA_OR_4, size,
@@ -712,8 +698,6 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, 
const GLvoid *ptr)
GET_CURRENT_CONTEXT(ctx);
const GLint sizeMin = (ctx->API == API_OPENGLES) ? 4 : 3;
 
-   FLUSH_VERTICES(ctx, 0);
-
GLenum format = get_array_format(ctx, BGRA_OR_4, &size);
const GLbitfield legalTypes = (ctx->API == API_OPENGLES)
   ? (UNSIGNED_BYTE_BIT | HALF_BIT | FLOAT_BIT | FIXED_ES_BIT)
@@ -740,7 +724,6 @@ void GLAPIENTRY
 _mesa_FogCoordPointer_no_error(GLenum type, GLsizei stride, const GLvoid *ptr)
 {
GET_CURRENT_CONTEXT(ctx);
-   FLUSH_VERTICES(ctx, 0);
 

Mesa (master): mesa: Remove Array._DrawArrays.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 881d2fcafaddd391b03753173d126148c9dafbcf
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=881d2fcafaddd391b03753173d126148c9dafbcf

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

mesa: Remove Array._DrawArrays.

Only tnl based drivers still use this array. So remove it
from core mesa and use Array._DrawVAO instead.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c |  4 ++--
 src/mesa/main/arrayobj.c |  1 -
 src/mesa/main/attrib.c   |  1 -
 src/mesa/main/mtypes.h   |  6 --
 src/mesa/main/varray.h   | 14 --
 src/mesa/tnl/t_draw.c| 11 +--
 src/mesa/tnl/tnl.h   |  2 +-
 7 files changed, 8 insertions(+), 31 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 79b444cf55..d031ebeabd 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -550,9 +550,9 @@ TAG(vbo_draw)(struct gl_context *ctx,
  struct gl_buffer_object *indirect)
 {
/* Borrow and update the inputs list from the tnl context */
-   _tnl_bind_inputs(ctx);
+   const struct gl_vertex_array* arrays = _tnl_bind_inputs(ctx);
 
-   TAG(vbo_check_render_prims)(ctx, ctx->Array._DrawArrays,
+   TAG(vbo_check_render_prims)(ctx, arrays,
prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
tfb_vertcount, stream, indirect);
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 05af50ef40..5ee68cf9e9 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -970,7 +970,6 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, bool 
no_error)
 * or to prevent a crash if the VAO being unbound is going to be
 * deleted.
 */
-   _mesa_set_drawing_arrays(ctx, NULL);
_mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
 
ctx->NewState |= _NEW_ARRAY;
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index e565750a89..cbe93ab6fa 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1588,7 +1588,6 @@ copy_array_attrib(struct gl_context *ctx,
/* skip IndexBufferObj */
 
/* Invalidate array state. It will be updated during the next draw. */
-   _mesa_set_drawing_arrays(ctx, NULL);
_mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
 }
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index e751704386..0b55a510b0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1629,12 +1629,6 @@ struct gl_array_attrib
 */
struct gl_vertex_array_object *_EmptyVAO;
 
-   /**
-* Vertex arrays as consumed by a driver.
-* The array pointer is set up only by the VBO module.
-*/
-   const struct gl_vertex_array *_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */
-
/** Legal array datatypes and the API for which they have been computed */
GLbitfield LegalTypesMask;
gl_api LegalTypesMaskAPI;
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 25d2a29e73..6ab55ed36a 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -53,20 +53,6 @@ _mesa_attr_zero_aliases_vertex(const struct gl_context *ctx)
 }
 
 
-/**
- * This specifies the set of vertex arrays used by the driver for drawing.
- */
-static inline void
-_mesa_set_drawing_arrays(struct gl_context *ctx,
- const struct gl_vertex_array *arrays)
-{
-   if (ctx->Array._DrawArrays != arrays) {
-  ctx->Array._DrawArrays = arrays;
-  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
-   }
-}
-
-
 extern void
 _mesa_update_array_format(struct gl_context *ctx,
   struct gl_vertex_array_object *vao,
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index a83b98eede..9814cdcec1 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -537,12 +537,12 @@ void _tnl_draw_prims(struct gl_context *ctx,
 }
 
 
-void
+const struct gl_vertex_array*
 _tnl_bind_inputs( struct gl_context *ctx )
 {
TNLcontext *tnl = TNL_CONTEXT(ctx);
-   _mesa_set_drawing_arrays(ctx, tnl->draw_arrays.inputs);
_vbo_update_inputs(ctx, &tnl->draw_arrays);
+   return tnl->draw_arrays.inputs;
 }
 
 
@@ -558,12 +558,11 @@ _tnl_draw(struct gl_context *ctx,
   struct gl_transform_feedback_object *tfb_vertcount,
   unsigned stream, struct gl_buffer_object *indirect)
 {
-   /* Update TNLcontext::draw_arrays and set that pointer
-* into Array._DrawArrays.
+   /* Update TNLcontext::draw_arrays and return that pointer.
 */
-   _tnl_bind_inputs(ctx);
+   const struct gl_vertex_array* arrays = _tnl_bind_inputs(ctx);
 
-   _tnl_draw_prims(ctx, ct

Mesa (master): st/mesa: Use Array._DrawVAO in st_atom_array.c.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 19a91841c347107d877bc750371c5fa4e9b4de19
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=19a91841c347107d877bc750371c5fa4e9b4de19

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

st/mesa: Use Array._DrawVAO in st_atom_array.c.

Finally make use of the binding information in the VAO when
setting up arrays for draw.

v2: Emit less relocations also for interleaved userspace arrays.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_atom_array.c | 433 -
 1 file changed, 108 insertions(+), 325 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom_array.c 
b/src/mesa/state_tracker/st_atom_array.c
index 2fd67e8d84..9a0935e21a 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -48,6 +48,7 @@
 #include "main/bufferobj.h"
 #include "main/glformats.h"
 #include "main/varray.h"
+#include "main/arrayobj.h"
 
 /* vertex_formats[gltype - GL_BYTE][integer*2 + normalized][size - 1] */
 static const uint16_t vertex_formats[][4][4] = {
@@ -306,79 +307,6 @@ st_pipe_vertex_format(const struct gl_array_attributes 
*attrib)
return vertex_formats[type - GL_BYTE][index][size-1];
 }
 
-static const struct gl_vertex_array *
-get_client_array(const struct gl_vertex_array *arrays,
- unsigned mesaAttr)
-{
-   /* st_program uses 0x to denote a double placeholder attribute */
-   if (mesaAttr == ST_DOUBLE_ATTRIB_PLACEHOLDER)
-  return NULL;
-   return &arrays[mesaAttr];
-}
-
-/**
- * Examine the active arrays to determine if we have interleaved
- * vertex arrays all living in one VBO, or all living in user space.
- */
-static GLboolean
-is_interleaved_arrays(const struct st_vertex_program *vp,
-  const struct gl_vertex_array *arrays,
-  unsigned num_inputs)
-{
-   GLuint attr;
-   const struct gl_buffer_object *firstBufObj = NULL;
-   GLint firstStride = -1;
-   const GLubyte *firstPtr = NULL;
-   GLboolean userSpaceBuffer = GL_FALSE;
-
-   for (attr = 0; attr < num_inputs; attr++) {
-  const struct gl_vertex_array *array;
-  const struct gl_vertex_buffer_binding *binding;
-  const struct gl_array_attributes *attrib;
-  const GLubyte *ptr;
-  const struct gl_buffer_object *bufObj;
-  GLsizei stride;
-
-  array = get_client_array(arrays, vp->index_to_input[attr]);
-  if (!array)
-continue;
-
-  binding = array->BufferBinding;
-  attrib = array->VertexAttrib;
-  stride = binding->Stride; /* in bytes */
-  ptr = _mesa_vertex_attrib_address(attrib, binding);
-
-  /* To keep things simple, don't allow interleaved zero-stride attribs. */
-  if (stride == 0)
- return false;
-
-  bufObj = binding->BufferObj;
-  if (attr == 0) {
- /* save info about the first array */
- firstStride = stride;
- firstPtr = ptr;
- firstBufObj = bufObj;
- userSpaceBuffer = !_mesa_is_bufferobj(bufObj);
-  }
-  else {
- /* check if other arrays interleave with the first, in same buffer */
- if (stride != firstStride)
-return GL_FALSE; /* strides don't match */
-
- if (bufObj != firstBufObj)
-return GL_FALSE; /* arrays in different VBOs */
-
- if (llabs(ptr - firstPtr) > firstStride)
-return GL_FALSE; /* arrays start too far apart */
-
- if ((!_mesa_is_bufferobj(bufObj)) != userSpaceBuffer)
-return GL_FALSE; /* mix of VBO and user-space arrays */
-  }
-   }
-
-   return GL_TRUE;
-}
-
 static void init_velement(struct pipe_vertex_element *velement,
   int src_offset, int format,
   int instance_divisor, int vbo_index)
@@ -392,13 +320,14 @@ static void init_velement(struct pipe_vertex_element 
*velement,
 
 static void init_velement_lowered(const struct st_vertex_program *vp,
   struct pipe_vertex_element *velements,
-  int src_offset, int format,
-  int instance_divisor, int vbo_index,
-  int nr_components, GLboolean doubles,
-  GLuint *attr_idx)
+  const struct gl_array_attributes *attrib,
+  int src_offset, int instance_divisor,
+  int vbo_index, int idx)
 {
-   int idx = *attr_idx;
-   if (doubles) {
+   const unsigned format = st_pipe_vertex_format(attrib);
+   const GLubyte nr_components = attrib->Size;
+
+   if (attrib->Doubles) {
   int lower_format;
 
   if (nr_components < 2)
@@ -427,15 +356,11 @@ static void init_velement_lowered(const struct 
st_vertex_program 

Mesa (master): st/mesa: Make the input_to_index array available.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 9987a072cbc00306eb4d34409f6325ae29728a2f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9987a072cbc00306eb4d34409f6325ae29728a2f

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

st/mesa: Make the input_to_index array available.

The input_to_index array is already available internally
when preparing vertex programs. Store the map in
struct st_vertex_program.
Also store the bitmask of mesa vertex processing inputs in
struct st_vp_variant.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_program.c  | 17 -
 src/mesa/state_tracker/st_program.h  |  5 +
 src/mesa/state_tracker/st_shader_cache.c |  4 
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_program.c 
b/src/mesa/state_tracker/st_program.c
index fe72ddaf2c..f256e2e862 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -388,11 +388,11 @@ st_translate_vertex_program(struct st_context *st,
enum pipe_error error;
unsigned num_outputs = 0;
unsigned attr;
-   ubyte input_to_index[VERT_ATTRIB_MAX] = {0};
ubyte output_semantic_name[VARYING_SLOT_MAX] = {0};
ubyte output_semantic_index[VARYING_SLOT_MAX] = {0};
 
stvp->num_inputs = 0;
+   memset(stvp->input_to_index, ~0, sizeof(stvp->input_to_index));
 
if (stvp->Base.arb.IsPositionInvariant)
   _mesa_insert_mvp_code(st->ctx, &stvp->Base);
@@ -403,7 +403,7 @@ st_translate_vertex_program(struct st_context *st,
 */
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
   if ((stvp->Base.info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
- input_to_index[attr] = stvp->num_inputs;
+ stvp->input_to_index[attr] = stvp->num_inputs;
  stvp->index_to_input[stvp->num_inputs] = attr;
  stvp->num_inputs++;
  if ((stvp->Base.info.vs.double_inputs_read &
@@ -415,7 +415,7 @@ st_translate_vertex_program(struct st_context *st,
   }
}
/* bit of a hack, presetup potentially unused edgeflag input */
-   input_to_index[VERT_ATTRIB_EDGEFLAG] = stvp->num_inputs;
+   stvp->input_to_index[VERT_ATTRIB_EDGEFLAG] = stvp->num_inputs;
stvp->index_to_input[stvp->num_inputs] = VERT_ATTRIB_EDGEFLAG;
 
/* Compute mapping of vertex program outputs to slots.
@@ -495,7 +495,7 @@ st_translate_vertex_program(struct st_context *st,
&stvp->Base,
/* inputs */
stvp->num_inputs,
-   input_to_index,
+   stvp->input_to_index,
NULL, /* inputSlotToAttr */
NULL, /* input semantic name */
NULL, /* input semantic index */
@@ -518,7 +518,7 @@ st_translate_vertex_program(struct st_context *st,
 &stvp->Base,
 /* inputs */
 stvp->num_inputs,
-input_to_index,
+stvp->input_to_index,
 NULL, /* input semantic name */
 NULL, /* input semantic index */
 NULL,
@@ -598,6 +598,13 @@ st_create_vp_variant(struct st_context *st,
  fprintf(stderr, "mesa: cannot emulate deprecated features\n");
}
 
+   for (unsigned index = 0; index < vpv->num_inputs; ++index) {
+  unsigned attr = stvp->index_to_input[index];
+  if (attr == ST_DOUBLE_ATTRIB_PLACEHOLDER)
+ continue;
+  vpv->vert_attrib_mask |= 1u << attr;
+   }
+
if (ST_DEBUG & DEBUG_TGSI) {
   tgsi_dump(vpv->tgsi.tokens, 0);
   debug_printf("\n");
diff --git a/src/mesa/state_tracker/st_program.h 
b/src/mesa/state_tracker/st_program.h
index a520ffbecb..f67ea5eb20 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -196,6 +196,9 @@ struct st_vp_variant
 
/** similar to that in st_vertex_program, but with edgeflags info too */
GLuint num_inputs;
+
+   /** Bitfield of VERT_BIT_* bits of mesa vertex processing inputs */
+   GLbitfield vert_attrib_mask;
 };
 
 
@@ -215,6 +218,8 @@ struct st_vertex_program
/** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
ubyte index_to_input[PIPE_MAX_ATTRIBS];
ubyte num_inputs;
+   /** Reverse mapping of the above */
+   ubyte input_to_index[VERT_ATTRIB_MAX];
 
/** Maps VARYING_SLOT_x to slot */
ubyte result_to_output[VARYING_SLOT_MAX];
diff --git a/src/mesa/state_tracker/st_shader_cache.c 
b/src/mesa/state_tracker/st_shader_cache.c
i

Mesa (master): st/mesa: Make feedback draw and rasterpos use _DrawVAO.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4c77f0d065d1690f1fd0265a07ac9f6e5d40ea68
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c77f0d065d1690f1fd0265a07ac9f6e5d40ea68

Author: Mathias Fröhlich 
Date:   Thu Apr 26 23:17:20 2018 +0200

st/mesa: Make feedback draw and rasterpos use _DrawVAO.

Instead of playing with Array._DrawArrays, make the feedback draw
path use Array._DrawVAO. Also st_RasterPos needs to use the VAO then.

v2: Use helper methods to get the offset values for array and binding.
Update comments.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_cb_rasterpos.c  | 43 ++---
 src/mesa/state_tracker/st_draw_feedback.c | 46 ++-
 2 files changed, 24 insertions(+), 65 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c 
b/src/mesa/state_tracker/st_cb_rasterpos.c
index b73d543653..cf4718f8cb 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -38,9 +38,11 @@
 
 #include "main/imports.h"
 #include "main/macros.h"
+#include "main/arrayobj.h"
 #include "main/feedback.h"
 #include "main/rastpos.h"
-#include "glformats.h"
+#include "main/state.h"
+#include "main/varray.h"
 
 #include "st_context.h"
 #include "st_atom.h"
@@ -61,9 +63,7 @@ struct rastpos_stage
struct gl_context *ctx;/**< Rendering context */
 
/* vertex attrib info we can setup once and re-use */
-   struct gl_vertex_buffer_binding binding;
-   struct gl_array_attributes attrib[VERT_ATTRIB_MAX];
-   struct gl_vertex_array array[VERT_ATTRIB_MAX];
+   struct gl_vertex_array_object *VAO;
struct _mesa_prim prim;
 };
 
@@ -103,6 +103,8 @@ rastpos_line( struct draw_stage *stage, struct prim_header 
*prim )
 static void
 rastpos_destroy(struct draw_stage *stage)
 {
+   struct rastpos_stage *rstage = (struct rastpos_stage*)stage;
+   _mesa_reference_vao(rstage->ctx, &rstage->VAO, NULL);
free(stage);
 }
 
@@ -182,8 +184,6 @@ static struct rastpos_stage *
 new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw)
 {
struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
-   GLuint i;
-   GLuint elementSize;
 
rs->stage.draw = draw;
rs->stage.next = NULL;
@@ -196,20 +196,11 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct 
draw_context *draw)
rs->stage.destroy = rastpos_destroy;
rs->ctx = ctx;
 
-   rs->binding.Stride = 0;
-   rs->binding.BufferObj = NULL;
-
-   elementSize = _mesa_bytes_per_vertex_attrib(4, GL_FLOAT);
-   for (i = 0; i < ARRAY_SIZE(rs->array); i++) {
-  rs->attrib[i].Size = 4;
-  rs->attrib[i].Type = GL_FLOAT;
-  rs->attrib[i].Format = GL_RGBA;
-  rs->attrib[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
-  rs->attrib[i].Normalized = GL_TRUE;
-  rs->attrib[i]._ElementSize = elementSize;
-  rs->array[i].BufferBinding = &rs->binding;
-  rs->array[i].VertexAttrib = &rs->attrib[i];
-   }
+   rs->VAO = _mesa_new_vao(ctx, ~((GLuint)0));
+   _mesa_vertex_attrib_binding(ctx, rs->VAO, VERT_ATTRIB_POS, 0, false);
+   _mesa_update_array_format(ctx, rs->VAO, VERT_ATTRIB_POS, 4, GL_FLOAT,
+ GL_RGBA, GL_FALSE, GL_FALSE, GL_FALSE, 0);
+   _mesa_enable_vertex_array_attrib(ctx, rs->VAO, 0, false);
 
rs->prim.mode = GL_POINTS;
rs->prim.indexed = 0;
@@ -229,7 +220,6 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
struct st_context *st = st_context(ctx);
struct draw_context *draw = st_get_draw_context(st);
struct rastpos_stage *rs;
-   const struct gl_vertex_array *saved_arrays = ctx->Array._DrawArrays;
 
if (!st->draw)
   return;
@@ -265,16 +255,13 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
/* All vertex attribs but position were previously initialized above.
 * Just plug in position pointer now.
 */
-   rs->attrib[0].Ptr = (GLubyte *) v;
+   rs->VAO->VertexAttrib[VERT_ATTRIB_POS].Ptr = (GLubyte *) v;
+   rs->VAO->NewArrays |= VERT_BIT_POS;
+   _mesa_set_draw_vao(ctx, rs->VAO, VERT_BIT_POS);
 
-   /* Draw the point.
-*
-* Don't set DriverFlags.NewArray.
-* st_feedback_draw_vbo doesn't check for that flag. */
-   ctx->Array._DrawArrays = rs->array;
+   /* Draw the point. */
st_feedback_draw_vbo(ctx, &rs->prim, 1, NULL, GL_TRUE, 0, 1,
 NULL, 0, NULL);
-   ctx->Array._DrawArrays = saved_arrays;
 
/* restore draw's rasterization stage depending on rendermode */
if (ctx->RenderMode == GL_FEEDBACK) {
diff --git a/src/mesa/state_tracker/st_draw_feedback.c 
b/src/mesa/state_tracker/st_draw_feedback.c
index fa96b4e2e2..eb05ac9669 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/s

Mesa (master): st/mesa: Remove the now unused gl_vertex_array.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 79eb6ab7b6dc187baa2837d90b3608c6b7a5f366
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=79eb6ab7b6dc187baa2837d90b3608c6b7a5f366

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

st/mesa: Remove the now unused gl_vertex_array.

Was meant to be temporary in gallium.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_cb_feedback.c | 32 ++--
 src/mesa/state_tracker/st_context.c |  3 ---
 src/mesa/state_tracker/st_context.h |  3 ---
 src/mesa/state_tracker/st_draw.c|  8 
 4 files changed, 2 insertions(+), 44 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_feedback.c 
b/src/mesa/state_tracker/st_cb_feedback.c
index b7a082fca3..6e48be6f5d 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -273,34 +273,6 @@ draw_glselect_stage(struct gl_context *ctx, struct 
draw_context *draw)
 
 
 static void
-feedback_draw_vbo(struct gl_context *ctx,
-  const struct _mesa_prim *prims,
-  GLuint nr_prims,
-  const struct _mesa_index_buffer *ib,
-  GLboolean index_bounds_valid,
-  GLuint min_index,
-  GLuint max_index,
-  struct gl_transform_feedback_object *tfb_vertcount,
-  unsigned stream,
-  struct gl_buffer_object *indirect)
-{
-   struct st_context *st = st_context(ctx);
-
-   /* The initial pushdown of the inputs array into the drivers */
-   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
-   _vbo_update_inputs(ctx, &st->draw_arrays);
-
-   /* The above needs to happen outside of st_feedback_draw_vbo,
-* since st_RasterPossets _DrawArrays and does not want that to be
-* overwritten by _mesa_set_drawing_arrays.
-*/
-   st_feedback_draw_vbo(ctx, prims, nr_prims, ib, index_bounds_valid,
-min_index, max_index, tfb_vertcount,
-stream, indirect);
-}
-
-
-static void
 st_RenderMode(struct gl_context *ctx, GLenum newMode )
 {
struct st_context *st = st_context(ctx);
@@ -318,7 +290,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
  st->selection_stage = draw_glselect_stage(ctx, draw);
   draw_set_rasterize_stage(draw, st->selection_stage);
   /* Plug in new vbo draw function */
-  ctx->Driver.Draw = feedback_draw_vbo;
+  ctx->Driver.Draw = st_feedback_draw_vbo;
}
else {
   struct gl_program *vp = st->ctx->VertexProgram._Current;
@@ -327,7 +299,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
  st->feedback_stage = draw_glfeedback_stage(ctx, draw);
   draw_set_rasterize_stage(draw, st->feedback_stage);
   /* Plug in new vbo draw function */
-  ctx->Driver.Draw = feedback_draw_vbo;
+  ctx->Driver.Draw = st_feedback_draw_vbo;
   /* need to generate/use a vertex program that emits pos/color/tex */
   if (vp)
  st->dirty |= ST_NEW_VERTEX_PROGRAM(st, st_vertex_program(vp));
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index ee76e07a7d..061b8b9c4c 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -552,9 +552,6 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
/* Initialize context's winsys buffers list */
LIST_INITHEAD(&st->winsys_buffers);
 
-   /* Keep our list of gl_vertex_array inputs */
-   _vbo_init_inputs(&st->draw_arrays);
-
return st;
 }
 
diff --git a/src/mesa/state_tracker/st_context.h 
b/src/mesa/state_tracker/st_context.h
index 5125fc5839..9f5bfba3fd 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -295,9 +295,6 @@ struct st_context
 
/* Winsys buffers */
struct list_head winsys_buffers;
-
-   /* For the initial pushdown, keep the list of vbo inputs. */
-   struct vbo_inputs draw_arrays;
 };
 
 
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 6243659b50..12cae85f40 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -146,10 +146,6 @@ st_draw_vbo(struct gl_context *ctx,
unsigned i;
unsigned start = 0;
 
-   /* The initial pushdown of the inputs array into the drivers */
-   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
-   _vbo_update_inputs(ctx, &st->draw_arrays);
-
prepare_draw(st, ctx);
 
if (st->vertex_array_out_of_memory)
@@ -255,10 +251,6 @@ st_indirect_draw_vbo(struct gl_context *ctx,
struct pipe_draw_info info;
struct pipe_draw_indirect_info indirect;
 
-   /* The initial pushdown of the inputs array into the drivers */
-   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
-   _vbo_update

Mesa (master): mesa: Compute effective buffer bindings in the vao.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: d1698d4311a63e1054e458ae1a27d7684595faee
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d1698d4311a63e1054e458ae1a27d7684595faee

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

mesa: Compute effective buffer bindings in the vao.

Compute VAO buffer binding information past the position/generic0 mapping.
Scan for duplicate buffer bindings and collapse them into derived
effective buffer binding index and effective attribute mask variables.
Provide a set of helper functions to access the distilled
information in the VAO. All of them prefixed with _mesa_draw_...
to indicate that they are meant to query draw information.

v2: Also group user space arrays containing interleaved arrays.
Add _Eff*Offset to be copied on attribute and binding copy.
Update comments.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/arrayobj.c   | 390 -
 src/mesa/main/arrayobj.h   | 186 +
 src/mesa/main/attrib.c |   1 +
 src/mesa/main/mtypes.h |  64 
 src/mesa/main/varray.c |   9 ++
 src/mesa/vbo/vbo.h |   8 +
 src/mesa/vbo/vbo_context.c |  17 ++
 src/mesa/vbo/vbo_private.h |  14 +-
 8 files changed, 682 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 899d4dec01..05af50ef40 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -451,8 +451,116 @@ _mesa_initialize_vao(struct gl_context *ctx,
 
 
 /**
- * Updates the derived gl_vertex_arrays when a gl_array_attributes
- * or a gl_vertex_buffer_binding has changed.
+ * Compute the offset range for the provided binding.
+ *
+ * This is a helper function for the below.
+ */
+static void
+compute_vbo_offset_range(const struct gl_vertex_array_object *vao,
+ const struct gl_vertex_buffer_binding *binding,
+ GLsizeiptr* min, GLsizeiptr* max)
+{
+   /* The function is meant to work on VBO bindings */
+   assert(_mesa_is_bufferobj(binding->BufferObj));
+
+   /* Start with an inverted range of relative offsets. */
+   GLuint min_offset = ~(GLuint)0;
+   GLuint max_offset = 0;
+
+   /* We work on the unmapped originaly VAO array entries. */
+   GLbitfield mask = vao->_Enabled & binding->_BoundArrays;
+   /* The binding should be active somehow, not to return inverted ranges */
+   assert(mask);
+   while (mask) {
+  const int i = u_bit_scan(&mask);
+  const GLuint off = vao->VertexAttrib[i].RelativeOffset;
+  min_offset = MIN2(off, min_offset);
+  max_offset = MAX2(off, max_offset);
+   }
+
+   *min = binding->Offset + (GLsizeiptr)min_offset;
+   *max = binding->Offset + (GLsizeiptr)max_offset;
+}
+
+
+/**
+ * Update the unique binding and pos/generic0 map tracking in the vao.
+ *
+ * The idea is to build up information in the vao so that a consuming
+ * backend can execute the following to set up buffer and vertex element
+ * information:
+ *
+ * const GLbitfield inputs_read = VERT_BIT_ALL; // backend vp inputs
+ *
+ * // Attribute data is in a VBO.
+ * GLbitfield vbomask = inputs_read & _mesa_draw_vbo_array_bits(ctx);
+ * while (vbomask) {
+ *// The attribute index to start pulling a binding
+ *const gl_vert_attrib i = ffs(vbomask) - 1;
+ *const struct gl_vertex_buffer_binding *const binding
+ *   = _mesa_draw_buffer_binding(vao, i);
+ *
+ *
+ *
+ *const GLbitfield boundmask = _mesa_draw_bound_attrib_bits(binding);
+ *GLbitfield attrmask = vbomask & boundmask;
+ *assert(attrmask);
+ *// Walk attributes belonging to the binding
+ *while (attrmask) {
+ *   const gl_vert_attrib attr = u_bit_scan(&attrmask);
+ *   const struct gl_array_attributes *const attrib
+ *  = _mesa_draw_array_attrib(vao, attr);
+ *
+ *   
+ *}
+ *vbomask &= ~boundmask;
+ * }
+ *
+ * // Process user space buffers
+ * GLbitfield usermask = inputs_read & _mesa_draw_user_array_bits(ctx);
+ * while (usermask) {
+ *// The attribute index to start pulling a binding
+ *const gl_vert_attrib i = ffs(usermask) - 1;
+ *const struct gl_vertex_buffer_binding *const binding
+ *   = _mesa_draw_buffer_binding(vao, i);
+ *
+ *
+ *
+ *const GLbitfield boundmask = _mesa_draw_bound_attrib_bits(binding);
+ *GLbitfield attrmask = usermask & boundmask;
+ *assert(attrmask);
+ *// Walk interleaved attributes with a common stride and instance divisor
+ *while (attrmask) {
+ *   const gl_vert_attrib attr = u_bit_scan(&attrmask);
+ *   const struct gl_array_attributes *const attrib
+ *  = _mesa_draw_array_attrib(vao, attr);
+ *
+ *   
+ *}
+ *usermask &= ~boundmask;
+ * }
+ *
+ * // Process values that should have better been uniforms in the application
+ * GLbitfield curmask = inputs_read & _mesa_draw_current_bits(ctx);
+ * w

Mesa (master): i965: Remove the now unused gl_vertex_array.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 899476b6b1d41c5ed08391843110c7d62b2ca863
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=899476b6b1d41c5ed08391843110c7d62b2ca863

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

i965: Remove the now unused gl_vertex_array.

Was meant to be temporary in i965.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/i965/brw_context.h | 4 
 src/mesa/drivers/dri/i965/brw_draw.c| 7 ---
 2 files changed, 11 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index d3c2450a88..7dcbd040f0 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -37,7 +37,6 @@
 #include "main/macros.h"
 #include "main/mtypes.h"
 #include "main/errors.h"
-#include "vbo/vbo.h"
 #include "brw_structs.h"
 #include "brw_pipe_control.h"
 #include "compiler/brw_compiler.h"
@@ -966,9 +965,6 @@ struct brw_context
* These bitfields indicate which workarounds are needed.
*/
   uint8_t attrib_wa_flags[VERT_ATTRIB_MAX];
-
-  /* For the initial pushdown, keep the list of vbo inputs. */
-  struct vbo_inputs draw_arrays;
} vb;
 
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 3b47dc7b26..ae3b7be2dd 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -936,10 +936,6 @@ brw_draw_prims(struct gl_context *ctx,
struct brw_transform_feedback_object *xfb_obj =
   (struct brw_transform_feedback_object *) gl_xfb_obj;
 
-   /* The initial pushdown of the inputs array into the drivers */
-   _mesa_set_drawing_arrays(ctx, brw->vb.draw_arrays.inputs);
-   _vbo_update_inputs(ctx, &brw->vb.draw_arrays);
-
if (!brw_check_conditional_render(brw))
   return;
 
@@ -1078,9 +1074,6 @@ brw_init_draw_functions(struct dd_function_table 
*functions)
 void
 brw_draw_init(struct brw_context *brw)
 {
-   /* Keep our list of gl_vertex_array inputs */
-   _vbo_init_inputs(&brw->vb.draw_arrays);
-
for (int i = 0; i < VERT_ATTRIB_MAX; i++)
   brw->vb.inputs[i].buffer = -1;
brw->vb.nr_buffers = 0;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): i965: Implement all_varyings_in_vbos in terms of Array._DrawVAO.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 172c9a908f7d6405b41ff2a0087169ec83a3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=172c9a908f7d6405b41ff2a0087169ec83a3

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

i965: Implement all_varyings_in_vbos in terms of Array._DrawVAO.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/i965/brw_draw.c | 17 ++---
 1 file changed, 2 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 25ba372c44..c5f04264fa 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -25,6 +25,7 @@
 
 #include 
 
+#include "main/arrayobj.h"
 #include "main/blend.h"
 #include "main/context.h"
 #include "main/condrender.h"
@@ -917,20 +918,6 @@ retry:
 }
 
 
-static bool
-all_varyings_in_vbos(const struct gl_vertex_array *arrays)
-{
-   GLuint i;
-
-   for (i = 0; i < VERT_ATTRIB_MAX; i++)
-  if (arrays[i].BufferBinding->Stride &&
-  arrays[i].BufferBinding->BufferObj->Name == 0)
- return false;
-
-   return true;
-}
-
-
 
 void
 brw_draw_prims(struct gl_context *ctx,
@@ -982,7 +969,7 @@ brw_draw_prims(struct gl_context *ctx,
 * get the minimum and maximum of their index buffer so we know what range
 * to upload.
 */
-   if (!index_bounds_valid && !all_varyings_in_vbos(arrays)) {
+   if (!index_bounds_valid && _mesa_draw_user_array_bits(ctx) != 0) {
   perf_debug("Scanning index buffer to compute index buffer bounds.  "
  "Use glDrawRangeElements() to avoid this.\n");
   vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa/vbo/tnl: Move gl_vertex_array related stuff to tnl.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: f6606830271192dc0232b54b776ec263235c0688
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f6606830271192dc0232b54b776ec263235c0688

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

mesa/vbo/tnl: Move gl_vertex_array related stuff to tnl.

The only remaining users of gl_vertex_array are tnl based
drivers. So move everything related to that into tnl and
rename it accordingly.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 38 +--
 src/mesa/main/mtypes.h   | 14 
 src/mesa/main/varray.h   | 12 
 src/mesa/state_tracker/st_draw.h |  1 -
 src/mesa/tnl/t_context.c |  4 +-
 src/mesa/tnl/t_context.h | 41 +++-
 src/mesa/tnl/t_draw.c| 95 ++--
 src/mesa/tnl/t_rebase.c  |  4 +-
 src/mesa/tnl/t_rebase.h  |  2 +-
 src/mesa/tnl/t_split.c   |  2 +-
 src/mesa/tnl/t_split.h   |  4 +-
 src/mesa/tnl/t_split_copy.c  | 34 ++
 src/mesa/tnl/t_split_inplace.c   |  4 +-
 src/mesa/tnl/tnl.h   | 24 +--
 src/mesa/vbo/vbo.h   | 37 ---
 src/mesa/vbo/vbo_exec.c  | 86 -
 16 files changed, 199 insertions(+), 203 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index d031ebeabd..3900c770cb 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -41,7 +41,7 @@
  * structures. */
 
 static int
-get_array_stride(struct gl_context *ctx, const struct gl_vertex_array *a)
+get_array_stride(struct gl_context *ctx, const struct tnl_vertex_array *a)
 {
struct nouveau_render_state *render = to_render_state(ctx);
const struct gl_vertex_buffer_binding *binding = a->BufferBinding;
@@ -57,7 +57,7 @@ get_array_stride(struct gl_context *ctx, const struct 
gl_vertex_array *a)
 
 static void
 vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
-   const struct gl_vertex_array *arrays)
+   const struct tnl_vertex_array *arrays)
 {
struct nouveau_render_state *render = to_render_state(ctx);
GLboolean imm = (render->mode == IMM);
@@ -78,7 +78,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct 
_mesa_index_buffer *ib,
}
 
FOR_EACH_BOUND_ATTR(render, i, attr) {
-   const struct gl_vertex_array *array = &arrays[attr];
+   const struct tnl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding =
array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
@@ -94,7 +94,7 @@ vbo_init_arrays(struct gl_context *ctx, const struct 
_mesa_index_buffer *ib,
 
 static void
 vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
- const struct gl_vertex_array *arrays)
+ const struct tnl_vertex_array *arrays)
 {
struct nouveau_render_state *render = to_render_state(ctx);
int i, attr;
@@ -118,7 +118,7 @@ vbo_deinit_arrays(struct gl_context *ctx, const struct 
_mesa_index_buffer *ib,
 /* Make some rendering decisions from the GL context. */
 
 static void
-vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array 
*arrays)
+vbo_choose_render_mode(struct gl_context *ctx, const struct tnl_vertex_array 
*arrays)
 {
struct nouveau_render_state *render = to_render_state(ctx);
int i;
@@ -136,12 +136,12 @@ vbo_choose_render_mode(struct gl_context *ctx, const 
struct gl_vertex_array *arr
 }
 
 static void
-vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array *arrays,
+vbo_emit_attr(struct gl_context *ctx, const struct tnl_vertex_array *arrays,
  int attr)
 {
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_render_state *render = to_render_state(ctx);
-   const struct gl_vertex_array *array = &arrays[attr];
+   const struct tnl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
@@ -179,7 +179,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct 
gl_vertex_array *arrays,
 #define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a)
 
 static void
-vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array *arrays)
+vbo_choose_attrs(struct gl_context *ctx, const struct tnl_vertex_array *arrays)
 {
s

Mesa (master): i965: Remove the gl_vertex_array indirection.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 0fabd5530623bb7b6a13ce35c24b665d3661f76f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0fabd5530623bb7b6a13ce35c24b665d3661f76f

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

i965: Remove the gl_vertex_array indirection.

For now store binding and attrib in brw_vertex_element.
The i965 driver still provides lots of opportunity to make use
of the unique binding information in the VAO which is currently not
taken from the VAO.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/i965/brw_context.h   |  3 ++-
 src/mesa/drivers/dri/i965/brw_draw.c  | 25 +
 src/mesa/drivers/dri/i965/brw_draw_upload.c   | 31 +--
 src/mesa/drivers/dri/i965/genX_state_upload.c | 12 ---
 4 files changed, 31 insertions(+), 40 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index d8b0d94aaf..d3c2450a88 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -440,7 +440,8 @@ struct brw_vertex_buffer {
GLuint step_rate;
 };
 struct brw_vertex_element {
-   const struct gl_vertex_array *glarray;
+   const struct gl_array_attributes *glattrib;
+   const struct gl_vertex_buffer_binding *glbinding;
 
int buffer;
bool is_dual_slot;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index c5f04264fa..3b47dc7b26 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -278,8 +278,7 @@ brw_emit_prim(struct brw_context *brw,
 
 
 static void
-brw_merge_inputs(struct brw_context *brw,
- const struct gl_vertex_array *arrays)
+brw_merge_inputs(struct brw_context *brw)
 {
const struct gen_device_info *devinfo = &brw->screen->devinfo;
const struct gl_context *ctx = &brw->ctx;
@@ -292,8 +291,10 @@ brw_merge_inputs(struct brw_context *brw,
brw->vb.nr_buffers = 0;
 
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
-  brw->vb.inputs[i].buffer = -1;
-  brw->vb.inputs[i].glarray = &arrays[i];
+  struct brw_vertex_element *input = &brw->vb.inputs[i];
+  input->buffer = -1;
+  _mesa_draw_attrib_and_binding(ctx, i,
+&input->glattrib, &input->glbinding);
}
 
if (devinfo->gen < 8 && !devinfo->is_haswell) {
@@ -306,7 +307,7 @@ brw_merge_inputs(struct brw_context *brw,
  uint8_t wa_flags = 0;
 
  i = u_bit_scan64(&mask);
- glattrib = brw->vb.inputs[i].glarray->VertexAttrib;
+ glattrib = brw->vb.inputs[i].glattrib;
 
  switch (glattrib->Type) {
 
@@ -693,7 +694,6 @@ brw_postdraw_reconcile_align_wa_slices(struct brw_context 
*brw)
 
 static void
 brw_prepare_drawing(struct gl_context *ctx,
-const struct gl_vertex_array *arrays,
 const struct _mesa_index_buffer *ib,
 bool index_bounds_valid,
 GLuint min_index,
@@ -746,7 +746,7 @@ brw_prepare_drawing(struct gl_context *ctx,
 
/* Bind all inputs, derive varying and size information:
 */
-   brw_merge_inputs(brw, arrays);
+   brw_merge_inputs(brw);
 
brw->ib.ib = ib;
brw->ctx.NewDriverState |= BRW_NEW_INDICES;
@@ -780,7 +780,6 @@ brw_finish_drawing(struct gl_context *ctx)
  */
 static void
 brw_draw_single_prim(struct gl_context *ctx,
- const struct gl_vertex_array *arrays,
  const struct _mesa_prim *prim,
  unsigned prim_id,
  struct brw_transform_feedback_object *xfb_obj,
@@ -811,7 +810,7 @@ brw_draw_single_prim(struct gl_context *ctx,
   brw->baseinstance = prim->base_instance;
   if (prim_id > 0) { /* For i == 0 we just did this before the loop */
  brw->ctx.NewDriverState |= BRW_NEW_VERTICES;
- brw_merge_inputs(brw, arrays);
+ brw_merge_inputs(brw);
   }
}
 
@@ -933,14 +932,12 @@ brw_draw_prims(struct gl_context *ctx,
 {
unsigned i;
struct brw_context *brw = brw_context(ctx);
-   const struct gl_vertex_array *arrays;
int predicate_state = brw->predicate.state;
struct brw_transform_feedback_object *xfb_obj =
   (struct brw_transform_feedback_object *) gl_xfb_obj;
 
/* The initial pushdown of the inputs array into the drivers */
_mesa_set_drawing_arrays(ctx, brw->vb.draw_arrays.inputs);
-   arrays = ctx->Array._DrawArrays;
_vbo_update_inputs(ctx, &brw->vb.draw_arrays);
 
if (!brw_check_conditional_render(brw))
@@ -976,8 +973,7 @@ brw_draw_prims(struct gl_context *ctx,
   index_bounds_valid = true;
}
 
-   brw_prepare_drawing(ctx, arrays, ib, index_bounds_valid, min_index,
-   max_index);
+   brw_prepare_drawing(ctx, ib, index_bounds

Mesa (master): st/mesa: Use _DrawVAO for edgeflag enabled check.

2018-05-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: f24bf4521023658012b2636a24cf2387fd55695a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f24bf4521023658012b2636a24cf2387fd55695a

Author: Mathias Fröhlich 
Date:   Sun Apr  1 20:18:36 2018 +0200

st/mesa: Use _DrawVAO for edgeflag enabled check.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_atom.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index 45a45960a3..df1a94e831 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -27,6 +27,7 @@
 
 
 #include 
+#include "main/arrayobj.h"
 #include "main/glheader.h"
 #include "main/context.h"
 
@@ -138,19 +139,15 @@ static void check_program_state( struct st_context *st )
 
 static void check_attrib_edgeflag(struct st_context *st)
 {
-   const struct gl_vertex_array *arrays = st->ctx->Array._DrawArrays;
-   const struct gl_vertex_buffer_binding *binding;
GLboolean vertdata_edgeflags, edgeflag_culls_prims, edgeflags_enabled;
struct gl_program *vp = st->ctx->VertexProgram._Current;
 
-   if (!arrays)
-  return;
-
edgeflags_enabled = st->ctx->Polygon.FrontMode != GL_FILL ||
st->ctx->Polygon.BackMode != GL_FILL;
 
-   binding = arrays[VERT_ATTRIB_EDGEFLAG].BufferBinding;
-   vertdata_edgeflags = edgeflags_enabled && binding->Stride != 0;
+   vertdata_edgeflags = edgeflags_enabled &&
+  _mesa_draw_edge_flag_array_enabled(st->ctx);
+
if (vertdata_edgeflags != st->vertdata_edgeflags) {
   st->vertdata_edgeflags = vertdata_edgeflags;
   if (vp)

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): tnl: Push down the gl_vertex_array inputs into tnl drivers.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 784fdef4e7d6055eafe8a3e8e149a64d3ca5e5f6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=784fdef4e7d6055eafe8a3e8e149a64d3ca5e5f6

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

tnl: Push down the gl_vertex_array inputs into tnl drivers.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/i915/intel_context.c  |  1 +
 src/mesa/drivers/dri/i965/brw_draw.c   |  4 +--
 src/mesa/drivers/dri/nouveau/nouveau_context.c |  1 +
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c   | 21 -
 src/mesa/drivers/dri/r200/r200_context.c   |  1 +
 src/mesa/drivers/dri/radeon/radeon_context.c   |  1 +
 src/mesa/drivers/dri/swrast/swrast.c   |  1 +
 src/mesa/drivers/osmesa/osmesa.c   |  1 +
 src/mesa/drivers/x11/xm_api.c  |  1 +
 src/mesa/tnl/t_context.c   |  6 ++--
 src/mesa/tnl/t_context.h   |  3 ++
 src/mesa/tnl/t_draw.c  | 42 --
 src/mesa/tnl/tnl.h | 14 +
 13 files changed, 88 insertions(+), 9 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_context.c 
b/src/mesa/drivers/dri/i915/intel_context.c
index 96d09ca947..f22ebbd7ac 100644
--- a/src/mesa/drivers/dri/i915/intel_context.c
+++ b/src/mesa/drivers/dri/i915/intel_context.c
@@ -380,6 +380,7 @@ void
 intelInitDriverFunctions(struct dd_function_table *functions)
 {
_mesa_init_driver_functions(functions);
+   _tnl_init_driver_draw_function(functions);
 
functions->Flush = intel_glFlush;
functions->Finish = intelFinish;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 5f52404bd6..4caaadd560 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -969,8 +969,8 @@ brw_draw_prims(struct gl_context *ctx,
  _mesa_enum_to_string(ctx->RenderMode));
   _swsetup_Wakeup(ctx);
   _tnl_wakeup(ctx);
-  _tnl_draw_prims(ctx, prims, nr_prims, ib,
-  index_bounds_valid, min_index, max_index, NULL, 0, NULL);
+  _tnl_draw(ctx, prims, nr_prims, ib,
+index_bounds_valid, min_index, max_index, NULL, 0, NULL);
   return;
}
 
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_context.c 
b/src/mesa/drivers/dri/nouveau/nouveau_context.c
index 5fab81d866..93f6ce473a 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_context.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_context.c
@@ -119,6 +119,7 @@ nouveau_context_init(struct gl_context *ctx, gl_api api,
 
/* Initialize the function pointers. */
_mesa_init_driver_functions(&functions);
+   _tnl_init_driver_draw_function(&functions);
nouveau_driver_functions_init(&functions);
nouveau_bufferobj_functions_init(&functions);
nouveau_texture_functions_init(&functions);
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index a7b911c50e..10b5c15e41 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -537,6 +537,24 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
tfb_vertcount, stream, indirect);
 }
 
+static void
+TAG(vbo_draw)(struct gl_context *ctx,
+ const struct _mesa_prim *prims, GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLboolean index_bounds_valid,
+ GLuint min_index, GLuint max_index,
+ struct gl_transform_feedback_object *tfb_vertcount,
+ unsigned stream,
+ struct gl_buffer_object *indirect)
+{
+   /* Borrow and update the inputs list from the tnl context */
+   _tnl_bind_inputs(ctx);
+
+   TAG(vbo_check_render_prims)(ctx, prims, nr_prims, ib,
+   index_bounds_valid, min_index, max_index,
+   tfb_vertcount, stream, indirect);
+}
+
 void
 TAG(vbo_init)(struct gl_context *ctx)
 {
@@ -546,7 +564,8 @@ TAG(vbo_init)(struct gl_context *ctx)
for (i = 0; i < VERT_ATTRIB_MAX; i++)
render->map[i] = -1;
 
-   vbo_set_draw_func(ctx, TAG(vbo_check_render_prims));
+   /* Overwrite our draw function */
+   ctx->Driver.Draw = TAG(vbo_draw);
vbo_use_buffer_objects(ctx);
 }
 
diff --git a/src/mesa/drivers/dri/r200/r200_context.c 
b/src/mesa/drivers/dri/r200/r200_context.c
index eb7d92f3c6..4524f06d10 100644
--- a/src/mesa/drivers/dri/r200/r200_context.c
+++ b/src/mesa/drivers/dri/r200/r200_context.c
@@ -227,6 +227,7 @@ GLboolean r200CreateContext( gl_api api,
 * (the texture functions are especially important)
 */
_mesa_init_driver_functions(&functions);
+   _tnl_init_driver_draw_function(&functions);
r200InitDriverFuncs(

Mesa (master): vbo: Remove the now unused vbo draw path.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 461698af267f8001aa339c8ca1aec937083ad8fb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=461698af267f8001aa339c8ca1aec937083ad8fb

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Remove the now unused vbo draw path.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/common/driverfuncs.c |  2 +-
 src/mesa/main/state.c | 12 ++---
 src/mesa/vbo/vbo.h| 20 ---
 src/mesa/vbo/vbo_context.c| 47 ---
 src/mesa/vbo/vbo_exec.c   |  8 --
 src/mesa/vbo/vbo_exec.h   |  4 ---
 src/mesa/vbo/vbo_private.h|  7 --
 7 files changed, 3 insertions(+), 97 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 2ddfdb5efa..11134b69e9 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -121,7 +121,7 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
driver->NewATIfs = NULL;
 
/* Draw functions */
-   driver->Draw = _vbo_draw;
+   driver->Draw = NULL;
driver->DrawIndirect = _vbo_draw_indirect;
 
/* simple state commands */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index fb97165db9..be8f3f302c 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -459,21 +459,13 @@ _mesa_set_vp_override(struct gl_context *ctx, GLboolean 
flag)
 
 
 static void
-set_new_array(struct gl_context *ctx)
-{
-   _vbo_set_recalculate_inputs(ctx);
-   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
-}
-
-
-static void
 set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m)
 {
if (ctx->VertexProgram._VPMode == m)
   return;
 
/* On change we may get new maps into the current values */
-   set_new_array(ctx);
+   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 
/* Finally memorize the value */
ctx->VertexProgram._VPMode = m;
@@ -532,7 +524,7 @@ _mesa_set_draw_vao(struct gl_context *ctx, struct 
gl_vertex_array_object *vao,
   new_array = true;
 
if (new_array)
-  set_new_array(ctx);
+  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 
ctx->Array._DrawVAOEnabledAttribs = enabled;
_mesa_set_varying_vp_inputs(ctx, enabled);
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index db136f9445..13f77d9db3 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -187,14 +187,6 @@ struct split_limits
 
 
 void
-_vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
-   GLuint nr_prims, const struct _mesa_index_buffer *ib,
-   GLboolean index_bounds_valid, GLuint min_index, GLuint 
max_index,
-   struct gl_transform_feedback_object *tfb_vertcount,
-   unsigned tfb_stream, struct gl_buffer_object *indirect);
-
-
-void
 _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
 struct gl_buffer_object *indirect_data,
 GLsizeiptr indirect_offset, unsigned draw_count,
@@ -231,9 +223,6 @@ void
 vbo_always_unmap_buffers(struct gl_context *ctx);
 
 void
-vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
-
-void
 vbo_sw_primitive_restart(struct gl_context *ctx,
  const struct _mesa_prim *prim,
  GLuint nr_prims,
@@ -261,15 +250,6 @@ struct vbo_inputs
 
 
 /**
- * Set the recalculate_inputs flag.
- * The method should in the longer run be replaced with listening for the
- * DriverFlags.NewArray flag in NewDriverState. But for now ...
- */
-void
-_vbo_set_recalculate_inputs(struct gl_context *ctx);
-
-
-/**
  * Initialize inputs.
  */
 void
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 54cbab0c14..b8c28ceffb 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -186,7 +186,6 @@ _vbo_CreateContext(struct gl_context *ctx)
init_legacy_currval(ctx);
init_generic_currval(ctx);
init_mat_currval(ctx);
-   _vbo_init_inputs(&vbo->draw_arrays);
 
/* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
@@ -235,52 +234,6 @@ _vbo_DestroyContext(struct gl_context *ctx)
 
 
 void
-vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   vbo->draw_prims = func;
-}
-
-
-/**
- * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
- * These will point to the arrays to actually use for drawing.  Some will
- * be user-provided arrays, other will be zero-stride const-valued arrays.
- */
-static void
-vbo_bind_arrays(struct gl_context *ctx)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
-
-   _mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
-
-

Mesa (master): vbo: Remove unused includes to vbo_private.h

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 3f1cd957d30ed77d8d18f37885de921247f5377d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f1cd957d30ed77d8d18f37885de921247f5377d

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Remove unused includes to vbo_private.h

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec_array.c| 2 --
 src/mesa/vbo/vbo_primitive_restart.c | 1 -
 2 files changed, 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 51fd434dc4..b3ce138a09 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -39,8 +39,6 @@
 #include "main/macros.h"
 #include "main/transformfeedback.h"
 
-#include "vbo_private.h"
-
 
 /**
  * Check that element 'j' of the array has reasonable data.
diff --git a/src/mesa/vbo/vbo_primitive_restart.c 
b/src/mesa/vbo/vbo_primitive_restart.c
index 699b566dca..f170347fbe 100644
--- a/src/mesa/vbo/vbo_primitive_restart.c
+++ b/src/mesa/vbo/vbo_primitive_restart.c
@@ -33,7 +33,6 @@
 #include "main/varray.h"
 
 #include "vbo.h"
-#include "vbo_private.h"
 
 
 #define UPDATE_MIN2(a, b) (a) = MIN2((a), (b))

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): gallium: Push down the gl_vertex_array inputs into gallium.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: fca1550550793f0a1156ad795445e2242c1fea9b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fca1550550793f0a1156ad795445e2242c1fea9b

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

gallium: Push down the gl_vertex_array inputs into gallium.

Let the gallium backend have its own gl_vertex_array array and basically
reimplement the way _vbo_draw works.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_cb_feedback.c | 35 ++---
 src/mesa/state_tracker/st_context.c |  9 -
 src/mesa/state_tracker/st_context.h |  4 
 src/mesa/state_tracker/st_draw.c| 16 ++-
 src/mesa/state_tracker/st_draw.h|  2 +-
 5 files changed, 52 insertions(+), 14 deletions(-)

diff --git a/src/mesa/state_tracker/st_cb_feedback.c 
b/src/mesa/state_tracker/st_cb_feedback.c
index 436062b1f8..b7a082fca3 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -40,6 +40,7 @@
 #include "main/imports.h"
 #include "main/context.h"
 #include "main/feedback.h"
+#include "main/varray.h"
 
 #include "vbo/vbo.h"
 
@@ -272,6 +273,34 @@ draw_glselect_stage(struct gl_context *ctx, struct 
draw_context *draw)
 
 
 static void
+feedback_draw_vbo(struct gl_context *ctx,
+  const struct _mesa_prim *prims,
+  GLuint nr_prims,
+  const struct _mesa_index_buffer *ib,
+  GLboolean index_bounds_valid,
+  GLuint min_index,
+  GLuint max_index,
+  struct gl_transform_feedback_object *tfb_vertcount,
+  unsigned stream,
+  struct gl_buffer_object *indirect)
+{
+   struct st_context *st = st_context(ctx);
+
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, st->draw_arrays.inputs);
+   _vbo_update_inputs(ctx, &st->draw_arrays);
+
+   /* The above needs to happen outside of st_feedback_draw_vbo,
+* since st_RasterPossets _DrawArrays and does not want that to be
+* overwritten by _mesa_set_drawing_arrays.
+*/
+   st_feedback_draw_vbo(ctx, prims, nr_prims, ib, index_bounds_valid,
+min_index, max_index, tfb_vertcount,
+stream, indirect);
+}
+
+
+static void
 st_RenderMode(struct gl_context *ctx, GLenum newMode )
 {
struct st_context *st = st_context(ctx);
@@ -282,14 +311,14 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
 
if (newMode == GL_RENDER) {
   /* restore normal VBO draw function */
-  st_init_draw(st);
+  st_init_draw_functions(&ctx->Driver);
}
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);
+  ctx->Driver.Draw = feedback_draw_vbo;
}
else {
   struct gl_program *vp = st->ctx->VertexProgram._Current;
@@ -298,7 +327,7 @@ st_RenderMode(struct gl_context *ctx, GLenum newMode )
  st->feedback_stage = draw_glfeedback_stage(ctx, draw);
   draw_set_rasterize_stage(draw, st->feedback_stage);
   /* Plug in new vbo draw function */
-  vbo_set_draw_func(ctx, st_feedback_draw_vbo);
+  ctx->Driver.Draw = feedback_draw_vbo;
   /* need to generate/use a vertex program that emits pos/color/tex */
   if (vp)
  st->dirty |= ST_NEW_VERTEX_PROGRAM(st, st_vertex_program(vp));
diff --git a/src/mesa/state_tracker/st_context.c 
b/src/mesa/state_tracker/st_context.c
index 90b7f9359a..a3da0f8f1f 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -382,7 +382,6 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
 
st_init_atoms(st);
st_init_clear(st);
-   st_init_draw(st);
st_init_pbo_helpers(st);
 
/* Choose texture target for glDrawPixels, glBitmap, renderbuffers */
@@ -551,6 +550,9 @@ st_create_context_priv(struct gl_context *ctx, struct 
pipe_context *pipe,
/* Initialize context's winsys buffers list */
LIST_INITHEAD(&st->winsys_buffers);
 
+   /* Keep our list of gl_vertex_array inputs */
+   _vbo_init_inputs(&st->draw_arrays);
+
return st;
 }
 
@@ -715,6 +717,7 @@ st_init_driver_functions(struct pipe_screen *screen,
_mesa_init_shader_object_functions(functions);
_mesa_init_sampler_object_functions(functions);
 
+   st_init_draw_functions(functions);
st_init_blit_functions(functions);
st_init_bufferobject_functions(screen, functions);
st_init_clear_functions(functions);
@@ -752,10 +755,6 @@ st_init_driver_functions(struct pipe_screen *screen,
if (screen->

Mesa (master): vbo: Readd the arrays argument to the legacy draw methods.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 245f9a3977dcc097ded07c535b589b82191d5e94
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=245f9a3977dcc097ded07c535b589b82191d5e94

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Readd the arrays argument to the legacy draw methods.

The legacy draw paths from back before 2012 contained a gl_vertex_array
array for the inputs to be used for draw. So all draw methods from legacy
drivers and everything that goes through tnl are originally written
for this calling convention. The same goes for tools like t_rebase or
vbo_split*, that even partly still have the original calling convention
with a currently unused such pointer.
Back in 2012 patch 50f7e75

mesa: move gl_client_array*[] from vbo_draw_func into gl_context

introduced Array._DrawArrays, which was something that was IMO aiming for
a similar direction than Array._DrawVAO introduced recently.
Now several tools like t_rebase and vbo_split*, which are mostly used by
tnl based drivers, would need to be converted to use the internal
Array._DrawVAO instead of Array._DrawArrays. The same goes for the driver
backends that use any of these tools.
Alternatively we can reintroduce the gl_vertex_array array in its call
argument list and put these tools finally into the tnl directory.
So this change reintroduces this gl_vertex_array array for the legacy
draw paths that are still required for the tools t_rebase and vbo_split*.
A followup will move vbo_split also into tnl.

Note that none of the affected drivers use the DriverFlags.NewArray
driver bit. So it should be safe to remove this also for the legacy
draw path.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c | 11 +++
 src/mesa/tnl/t_draw.c|  7 ---
 src/mesa/tnl/t_rebase.c  | 10 ++
 src/mesa/tnl/tnl.h   |  1 +
 src/mesa/vbo/vbo.h   |  2 ++
 src/mesa/vbo/vbo_split_copy.c|  8 +---
 src/mesa/vbo/vbo_split_inplace.c |  8 +---
 7 files changed, 18 insertions(+), 29 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 10b5c15e41..4533069692 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -239,6 +239,7 @@ get_max_client_stride(struct gl_context *ctx, const struct 
gl_vertex_array *arra
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
+ const struct gl_vertex_array *arrays,
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
@@ -476,6 +477,7 @@ vbo_draw_imm(struct gl_context *ctx, const struct 
gl_vertex_array *arrays,
 
 static void
 TAG(vbo_render_prims)(struct gl_context *ctx,
+ const struct gl_vertex_array *arrays,
  const struct _mesa_prim *prims, GLuint nr_prims,
  const struct _mesa_index_buffer *ib,
  GLboolean index_bounds_valid,
@@ -485,7 +487,6 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
  struct gl_buffer_object *indirect)
 {
struct nouveau_render_state *render = to_render_state(ctx);
-   const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
 
if (!index_bounds_valid)
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
@@ -514,6 +515,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
 
 static void
 TAG(vbo_check_render_prims)(struct gl_context *ctx,
+   const struct gl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLboolean index_bounds_valid,
@@ -527,12 +529,12 @@ TAG(vbo_check_render_prims)(struct gl_context *ctx,
nouveau_validate_framebuffer(ctx);
 
if (nctx->fallback == HWTNL)
-   TAG(vbo_render_prims)(ctx, prims, nr_prims, ib,
+   TAG(vbo_render_prims)(ctx, arrays, prims, nr_prims, ib,
  index_bounds_valid, min_index, max_index,
  tfb_vertcount, stream, indirect);
 
if (nctx->fallback == SWTNL)
-   _tnl_draw_prims(ctx, prims, nr_prims, ib,
+   _tnl_draw_prims(ctx, arrays, prims, nr_prims, ib,
index_bounds_valid, min_index, max_index,
tfb_vertcount, stream, indirect);
 }
@@ -550,7 +552,8 @@ TAG(vbo_draw)(struct gl_context *ctx,
/* Borrow and update the inputs list from the tnl context */
_tnl_bind_inputs(ctx);
 
-   TAG(vbo_check_render_prims)(ctx, prims, nr_prims

Mesa (master): vbo: Use alloca for _vbo_draw_indirect.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 1da345e56932b71067c069270828680aeb38d6b5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1da345e56932b71067c069270828680aeb38d6b5

Author: Mathias Fröhlich 
Date:   Wed Mar 28 07:19:02 2018 +0200

vbo: Use alloca for _vbo_draw_indirect.

Avoid using malloc in the draw path of mesa.
Since the draw_count is a user api input, fall back to malloc if
the amount of consumed stack space may get too high.

Reviewed-by: Brian Paul 
Reviewed-by: Marek Olšák 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_context.c | 79 --
 1 file changed, 55 insertions(+), 24 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index b8c28ceffb..e50cee7a8c 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -233,26 +233,20 @@ _vbo_DestroyContext(struct gl_context *ctx)
 }
 
 
-void
-_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
-struct gl_buffer_object *indirect_data,
-GLsizeiptr indirect_offset, unsigned draw_count,
-unsigned stride,
-struct gl_buffer_object *indirect_draw_count_buffer,
-GLsizeiptr indirect_draw_count_offset,
-const struct _mesa_index_buffer *ib)
+/*
+ * Helper function for _vbo_draw_indirect below that additionally takes a zero
+ * initialized array of _mesa_prim scratch space memory as the last argument.
+ */
+static void
+draw_indirect(struct gl_context *ctx, GLuint mode,
+  struct gl_buffer_object *indirect_data,
+  GLsizeiptr indirect_offset, unsigned draw_count,
+  unsigned stride,
+  struct gl_buffer_object *indirect_draw_count_buffer,
+  GLsizeiptr indirect_draw_count_offset,
+  const struct _mesa_index_buffer *ib,
+  struct _mesa_prim *prim)
 {
-   struct _mesa_prim *prim;
-
-   prim = calloc(draw_count, sizeof(*prim));
-   if (prim == NULL) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
-  (draw_count > 1) ? "Multi" : "",
-  ib ? "Elements" : "Arrays",
-  indirect_data ? "CountARB" : "");
-  return;
-   }
-
prim[0].begin = 1;
prim[draw_count - 1].end = 1;
for (unsigned i = 0; i < draw_count; ++i, indirect_offset += stride) {
@@ -266,10 +260,47 @@ _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
/* This should always be true at this time */
assert(indirect_data == ctx->DrawIndirectBuffer);
 
-   ctx->Driver.Draw(ctx, prim, draw_count,
-   ib, false, 0, ~0,
-   NULL, 0,
-   indirect_data);
+   ctx->Driver.Draw(ctx, prim, draw_count, ib, false, 0u, ~0u,
+NULL, 0, indirect_data);
+}
+
 
-   free(prim);
+/*
+ * Function to be put into dd_function_table::DrawIndirect as fallback.
+ * Calls into dd_function_table::Draw past adapting call arguments.
+ * See dd_function_table::DrawIndirect for call argument documentation.
+ */
+void
+_vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
+   struct gl_buffer_object *indirect_data,
+   GLsizeiptr indirect_offset, unsigned draw_count,
+   unsigned stride,
+   struct gl_buffer_object *indirect_draw_count_buffer,
+   GLsizeiptr indirect_draw_count_offset,
+   const struct _mesa_index_buffer *ib)
+{
+   /* Use alloca for the prim space if we are somehow in bounds. */
+   if (draw_count*sizeof(struct _mesa_prim) < 1024) {
+  struct _mesa_prim *space = alloca(draw_count*sizeof(struct _mesa_prim));
+  memset(space, 0, draw_count*sizeof(struct _mesa_prim));
+
+  draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
+stride, indirect_draw_count_buffer,
+indirect_draw_count_offset, ib, space);
+   } else {
+  struct _mesa_prim *space = calloc(draw_count, sizeof(struct _mesa_prim));
+  if (space == NULL) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
+ (draw_count > 1) ? "Multi" : "",
+ ib ? "Elements" : "Arrays",
+ indirect_data ? "CountARB" : "");
+ return;
+  }
+
+  draw_indirect(ctx, mode, indirect_data, indirect_offset, draw_count,
+stride, indirect_draw_count_buffer,
+indirect_draw_count_offset, ib, space);
+
+  free(space);
+   }
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Move vbo_split into the tnl module.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 6e9f00e3fc6f3b1331031f0995254c768d38ea81
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e9f00e3fc6f3b1331031f0995254c768d38ea81

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Move vbo_split into the tnl module.

Move the files, adapt to the naming scheme in tnl, update callers
and build system.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/Makefile.sources  | 10 +--
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c   |  4 +-
 src/mesa/meson.build   |  8 +--
 src/mesa/tnl/t_draw.c  |  8 +--
 src/mesa/tnl/t_rebase.c|  3 +-
 src/mesa/tnl/t_rebase.h|  4 +-
 src/mesa/{vbo/vbo_split.c => tnl/t_split.c}| 34 -
 src/mesa/{vbo/vbo_split.h => tnl/t_split.h}| 46 ++--
 .../{vbo/vbo_split_copy.c => tnl/t_split_copy.c}   | 23 +++---
 .../vbo_split_inplace.c => tnl/t_split_inplace.c}  | 51 +++---
 src/mesa/tnl/tnl.h | 80 +
 src/mesa/vbo/vbo.h | 81 --
 12 files changed, 178 insertions(+), 174 deletions(-)

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 0446078136..92565ef8f5 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -372,6 +372,10 @@ TNL_FILES = \
tnl/t_pipeline.h \
tnl/t_rebase.c \
tnl/t_rebase.h \
+   tnl/t_split.c \
+   tnl/t_split_copy.c \
+   tnl/t_split.h \
+   tnl/t_split_inplace.c \
tnl/t_vb_cliptmp.h \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
@@ -411,11 +415,7 @@ VBO_FILES = \
vbo/vbo_save.c \
vbo/vbo_save_draw.c \
vbo/vbo_save.h \
-   vbo/vbo_save_loopback.c \
-   vbo/vbo_split.c \
-   vbo/vbo_split_copy.c \
-   vbo/vbo_split.h \
-   vbo/vbo_split_inplace.c
+   vbo/vbo_save_loopback.c
 
 STATETRACKER_FILES = \
state_tracker/st_atifs_to_tgsi.c \
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index 4533069692..79b444cf55 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -277,8 +277,8 @@ vbo_maybe_split(struct gl_context *ctx, const struct 
gl_vertex_array *arrays,
.max_vb_size = ~0,
};
 
-   vbo_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
-   max_index, TAG(vbo_render_prims), &limits);
+   _tnl_split_prims(ctx, arrays, prims, nr_prims, ib, min_index,
+max_index, TAG(vbo_render_prims), &limits);
return GL_TRUE;
}
 
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index b74d169377..d2d058bfa3 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -343,10 +343,6 @@ files_libmesa_common = files(
   'vbo/vbo_save_draw.c',
   'vbo/vbo_save.h',
   'vbo/vbo_save_loopback.c',
-  'vbo/vbo_split.c',
-  'vbo/vbo_split_copy.c',
-  'vbo/vbo_split.h',
-  'vbo/vbo_split_inplace.c',
   'x86/common_x86.c',
 )
 
@@ -366,6 +362,10 @@ files_libmesa_classic = files(
   'tnl/t_pipeline.c',
   'tnl/t_pipeline.h',
   'tnl/t_rebase.c',
+  'tnl/t_split.c',
+  'tnl/t_split_copy.c',
+  'tnl/t_split.h',
+  'tnl/t_split_inplace.c',
   'tnl/t_vb_cliptmp.h',
   'tnl/t_vb_fog.c',
   'tnl/t_vb_light.c',
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index a0fd58432a..a83b98eede 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -486,10 +486,10 @@ void _tnl_draw_prims(struct gl_context *ctx,
   /* This will split the buffers one way or another and
* recursively call back into this function.
*/
-  vbo_split_prims( ctx, arrays, prim, nr_prims, ib, 
-  0, max_index + prim->basevertex,
-  _tnl_draw_prims,
-  &limits );
+  _tnl_split_prims( ctx, arrays, prim, nr_prims, ib,
+0, max_index + prim->basevertex,
+_tnl_draw_prims,
+&limits );
}
else {
   /* May need to map a vertex buffer object for every attribute plus
diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c
index 19e759f44b..d28512423c 100644
--- a/src/mesa/tnl/t_rebase.c
+++ b/src/mesa/tnl/t_rebase.c
@@ -51,6 +51,7 @@
 #include "main/glheader.h"
 #include "main/imports.h"
 #include "main/mtypes.h"
+#include "vbo/vbo.h"
 
 #include "t_rebase.h"
 
@@ -108,7 +109,7 @@ void t_rebase_prims

Mesa (master): vbo: Remove vbo_indirect_draw_func.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 7f8db5ca471c1940b0be42f49d37c24af381979a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f8db5ca471c1940b0be42f49d37c24af381979a

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

vbo: Remove vbo_indirect_draw_func.

Remove the vbo_indirect_draw_func vbo callback and make the default
implementation use the drivers main draw callback function directly.
This will be needed with the next changes when drivers without own main
drivers DrawIndirect implementation get moved to the main drivers
Draw method.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo.h | 32 
 src/mesa/vbo/vbo_context.c | 94 +++---
 src/mesa/vbo/vbo_private.h |  6 ---
 3 files changed, 30 insertions(+), 102 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index ef2bf9221a..db136f9445 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -169,34 +169,6 @@ typedef void (*vbo_draw_func)(struct gl_context *ctx,
   struct gl_buffer_object *indirect);
 
 
-/**
- * Draw a primitive, getting the vertex count, instance count, start
- * vertex, etc. from a buffer object.
- * \param mode  GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
- * \param indirect_data  buffer to get "DrawArrays/ElementsIndirectCommand" 
data
- * \param indirect_offset  offset of first primitive in indrect_data buffer
- * \param draw_count  number of primitives to draw
- * \param stride  stride, in bytes, between 
"DrawArrays/ElementsIndirectCommand"
- *objects
- * \param indirect_draw_count_buffer  if non-NULL specifies a buffer to get the
- *real draw_count value.  Used for
- *GL_ARB_indirect_parameters.
- * \param indirect_draw_count_offset  offset to the draw_count value in
- *indirect_draw_count_buffer
- * \param ib  index buffer for indexed drawing, NULL otherwise.
- */
-typedef void (*vbo_indirect_draw_func)(
-   struct gl_context *ctx,
-   GLuint mode,
-   struct gl_buffer_object *indirect_data,
-   GLsizeiptr indirect_offset,
-   unsigned draw_count,
-   unsigned stride,
-   struct gl_buffer_object *indirect_draw_count_buffer,
-   GLsizeiptr indirect_draw_count_offset,
-   const struct _mesa_index_buffer *ib);
-
-
 
 
 /* Utility function to cope with various constraints on tnl modules or
@@ -262,10 +234,6 @@ void
 vbo_set_draw_func(struct gl_context *ctx, vbo_draw_func func);
 
 void
-vbo_set_indirect_draw_func(struct gl_context *ctx,
-   vbo_indirect_draw_func func);
-
-void
 vbo_sw_primitive_restart(struct gl_context *ctx,
  const struct _mesa_prim *prim,
  GLuint nr_prims,
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 025d6d8de8..54cbab0c14 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -141,55 +141,6 @@ init_mat_currval(struct gl_context *ctx)
 }
 
 
-/**
- * Fallback for when a driver does not call vbo_set_indirect_draw_func().
- */
-static void
-vbo_draw_indirect_prims(struct gl_context *ctx,
-GLuint mode,
-struct gl_buffer_object *indirect_buffer,
-GLsizeiptr indirect_offset,
-unsigned draw_count,
-unsigned stride,
-struct gl_buffer_object *indirect_draw_count_buffer,
-GLsizeiptr indirect_draw_count_offset,
-const struct _mesa_index_buffer *ib)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct _mesa_prim *prim;
-   GLsizei i;
-
-   prim = calloc(draw_count, sizeof(*prim));
-   if (prim == NULL) {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "gl%sDraw%sIndirect%s",
-  (draw_count > 1) ? "Multi" : "",
-  ib ? "Elements" : "Arrays",
-  indirect_buffer ? "CountARB" : "");
-  return;
-   }
-
-   prim[0].begin = 1;
-   prim[draw_count - 1].end = 1;
-   for (i = 0; i < draw_count; ++i, indirect_offset += stride) {
-  prim[i].mode = mode;
-  prim[i].indexed = !!ib;
-  prim[i].indirect_offset = indirect_offset;
-  prim[i].is_indirect = 1;
-  prim[i].draw_id = i;
-   }
-
-   /* This should always be true at this time */
-   assert(indirect_buffer == ctx->DrawIndirectBuffer);
-
-   vbo->draw_prims(ctx, prim, draw_count,
-   ib, false, 0, ~0,
-   NULL, 0,
-   indirect_buffer);
-
-   free(prim);
-}
-
-
 void
 _vbo_install_exec_vtxfmt(struct gl_context *ctx)
 {
@@ -236,7 +187,6 @@ _vbo_CreateContext(struct gl_context *ctx)
init_generic_currval(ctx);
init_mat_currval(ctx);
_vbo_init_inputs(&a

Mesa (master): i965: Push down the gl_vertex_array inputs into i965.

2018-03-30 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4db9d83a2dd5611776577bacdbdbf483b6bea937
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4db9d83a2dd5611776577bacdbdbf483b6bea937

Author: Mathias Fröhlich 
Date:   Sun Mar 25 19:16:54 2018 +0200

i965: Push down the gl_vertex_array inputs into i965.

Let the i965 backend have its own gl_vertex_array array and basically
reimplement the way _vbo_draw works.
Note that brw_draw_indirect_prims calls brw_draw_prims internally
and gets its update to Array._DrawArray by this way.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/i965/brw_context.c |  1 +
 src/mesa/drivers/dri/i965/brw_context.h |  4 
 src/mesa/drivers/dri/i965/brw_draw.c| 23 +--
 src/mesa/drivers/dri/i965/brw_draw.h|  1 +
 4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_context.c 
b/src/mesa/drivers/dri/i965/brw_context.c
index 2e961a1ef6..01a3e16583 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -284,6 +284,7 @@ brw_init_driver_functions(struct brw_context *brw,
functions->GetString = intel_get_string;
functions->UpdateState = intel_update_state;
 
+   brw_init_draw_functions(functions);
intelInitTextureFuncs(functions);
intelInitTextureImageFuncs(functions);
intelInitTextureCopyImageFuncs(functions);
diff --git a/src/mesa/drivers/dri/i965/brw_context.h 
b/src/mesa/drivers/dri/i965/brw_context.h
index 177273c364..f049d08649 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -36,6 +36,7 @@
 #include 
 #include "main/macros.h"
 #include "main/mtypes.h"
+#include "vbo/vbo.h"
 #include "brw_structs.h"
 #include "brw_pipe_control.h"
 #include "compiler/brw_compiler.h"
@@ -954,6 +955,9 @@ struct brw_context
* These bitfields indicate which workarounds are needed.
*/
   uint8_t attrib_wa_flags[VERT_ATTRIB_MAX];
+
+  /* For the initial pushdown, keep the list of vbo inputs. */
+  struct vbo_inputs draw_arrays;
} vb;
 
struct {
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index 0d1ae8982c..5f52404bd6 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -34,6 +34,7 @@
 #include "main/macros.h"
 #include "main/transformfeedback.h"
 #include "main/framebuffer.h"
+#include "main/varray.h"
 #include "tnl/tnl.h"
 #include "vbo/vbo.h"
 #include "swrast/swrast.h"
@@ -941,11 +942,16 @@ brw_draw_prims(struct gl_context *ctx,
 {
unsigned i;
struct brw_context *brw = brw_context(ctx);
-   const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
+   const struct gl_vertex_array *arrays;
int predicate_state = brw->predicate.state;
struct brw_transform_feedback_object *xfb_obj =
   (struct brw_transform_feedback_object *) gl_xfb_obj;
 
+   /* The initial pushdown of the inputs array into the drivers */
+   _mesa_set_drawing_arrays(ctx, brw->vb.draw_arrays.inputs);
+   arrays = ctx->Array._DrawArrays;
+   _vbo_update_inputs(ctx, &brw->vb.draw_arrays);
+
if (!brw_check_conditional_render(brw))
   return;
 
@@ -1075,14 +1081,19 @@ brw_draw_indirect_prims(struct gl_context *ctx,
 }
 
 void
-brw_draw_init(struct brw_context *brw)
+brw_init_draw_functions(struct dd_function_table *functions)
 {
-   struct gl_context *ctx = &brw->ctx;
-
/* Register our drawing function:
 */
-   vbo_set_draw_func(ctx, brw_draw_prims);
-   vbo_set_indirect_draw_func(ctx, brw_draw_indirect_prims);
+   functions->Draw = brw_draw_prims;
+   functions->DrawIndirect = brw_draw_indirect_prims;
+}
+
+void
+brw_draw_init(struct brw_context *brw)
+{
+   /* Keep our list of gl_vertex_array inputs */
+   _vbo_init_inputs(&brw->vb.draw_arrays);
 
for (int i = 0; i < VERT_ATTRIB_MAX; i++)
   brw->vb.inputs[i].buffer = -1;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.h 
b/src/mesa/drivers/dri/i965/brw_draw.h
index c3a972c276..c74a2536aa 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.h
+++ b/src/mesa/drivers/dri/i965/brw_draw.h
@@ -55,6 +55,7 @@ void brw_draw_prims(struct gl_context *ctx,
  unsigned stream,
 struct gl_buffer_object *indirect );
 
+void brw_init_draw_functions(struct dd_function_table *functions);
 void brw_draw_init( struct brw_context *brw );
 void brw_draw_destroy( struct brw_context *brw );
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Make sure the internal VAO's stay within limits.

2018-03-23 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4a8ef1f5d4c5fc96194be65045e6a3d4f5b9f913
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4a8ef1f5d4c5fc96194be65045e6a3d4f5b9f913

Author: Mathias Fröhlich 
Date:   Thu Mar 22 05:34:09 2018 +0100

vbo: Make sure the internal VAO's stay within limits.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec_draw.c | 5 -
 src/mesa/vbo/vbo_save_api.c  | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 026b7be129..31d7700225 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -200,8 +200,10 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
assert((~vao_enabled & vao->_Enabled) == 0);
 
/* Bind the buffer object */
+   const GLuint stride = exec->vtx.vertex_size*sizeof(GLfloat);
+   assert(stride <= ctx->Const.MaxVertexAttribStride);
_mesa_bind_vertex_buffer(ctx, vao, 0, exec->vtx.bufferobj, buffer_offset,
-exec->vtx.vertex_size*sizeof(GLfloat), false);
+stride, false);
 
/* Retrieve the mapping from VBO_ATTRIB to VERT_ATTRIB space
 * Note that the position/generic0 aliasing is done in the VAO.
@@ -217,6 +219,7 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
   const GLenum16 type = exec->vtx.attrtype[vbo_attr];
   const GLuint offset = (GLuint)((GLbyte *)exec->vtx.attrptr[vbo_attr] -
  (GLbyte *)exec->vtx.vertex);
+  assert(offset <= ctx->Const.MaxVertexAttribRelativeOffset);
 
   /* Set and enable */
   _vbo_set_attrib_format(ctx, vao, vao_attr, buffer_offset,
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 9dd9c7d7d2..a367a569c8 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -493,6 +493,7 @@ update_vao(struct gl_context *ctx,
*vao = _mesa_new_vao(ctx, ~((GLuint)0));
 
/* Bind the buffer object at binding point 0 */
+   assert(stride <= ctx->Const.MaxVertexAttribStride);
_mesa_bind_vertex_buffer(ctx, *vao, 0, bo, buffer_offset, stride, false);
 
/* Retrieve the mapping from VBO_ATTRIB to VERT_ATTRIB space
@@ -504,6 +505,7 @@ update_vao(struct gl_context *ctx,
while (mask) {
   const int vao_attr = u_bit_scan(&mask);
   const GLubyte vbo_attr = vao_to_vbo_map[vao_attr];
+  assert(offset[vbo_attr] <= ctx->Const.MaxVertexAttribRelativeOffset);
 
   _vbo_set_attrib_format(ctx, *vao, vao_attr, buffer_offset,
  size[vbo_attr], type[vbo_attr], offset[vbo_attr]);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: When copying a VAO also copy the vertex attribute mode.

2018-03-23 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 19526a57f58bba7e275388cf07b1c4568b2e03af
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=19526a57f58bba7e275388cf07b1c4568b2e03af

Author: Mathias Fröhlich 
Date:   Thu Mar 22 05:34:09 2018 +0100

mesa: When copying a VAO also copy the vertex attribute mode.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/attrib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 9d3aa728a1..9c632ffb51 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1515,6 +1515,7 @@ copy_array_object(struct gl_context *ctx,
dest->_Enabled = src->_Enabled;
/* The bitmask of bound VBOs needs to match the VertexBinding array */
dest->VertexAttribBufferMask = src->VertexAttribBufferMask;
+   dest->_AttributeMapMode = src->_AttributeMapMode;
dest->NewArrays = src->NewArrays;
 }
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Flag early if we modify a SharedAndImmutable VAO.

2018-03-23 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 1a131aaf4b03502980ea109c44531da8f965ecaa
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1a131aaf4b03502980ea109c44531da8f965ecaa

Author: Mathias Fröhlich 
Date:   Thu Mar 22 05:34:09 2018 +0100

mesa: Flag early if we modify a SharedAndImmutable VAO.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/varray.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 69a08a646f..5df38a14f0 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -162,6 +162,7 @@ _mesa_vertex_attrib_binding(struct gl_context *ctx,
 GLuint bindingIndex, bool flush_vertices)
 {
struct gl_array_attributes *array = &vao->VertexAttrib[attribIndex];
+   assert(!vao->SharedAndImmutable);
 
if (array->BufferBindingIndex != bindingIndex) {
   const GLbitfield array_bit = VERT_BIT(attribIndex);
@@ -197,6 +198,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
  GLintptr offset, GLsizei stride, bool flush_vertices)
 {
assert(index < ARRAY_SIZE(vao->BufferBinding));
+   assert(!vao->SharedAndImmutable);
struct gl_vertex_buffer_binding *binding = &vao->BufferBinding[index];
 
if (binding->BufferObj != vbo ||
@@ -233,6 +235,7 @@ vertex_binding_divisor(struct gl_context *ctx,
 {
struct gl_vertex_buffer_binding *binding =
   &vao->BufferBinding[bindingIndex];
+   assert(!vao->SharedAndImmutable);
 
if (binding->InstanceDivisor != divisor) {
   FLUSH_VERTICES(ctx, _NEW_ARRAY);
@@ -333,6 +336,7 @@ _mesa_update_array_format(struct gl_context *ctx,
struct gl_array_attributes *const array = &vao->VertexAttrib[attrib];
GLint elementSize;
 
+   assert(!vao->SharedAndImmutable);
assert(size <= 4);
 
elementSize = _mesa_bytes_per_vertex_attrib(size, type);
@@ -1097,6 +1101,7 @@ _mesa_enable_vertex_array_attrib(struct gl_context *ctx,
  gl_vert_attrib attrib, bool flush_vertices)
 {
assert(attrib < ARRAY_SIZE(vao->VertexAttrib));
+   assert(!vao->SharedAndImmutable);
 
if (!vao->VertexAttrib[attrib].Enabled) {
   /* was disabled, now being enabled */
@@ -1186,6 +1191,7 @@ _mesa_disable_vertex_array_attrib(struct gl_context *ctx,
   gl_vert_attrib attrib, bool flush_vertices)
 {
assert(attrib < ARRAY_SIZE(vao->VertexAttrib));
+   assert(!vao->SharedAndImmutable);
 
if (vao->VertexAttrib[attrib].Enabled) {
   /* was enabled, now being disabled */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: A change of gl_vertex_processing_mode needs an array update.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: bf328359a724bec9592f67e51a4d7e5cca550cd0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bf328359a724bec9592f67e51a4d7e5cca550cd0

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

mesa: A change of gl_vertex_processing_mode needs an array update.

Since arrays also handle the mapping of current values into the
disabled array slots, we need to tell the array update code that
this mapping has changed. Also mark only dirty if it has changed.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/state.c | 20 +---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index a6ae3b9001..fb97165db9 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -466,6 +466,20 @@ set_new_array(struct gl_context *ctx)
 }
 
 
+static void
+set_vertex_processing_mode(struct gl_context *ctx, gl_vertex_processing_mode m)
+{
+   if (ctx->VertexProgram._VPMode == m)
+  return;
+
+   /* On change we may get new maps into the current values */
+   set_new_array(ctx);
+
+   /* Finally memorize the value */
+   ctx->VertexProgram._VPMode = m;
+}
+
+
 /**
  * Update ctx->VertexProgram._VPMode.
  * This is to distinguish whether we're running
@@ -477,11 +491,11 @@ void
 _mesa_update_vertex_processing_mode(struct gl_context *ctx)
 {
if (ctx->_Shader->CurrentProgram[MESA_SHADER_VERTEX])
-  ctx->VertexProgram._VPMode = VP_MODE_SHADER;
+  set_vertex_processing_mode(ctx, VP_MODE_SHADER);
else if (_mesa_arb_vertex_program_enabled(ctx))
-  ctx->VertexProgram._VPMode = VP_MODE_SHADER;
+  set_vertex_processing_mode(ctx, VP_MODE_SHADER);
else
-  ctx->VertexProgram._VPMode = VP_MODE_FF;
+  set_vertex_processing_mode(ctx, VP_MODE_FF);
 }
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Move vbo draw functions into dd_function_table.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 6307d1be0a746bf30efe6d9c057ef5bad75ba183
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6307d1be0a746bf30efe6d9c057ef5bad75ba183

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

mesa: Move vbo draw functions into dd_function_table.

Move vbo draw functions into struct dd_function_table.
For now just wrap the underlying vbo functions.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/common/driverfuncs.c |  5 +++
 src/mesa/main/dd.h| 81 +++
 src/mesa/state_tracker/st_context.c   |  4 ++
 src/mesa/vbo/vbo.h| 18 
 src/mesa/vbo/vbo_context.c| 29 +
 src/mesa/vbo/vbo_exec_array.c | 39 ++---
 src/mesa/vbo/vbo_exec_draw.c  | 11 ++---
 src/mesa/vbo/vbo_primitive_restart.c  | 14 +++---
 src/mesa/vbo/vbo_save_draw.c  |  9 +---
 9 files changed, 162 insertions(+), 48 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c 
b/src/mesa/drivers/common/driverfuncs.c
index 8f2e3e075c..2ddfdb5efa 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -55,6 +55,7 @@
 #include "tnl/tnl.h"
 #include "swrast/swrast.h"
 #include "swrast/s_renderbuffer.h"
+#include "vbo/vbo.h"
 
 #include "driverfuncs.h"
 #include "meta.h"
@@ -119,6 +120,10 @@ _mesa_init_driver_functions(struct dd_function_table 
*driver)
/* ATI_fragment_shader */
driver->NewATIfs = NULL;
 
+   /* Draw functions */
+   driver->Draw = _vbo_draw;
+   driver->DrawIndirect = _vbo_draw_indirect;
+
/* simple state commands */
driver->AlphaFunc = NULL;
driver->BlendColor = NULL;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 3e6a0418a2..09e9c41244 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -51,6 +51,8 @@ struct gl_texture_image;
 struct gl_texture_object;
 struct gl_memory_info;
 struct util_queue_monitoring;
+struct _mesa_prim;
+struct _mesa_index_buffer;
 
 /* GL_ARB_vertex_buffer_object */
 /* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
@@ -489,6 +491,85 @@ struct dd_function_table {
struct gl_shader_program *shader);
/*@}*/
 
+
+   /**
+* \name Draw functions.
+*/
+   /*@{*/
+   /**
+* For indirect array drawing:
+*
+*typedef struct {
+*   GLuint count;
+*   GLuint primCount;
+*   GLuint first;
+*   GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+*} DrawArraysIndirectCommand;
+*
+* For indirect indexed drawing:
+*
+*typedef struct {
+*   GLuint count;
+*   GLuint primCount;
+*   GLuint firstIndex;
+*   GLint  baseVertex;
+*   GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
+*} DrawElementsIndirectCommand;
+*/
+
+   /**
+* Draw a number of primitives.
+* \param prims  array [nr_prims] describing what to draw (prim type,
+*   vertex count, first index, instance count, etc).
+* \param ib  index buffer for indexed drawing, NULL for array drawing
+* \param index_bounds_valid  are min_index and max_index valid?
+* \param min_index  lowest vertex index used
+* \param max_index  highest vertex index used
+* \param tfb_vertcount  if non-null, indicates which transform feedback
+*   object has the vertex count.
+* \param tfb_stream  If called via DrawTransformFeedbackStream, specifies
+*the vertex stream buffer from which to get the vertex
+*count.
+* \param indirect  If any prims are indirect, this specifies the buffer
+*  to find the "DrawArrays/ElementsIndirectCommand" data.
+*  This may be deprecated in the future
+*/
+   void (*Draw)(struct gl_context *ctx,
+const struct _mesa_prim *prims, GLuint nr_prims,
+const struct _mesa_index_buffer *ib,
+GLboolean index_bounds_valid,
+GLuint min_index, GLuint max_index,
+struct gl_transform_feedback_object *tfb_vertcount,
+unsigned tfb_stream, struct gl_buffer_object *indirect);
+
+
+   /**
+* Draw a primitive, getting the vertex count, instance count, start
+* vertex, etc. from a buffer object.
+* \param mode  GL_POINTS, GL_LINES, GL_TRIANGLE_STRIP, etc.
+* \param indirect_data  buffer to get "DrawArrays/ElementsIndirectCommand"
+*   data
+* \param indirect_offset  offset of first primitive in indrect_data buffer
+* \param draw_count  number of primitives to draw
+* \param stride  stride, in bytes, between
+*"DrawArrays/ElementsIndi

Mesa (master): vbo: Remove now duplicate _vbo_update_inputs from dlist draw.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 006b5e798a4a82590abf1e621b8b43aea5b19994
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=006b5e798a4a82590abf1e621b8b43aea5b19994

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

vbo: Remove now duplicate _vbo_update_inputs from dlist draw.

At the current state, _vbo_update_inputs is called from
the draw callback if vbo...recalculate_inputs is set.
But that is now set of the _DrawVAO or its content or the
vertex program mode is changed.
So remove _vbo_update_inputs from the direct dlist draw path.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save_draw.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index ed3b50434f..096e43c816 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -206,9 +206,6 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void 
*data)
  return;
   }
 
-  /* Finally update the inputs array */
-  _vbo_update_inputs(ctx, &vbo->draw_arrays);
-
   assert(ctx->NewState == 0);
 
   if (node->vertex_count > 0) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove redundant set of DriverFlags.NewArray in vbo_bind_arrays.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 2887c981405a911a26a4a6c7f989b803cc94dd54
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2887c981405a911a26a4a6c7f989b803cc94dd54

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

vbo: Remove redundant set of DriverFlags.NewArray in vbo_bind_arrays.

Now that setting vbo...recalculate_inputs also sets the
DriverFlags.NewArray bits into the NewDriverState setting that from
vbo_bind_arrays is redundant.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_context.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 6b4f74d72f..025d6d8de8 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -317,7 +317,6 @@ vbo_bind_arrays(struct gl_context *ctx)
if (exec->array.recalculate_inputs) {
   /* Finally update the inputs array */
   _vbo_update_inputs(ctx, &vbo->draw_arrays);
-  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
   exec->array.recalculate_inputs = GL_FALSE;
}
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Set DriverFlags.NewArray together with vbo...recalculate_inputs.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 5b917862251f365f2c670196f9222b33f4adcd4f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b917862251f365f2c670196f9222b33f4adcd4f

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

mesa: Set DriverFlags.NewArray together with vbo...recalculate_inputs.

Both mean something very similar and are set at the same time now.
For that vbo module to be set from core mesa, implement a public vbo
module method to set that flag. In the longer term the flag should
vanish in favor of a driver flag of the appropriate driver.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/state.c   | 19 ---
 src/mesa/vbo/vbo.h  |  9 +
 src/mesa/vbo/vbo_exec.c |  7 +++
 3 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index e523bccd0c..a6ae3b9001 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -458,6 +458,14 @@ _mesa_set_vp_override(struct gl_context *ctx, GLboolean 
flag)
 }
 
 
+static void
+set_new_array(struct gl_context *ctx)
+{
+   _vbo_set_recalculate_inputs(ctx);
+   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+}
+
+
 /**
  * Update ctx->VertexProgram._VPMode.
  * This is to distinguish whether we're running
@@ -490,23 +498,28 @@ _mesa_set_draw_vao(struct gl_context *ctx, struct 
gl_vertex_array_object *vao,
GLbitfield filter)
 {
struct gl_vertex_array_object **ptr = &ctx->Array._DrawVAO;
+   bool new_array = false;
if (*ptr != vao) {
   _mesa_reference_vao_(ctx, ptr, vao);
 
-  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+  new_array = true;
}
 
if (vao->NewArrays) {
   _mesa_update_vao_derived_arrays(ctx, vao);
   vao->NewArrays = 0;
 
-  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+  new_array = true;
}
 
/* May shuffle the position and generic0 bits around, filter out unwanted */
const GLbitfield enabled = filter & _mesa_get_vao_vp_inputs(vao);
if (ctx->Array._DrawVAOEnabledAttribs != enabled)
-  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+  new_array = true;
+
+   if (new_array)
+  set_new_array(ctx);
+
ctx->Array._DrawVAOEnabledAttribs = enabled;
_mesa_set_varying_vp_inputs(ctx, enabled);
 }
diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 42436e0fac..ef2bf9221a 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -293,6 +293,15 @@ struct vbo_inputs
 
 
 /**
+ * Set the recalculate_inputs flag.
+ * The method should in the longer run be replaced with listening for the
+ * DriverFlags.NewArray flag in NewDriverState. But for now ...
+ */
+void
+_vbo_set_recalculate_inputs(struct gl_context *ctx);
+
+
+/**
  * Initialize inputs.
  */
 void
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
index c0b0a11fe5..f9cf8355ed 100644
--- a/src/mesa/vbo/vbo_exec.c
+++ b/src/mesa/vbo/vbo_exec.c
@@ -244,6 +244,13 @@ vbo_merge_prims(struct _mesa_prim *p0, const struct 
_mesa_prim *p1)
 
 
 void
+_vbo_set_recalculate_inputs(struct gl_context *ctx)
+{
+   vbo_context(ctx)->exec.array.recalculate_inputs = GL_TRUE;
+}
+
+
+void
 _vbo_init_inputs(struct vbo_inputs *inputs)
 {
inputs->current = 0;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove vbo...recalculate_inputs from vbo_exec_invalidate_state.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 9f5b6ef2ef4a9ba266250ec02769a46cf490ed7b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=9f5b6ef2ef4a9ba266250ec02769a46cf490ed7b

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

vbo: Remove vbo...recalculate_inputs from vbo_exec_invalidate_state.

This flag is now set when the actual Array._DrawVAO changes.
So setting this flag is redundant here.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_context.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 28f494839e..6b4f74d72f 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -206,16 +206,8 @@ vbo_exec_invalidate_state(struct gl_context *ctx)
struct vbo_exec_context *exec = &vbo->exec;
 
if (ctx->NewState & (_NEW_PROGRAM | _NEW_ARRAY)) {
-  exec->array.recalculate_inputs = GL_TRUE;
-
   _ae_invalidate_state(ctx);
}
-   /* If _mesa_update_state is called in a non draw code path,
-* changes in the VAO need to be captured.
-*/
-   if (ctx->Array.VAO->NewArrays)
-  exec->array.recalculate_inputs = GL_TRUE;
-
if (ctx->NewState & _NEW_EVAL)
   exec->eval.recalculate_maps = GL_TRUE;
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove now duplicate _DrawVAO notification.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 862c872c48fb96ab3f2119bd3a161d241f4fb766
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=862c872c48fb96ab3f2119bd3a161d241f4fb766

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

vbo: Remove now duplicate _DrawVAO notification.

The DriverFlags.NewArray bit is already set to NewDriverState in
_mesa_set_draw_vao since we have actually just above changed the VAOs
content. So this can be removed.
The _vbo_update_inputs is called by the vbo...recalculate_inputs being
set through the same mechanism as described above.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_exec_draw.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 3490dbe44d..026b7be129 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -232,11 +232,6 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
   (vao_enabled & ~vao->VertexAttribBufferMask) == 0);
 
_mesa_set_draw_vao(ctx, vao, _vbo_get_vao_filter(mode));
-   /* The exec VAO is not immutable, so we need to set manually */
-   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
-
-   /* Finally update the inputs array */
-   _vbo_update_inputs(ctx, &vbo->draw_arrays);
 }
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Move vbo_bind_arrays into a dd_driver_functions draw callback.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: c4c56ff303e39f55e7940b33e8afeafa80b26280
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c4c56ff303e39f55e7940b33e8afeafa80b26280

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

vbo: Move vbo_bind_arrays into a dd_driver_functions draw callback.

Factor out that common call into the almost single place.
Remove the _mesa_set_drawing_arrays call from vbo_{exec,save}_draw code
paths as the function is now called through vbo_bind_arrays.
Prepare updating the list of struct gl_vertex_array entries via
calling _vbo_update_inputs for being pushed into those drivers that
finally work on that long list of gl_vertex_array pointers.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_context.c| 27 ++
 src/mesa/vbo/vbo_exec_array.c | 44 ---
 src/mesa/vbo/vbo_exec_draw.c  |  1 -
 src/mesa/vbo/vbo_save_draw.c  |  1 -
 4 files changed, 27 insertions(+), 46 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index bef2b47fdf..28f494839e 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -309,6 +309,31 @@ vbo_set_indirect_draw_func(struct gl_context *ctx,
 }
 
 
+/**
+ * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
+ * These will point to the arrays to actually use for drawing.  Some will
+ * be user-provided arrays, other will be zero-stride const-valued arrays.
+ */
+static void
+vbo_bind_arrays(struct gl_context *ctx)
+{
+   struct vbo_context *vbo = vbo_context(ctx);
+   struct vbo_exec_context *exec = &vbo->exec;
+
+   _mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
+
+   if (exec->array.recalculate_inputs) {
+  /* Finally update the inputs array */
+  _vbo_update_inputs(ctx, &vbo->draw_arrays);
+  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+  exec->array.recalculate_inputs = GL_FALSE;
+   }
+
+   assert(ctx->NewState == 0);
+   assert(ctx->Array._DrawVAO->NewArrays == 0);
+}
+
+
 void
 _vbo_draw(struct gl_context *ctx, const struct _mesa_prim *prims,
GLuint nr_prims, const struct _mesa_index_buffer *ib,
@@ -317,6 +342,7 @@ _vbo_draw(struct gl_context *ctx, const struct _mesa_prim 
*prims,
unsigned tfb_stream, struct gl_buffer_object *indirect)
 {
struct vbo_context *vbo = vbo_context(ctx);
+   vbo_bind_arrays(ctx);
vbo->draw_prims(ctx, prims, nr_prims, ib, index_bounds_valid,
min_index, max_index, tfb_vertcount, tfb_stream, indirect);
 }
@@ -332,6 +358,7 @@ _vbo_draw_indirect(struct gl_context *ctx, GLuint mode,
 const struct _mesa_index_buffer *ib)
 {
struct vbo_context *vbo = vbo_context(ctx);
+   vbo_bind_arrays(ctx);
vbo->draw_indirect_prims(ctx, mode, indirect_data, indirect_offset,
 draw_count, stride, indirect_draw_count_buffer,
 indirect_draw_count_offset, ib);
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 18b0032ae8..51fd434dc4 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -361,30 +361,6 @@ enabled_filter(const struct gl_context *ctx)
 
 
 /**
- * Examine the enabled vertex arrays to set the exec->array.inputs[] values.
- * These will point to the arrays to actually use for drawing.  Some will
- * be user-provided arrays, other will be zero-stride const-valued arrays.
- */
-static void
-vbo_bind_arrays(struct gl_context *ctx)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
-
-   _mesa_set_drawing_arrays(ctx, vbo->draw_arrays.inputs);
-
-   if (exec->array.recalculate_inputs) {
-  /* Finally update the inputs array */
-  _vbo_update_inputs(ctx, &vbo->draw_arrays);
-  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
-  exec->array.recalculate_inputs = GL_FALSE;
-
-  assert(ctx->NewState == 0);
-   }
-}
-
-
-/**
  * Helper function called by the other DrawArrays() functions below.
  * This is where we handle primitive restart for drawing non-indexed
  * arrays.  If primitive restart is enabled, it typically means
@@ -400,8 +376,6 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint 
start,
if (skip_validated_draw(ctx))
   return;
 
-   vbo_bind_arrays(ctx);
-
/* OpenGL 4.5 says that primitive restart is ignored with non-indexed
 * draws.
 */
@@ -818,8 +792,6 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, 
GLenum mode,
if (skip_draw_elements(ctx, count, indices))
   return;
 
-   vbo_bind_arrays(ctx);
-
ib.count = count;
ib.index_size = sizeof_ib_type(type);
ib.obj = ctx->Array.VAO->IndexBufferObj;
@@ -1251,8 +1223,6 @@ vbo_validated_multidrawelements(struct gl_context *ctx, 
GLenum mode,

Mesa (master): mesa: Update VAO internal state when setting the _DrawVAO.

2018-03-21 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: d3c604e12e1e2ef1e562f51e529ba18bae2d9af1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d3c604e12e1e2ef1e562f51e529ba18bae2d9af1

Author: Mathias Fröhlich 
Date:   Fri Mar 16 06:34:35 2018 +0100

mesa: Update VAO internal state when setting the _DrawVAO.

Update the VAO internal state on Array._DrawVAO instead of
Array.VAO. Also the VAO internal state update gets triggered now
by a change of Array._DrawVAO instead of the _NEW_ARRAY state flag.
Also no driver looks at any VAO's NewArrays value from within
the Driver.UpdateState callback. So it should be safe to move
this update into the _mesa_set_draw_vao method.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/main/arrayobj.c |  6 ++
 src/mesa/main/state.c| 12 +++-
 src/mesa/vbo/vbo_exec_draw.c |  3 ---
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 7cb9833719..0d2f7a918a 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -461,6 +461,12 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
 {
/* Make sure we do not run into problems with shared objects */
assert(!vao->SharedAndImmutable || vao->NewArrays == 0);
+
+   /*
+* Stay tuned, the next series scans for duplicate bindings in this
+* function. So that drivers can easily know the minimum unique set
+* of bindings.
+*/
 }
 
 
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 6dd7a7ec07..e523bccd0c 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -360,9 +360,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
  update_program(ctx);
}
 
-   if (new_state & _NEW_ARRAY)
-  _mesa_update_vao_derived_arrays(ctx, ctx->Array.VAO);
-
  out:
new_prog_state |= update_program_constants(ctx);
 
@@ -377,7 +374,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
 */
ctx->Driver.UpdateState(ctx);
ctx->NewState = 0;
-   ctx->Array.VAO->NewArrays = 0x0;
 }
 
 
@@ -496,8 +492,14 @@ _mesa_set_draw_vao(struct gl_context *ctx, struct 
gl_vertex_array_object *vao,
struct gl_vertex_array_object **ptr = &ctx->Array._DrawVAO;
if (*ptr != vao) {
   _mesa_reference_vao_(ctx, ptr, vao);
+
   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
-   } else if (vao->NewArrays) {
+   }
+
+   if (vao->NewArrays) {
+  _mesa_update_vao_derived_arrays(ctx, vao);
+  vao->NewArrays = 0;
+
   ctx->NewDriverState |= ctx->DriverFlags.NewArray;
}
 
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 1ed9d5eac0..3490dbe44d 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -231,9 +231,6 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
assert(!_mesa_is_bufferobj(exec->vtx.bufferobj) ||
   (vao_enabled & ~vao->VertexAttribBufferMask) == 0);
 
-   _mesa_update_vao_derived_arrays(ctx, vao);
-   vao->NewArrays = 0;
-
_mesa_set_draw_vao(ctx, vao, _vbo_get_vao_filter(mode));
/* The exec VAO is not immutable, so we need to set manually */
ctx->NewDriverState |= ctx->DriverFlags.NewArray;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Correctly handle source arrays in vbo_split_copy.

2018-03-14 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 98f35ad63c23805c32654843f55208e675d4e4db
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=98f35ad63c23805c32654843f55208e675d4e4db

Author: Mathias Fröhlich 
Date:   Tue Mar 13 09:12:48 2018 +0100

vbo: Correctly handle source arrays in vbo_split_copy.

The original approach did optimize away a bit too many fields.
Restablish the pointer into the original array and correctly feed that
one.

Reviewed-by: Brian Paul 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105471
Fixes: 64d2a20480547d5897fd9d7b8fd306f2625138cb
mesa: Make gl_vertex_array contain pointers to first order VAO members.
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_split_copy.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
index 09b5b3b651..96828a073f 100644
--- a/src/mesa/vbo/vbo_split_copy.c
+++ b/src/mesa/vbo/vbo_split_copy.c
@@ -63,6 +63,7 @@ struct copy_context {
struct {
   GLuint attr;
   GLuint size;
+  const struct gl_vertex_array *array;
   const GLubyte *src_ptr;
 
   struct gl_vertex_buffer_binding dstbinding;
@@ -258,7 +259,7 @@ elt(struct copy_context *copy, GLuint elt_idx)
   GLuint i;
 
   for (i = 0; i < copy->nr_varying; i++) {
- const struct gl_vertex_array *srcarray = ©->array[i];
+ const struct gl_vertex_array *srcarray = copy->varying[i].array;
  const struct gl_vertex_buffer_binding* srcbinding
 = srcarray->BufferBinding;
  const GLubyte *srcptr
@@ -449,6 +450,7 @@ replay_init(struct copy_context *copy)
  GLuint j = copy->nr_varying++;
 
  copy->varying[j].attr = i;
+ copy->varying[j].array = ©->array[i];
  copy->varying[j].size = attr_size(attrib);
  copy->vertex_size += attr_size(attrib);
 
@@ -520,7 +522,7 @@ replay_init(struct copy_context *copy)
/* Setup new vertex arrays to point into the output buffer:
 */
for (offset = 0, i = 0; i < copy->nr_varying; i++) {
-  const struct gl_vertex_array *src = ©->array[i];
+  const struct gl_vertex_array *src = copy->varying[i].array;
   const struct gl_array_attributes *srcattr = src->VertexAttrib;
   struct gl_vertex_array *dst = ©->dstarray[i];
   struct gl_vertex_buffer_binding *dstbind = ©->varying[i].dstbinding;
@@ -576,7 +578,7 @@ replay_finish(struct copy_context *copy)
/* Unmap VBO's */
for (i = 0; i < copy->nr_varying; i++) {
   struct gl_buffer_object *vbo =
- copy->array[i].BufferBinding->BufferObj;
+ copy->varying[i].array->BufferBinding->BufferObj;
   if (_mesa_is_bufferobj(vbo) && _mesa_bufferobj_mapped(vbo, MAP_INTERNAL))
  ctx->Driver.UnmapBuffer(ctx, vbo, MAP_INTERNAL);
}

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): gallium: Use struct gl_array_attributes* as st_pipe_vertex_format argument.

2018-03-12 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: a2f08dd574ad3da47b99bd1865b069f0b5b06c4c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a2f08dd574ad3da47b99bd1865b069f0b5b06c4c

Author: Mathias Fröhlich 
Date:   Sat Mar 10 16:01:31 2018 +0100

gallium: Use struct gl_array_attributes* as st_pipe_vertex_format argument.

Reviewed-by: Brian Paul 
Reviewed-by: Eric Engestrom 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/state_tracker/st_atom.h  |  3 +--
 src/mesa/state_tracker/st_atom_array.c| 25 +
 src/mesa/state_tracker/st_draw_feedback.c |  7 +--
 3 files changed, 11 insertions(+), 24 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index 68388a5674..2567ad30df 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -55,8 +55,7 @@ void st_validate_state( struct st_context *st, enum 
st_pipeline pipeline );
 GLuint st_compare_func_to_pipe(GLenum func);
 
 enum pipe_format
-st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
-  GLboolean normalized, GLboolean integer);
+st_pipe_vertex_format(const struct gl_array_attributes *attrib);
 
 
 /* Define ST_NEW_xxx_INDEX */
diff --git a/src/mesa/state_tracker/st_atom_array.c 
b/src/mesa/state_tracker/st_atom_array.c
index ff7a5d0746..2fd67e8d84 100644
--- a/src/mesa/state_tracker/st_atom_array.c
+++ b/src/mesa/state_tracker/st_atom_array.c
@@ -237,13 +237,18 @@ static const uint16_t vertex_formats[][4][4] = {
  * Return a PIPE_FORMAT_x for the given GL datatype and size.
  */
 enum pipe_format
-st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
-  GLboolean normalized, GLboolean integer)
+st_pipe_vertex_format(const struct gl_array_attributes *attrib)
 {
+   const GLubyte size = attrib->Size;
+   const GLenum16 format = attrib->Format;
+   const bool normalized = attrib->Normalized;
+   const bool integer = attrib->Integer;
+   GLenum16 type = attrib->Type;
unsigned index;
 
assert(size >= 1 && size <= 4);
assert(format == GL_RGBA || format == GL_BGRA);
+   assert(attrib->_ElementSize == _mesa_bytes_per_vertex_attrib(size, type));
 
switch (type) {
case GL_HALF_FLOAT_OES:
@@ -532,14 +537,8 @@ setup_interleaved_attribs(struct st_context *st,
   ptr = _mesa_vertex_attrib_address(attrib, binding);
 
   src_offset = (unsigned) (ptr - low_addr);
-  assert(attrib->_ElementSize ==
- _mesa_bytes_per_vertex_attrib(attrib->Size, attrib->Type));
 
-  src_format = st_pipe_vertex_format(attrib->Type,
- attrib->Size,
- attrib->Format,
- attrib->Normalized,
- attrib->Integer);
+  src_format = st_pipe_vertex_format(attrib);
 
   init_velement_lowered(vp, velements, src_offset, src_format,
 binding->InstanceDivisor, 0,
@@ -623,8 +622,6 @@ setup_non_interleaved_attribs(struct st_context *st,
   attrib = array->VertexAttrib;
   stride = binding->Stride;
   bufobj = binding->BufferObj;
-  assert(attrib->_ElementSize ==
- _mesa_bytes_per_vertex_attrib(attrib->Size, attrib->Type));
 
   if (_mesa_is_bufferobj(bufobj)) {
  /* Attribute data is in a VBO.
@@ -688,11 +685,7 @@ setup_non_interleaved_attribs(struct st_context *st,
   /* common-case setup */
   vbuffer[bufidx].stride = stride; /* in bytes */
 
-  src_format = st_pipe_vertex_format(attrib->Type,
- attrib->Size,
- attrib->Format,
- attrib->Normalized,
- attrib->Integer);
+  src_format = st_pipe_vertex_format(attrib);
 
   init_velement_lowered(vp, velements, 0, src_format,
 binding->InstanceDivisor, bufidx,
diff --git a/src/mesa/state_tracker/st_draw_feedback.c 
b/src/mesa/state_tracker/st_draw_feedback.c
index 46a12848c0..fa96b4e2e2 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -240,12 +240,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
   vbuffers[attr].stride = binding->Stride; /* in bytes */
   velements[attr].instance_divisor = 0;
   velements[attr].vertex_buffer_index = attr;
-  velements[attr].src_format =
- st_pipe_vertex_format(attrib->Type,
-   attrib->Size,
-   attrib->Format,
-   attrib->Normalized,
-   attrib->Integer);
+  velements[attr].src_format = st_pipe_vertex_format(attrib);
   assert(velements[attr].src_format);
 
   /* tell d

Mesa (master): mesa: Make gl_vertex_array contain pointers to first order VAO members.

2018-03-10 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 64d2a20480547d5897fd9d7b8fd306f2625138cb
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=64d2a20480547d5897fd9d7b8fd306f2625138cb

Author: Mathias Fröhlich 
Date:   Sun Mar  4 18:15:53 2018 +0100

mesa: Make gl_vertex_array contain pointers to first order VAO members.

Instead of keeping a copy of the vertex array content in
struct gl_vertex_array only keep pointers to the first order
information originaly in the VAO.
For that represent the current values by struct gl_array_attributes
and struct gl_vertex_buffer_binding.

v2: Change comments.
Remove gl... prefix from variables except in the i965 directory where
it was like that before. Reindent because of that.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/drivers/dri/i965/brw_context.h   |   2 +-
 src/mesa/drivers/dri/i965/brw_draw.c  |  28 +++---
 src/mesa/drivers/dri/i965/brw_draw_upload.c   | 130 ++
 src/mesa/drivers/dri/i965/genX_state_upload.c |  23 +++--
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c  |  81 +---
 src/mesa/main/arrayobj.c  |  16 
 src/mesa/main/attrib.c|   1 -
 src/mesa/main/mtypes.h|  47 +++---
 src/mesa/main/varray.c|  21 -
 src/mesa/main/varray.h|  49 +++---
 src/mesa/state_tracker/st_atom.c  |   7 +-
 src/mesa/state_tracker/st_atom_array.c| 115 ++-
 src/mesa/state_tracker/st_cb_rasterpos.c  |  26 +++---
 src/mesa/state_tracker/st_draw_feedback.c |  46 ++---
 src/mesa/tnl/t_draw.c |  95 ++-
 src/mesa/tnl/t_rebase.c   |  20 ++--
 src/mesa/tnl/t_rebase.h   |   2 +-
 src/mesa/vbo/vbo.h|   4 +-
 src/mesa/vbo/vbo_context.c|  52 +--
 src/mesa/vbo/vbo_exec.c   |  16 ++--
 src/mesa/vbo/vbo_exec_api.c   |  22 ++---
 src/mesa/vbo/vbo_private.h|   3 +-
 src/mesa/vbo/vbo_save_draw.c  |   2 +-
 src/mesa/vbo/vbo_split.c  |   2 +-
 src/mesa/vbo/vbo_split.h  |   4 +-
 src/mesa/vbo/vbo_split_copy.c |  97 +++
 src/mesa/vbo/vbo_split_inplace.c  |   6 +-
 27 files changed, 480 insertions(+), 437 deletions(-)

Diff:   
http://cgit.freedesktop.org/mesa/mesa/diff/?id=64d2a20480547d5897fd9d7b8fd306f2625138cb
___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Try to reuse the same VAO more often for successive dlists.

2018-03-04 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 411aa8c322f6703b20d32c7c263fd7ea8639cf3f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=411aa8c322f6703b20d32c7c263fd7ea8639cf3f

Author: Mathias Fröhlich 
Date:   Wed Feb 28 08:31:44 2018 +0100

vbo: Try to reuse the same VAO more often for successive dlists.

The change tries to catch more opportunities to reuse the same set
of VAO's when building up display lists. Instead of checking the
offset with respect to the beginning of the vertex buffer object
the change tries to apply this same optimization with respect to the
previous display list node.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save_api.c | 17 ++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 47ee355e72..9dd9c7d7d2 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -542,11 +542,18 @@ compile_vertex_list(struct gl_context *ctx)
 
/* Duplicate our template, increment refcounts to the storage structs:
 */
+   GLintptr old_offset = 0;
+   if (save->VAO[0]) {
+  old_offset = save->VAO[0]->BufferBinding[0].Offset
+ + save->VAO[0]->VertexAttrib[VERT_ATTRIB_POS].RelativeOffset;
+   }
const GLsizei stride = save->vertex_size*sizeof(GLfloat);
GLintptr buffer_offset =
(save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
+   assert(old_offset <= buffer_offset);
+   const GLintptr offset_diff = buffer_offset - old_offset;
GLuint start_offset = 0;
-   if (0 < buffer_offset && 0 < stride && buffer_offset % stride == 0) {
+   if (offset_diff > 0 && stride > 0 && offset_diff % stride == 0) {
   /* The vertex size is an exact multiple of the buffer offset.
* This means that we can use zero-based vertex attribute pointers
* and specify the start of the primitive with the _mesa_prim::start
@@ -558,8 +565,9 @@ compile_vertex_list(struct gl_context *ctx)
   /* We cannot immediately update the primitives as some methods below
* still need the uncorrected start vertices
*/
-  start_offset = buffer_offset/stride;
-  buffer_offset = 0;
+  start_offset = offset_diff/stride;
+  assert(old_offset == buffer_offset - offset_diff);
+  buffer_offset = old_offset;
}
GLuint offsets[VBO_ATTRIB_MAX];
for (unsigned i = 0, offset = 0; i < VBO_ATTRIB_MAX; ++i) {
@@ -666,6 +674,9 @@ compile_vertex_list(struct gl_context *ctx)
*/
   free_vertex_store(ctx, save->vertex_store);
   save->vertex_store = NULL;
+  /* When we have a new vbo, we will for sure need a new vao */
+  for (gl_vertex_processing_mode vpm = 0; vpm < VP_MODE_MAX; ++vpm)
+ _mesa_reference_vao(ctx, &save->VAO[vpm], NULL);
 
   /* Allocate and map new store:
*/

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove vbo_save_vertex_list::attrtype.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 95b4be4f29fab106cee715dd96657be044e54654
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=95b4be4f29fab106cee715dd96657be044e54654

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove vbo_save_vertex_list::attrtype.

Is not used anymore on replay, move the last use in display list
compilation to the original array in the display list compiler.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h | 1 -
 src/mesa/vbo/vbo_save_api.c | 4 +---
 2 files changed, 1 insertion(+), 4 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 4dd886eb12..3ccbfac7e2 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -62,7 +62,6 @@ struct vbo_save_copied_vtx {
  */
 struct vbo_save_vertex_list {
GLubyte attrsz[VBO_ATTRIB_MAX];
-   GLenum16 attrtype[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
struct gl_vertex_array_object *VAO[VP_MODE_MAX];
 
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 95593fc0a7..2263276a18 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -545,8 +545,6 @@ compile_vertex_list(struct gl_context *ctx)
 */
STATIC_ASSERT(sizeof(node->attrsz) == sizeof(save->attrsz));
memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz));
-   STATIC_ASSERT(sizeof(node->attrtype) == sizeof(save->attrtype));
-   memcpy(node->attrtype, save->attrtype, sizeof(node->attrtype));
node->vertex_size = save->vertex_size;
node->buffer_offset =
   (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
@@ -582,7 +580,7 @@ compile_vertex_list(struct gl_context *ctx)
   update_vao(ctx, vpm, &save->VAO[vpm],
  save->vertex_store->bufferobj, buffer_offset,
  node->vertex_size*sizeof(GLfloat), save->enabled,
- node->attrsz, node->attrtype, offsets);
+ node->attrsz, save->attrtype, offsets);
   /* Reference the vao in the dlist */
   node->VAO[vpm] = NULL;
   _mesa_reference_vao(ctx, &node->VAO[vpm], save->VAO[vpm]);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove vbo_save_vertex_list::vertex_size.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4c232dc721645c147c864f102268a52c9536096d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4c232dc721645c147c864f102268a52c9536096d

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove vbo_save_vertex_list::vertex_size.

Like before use local variables from compile_vertex_list instead.
Remove vertex_size from struct vbo_save_vertex_list.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h |  1 -
 src/mesa/vbo/vbo_save_api.c | 14 ++
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index a9834d6e6d..b158c07795 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -61,7 +61,6 @@ struct vbo_save_copied_vtx {
  * compiled using the fallback opcode mechanism provided by dlist.c.
  */
 struct vbo_save_vertex_list {
-   GLuint vertex_size;  /**< size in GLfloats */
struct gl_vertex_array_object *VAO[VP_MODE_MAX];
 
/* Copy of the final vertex from node->vertex_store->bufferobj.
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index e6cd04281e..47ee355e72 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -543,7 +543,6 @@ compile_vertex_list(struct gl_context *ctx)
/* Duplicate our template, increment refcounts to the storage structs:
 */
const GLsizei stride = save->vertex_size*sizeof(GLfloat);
-   node->vertex_size = save->vertex_size;
GLintptr buffer_offset =
(save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
GLuint start_offset = 0;
@@ -579,9 +578,8 @@ compile_vertex_list(struct gl_context *ctx)
for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm) {
   /* create or reuse the vao */
   update_vao(ctx, vpm, &save->VAO[vpm],
- save->vertex_store->bufferobj, buffer_offset,
- node->vertex_size*sizeof(GLfloat), save->enabled,
- save->attrsz, save->attrtype, offsets);
+ save->vertex_store->bufferobj, buffer_offset, stride,
+ save->enabled, save->attrsz, save->attrtype, offsets);
   /* Reference the vao in the dlist */
   node->VAO[vpm] = NULL;
   _mesa_reference_vao(ctx, &node->VAO[vpm], save->VAO[vpm]);
@@ -593,7 +591,7 @@ compile_vertex_list(struct gl_context *ctx)
   node->current_data = NULL;
}
else {
-  GLuint current_size = node->vertex_size - save->attrsz[0];
+  GLuint current_size = save->vertex_size - save->attrsz[0];
   node->current_data = NULL;
 
   if (current_size) {
@@ -604,8 +602,7 @@ compile_vertex_list(struct gl_context *ctx)
 unsigned vertex_offset = 0;
 
 if (node->vertex_count)
-   vertex_offset =
-  (node->vertex_count - 1) * node->vertex_size * 
sizeof(GLfloat);
+   vertex_offset = (node->vertex_count - 1) * stride;
 
 memcpy(node->current_data, buffer + vertex_offset + attr_offset,
current_size * sizeof(GLfloat));
@@ -1817,11 +1814,12 @@ vbo_print_vertex_list(struct gl_context *ctx, void 
*data, FILE *f)
struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data;
GLuint i;
struct gl_buffer_object *buffer = node->VAO[0]->BufferBinding[0].BufferObj;
+   const GLuint vertex_size = _vbo_save_get_stride(node)/sizeof(GLfloat);
(void) ctx;
 
fprintf(f, "VBO-VERTEX-LIST, %u vertices, %d primitives, %d vertsize, "
"buffer %p\n",
-   node->vertex_count, node->prim_count, node->vertex_size,
+   node->vertex_count, node->prim_count, vertex_size,
buffer);
 
for (i = 0; i < node->prim_count; i++) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Implement current values update in terms of the VAO.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 6e410270ee73f21c4363c8d9cc8f4eef4bf949b1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6e410270ee73f21c4363c8d9cc8f4eef4bf949b1

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Implement current values update in terms of the VAO.

Use the information already present in the VAO to update the current values
after display list replay. Set GL_OUT_OF_MEMORY on allocation failure
for the current value update storage.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h  |  1 -
 src/mesa/vbo/vbo_save_api.c  | 14 +++
 src/mesa/vbo/vbo_save_draw.c | 94 +++-
 3 files changed, 47 insertions(+), 62 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 44dc8c201f..00f18363b7 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -72,7 +72,6 @@ struct vbo_save_vertex_list {
 * map/unmap of the VBO when updating GL current data.
 */
fi_type *current_data;
-   GLuint current_size;
 
GLuint buffer_offset;/**< in bytes */
GLuint start_vertex; /**< first vertex used by any primitive */
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index dc248934f7..db9a3fbdfa 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -595,18 +595,14 @@ compile_vertex_list(struct gl_context *ctx)
node->prim_store->refcount++;
 
if (node->prims[0].no_current_update) {
-  node->current_size = 0;
   node->current_data = NULL;
}
else {
-  node->current_size = node->vertex_size - node->attrsz[0];
+  GLuint current_size = node->vertex_size - node->attrsz[0];
   node->current_data = NULL;
 
-  if (node->current_size) {
- /* If the malloc fails, we just pull the data out of the VBO
-  * later instead.
-  */
- node->current_data = malloc(node->current_size * sizeof(GLfloat));
+  if (current_size) {
+ node->current_data = malloc(current_size * sizeof(GLfloat));
  if (node->current_data) {
 const char *buffer = (const char *) save->vertex_store->buffer_map;
 unsigned attr_offset = node->attrsz[0] * sizeof(GLfloat);
@@ -618,7 +614,9 @@ compile_vertex_list(struct gl_context *ctx)
 
 memcpy(node->current_data,
buffer + node->buffer_offset + vertex_offset + attr_offset,
-   node->current_size * sizeof(GLfloat));
+   current_size * sizeof(GLfloat));
+ } else {
+_mesa_error(ctx, GL_OUT_OF_MEMORY, "Current value allocation");
  }
   }
}
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 0358ecd2f9..b8b6b872c0 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -42,72 +42,60 @@
 #include "vbo_private.h"
 
 
-/**
- * After playback, copy everything but the position from the
- * last vertex to the saved state
- */
 static void
-playback_copy_to_current(struct gl_context *ctx,
- const struct vbo_save_vertex_list *node)
+copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao,
+ GLbitfield mask, GLbitfield state, int shift, fi_type **data)
 {
struct vbo_context *vbo = vbo_context(ctx);
-   fi_type vertex[VBO_ATTRIB_MAX * 4];
-   fi_type *data;
-   GLbitfield64 mask;
-
-   if (node->current_size == 0)
-  return;
-
-   if (node->current_data) {
-  data = node->current_data;
-   }
-   else {
-  /* Position of last vertex */
-  const GLuint pos = node->vertex_count > 0 ? node->vertex_count - 1 : 0;
-  /* Offset to last vertex in the vertex buffer */
-  const GLuint offset = node->buffer_offset
- + pos * node->vertex_size * sizeof(GLfloat);
-
-  data = vertex;
-
-  ctx->Driver.GetBufferSubData(ctx, offset,
-   node->vertex_size * sizeof(GLfloat),
-   data, node->vertex_store->bufferobj);
-
-  data += node->attrsz[0]; /* skip vertex position */
-   }
 
-   mask = node->enabled & (~BITFIELD64_BIT(VBO_ATTRIB_POS));
+   mask &= vao->_Enabled;
while (mask) {
-  const int i = u_bit_scan64(&mask);
-  fi_type *current = (fi_type *)vbo->currval[i].Ptr;
+  const int i = u_bit_scan(&mask);
+  const struct gl_array_attributes *attrib = &vao->VertexAttrib[i];
+  struct gl_vertex_array *currval = &vbo->currval[shift + i];
+  const GLubyte size = attrib->Size;
+  const GLenum16 type = attrib->Type;
   fi_type tmp[4];
-  assert(node->attrsz[i]);
 
-  COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
-  node->attrsz[i],
-   

Mesa (master): vbo: Remove vbo_save_vertex_list::start_vertex.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: bfa8d8e5bf5a2f2f5b727acde0b4dad34d0c4210
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=bfa8d8e5bf5a2f2f5b727acde0b4dad34d0c4210

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove vbo_save_vertex_list::start_vertex.

Replace last use on replay with _vbo_save_get_{min,max}_index. Appart from
that it is not used anymore.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h  | 1 -
 src/mesa/vbo/vbo_save_api.c  | 3 ---
 src/mesa/vbo/vbo_save_draw.c | 4 ++--
 3 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index cbf73892ee..51ca3c2614 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -71,7 +71,6 @@ struct vbo_save_vertex_list {
fi_type *current_data;
 
GLuint buffer_offset;/**< in bytes */
-   GLuint start_vertex; /**< first vertex used by any primitive */
GLuint vertex_count; /**< number of vertices in this list */
GLuint wrap_count;  /* number of copied vertices at start */
 
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index e21315120d..e8d027f15c 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -642,9 +642,6 @@ compile_vertex_list(struct gl_context *ctx)
   for (unsigned i = 0; i < node->prim_count; i++) {
  node->prims[i].start += start_offset;
   }
-  node->start_vertex = start_offset;
-   } else {
-  node->start_vertex = 0;
}
 
/* Deal with GL_COMPILE_AND_EXECUTE:
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index b8b6b872c0..137fb6e3fd 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -213,8 +213,8 @@ vbo_save_playback_vertex_list(struct gl_context *ctx, void 
*data)
   assert(ctx->NewState == 0);
 
   if (node->vertex_count > 0) {
- GLuint min_index = node->start_vertex;
- GLuint max_index = min_index + node->vertex_count - 1;
+ GLuint min_index = _vbo_save_get_min_index(node);
+ GLuint max_index = _vbo_save_get_max_index(node);
  vbo->draw_prims(ctx,
  node->prims,
  node->prim_count,

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove vbo_save_vertex_list::enabled.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 77df52cc4febb45008db4cfca3c144482a3a8578
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=77df52cc4febb45008db4cfca3c144482a3a8578

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove vbo_save_vertex_list::enabled.

Is not used anymore on replay.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h | 1 -
 src/mesa/vbo/vbo_save_api.c | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index f4565023fd..4dd886eb12 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -61,7 +61,6 @@ struct vbo_save_copied_vtx {
  * compiled using the fallback opcode mechanism provided by dlist.c.
  */
 struct vbo_save_vertex_list {
-   GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];
GLenum16 attrtype[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 8dac6251c4..95593fc0a7 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -543,7 +543,6 @@ compile_vertex_list(struct gl_context *ctx)
 
/* Duplicate our template, increment refcounts to the storage structs:
 */
-   node->enabled = save->enabled;
STATIC_ASSERT(sizeof(node->attrsz) == sizeof(save->attrsz));
memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz));
STATIC_ASSERT(sizeof(node->attrtype) == sizeof(save->attrtype));
@@ -582,7 +581,7 @@ compile_vertex_list(struct gl_context *ctx)
   /* create or reuse the vao */
   update_vao(ctx, vpm, &save->VAO[vpm],
  save->vertex_store->bufferobj, buffer_offset,
- node->vertex_size*sizeof(GLfloat), node->enabled,
+ node->vertex_size*sizeof(GLfloat), save->enabled,
  node->attrsz, node->attrtype, offsets);
   /* Reference the vao in the dlist */
   node->VAO[vpm] = NULL;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove vbo_save_vertex_list::buffer_offset.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 478a9bc7bb6870993e2a8df97b2dab1d4e45a723
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=478a9bc7bb6870993e2a8df97b2dab1d4e45a723

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove vbo_save_vertex_list::buffer_offset.

The buffer_offset is used in aligned_vertex_buffer_offset.
But now that most of these decisions are done in compile_vertex_list
we can work on local variables instead of struct members in the
display list code. Clean that up and remove buffer_offset.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h | 14 --
 src/mesa/vbo/vbo_save_api.c | 28 +---
 2 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 51ca3c2614..a9834d6e6d 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -70,7 +70,6 @@ struct vbo_save_vertex_list {
 */
fi_type *current_data;
 
-   GLuint buffer_offset;/**< in bytes */
GLuint vertex_count; /**< number of vertices in this list */
GLuint wrap_count;  /* number of copied vertices at start */
 
@@ -82,19 +81,6 @@ struct vbo_save_vertex_list {
 
 
 /**
- * Is the vertex list's buffer offset an exact multiple of the
- * vertex size (in bytes)?  This is used to check for a vertex array /
- * drawing optimization.
- */
-static inline bool
-aligned_vertex_buffer_offset(const struct vbo_save_vertex_list *node)
-{
-   unsigned vertex_size = node->vertex_size * sizeof(GLfloat); /* in bytes */
-   return vertex_size != 0 && node->buffer_offset % vertex_size == 0;
-}
-
-
-/**
  * Return the stride in bytes of the display list node.
  */
 static inline GLsizei
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index e8d027f15c..e6cd04281e 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -527,7 +527,6 @@ compile_vertex_list(struct gl_context *ctx)
 {
struct vbo_save_context *save = &vbo_context(ctx)->save;
struct vbo_save_vertex_list *node;
-   GLintptr buffer_offset = 0;
 
/* Allocate space for this structure in the display list currently
 * being compiled.
@@ -543,10 +542,12 @@ compile_vertex_list(struct gl_context *ctx)
 
/* Duplicate our template, increment refcounts to the storage structs:
 */
+   const GLsizei stride = save->vertex_size*sizeof(GLfloat);
node->vertex_size = save->vertex_size;
-   node->buffer_offset =
-  (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
-   if (aligned_vertex_buffer_offset(node)) {
+   GLintptr buffer_offset =
+   (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
+   GLuint start_offset = 0;
+   if (0 < buffer_offset && 0 < stride && buffer_offset % stride == 0) {
   /* The vertex size is an exact multiple of the buffer offset.
* This means that we can use zero-based vertex attribute pointers
* and specify the start of the primitive with the _mesa_prim::start
@@ -555,9 +556,11 @@ compile_vertex_list(struct gl_context *ctx)
* changes in drivers.  In particular, the Gallium CSO module will
* filter out redundant vertex buffer changes.
*/
+  /* We cannot immediately update the primitives as some methods below
+   * still need the uncorrected start vertices
+   */
+  start_offset = buffer_offset/stride;
   buffer_offset = 0;
-   } else {
-  buffer_offset = node->buffer_offset;
}
GLuint offsets[VBO_ATTRIB_MAX];
for (unsigned i = 0, offset = 0; i < VBO_ATTRIB_MAX; ++i) {
@@ -596,7 +599,7 @@ compile_vertex_list(struct gl_context *ctx)
   if (current_size) {
  node->current_data = malloc(current_size * sizeof(GLfloat));
  if (node->current_data) {
-const char *buffer = (const char *) save->vertex_store->buffer_map;
+const char *buffer = (const char *)save->buffer_map;
 unsigned attr_offset = save->attrsz[0] * sizeof(GLfloat);
 unsigned vertex_offset = 0;
 
@@ -604,8 +607,7 @@ compile_vertex_list(struct gl_context *ctx)
vertex_offset =
   (node->vertex_count - 1) * node->vertex_size * 
sizeof(GLfloat);
 
-memcpy(node->current_data,
-   buffer + node->buffer_offset + vertex_offset + attr_offset,
+memcpy(node->current_data, buffer + vertex_offset + attr_offset,
current_size * sizeof(GLfloat));
  } else {
 _mesa_error(ctx, GL_OUT_OF_MEMORY, "Current value allocation");
@@ -636,12 +638,8 @@ compile_vertex_list(struct gl_context *ctx)
 * On the other hand the _vbo_loopback_vertex_list call below needs the
 * primitves to be corrected already.
 */
-   if (aligned_v

Mesa (master): vbo: Remove vbo_save_vertex_list::attrsz.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 6dd3e98c213f8c82a934c49eb369e88f5a648f19
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6dd3e98c213f8c82a934c49eb369e88f5a648f19

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove vbo_save_vertex_list::attrsz.

Is not used anymore on replay, move the last use in display list
compilation to the original array in the display list compiler.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h |  1 -
 src/mesa/vbo/vbo_save_api.c | 10 --
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 3ccbfac7e2..cbf73892ee 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -61,7 +61,6 @@ struct vbo_save_copied_vtx {
  * compiled using the fallback opcode mechanism provided by dlist.c.
  */
 struct vbo_save_vertex_list {
-   GLubyte attrsz[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
struct gl_vertex_array_object *VAO[VP_MODE_MAX];
 
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 2263276a18..e21315120d 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -543,8 +543,6 @@ compile_vertex_list(struct gl_context *ctx)
 
/* Duplicate our template, increment refcounts to the storage structs:
 */
-   STATIC_ASSERT(sizeof(node->attrsz) == sizeof(save->attrsz));
-   memcpy(node->attrsz, save->attrsz, sizeof(node->attrsz));
node->vertex_size = save->vertex_size;
node->buffer_offset =
   (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
@@ -580,7 +578,7 @@ compile_vertex_list(struct gl_context *ctx)
   update_vao(ctx, vpm, &save->VAO[vpm],
  save->vertex_store->bufferobj, buffer_offset,
  node->vertex_size*sizeof(GLfloat), save->enabled,
- node->attrsz, save->attrtype, offsets);
+ save->attrsz, save->attrtype, offsets);
   /* Reference the vao in the dlist */
   node->VAO[vpm] = NULL;
   _mesa_reference_vao(ctx, &node->VAO[vpm], save->VAO[vpm]);
@@ -592,14 +590,14 @@ compile_vertex_list(struct gl_context *ctx)
   node->current_data = NULL;
}
else {
-  GLuint current_size = node->vertex_size - node->attrsz[0];
+  GLuint current_size = node->vertex_size - save->attrsz[0];
   node->current_data = NULL;
 
   if (current_size) {
  node->current_data = malloc(current_size * sizeof(GLfloat));
  if (node->current_data) {
 const char *buffer = (const char *) save->vertex_store->buffer_map;
-unsigned attr_offset = node->attrsz[0] * sizeof(GLfloat);
+unsigned attr_offset = save->attrsz[0] * sizeof(GLfloat);
 unsigned vertex_offset = 0;
 
 if (node->vertex_count)
@@ -615,7 +613,7 @@ compile_vertex_list(struct gl_context *ctx)
   }
}
 
-   assert(node->attrsz[VBO_ATTRIB_POS] != 0 || node->vertex_count == 0);
+   assert(save->attrsz[VBO_ATTRIB_POS] != 0 || node->vertex_count == 0);
 
if (save->dangling_attr_ref)
   ctx->ListState.CurrentList->Flags |= DLIST_DANGLING_REFS;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove unused vbo_save_vertex_list::dangling_attr_ref.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 07915020f0de9f5f1e8865bb61e2cf0d673ff278
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=07915020f0de9f5f1e8865bb61e2cf0d673ff278

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove unused vbo_save_vertex_list::dangling_attr_ref.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h | 2 --
 src/mesa/vbo/vbo_save_api.c | 1 -
 2 files changed, 3 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index edbce3673d..ee3de0fedb 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -79,8 +79,6 @@ struct vbo_save_vertex_list {
GLuint start_vertex; /**< first vertex used by any primitive */
GLuint vertex_count; /**< number of vertices in this list */
GLuint wrap_count;  /* number of copied vertices at start */
-   GLboolean dangling_attr_ref;/* current attr implicitly referenced
-   outside the list */
 
struct _mesa_prim *prims;
GLuint prim_count;
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index 1edf7b9dfa..a87bbe0856 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -573,7 +573,6 @@ compile_vertex_list(struct gl_context *ctx)
}
node->vertex_count = save->vert_count;
node->wrap_count = save->copied.nr;
-   node->dangling_attr_ref = save->dangling_attr_ref;
node->prims = save->prims;
node->prim_count = save->prim_count;
node->vertex_store = save->vertex_store;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove unused vbo_save_context::wrap_count.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 1cc3516a1105c90214b2e3465421681f64699a7f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1cc3516a1105c90214b2e3465421681f64699a7f

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove unused vbo_save_context::wrap_count.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index ee3de0fedb..414a477f31 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -149,7 +149,6 @@ struct vbo_save_context {
 
GLboolean out_of_memory;  /**< True if last VBO allocation failed */
 
-   GLuint wrap_count;
GLbitfield replay_flags;
 
struct _mesa_prim *prims;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Use a local variable for the dlist offsets.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: f7178d677ca6a072455ff45b328b1078175a93b6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7178d677ca6a072455ff45b328b1078175a93b6

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Use a local variable for the dlist offsets.

The master value is now stored inside the VAO already present in
struct vbo_save_vertex_list. Remove the unneeded copy from dlist storage.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h |  1 -
 src/mesa/vbo/vbo_save_api.c | 15 +++
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 414a477f31..14ac831ffd 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -64,7 +64,6 @@ struct vbo_save_vertex_list {
GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];
GLenum16 attrtype[VBO_ATTRIB_MAX];
-   GLuint offsets[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
struct gl_vertex_array_object *VAO[VP_MODE_MAX];
 
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index a87bbe0856..b6fc7daa35 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -529,8 +529,6 @@ compile_vertex_list(struct gl_context *ctx)
struct vbo_save_context *save = &vbo_context(ctx)->save;
struct vbo_save_vertex_list *node;
GLintptr buffer_offset = 0;
-   GLuint offset;
-   unsigned i;
 
/* Allocate space for this structure in the display list currently
 * being compiled.
@@ -563,13 +561,14 @@ compile_vertex_list(struct gl_context *ctx)
* changes in drivers.  In particular, the Gallium CSO module will
* filter out redundant vertex buffer changes.
*/
-  offset = 0;
+  buffer_offset = 0;
} else {
-  offset = node->buffer_offset;
+  buffer_offset = node->buffer_offset;
}
-   for (i = 0; i < VBO_ATTRIB_MAX; ++i) {
-  node->offsets[i] = offset;
-  offset += node->attrsz[i] * sizeof(GLfloat);
+   GLuint offsets[VBO_ATTRIB_MAX];
+   for (unsigned i = 0, offset = 0; i < VBO_ATTRIB_MAX; ++i) {
+  offsets[i] = offset;
+  offset += save->attrsz[i] * sizeof(GLfloat);
}
node->vertex_count = save->vert_count;
node->wrap_count = save->copied.nr;
@@ -586,7 +585,7 @@ compile_vertex_list(struct gl_context *ctx)
   update_vao(ctx, vpm, &save->VAO[vpm],
  node->vertex_store->bufferobj, buffer_offset,
  node->vertex_size*sizeof(GLfloat), node->enabled,
- node->attrsz, node->attrtype, node->offsets);
+ node->attrsz, node->attrtype, offsets);
   /* Reference the vao in the dlist */
   node->VAO[vpm] = NULL;
   _mesa_reference_vao(ctx, &node->VAO[vpm], save->VAO[vpm]);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove reference to the vertex_store from the dlist node.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 19a0f27a491ae7cb3abceda8e60b9944cd273558
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=19a0f27a491ae7cb3abceda8e60b9944cd273558

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Remove reference to the vertex_store from the dlist node.

Since we now store a set of VAOs in the display list, use these object
to get the reference to the VBO in several places.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.c | 11 +--
 src/mesa/vbo/vbo_save.h |  6 ++
 src/mesa/vbo/vbo_save_api.c | 14 +++---
 3 files changed, 10 insertions(+), 21 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c
index f106cf279a..361964195c 100644
--- a/src/mesa/vbo/vbo_save.c
+++ b/src/mesa/vbo/vbo_save.c
@@ -65,12 +65,11 @@ void vbo_save_destroy( struct gl_context *ctx )
  free(save->prim_store);
  save->prim_store = NULL;
   }
-  if ( --save->vertex_store->refcount == 0 ) {
- _mesa_reference_buffer_object(ctx,
-   &save->vertex_store->bufferobj, NULL);
- free(save->vertex_store);
- save->vertex_store = NULL;
-  }
+   }
+   if (save->vertex_store) {
+  _mesa_reference_buffer_object(ctx, &save->vertex_store->bufferobj, NULL);
+  free(save->vertex_store);
+  save->vertex_store = NULL;
}
 }
 
diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 00f18363b7..f4565023fd 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -81,7 +81,6 @@ struct vbo_save_vertex_list {
struct _mesa_prim *prims;
GLuint prim_count;
 
-   struct vbo_save_vertex_store *vertex_store;
struct vbo_save_primitive_store *prim_store;
 };
 
@@ -163,15 +162,14 @@ _vbo_save_get_vertex_count(const struct 
vbo_save_vertex_list *node)
 
 #define VBO_SAVE_FALLBACK0x1000
 
-/* Storage to be shared among several vertex_lists.
- */
 struct vbo_save_vertex_store {
struct gl_buffer_object *bufferobj;
fi_type *buffer_map;
GLuint used;   /**< Number of 4-byte words used in buffer */
-   GLuint refcount;
 };
 
+/* Storage to be shared among several vertex_lists.
+ */
 struct vbo_save_primitive_store {
struct _mesa_prim prims[VBO_SAVE_PRIM_SIZE];
GLuint used;
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index db9a3fbdfa..8dac6251c4 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -222,7 +222,6 @@ alloc_vertex_store(struct gl_context *ctx)
 
vertex_store->buffer_map = NULL;
vertex_store->used = 0;
-   vertex_store->refcount = 1;
 
return vertex_store;
 }
@@ -574,7 +573,6 @@ compile_vertex_list(struct gl_context *ctx)
node->wrap_count = save->copied.nr;
node->prims = save->prims;
node->prim_count = save->prim_count;
-   node->vertex_store = save->vertex_store;
node->prim_store = save->prim_store;
 
/* Create a pair of VAOs for the possible VERTEX_PROCESSING_MODEs
@@ -583,7 +581,7 @@ compile_vertex_list(struct gl_context *ctx)
for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm) {
   /* create or reuse the vao */
   update_vao(ctx, vpm, &save->VAO[vpm],
- node->vertex_store->bufferobj, buffer_offset,
+ save->vertex_store->bufferobj, buffer_offset,
  node->vertex_size*sizeof(GLfloat), node->enabled,
  node->attrsz, node->attrtype, offsets);
   /* Reference the vao in the dlist */
@@ -591,7 +589,6 @@ compile_vertex_list(struct gl_context *ctx)
   _mesa_reference_vao(ctx, &node->VAO[vpm], save->VAO[vpm]);
}
 
-   node->vertex_store->refcount++;
node->prim_store->refcount++;
 
if (node->prims[0].no_current_update) {
@@ -680,8 +677,7 @@ compile_vertex_list(struct gl_context *ctx)
 
   /* Release old reference:
*/
-  save->vertex_store->refcount--;
-  assert(save->vertex_store->refcount != 0);
+  free_vertex_store(ctx, save->vertex_store);
   save->vertex_store = NULL;
 
   /* Allocate and map new store:
@@ -1817,9 +1813,6 @@ vbo_destroy_vertex_list(struct gl_context *ctx, void 
*data)
for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm)
   _mesa_reference_vao(ctx, &node->VAO[vpm], NULL);
 
-   if (--node->vertex_store->refcount == 0)
-  free_vertex_store(ctx, node->vertex_store);
-
if (--node->prim_store->refcount == 0)
   free(node->prim_store);
 
@@ -1833,8 +1826,7 @@ vbo_print_vertex_list(struct gl_context *ctx, void *data, 
FILE *f)
 {
struct vbo_save_vertex_list *node = (struct vbo_save_vertex_list *) data;
GLuint i;
-   struct gl_buffer_object *buffer = node->vertex_st

Mesa (master): vbo: Implement vbo_loopback_vertex_list in terms of the VAO.

2018-02-28 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 08aa0d9bf49ea74f84b19cd11a0f0ace7ce7211a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=08aa0d9bf49ea74f84b19cd11a0f0ace7ce7211a

Author: Mathias Fröhlich 
Date:   Sun Feb 25 18:01:07 2018 +0100

vbo: Implement vbo_loopback_vertex_list in terms of the VAO.

Use the information already present in the VAO to replay a display list
node using immediate mode draw commands. Use a hand full of helper methods
that will be useful for the next patches also.

v2: Insert asserts, constify local variables.

Reviewed-by: Brian Paul 
Signed-off-by: Mathias Fröhlich 

---

 src/mesa/vbo/vbo_save.h  |  55 +++---
 src/mesa/vbo/vbo_save_api.c  |  42 ++
 src/mesa/vbo/vbo_save_draw.c |  28 +++--
 src/mesa/vbo/vbo_save_loopback.c | 119 +--
 4 files changed, 151 insertions(+), 93 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 14ac831ffd..44dc8c201f 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -100,6 +100,52 @@ aligned_vertex_buffer_offset(const struct 
vbo_save_vertex_list *node)
 }
 
 
+/**
+ * Return the stride in bytes of the display list node.
+ */
+static inline GLsizei
+_vbo_save_get_stride(const struct vbo_save_vertex_list *node)
+{
+   return node->VAO[0]->BufferBinding[0].Stride;
+}
+
+
+/**
+ * Return the first referenced vertex index in the display list node.
+ */
+static inline GLuint
+_vbo_save_get_min_index(const struct vbo_save_vertex_list *node)
+{
+   assert(node->prim_count > 0);
+   return node->prims[0].start;
+}
+
+
+/**
+ * Return the last referenced vertex index in the display list node.
+ */
+static inline GLuint
+_vbo_save_get_max_index(const struct vbo_save_vertex_list *node)
+{
+   assert(node->prim_count > 0);
+   const struct _mesa_prim *last_prim = &node->prims[node->prim_count - 1];
+   return last_prim->start + last_prim->count - 1;
+}
+
+
+/**
+ * Return the vertex count in the display list node.
+ */
+static inline GLuint
+_vbo_save_get_vertex_count(const struct vbo_save_vertex_list *node)
+{
+   assert(node->prim_count > 0);
+   const struct _mesa_prim *first_prim = &node->prims[0];
+   const struct _mesa_prim *last_prim = &node->prims[node->prim_count - 1];
+   return last_prim->start - first_prim->start + last_prim->count;
+}
+
+
 /* These buffers should be a reasonable size to support upload to
  * hardware.  Current vbo implementation will re-upload on any
  * changes, so don't make too big or apps which dynamically create
@@ -178,13 +224,8 @@ void vbo_save_fallback(struct gl_context *ctx, GLboolean 
fallback);
 
 /* save_loopback.c:
  */
-void vbo_loopback_vertex_list(struct gl_context *ctx,
-  const GLfloat *buffer,
-  const GLubyte *attrsz,
-  const struct _mesa_prim *prim,
-  GLuint prim_count,
-  GLuint wrap_count,
-  GLuint vertex_size);
+void _vbo_loopback_vertex_list(struct gl_context *ctx,
+   const struct vbo_save_vertex_list* node);
 
 /* Callbacks:
  */
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index b6fc7daa35..dc248934f7 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -641,6 +641,22 @@ compile_vertex_list(struct gl_context *ctx)
 
merge_prims(node->prims, &node->prim_count);
 
+   /* Correct the primitive starts, we can only do this here as copy_vertices
+* and convert_line_loop_to_strip above consume the uncorrected starts.
+* On the other hand the _vbo_loopback_vertex_list call below needs the
+* primitves to be corrected already.
+*/
+   if (aligned_vertex_buffer_offset(node)) {
+  const unsigned start_offset =
+ node->buffer_offset / (node->vertex_size * sizeof(GLfloat));
+  for (unsigned i = 0; i < node->prim_count; i++) {
+ node->prims[i].start += start_offset;
+  }
+  node->start_vertex = start_offset;
+   } else {
+  node->start_vertex = 0;
+   }
+
/* Deal with GL_COMPILE_AND_EXECUTE:
 */
if (ctx->ExecuteFlag) {
@@ -648,13 +664,8 @@ compile_vertex_list(struct gl_context *ctx)
 
   _glapi_set_dispatch(ctx->Exec);
 
-  const GLfloat *buffer = (const GLfloat *)
- ((const char *) save->vertex_store->buffer_map +
-  node->buffer_offset);
-
-  vbo_loopback_vertex_list(ctx, buffer,
-   node->attrsz, node->prims, node->prim_count,
-   node->wrap_count, node->vertex_size);
+  /* Note that the range of referenced vertices must be mapped already */
+  _vbo_loopback_vertex_list(ctx, node);
 
   _glapi_set_dispatch(dispatch);
}
@@ -693,23 +704,6 

Mesa (master): mesa: Update vertex processing mode on _mesa_UseProgram.

2018-02-23 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: b54bf0e3e3378725dec924f8152dcb012dffcd2e
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b54bf0e3e3378725dec924f8152dcb012dffcd2e

Author: Mathias Fröhlich 
Date:   Fri Feb 23 20:46:20 2018 +0100

mesa: Update vertex processing mode on _mesa_UseProgram.

The change is a bug fix for 92d76a169:
  mesa: Provide an alternative to get_vp_mode()
that actually got exposed through 4562a7b0:
  vbo: Make use of _DrawVAO from the dlist code.

Fixes: KHR-GLES31.core.shader_image_load_store.advanced-sso-simple
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105229
Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/shaderapi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 59089a12b0..76bad7f31e 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2069,6 +2069,8 @@ use_program(GLuint program, bool no_error)
 _mesa_BindProgramPipeline(ctx->Pipeline.Current->Name);
   }
}
+
+   _mesa_update_vertex_processing_mode(ctx);
 }
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Make use of _DrawVAO from immediate mode draw

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 8a3a4b6fae75905088ce4fcb42fc50cb09763a10
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a3a4b6fae75905088ce4fcb42fc50cb09763a10

Author: Mathias Fröhlich 
Date:   Wed Feb  7 08:59:13 2018 +0100

vbo: Make use of _DrawVAO from immediate mode draw

Finally use an internal VAO to execute immediate mode draws. Avoid
duplicate state validation for immediate mode draws. Remove client arrays
previously used exclusively for immediate mode draws.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_context.c   |   8 +++
 src/mesa/vbo/vbo_exec.h  |   8 ---
 src/mesa/vbo/vbo_exec_api.c  |  47 +
 src/mesa/vbo/vbo_exec_draw.c | 117 ---
 src/mesa/vbo/vbo_private.h   |   2 +
 5 files changed, 78 insertions(+), 104 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 222bdcf1f2..3dc3222c0d 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -30,6 +30,8 @@
 #include "math/m_eval.h"
 #include "main/vtxfmt.h"
 #include "main/api_arrayelt.h"
+#include "main/arrayobj.h"
+#include "main/varray.h"
 #include "vbo.h"
 #include "vbo_private.h"
 
@@ -252,6 +254,11 @@ _vbo_CreateContext(struct gl_context *ctx)
if (ctx->API == API_OPENGL_COMPAT)
   vbo_save_init(ctx);
 
+   vbo->VAO = _mesa_new_vao(ctx, ~((GLuint)0));
+   /* The exec VAO assumes to have all arributes bound to binding 0 */
+   for (unsigned i = 0; i < VERT_ATTRIB_MAX; ++i)
+  _mesa_vertex_attrib_binding(ctx, vbo->VAO, i, 0, false);
+
_math_init_eval();
 
return GL_TRUE;
@@ -278,6 +285,7 @@ _vbo_DestroyContext(struct gl_context *ctx)
   vbo_exec_destroy(ctx);
   if (ctx->API == API_OPENGL_COMPAT)
  vbo_save_destroy(ctx);
+  _mesa_reference_vao(ctx, &vbo->VAO, NULL);
   free(vbo);
   ctx->vbo_context = NULL;
}
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index b00045c7c8..07ab5cc837 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -101,14 +101,6 @@ struct vbo_exec_context
 
   /** pointers into the current 'vertex' array, declared above */
   fi_type *attrptr[VBO_ATTRIB_MAX];
-
-  struct gl_vertex_array arrays[VERT_ATTRIB_MAX];
-
-  /* According to program mode, the values above plus current
-   * values are squashed down to the 32 attributes passed to the
-   * vertex program below:
-   */
-  const struct gl_vertex_array *inputs[VERT_ATTRIB_MAX];
} vtx;
 
struct {
diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c
index 64e792bfa2..317fc43d1c 100644
--- a/src/mesa/vbo/vbo_exec_api.c
+++ b/src/mesa/vbo/vbo_exec_api.c
@@ -758,7 +758,8 @@ static void GLAPIENTRY
 vbo_exec_Begin(GLenum mode)
 {
GET_CURRENT_CONTEXT(ctx);
-   struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
+   struct vbo_context *vbo = vbo_context(ctx);
+   struct vbo_exec_context *exec = &vbo->exec;
int i;
 
if (_mesa_inside_begin_end(ctx)) {
@@ -770,8 +771,6 @@ vbo_exec_Begin(GLenum mode)
   return;
}
 
-   _mesa_set_drawing_arrays(ctx, exec->vtx.inputs);
-
if (ctx->NewState) {
   _mesa_update_state(ctx);
 
@@ -1162,7 +1161,6 @@ void
 vbo_exec_vtx_init(struct vbo_exec_context *exec)
 {
struct gl_context *ctx = exec->ctx;
-   struct vbo_context *vbo = vbo_context(ctx);
GLuint i;
 
/* Allocate a buffer object.  Will just reuse this object
@@ -1189,38 +1187,6 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec)
   assert(i < ARRAY_SIZE(exec->vtx.active_sz));
   exec->vtx.active_sz[i] = 0;
}
-   for (i = 0 ; i < VERT_ATTRIB_MAX; i++) {
-  assert(i < ARRAY_SIZE(exec->vtx.inputs));
-  assert(i < ARRAY_SIZE(exec->vtx.arrays));
-  exec->vtx.inputs[i] = &exec->vtx.arrays[i];
-   }
-
-   {
-  struct gl_vertex_array *arrays = exec->vtx.arrays;
-  unsigned i;
-
-  memcpy(arrays, &vbo->currval[VBO_ATTRIB_POS],
- VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
-  for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
- struct gl_vertex_array *array;
- array = &arrays[VERT_ATTRIB_FF(i)];
- array->BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &array->BufferObj,
-   
vbo->currval[VBO_ATTRIB_POS+i].BufferObj);
-  }
-
-  memcpy(arrays + VERT_ATTRIB_GENERIC(0),
- &vbo->currval[VBO_ATTRIB_GENERIC0],
- VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0]));
-
-  for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) {
- struct gl_vertex_array *array;
- array = &arrays[VERT_ATTRIB_GENERIC(i)];
- array->BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &arr

Mesa (master): mesa: Use atomics for shared VAO reference counts.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 2f351408467a1d2e46927b8df0d3047b67ae2623
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f351408467a1d2e46927b8df0d3047b67ae2623

Author: Mathias Fröhlich 
Date:   Sat Feb  3 15:22:33 2018 +0100

mesa: Use atomics for shared VAO reference counts.

VAOs will be used in the next change as immutable object across multiple
contexts. Only reference counting may write concurrently on the VAO. So,
make the reference count thread safe for those and only those VAO objects.

v3: Use bool/true/false for gl_vertex_array_object::SharedAndImmutable.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/arrayobj.c | 35 ++-
 src/mesa/main/arrayobj.h |  9 +
 src/mesa/main/mtypes.h   |  7 +++
 3 files changed, 46 insertions(+), 5 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index cf9c5d7ecc..2526404fda 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -53,6 +53,7 @@
 #include "varray.h"
 #include "main/dispatch.h"
 #include "util/bitscan.h"
+#include "util/u_atomic.h"
 
 
 const GLubyte
@@ -331,10 +332,16 @@ _mesa_reference_vao_(struct gl_context *ctx,
   /* Unreference the old array object */
   struct gl_vertex_array_object *oldObj = *ptr;
 
-  assert(oldObj->RefCount > 0);
-  oldObj->RefCount--;
+  bool deleteFlag;
+  if (oldObj->SharedAndImmutable) {
+ deleteFlag = p_atomic_dec_zero(&oldObj->RefCount);
+  } else {
+ assert(oldObj->RefCount > 0);
+ oldObj->RefCount--;
+ deleteFlag = (oldObj->RefCount == 0);
+  }
 
-  if (oldObj->RefCount == 0)
+  if (deleteFlag)
  _mesa_delete_vao(ctx, oldObj);
 
   *ptr = NULL;
@@ -343,9 +350,13 @@ _mesa_reference_vao_(struct gl_context *ctx,
 
if (vao) {
   /* reference new array object */
-  assert(vao->RefCount > 0);
+  if (vao->SharedAndImmutable) {
+ p_atomic_inc(&vao->RefCount);
+  } else {
+ assert(vao->RefCount > 0);
+ vao->RefCount++;
+  }
 
-  vao->RefCount++;
   *ptr = vao;
}
 }
@@ -407,6 +418,7 @@ _mesa_initialize_vao(struct gl_context *ctx,
vao->Name = name;
 
vao->RefCount = 1;
+   vao->SharedAndImmutable = false;
 
/* Init the individual arrays */
for (i = 0; i < ARRAY_SIZE(vao->VertexAttrib); i++) {
@@ -452,6 +464,9 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
 {
GLbitfield arrays = vao->NewArrays;
 
+   /* Make sure we do not run into problems with shared objects */
+   assert(!vao->SharedAndImmutable || vao->NewArrays == 0);
+
while (arrays) {
   const int attrib = u_bit_scan(&arrays);
   struct gl_vertex_array *array = &vao->_VertexArray[attrib];
@@ -465,6 +480,16 @@ _mesa_update_vao_derived_arrays(struct gl_context *ctx,
 }
 
 
+void
+_mesa_set_vao_immutable(struct gl_context *ctx,
+struct gl_vertex_array_object *vao)
+{
+   _mesa_update_vao_derived_arrays(ctx, vao);
+   vao->NewArrays = 0;
+   vao->SharedAndImmutable = true;
+}
+
+
 bool
 _mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao)
 {
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 5de74505bb..8da5c9ffe0 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -81,6 +81,15 @@ extern void
 _mesa_update_vao_derived_arrays(struct gl_context *ctx,
 struct gl_vertex_array_object *vao);
 
+
+/**
+ * Mark the vao as shared and immutable, do remaining updates.
+ */
+extern void
+_mesa_set_vao_immutable(struct gl_context *ctx,
+struct gl_vertex_array_object *vao);
+
+
 /* Returns true if all varying arrays reside in vbos */
 extern bool
 _mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index bdecd422a9..15f39cbacc 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1608,6 +1608,13 @@ struct gl_vertex_array_object
GLboolean EverBound;
 
/**
+* Marked to true if the object is shared between contexts and immutable.
+* Then reference counting is done using atomics and thread safe.
+* Is used for dlist VAOs.
+*/
+   bool SharedAndImmutable;
+
+   /**
 * Derived vertex attribute arrays
 *
 * This is a legacy data structure created from gl_array_attributes and

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Make use of _DrawVAO from the dlist code.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4562a7b0e82bf664b30ee72da141d070adc659da
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4562a7b0e82bf664b30ee72da141d070adc659da

Author: Mathias Fröhlich 
Date:   Sat Feb  3 22:25:50 2018 +0100

vbo: Make use of _DrawVAO from the dlist code.

Finally use an internal VAO to execute display list draws. Avoid
duplicate state validation for display list draws. Remove client arrays
previously used exclusively for display lists.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_save.c  |  37 ++--
 src/mesa/vbo/vbo_save.h  |   4 +-
 src/mesa/vbo/vbo_save_api.c  | 132 +--
 src/mesa/vbo/vbo_save_draw.c |  64 -
 4 files changed, 144 insertions(+), 93 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.c b/src/mesa/vbo/vbo_save.c
index 19c40ec530..f106cf279a 100644
--- a/src/mesa/vbo/vbo_save.c
+++ b/src/mesa/vbo/vbo_save.c
@@ -27,6 +27,7 @@
 
 
 #include "main/mtypes.h"
+#include "main/arrayobj.h"
 #include "main/bufferobj.h"
 
 #include "vbo_private.h"
@@ -44,32 +45,8 @@ void vbo_save_init( struct gl_context *ctx )
 
vbo_save_api_init( save );
 
-   {
-  struct gl_vertex_array *arrays = save->arrays;
-  unsigned i;
-
-  memcpy(arrays, &vbo->currval[VBO_ATTRIB_POS],
- VERT_ATTRIB_FF_MAX * sizeof(arrays[0]));
-  for (i = 0; i < VERT_ATTRIB_FF_MAX; ++i) {
- struct gl_vertex_array *array;
- array = &arrays[VERT_ATTRIB_FF(i)];
- array->BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &arrays->BufferObj,
-   
vbo->currval[VBO_ATTRIB_POS+i].BufferObj);
-  }
-
-  memcpy(arrays + VERT_ATTRIB_GENERIC(0),
- &vbo->currval[VBO_ATTRIB_GENERIC0],
- VERT_ATTRIB_GENERIC_MAX * sizeof(arrays[0]));
-
-  for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; ++i) {
- struct gl_vertex_array *array;
- array = &arrays[VERT_ATTRIB_GENERIC(i)];
- array->BufferObj = NULL;
- _mesa_reference_buffer_object(ctx, &array->BufferObj,
-   vbo->currval[VBO_ATTRIB_GENERIC0+i].BufferObj);
-  }
-   }
+   for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm)
+  save->VAO[vpm] = NULL;
 
ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
 }
@@ -79,7 +56,9 @@ void vbo_save_destroy( struct gl_context *ctx )
 {
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_save_context *save = &vbo->save;
-   GLuint i;
+
+   for (gl_vertex_processing_mode vpm = VP_MODE_FF; vpm < VP_MODE_MAX; ++vpm)
+  _mesa_reference_vao(ctx, &save->VAO[vpm], NULL);
 
if (save->prim_store) {
   if ( --save->prim_store->refcount == 0 ) {
@@ -93,10 +72,6 @@ void vbo_save_destroy( struct gl_context *ctx )
  save->vertex_store = NULL;
   }
}
-
-   for (i = 0; i < VBO_ATTRIB_MAX; i++) {
-  _mesa_reference_buffer_object(ctx, &save->arrays[i].BufferObj, NULL);
-   }
 }
 
 
diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index cb0bff2341..edbce3673d 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -66,6 +66,7 @@ struct vbo_save_vertex_list {
GLenum16 attrtype[VBO_ATTRIB_MAX];
GLuint offsets[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
+   struct gl_vertex_array_object *VAO[VP_MODE_MAX];
 
/* Copy of the final vertex from node->vertex_store->bufferobj.
 * Keep this in regular (non-VBO) memory to avoid repeated
@@ -140,14 +141,13 @@ struct vbo_save_context {
struct gl_context *ctx;
GLvertexformat vtxfmt;
GLvertexformat vtxfmt_noop;  /**< Used if out_of_memory is true */
-   struct gl_vertex_array arrays[VBO_ATTRIB_MAX];
-   const struct gl_vertex_array *inputs[VBO_ATTRIB_MAX];
 
GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
GLenum16 attrtype[VBO_ATTRIB_MAX];  /**< GL_FLOAT, GL_INT, etc */
GLubyte active_sz[VBO_ATTRIB_MAX];  /**< 1, 2, 3 or 4 */
GLuint vertex_size;  /**< size in GLfloats */
+   struct gl_vertex_array_object *VAO[VP_MODE_MAX];
 
GLboolean out_of_memory;  /**< True if last VBO allocation failed */
 
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index fb51bdb84e..1edf7b9dfa 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -68,6 +68,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 
 #include "main/glheader.h"
+#include "main/arrayobj.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
 #include "main/dlist.h"
@@ -79,6 +80,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/vtxfmt.h"
 #include "

Mesa (master): vbo: Implement tool functions for vbo specific VAO setup.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: c757e416ce9547d3335f350fc02c0261d9e006de
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c757e416ce9547d3335f350fc02c0261d9e006de

Author: Mathias Fröhlich 
Date:   Sat Feb  3 21:28:40 2018 +0100

vbo: Implement tool functions for vbo specific VAO setup.

Correct VBO_MATERIAL_SHIFT value.
The functions will be used next in this series.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_attrib.h  |  4 ++--
 src/mesa/vbo/vbo_private.h | 53 ++
 2 files changed, 55 insertions(+), 2 deletions(-)

diff --git a/src/mesa/vbo/vbo_attrib.h b/src/mesa/vbo/vbo_attrib.h
index fb178e17d6..0592d845ba 100644
--- a/src/mesa/vbo/vbo_attrib.h
+++ b/src/mesa/vbo/vbo_attrib.h
@@ -113,8 +113,8 @@ enum vbo_attrib {
  VBO_ATTRIB_LAST_MATERIAL - VBO_ATTRIB_FIRST_MATERIAL + 1)
 
 /** Shift to move legacy material attribs into generic slots */
-#define VBO_MATERIAL_SHIFT (VBO_ATTRIB_FIRST_MATERIAL - VBO_ATTRIB_GENERIC0)
-
+#define VBO_MATERIAL_SHIFT \
+   (VBO_ATTRIB_LAST_MATERIAL - VBO_ATTRIB_FIRST_MATERIAL + 1)
 
 
 
diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index 2fda06dec6..2640f3e21f 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -36,6 +36,7 @@
 #include "vbo/vbo_exec.h"
 #include "vbo/vbo_save.h"
 #include "main/mtypes.h"
+#include "main/varray.h"
 
 
 struct _glapi_table;
@@ -172,4 +173,56 @@ void
 vbo_merge_prims(struct _mesa_prim *p0, const struct _mesa_prim *p1);
 
 
+/**
+ * Get the filter mask for vbo draws depending on the vertex_processing_mode.
+ */
+static inline GLbitfield
+_vbo_get_vao_filter(gl_vertex_processing_mode vertex_processing_mode)
+{
+   if (vertex_processing_mode == VP_MODE_FF) {
+  /* The materials mapped into the generic arrays */
+  return VERT_BIT_FF_ALL | VERT_BIT_MAT_ALL;
+   } else {
+  return VERT_BIT_ALL;
+   }
+}
+
+
+/**
+ * Translate the bitmask of VBO_ATTRIB_BITs to VERT_ATTRIB_BITS.
+ * Note that position/generic0 attribute aliasing is done
+ * generically in the VAO.
+ */
+static inline GLbitfield
+_vbo_get_vao_enabled_from_vbo(gl_vertex_processing_mode vertex_processing_mode,
+  GLbitfield64 enabled)
+{
+   if (vertex_processing_mode == VP_MODE_FF) {
+  /* The materials mapped into the generic arrays */
+  return (((GLbitfield)enabled) & VERT_BIT_FF_ALL)
+ | (((GLbitfield)(enabled >> VBO_MATERIAL_SHIFT)) & VERT_BIT_MAT_ALL);
+   } else {
+  return ((GLbitfield)enabled) & VERT_BIT_ALL;
+   }
+}
+
+
+/**
+ * Set the vertex attrib for vbo draw use.
+ */
+static inline void
+_vbo_set_attrib_format(struct gl_context *ctx,
+   struct gl_vertex_array_object *vao,
+   gl_vert_attrib attr, GLintptr buffer_offset,
+   GLubyte size, GLenum16 type, GLuint offset)
+{
+   const GLboolean integer = vbo_attrtype_to_integer_flag(type);
+   const GLboolean doubles = vbo_attrtype_to_double_flag(type);
+   _mesa_update_array_format(ctx, vao, attr, size, type, GL_RGBA,
+ GL_FALSE, integer, doubles, offset);
+   /* Ptr for userspace arrays */
+   vao->VertexAttrib[attr].Ptr = ADD_POINTERS(buffer_offset, offset);
+}
+
+
 #endif /* VBO_PRIVATE_H */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Add flush_vertices to _mesa_{enable,disable}_vertex_array_attrib.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4331969ac44ce29c3dac810242ed2b9a4633999f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4331969ac44ce29c3dac810242ed2b9a4633999f

Author: Mathias Fröhlich 
Date:   Wed Aug 24 08:45:05 2016 +0200

mesa: Add flush_vertices to _mesa_{enable,disable}_vertex_array_attrib.

We will need the flush_vertices argument later in this series.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/drivers/common/meta.c | 18 +++---
 src/mesa/main/enable.c |  4 ++--
 src/mesa/main/varray.c | 30 +++---
 src/mesa/main/varray.h |  4 ++--
 4 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 0cb2ef450e..3d9833dabb 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -350,7 +350,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
   *buf_obj, 0, sizeof(struct vertex));
  _mesa_enable_vertex_array_attrib(ctx, array_obj,
-  VERT_ATTRIB_GENERIC(0));
+  VERT_ATTRIB_GENERIC(0), true);
  if (texcoord_size > 0) {
 _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
   texcoord_size, GL_FLOAT, GL_RGBA,
@@ -359,7 +359,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
  *buf_obj, 0, sizeof(struct vertex));
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
- VERT_ATTRIB_GENERIC(1));
+ VERT_ATTRIB_GENERIC(1), true);
  }
   } else {
  _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS,
@@ -368,7 +368,8 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
offsetof(struct vertex, x));
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
   *buf_obj, 0, sizeof(struct vertex));
- _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
+ _mesa_enable_vertex_array_attrib(ctx, array_obj,
+  VERT_ATTRIB_POS, true);
 
  if (texcoord_size > 0) {
 _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(0),
@@ -377,7 +378,8 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   offsetof(struct vertex, tex));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
  *buf_obj, 0, sizeof(struct vertex));
-_mesa_enable_vertex_array_attrib(ctx, array_obj, 
VERT_ATTRIB_TEX(0));
+_mesa_enable_vertex_array_attrib(ctx, array_obj,
+ VERT_ATTRIB_TEX(0), true);
  }
 
  if (color_size > 0) {
@@ -387,7 +389,8 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   offsetof(struct vertex, r));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
  *buf_obj, 0, sizeof(struct vertex));
-_mesa_enable_vertex_array_attrib(ctx, array_obj, 
VERT_ATTRIB_COLOR0);
+_mesa_enable_vertex_array_attrib(ctx, array_obj,
+ VERT_ATTRIB_COLOR0, true);
  }
   }
} else {
@@ -3345,7 +3348,7 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
 offsetof(struct vertex, x));
   _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
drawtex->buf_obj, 0, sizeof(struct vertex));
-  _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS);
+  _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS, true);
 
 
   for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
@@ -3356,7 +3359,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
offsetof(struct vertex, st[i]));
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(i),
   drawtex->buf_obj, 0, sizeof(struct vertex));
- _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_TEX(i));
+ _mesa_enable_vertex_array_attrib(ctx, array_obj,
+  VERT_ATTRIB_TEX(i), true);
   }
}
else {
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 868b73ac68..7625a4c957 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -68,9

Mesa (master): vbo: Use _VPMode instead of get_vp_mode().

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 60c3ca1b2399804257cad394267ca740017361c6
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=60c3ca1b2399804257cad394267ca740017361c6

Author: Mathias Fröhlich 
Date:   Sat Feb  3 10:42:01 2018 +0100

vbo: Use _VPMode instead of get_vp_mode().

At those places where we used get_vp_mode() use
gl_vertex_program_state::_VPMode instead.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_exec.c   |  4 ++--
 src/mesa/vbo/vbo_exec_array.c | 11 ++-
 src/mesa/vbo/vbo_exec_draw.c  |  5 +++--
 src/mesa/vbo/vbo_save_draw.c  |  5 +++--
 4 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
index fc06979dcb..372d0237aa 100644
--- a/src/mesa/vbo/vbo_exec.c
+++ b/src/mesa/vbo/vbo_exec.c
@@ -34,7 +34,7 @@
 
 const GLubyte
 _vbo_attribute_alias_map[VP_MODE_MAX][VERT_ATTRIB_MAX] = {
-   /* VP_FF: */
+   /* VP_MODE_FF: */
{
   VBO_ATTRIB_POS, /* VERT_ATTRIB_POS */
   VBO_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
@@ -70,7 +70,7 @@ _vbo_attribute_alias_map[VP_MODE_MAX][VERT_ATTRIB_MAX] = {
   VBO_ATTRIB_MAT_BACK_INDEXES /* VERT_ATTRIB_GENERIC15 */
},
 
-   /* VP_SHADER: */
+   /* VP_MODE_SHADER: */
{
   VBO_ATTRIB_POS, /* VERT_ATTRIB_POS */
   VBO_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 25abe09559..0c3c9017b1 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -338,10 +338,11 @@ recalculate_input_bindings(struct gl_context *ctx)
/* May shuffle the position and generic0 bits around */
GLbitfield vp_inputs = _mesa_get_vao_vp_inputs(vao);
 
-   const enum vp_mode program_mode = get_vp_mode(ctx);
-   const GLubyte *const map = _vbo_attribute_alias_map[program_mode];
-   switch (program_mode) {
-   case VP_FF:
+   const gl_vertex_processing_mode processing_mode
+  = ctx->VertexProgram._VPMode;
+   const GLubyte * const map = _vbo_attribute_alias_map[processing_mode];
+   switch (processing_mode) {
+   case VP_MODE_FF:
   /* When no vertex program is active (or the vertex program is generated
* from fixed-function state).  We put the material values into the
* generic slots.  Since the vao has no material arrays, mute these
@@ -352,7 +353,7 @@ recalculate_input_bindings(struct gl_context *ctx)
 
   break;
 
-   case VP_SHADER:
+   case VP_MODE_SHADER:
   /* There are no shaders in OpenGL ES 1.x, so this code path should be
* impossible to reach.  The meta code is careful to not use shaders in
* ES1.
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index b0cc394642..4421496072 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -178,8 +178,9 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
GLuint attr;
GLbitfield varying_inputs = 0x0;
 
-   const enum vp_mode program_mode = get_vp_mode(exec->ctx);
-   const GLubyte * const map = _vbo_attribute_alias_map[program_mode];
+   const gl_vertex_processing_mode processing_mode
+  = ctx->VertexProgram._VPMode;
+   const GLubyte * const map = _vbo_attribute_alias_map[processing_mode];
 
/* Grab VERT_ATTRIB_{POS,GENERIC0} from VBO_ATTRIB_POS */
const gl_attribute_map_mode mode = ATTRIBUTE_MAP_MODE_POSITION;
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 96a9bab029..8c58fecf40 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -142,8 +142,9 @@ bind_vertex_list(struct gl_context *ctx,
GLuint attr;
GLbitfield varying_inputs = 0x0;
 
-   const enum vp_mode program_mode = get_vp_mode(ctx);
-   const GLubyte * const map = _vbo_attribute_alias_map[program_mode];
+   const gl_vertex_processing_mode processing_mode
+  = ctx->VertexProgram._VPMode;
+   const GLubyte * const map = _vbo_attribute_alias_map[processing_mode];
 
/* Grab VERT_ATTRIB_{POS,GENERIC0} from VBO_ATTRIB_POS */
const gl_attribute_map_mode mode = ATTRIBUTE_MAP_MODE_POSITION;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Add flush_vertices to _mesa_bind_vertex_buffer.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: ef8028017ddd0aa27d0db07c0d7409d0519de6fe
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ef8028017ddd0aa27d0db07c0d7409d0519de6fe

Author: Mathias Fröhlich 
Date:   Sat Feb  3 21:16:19 2018 +0100

mesa: Add flush_vertices to _mesa_bind_vertex_buffer.

We will need the flush_vertices argument later in this series.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/drivers/common/meta.c | 16 +---
 src/mesa/main/bufferobj.c  |  2 +-
 src/mesa/main/varray.c | 15 ---
 src/mesa/main/varray.h |  2 +-
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 3d9833dabb..830d82ad49 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -348,7 +348,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x));
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(0),
-  *buf_obj, 0, sizeof(struct vertex));
+  *buf_obj, 0, sizeof(struct vertex), true);
  _mesa_enable_vertex_array_attrib(ctx, array_obj,
   VERT_ATTRIB_GENERIC(0), true);
  if (texcoord_size > 0) {
@@ -357,7 +357,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE, GL_FALSE,
   offsetof(struct vertex, tex));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_GENERIC(1),
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
  VERT_ATTRIB_GENERIC(1), true);
  }
@@ -367,7 +367,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, x));
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
-  *buf_obj, 0, sizeof(struct vertex));
+  *buf_obj, 0, sizeof(struct vertex), true);
  _mesa_enable_vertex_array_attrib(ctx, array_obj,
   VERT_ATTRIB_POS, true);
 
@@ -377,7 +377,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE,
   offsetof(struct vertex, tex));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(0),
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
  VERT_ATTRIB_TEX(0), true);
  }
@@ -388,7 +388,7 @@ _mesa_meta_setup_vertex_objects(struct gl_context *ctx,
   GL_FALSE, GL_FALSE,
   offsetof(struct vertex, r));
 _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_COLOR0,
- *buf_obj, 0, sizeof(struct vertex));
+ *buf_obj, 0, sizeof(struct vertex), true);
 _mesa_enable_vertex_array_attrib(ctx, array_obj,
  VERT_ATTRIB_COLOR0, true);
  }
@@ -3347,7 +3347,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
 GL_FALSE, GL_FALSE,
 offsetof(struct vertex, x));
   _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_POS,
-   drawtex->buf_obj, 0, sizeof(struct vertex));
+   drawtex->buf_obj, 0,
+   sizeof(struct vertex), true);
   _mesa_enable_vertex_array_attrib(ctx, array_obj, VERT_ATTRIB_POS, true);
 
 
@@ -3358,7 +3359,8 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
GL_FALSE, GL_FALSE,
offsetof(struct vertex, st[i]));
  _mesa_bind_vertex_buffer(ctx, array_obj, VERT_ATTRIB_TEX(i),
-  drawtex->buf_obj, 0, sizeof(struct vertex));
+  drawtex->buf_obj, 0,
+  sizeof(struct vertex), true);
  _mesa_enable_vertex_array_attrib(ctx, array_obj,
   VERT_ATTRIB_TEX(i), true);
   }
diff --git a/src/mesa/main/bufferobj.c 

Mesa (master): vbo: Implement method to track the inputs array.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 6002ab564bfb643d5e9fd1b8c3c7c45384de570a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=6002ab564bfb643d5e9fd1b8c3c7c45384de570a

Author: Mathias Fröhlich 
Date:   Sat Feb  3 17:19:24 2018 +0100

vbo: Implement method to track the inputs array.

Provided the _DrawVAO and the derived state that is maintained if we have
the _DrawVAO set, implement a method to incrementally update the array of
gl_vertex_array input pointers.

v2: Add some more comments.
Rename _vbo_array_init to _vbo_init_inputs.
Rename vbo_context::arrays to vbo_context::draw_arrays.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo.h | 36 
 src/mesa/vbo/vbo_context.c |  1 +
 src/mesa/vbo/vbo_exec.c| 83 ++
 src/mesa/vbo/vbo_private.h |  2 ++
 4 files changed, 122 insertions(+)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index d594ba8f6a..345aa6b0d2 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -254,6 +254,42 @@ vbo_sw_primitive_restart(struct gl_context *ctx,
  const struct _mesa_index_buffer *ib,
  struct gl_buffer_object *indirect);
 
+
+/**
+ * Utility that tracks and updates the current array entries.
+ */
+struct vbo_inputs
+{
+   /**
+* Array of inputs to be set to the _DrawArrays pointer.
+* The array contains pointers into the _DrawVAO and to the vbo modules
+* current values. The array of pointers is updated incrementally
+* based on the current and vertex_processing_mode values below.
+*/
+   const struct gl_vertex_array *inputs[VERT_ATTRIB_MAX];
+   /** Those VERT_BIT_'s where the inputs array point to current values. */
+   GLbitfield current;
+   /** Store which aliasing current values - generics or materials - are set. 
*/
+   gl_vertex_processing_mode vertex_processing_mode;
+};
+
+
+/**
+ * Initialize inputs.
+ */
+void
+_vbo_init_inputs(struct vbo_inputs *inputs);
+
+
+/**
+ * Update the gl_vertex_array array inside the vbo_inputs structure
+ * provided the current _VPMode, the provided vao and
+ * the vao's enabled arrays filtered by the filter bitmask.
+ */
+void
+_vbo_update_inputs(struct gl_context *ctx, struct vbo_inputs *inputs);
+
+
 void GLAPIENTRY
 _es_Color4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a);
 
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 5bc6bf0acd..7b1ebc68f1 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -234,6 +234,7 @@ _vbo_CreateContext(struct gl_context *ctx)
init_legacy_currval(ctx);
init_generic_currval(ctx);
init_mat_currval(ctx);
+   _vbo_init_inputs(&vbo->draw_arrays);
vbo_set_indirect_draw_func(ctx, vbo_draw_indirect_prims);
 
/* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
index 372d0237aa..69a150c78b 100644
--- a/src/mesa/vbo/vbo_exec.c
+++ b/src/mesa/vbo/vbo_exec.c
@@ -27,6 +27,7 @@
 
 
 #include "main/glheader.h"
+#include "main/arrayobj.h"
 #include "main/mtypes.h"
 #include "main/api_arrayelt.h"
 #include "main/vtxfmt.h"
@@ -240,3 +241,85 @@ vbo_merge_prims(struct _mesa_prim *p0, const struct 
_mesa_prim *p1)
p0->count += p1->count;
p0->end = p1->end;
 }
+
+
+void
+_vbo_init_inputs(struct vbo_inputs *inputs)
+{
+   inputs->current = 0;
+   inputs->vertex_processing_mode = VP_MODE_FF;
+}
+
+
+/**
+ * Update the vbo_inputs's arrays to point to the vao->_VertexArray arrays
+ * according to the 'enable' bitmask.
+ * \param enable  bitfield of VERT_BIT_x flags.
+ */
+static inline void
+update_vao_inputs(struct gl_context *ctx,
+  struct vbo_inputs *inputs, GLbitfield enable)
+{
+   const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
+
+   /* Make sure we process only arrays enabled in the VAO */
+   assert((enable & ~_mesa_get_vao_vp_inputs(vao)) == 0);
+
+   /* Fill in the client arrays from the VAO */
+   const GLubyte *const map = _mesa_vao_attribute_map[vao->_AttributeMapMode];
+   const struct gl_vertex_array *array = vao->_VertexArray;
+   const struct gl_vertex_array **iarray = &inputs->inputs[0];
+   while (enable) {
+  const int attr = u_bit_scan(&enable);
+  iarray[attr] = &array[map[attr]];
+   }
+}
+
+
+/**
+ * Update the vbo_inputs's arrays to point to the vbo->currval arrays
+ * according to the 'current' bitmask.
+ * \param current  bitfield of VERT_BIT_x flags.
+ */
+static inline void
+update_current_inputs(struct gl_context *ctx,
+  struct vbo_inputs *inputs, GLbitfield current)
+{
+   gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode;
+
+   /* All previously non current array pointers need update. */
+   GLbitfield mask = current &am

Mesa (master): mesa: Introduce a yet unused _DrawVAO.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 08c7474189da25729e4e0bc8755b676e13c2c2c8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=08c7474189da25729e4e0bc8755b676e13c2c2c8

Author: Mathias Fröhlich 
Date:   Wed Aug 24 08:45:05 2016 +0200

mesa: Introduce a yet unused _DrawVAO.

During the patch series this VAO gets populated with either the currently
bound VAO or an internal VAO that will be used for immediate mode and
dlist rendering.

v2: More comments about the _DrawVAO, filter and enabled mask.
Rename _DrawVAOEnabled to _DrawVAOEnabledAttribs.
v3: Fix and move comment.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/arrayobj.c |  4 
 src/mesa/main/attrib.c   |  2 ++
 src/mesa/main/context.c  |  2 ++
 src/mesa/main/mtypes.h   | 22 ++
 src/mesa/main/state.c| 29 +
 src/mesa/main/state.h|  8 
 src/mesa/main/varray.c   |  2 ++
 7 files changed, 69 insertions(+)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index a6fa33c82c..cf9c5d7ecc 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -49,6 +49,7 @@
 #include "arrayobj.h"
 #include "macros.h"
 #include "mtypes.h"
+#include "state.h"
 #include "varray.h"
 #include "main/dispatch.h"
 #include "util/bitscan.h"
@@ -578,6 +579,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, bool 
no_error)
 * deleted.
 */
_mesa_set_drawing_arrays(ctx, NULL);
+   _mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
 
ctx->NewState |= _NEW_ARRAY;
_mesa_reference_vao(ctx, &ctx->Array.VAO, newObj);
@@ -629,6 +631,8 @@ delete_vertex_arrays(struct gl_context *ctx, GLsizei n, 
const GLuint *ids)
 
  if (ctx->Array.LastLookedUpVAO == obj)
 _mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, NULL);
+ if (ctx->Array._DrawVAO == obj)
+_mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
 
  /* Unreference the array object. 
   * If refcount hits zero, the object will be deleted.
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 398ff653b7..dd6b98ce04 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -57,6 +57,7 @@
 #include "viewport.h"
 #include "mtypes.h"
 #include "main/dispatch.h"
+#include "state.h"
 #include "hash.h"
 #include 
 
@@ -1548,6 +1549,7 @@ copy_array_attrib(struct gl_context *ctx,
 
/* Invalidate array state. It will be updated during the next draw. */
_mesa_set_drawing_arrays(ctx, NULL);
+   _mesa_set_draw_vao(ctx, ctx->Array._EmptyVAO, 0);
 }
 
 /**
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 0aa2e3639f..e13343b5e6 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1335,6 +1335,8 @@ _mesa_free_context_data( struct gl_context *ctx )
 
_mesa_reference_vao(ctx, &ctx->Array.VAO, NULL);
_mesa_reference_vao(ctx, &ctx->Array.DefaultVAO, NULL);
+   _mesa_reference_vao(ctx, &ctx->Array._EmptyVAO, NULL);
+   _mesa_reference_vao(ctx, &ctx->Array._DrawVAO, NULL);
 
_mesa_free_attrib_data(ctx);
_mesa_free_buffer_objects(ctx);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 41df04d38d..bdecd422a9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1692,6 +1692,28 @@ struct gl_array_attrib
struct gl_buffer_object *ArrayBufferObj;
 
/**
+* Vertex array object that is used with the currently active draw command.
+* The _DrawVAO is either set to the currently bound VAO for array type
+* draws or to internal VAO's set up by the vbo module to execute immediate
+* mode or display list draws.
+*/
+   struct gl_vertex_array_object *_DrawVAO;
+   /**
+* The VERT_BIT_* bits effectively enabled from the current _DrawVAO.
+* This is always a subset of _mesa_get_vao_vp_inputs(_DrawVAO)
+* but may omit those arrays that shall not be referenced by the current
+* gl_vertex_program_state::_VPMode. For example the generic attributes are
+* maked out form the _DrawVAO's enabled arrays when a fixed function
+* array draw is executed.
+*/
+   GLbitfield _DrawVAOEnabledAttribs;
+   /**
+* Initially or if the VAO referenced by _DrawVAO is deleted the _DrawVAO
+* pointer is set to the _EmptyVAO which is just an empty VAO all the time.
+*/
+   struct gl_vertex_array_object *_EmptyVAO;
+
+   /**
 * Vertex arrays as consumed by a driver.
 * The array pointer is set up only by the VBO module.
 */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 2fd4fb9d32..6dd7a7ec07 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -479,3 +479,32 @@ _mesa_update_vertex_processing_mode(struct gl_context *ctx)
else
   ctx->VertexProgram._VPMode = VP_MOD

Mesa (master): vbo: Use _DrawVAO for array type draw commands.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 195bb990ed1a76e5ea9dd37af51f8270e9c3bf7d
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=195bb990ed1a76e5ea9dd37af51f8270e9c3bf7d

Author: Mathias Fröhlich 
Date:   Sat Feb  3 19:42:20 2018 +0100

vbo: Use _DrawVAO for array type draw commands.

Switch over to use the _DrawVAO for all the array type draws.
The _DrawVAO needs to be set before we enter _mesa_update_state, so move
setting the draw method in front of the first call to _mesa_update_state
which is in turn called from the *validate*Draw* calls. Using the
gl_vertex_array_object::_Enabled bitmask, gl_vertex_program_state::_VPMode
and gl_vertex_array_object::_AttributeMapMode we can already set
varying_vp_inputs before we call _mesa_update_state the first time.
Thus remove duplicate state validation.

v2: Update comments.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_context.c|   8 ++-
 src/mesa/vbo/vbo_exec.h   |   6 --
 src/mesa/vbo/vbo_exec_array.c | 159 +-
 3 files changed, 100 insertions(+), 73 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 7b1ebc68f1..222bdcf1f2 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -206,11 +206,15 @@ vbo_exec_invalidate_state(struct gl_context *ctx)
struct vbo_exec_context *exec = &vbo->exec;
 
if (ctx->NewState & (_NEW_PROGRAM | _NEW_ARRAY)) {
-  if (!exec->validating)
- exec->array.recalculate_inputs = GL_TRUE;
+  exec->array.recalculate_inputs = GL_TRUE;
 
   _ae_invalidate_state(ctx);
}
+   /* If _mesa_update_state is called in a non draw code path,
+* changes in the VAO need to be captured.
+*/
+   if (ctx->Array.VAO->NewArrays)
+  exec->array.recalculate_inputs = GL_TRUE;
 
if (ctx->NewState & _NEW_EVAL)
   exec->eval.recalculate_maps = GL_TRUE;
diff --git a/src/mesa/vbo/vbo_exec.h b/src/mesa/vbo/vbo_exec.h
index 7e00d45de0..b00045c7c8 100644
--- a/src/mesa/vbo/vbo_exec.h
+++ b/src/mesa/vbo/vbo_exec.h
@@ -76,7 +76,6 @@ struct vbo_exec_context
struct gl_context *ctx;
GLvertexformat vtxfmt;
GLvertexformat vtxfmt_noop;
-   GLboolean validating; /**< if we're in the middle of state validation */
 
struct {
   struct gl_buffer_object *bufferobj;
@@ -119,11 +118,6 @@ struct vbo_exec_context
} eval;
 
struct {
-  /* Arrays and current values manipulated according to program
-   * mode, etc.  These are the attributes as seen by vertex
-   * programs:
-   */
-  const struct gl_vertex_array *inputs[VERT_ATTRIB_MAX];
   GLboolean recalculate_inputs;
} array;
 
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 0c3c9017b1..5029937336 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -319,29 +319,14 @@ print_draw_arrays(struct gl_context *ctx,
 
 
 /**
- * Set the vbo->exec->inputs[] pointers to point to the enabled
- * vertex arrays.  This depends on the current vertex program/shader
- * being executed because of whether or not generic vertex arrays
- * alias the conventional vertex arrays.
- * For arrays that aren't enabled, we set the input[attrib] pointer
- * to point at a zero-stride current value "array".
+ * Return a filter mask for the net enabled vao arrays.
+ * This is to mask out arrays that would otherwise supersed required current
+ * values for the fixed function shaders for example.
  */
-static void
-recalculate_input_bindings(struct gl_context *ctx)
+static GLbitfield
+enabled_filter(const struct gl_context *ctx)
 {
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
-   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   const struct gl_vertex_array *vertexAttrib = vao->_VertexArray;
-   const struct gl_vertex_array **inputs = &exec->array.inputs[0];
-
-   /* May shuffle the position and generic0 bits around */
-   GLbitfield vp_inputs = _mesa_get_vao_vp_inputs(vao);
-
-   const gl_vertex_processing_mode processing_mode
-  = ctx->VertexProgram._VPMode;
-   const GLubyte * const map = _vbo_attribute_alias_map[processing_mode];
-   switch (processing_mode) {
+   switch (ctx->VertexProgram._VPMode) {
case VP_MODE_FF:
   /* When no vertex program is active (or the vertex program is generated
* from fixed-function state).  We put the material values into the
@@ -349,9 +334,7 @@ recalculate_input_bindings(struct gl_context *ctx)
* slots from the enabled arrays so that the current material values
* are pulled instead of the vao arrays.
*/
-  vp_inputs &= VERT_BIT_FF_ALL;
-
-  break;
+  return VERT_BIT_FF_ALL;
 
case VP_MODE_SHADER:
   /* There are no shaders in OpenGL ES 1.x, so this code path should be
@@ -360,40 +343,20 @@

Mesa (master): vbo: Remove get_vp_mode() and enum vp_mode.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: ce3d2421a0bc0dd2e99fa6a54a127ca5fc57ba15
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce3d2421a0bc0dd2e99fa6a54a127ca5fc57ba15

Author: Mathias Fröhlich 
Date:   Sat Feb  3 10:44:10 2018 +0100

vbo: Remove get_vp_mode() and enum vp_mode.

Is now unused.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_private.h | 27 ---
 1 file changed, 27 deletions(-)

diff --git a/src/mesa/vbo/vbo_private.h b/src/mesa/vbo/vbo_private.h
index e44a521b11..49922892e5 100644
--- a/src/mesa/vbo/vbo_private.h
+++ b/src/mesa/vbo/vbo_private.h
@@ -69,33 +69,6 @@ vbo_context(struct gl_context *ctx)
 
 
 /**
- * Current vertex processing mode: fixed function vs. shader.
- * In reality, fixed function is probably implemented by a shader but that's
- * not what we care about here.
- */
-enum vp_mode {
-   VP_FF,/**< legacy / fixed function */
-   VP_SHADER, /**< ARB vertex program or GLSL vertex shader */
-   VP_MODE_MAX /**< for sizing arrays */
-};
-
-
-/**
- * Get current vertex processing mode (fixed function vs. shader).
- */
-static inline enum vp_mode
-get_vp_mode( struct gl_context *ctx )
-{
-   if (!ctx->VertexProgram._Current)
-  return VP_FF;
-   else if (ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram)
-  return VP_FF;
-   else
-  return VP_SHADER;
-}
-
-
-/**
  * Array to apply the fixed function material aliasing map to
  * an attribute value used in vbo processing inputs to an attribute
  * as they appear in the vao.

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Provide an alternative to get_vp_mode()

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 92d76a169127a6b8b4e2027a95425b592d0ca3db
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=92d76a169127a6b8b4e2027a95425b592d0ca3db

Author: Mathias Fröhlich 
Date:   Fri Feb  2 21:31:27 2018 +0100

mesa: Provide an alternative to get_vp_mode()

To get equivalent information than get_vp_mode(), track the vertex
processing mode in a per context variable at
gl_vertex_program_state::_VPMode.
This aims to replace get_vp_mode() as seen in the vbo module.
But instead of the get_vp_mode() implementation which only gives correct
answers past calling _mesa_update_state() this context variable is
immediately tracked when the vertex processing state is modified. The
correctness of this value is asserted on state validation.

With this in place we should be able to untangle the dependency with
varying_vp_inputs and state invalidation.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/drivers/common/meta.c |  2 ++
 src/mesa/main/arbprogram.c |  5 +
 src/mesa/main/context.c|  3 +++
 src/mesa/main/enable.c |  2 ++
 src/mesa/main/mtypes.h | 24 
 src/mesa/main/pipelineobj.c|  3 +++
 src/mesa/main/shaderapi.c  |  5 +
 src/mesa/main/state.c  | 23 +++
 src/mesa/main/state.h  |  7 +++
 src/mesa/program/program.c |  1 +
 10 files changed, 75 insertions(+)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index cd898e26f6..0cb2ef450e 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -1012,6 +1012,8 @@ _mesa_meta_end(struct gl_context *ctx)
 
  _mesa_reference_pipeline_object(ctx, &save->Pipeline, NULL);
   }
+
+  _mesa_update_vertex_processing_mode(ctx);
}
 
if (state & MESA_META_STENCIL_TEST) {
diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
index 625dc667f8..b169bce0c5 100644
--- a/src/mesa/main/arbprogram.c
+++ b/src/mesa/main/arbprogram.c
@@ -37,6 +37,7 @@
 #include "main/mtypes.h"
 #include "main/arbprogram.h"
 #include "main/shaderapi.h"
+#include "main/state.h"
 #include "program/arbprogparse.h"
 #include "program/program.h"
 #include "program/prog_print.h"
@@ -133,6 +134,8 @@ _mesa_BindProgramARB(GLenum target, GLuint id)
   _mesa_reference_program(ctx, &ctx->FragmentProgram.Current, newProg);
}
 
+   _mesa_update_vertex_processing_mode(ctx);
+
/* Never null pointers */
assert(ctx->VertexProgram.Current);
assert(ctx->FragmentProgram.Current);
@@ -369,6 +372,8 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, 
GLsizei len,
   }
}
 
+   _mesa_update_vertex_processing_mode(ctx);
+
if (ctx->_Shader->Flags & GLSL_DUMP) {
   const char *shader_type =
  target == GL_FRAGMENT_PROGRAM_ARB ? "fragment" : "vertex";
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index 79d3e39e92..0aa2e3639f 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -123,6 +123,7 @@
 #include "shared.h"
 #include "shaderobj.h"
 #include "shaderimage.h"
+#include "state.h"
 #include "util/debug.h"
 #include "util/disk_cache.h"
 #include "util/strtod.h"
@@ -1579,6 +1580,8 @@ handle_first_current(struct gl_context *ctx)
 
check_context_limits(ctx);
 
+   _mesa_update_vertex_processing_mode(ctx);
+
/* According to GL_MESA_configless_context the default value of
 * glDrawBuffers depends on the config of the first surface it is bound to.
 * For GLES it is always GL_BACK which has a magic interpretation.
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index f23673a6cd..868b73ac68 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -39,6 +39,7 @@
 #include "light.h"
 #include "mtypes.h"
 #include "enums.h"
+#include "state.h"
 #include "texstate.h"
 #include "varray.h"
 
@@ -919,6 +920,7 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, 
GLboolean state)
 return;
  FLUSH_VERTICES(ctx, _NEW_PROGRAM);
  ctx->VertexProgram.Enabled = state;
+ _mesa_update_vertex_processing_mode(ctx);
  break;
   case GL_VERTEX_PROGRAM_POINT_SIZE_ARB:
  /* This was added with ARB_vertex_program, but it is also used with
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 7da3240da7..41df04d38d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2137,6 +2137,19 @@ typedef enum
 
 
 /**
+ * Current vertex processing mode: fixed function vs. shader.
+ * In reality, fixed function is probably implemented by a shader but that's
+ * not what we care about here.
+ */
+typedef enum
+{
+   VP_MODE_FF, /**< legacy / fixed 

Mesa (master): mesa: Make _mesa_vertex_attrib_binding public.

2018-02-22 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 354b76ad2070f23b91de14dd6bf4d14ff13e43fc
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=354b76ad2070f23b91de14dd6bf4d14ff13e43fc

Author: Mathias Fröhlich 
Date:   Sat Feb  3 20:50:35 2018 +0100

mesa: Make _mesa_vertex_attrib_binding public.

Change vertex_attrib_binding() to _mesa_vertex_attrib_binding(), add a
flush_vertices argument, and make it publicly available.
The function will be needed later in the series.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/varray.c | 38 --
 src/mesa/main/varray.h |  7 +++
 2 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 90b874aa49..f7d32fdbef 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -155,11 +155,11 @@ update_attribute_map_mode(const struct gl_context *ctx,
  * Sets the BufferBindingIndex field for the vertex attribute given by
  * attribIndex.
  */
-static void
-vertex_attrib_binding(struct gl_context *ctx,
-  struct gl_vertex_array_object *vao,
-  gl_vert_attrib attribIndex,
-  GLuint bindingIndex)
+void
+_mesa_vertex_attrib_binding(struct gl_context *ctx,
+struct gl_vertex_array_object *vao,
+gl_vert_attrib attribIndex,
+GLuint bindingIndex, bool flush_vertices)
 {
struct gl_array_attributes *array = &vao->VertexAttrib[attribIndex];
 
@@ -171,7 +171,9 @@ vertex_attrib_binding(struct gl_context *ctx,
   else
  vao->VertexAttribBufferMask &= ~array_bit;
 
-  FLUSH_VERTICES(ctx, _NEW_ARRAY);
+  if (flush_vertices) {
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+  }
 
   vao->BufferBinding[array->BufferBindingIndex]._BoundArrays &= ~array_bit;
   vao->BufferBinding[bindingIndex]._BoundArrays |= array_bit;
@@ -592,7 +594,7 @@ update_array(struct gl_context *ctx,
  normalized, integer, doubles, 0);
 
/* Reset the vertex attrib binding */
-   vertex_attrib_binding(ctx, vao, attrib, attrib);
+   _mesa_vertex_attrib_binding(ctx, vao, attrib, attrib, true);
 
/* The Stride and Ptr fields are not set by update_array_format() */
struct gl_array_attributes *array = &vao->VertexAttrib[attrib];
@@ -2030,7 +2032,7 @@ _mesa_VertexAttribDivisor_no_error(GLuint index, GLuint 
divisor)
 *   VertexAttribBinding(index, index);
 *   VertexBindingDivisor(index, divisor);"
 */
-   vertex_attrib_binding(ctx, vao, genericIndex, genericIndex);
+   _mesa_vertex_attrib_binding(ctx, vao, genericIndex, genericIndex, true);
vertex_binding_divisor(ctx, vao, genericIndex, divisor);
 }
 
@@ -2072,7 +2074,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
 *   VertexAttribBinding(index, index);
 *   VertexBindingDivisor(index, divisor);"
 */
-   vertex_attrib_binding(ctx, vao, genericIndex, genericIndex);
+   _mesa_vertex_attrib_binding(ctx, vao, genericIndex, genericIndex, true);
vertex_binding_divisor(ctx, vao, genericIndex, divisor);
 }
 
@@ -2674,9 +2676,9 @@ vertex_array_attrib_binding(struct gl_context *ctx,
 
assert(VERT_ATTRIB_GENERIC(attribIndex) < ARRAY_SIZE(vao->VertexAttrib));
 
-   vertex_attrib_binding(ctx, vao,
- VERT_ATTRIB_GENERIC(attribIndex),
- VERT_ATTRIB_GENERIC(bindingIndex));
+   _mesa_vertex_attrib_binding(ctx, vao,
+   VERT_ATTRIB_GENERIC(attribIndex),
+   VERT_ATTRIB_GENERIC(bindingIndex), true);
 }
 
 
@@ -2684,9 +2686,9 @@ void GLAPIENTRY
 _mesa_VertexAttribBinding_no_error(GLuint attribIndex, GLuint bindingIndex)
 {
GET_CURRENT_CONTEXT(ctx);
-   vertex_attrib_binding(ctx, ctx->Array.VAO,
- VERT_ATTRIB_GENERIC(attribIndex),
- VERT_ATTRIB_GENERIC(bindingIndex));
+   _mesa_vertex_attrib_binding(ctx, ctx->Array.VAO,
+   VERT_ATTRIB_GENERIC(attribIndex),
+   VERT_ATTRIB_GENERIC(bindingIndex), true);
 }
 
 
@@ -2720,9 +2722,9 @@ _mesa_VertexArrayAttribBinding_no_error(GLuint vaobj, 
GLuint attribIndex,
GET_CURRENT_CONTEXT(ctx);
 
struct gl_vertex_array_object *vao = _mesa_lookup_vao(ctx, vaobj);
-   vertex_attrib_binding(ctx, vao,
- VERT_ATTRIB_GENERIC(attribIndex),
- VERT_ATTRIB_GENERIC(bindingIndex));
+   _mesa_vertex_attrib_binding(ctx, vao,
+   VERT_ATTRIB_GENERIC(attribIndex),
+   VERT_ATTRIB_GENERIC(bindingIndex), true);
 }
 
 
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 93ffb37a0d..6585355771 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -121,6 +121,13 @@ 

Mesa (master): gallium: Mute arrays for several meta like callbacks.

2018-02-08 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 437cae411e7664e01d9c1c280317274b3ffc0734
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=437cae411e7664e01d9c1c280317274b3ffc0734

Author: Mathias Fröhlich 
Date:   Mon Feb  5 22:02:51 2018 +0100

gallium: Mute arrays for several meta like callbacks.

Set the _DrawArray pointer to NULL when calling into the Drivers
Bitmap/CopyPixels/DrawAtlasBitmaps/DrawPixels/DrawTex hooks.
This fixes an assert that gets uncovered when the following
patch gets applied.

v2: Mute from within the state tracker instead of generic mesa.
v3: Avoid evaluating _DrawArrays from within st_validate_state.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Marek Olšák 

---

 src/mesa/state_tracker/st_atom.c  | 10 ++
 src/mesa/state_tracker/st_atom.h  |  3 +++
 src/mesa/state_tracker/st_cb_bitmap.c |  4 ++--
 src/mesa/state_tracker/st_cb_drawpixels.c |  4 ++--
 src/mesa/state_tracker/st_cb_drawtex.c|  2 +-
 5 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index 253b508164..b597c62632 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -203,6 +203,16 @@ void st_validate_state( struct st_context *st, enum 
st_pipeline pipeline )
   pipeline_mask = ST_PIPELINE_CLEAR_STATE_MASK;
   break;
 
+   case ST_PIPELINE_META:
+  if (st->gfx_shaders_may_be_dirty) {
+ check_program_state(st);
+ st->gfx_shaders_may_be_dirty = false;
+  }
+
+  st_manager_validate_framebuffers(st);
+  pipeline_mask = ST_PIPELINE_META_STATE_MASK;
+  break;
+
case ST_PIPELINE_UPDATE_FRAMEBUFFER:
   st_manager_validate_framebuffers(st);
   pipeline_mask = ST_PIPELINE_UPDATE_FB_STATE_MASK;
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index f9711d5393..68388a5674 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -44,6 +44,7 @@ struct st_context;
 enum st_pipeline {
ST_PIPELINE_RENDER,
ST_PIPELINE_CLEAR,
+   ST_PIPELINE_META,
ST_PIPELINE_UPDATE_FRAMEBUFFER,
ST_PIPELINE_COMPUTE,
 };
@@ -149,6 +150,8 @@ enum {
 #define ST_PIPELINE_CLEAR_STATE_MASK (ST_NEW_FB_STATE | \
   ST_NEW_SCISSOR | \
   ST_NEW_WINDOW_RECTANGLES)
+#define ST_PIPELINE_META_STATE_MASK (ST_PIPELINE_RENDER_STATE_MASK & \
+ ~ST_NEW_VERTEX_ARRAYS)
 /* For ReadPixels, ReadBuffer, GetSamplePosition: */
 #define ST_PIPELINE_UPDATE_FB_STATE_MASK (ST_NEW_FB_STATE)
 
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c 
b/src/mesa/state_tracker/st_cb_bitmap.c
index 0a30ffa0f3..c41ed2ba02 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -626,7 +626,7 @@ st_Bitmap(struct gl_context *ctx, GLint x, GLint y,
if ((st->dirty | ctx->NewDriverState) & ~ST_NEW_CONSTANTS &
ST_PIPELINE_RENDER_STATE_MASK ||
st->gfx_shaders_may_be_dirty) {
-  st_validate_state(st, ST_PIPELINE_RENDER);
+  st_validate_state(st, ST_PIPELINE_META);
}
 
if (UseBitmapCache && accum_bitmap(ctx, x, y, width, height, unpack, 
bitmap))
@@ -681,7 +681,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
 
st_flush_bitmap_cache(st);
 
-   st_validate_state(st, ST_PIPELINE_RENDER);
+   st_validate_state(st, ST_PIPELINE_META);
st_invalidate_readpix_cache(st);
 
sv = st_create_texture_sampler_view(pipe, stObj->pt);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c 
b/src/mesa/state_tracker/st_cb_drawpixels.c
index ddf6926332..471eb19661 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -1147,7 +1147,7 @@ st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
st_flush_bitmap_cache(st);
st_invalidate_readpix_cache(st);
 
-   st_validate_state(st, ST_PIPELINE_RENDER);
+   st_validate_state(st, ST_PIPELINE_META);
 
/* Limit the size of the glDrawPixels to the max texture size.
 * Strictly speaking, that's not correct but since we don't handle
@@ -1514,7 +1514,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint 
srcy,
st_flush_bitmap_cache(st);
st_invalidate_readpix_cache(st);
 
-   st_validate_state(st, ST_PIPELINE_RENDER);
+   st_validate_state(st, ST_PIPELINE_META);
 
if (type == GL_DEPTH_STENCIL) {
   /* XXX make this more efficient */
diff --git a/src/mesa/state_tracker/st_cb_drawtex.c 
b/src/mesa/state_tracker/st_cb_drawtex.c
index 01c5757a73..f18925ecfe 100644
--- a/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/state_tracker/st_cb_drawtex.c
@@ -120,7 +120,7 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, 
GLfloat z,
st_flush_bitmap_cache(st);
st_invalidate_readpix_cache(st);
 
-   st_validate_state(st, ST_PIPELINE_RENDER);
+   st_validate_state(st, 

Mesa (master): mesa: Only update enabled VAO gl_vertex_array entries.

2018-02-08 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 77cb2fc0bd8f57b646ef5ab674c1f76d873a22ae
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=77cb2fc0bd8f57b646ef5ab674c1f76d873a22ae

Author: Mathias Fröhlich 
Date:   Sun Feb  4 17:13:06 2018 +0100

mesa: Only update enabled VAO gl_vertex_array entries.

Instead of updating all modified gl_vertex_array_object::_VertexArray
entries just update those that are modified and enabled.
Also release buffer object from the _VertexArray that belong
to disabled attributes.

v2: Also set Ptr and Size to zero.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/varray.c |  8 
 src/mesa/main/varray.h | 29 ++---
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 4dfc3546a8..d55f74e968 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -178,7 +178,7 @@ vertex_attrib_binding(struct gl_context *ctx,
 
   array->BufferBindingIndex = bindingIndex;
 
-  vao->NewArrays |= array_bit;
+  vao->NewArrays |= vao->_Enabled & array_bit;
}
 }
 
@@ -213,7 +213,7 @@ _mesa_bind_vertex_buffer(struct gl_context *ctx,
   else
  vao->VertexAttribBufferMask |= binding->_BoundArrays;
 
-  vao->NewArrays |= binding->_BoundArrays;
+  vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
}
 }
 
@@ -234,7 +234,7 @@ vertex_binding_divisor(struct gl_context *ctx,
if (binding->InstanceDivisor != divisor) {
   FLUSH_VERTICES(ctx, _NEW_ARRAY);
   binding->InstanceDivisor = divisor;
-  vao->NewArrays |= binding->_BoundArrays;
+  vao->NewArrays |= vao->_Enabled & binding->_BoundArrays;
}
 }
 
@@ -344,7 +344,7 @@ _mesa_update_array_format(struct gl_context *ctx,
array->RelativeOffset = relativeOffset;
array->_ElementSize = elementSize;
 
-   vao->NewArrays |= VERT_BIT(attrib);
+   vao->NewArrays |= vao->_Enabled & VERT_BIT(attrib);
ctx->NewState |= _NEW_ARRAY;
 }
 
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index ddabd0bc58..46f83b2200 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -58,17 +58,24 @@ _mesa_update_vertex_array(struct gl_context *ctx,
   const struct gl_array_attributes *attribs,
   const struct gl_vertex_buffer_binding *binding)
 {
-   dst->Size = attribs->Size;
-   dst->Type = attribs->Type;
-   dst->Format = attribs->Format;
-   dst->StrideB = binding->Stride;
-   dst->Ptr = _mesa_vertex_attrib_address(attribs, binding);
-   dst->Normalized = attribs->Normalized;
-   dst->Integer = attribs->Integer;
-   dst->Doubles = attribs->Doubles;
-   dst->InstanceDivisor = binding->InstanceDivisor;
-   dst->_ElementSize = attribs->_ElementSize;
-   _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
+   if (attribs->Enabled) {
+  dst->Size = attribs->Size;
+  dst->Type = attribs->Type;
+  dst->Format = attribs->Format;
+  dst->StrideB = binding->Stride;
+  dst->Ptr = _mesa_vertex_attrib_address(attribs, binding);
+  dst->Normalized = attribs->Normalized;
+  dst->Integer = attribs->Integer;
+  dst->Doubles = attribs->Doubles;
+  dst->InstanceDivisor = binding->InstanceDivisor;
+  dst->_ElementSize = attribs->_ElementSize;
+  _mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
+   } else {
+  /* Disabled arrays shall not be consumed */
+  dst->Size = 0;
+  dst->Ptr = NULL;
+  _mesa_reference_buffer_object(ctx, &dst->BufferObj, NULL);
+   }
 }
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Fix VAO buffer object tracking.

2018-02-08 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 2f9eb0aad5a0d2177b52a22d012fd53438edf9fe
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2f9eb0aad5a0d2177b52a22d012fd53438edf9fe

Author: Mathias Fröhlich 
Date:   Sun Feb  4 13:18:34 2018 +0100

mesa: Fix VAO buffer object tracking.

When changing the attribute binding in the VAO we also need to
account for getting rid of non vbo bits from VertexAttribBufferMask.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/varray.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index b268aaa9a3..4dfc3546a8 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -168,6 +168,8 @@ vertex_attrib_binding(struct gl_context *ctx,
 
   if (_mesa_is_bufferobj(vao->BufferBinding[bindingIndex].BufferObj))
  vao->VertexAttribBufferMask |= array_bit;
+  else
+ vao->VertexAttribBufferMask &= ~array_bit;
 
   FLUSH_VERTICES(ctx, _NEW_ARRAY);
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Move vbo_rebase into its only caller module tnl.

2018-02-06 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 236657842b56e08055a4a9be8def8e440de78b58
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=236657842b56e08055a4a9be8def8e440de78b58

Author: Mathias Fröhlich 
Date:   Sat Dec 16 10:57:47 2017 +0100

vbo: Move vbo_rebase into its only caller module tnl.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/Makefile.sources |  3 ++-
 src/mesa/meson.build  |  2 +-
 src/mesa/tnl/t_draw.c |  7 ++---
 src/mesa/{vbo/vbo_rebase.c => tnl/t_rebase.c} | 18 ++---
 src/mesa/tnl/t_rebase.h   | 39 +++
 src/mesa/vbo/vbo.h| 11 
 6 files changed, 55 insertions(+), 25 deletions(-)

diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources
index 880f379eb1..0a9aad52d0 100644
--- a/src/mesa/Makefile.sources
+++ b/src/mesa/Makefile.sources
@@ -370,6 +370,8 @@ TNL_FILES = \
tnl/tnl.h \
tnl/t_pipeline.c \
tnl/t_pipeline.h \
+   tnl/t_rebase.c \
+   tnl/t_rebase.h \
tnl/t_vb_cliptmp.h \
tnl/t_vb_fog.c \
tnl/t_vb_light.c \
@@ -405,7 +407,6 @@ VBO_FILES = \
vbo/vbo_noop.h \
vbo/vbo_primitive_restart.c \
vbo/vbo_private.h \
-   vbo/vbo_rebase.c \
vbo/vbo_save_api.c \
vbo/vbo_save.c \
vbo/vbo_save_draw.c \
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
index a74c39d29e..aa27d59264 100644
--- a/src/mesa/meson.build
+++ b/src/mesa/meson.build
@@ -338,7 +338,6 @@ files_libmesa_common = files(
   'vbo/vbo_noop.c',
   'vbo/vbo_noop.h',
   'vbo/vbo_primitive_restart.c',
-  'vbo/vbo_rebase.c',
   'vbo/vbo_save_api.c',
   'vbo/vbo_save.c',
   'vbo/vbo_save_draw.c',
@@ -366,6 +365,7 @@ files_libmesa_classic = files(
   'tnl/tnl.h',
   'tnl/t_pipeline.c',
   'tnl/t_pipeline.h',
+  'tnl/t_rebase.c',
   'tnl/t_vb_cliptmp.h',
   'tnl/t_vb_fog.c',
   'tnl/t_vb_light.c',
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
index 9fca4da1f4..c19d77d641 100644
--- a/src/mesa/tnl/t_draw.c
+++ b/src/mesa/tnl/t_draw.c
@@ -38,6 +38,7 @@
 #include "util/half_float.h"
 
 #include "t_context.h"
+#include "t_rebase.h"
 #include "tnl.h"
 
 
@@ -461,9 +462,9 @@ void _tnl_draw_prims(struct gl_context *ctx,
if (min_index) {
   /* We always translate away calls with min_index != 0. 
*/
-  vbo_rebase_prims( ctx, arrays, prim, nr_prims, ib, 
-   min_index, max_index,
-   _tnl_draw_prims );
+  t_rebase_prims( ctx, arrays, prim, nr_prims, ib,
+  min_index, max_index,
+  _tnl_draw_prims );
   return;
}
else if ((GLint)max_index + max_basevertex > max) {
diff --git a/src/mesa/vbo/vbo_rebase.c b/src/mesa/tnl/t_rebase.c
similarity index 94%
rename from src/mesa/vbo/vbo_rebase.c
rename to src/mesa/tnl/t_rebase.c
index 02dbc68dcb..b781781cb0 100644
--- a/src/mesa/vbo/vbo_rebase.c
+++ b/src/mesa/tnl/t_rebase.c
@@ -51,7 +51,7 @@
 #include "main/imports.h"
 #include "main/mtypes.h"
 
-#include "vbo.h"
+#include "t_rebase.h"
 
 
 #define REBASE(TYPE)   \
@@ -100,14 +100,14 @@ REBASE(GLubyte)
  *- can't save time by trying to upload half a vbo - typically it is
  *  all or nothing.
  */
-void vbo_rebase_prims( struct gl_context *ctx,
-  const struct gl_vertex_array *arrays[],
-  const struct _mesa_prim *prim,
-  GLuint nr_prims,
-  const struct _mesa_index_buffer *ib,
-  GLuint min_index,
-  GLuint max_index,
-  vbo_draw_func draw )
+void t_rebase_prims( struct gl_context *ctx,
+ const struct gl_vertex_array *arrays[],
+ const struct _mesa_prim *prim,
+ GLuint nr_prims,
+ const struct _mesa_index_buffer *ib,
+ GLuint min_index,
+ GLuint max_index,
+ vbo_draw_func draw )
 {
struct gl_vertex_array tmp_arrays[VERT_ATTRIB_MAX];
const struct gl_vertex_array *tmp_array_pointers[VERT_ATTRIB_MAX];
diff --git a/src/mesa/tnl/t_rebase.h b/src/mesa/tnl/t_rebase.h
new file mode 100644
index 00..35175868d5
--- /dev/null
+++ b/src/mesa/tnl/t_rebase.h
@@ -0,0 +1,39 @@
+/*
+ * mesa 3-D graphics library
+ *
+ * Copyright (C) 1999-2006  Brian Paul   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 withou

Mesa (master): mesa: Use atomics for buffer objects reference counts.

2018-02-06 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 2313c33e950a1b17e7787dd8a3b2f1e823d0cfd4
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=2313c33e950a1b17e7787dd8a3b2f1e823d0cfd4

Author: Mathias Fröhlich 
Date:   Sat Feb  3 15:06:16 2018 +0100

mesa: Use atomics for buffer objects reference counts.

The mutex is currently used for reference counting and updating
the minmax index cache.
The change uses atomics directly for reference counting and
the mutex for the minmax cache.
This is safe since the reference count is not modified beside
in _mesa_reference_buffer_object where atomics aim to be used.
While using the minmax cache, the calling code holds a reference
to the buffer object. Thus unreferencing or even referencing the
buffer object does not need to be serialized with accessing
the minmax cache.
The change reduces the time _mesa_reference_buffer_object_ takes
by about a factor of two when looking at perf results for some
of my favorite use cases.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/bufferobj.c   | 22 ++
 src/mesa/main/mtypes.h  |  2 +-
 src/mesa/vbo/vbo_minmax_index.c |  8 
 3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index c1dfdfba82..67f9cd0a90 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -46,6 +46,7 @@
 #include "texstore.h"
 #include "transformfeedback.h"
 #include "varray.h"
+#include "util/u_atomic.h"
 
 
 /* Debug flags */
@@ -471,7 +472,7 @@ _mesa_delete_buffer_object(struct gl_context *ctx,
bufObj->RefCount = -1000;
bufObj->Name = ~0;
 
-   simple_mtx_destroy(&bufObj->Mutex);
+   simple_mtx_destroy(&bufObj->MinMaxCacheMutex);
free(bufObj->Label);
free(bufObj);
 }
@@ -490,16 +491,9 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
 {
if (*ptr) {
   /* Unreference the old buffer */
-  GLboolean deleteFlag = GL_FALSE;
   struct gl_buffer_object *oldObj = *ptr;
 
-  simple_mtx_lock(&oldObj->Mutex);
-  assert(oldObj->RefCount > 0);
-  oldObj->RefCount--;
-  deleteFlag = (oldObj->RefCount == 0);
-  simple_mtx_unlock(&oldObj->Mutex);
-
-  if (deleteFlag) {
+  if (p_atomic_dec_zero(&oldObj->RefCount)) {
 assert(ctx->Driver.DeleteBuffer);
  ctx->Driver.DeleteBuffer(ctx, oldObj);
   }
@@ -510,12 +504,8 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
 
if (bufObj) {
   /* reference new buffer */
-  simple_mtx_lock(&bufObj->Mutex);
-  assert(bufObj->RefCount > 0);
-
-  bufObj->RefCount++;
+  p_atomic_inc(&bufObj->RefCount);
   *ptr = bufObj;
-  simple_mtx_unlock(&bufObj->Mutex);
}
 }
 
@@ -547,11 +537,11 @@ _mesa_initialize_buffer_object(struct gl_context *ctx,
GLuint name)
 {
memset(obj, 0, sizeof(struct gl_buffer_object));
-   simple_mtx_init(&obj->Mutex, mtx_plain);
obj->RefCount = 1;
obj->Name = name;
obj->Usage = GL_STATIC_DRAW_ARB;
 
+   simple_mtx_init(&obj->MinMaxCacheMutex, mtx_plain);
if (get_no_minmax_cache())
   obj->UsageHistory |= USAGE_DISABLE_MINMAX_CACHE;
 }
@@ -870,7 +860,7 @@ _mesa_init_buffer_objects( struct gl_context *ctx )
GLuint i;
 
memset(&DummyBufferObject, 0, sizeof(DummyBufferObject));
-   simple_mtx_init(&DummyBufferObject.Mutex, mtx_plain);
+   simple_mtx_init(&DummyBufferObject.MinMaxCacheMutex, mtx_plain);
DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */
 
_mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 3a67d43420..b6d606386e 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1443,7 +1443,6 @@ typedef enum
  */
 struct gl_buffer_object
 {
-   simple_mtx_t Mutex;
GLint RefCount;
GLuint Name;
GLchar *Label;   /**< GL_KHR_debug */
@@ -1464,6 +1463,7 @@ struct gl_buffer_object
struct gl_buffer_mapping Mappings[MAP_COUNT];
 
/** Memoization of min/max index computations for static index buffers */
+   simple_mtx_t MinMaxCacheMutex;
struct hash_table *MinMaxCache;
unsigned MinMaxCacheHitIndices;
unsigned MinMaxCacheMissIndices;
diff --git a/src/mesa/vbo/vbo_minmax_index.c b/src/mesa/vbo/vbo_minmax_index.c
index c9d2020167..d1298dcdc3 100644
--- a/src/mesa/vbo/vbo_minmax_index.c
+++ b/src/mesa/vbo/vbo_minmax_index.c
@@ -115,7 +115,7 @@ vbo_get_minmax_cached(struct gl_buffer_object *bufferObj,
if (!vbo_use_minmax_cache(bufferObj))
   return GL_FALSE;
 
-   simple_mtx_lock(&bufferObj->Mutex);
+   simple_mtx_lock(&bufferObj->MinMaxCacheMutex);
 
if (bufferObj->MinMaxCacheDirty) {
   /* Disable the cache permanently for this BO if the num

Mesa (master): mesa: Factor out _mesa_disable_vertex_array_attrib.

2018-02-06 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: e8a9473d32149ed0f8b9b188652a7ef951324f72
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e8a9473d32149ed0f8b9b188652a7ef951324f72

Author: Mathias Fröhlich 
Date:   Sat Feb  3 20:25:39 2018 +0100

mesa: Factor out _mesa_disable_vertex_array_attrib.

And use it in the enable code path.
Move _mesa_update_attribute_map_mode into its only remaining file.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/arrayobj.h | 26 
 src/mesa/main/enable.c   | 64 ++--
 src/mesa/main/varray.c   | 58 ---
 src/mesa/main/varray.h   |  7 ++
 4 files changed, 75 insertions(+), 80 deletions(-)

diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 411ed65c50..5de74505bb 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -100,32 +100,6 @@ 
_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX];
 
 
 /**
- * Depending on the position and generic0 attributes enable flags select
- * the one that is used for both attributes.
- * The generic0 attribute takes precedence.
- */
-static inline void
-_mesa_update_attribute_map_mode(const struct gl_context *ctx,
-struct gl_vertex_array_object *vao)
-{
-   /*
-* There is no need to change the mapping away from the
-* identity mapping if we are not in compat mode.
-*/
-   if (ctx->API != API_OPENGL_COMPAT)
-  return;
-   /* The generic0 attribute superseeds the position attribute */
-   const GLbitfield enabled = vao->_Enabled;
-   if (enabled & VERT_BIT_GENERIC0)
-  vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_GENERIC0;
-   else if (enabled & VERT_BIT_POS)
-  vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_POSITION;
-   else
-  vao->_AttributeMapMode = ATTRIBUTE_MAP_MODE_IDENTITY;
-}
-
-
-/**
  * Apply the position/generic0 aliasing map to a bitfield from the vao.
  * Use for example to convert gl_vertex_array_object::_Enabled
  * or gl_vertex_buffer_binding::_VertexBinding from the vao numbering to
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index bc22410bda..967d23080c 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -40,6 +40,7 @@
 #include "mtypes.h"
 #include "enums.h"
 #include "texstate.h"
+#include "varray.h"
 
 
 
@@ -58,55 +59,56 @@ update_derived_primitive_restart_state(struct gl_context 
*ctx)
   || ctx->Array.PrimitiveRestartFixedIndex;
 }
 
+
+/**
+ * Helper to enable/disable VAO client-side state.
+ */
+static void
+vao_state(struct gl_context *ctx, gl_vert_attrib attr, GLboolean state)
+{
+   if (state)
+  _mesa_enable_vertex_array_attrib(ctx, ctx->Array.VAO, attr);
+   else
+  _mesa_disable_vertex_array_attrib(ctx, ctx->Array.VAO, attr);
+}
+
+
 /**
  * Helper to enable/disable client-side state.
  */
 static void
 client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
 {
-   struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   GLbitfield vert_attrib_bit;
-   GLboolean *enable_var;
-
switch (cap) {
   case GL_VERTEX_ARRAY:
- enable_var = &vao->VertexAttrib[VERT_ATTRIB_POS].Enabled;
- vert_attrib_bit = VERT_BIT_POS;
+ vao_state(ctx, VERT_ATTRIB_POS, state);
  break;
   case GL_NORMAL_ARRAY:
- enable_var = &vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
- vert_attrib_bit = VERT_BIT_NORMAL;
+ vao_state(ctx, VERT_ATTRIB_NORMAL, state);
  break;
   case GL_COLOR_ARRAY:
- enable_var = &vao->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled;
- vert_attrib_bit = VERT_BIT_COLOR0;
+ vao_state(ctx, VERT_ATTRIB_COLOR0, state);
  break;
   case GL_INDEX_ARRAY:
- enable_var = &vao->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled;
- vert_attrib_bit = VERT_BIT_COLOR_INDEX;
+ vao_state(ctx, VERT_ATTRIB_COLOR_INDEX, state);
  break;
   case GL_TEXTURE_COORD_ARRAY:
- enable_var = 
&vao->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled;
- vert_attrib_bit = VERT_BIT_TEX(ctx->Array.ActiveTexture);
+ vao_state(ctx, VERT_ATTRIB_TEX(ctx->Array.ActiveTexture), state);
  break;
   case GL_EDGE_FLAG_ARRAY:
- enable_var = &vao->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled;
- vert_attrib_bit = VERT_BIT_EDGEFLAG;
+ vao_state(ctx, VERT_ATTRIB_EDGEFLAG, state);
  break;
   case GL_FOG_COORDINATE_ARRAY_EXT:
- enable_var = &vao->VertexAttrib[VERT_ATTRIB_FOG].Enabled;
- vert_attrib_bit = VERT_BIT_FOG;
+ vao_state(ctx, VERT_ATTRIB_FOG, state);
  break;
   case GL_SECONDARY_COLOR_ARRAY_EXT:
- enable_var = &vao->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled;
- ve

Mesa (master): vbo: Use static const VERT_ATTRIB->VBO_ATTRIB maps.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 3d4fb879ddbce1c5da7199ae74bc2e7ae98d1b70
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3d4fb879ddbce1c5da7199ae74bc2e7ae98d1b70

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Use static const VERT_ATTRIB->VBO_ATTRIB maps.

Instead of each context having its own map instance for
this purpose, use a global static const map.

v2: s,unsigned char,GLubyte,g
s,_VP_MODE_MAX,VP_MODE_MAX,g
Change comment style.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_context.c| 23 ++
 src/mesa/vbo/vbo_exec.c   | 74 +++
 src/mesa/vbo/vbo_exec_array.c |  5 ++-
 src/mesa/vbo/vbo_exec_draw.c  |  8 ++---
 src/mesa/vbo/vbo_private.h| 16 +++---
 src/mesa/vbo/vbo_save_draw.c  |  8 ++---
 6 files changed, 99 insertions(+), 35 deletions(-)

diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 4fa6f62ad0..5bc6bf0acd 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -236,27 +236,8 @@ _vbo_CreateContext(struct gl_context *ctx)
init_mat_currval(ctx);
vbo_set_indirect_draw_func(ctx, vbo_draw_indirect_prims);
 
-   /* Build mappings from VERT_ATTRIB -> VBO_ATTRIB depending on type
-* of vertex program active.
-*/
-   {
-  GLuint i;
-
-  /* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
-  STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
-
-  /* identity mapping */
-  for (i = 0; i < ARRAY_SIZE(vbo->map_vp_none); i++)
- vbo->map_vp_none[i] = i;
-  /* map material attribs to generic slots */
-  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++)
- vbo->map_vp_none[VERT_ATTRIB_MAT(i)]
-= VBO_ATTRIB_MAT_FRONT_AMBIENT + i;
-
-  for (i = 0; i < ARRAY_SIZE(vbo->map_vp_arb); i++)
- vbo->map_vp_arb[i] = i;
-   }
-
+   /* make sure all VBO_ATTRIB_ values can fit in an unsigned byte */
+   STATIC_ASSERT(VBO_ATTRIB_MAX <= 255);
 
/* Hook our functions into exec and compile dispatch tables.  These
 * will pretty much be permanently installed, which means that the
diff --git a/src/mesa/vbo/vbo_exec.c b/src/mesa/vbo/vbo_exec.c
index 82f204e3dc..fc06979dcb 100644
--- a/src/mesa/vbo/vbo_exec.c
+++ b/src/mesa/vbo/vbo_exec.c
@@ -32,6 +32,80 @@
 #include "main/vtxfmt.h"
 #include "vbo_private.h"
 
+const GLubyte
+_vbo_attribute_alias_map[VP_MODE_MAX][VERT_ATTRIB_MAX] = {
+   /* VP_FF: */
+   {
+  VBO_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VBO_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VBO_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VBO_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VBO_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+  VBO_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+  VBO_ATTRIB_EDGEFLAG,/* VERT_ATTRIB_EDGEFLAG */
+  VBO_ATTRIB_TEX0,/* VERT_ATTRIB_TEX0 */
+  VBO_ATTRIB_TEX1,/* VERT_ATTRIB_TEX1 */
+  VBO_ATTRIB_TEX2,/* VERT_ATTRIB_TEX2 */
+  VBO_ATTRIB_TEX3,/* VERT_ATTRIB_TEX3 */
+  VBO_ATTRIB_TEX4,/* VERT_ATTRIB_TEX4 */
+  VBO_ATTRIB_TEX5,/* VERT_ATTRIB_TEX5 */
+  VBO_ATTRIB_TEX6,/* VERT_ATTRIB_TEX6 */
+  VBO_ATTRIB_TEX7,/* VERT_ATTRIB_TEX7 */
+  VBO_ATTRIB_POINT_SIZE,  /* VERT_ATTRIB_POINT_SIZE */
+  VBO_ATTRIB_GENERIC0,/* VERT_ATTRIB_GENERIC0 */
+  VBO_ATTRIB_GENERIC1,/* VERT_ATTRIB_GENERIC1 */
+  VBO_ATTRIB_GENERIC2,/* VERT_ATTRIB_GENERIC2 */
+  VBO_ATTRIB_GENERIC3,/* VERT_ATTRIB_GENERIC3 */
+  VBO_ATTRIB_MAT_FRONT_AMBIENT,   /* VERT_ATTRIB_GENERIC4 */
+  VBO_ATTRIB_MAT_BACK_AMBIENT,/* VERT_ATTRIB_GENERIC5 */
+  VBO_ATTRIB_MAT_FRONT_DIFFUSE,   /* VERT_ATTRIB_GENERIC6 */
+  VBO_ATTRIB_MAT_BACK_DIFFUSE,/* VERT_ATTRIB_GENERIC7 */
+  VBO_ATTRIB_MAT_FRONT_SPECULAR,  /* VERT_ATTRIB_GENERIC8 */
+  VBO_ATTRIB_MAT_BACK_SPECULAR,   /* VERT_ATTRIB_GENERIC9 */
+  VBO_ATTRIB_MAT_FRONT_EMISSION,  /* VERT_ATTRIB_GENERIC10 */
+  VBO_ATTRIB_MAT_BACK_EMISSION,   /* VERT_ATTRIB_GENERIC11 */
+  VBO_ATTRIB_MAT_FRONT_SHININESS, /* VERT_ATTRIB_GENERIC12 */
+  VBO_ATTRIB_MAT_BACK_SHININESS,  /* VERT_ATTRIB_GENERIC13 */
+  VBO_ATTRIB_MAT_FRONT_INDEXES,   /* VERT_ATTRIB_GENERIC14 */
+  VBO_ATTRIB_MAT_BACK_INDEXES /* VERT_ATTRIB_GENERIC15 */
+   },
+
+   /* VP_SHADER: */
+   {
+  VBO_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VBO_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VBO_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VBO_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VBO_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+  VB

Mesa (master): vbo: Simplify input array distribution for dlist type draws.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 5b3d58520f40d575adc83cbbcd1c1208932d16d1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=5b3d58520f40d575adc83cbbcd1c1208932d16d1

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Simplify input array distribution for dlist type draws.

Using the newly introduced VAO array maps, we can
simplify vbo_bind_vertex_list.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_save_draw.c | 54 +++-
 1 file changed, 8 insertions(+), 46 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index ad45f4d050..96a9bab029 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -27,6 +27,7 @@
  */
 
 #include 
+#include "main/arrayobj.h"
 #include "main/glheader.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
@@ -140,54 +141,20 @@ bind_vertex_list(struct gl_context *ctx,
struct gl_vertex_array *arrays = save->arrays;
GLuint attr;
GLbitfield varying_inputs = 0x0;
-   bool generic_from_pos = false;
 
const enum vp_mode program_mode = get_vp_mode(ctx);
const GLubyte * const map = _vbo_attribute_alias_map[program_mode];
 
-   /* Install the default (ie Current) attributes first */
-   for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-  save->inputs[attr] = &vbo->currval[VBO_ATTRIB_POS + attr];
-   }
-
-   /* Overlay other active attributes */
-   switch (program_mode) {
-   case VP_FF:
-  for (attr = 0; attr < VERT_ATTRIB_MAT0; attr++) {
- save->inputs[VERT_ATTRIB_GENERIC(attr)] =
-&vbo->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-  for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
- save->inputs[VERT_ATTRIB_MAT(attr)] =
-&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
-  }
-  break;
-   case VP_SHADER:
-  for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
- save->inputs[VERT_ATTRIB_GENERIC(attr)] =
-&vbo->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-
-  /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read.
-   * In that case we effectively need to route the data from
-   * glVertexAttrib(0, val) calls to feed into the GENERIC0 input.
-   */
-  const GLbitfield64 inputs_read =
- ctx->VertexProgram._Current->info.inputs_read;
-  if ((inputs_read & VERT_BIT_POS) == 0 &&
-  (inputs_read & VERT_BIT_GENERIC0)) {
- generic_from_pos = true;
-  }
-  break;
-   default:
-  unreachable("Bad vertex program mode");
-   }
-
+   /* Grab VERT_ATTRIB_{POS,GENERIC0} from VBO_ATTRIB_POS */
+   const gl_attribute_map_mode mode = ATTRIBUTE_MAP_MODE_POSITION;
+   const GLubyte *const array_map = _mesa_vao_attribute_map[mode];
for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
-  const GLuint src = map[attr];
+  const GLuint src = map[array_map[attr]];
   const GLubyte size = node->attrsz[src];
 
-  if (size) {
+  if (size == 0) {
+ save->inputs[attr] = &vbo->currval[map[attr]];
+  } else {
  struct gl_vertex_array *array = &arrays[attr];
  const GLenum16 type = node->attrtype[src];
 
@@ -211,11 +178,6 @@ bind_vertex_list(struct gl_context *ctx,
   }
}
 
-   if (generic_from_pos) {
-  varying_inputs |= (varying_inputs & VERT_BIT_POS) << 
VERT_ATTRIB_GENERIC0;
-  save->inputs[VERT_ATTRIB_GENERIC0] = save->inputs[VERT_ATTRIB_POS];
-   }
-
_mesa_set_varying_vp_inputs(ctx, varying_inputs);
ctx->NewDriverState |= ctx->DriverFlags.NewArray;
 }

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Use defines for the aliased material array attributes.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 38b41fd718cfffd11dab637d9d0cbd6c2a30b2c2
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=38b41fd718cfffd11dab637d9d0cbd6c2a30b2c2

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

mesa: Use defines for the aliased material array attributes.

Instead of just assuming that the material attributes
just overlap with the generic attributes 0-12, give
them symbolic defines so that we can easier move them
to an other range.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/compiler/shader_enums.h | 10 ++
 src/mesa/drivers/dri/nouveau/nouveau_render_t.c |  2 +-
 src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c|  8 
 src/mesa/drivers/dri/nouveau/nv10_render.c  | 10 +-
 src/mesa/drivers/dri/nouveau/nv20_render.c  | 20 ++--
 src/mesa/main/ffvertex_prog.c   |  7 ---
 src/mesa/tnl/t_context.h|  2 +-
 src/mesa/vbo/vbo_context.c  |  4 ++--
 src/mesa/vbo/vbo_exec_array.c   | 10 +-
 src/mesa/vbo/vbo_exec_draw.c| 10 +++---
 src/mesa/vbo/vbo_save_draw.c|  9 ++---
 11 files changed, 55 insertions(+), 37 deletions(-)

diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index ffe551ab20..aa296adb5a 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -124,6 +124,9 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
  * VERT_ATTRIB_GENERIC
  *   include the OpenGL 2.0+ GLSL generic shader attributes.
  *   These alias the generic GL_ARB_vertex_shader attributes.
+ * VERT_ATTRIB_MAT
+ *   include the generic shader attributes used to alias
+ *   varying material values for the TNL shader programs.
  */
 #define VERT_ATTRIB_FF(i)   (VERT_ATTRIB_POS + (i))
 #define VERT_ATTRIB_FF_MAX  VERT_ATTRIB_GENERIC0
@@ -134,6 +137,9 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
 #define VERT_ATTRIB_GENERIC(i)  (VERT_ATTRIB_GENERIC0 + (i))
 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
 
+#define VERT_ATTRIB_MAT(i)  VERT_ATTRIB_GENERIC(i)
+#define VERT_ATTRIB_MAT_MAX MAT_ATTRIB_MAX
+
 /**
  * Bitflags for vertex attributes.
  * These are used in bitfields in many places.
@@ -169,6 +175,10 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
 #define VERT_BIT_GENERIC(i)  VERT_BIT(VERT_ATTRIB_GENERIC(i))
 #define VERT_BIT_GENERIC_ALL \
BITFIELD_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
+
+#define VERT_BIT_MAT(i) VERT_BIT(VERT_ATTRIB_MAT(i))
+#define VERT_BIT_MAT_ALL \
+   BITFIELD_RANGE(VERT_ATTRIB_MAT(0), VERT_ATTRIB_MAT_MAX)
 /*@}*/
 
 #define MAX_VARYING 32 /**< number of float[4] vectors */
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
index db60b59c8f..5699f38f4d 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_render_t.c
@@ -188,7 +188,7 @@ static void
 TAG(emit_material)(struct gl_context *ctx, struct nouveau_array *a,
   const void *v)
 {
-   int attr = a->attr - VERT_ATTRIB_GENERIC0;
+   int attr = a->attr - VERT_ATTRIB_MAT(0);
int state = ((int []) {
NOUVEAU_STATE_MATERIAL_FRONT_AMBIENT,
NOUVEAU_STATE_MATERIAL_BACK_AMBIENT,
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c 
b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index fdd135c5d7..b9145e6851 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -118,8 +118,8 @@ vbo_choose_render_mode(struct gl_context *ctx, const struct 
gl_vertex_array **ar
render->mode = VBO;
 
if (ctx->Light.Enabled) {
-   for (i = 0; i < MAT_ATTRIB_MAX; i++) {
-   if (arrays[VERT_ATTRIB_GENERIC0 + i]->StrideB) {
+   for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
+   if (arrays[VERT_ATTRIB_MAT(i)]->StrideB) {
render->mode = IMM;
break;
}
@@ -138,7 +138,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct 
gl_vertex_array **arrays,
RENDER_LOCALS(ctx);
 
if (!array->StrideB) {
-   if (attr >= VERT_ATTRIB_GENERIC0)
+   if (attr >= VERT_ATTRIB_MAT(0))
/* nouveau_update_state takes care of materials. */
return;
 
@@ -165,7 +165,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct 
gl_vertex_array **arrays,
}
 }
 
-#define MAT(a) (VERT_ATTRIB_GENERIC0 + MAT_ATTRIB_##a)
+#define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a)
 
 static void
 vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array 

Mesa (master): vbo: Simplify input array distribution for imm type draws.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: fb10a7b7b0da7b4965a60a9427bf295825bf78c8
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fb10a7b7b0da7b4965a60a9427bf295825bf78c8

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Simplify input array distribution for imm type draws.

Using the newly introduced VAO array maps, we can
simplify vbo_exec_bind_arrays.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_exec_draw.c | 81 
 1 file changed, 15 insertions(+), 66 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index e3e050595c..b0cc394642 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -27,6 +27,7 @@
 
 #include 
 #include 
+#include "main/arrayobj.h"
 #include "main/glheader.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
@@ -176,62 +177,20 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
struct gl_vertex_array *arrays = exec->vtx.arrays;
GLuint attr;
GLbitfield varying_inputs = 0x0;
-   bool swap_pos = false;
 
const enum vp_mode program_mode = get_vp_mode(exec->ctx);
const GLubyte * const map = _vbo_attribute_alias_map[program_mode];
 
-   /* Install the default (ie Current) attributes first */
-   for (attr = 0; attr < VERT_ATTRIB_FF_MAX; attr++) {
-  exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr];
-   }
+   /* Grab VERT_ATTRIB_{POS,GENERIC0} from VBO_ATTRIB_POS */
+   const gl_attribute_map_mode mode = ATTRIBUTE_MAP_MODE_POSITION;
+   const GLubyte *const array_map = _mesa_vao_attribute_map[mode];
+   for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+  const GLuint src = map[array_map[attr]];
+  const GLubyte size = exec->vtx.attrsz[src];
 
-   /* Overlay other active attributes */
-   switch (program_mode) {
-   case VP_FF:
-  for (attr = 0; attr < VERT_ATTRIB_MAT0; attr++) {
- assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
- exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
-&vbo->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-  for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
- assert(VERT_ATTRIB_MAT(attr) < ARRAY_SIZE(exec->vtx.inputs));
- exec->vtx.inputs[VERT_ATTRIB_MAT(attr)] =
-&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
-  }
-  break;
-   case VP_SHADER:
-  for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) {
- assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
- exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
-&vbo->currval[VBO_ATTRIB_GENERIC0+attr];
-  }
-
-  /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read.
-   * In that case we effectively need to route the data from
-   * glVertexAttrib(0, val) calls to feed into the GENERIC0 input.
-   * The original state gets essentially restored below.
-   */
-  const GLbitfield64 inputs_read =
- ctx->VertexProgram._Current->info.inputs_read;
-  if ((inputs_read & VERT_BIT_POS) == 0 &&
-  (inputs_read & VERT_BIT_GENERIC0)) {
- swap_pos = true;
- exec->vtx.inputs[VERT_ATTRIB_GENERIC0] = exec->vtx.inputs[0];
- exec->vtx.attrsz[VERT_ATTRIB_GENERIC0] = exec->vtx.attrsz[0];
- exec->vtx.attrtype[VERT_ATTRIB_GENERIC0] = exec->vtx.attrtype[0];
- exec->vtx.attrptr[VERT_ATTRIB_GENERIC0] = exec->vtx.attrptr[0];
- exec->vtx.attrsz[0] = 0;
-  }
-  break;
-   default:
-  unreachable("Bad vertex program mode");
-   }
-
-   for (attr = 0; attr < VERT_ATTRIB_MAX ; attr++) {
-  const GLuint src = map[attr];
-
-  if (exec->vtx.attrsz[src]) {
+  if (size == 0) {
+ exec->vtx.inputs[attr] = &vbo->currval[map[attr]];
+  } else {
  GLsizeiptr offset = (GLbyte *)exec->vtx.attrptr[src] -
 (GLbyte *)exec->vtx.vertex;
 
@@ -251,13 +210,13 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
 /* Ptr into ordinary app memory */
 arrays[attr].Ptr = (GLubyte *)exec->vtx.buffer_map + offset;
  }
- arrays[attr].Size = exec->vtx.attrsz[src];
+ arrays[attr].Size = size;
  arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
- arrays[attr].Type = exec->vtx.attrtype[src];
- arrays[attr].Integer =
-   vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]);
+ const GLenum16 type = exec->vtx.attrtype[src];
+ arrays[attr].Type = type;
+ arrays[attr].Integer = vbo_attrtype_to_integer_flag(type);
  arrays[attr].Format = GL_RGBA;
- arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat);
+ arrays[attr].

Mesa (master): mesa: Put materials at the end of the generic block.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 186f03cfb021223f0a6f238da036517fbf240d26
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=186f03cfb021223f0a6f238da036517fbf240d26

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

mesa: Put materials at the end of the generic block.

The materials are now moved to the end of the
generic attributes block to the range 4-15.

Before, the way the position and generic 0 attribute
is handled was dependent on the presence and kind of
the currently attached vertex program. With this
change the way the position attribute and the generic 0
attribute is treated only depends on the enabled
flag of those two arrays.
This will later help to untangle the update dependencies
between enabled arrays and shader inputs.

v2: s,VERT_ATTRIB_MAT_OFFSET,VERT_ATTRIB_MAT0,g

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/compiler/shader_enums.h   |  7 ++-
 src/mesa/tnl/t_context.h  |  4 ++--
 src/mesa/vbo/vbo_exec_array.c | 14 +++---
 src/mesa/vbo/vbo_exec_draw.c  | 10 +-
 src/mesa/vbo/vbo_save_draw.c  |  8 
 5 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index aa296adb5a..fb78ad384c 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -127,6 +127,8 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
  * VERT_ATTRIB_MAT
  *   include the generic shader attributes used to alias
  *   varying material values for the TNL shader programs.
+ *   They are located at the end of the generic attribute
+ *   block not to overlap with the generic 0 attribute.
  */
 #define VERT_ATTRIB_FF(i)   (VERT_ATTRIB_POS + (i))
 #define VERT_ATTRIB_FF_MAX  VERT_ATTRIB_GENERIC0
@@ -137,7 +139,10 @@ const char *gl_vert_attrib_name(gl_vert_attrib attrib);
 #define VERT_ATTRIB_GENERIC(i)  (VERT_ATTRIB_GENERIC0 + (i))
 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
 
-#define VERT_ATTRIB_MAT(i)  VERT_ATTRIB_GENERIC(i)
+#define VERT_ATTRIB_MAT0\
+   (VERT_ATTRIB_GENERIC_MAX - VERT_ATTRIB_MAT_MAX)
+#define VERT_ATTRIB_MAT(i)  \
+   VERT_ATTRIB_GENERIC((i) + VERT_ATTRIB_MAT0)
 #define VERT_ATTRIB_MAT_MAX MAT_ATTRIB_MAX
 
 /**
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 48d7ced791..082110c607 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -158,8 +158,8 @@ enum {
 #define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0
 #define _TNL_LAST_GENERIC  _TNL_ATTRIB_GENERIC15
 
-#define _TNL_FIRST_MAT   _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */
-#define _TNL_LAST_MAT_TNL_ATTRIB_MAT_BACK_INDEXES  /* GENERIC11 */
+#define _TNL_FIRST_MAT   _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC4 */
+#define _TNL_LAST_MAT_TNL_ATTRIB_MAT_BACK_INDEXES  /* GENERIC15 */
 
 /* Number of available texture attributes */
 #define _TNL_NUM_TEX 8
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index d1f4da0c0e..98eb6466ba 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -335,20 +335,20 @@ recalculate_input_bindings(struct gl_context *ctx)
  }
   }
 
-  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
- inputs[VERT_ATTRIB_MAT(i)] =
-&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
- const_inputs |= VERT_BIT_MAT(i);
-  }
-
   /* Could use just about anything, just to fill in the empty
* slots:
*/
-  for (i = VERT_ATTRIB_MAT_MAX; i < VERT_ATTRIB_GENERIC_MAX; i++) {
+  for (i = 0; i < VERT_ATTRIB_MAT0; i++) {
  inputs[VERT_ATTRIB_GENERIC(i)] =
 &vbo->currval[VBO_ATTRIB_GENERIC0 + i];
  const_inputs |= VERT_BIT_GENERIC(i);
   }
+
+  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
+ inputs[VERT_ATTRIB_MAT(i)] =
+&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
+ const_inputs |= VERT_BIT_MAT(i);
+  }
   break;
 
case VP_SHADER:
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 2b7784694f..bd82825b51 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -187,16 +187,16 @@ vbo_exec_bind_arrays(struct gl_context *ctx)
/* Overlay other active attributes */
switch (get_vp_mode(exec->ctx)) {
case VP_FF:
+  for (attr = 0; attr < VERT_ATTRIB_MAT0; attr++) {
+ assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs));
+ exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] =
+&vbo->currval[VBO_ATTRIB_GENERIC0+attr];
+  }
   for (attr = 0; attr < VERT_ATTRIB_MAT_MAX; attr++) {
  assert(VERT_ATTRIB_MAT(attr) < ARRAY_SIZE(exec->vtx.inputs));
  exec->vtx.inputs[VERT_ATTRIB_MAT(attr)] =
 &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr];
   }
- 

Mesa (master): mesa: Track position/generic0 aliasing in the VAO.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: b4fd63015ac7fd73e0147ff078caec47be729e87
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4fd63015ac7fd73e0147ff078caec47be729e87

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

mesa: Track position/generic0 aliasing in the VAO.

Since the first material attribute no longer aliases with
the generic0 attribute, only aliasing between generic0 and
position is left and entirely dependent on the enabled
state of the VAO. So introduce a gl_attribute_map_mode
in the VAO that is used to track how the position
and the generic 0 attribute alias.
Provide a static const array that can be used to
map from vertex program input indices to VERT_ATTRIB_*
indices. The outer dimension of the array is meant to
be indexed directly by the new VAO member variable.
Also provide methods on the VAO to convert bitmasks of
VERT_BIT's from the VAO numbering to the vertex processing
inputs numbering.

v2: s,unsigned char,GLubyte,g
s,_ATTRIBUTE_MAP_MODE_MAX,ATTRIBUTE_MAP_MODE_MAX,g
Change comment style, add comments.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/main/arrayobj.c | 131 +++
 src/mesa/main/arrayobj.h |  74 ++
 src/mesa/main/enable.c   |   5 ++
 src/mesa/main/mtypes.h   |  18 +++
 src/mesa/main/varray.c   |  18 +--
 5 files changed, 242 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 7208f4c534..360d097ec1 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -54,6 +54,135 @@
 #include "util/bitscan.h"
 
 
+const GLubyte
+_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX] =
+{
+   /* ATTRIBUTE_MAP_MODE_IDENTITY
+*
+* Grab vertex processing attribute VERT_ATTRIB_POS from
+* the VAO attribute VERT_ATTRIB_POS, and grab vertex processing
+* attribute VERT_ATTRIB_GENERIC0 from the VAO attribute
+* VERT_ATTRIB_GENERIC0.
+*/
+   {
+  VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VERT_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VERT_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VERT_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+  VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+  VERT_ATTRIB_EDGEFLAG,/* VERT_ATTRIB_EDGEFLAG */
+  VERT_ATTRIB_TEX0,/* VERT_ATTRIB_TEX0 */
+  VERT_ATTRIB_TEX1,/* VERT_ATTRIB_TEX1 */
+  VERT_ATTRIB_TEX2,/* VERT_ATTRIB_TEX2 */
+  VERT_ATTRIB_TEX3,/* VERT_ATTRIB_TEX3 */
+  VERT_ATTRIB_TEX4,/* VERT_ATTRIB_TEX4 */
+  VERT_ATTRIB_TEX5,/* VERT_ATTRIB_TEX5 */
+  VERT_ATTRIB_TEX6,/* VERT_ATTRIB_TEX6 */
+  VERT_ATTRIB_TEX7,/* VERT_ATTRIB_TEX7 */
+  VERT_ATTRIB_POINT_SIZE,  /* VERT_ATTRIB_POINT_SIZE */
+  VERT_ATTRIB_GENERIC0,/* VERT_ATTRIB_GENERIC0 */
+  VERT_ATTRIB_GENERIC1,/* VERT_ATTRIB_GENERIC1 */
+  VERT_ATTRIB_GENERIC2,/* VERT_ATTRIB_GENERIC2 */
+  VERT_ATTRIB_GENERIC3,/* VERT_ATTRIB_GENERIC3 */
+  VERT_ATTRIB_GENERIC4,/* VERT_ATTRIB_GENERIC4 */
+  VERT_ATTRIB_GENERIC5,/* VERT_ATTRIB_GENERIC5 */
+  VERT_ATTRIB_GENERIC6,/* VERT_ATTRIB_GENERIC6 */
+  VERT_ATTRIB_GENERIC7,/* VERT_ATTRIB_GENERIC7 */
+  VERT_ATTRIB_GENERIC8,/* VERT_ATTRIB_GENERIC8 */
+  VERT_ATTRIB_GENERIC9,/* VERT_ATTRIB_GENERIC9 */
+  VERT_ATTRIB_GENERIC10,   /* VERT_ATTRIB_GENERIC10 */
+  VERT_ATTRIB_GENERIC11,   /* VERT_ATTRIB_GENERIC11 */
+  VERT_ATTRIB_GENERIC12,   /* VERT_ATTRIB_GENERIC12 */
+  VERT_ATTRIB_GENERIC13,   /* VERT_ATTRIB_GENERIC13 */
+  VERT_ATTRIB_GENERIC14,   /* VERT_ATTRIB_GENERIC14 */
+  VERT_ATTRIB_GENERIC15/* VERT_ATTRIB_GENERIC15 */
+   },
+
+   /* ATTRIBUTE_MAP_MODE_POSITION
+*
+* Grab vertex processing attribute VERT_ATTRIB_POS as well as
+* vertex processing attribute VERT_ATTRIB_GENERIC0 from the
+* VAO attribute VERT_ATTRIB_POS.
+*/
+   {
+  VERT_ATTRIB_POS, /* VERT_ATTRIB_POS */
+  VERT_ATTRIB_NORMAL,  /* VERT_ATTRIB_NORMAL */
+  VERT_ATTRIB_COLOR0,  /* VERT_ATTRIB_COLOR0 */
+  VERT_ATTRIB_COLOR1,  /* VERT_ATTRIB_COLOR1 */
+  VERT_ATTRIB_FOG, /* VERT_ATTRIB_FOG */
+  VERT_ATTRIB_COLOR_INDEX, /* VERT_ATTRIB_COLOR_INDEX */
+  VERT_ATTRIB_EDGEFLAG,/* VERT_ATTRIB_EDGEFLAG */
+  VERT_ATTRIB_TEX0,/* VERT_ATTRIB_TEX0 */
+  VERT_ATTRIB_TEX1,/* VERT_ATTRIB_TEX1 */
+  V

Mesa (master): vbo: Correctly handle attribute offsets in dlist draw.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: f37e29ac224887f1b4f0cb7c61e47fb4bc6671e1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f37e29ac224887f1b4f0cb7c61e47fb4bc6671e1

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Correctly handle attribute offsets in dlist draw.

When executing a display list draw, for the offset
list to be correct, the offset computation needs to
accumulate all attribute size values in order.
Specifically, if we are shuffling around the position
and generic0 attributes, we may violate the order or
if we do not walk the generic vbo attributes we may
skip some of the attributes.
Even if this is an unlikely usecase we can fix this use
case by precomputing the offsets on the full attribute list
and store the full offset list in the display list node.

v2: Formatting fix
v3: Rebase

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_save.h  |  1 +
 src/mesa/vbo/vbo_save_api.c  | 19 ++
 src/mesa/vbo/vbo_save_draw.c | 47 +++-
 3 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/src/mesa/vbo/vbo_save.h b/src/mesa/vbo/vbo_save.h
index 1dc66a598e..cb0bff2341 100644
--- a/src/mesa/vbo/vbo_save.h
+++ b/src/mesa/vbo/vbo_save.h
@@ -64,6 +64,7 @@ struct vbo_save_vertex_list {
GLbitfield64 enabled; /**< mask of enabled vbo arrays. */
GLubyte attrsz[VBO_ATTRIB_MAX];
GLenum16 attrtype[VBO_ATTRIB_MAX];
+   GLuint offsets[VBO_ATTRIB_MAX];
GLuint vertex_size;  /**< size in GLfloats */
 
/* Copy of the final vertex from node->vertex_store->bufferobj.
diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index a0fb62d814..fb51bdb84e 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -420,6 +420,8 @@ compile_vertex_list(struct gl_context *ctx)
 {
struct vbo_save_context *save = &vbo_context(ctx)->save;
struct vbo_save_vertex_list *node;
+   GLuint offset;
+   unsigned i;
 
/* Allocate space for this structure in the display list currently
 * being compiled.
@@ -443,6 +445,23 @@ compile_vertex_list(struct gl_context *ctx)
node->vertex_size = save->vertex_size;
node->buffer_offset =
   (save->buffer_map - save->vertex_store->buffer_map) * sizeof(GLfloat);
+   if (aligned_vertex_buffer_offset(node)) {
+  /* The vertex size is an exact multiple of the buffer offset.
+   * This means that we can use zero-based vertex attribute pointers
+   * and specify the start of the primitive with the _mesa_prim::start
+   * field.  This results in issuing several draw calls with identical
+   * vertex attribute information.  This can result in fewer state
+   * changes in drivers.  In particular, the Gallium CSO module will
+   * filter out redundant vertex buffer changes.
+   */
+  offset = 0;
+   } else {
+  offset = node->buffer_offset;
+   }
+   for (i = 0; i < VBO_ATTRIB_MAX; ++i) {
+  node->offsets[i] = offset;
+  offset += node->attrsz[i] * sizeof(GLfloat);
+   }
node->vertex_count = save->vert_count;
node->wrap_count = save->copied.nr;
node->dangling_attr_ref = save->dangling_attr_ref;
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index cf824c66b0..486247f744 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -26,6 +26,7 @@
  *Keith Whitwell 
  */
 
+#include 
 #include "main/glheader.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
@@ -137,29 +138,10 @@ bind_vertex_list(struct gl_context *ctx,
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_save_context *save = &vbo->save;
struct gl_vertex_array *arrays = save->arrays;
-   GLuint buffer_offset = node->buffer_offset;
const GLubyte *map;
GLuint attr;
-   GLubyte node_attrsz[VBO_ATTRIB_MAX];  /* copy of node->attrsz[] */
-   GLenum16 node_attrtype[VBO_ATTRIB_MAX];  /* copy of node->attrtype[] */
GLbitfield varying_inputs = 0x0;
-
-   STATIC_ASSERT(sizeof(node_attrsz) == sizeof(node->attrsz));
-   memcpy(node_attrsz, node->attrsz, sizeof(node->attrsz));
-   STATIC_ASSERT(sizeof(node_attrtype) == sizeof(node->attrtype));
-   memcpy(node_attrtype, node->attrtype, sizeof(node->attrtype));
-
-   if (aligned_vertex_buffer_offset(node)) {
-  /* The vertex size is an exact multiple of the buffer offset.
-   * This means that we can use zero-based vertex attribute pointers
-   * and specify the start of the primitive with the _mesa_prim::start
-   * field.  This results in issuing several draw calls with identical
-   * vertex attribute information.  This can result in fewer state
-   * changes in drivers.  In particular, the Gallium CSO module will
-   * filter out redundant vertex buffer changes.
-   */
-  buffer_offs

Mesa (master): vbo: Simplify input array distribution for array type draws.

2018-02-01 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 44b1454b968deb5ee0a5ecaf8cd06ed6bf11989a
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=44b1454b968deb5ee0a5ecaf8cd06ed6bf11989a

Author: Mathias Fröhlich 
Date:   Sat Jan 27 16:07:22 2018 +0100

vbo: Simplify input array distribution for array type draws.

Using the newly introduced VAO state variable, we can
simplify recalculate_input_bindings.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 

---

 src/mesa/vbo/vbo_exec_array.c | 110 +++---
 1 file changed, 27 insertions(+), 83 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index ee4b7b56b6..42759d5897 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -313,43 +313,25 @@ recalculate_input_bindings(struct gl_context *ctx)
 {
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
-   const struct gl_array_attributes *array = ctx->Array.VAO->VertexAttrib;
-   struct gl_vertex_array *vertexAttrib = ctx->Array.VAO->_VertexAttrib;
+   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
+   const struct gl_vertex_array *vertexAttrib = vao->_VertexAttrib;
const struct gl_vertex_array **inputs = &exec->array.inputs[0];
-   GLbitfield const_inputs = 0x0;
-   GLuint i;
+
+   /* May shuffle the position and generic0 bits around */
+   GLbitfield vp_inputs = _mesa_get_vao_vp_inputs(vao);
 
const enum vp_mode program_mode = get_vp_mode(ctx);
+   const GLubyte *const map = _vbo_attribute_alias_map[program_mode];
switch (program_mode) {
case VP_FF:
   /* When no vertex program is active (or the vertex program is generated
* from fixed-function state).  We put the material values into the
-   * generic slots.  This is the only situation where material values
-   * are available as per-vertex attributes.
+   * generic slots.  Since the vao has no material arrays, mute these
+   * slots from the enabled arrays so that the current material values
+   * are pulled instead of the vao arrays.
*/
-  for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
- if (array[VERT_ATTRIB_FF(i)].Enabled)
-inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
- else {
-inputs[i] = &vbo->currval[VBO_ATTRIB_POS + i];
-const_inputs |= VERT_BIT_FF(i);
- }
-  }
-
-  /* Could use just about anything, just to fill in the empty
-   * slots:
-   */
-  for (i = 0; i < VERT_ATTRIB_MAT0; i++) {
- inputs[VERT_ATTRIB_GENERIC(i)] =
-&vbo->currval[VBO_ATTRIB_GENERIC0 + i];
- const_inputs |= VERT_BIT_GENERIC(i);
-  }
+  vp_inputs &= VERT_BIT_FF_ALL;
 
-  for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
- inputs[VERT_ATTRIB_MAT(i)] =
-&vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT + i];
- const_inputs |= VERT_BIT_MAT(i);
-  }
   break;
 
case VP_SHADER:
@@ -368,68 +350,30 @@ recalculate_input_bindings(struct gl_context *ctx)
* In all other APIs, only the generic attributes exist, and none of the
* slots are considered "magic."
*/
-  if (ctx->API == API_OPENGL_COMPAT) {
- if (array[VERT_ATTRIB_GENERIC0].Enabled)
-inputs[VERT_ATTRIB_POS] = &vertexAttrib[VERT_ATTRIB_GENERIC0];
- else if (array[VERT_ATTRIB_POS].Enabled)
-inputs[VERT_ATTRIB_POS] = &vertexAttrib[VERT_ATTRIB_POS];
- else {
-inputs[VERT_ATTRIB_POS] = &vbo->currval[VBO_ATTRIB_GENERIC0];
-const_inputs |= VERT_BIT_POS;
- }
-
- for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) {
-if (array[VERT_ATTRIB_FF(i)].Enabled)
-   inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
-else {
-   inputs[i] = &vbo->currval[VBO_ATTRIB_POS + i];
-   const_inputs |= VERT_BIT_FF(i);
-}
- }
-
- for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-if (array[VERT_ATTRIB_GENERIC(i)].Enabled)
-   inputs[VERT_ATTRIB_GENERIC(i)] =
-  &vertexAttrib[VERT_ATTRIB_GENERIC(i)];
-else {
-   inputs[VERT_ATTRIB_GENERIC(i)] =
-  &vbo->currval[VBO_ATTRIB_GENERIC0 + i];
-   const_inputs |= VERT_BIT_GENERIC(i);
-}
- }
-
- inputs[VERT_ATTRIB_GENERIC0] = inputs[0];
-  } else {
- /* Other parts of the code assume that inputs[0] through
-  * inputs[VERT_ATTRIB_FF_MAX] will be non-NULL.  However, in OpenGL
-  * ES 2.0+ or OpenGL core profile, none of these arrays should ever
-  * be enabled.
-  */
- for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
-assert(!array[VERT_ATTRIB_FF(i)].Enabled);
-
-

Mesa (master): vbo: Array draw must not care about glBegin/ glEnd vbo mapping.

2016-08-14 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: c17cf1c8f5c4553780a9dba761e5e089ae3d3b01
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=c17cf1c8f5c4553780a9dba761e5e089ae3d3b01

Author: Mathias Fröhlich 
Date:   Sun Aug 14 14:03:58 2016 +0200

vbo: Array draw must not care about glBegin/glEnd vbo mapping.

In array draw do not check if the vertex buffer object that
is used to implement immediate mode glBegin/glEnd is mapped.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 
Reviewed-by: Eric Anholt 

---

 src/mesa/vbo/vbo_exec_array.c | 18 +-
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index f371890..8789837 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -77,22 +77,6 @@ check_input_buffers_are_unmapped(const struct 
gl_vertex_array_object *vao)
 
 
 /**
- * A debug function that may be called from other parts of Mesa as
- * needed during debugging.
- */
-static bool
-check_buffers_are_unmapped(struct gl_context *ctx)
-{
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
-
-   /* check the current vertex arrays */
-   return !_mesa_check_disallowed_mapping(exec->vtx.bufferobj) &&
-  check_input_buffers_are_unmapped(ctx->Array.VAO);
-}
-
-
-/**
  * Check that element 'j' of the array has reasonable data.
  * Map VBO if needed.
  * For debugging purposes; not normally used.
@@ -446,7 +430,7 @@ vbo_bind_arrays(struct gl_context *ctx)
   }
}
 
-   if (!check_buffers_are_unmapped(ctx)) {
+   if (!check_input_buffers_are_unmapped(ctx->Array.VAO)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
   "draw call (vertex buffers are mapped)");
   return false;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Remove always true return from vbo_bind_arrays.

2016-08-14 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 84984b998632a17b373c7be2441c764879a6cae5
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=84984b998632a17b373c7be2441c764879a6cae5

Author: Mathias Fröhlich 
Date:   Sun Aug 14 14:03:58 2016 +0200

vbo: Remove always true return from vbo_bind_arrays.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 
Reviewed-by: Eric Anholt 

---

 src/mesa/vbo/vbo.h|  2 +-
 src/mesa/vbo/vbo_exec_array.c | 36 +++-
 2 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/src/mesa/vbo/vbo.h b/src/mesa/vbo/vbo.h
index 939a3a6..73478e6 100644
--- a/src/mesa/vbo/vbo.h
+++ b/src/mesa/vbo/vbo.h
@@ -197,7 +197,7 @@ void vbo_set_draw_func(struct gl_context *ctx, 
vbo_draw_func func);
 void vbo_set_indirect_draw_func(struct gl_context *ctx,
 vbo_indirect_draw_func func);
 
-bool vbo_bind_arrays(struct gl_context *ctx);
+void vbo_bind_arrays(struct gl_context *ctx);
 
 size_t
 vbo_count_tessellated_primitives(GLenum mode, GLuint count,
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index bfa9cd6..2fee50b 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -369,7 +369,7 @@ recalculate_input_bindings(struct gl_context *ctx)
  * Note that this might set the _NEW_VARYING_VP_INPUTS dirty flag so state
  * validation must be done after this call.
  */
-bool
+void
 vbo_bind_arrays(struct gl_context *ctx)
 {
struct vbo_context *vbo = vbo_context(ctx);
@@ -395,8 +395,6 @@ vbo_bind_arrays(struct gl_context *ctx)
  exec->validating = GL_FALSE;
   }
}
-
-   return true;
 }
 
 /**
@@ -412,8 +410,7 @@ vbo_draw_arrays(struct gl_context *ctx, GLenum mode, GLint 
start,
struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_prim prim[2];
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* init most fields to zero */
memset(prim, 0, sizeof(prim));
@@ -762,8 +759,7 @@ vbo_validated_drawrangeelements(struct gl_context *ctx, 
GLenum mode,
struct _mesa_index_buffer ib;
struct _mesa_prim prim[1];
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
ib.count = count;
ib.type = type;
@@ -1106,10 +1102,7 @@ vbo_validated_multidrawelements(struct gl_context *ctx, 
GLenum mode,
   return;
}
 
-   if (!vbo_bind_arrays(ctx)) {
-  free(prim);
-  return;
-   }
+   vbo_bind_arrays(ctx);
 
min_index_ptr = (uintptr_t)indices[0];
max_index_ptr = 0;
@@ -1273,8 +1266,7 @@ vbo_draw_transform_feedback(struct gl_context *ctx, 
GLenum mode,
   return;
}
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* init most fields to zero */
memset(prim, 0, sizeof(prim));
@@ -1370,8 +1362,7 @@ vbo_validated_drawarraysindirect(struct gl_context *ctx,
 {
struct vbo_context *vbo = vbo_context(ctx);
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, (GLsizeiptr)indirect,
@@ -1394,8 +1385,7 @@ vbo_validated_multidrawarraysindirect(struct gl_context 
*ctx,
if (primcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, offset,
@@ -1414,8 +1404,7 @@ vbo_validated_drawelementsindirect(struct gl_context *ctx,
struct vbo_context *vbo = vbo_context(ctx);
struct _mesa_index_buffer ib;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
ib.count = 0; /* unknown */
ib.type = type;
@@ -1445,8 +1434,7 @@ vbo_validated_multidrawelementsindirect(struct gl_context 
*ctx,
if (primcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* NOTE: IndexBufferObj is guaranteed to be a VBO. */
 
@@ -1566,8 +1554,7 @@ vbo_validated_multidrawarraysindirectcount(struct 
gl_context *ctx,
if (maxdrawcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
vbo->draw_indirect_prims(ctx, mode,
 ctx->DrawIndirectBuffer, offset,
@@ -1594,8 +1581,7 @@ vbo_validated_multidrawelementsindirectcount(struct 
gl_context *ctx,
if (maxdrawcount == 0)
   return;
 
-   if (!vbo_bind_arrays(ctx))
-  return;
+   vbo_bind_arrays(ctx);
 
/* NOTE: IndexBufferObj is guaranteed to be a VBO. */
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Move check for vbo mapping into api_validate.c.

2016-08-14 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 72f1566f90c434c7752d8405193eec68d6743246
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=72f1566f90c434c7752d8405193eec68d6743246

Author: Mathias Fröhlich 
Date:   Sun Aug 14 14:03:58 2016 +0200

mesa: Move check for vbo mapping into api_validate.c.

Instead of checking for mapped buffers in vbo_bind_arrays
do this check in api_validate.c. This additionally
enables printing the draw calls name into the error
string.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/api_validate.c  | 7 +++
 src/mesa/vbo/vbo_exec_array.c | 8 +---
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index ec3cc1b..ae3e118 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -25,6 +25,7 @@
 #include 
 #include "glheader.h"
 #include "api_validate.h"
+#include "arrayobj.h"
 #include "bufferobj.h"
 #include "context.h"
 #include "imports.h"
@@ -119,6 +120,12 @@ check_valid_to_render(struct gl_context *ctx, const char 
*function)
   unreachable("Invalid API value in check_valid_to_render()");
}
 
+   if (!_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
+  _mesa_error(ctx, GL_INVALID_OPERATION,
+  "%s(vertex buffers are mapped)", function);
+  return false;
+   }
+
return true;
 }
 
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index e1aa3ac..bfa9cd6 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -396,13 +396,7 @@ vbo_bind_arrays(struct gl_context *ctx)
   }
}
 
-   if (!_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
-  _mesa_error(ctx, GL_INVALID_OPERATION,
-  "draw call (vertex buffers are mapped)");
-  return false;
-   } else {
-  return true;
-   }
+   return true;
 }
 
 /**

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Move _mesa_all_buffers_are_unmapped to arrayobj.c.

2016-08-14 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: b7b0c51f1fd54c666e9520e1166e24216cc72211
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b7b0c51f1fd54c666e9520e1166e24216cc72211

Author: Mathias Fröhlich 
Date:   Sun Aug 14 14:03:58 2016 +0200

mesa: Move _mesa_all_buffers_are_unmapped to arrayobj.c.

Move the function to check if all vao buffers are
unmapped into the vao implementation file.
Rename the function to _mesa_all_buffers_are_unmapped.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/arrayobj.c  | 28 
 src/mesa/main/arrayobj.h  |  4 
 src/mesa/vbo/vbo_exec_array.c | 36 +---
 3 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index becf32f..2d3b69c 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -393,6 +393,34 @@ _mesa_all_varyings_in_vbos(const struct 
gl_vertex_array_object *vao)
return true;
 }
 
+bool
+_mesa_all_buffers_are_unmapped(const struct gl_vertex_array_object *vao)
+{
+   /* Walk the enabled arrays that have a vbo attached */
+   GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask;
+
+   while (mask) {
+  const int i = ffsll(mask) - 1;
+  const struct gl_vertex_attrib_array *attrib_array =
+ &vao->VertexAttrib[i];
+  const struct gl_vertex_buffer_binding *buffer_binding =
+ &vao->VertexBinding[attrib_array->VertexBinding];
+
+  /* Only enabled arrays shall appear in the _Enabled bitmask */
+  assert(attrib_array->Enabled);
+  /* We have already masked with vao->VertexAttribBufferMask  */
+  assert(_mesa_is_bufferobj(buffer_binding->BufferObj));
+
+  /* Bail out once we find the first disallowed mapping */
+  if (_mesa_check_disallowed_mapping(buffer_binding->BufferObj))
+ return false;
+
+  /* We have handled everything that is bound to this buffer_binding. */
+  mask &= ~buffer_binding->_BoundArrays;
+   }
+
+   return true;
+}
 
 /**/
 /* API Functions  */
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index d30c85c..830502e 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -85,6 +85,10 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx,
 extern bool
 _mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao);
 
+/* Returns true if all vbos are unmapped */
+extern bool
+_mesa_all_buffers_are_unmapped(const struct gl_vertex_array_object *vao);
+
 /*
  * API functions
  */
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 8789837..e1aa3ac 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -43,40 +43,6 @@
 
 
 /**
- * All vertex buffers should be in an unmapped state when we're about
- * to draw.
- */
-static bool
-check_input_buffers_are_unmapped(const struct gl_vertex_array_object *vao)
-{
-   /* Walk the enabled arrays that have a vbo attached */
-   GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask;
-
-   while (mask) {
-  int i = ffsll(mask) - 1;
-  const struct gl_vertex_attrib_array *attrib_array =
- &vao->VertexAttrib[i];
-  const struct gl_vertex_buffer_binding *buffer_binding =
- &vao->VertexBinding[attrib_array->VertexBinding];
-
-  /* Only enabled arrays shall appear in the _Enabled bitmask */
-  assert(attrib_array->Enabled);
-  /* We have already masked with vao->VertexAttribBufferMask  */
-  assert(_mesa_is_bufferobj(buffer_binding->BufferObj));
-
-  /* Bail out once we find the first disallowed mapping */
-  if (_mesa_check_disallowed_mapping(buffer_binding->BufferObj))
- return false;
-
-  /* We have handled everything that is bound to this buffer_binding. */
-  mask &= ~buffer_binding->_BoundArrays;
-   }
-
-   return true;
-}
-
-
-/**
  * Check that element 'j' of the array has reasonable data.
  * Map VBO if needed.
  * For debugging purposes; not normally used.
@@ -430,7 +396,7 @@ vbo_bind_arrays(struct gl_context *ctx)
   }
}
 
-   if (!check_input_buffers_are_unmapped(ctx->Array.VAO)) {
+   if (!_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
   _mesa_error(ctx, GL_INVALID_OPERATION,
   "draw call (vertex buffers are mapped)");
   return false;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Remove duplicate include.

2016-08-14 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 312ece9cd773553a8a45a5d81edc7c09032ff4f1
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=312ece9cd773553a8a45a5d81edc7c09032ff4f1

Author: Mathias Fröhlich 
Date:   Sun Aug 14 14:03:58 2016 +0200

mesa: Remove duplicate include.

In api_validate.c stdbool.h was included twice.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/api_validate.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index ae3e118..384a8858 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -33,7 +33,6 @@
 #include "enums.h"
 #include "vbo/vbo.h"
 #include "transformfeedback.h"
-#include 
 
 
 /**

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): util: Use win32 intrinsics for util_last_bit if present.

2016-08-10 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 0ce5ec8ece78f7936dc7bf0ad58fa1ed01783e25
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=0ce5ec8ece78f7936dc7bf0ad58fa1ed01783e25

Author: Mathias Fröhlich 
Date:   Sat Aug  6 07:26:51 2016 +0200

util: Use win32 intrinsics for util_last_bit if present.

v2: Split into two patches.
v3: Fix off by one problem.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 
Tested-by: Brian Paul 

---

 src/util/bitscan.h | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/util/bitscan.h b/src/util/bitscan.h
index 0743fe7..8afef81 100644
--- a/src/util/bitscan.h
+++ b/src/util/bitscan.h
@@ -157,6 +157,12 @@ util_last_bit(unsigned u)
 {
 #if defined(HAVE___BUILTIN_CLZ)
return u == 0 ? 0 : 32 - __builtin_clz(u);
+#elif defined(_MSC_VER) && (_M_IX86 || _M_ARM || _M_AMD64 || _M_IA64)
+   unsigned long index;
+   if (_BitScanReverse(&index, u))
+  return index + 1;
+   else
+  return 0;
 #else
unsigned r = 0;
while (u) {
@@ -177,6 +183,12 @@ util_last_bit64(uint64_t u)
 {
 #if defined(HAVE___BUILTIN_CLZLL)
return u == 0 ? 0 : 64 - __builtin_clzll(u);
+#elif defined(_MSC_VER) && (_M_AMD64 || _M_ARM || _M_IA64)
+   unsigned long index;
+   if (_BitScanReverse64(&index, u))
+  return index + 1;
+   else
+  return 0;
 #else
unsigned r = 0;
while (u) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): util: Move _mesa_fsl/util_last_bit into util/bitscan.h

2016-08-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 027cbf00f248bda325521db8f56a3718898da46b
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=027cbf00f248bda325521db8f56a3718898da46b

Author: Mathias Fröhlich 
Date:   Tue Aug  2 08:46:04 2016 +0200

util: Move _mesa_fsl/util_last_bit into util/bitscan.h

As requested with the initial creation of util/bitscan.h
now move other bitscan related functions into util.

v2: Split into two patches.

Signed-off-by: Mathias Fröhlich 
Tested-by: Brian Paul 
Reviewed-by: Brian Paul 

---

 src/compiler/glsl/glsl_to_nir.cpp |  2 +-
 src/gallium/auxiliary/util/u_math.h   | 64 -
 src/mesa/drivers/dri/i965/brw_cs.c|  2 +-
 src/mesa/drivers/dri/i965/brw_draw.c  | 10 ++--
 src/mesa/drivers/dri/i965/brw_fs_nir.cpp  |  6 +-
 src/mesa/drivers/dri/i965/brw_program.c   |  2 +-
 src/mesa/drivers/dri/i965/brw_shader.cpp  |  2 +-
 src/mesa/drivers/dri/i965/brw_vec4_gs_visitor.cpp |  2 +-
 src/mesa/drivers/dri/i965/brw_wm_surface_state.c  |  2 +-
 src/mesa/main/imports.h   | 45 ---
 src/mesa/program/prog_to_nir.c|  6 +-
 src/util/bitscan.h| 68 +++
 12 files changed, 85 insertions(+), 126 deletions(-)

diff --git a/src/compiler/glsl/glsl_to_nir.cpp 
b/src/compiler/glsl/glsl_to_nir.cpp
index 20302e3..d3cc5b4 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -146,7 +146,7 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
shader->info.name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
if (shader_prog->Label)
   shader->info.label = ralloc_strdup(shader, shader_prog->Label);
-   shader->info.num_textures = _mesa_fls(sh->Program->SamplersUsed);
+   shader->info.num_textures = util_last_bit(sh->Program->SamplersUsed);
shader->info.num_ubos = sh->NumUniformBlocks;
shader->info.num_abos = shader_prog->NumAtomicBuffers;
shader->info.num_ssbos = sh->NumShaderStorageBlocks;
diff --git a/src/gallium/auxiliary/util/u_math.h 
b/src/gallium/auxiliary/util/u_math.h
index 1661e63..a923271 100644
--- a/src/gallium/auxiliary/util/u_math.h
+++ b/src/gallium/auxiliary/util/u_math.h
@@ -347,70 +347,6 @@ util_half_inf_sign(int16_t x)
 
 
 /**
- * Find last bit set in a word.  The least significant bit is 1.
- * Return 0 if no bits are set.
- */
-static inline unsigned
-util_last_bit(unsigned u)
-{
-#if defined(HAVE___BUILTIN_CLZ)
-   return u == 0 ? 0 : 32 - __builtin_clz(u);
-#else
-   unsigned r = 0;
-   while (u) {
-   r++;
-   u >>= 1;
-   }
-   return r;
-#endif
-}
-
-/**
- * Find last bit set in a word.  The least significant bit is 1.
- * Return 0 if no bits are set.
- */
-static inline unsigned
-util_last_bit64(uint64_t u)
-{
-#if defined(HAVE___BUILTIN_CLZLL)
-   return u == 0 ? 0 : 64 - __builtin_clzll(u);
-#else
-   unsigned r = 0;
-   while (u) {
-   r++;
-   u >>= 1;
-   }
-   return r;
-#endif
-}
-
-/**
- * Find last bit in a word that does not match the sign bit. The least
- * significant bit is 1.
- * Return 0 if no bits are set.
- */
-static inline unsigned
-util_last_bit_signed(int i)
-{
-   if (i >= 0)
-  return util_last_bit(i);
-   else
-  return util_last_bit(~(unsigned)i);
-}
-
-/* Returns a bitfield in which the first count bits starting at start are
- * set.
- */
-static inline unsigned
-u_bit_consecutive(unsigned start, unsigned count)
-{
-   assert(start + count <= 32);
-   if (count == 32)
-  return ~0;
-   return ((1u << count) - 1) << start;
-}
-
-/**
  * Return float bits.
  */
 static inline unsigned
diff --git a/src/mesa/drivers/dri/i965/brw_cs.c 
b/src/mesa/drivers/dri/i965/brw_cs.c
index 655adc1..6685acd 100644
--- a/src/mesa/drivers/dri/i965/brw_cs.c
+++ b/src/mesa/drivers/dri/i965/brw_cs.c
@@ -220,7 +220,7 @@ brw_upload_cs_prog(struct brw_context *brw)
   return;
 
brw->cs.base.sampler_count =
-  _mesa_fls(ctx->ComputeProgram._Current->Base.SamplersUsed);
+  util_last_bit(ctx->ComputeProgram._Current->Base.SamplersUsed);
 
brw_cs_populate_key(brw, &key);
 
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c 
b/src/mesa/drivers/dri/i965/brw_draw.c
index d7a1ba3..9b1e18c 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -452,15 +452,15 @@ brw_try_draw_prims(struct gl_context *ctx,
 * index.
 */
brw->wm.base.sampler_count =
-  _mesa_fls(ctx->FragmentProgram._Current->Base.SamplersUsed);
+  util_last_bit(ctx->FragmentProgram._Current->Base.SamplersUsed);
brw->gs.base.sampler_count = ctx->GeometryProgram._Current ?
-  _mesa_fls(ctx->GeometryProgram._Current->Base.SamplersUsed) : 0;
+  util_last_bit(ctx->GeometryProgram._Curre

Mesa (master): gallium: Add c99_compat.h to u_bitcast.h

2016-08-09 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: aa920736feeddd1793861651e95bcd09524e024c
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa920736feeddd1793861651e95bcd09524e024c

Author: Mathias Fröhlich 
Date:   Sat Aug  6 07:26:59 2016 +0200

gallium: Add c99_compat.h to u_bitcast.h

We need this for 'inline'.

Signed-off-by: Mathias Fröhlich 
Tested-by: Brian Paul 
Reviewed-by: Brian Paul 

---

 src/gallium/auxiliary/util/u_bitcast.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_bitcast.h 
b/src/gallium/auxiliary/util/u_bitcast.h
index b1f9938..e8fb0fe 100644
--- a/src/gallium/auxiliary/util/u_bitcast.h
+++ b/src/gallium/auxiliary/util/u_bitcast.h
@@ -30,6 +30,8 @@
 
 #include 
 
+#include "c99_compat.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Copy bitmask of VBOs in the VAO on gl{Push, Pop}Attrib.

2016-08-05 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 62d41162bbde86b181afd9e550d49b918fa02831
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=62d41162bbde86b181afd9e550d49b918fa02831

Author: Mathias Fröhlich 
Date:   Mon Aug  1 06:55:35 2016 +0200

mesa: Copy bitmask of VBOs in the VAO on gl{Push,Pop}Attrib.

On gl{Push,Pop}Attrib(GL_CLIENT_VERTEX_ARRAY_BIT) take
care that gl_vertex_array_object::VertexAttribBufferMask
matches the bound buffer object in the
gl_vertex_array_object::VertexBinding array.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Brian Paul 
Reviewed-by: Fredrik Höglund 

---

 src/mesa/main/attrib.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index f859191..ff5f0f1 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1489,6 +1489,8 @@ copy_array_object(struct gl_context *ctx,
 
/* _Enabled must be the same than on push */
dest->_Enabled = src->_Enabled;
+   /* The bitmask of bound VBOs needs to match the VertexBinding array */
+   dest->VertexAttribBufferMask = src->VertexAttribBufferMask;
dest->NewArrays = src->NewArrays;
 }
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Implement _mesa_all_varyings_in_vbos.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: f8be969b1bfafc0e7ec6c066b56e53ec382464d0
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f8be969b1bfafc0e7ec6c066b56e53ec382464d0

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:04 2016 +0200

mesa: Implement _mesa_all_varyings_in_vbos.

Implement the equivalent of vbo_all_varyings_in_vbos for
vertex array objects.

v2: Update comment.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/arrayobj.c | 35 +++
 src/mesa/main/arrayobj.h |  4 
 2 files changed, 39 insertions(+)

diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c
index 9c3451e..becf32f 100644
--- a/src/mesa/main/arrayobj.c
+++ b/src/mesa/main/arrayobj.c
@@ -359,6 +359,41 @@ _mesa_update_vao_client_arrays(struct gl_context *ctx,
 }
 
 
+bool
+_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao)
+{
+   /* Walk those enabled arrays that have the default vbo attached */
+   GLbitfield64 mask = vao->_Enabled & ~vao->VertexAttribBufferMask;
+
+   while (mask) {
+  /* Do not use u_bit_scan64 as we can walk multiple
+   * attrib arrays at once
+   */
+  const int i = ffsll(mask) - 1;
+  const struct gl_vertex_attrib_array *attrib_array =
+ &vao->VertexAttrib[i];
+  const struct gl_vertex_buffer_binding *buffer_binding =
+ &vao->VertexBinding[attrib_array->VertexBinding];
+
+  /* Only enabled arrays shall appear in the _Enabled bitmask */
+  assert(attrib_array->Enabled);
+  /* We have already masked out vao->VertexAttribBufferMask  */
+  assert(!_mesa_is_bufferobj(buffer_binding->BufferObj));
+
+  /* Bail out once we find the first non vbo with a non zero stride */
+  if (buffer_binding->Stride != 0)
+ return false;
+
+  /* Note that we cannot use the xor variant since the _BoundArray mask
+   * may contain array attributes that are bound but not enabled.
+   */
+  mask &= ~buffer_binding->_BoundArrays;
+   }
+
+   return true;
+}
+
+
 /**/
 /* API Functions  */
 /**/
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 6a4247f..d30c85c 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -81,6 +81,10 @@ extern void
 _mesa_update_vao_client_arrays(struct gl_context *ctx,
struct gl_vertex_array_object *vao);
 
+/* Returns true if all varying arrays reside in vbos */
+extern bool
+_mesa_all_varyings_in_vbos(const struct gl_vertex_array_object *vao);
+
 /*
  * API functions
  */

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Walk the VAO in print_draw_arrays.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 99b42184f998803c57beb3eec085bdb7f388ec22
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=99b42184f998803c57beb3eec085bdb7f388ec22

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

vbo: Walk the VAO in print_draw_arrays.

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO. Also make use of gl_vert_attrib_name.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/vbo/vbo_exec_array.c | 40 
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 2d5b0dc..48182ab 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -230,37 +230,37 @@ static void
 print_draw_arrays(struct gl_context *ctx,
   GLenum mode, GLint start, GLsizei count)
 {
-   struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
-   struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   int i;
+   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
 
printf("vbo_exec_DrawArrays(mode 0x%x, start %d, count %d):\n",
  mode, start, count);
 
-   for (i = 0; i < 32; i++) {
-  struct gl_buffer_object *bufObj = exec->array.inputs[i]->BufferObj;
-  GLuint bufName = bufObj->Name;
-  GLint stride = exec->array.inputs[i]->Stride;
-  printf("attr %2d: size %d stride %d  enabled %d  "
+   unsigned i;
+   for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
+  const struct gl_vertex_attrib_array *array = &vao->VertexAttrib[i];
+  if (!array->Enabled)
+ continue;
+
+  const struct gl_vertex_buffer_binding *binding =
+ &vao->VertexBinding[array->VertexBinding];
+  struct gl_buffer_object *bufObj = binding->BufferObj;
+
+  printf("attr %s: size %d stride %d  enabled %d  "
 "ptr %p  Bufobj %u\n",
-i,
-exec->array.inputs[i]->Size,
-stride,
-/*exec->array.inputs[i]->Enabled,*/
-vao->_VertexAttrib[VERT_ATTRIB_FF(i)].Enabled,
-exec->array.inputs[i]->Ptr,
-bufName);
-
-  if (bufName) {
+ gl_vert_attrib_name((gl_vert_attrib)i),
+array->Size, binding->Stride, array->Enabled,
+ array->Ptr, bufObj->Name);
+
+  if (_mesa_is_bufferobj(bufObj)) {
  GLubyte *p = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size,
 GL_MAP_READ_BIT, bufObj,
  MAP_INTERNAL);
- int offset = (int) (GLintptr) exec->array.inputs[i]->Ptr;
+ int offset = (int) (GLintptr)
+_mesa_vertex_attrib_address(array, binding);
  float *f = (float *) (p + offset);
  int *k = (int *) f;
  int i;
- int n = (count * stride) / 4;
+ int n = (count * binding->Stride) / 4;
  if (n > 32)
 n = 32;
  printf("  Data at offset %d:\n", offset);

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Walk the VAO to see if all varyings are in vbos.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 3f5e5696feb10ec9c779c30a84ce9b367db081fd
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=3f5e5696feb10ec9c779c30a84ce9b367db081fd

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

vbo: Walk the VAO to see if all varyings are in vbos.

In vbo_draw_transform_feedback we currently look at
exec->array.inputs to determine if all varying
vertex attributes reside in vbos. But the vbo_bind_arrays
call only happens past the vbo_all_varyings_in_vbos
query. Thus we may work on a stale set of client arrays.
Using the current VAOs content for this query feels much
more logical to me.
Additionally with this change mesa makes more use of the
information already tracked in the VAO instead of looping
across VERT_ATTRIB_MAX vertex arrays.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/vbo/vbo_exec_array.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 87ed7f7..b75c772 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -27,6 +27,7 @@
  **/
 
 #include 
+#include "main/arrayobj.h"
 #include "main/glheader.h"
 #include "main/context.h"
 #include "main/state.h"
@@ -1290,7 +1291,6 @@ vbo_draw_transform_feedback(struct gl_context *ctx, 
GLenum mode,
 GLuint stream, GLuint numInstances)
 {
struct vbo_context *vbo = vbo_context(ctx);
-   struct vbo_exec_context *exec = &vbo->exec;
struct _mesa_prim prim[2];
 
if (!_mesa_validate_DrawTransformFeedback(ctx, mode, obj, stream,
@@ -1300,7 +1300,7 @@ vbo_draw_transform_feedback(struct gl_context *ctx, 
GLenum mode,
 
if (ctx->Driver.GetTransformFeedbackVertexCount &&
(ctx->Const.AlwaysUseGetTransformFeedbackVertexCount ||
-!vbo_all_varyings_in_vbos(exec->array.inputs))) {
+!_mesa_all_varyings_in_vbos(ctx->Array.VAO))) {
   GLsizei n = ctx->Driver.GetTransformFeedbackVertexCount(ctx, obj, 
stream);
   vbo_draw_arrays(ctx, mode, 0, n, numInstances, 0);
   return;

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Remove set but not used gl_client_array::Stride.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: b730960e779c842d27192f812b33686f025431ff
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=b730960e779c842d27192f812b33686f025431ff

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

mesa: Remove set but not used gl_client_array::Stride.

The field is only read for printing today and
there it was probably a leftover.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/mtypes.h   | 1 -
 src/mesa/main/varray.c   | 1 -
 src/mesa/main/varray.h   | 1 -
 src/mesa/state_tracker/st_cb_rasterpos.c | 1 -
 src/mesa/vbo/vbo_context.c   | 1 -
 src/mesa/vbo/vbo_exec_draw.c | 1 -
 src/mesa/vbo/vbo_save_draw.c | 1 -
 src/mesa/vbo/vbo_split_copy.c| 3 +--
 8 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 03c68cf..2647f8f 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1323,7 +1323,6 @@ struct gl_client_array
GLint Size;  /**< components per element (1,2,3,4) */
GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
GLenum Format;   /**< default: GL_RGBA, but may be GL_BGRA */
-   GLsizei Stride; /**< user-specified stride */
GLsizei StrideB;/**< actual stride in bytes */
GLuint _ElementSize; /**< size of each element in bytes */
const GLubyte *Ptr;  /**< Points to array data */
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 1137584..027ae7c 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2315,7 +2315,6 @@ _mesa_copy_client_array(struct gl_context *ctx,
dst->Size = src->Size;
dst->Type = src->Type;
dst->Format = src->Format;
-   dst->Stride = src->Stride;
dst->StrideB = src->StrideB;
dst->Ptr = src->Ptr;
dst->Normalized = src->Normalized;
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 3c5d01e..54229ff 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -62,7 +62,6 @@ _mesa_update_client_array(struct gl_context *ctx,
dst->Size = src->Size;
dst->Type = src->Type;
dst->Format = src->Format;
-   dst->Stride = src->Stride;
dst->StrideB = binding->Stride;
dst->Ptr = _mesa_vertex_attrib_address(src, binding);
dst->Normalized = src->Normalized;
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c 
b/src/mesa/state_tracker/st_cb_rasterpos.c
index fc7c07d..29c1484 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -196,7 +196,6 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct 
draw_context *draw)
   rs->array[i].Size = 4;
   rs->array[i].Type = GL_FLOAT;
   rs->array[i].Format = GL_RGBA;
-  rs->array[i].Stride = 0;
   rs->array[i].StrideB = 0;
   rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
   rs->array[i].Normalized = GL_TRUE;
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index 9bceaf4..7a5bd51 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -55,7 +55,6 @@ init_array(struct gl_context *ctx, struct gl_client_array *cl,
cl->Size = size;
cl->Type = GL_FLOAT;
cl->Format = GL_RGBA;
-   cl->Stride = 0;
cl->StrideB = 0;
cl->_ElementSize = cl->Size * sizeof(GLfloat);
cl->Ptr = pointer;
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 2f5333f..0ae879b 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -250,7 +250,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
  }
 arrays[attr].Size = exec->vtx.attrsz[src];
 arrays[attr].StrideB = exec->vtx.vertex_size * sizeof(GLfloat);
-arrays[attr].Stride = exec->vtx.vertex_size * sizeof(GLfloat);
 arrays[attr].Type = exec->vtx.attrtype[src];
 arrays[attr].Integer =
vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]);
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 3424b78..507ab82 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -196,7 +196,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
 arrays[attr].Ptr = (const GLubyte *) NULL + buffer_offset;
 arrays[attr].Size = node_attrsz[src];
 arrays[attr].StrideB = node->vertex_size * sizeof(GLfloat);
-arrays[attr].Stride = node->vertex_size * sizeof(GLfloat);
  arrays[attr].Type = node_attrtype[src];
  arrays[attr].Integer =
vbo_attrtype_to_integer_flag(node_attrtype[src]);
diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo/vbo_split_copy.c
index 084110c.

Mesa (master): mesa: Remove set but not used gl_client_array::Enabled.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 56c65cd31538bd78b3ad9e516ddcb73438c535c9
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=56c65cd31538bd78b3ad9e516ddcb73438c535c9

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

mesa: Remove set but not used gl_client_array::Enabled.

The way it is used today does not care about the
Enabled flag anymore.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/mtypes.h   | 1 -
 src/mesa/main/varray.c   | 1 -
 src/mesa/main/varray.h   | 1 -
 src/mesa/state_tracker/st_cb_rasterpos.c | 1 -
 src/mesa/vbo/vbo_context.c   | 1 -
 src/mesa/vbo/vbo_exec_draw.c | 1 -
 src/mesa/vbo/vbo_save_draw.c | 1 -
 src/mesa/vbo/vbo_split_copy.c| 5 ++---
 8 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index ad046e2..03c68cf 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1327,7 +1327,6 @@ struct gl_client_array
GLsizei StrideB;/**< actual stride in bytes */
GLuint _ElementSize; /**< size of each element in bytes */
const GLubyte *Ptr;  /**< Points to array data */
-   GLboolean Enabled;  /**< Enabled flag is a boolean */
GLboolean Normalized;/**< GL_ARB_vertex_program */
GLboolean Integer;   /**< Integer-valued? */
GLboolean Doubles;   /**< double precision values are not converted to 
floats */
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index 36aa33c..1137584 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2318,7 +2318,6 @@ _mesa_copy_client_array(struct gl_context *ctx,
dst->Stride = src->Stride;
dst->StrideB = src->StrideB;
dst->Ptr = src->Ptr;
-   dst->Enabled = src->Enabled;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
dst->Doubles = src->Doubles;
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index a766afa..3c5d01e 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -65,7 +65,6 @@ _mesa_update_client_array(struct gl_context *ctx,
dst->Stride = src->Stride;
dst->StrideB = binding->Stride;
dst->Ptr = _mesa_vertex_attrib_address(src, binding);
-   dst->Enabled = src->Enabled;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
dst->Doubles = src->Doubles;
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c 
b/src/mesa/state_tracker/st_cb_rasterpos.c
index eec72f8..fc7c07d 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -199,7 +199,6 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct 
draw_context *draw)
   rs->array[i].Stride = 0;
   rs->array[i].StrideB = 0;
   rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
-  rs->array[i].Enabled = GL_TRUE;
   rs->array[i].Normalized = GL_TRUE;
   rs->array[i].BufferObj = NULL;
   rs->arrays[i] = &rs->array[i];
diff --git a/src/mesa/vbo/vbo_context.c b/src/mesa/vbo/vbo_context.c
index ae5d265..9bceaf4 100644
--- a/src/mesa/vbo/vbo_context.c
+++ b/src/mesa/vbo/vbo_context.c
@@ -59,7 +59,6 @@ init_array(struct gl_context *ctx, struct gl_client_array *cl,
cl->StrideB = 0;
cl->_ElementSize = cl->Size * sizeof(GLfloat);
cl->Ptr = pointer;
-   cl->Enabled = 1;
 
_mesa_reference_buffer_object(ctx, &cl->BufferObj,
  ctx->Shared->NullBufferObj);
diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c
index 6061ca0..2f5333f 100644
--- a/src/mesa/vbo/vbo_exec_draw.c
+++ b/src/mesa/vbo/vbo_exec_draw.c
@@ -255,7 +255,6 @@ vbo_exec_bind_arrays( struct gl_context *ctx )
 arrays[attr].Integer =
vbo_attrtype_to_integer_flag(exec->vtx.attrtype[src]);
  arrays[attr].Format = GL_RGBA;
-arrays[attr].Enabled = 1;
  arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat);
  _mesa_reference_buffer_object(ctx,
&arrays[attr].BufferObj,
diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c
index 7881ce1..3424b78 100644
--- a/src/mesa/vbo/vbo_save_draw.c
+++ b/src/mesa/vbo/vbo_save_draw.c
@@ -201,7 +201,6 @@ static void vbo_bind_vertex_list(struct gl_context *ctx,
  arrays[attr].Integer =
vbo_attrtype_to_integer_flag(node_attrtype[src]);
  arrays[attr].Format = GL_RGBA;
-arrays[attr].Enabled = 1;
  arrays[attr]._ElementSize = arrays[attr].Size * sizeof(GLfloat);
  _mesa_reference_buffer_object(ctx,
&arrays[attr].BufferObj,
diff --git a/src/mesa/vbo/vbo_split_copy.c b/src/mesa/vbo

Mesa (master): vbo: Walk the VAO in check_array_data.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 4cda6900193ddfbc80e3cb845c732851a870df6f
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4cda6900193ddfbc80e3cb845c732851a870df6f

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

vbo: Walk the VAO in check_array_data.

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/vbo/vbo_exec_array.c | 49 +--
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 48182ab..8de3e0c 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -98,26 +98,30 @@ check_buffers_are_unmapped(struct gl_context *ctx)
  * For debugging purposes; not normally used.
  */
 static void
-check_array_data(struct gl_context *ctx, struct gl_client_array *array,
+check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao,
  GLuint attrib, GLuint j)
 {
+   const struct gl_vertex_attrib_array *array = &vao->VertexAttrib[attrib];
if (array->Enabled) {
+  const struct gl_vertex_buffer_binding *binding =
+ &vao->VertexBinding[array->VertexBinding];
+  struct gl_buffer_object *bo = binding->BufferObj;
   const void *data = array->Ptr;
-  if (_mesa_is_bufferobj(array->BufferObj)) {
- if (!array->BufferObj->Mappings[MAP_INTERNAL].Pointer) {
+  if (_mesa_is_bufferobj(bo)) {
+ if (!bo->Mappings[MAP_INTERNAL].Pointer) {
 /* need to map now */
-array->BufferObj->Mappings[MAP_INTERNAL].Pointer =
-   ctx->Driver.MapBufferRange(ctx, 0, array->BufferObj->Size,
- GL_MAP_READ_BIT, array->BufferObj,
+bo->Mappings[MAP_INTERNAL].Pointer =
+   ctx->Driver.MapBufferRange(ctx, 0, bo->Size,
+ GL_MAP_READ_BIT, bo,
   MAP_INTERNAL);
  }
- data = ADD_POINTERS(data,
- array->BufferObj->Mappings[MAP_INTERNAL].Pointer);
+ data = ADD_POINTERS(_mesa_vertex_attrib_address(array, binding),
+ bo->Mappings[MAP_INTERNAL].Pointer);
   }
   switch (array->Type) {
   case GL_FLOAT:
  {
-GLfloat *f = (GLfloat *) ((GLubyte *) data + array->StrideB * j);
+GLfloat *f = (GLfloat *) ((GLubyte *) data + binding->Stride * j);
 GLint k;
 for (k = 0; k < array->Size; k++) {
if (IS_INF_OR_NAN(f[k]) ||
@@ -126,9 +130,9 @@ check_array_data(struct gl_context *ctx, struct 
gl_client_array *array,
   printf("  Element[%u].%u = %f\n", j, k, f[k]);
   printf("  Array %u at %p\n", attrib, (void* ) array);
   printf("  Type 0x%x, Size %d, Stride %d\n",
-array->Type, array->Size, array->Stride);
+array->Type, array->Size, binding->Stride);
   printf("  Address/offset %p in Buffer Object %u\n",
-array->Ptr, array->BufferObj->Name);
+array->Ptr, bo->Name);
   f[k] = 1.0F; /* XXX replace the bad value! */
}
/*assert(!IS_INF_OR_NAN(f[k]));*/
@@ -146,12 +150,17 @@ check_array_data(struct gl_context *ctx, struct 
gl_client_array *array,
  * Unmap the buffer object referenced by given array, if mapped.
  */
 static void
-unmap_array_buffer(struct gl_context *ctx, struct gl_client_array *array)
+unmap_array_buffer(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+   GLuint attrib)
 {
-   if (array->Enabled &&
-   _mesa_is_bufferobj(array->BufferObj) &&
-   _mesa_bufferobj_mapped(array->BufferObj, MAP_INTERNAL)) {
-  ctx->Driver.UnmapBuffer(ctx, array->BufferObj, MAP_INTERNAL);
+   const struct gl_vertex_attrib_array *array = &vao->VertexAttrib[attrib];
+   if (array->Enabled) {
+  const struct gl_vertex_buffer_binding *binding =
+ &vao->VertexBinding[array->VertexBinding];
+  struct gl_buffer_object *bo = binding->BufferObj;
+  if (_mesa_is_bufferobj(bo) && _mesa_bufferobj_mapped(bo, MAP_INTERNAL)) {
+ ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
+  }
}
 }
 
@@ -197,8 +206,8 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei 
count, GLenum elemType,
   }
 
   /* check element j of each enabled array */
-  for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) {
- check_array_data(ctx, &v

Mesa (master): vbo: Use the VAO array enabled flags in vbo_exec_array.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 43a6f435caf011cc6fd193671ad8eec37dbcb016
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=43a6f435caf011cc6fd193671ad8eec37dbcb016

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

vbo: Use the VAO array enabled flags in vbo_exec_array.

Instead of gl_client_array::Enabled inside a VAO,
directly use the gl_vertex_attrib_array::Enabled value
which is the origin of the above.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/vbo/vbo_exec_array.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 8de3e0c..f371890 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -295,6 +295,7 @@ recalculate_input_bindings(struct gl_context *ctx)
 {
struct vbo_context *vbo = vbo_context(ctx);
struct vbo_exec_context *exec = &vbo->exec;
+   const struct gl_vertex_attrib_array *array = ctx->Array.VAO->VertexAttrib;
struct gl_client_array *vertexAttrib = ctx->Array.VAO->_VertexAttrib;
const struct gl_client_array **inputs = &exec->array.inputs[0];
GLbitfield64 const_inputs = 0x0;
@@ -308,7 +309,7 @@ recalculate_input_bindings(struct gl_context *ctx)
* are available as per-vertex attributes.
*/
   for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
+if (array[VERT_ATTRIB_FF(i)].Enabled)
inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
 else {
inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
@@ -348,9 +349,9 @@ recalculate_input_bindings(struct gl_context *ctx)
* slots are considered "magic."
*/
   if (ctx->API == API_OPENGL_COMPAT) {
- if (vertexAttrib[VERT_ATTRIB_GENERIC0].Enabled)
+ if (array[VERT_ATTRIB_GENERIC0].Enabled)
 inputs[0] = &vertexAttrib[VERT_ATTRIB_GENERIC0];
- else if (vertexAttrib[VERT_ATTRIB_POS].Enabled)
+ else if (array[VERT_ATTRIB_POS].Enabled)
 inputs[0] = &vertexAttrib[VERT_ATTRIB_POS];
  else {
 inputs[0] = &vbo->currval[VBO_ATTRIB_POS];
@@ -358,7 +359,7 @@ recalculate_input_bindings(struct gl_context *ctx)
  }
 
  for (i = 1; i < VERT_ATTRIB_FF_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_FF(i)].Enabled)
+if (array[VERT_ATTRIB_FF(i)].Enabled)
inputs[i] = &vertexAttrib[VERT_ATTRIB_FF(i)];
 else {
inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
@@ -367,7 +368,7 @@ recalculate_input_bindings(struct gl_context *ctx)
  }
 
  for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
+if (array[VERT_ATTRIB_GENERIC(i)].Enabled)
inputs[VERT_ATTRIB_GENERIC(i)] =
   &vertexAttrib[VERT_ATTRIB_GENERIC(i)];
 else {
@@ -385,14 +386,14 @@ recalculate_input_bindings(struct gl_context *ctx)
   * be enabled.
   */
  for (i = 0; i < VERT_ATTRIB_FF_MAX; i++) {
-assert(!vertexAttrib[VERT_ATTRIB_FF(i)].Enabled);
+assert(!array[VERT_ATTRIB_FF(i)].Enabled);
 
 inputs[i] = &vbo->currval[VBO_ATTRIB_POS+i];
 const_inputs |= VERT_BIT_FF(i);
  }
 
  for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++) {
-if (vertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
+if (array[VERT_ATTRIB_GENERIC(i)].Enabled)
inputs[VERT_ATTRIB_GENERIC(i)] =
   &vertexAttrib[VERT_ATTRIB_GENERIC(i)];
 else {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Unbind deleted vbo using _mesa_bind_vertex_buffer.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: f7cb46a9721ace5ec6d1e51cdc4ce70348605701
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=f7cb46a9721ace5ec6d1e51cdc4ce70348605701

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:04 2016 +0200

mesa: Unbind deleted vbo using _mesa_bind_vertex_buffer.

When a vertex buffer object gets deleted, it is unbound
at the VAO. To do this use _mesa_bind_vertex_buffer instead
of plain unreferencing the buffer object. This keeps the VAOs
internal state consistent. In this case it showed up with
gl_vertex_array_object::VertexAttribBufferMask getting out of
sync.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/bufferobj.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 795cb16..885a99d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -44,6 +44,7 @@
 #include "glformats.h"
 #include "texstore.h"
 #include "transformfeedback.h"
+#include "varray.h"
 
 
 /* Debug flags */
@@ -1199,11 +1200,13 @@ _mesa_multi_bind_lookup_bufferobj(struct gl_context 
*ctx,
  */
 static void
 unbind(struct gl_context *ctx,
-   struct gl_buffer_object **ptr,
+   struct gl_vertex_array_object *vao, unsigned index,
struct gl_buffer_object *obj)
 {
-   if (*ptr == obj) {
-  _mesa_reference_buffer_object(ctx, ptr, ctx->Shared->NullBufferObj);
+   if (vao->VertexBinding[index].BufferObj == obj) {
+  _mesa_bind_vertex_buffer(ctx, vao, index, ctx->Shared->NullBufferObj,
+   vao->VertexBinding[index].Offset,
+   vao->VertexBinding[index].Stride);
}
 }
 
@@ -1302,7 +1305,7 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
 
  /* unbind any vertex pointers bound to this buffer */
  for (j = 0; j < ARRAY_SIZE(vao->VertexBinding); j++) {
-unbind(ctx, &vao->VertexBinding[j].BufferObj, bufObj);
+unbind(ctx, vao, j, bufObj);
  }
 
  if (ctx->Array.ArrayBufferObj == bufObj) {

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): mesa: Walk the VAO in _mesa_print_arrays.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: eec516d8e16eecbe290a6a3cc7afa628760cefb3
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=eec516d8e16eecbe290a6a3cc7afa628760cefb3

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

mesa: Walk the VAO in _mesa_print_arrays.

Only a debugging function, but move away from
gl_client_array and use the first order information
from the VAO. Also make use of gl_vert_attrib_name.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/main/varray.c | 52 +++---
 1 file changed, 20 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index c2bf295..36aa33c 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -2360,44 +2360,32 @@ _mesa_copy_vertex_buffer_binding(struct gl_context *ctx,
 }
 
 /**
- * Print vertex array's fields.
- */
-static void
-print_array(const char *name, GLint index, const struct gl_client_array *array)
-{
-   if (index >= 0)
-  fprintf(stderr, "  %s[%d]: ", name, index);
-   else
-  fprintf(stderr, "  %s: ", name);
-   fprintf(stderr, "Ptr=%p, Type=%s, Size=%d, ElemSize=%u, Stride=%d, 
Buffer=%u(Size %lu)\n",
-   array->Ptr, _mesa_enum_to_string(array->Type), array->Size,
-   array->_ElementSize, array->StrideB, array->BufferObj->Name,
-   (unsigned long) array->BufferObj->Size);
-}
-
-
-/**
  * Print current vertex object/array info.  For debug.
  */
 void
 _mesa_print_arrays(struct gl_context *ctx)
 {
-   struct gl_vertex_array_object *vao = ctx->Array.VAO;
-   GLuint i;
+   const struct gl_vertex_array_object *vao = ctx->Array.VAO;
 
-   printf("Array Object %u\n", vao->Name);
-   if (vao->_VertexAttrib[VERT_ATTRIB_POS].Enabled)
-  print_array("Vertex", -1, &vao->_VertexAttrib[VERT_ATTRIB_POS]);
-   if (vao->_VertexAttrib[VERT_ATTRIB_NORMAL].Enabled)
-  print_array("Normal", -1, &vao->_VertexAttrib[VERT_ATTRIB_NORMAL]);
-   if (vao->_VertexAttrib[VERT_ATTRIB_COLOR0].Enabled)
-  print_array("Color", -1, &vao->_VertexAttrib[VERT_ATTRIB_COLOR0]);
-   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
-  if (vao->_VertexAttrib[VERT_ATTRIB_TEX(i)].Enabled)
- print_array("TexCoord", i, &vao->_VertexAttrib[VERT_ATTRIB_TEX(i)]);
-   for (i = 0; i < VERT_ATTRIB_GENERIC_MAX; i++)
-  if (vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)].Enabled)
- print_array("Attrib", i, &vao->_VertexAttrib[VERT_ATTRIB_GENERIC(i)]);
+   fprintf(stderr, "Array Object %u\n", vao->Name);
+
+   unsigned i;
+   for (i = 0; i < VERT_ATTRIB_MAX; ++i) {
+  const struct gl_vertex_attrib_array *array = &vao->VertexAttrib[i];
+  if (!array->Enabled)
+ continue;
+
+  const struct gl_vertex_buffer_binding *binding =
+ &vao->VertexBinding[array->VertexBinding];
+  const struct gl_buffer_object *bo = binding->BufferObj;
+
+  fprintf(stderr, "  %s: Ptr=%p, Type=%s, Size=%d, ElemSize=%u, "
+  "Stride=%d, Buffer=%u(Size %lu)\n",
+  gl_vert_attrib_name((gl_vert_attrib)i),
+  array->Ptr, _mesa_enum_to_string(array->Type), array->Size,
+  array->_ElementSize, binding->Stride, bo->Name,
+  (unsigned long) bo->Size);
+   }
 }
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


Mesa (master): vbo: Walk the VAO to check for mapped buffers.

2016-07-31 Thread Mathias Fröhlich
Module: Mesa
Branch: master
Commit: 144737a4988ebca0649c0d1d9ddba4a391757b86
URL:
http://cgit.freedesktop.org/mesa/mesa/commit/?id=144737a4988ebca0649c0d1d9ddba4a391757b86

Author: Mathias Fröhlich 
Date:   Fri Jun 17 08:09:05 2016 +0200

vbo: Walk the VAO to check for mapped buffers.

Similarily to _mesa_all_varyings_in_vbos walk the VAO
to check if we have an illegal mapped buffer object
instead of walking all gl_client_arrays.

Signed-off-by: Mathias Fröhlich 
Reviewed-by: Eric Anholt 

---

 src/mesa/vbo/vbo_exec_array.c | 33 +++--
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index b75c772..2d5b0dc 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -47,16 +47,29 @@
  * to draw.
  */
 static bool
-check_input_buffers_are_unmapped(const struct gl_client_array **inputs)
+check_input_buffers_are_unmapped(const struct gl_vertex_array_object *vao)
 {
-   GLuint i;
-
-   for (i = 0; i < VERT_ATTRIB_MAX; i++) {
-  if (inputs[i]) {
- struct gl_buffer_object *obj = inputs[i]->BufferObj;
- if (_mesa_check_disallowed_mapping(obj))
-return false;
-  }
+   /* Walk the enabled arrays that have a vbo attached */
+   GLbitfield64 mask = vao->_Enabled & vao->VertexAttribBufferMask;
+
+   while (mask) {
+  int i = ffsll(mask) - 1;
+  const struct gl_vertex_attrib_array *attrib_array =
+ &vao->VertexAttrib[i];
+  const struct gl_vertex_buffer_binding *buffer_binding =
+ &vao->VertexBinding[attrib_array->VertexBinding];
+
+  /* Only enabled arrays shall appear in the _Enabled bitmask */
+  assert(attrib_array->Enabled);
+  /* We have already masked with vao->VertexAttribBufferMask  */
+  assert(_mesa_is_bufferobj(buffer_binding->BufferObj));
+
+  /* Bail out once we find the first disallowed mapping */
+  if (_mesa_check_disallowed_mapping(buffer_binding->BufferObj))
+ return false;
+
+  /* We have handled everything that is bound to this buffer_binding. */
+  mask &= ~buffer_binding->_BoundArrays;
}
 
return true;
@@ -75,7 +88,7 @@ check_buffers_are_unmapped(struct gl_context *ctx)
 
/* check the current vertex arrays */
return !_mesa_check_disallowed_mapping(exec->vtx.bufferobj) &&
-  check_input_buffers_are_unmapped(exec->array.inputs);
+  check_input_buffers_are_unmapped(ctx->Array.VAO);
 }
 
 

___
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit


  1   2   >