Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLTextures: Directly evaluate capabilities. #27340

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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