Skip to content

Commit

Permalink
WebGLTextures: Directly evaluate capabilities. (#27340)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mugen87 authored Dec 8, 2023
1 parent 29ce872 commit 4ec8560
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { ColorManagement } from '../../math/ColorManagement.js';
function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {

const isWebGL2 = capabilities.isWebGL2;
const maxTextures = capabilities.maxTextures;
const maxCubemapSize = capabilities.maxCubemapSize;
const maxTextureSize = capabilities.maxTextureSize;
const maxSamples = capabilities.maxSamples;
const multisampledRTTExt = extensions.has( 'WEBGL_multisampled_render_to_texture' ) ? extensions.get( 'WEBGL_multisampled_render_to_texture' ) : null;
const supportsInvalidateFramebuffer = typeof navigator === 'undefined' ? false : /OculusBrowser/g.test( navigator.userAgent );

Expand Down Expand Up @@ -429,9 +425,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

const textureUnit = textureUnits;

if ( textureUnit >= maxTextures ) {
if ( textureUnit >= capabilities.maxTextures ) {

console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );
console.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + capabilities.maxTextures );

}

Expand Down Expand Up @@ -748,7 +744,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
_gl.pixelStorei( _gl.UNPACK_COLORSPACE_CONVERSION_WEBGL, unpackConversion );

const needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;
let image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );
let image = resizeImage( texture.image, needsPowerOfTwo, false, capabilities.maxTextureSize );
image = verifyColorSpace( texture, image );

const supportsMips = isPowerOfTwo( image ) || isWebGL2,
Expand Down Expand Up @@ -1174,7 +1170,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

if ( ! isCompressed && ! isDataTexture ) {

cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );
cubeImage[ i ] = resizeImage( texture.image[ i ], false, true, capabilities.maxCubemapSize );

} else {

Expand Down Expand Up @@ -2005,7 +2001,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

function getRenderTargetSamples( renderTarget ) {

return Math.min( maxSamples, renderTarget.samples );
return Math.min( capabilities.maxSamples, renderTarget.samples );

}

Expand Down

0 comments on commit 4ec8560

Please sign in to comment.