2021-01-20 03:33:27 +00:00
|
|
|
|
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-20 03:33:27 +00:00
|
|
|
|
{
|
2021-01-29 02:07:48 +00:00
|
|
|
|
var bytecode = Bytecode.ReadBytecodeAsUInt32(filePath);
|
|
|
|
|
|
|
|
|
|
fixed (uint* ptr = bytecode)
|
2021-01-20 03:33:27 +00:00
|
|
|
|
{
|
|
|
|
|
Refresh.ShaderModuleCreateInfo shaderModuleCreateInfo;
|
2021-01-29 02:07:48 +00:00
|
|
|
|
shaderModuleCreateInfo.codeSize = (UIntPtr) (bytecode.Length * sizeof(uint));
|
2021-01-20 03:33:27 +00:00
|
|
|
|
shaderModuleCreateInfo.byteCode = (IntPtr) ptr;
|
|
|
|
|
|
2021-01-22 01:27:25 +00:00
|
|
|
|
Handle = Refresh.Refresh_CreateShaderModule(device.Handle, shaderModuleCreateInfo);
|
2021-01-20 03:33:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|