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)); }
GLSlang.IShader CompileShader(IShader shader) { if (shader is HLSLShader) { // pass the shader through GLSLang's hlsl front end HLSLShader hlsl = shader as HLSLShader; return(m_GLSLang.CompileHLSL(shader.Code, hlsl.CompileOptions, m_GLSLangConfig, shader.SourceFilePath)); } else if (shader is GLSLShader) { GLSLShader glsl = shader as GLSLShader; return(m_GLSLang.Compile(shader.Code, glsl.CompileOptions.ShaderType, m_GLSLangConfig, glsl.SourceFilePath)); } else { throw new System.Exception("Bad shader type?!?"); } }
public IResultSet Compile(IShader shader, IBackendOptions options) { if (shader is GLSLShader) { GLSLShader sh = (GLSLShader)shader; IGLSLOptions glOpts = sh.CompileOptions; GLSlang.IShader result = m_Compiler.Compile(sh.Code, glOpts.ShaderType, m_Config, shader.SourceFilePath); return(new GLSLangResultSet(result)); } else if (shader is HLSLShader) { HLSLShader sh = (HLSLShader)shader; IHLSLOptions hlslOpts = sh.CompileOptions; GLSlang.IShader result = m_Compiler.CompileHLSL(sh.Code, hlslOpts, m_Config, shader.SourceFilePath); return(new GLSLangResultSet(result)); } else { return(null); } }
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); } }