std::string ShaderD3D::getDebugInfo() const { if (mDebugInfo.empty()) { return ""; } return mDebugInfo + std::string("\n// ") + GetShaderTypeString(mData.getShaderType()) + " SHADER END\n"; }
bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) { // TODO(jmadill): We shouldn't need to cache this. mCompilerOutputType = compiler->getShaderOutputType(); const std::string &translatedSource = mData.getTranslatedSource(); mUsesMultipleRenderTargets = translatedSource.find("GL_USES_MRT") != std::string::npos; mUsesFragColor = translatedSource.find("GL_USES_FRAG_COLOR") != std::string::npos; mUsesFragData = translatedSource.find("GL_USES_FRAG_DATA") != std::string::npos; mUsesFragCoord = translatedSource.find("GL_USES_FRAG_COORD") != std::string::npos; mUsesFrontFacing = translatedSource.find("GL_USES_FRONT_FACING") != std::string::npos; mUsesPointSize = translatedSource.find("GL_USES_POINT_SIZE") != std::string::npos; mUsesPointCoord = translatedSource.find("GL_USES_POINT_COORD") != std::string::npos; mUsesDepthRange = translatedSource.find("GL_USES_DEPTH_RANGE") != std::string::npos; mUsesFragDepth = translatedSource.find("GL_USES_FRAG_DEPTH") != std::string::npos; mHasANGLEMultiviewEnabled = translatedSource.find("GL_ANGLE_MULTIVIEW_ENABLED") != std::string::npos; mUsesViewID = translatedSource.find("GL_USES_VIEW_ID") != std::string::npos; mUsesDiscardRewriting = translatedSource.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos; mUsesNestedBreak = translatedSource.find("ANGLE_USES_NESTED_BREAK") != std::string::npos; mRequiresIEEEStrictCompiling = translatedSource.find("ANGLE_REQUIRES_IEEE_STRICT_COMPILING") != std::string::npos; ShHandle compilerHandle = compiler->getCompilerHandle(mData.getShaderType()); mUniformRegisterMap = GetUniformRegisterMap(sh::GetUniformRegisterMap(compilerHandle)); for (const sh::InterfaceBlock &interfaceBlock : mData.getUniformBlocks()) { if (interfaceBlock.staticUse) { unsigned int index = static_cast<unsigned int>(-1); bool blockRegisterResult = sh::GetUniformBlockRegister(compilerHandle, interfaceBlock.name, &index); ASSERT(blockRegisterResult); mUniformBlockRegisterMap[interfaceBlock.name] = index; } } mDebugInfo += std::string("// ") + GetShaderTypeString(mData.getShaderType()) + " SHADER BEGIN\n"; mDebugInfo += "\n// GLSL BEGIN\n\n" + mData.getSource() + "\n\n// GLSL END\n\n\n"; mDebugInfo += "// INITIAL HLSL BEGIN\n\n" + translatedSource + "\n// INITIAL HLSL END\n\n\n"; // Successive steps will append more info return true; }
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(); }
std::string ShaderD3D::getDebugInfo() const { return mDebugInfo + std::string("\n// ") + GetShaderTypeString(mShaderType) + " SHADER END\n"; }
bool ShaderD3D::postTranslateCompile(gl::Compiler *compiler, std::string *infoLog) { // TODO(jmadill): We shouldn't need to cache this. mCompilerOutputType = compiler->getShaderOutputType(); const std::string &translatedSource = mData.getTranslatedSource(); mUsesMultipleRenderTargets = translatedSource.find("GL_USES_MRT") != std::string::npos; mUsesFragColor = translatedSource.find("GL_USES_FRAG_COLOR") != std::string::npos; mUsesFragData = translatedSource.find("GL_USES_FRAG_DATA") != std::string::npos; mUsesFragCoord = translatedSource.find("GL_USES_FRAG_COORD") != std::string::npos; mUsesFrontFacing = translatedSource.find("GL_USES_FRONT_FACING") != std::string::npos; mUsesPointSize = translatedSource.find("GL_USES_POINT_SIZE") != std::string::npos; mUsesPointCoord = translatedSource.find("GL_USES_POINT_COORD") != std::string::npos; mUsesDepthRange = translatedSource.find("GL_USES_DEPTH_RANGE") != std::string::npos; mUsesFragDepth = translatedSource.find("GL_USES_FRAG_DEPTH") != std::string::npos; mUsesDiscardRewriting = translatedSource.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos; mUsesNestedBreak = translatedSource.find("ANGLE_USES_NESTED_BREAK") != std::string::npos; mUsesDeferredInit = translatedSource.find("ANGLE_USES_DEFERRED_INIT") != std::string::npos; mRequiresIEEEStrictCompiling = translatedSource.find("ANGLE_REQUIRES_IEEE_STRICT_COMPILING") != std::string::npos; ShHandle compilerHandle = compiler->getCompilerHandle(mData.getShaderType()); for (const sh::Uniform &uniform : mData.getUniforms()) { if (uniform.staticUse && !uniform.isBuiltIn()) { unsigned int index = static_cast<unsigned int>(-1); bool getUniformRegisterResult = ShGetUniformRegister(compilerHandle, uniform.name, &index); UNUSED_ASSERTION_VARIABLE(getUniformRegisterResult); ASSERT(getUniformRegisterResult); mUniformRegisterMap[uniform.name] = index; } } for (const sh::InterfaceBlock &interfaceBlock : mData.getInterfaceBlocks()) { if (interfaceBlock.staticUse) { unsigned int index = static_cast<unsigned int>(-1); bool blockRegisterResult = ShGetInterfaceBlockRegister(compilerHandle, interfaceBlock.name, &index); UNUSED_ASSERTION_VARIABLE(blockRegisterResult); ASSERT(blockRegisterResult); mInterfaceBlockRegisterMap[interfaceBlock.name] = index; } } #if ANGLE_SHADER_DEBUG_INFO == ANGLE_ENABLED mDebugInfo += std::string("// ") + GetShaderTypeString(mData->getShaderType()) + " SHADER BEGIN\n"; mDebugInfo += "\n// GLSL BEGIN\n\n" + source + "\n\n// GLSL END\n\n\n"; mDebugInfo += "// INITIAL HLSL BEGIN\n\n" + translatedSource + "\n// INITIAL HLSL END\n\n\n"; // Successive steps will append more info #else mDebugInfo += translatedSource; #endif return true; }