--- a/dom/canvas/WebGLProgram.cpp
+++ b/dom/canvas/WebGLProgram.cpp
@@ -204,24 +204,17 @@ QueryProgramInfo(WebGLProgram* prog, gl:
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);
- printf_stderr("maxUniformBlockLenWithNull: %d\n", maxUniformBlockLenWithNull);
-#endif
-
- // Attribs
+ // Attribs (can't be arrays)
GLuint numActiveAttribs = 0;
gl->fGetProgramiv(prog->mGLName, LOCAL_GL_ACTIVE_ATTRIBUTES,
(GLint*)&numActiveAttribs);
for (GLuint i = 0; i < numActiveAttribs; i++) {
nsAutoCString mappedName;
mappedName.SetLength(maxAttribLenWithNull - 1);
@@ -233,53 +226,45 @@ QueryProgramInfo(WebGLProgram* prog, gl:
&elemCount, &elemType, mappedName.BeginWriting());
GLenum error = gl->fGetError();
if (error != LOCAL_GL_NO_ERROR) {
gfxCriticalNote << "Failed to do glGetActiveAttrib: " << error;
}
mappedName.SetLength(lengthWithoutNull);
- if (mappedName.Find("gl_") == 0) {
-#ifdef DUMP_SHADERVAR_MAPPINGS
- printf_stderr("[attrib %u/%u] <skipping %s>\n", i, numActiveAttribs,
- mappedName.BeginReading());
-#endif
- continue;
+ ////
+
+ nsCString userName;
+ if (!prog->FindAttribUserNameByMappedName(mappedName, &userName)) {
+ userName = mappedName;
}
- // Attribs can't be arrays, so we can skip some of the mess we have in the Uniform
- // path.
- nsDependentCString userName;
- if (!prog->FindAttribUserNameByMappedName(mappedName, &userName))
- userName.Rebind(mappedName, 0);
-
///////
const GLint loc = gl->fGetAttribLocation(prog->mGLName,
mappedName.BeginReading());
-
#ifdef DUMP_SHADERVAR_MAPPINGS
- printf_stderr("[attrib %u/%u] @%u %s->%s\n", i, numActiveAttribs, loc,
+ printf_stderr("[attrib %u/%u] @%i %s->%s\n", i, numActiveAttribs, loc,
userName.BeginReading(), mappedName.BeginReading());
#endif
///////
const bool isArray = false;
const RefPtr<WebGLActiveInfo> activeInfo = new WebGLActiveInfo(webgl, elemCount,
elemType, isArray,
userName,
mappedName);
const GLenum baseType = AttribBaseType(elemType);
- const webgl::AttribInfo attrib = {activeInfo, uint32_t(loc), baseType};
+ const webgl::AttribInfo attrib = {activeInfo, loc, baseType};
info->attribs.push_back(attrib);
}
- // Uniforms
+ // Uniforms (can be basically anything)
const bool needsCheckForArrays = gl->WorkAroundDriverBugs();
GLuint numActiveUniforms = 0;
gl->fGetProgramiv(prog->mGLName, LOCAL_GL_ACTIVE_UNIFORMS,
(GLint*)&numActiveUniforms);
for (GLuint i = 0; i < numActiveUniforms; i++) {
@@ -288,17 +273,16 @@ QueryProgramInfo(WebGLProgram* prog, gl:
GLsizei lengthWithoutNull = 0;
GLint elemCount = 0; // `size`
GLenum elemType = 0; // `type`
gl->fGetActiveUniform(prog->mGLName, i, mappedName.Length()+1, &lengthWithoutNull,
&elemCount, &elemType, mappedName.BeginWriting());
mappedName.SetLength(lengthWithoutNull);
- MOZ_ASSERT(mappedName.Find("gl_") != 0);
///////
nsAutoCString baseMappedName;
bool isArray;
size_t arrayIndex;
if (!ParseName(mappedName, &baseMappedName, &isArray, &arrayIndex))
MOZ_CRASH("GFX: Failed to parse `mappedName` received from driver.");
@@ -343,35 +327,32 @@ QueryProgramInfo(WebGLProgram* prog, gl:
auto* uniform = new webgl::UniformInfo(activeInfo);
info->uniforms.push_back(uniform);
if (uniform->mSamplerTexList) {
info->uniformSamplers.push_back(uniform);
}
}
- // Uniform Blocks
- // (no sampler types allowed!)
+ // Uniform Blocks (can be arrays, but can't contain sampler types)
if (gl->IsSupported(gl::GLFeature::uniform_buffer_object)) {
GLuint numActiveUniformBlocks = 0;
gl->fGetProgramiv(prog->mGLName, LOCAL_GL_ACTIVE_UNIFORM_BLOCKS,
(GLint*)&numActiveUniformBlocks);
for (GLuint i = 0; i < numActiveUniformBlocks; i++) {
nsAutoCString mappedName;
mappedName.SetLength(maxUniformBlockLenWithNull - 1);
GLint lengthWithoutNull;
gl->fGetActiveUniformBlockiv(prog->mGLName, i, LOCAL_GL_UNIFORM_BLOCK_NAME_LENGTH, &lengthWithoutNull);
gl->fGetActiveUniformBlockName(prog->mGLName, i, maxUniformBlockLenWithNull, &lengthWithoutNull, mappedName.BeginWriting());
mappedName.SetLength(lengthWithoutNull);
- MOZ_ASSERT(mappedName.Find("gl_") != 0);
-
////
nsCString userName;
if (!prog->UnmapUniformBlockName(mappedName, &userName))
continue;
#ifdef DUMP_SHADERVAR_MAPPINGS
printf_stderr("[uniform block %u/%u] %s->%s\n", i, numActiveUniformBlocks,
@@ -387,17 +368,17 @@ QueryProgramInfo(WebGLProgram* prog, gl:
auto* block = new webgl::UniformBlockInfo(webgl, userName, mappedName,
dataSize);
info->uniformBlocks.push_back(block);
}
}
- // Transform feedback varyings
+ // Transform feedback varyings (can be arrays)
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;
@@ -407,18 +388,16 @@ QueryProgramInfo(WebGLProgram* prog, gl:
GLsizei elemCount;
GLenum elemType;
gl->fGetTransformFeedbackVarying(prog->mGLName, i,
maxTransformFeedbackVaryingLenWithNull,
&lengthWithoutNull, &elemCount, &elemType,
mappedName.BeginWriting());
mappedName.SetLength(lengthWithoutNull);
- // Allowed to start with "gl_".
-
////
nsAutoCString baseMappedName;
bool isArray;
size_t arrayIndex;
if (!ParseName(mappedName, &baseMappedName, &isArray, &arrayIndex))
MOZ_CRASH("GFX: Failed to parse `mappedName` received from driver.");
@@ -1201,16 +1180,19 @@ WebGLProgram::ValidateAfterTentativeLink
attribName.BeginReading());
return false;
}
}
}
std::map<uint32_t, const webgl::AttribInfo*> attribsByLoc;
for (const auto& attrib : linkInfo->attribs) {
+ if (attrib.mLoc == -1)
+ continue;
+
const auto& elemType = attrib.mActiveInfo->mElemType;
const auto numUsedLocs = NumUsedLocationsByElemType(elemType);
for (uint32_t i = 0; i < numUsedLocs; i++) {
const uint32_t usedLoc = attrib.mLoc + i;
const auto res = attribsByLoc.insert({usedLoc, &attrib});
const bool& didInsert = res.second;
if (!didInsert) {
@@ -1385,17 +1367,17 @@ WebGLProgram::LinkAndUpdate()
return;
mMostRecentLinkInfo = QueryProgramInfo(this, gl);
MOZ_RELEASE_ASSERT(mMostRecentLinkInfo, "GFX: most recent link info not set.");
}
bool
WebGLProgram::FindAttribUserNameByMappedName(const nsACString& mappedName,
- nsDependentCString* const out_userName) const
+ nsCString* const out_userName) const
{
if (mVertShader->FindAttribUserNameByMappedName(mappedName, out_userName))
return true;
return false;
}
bool