On Thursday 19 March 2015, Brian Paul wrote:
> On 03/18/2015 05:18 PM, Fredrik Höglund wrote:
> > This saves the cost of repeated hash table lookups when the same
> > vertex array object is referenced in a sequence of calls such as:
> >
> >      glVertexArrayAttribFormat(vao, ...);
> >      glVertexArrayAttribBinding(vao, ...);
> >      glEnableVertexArrayAttrib(vao, ...);
> >      ...
> >
> > Note that VAO's are container objects that are not shared between
> > contexts.
> 
> I wonder if this optimization could be put into the hash table functions 
> themselves so it would benefit all object types.

The downside to that approach is that we can't avoid locking the hash table
mutex when the pointer is stored in the hash table.

I've been doing some measurements comparing the following sequence
of calls:

    glTextureParameteri(tex, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTextureParameteri(tex, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTextureParameteri(tex, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTextureParameteri(tex, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTextureParameteri(tex, GL_TEXTURE_MAX_LEVEL, 0);

to:

    glBindTexture(GL_TEXTURE_2D, tex);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);

And with master, the selector-based version is ~20% faster than the DSA
version.  With this optimization done in the hash table, the selector based
version is still ~10% faster than the DSA version.  But with a reference
stored in each context, as in this patch, the DSA version becomes ~8%
faster than the selector-based version.  So locking the mutex is not an
insignificant part of the cost.

Fredrik

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

Reply via email to