diff --git a/.eslintrc.js b/.eslintrc.js index 08a99ed6ad..765c76ca54 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -9,6 +9,7 @@ module.exports = { 'no-inline-comments': 0, camelcase: 0, 'max-statements': 0, + 'max-depth': 0, 'luma-gl-custom-rules/check-log-call': 1, 'import/no-unresolved': ['error'], 'import/no-extraneous-dependencies': [ diff --git a/docs/api-reference/webgl/program.md b/docs/api-reference/webgl/program.md index b35b4d218c..68625bf4ca 100644 --- a/docs/api-reference/webgl/program.md +++ b/docs/api-reference/webgl/program.md @@ -159,6 +159,7 @@ Notes: * Indexed rendering uses the element buffer (`GL.ELEMENT_ARRAY_BUFFER`), make sure your attributes or `VertexArray` contains one. * If a `TransformFeedback` object is supplied, `transformFeedback.begin()` and `transformFeedback.end()` will be called before and after the draw call. * A `Sampler` will only be bound if there is a matching Texture with the same key in the supplied `uniforms` object. +* Once a uniform is set, it's size should not be changed. This is only a concern for array uniforms. The following WebGL APIs are called in this function: diff --git a/docs/upgrade-guide.md b/docs/upgrade-guide.md index 8e2c68e8a3..03f36558fb 100644 --- a/docs/upgrade-guide.md +++ b/docs/upgrade-guide.md @@ -6,6 +6,7 @@ - `BaseModel` and `Model` have been consolidated in `Model`. `Model` be used as a substitute for `BaseModel` where necessary. - `AmbientLight`, `DirectionalLight`, `PointLight`, `PhongMaterial`, `PBRMaterial`, `CameraNode` have been removed from @luma.gl/core. These were either empty classes or simple data objects and so can be replaced by plain JavaScript objects in most cases. - `ShaderCache` has been removed and superseded by `ProgramManager`. +- `VertexArray.getDrawParams` no longer takes overrides as an argument. The calling function can manually override values as needed. - @luma.gl/glfx has been renamed to @luma.gl/effects. - @luma.gl/main has been removed. Use individual modules instead. - `Multipass` classes have been removed. diff --git a/examples/performance/stress-test/app.js b/examples/performance/stress-test/app.js index f0e369a902..b7bdaf8005 100644 --- a/examples/performance/stress-test/app.js +++ b/examples/performance/stress-test/app.js @@ -165,11 +165,16 @@ export default class AppAnimationLoop extends AnimationLoop { opaqueCubes, transparentCubes, angle, - statsWidget + statsWidget, + tick } = props; statsWidget.update(); + if (tick % 600 === 0) { + this.stats.reset(); + } + const camX = Math.cos(angle); const camZ = Math.sin(angle); const camRadius = 800; diff --git a/modules/core/src/lib/model.js b/modules/core/src/lib/model.js index e00e0cd3e7..8112d5a99c 100644 --- a/modules/core/src/lib/model.js +++ b/modules/core/src/lib/model.js @@ -17,6 +17,9 @@ const LOG_DRAW_TIMEOUT = 10000; const ERR_MODEL_PARAMS = 'Model needs drawMode and vertexCount'; +const NOOP = () => {}; +const DRAW_PARAMS = {}; + export default class Model { constructor(gl, props = {}) { // Deduce a helpful id @@ -25,6 +28,7 @@ export default class Model { this.id = id; this.gl = gl; this.id = props.id || uid('Model'); + this.debug = props.debug || false; this.lastLogTime = 0; // TODO - move to probe.gl this.initialize(props); } @@ -236,25 +240,34 @@ export default class Model { this.updateModuleSettings(moduleSettings); this.setUniforms(uniforms); - const logPriority = this._logDrawCallStart(2); + let logPriority; + + if (this.debug) { + logPriority = this._logDrawCallStart(2); + } + + const drawParams = this.vertexArray.getDrawParams(); + const { + isIndexed = drawParams.isIndexed, + indexType = drawParams.indexType, + indexOffset = drawParams.indexOffset, + vertexArrayInstanced = drawParams.isInstanced + } = this.props; - const drawParams = this.vertexArray.getDrawParams(this.props); - if (drawParams.isInstanced && !this.isInstanced) { + if (vertexArrayInstanced && !this.isInstanced) { log.warn('Found instanced attributes on non-instanced model', this.id)(); } - const {isIndexed, indexType, indexOffset} = drawParams; const {isInstanced, instanceCount} = this; - const noop = () => {}; - const {onBeforeRender = noop, onAfterRender = noop} = this.props; + const {onBeforeRender = NOOP, onAfterRender = NOOP} = this.props; onBeforeRender(); this.program.setUniforms(this.uniforms); const didDraw = this.program.draw( - Object.assign({}, opts, { + Object.assign(DRAW_PARAMS, opts, { logPriority, uniforms: null, // Already set (may contain "function values" not understood by Program) framebuffer, @@ -273,7 +286,9 @@ export default class Model { onAfterRender(); - this._logDrawCallEnd(logPriority, vertexArray, framebuffer); + if (this.debug) { + this._logDrawCallEnd(logPriority, vertexArray, framebuffer); + } return didDraw; } diff --git a/modules/webgl/src/classes/program.js b/modules/webgl/src/classes/program.js index 0534964fa4..0480a1e8b8 100644 --- a/modules/webgl/src/classes/program.js +++ b/modules/webgl/src/classes/program.js @@ -6,7 +6,7 @@ import Framebuffer from './framebuffer'; import {parseUniformName, getUniformSetter} from './uniforms'; import {VertexShader, FragmentShader} from './shader'; import ProgramConfiguration from './program-configuration'; -import {checkUniformValues, areUniformsEqual, getUniformCopy} from './uniforms'; +import {copyUniform, checkUniformValues} from './uniforms'; import {withParameters} from '../context'; import {assertWebGL2Context, isWebGL2, getKey} from '../webgl-utils'; @@ -54,9 +54,10 @@ export default class Program extends Resource { } initialize(props = {}) { - const {hash, vs, fs, varyings, bufferMode = GL_SEPARATE_ATTRIBS} = props; + const {hash, vs, fs, varyings, bufferMode = GL_SEPARATE_ATTRIBS, debug = false} = props; this.hash = hash || ''; // Used by ProgramManager + this.debug = debug; // Create shaders if needed this.vs = @@ -69,6 +70,8 @@ export default class Program extends Resource { // uniforms this.uniforms = {}; + this._texturesRenderable = true; + // Setup varyings if supplied if (varyings && varyings.length > 0) { assertWebGL2Context(this.gl); @@ -128,7 +131,7 @@ export default class Program extends Resource { this.setUniforms(uniforms || {}); } - if (logPriority !== undefined) { + if (this.debug && logPriority !== undefined) { const fb = framebuffer ? framebuffer.id : 'default'; const message = `mode=${getKey(this.gl, drawMode)} verts=${vertexCount} ` + @@ -185,22 +188,51 @@ export default class Program extends Resource { return true; } - setUniforms(uniforms = {}, _onChangeCallback = () => {}) { - // Simple change detection - if all uniforms are unchanged, do nothing - let somethingChanged = false; - const changedUniforms = {}; - for (const key in uniforms) { - if (!areUniformsEqual(this.uniforms[key], uniforms[key])) { - somethingChanged = true; - changedUniforms[key] = uniforms[key]; - this.uniforms[key] = getUniformCopy(uniforms[key]); - } + setUniforms(uniforms = {}) { + if (this.debug) { + checkUniformValues(uniforms, this.id, this._uniformSetters); } - if (somethingChanged) { - _onChangeCallback(); - checkUniformValues(changedUniforms, this.id, this._uniformSetters); - this._setUniforms(changedUniforms); + this.gl.useProgram(this.handle); + + for (const uniformName in uniforms) { + const uniform = uniforms[uniformName]; + const uniformSetter = this._uniformSetters[uniformName]; + + if (uniformSetter) { + let value = uniform; + let textureUpdate = false; + if (value instanceof Framebuffer) { + value = value.texture; + } + if (value instanceof Texture) { + textureUpdate = this.uniforms[uniformName] !== uniform; + + if (textureUpdate) { + // eslint-disable-next-line max-depth + if (uniformSetter.textureIndex === undefined) { + uniformSetter.textureIndex = this._textureIndexCounter++; + } + + // Bind texture to index + const texture = value; + const {textureIndex} = uniformSetter; + + texture.bind(textureIndex); + value = textureIndex; + + if (!texture.loaded) { + this._texturesRenderable = false; + } + } + } + + // NOTE(Tarek): uniformSetter returns whether + // value had to be updated or not. + if (uniformSetter(value) || textureUpdate) { + copyUniform(this.uniforms, uniformName, uniform); + } + } } return this; @@ -208,13 +240,14 @@ export default class Program extends Resource { // PRIVATE METHODS - // stub for shader chache, should reset uniforms to default valiues - reset() {} - // Checks if all texture-values uniforms are renderable (i.e. loaded) // Note: This is currently done before every draw call _areTexturesRenderable() { - let texturesRenderable = true; + if (this._texturesRenderable) { + return true; + } + + this._texturesRenderable = true; for (const uniformName in this.uniforms) { const uniformSetter = this._uniformSetters[uniformName]; @@ -230,12 +263,12 @@ export default class Program extends Resource { if (uniform instanceof Texture) { const texture = uniform; // Check that texture is loaded - texturesRenderable = texturesRenderable && texture.loaded; + this._texturesRenderable = this._texturesRenderable && texture.loaded; } } } - return texturesRenderable; + return this._texturesRenderable; } // Binds textures @@ -259,43 +292,6 @@ export default class Program extends Resource { } } - // Apply a set of uniform values to a program - // Only uniforms actually present in the linked program will be updated. - _setUniforms(uniforms) { - this.gl.useProgram(this.handle); - - for (const uniformName in uniforms) { - let uniform = uniforms[uniformName]; - const uniformSetter = this._uniformSetters[uniformName]; - - if (uniformSetter) { - if (uniform instanceof Framebuffer) { - uniform = uniform.texture; - } - if (uniform instanceof Texture) { - // eslint-disable-next-line max-depth - if (uniformSetter.textureIndex === undefined) { - uniformSetter.textureIndex = this._textureIndexCounter++; - } - - // Bind texture to index - const texture = uniform; - const {textureIndex} = uniformSetter; - - texture.bind(textureIndex); - - // Set the uniform sampler to the texture index - uniformSetter(textureIndex); - } else { - // Just set the value - uniformSetter(uniform); - } - } - } - - return this; - } - // RESOURCE METHODS _createHandle() { diff --git a/modules/webgl/src/classes/uniforms.js b/modules/webgl/src/classes/uniforms.js index 081534da90..9bee945969 100644 --- a/modules/webgl/src/classes/uniforms.js +++ b/modules/webgl/src/classes/uniforms.js @@ -2,72 +2,123 @@ import GL from '@luma.gl/constants'; import Framebuffer from './framebuffer'; import Renderbuffer from './renderbuffer'; import Texture from './texture'; -import {log} from '../utils'; +import {log, assert} from '../utils'; const UNIFORM_SETTERS = { // WEBGL1 /* eslint-disable max-len */ - [GL.FLOAT]: (gl, location, value) => gl.uniform1fv(location, toFloatArray(value, 1)), - [GL.FLOAT_VEC2]: (gl, location, value) => gl.uniform2fv(location, toFloatArray(value, 2)), - [GL.FLOAT_VEC3]: (gl, location, value) => gl.uniform3fv(location, toFloatArray(value, 3)), - [GL.FLOAT_VEC4]: (gl, location, value) => gl.uniform4fv(location, toFloatArray(value, 4)), + [GL.FLOAT]: getArraySetter.bind(null, 'uniform1fv', toFloatArray, 1, setVectorUniform), + [GL.FLOAT_VEC2]: getArraySetter.bind(null, 'uniform2fv', toFloatArray, 2, setVectorUniform), + [GL.FLOAT_VEC3]: getArraySetter.bind(null, 'uniform3fv', toFloatArray, 3, setVectorUniform), + [GL.FLOAT_VEC4]: getArraySetter.bind(null, 'uniform4fv', toFloatArray, 4, setVectorUniform), - [GL.INT]: (gl, location, value) => gl.uniform1iv(location, toIntArray(value, 1)), - [GL.INT_VEC2]: (gl, location, value) => gl.uniform2iv(location, toIntArray(value, 2)), - [GL.INT_VEC3]: (gl, location, value) => gl.uniform3iv(location, toIntArray(value, 3)), - [GL.INT_VEC4]: (gl, location, value) => gl.uniform4iv(location, toIntArray(value, 4)), + [GL.INT]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform), + [GL.INT_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform), + [GL.INT_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform), + [GL.INT_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform), - [GL.BOOL]: (gl, location, value) => gl.uniform1iv(location, toIntArray(value, 1)), - [GL.BOOL_VEC2]: (gl, location, value) => gl.uniform2iv(location, toIntArray(value, 2)), - [GL.BOOL_VEC3]: (gl, location, value) => gl.uniform3iv(location, toIntArray(value, 3)), - [GL.BOOL_VEC4]: (gl, location, value) => gl.uniform4iv(location, toIntArray(value, 4)), + [GL.BOOL]: getArraySetter.bind(null, 'uniform1iv', toIntArray, 1, setVectorUniform), + [GL.BOOL_VEC2]: getArraySetter.bind(null, 'uniform2iv', toIntArray, 2, setVectorUniform), + [GL.BOOL_VEC3]: getArraySetter.bind(null, 'uniform3iv', toIntArray, 3, setVectorUniform), + [GL.BOOL_VEC4]: getArraySetter.bind(null, 'uniform4iv', toIntArray, 4, setVectorUniform), // uniformMatrix(false): don't transpose the matrix - [GL.FLOAT_MAT2]: (gl, location, value) => - gl.uniformMatrix2fv(location, false, toFloatArray(value, 4)), - [GL.FLOAT_MAT3]: (gl, location, value) => - gl.uniformMatrix3fv(location, false, toFloatArray(value, 9)), - [GL.FLOAT_MAT4]: (gl, location, value) => - gl.uniformMatrix4fv(location, false, toFloatArray(value, 16)), + [GL.FLOAT_MAT2]: getArraySetter.bind(null, 'uniformMatrix2fv', toFloatArray, 4, setMatrixUniform), + [GL.FLOAT_MAT3]: getArraySetter.bind(null, 'uniformMatrix3fv', toFloatArray, 9, setMatrixUniform), + [GL.FLOAT_MAT4]: getArraySetter.bind( + null, + 'uniformMatrix4fv', + toFloatArray, + 16, + setMatrixUniform + ), - [GL.SAMPLER_2D]: (gl, location, value) => gl.uniform1i(location, value), - [GL.SAMPLER_CUBE]: (gl, location, value) => gl.uniform1i(location, value), + [GL.SAMPLER_2D]: getSamplerSetter, + [GL.SAMPLER_CUBE]: getSamplerSetter, // WEBGL2 - unsigned integers, irregular matrices, additional texture samplers - [GL.UNSIGNED_INT]: (gl, location, value) => gl.uniform1uiv(location, toUIntArray(value, 1)), - [GL.UNSIGNED_INT_VEC2]: (gl, location, value) => gl.uniform2uiv(location, toUIntArray(value, 2)), - [GL.UNSIGNED_INT_VEC3]: (gl, location, value) => gl.uniform3uiv(location, toUIntArray(value, 3)), - [GL.UNSIGNED_INT_VEC4]: (gl, location, value) => gl.uniform4uiv(location, toUIntArray(value, 4)), + [GL.UNSIGNED_INT]: getArraySetter.bind(null, 'uniform1uiv', toUIntArray, 1, setVectorUniform), + [GL.UNSIGNED_INT_VEC2]: getArraySetter.bind( + null, + 'uniform2uiv', + toUIntArray, + 2, + setVectorUniform + ), + [GL.UNSIGNED_INT_VEC3]: getArraySetter.bind( + null, + 'uniform3uiv', + toUIntArray, + 3, + setVectorUniform + ), + [GL.UNSIGNED_INT_VEC4]: getArraySetter.bind( + null, + 'uniform4uiv', + toUIntArray, + 4, + setVectorUniform + ), // uniformMatrix(false): don't transpose the matrix - [GL.FLOAT_MAT2x3]: (gl, location, value) => - gl.uniformMatrix2x3fv(location, false, toFloatArray(value, 6)), - [GL.FLOAT_MAT2x4]: (gl, location, value) => - gl.uniformMatrix2x4fv(location, false, toFloatArray(value, 8)), - [GL.FLOAT_MAT3x2]: (gl, location, value) => - gl.uniformMatrix3x2fv(location, false, toFloatArray(value, 6)), - [GL.FLOAT_MAT3x4]: (gl, location, value) => - gl.uniformMatrix3x4fv(location, false, toFloatArray(value, 12)), - [GL.FLOAT_MAT4x2]: (gl, location, value) => - gl.uniformMatrix4x2fv(location, false, toFloatArray(value, 8)), - [GL.FLOAT_MAT4x3]: (gl, location, value) => - gl.uniformMatrix4x3fv(location, false, toFloatArray(value, 12)), - - [GL.SAMPLER_3D]: (gl, location, value) => gl.uniform1i(location, value), - [GL.SAMPLER_2D_SHADOW]: (gl, location, value) => gl.uniform1i(location, value), - [GL.SAMPLER_2D_ARRAY]: (gl, location, value) => gl.uniform1i(location, value), - [GL.SAMPLER_2D_ARRAY_SHADOW]: (gl, location, value) => gl.uniform1i(location, value), - [GL.SAMPLER_CUBE_SHADOW]: (gl, location, value) => gl.uniform1i(location, value), - [GL.INT_SAMPLER_2D]: (gl, location, value) => gl.uniform1i(location, value), - [GL.INT_SAMPLER_3D]: (gl, location, value) => gl.uniform1i(location, value), - [GL.INT_SAMPLER_CUBE]: (gl, location, value) => gl.uniform1i(location, value), - [GL.INT_SAMPLER_2D_ARRAY]: (gl, location, value) => gl.uniform1i(location, value), - [GL.UNSIGNED_INT_SAMPLER_2D]: (gl, location, value) => gl.uniform1i(location, value), - [GL.UNSIGNED_INT_SAMPLER_3D]: (gl, location, value) => gl.uniform1i(location, value), - [GL.UNSIGNED_INT_SAMPLER_CUBE]: (gl, location, value) => gl.uniform1i(location, value), - [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: (gl, location, value) => gl.uniform1i(location, value) + [GL.FLOAT_MAT2x3]: getArraySetter.bind( + null, + 'uniformMatrix2x3fv', + toFloatArray, + 6, + setMatrixUniform + ), + [GL.FLOAT_MAT2x4]: getArraySetter.bind( + null, + 'uniformMatrix2x4fv', + toFloatArray, + 8, + setMatrixUniform + ), + [GL.FLOAT_MAT3x2]: getArraySetter.bind( + null, + 'uniformMatrix3x2fv', + toFloatArray, + 6, + setMatrixUniform + ), + [GL.FLOAT_MAT3x4]: getArraySetter.bind( + null, + 'uniformMatrix3x4fv', + toFloatArray, + 12, + setMatrixUniform + ), + [GL.FLOAT_MAT4x2]: getArraySetter.bind( + null, + 'uniformMatrix4x2fv', + toFloatArray, + 8, + setMatrixUniform + ), + [GL.FLOAT_MAT4x3]: getArraySetter.bind( + null, + 'uniformMatrix4x3fv', + toFloatArray, + 12, + setMatrixUniform + ), + + [GL.SAMPLER_3D]: getSamplerSetter, + [GL.SAMPLER_2D_SHADOW]: getSamplerSetter, + [GL.SAMPLER_2D_ARRAY]: getSamplerSetter, + [GL.SAMPLER_2D_ARRAY_SHADOW]: getSamplerSetter, + [GL.SAMPLER_CUBE_SHADOW]: getSamplerSetter, + [GL.INT_SAMPLER_2D]: getSamplerSetter, + [GL.INT_SAMPLER_3D]: getSamplerSetter, + [GL.INT_SAMPLER_CUBE]: getSamplerSetter, + [GL.INT_SAMPLER_2D_ARRAY]: getSamplerSetter, + [GL.UNSIGNED_INT_SAMPLER_2D]: getSamplerSetter, + [GL.UNSIGNED_INT_SAMPLER_3D]: getSamplerSetter, + [GL.UNSIGNED_INT_SAMPLER_CUBE]: getSamplerSetter, + [GL.UNSIGNED_INT_SAMPLER_2D_ARRAY]: getSamplerSetter /* eslint-enable max-len */ }; @@ -79,7 +130,8 @@ const UINT_ARRAY = {}; const array1 = [0]; // Functions to ensure the type of uniform values -// TODO - Why is this necessary? The uniform*v funtions can consume Arrays +// This is done because uniform*v functions +// are extremely slow when consuming JS arrays directly. function toTypedArray(value, uniformLength, Type, cache) { // convert boolean uniforms to Number if (uniformLength === 1 && typeof value === 'boolean') { @@ -151,7 +203,7 @@ export function getUniformSetter(gl, location, info) { if (!setter) { throw new Error(`Unknown GLSL uniform type ${info.type}`); } - return setter.bind(null, gl, location); + return setter().bind(null, gl, location); } // Basic checks of uniform values (with or without knowledge of program) @@ -211,33 +263,69 @@ function checkUniformArray(value) { } /** - * Given two values of a uniform, returns `true` if they are equal + * Creates a copy of the uniform */ -export function areUniformsEqual(uniform1, uniform2) { - if (Array.isArray(uniform1) || ArrayBuffer.isView(uniform1)) { - if (!uniform2) { - return false; +export function copyUniform(uniforms, key, value) { + if (Array.isArray(value) || ArrayBuffer.isView(value)) { + if (uniforms[key]) { + const dest = uniforms[key]; + for (let i = 0, len = value.length; i < len; ++i) { + dest[i] = value[i]; + } + } else { + uniforms[key] = value.slice(); } - const len = uniform1.length; - if (uniform2.length !== len) { - return false; + } else { + uniforms[key] = value; + } +} + +function getSamplerSetter() { + let cache = null; + return (gl, location, value) => { + const update = cache !== value; + if (update) { + gl.uniform1i(location, value); + cache = value; } - for (let i = 0; i < len; i++) { - if (uniform1[i] !== uniform2[i]) { - return false; + + return update; + }; +} + +function getArraySetter(functionName, toArray, size, uniformSetter) { + let cache = null; + let cacheLength = null; + return (gl, location, value) => { + const arrayValue = toArray(value, size); + const length = arrayValue.length; + let update = false; + if (cache === null) { + cache = new Float32Array(length); + cacheLength = length; + update = true; + } else { + assert(cacheLength === length, 'Uniform length cannot change.'); + for (let i = 0; i < length; ++i) { + if (arrayValue[i] !== cache[i]) { + update = true; + break; + } } } - return true; - } - return uniform1 === uniform2; + if (update) { + uniformSetter(gl, functionName, location, arrayValue); + cache.set(arrayValue); + } + + return update; + }; } -/** - * Creates a copy of the uniform - */ -export function getUniformCopy(uniform) { - if (Array.isArray(uniform) || ArrayBuffer.isView(uniform)) { - return uniform.slice(); - } - return uniform; +function setVectorUniform(gl, functionName, location, value) { + gl[functionName](location, value); +} + +function setMatrixUniform(gl, functionName, location, value) { + gl[functionName](location, false, value); } diff --git a/modules/webgl/src/classes/vertex-array.js b/modules/webgl/src/classes/vertex-array.js index 8be7bf1da1..4d3ec804e4 100644 --- a/modules/webgl/src/classes/vertex-array.js +++ b/modules/webgl/src/classes/vertex-array.js @@ -109,12 +109,11 @@ export default class VertexArray { this.drawParams = null; } - getDrawParams(appParameters) { + getDrawParams() { // Auto deduced draw parameters this.drawParams = this.drawParams || this._updateDrawParams(); - // Override with any application supplied draw parameters - return Object.assign({}, this.drawParams, appParameters); + return this.drawParams; } // Set (bind) an array or map of vertex array buffers, either in numbered or named locations. diff --git a/modules/webgl/test/classes/uniforms.spec.js b/modules/webgl/test/classes/uniforms.spec.js index 7ad55ddd9e..88d149639d 100644 --- a/modules/webgl/test/classes/uniforms.spec.js +++ b/modules/webgl/test/classes/uniforms.spec.js @@ -3,11 +3,7 @@ import test from 'tape-catch'; import {Program, Texture2D} from '@luma.gl/webgl'; import {isBrowser} from '@luma.gl/webgl/utils'; import {equals} from 'math.gl'; -import { - checkUniformValues, - areUniformsEqual, - parseUniformName -} from '@luma.gl/webgl/classes/uniforms'; +import {checkUniformValues, parseUniformName} from '@luma.gl/webgl/classes/uniforms'; import {fixture} from 'test/setup'; @@ -384,75 +380,6 @@ test('WebGL2#Uniforms Program setUniforms for scalar arrays', t => { } }); -test('WebGL#Uniforms areUniformsEqual', t => { - const {gl} = fixture; - - const TEST_TEXTURE = new Texture2D(gl); - - const TEST_CASES = [ - { - title: 'Numeric values', - value1: 1, - value2: 1, - equals: true - }, - { - title: 'Numeric values', - value1: 1, - value2: 2, - equals: false - }, - { - title: 'Texture objects', - value1: TEST_TEXTURE, - value2: TEST_TEXTURE, - equals: true - }, - { - title: 'Texture objects', - value1: TEST_TEXTURE, - value2: new Texture2D(gl), - equals: false - }, - { - title: 'null', - value1: null, - value2: null, - equals: true - }, - { - title: 'Array vs array', - value1: [0, 0, 0], - value2: [0, 0, 0], - equals: true - }, - { - title: 'TypedArray vs array', - value1: new Float32Array(3), - value2: [0, 0, 0], - equals: true - }, - { - title: 'Array different length', - value1: [0, 0, 0, 0], - value2: new Float32Array(3), - equals: false - }, - { - title: 'Array vs null', - value1: new Float32Array(3), - value2: null, - equals: false - } - ]; - - TEST_CASES.forEach(testCase => { - t.is(areUniformsEqual(testCase.value1, testCase.value2), testCase.equals, testCase.title); - }); - - t.end(); -}); - test('WebGL#Uniforms parseUniformName', t => { const regularUniform = parseUniformName('position'); t.equal(regularUniform.name, 'position');