public sealed class GlDeviceThe graphics device over an OpenGL context.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
ADR-001's abstraction validator. D3D12 is postponed past 1.0 and this backend inherits its job: proving the RHI is API-neutral rather than a Vulkan wrapper with the serial numbers filed off. It is a harder test than D3D12 would have been, because GL is further away in every direction that matters — no pipeline objects, no descriptor sets, no explicit barriers, no multithreaded recording, and a clip space the other way up.
Every one of those is answered in a named place rather than smeared through the device: GlProgramCache and GlStateCache for pipelines, GlBindingPlan for descriptor sets, Replay for barriers, GlCommandList for threading, and GlslTranslator for clip space. The findings are collected in docs/rhi-backend-mapping.md.
Threading. Every GL call happens on the thread that owns the context, which is the thread that constructs the device and the thread that submits. Command lists are recorded anywhere.
Deferred destruction is free here. The RHI requires that destroying a resource an in-flight frame still references be safe. GL gives that for nothing: glDelete* unbinds the name and the driver keeps the object alive until nothing references it. That is one of the two places where GL's implicitness is an advantage rather than a tax.
Fields and properties (11)
public GlProfile ProfileWhich dialect this device drives.
public IGraphicsAdapter AdapterThe adapter this device runs on.
public GraphicsDeviceFeatures FeaturesWhat it can do.
public ICommandSubmitter GraphicsQueueThe queue that can do everything.
public ICommandSubmitter ComputeQueueThe compute queue, which is GraphicsQueue where the hardware has only one.
public ICommandSubmitter TransferQueueThe transfer queue, which is GraphicsQueue where the hardware has only one.
public int FramesInFlightHow many frames may be recorded before the first has to have finished.
public long FrameCountHow many frames BeginFrame has started.
public int LiveResourceCountHow many resources are alive, across every kind.
public int FramebufferCountHow many framebuffer objects the pass cache holds.
public int ProgramCountHow many distinct programs have been linked.
Methods (37)
public static bool TryCreate(GlDeviceOptions options, out GlDevice? device, out string? reason)Creates a device, reporting failure rather than throwing.
public GlDevice(GlDeviceOptions options)Creates the device over a context that is already current.
public BufferHandle CreateBuffer(in BufferDescription description)Creates a buffer.
public void Write(BufferHandle buffer, long offset, ReadOnlySpan<byte> data)Writes into a host-visible buffer.
public void Read(BufferHandle buffer, long offset, Span<byte> destination)Reads out of a readback buffer.
public TextureHandle CreateTexture(in TextureDescription description)Creates a texture.
public TextureViewHandle CreateTextureView(TextureHandle texture, PixelFormat format = Undefined, int baseMipLevel = 0, int mipLevelCount = 0, int baseArrayLayer = 0, int arrayLayerCount = 0)Creates a view of part of a texture.
public SamplerHandle CreateSampler(in SamplerDescription description)Creates a sampler.
public ShaderHandle CreateShader(ShaderStage stage, ReadOnlySpan<byte> bytecode, string name = "")public DescriptorSetLayoutHandle CreateDescriptorSetLayout(in DescriptorSetLayoutDescription description)Creates a descriptor-set layout.
public PipelineLayoutHandle CreatePipelineLayout(in PipelineLayoutDescription description)Creates a pipeline layout.
public DescriptorSetHandle CreateDescriptorSet(DescriptorSetLayoutHandle layout, string name = "")Creates a descriptor set.
public void UpdateDescriptorSet(DescriptorSetHandle descriptors, ReadOnlySpan<DescriptorWrite> writes)Points a descriptor set's bindings at resources.
public PipelineHandle CreateGraphicsPipeline(in GraphicsPipelineDescription description)Compiles a graphics pipeline.
public PipelineHandle CreateComputePipeline(in ComputePipelineDescription description)Compiles a compute pipeline.
public ISwapChain CreateSwapChain(in SwapChainDescription description)Creates a swapchain for a window surface.
public QueryPoolHandle CreateQueryPool(in QueryPoolDescription description)public void Destroy(QueryPoolHandle handle)Returns a query pool.
public bool TryResolveQueries(QueryPoolHandle pool, int first, Span<ulong> results)Reads out whatever a pool's queries have answered.
public AccelerationStructureSizes GetAccelerationStructureSizes(in AccelerationStructureBuildInput input)public AccelerationStructureHandle CreateAccelerationStructure(in AccelerationStructureDescription description)Creates an acceleration structure — empty until a build fills it.
public ulong GetAccelerationStructureAddress(AccelerationStructureHandle handle)The GPU address a top-level build's instances refer to a bottom level by.
public void Destroy(AccelerationStructureHandle handle)Returns an acceleration structure.
public void Destroy(BufferHandle handle)Returns a buffer.
public void Destroy(TextureHandle handle)Returns a texture.
public void Destroy(TextureViewHandle handle)Returns a texture view.
public void Destroy(SamplerHandle handle)Returns a sampler.
public void Destroy(ShaderHandle handle)Returns a shader module.
public void Destroy(PipelineHandle handle)public void Destroy(PipelineLayoutHandle handle)Returns a pipeline layout.
public void Destroy(DescriptorSetLayoutHandle handle)Returns a descriptor-set layout.
public void Destroy(DescriptorSetHandle handle)Returns a descriptor set.
public ICommandList BeginCommandList(QueueKind kind = Graphics, string name = "")Takes a command list to record into.
public void BeginFrame()Marks the start of a frame, retiring whatever the oldest in-flight frame held.
public void EndFrame()Marks the end of a frame.
public void WaitIdle()public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Used by (9)
- GlCommandListVixen.Graphics.OpenGL
- GlCommandListTestsVixen.Graphics.OpenGL.Tests
- GlDeviceTestsVixen.Graphics.OpenGL.Tests
- GlReplayTestsVixen.Graphics.OpenGL.Tests
- GlStateCacheTestsVixen.Graphics.OpenGL.Tests
- GlSubmitterVixen.Graphics.OpenGL
- GlSwapChainVixen.Graphics.OpenGL
- PipelinesVixen.Graphics.OpenGL.Tests
- GraphicsHostVixen.App