зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1048745 - Non square UniformMatrix. r=jgilbert
This commit is contained in:
Родитель
b8c700cc25
Коммит
800637e333
|
@ -34,6 +34,8 @@ private:
|
|||
virtual bool ValidateBufferTarget(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 ValidateUniformMatrixTranspose(bool transpose, const char* info) override;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "WebGL1Context.h"
|
||||
|
||||
using namespace mozilla;
|
||||
namespace mozilla {
|
||||
|
||||
bool
|
||||
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);
|
||||
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
|
||||
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 Uniform2ui(WebGLUniformLocation* location, GLuint v0, GLuint v1);
|
||||
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 Uniform3uiv(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);
|
||||
void UniformMatrix2x3fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value);
|
||||
void UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value);
|
||||
void UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value);
|
||||
void UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value);
|
||||
void UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value);
|
||||
void UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value);
|
||||
void UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value);
|
||||
void UniformMatrix3x4fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value);
|
||||
void UniformMatrix3x4fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value);
|
||||
void UniformMatrix4x3fv(WebGLUniformLocation* location, bool transpose, const dom::Float32Array& value);
|
||||
void UniformMatrix4x3fv(WebGLUniformLocation* location, bool transpose, const dom::Sequence<GLfloat>& value);
|
||||
private:
|
||||
void UniformMatrix2x3fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const GLfloat* data);
|
||||
void UniformMatrix3x2fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const GLfloat* data);
|
||||
void UniformMatrix2x4fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const GLfloat* data);
|
||||
void UniformMatrix4x2fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const GLfloat* data);
|
||||
void UniformMatrix3x4fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const GLfloat* data);
|
||||
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:
|
||||
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 ValidateBufferIndexedTarget(GLenum target, 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
|
||||
|
|
|
@ -74,6 +74,12 @@ WebGL2Context::ValidateAttribPointerType(bool integerMode, GLenum type,
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
WebGL2Context::ValidateUniformMatrixTranspose(bool /*transpose*/, const char* /*info*/)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Uniforms and attributes
|
||||
|
||||
|
@ -166,87 +172,111 @@ WebGL2Context::Uniform4uiv(WebGLUniformLocation* location,
|
|||
}
|
||||
|
||||
void
|
||||
WebGL2Context::UniformMatrix2x3fv(WebGLUniformLocation* location, bool transpose,
|
||||
const dom::Float32Array& value)
|
||||
WebGL2Context::UniformMatrix2x3fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
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
|
||||
WebGL2Context::UniformMatrix2x3fv(WebGLUniformLocation* location, bool transpose,
|
||||
const dom::Sequence<GLfloat>& value)
|
||||
WebGL2Context::UniformMatrix2x4fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
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
|
||||
WebGL2Context::UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose,
|
||||
const dom::Float32Array& value)
|
||||
WebGL2Context::UniformMatrix3x2fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
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
|
||||
WebGL2Context::UniformMatrix3x2fv(WebGLUniformLocation* location, bool transpose,
|
||||
const dom::Sequence<GLfloat>& value)
|
||||
WebGL2Context::UniformMatrix3x4fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
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
|
||||
WebGL2Context::UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose,
|
||||
const dom::Float32Array& value)
|
||||
WebGL2Context::UniformMatrix4x2fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
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
|
||||
WebGL2Context::UniformMatrix2x4fv(WebGLUniformLocation* location, bool transpose,
|
||||
const dom::Sequence<GLfloat>& value)
|
||||
WebGL2Context::UniformMatrix4x3fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const GLfloat* data)
|
||||
{
|
||||
MOZ_CRASH("Not Implemented.");
|
||||
GLuint rawLoc;
|
||||
GLsizei numElementsToUpload;
|
||||
|
||||
if (!ValidateUniformMatrixArraySetter(loc, 4, 3, LOCAL_GL_FLOAT, arrayLength,
|
||||
transpose, "uniformMatrix4x3fv",
|
||||
&rawLoc, &numElementsToUpload))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose,
|
||||
const dom::Float32Array& value)
|
||||
{
|
||||
MOZ_CRASH("Not Implemented.");
|
||||
}
|
||||
|
||||
void
|
||||
WebGL2Context::UniformMatrix4x2fv(WebGLUniformLocation* location, bool transpose,
|
||||
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.");
|
||||
MakeContextCurrent();
|
||||
gl->fUniformMatrix4x3fv(rawLoc, numElementsToUpload, transpose, data);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -815,9 +815,8 @@ public:
|
|||
UniformMatrix2fv_base(loc, transpose, value.Length(),
|
||||
value.Elements());
|
||||
}
|
||||
void UniformMatrix2fv_base(WebGLUniformLocation* loc,
|
||||
WebGLboolean transpose, size_t arrayLength,
|
||||
const float* data);
|
||||
void UniformMatrix2fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const float* data);
|
||||
|
||||
void UniformMatrix3fv(WebGLUniformLocation* loc, WebGLboolean transpose,
|
||||
const dom::Float32Array& value)
|
||||
|
@ -830,9 +829,8 @@ public:
|
|||
{
|
||||
UniformMatrix3fv_base(loc, transpose, value.Length(), value.Elements());
|
||||
}
|
||||
void UniformMatrix3fv_base(WebGLUniformLocation* loc,
|
||||
WebGLboolean transpose, size_t arrayLength,
|
||||
const float* data);
|
||||
void UniformMatrix3fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const float* data);
|
||||
|
||||
void UniformMatrix4fv(WebGLUniformLocation* loc, WebGLboolean transpose,
|
||||
const dom::Float32Array& value)
|
||||
|
@ -840,15 +838,14 @@ public:
|
|||
value.ComputeLengthAndData();
|
||||
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)
|
||||
{
|
||||
UniformMatrix4fv_base(loc, transpose, value.Length(),
|
||||
value.Elements());
|
||||
}
|
||||
void UniformMatrix4fv_base(WebGLUniformLocation* loc,
|
||||
WebGLboolean transpose, size_t arrayLength,
|
||||
const float* data);
|
||||
void UniformMatrix4fv_base(WebGLUniformLocation* loc, bool transpose,
|
||||
size_t arrayLength, const float* data);
|
||||
|
||||
void UseProgram(WebGLProgram* prog);
|
||||
|
||||
|
@ -864,10 +861,13 @@ public:
|
|||
GLuint* out_rawLoc,
|
||||
GLsizei* out_numElementsToUpload);
|
||||
bool ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
||||
uint8_t setterDims, GLenum setterType,
|
||||
uint8_t setterCols,
|
||||
uint8_t setterRows,
|
||||
GLenum setterType,
|
||||
size_t setterArraySize,
|
||||
bool setterTranspose,
|
||||
const char* info, GLuint* out_rawLoc,
|
||||
const char* info,
|
||||
GLuint* out_rawLoc,
|
||||
GLsizei* out_numElementsToUpload);
|
||||
void ValidateProgram(WebGLProgram* prog);
|
||||
bool ValidateUniformLocation(const char* info, WebGLUniformLocation* loc);
|
||||
|
@ -1389,6 +1389,7 @@ private:
|
|||
virtual bool ValidateBufferTarget(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 ValidateUniformMatrixTranspose(bool transpose, const char* info) = 0;
|
||||
|
||||
protected:
|
||||
int32_t MaxTextureSizeForTarget(TexTarget target) const {
|
||||
|
|
|
@ -2804,7 +2804,7 @@ WebGLContext::UniformMatrix2fv_base(WebGLUniformLocation* loc, bool transpose,
|
|||
{
|
||||
GLuint rawLoc;
|
||||
GLsizei numElementsToUpload;
|
||||
if (!ValidateUniformMatrixArraySetter(loc, 2, LOCAL_GL_FLOAT, arrayLength,
|
||||
if (!ValidateUniformMatrixArraySetter(loc, 2, 2, LOCAL_GL_FLOAT, arrayLength,
|
||||
transpose, "uniformMatrix2fv",
|
||||
&rawLoc, &numElementsToUpload))
|
||||
{
|
||||
|
@ -2821,7 +2821,7 @@ WebGLContext::UniformMatrix3fv_base(WebGLUniformLocation* loc, bool transpose,
|
|||
{
|
||||
GLuint rawLoc;
|
||||
GLsizei numElementsToUpload;
|
||||
if (!ValidateUniformMatrixArraySetter(loc, 3, LOCAL_GL_FLOAT, arrayLength,
|
||||
if (!ValidateUniformMatrixArraySetter(loc, 3, 3, LOCAL_GL_FLOAT, arrayLength,
|
||||
transpose, "uniformMatrix3fv",
|
||||
&rawLoc, &numElementsToUpload))
|
||||
{
|
||||
|
@ -2838,7 +2838,7 @@ WebGLContext::UniformMatrix4fv_base(WebGLUniformLocation* loc, bool transpose,
|
|||
{
|
||||
GLuint rawLoc;
|
||||
GLsizei numElementsToUpload;
|
||||
if (!ValidateUniformMatrixArraySetter(loc, 4, LOCAL_GL_FLOAT, arrayLength,
|
||||
if (!ValidateUniformMatrixArraySetter(loc, 4, 4, LOCAL_GL_FLOAT, arrayLength,
|
||||
transpose, "uniformMatrix4fv",
|
||||
&rawLoc, &numElementsToUpload))
|
||||
{
|
||||
|
|
|
@ -1539,7 +1539,8 @@ WebGLContext::ValidateUniformArraySetter(WebGLUniformLocation* loc,
|
|||
|
||||
bool
|
||||
WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
||||
uint8_t setterDims,
|
||||
uint8_t setterCols,
|
||||
uint8_t setterRows,
|
||||
GLenum setterType,
|
||||
size_t setterArraySize,
|
||||
bool setterTranspose,
|
||||
|
@ -1547,7 +1548,7 @@ WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
|||
GLuint* const out_rawLoc,
|
||||
GLsizei* const out_numElementsToUpload)
|
||||
{
|
||||
uint8_t setterElemSize = setterDims * setterDims;
|
||||
uint8_t setterElemSize = setterCols * setterRows;
|
||||
|
||||
if (IsContextLost())
|
||||
return false;
|
||||
|
@ -1561,10 +1562,8 @@ WebGLContext::ValidateUniformMatrixArraySetter(WebGLUniformLocation* loc,
|
|||
if (!loc->ValidateArrayLength(setterElemSize, setterArraySize, this, funcName))
|
||||
return false;
|
||||
|
||||
if (setterTranspose) {
|
||||
ErrorInvalidValue("%s: `transpose` must be false.", funcName);
|
||||
if (!ValidateUniformMatrixTranspose(setterTranspose, funcName))
|
||||
return false;
|
||||
}
|
||||
|
||||
*out_rawLoc = loc->mLoc;
|
||||
*out_numElementsToUpload = std::min((size_t)loc->mActiveInfo->mElemCount,
|
||||
|
|
|
@ -50,49 +50,67 @@ WebGLUniformLocation::ValidateForProgram(WebGLProgram* prog, WebGLContext* webgl
|
|||
static bool
|
||||
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) {
|
||||
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_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_VEC3:
|
||||
case LOCAL_GL_FLOAT_VEC4:
|
||||
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:
|
||||
MOZ_CRASH("Bad `uniformType`.");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче