зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1241042 - save frag translated varying names into LinkedProgramInfo. r=jgilbert
Save the frag name info to the LinkedProgramInfo object. Then the fragment shader can be freely detached at any time.
This commit is contained in:
Родитель
da244c1539
Коммит
b44cfb7256
|
@ -396,6 +396,10 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
|
|||
}
|
||||
}
|
||||
|
||||
// Frag outputs
|
||||
|
||||
prog->EnumerateFragOutputs(info->fragDataMap);
|
||||
|
||||
return info.forget();
|
||||
}
|
||||
|
||||
|
@ -632,9 +636,9 @@ WebGLProgram::GetFragDataLocation(const nsAString& userName_wide) const
|
|||
}
|
||||
|
||||
const NS_LossyConvertUTF16toASCII userName(userName_wide);
|
||||
|
||||
nsCString mappedName;
|
||||
if (!FindActiveOutputMappedNameByUserName(userName, &mappedName)) {
|
||||
|
||||
if (!LinkInfo()->FindFragData(userName, &mappedName)) {
|
||||
mappedName = userName;
|
||||
}
|
||||
|
||||
|
@ -1309,6 +1313,14 @@ WebGLProgram::FindUniformBlockByMappedName(const nsACString& mappedName,
|
|||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLProgram::EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const
|
||||
{
|
||||
MOZ_ASSERT(mFragShader);
|
||||
|
||||
mFragShader->EnumerateFragOutputs(out_FragOutputs);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool
|
||||
|
|
|
@ -90,6 +90,9 @@ struct LinkedProgramInfo final
|
|||
|
||||
//////
|
||||
|
||||
// The maps for the frag data names to the translated names.
|
||||
std::map<nsCString, const nsCString> fragDataMap;
|
||||
|
||||
explicit LinkedProgramInfo(WebGLProgram* prog);
|
||||
~LinkedProgramInfo();
|
||||
|
||||
|
@ -97,6 +100,19 @@ struct LinkedProgramInfo final
|
|||
bool FindUniform(const nsCString& baseUserName, UniformInfo** const out) const;
|
||||
bool FindUniformBlock(const nsCString& baseUserName,
|
||||
const UniformBlockInfo** const out) const;
|
||||
|
||||
bool
|
||||
FindFragData(const nsCString& baseUserName,
|
||||
nsCString* const out_baseMappedName) const
|
||||
{
|
||||
const auto itr = fragDataMap.find(baseUserName);
|
||||
if (itr == fragDataMap.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
*out_baseMappedName = itr->second;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace webgl
|
||||
|
@ -162,6 +178,8 @@ public:
|
|||
GLenum bufferMode);
|
||||
already_AddRefed<WebGLActiveInfo> GetTransformFeedbackVarying(GLuint index);
|
||||
|
||||
void EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const;
|
||||
|
||||
bool IsLinked() const { return mMostRecentLinkInfo; }
|
||||
|
||||
const webgl::LinkedProgramInfo* LinkInfo() const {
|
||||
|
|
|
@ -412,6 +412,17 @@ WebGLShader::FindUniformBlockByMappedName(const nsACString& mappedName,
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
WebGLShader::EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const
|
||||
{
|
||||
out_FragOutputs.clear();
|
||||
|
||||
if (!mValidator) {
|
||||
return;
|
||||
}
|
||||
mValidator->EnumerateFragOutputs(out_FragOutputs);
|
||||
}
|
||||
|
||||
void
|
||||
WebGLShader::ApplyTransformFeedbackVaryings(GLuint prog,
|
||||
const std::vector<nsCString>& varyings,
|
||||
|
|
|
@ -66,6 +66,8 @@ public:
|
|||
nsCString* const out_userName,
|
||||
bool* const out_isArray) const;
|
||||
|
||||
void EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const;
|
||||
|
||||
bool IsCompiled() const {
|
||||
return mTranslationSuccessful && mCompilationSuccessful;
|
||||
}
|
||||
|
|
|
@ -538,5 +538,18 @@ ShaderValidator::FindUniformBlockByMappedName(const std::string& mappedName,
|
|||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
ShaderValidator::EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const
|
||||
{
|
||||
const auto* fragOutputs = ShGetOutputVariables(mHandle);
|
||||
|
||||
if (fragOutputs) {
|
||||
for (const auto& fragOutput : *fragOutputs) {
|
||||
out_FragOutputs.insert({nsCString(fragOutput.name.c_str()),
|
||||
nsCString(fragOutput.mappedName.c_str())});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace webgl
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -66,6 +66,7 @@ public:
|
|||
bool FindUniformBlockByMappedName(const std::string& mappedName,
|
||||
std::string* const out_userName) const;
|
||||
|
||||
void EnumerateFragOutputs(std::map<nsCString, const nsCString> &out_FragOutputs) const;
|
||||
};
|
||||
|
||||
} // namespace webgl
|
||||
|
|
Загрузка…
Ссылка в новой задаче