Started rewriting shader compilation/processing

This commit is contained in:
Simon Lübeß
2024-08-18 23:30:47 +02:00
parent f3e68bd8d8
commit 7b7a3dc645
5 changed files with 972 additions and 1 deletions
@@ -0,0 +1,51 @@
using Bon;
using System;
using System.Collections;
using GlitchyEngine.Content;
using System.IO;
namespace GlitchyEditor.Assets.Importers;
class ImportedShader : ImportedResource
{
private String _hlslCode = new .() ~ delete _;
public StringView HlslCode
{
get => _hlslCode;
}
public this(AssetIdentifier ownAssetIdentifier) : base(ownAssetIdentifier)
{
}
}
[BonTarget, BonPolyRegister]
class ShaderImporterConfig : AssetImporterConfig
{
}
class ShaderImporter : IAssetImporter
{
private static readonly List<StringView> _fileExtensions = new .(){".hlsl"} ~ delete _;
public static List<StringView> FileExtensions => _fileExtensions;
public static Type ProcessedAssetType => typeof(ImportedShader);
public AssetImporterConfig CreateDefaultConfig()
{
return new AssetImporterConfig();
}
public Result<ImportedResource> Import(StringView fullFileName, AssetIdentifier assetIdentifier, AssetConfig config)
{
ImportedShader shader = new ImportedShader(new AssetIdentifier(assetIdentifier));
Try!(File.ReadAllText(fullFileName, shader.[Friend]_hlslCode, true));
shader.[Friend]_hlslCode.Append('\n');
return shader;
}
}