/// <summary> /// Get the produced SpirV bytecode /// </summary> /// <returns></returns> public byte[] GetBytes() { int size = (int)ShadercNative.shaderc_result_get_length(_handle); IntPtr nativeBuf = ShadercNative.shaderc_result_get_bytes(_handle); byte[] result = new byte[size]; Marshal.Copy(nativeBuf, result, 0, size); return(result); }
/// <summary> /// Compile a given source to spirv bytecode /// </summary> /// <param name="source">The source string of the shader</param> /// <param name="stage">The stage in the pipeline</param> /// <param name="options">The compile options</param> /// <param name="name">The name of the shader that will be used for include directives</param> /// <param name="entryPoint">The name of the entry point</param> /// <returns>The result</returns> public CompileResult Compile(string source, Stage stage, CompileOptions options, string name, string entryPoint = "main") { IntPtr resultPtr = ShadercNative.shaderc_compile_into_spv(_handle, source, new UIntPtr((uint)source.Length), (int)stage, name, entryPoint, options.NativeHandle); return(new CompileResult(resultPtr)); }
public ShaderCompiler() { _handle = ShadercNative.shaderc_compiler_initialize(); }