MoonWorks/src/Graphics/Resources/ShaderModule.cs

26 lines
841 B
C#
Raw Normal View History

using RefreshCS;
using System;
using System.IO;
namespace MoonWorks.Graphics
{
public class ShaderModule : GraphicsResource
{
protected override Action<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);
}
}
}
}