- Added resource manager

- Shader building now inspects the spir-v for descriptor sets and writes the info to the output binary
This commit is contained in:
2024-07-13 13:45:12 +02:00
parent cce6e00960
commit 92cf24fe9f
28 changed files with 420 additions and 978 deletions
+14 -23
View File
@@ -11,13 +11,12 @@ public class Builder : IDisposable
{
rawFileImporter = new RawFileImporter();
ShaderImporter shaderImporter = new ShaderImporter();
importers.Add(".vert", shaderImporter); // Vertex shader
importers.Add(".frag", shaderImporter); // Fragment shader
importers.Add(".tesc", shaderImporter); // Tessellation control shader
importers.Add(".tese", shaderImporter); // Tessellation evaluation shader
importers.Add(".geom", shaderImporter); // Geometry shader
importers.Add(".comp", shaderImporter); // Compute shader
importers.Add(".vert", new ShaderImporter(ShaderStage.Vertex)); // Vertex shader
importers.Add(".frag", new ShaderImporter(ShaderStage.Fragment)); // Fragment shader
//importers.Add(".tesc", shaderImporter); // Tessellation control shader
//importers.Add(".tese", shaderImporter); // Tessellation evaluation shader
//importers.Add(".geom", shaderImporter); // Geometry shader
//importers.Add(".comp", shaderImporter); // Compute shader
}
public void Run(BuildArgs args)
@@ -25,22 +24,19 @@ public class Builder : IDisposable
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
CopyLibs(args.ProjectPath);
//CopyLibs(args.ResourcePath);
List<string> contentFiles = args.ContentFiles;
string absContentPath = $"{args.ProjectPath}/{PathUtil.ContentFolderName}";
List<string> contentFiles = args.ResourceFiles;
// If no files are provided, build all content.
if (args.ContentFiles == null)
if (args.ResourceFiles == null)
{
contentFiles = [];
CollectAssetFiles(absContentPath, absContentPath, ref contentFiles);
CollectAssetFiles(args.ResourcePath, args.ResourcePath, ref contentFiles);
}
if (contentFiles.Count > 0)
{
string importPath = $"{args.ProjectPath}/{PathUtil.ImportFolderName}";
ParallelOptions parallelOptions = new ParallelOptions
{
MaxDegreeOfParallelism = contentFiles.Count
@@ -50,7 +46,7 @@ public class Builder : IDisposable
{
try
{
string inFile = $"{args.ProjectPath}/{PathUtil.ContentFolderName}/{relativeFile}";
string inFile = $"{args.ResourcePath}/{relativeFile}";
if (!File.Exists(inFile))
{
@@ -58,7 +54,7 @@ public class Builder : IDisposable
return;
}
string outFile = $"{importPath}/{relativeFile}{PathUtil.ImportedFileExtension}";
string outFile = $"{args.ResourceOutPath}/{relativeFile}{PathUtil.ImportedFileExtension}";
FileInfo inFileInfo = new FileInfo(inFile);
FileInfo outFileInfo = new FileInfo(outFile);
@@ -97,7 +93,7 @@ public class Builder : IDisposable
Console.WriteLine($"Build content completed in {stopwatch.Elapsed.TotalSeconds:F2} seconds");
}
private void CopyLibs(string projectPath)
/*private void CopyLibs(string projectPath)
{
string libDir = $"{AppDomain.CurrentDomain.BaseDirectory}/../../Native/";
if (OperatingSystem.IsWindows())
@@ -123,17 +119,12 @@ public class Builder : IDisposable
FileUtil.Copy(srcFileInfo, dstFileInfo);
}
}
}
}*/
private void CollectAssetFiles(string assetDir, string dir, ref List<string> files)
{
foreach (string file in Directory.EnumerateFiles(dir))
{
if (Path.GetExtension(file).Equals(PathUtil.ImportFileExtension, StringComparison.CurrentCultureIgnoreCase))
{
continue;
}
string relativeFile = file.Substring(assetDir.Length, file.Length - assetDir.Length);
if (relativeFile[0] == Path.DirectorySeparatorChar || relativeFile[0] == Path.AltDirectorySeparatorChar)
{