MoonWorks/src/Graphics/Resources/ShaderModule.cs

28 lines
932 B
C#
Raw Normal View History

using RefreshCS;
using System;
namespace MoonWorks.Graphics
{
2021-02-24 20:43:35 +00:00
/// <summary>
/// Shader modules expect input in SPIR-V bytecode format.
/// </summary>
public class ShaderModule : GraphicsResource
{
2022-02-19 05:02:16 +00:00
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule;
2021-01-29 02:07:48 +00:00
public unsafe ShaderModule(GraphicsDevice device, string filePath) : base(device)
{
2021-01-29 02:07:48 +00:00
var bytecode = Bytecode.ReadBytecodeAsUInt32(filePath);
fixed (uint* ptr = bytecode)
{
Refresh.ShaderModuleCreateInfo shaderModuleCreateInfo;
2021-01-29 02:07:48 +00:00
shaderModuleCreateInfo.codeSize = (UIntPtr) (bytecode.Length * sizeof(uint));
shaderModuleCreateInfo.byteCode = (IntPtr) ptr;
Handle = Refresh.Refresh_CreateShaderModule(device.Handle, shaderModuleCreateInfo);
}
}
}
}