webgpuEngine.d.ts 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020
  1. import type { Nullable, DataArray, IndicesArray, Immutable, FloatArray } from "../types";
  2. import { InternalTexture, InternalTextureSource } from "../Materials/Textures/internalTexture";
  3. import type { IEffectCreationOptions, IShaderPath } from "../Materials/effect";
  4. import { Effect } from "../Materials/effect";
  5. import type { EffectFallbacks } from "../Materials/effectFallbacks";
  6. import { VertexBuffer } from "../Buffers/buffer";
  7. import type { IPipelineContext } from "./IPipelineContext";
  8. import type { DataBuffer } from "../Buffers/dataBuffer";
  9. import type { BaseTexture } from "../Materials/Textures/baseTexture";
  10. import type { IShaderProcessor } from "./Processors/iShaderProcessor";
  11. import type { ShaderProcessingContext } from "./Processors/shaderProcessingOptions";
  12. import { WebGPUTextureManager } from "./WebGPU/webgpuTextureManager";
  13. import { type ISceneLike, AbstractEngine } from "./abstractEngine";
  14. import { WebGPUBufferManager } from "./WebGPU/webgpuBufferManager";
  15. import type { HardwareTextureWrapper } from "../Materials/Textures/hardwareTextureWrapper";
  16. import { WebGPUHardwareTexture } from "./WebGPU/webgpuHardwareTexture";
  17. import type { IColor4Like } from "../Maths/math.like";
  18. import { WebGPUCacheSampler } from "./WebGPU/webgpuCacheSampler";
  19. import type { WebGPUCacheRenderPipeline } from "./WebGPU/webgpuCacheRenderPipeline";
  20. import type { DrawWrapper } from "../Materials/drawWrapper";
  21. import { WebGPUMaterialContext } from "./WebGPU/webgpuMaterialContext";
  22. import { WebGPUDrawContext } from "./WebGPU/webgpuDrawContext";
  23. import type { IStencilState } from "../States/IStencilState";
  24. import { WebGPUBundleList } from "./WebGPU/webgpuBundleList";
  25. import { WebGPUTimestampQuery } from "./WebGPU/webgpuTimestampQuery";
  26. import type { ComputeEffect } from "../Compute/computeEffect";
  27. import { WebGPUOcclusionQuery } from "./WebGPU/webgpuOcclusionQuery";
  28. import type { TwgslOptions } from "./WebGPU/webgpuTintWASM";
  29. import type { ExternalTexture } from "../Materials/Textures/externalTexture";
  30. import { ShaderLanguage } from "../Materials/shaderLanguage";
  31. import type { InternalTextureCreationOptions, TextureSize } from "../Materials/Textures/textureCreationOptions";
  32. import type { WebGPUDataBuffer } from "../Meshes/WebGPU/webgpuDataBuffer";
  33. import "../Buffers/buffer.align";
  34. import "../ShadersWGSL/postprocess.vertex";
  35. import type { RenderTargetTexture } from "../Materials/Textures/renderTargetTexture";
  36. import type { RenderTargetWrapper } from "./renderTargetWrapper";
  37. import { WebGPUPerfCounter } from "./WebGPU/webgpuPerfCounter";
  38. import type { Scene } from "../scene";
  39. import type { AbstractEngineOptions } from "./abstractEngine";
  40. import type { PostProcess } from "../PostProcesses/postProcess";
  41. import { PerformanceMonitor } from "../Misc/performanceMonitor";
  42. import "./AbstractEngine/abstractEngine.loadingScreen";
  43. import "./AbstractEngine/abstractEngine.dom";
  44. import "./AbstractEngine/abstractEngine.states";
  45. import "./AbstractEngine/abstractEngine.renderPass";
  46. import "../Audio/audioEngine";
  47. /** @internal */
  48. interface IWebGPURenderPassWrapper {
  49. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  50. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  51. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  52. colorAttachmentGPUTextures: (WebGPUHardwareTexture | null)[];
  53. depthTextureFormat: GPUTextureFormat | undefined;
  54. }
  55. /**
  56. * Options to load the associated Glslang library
  57. */
  58. export interface GlslangOptions {
  59. /**
  60. * Defines an existing instance of Glslang (useful in modules who do not access the global instance).
  61. */
  62. glslang?: any;
  63. /**
  64. * Defines the URL of the glslang JS File.
  65. */
  66. jsPath?: string;
  67. /**
  68. * Defines the URL of the glslang WASM File.
  69. */
  70. wasmPath?: string;
  71. }
  72. /**
  73. * Options to create the WebGPU engine
  74. */
  75. export interface WebGPUEngineOptions extends AbstractEngineOptions, GPURequestAdapterOptions {
  76. /**
  77. * Defines the category of adapter to use.
  78. * Is it the discrete or integrated device.
  79. */
  80. powerPreference?: GPUPowerPreference;
  81. /**
  82. * When set to true, indicates that only a fallback adapter may be returned when requesting an adapter.
  83. * If the user agent does not support a fallback adapter, will cause requestAdapter() to resolve to null.
  84. * Default: false
  85. */
  86. forceFallbackAdapter?: boolean;
  87. /**
  88. * Defines the device descriptor used to create a device once we have retrieved an appropriate adapter
  89. */
  90. deviceDescriptor?: GPUDeviceDescriptor;
  91. /**
  92. * When requesting the device, enable all the features supported by the adapter. Default: false
  93. * Note that this setting is ignored if you explicitely set deviceDescriptor.requiredFeatures
  94. */
  95. enableAllFeatures?: boolean;
  96. /**
  97. * When requesting the device, set the required limits to the maximum possible values (the ones from adapter.limits). Default: false
  98. * Note that this setting is ignored if you explicitely set deviceDescriptor.requiredLimits
  99. */
  100. setMaximumLimits?: boolean;
  101. /**
  102. * Defines the requested Swap Chain Format.
  103. */
  104. swapChainFormat?: GPUTextureFormat;
  105. /**
  106. * Defines whether we should generate debug markers in the gpu command lists (can be seen with PIX for eg). Default: false
  107. */
  108. enableGPUDebugMarkers?: boolean;
  109. /**
  110. * Options to load the associated Glslang library
  111. */
  112. glslangOptions?: GlslangOptions;
  113. /**
  114. * Options to load the associated Twgsl library
  115. */
  116. twgslOptions?: TwgslOptions;
  117. }
  118. /**
  119. * The web GPU engine class provides support for WebGPU version of babylon.js.
  120. * @since 5.0.0
  121. */
  122. export declare class WebGPUEngine extends AbstractEngine {
  123. private static readonly _GLSLslangDefaultOptions;
  124. private static _InstanceId;
  125. /** true to enable using TintWASM to convert Spir-V to WGSL */
  126. static UseTWGSL: boolean;
  127. /** A unique id to identify this instance */
  128. readonly uniqueId = -1;
  129. private readonly _uploadEncoderDescriptor;
  130. private readonly _renderEncoderDescriptor;
  131. /** @internal */
  132. readonly _clearDepthValue = 1;
  133. /** @internal */
  134. readonly _clearReverseDepthValue = 0;
  135. /** @internal */
  136. readonly _clearStencilValue = 0;
  137. private readonly _defaultSampleCount;
  138. /** @internal */
  139. _options: WebGPUEngineOptions;
  140. private _glslang;
  141. private _tintWASM;
  142. private _adapter;
  143. private _adapterSupportedExtensions;
  144. private _adapterInfo;
  145. private _adapterSupportedLimits;
  146. /** @internal */
  147. _device: GPUDevice;
  148. private _deviceEnabledExtensions;
  149. private _deviceLimits;
  150. private _context;
  151. private _mainPassSampleCount;
  152. private _glslangOptions?;
  153. private _twgslOptions?;
  154. /** @internal */
  155. _textureHelper: WebGPUTextureManager;
  156. /** @internal */
  157. _bufferManager: WebGPUBufferManager;
  158. private _clearQuad;
  159. /** @internal */
  160. _cacheSampler: WebGPUCacheSampler;
  161. /** @internal */
  162. _cacheRenderPipeline: WebGPUCacheRenderPipeline;
  163. private _cacheBindGroups;
  164. private _emptyVertexBuffer;
  165. /** @internal */
  166. _mrtAttachments: number[];
  167. /** @internal */
  168. _timestampQuery: WebGPUTimestampQuery;
  169. /** @internal */
  170. _timestampIndex: number;
  171. /** @internal */
  172. _occlusionQuery: WebGPUOcclusionQuery;
  173. /** @internal */
  174. _compiledComputeEffects: {
  175. [key: string]: ComputeEffect;
  176. };
  177. /** @internal */
  178. _counters: {
  179. numEnableEffects: number;
  180. numEnableDrawWrapper: number;
  181. numBundleCreationNonCompatMode: number;
  182. numBundleReuseNonCompatMode: number;
  183. };
  184. /**
  185. * Counters from last frame
  186. */
  187. readonly countersLastFrame: {
  188. numEnableEffects: number;
  189. numEnableDrawWrapper: number;
  190. numBundleCreationNonCompatMode: number;
  191. numBundleReuseNonCompatMode: number;
  192. };
  193. /**
  194. * Max number of uncaptured error messages to log
  195. */
  196. numMaxUncapturedErrors: number;
  197. /**
  198. * Gets the list of created scenes
  199. */
  200. scenes: Scene[];
  201. /** @internal */
  202. _virtualScenes: Scene[];
  203. private _mainTexture;
  204. private _depthTexture;
  205. private _mainTextureExtends;
  206. private _depthTextureFormat;
  207. private _colorFormat;
  208. /** @internal */
  209. _ubInvertY: WebGPUDataBuffer;
  210. /** @internal */
  211. _ubDontInvertY: WebGPUDataBuffer;
  212. /** @internal */
  213. _uploadEncoder: GPUCommandEncoder;
  214. /** @internal */
  215. _renderEncoder: GPUCommandEncoder;
  216. private _commandBuffers;
  217. /** @internal */
  218. _currentRenderPass: Nullable<GPURenderPassEncoder>;
  219. private _mainRenderPassWrapper;
  220. private _rttRenderPassWrapper;
  221. /** @internal */
  222. _pendingDebugCommands: Array<[string, Nullable<string>]>;
  223. /**
  224. * Used for both the compatibilityMode=false and the snapshot rendering modes (as both can't be enabled at the same time)
  225. * @internal
  226. */
  227. _bundleList: WebGPUBundleList;
  228. private _defaultDrawContext;
  229. private _defaultMaterialContext;
  230. /** @internal */
  231. _currentDrawContext: WebGPUDrawContext;
  232. /** @internal */
  233. _currentMaterialContext: WebGPUMaterialContext;
  234. private _currentOverrideVertexBuffers;
  235. private _currentIndexBuffer;
  236. private _colorWriteLocal;
  237. private _forceEnableEffect;
  238. /** @internal */
  239. dbgShowShaderCode: boolean;
  240. /** @internal */
  241. dbgSanityChecks: boolean;
  242. /** @internal */
  243. dbgVerboseLogsForFirstFrames: boolean;
  244. /** @internal */
  245. dbgVerboseLogsNumFrames: number;
  246. /** @internal */
  247. dbgLogIfNotDrawWrapper: boolean;
  248. /** @internal */
  249. dbgShowEmptyEnableEffectCalls: boolean;
  250. private _snapshotRendering;
  251. protected _snapshotRenderingMode: number;
  252. /**
  253. * Gets or sets the snapshot rendering mode
  254. */
  255. get snapshotRenderingMode(): number;
  256. set snapshotRenderingMode(mode: number);
  257. /**
  258. * Creates a new snapshot at the next frame using the current snapshotRenderingMode
  259. */
  260. snapshotRenderingReset(): void;
  261. /**
  262. * Enables or disables the snapshot rendering mode
  263. * Note that the WebGL engine does not support snapshot rendering so setting the value won't have any effect for this engine
  264. */
  265. get snapshotRendering(): boolean;
  266. set snapshotRendering(activate: boolean);
  267. /**
  268. * Sets this to true to disable the cache for the samplers. You should do it only for testing purpose!
  269. */
  270. get disableCacheSamplers(): boolean;
  271. set disableCacheSamplers(disable: boolean);
  272. /**
  273. * Sets this to true to disable the cache for the render pipelines. You should do it only for testing purpose!
  274. */
  275. get disableCacheRenderPipelines(): boolean;
  276. set disableCacheRenderPipelines(disable: boolean);
  277. /**
  278. * Sets this to true to disable the cache for the bind groups. You should do it only for testing purpose!
  279. */
  280. get disableCacheBindGroups(): boolean;
  281. set disableCacheBindGroups(disable: boolean);
  282. /**
  283. * Gets a boolean indicating if all created effects are ready
  284. * @returns true if all effects are ready
  285. */
  286. areAllEffectsReady(): boolean;
  287. /**
  288. * Get Font size information
  289. * @param font font name
  290. * @returns an object containing ascent, height and descent
  291. */
  292. getFontOffset(font: string): {
  293. ascent: number;
  294. height: number;
  295. descent: number;
  296. };
  297. /**
  298. * Gets a Promise<boolean> indicating if the engine can be instantiated (ie. if a WebGPU context can be found)
  299. */
  300. static get IsSupportedAsync(): Promise<boolean>;
  301. /**
  302. * Not supported by WebGPU, you should call IsSupportedAsync instead!
  303. */
  304. static get IsSupported(): boolean;
  305. /**
  306. * Gets a boolean indicating that the engine supports uniform buffers
  307. */
  308. get supportsUniformBuffers(): boolean;
  309. /** Gets the supported extensions by the WebGPU adapter */
  310. get supportedExtensions(): Immutable<GPUFeatureName[]>;
  311. /** Gets the currently enabled extensions on the WebGPU device */
  312. get enabledExtensions(): Immutable<GPUFeatureName[]>;
  313. /** Gets the supported limits by the WebGPU adapter */
  314. get supportedLimits(): GPUSupportedLimits;
  315. /** Gets the current limits of the WebGPU device */
  316. get currentLimits(): GPUSupportedLimits;
  317. /**
  318. * Returns a string describing the current engine
  319. */
  320. get description(): string;
  321. /**
  322. * Returns the version of the engine
  323. */
  324. get version(): number;
  325. /**
  326. * Gets an object containing information about the current engine context
  327. * @returns an object containing the vendor, the renderer and the version of the current engine context
  328. */
  329. getInfo(): {
  330. vendor: string;
  331. renderer: string;
  332. version: string;
  333. };
  334. /**
  335. * (WebGPU only) True (default) to be in compatibility mode, meaning rendering all existing scenes without artifacts (same rendering than WebGL).
  336. * Setting the property to false will improve performances but may not work in some scenes if some precautions are not taken.
  337. * See https://doc.babylonjs.com/setup/support/webGPU/webGPUOptimization/webGPUNonCompatibilityMode for more details
  338. */
  339. get compatibilityMode(): boolean;
  340. set compatibilityMode(mode: boolean);
  341. /**
  342. * Enables or disables GPU timing measurements.
  343. * Note that this is only supported if the "timestamp-query" extension is enabled in the options.
  344. */
  345. get enableGPUTimingMeasurements(): boolean;
  346. set enableGPUTimingMeasurements(enable: boolean);
  347. /**
  348. * Gets the GPU time spent in the main render pass for the last frame rendered (in nanoseconds).
  349. * You have to enable the "timestamp-query" extension in the engine constructor options and set engine.enableGPUTimingMeasurements = true.
  350. * It will only return time spent in the main pass, not additional render target / compute passes (if any)!
  351. */
  352. readonly gpuTimeInFrameForMainPass?: WebGPUPerfCounter;
  353. /** @internal */
  354. get currentSampleCount(): number;
  355. /**
  356. * Create a new instance of the gpu engine asynchronously
  357. * @param canvas Defines the canvas to use to display the result
  358. * @param options Defines the options passed to the engine to create the GPU context dependencies
  359. * @returns a promise that resolves with the created engine
  360. */
  361. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  362. /**
  363. * Indicates if the z range in NDC space is 0..1 (value: true) or -1..1 (value: false)
  364. */
  365. readonly isNDCHalfZRange: boolean;
  366. /**
  367. * Indicates that the origin of the texture/framebuffer space is the bottom left corner. If false, the origin is top left
  368. */
  369. readonly hasOriginBottomLeft: boolean;
  370. /** @internal */
  371. protected _creationOptions: WebGPUEngineOptions;
  372. /**
  373. * Create a new instance of the gpu engine.
  374. * @param canvas Defines the canvas to use to display the result
  375. * @param options Defines the options passed to the engine to create the GPU context dependencies
  376. */
  377. constructor(canvas: HTMLCanvasElement | OffscreenCanvas, options?: WebGPUEngineOptions);
  378. /**
  379. * Initializes the WebGPU context and dependencies.
  380. * @param glslangOptions Defines the GLSLang compiler options if necessary
  381. * @param twgslOptions Defines the Twgsl compiler options if necessary
  382. * @returns a promise notifying the readiness of the engine.
  383. */
  384. initAsync(glslangOptions?: GlslangOptions, twgslOptions?: TwgslOptions): Promise<void>;
  385. private _initGlslang;
  386. private _initializeLimits;
  387. private _initializeContextAndSwapChain;
  388. private _initializeMainAttachments;
  389. /**
  390. * Shared initialization across engines types.
  391. * @param canvas The canvas associated with this instance of the engine.
  392. */
  393. protected _sharedInit(canvas: HTMLCanvasElement): void;
  394. private _configureContext;
  395. /**
  396. * Resize an image and returns the image data as an uint8array
  397. * @param image image to resize
  398. * @param bufferWidth destination buffer width
  399. * @param bufferHeight destination buffer height
  400. * @returns an uint8array containing RGBA values of bufferWidth * bufferHeight size
  401. */
  402. resizeImageBitmap(image: HTMLImageElement | ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;
  403. /**
  404. * Engine abstraction for loading and creating an image bitmap from a given source string.
  405. * @param imageSource source to load the image from.
  406. * @param options An object that sets options for the image's extraction.
  407. * @returns ImageBitmap
  408. */
  409. _createImageBitmapFromSource(imageSource: string, options?: ImageBitmapOptions): Promise<ImageBitmap>;
  410. /**
  411. * Toggle full screen mode
  412. * @param requestPointerLock defines if a pointer lock should be requested from the user
  413. */
  414. switchFullscreen(requestPointerLock: boolean): void;
  415. /**
  416. * Enters full screen mode
  417. * @param requestPointerLock defines if a pointer lock should be requested from the user
  418. */
  419. enterFullscreen(requestPointerLock: boolean): void;
  420. /**
  421. * Exits full screen mode
  422. */
  423. exitFullscreen(): void;
  424. /**
  425. * Enters Pointerlock mode
  426. */
  427. enterPointerlock(): void;
  428. /**
  429. * Exits Pointerlock mode
  430. */
  431. exitPointerlock(): void;
  432. protected _rebuildBuffers(): void;
  433. protected _restoreEngineAfterContextLost(initEngine: () => void): void;
  434. /**
  435. * Sets a depth stencil texture from a render target to the according uniform.
  436. * @param channel The texture channel
  437. * @param uniform The uniform to set
  438. * @param texture The render target texture containing the depth stencil texture to apply
  439. * @param name The texture name
  440. */
  441. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  442. /**
  443. * Sets a texture to the context from a postprocess
  444. * @param channel defines the channel to use
  445. * @param postProcess defines the source postprocess
  446. * @param name name of the channel
  447. */
  448. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  449. /**
  450. * Binds the output of the passed in post process to the texture channel specified
  451. * @param channel The channel the texture should be bound to
  452. * @param postProcess The post process which's output should be bound
  453. * @param name name of the channel
  454. */
  455. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  456. /**
  457. * Force a specific size of the canvas
  458. * @param width defines the new canvas' width
  459. * @param height defines the new canvas' height
  460. * @param forceSetSize true to force setting the sizes of the underlying canvas
  461. * @returns true if the size was changed
  462. */
  463. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  464. private _shaderProcessorWGSL;
  465. /**
  466. * @internal
  467. */
  468. _getShaderProcessor(shaderLanguage: ShaderLanguage): Nullable<IShaderProcessor>;
  469. /**
  470. * @internal
  471. */
  472. _getShaderProcessingContext(shaderLanguage: ShaderLanguage): Nullable<ShaderProcessingContext>;
  473. private _currentPassIsMainPass;
  474. private _getCurrentRenderPass;
  475. /** @internal */
  476. _getCurrentRenderPassWrapper(): IWebGPURenderPassWrapper;
  477. /** @internal */
  478. applyStates(): void;
  479. /**
  480. * Force the entire cache to be cleared
  481. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  482. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  483. */
  484. wipeCaches(bruteForce?: boolean): void;
  485. /**
  486. * Enable or disable color writing
  487. * @param enable defines the state to set
  488. */
  489. setColorWrite(enable: boolean): void;
  490. /**
  491. * Gets a boolean indicating if color writing is enabled
  492. * @returns the current color writing state
  493. */
  494. getColorWrite(): boolean;
  495. private _viewportsCurrent;
  496. private _mustUpdateViewport;
  497. private _applyViewport;
  498. /**
  499. * @internal
  500. */
  501. _viewport(x: number, y: number, width: number, height: number): void;
  502. private _scissorsCurrent;
  503. protected _scissorCached: {
  504. x: number;
  505. y: number;
  506. z: number;
  507. w: number;
  508. };
  509. private _mustUpdateScissor;
  510. private _applyScissor;
  511. private _scissorIsActive;
  512. enableScissor(x: number, y: number, width: number, height: number): void;
  513. disableScissor(): void;
  514. private _stencilRefsCurrent;
  515. private _mustUpdateStencilRef;
  516. private _applyStencilRef;
  517. private _blendColorsCurrent;
  518. private _mustUpdateBlendColor;
  519. private _applyBlendColor;
  520. private _resetRenderPassStates;
  521. /**
  522. * Clear the current render buffer or the current render target (if any is set up)
  523. * @param color defines the color to use
  524. * @param backBuffer defines if the back buffer must be cleared
  525. * @param depth defines if the depth buffer must be cleared
  526. * @param stencil defines if the stencil buffer must be cleared
  527. */
  528. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  529. private _clearFullQuad;
  530. /**
  531. * Creates a vertex buffer
  532. * @param data the data or the size for the vertex buffer
  533. * @param _updatable whether the buffer should be created as updatable
  534. * @param label defines the label of the buffer (for debug purpose)
  535. * @returns the new buffer
  536. */
  537. createVertexBuffer(data: DataArray | number, _updatable?: boolean, label?: string): DataBuffer;
  538. /**
  539. * Creates a vertex buffer
  540. * @param data the data for the dynamic vertex buffer
  541. * @param label defines the label of the buffer (for debug purpose)
  542. * @returns the new buffer
  543. */
  544. createDynamicVertexBuffer(data: DataArray, label?: string): DataBuffer;
  545. /**
  546. * Creates a new index buffer
  547. * @param indices defines the content of the index buffer
  548. * @param _updatable defines if the index buffer must be updatable
  549. * @param label defines the label of the buffer (for debug purpose)
  550. * @returns a new buffer
  551. */
  552. createIndexBuffer(indices: IndicesArray, _updatable?: boolean, label?: string): DataBuffer;
  553. /**
  554. * Update a dynamic index buffer
  555. * @param indexBuffer defines the target index buffer
  556. * @param indices defines the data to update
  557. * @param offset defines the offset in the target index buffer where update should start
  558. */
  559. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  560. /**
  561. * Updates a dynamic vertex buffer.
  562. * @param vertexBuffer the vertex buffer to update
  563. * @param data the data used to update the vertex buffer
  564. * @param byteOffset the byte offset of the data
  565. * @param byteLength the byte length of the data
  566. */
  567. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  568. /**
  569. * @internal
  570. */
  571. _createBuffer(data: DataArray | number, creationFlags: number, label?: string): DataBuffer;
  572. /**
  573. * @internal
  574. */
  575. bindBuffersDirectly(): void;
  576. /**
  577. * @internal
  578. */
  579. updateAndBindInstancesBuffer(): void;
  580. /**
  581. * Unbind all instance attributes
  582. */
  583. unbindInstanceAttributes(): void;
  584. /**
  585. * Bind a list of vertex buffers with the engine
  586. * @param vertexBuffers defines the list of vertex buffers to bind
  587. * @param indexBuffer defines the index buffer to bind
  588. * @param effect defines the effect associated with the vertex buffers
  589. * @param overrideVertexBuffers defines optional list of avertex buffers that overrides the entries in vertexBuffers
  590. */
  591. bindBuffers(vertexBuffers: {
  592. [key: string]: Nullable<VertexBuffer>;
  593. }, indexBuffer: Nullable<DataBuffer>, effect: Effect, overrideVertexBuffers?: {
  594. [kind: string]: Nullable<VertexBuffer>;
  595. }): void;
  596. /**
  597. * @internal
  598. */
  599. _releaseBuffer(buffer: DataBuffer): boolean;
  600. /**
  601. * Create an uniform buffer
  602. * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets
  603. * @param elements defines the content of the uniform buffer
  604. * @param label defines a name for the buffer (for debugging purpose)
  605. * @returns the webGL uniform buffer
  606. */
  607. createUniformBuffer(elements: FloatArray, label?: string): DataBuffer;
  608. /**
  609. * Create a dynamic uniform buffer (no different from a non dynamic uniform buffer in WebGPU)
  610. * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets
  611. * @param elements defines the content of the uniform buffer
  612. * @param label defines a name for the buffer (for debugging purpose)
  613. * @returns the webGL uniform buffer
  614. */
  615. createDynamicUniformBuffer(elements: FloatArray, label?: string): DataBuffer;
  616. /**
  617. * Update an existing uniform buffer
  618. * @see https://doc.babylonjs.com/setup/support/webGL2#uniform-buffer-objets
  619. * @param uniformBuffer defines the target uniform buffer
  620. * @param elements defines the content to update
  621. * @param offset defines the offset in the uniform buffer where update should start
  622. * @param count defines the size of the data to update
  623. */
  624. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  625. /**
  626. * Bind a buffer to the current draw context
  627. * @param buffer defines the buffer to bind
  628. * @param _location not used in WebGPU
  629. * @param name Name of the uniform variable to bind
  630. */
  631. bindUniformBufferBase(buffer: DataBuffer, _location: number, name: string): void;
  632. /**
  633. * Unused in WebGPU
  634. */
  635. bindUniformBlock(): void;
  636. /**
  637. * Create a new effect (used to store vertex/fragment shaders)
  638. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  639. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  640. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  641. * @param samplers defines an array of string used to represent textures
  642. * @param defines defines the string containing the defines to use to compile the shaders
  643. * @param fallbacks defines the list of potential fallbacks to use if shader compilation fails
  644. * @param onCompiled defines a function to call when the effect creation is successful
  645. * @param onError defines a function to call when the effect creation has failed
  646. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  647. * @param shaderLanguage the language the shader is written in (default: GLSL)
  648. * @returns the new Effect
  649. */
  650. createEffect(baseName: string | (IShaderPath & {
  651. vertexToken?: string;
  652. fragmentToken?: string;
  653. }), attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | AbstractEngine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any, shaderLanguage?: ShaderLanguage): Effect;
  654. private _compileRawShaderToSpirV;
  655. private _compileShaderToSpirV;
  656. private _getWGSLShader;
  657. private _createPipelineStageDescriptor;
  658. private _compileRawPipelineStageDescriptor;
  659. private _compilePipelineStageDescriptor;
  660. /**
  661. * @internal
  662. */
  663. createRawShaderProgram(): WebGLProgram;
  664. /**
  665. * @internal
  666. */
  667. createShaderProgram(): WebGLProgram;
  668. /**
  669. * Inline functions in shader code that are marked to be inlined
  670. * @param code code to inline
  671. * @returns inlined code
  672. */
  673. inlineShaderCode(code: string): string;
  674. /**
  675. * Creates a new pipeline context
  676. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  677. * @returns the new pipeline
  678. */
  679. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  680. /**
  681. * Creates a new material context
  682. * @returns the new context
  683. */
  684. createMaterialContext(): WebGPUMaterialContext | undefined;
  685. /**
  686. * Creates a new draw context
  687. * @returns the new context
  688. */
  689. createDrawContext(): WebGPUDrawContext | undefined;
  690. /**
  691. * @internal
  692. */
  693. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>): void;
  694. /**
  695. * Gets the list of active attributes for a given WebGPU program
  696. * @param pipelineContext defines the pipeline context to use
  697. * @param attributesNames defines the list of attribute names to get
  698. * @returns an array of indices indicating the offset of each attribute
  699. */
  700. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  701. /**
  702. * Activates an effect, making it the current one (ie. the one used for rendering)
  703. * @param effect defines the effect to activate
  704. */
  705. enableEffect(effect: Nullable<Effect | DrawWrapper>): void;
  706. /**
  707. * @internal
  708. */
  709. _releaseEffect(effect: Effect): void;
  710. /**
  711. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  712. */
  713. releaseEffects(): void;
  714. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  715. /**
  716. * Gets a boolean indicating that only power of 2 textures are supported
  717. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  718. */
  719. get needPOTTextures(): boolean;
  720. /** @internal */
  721. _createHardwareTexture(): HardwareTextureWrapper;
  722. /**
  723. * @internal
  724. */
  725. _releaseTexture(texture: InternalTexture): void;
  726. /**
  727. * @internal
  728. */
  729. _getRGBABufferInternalSizedFormat(): number;
  730. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  731. /**
  732. * Creates an internal texture without binding it to a framebuffer
  733. * @internal
  734. * @param size defines the size of the texture
  735. * @param options defines the options used to create the texture
  736. * @param delayGPUTextureCreation true to delay the texture creation the first time it is really needed. false to create it right away
  737. * @param source source type of the texture
  738. * @returns a new internal texture
  739. */
  740. _createInternalTexture(size: TextureSize, options: boolean | InternalTextureCreationOptions, delayGPUTextureCreation?: boolean, source?: InternalTextureSource): InternalTexture;
  741. /**
  742. * Usually called from Texture.ts.
  743. * Passed information to create a hardware texture
  744. * @param url defines a value which contains one of the following:
  745. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  746. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  747. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  748. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  749. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  750. * @param scene needed for loading to the correct scene
  751. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  752. * @param onLoad optional callback to be called upon successful completion
  753. * @param onError optional callback to be called upon failure
  754. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  755. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  756. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  757. * @param forcedExtension defines the extension to use to pick the right loader
  758. * @param mimeType defines an optional mime type
  759. * @param loaderOptions options to be passed to the loader
  760. * @param creationFlags specific flags to use when creating the texture (Constants.TEXTURE_CREATIONFLAG_STORAGE for storage textures, for eg)
  761. * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
  762. * @returns a InternalTexture for assignment back into BABYLON.Texture
  763. */
  764. createTexture(url: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<(texture: InternalTexture) => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string, loaderOptions?: any, creationFlags?: number, useSRGBBuffer?: boolean): InternalTexture;
  765. /**
  766. * Wraps an external web gpu texture in a Babylon texture.
  767. * @param texture defines the external texture
  768. * @returns the babylon internal texture
  769. */
  770. wrapWebGPUTexture(texture: GPUTexture): InternalTexture;
  771. /**
  772. * Wraps an external web gl texture in a Babylon texture.
  773. * @returns the babylon internal texture
  774. */
  775. wrapWebGLTexture(): InternalTexture;
  776. generateMipMapsForCubemap(texture: InternalTexture): void;
  777. /**
  778. * @internal
  779. */
  780. _getUseSRGBBuffer(useSRGBBuffer: boolean, noMipmap: boolean): boolean;
  781. /**
  782. * Update the sampling mode of a given texture
  783. * @param samplingMode defines the required sampling mode
  784. * @param texture defines the texture to update
  785. * @param generateMipMaps defines whether to generate mipmaps for the texture
  786. */
  787. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  788. /**
  789. * Update the sampling mode of a given texture
  790. * @param texture defines the texture to update
  791. * @param wrapU defines the texture wrap mode of the u coordinates
  792. * @param wrapV defines the texture wrap mode of the v coordinates
  793. * @param wrapR defines the texture wrap mode of the r coordinates
  794. */
  795. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  796. /**
  797. * Update the dimensions of a texture
  798. * @param texture texture to update
  799. * @param width new width of the texture
  800. * @param height new height of the texture
  801. * @param depth new depth of the texture
  802. */
  803. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  804. /**
  805. * @internal
  806. */
  807. _setInternalTexture(name: string, texture: Nullable<InternalTexture | ExternalTexture>, baseName?: string): void;
  808. /**
  809. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  810. * @param rootUrl defines the url where the file to load is located
  811. * @param scene defines the current scene
  812. * @param lodScale defines scale to apply to the mip map selection
  813. * @param lodOffset defines offset to apply to the mip map selection
  814. * @param onLoad defines an optional callback raised when the texture is loaded
  815. * @param onError defines an optional callback raised if there is an issue to load the texture
  816. * @param format defines the format of the data
  817. * @param forcedExtension defines the extension to use to pick the right loader
  818. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  819. * @returns the cube texture as an InternalTexture
  820. */
  821. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, lodScale: number, lodOffset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean): InternalTexture;
  822. /**
  823. * Sets a texture to the according uniform.
  824. * @param channel The texture channel
  825. * @param unused unused parameter
  826. * @param texture The texture to apply
  827. * @param name The name of the uniform in the effect
  828. */
  829. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  830. /**
  831. * Sets an array of texture to the WebGPU context
  832. * @param channel defines the channel where the texture array must be set
  833. * @param unused unused parameter
  834. * @param textures defines the array of textures to bind
  835. * @param name name of the channel
  836. */
  837. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  838. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string): boolean;
  839. /**
  840. * @internal
  841. */
  842. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  843. /**
  844. * @internal
  845. */
  846. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  847. /**
  848. * Generates the mipmaps for a texture
  849. * @param texture texture to generate the mipmaps for
  850. */
  851. generateMipmaps(texture: InternalTexture): void;
  852. /**
  853. * @internal
  854. */
  855. _generateMipmaps(texture: InternalTexture, commandEncoder?: GPUCommandEncoder): void;
  856. /**
  857. * Update a portion of an internal texture
  858. * @param texture defines the texture to update
  859. * @param imageData defines the data to store into the texture
  860. * @param xOffset defines the x coordinates of the update rectangle
  861. * @param yOffset defines the y coordinates of the update rectangle
  862. * @param width defines the width of the update rectangle
  863. * @param height defines the height of the update rectangle
  864. * @param faceIndex defines the face index if texture is a cube (0 by default)
  865. * @param lod defines the lod level to update (0 by default)
  866. * @param generateMipMaps defines whether to generate mipmaps or not
  867. */
  868. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number, generateMipMaps?: boolean): void;
  869. /**
  870. * @internal
  871. */
  872. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  873. /**
  874. * @internal
  875. */
  876. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  877. /**
  878. * @internal
  879. */
  880. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  881. /**
  882. * @internal
  883. */
  884. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  885. /**
  886. * Reads pixels from the current frame buffer. Please note that this function can be slow
  887. * @param x defines the x coordinate of the rectangle where pixels must be read
  888. * @param y defines the y coordinate of the rectangle where pixels must be read
  889. * @param width defines the width of the rectangle where pixels must be read
  890. * @param height defines the height of the rectangle where pixels must be read
  891. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  892. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  893. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  894. */
  895. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  896. private _measureFps;
  897. private _performanceMonitor;
  898. /**
  899. * Gets the performance monitor attached to this engine
  900. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#engineinstrumentation
  901. */
  902. get performanceMonitor(): PerformanceMonitor;
  903. /**
  904. * Begin a new frame
  905. */
  906. beginFrame(): void;
  907. /**
  908. * End the current frame
  909. */
  910. endFrame(): void;
  911. /**Gets driver info if available */
  912. extractDriverInfo(): string;
  913. /**
  914. * Force a WebGPU flush (ie. a flush of all waiting commands)
  915. */
  916. flushFramebuffer(): void;
  917. /** @internal */
  918. _currentFrameBufferIsDefaultFrameBuffer(): boolean;
  919. private _startRenderTargetRenderPass;
  920. private _startMainRenderPass;
  921. /** @internal */
  922. _endCurrentRenderPass(): number;
  923. /**
  924. * Binds the frame buffer to the specified texture.
  925. * @param texture The render target wrapper to render to
  926. * @param faceIndex The face of the texture to render to in case of cube texture
  927. * @param requiredWidth The width of the target to render to
  928. * @param requiredHeight The height of the target to render to
  929. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  930. * @param lodLevel defines the lod level to bind to the frame buffer
  931. * @param layer defines the 2d array index to bind to frame buffer to
  932. */
  933. bindFramebuffer(texture: RenderTargetWrapper, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  934. /**
  935. * Unbind the current render target texture from the WebGPU context
  936. * @param texture defines the render target wrapper to unbind
  937. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  938. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  939. */
  940. unBindFramebuffer(texture: RenderTargetWrapper, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  941. /**
  942. * Unbind the current render target and bind the default framebuffer
  943. */
  944. restoreDefaultFramebuffer(): void;
  945. /**
  946. * @internal
  947. */
  948. _setColorFormat(wrapper: IWebGPURenderPassWrapper): void;
  949. /**
  950. * @internal
  951. */
  952. _setDepthTextureFormat(wrapper: IWebGPURenderPassWrapper): void;
  953. setDitheringState(): void;
  954. setRasterizerState(): void;
  955. /**
  956. * @internal
  957. */
  958. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  959. /**
  960. * @internal
  961. */
  962. bindSamplers(): void;
  963. /** @internal */
  964. _getUnpackAlignement(): number;
  965. /**
  966. * @internal
  967. */
  968. _bindTextureDirectly(): boolean;
  969. /**
  970. * Set various states to the webGL context
  971. * @param culling defines culling state: true to enable culling, false to disable it
  972. * @param zOffset defines the value to apply to zOffset (0 by default)
  973. * @param force defines if states must be applied even if cache is up to date
  974. * @param reverseSide defines if culling must be reversed (CCW if false, CW if true)
  975. * @param cullBackFaces true to cull back faces, false to cull front faces (if culling is enabled)
  976. * @param stencil stencil states to set
  977. * @param zOffsetUnits defines the value to apply to zOffsetUnits (0 by default)
  978. */
  979. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean, cullBackFaces?: boolean, stencil?: IStencilState, zOffsetUnits?: number): void;
  980. private _applyRenderPassChanges;
  981. private _draw;
  982. /**
  983. * Draw a list of indexed primitives
  984. * @param fillMode defines the primitive to use
  985. * @param indexStart defines the starting index
  986. * @param indexCount defines the number of index to draw
  987. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  988. */
  989. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  990. /**
  991. * Draw a list of unindexed primitives
  992. * @param fillMode defines the primitive to use
  993. * @param verticesStart defines the index of first vertex to draw
  994. * @param verticesCount defines the count of vertices to draw
  995. * @param instancesCount defines the number of instances to draw (if instantiation is enabled)
  996. */
  997. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  998. /**
  999. * Dispose and release all associated resources
  1000. */
  1001. dispose(): void;
  1002. /**
  1003. * Gets the current render width
  1004. * @param useScreen defines if screen size must be used (or the current render target if any)
  1005. * @returns a number defining the current render width
  1006. */
  1007. getRenderWidth(useScreen?: boolean): number;
  1008. /**
  1009. * Gets the current render height
  1010. * @param useScreen defines if screen size must be used (or the current render target if any)
  1011. * @returns a number defining the current render height
  1012. */
  1013. getRenderHeight(useScreen?: boolean): number;
  1014. /**
  1015. * Get the current error code of the WebGPU context
  1016. * @returns the error code
  1017. */
  1018. getError(): number;
  1019. }
  1020. export {};