@midscene/android-playground 1.0.1-beta-20251021060907.0 → 1.0.1-beta-20251024063839.0

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.
Files changed (48) hide show
  1. package/dist/es/bin.mjs +5 -3
  2. package/dist/lib/bin.js +5 -3
  3. package/package.json +5 -5
  4. package/static/index.html +1 -1
  5. package/static/static/js/142.64c1e0d5.js +697 -0
  6. package/static/static/js/{825.c5ade4c6.js.map → 142.64c1e0d5.js.map} +1 -1
  7. package/static/static/js/async/150.d439b38c.js +158 -0
  8. package/static/static/js/async/{212.850ade70.js.map → 150.d439b38c.js.map} +1 -1
  9. package/static/static/js/async/{624.8a1fe2e8.js → 195.aa1e3152.js} +3 -3
  10. package/static/static/js/async/{624.8a1fe2e8.js.map → 195.aa1e3152.js.map} +1 -1
  11. package/static/static/js/async/260.d838b3b7.js +2 -0
  12. package/static/static/js/async/{544.18ac9afb.js.map → 260.d838b3b7.js.map} +1 -1
  13. package/static/static/js/async/271.71b3326b.js +3 -0
  14. package/static/static/js/async/{173.f2381e64.js.map → 271.71b3326b.js.map} +1 -1
  15. package/static/static/js/async/355.76c31308.js +1 -0
  16. package/static/static/js/async/{644.910ce3d0.js → 441.675c15a8.js} +1 -1
  17. package/static/static/js/async/45.ce50b37f.js +21 -0
  18. package/static/static/js/async/45.ce50b37f.js.map +1 -0
  19. package/static/static/js/async/586.ffc417d5.js +26 -0
  20. package/static/static/js/async/{329.261bc4a1.js.map → 586.ffc417d5.js.map} +1 -1
  21. package/static/static/js/async/631.9799e85f.js +30 -0
  22. package/static/static/js/async/{364.d88c3cff.js.map → 631.9799e85f.js.map} +1 -1
  23. package/static/static/js/async/{702.1f38a17e.js → 779.e7bfc2ed.js} +15 -15
  24. package/static/static/js/async/{702.1f38a17e.js.map → 779.e7bfc2ed.js.map} +1 -1
  25. package/static/static/js/async/782.f77f2205.js +2 -0
  26. package/static/static/js/async/782.f77f2205.js.map +1 -0
  27. package/static/static/js/index.dd3aa15e.js +30 -0
  28. package/static/static/js/index.dd3aa15e.js.map +1 -0
  29. package/static/static/js/lib-react.d7dec362.js +3 -0
  30. package/static/static/js/{lib-react.c74a0742.js.map → lib-react.d7dec362.js.map} +1 -1
  31. package/static/static/js/825.c5ade4c6.js +0 -697
  32. package/static/static/js/async/166.834644b5.js +0 -2
  33. package/static/static/js/async/166.834644b5.js.map +0 -1
  34. package/static/static/js/async/173.f2381e64.js +0 -3
  35. package/static/static/js/async/212.850ade70.js +0 -158
  36. package/static/static/js/async/329.261bc4a1.js +0 -26
  37. package/static/static/js/async/364.d88c3cff.js +0 -30
  38. package/static/static/js/async/544.18ac9afb.js +0 -2
  39. package/static/static/js/async/582.8f4b5264.js +0 -21
  40. package/static/static/js/async/582.8f4b5264.js.map +0 -1
  41. package/static/static/js/async/983.b98b40af.js +0 -1
  42. package/static/static/js/index.eb785992.js +0 -30
  43. package/static/static/js/index.eb785992.js.map +0 -1
  44. package/static/static/js/lib-react.c74a0742.js +0 -3
  45. /package/static/static/js/{825.c5ade4c6.js.LICENSE.txt → 142.64c1e0d5.js.LICENSE.txt} +0 -0
  46. /package/static/static/js/{index.eb785992.js.LICENSE.txt → index.dd3aa15e.js.LICENSE.txt} +0 -0
  47. /package/static/static/js/{lib-react.c74a0742.js.LICENSE.txt → lib-react.d7dec362.js.LICENSE.txt} +0 -0
  48. /package/static/static/wasm/{9e906fbf55e08f98.module.wasm → 9e906fbf.module.wasm} +0 -0
@@ -0,0 +1,26 @@
1
+ "use strict";(self.webpackChunkandroid_playground=self.webpackChunkandroid_playground||[]).push([["586"],{42665:function(e,t,r){r.d(t,{WebGPURenderer:()=>e_});var s=r(82295),i=r(16325),n=r(94777),o=r(81199),a=r(64367),u=r(31988),d=r(32791),h=r(88101),l=r(56959),c=r(88675);class p{init(){let e=new c.k({uTransformMatrix:{value:new i.u,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),t=(0,o.v)({name:"graphics",bits:[a.F,(0,u._)(16),d._Q,h.b]});this.shader=new l.M({gpuProgram:t,resources:{localUniforms:e}})}execute(e,t){let r=t.context,s=r.customShader||this.shader,i=e.renderer,{geometry:o,instructions:a}=i.graphicsContext.getContextRenderData(r),u=i.encoder;u.setPipelineFromGeometryProgramAndState(o,s.gpuProgram,e.state),u.setGeometry(o);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=a.instructions;for(let e=0;e<a.instructionSize;e++){let t=l[e];if(s.groups[1]=t.bindGroup,!t.gpuBindGroup){let e=t.textures;t.bindGroup=(0,n.w)(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}}p.extension={type:[s.Ag.WebGPUPipesAdaptor],name:"graphics"};var f=r(15875),g=r(55003),_=r(42912);class m{init(){let e=(0,o.v)({name:"mesh",bits:[d.Ls,f.R,h.b]});this._shader=new l.M({gpuProgram:e,resources:{uTexture:g.g.EMPTY._source,uSampler:g.g.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new i.u}}}})}execute(e,t){let r=e.renderer,s=t._shader;if(s){if(!s.gpuProgram)return void(0,_.R)("Mesh shader has no gpuProgram",t.shader)}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}}m.extension={type:[s.Ag.WebGPUPipesAdaptor],name:"mesh"};var b=r(69071);let x=b.U.for2d();class y{init(){let e=(0,o.v)({name:"batch",bits:[a.F,(0,u._)(16),h.b]});this._shader=new l.M({gpuProgram:e,groups:{}})}start(e,t){let r=e.renderer,s=r.encoder,i=this._shader.gpuProgram;this._geometry=t,s.setGeometry(t),x.blendMode="normal",r.pipeline.getPipeline(t,i,x);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.w)(e.textures,e.count)}x.blendMode=t.blendMode;let o=s.bindGroup.getBindGroup(t.bindGroup,r,1),a=s.pipeline.getPipeline(this._geometry,r,x);t.bindGroup._touch(s.textureGC.count),i.setPipeline(a),i.renderPassEncoder.setBindGroup(1,o),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}destroy(){this._shader.destroy(!0),this._shader=null}}y.extension={type:[s.Ag.WebGPUPipesAdaptor],name:"batch"};var G=r(71771),P=r(60019),B=r(74711);class S{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=[],o=this._renderer;for(let t in i){let r,s=e.resources[t]??e.resources[i[t]];if("uniformGroup"===s._resourceType){o.ubo.updateUniformGroup(s);let e=s.buffer;r={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else"buffer"===s._resourceType?r={buffer:o.buffer.getGPUBuffer(s),offset:0,size:s.descriptor.size}:"bufferResource"===s._resourceType?r={buffer:o.buffer.getGPUBuffer(s.buffer),offset:s.offset,size:s.size}:"textureSampler"===s._resourceType?r=o.texture.getGpuSampler(s):"textureSource"===s._resourceType&&(r=o.texture.getGpuSource(s).createView({}));n.push({binding:i[t],resource:r})}let a=o.shader.getProgramData(t).bindGroups[r],u=s.createBindGroup({layout:a,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}}S.extension={type:[s.Ag.WebGPUSystem],name:"bindGroup"};var T=r(8508);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,T.W)(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)}destroy(){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.Ag.WebGPUSystem],name:"buffer"};class v{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}}v.extension={type:[s.Ag.WebGPUSystem],name:"colorMask"};class M{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}}M.extension={type:[s.Ag.WebGPUSystem],name:"device"},M.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class U{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:o,instanceCount:a,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,a||t.instanceCount,o||0):this.renderPassEncoder.draw(n||t.getSize(),a||t.instanceCount,o||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}}U.extension={type:[s.Ag.WebGPUSystem],name:"encoder",priority:1};var w=r(40729);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:w.K.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.Ag.WebGPUSystem],name:"stencil"};var E=r(39258),A=r(65657),k=r(35097),O=r(37824);class H{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 F=r(48997);class D{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new H({minUniformOffsetAlignment:128});for(let e=0;e<2;e++){let t=O.S.UNIFORM|O.S.COPY_DST;0===e&&(t|=O.S.COPY_SRC),this._buffers.push(new A.h({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 k.d({buffer:t,offset:(e/2|0)*256,size:128})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){let t=new F.T({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)}this._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}}D.extension={type:[s.Ag.WebGPUPipes],name:"uniformBatch"};var L=r(27992),I=r(45732),W=r(19016);let V={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class N{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(w.K.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=+!!e.descriptor.depthStencilAttachment,this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=W.g[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,o;e._layoutKey||((0,L.q)(e,t.attributeData),this._generateBufferKey(e)),s=s||e.topology;let a=(i=e._layoutKey,n=t._layoutKey,o=r.data,i<<24|n<<16|o<<10|r._blendModeId<<5|V[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),o=this._renderer.state.getColorTargets(r);o[0].writeMask=this._stencilMode===w.K.RENDERING_MASK_ADD?0:this._colorMask;let a=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:o},primitive:{topology:s,cullMode:r.cullMode},layout:a,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,I.X)(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}}N.extension={type:[s.Ag.WebGPUSystem],name:"pipeline"};var z=r(88138),j=r(72653),K=r(3616),q=r(66747);class Y{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class X{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,r,s,i){let n=this._renderer,o=this._getGpuColorTexture(e),a=n.texture.getGpuSource(t.source);return n.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:r},{texture:a,origin:i},s),t}startRenderPass(e,t=!0,r,s){let i=this._renderTargetSystem.getGpuRenderTarget(e);i.descriptor=this.getDescriptor(e,t,r),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)}getDescriptor(e,t,r){let s;"boolean"==typeof t&&(t=t?j.u.ALL:j.u.NONE);let i=this._renderTargetSystem,n=i.getGpuRenderTarget(e),o=e.colorTextures.map((e,s)=>{let o,a,u=n.contexts[s];o=u?u.getCurrentTexture().createView():this._renderer.texture.getGpuSource(e).createView({mipLevelCount:1}),n.msaaTextures[s]&&(a=o,o=this._renderer.texture.getTextureView(n.msaaTextures[s]));let d=t&j.u.COLOR?"clear":"load";return r??(r=i.defaultClearColor),{view:o,resolveTarget:a,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.u.STENCIL?"clear":"load",i=t&j.u.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:o,depthStencilAttachment:s}}clear(e,t=!0,r,s){if(!t)return;let{gpu:i,encoder:n}=this._renderer,o=i.device;if(null===n.commandEncoder){let i=o.createCommandEncoder(),n=this.getDescriptor(e,t,r),a=i.beginRenderPass(n);a.setViewport(s.x,s.y,s.width,s.height,0,1),a.end();let u=i.finish();o.queue.submit([u])}else this.startRenderPass(e,t,r,s)}initGpuRenderTarget(e){e.isRoot=!0;let t=new Y;return e.colorTextures.forEach((e,r)=>{if(K.q.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 q.v({width:0,height:0,sampleCount:4});t.msaaTextures[r]=e}}),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4)),t}destroyGpuRenderTarget(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 Q extends z.l{constructor(e){super(e),this.adaptor=new X,this.adaptor.init(e,this)}}Q.extension={type:[s.Ag.WebGPUSystem],name:"renderTarget"};class ${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}}$.extension={type:[s.Ag.WebGPUSystem],name:"shader"};let J={};J.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},J.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},J.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},J.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},J.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},J.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},J["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},J["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},J["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},J.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}};class Z{constructor(){this.defaultState=new b.U,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e){return[{format:"bgra8unorm",writeMask:0,blend:J[e.blendMode]||J.normal}]}destroy(){this.gpu=null}}Z.extension={type:[s.Ag.WebGPUSystem],name:"state"};var ee=r(50160),et=r(82164);let er={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})}},es={"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}},ei={blockBytes:4,blockWidth:1,blockHeight:1},en={type:"compressed",upload(e,t,r){let s=e.pixelWidth,i=e.pixelHeight,n=es[e.format]||ei;for(let o=0;o<e.resource.length;o++){let a=e.resource[o],u=Math.ceil(s/n.blockWidth)*n.blockBytes;r.device.queue.writeTexture({texture:t,mipLevel:o},a,{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)}}},eo={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),o="premultiply-alpha-on-upload"===e.alphaMode;r.device.queue.copyExternalImageToTexture({source:s},{texture:t,premultipliedAlpha:o},{width:i,height:n})}},ea={type:"video",upload(e,t,r){eo.upload(e,t,r)}};class eu{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:`
2
+ var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
3
+ vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));
4
+
5
+ struct VertexOutput {
6
+ @builtin(position) position : vec4<f32>,
7
+ @location(0) texCoord : vec2<f32>,
8
+ };
9
+
10
+ @vertex
11
+ fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {
12
+ var output : VertexOutput;
13
+ output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);
14
+ output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);
15
+ return output;
16
+ }
17
+
18
+ @group(0) @binding(0) var imgSampler : sampler;
19
+ @group(0) @binding(1) var img : texture_2d<f32>;
20
+
21
+ @fragment
22
+ fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
23
+ return textureSample(img, imgSampler, texCoord);
24
+ }
25
+ `})),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({}),o=t.getBindGroupLayout(0);for(let a=0;a<s;++a){let s=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),u=+!!i;for(let i=1;i<e.mipLevelCount;++i){let e=r.createView({baseMipLevel:u++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,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:o,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 ed{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:eo,buffer:er,video:ea,compressed:en},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=es[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},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},o=this._gpu.device.createTexture(n);return this._gpuSources[e.uid]=o,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),o}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 eu(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 F.T({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=ee.e.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=et.N.getOptimalCanvasAndContext(t.width,t.height),s=r.context;s.drawImage(t,0,0);let{width:i,height:n}=t,o=new Uint8ClampedArray(s.getImageData(0,0,i,n).data.buffer);return et.N.returnCanvasAndContext(r),{pixels:o,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}}ed.extension={type:[s.Ag.WebGPUSystem],name:"texture"};let eh=[...P.i,E.u,U,M,C,ed,Q,$,Z,N,v,R,S],el=[...P.f,D],ec=[y,m,p],ep=[],ef=[],eg=[];s.XO.handleByNamedList(s.Ag.WebGPUSystem,ep),s.XO.handleByNamedList(s.Ag.WebGPUPipes,ef),s.XO.handleByNamedList(s.Ag.WebGPUPipesAdaptor,eg),s.XO.add(...eh,...el,...ec);class e_ extends G.k{constructor(){super({name:"webgpu",type:B.W.WEBGPU,systems:ep,renderPipes:ef,renderPipeAdaptors:eg})}}},82164:function(e,t,r){r.d(t,{N:()=>n});var s=r(50160),i=r(92111);let n=new class{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){let r=s.e.get().createCanvas();r.width=e,r.height=t;let i=r.getContext("2d");return{canvas:r,context:i}}getOptimalCanvasAndContext(e,t,r=1){e=Math.ceil(e*r-1e-6),t=Math.ceil(t*r-1e-6),e=(0,i.U5)(e),t=(0,i.U5)(t);let s=(e<<17)+(t<<1);this._canvasPool[s]||(this._canvasPool[s]=[]);let n=this._canvasPool[s].pop();return n||(n=this._createCanvasAndContext(e,t)),n}returnCanvasAndContext(e){let{width:t,height:r}=e.canvas;this._canvasPool[(t<<17)+(r<<1)].push(e)}clear(){this._canvasPool={}}}}}]);
26
+ //# sourceMappingURL=586.ffc417d5.js.map