Bug 845636 - WebGL uniform1i should generate INVALID_VALUE for invalid texture units - r=bjacob

This commit is contained in:
Jeff Gilbert 2013-03-04 16:44:31 -08:00
Родитель df010bad60
Коммит ba0297075f
3 изменённых файлов: 77 добавлений и 0 удалений

Просмотреть файл

@ -764,6 +764,9 @@ public:
bool ValidateUniformSetter(const char* name, WebGLUniformLocation *location_object, GLint& location);
void ValidateProgram(WebGLProgram *prog);
bool ValidateUniformLocation(const char* info, WebGLUniformLocation *location_object);
bool ValidateSamplerUniformSetter(const char* info,
WebGLUniformLocation *location,
WebGLint value);
void VertexAttrib1f(WebGLuint index, WebGLfloat x0);
void VertexAttrib2f(WebGLuint index, WebGLfloat x0, WebGLfloat x1);

Просмотреть файл

@ -3673,12 +3673,17 @@ WebGLContext::SurfaceFromElementResultToImageSurface(nsLayoutUtils::SurfaceFromE
}
void
WebGLContext::Uniform1i(WebGLUniformLocation *location_object, WebGLint a1)
{
GLint location;
if (!ValidateUniformSetter("Uniform1i", location_object, location))
return;
if (!ValidateSamplerUniformSetter("Uniform1i", location_object, a1))
return;
MakeContextCurrent();
gl->fUniform1i(location, a1);
}
@ -3690,6 +3695,13 @@ WebGLContext::Uniform2i(WebGLUniformLocation *location_object, WebGLint a1,
GLint location;
if (!ValidateUniformSetter("Uniform2i", location_object, location))
return;
if (!ValidateSamplerUniformSetter("Uniform2i", location_object, a1) ||
!ValidateSamplerUniformSetter("Uniform2i", location_object, a2))
{
return;
}
MakeContextCurrent();
gl->fUniform2i(location, a1, a2);
}
@ -3701,6 +3713,14 @@ WebGLContext::Uniform3i(WebGLUniformLocation *location_object, WebGLint a1,
GLint location;
if (!ValidateUniformSetter("Uniform3i", location_object, location))
return;
if (!ValidateSamplerUniformSetter("Uniform3i", location_object, a1) ||
!ValidateSamplerUniformSetter("Uniform3i", location_object, a2) ||
!ValidateSamplerUniformSetter("Uniform3i", location_object, a3))
{
return;
}
MakeContextCurrent();
gl->fUniform3i(location, a1, a2, a3);
}
@ -3712,6 +3732,15 @@ WebGLContext::Uniform4i(WebGLUniformLocation *location_object, WebGLint a1,
GLint location;
if (!ValidateUniformSetter("Uniform4i", location_object, location))
return;
if (!ValidateSamplerUniformSetter("Uniform4i", location_object, a1) ||
!ValidateSamplerUniformSetter("Uniform4i", location_object, a2) ||
!ValidateSamplerUniformSetter("Uniform4i", location_object, a3) ||
!ValidateSamplerUniformSetter("Uniform4i", location_object, a4))
{
return;
}
MakeContextCurrent();
gl->fUniform4i(location, a1, a2, a3, a4);
}
@ -3769,6 +3798,10 @@ WebGLContext::Uniform1iv_base(WebGLUniformLocation *location_object,
numElementsToUpload, arrayLength)) {
return;
}
if (!ValidateSamplerUniformSetter("Uniform1iv", location_object, data[0]))
return;
MakeContextCurrent();
gl->fUniform1iv(location, numElementsToUpload, data);
}
@ -3783,6 +3816,13 @@ WebGLContext::Uniform2iv_base(WebGLUniformLocation *location_object,
numElementsToUpload, arrayLength)) {
return;
}
if (!ValidateSamplerUniformSetter("Uniform2iv", location_object, data[0]) ||
!ValidateSamplerUniformSetter("Uniform2iv", location_object, data[1]))
{
return;
}
MakeContextCurrent();
gl->fUniform2iv(location, numElementsToUpload, data);
}
@ -3797,6 +3837,14 @@ WebGLContext::Uniform3iv_base(WebGLUniformLocation *location_object,
numElementsToUpload, arrayLength)) {
return;
}
if (!ValidateSamplerUniformSetter("Uniform3iv", location_object, data[0]) ||
!ValidateSamplerUniformSetter("Uniform3iv", location_object, data[1]) ||
!ValidateSamplerUniformSetter("Uniform3iv", location_object, data[2]))
{
return;
}
MakeContextCurrent();
gl->fUniform3iv(location, numElementsToUpload, data);
}
@ -3811,6 +3859,15 @@ WebGLContext::Uniform4iv_base(WebGLUniformLocation *location_object,
numElementsToUpload, arrayLength)) {
return;
}
if (!ValidateSamplerUniformSetter("Uniform4iv", location_object, data[0]) ||
!ValidateSamplerUniformSetter("Uniform4iv", location_object, data[1]) ||
!ValidateSamplerUniformSetter("Uniform4iv", location_object, data[2]) ||
!ValidateSamplerUniformSetter("Uniform4iv", location_object, data[3]))
{
return;
}
MakeContextCurrent();
gl->fUniform4iv(location, numElementsToUpload, data);
}

Просмотреть файл

@ -688,6 +688,23 @@ WebGLContext::ValidateUniformLocation(const char* info, WebGLUniformLocation *lo
return true;
}
bool
WebGLContext::ValidateSamplerUniformSetter(const char* info, WebGLUniformLocation *location, WebGLint value)
{
if (location->Info().type != SH_SAMPLER_2D &&
location->Info().type != SH_SAMPLER_CUBE)
{
return true;
}
if (value >= 0 && value < mGLMaxTextureUnits)
return true;
ErrorInvalidValue("%s: this uniform location is a sampler, but %d is not a valid texture unit",
info, value);
return false;
}
bool
WebGLContext::ValidateAttribArraySetter(const char* name, uint32_t cnt, uint32_t arrayLength)
{