[Mesa-dev] [PATCH 1/6] main: Added entry point for glCreateTransformFeedbacks

2015-02-09 Thread Martin Peres
v2: Review from Laura Ekstrand
- generate the name of the gl method once
- shorten some lines to stay in the 78 chars limit

v3: Review from Fredrik Höglund 
- rename gl_mthd_name to func
- set EverBound in _mesa_create_transform_feedbacks in the dsa case

v4:
- rename _mesa_create_transform_feedbacks to create_transform_feedbacks and
  make it static

Signed-off-by: Martin Peres 
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 src/mesa/main/transformfeedback.c  | 67 --
 src/mesa/main/transformfeedback.h  |  3 ++
 4 files changed, 63 insertions(+), 15 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 2fe1638..15b00c2 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -7,6 +7,13 @@


 
+   
+
+  
+  
+  
+   
+

 

diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index 1f1a3a8..bf320bf 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
{ "glClipControl", 45, -1 },
 
/* GL_ARB_direct_state_access */
+   { "glCreateTransformFeedbacks", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
{ "glTextureStorage2D", 45, -1 },
diff --git a/src/mesa/main/transformfeedback.c 
b/src/mesa/main/transformfeedback.c
index a737463..10bb6a1 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -825,25 +825,24 @@ _mesa_lookup_transform_feedback_object(struct gl_context 
*ctx, GLuint name)
  _mesa_HashLookup(ctx->TransformFeedback.Objects, name);
 }
 
-
-/**
- * Create new transform feedback objects.   Transform feedback objects
- * encapsulate the state related to transform feedback to allow quickly
- * switching state (and drawing the results, below).
- * Part of GL_ARB_transform_feedback2.
- */
-void GLAPIENTRY
-_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+static void
+create_transform_feedbacks(struct gl_context *ctx, GLsizei n, GLuint *ids,
+   bool dsa)
 {
GLuint first;
-   GET_CURRENT_CONTEXT(ctx);
+   const char* func;
+
+   if (dsa)
+  func = "glCreateTransformFeedbacks";
+   else
+  func = "glGenTransformFeedbacks";
 
if (n < 0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)");
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
   return;
}
 
-   if (!names)
+   if (!ids)
   return;
 
/* we don't need contiguous IDs, but this might be faster */
@@ -854,18 +853,56 @@ _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
  struct gl_transform_feedback_object *obj
 = ctx->Driver.NewTransformFeedback(ctx, first + i);
  if (!obj) {
-_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
 return;
  }
- names[i] = first + i;
+ ids[i] = first + i;
  _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj);
+ if (dsa) {
+/* this is normally done at bind time in the non-dsa case */
+obj->EverBound = GL_TRUE;
+ }
   }
}
else {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
}
 }
 
+/**
+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_transform_feedback2.
+ */
+void GLAPIENTRY
+_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* GenTransformFeedbacks should just reserve the object names that a
+* subsequent call to BindTransformFeedback should actively create. For
+* the sake of simplicity, we reserve the names and create the objects
+* straight away.
+*/
+
+   create_transform_feedbacks(ctx, n, names, false);
+}
+
+/**
+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_direct_state_access.
+ */
+void GLAPIENTRY
+_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   create_transform_feedbacks(ctx, n, names, true);
+}
+
 
 /**
  * Is the given ID a transform feedback object?
diff --git a/src/mesa/main/transformfeedback.h 
b/src/mesa/main/transformfeedback.h
index 87f4080..9de1fef 100644
--- a/src/mesa/main/transformfeedback.h
+++ b/src/mesa/main/transformfeedback.h
@@ -102,6

Re: [Mesa-dev] [PATCH 1/6] main: Added entry point for glCreateTransformFeedbacks

2015-02-03 Thread Martin Peres

On 02/02/15 23:36, Laura Ekstrand wrote:
On Mon, Feb 2, 2015 at 2:58 AM, Martin Peres 
mailto:martin.pe...@linux.intel.com>> 
wrote:


  if (!obj) {
-_mesa_error(ctx, GL_OUT_OF_MEMORY,
"glGenTransformFeedbacks");
+_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);

^^
This doesn't line up with ( above.  Mesa uses 3-space identation.
Seems like a visualisation problem as the indentation was good before 
the patch and is still good after it...


 return;
  }
- names[i] = first + i;
+ ids[i] = first + i;

Same thing


Same thing


_mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj);
+ if (dsa) {
+/* this is normally done at bind time in the non-dsa
case */
+obj->EverBound = GL_TRUE;
+ }
   }
}
else {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);

Same thing.


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


Re: [Mesa-dev] [PATCH 1/6] main: Added entry point for glCreateTransformFeedbacks

2015-02-02 Thread Laura Ekstrand
On Mon, Feb 2, 2015 at 2:58 AM, Martin Peres 
wrote:

> v2: Review from Laura Ekstrand
> - generate the name of the gl method once
> - shorten some lines to stay in the 78 chars limit
>
> v3: Review from Fredrik Höglund 
> - rename gl_mthd_name to func
> - set EverBound in _mesa_create_transform_feedbacks in the dsa case
>
> Signed-off-by: Martin Peres 
> ---
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
>  src/mesa/main/tests/dispatch_sanity.cpp|  1 +
>  src/mesa/main/transformfeedback.c  | 67
> --
>  src/mesa/main/transformfeedback.h  |  6 +++
>  4 files changed, 66 insertions(+), 15 deletions(-)
>
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index 2fe1638..15b00c2 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -7,6 +7,13 @@
> 
> 
>
> +   
> +
> +  
> +  
> +  
> +   
> +
> 
>
> 
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp
> b/src/mesa/main/tests/dispatch_sanity.cpp
> index ee4db45..5e7f7ae 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
> { "glClipControl", 45, -1 },
>
> /* GL_ARB_direct_state_access */
> +   { "glCreateTransformFeedbacks", 45, -1 },
> { "glCreateTextures", 45, -1 },
> { "glTextureStorage1D", 45, -1 },
> { "glTextureStorage2D", 45, -1 },
> diff --git a/src/mesa/main/transformfeedback.c
> b/src/mesa/main/transformfeedback.c
> index a737463..466d401 100644
> --- a/src/mesa/main/transformfeedback.c
> +++ b/src/mesa/main/transformfeedback.c
> @@ -825,25 +825,24 @@ _mesa_lookup_transform_feedback_object(struct
> gl_context *ctx, GLuint name)
>   _mesa_HashLookup(ctx->TransformFeedback.Objects, name);
>  }
>
> -
> -/**
> - * Create new transform feedback objects.   Transform feedback objects
> - * encapsulate the state related to transform feedback to allow quickly
> - * switching state (and drawing the results, below).
> - * Part of GL_ARB_transform_feedback2.
> - */
> -void GLAPIENTRY
> -_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
> +void
> +_mesa_create_transform_feedbacks(struct gl_context *ctx, GLsizei n,
> + GLuint *ids, bool dsa)
>  {
> GLuint first;
> -   GET_CURRENT_CONTEXT(ctx);
> +   const char* func;
> +
> +   if (dsa)
> +  func = "glCreateTransformFeedbacks";
> +   else
> +  func = "glGenTransformFeedbacks";
>
> if (n < 0) {
> -  _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n <
> 0)");
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
>return;
> }
>
> -   if (!names)
> +   if (!ids)
>return;
>
> /* we don't need contiguous IDs, but this might be faster */
> @@ -854,18 +853,56 @@ _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
>   struct gl_transform_feedback_object *obj
>  = ctx->Driver.NewTransformFeedback(ctx, first + i);
>   if (!obj) {
> -_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
> +_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);

^^
This doesn't line up with ( above.  Mesa uses 3-space identation.

>  return;
>   }
> - names[i] = first + i;
> + ids[i] = first + i;
>
Same thing

>   _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj);
> + if (dsa) {
> +/* this is normally done at bind time in the non-dsa case */
> +obj->EverBound = GL_TRUE;
> + }
>}
> }
> else {
> -  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
> +  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
>
Same thing.

> }
>  }
>
> +/**
> + * Create new transform feedback objects.   Transform feedback objects
> + * encapsulate the state related to transform feedback to allow quickly
> + * switching state (and drawing the results, below).
> + * Part of GL_ARB_transform_feedback2.
> + */
> +void GLAPIENTRY
> +_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +
> +   /* GenTransformFeedbacks should just reserve the object names that a
> +* subsequent call to BindTransformFeedback should actively create. For
> +* the sake of simplicity, we reserve the names and create the objects
> +* straight away.
> +*/
> +
> +   _mesa_create_transform_feedbacks(ctx, n, names, false);
> +}
> +
> +/**
> + * Create new transform feedback objects.   Transform feedback objects
> + * encapsulate the state related to transform feedback to allow quickly
> + * switching state (and drawing the results, below).
> + * Part of GL_ARB_direct_state_access.
> + */
> +void GLAPIENTRY
> +_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
> +

[Mesa-dev] [PATCH 1/6] main: Added entry point for glCreateTransformFeedbacks

2015-02-02 Thread Martin Peres
v2: Review from Laura Ekstrand
- generate the name of the gl method once
- shorten some lines to stay in the 78 chars limit

v3: Review from Fredrik Höglund 
- rename gl_mthd_name to func
- set EverBound in _mesa_create_transform_feedbacks in the dsa case

Signed-off-by: Martin Peres 
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 src/mesa/main/transformfeedback.c  | 67 --
 src/mesa/main/transformfeedback.h  |  6 +++
 4 files changed, 66 insertions(+), 15 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 2fe1638..15b00c2 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -7,6 +7,13 @@


 
+   
+
+  
+  
+  
+   
+

 

diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index ee4db45..5e7f7ae 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
{ "glClipControl", 45, -1 },
 
/* GL_ARB_direct_state_access */
+   { "glCreateTransformFeedbacks", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
{ "glTextureStorage2D", 45, -1 },
diff --git a/src/mesa/main/transformfeedback.c 
b/src/mesa/main/transformfeedback.c
index a737463..466d401 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -825,25 +825,24 @@ _mesa_lookup_transform_feedback_object(struct gl_context 
*ctx, GLuint name)
  _mesa_HashLookup(ctx->TransformFeedback.Objects, name);
 }
 
-
-/**
- * Create new transform feedback objects.   Transform feedback objects
- * encapsulate the state related to transform feedback to allow quickly
- * switching state (and drawing the results, below).
- * Part of GL_ARB_transform_feedback2.
- */
-void GLAPIENTRY
-_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+void
+_mesa_create_transform_feedbacks(struct gl_context *ctx, GLsizei n,
+ GLuint *ids, bool dsa)
 {
GLuint first;
-   GET_CURRENT_CONTEXT(ctx);
+   const char* func;
+
+   if (dsa)
+  func = "glCreateTransformFeedbacks";
+   else
+  func = "glGenTransformFeedbacks";
 
if (n < 0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)");
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
   return;
}
 
-   if (!names)
+   if (!ids)
   return;
 
/* we don't need contiguous IDs, but this might be faster */
@@ -854,18 +853,56 @@ _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
  struct gl_transform_feedback_object *obj
 = ctx->Driver.NewTransformFeedback(ctx, first + i);
  if (!obj) {
-_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
 return;
  }
- names[i] = first + i;
+ ids[i] = first + i;
  _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj);
+ if (dsa) {
+/* this is normally done at bind time in the non-dsa case */
+obj->EverBound = GL_TRUE;
+ }
   }
}
else {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
}
 }
 
+/**
+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_transform_feedback2.
+ */
+void GLAPIENTRY
+_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* GenTransformFeedbacks should just reserve the object names that a
+* subsequent call to BindTransformFeedback should actively create. For
+* the sake of simplicity, we reserve the names and create the objects
+* straight away.
+*/
+
+   _mesa_create_transform_feedbacks(ctx, n, names, false);
+}
+
+/**
+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_direct_state_access.
+ */
+void GLAPIENTRY
+_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_create_transform_feedbacks(ctx, n, names, true);
+}
+
 
 /**
  * Is the given ID a transform feedback object?
diff --git a/src/mesa/main/transformfeedback.h 
b/src/mesa/main/transformfeedback.h
index 87f4080..d598533 100644
--- a/src/mesa/main/transformfeedback.h
+++ b/src/mesa/main/transformfeedback.h
@@ -99,9 +99,15 @@ _mesa_init_transform_feedback_object(struct 
gl_transform_feedback_obj

Re: [Mesa-dev] [PATCH 1/6] main: Added entry point for glCreateTransformFeedbacks

2015-01-29 Thread Martin Peres


On 29/01/15 15:37, Fredrik Höglund wrote:

On Thursday 29 January 2015, Martin Peres wrote:

v2: Review from Laura Ekstrand
- generate the name of the gl method once
- shorten some lines to stay in the 78 chars limit

Signed-off-by: Martin Peres 
---
  src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
  src/mesa/main/tests/dispatch_sanity.cpp|  1 +
  src/mesa/main/transformfeedback.c  | 63 --
  src/mesa/main/transformfeedback.h  |  6 +++
  4 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 2fe1638..15b00c2 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -7,6 +7,13 @@
 
 
  
+   

+
+  
+  
+  
+   
+
 
  
 

diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index ee4db45..5e7f7ae 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
 { "glClipControl", 45, -1 },
  
 /* GL_ARB_direct_state_access */

+   { "glCreateTransformFeedbacks", 45, -1 },
 { "glCreateTextures", 45, -1 },
 { "glTextureStorage1D", 45, -1 },
 { "glTextureStorage2D", 45, -1 },
diff --git a/src/mesa/main/transformfeedback.c 
b/src/mesa/main/transformfeedback.c
index a737463..b0fca48 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -825,25 +825,24 @@ _mesa_lookup_transform_feedback_object(struct gl_context 
*ctx, GLuint name)
   _mesa_HashLookup(ctx->TransformFeedback.Objects, name);
  }
  
-

-/**
- * Create new transform feedback objects.   Transform feedback objects
- * encapsulate the state related to transform feedback to allow quickly
- * switching state (and drawing the results, below).
- * Part of GL_ARB_transform_feedback2.
- */
-void GLAPIENTRY
-_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+void
+_mesa_create_transform_feedbacks(struct gl_context *ctx, GLsizei n,
+ GLuint *ids, bool dsa)
  {
 GLuint first;
-   GET_CURRENT_CONTEXT(ctx);
+   const char* gl_mthd_name;

I would prefer it if you used a simpler name for this variable, such
as "func".


Func seems like a good name. Thanks.



+   if (dsa)
+  gl_mthd_name = "glCreateTransformFeedbacks";
+   else
+  gl_mthd_name = "glGenTransformFeedbacks";
  
 if (n < 0) {

-  _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)");
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", gl_mthd_name);
return;
 }
  
-   if (!names)

+   if (!ids)
return;
  
 /* we don't need contiguous IDs, but this might be faster */

@@ -854,18 +853,52 @@ _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
   struct gl_transform_feedback_object *obj
  = ctx->Driver.NewTransformFeedback(ctx, first + i);
   if (!obj) {
-_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", gl_mthd_name);
  return;
   }
- names[i] = first + i;
+ ids[i] = first + i;
   _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj);

You have to set EverBound to true when dsa is true. Otherwise
glIsTransformFeedback() will return false when it's passed an ID that
was created by glCreateTransformFeedbacks().


Good catch! I'm going to modify my piglit test to check for this 
behaviour. Thanks.



}
 }
 else {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", gl_mthd_name);
 }
  }
  
+/**

+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_transform_feedback2.
+ */
+void GLAPIENTRY
+_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* GenTransformFeedbacks should just reserve the object names that a
+* subsequent call to BindTransformFeedback should actively create. For
+* the sake of simplicity, we reserve the names and create the objects
+* straight away.
+*/
+   _mesa_create_transform_feedbacks(ctx, n, names, false);
+}
+
+/**
+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_direct_state_access.
+ */
+void GLAPIENTRY
+_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_create_transform_feedbacks(ctx, n, names, true);
+}
+
  
  /**

   * Is the given ID a tran

Re: [Mesa-dev] [PATCH 1/6] main: Added entry point for glCreateTransformFeedbacks

2015-01-29 Thread Fredrik Höglund
On Thursday 29 January 2015, Martin Peres wrote:
> v2: Review from Laura Ekstrand
> - generate the name of the gl method once
> - shorten some lines to stay in the 78 chars limit
> 
> Signed-off-by: Martin Peres 
> ---
>  src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
>  src/mesa/main/tests/dispatch_sanity.cpp|  1 +
>  src/mesa/main/transformfeedback.c  | 63 
> --
>  src/mesa/main/transformfeedback.h  |  6 +++
>  4 files changed, 62 insertions(+), 15 deletions(-)
> 
> diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
> b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> index 2fe1638..15b00c2 100644
> --- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
> +++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
> @@ -7,6 +7,13 @@
> 
> 
>  
> +   
> +
> +  
> +  
> +  
> +   
> +
> 
>  
> 
> diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
> b/src/mesa/main/tests/dispatch_sanity.cpp
> index ee4db45..5e7f7ae 100644
> --- a/src/mesa/main/tests/dispatch_sanity.cpp
> +++ b/src/mesa/main/tests/dispatch_sanity.cpp
> @@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
> { "glClipControl", 45, -1 },
>  
> /* GL_ARB_direct_state_access */
> +   { "glCreateTransformFeedbacks", 45, -1 },
> { "glCreateTextures", 45, -1 },
> { "glTextureStorage1D", 45, -1 },
> { "glTextureStorage2D", 45, -1 },
> diff --git a/src/mesa/main/transformfeedback.c 
> b/src/mesa/main/transformfeedback.c
> index a737463..b0fca48 100644
> --- a/src/mesa/main/transformfeedback.c
> +++ b/src/mesa/main/transformfeedback.c
> @@ -825,25 +825,24 @@ _mesa_lookup_transform_feedback_object(struct 
> gl_context *ctx, GLuint name)
>   _mesa_HashLookup(ctx->TransformFeedback.Objects, name);
>  }
>  
> -
> -/**
> - * Create new transform feedback objects.   Transform feedback objects
> - * encapsulate the state related to transform feedback to allow quickly
> - * switching state (and drawing the results, below).
> - * Part of GL_ARB_transform_feedback2.
> - */
> -void GLAPIENTRY
> -_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
> +void
> +_mesa_create_transform_feedbacks(struct gl_context *ctx, GLsizei n,
> + GLuint *ids, bool dsa)
>  {
> GLuint first;
> -   GET_CURRENT_CONTEXT(ctx);
> +   const char* gl_mthd_name;

I would prefer it if you used a simpler name for this variable, such
as "func".

> +   if (dsa)
> +  gl_mthd_name = "glCreateTransformFeedbacks";
> +   else
> +  gl_mthd_name = "glGenTransformFeedbacks";
>  
> if (n < 0) {
> -  _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)");
> +  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", gl_mthd_name);
>return;
> }
>  
> -   if (!names)
> +   if (!ids)
>return;
>  
> /* we don't need contiguous IDs, but this might be faster */
> @@ -854,18 +853,52 @@ _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
>   struct gl_transform_feedback_object *obj
>  = ctx->Driver.NewTransformFeedback(ctx, first + i);
>   if (!obj) {
> -_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
> +_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", gl_mthd_name);
>  return;
>   }
> - names[i] = first + i;
> + ids[i] = first + i;
>   _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj);

You have to set EverBound to true when dsa is true. Otherwise
glIsTransformFeedback() will return false when it's passed an ID that
was created by glCreateTransformFeedbacks().

>}
> }
> else {
> -  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
> +  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", gl_mthd_name);
> }
>  }
>  
> +/**
> + * Create new transform feedback objects.   Transform feedback objects
> + * encapsulate the state related to transform feedback to allow quickly
> + * switching state (and drawing the results, below).
> + * Part of GL_ARB_transform_feedback2.
> + */
> +void GLAPIENTRY
> +_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +
> +   /* GenTransformFeedbacks should just reserve the object names that a
> +* subsequent call to BindTransformFeedback should actively create. For
> +* the sake of simplicity, we reserve the names and create the objects
> +* straight away.
> +*/
> +   _mesa_create_transform_feedbacks(ctx, n, names, false);
> +}
> +
> +/**
> + * Create new transform feedback objects.   Transform feedback objects
> + * encapsulate the state related to transform feedback to allow quickly
> + * switching state (and drawing the results, below).
> + * Part of GL_ARB_direct_state_access.
> + */
> +void GLAPIENTRY
> +_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
> +{
> +   GET_CURRENT_CONTEXT(ctx);
> +
> +   _mesa_create_transform_feedbacks(ctx, n, names, 

[Mesa-dev] [PATCH 1/6] main: Added entry point for glCreateTransformFeedbacks

2015-01-29 Thread Martin Peres
v2: Review from Laura Ekstrand
- generate the name of the gl method once
- shorten some lines to stay in the 78 chars limit

Signed-off-by: Martin Peres 
---
 src/mapi/glapi/gen/ARB_direct_state_access.xml |  7 +++
 src/mesa/main/tests/dispatch_sanity.cpp|  1 +
 src/mesa/main/transformfeedback.c  | 63 --
 src/mesa/main/transformfeedback.h  |  6 +++
 4 files changed, 62 insertions(+), 15 deletions(-)

diff --git a/src/mapi/glapi/gen/ARB_direct_state_access.xml 
b/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 2fe1638..15b00c2 100644
--- a/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -7,6 +7,13 @@


 
+   
+
+  
+  
+  
+   
+

 

diff --git a/src/mesa/main/tests/dispatch_sanity.cpp 
b/src/mesa/main/tests/dispatch_sanity.cpp
index ee4db45..5e7f7ae 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -955,6 +955,7 @@ const struct function gl_core_functions_possible[] = {
{ "glClipControl", 45, -1 },
 
/* GL_ARB_direct_state_access */
+   { "glCreateTransformFeedbacks", 45, -1 },
{ "glCreateTextures", 45, -1 },
{ "glTextureStorage1D", 45, -1 },
{ "glTextureStorage2D", 45, -1 },
diff --git a/src/mesa/main/transformfeedback.c 
b/src/mesa/main/transformfeedback.c
index a737463..b0fca48 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -825,25 +825,24 @@ _mesa_lookup_transform_feedback_object(struct gl_context 
*ctx, GLuint name)
  _mesa_HashLookup(ctx->TransformFeedback.Objects, name);
 }
 
-
-/**
- * Create new transform feedback objects.   Transform feedback objects
- * encapsulate the state related to transform feedback to allow quickly
- * switching state (and drawing the results, below).
- * Part of GL_ARB_transform_feedback2.
- */
-void GLAPIENTRY
-_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+void
+_mesa_create_transform_feedbacks(struct gl_context *ctx, GLsizei n,
+ GLuint *ids, bool dsa)
 {
GLuint first;
-   GET_CURRENT_CONTEXT(ctx);
+   const char* gl_mthd_name;
+
+   if (dsa)
+  gl_mthd_name = "glCreateTransformFeedbacks";
+   else
+  gl_mthd_name = "glGenTransformFeedbacks";
 
if (n < 0) {
-  _mesa_error(ctx, GL_INVALID_VALUE, "glGenTransformFeedbacks(n < 0)");
+  _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", gl_mthd_name);
   return;
}
 
-   if (!names)
+   if (!ids)
   return;
 
/* we don't need contiguous IDs, but this might be faster */
@@ -854,18 +853,52 @@ _mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
  struct gl_transform_feedback_object *obj
 = ctx->Driver.NewTransformFeedback(ctx, first + i);
  if (!obj) {
-_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", gl_mthd_name);
 return;
  }
- names[i] = first + i;
+ ids[i] = first + i;
  _mesa_HashInsert(ctx->TransformFeedback.Objects, first + i, obj);
   }
}
else {
-  _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTransformFeedbacks");
+  _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", gl_mthd_name);
}
 }
 
+/**
+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_transform_feedback2.
+ */
+void GLAPIENTRY
+_mesa_GenTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   /* GenTransformFeedbacks should just reserve the object names that a
+* subsequent call to BindTransformFeedback should actively create. For
+* the sake of simplicity, we reserve the names and create the objects
+* straight away.
+*/
+
+   _mesa_create_transform_feedbacks(ctx, n, names, false);
+}
+
+/**
+ * Create new transform feedback objects.   Transform feedback objects
+ * encapsulate the state related to transform feedback to allow quickly
+ * switching state (and drawing the results, below).
+ * Part of GL_ARB_direct_state_access.
+ */
+void GLAPIENTRY
+_mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
+{
+   GET_CURRENT_CONTEXT(ctx);
+
+   _mesa_create_transform_feedbacks(ctx, n, names, true);
+}
+
 
 /**
  * Is the given ID a transform feedback object?
diff --git a/src/mesa/main/transformfeedback.h 
b/src/mesa/main/transformfeedback.h
index 87f4080..d598533 100644
--- a/src/mesa/main/transformfeedback.h
+++ b/src/mesa/main/transformfeedback.h
@@ -99,9 +99,15 @@ _mesa_init_transform_feedback_object(struct 
gl_transform_feedback_object *obj,
 struct gl_transform_feedback_object *
 _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name);
 
+extern void
+_mesa_create_transform_feedbacks(struct gl_context *ctx, GLsizei n, GLuint 
*ids, bool