Re: [Mesa-dev] [PATCH 19/23] meta: Use internal functions for buffer object and VAO access in _mesa_meta_DrawTex

2015-11-13 Thread Anuj Phogat
On Mon, Nov 9, 2015 at 4:56 PM, Ian Romanick  wrote:
> From: Ian Romanick 
>
> Signed-off-by: Ian Romanick 
> ---
>  src/mesa/drivers/common/meta.c | 32 
>  1 file changed, 20 insertions(+), 12 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index 6927ae9..57993cf 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -3298,13 +3298,16 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
> GLfloat y, GLfloat z,
>
> if (drawtex->VAO == 0) {
>/* one-time setup */
> -  GLint active_texture;
> +  struct gl_vertex_array_object *array_obj;
>GLuint VBO;
>
>/* create vertex array object */
>_mesa_GenVertexArrays(1, >VAO);
>_mesa_BindVertexArray(drawtex->VAO);
>
> +  array_obj = _mesa_lookup_vao(ctx, drawtex->VAO);
> +  assert(array_obj != NULL);
> +
>/* create vertex array buffer */
>_mesa_CreateBuffers(1, );
>drawtex->buf_obj = _mesa_lookup_bufferobj(ctx, VBO);
> @@ -3321,22 +3324,27 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
> GLfloat y, GLfloat z,
>
>assert(drawtex->buf_obj->Size == sizeof(verts));
>
> -  /* client active texture is not part of the array object */
> -  active_texture = ctx->Array.ActiveTexture;
> -
>_mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, VBO);
>
>/* setup vertex arrays */
> -  _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
> -  _mesa_EnableClientState(GL_VERTEX_ARRAY);
> +  _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS,
> +3, GL_FLOAT, GL_RGBA, GL_FALSE,
> +GL_FALSE, GL_FALSE,
> +offsetof(struct vertex, x), true);
> +  _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);
> +
> +
>for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
> - _mesa_ClientActiveTexture(GL_TEXTURE0 + i);
> - _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), 
> OFFSET(st[i]));
> - _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
> + _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(i),
> +   2, GL_FLOAT, GL_RGBA, GL_FALSE,
> +   GL_FALSE, GL_FALSE,
> +   offsetof(struct vertex, st[i]), true);
> + _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));
>}
> -
> -  /* restore client active texture */
> -  _mesa_ClientActiveTexture(GL_TEXTURE0 + active_texture);
> }
> else {
>_mesa_BindVertexArray(drawtex->VAO);
> --
> 2.1.0
>
> ___
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reviewed-by: Anuj Phogat 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 19/23] meta: Use internal functions for buffer object and VAO access in _mesa_meta_DrawTex

2015-11-09 Thread Ian Romanick
From: Ian Romanick 

Signed-off-by: Ian Romanick 
---
 src/mesa/drivers/common/meta.c | 32 
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 6927ae9..57993cf 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -3298,13 +3298,16 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
 
if (drawtex->VAO == 0) {
   /* one-time setup */
-  GLint active_texture;
+  struct gl_vertex_array_object *array_obj;
   GLuint VBO;
 
   /* create vertex array object */
   _mesa_GenVertexArrays(1, >VAO);
   _mesa_BindVertexArray(drawtex->VAO);
 
+  array_obj = _mesa_lookup_vao(ctx, drawtex->VAO);
+  assert(array_obj != NULL);
+
   /* create vertex array buffer */
   _mesa_CreateBuffers(1, );
   drawtex->buf_obj = _mesa_lookup_bufferobj(ctx, VBO);
@@ -3321,22 +3324,27 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, 
GLfloat y, GLfloat z,
 
   assert(drawtex->buf_obj->Size == sizeof(verts));
 
-  /* client active texture is not part of the array object */
-  active_texture = ctx->Array.ActiveTexture;
-
   _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, VBO);
 
   /* setup vertex arrays */
-  _mesa_VertexPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(x));
-  _mesa_EnableClientState(GL_VERTEX_ARRAY);
+  _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_POS,
+3, GL_FLOAT, GL_RGBA, GL_FALSE,
+GL_FALSE, GL_FALSE,
+offsetof(struct vertex, x), true);
+  _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);
+
+
   for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- _mesa_ClientActiveTexture(GL_TEXTURE0 + i);
- _mesa_TexCoordPointer(2, GL_FLOAT, sizeof(struct vertex), 
OFFSET(st[i]));
- _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY);
+ _mesa_update_array_format(ctx, array_obj, VERT_ATTRIB_TEX(i),
+   2, GL_FLOAT, GL_RGBA, GL_FALSE,
+   GL_FALSE, GL_FALSE,
+   offsetof(struct vertex, st[i]), true);
+ _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));
   }
-
-  /* restore client active texture */
-  _mesa_ClientActiveTexture(GL_TEXTURE0 + active_texture);
}
else {
   _mesa_BindVertexArray(drawtex->VAO);
-- 
2.1.0

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