private void HandleConfigDefinesChangeOnStartup(IDiffSpread <string> spread) { if (FConfigShader[0] != "" && !configWritten) { DX11ShaderInclude FIncludeHandler = new DX11ShaderInclude(); List <ShaderMacro> sms = new List <ShaderMacro>(); if (FConfigDefines[0] != "") { string[] defines = FConfigDefines[0].Split(",".ToCharArray()); for (int i = 0; i < defines.Length; i++) { try { string[] s = defines[i].Split("=".ToCharArray()); if (s.Length == 2) { ShaderMacro sm = new ShaderMacro(); sm.Name = s[0]; sm.Value = s[1]; sms.Add(sm); } } catch { } } } FShader = DX11Effect.FromString(FConfigShader[0], FIncludeHandler, sms.ToArray()); this.SetShader(FShader, !ShaderCreatedByConfig); ShaderCreatedByConfig = true; } }
public AbstractDX11ShaderFactory(CompositionContainer parentContainer, string exts) : base(exts) { FProjects = new Dictionary <string, FXProject>(); FProjectNodeInfo = new Dictionary <FXProject, INodeInfo>(); FIncludeHandler = new DX11ShaderInclude(); FParentContainer = parentContainer; }
private void HandleConfigShaderChangeOnStartup(IDiffSpread <string> spread) { if (FConfigShader[0] != "" && !configWritten) { DX11ShaderInclude FIncludeHandler = new DX11ShaderInclude(); List <ShaderMacro> sms = new List <ShaderMacro>(); FShader = DX11Effect.FromString(FConfigShader[0], FIncludeHandler, sms.ToArray()); this.SetShader(FShader, true); ShaderCreatedByConfig = true; } }
public AbstractDX11ShaderFactory(CompositionContainer parentContainer, string exts) : base(exts) { FProjects = new Dictionary <string, FXProject>(); FProjectNodeInfo = new Dictionary <FXProject, INodeInfo>(); FIncludeHandler = new DX11ShaderInclude(); string arch = Environment.Is64BitProcess ? "x64" : "x86"; string userpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "vvvv\\beta_" + arch); FIncludeHandler.FolderIncludeHandler.AdditionalSystemPath = userpath; FParentContainer = parentContainer; }
public void Evaluate(int SpreadMax) { this.shaderupdated = false; this.spmax = this.CalculateSpreadMax(); if (FShaderCode.IsChanged || FFileName.IsChanged || FInDefines.IsChanged) { List <ShaderMacro> sms = new List <ShaderMacro>(); for (int i = 0; i < this.FInDefines.SliceCount; i++) { try { string[] s = this.FInDefines[i].Split("=".ToCharArray()); if (s.Length == 2) { ShaderMacro sm = new ShaderMacro(); sm.Name = s[0]; sm.Value = s[1]; sms.Add(sm); } } catch { } } DX11ShaderInclude FIncludeHandler = new DX11ShaderInclude(); FIncludeHandler.ParentPath = Path.GetDirectoryName(FFileName[0]); FShader = DX11Effect.FromString(FShaderCode[0], FIncludeHandler, sms.ToArray()); if (init && !ShaderCreatedByConfig) { this.SetShader(FShader, true); init = false; } else { this.SetShader(FShader, false); } // Write Shadercode & Defines into config -> needed to restore dynamic pins if (HasDynamicPins(FShader)) { configWritten = true; if (FConfigShader[0] != FShaderCode[0]) { FConfigShader[0] = FShaderCode[0]; FConfigDefines[0] = ""; for (int i = 0; i < FInDefines.SliceCount; i++) { if (i != 0) { FConfigDefines[0] += ","; } FConfigDefines[0] += this.FInDefines[i]; } } } else { if (FConfigShader[0] != "") { FConfigShader[0] = ""; FConfigDefines[0] = ""; } } } if (FShader.TechniqueNames != null && this.FInTechnique.IsChanged && FInTechnique.SliceCount > 0) { this.techniqueindex = Array.IndexOf(FShader.TechniqueNames, FInTechnique[0].Name); this.techniquechanged = true; } float *src; //Cache world pointer this.FInWorld.GetMatrixPointer(out this.mworldcount, out src); this.mworld = (Matrix *)src; this.FOutLayer.SliceCount = 1; if (this.FOutLayer[0] == null) { this.FOutLayer[0] = new DX11Resource <DX11Layer>(); } if (this.FInvalidate) { if (this.FShader.IsCompiled) { this.FOutCompiled[0] = true; this.FOutTechniqueValid.SliceCount = this.FShader.TechniqueValids.Length; for (int i = 0; i < this.FShader.TechniqueValids.Length; i++) { this.FOutTechniqueValid[i] = this.FShader.TechniqueValids[i]; } } else { this.FOutCompiled[0] = false; this.FOutTechniqueValid.SliceCount = 0; } this.FInvalidate = false; } if (this.FOutQueryable[0] == null) { this.FOutQueryable[0] = this; } }