mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
b=612334; fix webgl program-test test; r=bjacob
This commit is contained in:
parent
fe5e4b6c3b
commit
628a93151e
@ -1253,21 +1253,21 @@ public:
|
||||
return mAttachedShaders.RemoveElement(shader);
|
||||
}
|
||||
|
||||
PRBool HasBothShaderTypesAttached() {
|
||||
PRBool haveVertex = PR_FALSE;
|
||||
PRBool haveFrag = PR_FALSE;
|
||||
PRBool HasAttachedShaderOfType(GLenum shaderType) {
|
||||
for (PRUint32 i = 0; i < mAttachedShaders.Length(); ++i) {
|
||||
if (mAttachedShaders[i]->ShaderType() == LOCAL_GL_FRAGMENT_SHADER)
|
||||
haveFrag = PR_TRUE;
|
||||
else if (mAttachedShaders[i]->ShaderType() == LOCAL_GL_VERTEX_SHADER)
|
||||
haveVertex = PR_TRUE;
|
||||
if (haveFrag && haveVertex)
|
||||
if (mAttachedShaders[i]->ShaderType() == shaderType) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool HasBothShaderTypesAttached() {
|
||||
return
|
||||
HasAttachedShaderOfType(LOCAL_GL_VERTEX_SHADER) &&
|
||||
HasAttachedShaderOfType(LOCAL_GL_FRAGMENT_SHADER);
|
||||
}
|
||||
|
||||
PRBool NextGeneration()
|
||||
{
|
||||
if (!(mGeneration+1).valid())
|
||||
|
@ -162,6 +162,12 @@ WebGLContext::AttachShader(nsIWebGLProgram *pobj, nsIWebGLShader *shobj)
|
||||
!GetConcreteObjectAndGLName("attachShader: shader", shobj, &shader, &shadername))
|
||||
return NS_OK;
|
||||
|
||||
// Per GLSL ES 2.0, we can only have one of each type of shader
|
||||
// attached. This renders the next test somewhat moot, but we'll
|
||||
// leave it for when we support more than one shader of each type.
|
||||
if (program->HasAttachedShaderOfType(shader->ShaderType()))
|
||||
return ErrorInvalidOperation("AttachShader: only one of each type of shader may be attached to a program");
|
||||
|
||||
if (!program->AttachShader(shader))
|
||||
return ErrorInvalidOperation("AttachShader: shader is already attached");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user