Re: [Mesa-dev] [PATCH 2/2] mesa: finish implementing glPrimitiveRestartNV() for display lists

2017-07-07 Thread Charmaine Lee

>From: Brian Paul 
>Sent: Friday, July 7, 2017 7:10 AM
>To: mesa-dev@lists.freedesktop.org
>Cc: Charmaine Lee; Neha Bhende; Olivier Lauffenburger
>Subject: [PATCH 2/2] mesa: finish implementing glPrimitiveRestartNV() for 
>display lists

>If we try to build a display list with just a glPrimitiveRestartNV()
>call, we'd crash because of a null GLvertexformat::PrimitiveRestartNV
>pointer.  This change fixes that case.

>The previous patch fixed the case of calling glPrimitiveRestartNV()
>inside a glBegin/End pair.
>---
> src/mesa/main/dlist.c | 27 ++-
> 1 file changed, 26 insertions(+), 1 deletion(-)

>diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 9e817be..6e334fd 100644
>--- a/src/mesa/main/dlist.c
>+++ b/src/mesa/main/dlist.c
>@@ -325,7 +325,8 @@ typedef enum
>OPCODE_STENCIL_FUNC_SEPARATE,
>OPCODE_STENCIL_OP_SEPARATE,
>OPCODE_STENCIL_MASK_SEPARATE,
>-
>+   /* GL_NV_primitive_restart */
>+   OPCODE_PRIMITIVE_RESTART_NV,
>/* GL_ARB_shader_objects */
>OPCODE_USE_PROGRAM,
>OPCODE_UNIFORM_1F,
>@@ -6095,6 +6096,24 @@ save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
> }

> static void GLAPIENTRY
>+save_PrimitiveRestartNV(void)
>+{
>+   /* Note: this is used when outside a glBegin/End pair in a display list */
>+   GET_CURRENT_CONTEXT(ctx);
>+   Node *n;
>+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
>+   n = alloc_instruction(ctx, OPCODE_PRIMITIVE_RESTART_NV, 0);
>+   if (n) {
>+  /* nothing */
>+   }

Can you remove this if clause since it is not doing anything?

>+   if (ctx->ExecuteFlag) {
>+  CALL_PrimitiveRestartNV(ctx->Exec, ());
>+   }
>+
>+}
>+
>+
>+static void GLAPIENTRY
> save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
>GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
> GLbitfield mask, GLenum filter)
>@@ -8670,6 +8689,10 @@ execute_list(struct gl_context *ctx, GLuint list)
> n[5].i, n[6].i, n[7].i, 
> n[8].i,
> n[9].i, n[10].e));
> break;
>+ case OPCODE_PRIMITIVE_RESTART_NV:
>+CALL_PrimitiveRestartNV(ctx->Exec, ());
>+break;
>+
>  case OPCODE_USE_PROGRAM:
> CALL_UseProgram(ctx->Exec, (n[1].ui));
> break;
>@@ -10460,6 +10483,8 @@ save_vtxfmt_init(GLvertexformat * vfmt)
>vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
>vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
>vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
>+
>+   vfmt->PrimitiveRestartNV = save_PrimitiveRestartNV;
> }


For this series,  Reviewed-by: Charmaine Lee 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/2] mesa: finish implementing glPrimitiveRestartNV() for display lists

2017-07-07 Thread Brian Paul
If we try to build a display list with just a glPrimitiveRestartNV()
call, we'd crash because of a null GLvertexformat::PrimitiveRestartNV
pointer.  This change fixes that case.

The previous patch fixed the case of calling glPrimitiveRestartNV()
inside a glBegin/End pair.
---
 src/mesa/main/dlist.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 9e817be..6e334fd 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -325,7 +325,8 @@ typedef enum
OPCODE_STENCIL_FUNC_SEPARATE,
OPCODE_STENCIL_OP_SEPARATE,
OPCODE_STENCIL_MASK_SEPARATE,
-
+   /* GL_NV_primitive_restart */
+   OPCODE_PRIMITIVE_RESTART_NV,
/* GL_ARB_shader_objects */
OPCODE_USE_PROGRAM,
OPCODE_UNIFORM_1F,
@@ -6095,6 +6096,24 @@ save_VertexAttrib4fvARB(GLuint index, const GLfloat * v)
 }
 
 static void GLAPIENTRY
+save_PrimitiveRestartNV(void)
+{
+   /* Note: this is used when outside a glBegin/End pair in a display list */
+   GET_CURRENT_CONTEXT(ctx);
+   Node *n;
+   ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+   n = alloc_instruction(ctx, OPCODE_PRIMITIVE_RESTART_NV, 0);
+   if (n) {
+  /* nothing */
+   }
+   if (ctx->ExecuteFlag) {
+  CALL_PrimitiveRestartNV(ctx->Exec, ());
+   }
+
+}
+
+
+static void GLAPIENTRY
 save_BlitFramebufferEXT(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
 GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
 GLbitfield mask, GLenum filter)
@@ -8670,6 +8689,10 @@ execute_list(struct gl_context *ctx, GLuint list)
 n[5].i, n[6].i, n[7].i, n[8].i,
 n[9].i, n[10].e));
 break;
+ case OPCODE_PRIMITIVE_RESTART_NV:
+CALL_PrimitiveRestartNV(ctx->Exec, ());
+break;
+
  case OPCODE_USE_PROGRAM:
 CALL_UseProgram(ctx->Exec, (n[1].ui));
 break;
@@ -10460,6 +10483,8 @@ save_vtxfmt_init(GLvertexformat * vfmt)
vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
+
+   vfmt->PrimitiveRestartNV = save_PrimitiveRestartNV;
 }
 
 
-- 
1.9.1

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