Refactor shader system: arrays, keywords, property syntax

Major refactor of shader compiler and related systems:
- Switch ShaderDescriptor/PassDescriptor to arrays; remove IPassDescriptor
- Rewrite keywords block parser/semantic analysis for flexible syntax
- Change property initializers to brace syntax `{ ... }`
- Simplify TokenStream API (remove ref index params)
- Make GetBindlessIndex return uint (~0u for not found)
- Update shader compilation and variant logic for new descriptors
- Update test shader syntax to match new property/keyword formats
- Add AGENTS.md agent development guide
- Add Antlr4 dependency to Ghost.DSL
- Miscellaneous code style and error handling improvements
This commit is contained in:
2026-01-10 18:36:18 +09:00
parent 6a041f75ba
commit d71bdb3fc9
18 changed files with 548 additions and 246 deletions

View File

@@ -102,30 +102,23 @@ public partial struct Shader : IResourceReleasable
internal Shader(ShaderDescriptor descriptor)
{
_cbufferSize = descriptor.cbufferSize;
_shaderPasses = new UnsafeArray<ShaderPass>(descriptor.passes.Count, Allocator.Persistent);
_passIDToLocal = new UnsafeHashMap<int, int>(descriptor.passes.Count, Allocator.Persistent);
_shaderPasses = new UnsafeArray<ShaderPass>(descriptor.passes.Length, Allocator.Persistent);
_passIDToLocal = new UnsafeHashMap<int, int>(descriptor.passes.Length, Allocator.Persistent);
_keywordIDToLocal = new UnsafeHashMap<int, int>(32, Allocator.Persistent);
for (var i = 0; i < descriptor.passes.Count; i++)
for (var i = 0; i < descriptor.passes.Length; i++)
{
var pass = descriptor.passes[i];
// TODO: Handle inherited passes
if (pass is not PassDescriptor fullPass)
{
continue;
}
var passKey = RHIUtility.CreateShaderPassKey(pass.Identifier);
var passKey = RHIUtility.CreateShaderPassKey(pass.identifier);
var keywords = default(LocalKeywordSet);
if (fullPass.keywords != null && fullPass.keywords.Count > 0)
if (pass.keywords.Length > 0)
{
var localKeywordIndex = 0;
for (var j = 0; j < fullPass.keywords.Count; j++)
for (var j = 0; j < pass.keywords.Length; j++)
{
var group = fullPass.keywords[j];
var group = pass.keywords[j];
if (group.keywords == null)
{
continue;
@@ -150,11 +143,11 @@ public partial struct Shader : IResourceReleasable
_shaderPasses[i] = new ShaderPass
{
Key = passKey,
DeafaultState = fullPass.localPipeline,
DeafaultState = pass.localPipeline,
KeywordIDs = keywords,
};
_passIDToLocal[GetPassID(pass.Name)] = (ushort)i;
_passIDToLocal[GetPassID(pass.name)] = (ushort)i;
}
}