Re: [Mesa-dev] [PATCH 1/2] vbo: fix glPrimitiveRestartNV crash inside a display list

2017-07-09 Thread Brian Paul
The fact that nobody noticed this until recently tells me it's not 
terribly important.  But if the patches apply cleanly, sure.


-Brian

On 07/08/2017 04:01 PM, Andres Gomez wrote:

It looks like we could want this series into -stable (?)

On Fri, 2017-07-07 at 08:10 -0600, Brian Paul wrote:

From: Olivier Lauffenburger 

glPrimitiveRestartNV crashes when it is called during the compilation
of a display list.

There are two reasons:
- ctx->Driver.CurrentSavePrimitive is not set to the current primitive
- save_PrimitiveRestartNV() calls _save_Begin() which only sets an
   OpenGL error, instead of calling vbo_save_NotifyBegin().

This patch correctly calls vbo_save_NotifyBegin() but it detects
the current primitive mode by looking at the latest saved primitive.

Additional work by Brian Paul

Signed-off-by: Olivier Lauffenburger 
Bugzilla: 
https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D101464=DwICaQ=uilaK90D4TOVoH58JNXRgQ=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA=ALF8sUngY-vAUaF06oa0BPR23YXqODMASRt0SibYNwk=EWp7qEWuQ7DeSCz0OzbJmResjK31q89tPymB6Zcad9g=
Reviewed-by: Brian Paul 
---
  src/mesa/vbo/vbo_save_api.c | 20 +++-
  1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index a42a3c3..aab5f54 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1108,13 +1108,23 @@ _save_Begin(GLenum mode)
  static void GLAPIENTRY
  _save_PrimitiveRestartNV(void)
  {
-   GLenum curPrim;
 GET_CURRENT_CONTEXT(ctx);
+   struct vbo_save_context *save = _context(ctx)->save;

-   curPrim = ctx->Driver.CurrentSavePrimitive;
-
-   _save_End();
-   _save_Begin(curPrim);
+   if (save->prim_count == 0) {
+  /* We're not inside a glBegin/End pair, so calling glPrimitiverRestartNV
+   * is an error.
+   */
+  _mesa_compile_error(ctx, GL_INVALID_OPERATION,
+  "glPrimitiveRestartNV called outside glBegin/End");
+   } else {
+  /* get current primitive mode */
+  GLenum curPrim = save->prim[save->prim_count - 1].mode;
+
+  /* restart primitive */
+  CALL_End(GET_DISPATCH(), ());
+  vbo_save_NotifyBegin(ctx, curPrim);
+   }
  }




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


Re: [Mesa-dev] [PATCH 1/2] vbo: fix glPrimitiveRestartNV crash inside a display list

2017-07-08 Thread Andres Gomez
It looks like we could want this series into -stable (?)

On Fri, 2017-07-07 at 08:10 -0600, Brian Paul wrote:
> From: Olivier Lauffenburger 
> 
> glPrimitiveRestartNV crashes when it is called during the compilation
> of a display list.
> 
> There are two reasons:
> - ctx->Driver.CurrentSavePrimitive is not set to the current primitive
> - save_PrimitiveRestartNV() calls _save_Begin() which only sets an
>   OpenGL error, instead of calling vbo_save_NotifyBegin().
> 
> This patch correctly calls vbo_save_NotifyBegin() but it detects
> the current primitive mode by looking at the latest saved primitive.
> 
> Additional work by Brian Paul
> 
> Signed-off-by: Olivier Lauffenburger 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101464
> Reviewed-by: Brian Paul 
> ---
>  src/mesa/vbo/vbo_save_api.c | 20 +++-
>  1 file changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
> index a42a3c3..aab5f54 100644
> --- a/src/mesa/vbo/vbo_save_api.c
> +++ b/src/mesa/vbo/vbo_save_api.c
> @@ -1108,13 +1108,23 @@ _save_Begin(GLenum mode)
>  static void GLAPIENTRY
>  _save_PrimitiveRestartNV(void)
>  {
> -   GLenum curPrim;
> GET_CURRENT_CONTEXT(ctx);
> +   struct vbo_save_context *save = _context(ctx)->save;
>  
> -   curPrim = ctx->Driver.CurrentSavePrimitive;
> -
> -   _save_End();
> -   _save_Begin(curPrim);
> +   if (save->prim_count == 0) {
> +  /* We're not inside a glBegin/End pair, so calling 
> glPrimitiverRestartNV
> +   * is an error.
> +   */
> +  _mesa_compile_error(ctx, GL_INVALID_OPERATION,
> +  "glPrimitiveRestartNV called outside glBegin/End");
> +   } else {
> +  /* get current primitive mode */
> +  GLenum curPrim = save->prim[save->prim_count - 1].mode;
> +
> +  /* restart primitive */
> +  CALL_End(GET_DISPATCH(), ());
> +  vbo_save_NotifyBegin(ctx, curPrim);
> +   }
>  }
>  
>  
-- 
Br,

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


[Mesa-dev] [PATCH 1/2] vbo: fix glPrimitiveRestartNV crash inside a display list

2017-07-07 Thread Brian Paul
From: Olivier Lauffenburger 

glPrimitiveRestartNV crashes when it is called during the compilation
of a display list.

There are two reasons:
- ctx->Driver.CurrentSavePrimitive is not set to the current primitive
- save_PrimitiveRestartNV() calls _save_Begin() which only sets an
  OpenGL error, instead of calling vbo_save_NotifyBegin().

This patch correctly calls vbo_save_NotifyBegin() but it detects
the current primitive mode by looking at the latest saved primitive.

Additional work by Brian Paul

Signed-off-by: Olivier Lauffenburger 
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101464
Reviewed-by: Brian Paul 
---
 src/mesa/vbo/vbo_save_api.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/mesa/vbo/vbo_save_api.c b/src/mesa/vbo/vbo_save_api.c
index a42a3c3..aab5f54 100644
--- a/src/mesa/vbo/vbo_save_api.c
+++ b/src/mesa/vbo/vbo_save_api.c
@@ -1108,13 +1108,23 @@ _save_Begin(GLenum mode)
 static void GLAPIENTRY
 _save_PrimitiveRestartNV(void)
 {
-   GLenum curPrim;
GET_CURRENT_CONTEXT(ctx);
+   struct vbo_save_context *save = _context(ctx)->save;
 
-   curPrim = ctx->Driver.CurrentSavePrimitive;
-
-   _save_End();
-   _save_Begin(curPrim);
+   if (save->prim_count == 0) {
+  /* We're not inside a glBegin/End pair, so calling glPrimitiverRestartNV
+   * is an error.
+   */
+  _mesa_compile_error(ctx, GL_INVALID_OPERATION,
+  "glPrimitiveRestartNV called outside glBegin/End");
+   } else {
+  /* get current primitive mode */
+  GLenum curPrim = save->prim[save->prim_count - 1].mode;
+
+  /* restart primitive */
+  CALL_End(GET_DISPATCH(), ());
+  vbo_save_NotifyBegin(ctx, curPrim);
+   }
 }
 
 
-- 
1.9.1

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