Bug 1048745 - Non square UniformMatrix. r=jgilbert

This commit is contained in:
Dan Glastonbury 2015-03-23 11:29:32 +10:00
Родитель b8c700cc25
Коммит 800637e333
8 изменённых файлов: 246 добавлений и 127 удалений

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

@ -34,6 +34,8 @@ private:
virtual bool ValidateBufferTarget(GLenum target, const char* info) override; virtual bool ValidateBufferTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override; virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override; virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
}; };
} // namespace mozilla } // namespace mozilla

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

@ -5,7 +5,7 @@
#include "WebGL1Context.h" #include "WebGL1Context.h"
using namespace mozilla; namespace mozilla {
bool bool
WebGL1Context::ValidateAttribPointerType(bool /*integerMode*/, GLenum type, GLsizei* out_alignment, const char* info) WebGL1Context::ValidateAttribPointerType(bool /*integerMode*/, GLenum type, GLsizei* out_alignment, const char* info)
@ -33,3 +33,17 @@ WebGL1Context::ValidateAttribPointerType(bool /*integerMode*/, GLenum type, GLsi
ErrorInvalidEnumInfo(info, type); ErrorInvalidEnumInfo(info, type);
return false; return false;
} }
bool
WebGL1Context::ValidateUniformMatrixTranspose(bool transpose, const char* info)
{
if (transpose) {
ErrorInvalidValue("%s: transpose must be FALSE as per the "
"OpenGL ES 2.0 spec", info);
return false;
}
return true;
}
} // namespace mozilla

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

@ -108,6 +108,7 @@ public:
// Uniforms and attributes - WebGL2ContextUniforms.cpp // Uniforms and attributes - WebGL2ContextUniforms.cpp
void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset); void VertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, GLintptr offset);
// GL 3.0 & ES 3.0
void Uniform1ui(WebGLUniformLocation* location, GLuint v0); void Uniform1ui(WebGLUniformLocation* location, GLuint v0);
void Uniform2ui(WebGLUniformLocation* location, GLuint v0, GLuint v1); void Uniform2ui(WebGLUniformLocation* location, GLuint v0, GLuint v1);
void Uniform3ui(WebGLUniformLocation* location, GLuint v0, GLuint v1, GLuint v2); void Uniform3ui(WebGLUniformLocation* location, GLuint v0, GLuint v1, GLuint v2);
@ -116,18 +117,70 @@ public:
void Uniform2uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value); void Uniform2uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value);
void Uniform3uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value); void Uniform3uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value);
void Uniform4uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value); void Uniform4uiv(WebGLUniformLocation* location, const dom::Sequence<GLuint>& value);
void UniformMatrix2x3fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value); private:
void UniformMatrix2x3fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value); void UniformMatrix2x3fv_base(WebGLUniformLocation* loc, bool transpose,
void UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value); size_t arrayLength, const GLfloat* data);
void UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value); void UniformMatrix3x2fv_base(WebGLUniformLocation* loc, bool transpose,
void UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value); size_t arrayLength, const GLfloat* data);
void UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value); void UniformMatrix2x4fv_base(WebGLUniformLocation* loc, bool transpose,
void UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value); size_t arrayLength, const GLfloat* data);
void UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value); void UniformMatrix4x2fv_base(WebGLUniformLocation* loc, bool transpose,
void UniformMatrix3x4fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value); size_t arrayLength, const GLfloat* data);
void UniformMatrix3x4fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value); void UniformMatrix3x4fv_base(WebGLUniformLocation* loc, bool transpose,
void UniformMatrix4x3fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value); size_t arrayLength, const GLfloat* data);
void UniformMatrix4x3fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value); void UniformMatrix4x3fv_base(WebGLUniformLocation* loc, bool transpose,
size_t arrayLength, const GLfloat* data);
public:
// GL 2.1 & ES 3.0
void UniformMatrix2x3fv(WebGLUniformLocation* loc, bool transpose, const dom::Sequence<GLfloat>& value){
UniformMatrix2x3fv_base(loc, transpose, value.Length(), value.Elements());
}
void UniformMatrix2x4fv(WebGLUniformLocation* loc, bool transpose, const dom::Sequence<GLfloat>& value){
UniformMatrix2x4fv_base(loc, transpose, value.Length(), value.Elements());
}
void UniformMatrix3x2fv(WebGLUniformLocation* loc, bool transpose, const dom::Sequence<GLfloat>& value){
UniformMatrix3x2fv_base(loc, transpose, value.Length(), value.Elements());
}
void UniformMatrix3x4fv(WebGLUniformLocation* loc, bool transpose, const dom::Sequence<GLfloat>& value){
UniformMatrix3x4fv_base(loc, transpose, value.Length(), value.Elements());
}
void UniformMatrix4x2fv(WebGLUniformLocation* loc, bool transpose, const dom::Sequence<GLfloat>& value){
UniformMatrix4x2fv_base(loc, transpose, value.Length(), value.Elements());
}
void UniformMatrix4x3fv(WebGLUniformLocation* loc, bool transpose, const dom::Sequence<GLfloat>& value){
UniformMatrix4x3fv_base(loc, transpose, value.Length(), value.Elements());
}
void UniformMatrix2x3fv(WebGLUniformLocation* loc, bool transpose, const dom::Float32Array& value){
value.ComputeLengthAndData();
UniformMatrix2x3fv_base(loc, transpose, value.Length(), value.Data());
}
void UniformMatrix2x4fv(WebGLUniformLocation* loc, bool transpose, const dom::Float32Array& value){
value.ComputeLengthAndData();
UniformMatrix2x4fv_base(loc, transpose, value.Length(), value.Data());
}
void UniformMatrix3x2fv(WebGLUniformLocation* loc, bool transpose, const dom::Float32Array& value){
value.ComputeLengthAndData();
UniformMatrix3x2fv_base(loc, transpose, value.Length(), value.Data());
}
void UniformMatrix3x4fv(WebGLUniformLocation* loc, bool transpose, const dom::Float32Array& value){
value.ComputeLengthAndData();
UniformMatrix3x4fv_base(loc, transpose, value.Length(), value.Data());
}
void UniformMatrix4x2fv(WebGLUniformLocation* loc, bool transpose, const dom::Float32Array& value){
value.ComputeLengthAndData();
UniformMatrix4x2fv_base(loc, transpose, value.Length(), value.Data());
}
void UniformMatrix4x3fv(WebGLUniformLocation* loc, bool transpose, const dom::Float32Array& value){
value.ComputeLengthAndData();
UniformMatrix4x3fv_base(loc, transpose, value.Length(), value.Data());
}
private: private:
void VertexAttribI4iv(GLuint index, size_t length, const GLint* v); void VertexAttribI4iv(GLuint index, size_t length, const GLint* v);
@ -278,6 +331,8 @@ private:
virtual bool ValidateBufferTarget(GLenum target, const char* info) override; virtual bool ValidateBufferTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override; virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) override;
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override; virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) override;
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
}; };
} // namespace mozilla } // namespace mozilla

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

@ -74,6 +74,12 @@ WebGL2Context::ValidateAttribPointerType(bool integerMode, GLenum type,
return false; return false;
} }
bool
WebGL2Context::ValidateUniformMatrixTranspose(bool /*transpose*/, const char* /*info*/)
{
return true;
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Uniforms and attributes // Uniforms and attributes
@ -166,87 +172,111 @@ WebGL2Context::Uniform4uiv(WebGLUniformLocation* location,
} }
void void
WebGL2Context::UniformMatrix2x3fv(WebGLUniformLocation* location, bool transpose, WebGL2Context::UniformMatrix2x3fv_base(WebGLUniformLocation* loc, bool transpose,
const dom::Float32Array& value) size_t arrayLength, const GLfloat* data)
{ {
MOZ_CRASH("Not Implemented."); GLuint rawLoc;
GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 2, 3, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix2x3fv",
&rawLoc, &numElementsToUpload))
{
return;
}
MakeContextCurrent();
gl->fUniformMatrix2x3fv(rawLoc, numElementsToUpload, transpose, data);
} }
void void
WebGL2Context::UniformMatrix2x3fv(WebGLUniformLocation* location, bool transpose, WebGL2Context::UniformMatrix2x4fv_base(WebGLUniformLocation* loc, bool transpose,
const dom::Sequence<GLfloat>& value) size_t arrayLength, const GLfloat* data)
{ {
MOZ_CRASH("Not Implemented."); GLuint rawLoc;
GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 2, 4, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix2x4fv",
&rawLoc, &numElementsToUpload))
{
return;
}
MakeContextCurrent();
gl->fUniformMatrix2x4fv(rawLoc, numElementsToUpload, transpose, data);
} }
void void
WebGL2Context::UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose, WebGL2Context::UniformMatrix3x2fv_base(WebGLUniformLocation* loc, bool transpose,
const dom::Float32Array& value) size_t arrayLength, const GLfloat* data)
{ {
MOZ_CRASH("Not Implemented."); GLuint rawLoc;
GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 3, 2, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix3x2fv",
&rawLoc, &numElementsToUpload))
{
return;
}
MakeContextCurrent();
gl->fUniformMatrix3x2fv(rawLoc, numElementsToUpload, transpose, data);
} }
void void
WebGL2Context::UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose, WebGL2Context::UniformMatrix3x4fv_base(WebGLUniformLocation* loc, bool transpose,
const dom::Sequence<GLfloat>& value) size_t arrayLength, const GLfloat* data)
{ {
MOZ_CRASH("Not Implemented."); GLuint rawLoc;
GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 3, 4, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix3x4fv",
&rawLoc, &numElementsToUpload))
{
return;
}
MakeContextCurrent();
gl->fUniformMatrix3x4fv(rawLoc, numElementsToUpload, transpose, data);
} }
void void
WebGL2Context::UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose, WebGL2Context::UniformMatrix4x2fv_base(WebGLUniformLocation* loc, bool transpose,
const dom::Float32Array& value) size_t arrayLength, const GLfloat* data)
{ {
MOZ_CRASH("Not Implemented."); GLuint rawLoc;
GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 4, 2, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix4x2fv",
&rawLoc, &numElementsToUpload))
{
return;
}
MakeContextCurrent();
gl->fUniformMatrix4x2fv(rawLoc, numElementsToUpload, transpose, data);
} }
void void
WebGL2Context::UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose, WebGL2Context::UniformMatrix4x3fv_base(WebGLUniformLocation* loc, bool transpose,
const dom::Sequence<GLfloat>& value) size_t arrayLength, const GLfloat* data)
{ {
MOZ_CRASH("Not Implemented."); GLuint rawLoc;
} GLsizei numElementsToUpload;
void if (!ValidateUniformMatrixArraySetter(loc, 4, 3, LOCAL_GL_FLOAT, arrayLength,
WebGL2Context::UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose, transpose, "uniformMatrix4x3fv",
const dom::Float32Array& value) &rawLoc, &numElementsToUpload))
{ {
MOZ_CRASH("Not Implemented."); return;
} }
void MakeContextCurrent();
WebGL2Context::UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose, gl->fUniformMatrix4x3fv(rawLoc, numElementsToUpload, transpose, data);
const dom::Sequence<GLfloat>& value)
{
MOZ_CRASH("Not Implemented.");
}
void
WebGL2Context::UniformMatrix3x4fv(WebGLUniformLocation* location, bool transpose,
const dom::Float32Array& value)
{
MOZ_CRASH("Not Implemented.");
}
void
WebGL2Context::UniformMatrix3x4fv(WebGLUniformLocation* location, bool transpose,
const dom::Sequence<GLfloat>& value)
{
MOZ_CRASH("Not Implemented.");
}
void
WebGL2Context::UniformMatrix4x3fv(WebGLUniformLocation* location, bool transpose,
const dom::Float32Array& value)
{
MOZ_CRASH("Not Implemented.");
}
void
WebGL2Context::UniformMatrix4x3fv(WebGLUniformLocation* location, bool transpose,
const dom::Sequence<GLfloat>& value)
{
MOZ_CRASH("Not Implemented.");
} }
void void

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

@ -815,9 +815,8 @@ public:
UniformMatrix2fv_base(loc, transpose, value.Length(), UniformMatrix2fv_base(loc, transpose, value.Length(),
value.Elements()); value.Elements());
} }
void UniformMatrix2fv_base(WebGLUniformLocation* loc, void UniformMatrix2fv_base(WebGLUniformLocation* loc, bool transpose,
WebGLboolean transpose, size_t arrayLength, size_t arrayLength, const float* data);
const float* data);
void UniformMatrix3fv(WebGLUniformLocation* loc, WebGLboolean transpose, void UniformMatrix3fv(WebGLUniformLocation* loc, WebGLboolean transpose,
const dom::Float32Array& value) const dom::Float32Array& value)
@ -830,9 +829,8 @@ public:
{ {
UniformMatrix3fv_base(loc, transpose, value.Length(), value.Elements()); UniformMatrix3fv_base(loc, transpose, value.Length(), value.Elements());
} }
void UniformMatrix3fv_base(WebGLUniformLocation* loc, void UniformMatrix3fv_base(WebGLUniformLocation* loc, bool transpose,
WebGLboolean transpose, size_t arrayLength, size_t arrayLength, const float* data);
const float* data);
void UniformMatrix4fv(WebGLUniformLocation* loc, WebGLboolean transpose, void UniformMatrix4fv(WebGLUniformLocation* loc, WebGLboolean transpose,
const dom::Float32Array& value) const dom::Float32Array& value)
@ -840,15 +838,14 @@ public:
value.ComputeLengthAndData(); value.ComputeLengthAndData();
UniformMatrix4fv_base(loc, transpose, value.Length(), value.Data()); UniformMatrix4fv_base(loc, transpose, value.Length(), value.Data());
} }
void UniformMatrix4fv(WebGLUniformLocation* loc, WebGLboolean transpose, void UniformMatrix4fv(WebGLUniformLocation* loc, bool transpose,
const dom::Sequence<float>& value) const dom::Sequence<float>& value)
{ {
UniformMatrix4fv_base(loc, transpose, value.Length(), UniformMatrix4fv_base(loc, transpose, value.Length(),
value.Elements()); value.Elements());
} }
void UniformMatrix4fv_base(WebGLUniformLocation* loc, void UniformMatrix4fv_base(WebGLUniformLocation* loc, bool transpose,
WebGLboolean transpose, size_t arrayLength, size_t arrayLength, const float* data);
const float* data);
void UseProgram(WebGLProgram* prog); void UseProgram(WebGLProgram* prog);
@ -864,10 +861,13 @@ public:
GLuint* out_rawLoc, GLuint* out_rawLoc,
GLsizei* out_numElementsToUpload); GLsizei* out_numElementsToUpload);
bool ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc, bool ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
uint8_t setterDims, GLenum setterType, uint8_t setterCols,
uint8_t setterRows,
GLenum setterType,
size_t setterArraySize, size_t setterArraySize,
bool setterTranspose, bool setterTranspose,
const char* info, GLuint* out_rawLoc, const char* info,
GLuint* out_rawLoc,
GLsizei* out_numElementsToUpload); GLsizei* out_numElementsToUpload);
void ValidateProgram(WebGLProgram* prog); void ValidateProgram(WebGLProgram* prog);
bool ValidateUniformLocation(const char* info, WebGLUniformLocation* loc); bool ValidateUniformLocation(const char* info, WebGLUniformLocation* loc);
@ -1389,6 +1389,7 @@ private:
virtual bool ValidateBufferTarget(GLenum target, const char* info) = 0; virtual bool ValidateBufferTarget(GLenum target, const char* info) = 0;
virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) = 0; virtual bool ValidateBufferIndexedTarget(GLenum target, const char* info) = 0;
virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) = 0; virtual bool ValidateBufferForTarget(GLenum target, WebGLBuffer* buffer, const char* info) = 0;
virtual bool ValidateUniformMatrixTranspose(bool transpose, const char* info) = 0;
protected: protected:
int32_t MaxTextureSizeForTarget(TexTarget target) const { int32_t MaxTextureSizeForTarget(TexTarget target) const {

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

@ -2804,7 +2804,7 @@ WebGLContext::UniformMatrix2fv_base(WebGLUniformLocation* loc, bool transpose,
{ {
GLuint rawLoc; GLuint rawLoc;
GLsizei numElementsToUpload; GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 2, LOCAL_GL_FLOAT, arrayLength, if (!ValidateUniformMatrixArraySetter(loc, 2, 2, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix2fv", transpose, "uniformMatrix2fv",
&rawLoc, &numElementsToUpload)) &rawLoc, &numElementsToUpload))
{ {
@ -2821,7 +2821,7 @@ WebGLContext::UniformMatrix3fv_base(WebGLUniformLocation* loc, bool transpose,
{ {
GLuint rawLoc; GLuint rawLoc;
GLsizei numElementsToUpload; GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 3, LOCAL_GL_FLOAT, arrayLength, if (!ValidateUniformMatrixArraySetter(loc, 3, 3, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix3fv", transpose, "uniformMatrix3fv",
&rawLoc, &numElementsToUpload)) &rawLoc, &numElementsToUpload))
{ {
@ -2838,7 +2838,7 @@ WebGLContext::UniformMatrix4fv_base(WebGLUniformLocation* loc, bool transpose,
{ {
GLuint rawLoc; GLuint rawLoc;
GLsizei numElementsToUpload; GLsizei numElementsToUpload;
if (!ValidateUniformMatrixArraySetter(loc, 4, LOCAL_GL_FLOAT, arrayLength, if (!ValidateUniformMatrixArraySetter(loc, 4, 4, LOCAL_GL_FLOAT, arrayLength,
transpose, "uniformMatrix4fv", transpose, "uniformMatrix4fv",
&rawLoc, &numElementsToUpload)) &rawLoc, &numElementsToUpload))
{ {

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

@ -1539,7 +1539,8 @@ WebGLContext::ValidateUniformArraySetter(WebGLUniformLocation* loc,
bool bool
WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc, WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
uint8_t setterDims, uint8_t setterCols,
uint8_t setterRows,
GLenum setterType, GLenum setterType,
size_t setterArraySize, size_t setterArraySize,
bool setterTranspose, bool setterTranspose,
@ -1547,7 +1548,7 @@ WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
GLuint* const out_rawLoc, GLuint* const out_rawLoc,
GLsizei* const out_numElementsToUpload) GLsizei* const out_numElementsToUpload)
{ {
uint8_t setterElemSize = setterDims * setterDims; uint8_t setterElemSize = setterCols * setterRows;
if (IsContextLost()) if (IsContextLost())
return false; return false;
@ -1561,10 +1562,8 @@ WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, this, funcName)) if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, this, funcName))
return false; return false;
if (setterTranspose) { if (!ValidateUniformMatrixTranspose(setterTranspose, funcName))
ErrorInvalidValue("%s: `transpose` must be false.", funcName);
return false; return false;
}
*out_rawLoc = loc->mLoc; *out_rawLoc = loc->mLoc;
*out_numElementsToUpload = std::min((size_t)loc->mActiveInfo->mElemCount, *out_numElementsToUpload = std::min((size_t)loc->mActiveInfo->mElemCount,

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

@ -50,49 +50,67 @@ WebGLUniformLocation::ValidateForProgram(WebGLProgram* prog, WebGLContext* webgl
static bool static bool
IsUniformSetterTypeValid(GLenum setterType, GLenum uniformType) IsUniformSetterTypeValid(GLenum setterType, GLenum uniformType)
{ {
// The order in this switch matches table 2.10 from OpenGL ES
// 3.0.4 (Aug 27, 2014) es_spec_3.0.4.pdf
switch (uniformType) { switch (uniformType) {
case LOCAL_GL_BOOL:
case LOCAL_GL_BOOL_VEC2:
case LOCAL_GL_BOOL_VEC3:
case LOCAL_GL_BOOL_VEC4:
return setterType == LOCAL_GL_INT ||
setterType == LOCAL_GL_FLOAT; // GLfloat(0.0) sets a bool to false.
case LOCAL_GL_INT:
case LOCAL_GL_INT_SAMPLER_2D:
case LOCAL_GL_INT_SAMPLER_2D_ARRAY:
case LOCAL_GL_INT_SAMPLER_3D:
case LOCAL_GL_INT_SAMPLER_CUBE:
case LOCAL_GL_INT_VEC2:
case LOCAL_GL_INT_VEC3:
case LOCAL_GL_INT_VEC4:
case LOCAL_GL_SAMPLER_2D:
case LOCAL_GL_SAMPLER_2D_ARRAY:
case LOCAL_GL_SAMPLER_2D_ARRAY_SHADOW:
case LOCAL_GL_SAMPLER_2D_SHADOW:
case LOCAL_GL_SAMPLER_CUBE:
case LOCAL_GL_SAMPLER_CUBE_SHADOW:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_2D:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_3D:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE:
return setterType == LOCAL_GL_INT;
case LOCAL_GL_FLOAT: case LOCAL_GL_FLOAT:
case LOCAL_GL_FLOAT_MAT2:
case LOCAL_GL_FLOAT_MAT2x3:
case LOCAL_GL_FLOAT_MAT2x4:
case LOCAL_GL_FLOAT_MAT3:
case LOCAL_GL_FLOAT_MAT3x2:
case LOCAL_GL_FLOAT_MAT3x4:
case LOCAL_GL_FLOAT_MAT4:
case LOCAL_GL_FLOAT_MAT4x2:
case LOCAL_GL_FLOAT_MAT4x3:
case LOCAL_GL_FLOAT_VEC2: case LOCAL_GL_FLOAT_VEC2:
case LOCAL_GL_FLOAT_VEC3: case LOCAL_GL_FLOAT_VEC3:
case LOCAL_GL_FLOAT_VEC4: case LOCAL_GL_FLOAT_VEC4:
return setterType == LOCAL_GL_FLOAT; return setterType == LOCAL_GL_FLOAT;
case LOCAL_GL_INT:
case LOCAL_GL_INT_VEC2:
case LOCAL_GL_INT_VEC3:
case LOCAL_GL_INT_VEC4:
return setterType == LOCAL_GL_INT;
case LOCAL_GL_UNSIGNED_INT:
case LOCAL_GL_UNSIGNED_INT_VEC2:
case LOCAL_GL_UNSIGNED_INT_VEC3:
case LOCAL_GL_UNSIGNED_INT_VEC4:
return setterType == LOCAL_GL_UNSIGNED_INT;
/* bool can be set via any function: 0, 0.0f -> FALSE, _ -> TRUE */
case LOCAL_GL_BOOL:
case LOCAL_GL_BOOL_VEC2:
case LOCAL_GL_BOOL_VEC3:
case LOCAL_GL_BOOL_VEC4:
return (setterType == LOCAL_GL_INT ||
setterType == LOCAL_GL_FLOAT ||
setterType == LOCAL_GL_UNSIGNED_INT);
case LOCAL_GL_FLOAT_MAT2:
case LOCAL_GL_FLOAT_MAT3:
case LOCAL_GL_FLOAT_MAT4:
case LOCAL_GL_FLOAT_MAT2x3:
case LOCAL_GL_FLOAT_MAT2x4:
case LOCAL_GL_FLOAT_MAT3x2:
case LOCAL_GL_FLOAT_MAT3x4:
case LOCAL_GL_FLOAT_MAT4x2:
case LOCAL_GL_FLOAT_MAT4x3:
return setterType == LOCAL_GL_FLOAT;
/* Samplers can only be set via Uniform1i */
case LOCAL_GL_SAMPLER_2D:
case LOCAL_GL_SAMPLER_3D:
case LOCAL_GL_SAMPLER_CUBE:
case LOCAL_GL_SAMPLER_2D_SHADOW:
case LOCAL_GL_SAMPLER_2D_ARRAY:
case LOCAL_GL_SAMPLER_2D_ARRAY_SHADOW:
case LOCAL_GL_SAMPLER_CUBE_SHADOW:
case LOCAL_GL_INT_SAMPLER_2D:
case LOCAL_GL_INT_SAMPLER_3D:
case LOCAL_GL_INT_SAMPLER_CUBE:
case LOCAL_GL_INT_SAMPLER_2D_ARRAY:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_2D:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_3D:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_CUBE:
case LOCAL_GL_UNSIGNED_INT_SAMPLER_2D_ARRAY:
return setterType == LOCAL_GL_INT;
default: default:
MOZ_CRASH("Bad `uniformType`."); MOZ_CRASH("Bad `uniformType`.");
} }