Exemple #1
0
ShShaderOutput ShaderD3D::getCompilerOutputType(GLenum shader)
{
    void *compiler = NULL;

    switch (shader)
    {
      case GL_VERTEX_SHADER:   compiler = mVertexCompiler;   break;
      case GL_FRAGMENT_SHADER: compiler = mFragmentCompiler; break;
      default: UNREACHABLE();  return SH_HLSL9_OUTPUT;
    }

    return ShGetShaderOutputType(compiler);
}
Exemple #2
0
bool ShaderD3D::compile(gl::Compiler *compiler, const std::string &source)
{
    uncompile();

    CompilerD3D *compilerD3D = GetImplAs<CompilerD3D>(compiler);
    ShHandle compilerHandle = compilerD3D->getCompilerHandle(mShaderType);

    mCompilerOutputType = ShGetShaderOutputType(compilerHandle);

    compileToHLSL(compilerHandle, source);

    if (mShaderType == GL_VERTEX_SHADER)
    {
        parseAttributes(compilerHandle);
    }

    parseVaryings(compilerHandle);

    if (mShaderType == GL_FRAGMENT_SHADER)
    {
        std::sort(mVaryings.begin(), mVaryings.end(), CompareVarying);

        const std::string &hlsl = getTranslatedSource();
        if (!hlsl.empty())
        {
            mActiveOutputVariables = *GetShaderVariables(ShGetOutputVariables(compilerHandle));
            FilterInactiveVariables(&mActiveOutputVariables);
        }
    }

#if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED
    mDebugInfo += std::string("// ") + GetShaderTypeString(mShaderType) + " SHADER BEGIN\n";
    mDebugInfo += "\n// GLSL BEGIN\n\n" + source + "\n\n// GLSL END\n\n\n";
    mDebugInfo += "// INITIAL HLSL BEGIN\n\n" + getTranslatedSource() + "\n// INITIAL HLSL END\n\n\n";
    // Successive steps will append more info
#else
    mDebugInfo += getTranslatedSource();
#endif

    return !getTranslatedSource().empty();
}