Michael Herzog 1 год назад
Родитель
Сommit
d1c1340527

+ 1 - 1
examples/jsm/tsl/display/AfterImageNode.js

@@ -1,5 +1,5 @@
 import { RenderTarget, Vector2, QuadMesh, NodeMaterial, RendererUtils, TempNode, NodeUpdateType } from 'three/webgpu';
-import { nodeObject, Fn, float, vec4, uv, texture, passTexture, uniform, sign, max, convertToTexture } from 'three/tsl';
+import { nodeObject, Fn, float, uv, texture, passTexture, uniform, sign, max, convertToTexture } from 'three/tsl';
 
 /** @module AfterImageNode **/
 

+ 1 - 1
src/nodes/utils/MaxMipLevelNode.js

@@ -2,7 +2,7 @@ import UniformNode from '../core/UniformNode.js';
 import { NodeUpdateType } from '../core/constants.js';
 import { nodeProxy } from '../tsl/TSLBase.js';
 
-/** @module MatcapUVNode **/
+/** @module MaxMipLevelNode **/
 
 /**
  * A special type of uniform node that computes the

+ 65 - 6
src/renderers/common/TimestampQueryPool.js

@@ -1,30 +1,89 @@
+/**
+ * Abstract base class of a timestamp query pool.
+ *
+ * @abstract
+ */
 class TimestampQueryPool {
 
+	/**
+	 * Creates a new timestamp query pool.
+	 *
+	 * @param {Number} [maxQueries=256] - Maximum number of queries this pool can hold.
+	 */
 	constructor( maxQueries = 256 ) {
 
+		/**
+		 * Whether to track timestamps or not.
+		 *
+		 * @type {Boolean}
+		 * @default true
+		 */
 		this.trackTimestamp = true;
+
+		/**
+		 * Maximum number of queries this pool can hold.
+		 *
+		 * @type {Number}
+		 * @default 256
+		 */
 		this.maxQueries = maxQueries;
-		this.currentQueryIndex = 0; // how many queries allocated so far
-		this.queryOffsets = new Map(); // track offsets for different contexts
+
+		/**
+		 * How many queries allocated so far.
+		 *
+		 * @type {Number}
+		 * @default 0
+		 */
+		this.currentQueryIndex = 0;
+
+		/**
+		 * Tracks offsets for different contexts.
+		 *
+		 * @type {Map}
+		 */
+		this.queryOffsets = new Map();
+
+		/**
+		 * Whether the pool has been disposed or not.
+		 *
+		 * @type {Boolean}
+		 * @default false
+		 */
 		this.isDisposed = false;
+
+		/**
+		 * TODO
+		 *
+		 * @type {Number}
+		 * @default 0
+		 */
 		this.lastValue = 0;
+
+		/**
+		 * TODO
+		 *
+		 * @type {Boolean}
+		 * @default false
+		 */
 		this.pendingResolve = false;
 
 	}
 
 	/**
-     * Allocate queries for a specific renderContext.
+	 * Allocate queries for a specific renderContext.
 	 *
 	 * @abstract
-     */
+	 * @param {Object} renderContext - The render context to allocate queries for.
+	 */
 	allocateQueriesForContext( /* renderContext */ ) {}
 
 	/**
-     * Resolve all timestamps and return data (or process them).
+	 * Resolve all timestamps and return data (or process them).
 	 *
 	 * @abstract
+	 * @async
 	 * @returns {Promise<Number>|Number} The resolved timestamp value.
-     */
+	 */
 	async resolveQueriesAsync() {}
 
 	/**

+ 37 - 29
src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js

@@ -4,16 +4,18 @@ import TimestampQueryPool from '../../common/TimestampQueryPool.js';
 /**
  * Manages a pool of WebGL timestamp queries for performance measurement.
  * Handles creation, execution, and resolution of timer queries using WebGL extensions.
- * @extends TimestampQueryPool
+ *
+ * @augments TimestampQueryPool
  */
 class WebGLTimestampQueryPool extends TimestampQueryPool {
 
 	/**
-     * Creates a new WebGL timestamp query pool.
-     * @param {WebGLRenderingContext|WebGL2RenderingContext} gl - The WebGL context.
-     * @param {string} type - The type identifier for this query pool.
-     * @param {number} [maxQueries=2048] - Maximum number of queries this pool can hold.
-     */
+	 * Creates a new WebGL timestamp query pool.
+	 *
+	 * @param {WebGLRenderingContext|WebGL2RenderingContext} gl - The WebGL context.
+	 * @param {string} type - The type identifier for this query pool.
+	 * @param {number} [maxQueries=2048] - Maximum number of queries this pool can hold.
+	 */
 	constructor( gl, type, maxQueries = 2048 ) {
 
 		super( maxQueries );
@@ -23,7 +25,7 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
 
 		// Check for timer query extensions
 		this.ext = gl.getExtension( 'EXT_disjoint_timer_query_webgl2' ) ||
-                  gl.getExtension( 'EXT_disjoint_timer_query' );
+				  gl.getExtension( 'EXT_disjoint_timer_query' );
 
 		if ( ! this.ext ) {
 
@@ -47,10 +49,11 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Allocates a pair of queries for a given render context.
-     * @param {Object} renderContext - The render context to allocate queries for.
-     * @returns {?number} The base offset for the allocated queries, or null if allocation failed.
-     */
+	 * Allocates a pair of queries for a given render context.
+	 *
+	 * @param {Object} renderContext - The render context to allocate queries for.
+	 * @returns {Number?} The base offset for the allocated queries, or null if allocation failed.
+	 */
 	allocateQueriesForContext( renderContext ) {
 
 		if ( ! this.trackTimestamp ) return null;
@@ -75,9 +78,10 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Begins a timestamp query for the specified render context.
-     * @param {Object} renderContext - The render context to begin timing for.
-     */
+	 * Begins a timestamp query for the specified render context.
+	 *
+	 * @param {Object} renderContext - The render context to begin timing for.
+	 */
 	beginQuery( renderContext ) {
 
 		if ( ! this.trackTimestamp || this.isDisposed ) {
@@ -129,10 +133,11 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Ends the active timestamp query for the specified render context.
-     * @param {Object} renderContext - The render context to end timing for.
-     * @param {string} renderContext.id - Unique identifier for the render context.
-     */
+	 * Ends the active timestamp query for the specified render context.
+	 *
+	 * @param {Object} renderContext - The render context to end timing for.
+	 * @param {String} renderContext.id - Unique identifier for the render context.
+	 */
 	endQuery( renderContext ) {
 
 		if ( ! this.trackTimestamp || this.isDisposed ) {
@@ -173,9 +178,11 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Asynchronously resolves all completed queries and returns the total duration.
-     * @returns {Promise<number>} The total duration in milliseconds, or the last valid value if resolution fails.
-     */
+	 * Asynchronously resolves all completed queries and returns the total duration.
+	 *
+	 * @async
+	 * @returns {Promise<Number>} The total duration in milliseconds, or the last valid value if resolution fails.
+	 */
 	async resolveQueriesAsync() {
 
 		if ( ! this.trackTimestamp || this.pendingResolve ) {
@@ -236,11 +243,12 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Resolves a single query, checking for completion and disjoint operation.
-     * @private
-     * @param {WebGLQuery} query - The query object to resolve.
-     * @returns {Promise<number>} The elapsed time in milliseconds.
-     */
+	 * Resolves a single query, checking for completion and disjoint operation.
+	 *
+	 * @async
+	 * @param {WebGLQuery} query - The query object to resolve.
+	 * @returns {Promise<Number>} The elapsed time in milliseconds.
+	 */
 	async resolveQuery( query ) {
 
 		return new Promise( ( resolve ) => {
@@ -325,9 +333,9 @@ class WebGLTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Releases all resources held by this query pool.
-     * This includes deleting all query objects and clearing internal state.
-     */
+	 * Releases all resources held by this query pool.
+	 * This includes deleting all query objects and clearing internal state.
+	 */
 	dispose() {
 
 		if ( this.isDisposed ) {

+ 31 - 18
src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js

@@ -4,16 +4,18 @@ import TimestampQueryPool from '../../common/TimestampQueryPool.js';
 /**
  * Manages a pool of WebGPU timestamp queries for performance measurement.
  * Extends the base TimestampQueryPool to provide WebGPU-specific implementation.
- * @extends TimestampQueryPool
+ *
+ * @augments TimestampQueryPool
  */
 class WebGPUTimestampQueryPool extends TimestampQueryPool {
 
 	/**
-     * Creates a new WebGPU timestamp query pool.
-     * @param {GPUDevice} device - The WebGPU device to create queries on.
-     * @param {string} type - The type identifier for this query pool.
-     * @param {number} [maxQueries=2048] - Maximum number of queries this pool can hold.
-     */
+	 * Creates a new WebGPU timestamp query pool.
+	 *
+	 * @param {GPUDevice} device - The WebGPU device to create queries on.
+	 * @param {String} type - The type identifier for this query pool.
+	 * @param {Number} [maxQueries=2048] - Maximum number of queries this pool can hold.
+	 */
 	constructor( device, type, maxQueries = 2048 ) {
 
 		super( maxQueries );
@@ -42,10 +44,11 @@ class WebGPUTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Allocates a pair of queries for a given render context.
-     * @param {Object} renderContext - The render context to allocate queries for.
-     * @returns {?number} The base offset for the allocated queries, or null if allocation failed.
-     */
+	 * Allocates a pair of queries for a given render context.
+	 *
+	 * @param {Object} renderContext - The render context to allocate queries for.
+	 * @returns {Number?} The base offset for the allocated queries, or null if allocation failed.
+	 */
 	allocateQueriesForContext( renderContext ) {
 
 		if ( ! this.trackTimestamp || this.isDisposed ) return null;
@@ -66,10 +69,12 @@ class WebGPUTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Asynchronously resolves all pending queries and returns the total duration.
-     * If there's already a pending resolve operation, returns that promise instead.
-     * @returns {Promise<number>} The total duration in milliseconds, or the last valid value if resolution fails.
-     */
+	 * Asynchronously resolves all pending queries and returns the total duration.
+	 * If there's already a pending resolve operation, returns that promise instead.
+	 *
+	 * @async
+	 * @returns {Promise<Number>} The total duration in milliseconds, or the last valid value if resolution fails.
+	 */
 	async resolveQueriesAsync() {
 
 		if ( ! this.trackTimestamp || this.currentQueryIndex === 0 || this.isDisposed ) {
@@ -100,10 +105,12 @@ class WebGPUTimestampQueryPool extends TimestampQueryPool {
 	}
 
 	/**
-     * Internal method to resolve queries and calculate total duration.
-     * @private
-     * @returns {Promise<number>} The total duration in milliseconds.
-     */
+	 * Internal method to resolve queries and calculate total duration.
+	 *
+	 * @async
+	 * @private
+	 * @returns {Promise<Number>} The total duration in milliseconds.
+	 */
 	async _resolveQueries() {
 
 		if ( this.isDisposed ) {
@@ -202,6 +209,12 @@ class WebGPUTimestampQueryPool extends TimestampQueryPool {
 
 	}
 
+	/**
+	 * Dispose of the query pool.
+	 *
+	 * @async
+	 * @returns {Promise} A Promise that resolves when the dispose has been executed.
+	 */
 	async dispose() {
 
 		if ( this.isDisposed ) {

粤ICP备19079148号