示例#1
0
        public uint GetCode(out IntPtr nativeBuf)
        {
            uint size = (uint)ShadercNative.shaderc_result_get_length(_handle);

            nativeBuf = ShadercNative.shaderc_result_get_bytes(_handle);
            return(size);
        }
示例#2
0
        /// <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);
        }
示例#3
0
        /// <summary>
        /// Create new compile options
        /// </summary>
        public CompileOptions(IncludeHandler includeCallback = null)
        {
            IncludeCallback = includeCallback;
            _handle         = ShadercNative.shaderc_compile_options_initialize();

            includeFunction = new ShadercNative.IncludeFunction(DelegateWrapper);
            releaseInclude  = new ShadercNative.ReleaseInclude(ReleaseInclude);
            ShadercNative.shaderc_compile_options_set_include_callbacks(_handle, includeFunction,
                                                                        releaseInclude, IntPtr.Zero);
        }
示例#4
0
 /// <summary>
 /// Make a clone
 /// </summary>
 public CompileOptions Clone()
 {
     return(new CompileOptions(ShadercNative.shaderc_compile_options_clone(_handle)));
 }
示例#5
0
 /// <summary>
 /// Create new compile options
 /// </summary>
 public CompileOptions()
 {
     _handle = ShadercNative.shaderc_compile_options_initialize();
     ShadercNative.shaderc_compile_options_set_include_callbacks(_handle, DelegateWrapper, ReleaseInclude, IntPtr.Zero);
 }
        /// <summary>
        /// Similar to Compile, but instead of spv bytecode returns the preprocessed shader
        /// </summary>
        /// <param name="source"></param>
        /// <param name="stage"></param>
        /// <param name="options"></param>
        /// <param name="name"></param>
        /// <param name="entryPoint"></param>
        /// <returns></returns>
        public CompileResult Preprocess(string source, Stage stage, CompileOptions options, string name, string entryPoint = "main")
        {
            IntPtr resultPtr = ShadercNative.shaderc_compile_into_preprocessed_text(_handle, source, new UIntPtr((uint)source.Length), (int)stage, name, entryPoint, options.NativeHandle);

            return(new CompileResult(resultPtr));
        }
 public ShaderCompiler()
 {
     _handle = ShadercNative.shaderc_compiler_initialize();
 }