Esempio n. 1
0
        private byte[] CompileToSpirv(
            ShaderVariantDescription variant,
            string fileName,
            ShaderStages stage)
        {
            GlslCompileOptions     glslOptions = GetOptions(variant);
            string                 glsl        = LoadGlsl(fileName);
            SpirvCompilationResult result      = SpirvCompilation.CompileGlslToSpirv(
                glsl,
                fileName,
                stage,
                glslOptions);

            return(result.SpirvBytes);
        }
        private static unsafe byte[] EnsureSpirv(ShaderDescription description)
        {
            if (Util.HasSpirvHeader(description.ShaderBytes))
            {
                return(description.ShaderBytes);
            }
            else
            {
                fixed(byte *sourceAsciiPtr = description.ShaderBytes)
                {
                    SpirvCompilationResult glslCompileResult = SpirvCompilation.CompileGlslToSpirv(
                        (uint)description.ShaderBytes.Length,
                        sourceAsciiPtr,
                        null,
                        description.Stage,
                        description.Debug,
                        0,
                        null);

                    return(glslCompileResult.SpirvBytes);
                }
            }
        }