webgpuPerfCounter.js 891 B

12345678910111213141516171819202122232425262728293031
  1. import { PerfCounter } from "../../Misc/perfCounter.js";
  2. /**
  3. * Class used to define a WebGPU performance counter
  4. */
  5. export class WebGPUPerfCounter {
  6. constructor() {
  7. this._gpuTimeInFrameId = -1;
  8. /**
  9. * The GPU time in nanoseconds spent in the last frame
  10. */
  11. this.counter = new PerfCounter();
  12. }
  13. /**
  14. * @internal
  15. */
  16. _addDuration(currentFrameId, duration) {
  17. if (currentFrameId < this._gpuTimeInFrameId) {
  18. return;
  19. }
  20. if (this._gpuTimeInFrameId !== currentFrameId) {
  21. this.counter._fetchResult();
  22. this.counter.fetchNewFrame();
  23. this.counter.addCount(duration, false);
  24. this._gpuTimeInFrameId = currentFrameId;
  25. }
  26. else {
  27. this.counter.addCount(duration, false);
  28. }
  29. }
  30. }
  31. //# sourceMappingURL=webgpuPerfCounter.js.map