Changeset 2805


Ignore:
Timestamp:
Jul 18, 2013, 12:03:42 PM (4 years ago)
Author:
benlitz
Message:

shaders now cache attribute location once they have been retrieved for the first time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gpu/shader.cpp

    r2787 r2805  
    6161#elif !defined __CELLOS_LV2__
    6262    GLuint prog_id, vert_id, frag_id;
     63        // Benlitz: using a simple array could be faster since there is never more than a few attribute locations to store
     64        Map<String, GLint> attrib_locations;
    6365#else
    6466    CGprogram vert_id, frag_id;
     
    333335#if defined USE_D3D9 || defined _XBOX
    334336#elif !defined __CELLOS_LV2__
    335     GLint l = glGetAttribLocation(data->prog_id, attr);
    336     if (l < 0)
    337     {
    338         Log::Warn("tried to query invalid attribute: %s\n", attr);
    339         l = 0;
    340     }
     337        GLint l;
     338       
     339        if (!data->attrib_locations.TryGetValue(attr, l))
     340        {
     341                l = glGetAttribLocation(data->prog_id, attr);
     342                if (l < 0)
     343                {
     344                        Log::Warn("tried to query invalid attribute: %s\n", attr);
     345                        l = 0;
     346                }
     347                else
     348                {
     349                        data->attrib_locations[String(attr)] = l;
     350                }
     351        }
    341352    ret.m_flags |= (uint64_t)(uint32_t)l << 32;
    342353#else
Note: See TracChangeset for help on using the changeset viewer.