using Ghost.Core; using System.Runtime.CompilerServices; namespace Ghost.RenderGraph.Concept; internal enum RenderGraphResourceType { Texture, Buffer, AccelerationStructure, Count } public struct RGResource; public struct RGTexture; public struct RGBuffer; public static class RGResourceExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Identifier AsResource(this Identifier texture) { return new Identifier(texture.Value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Identifier AsResource(this Identifier buffer) { return new Identifier(buffer.Value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Identifier AsTexture(this Identifier resource) { return new Identifier(resource.Value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static Identifier AsBuffer(this Identifier resource) { return new Identifier(resource.Value); } } internal readonly struct TextureAccess { public readonly Identifier id; public readonly AccessFlags accessFlags; public TextureAccess(Identifier id, AccessFlags accessFlags) { this.id = id; this.accessFlags = accessFlags; } } /// /// Texture formats supported by the render graph. /// public enum TextureFormat : int { RGBA8, RGBA16F, RGBA32F, Depth32F, Depth24Stencil8 } /// /// Descriptor for creating a texture resource. /// public readonly struct TextureDescriptor : IEquatable { public readonly int Width; public readonly int Height; public readonly TextureFormat Format; public readonly string Name; public TextureDescriptor(int width, int height, TextureFormat format, string name) { Width = width; Height = height; Format = format; Name = name; } public readonly bool Equals(TextureDescriptor other) => Width == other.Width && Height == other.Height && Format == other.Format && Name == other.Name; public override readonly bool Equals(object? obj) => obj is TextureDescriptor other && Equals(other); public override readonly int GetHashCode() => HashCode.Combine(Width, Height, Format, Name); } /// /// Base interface for pass data that can be stored in the blackboard. /// public interface IPassData { }