Esempio n. 1
0
        public IResultSet Compile(string shader, ICompileOptions opts)
        {
            if (opts.Language != Languages.GLSL)
                return null;

            IGLSLOptions glOpts = (IGLSLOptions)opts;

            GLSlangOptions slangOpts = new GLSlangOptions();
            slangOpts.ShaderType = glOpts.ShaderType;
            slangOpts.Config = m_Config;
            GLSlang.IShader result = m_Compiler.Compile(shader, slangOpts);
            return new GLSLangResultSet(result);
        }
Esempio n. 2
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (!(shader is GLSLShader) )
                return null;

            GLSLShader sh = (GLSLShader)shader;
            IGLSLOptions glOpts = sh.CompileOptions;

            GLSlangOptions slangOpts = new GLSlangOptions();
            slangOpts.ShaderType = glOpts.ShaderType;
            slangOpts.Config = m_Config;
            GLSlang.IShader result = m_Compiler.Compile(sh.Code, slangOpts);
            return new GLSLangResultSet(result);
        }
Esempio n. 3
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (!(shader is GLSLShader))
            {
                return(null);
            }

            GLSLShader   sh     = (GLSLShader)shader;
            IGLSLOptions glOpts = sh.CompileOptions;

            GLSlangOptions slangOpts = new GLSlangOptions();

            slangOpts.ShaderType = glOpts.ShaderType;
            slangOpts.Config     = m_Config;
            GLSlang.IShader result = m_Compiler.Compile(sh.Code, slangOpts);
            return(new GLSLangResultSet(result));
        }
Esempio n. 4
0
        public IResultSet Compile(IShader shader, IBackendOptions options)
        {
            if (shader is GLSLShader)
            {
                GLSLShader   sh     = (GLSLShader)shader;
                IGLSLOptions glOpts = sh.CompileOptions;

                GLSlangOptions slangOpts = new GLSlangOptions();
                slangOpts.ShaderType = glOpts.ShaderType;
                slangOpts.Config     = m_Config;
                GLSlang.IShader result = m_Compiler.Compile(sh.Code, slangOpts);
                return(new GLSLangResultSet(result));
            }
            else if (shader is HLSLShader)
            {
                HLSLShader   sh       = (HLSLShader)shader;
                IHLSLOptions hlslOpts = sh.CompileOptions;

                // turn HLSL shader profile into GLSL shader type
                GLSLShaderType eShaderType;
                string         profile = hlslOpts.Target.ToString();
                if (profile.StartsWith("vs"))
                {
                    eShaderType = GLSLShaderType.VERTEX;
                }
                else if (profile.StartsWith("ps"))
                {
                    eShaderType = GLSLShaderType.FRAGMENT;
                }
                else if (profile.StartsWith("gs"))
                {
                    eShaderType = GLSLShaderType.GEOMETRY;
                }
                else if (profile.StartsWith("hs"))
                {
                    eShaderType = GLSLShaderType.TESS_CONTROL;
                }
                else if (profile.StartsWith("ds"))
                {
                    eShaderType = GLSLShaderType.TESS_EVALUATION;
                }
                else if (profile.StartsWith("cs"))
                {
                    eShaderType = GLSLShaderType.COMPUTE;
                }
                else
                {
                    throw new System.Exception("Don't know what this shader profile is");
                }

                string EntryPoint = hlslOpts.EntryPoint;

                GLSlangOptions slangOpts = new GLSlangOptions();
                slangOpts.ShaderType = eShaderType;
                slangOpts.Config     = m_Config;
                GLSlang.IShader result = m_Compiler.CompileHLSL(sh.Code, slangOpts, EntryPoint);
                return(new GLSLangResultSet(result));
            }
            else
            {
                return(null);
            }
        }