本文整理汇总了C#中ShaderMacro.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# ShaderMacro.GetString方法的具体用法?C# ShaderMacro.GetString怎么用?C# ShaderMacro.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShaderMacro
的用法示例。
在下文中一共展示了ShaderMacro.GetString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compile
internal static byte[] Compile(string source, ShaderMacro[] macros, MyShadersDefines.Profiles profile, string sourceDescriptor, bool invalidateCache)
{
bool wasCached;
string compileLog;
var result = Compile(source, macros, profile, sourceDescriptor, !MyRender11.DebugMode, invalidateCache, out wasCached, out compileLog);
if (!wasCached)
{
string message = "WARNING: Shader was not precompiled - " + sourceDescriptor + " @ profile " + profile + " with defines " + macros.GetString();
MyRender11.Log.WriteLine(message);
}
if (!string.IsNullOrEmpty(compileLog))
{
string descriptor = sourceDescriptor + " " + MyShadersDefines.ProfileToString(profile) + " " + macros.GetString();
if (result != null)
{
Debug.WriteLine(String.Format("Compilation of shader {0} notes:\n{1}", descriptor, compileLog));
}
else
{
string message = String.Format("Compilation of shader {0} errors:\n{1}", descriptor, compileLog);
MyRender11.Log.WriteLine(message);
Debug.WriteLine(message);
Debugger.Break();
}
}
return result;
}
示例2: Compile
internal static byte[] Compile(string filepath, ShaderMacro[] macros, MyShaderProfile profile, string sourceDescriptor, bool optimize, bool invalidateCache, out bool wasCached, out string compileLog)
{
ProfilerShort.Begin("MyShaders.Compile");
var globalMacros = GlobalShaderMacros;
if (globalMacros.Length != 0)
{
var macroList = new List<ShaderMacro>();
macroList.AddRange(globalMacros);
macroList.AddRange(macros);
macros = macroList.ToArray();
}
string function = ProfileEntryPoint(profile);
string profileName = ProfileToString(profile);
wasCached = false;
compileLog = null;
ProfilerShort.Begin("MyShaders.Preprocess");
string errors;
string preprocessedSource = PreprocessShader(filepath, macros, out errors);
if (preprocessedSource == null)
{
compileLog = errors;
return null;
}
// modify preprocessor to be readable for NSight
if (MyCompilationSymbols.EnableShaderDebuggingInNSight)
{
preprocessedSource = Regex.Replace(preprocessedSource, "#line [^\n]*\n", "");
}
MyShaderIdentity identity = null;
if (!invalidateCache && !MyCompilationSymbols.EnableShaderDebuggingInNSight)
{
identity = MyShaderCache.ComputeShaderIdentity(preprocessedSource, profile);
byte[] cached;
if (MyShaderCache.TryFetch(identity, out cached))
{
wasCached = true;
ProfilerShort.End();
ProfilerShort.End();
return cached;
}
}
ProfilerShort.End();
try
{
string descriptor = sourceDescriptor + " " + profile + " " + macros.GetString();
CompilationResult compilationResult;
if (MyCompilationSymbols.EnableShaderDebuggingInNSight)
{
if (MyCompilationSymbols.EnableShaderPreprocessorInNSight)
compilationResult = ShaderBytecode.Compile(preprocessedSource, function, profileName, 0, 0, macros, new MyIncludeProcessor(filepath));
else
{
compilationResult = ShaderBytecode.CompileFromFile(filepath, function, profileName, 0, 0, macros, new MyIncludeProcessor(filepath));
}
}
else
compilationResult = ShaderBytecode.Compile(preprocessedSource, function, profileName,
optimize ? ShaderFlags.OptimizationLevel3 : ShaderFlags.None,
EffectFlags.None, filepath);
if (DUMP_CODE)
{
var disassembly = compilationResult.Bytecode.Disassemble(DisassemblyFlags.EnableColorCode |
DisassemblyFlags.EnableInstructionNumbering);
string asmPath;
if (MyRender11.DebugMode)
{
asmPath = Path.GetFileName(descriptor + "__DEBUG.html");
}
else
{
asmPath = Path.GetFileName(descriptor + "__O3.html");
}
using (var writer = new StreamWriter(Path.Combine(MyFileSystem.ContentPath, "ShaderOutput", asmPath)))
{
writer.Write(disassembly);
}
}
if (compilationResult.Message != null)
compileLog = compilationResult.Message;
if (!MyCompilationSymbols.EnableShaderDebuggingInNSight && compilationResult.Bytecode != null
&& compilationResult.Bytecode.Data.Length > 0)
MyShaderCache.Store(identity, compilationResult.Bytecode.Data);
return compilationResult.Bytecode != null ? compilationResult.Bytecode.Data : null;
}
catch (Exception e)
{
Debug.WriteLine(preprocessedSource);
compileLog = e.Message;
//.........这里部分代码省略.........