// Generated API outline. Implementation bodies omitted. #nullable enable using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using System; using nfloat = System.Runtime.InteropServices.NFloat; using static Xui.Core.Math2D.Constants; namespace Xui.GPU.Hardware { /// /// Specifies which triangle faces to cull during rasterization. /// public enum GpuCullMode { /// No culling — all triangles are rendered. None = 0, /// Back-facing triangles are culled (default). Back = 1, /// Front-facing triangles are culled. Front = 2, } /// /// Describes a hardware GPU render pipeline, binding shaders and state together. /// public sealed class GpuPipelineDesc { /// Enables premultiplied source-over blending. Requires the resource-device capability. public bool PremultipliedAlpha { get; set; } /// Vertex attribute component counts in location order; null selects Float3 + Float4. public int[]? VertexComponents { get; set; } /// Gets or sets the compiled vertex shader. public IGpuVertexShader? VertexShader { get; set; } /// Gets or sets the compiled fragment (pixel) shader. public IGpuFragmentShader? FragmentShader { get; set; } /// Gets or sets whether depth testing is enabled. public bool DepthTestEnabled { get; set; } /// Gets or sets whether depth writing is enabled. public bool DepthWriteEnabled { get; set; } /// Gets or sets the triangle cull mode. public GpuCullMode CullMode { get; set; } } /// Shared validation for tightly packed RGBA8 mip chains. public static class GpuTextureValidation { /// Checks dimensions and each mip's byte length before any native allocation. public static void Validate(int width, int height, IReadOnlyList levels); } /// /// Describes the vertex buffer layout for a GPU draw call. /// public sealed class GpuVertexBufferDesc { /// Gets or sets the stride (bytes per vertex). public int Stride { get; set; } /// Gets or sets the vertex count. public int VertexCount { get; set; } } /// /// Represents a GPU command list / draw context for recording rendering commands. /// public interface IGpuCommandList : IDisposable { /// /// Begins a render pass targeting the given render target. /// void BeginRenderPass(IGpuRenderTarget renderTarget, Xui.GPU.Shaders.Types.Color4 clearColor); /// /// Ends the current render pass. /// void EndRenderPass(); /// /// Sets the pipeline state for subsequent draw calls. /// void SetPipeline(GpuPipelineDesc pipeline); /// /// Sets the vertex buffer for subsequent draw calls. /// /// Pointer to vertex data. /// Vertex buffer description. unsafe void SetVertexBuffer(void* data, GpuVertexBufferDesc desc); /// Uploads tightly packed unmanaged vertices; the input is borrowed only for this call. /// Native backends use the pointer overload by default. Managed backends may override this /// overload to copy non-contiguous managed storage into their upload representation. unsafe void SetVertexBuffer(ReadOnlySpan vertices) where T : unmanaged; /// Uploads one unmanaged constant-buffer value, borrowed only for this call. unsafe void SetConstantBuffer(in T value) where T : unmanaged; /// /// Sets the uniform/constant buffer data. /// /// Pointer to constant data. /// Size of the constant data in bytes. unsafe void SetConstantBuffer(void* data, int sizeInBytes); /// /// Draws primitives using the current pipeline and vertex buffer. /// /// Number of vertices to draw. void Draw(int vertexCount); /// /// Submits all recorded commands. Native presentation targets schedule presentation /// asynchronously; submission does not mean that the frame has finished displaying. /// Offscreen readback uses the backend's completion/synchronization mechanism. /// void Commit(); } /// /// Abstract interface for a GPU hardware device. /// Implementations exist for Direct3D 11 (Windows) and Metal (macOS/iOS). /// public interface IGpuDevice : IDisposable { /// Gets the name of this GPU backend (e.g., "D3D11", "Metal"). string BackendName { get; } /// Gets whether this device has been disposed. bool IsDisposed { get; } /// /// Compiles a vertex shader from native shader source code. /// /// The shader source (HLSL for D3D11, MSL for Metal). /// The name of the entry point function. /// A compiled vertex shader. IGpuVertexShader CompileVertexShader(string source, string entryPoint); /// /// Compiles a fragment (pixel) shader from native shader source code. /// /// The shader source (HLSL for D3D11, MSL for Metal). /// The name of the entry point function. /// A compiled fragment shader. IGpuFragmentShader CompileFragmentShader(string source, string entryPoint); /// /// Creates a render target texture. /// /// Width in pixels. /// Height in pixels. /// A render target that can be used with a command list. IGpuRenderTarget CreateRenderTarget(int width, int height); /// /// Creates a command list for recording rendering commands. /// IGpuCommandList CreateCommandList(); } /// /// Represents a compiled fragment (pixel) shader. /// public interface IGpuFragmentShader : IGpuShader { } /// /// Represents a GPU render target backed by a texture. /// Offscreen targets support readback; borrowed native presentation targets may forbid it. /// public interface IGpuRenderTarget : IDisposable { /// Gets the underlying texture. Framebuffer-only presentation targets may throw NotSupportedException. IGpuTexture Texture { get; } /// Gets the width of the render target in pixels. int Width { get; } /// Gets the height of the render target in pixels. int Height { get; } /// /// Reads back the rendered pixels to a CPU byte array. /// Native presentation targets may throw NotSupportedException. /// The pixel format is BGRA (Blue, Green, Red, Alpha), 4 bytes per pixel. /// /// /// A byte array of size Width * Height * 4 to receive the pixels. /// void ReadbackPixelsBgra(byte[] destination); } /// /// Represents a compiled GPU shader ready for use in a hardware pipeline. /// public interface IGpuShader : IDisposable { /// Gets the name of this shader. string Name { get; } } /// /// Represents a GPU texture that can be used as a render target. /// public interface IGpuTexture : IDisposable { /// Gets the width of the texture in pixels. int Width { get; } /// Gets the height of the texture in pixels. int Height { get; } } /// /// Represents a compiled vertex shader. /// public interface IGpuVertexShader : IGpuShader { } } namespace Xui.GPU.Hardware { using Xui.GPU.Shaders.Types; /// Resource bindings supported by devices implementing . public interface IGpuResourceCommandList : IGpuCommandList { /// Binds an immutable vertex buffer without uploading it again. void SetVertexBuffer(IGpuVertexBuffer buffer); /// Binds a sampled texture to a fragment texture and sampler slot; mip filtering is linear. void SetTexture(int slot, IGpuTexture texture, Sampler sampler); } /// Optional device capability for sampled RGBA textures and immutable vertex buffers. public interface IGpuResourceDevice : IGpuDevice { /// Uploads premultiplied RGBA8 mip levels, largest first, with tightly packed rows. IGpuTexture CreateSampledTexture(int width, int height, IReadOnlyList mipLevels); /// Uploads immutable vertices once. The caller owns the returned buffer. IGpuVertexBuffer CreateVertexBuffer(ReadOnlySpan vertices, int stride); } /// An owned immutable vertex buffer. public interface IGpuVertexBuffer : IDisposable { /// Number of vertices in the buffer. int VertexCount { get; } } }