| 185 | } |
| 186 | |
| 187 | GFXShader* ShaderData::getShader( const Vector<GFXShaderMacro> ¯os ) |
| 188 | { |
| 189 | PROFILE_SCOPE( ShaderData_GetShader ); |
| 190 | |
| 191 | // Combine the dynamic macros with our script defined macros. |
| 192 | Vector<GFXShaderMacro> finalMacros; |
| 193 | finalMacros.merge( _getMacros() ); |
| 194 | finalMacros.merge( macros ); |
| 195 | |
| 196 | // Convert the final macro list to a string. |
| 197 | String cacheKey; |
| 198 | GFXShaderMacro::stringize( macros, &cacheKey ); |
| 199 | |
| 200 | // Lookup the shader for this instance. |
| 201 | ShaderCache::Iterator iter = mShaders.find( cacheKey ); |
| 202 | if ( iter != mShaders.end() ) |
| 203 | return iter->value; |
| 204 | |
| 205 | // Create the shader instance... if it fails then |
| 206 | // bail out and return nothing to the caller. |
| 207 | GFXShader *shader = _createShader( finalMacros ); |
| 208 | if ( !shader ) |
| 209 | return NULL; |
| 210 | |
| 211 | _checkDefinition(shader); |
| 212 | |
| 213 | // Store the shader in the cache and return it. |
| 214 | mShaders.insertUnique( cacheKey, shader ); |
| 215 | return shader; |
| 216 | } |
| 217 | |
| 218 | GFXShader* ShaderData::_createShader( const Vector<GFXShaderMacro> ¯os ) |
| 219 | { |
no test coverage detected