port from perforce
This commit is contained in:
6
8kode/src/shc/App.config
Normal file
6
8kode/src/shc/App.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
593
8kode/src/shc/Program.cs
Normal file
593
8kode/src/shc/Program.cs
Normal file
@@ -0,0 +1,593 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace shc
|
||||
{
|
||||
class Program
|
||||
{
|
||||
struct EntryPoint
|
||||
{
|
||||
public string TypeName { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public string[] Parameters { get; set; }
|
||||
}
|
||||
|
||||
struct ShaderInfo
|
||||
{
|
||||
public ShaderInfo(string pointerType, string prefix, string createFunction)
|
||||
: this()
|
||||
{
|
||||
PointerType = pointerType;
|
||||
Prefix = prefix;
|
||||
CreateFunction = createFunction;
|
||||
}
|
||||
|
||||
public string PointerType { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public string CreateFunction { get; set; }
|
||||
}
|
||||
|
||||
static int Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("shc " + string.Join(" ", args.Select(arg => "\"" + arg + "\"")));
|
||||
|
||||
if (args.Length != 4)
|
||||
{
|
||||
Console.WriteLine("Usage: shc $(HlslInputPath) $(MinifiedHeaderPath) $(ShaderHeaderPath) $(MergedHlslOutputPath) ");
|
||||
return -1;
|
||||
}
|
||||
|
||||
var path = Path.GetFullPath(args[0]);
|
||||
if (!File.Exists(args[0]))
|
||||
{
|
||||
Console.WriteLine("ERROR: " + args[0] + " does not exist!");
|
||||
return -2;
|
||||
}
|
||||
|
||||
var resultLines = new List<string>();
|
||||
var entryPoints = new List<EntryPoint>();
|
||||
string mergedPath = args[3];
|
||||
try
|
||||
{
|
||||
var lines = GetCombinedLinesFromIncludes(path, resultLines, entryPoints);
|
||||
lines.Add(string.Empty);
|
||||
File.WriteAllText(mergedPath, string.Join("\n", lines));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("ERROR: While loading " + path + ": " + e.Message);
|
||||
return -3;
|
||||
}
|
||||
|
||||
var outputPath = Path.GetFullPath(args[1]);
|
||||
if (File.Exists(outputPath))
|
||||
{
|
||||
File.Delete(outputPath);
|
||||
}
|
||||
|
||||
var toolsLocation = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "..\\tools");
|
||||
try
|
||||
{
|
||||
string arguments = "--hlsl -v -o " + outputPath + " ";
|
||||
if (entryPoints.Count > 0)
|
||||
{
|
||||
arguments += "--no-renaming-list " + string.Join(",", entryPoints.Select(kvp => kvp.Name)) + " ";
|
||||
}
|
||||
arguments += mergedPath;
|
||||
|
||||
Process myProcess = new Process();
|
||||
ProcessStartInfo myProcessStartInfo = new ProcessStartInfo(Path.Combine(toolsLocation, "shader_minifier.exe"), arguments);
|
||||
myProcessStartInfo.UseShellExecute = false;
|
||||
myProcessStartInfo.RedirectStandardOutput = true;
|
||||
myProcess.StartInfo = myProcessStartInfo;
|
||||
myProcess.Start();
|
||||
StreamReader myStreamReader = myProcess.StandardOutput;
|
||||
var output = myStreamReader.ReadToEnd();
|
||||
Console.WriteLine(output);
|
||||
myProcess.WaitForExit();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("ERROR: While running shader minifier: " + e.Message);
|
||||
return -4;
|
||||
}
|
||||
|
||||
if (!File.Exists(outputPath))
|
||||
{
|
||||
return -5;
|
||||
}
|
||||
|
||||
var outputLines = File.ReadAllLines(outputPath).ToArray();
|
||||
for (int i = 0; i < outputLines.Length; ++i)
|
||||
{
|
||||
if (outputLines[i].Trim() == "char merged_hlsl[] =")
|
||||
{
|
||||
outputLines[i] = "char merged_hlsl[] = \"#define _ [numthreads(16,16,1)]\\n\"";
|
||||
}
|
||||
else if (outputLines[i].Trim() == "\"[numthreads(16,16,1)]\"")
|
||||
{
|
||||
outputLines[i] = " \"_ \"";
|
||||
}
|
||||
}
|
||||
File.WriteAllLines(outputPath, outputLines);
|
||||
|
||||
try
|
||||
{
|
||||
var headerPath = Path.GetFullPath(args[2]);
|
||||
using (var stream = new FileStream(headerPath, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
using (var writer = new StreamWriter(stream))
|
||||
{
|
||||
if (entryPoints.Count > 0)
|
||||
{
|
||||
writer.WriteLine("#pragma once");
|
||||
writer.WriteLine("// WARNING: This file is autogenerated by shc. Do not edit");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\".cs_5_0\")");
|
||||
writer.WriteLine("static char cs_5_0[] = \"cs_5_0\";");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\".vs_5_0\")");
|
||||
writer.WriteLine("static char vs_5_0[] = \"vs_5_0\";");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\".gs_5_0\")");
|
||||
writer.WriteLine("static char gs_5_0[] = \"gs_5_0\";");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\".ds_5_0\")");
|
||||
writer.WriteLine("static char ds_5_0[] = \"ds_5_0\";");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\".hs_5_0\")");
|
||||
writer.WriteLine("static char hs_5_0[] = \"hs_5_0\";");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\".ps_5_0\")");
|
||||
writer.WriteLine("static char ps_5_0[] = \"ps_5_0\";");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma bss_seg(\".shaderbss\")");
|
||||
foreach (var entryPoint in entryPoints)
|
||||
{
|
||||
if (entryPoint.TypeName == "hc")
|
||||
continue;
|
||||
|
||||
foreach (var shaderInfo in GetShaderInfo(entryPoint.TypeName))
|
||||
{
|
||||
writer.WriteLine("static " + shaderInfo.PointerType + "* " + shaderInfo.Prefix + entryPoint.Name + ";");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var entryPoint in entryPoints)
|
||||
{
|
||||
if (entryPoint.TypeName == "hc")
|
||||
continue;
|
||||
|
||||
if (entryPoint.TypeName == "gs_so" || entryPoint.TypeName == "vs_gs_so")
|
||||
{
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\"." + entryPoint.Name + "SODeclarations\")");
|
||||
writer.WriteLine("extern D3D11_SO_DECLARATION_ENTRY " + entryPoint.Name + "SODeclarations[" + entryPoint.Parameters[0] + "];");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\"." + entryPoint.Name + "Strides\")");
|
||||
writer.WriteLine("extern UINT " + entryPoint.Name + "Strides[" + entryPoint.Parameters[1] + "];");
|
||||
}
|
||||
|
||||
if (entryPoint.TypeName == "vs_il")
|
||||
{
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma data_seg(\"." + entryPoint.Name + "InputLayoutDesc\")");
|
||||
writer.WriteLine("extern D3D11_INPUT_ELEMENT_DESC " + entryPoint.Name + "InputLayoutDesc[" + entryPoint.Parameters[0] + "];");
|
||||
}
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma code_seg(\".FrameworkShadersCompile\")");
|
||||
writer.WriteLine("INLINE void FrameworkShadersCompile()");
|
||||
writer.WriteLine("{");
|
||||
foreach (var entryPoint in entryPoints)
|
||||
{
|
||||
if (entryPoint.TypeName == "hc")
|
||||
continue;
|
||||
|
||||
writer.WriteLine("\tCompileShader(\"" + entryPoint.Name + "\", " + entryPoint.Prefix + "_5_0);");
|
||||
foreach (var shaderInfo in GetShaderInfo(entryPoint.TypeName))
|
||||
{
|
||||
if (shaderInfo.CreateFunction == "CreateGeometryShaderWithStreamOutput")
|
||||
{
|
||||
var parameters = string.Join(", ", entryPoint.Parameters);
|
||||
writer.WriteLine("\tdevice->CreateGeometryShaderWithStreamOutput(shaderCode, shaderSize, " + entryPoint.Name + "SODeclarations, " + entryPoint.Parameters[0] + ", " + entryPoint.Name + "Strides, " + entryPoint.Parameters[1] + ", D3D11_SO_NO_RASTERIZED_STREAM, NULL, &" + shaderInfo.Prefix + entryPoint.Name + ");");
|
||||
}
|
||||
else if (shaderInfo.CreateFunction == "CreateInputLayout")
|
||||
{
|
||||
var parameters = string.Join(", ", entryPoint.Parameters);
|
||||
writer.WriteLine("\tdevice->CreateInputLayout(" + entryPoint.Name + "InputLayoutDesc, " + entryPoint.Parameters[0] + ", shaderCode, shaderSize, &" + shaderInfo.Prefix + entryPoint.Name + ");");
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine("\tdevice->" + shaderInfo.CreateFunction + "(shaderCode, shaderSize, NULL, &" + shaderInfo.Prefix + entryPoint.Name + ");");
|
||||
}
|
||||
}
|
||||
}
|
||||
writer.WriteLine("}");
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
int iSize = 0;
|
||||
foreach (var line in s_SyncStructLines)
|
||||
{
|
||||
var tokens = line.Split(' ', '\t', ';').Select(t => t.Trim()).Where(t => !string.IsNullOrEmpty(t)).ToList();
|
||||
if (tokens[0] == "struct")
|
||||
{
|
||||
s_SyncStructName = tokens[1];
|
||||
writer.WriteLine(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
int typeIndex = Math.Max(Math.Max(Math.Max(tokens.IndexOf("float"), tokens.IndexOf("float2")), tokens.IndexOf("float3")), tokens.IndexOf("float4"));
|
||||
if (typeIndex != -1)
|
||||
{
|
||||
switch (tokens[typeIndex])
|
||||
{
|
||||
case "float":
|
||||
{
|
||||
RecordSyncVariable(1, tokens[typeIndex + 1]);
|
||||
iSize += 4;
|
||||
break;
|
||||
}
|
||||
case "float2":
|
||||
{
|
||||
RecordSyncVariable(2, tokens[typeIndex + 1]);
|
||||
iSize += 8;
|
||||
break;
|
||||
}
|
||||
case "float3":
|
||||
{
|
||||
RecordSyncVariable(3, tokens[typeIndex + 1]);
|
||||
iSize += 12;
|
||||
break;
|
||||
}
|
||||
case "float4":
|
||||
{
|
||||
RecordSyncVariable(4, tokens[typeIndex + 1]);
|
||||
iSize += 16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (line.Trim()[0] == '}')
|
||||
{
|
||||
if (iSize % 16 != 0)
|
||||
iSize += 16 - (iSize % 16);
|
||||
|
||||
foreach (var syncVar in s_SyncVariables)
|
||||
{
|
||||
switch (syncVar.Item1)
|
||||
{
|
||||
case 1:
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + ";");
|
||||
iSize -= 4;
|
||||
break;
|
||||
case 2:
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_x;");
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_y;");
|
||||
iSize -= 8;
|
||||
break;
|
||||
case 3:
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_x;");
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_y;");
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_z;");
|
||||
iSize -= 12;
|
||||
break;
|
||||
case 4:
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_x;");
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_y;");
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_z;");
|
||||
writer.WriteLine("\tfloat " + syncVar.Item2 + "_w;");
|
||||
iSize -= 16;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int iDummyIndex = 1;
|
||||
|
||||
while (iSize > 0)
|
||||
{
|
||||
writer.WriteLine("\tfloat dummy_" + iDummyIndex++ + ";");
|
||||
iSize -= 4;
|
||||
}
|
||||
writer.WriteLine(line);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_SyncStructLines.Count > 0)
|
||||
{
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#define SYNC_TYPE_NAME " + s_SyncStructName);
|
||||
writer.WriteLine("#define SYNC_VAR_NAME s_" + s_SyncStructName);
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma bss_seg(\".syncbss\")");
|
||||
writer.WriteLine("static SYNC_TYPE_NAME SYNC_VAR_NAME;");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#pragma code_seg(\".SyncInit\")");
|
||||
writer.WriteLine("INLINE void SyncInit()");
|
||||
writer.WriteLine("{");
|
||||
writer.WriteLine("\tif (usync_init() < 0)");
|
||||
writer.WriteLine("\t\treturn;");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#ifndef SYNC_PLAYER");
|
||||
foreach (var syncVar in s_SyncVariables)
|
||||
{
|
||||
if (syncVar.Item2.StartsWith("dummy"))
|
||||
continue;
|
||||
|
||||
switch (syncVar.Item1)
|
||||
{
|
||||
case 1:
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + ");");
|
||||
break;
|
||||
case 2:
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_x);");
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_y);");
|
||||
break;
|
||||
case 3:
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_x);");
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_y);");
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_z);");
|
||||
break;
|
||||
case 4:
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_x);");
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_y);");
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_z);");
|
||||
writer.WriteLine("\tusync_get_val(" + syncVar.Item2 + "_w);");
|
||||
break;
|
||||
}
|
||||
}
|
||||
writer.WriteLine("\tusync_update(0.0f, NULL);");
|
||||
writer.WriteLine("#endif");
|
||||
writer.WriteLine("}");
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("INLINE void SyncUpdate(float t)");
|
||||
writer.WriteLine("{");
|
||||
writer.WriteLine("#ifndef SYNC_PLAYER");
|
||||
writer.WriteLine("\tusync_update(t * SYNC_ROWS_PER_SCENE, NULL);");
|
||||
foreach (var syncVar in s_SyncVariables)
|
||||
{
|
||||
if (syncVar.Item2.StartsWith("dummy"))
|
||||
continue;
|
||||
|
||||
switch (syncVar.Item1)
|
||||
{
|
||||
case 1:
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + " = usync_get_val(" + syncVar.Item2 + ");");
|
||||
break;
|
||||
case 2:
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_x = usync_get_val(" + syncVar.Item2 + "_x);");
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_y = usync_get_val(" + syncVar.Item2 + "_y);");
|
||||
break;
|
||||
case 3:
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_x = usync_get_val(" + syncVar.Item2 + "_x);");
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_y = usync_get_val(" + syncVar.Item2 + "_y);");
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_z = usync_get_val(" + syncVar.Item2 + "_z);");
|
||||
break;
|
||||
case 4:
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_x = usync_get_val(" + syncVar.Item2 + "_x);");
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_y = usync_get_val(" + syncVar.Item2 + "_y);");
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_z = usync_get_val(" + syncVar.Item2 + "_z);");
|
||||
writer.WriteLine("\tSYNC_VAR_NAME." + syncVar.Item2 + "_w = usync_get_val(" + syncVar.Item2 + "_w);");
|
||||
break;
|
||||
}
|
||||
}
|
||||
writer.WriteLine("#else");
|
||||
writer.WriteLine("\tusync_update(t * SYNC_ROWS_PER_SCENE, (float*)&SYNC_VAR_NAME);");
|
||||
writer.WriteLine("#endif");
|
||||
writer.WriteLine("}");
|
||||
writer.WriteLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteLine();
|
||||
writer.WriteLine("#define SyncInit()");
|
||||
writer.WriteLine("#define SyncUpdate(t)");
|
||||
}
|
||||
writer.Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("ERROR: While generating shc output: " + e.Message);
|
||||
return -6;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void RecordSyncVariable(int _iSize, string _sSyncVarName)
|
||||
{
|
||||
s_SyncVariables.Add(new Tuple<int, string>(_iSize, _sSyncVarName));
|
||||
}
|
||||
|
||||
private static IEnumerable<ShaderInfo> GetShaderInfo(string p)
|
||||
{
|
||||
if (p == "cs")
|
||||
yield return new ShaderInfo("ID3D11ComputeShader", "", "CreateComputeShader");
|
||||
else if (p == "vs")
|
||||
yield return new ShaderInfo("ID3D11VertexShader", "", "CreateVertexShader");
|
||||
else if (p == "vs_il")
|
||||
{
|
||||
yield return new ShaderInfo("ID3D11VertexShader", "vs_", "CreateVertexShader");
|
||||
yield return new ShaderInfo("ID3D11InputLayout", "il_", "CreateInputLayout");
|
||||
}
|
||||
else if (p == "ds")
|
||||
yield return new ShaderInfo("ID3D11DomainShader", "", "CreateDomainShader");
|
||||
else if (p == "hs")
|
||||
yield return new ShaderInfo("ID3D11HullShader", "", "CreateHullShader");
|
||||
else if (p == "gs")
|
||||
yield return new ShaderInfo("ID3D11GeometryShader", "", "CreateGeometryShader");
|
||||
else if (p == "ps")
|
||||
yield return new ShaderInfo("ID3D11PixelShader", "", "CreatePixelShader");
|
||||
else if (p == "gs_so")
|
||||
yield return new ShaderInfo("ID3D11GeometryShader", "", "CreateGeometryShaderWithStreamOutput");
|
||||
else if (p == "vs_gs_so")
|
||||
{
|
||||
yield return new ShaderInfo("ID3D11VertexShader", "vs_", "CreateVertexShader");
|
||||
yield return new ShaderInfo("ID3D11GeometryShader", "gs_", "CreateGeometryShaderWithStreamOutput");
|
||||
}
|
||||
}
|
||||
|
||||
private static List<string> GetCombinedLinesFromIncludes(string path, List<string> resultLines, List<EntryPoint> entryPoints)
|
||||
{
|
||||
var loadedPaths = new List<string>();
|
||||
AggregateLines(path, resultLines, entryPoints, loadedPaths);
|
||||
return resultLines;
|
||||
}
|
||||
|
||||
private static void AggregateLines(string path, List<string> resultLines, List<EntryPoint> entryPoints, List<string> loadedPaths)
|
||||
{
|
||||
if (loadedPaths.Contains(path))
|
||||
return;
|
||||
|
||||
loadedPaths.Add(path);
|
||||
var basePath = Path.GetDirectoryName(path);
|
||||
var lines = File.ReadAllLines(path);
|
||||
string sEntryPointType = null;
|
||||
string[] entryPointParameters = null;
|
||||
int lineNumber = 1;
|
||||
var enumerator = lines.GetEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
var line = (string)enumerator.Current;
|
||||
if (line.StartsWith("#include"))
|
||||
{
|
||||
var includeFile = line.Substring(8).Trim().Split('"')[1];
|
||||
var includePath = Path.GetFullPath(Path.Combine(basePath, includeFile));
|
||||
AggregateLines(includePath, resultLines, entryPoints, loadedPaths);
|
||||
}
|
||||
else if (line.Trim().StartsWith("[entrypoint"))
|
||||
{
|
||||
sEntryPointType = line.Trim().Substring(11).Trim();
|
||||
if (sEntryPointType.StartsWith("("))
|
||||
{
|
||||
entryPointParameters = sEntryPointType.Substring(1, sEntryPointType.Length - 2).Trim().Split(',', ')').Skip(1).ToArray();
|
||||
entryPointParameters = entryPointParameters.Take(entryPointParameters.Length - 1).Select(p => p.Trim()).ToArray();
|
||||
sEntryPointType = sEntryPointType.Substring(1).Split(',', ')')[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
sEntryPointType = "unknown";
|
||||
}
|
||||
|
||||
if (sEntryPointType == "vs_gs_so" || sEntryPointType == "gs_so")
|
||||
{
|
||||
if (entryPointParameters.Length != 2)
|
||||
{
|
||||
throw new Exception("An entry point of type " + sEntryPointType + " needs 2 parameters: (StreamOutputDeclaration count, Stride count)");
|
||||
}
|
||||
}
|
||||
else if (sEntryPointType == "vs_il")
|
||||
{
|
||||
if (entryPointParameters.Length != 1)
|
||||
{
|
||||
throw new Exception("An entry point of type " + sEntryPointType + " needs 1 parameter: (InputElementDesc count)");
|
||||
}
|
||||
}
|
||||
else if (entryPointParameters != null && entryPointParameters.Length != 0)
|
||||
{
|
||||
throw new Exception("An entry point of type " + sEntryPointType + " needs no parameters");
|
||||
}
|
||||
|
||||
resultLines.Add(GetComment(path, lineNumber));
|
||||
}
|
||||
else if (line.Trim().StartsWith("[patchconstantfunc"))
|
||||
{
|
||||
var sEntryPointName = line.Trim().Substring(18).Trim();
|
||||
if (sEntryPointName.StartsWith("("))
|
||||
{
|
||||
sEntryPointName = sEntryPointName.Substring(2).Split('\"', ')')[0];
|
||||
}
|
||||
entryPoints.Add(new EntryPoint() { TypeName = "hc", Name = sEntryPointName });
|
||||
resultLines.Add(line + GetComment(path, lineNumber));
|
||||
}
|
||||
else if (line.Trim() == "[syncstruct]")
|
||||
{
|
||||
int iBracketCount = 0;
|
||||
bool bStructStarted = false;
|
||||
bool bStructFound = false;
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
line = (string)enumerator.Current;
|
||||
if (line.Contains('{'))
|
||||
{
|
||||
++iBracketCount;
|
||||
bStructStarted = true;
|
||||
}
|
||||
if (line.Contains('}'))
|
||||
{
|
||||
--iBracketCount;
|
||||
}
|
||||
|
||||
resultLines.Add(line + GetComment(path, lineNumber));
|
||||
s_SyncStructLines.Add(line);
|
||||
++lineNumber;
|
||||
|
||||
if (bStructStarted && iBracketCount == 0)
|
||||
{
|
||||
bStructFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bStructFound)
|
||||
{
|
||||
throw new Exception("[syncstruct] may only be used before a struct");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sEntryPointType != null)
|
||||
{
|
||||
var tempLine = line.Trim();
|
||||
while (tempLine.StartsWith("["))
|
||||
{
|
||||
var idx = tempLine.IndexOf("]");
|
||||
tempLine = tempLine.Substring(idx + 1).Trim();
|
||||
}
|
||||
var functionName = tempLine.Split(' ')[1].Split('(')[0];
|
||||
entryPoints.Add(new EntryPoint() { TypeName = sEntryPointType.ToLower(), Name = functionName, Prefix = sEntryPointType.ToLower().Substring(0, 2), Parameters = entryPointParameters });
|
||||
sEntryPointType = null;
|
||||
}
|
||||
|
||||
var resultLine = line;
|
||||
var commentIndex = line.IndexOf("//");
|
||||
if (commentIndex != -1)
|
||||
resultLine = resultLine.Substring(0, commentIndex);
|
||||
|
||||
if (line.StartsWith("#"))
|
||||
{
|
||||
resultLines.Add(resultLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
resultLines.Add(resultLine + GetComment(path, lineNumber));
|
||||
}
|
||||
}
|
||||
|
||||
++lineNumber;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetComment(string path, int lineNumber)
|
||||
{
|
||||
return " /*(" + path + "|" + lineNumber + ")*/";
|
||||
}
|
||||
|
||||
private static List<string> s_SyncStructLines = new List<string>();
|
||||
private static List<Tuple<int, string>> s_SyncVariables = new List<Tuple<int, string>>();
|
||||
private static string s_SyncStructName;
|
||||
}
|
||||
}
|
||||
36
8kode/src/shc/Properties/AssemblyInfo.cs
Normal file
36
8kode/src/shc/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("shc")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("shc")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("8e619b64-e97a-4b10-8e79-96582ebfe084")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
6
8kode/src/shc/bin/Debug/shc.exe.config
Normal file
6
8kode/src/shc/bin/Debug/shc.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
6
8kode/src/shc/bin/Debug/shc.vshost.exe.config
Normal file
6
8kode/src/shc/bin/Debug/shc.vshost.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
BIN
8kode/src/shc/bin/Release/shc.exe
Normal file
BIN
8kode/src/shc/bin/Release/shc.exe
Normal file
Binary file not shown.
6
8kode/src/shc/bin/Release/shc.exe.config
Normal file
6
8kode/src/shc/bin/Release/shc.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
BIN
8kode/src/shc/bin/Release/shc.pdb
Normal file
BIN
8kode/src/shc/bin/Release/shc.pdb
Normal file
Binary file not shown.
BIN
8kode/src/shc/bin/Release/shc.vshost.exe
Normal file
BIN
8kode/src/shc/bin/Release/shc.vshost.exe
Normal file
Binary file not shown.
6
8kode/src/shc/bin/Release/shc.vshost.exe.config
Normal file
6
8kode/src/shc/bin/Release/shc.vshost.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
11
8kode/src/shc/bin/Release/shc.vshost.exe.manifest
Normal file
11
8kode/src/shc/bin/Release/shc.vshost.exe.manifest
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
6
8kode/src/shc/bin/shc.exe.config
Normal file
6
8kode/src/shc/bin/shc.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
6
8kode/src/shc/bin/shc.vshost.exe.config
Normal file
6
8kode/src/shc/bin/shc.vshost.exe.config
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
||||
Binary file not shown.
18
8kode/src/shc/obj/Debug/shc.csproj.FileListAbsolute.txt
Normal file
18
8kode/src/shc/obj/Debug/shc.csproj.FileListAbsolute.txt
Normal file
@@ -0,0 +1,18 @@
|
||||
E:\blu-flame.org\hgplus\author\src\shc\bin\Debug\shc.exe.config
|
||||
E:\blu-flame.org\hgplus\author\src\shc\bin\shc.exe.config
|
||||
E:\blu-flame.org\hgplus\author\bin\shc.exe.config
|
||||
E:\blu-flame.org\hgplus\author\bin\shc.exe
|
||||
E:\blu-flame.org\hgplus\author\bin\shc.pdb
|
||||
E:\blu-flame.org\hgplus\author\src\shc\obj\Debug\shc.exe
|
||||
E:\blu-flame.org\hgplus\author\src\shc\obj\Debug\shc.pdb
|
||||
E:\blu-flame.org\hgplus\author\src\shc\obj\Debug\shc.csprojResolveAssemblyReference.cache
|
||||
E:\alcatraz\8kode\bin\shc.exe.config
|
||||
E:\alcatraz\8kode\bin\shc.exe
|
||||
E:\alcatraz\8kode\bin\shc.pdb
|
||||
E:\alcatraz\8kode\src\shc\obj\Debug\shc.exe
|
||||
E:\alcatraz\8kode\src\shc\obj\Debug\shc.pdb
|
||||
E:\blu-flame.org\8kode\bin\shc.exe.config
|
||||
E:\blu-flame.org\8kode\bin\shc.exe
|
||||
E:\blu-flame.org\8kode\bin\shc.pdb
|
||||
E:\blu-flame.org\8kode\src\shc\obj\Debug\shc.exe
|
||||
E:\blu-flame.org\8kode\src\shc\obj\Debug\shc.pdb
|
||||
BIN
8kode/src/shc/obj/Debug/shc.exe
Normal file
BIN
8kode/src/shc/obj/Debug/shc.exe
Normal file
Binary file not shown.
BIN
8kode/src/shc/obj/Debug/shc.pdb
Normal file
BIN
8kode/src/shc/obj/Debug/shc.pdb
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,6 @@
|
||||
E:\blu-flame.org\hgplus\author\src\shc\bin\Release\shc.exe.config
|
||||
E:\blu-flame.org\hgplus\author\src\shc\bin\Release\shc.exe
|
||||
E:\blu-flame.org\hgplus\author\src\shc\bin\Release\shc.pdb
|
||||
E:\blu-flame.org\hgplus\author\src\shc\obj\Release\shc.csprojResolveAssemblyReference.cache
|
||||
E:\blu-flame.org\hgplus\author\src\shc\obj\Release\shc.exe
|
||||
E:\blu-flame.org\hgplus\author\src\shc\obj\Release\shc.pdb
|
||||
Binary file not shown.
BIN
8kode/src/shc/obj/Release/shc.exe
Normal file
BIN
8kode/src/shc/obj/Release/shc.exe
Normal file
Binary file not shown.
BIN
8kode/src/shc/obj/Release/shc.pdb
Normal file
BIN
8kode/src/shc/obj/Release/shc.pdb
Normal file
Binary file not shown.
50
8kode/src/shc/shc.csproj
Normal file
50
8kode/src/shc/shc.csproj
Normal file
@@ -0,0 +1,50 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{930621BA-75BE-49FE-80DE-E75E7DC06931}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>shc</RootNamespace>
|
||||
<AssemblyName>shc</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
7
8kode/src/shc/shc.csproj.user
Normal file
7
8kode/src/shc/shc.csproj.user
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<StartArguments>shaders\intro.hlsl framework\intro_hlsl.h framework\shaders_shc.h framework\merged.hlsl</StartArguments>
|
||||
<StartWorkingDirectory>E:\alcatraz\revision15-8k\src\intro</StartWorkingDirectory>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user