Re: [Mesa-dev] [PATCH 04/13] mesa: Introduce a yet unused _DrawVAO.

2018-02-22 Thread Mathias Fröhlich
Hi Brian,

On Thursday, 22 February 2018 23:32:23 CET Brian Paul wrote:
> Just a few little nit-picks.  With those fixed, the series is: 
> Reviewed-by: Brian Paul 
> 
> Nice work!

Thanks!

Thank you for the review!
And is pushed now!

best

Mathias


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


Re: [Mesa-dev] [PATCH 04/13] mesa: Introduce a yet unused _DrawVAO.

2018-02-22 Thread Brian Paul
Just a few little nit-picks.  With those fixed, the series is: 
Reviewed-by: Brian Paul 


Nice work!

On 02/21/2018 10:45 PM, mathias.froehl...@gmx.net wrote:

From: Mathias Fröhlich 

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.

Signed-off-by: Mathias Fröhlich 
---
  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| 21 +
  src/mesa/main/state.h| 13 +
  src/mesa/main/varray.c   |  2 ++
  7 files changed, 66 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, >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, >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, >Array.VAO, NULL);

 _mesa_reference_vao(ctx, >Array.DefaultVAO, NULL);
+   _mesa_reference_vao(ctx, >Array._EmptyVAO, NULL);
+   _mesa_reference_vao(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
@@ -1691,6 +1691,28 @@ struct gl_array_attrib
 /* GL_ARB_vertex_buffer_object */
 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..5b1b3322e2 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -479,3 +479,24 @@ _mesa_update_vertex_processing_mode(struct gl_context *ctx)
 else
ctx->VertexProgram._VPMode = VP_MODE_FF;
  }
+
+
+void
+_mesa_set_draw_vao(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+   GLbitfield filter)
+{
+   struct gl_vertex_array_object **ptr = >Array._DrawVAO;
+   if (*ptr != 

Re: [Mesa-dev] [PATCH 04/13] mesa: Introduce a yet unused _DrawVAO.

2018-02-15 Thread Brian Paul

On 02/15/2018 12:55 PM, mathias.froehl...@gmx.net wrote:

From: Mathias Fröhlich 

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.

Signed-off-by: Mathias Fröhlich 
---
  src/mesa/main/arrayobj.c |  4 
  src/mesa/main/attrib.c   |  2 ++
  src/mesa/main/context.c  |  2 ++
  src/mesa/main/mtypes.h   |  7 +++
  src/mesa/main/state.c| 21 +
  src/mesa/main/state.h|  8 
  src/mesa/main/varray.c   |  2 ++
  7 files changed, 46 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, >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, >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, >Array.VAO, NULL);

 _mesa_reference_vao(ctx, >Array.DefaultVAO, NULL);
+   _mesa_reference_vao(ctx, >Array._EmptyVAO, NULL);
+   _mesa_reference_vao(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..b6fdb69283 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1691,6 +1691,13 @@ struct gl_array_attrib
 /* GL_ARB_vertex_buffer_object */
 struct gl_buffer_object *ArrayBufferObj;
  
+   /** Vertex array object used when no specific DrawVAO is bound */

+   struct gl_vertex_array_object *_EmptyVAO;


I'm not sure I understand the purpose of that.  By "used" do you mean 
when drawing?




+   /** Vertex array object used for the current draw */
+   struct gl_vertex_array_object *_DrawVAO;
+   /** The possibly reduced set of enabled vertex attributes from the above */
+   GLbitfield _DrawVAOEnabled;


_DrawVAOEnabledAttribs?



+
 /**
  * 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..42bf483682 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -479,3 +479,24 @@ _mesa_update_vertex_processing_mode(struct gl_context *ctx)
 else
ctx->VertexProgram._VPMode = VP_MODE_FF;
  }
+
+
+void
+_mesa_set_draw_vao(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+   GLbitfield filter)


Can you put a comment on this function to explain it, and specifically, 
the filter parameter?




+{
+   struct gl_vertex_array_object **ptr = >Array._DrawVAO;
+   if (*ptr != vao) {
+  _mesa_reference_vao_(ctx, ptr, vao);
+  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+   } else if (vao->NewArrays) {
+  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+   }
+
+   /* May shuffle the position and generic0 bits around, filter out unwanted */
+   const GLbitfield enabled = filter & _mesa_get_vao_vp_inputs(vao);
+   if (ctx->Array._DrawVAOEnabled != enabled)
+  ctx->NewDriverState |= ctx->DriverFlags.NewArray;
+   ctx->Array._DrawVAOEnabled = enabled;
+   _mesa_set_varying_vp_inputs(ctx, enabled);
+}
diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h
index 049166578c..589c6650ad 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -53,6 +53,14 @@