mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1218939. Fixup GetTransformFeedbackVarying. r=jgilbert
This commit is contained in:
parent
d87c17975b
commit
272913b22e
@ -119,6 +119,15 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
|
||||
maxUniformBlockLenWithNull = 1;
|
||||
}
|
||||
|
||||
GLuint maxTransformFeedbackVaryingLenWithNull = 0;
|
||||
if (gl->IsSupported(gl::GLFeature::transform_feedback2)) {
|
||||
gl->fGetProgramiv(prog->mGLName, LOCAL_GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH,
|
||||
(GLint*)&maxTransformFeedbackVaryingLenWithNull);
|
||||
if (maxTransformFeedbackVaryingLenWithNull < 1)
|
||||
maxTransformFeedbackVaryingLenWithNull = 1;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DUMP_SHADERVAR_MAPPINGS
|
||||
printf_stderr("maxAttribLenWithNull: %d\n", maxAttribLenWithNull);
|
||||
printf_stderr("maxUniformLenWithNull: %d\n", maxUniformLenWithNull);
|
||||
@ -278,6 +287,51 @@ QueryProgramInfo(WebGLProgram* prog, gl::GLContext* gl)
|
||||
}
|
||||
}
|
||||
|
||||
// Transform feedback varyings
|
||||
|
||||
if (gl->IsSupported(gl::GLFeature::transform_feedback2)) {
|
||||
GLuint numTransformFeedbackVaryings = 0;
|
||||
gl->fGetProgramiv(prog->mGLName, LOCAL_GL_TRANSFORM_FEEDBACK_VARYINGS,
|
||||
(GLint*)&numTransformFeedbackVaryings);
|
||||
|
||||
for (GLuint i = 0; i < numTransformFeedbackVaryings; i++) {
|
||||
nsAutoCString mappedName;
|
||||
mappedName.SetLength(maxTransformFeedbackVaryingLenWithNull - 1);
|
||||
|
||||
GLint lengthWithoutNull;
|
||||
GLsizei size;
|
||||
GLenum type;
|
||||
gl->fGetTransformFeedbackVarying(prog->mGLName, i, maxTransformFeedbackVaryingLenWithNull,
|
||||
&lengthWithoutNull, &size, &type,
|
||||
mappedName.BeginWriting());
|
||||
mappedName.SetLength(lengthWithoutNull);
|
||||
|
||||
nsAutoCString baseMappedName;
|
||||
bool isArray;
|
||||
size_t arrayIndex;
|
||||
if (!ParseName(mappedName, &baseMappedName, &isArray, &arrayIndex))
|
||||
MOZ_CRASH("Failed to parse `mappedName` received from driver.");
|
||||
|
||||
nsAutoCString baseUserName;
|
||||
if (!prog->FindVaryingByMappedName(mappedName, &baseUserName, &isArray)) {
|
||||
baseUserName = baseMappedName;
|
||||
|
||||
if (needsCheckForArrays && !isArray) {
|
||||
std::string mappedNameStr = baseMappedName.BeginReading();
|
||||
mappedNameStr += "[0]";
|
||||
|
||||
GLuint loc = gl->fGetUniformBlockIndex(prog->mGLName,
|
||||
mappedNameStr.c_str());
|
||||
if (loc != LOCAL_GL_INVALID_INDEX)
|
||||
isArray = true;
|
||||
}
|
||||
}
|
||||
|
||||
AddActiveInfo(prog->Context(), size, type, isArray, baseUserName, mappedName,
|
||||
&info->transformFeedbackVaryings, &info->transformFeedbackVaryingsMap);
|
||||
}
|
||||
}
|
||||
|
||||
return info.forget();
|
||||
}
|
||||
|
||||
@ -995,6 +1049,18 @@ WebGLProgram::FindAttribUserNameByMappedName(const nsACString& mappedName,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLProgram::FindVaryingByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
bool* const out_isArray) const
|
||||
{
|
||||
if (mVertShader->FindVaryingByMappedName(mappedName, out_userName, out_isArray))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
WebGLProgram::FindUniformByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
@ -1058,19 +1124,13 @@ WebGLProgram::GetTransformFeedbackVarying(GLuint index)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (index >= mTransformFeedbackVaryings.size()) {
|
||||
if (index >= LinkInfo()->transformFeedbackVaryings.size()) {
|
||||
mContext->ErrorInvalidValue("getTransformFeedbackVarying: `index` is greater or "
|
||||
"equal to TRANSFORM_FEEDBACK_VARYINGS.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const nsCString& varyingUserName = mTransformFeedbackVaryings[index];
|
||||
|
||||
WebGLActiveInfo* info;
|
||||
LinkInfo()->FindAttrib(varyingUserName, (const WebGLActiveInfo**) &info);
|
||||
MOZ_ASSERT(info);
|
||||
|
||||
RefPtr<WebGLActiveInfo> ret(info);
|
||||
RefPtr<WebGLActiveInfo> ret = LinkInfo()->transformFeedbackVaryings[index];
|
||||
return ret.forget();
|
||||
}
|
||||
|
||||
|
@ -59,11 +59,13 @@ struct LinkedProgramInfo final
|
||||
WebGLProgram* const prog;
|
||||
std::vector<RefPtr<WebGLActiveInfo>> activeAttribs;
|
||||
std::vector<RefPtr<WebGLActiveInfo>> activeUniforms;
|
||||
std::vector<RefPtr<WebGLActiveInfo>> transformFeedbackVaryings;
|
||||
|
||||
// Needed for Get{Attrib,Uniform}Location. The keys for these are non-mapped
|
||||
// user-facing `GLActiveInfo::name`s, without any final "[0]".
|
||||
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;
|
||||
@ -173,6 +175,9 @@ public:
|
||||
|
||||
bool FindAttribUserNameByMappedName(const nsACString& mappedName,
|
||||
nsDependentCString* const out_userName) const;
|
||||
bool FindVaryingByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
bool* const out_isArray) const;
|
||||
bool FindUniformByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
bool* const out_isArray) const;
|
||||
|
@ -335,6 +335,23 @@ WebGLShader::FindAttribUserNameByMappedName(const nsACString& mappedName,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLShader::FindVaryingByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
bool* const out_isArray) const
|
||||
{
|
||||
if (!mValidator)
|
||||
return false;
|
||||
|
||||
const std::string mappedNameStr(mappedName.BeginReading());
|
||||
std::string userNameStr;
|
||||
if (!mValidator->FindVaryingByMappedName(mappedNameStr, &userNameStr, out_isArray))
|
||||
return false;
|
||||
|
||||
*out_userName = userNameStr.c_str();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGLShader::FindUniformByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
void BindAttribLocation(GLuint prog, const nsCString& userName, GLuint index) const;
|
||||
bool FindAttribUserNameByMappedName(const nsACString& mappedName,
|
||||
nsDependentCString* const out_userName) const;
|
||||
bool FindVaryingByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
bool* const out_isArray) const;
|
||||
bool FindUniformByMappedName(const nsACString& mappedName,
|
||||
nsCString* const out_userName,
|
||||
bool* const out_isArray) const;
|
||||
|
@ -361,6 +361,24 @@ ShaderValidator::FindAttribMappedNameByUserName(const std::string& userName,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ShaderValidator::FindVaryingByMappedName(const std::string& mappedName,
|
||||
std::string* const out_userName,
|
||||
bool* const out_isArray) const
|
||||
{
|
||||
const std::vector<sh::Varying>& varyings = *ShGetVaryings(mHandle);
|
||||
for (auto itr = varyings.begin(); itr != varyings.end(); ++itr) {
|
||||
const sh::ShaderVariable* found;
|
||||
if (!itr->findInfoByMappedName(mappedName, &found, out_userName))
|
||||
continue;
|
||||
|
||||
*out_isArray = found->isArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
ShaderValidator::FindVaryingMappedNameByUserName(const std::string& userName,
|
||||
const std::string** const out_mappedName) const
|
||||
@ -375,7 +393,6 @@ ShaderValidator::FindVaryingMappedNameByUserName(const std::string& userName,
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// This must handle names like "foo.bar[0]".
|
||||
bool
|
||||
ShaderValidator::FindUniformByMappedName(const std::string& mappedName,
|
||||
|
@ -53,6 +53,9 @@ public:
|
||||
bool FindVaryingMappedNameByUserName(const std::string& userName,
|
||||
const std::string** const out_mappedName) const;
|
||||
|
||||
bool FindVaryingByMappedName(const std::string& mappedName,
|
||||
std::string* const out_userName,
|
||||
bool* const out_isArray) const;
|
||||
bool FindUniformByMappedName(const std::string& mappedName,
|
||||
std::string* const out_userName,
|
||||
bool* const out_isArray) const;
|
||||
|
Loading…
Reference in New Issue
Block a user