[Mesa-dev] [PATCH 1/2] meta: Add a GLSL-based _mesa_meta_Clear() variant.
Brian Paul
brianp at vmware.com
Mon Jul 18 12:02:14 PDT 2011
On 07/18/2011 12:47 PM, Brian Paul wrote:
> On 07/18/2011 10:33 AM, Eric Anholt wrote:
>> This cuts out a large portion of the overhead of glClear() from
>> resetting the texenv state and recomputing the fixed function
>> programs. It also means less use of fixed function internally in our
>> GLES2 drivers, which is rather bogus.
>
> Looks good. Only minor comments below.
>
> Reviewed-by: Brian Paul <brianp at vmware.com>
>
>
>> ---
>> src/mesa/drivers/common/meta.c | 166
>> ++++++++++++++++++++++++++++++++++++++++
>> src/mesa/drivers/common/meta.h | 3 +
>> 2 files changed, 169 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/mesa/drivers/common/meta.c
>> b/src/mesa/drivers/common/meta.c
>> index 0e58aec..09d7186 100644
>> --- a/src/mesa/drivers/common/meta.c
>> +++ b/src/mesa/drivers/common/meta.c
>> @@ -62,6 +62,7 @@
>> #include "main/teximage.h"
>> #include "main/texparam.h"
>> #include "main/texstate.h"
>> +#include "main/uniforms.h"
>> #include "main/varray.h"
>> #include "main/viewport.h"
>> #include "program/program.h"
>> @@ -235,6 +236,8 @@ struct clear_state
>> {
>> GLuint ArrayObj;
>> GLuint VBO;
>> + GLuint ShaderProg;
>> + GLint ColorLocation;
>> };
>>
>>
>> @@ -1589,6 +1592,169 @@ _mesa_meta_Clear(struct gl_context *ctx,
>> GLbitfield buffers)
>> _mesa_meta_end(ctx);
>> }
>>
>> +static void
>> +meta_glsl_clear_init(struct gl_context *ctx, struct clear_state
>> *clear)
>> +{
>> + const char *vs_source =
>> + "attribute vec4 position;\n"
>> + "void main()\n"
>> + "{\n"
>> + " gl_Position = position;\n"
>> + "}\n";
>> + const char *fs_source =
>> + "uniform vec4 color;\n"
>> + "void main()\n"
>> + "{\n"
>> + " gl_FragColor = color;\n"
>> + "}\n";
>> + GLuint vs, fs;
>> +
>
> /* check if GLSL-clear state already initialized */
>> + if (clear->ArrayObj != 0)
>> + return;
>> +
>> + /* create vertex array object */
>> + _mesa_GenVertexArrays(1,&clear->ArrayObj);
>> + _mesa_BindVertexArray(clear->ArrayObj);
>> +
>> + /* create vertex array buffer */
>> + _mesa_GenBuffersARB(1,&clear->VBO);
>> + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, clear->VBO);
>> +
>> + /* setup vertex arrays */
>> + _mesa_VertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, 3 *
>> sizeof(float),
>> + (void *)0);
>
> You can pass stride=0 here, and I'd use NULL:
>
> _mesa_VertexAttribPointerARB(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);
Nevermind the NULL thing. (void*)0 emphasizes it's an offset.
-Brian
More information about the mesa-dev
mailing list