1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[975],{3975:function(e,t,r){r.d(t,{WebGPURenderer:function(){return eS}});var s=r(2827),i=r(4588),n=r(1702),a=r(7907),o=r(1786),u=r(7746),d=r(6805),h=r(9615),l=r(973),c=r(7350),p=r(5783);class f{init(){let e=new c.o({uTransformMatrix:{value:new i.y,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),t=(0,a.d)({name:"graphics",bits:[o.M,(0,u.m)((0,p.I)()),d.Kt,h.j]});this.shader=new l.e({gpuProgram:t,resources:{localUniforms:e}})}execute(e,t){let r=t.context,s=r.customShader||this.shader,i=e.renderer,{geometry:a,instructions:o}=i.graphicsContext.getContextRenderData(r),u=i.encoder;u.setPipelineFromGeometryProgramAndState(a,s.gpuProgram,e.state),u.setGeometry(a);let d=i.globalUniforms.bindGroup;u.setBindGroup(0,d,s.gpuProgram);let h=i.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);u.setBindGroup(2,h,s.gpuProgram);let l=o.instructions;for(let e=0;e<o.instructionSize;e++){let t=l[e];if(s.groups[1]=t.bindGroup,!t.gpuBindGroup){let e=t.textures;t.bindGroup=(0,n.Q)(e.textures,e.count),t.gpuBindGroup=i.bindGroup.getBindGroup(t.bindGroup,s.gpuProgram,1)}u.setBindGroup(1,t.bindGroup,s.gpuProgram),u.renderPassEncoder.drawIndexed(t.size,1,t.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}f.extension={type:[s.nw.WebGPUPipesAdaptor],name:"graphics"};var g=r(8127),m=r(7844),_=r(4972);class b{init(){let e=(0,a.d)({name:"mesh",bits:[d.XH,g.r,h.j]});this._shader=new l.e({gpuProgram:e,resources:{uTexture:m.x.EMPTY._source,uSampler:m.x.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new i.y}}}})}execute(e,t){let r=e.renderer,s=t._shader;if(s){if(!s.gpuProgram){(0,_.Z)("Mesh shader has no gpuProgram",t.shader);return}}else(s=this._shader).resources.uTexture=t.texture.source,s.resources.uSampler=t.texture.source.style,s.resources.textureUniforms.uniforms.uTextureMatrix=t.texture.textureMatrix.mapCoord;let i=s.gpuProgram;if(i.autoAssignGlobalUniforms&&(s.groups[0]=r.globalUniforms.bindGroup),i.autoAssignLocalUniforms){let t=e.localUniforms;s.groups[1]=r.renderPipes.uniformBatch.getUniformBindGroup(t,!0)}r.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}b.extension={type:[s.nw.WebGPUPipesAdaptor],name:"mesh"};var x=r(2308);let y=x.Z.for2d();class G{init(){let e=(0,a.d)({name:"batch",bits:[o.M,(0,u.m)((0,p.I)()),h.j]});this._shader=new l.e({gpuProgram:e,groups:{}})}start(e,t){let r=e.renderer,s=r.encoder,i=this._shader.gpuProgram;this._geometry=t,s.setGeometry(t),y.blendMode="normal",r.pipeline.getPipeline(t,i,y);let n=r.globalUniforms.bindGroup;s.resetBindGroup(1),s.setBindGroup(0,n,i)}execute(e,t){let r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){let e=t.textures;t.bindGroup=(0,n.Q)(e.textures,e.count)}y.blendMode=t.blendMode;let a=s.bindGroup.getBindGroup(t.bindGroup,r,1),o=s.pipeline.getPipeline(this._geometry,r,y);t.bindGroup._touch(s.textureGC.count),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,a),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}destroy(){this._shader.destroy(!0),this._shader=null}}G.extension={type:[s.nw.WebGPUPipesAdaptor],name:"batch"};var P=r(1242),B=r(452),S=r(3150);class T{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){let s=this._gpu.device,i=t.layout[r],n=[],a=this._renderer;for(let t in i){let r;let s=e.resources[t]??e.resources[i[t]];if("uniformGroup"===s._resourceType){a.ubo.updateUniformGroup(s);let e=s.buffer;r={buffer:a.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else"buffer"===s._resourceType?r={buffer:a.buffer.getGPUBuffer(s),offset:0,size:s.descriptor.size}:"bufferResource"===s._resourceType?r={buffer:a.buffer.getGPUBuffer(s.buffer),offset:s.offset,size:s.size}:"textureSampler"===s._resourceType?r=a.texture.getGpuSampler(s):"textureSource"===s._resourceType&&(r=a.texture.getGpuSource(s).createView({}));n.push({binding:i[t],resource:r})}let o=a.shader.getProgramData(t).bindGroups[r],u=s.createBindGroup({layout:o,entries:n});return this._hash[e._key]=u,u}destroy(){for(let e of Object.keys(this._hash))this._hash[e]=null;this._hash=null,this._renderer=null}}T.extension={type:[s.nw.WebGPUSystem],name:"bindGroup"};var v=r(7014);class C{constructor(){this._gpuBuffers=Object.create(null),this._managedBuffers=[]}contextChange(e){this._gpu=e}getGPUBuffer(e){return this._gpuBuffers[e.uid]||this.createGPUBuffer(e)}updateBuffer(e){let t=this._gpuBuffers[e.uid]||this.createGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){for(let e in this._gpuBuffers)this._gpuBuffers[e].destroy();this._gpuBuffers={}}createGPUBuffer(e){this._gpuBuffers[e.uid]||(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this),e.on("destroy",this.onBufferDestroy,this));let t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e.data&&((0,v.T)(e.data.buffer,t.getMappedRange()),t.unmap()),this._gpuBuffers[e.uid]=t,this._managedBuffers.push(e),t}onBufferChange(e){this._gpuBuffers[e.uid].destroy(),e._updateID=0,this._gpuBuffers[e.uid]=this.createGPUBuffer(e)}onBufferDestroy(e){this._managedBuffers.splice(this._managedBuffers.indexOf(e),1),this._destroyBuffer(e)}
1destroy(){this._managedBuffers.forEach(e=>this._destroyBuffer(e)),this._managedBuffers=null,this._gpuBuffers=null}_destroyBuffer(e){this._gpuBuffers[e.uid].destroy(),e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this),e.off("destroy",this.onBufferDestroy,this),this._gpuBuffers[e.uid]=null}}C.extension={type:[s.nw.WebGPUSystem],name:"buffer"};class w{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}w.extension={type:[s.nw.WebGPUSystem],name:"colorMask"};class U{constructor(e){this._renderer=e}async init(e){return this._initPromise||(this._initPromise=this._createDeviceAndAdaptor(e).then(e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)})),this._initPromise}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){let t=await navigator.gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(e=>t.features.has(e)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}U.extension={type:[s.nw.WebGPUSystem],name:"device"},U.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class M{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){let i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;let t=2===e.data.BYTES_PER_ELEMENT?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.textureGC.count);let s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e){for(let t in e.attributes){let r=e.attributes[t];this._setVertexBuffer(r.location,r.buffer)}e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(let r in e.groups){let s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(let t in e.resources){let r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){let{geometry:t,shader:r,state:s,topology:i,size:n,start:a,instanceCount:o,skipSync:u}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t),this._setShaderBindGroups(r,u),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,o||t.instanceCount,a||0):this.renderPassEncoder.draw(n||t.getSize(),o||t.instanceCount,a||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){let e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1]);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);let t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();let n=this._renderer.renderTarget.viewport;for(let e in this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t),r)this._setVertexBuffer(e,r[e]);for(let e in i)this.setBindGroup(e,i[e],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}M.extension={type:[s.nw.WebGPUSystem],name:"encoder",priority:1};var E=r(3798);class R{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:E.D.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){let r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;let s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}R.extension={type:[s.nw.WebGPUSystem],name:"stencil"};var z=r(8476);
1let k={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function H(e){let t=e.map(e=>({data:e,offset:0,size:0})),r=0;for(let e=0;e<t.length;e++){let s=t[e],i=k[s.data.type].size,n=k[s.data.type].align;if(!k[s.data.type])throw Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),r=Math.ceil(r/n)*n,s.size=i,s.offset=r,r+=i}return{uboElements:t,size:r=16*Math.ceil(r/16)}}var O=r(557),F=r(4963);function A(e,t){let{size:r,align:s}=k[e.data.type],i=(s-r)/4;return` 2 v = uv.${e.data.name}; 3 ${0!==t?`offset += ${t};`:""} 4 5 arrayOffset = offset; 6 7 t = 0; 8 9 for(var i=0; i < ${e.data.size*(r/4)}; i++) 10 { 11 for(var j = 0; j < ${r/4}; j++) 12 { 13 data[arrayOffset++] = v[t++]; 14 } 15 ${0!==i?`arrayOffset += ${i};`:""} 16 } 17 `}function D(e){return(0,O.S)(e,"uboWgsl",A,F.R)}class L extends z.L{constructor(){super({createUboElements:H,generateUboSync:D})}}L.extension={type:[s.nw.WebGPUSystem],name:"ubo"};var I=r(6514),W=r(1565),V=r(1739);class N{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw Error(`UniformBufferBatch: array is too large: ${4*e}`);let t=this.byteIndex,r=t+4*e;if((r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment)>4*this.data.length)throw Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){let t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this._buffer.destroy(),this._buffer=null,this.data=null}}var j=r(2240);class K{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new N({minUniformOffsetAlignment:128});for(let e=0;e<2;e++){let t=V.F.UNIFORM|V.F.COPY_DST;0===e&&(t|=V.F.COPY_SRC),this._buffers.push(new I.l({data:this._batchBuffer.data,usage:t}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){for(let e in this._bindGroupHash)this._bindGroupHash[e]=null;this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);let r=e.buffer.data,s=this._batchBuffer.addEmptyGroup(r.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,s/4),this._bindGroupHash[e.uid]=this._getBindGroup(s/128),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);let t=e.buffer.data,r=this._batchBuffer.addGroup(t);return this._getBufferResource(r/128)}getArrayBindGroup(e){let t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/128)}getArrayBufferResource(e){let t=this._batchBuffer.addGroup(e);return this._getBufferResource(t/128)}_getBufferResource(e){if(!this._bufferResources[e]){let t=this._buffers[e%2];this._bufferResources[e]=new W.q({buffer:t,offset:(e/2|0)*256,size:128})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){let t=new j.v({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){let e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);let r=this._renderer.gpu.device.createCommandEncoder();for(let s=1;s<this._buffers.length;s++){let i=this._buffers[s];r.copyBufferToBuffer(e.getGPUBuffer(t),128,e.getGPUBuffer(i),0,this._batchBuffer.byteIndex)}
17this._renderer.gpu.device.queue.submit([r.finish()])}destroy(){for(let e=0;e<this._bindGroups.length;e++)this._bindGroups[e].destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._bindGroupHash=null,this._renderer=null}}K.extension={type:[s.nw.WebGPUPipes],name:"uniformBatch"};var q=r(6725),Y=r(2060),$=r(23);let X={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class Z{constructor(e){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._renderer=e}contextChange(e){this._gpu=e,this.setStencilMode(E.D.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=e.descriptor.depthStencilAttachment?1:0,this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=$.L[e],this._updatePipeHash())}setPipeline(e,t,r,s){let i=this.getPipeline(e,t,r);s.setPipeline(i)}getPipeline(e,t,r,s){var i,n;e._layoutKey||((0,q.B)(e,t.attributeData),this._generateBufferKey(e)),s=s||e.topology;let a=(i=e._layoutKey,n=t._layoutKey,i<<24|n<<16|r.data<<10|r._blendModeId<<5|X[s]);return this._pipeCache[a]||(this._pipeCache[a]=this._createPipeline(e,t,r,s)),this._pipeCache[a]}_createPipeline(e,t,r,s){let i=this._gpu.device,n=this._createVertexBufferLayouts(e),a=this._renderer.state.getColorTargets(r);a[0].writeMask=this._stencilMode===E.D.RENDERING_MASK_ADD?0:this._colorMask;let o=this._renderer.shader.getProgramData(t).pipeline,u={vertex:{module:this._getModule(t.vertex.source),entryPoint:t.vertex.entryPoint,buffers:n},fragment:{module:this._getModule(t.fragment.source),entryPoint:t.fragment.entryPoint,targets:a},primitive:{topology:s,cullMode:r.cullMode},layout:o,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(u.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:r.depthTest,depthCompare:r.depthTest?"less":"always"}),i.createRenderPipeline(u)}_getModule(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){let t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){let t=[],r=0,s=Object.keys(e.attributes).sort();for(let i=0;i<s.length;i++){let n=e.attributes[s[i]];t[r++]=n.location,t[r++]=n.offset,t[r++]=n.format,t[r++]=n.stride}let i=t.join("");return e._layoutKey=(0,Y.Z)(i,"geometry"),e._layoutKey}_createVertexBufferLayouts(e){if(this._bufferLayoutsCache[e._layoutKey])return this._bufferLayoutsCache[e._layoutKey];let t=[];return e.buffers.forEach(r=>{let s={arrayStride:0,stepMode:"vertex",attributes:[]},i=s.attributes;for(let t in e.attributes){let n=e.attributes[t];n.buffer===r&&(s.arrayStride=n.stride,s.stepMode=n.instance?"instance":"vertex",i.push({shaderLocation:n.location,offset:n.offset,format:n.format}))}i.length&&t.push(s)}),this._bufferLayoutsCache[e._layoutKey]=t,t}_updatePipeHash(){var e,t;let r=(e=this._stencilMode,t=this._multisampleCount,this._colorMask<<6|e<<3|this._depthStencilAttachment<<1|t);this._pipeStateCaches[r]||(this._pipeStateCaches[r]=Object.create(null)),this._pipeCache=this._pipeStateCaches[r]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Z.extension={type:[s.nw.WebGPUSystem],name:"pipeline"};var Q=r(7724),J=r(3170),ee=r(3852),et=r(4192);class er{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class es{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,r,s,i){let n=this._renderer,a=this._getGpuColorTexture(e),o=n.texture.getGpuSource(t.source);return n.encoder.commandEncoder.copyTextureToTexture({texture:a,origin:r},{texture:o,origin:i},s),t}startRenderPass(e,t=!0,r,s){let i=this._renderTargetSystem.getGpuRenderTarget(e),n=this.getDescriptor(e,t,r);i.descriptor=n,this._renderer.pipeline.setRenderTarget(i),this._renderer.encoder.beginRenderPass(i),this._renderer.encoder.setViewport(s)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);return t.contexts[0]?t.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(e.colorTextures[0].source)}
17getDescriptor(e,t,r){let s;"boolean"==typeof t&&(t=t?J.E.ALL:J.E.NONE);let i=this._renderTargetSystem,n=i.getGpuRenderTarget(e),a=e.colorTextures.map((e,s)=>{let a,o;let u=n.contexts[s];a=u?u.getCurrentTexture().createView():this._renderer.texture.getGpuSource(e).createView({mipLevelCount:1}),n.msaaTextures[s]&&(o=a,a=this._renderer.texture.getTextureView(n.msaaTextures[s]));let d=t&J.E.COLOR?"clear":"load";return r??(r=i.defaultClearColor),{view:a,resolveTarget:o,clearValue:r,storeOp:"store",loadOp:d}});if((e.stencil||e.depth)&&!e.depthStencilTexture&&(e.ensureDepthStencilTexture(),e.depthStencilTexture.source.sampleCount=n.msaa?4:1),e.depthStencilTexture){let r=t&J.E.STENCIL?"clear":"load",i=t&J.E.DEPTH?"clear":"load";s={view:this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:r,depthClearValue:1,depthLoadOp:i,depthStoreOp:"store"}}return{colorAttachments:a,depthStencilAttachment:s}}clear(e,t=!0,r,s){if(!t)return;let{gpu:i,encoder:n}=this._renderer,a=i.device;if(null===n.commandEncoder){let i=a.createCommandEncoder(),n=this.getDescriptor(e,t,r),o=i.beginRenderPass(n);o.setViewport(s.x,s.y,s.width,s.height,0,1),o.end();let u=i.finish();a.queue.submit([u])}else this.startRenderPass(e,t,r,s)}initGpuRenderTarget(e){e.isRoot=!0;let t=new er;return e.colorTextures.forEach((e,r)=>{if(ee.D.test(e.resource)){let s=e.resource.getContext("webgpu"),i=e.transparent?"premultiplied":"opaque";try{s.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:i})}catch(e){console.error(e)}t.contexts[r]=s}if(t.msaa=e.source.antialias,e.source.antialias){let e=new et.p({width:0,height:0,sampleCount:4});t.msaaTextures[r]=e}}),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4)),t}
17destroyGpuRenderTarget(e){e.contexts.forEach(e=>{e.unconfigure()}),e.msaaTextures.forEach(e=>{e.destroy()}),e.msaaTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);e.depthStencilTexture&&t.msaa&&(e.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(e){let t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorTextures.forEach((e,r)=>{let s=t.msaaTextures[r];s?.resize(e.source.width,e.source.height,e.source._resolution)})}}class ei extends Q.l{constructor(e){super(e),this.adaptor=new es,this.adaptor.init(e,this)}}ei.extension={type:[s.nw.WebGPUSystem],name:"renderTarget"};class en{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){let t=this._gpu.device,r=e.gpuLayout.map(e=>t.createBindGroupLayout({entries:e}));return this._gpuProgramData[e._layoutKey]={bindGroups:r,pipeline:t.createPipelineLayout({bindGroupLayouts:r})},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}en.extension={type:[s.nw.WebGPUSystem],name:"shader"};let ea={};ea.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},ea.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},ea.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},ea.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ea.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},ea.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},ea["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},ea["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},ea["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},ea.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};class eo{constructor(){this.defaultState=new x.Z,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e){return[{format:"bgra8unorm",writeMask:0,blend:ea[e.blendMode]||ea.normal}]}destroy(){this.gpu=null}}eo.extension={type:[s.nw.WebGPUSystem],name:"state"};var eu=r(9941),ed=r(4274);let eh={type:"image",upload(e,t,r){let s=e.resource,i=(0|e.pixelWidth)*(0|e.pixelHeight),n=s.byteLength/i;r.device.queue.writeTexture({texture:t},s,{offset:0,rowsPerImage:e.pixelHeight,bytesPerRow:e.pixelHeight*n},{width:e.pixelWidth,height:e.pixelHeight,depthOrArrayLayers:1})}},el={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},ec={blockBytes:4,blockWidth:1,blockHeight:1},ep={type:"compressed",upload(e,t,r){let s=e.pixelWidth,i=e.pixelHeight,n=el[e.format]||ec;for(let a=0;a<e.resource.length;a++){let o=e.resource[a],u=Math.ceil(s/n.blockWidth)*n.blockBytes;r.device.queue.writeTexture({texture:t,mipLevel:a},o,{offset:0,bytesPerRow:u},{width:Math.ceil(s/n.blockWidth)*n.blockWidth,height:Math.ceil(i/n.blockHeight)*n.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),i=Math.max(i>>1,1)}}},ef={type:"image",upload(e,t,r){let s=e.resource;if(!s)return;let i=Math.min(t.width,e.resourceWidth||e.pixelWidth),n=Math.min(t.height,e.resourceHeight||e.pixelHeight),a="premultiply-alpha-on-upload"===e.alphaMode;r.device.queue.copyExternalImageToTexture({source:s},{texture:t,premultipliedAlpha:a},{width:i,height:n})}},eg={type:"video",upload(e,t,r){ef.upload(e,t,r)}};class em{constructor(e){this.device=e,this.sampler=e.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(e){let t=this.pipelines[e];return t||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:` 18 var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>( 19 vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0)); 20 21 struct VertexOutput { 22 @builtin(position) position : vec4<f32>, 23 @location(0) texCoord : vec2<f32>, 24 }; 25 26 @vertex 27 fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput { 28 var output : VertexOutput; 29 output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5); 30 output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0); 31 return output; 32 } 33 34 @group(0) @binding(0) var imgSampler : sampler; 35 @group(0) @binding(1) var img : texture_2d<f32>; 36 37 @fragment 38 fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> { 39 return textureSample(img, imgSampler, texCoord); 40 } 41 `})),t=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){let t=this._getMipmapPipeline(e.format);if("3d"===e.dimension||"1d"===e.dimension)throw Error("Generating mipmaps for non-2d textures is currently unsupported!");let r=e,s=e.depthOrArrayLayers||1,i=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!i){let t={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:s},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};r=this.device.createTexture(t)}let n=this.device.createCommandEncoder({}),a=t.getBindGroupLayout(0);for(let o=0;o<s;++o){let s=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),u=i?1:0;for(let i=1;i<e.mipLevelCount;++i){let e=r.createView({baseMipLevel:u++,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),i=n.beginRenderPass({colorAttachments:[{view:e,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),d=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.sampler},{binding:1,resource:s}]});i.setPipeline(t),i.setBindGroup(0,d),i.draw(3,1,0,0),i.end(),s=e}}if(!i){let t={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:s};for(let s=1;s<e.mipLevelCount;++s)n.copyTextureToTexture({texture:r,mipLevel:s-1},{texture:e,mipLevel:s},t),t.width=Math.ceil(t.width/2),t.height=Math.ceil(t.height/2)}return this.device.queue.submit([n.finish()]),i||r.destroy(),e}}class e_{constructor(e){this.managedTextures=[],this._gpuSources=Object.create(null),this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._textureViewHash=Object.create(null),this._uploads={image:ef,buffer:eh,video:eg,compressed:ep},this._renderer=e}contextChange(e){this._gpu=e}initSource(e){if(e.autoGenerateMipmaps){let t=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(t))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==e.uploadMethodId&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);let r=el[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},s=Math.ceil(e.pixelWidth/r.blockWidth)*r.blockWidth,i=Math.ceil(e.pixelHeight/r.blockHeight)*r.blockHeight,n={label:e.label,size:{width:s,height:i}
41,format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},a=this._gpu.device.createTexture(n);return this._gpuSources[e.uid]=a,this.managedTextures.includes(e)||(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceResize,this),e.on("destroy",this.onSourceDestroy,this),e.on("unload",this.onSourceUnload,this),e.on("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.push(e)),this.onSourceUpdate(e),a}onSourceUpdate(e){let t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onSourceUnload(e){let t=this._gpuSources[e.uid];t&&(this._gpuSources[e.uid]=null,t.destroy())}onUpdateMipmaps(e){this._mipmapGenerator||(this._mipmapGenerator=new em(this._gpu.device));let t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceDestroy(e){e.off("update",this.onSourceUpdate,this),e.off("unload",this.onSourceUnload,this),e.off("destroy",this.onSourceDestroy,this),e.off("resize",this.onSourceResize,this),e.off("updateMipmaps",this.onUpdateMipmaps,this),this.managedTextures.splice(this.managedTextures.indexOf(e),1),this.onSourceUnload(e)}onSourceResize(e){let t=this._gpuSources[e.uid];t?(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(this._textureViewHash[e.uid]=null,this._bindGroupHash[e.uid]=null,this.onSourceUnload(e),this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){return this._gpuSources[e.uid]||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]??this._createTextureBindGroup(e)}_createTextureBindGroup(e){let t=e.source,r=t.uid;return this._bindGroupHash[r]=new j.v({0:t,1:t.style}),this._bindGroupHash[r]}getTextureView(e){let t=e.source;return this._textureViewHash[t.uid]??this._createTextureView(t)}_createTextureView(e){return this._textureViewHash[e.uid]=this.getGpuSource(e).createView(),this._textureViewHash[e.uid]}generateCanvas(e){let t=this._renderer,r=t.gpu.device.createCommandEncoder(),s=eu.z.get().createCanvas();s.width=e.source.pixelWidth,s.height=e.source.pixelHeight;let i=s.getContext("webgpu");return i.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:navigator.gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),r.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:i.getCurrentTexture()},{width:s.width,height:s.height}),t.gpu.device.queue.submit([r.finish()]),s}getPixels(e){let t=this.generateCanvas(e),r=ed.h.getOptimalCanvasAndContext(t.width,t.height),s=r.context;s.drawImage(t,0,0);let{width:i,height:n}=t,a=new Uint8ClampedArray(s.getImageData(0,0,i,n).data.buffer);return ed.h.returnCanvasAndContext(r),{pixels:a,width:i,height:n}}destroy(){for(let e of(this.managedTextures.slice().forEach(e=>this.onSourceDestroy(e)),this.managedTextures=null,Object.keys(this._bindGroupHash))){let t=Number(e),r=this._bindGroupHash[t];r?.destroy(),this._bindGroupHash[t]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}e_.extension={type:[s.nw.WebGPUSystem],name:"texture"};let eb=[...B.N,L,M,U,C,e_,ei,en,eo,Z,w,R,T],ex=[...B.U,K],ey=[G,b,f],eG=[],eP=[],eB=[];s.Rw.handleByNamedList(s.nw.WebGPUSystem,eG),s.Rw.handleByNamedList(s.nw.WebGPUPipes,eP),s.Rw.handleByNamedList(s.nw.WebGPUPipesAdaptor,eB),s.Rw.add(...eb,...ex,...ey);class eS extends P.I{constructor(){super({name:"webgpu",type:S.g.WEBGPU,systems:eG,renderPipes:eP,renderPipeAdaptors:eB})}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.