2021-01-20 03:33:27 +00:00
|
|
|
|
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>
|
2021-01-20 03:33:27 +00:00
|
|
|
|
public class ShaderModule : GraphicsResource
|
|
|
|
|
{
|
2022-02-19 05:02:16 +00:00
|
|
|
|
protected override Action<IntPtr, IntPtr, IntPtr> QueueDestroyFunction => Refresh.Refresh_QueueDestroyShaderModule;
|
2021-01-20 03:33:27 +00:00
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|