未验证 提交 50702559 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #14038 from Mugen87/dev4

WebGLUniforms: Clean up
......@@ -372,12 +372,13 @@ function setValue4fm( gl, v ) {
function setValueT1( gl, v, renderer ) {
var cache = this.cache;
var unit = renderer.allocTextureUnit();
if ( this.cache[ 0 ] !== unit ) {
if ( cache[ 0 ] !== unit ) {
gl.uniform1i( this.addr, unit );
this.cache[ 0 ] = unit;
cache[ 0 ] = unit;
}
......@@ -387,12 +388,13 @@ function setValueT1( gl, v, renderer ) {
function setValueT6( gl, v, renderer ) {
var cache = this.cache;
var unit = renderer.allocTextureUnit();
if ( this.cache[ 0 ] !== unit ) {
if ( cache[ 0 ] !== unit ) {
gl.uniform1i( this.addr, unit );
this.cache[ 0 ] = unit;
cache[ 0 ] = unit;
}
......@@ -404,31 +406,37 @@ function setValueT6( gl, v, renderer ) {
function setValue2iv( gl, v ) {
if ( arraysEqual( this.cache, v ) ) return;
var cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform2iv( this.addr, v );
copyArray( this.cache, v );
copyArray( cache, v );
}
function setValue3iv( gl, v ) {
if ( arraysEqual( this.cache, v ) ) return;
var cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform3iv( this.addr, v );
copyArray( this.cache, v );
copyArray( cache, v );
}
function setValue4iv( gl, v ) {
if ( arraysEqual( this.cache, v ) ) return;
var cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform4iv( this.addr, v );
copyArray( this.cache, v );
copyArray( cache, v );
}
......@@ -463,13 +471,25 @@ function getSingularSetter( type ) {
function setValue1fv( gl, v ) {
var cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform1fv( this.addr, v );
copyArray( cache, v );
}
function setValue1iv( gl, v ) {
var cache = this.cache;
if ( arraysEqual( cache, v ) ) return;
gl.uniform1iv( this.addr, v );
copyArray( cache, v );
}
// Array of vectors (flat or from THREE classes)
......@@ -588,6 +608,7 @@ function PureArrayUniform( id, activeInfo, addr ) {
this.id = id;
this.addr = addr;
this.cache = [];
this.size = activeInfo.size;
this.setValue = getPureArraySetter( activeInfo.type );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册