@babylonjs/core 7.48.1 → 7.48.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { Nullable, IndicesArray, DataArray, FloatArray, DeepImmutable } from "../types";
1
+ import type { Nullable, IndicesArray, DataArray, FloatArray, DeepImmutable, int } from "../types";
2
2
  import { Engine } from "../Engines/engine";
3
3
  import type { VertexBuffer } from "../Buffers/buffer";
4
4
  import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture";
@@ -23,6 +23,7 @@ import type { ShaderProcessingContext } from "./Processors/shaderProcessingOptio
23
23
  import type { ShaderLanguage } from "../Materials/shaderLanguage";
24
24
  import type { WebGLHardwareTexture } from "./WebGL/webGLHardwareTexture";
25
25
  import "../Buffers/buffer.align";
26
+ import { _TimeToken } from "../Instrumentation/timeToken";
26
27
  declare module "../Materials/effect" {
27
28
  /** internal */
28
29
  interface Effect {
@@ -68,6 +69,7 @@ export declare class NativeEngine extends Engine {
68
69
  private readonly _engine;
69
70
  private readonly _camera;
70
71
  private readonly _commandBufferEncoder;
72
+ private readonly _frameStats;
71
73
  private _boundBuffersVertexArray;
72
74
  private _currentDepthTest;
73
75
  private _stencilTest;
@@ -539,5 +541,7 @@ export declare class NativeEngine extends Engine {
539
541
  */
540
542
  flushFramebuffer(): void;
541
543
  _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, _flushRenderer?: boolean, _noDataConversion?: boolean, x?: number, y?: number): Promise<ArrayBufferView>;
544
+ startTimeQuery(): Nullable<_TimeToken>;
545
+ endTimeQuery(token: _TimeToken): int;
542
546
  }
543
547
  export {};
@@ -20,6 +20,7 @@ import { checkNonFloatVertexBuffers } from "../Buffers/buffer.nonFloatVertexBuff
20
20
  import { NativeShaderProcessingContext } from "./Native/nativeShaderProcessingContext.js";
21
21
  import "../Buffers/buffer.align.js";
22
22
  import { _GetCompatibleTextureLoader } from "../Materials/Textures/Loaders/textureLoaderManager.js";
23
+ import { _TimeToken } from "../Instrumentation/timeToken.js";
23
24
  const onNativeObjectInitialized = new Observable();
24
25
  if (typeof self !== "undefined" && !Object.prototype.hasOwnProperty.call(self, "_native")) {
25
26
  let __native;
@@ -131,6 +132,7 @@ export class NativeEngine extends Engine {
131
132
  });
132
133
  this._camera = _native.Camera ? new _native.Camera() : null;
133
134
  this._commandBufferEncoder = new CommandBufferEncoder(this._engine);
135
+ this._frameStats = { gpuTimeNs: Number.NaN };
134
136
  this._boundBuffersVertexArray = null;
135
137
  this._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL;
136
138
  this._stencilTest = false;
@@ -2103,6 +2105,17 @@ export class NativeEngine extends Engine {
2103
2105
  return buffer;
2104
2106
  });
2105
2107
  }
2108
+ startTimeQuery() {
2109
+ if (!this._gpuFrameTimeToken) {
2110
+ this._gpuFrameTimeToken = new _TimeToken();
2111
+ }
2112
+ // Always return the same time token. For native, we don't need a start marker, we just query for native frame stats.
2113
+ return this._gpuFrameTimeToken;
2114
+ }
2115
+ endTimeQuery(token) {
2116
+ this._engine.populateFrameStats?.(this._frameStats);
2117
+ return this._frameStats.gpuTimeNs;
2118
+ }
2106
2119
  }
2107
2120
  // This must match the protocol version in NativeEngine.cpp
2108
2121
  NativeEngine.PROTOCOL_VERSION = 8;