public bool Release() { if (State != RendererDataState.Compiled) { return(false); } Debug.Assert(_shader is not null); Debug.Assert(_vertexType is not null); var key = new SourceKey(_shader, _vertexType); var screen = Engine.GetValidCurrentContext(); CompiledProgramCacheStore.Delete(screen, key, ref _program); try { _shader.InvokeOnProgramDisposed(); } catch { if (EngineSetting.UserCodeExceptionCatchMode == UserCodeExceptionCatchMode.Throw) { throw; } // ignore exceptions in user code. } Debug.Assert(State != RendererDataState.Compiled); return(true); }
private bool CompileIfNeeded() { var state = State; if (state == RendererDataState.Compiled) { return(false); } Debug.Assert(_shader is not null); Debug.Assert(_vertexType is not null); var key = new SourceKey(_shader, _vertexType); var screen = Engine.GetValidCurrentContext(); _program = CompiledProgramCacheStore.GetCacheOrCompile(screen, key); return(true); }