namespace Ghost.Graphics.RHI; /// /// Pipeline state object interface /// public interface IPipelineState : IDisposable { /// /// Pipeline type (graphics or compute) /// PipelineType Type { get; } /// /// Pipeline name for debugging /// string Name { get; set; } } /// /// Root signature interface /// public interface IRootSignature : IDisposable { /// /// Root signature name for debugging /// string Name { get; set; } } /// /// Pipeline types /// public enum PipelineType { Graphics, Compute } /// /// Render target description /// Supports either color OR depth rendering, not both /// public struct RenderTargetDesc { /// /// Width of the render target /// public uint Width; /// /// Height of the render target /// public uint Height; /// /// Type of render target (color or depth) /// public RenderTargetType Type; /// /// Target texture format /// public TextureFormat Format; /// /// Texture dimension /// public TextureDimension Dimension; /// /// Creation flags for the render target /// public RenderTargetCreationFlags CreationFlags; /// /// Number of mip levels. 0 to generate full mip chain /// public uint MipLevels; /// /// Number of samples for MSAA /// public uint SampleCount; /// /// Creates a color render target /// public static RenderTargetDesc Color(uint width, uint height, TextureFormat format, TextureDimension dimension = TextureDimension.Texture2D, RenderTargetCreationFlags creationFlags = RenderTargetCreationFlags.AllowUAV | RenderTargetCreationFlags.DynamicallyScalable | RenderTargetCreationFlags.GenerateMips, uint mipLevels = 0u, uint sampleCount = 1) { return new RenderTargetDesc { Width = width, Height = height, Type = RenderTargetType.Color, Format = format, Dimension = dimension, CreationFlags = creationFlags, MipLevels = mipLevels, SampleCount = sampleCount }; } /// /// Creates a depth render target /// public static RenderTargetDesc Depth(uint width, uint height, TextureFormat format = TextureFormat.D24_UNorm_S8_UInt, TextureDimension dimension = TextureDimension.Texture2D, RenderTargetCreationFlags creationFlags = RenderTargetCreationFlags.AllowUAV | RenderTargetCreationFlags.DynamicallyScalable, uint mipLevels = 0u, uint sampleCount = 1) { return new RenderTargetDesc { Width = width, Height = height, Type = RenderTargetType.Depth, Format = format, Dimension = dimension, CreationFlags = creationFlags, MipLevels = mipLevels, SampleCount = sampleCount }; } } /// /// Texture description /// public struct TextureDesc { /// /// Width of the texture /// public uint Width; /// /// Height of the texture /// public uint Height; /// /// Texture format /// public TextureFormat Format; /// /// Texture dimension /// public TextureDimension Dimension; /// /// Number of mip levels. 0 to generate full mip chain /// public uint MipLevels; /// /// Texture usage flags /// public TextureUsage Usage; public TextureDesc(uint width, uint height, TextureFormat format, TextureDimension dimension = TextureDimension.Texture2D, uint mipLevels = 0u, TextureUsage usage = TextureUsage.ShaderResource) { Width = width; Height = height; Format = format; Dimension = dimension; MipLevels = mipLevels; Usage = usage; } } /// /// Buffer description /// public struct BufferDesc { /// /// Size of the buffer in bytes /// public ulong Size; /// /// Buffer usage flags /// public BufferUsage Usage; /// /// Memory type for the buffer /// public MemoryType MemoryType; public BufferDesc(ulong size, BufferUsage usage, MemoryType memoryType = MemoryType.Default) { Size = size; Usage = usage; MemoryType = memoryType; } } /// /// Texture usage flags /// [Flags] public enum TextureUsage { None = 0, ShaderResource = 1 << 0, RenderTarget = 1 << 1, DepthStencil = 1 << 2, UnorderedAccess = 1 << 3 } /// /// Dimensions of the texture /// public enum TextureDimension { Unknown = -1, None = 0, Texture2D = 1, Texture3D = 2, TextureCube = 3, Texture2DArray = 4, TextureCubeArray = 5 } /// /// Render target creation flags /// [Flags] public enum RenderTargetCreationFlags { None = 0, AllowUAV = 1 << 0, AllowMSAA = 1 << 1, DynamicallyScalable = 1 << 2, GenerateMips = 1 << 3 } /// /// Memory types for resources /// public enum MemoryType { Default, // GPU memory Upload, // CPU-to-GPU memory Readback // GPU-to-CPU memory }