From: <re...@us...> - 2009-12-31 18:52:47
|
Revision: 33457 http://crystal.svn.sourceforge.net/crystal/?rev=33457&view=rev Author: res2002 Date: 2009-12-31 18:52:37 +0000 (Thu, 31 Dec 2009) Log Message: ----------- Fix failure to load any limits combo other than the current from the shader cache. If loading a program from the cache succeeded with an invalid program, but the best limits are worse than the current limits, pretend the load failed to allow a try with the current limits. Modified Paths: -------------- CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.cpp CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.h CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgfp.h Modified: CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.cpp =================================================================== --- CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.cpp 2009-12-31 17:31:39 UTC (rev 33456) +++ CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.cpp 2009-12-31 18:52:37 UTC (rev 33457) @@ -736,7 +736,8 @@ iShaderProgram::CacheLoadResult csShaderGLCGCommon::LoadFromCache ( iHierarchicalCache* cache, iBase* previous, iDocumentNode* node, - csRef<iString>* failReason, csRef<iString>* tag) + csRef<iString>* failReason, csRef<iString>* tag, + ProfileLimitsPair* cacheLimits) { if (!cache) return iShaderProgram::loadFail; @@ -826,11 +827,21 @@ csString allReasons; bool oneReadCorrectly = false; + ProfileLimits bestLimits ( + CS::PluginCommon::ShaderProgramPluginGL::Other, + CG_PROFILE_UNKNOWN); + bool bestLimitsSet = false; for (size_t i = cachedProgWrappers.GetSize(); i-- > 0;) { const CachedShaderWrapper& wrapper = cachedProgWrappers[i]; const ProfileLimits& limits = (programType == progVP) ? wrapper.limits.vp : wrapper.limits.fp; + + if (!bestLimitsSet) + { + bestLimits = limits; + bestLimitsSet = true; + } if (strictMatch && (limits != currentLimits)) { @@ -994,6 +1005,9 @@ DoDebugDump(); tag->AttachNew (new scfString (wrapper.name)); + + if (cacheLimits != 0) + *cacheLimits = wrapper.limits; if (shaderPlug->ProfileNeedsRouting (programProfile)) { @@ -1007,9 +1021,28 @@ } } + iShaderProgram::CacheLoadResult ret; if (failReason) failReason->AttachNew ( new scfString (allReasons)); - return oneReadCorrectly ? iShaderProgram::loadSuccessShaderInvalid : iShaderProgram::loadFail; + if (oneReadCorrectly) + { + if (bestLimits < currentLimits) + { + /* The best found program is worse than the current limits, so pretend + that the shader program failed (instead just being 'invalid') - + that will make xmlshader try to load the program from scratch, + ie with current limits, which may just work. */ + allReasons += "Provoking clean load with current limits"; + ret = iShaderProgram::loadFail; + } + else + ret = iShaderProgram::loadSuccessShaderInvalid; + } + else + ret = iShaderProgram::loadFail; + if (failReason) + failReason->AttachNew (new scfString (allReasons)); + return ret; } bool csShaderGLCGCommon::LoadProgramWithPS1 () Modified: CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.h =================================================================== --- CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.h 2009-12-31 17:31:39 UTC (rev 33456) +++ CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgcommon.h 2009-12-31 18:52:37 UTC (rev 33457) @@ -234,9 +234,14 @@ const csSet<csString>& GetUnusedParameters () { return unusedParams; } + iShaderProgram::CacheLoadResult LoadFromCache ( + iHierarchicalCache* cache, iBase* previous, iDocumentNode* programNode, + csRef<iString>* failReason = 0, csRef<iString>* tag = 0, + ProfileLimitsPair* cacheLimits = 0); virtual iShaderProgram::CacheLoadResult LoadFromCache ( iHierarchicalCache* cache, iBase* previous, iDocumentNode* programNode, - csRef<iString>* failReason = 0, csRef<iString>* = 0); + csRef<iString>* failReason = 0, csRef<iString>* tag = 0) + { return LoadFromCache (cache, previous, programNode, failReason, tag, 0); } }; } Modified: CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgfp.h =================================================================== --- CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgfp.h 2009-12-31 17:31:39 UTC (rev 33456) +++ CS/trunk/plugins/video/render3d/shader/shaderplugins/glshader_cg/glshader_cgfp.h 2009-12-31 18:52:37 UTC (rev 33457) @@ -82,9 +82,13 @@ csShaderGLCGCommon::GetUsedShaderVars (bits); } - /*iShaderProgram::CacheLoadResult LoadFromCache ( + iShaderProgram::CacheLoadResult LoadFromCache ( iHierarchicalCache* cache, iBase* previous, iDocumentNode* programNode, - csRef<iString>* failReason = 0, csRef<iString>* = 0);*/ + csRef<iString>* failReason = 0, csRef<iString>* tag = 0) + { + return csShaderGLCGCommon::LoadFromCache (cache, previous, programNode, + failReason, tag, &cacheLimits); + } }; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |