Commit e9ed1848 authored by Ken Martin's avatar Ken Martin

some performance improvements for the OpenGL2 shader

There were lost of std::string operations that resulted
in lots of memory allocs/deallocs. This patch significantly
reduces them. In my testing of vtkCompositePolyDataMapper2
these changes improved the frame rate from 75 fps up to
400 fps.
parent 3edd29cc
Pipeline #24456 passed with stage
This diff is collapsed.
......@@ -207,6 +207,20 @@ public:
// name.
bool IsAttributeUsed(const char *name);
// maps of std::string are super slow when calling find
// with a string literal or const char * as find
// forces construction/copy/destruction of a
// std::sting copy of the const char *
// In spite of the doubters this can really be a
// huge CPU hog.
struct cmp_str
bool operator()(const char *a, const char *b) const
return strcmp(a, b) < 0;
......@@ -284,10 +298,11 @@ protected:
std::string Error;
std::map<std::string, int> AttributeLocs;
std::map<std::string, int> UniformLocs;
// since we are using const char * arrays we have to
// free our memory :-)
void ClearMaps();
std::map<const char *, int, cmp_str> AttributeLocs;
std::map<const char *, int, cmp_str> UniformLocs;
friend class VertexArrayObject;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment