(pInst, w, h, isMainCanvas, elt)
| 374 | |
| 375 | class RendererWebGPU extends Renderer3D { |
| 376 | constructor(pInst, w, h, isMainCanvas, elt) { |
| 377 | super(pInst, w, h, isMainCanvas, elt) |
| 378 | |
| 379 | // Used to group draws into one big render pass |
| 380 | this.activeRenderPass = null; |
| 381 | this.activeRenderPassEncoder = null; |
| 382 | this.activeShaderOptions = null; |
| 383 | this.activeShader = null; |
| 384 | |
| 385 | this.samplers = new Map(); |
| 386 | |
| 387 | // Some uniforms update every frame, like model matrices and sometimes colors. |
| 388 | // The fastest way to handle these is to use mapped memory. We'll batch those |
| 389 | // into bigger buffers with dynamic offsets, separate from the usual system |
| 390 | // where bind groups have their own little buffers that get cached when they |
| 391 | // are unchanged |
| 392 | this.uniformBufferAlignment = 256; |
| 393 | this.activeUniformBuffers = []; |
| 394 | this.currentUniformBuffer = undefined; |
| 395 | this.uniformBufferPool = []; |
| 396 | this.resettingUniformBuffers = []; |
| 397 | |
| 398 | this.dynamicEntryOffsets = new Uint32Array(64); |
| 399 | |
| 400 | // Cache for current frame's canvas texture view |
| 401 | this.currentCanvasColorTexture = null; |
| 402 | this.currentCanvasColorTextureView = null; |
| 403 | |
| 404 | // Single reusable staging buffer for pixel reading |
| 405 | this.pixelReadBuffer = null; |
| 406 | this.pixelReadBufferSize = 0; |
| 407 | |
| 408 | this.strandsBackend = wgslBackend; |
| 409 | |
| 410 | // Registry to track all shaders for uniform data pooling |
| 411 | this._shadersWithPools = []; |
| 412 | |
| 413 | // Registry to track geometries with buffer pools |
| 414 | this._geometriesWithPools = []; |
| 415 | |
| 416 | // Flag to track if any draws have happened that need queue submission |
| 417 | this._hasPendingDraws = false; |
| 418 | this._pendingCommandEncoders = []; |
| 419 | |
| 420 | // Queue of callbacks to run after next submit (mainly for safe texture deletion) |
| 421 | this._postSubmitCallbacks = []; |
| 422 | |
| 423 | // Retired buffers to destroy at end of frame |
| 424 | this._retiredBuffers = []; |
| 425 | |
| 426 | // Storage buffers for compute shaders |
| 427 | this._storageBuffers = new Set(); |
| 428 | |
| 429 | // 2D canvas for pixel reading fallback |
| 430 | this._pixelReadCanvas = null; |
| 431 | this._pixelReadCtx = null; |
| 432 | this.mainFramebuffer = null; |
| 433 | this._frameState = FRAME_STATE.PENDING; |
nothing calls this directly
no test coverage detected