import{L as V,I as X}from"./index-CDrXokXW.js";import{WebGPUEngine as f}from"./webgpuEngine-C4n6cvIQ.js";import"./index-DWyDLubb.js";import"./instancesVertex-CO_CTxxp.js";import"./bakedVertexAnimation-DoavwM49.js";import"./instancesDeclaration-DZdrWbmN.js";import"./helperFunctions-CZpZ-EbL.js";import"./fresnelFunction-cCRUtTOI.js";import"./meshUboDeclaration-Bk1ASTX2.js";import"./sceneUboDeclaration-BH1tZjjY.js";import"./decalFragment-iGkmQ-pm.js";import"./audioEngine-C797_5QL.js";f.prototype.unBindMultiColorAttachmentFramebuffer=function(t,e=!1,n){n&&n(),this._endCurrentRenderPass(),t.disableAutomaticMSAAResolve||this.resolveMultiFramebuffer(t,!1),e||this.generateMipMapsMultiFramebuffer(t),this._currentRenderTarget=null,this._mrtAttachments=[],this._cacheRenderPipeline.setMRT([]),this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments)};f.prototype.createMultipleRenderTarget=function(t,e,n){let a=!1,l=!0,i=!1,m=!1,c=15,g=1,o=1;const U=0,v=3,H=!1,k=5,N=3553;let x=[],T=[],M=[],_=[],y=[],R=[],b=[],S=[],F=[],A=[],d=!1;const u=this._createHardwareRenderTargetWrapper(!0,!1,t);e!==void 0&&(a=e.generateMipMaps??!1,l=e.generateDepthBuffer??!0,i=e.generateStencilBuffer??!1,m=e.generateDepthTexture??!1,g=e.textureCount??1,c=e.depthTextureFormat??15,x=e.types||x,T=e.samplingModes||T,M=e.useSRGBBuffers||M,_=e.formats||_,y=e.targetTypes||y,R=e.faceIndex||R,b=e.layerIndex||b,S=e.layerCounts||S,F=e.labels||F,A=e.creationFlags||A,o=e.samples??o,d=e.dontCreateTextures??!1);const D=t.width??t,G=t.height??t,B=[],I=[],P=[];u.label=e?.label??"MultiRenderTargetWrapper",u._generateDepthBuffer=l,u._generateStencilBuffer=i,u._attachments=I,u._defaultAttachments=P;let h=null;(l||i||m)&&!d&&(m||(l&&i?c=13:l?c=14:c=19),h=u.createDepthStencilTexture(0,!1,i,1,c,u.label+"-DepthStencil"));const w=e!==void 0&&typeof e=="object"&&e.createMipMaps&&!a;for(let s=0;s<g;s++){let C=T[s]||v,p=x[s]||U;const Y=_[s]||k,j=(M[s]||H)&&this._caps.supportSRGBBuffers,E=y[s]||N,L=S[s]??1,O=A[s];if((p===1&&!this._caps.textureFloatLinearFiltering||p===2&&!this._caps.textureHalfFloatLinearFiltering)&&(C=1),p===1&&!this._caps.textureFloat&&(p=0,V.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),I.push(s+1),P.push(n?s+1:s===0?1:0),E===-1||d)continue;const r=new X(this,6);switch(B[s]=r,E){case 34067:r.isCube=!0;break;case 32879:r.is3D=!0,r.baseDepth=r.depth=L;break;case 35866:r.is2DArray=!0,r.baseDepth=r.depth=L;break}r.baseWidth=D,r.baseHeight=G,r.width=D,r.height=G,r.isReady=!0,r.samples=1,r.generateMipMaps=a,r.samplingMode=C,r.type=p,r._cachedWrapU=0,r._cachedWrapV=0,r._useSRGBBuffer=j,r.format=Y,r.label=F[s]??u.label+"-Texture"+s,this._internalTexturesCache.push(r),w&&(r.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(r,void 0,void 0,void 0,O),w&&(r.generateMipMaps=!1)}return h&&(h.incrementReferences(),B[g]=h,this._internalTexturesCache.push(h)),u.setTextures(B),u.setLayerAndFaceIndices(b,R),d?u._samples=o:this.updateMultipleRenderTargetTextureSampleCount(u,o),u};f.prototype.updateMultipleRenderTargetTextureSampleCount=function(t,e){if(!t||!t.textures||t.textures.length===0||t.textures[0].samples===e)return e;const n=t.textures.length;if(n===0)return 1;e=Math.min(e,this.getCaps().maxMSAASamples);for(let a=0;a<n;++a)t.textures[a]._hardwareTexture?.releaseMSAATextures();for(let a=0;a<n;++a){const l=t.textures[a];l.samples=e}return t._depthStencilTexture&&(t._depthStencilTexture.samples=e),t._samples=e,e};f.prototype.generateMipMapsMultiFramebuffer=function(t){const e=t;if(!e.isMulti)return;const a=e._attachments.length;for(let l=0;l<a;l++){const i=e.textures[l];i.generateMipMaps&&!i.isCube&&!i.is3D&&this._generateMipmaps(i)}};f.prototype.resolveMultiFramebuffer=function(t,e=!0){this.resolveFramebuffer(t,e)};f.prototype.bindAttachments=function(t){t.length===0||!this._currentRenderTarget||(this._mrtAttachments=t,this._currentRenderPass&&this._cacheRenderPipeline.setMRTAttachments(t))};f.prototype.buildTextureLayout=function(t,e=!1){const n=[];if(e)n.push(1);else for(let a=0;a<t.length;a++)t[a]?n.push(a+1):n.push(0);return n};f.prototype.restoreSingleAttachment=function(){};f.prototype.restoreSingleAttachmentForRenderTarget=function(){};
