internal void ForEachFragment(EffectCodeGenerator generator, Action <EffectCodeGenerator, StitchedFragmentSymbol, string> action) { foreach (StitchedFragmentSymbol stitchedFragmentNode in Fragments) { action(generator, stitchedFragmentNode, string.Format("{0}_{1}", Technique.Name, Name)); } }
private static bool AttemptEffectCompilation( ContentProcessorContext context, StitchedEffectContent input, StitchedEffectSymbol stitchedEffect, ShaderProfile shaderProfile, out CompiledEffectContent compiledEffect) { // Generate effect code. StringWriter writer = new StringWriter(); EffectCodeGenerator codeGenerator = new EffectCodeGenerator(stitchedEffect, shaderProfile, writer); codeGenerator.GenerateCode(); string effectCode = writer.ToString(); // Save effect code so that if there are errors, we'll be able to view the generated .fx file. string tempEffectFile = GetTempEffectFileName(input); File.WriteAllText(tempEffectFile, effectCode, Encoding.GetEncoding(1252)); // Process effect code. EffectProcessor effectProcessor = new EffectProcessor { DebugMode = EffectProcessorDebugMode.Auto, Defines = null }; EffectContent effectContent = new EffectContent { EffectCode = effectCode, Identity = new ContentIdentity(tempEffectFile), Name = input.Name }; try { compiledEffect = effectProcessor.Process(effectContent, context); // This is only needed if the compilation was successful - if it failed, // a more specific error message (with link to the generated file) // will be shown to the user. context.Logger.LogImportantMessage(string.Format("{0} : Stitched effect generated (double-click this message to view).", tempEffectFile)); return(true); } catch (InvalidContentException ex) { if (ErrorIndicatesNeedForShaderModel3(ex.Message)) { compiledEffect = null; return(false); } throw; } }