mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 04:58:24 +01:00
SOURCE DUMP v1
This commit is contained in:
parent
bd62d51ec9
commit
fb20299e9d
1 changed files with 768360 additions and 0 deletions
|
|
@ -0,0 +1,69 @@
|
|||
namespace Brutal.VulkanApi.Abstractions;
|
||||
|
||||
/// <summary>
|
||||
/// A builder for <see cref="VkPipelineShaderStageCreateInfo"></see>
|
||||
/// </summary>
|
||||
public class ShaderStages(Device inDevice, Span<VkPipelineShaderStageCreateInfo> inStages, VkAllocator? allocator)
|
||||
: IDisposable
|
||||
{
|
||||
private readonly NativeList<VkPipelineShaderStageCreateInfo> _stages = new(inStages);
|
||||
|
||||
/// <summary>
|
||||
/// The number of stages
|
||||
/// </summary>
|
||||
public int Count => _stages.Count;
|
||||
|
||||
/// <summary>
|
||||
/// Destroy shaders (only call this if you know you are responsible for destroying them!)
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_stages.Count == 0)
|
||||
return;
|
||||
|
||||
for (var index = 0; index < _stages.Count; index++)
|
||||
inDevice.DestroyShaderModule(_stages[index].Module, allocator);
|
||||
|
||||
_stages.Count = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implicit cast to the <see cref="VkPipelineVertexInputStateCreateInfo">PipelineVertexInputStateCreateInfo</see> structure
|
||||
/// </summary>
|
||||
public static unsafe implicit operator VkPipelineShaderStageCreateInfo*(ShaderStages inValue) =>
|
||||
inValue._stages.Ptr;
|
||||
|
||||
/// <summary>
|
||||
/// Offset the stages by some number
|
||||
/// </summary>
|
||||
public static unsafe VkPipelineShaderStageCreateInfo* operator +(ShaderStages inStages, int inValue)
|
||||
{
|
||||
if (inStages.Count <= inValue)
|
||||
throw new ArgumentOutOfRangeException(nameof(inValue));
|
||||
|
||||
return (VkPipelineShaderStageCreateInfo*)inStages + inValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a span from a subset of the shader stages
|
||||
/// </summary>
|
||||
/// <param name="start">The start element</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentOutOfRangeException"></exception>
|
||||
public Span<VkPipelineShaderStageCreateInfo> Slice(int start)
|
||||
{
|
||||
return _stages.Slice(start);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a span from a subset of the shader stages
|
||||
/// </summary>
|
||||
/// <param name="start">The start element</param>
|
||||
/// <param name="length">How many elements to include</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentException"></exception>
|
||||
public Span<VkPipelineShaderStageCreateInfo> Slice(int start, int length)
|
||||
{
|
||||
return _stages.Slice(start, length);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue