void IShaderCompiler.Compile(string text, string function, ref ShaderHandle result) { if(!result.IsValid || result.Reference != this) { Compile(text, function, out result); } }
public PixelShader Resolve(ShaderHandle shader) { if(shader.IsValid && shader.Reference == this) { return _Shaders[shader.Index]; } return null; }
private void Compile(string text, string function, out ShaderHandle result) { Contract.Requires(!String.IsNullOrEmpty(text)); Contract.Requires(!String.IsNullOrEmpty(function)); const ShaderFlags flags = ShaderFlags.OptimizationLevel3; text = text.Insert(0, PredefinedConstants.ShaderText); using(var byteCode = ShaderBytecode.Compile(text, function, "ps_4_0", flags)) { PixelShader shader = new PixelShader(_Device3D, byteCode); try { _Shaders.Add(shader); } catch { shader.Dispose(); throw; } _CachedShaderCount.Value = _Shaders.Count; } result = new ShaderHandle(_Shaders.Count - 1, this); }
public void Compile(string text, string function, ref ShaderHandle result) { Contract.Requires(!string.IsNullOrEmpty(text)); Contract.Requires(!string.IsNullOrEmpty(function)); }