Skip to content

Commit

Permalink
Load and check for extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
deccer committed Jan 5, 2023
1 parent 7405253 commit 9547d62
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/EngineKit/Graphics/GraphicsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal sealed class GraphicsContext : IGraphicsContext, IInternalGraphicsConte
private readonly IDictionary<IPipeline, GraphicsPipelineDescriptor> _graphicsPipelineCache;
private readonly IDictionary<IPipeline, ComputePipelineDescriptor> _computePipelineCache;
private readonly IDictionary<int, IInputLayout> _inputLayoutCache;
private readonly IList<string> _extensions;
private uint? _currentFramebuffer;

public GraphicsContext(ILogger logger, IFramebufferCache framebufferCache)
Expand All @@ -28,6 +29,7 @@ public GraphicsContext(ILogger logger, IFramebufferCache framebufferCache)
_graphicsPipelineCache = new Dictionary<IPipeline, GraphicsPipelineDescriptor>(16);
_computePipelineCache = new Dictionary<IPipeline, ComputePipelineDescriptor>(16);
_inputLayoutCache = new Dictionary<int, IInputLayout>(16);
_extensions = new List<string>(512);
}

public void Dispose()
Expand Down Expand Up @@ -517,4 +519,18 @@ public void RemoveFramebuffer(FramebufferRenderDescriptor framebufferRenderDescr
{
_framebufferCache.RemoveFramebuffer(framebufferRenderDescriptor);
}

public bool IsExtensionSupported(string extensionName)
{
return _extensions.Contains(extensionName);
}

public void LoadExtensions()
{
var extensionCount = GL.GetInteger((uint)GL.GetName.NumExtensions);
for (var i = 0u; i < extensionCount; i++)
{
_extensions.Add(GL.GetString(GL.StringName.Extensions, i));
}
}
}
4 changes: 4 additions & 0 deletions src/EngineKit/Graphics/IGraphicsContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ ITexture CreateTexture2D(
void InsertMemoryBarrier(BarrierMask mask);

void RemoveFramebuffer(FramebufferRenderDescriptor framebufferRenderDescriptor);

bool IsExtensionSupported(string extensionName);

void LoadExtensions();
}

0 comments on commit 9547d62

Please sign in to comment.