Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion src/nodes/accessors/TextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,19 @@ class TextureNode extends UniformNode {
const gradSnippet = gradNode ? [ gradNode[ 0 ].build( builder, 'vec2' ), gradNode[ 1 ].build( builder, 'vec2' ) ] : null;
const offsetSnippet = offsetNode ? this.generateOffset( builder, offsetNode ) : null;

let finalDepthSnippet = depthSnippet;

if ( finalDepthSnippet === null && texture.isArrayTexture ) {

finalDepthSnippet = '0';

}

const nodeVar = builder.getVarFromNode( this );

propertyName = builder.getPropertyName( nodeVar );

let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, depthSnippet, compareSnippet, gradSnippet, offsetSnippet );
let snippet = this.generateSnippet( builder, textureProperty, uvSnippet, levelSnippet, biasSnippet, finalDepthSnippet, compareSnippet, gradSnippet, offsetSnippet );

if ( compareStepSnippet !== null ) {

Expand Down
2 changes: 1 addition & 1 deletion src/nodes/core/NodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ class NodeBuilder {
*/
getUniformBufferLimit() {

return 16384;
return this.renderer.backend.capabilities.getUniformBufferLimit();

}

Expand Down
8 changes: 0 additions & 8 deletions src/renderers/common/Backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -604,14 +604,6 @@ class Backend {
*/
hasFeature( /*name*/ ) {}

/**
* Returns the maximum anisotropy texture filtering value.
*
* @abstract
* @return {number} The maximum anisotropy texture filtering value.
*/
getMaxAnisotropy() {}

/**
* Returns the drawing buffer size.
*
Expand Down
2 changes: 1 addition & 1 deletion src/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,7 @@ class Renderer {
*/
getMaxAnisotropy() {

return this.backend.getMaxAnisotropy();
return this.backend.capabilities.getMaxAnisotropy();

}

Expand Down
11 changes: 0 additions & 11 deletions src/renderers/webgl-fallback/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -2009,17 +2009,6 @@ class WebGLBackend extends Backend {

}

/**
* Returns the maximum anisotropy texture filtering value.
*
* @return {number} The maximum anisotropy texture filtering value.
*/
getMaxAnisotropy() {

return this.capabilities.getMaxAnisotropy();

}

/**
* Copies data of the given source texture to the given destination texture.
*
Expand Down
12 changes: 0 additions & 12 deletions src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1316,18 +1316,6 @@ ${ flowData.code }

}

/**
* Returns the maximum number of bytes available for uniform buffers.
*
* @return {number} The maximum number of bytes available for uniform buffers.
*/
getUniformBufferLimit() {

const gl = this.renderer.backend.gl;
return gl.getParameter( gl.MAX_UNIFORM_BLOCK_SIZE );

}

/**
* Enables hardware clipping.
*
Expand Down
25 changes: 25 additions & 0 deletions src/renderers/webgl-fallback/utils/WebGLCapabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ class WebGLCapabilities {
*/
this.maxAnisotropy = null;

/**
* This value holds the cached max uniform block size value.
*
* @type {?number}
* @default null
*/
this.maxUniformBlockSize = null;

}

/**
Expand Down Expand Up @@ -59,6 +67,23 @@ class WebGLCapabilities {

}

/**
* Returns the maximum number of bytes available for uniform buffers.
*
* @return {number} The maximum number of bytes available for uniform buffers.
*/
getUniformBufferLimit() {

if ( this.maxUniformBlockSize !== null ) return this.maxUniformBlockSize;

const gl = this.backend.gl;

this.maxUniformBlockSize = gl.getParameter( gl.MAX_UNIFORM_BLOCK_SIZE );

return this.maxUniformBlockSize;

}

}

export default WebGLCapabilities;
2 changes: 1 addition & 1 deletion src/renderers/webgl-fallback/utils/WebGLTextureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class WebGLTextureUtils {
if ( texture.anisotropy > 1 ) {

const extension = extensions.get( 'EXT_texture_filter_anisotropic' );
gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, backend.getMaxAnisotropy() ) );
gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, backend.capabilities.getMaxAnisotropy() ) );

}

Expand Down
20 changes: 9 additions & 11 deletions src/renderers/webgpu/WebGPUBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Backend from '../common/Backend.js';
import WebGPUUtils from './utils/WebGPUUtils.js';
import WebGPUAttributeUtils from './utils/WebGPUAttributeUtils.js';
import WebGPUBindingUtils from './utils/WebGPUBindingUtils.js';
import WebGPUCapabilities from './utils/WebGPUCapabilities.js';
import WebGPUPipelineUtils from './utils/WebGPUPipelineUtils.js';
import WebGPUTextureUtils from './utils/WebGPUTextureUtils.js';

Expand Down Expand Up @@ -116,6 +117,14 @@ class WebGPUBackend extends Backend {
*/
this.bindingUtils = new WebGPUBindingUtils( this );

/**
* A reference to a backend module holding device capability related
* utility functions.
*
* @type {WebGPUCapabilities}
*/
this.capabilities = new WebGPUCapabilities( this );

/**
* A reference to a backend module holding shader pipeline-related
* utility functions.
Expand Down Expand Up @@ -2293,17 +2302,6 @@ class WebGPUBackend extends Backend {

// utils public

/**
* Returns the maximum anisotropy texture filtering value.
*
* @return {number} The maximum anisotropy texture filtering value.
*/
getMaxAnisotropy() {

return 16;

}

/**
* Checks if the given feature is supported by the backend.
*
Expand Down
11 changes: 0 additions & 11 deletions src/renderers/webgpu/nodes/WGSLNodeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2280,17 +2280,6 @@ ${ flowData.code }

}

/**
* Returns the maximum uniform buffer size limit.
*
* @return {number} The maximum uniform buffer size in bytes.
*/
getUniformBufferLimit() {

return this.renderer.backend.device.limits.maxUniformBufferBindingSize;

}

/**
* Returns the native shader method name for a given generic name.
*
Expand Down
48 changes: 48 additions & 0 deletions src/renderers/webgpu/utils/WebGPUCapabilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* A WebGPU backend utility module for managing the device's capabilities.
*
* @private
*/
class WebGPUCapabilities {

/**
* Constructs a new utility object.
*
* @param {WebGPUBackend} backend - The WebGPU backend.
*/
constructor( backend ) {

/**
* A reference to the WebGPU backend.
*
* @type {WebGPUBackend}
*/
this.backend = backend;

}

/**
* Returns the maximum anisotropy texture filtering value.
*
* @return {number} The maximum anisotropy texture filtering value.
*/
getMaxAnisotropy() {

return 16;

}

/**
* Returns the maximum number of bytes available for uniform buffers.
*
* @return {number} The maximum number of bytes available for uniform buffers.
*/
getUniformBufferLimit() {

return this.backend.device.limits.maxUniformBufferBindingSize;

}

}

export default WebGPUCapabilities;