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