Bug 1241042 - Get correct frag varying from angle validator. r=jmuizelaar

This commit is contained in:
Ethan Lin 2016-03-14 02:48:00 -04:00
parent 9b3e892c5b
commit 9b0ebddb01
6 changed files with 52 additions and 15 deletions

View File

@ -342,7 +342,6 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
webgl::LinkedProgramInfo::LinkedProgramInfo(WebGLProgram* prog)
: prog(prog)
, fragDataMap(nullptr)
{ }
////////////////////////////////////////////////////////////////////////////////
@ -569,8 +568,9 @@ WebGLProgram::GetFragDataLocation(const nsAString& userName_wide) const
const NS_LossyConvertUTF16toASCII userName(userName_wide);
nsCString mappedName;
if (!LinkInfo()->FindFragData(userName, &mappedName))
return -1;
if (!FindActiveOutputMappedNameByUserName(userName, &mappedName)) {
mappedName = userName;
}
gl::GLContext* gl = mContext->GL();
gl->MakeCurrent();
@ -1050,6 +1050,17 @@ WebGLProgram::LinkAndUpdate()
return mMostRecentLinkInfo;
}
bool
WebGLProgram::FindActiveOutputMappedNameByUserName(const nsACString& userName,
nsCString* const out_mappedName) const
{
if (mFragShader->FindActiveOutputMappedNameByUserName(userName, out_mappedName)) {
return true;
}
return false;
}
bool
WebGLProgram::FindAttribUserNameByMappedName(const nsACString& mappedName,
nsDependentCString* const out_userName) const

View File

@ -67,7 +67,6 @@ struct LinkedProgramInfo final
std::map<nsCString, const WebGLActiveInfo*> attribMap;
std::map<nsCString, const WebGLActiveInfo*> uniformMap;
std::map<nsCString, const WebGLActiveInfo*> transformFeedbackVaryingsMap;
std::map<nsCString, const nsCString>* fragDataMap;
std::vector<RefPtr<UniformBlockInfo>> uniformBlocks;
@ -112,17 +111,6 @@ struct LinkedProgramInfo final
return false;
}
bool FindFragData(const nsCString& baseUserName,
nsCString* const out_baseMappedName) const
{
if (!fragDataMap) {
*out_baseMappedName = baseUserName;
return true;
}
MOZ_CRASH("Not implemented.");
}
bool HasActiveAttrib(GLuint loc) const {
auto itr = activeAttribLocs.find(loc);
return itr != activeAttribLocs.end();
@ -174,6 +162,8 @@ public:
////////////////
bool FindActiveOutputMappedNameByUserName(const nsACString& userName,
nsCString* const out_mappedName) const;
bool FindAttribUserNameByMappedName(const nsACString& mappedName,
nsDependentCString* const out_userName) const;
bool FindVaryingByMappedName(const nsACString& mappedName,

View File

@ -329,6 +329,22 @@ WebGLShader::BindAttribLocation(GLuint prog, const nsCString& userName,
mContext->gl->fBindAttribLocation(prog, index, mappedNameStr->c_str());
}
bool
WebGLShader::FindActiveOutputMappedNameByUserName(const nsACString& userName,
nsCString* const out_mappedName) const
{
if (!mValidator)
return false;
const std::string userNameStr(userName.BeginReading());
const std::string* mappedNameStr;
if (!mValidator->FindActiveOutputMappedNameByUserName(userNameStr, &mappedNameStr))
return false;
*out_mappedName = mappedNameStr->c_str();
return true;
}
bool
WebGLShader::FindAttribUserNameByMappedName(const nsACString& mappedName,
nsDependentCString* const out_userName) const

View File

@ -52,6 +52,8 @@ public:
size_t CalcNumSamplerUniforms() const;
size_t NumAttributes() const;
void BindAttribLocation(GLuint prog, const nsCString& userName, GLuint index) const;
bool FindActiveOutputMappedNameByUserName(const nsACString& userName,
nsCString* const out_mappedName) const;
bool FindAttribUserNameByMappedName(const nsACString& mappedName,
nsDependentCString* const out_userName) const;
bool FindVaryingByMappedName(const nsACString& mappedName,

View File

@ -396,6 +396,21 @@ ShaderValidator::FindAttribUserNameByMappedName(const std::string& mappedName,
return false;
}
bool
ShaderValidator::FindActiveOutputMappedNameByUserName(const std::string& userName,
const std::string** const out_mappedName) const
{
const std::vector<sh::OutputVariable>& varibles = *ShGetOutputVariables(mHandle);
for (auto itr = varibles.begin(); itr != varibles.end(); ++itr) {
if (itr->name == userName) {
*out_mappedName = &(itr->mappedName);
return true;
}
}
return false;
}
bool
ShaderValidator::FindAttribMappedNameByUserName(const std::string& userName,
const std::string** const out_mappedName) const

View File

@ -48,6 +48,9 @@ public:
bool FindAttribUserNameByMappedName(const std::string& mappedName,
const std::string** const out_userName) const;
bool FindActiveOutputMappedNameByUserName(const std::string& userName,
const std::string** const out_mappedName) const;
bool FindAttribMappedNameByUserName(const std::string& userName,
const std::string** const out_mappedName) const;