Skip to content

Commit

Permalink
WebGLUniformsGroups: UBO Boolean support and fix cache on number (#27285
Browse files Browse the repository at this point in the history
)

* add boolean support and fix number cache

* fix const assignment

* good fix assignment to local var

* Update WebGLUniformsGroups.js

Improve comment.

---------

Co-authored-by: Michael Herzog <[email protected]>
  • Loading branch information
RenaudRohlinger and Mugen87 authored Dec 1, 2023
1 parent 0873a8a commit b019c39
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/renderers/webgl/WebGLUniformsGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {

const info = getUniformSize( value );

if ( typeof value === 'number' ) {
if ( typeof value === 'number' || typeof value === 'boolean' ) {

uniform.__data[ 0 ] = value;
gl.bufferSubData( gl.UNIFORM_BUFFER, offset + arrayOffset, uniform.__data );
Expand Down Expand Up @@ -164,7 +164,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {

// cache entry does not exist so far

if ( typeof value === 'number' ) {
if ( typeof value === 'number' || typeof value === 'boolean' ) {

cache[ index ] = value;

Expand All @@ -190,7 +190,7 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {

// compare current value with cached entry

if ( typeof value === 'number' ) {
if ( typeof value === 'number' || typeof value === 'boolean' ) {

if ( cache[ index ] !== value ) {

Expand All @@ -208,7 +208,16 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {

const cachedObject = cachedObjects[ i ];

if ( cachedObject.equals( values[ i ] ) === false ) {
if ( typeof cachedObject === 'number' || typeof cachedObject === 'boolean' ) {

if ( cachedObject !== values[ i ] ) {

cachedObjects[ i ] = values[ i ];
return true;

}

} else if ( cachedObject.equals( values[ i ] ) === false ) {

cachedObject.copy( values[ i ] );
return true;
Expand Down Expand Up @@ -312,9 +321,9 @@ function WebGLUniformsGroups( gl, info, capabilities, state ) {

// determine sizes according to STD140

if ( typeof value === 'number' ) {
if ( typeof value === 'number' || typeof value === 'boolean' ) {

// float/int
// float/int/bool

info.boundary = 4;
info.storage = 4;
Expand Down

0 comments on commit b019c39

Please sign in to comment.