@onerjs/core 8.31.8 → 8.31.9

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.
@@ -165,7 +165,12 @@ export class RenderTargetWrapper {
165
165
  */
166
166
  generateMipMaps() {
167
167
  if (this._engine._currentRenderTarget === this) {
168
- this._engine.unBindFramebuffer(this, true);
168
+ if (this.isMulti) {
169
+ this._engine.unBindMultiColorAttachmentFramebuffer(this, true);
170
+ }
171
+ else {
172
+ this._engine.unBindFramebuffer(this, true);
173
+ }
169
174
  }
170
175
  if (this.isMulti) {
171
176
  this._engine.generateMipMapsMultiFramebuffer(this);
@@ -1 +1 @@
1
- {"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/renderTargetWrapper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,yDAAwD;AAYnF;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA6B5B;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,OAAkC,EAAE,eAAe,GAAG,IAAI;QACpF,IAAI,eAAe,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/C,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC;QAEpC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,+BAA+B,GAAG,KAAK,CAAC;QAEvG,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,+BAA+B,GAAG,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAA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I,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,uBAAuB,GAAG,KAAK;QAC1C,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC3B,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { AbstractEngine } from \"./abstractEngine\";\r\nimport type { IMultiRenderTargetOptions } from \"../Materials/Textures/multiRenderTarget\";\r\nimport { HasStencilAspect } from \"core/Materials/Textures/textureHelper.functions\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: AbstractEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n private _faceIndices: Nullable<number[]> = null;\r\n private _layerIndices: Nullable<number[]> = null;\r\n private _depthStencilTextureLabel?: string;\r\n /** @internal */\r\n public _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets or sets the label of the render target wrapper (optional, for debugging purpose)\r\n */\r\n public label?: string;\r\n\r\n /**\r\n * Gets the depth/stencil texture\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Sets the depth/stencil texture\r\n * @param texture The depth/stencil texture to set\r\n * @param disposeExisting True to dispose the existing depth/stencil texture (if any) before replacing it (default: true)\r\n */\r\n public setDepthStencilTexture(texture: Nullable<InternalTexture>, disposeExisting = true) {\r\n if (disposeExisting && this._depthStencilTexture) {\r\n this._depthStencilTexture.dispose();\r\n }\r\n\r\n this._depthStencilTexture = texture;\r\n\r\n this._generateDepthBuffer = this._generateStencilBuffer = this._depthStencilTextureWithStencil = false;\r\n\r\n if (texture) {\r\n this._generateDepthBuffer = true;\r\n this._generateStencilBuffer = this._depthStencilTextureWithStencil = HasStencilAspect(texture.format);\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a 3D texture\r\n */\r\n public get is3D(): boolean {\r\n return this.depth > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the depth of the render target wrapper (only used if is3D is true and wrapper is not a multi render target)\r\n */\r\n public get depth(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).depth || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the face indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get faceIndices(): Nullable<number[]> {\r\n return this._faceIndices;\r\n }\r\n\r\n /**\r\n * Gets the layer indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get layerIndices(): Nullable<number[]> {\r\n return this._layerIndices;\r\n }\r\n\r\n /**\r\n * Sets this property to true to disable the automatic MSAA resolve that happens when the render target wrapper is unbound (default is false)\r\n */\r\n public disableAutomaticMSAAResolve = false;\r\n\r\n /**\r\n * Indicates if MSAA color texture(s) should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is true)\r\n * Note that you can trigger a MSAA resolve at any time by calling resolveMSAATextures()\r\n */\r\n public resolveMSAAColors = true;\r\n\r\n /**\r\n * Indicates if MSAA depth texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAADepth = false;\r\n\r\n /**\r\n * Indicates if MSAA stencil texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAAStencil = false;\r\n\r\n /**\r\n * Indicates if the depth texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * Indicates if the stencil texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * Gets the base array layer of a texture in the textures array\r\n * This is an number that is calculated based on the layer and face indices set for this texture at that index\r\n * @param index The index of the texture in the textures array to get the base array layer for\r\n * @returns the base array layer of the texture at the given index\r\n */\r\n public getBaseArrayLayer(index: number): number {\r\n if (!this._textures) {\r\n return -1;\r\n }\r\n\r\n const texture = this._textures[index];\r\n const layerIndex = this._layerIndices?.[index] ?? 0;\r\n const faceIndex = this._faceIndices?.[index] ?? 0;\r\n\r\n return texture.isCube ? layerIndex * 6 + faceIndex : texture.is3D ? 0 : layerIndex;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Resolves the MSAA textures into their non-MSAA version.\r\n * Note that if samples equals 1 (no MSAA), no resolve is performed.\r\n */\r\n public resolveMSAATextures(): void {\r\n if (this.isMulti) {\r\n this._engine.resolveMultiFramebuffer(this);\r\n } else {\r\n this._engine.resolveFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Generates mipmaps for each texture of the render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._engine._currentRenderTarget === this) {\r\n this._engine.unBindFramebuffer(this, true);\r\n }\r\n if (this.isMulti) {\r\n this._engine.generateMipMapsMultiFramebuffer(this);\r\n } else {\r\n this._engine.generateMipMapsFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n * @param label defines the label to use for the wrapper (for debugging purpose only)\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: AbstractEngine, label?: string) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture The texture to set\r\n * @param index The index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] === texture) {\r\n return;\r\n }\r\n\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture bound to each color attachment\r\n * @param layers The layers of each texture to be set\r\n * @param faces The faces of each texture to be set\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n this._layerIndices = layers;\r\n this._faceIndices = faces;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n if (!this._layerIndices) {\r\n this._layerIndices = [];\r\n }\r\n if (!this._faceIndices) {\r\n this._faceIndices = [];\r\n }\r\n\r\n if (layer !== undefined && layer >= 0) {\r\n this._layerIndices[index] = layer;\r\n }\r\n if (face !== undefined && face >= 0) {\r\n this._faceIndices[index] = face;\r\n }\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil Not used anymore. \"format\" will be used to determine if stencil should be created\r\n * @param samples sample count to use when creating the texture (default: 1)\r\n * @param format format of the depth texture (default: Constants.TEXTUREFORMAT_DEPTH32_FLOAT)\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTextureLabel = label;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n label,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * @deprecated Use shareDepth instead\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n this.shareDepth(renderTarget);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n renderTarget._depthStencilTextureWithStencil = this._depthStencilTextureWithStencil;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n let depthTextureFormat = -1;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n depthTextureFormat = textureArray[textureArray.length - 1].format;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const targetTypes: number[] = [];\r\n const faceIndex: number[] = [];\r\n const layerIndex: number[] = [];\r\n const layerCounts: number[] = [];\r\n const internalTexture2Index: { [id: number]: number } = {};\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n formats.push(texture.format);\r\n\r\n const index = internalTexture2Index[texture.uniqueId];\r\n if (index !== undefined) {\r\n targetTypes.push(-1);\r\n layerCounts.push(0);\r\n } else {\r\n internalTexture2Index[texture.uniqueId] = i;\r\n if (texture.is2DArray) {\r\n targetTypes.push(Constants.TEXTURE_2D_ARRAY);\r\n layerCounts.push(texture.depth);\r\n } else if (texture.isCube) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP);\r\n layerCounts.push(0);\r\n } /*else if (texture.isCubeArray) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP_ARRAY);\r\n layerCounts.push(texture.depth);\r\n }*/ else if (texture.is3D) {\r\n targetTypes.push(Constants.TEXTURE_3D);\r\n layerCounts.push(texture.depth);\r\n } else {\r\n targetTypes.push(Constants.TEXTURE_2D);\r\n layerCounts.push(0);\r\n }\r\n }\r\n\r\n if (this._faceIndices) {\r\n faceIndex.push(this._faceIndices[i] ?? 0);\r\n }\r\n if (this._layerIndices) {\r\n layerIndex.push(this._layerIndices[i] ?? 0);\r\n }\r\n }\r\n\r\n const optionsMRT: IMultiRenderTargetOptions = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n depthTextureFormat,\r\n types,\r\n formats,\r\n textureCount,\r\n targetTypes,\r\n faceIndex,\r\n layerIndex,\r\n layerCounts,\r\n label: this.label,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n depth: this.depth,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n if (targetTypes[i] !== -1) {\r\n continue;\r\n }\r\n const index = internalTexture2Index[textureArray[i].uniqueId];\r\n rtw.setTexture(rtw.textures![index], i);\r\n }\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n options.noColorAttachment = !this._textures;\r\n options.label = this.label;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray || this.is3D ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n if (rtw.texture) {\r\n rtw.texture.isReady = true;\r\n }\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const format = this._depthStencilTexture.format;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n\r\n rtw.createDepthStencilTexture(\r\n this._depthStencilTexture._comparisonFunction,\r\n bilinear,\r\n this._depthStencilTextureWithStencil,\r\n this._depthStencilTexture.samples,\r\n format,\r\n this._depthStencilTextureLabel\r\n );\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"renderTargetWrapper.js","sourceRoot":"","sources":["../../../../dev/core/src/Engines/renderTargetWrapper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,yDAAwD;AAYnF;;GAEG;AACH,MAAM,OAAO,mBAAmB;IA6B5B;;OAEG;IACH,IAAW,mBAAmB;QAC1B,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;IAED;;;;OAIG;IACI,sBAAsB,CAAC,OAAkC,EAAE,eAAe,GAAG,IAAI;QACpF,IAAI,eAAe,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC/C,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACxC,CAAC;QAED,IAAI,CAAC,oBAAoB,GAAG,OAAO,CAAC;QAEpC,IAAI,CAAC,oBAAoB,GAAG,IAA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OAAO,GAAG,CAAC,EAAE,CAAC;YACnB,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QAED,GAAG,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;QACnC,GAAG,CAAC,OAAO,EAAE,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,eAAe;QAClB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC;gBAC7C,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;OAGG;IACI,OAAO,CAAC,uBAAuB,GAAG,KAAK;QAC1C,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC3B,IAAI,CAAC,oBAAoB,EAAE,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACjC,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3B,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;IACnD,CAAC;CACJ","sourcesContent":["import type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { InternalTextureSource } from \"../Materials/Textures/internalTexture\";\r\nimport type { RenderTargetCreationOptions, TextureSize } from \"../Materials/Textures/textureCreationOptions\";\r\nimport type { Nullable } from \"../types\";\r\nimport { Constants } from \"./constants\";\r\nimport type { AbstractEngine } from \"./abstractEngine\";\r\nimport type { IMultiRenderTargetOptions } from \"../Materials/Textures/multiRenderTarget\";\r\nimport { HasStencilAspect } from \"core/Materials/Textures/textureHelper.functions\";\r\n\r\n/**\r\n * An interface enforcing the renderTarget accessor to used by render target textures.\r\n */\r\nexport interface IRenderTargetTexture {\r\n /**\r\n * Entry point to access the wrapper on a texture.\r\n */\r\n renderTarget: Nullable<RenderTargetWrapper>;\r\n}\r\n\r\n/**\r\n * Wrapper around a render target (either single or multi textures)\r\n */\r\nexport class RenderTargetWrapper {\r\n protected _engine: AbstractEngine;\r\n private _size: TextureSize;\r\n private _isCube: boolean;\r\n private _isMulti: boolean;\r\n private _textures: Nullable<InternalTexture[]> = null;\r\n private _faceIndices: Nullable<number[]> = null;\r\n private _layerIndices: Nullable<number[]> = null;\r\n private _depthStencilTextureLabel?: string;\r\n /** @internal */\r\n public _samples = 1;\r\n\r\n /** @internal */\r\n public _attachments: Nullable<number[]> = null;\r\n /** @internal */\r\n public _generateStencilBuffer: boolean = false;\r\n /** @internal */\r\n public _generateDepthBuffer: boolean = false;\r\n\r\n /** @internal */\r\n public _depthStencilTexture: Nullable<InternalTexture>;\r\n /** @internal */\r\n public _depthStencilTextureWithStencil: boolean = false;\r\n\r\n /**\r\n * Gets or sets the label of the render target wrapper (optional, for debugging purpose)\r\n */\r\n public label?: string;\r\n\r\n /**\r\n * Gets the depth/stencil texture\r\n */\r\n public get depthStencilTexture() {\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * Sets the depth/stencil texture\r\n * @param texture The depth/stencil texture to set\r\n * @param disposeExisting True to dispose the existing depth/stencil texture (if any) before replacing it (default: true)\r\n */\r\n public setDepthStencilTexture(texture: Nullable<InternalTexture>, disposeExisting = true) {\r\n if (disposeExisting && this._depthStencilTexture) {\r\n this._depthStencilTexture.dispose();\r\n }\r\n\r\n this._depthStencilTexture = texture;\r\n\r\n this._generateDepthBuffer = this._generateStencilBuffer = this._depthStencilTextureWithStencil = false;\r\n\r\n if (texture) {\r\n this._generateDepthBuffer = true;\r\n this._generateStencilBuffer = this._depthStencilTextureWithStencil = HasStencilAspect(texture.format);\r\n }\r\n }\r\n\r\n /**\r\n * Indicates if the depth/stencil texture has a stencil aspect\r\n */\r\n public get depthStencilTextureWithStencil() {\r\n return this._depthStencilTextureWithStencil;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a cube texture or if false a 2d texture\r\n */\r\n public get isCube(): boolean {\r\n return this._isCube;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or multi target render wrapper\r\n */\r\n public get isMulti(): boolean {\r\n return this._isMulti;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a single or an array of textures\r\n */\r\n public get is2DArray(): boolean {\r\n return this.layers > 0;\r\n }\r\n\r\n /**\r\n * Defines if the render target wrapper is for a 3D texture\r\n */\r\n public get is3D(): boolean {\r\n return this.depth > 0;\r\n }\r\n\r\n /**\r\n * Gets the size of the render target wrapper (used for cubes, as width=height in this case)\r\n */\r\n public get size(): number {\r\n return this.width;\r\n }\r\n\r\n /**\r\n * Gets the width of the render target wrapper\r\n */\r\n public get width(): number {\r\n return (<{ width: number; height: number }>this._size).width ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the height of the render target wrapper\r\n */\r\n public get height(): number {\r\n return (<{ width: number; height: number }>this._size).height ?? <number>this._size;\r\n }\r\n\r\n /**\r\n * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)\r\n */\r\n public get layers(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).layers || 0;\r\n }\r\n\r\n /**\r\n * Gets the depth of the render target wrapper (only used if is3D is true and wrapper is not a multi render target)\r\n */\r\n public get depth(): number {\r\n return (<{ width: number; height: number; depth?: number; layers?: number }>this._size).depth || 0;\r\n }\r\n\r\n /**\r\n * Gets the render texture. If this is a multi render target, gets the first texture\r\n */\r\n public get texture(): Nullable<InternalTexture> {\r\n return this._textures?.[0] ?? null;\r\n }\r\n\r\n /**\r\n * Gets the list of render textures. If we are not in a multi render target, the list will be null (use the texture getter instead)\r\n */\r\n public get textures(): Nullable<InternalTexture[]> {\r\n return this._textures;\r\n }\r\n\r\n /**\r\n * Gets the face indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get faceIndices(): Nullable<number[]> {\r\n return this._faceIndices;\r\n }\r\n\r\n /**\r\n * Gets the layer indices that correspond to the list of render textures. If we are not in a multi render target, the list will be null\r\n */\r\n public get layerIndices(): Nullable<number[]> {\r\n return this._layerIndices;\r\n }\r\n\r\n /**\r\n * Sets this property to true to disable the automatic MSAA resolve that happens when the render target wrapper is unbound (default is false)\r\n */\r\n public disableAutomaticMSAAResolve = false;\r\n\r\n /**\r\n * Indicates if MSAA color texture(s) should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is true)\r\n * Note that you can trigger a MSAA resolve at any time by calling resolveMSAATextures()\r\n */\r\n public resolveMSAAColors = true;\r\n\r\n /**\r\n * Indicates if MSAA depth texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAADepth = false;\r\n\r\n /**\r\n * Indicates if MSAA stencil texture should be resolved when a resolve occur (either automatically by the engine or manually by the user) (default is false)\r\n */\r\n public resolveMSAAStencil = false;\r\n\r\n /**\r\n * Indicates if the depth texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public depthReadOnly = false;\r\n\r\n /**\r\n * Indicates if the stencil texture is in read-only mode (may allow some optimizations in WebGPU)\r\n */\r\n public stencilReadOnly = false;\r\n\r\n /**\r\n * Gets the base array layer of a texture in the textures array\r\n * This is an number that is calculated based on the layer and face indices set for this texture at that index\r\n * @param index The index of the texture in the textures array to get the base array layer for\r\n * @returns the base array layer of the texture at the given index\r\n */\r\n public getBaseArrayLayer(index: number): number {\r\n if (!this._textures) {\r\n return -1;\r\n }\r\n\r\n const texture = this._textures[index];\r\n const layerIndex = this._layerIndices?.[index] ?? 0;\r\n const faceIndex = this._faceIndices?.[index] ?? 0;\r\n\r\n return texture.isCube ? layerIndex * 6 + faceIndex : texture.is3D ? 0 : layerIndex;\r\n }\r\n\r\n /**\r\n * Gets the sample count of the render target\r\n */\r\n public get samples(): number {\r\n return this._samples;\r\n }\r\n\r\n /**\r\n * Sets the sample count of the render target\r\n * @param value sample count\r\n * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).\r\n * @param force true to force calling the update sample count engine function even if the current sample count is equal to value\r\n * @returns the sample count that has been set\r\n */\r\n public setSamples(value: number, initializeBuffers = true, force = false): number {\r\n if (this.samples === value && !force) {\r\n return value;\r\n }\r\n\r\n const result = this._isMulti\r\n ? this._engine.updateMultipleRenderTargetTextureSampleCount(this, value, initializeBuffers)\r\n : this._engine.updateRenderTargetTextureSampleCount(this, value);\r\n this._samples = value;\r\n return result;\r\n }\r\n\r\n /**\r\n * Resolves the MSAA textures into their non-MSAA version.\r\n * Note that if samples equals 1 (no MSAA), no resolve is performed.\r\n */\r\n public resolveMSAATextures(): void {\r\n if (this.isMulti) {\r\n this._engine.resolveMultiFramebuffer(this);\r\n } else {\r\n this._engine.resolveFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Generates mipmaps for each texture of the render target\r\n */\r\n public generateMipMaps(): void {\r\n if (this._engine._currentRenderTarget === this) {\r\n if (this.isMulti) {\r\n this._engine.unBindMultiColorAttachmentFramebuffer(this, true);\r\n } else {\r\n this._engine.unBindFramebuffer(this, true);\r\n }\r\n }\r\n if (this.isMulti) {\r\n this._engine.generateMipMapsMultiFramebuffer(this);\r\n } else {\r\n this._engine.generateMipMapsFramebuffer(this);\r\n }\r\n }\r\n\r\n /**\r\n * Initializes the render target wrapper\r\n * @param isMulti true if the wrapper is a multi render target\r\n * @param isCube true if the wrapper should render to a cube texture\r\n * @param size size of the render target (width/height/layers)\r\n * @param engine engine used to create the render target\r\n * @param label defines the label to use for the wrapper (for debugging purpose only)\r\n */\r\n constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: AbstractEngine, label?: string) {\r\n this._isMulti = isMulti;\r\n this._isCube = isCube;\r\n this._size = size;\r\n this._engine = engine;\r\n this._depthStencilTexture = null;\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Sets the render target texture(s)\r\n * @param textures texture(s) to set\r\n */\r\n public setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void {\r\n if (Array.isArray(textures)) {\r\n this._textures = textures;\r\n } else if (textures) {\r\n this._textures = [textures];\r\n } else {\r\n this._textures = null;\r\n }\r\n }\r\n\r\n /**\r\n * Set a texture in the textures array\r\n * @param texture The texture to set\r\n * @param index The index in the textures array to set\r\n * @param disposePrevious If this function should dispose the previous texture\r\n */\r\n public setTexture(texture: InternalTexture, index: number = 0, disposePrevious: boolean = true): void {\r\n if (!this._textures) {\r\n this._textures = [];\r\n }\r\n if (this._textures[index] === texture) {\r\n return;\r\n }\r\n\r\n if (this._textures[index] && disposePrevious) {\r\n this._textures[index].dispose();\r\n }\r\n\r\n this._textures[index] = texture;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of every render target texture bound to each color attachment\r\n * @param layers The layers of each texture to be set\r\n * @param faces The faces of each texture to be set\r\n */\r\n public setLayerAndFaceIndices(layers: number[], faces: number[]) {\r\n this._layerIndices = layers;\r\n this._faceIndices = faces;\r\n }\r\n\r\n /**\r\n * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment\r\n * @param index The index of the texture in the textures array to modify\r\n * @param layer The layer of the texture to be set\r\n * @param face The face of the texture to be set\r\n */\r\n public setLayerAndFaceIndex(index: number = 0, layer?: number, face?: number): void {\r\n if (!this._layerIndices) {\r\n this._layerIndices = [];\r\n }\r\n if (!this._faceIndices) {\r\n this._faceIndices = [];\r\n }\r\n\r\n if (layer !== undefined && layer >= 0) {\r\n this._layerIndices[index] = layer;\r\n }\r\n if (face !== undefined && face >= 0) {\r\n this._faceIndices[index] = face;\r\n }\r\n }\r\n\r\n /**\r\n * Creates the depth/stencil texture\r\n * @param comparisonFunction Comparison function to use for the texture\r\n * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture\r\n * @param generateStencil Not used anymore. \"format\" will be used to determine if stencil should be created\r\n * @param samples sample count to use when creating the texture (default: 1)\r\n * @param format format of the depth texture (default: Constants.TEXTUREFORMAT_DEPTH32_FLOAT)\r\n * @param label defines the label to use for the texture (for debugging purpose only)\r\n * @returns the depth/stencil created texture\r\n */\r\n public createDepthStencilTexture(\r\n comparisonFunction: number = 0,\r\n bilinearFiltering: boolean = true,\r\n generateStencil: boolean = false,\r\n samples: number = 1,\r\n format: number = Constants.TEXTUREFORMAT_DEPTH32_FLOAT,\r\n label?: string\r\n ): InternalTexture {\r\n this._depthStencilTexture?.dispose();\r\n\r\n this._depthStencilTextureWithStencil = generateStencil;\r\n this._depthStencilTextureLabel = label;\r\n this._depthStencilTexture = this._engine.createDepthStencilTexture(\r\n this._size,\r\n {\r\n bilinearFiltering,\r\n comparisonFunction,\r\n generateStencil,\r\n isCube: this._isCube,\r\n samples,\r\n depthTextureFormat: format,\r\n label,\r\n },\r\n this\r\n );\r\n\r\n return this._depthStencilTexture;\r\n }\r\n\r\n /**\r\n * @deprecated Use shareDepth instead\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public _shareDepth(renderTarget: RenderTargetWrapper): void {\r\n this.shareDepth(renderTarget);\r\n }\r\n\r\n /**\r\n * Shares the depth buffer of this render target with another render target.\r\n * @param renderTarget Destination renderTarget\r\n */\r\n public shareDepth(renderTarget: RenderTargetWrapper): void {\r\n if (this._depthStencilTexture) {\r\n if (renderTarget._depthStencilTexture) {\r\n renderTarget._depthStencilTexture.dispose();\r\n }\r\n\r\n renderTarget._depthStencilTexture = this._depthStencilTexture;\r\n renderTarget._depthStencilTextureWithStencil = this._depthStencilTextureWithStencil;\r\n this._depthStencilTexture.incrementReferences();\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _swapAndDie(target: InternalTexture): void {\r\n if (this.texture) {\r\n this.texture._swapAndDie(target);\r\n }\r\n this._textures = null;\r\n this.dispose(true);\r\n }\r\n\r\n protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper> {\r\n let rtw: Nullable<RenderTargetWrapper> = null;\r\n\r\n if (this._isMulti) {\r\n const textureArray = this.textures;\r\n if (textureArray && textureArray.length > 0) {\r\n let generateDepthTexture = false;\r\n let textureCount = textureArray.length;\r\n let depthTextureFormat = -1;\r\n\r\n const lastTextureSource = textureArray[textureArray.length - 1]._source;\r\n if (lastTextureSource === InternalTextureSource.Depth || lastTextureSource === InternalTextureSource.DepthStencil) {\r\n generateDepthTexture = true;\r\n depthTextureFormat = textureArray[textureArray.length - 1].format;\r\n textureCount--;\r\n }\r\n\r\n const samplingModes: number[] = [];\r\n const types: number[] = [];\r\n const formats: number[] = [];\r\n const targetTypes: number[] = [];\r\n const faceIndex: number[] = [];\r\n const layerIndex: number[] = [];\r\n const layerCounts: number[] = [];\r\n const internalTexture2Index: { [id: number]: number } = {};\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n const texture = textureArray[i];\r\n\r\n samplingModes.push(texture.samplingMode);\r\n types.push(texture.type);\r\n formats.push(texture.format);\r\n\r\n const index = internalTexture2Index[texture.uniqueId];\r\n if (index !== undefined) {\r\n targetTypes.push(-1);\r\n layerCounts.push(0);\r\n } else {\r\n internalTexture2Index[texture.uniqueId] = i;\r\n if (texture.is2DArray) {\r\n targetTypes.push(Constants.TEXTURE_2D_ARRAY);\r\n layerCounts.push(texture.depth);\r\n } else if (texture.isCube) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP);\r\n layerCounts.push(0);\r\n } /*else if (texture.isCubeArray) {\r\n targetTypes.push(Constants.TEXTURE_CUBE_MAP_ARRAY);\r\n layerCounts.push(texture.depth);\r\n }*/ else if (texture.is3D) {\r\n targetTypes.push(Constants.TEXTURE_3D);\r\n layerCounts.push(texture.depth);\r\n } else {\r\n targetTypes.push(Constants.TEXTURE_2D);\r\n layerCounts.push(0);\r\n }\r\n }\r\n\r\n if (this._faceIndices) {\r\n faceIndex.push(this._faceIndices[i] ?? 0);\r\n }\r\n if (this._layerIndices) {\r\n layerIndex.push(this._layerIndices[i] ?? 0);\r\n }\r\n }\r\n\r\n const optionsMRT: IMultiRenderTargetOptions = {\r\n samplingModes,\r\n generateMipMaps: textureArray[0].generateMipMaps,\r\n generateDepthBuffer: this._generateDepthBuffer,\r\n generateStencilBuffer: this._generateStencilBuffer,\r\n generateDepthTexture,\r\n depthTextureFormat,\r\n types,\r\n formats,\r\n textureCount,\r\n targetTypes,\r\n faceIndex,\r\n layerIndex,\r\n layerCounts,\r\n label: this.label,\r\n };\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n depth: this.depth,\r\n };\r\n\r\n rtw = this._engine.createMultipleRenderTarget(size, optionsMRT);\r\n\r\n for (let i = 0; i < textureCount; ++i) {\r\n if (targetTypes[i] !== -1) {\r\n continue;\r\n }\r\n const index = internalTexture2Index[textureArray[i].uniqueId];\r\n rtw.setTexture(rtw.textures![index], i);\r\n }\r\n }\r\n } else {\r\n const options: RenderTargetCreationOptions = {};\r\n\r\n options.generateDepthBuffer = this._generateDepthBuffer;\r\n options.generateMipMaps = this.texture?.generateMipMaps ?? false;\r\n options.generateStencilBuffer = this._generateStencilBuffer;\r\n options.samplingMode = this.texture?.samplingMode;\r\n options.type = this.texture?.type;\r\n options.format = this.texture?.format;\r\n options.noColorAttachment = !this._textures;\r\n options.label = this.label;\r\n\r\n if (this.isCube) {\r\n rtw = this._engine.createRenderTargetCubeTexture(this.width, options);\r\n } else {\r\n const size = {\r\n width: this.width,\r\n height: this.height,\r\n layers: this.is2DArray || this.is3D ? this.texture?.depth : undefined,\r\n };\r\n\r\n rtw = this._engine.createRenderTargetTexture(size, options);\r\n }\r\n if (rtw.texture) {\r\n rtw.texture.isReady = true;\r\n }\r\n }\r\n\r\n return rtw;\r\n }\r\n\r\n protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void {\r\n if (this._textures && target._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i]._swapAndDie(target._textures[i], false);\r\n target._textures[i].isReady = true;\r\n }\r\n }\r\n if (this._depthStencilTexture && target._depthStencilTexture) {\r\n this._depthStencilTexture._swapAndDie(target._depthStencilTexture);\r\n target._depthStencilTexture.isReady = true;\r\n }\r\n\r\n this._textures = null;\r\n this._depthStencilTexture = null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {\r\n const rtw = this._cloneRenderTargetWrapper();\r\n if (!rtw) {\r\n return;\r\n }\r\n\r\n if (this._depthStencilTexture) {\r\n const samplingMode = this._depthStencilTexture.samplingMode;\r\n const format = this._depthStencilTexture.format;\r\n const bilinear =\r\n samplingMode === Constants.TEXTURE_BILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_TRILINEAR_SAMPLINGMODE ||\r\n samplingMode === Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST;\r\n\r\n rtw.createDepthStencilTexture(\r\n this._depthStencilTexture._comparisonFunction,\r\n bilinear,\r\n this._depthStencilTextureWithStencil,\r\n this._depthStencilTexture.samples,\r\n format,\r\n this._depthStencilTextureLabel\r\n );\r\n }\r\n\r\n if (this.samples > 1) {\r\n rtw.setSamples(this.samples);\r\n }\r\n\r\n rtw._swapRenderTargetWrapper(this);\r\n rtw.dispose();\r\n }\r\n\r\n /**\r\n * Releases the internal render textures\r\n */\r\n public releaseTextures(): void {\r\n if (this._textures) {\r\n for (let i = 0; i < this._textures.length; ++i) {\r\n this._textures[i].dispose();\r\n }\r\n }\r\n this._textures = null;\r\n }\r\n\r\n /**\r\n * Disposes the whole render target wrapper\r\n * @param disposeOnlyFramebuffers true if only the frame buffers should be released (used for the WebGL engine). If false, all the textures will also be released\r\n */\r\n public dispose(disposeOnlyFramebuffers = false): void {\r\n if (!disposeOnlyFramebuffers) {\r\n this._depthStencilTexture?.dispose();\r\n this._depthStencilTexture = null;\r\n this.releaseTextures();\r\n }\r\n\r\n this._engine._releaseRenderTargetWrapper(this);\r\n }\r\n}\r\n"]}
@@ -863,7 +863,8 @@ export declare class WebGPUEngine extends ThinWebGPUEngine {
863
863
  flushFramebuffer(): void;
864
864
  /** @internal */
865
865
  _currentFrameBufferIsDefaultFrameBuffer(): boolean;
866
- private _startRenderTargetRenderPass;
866
+ /** @internal */
867
+ _startRenderTargetRenderPass(renderTargetWrapper: RenderTargetWrapper, setClearStates: boolean, clearColor: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
867
868
  private _startMainRenderPass;
868
869
  /**
869
870
  * Binds the frame buffer to the specified texture.
@@ -883,17 +884,19 @@ export declare class WebGPUEngine extends ThinWebGPUEngine {
883
884
  * @param onBeforeUnbind defines a function which will be called before the effective unbind
884
885
  */
885
886
  unBindFramebuffer(texture: RenderTargetWrapper, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
887
+ private _resolveAndGenerateMipMapsFramebuffer;
886
888
  /**
887
889
  * Generates mipmaps for the texture of the (single) render target
888
890
  * @param texture The render target containing the texture to generate the mipmaps for
889
891
  */
890
892
  generateMipMapsFramebuffer(texture: RenderTargetWrapper): void;
891
893
  /**
892
- * Resolves the MSAA texture of the (single) render target into its non-MSAA version.
894
+ * Resolves the MSAA texture of the render target into its non-MSAA version.
893
895
  * Note that if "texture" is not a MSAA render target, no resolve is performed.
894
- * @param _texture The render target texture containing the MSAA texture to resolve
896
+ * @param texture The render target texture containing the MSAA texture to resolve
897
+ * @param resolveColors If true, resolve the color textures (default: true) - still subject to texture.resolveMSAAColors
895
898
  */
896
- resolveFramebuffer(_texture: RenderTargetWrapper): void;
899
+ resolveFramebuffer(texture: RenderTargetWrapper, resolveColors?: boolean): void;
897
900
  /**
898
901
  * Unbind the current render target and bind the default framebuffer
899
902
  */
@@ -2374,6 +2374,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2374
2374
  //------------------------------------------------------------------------------
2375
2375
  // Render Pass
2376
2376
  //------------------------------------------------------------------------------
2377
+ /** @internal */
2377
2378
  _startRenderTargetRenderPass(renderTargetWrapper, setClearStates, clearColor, clearDepth, clearStencil) {
2378
2379
  this._endCurrentRenderPass();
2379
2380
  const rtWrapper = renderTargetWrapper;
@@ -2381,9 +2382,11 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2381
2382
  const gpuDepthStencilWrapper = depthStencilTexture?._hardwareTexture;
2382
2383
  const gpuDepthStencilTexture = gpuDepthStencilWrapper?.underlyingResource;
2383
2384
  const gpuDepthStencilMSAATexture = gpuDepthStencilWrapper?.getMSAATexture(0);
2384
- const depthTextureView = gpuDepthStencilTexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2385
2385
  const depthMSAATextureView = gpuDepthStencilMSAATexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2386
- const depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilWrapper.format) : false;
2386
+ const depthTextureView = depthMSAATextureView ? undefined : gpuDepthStencilTexture?.createView(this._rttRenderPassWrapper.depthAttachmentViewDescriptor);
2387
+ // We use the MSAA texture format (if available) to determine if it has a stencil aspect or not because, for MSAA depth textures,
2388
+ // the format of the "resolve" texture (gpuDepthStencilWrapper.format) is a single red channel format, not a depth-stencil format.
2389
+ const depthTextureHasStencil = gpuDepthStencilWrapper ? WebGPUTextureHelper.HasStencilAspect(gpuDepthStencilMSAATexture?.format ?? gpuDepthStencilWrapper.format) : false;
2387
2390
  const colorAttachments = [];
2388
2391
  if (this.useReverseDepthBuffer) {
2389
2392
  this.setDepthFunctionToGreaterOrEqual();
@@ -2428,7 +2431,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2428
2431
  const colorMSAATextureView = gpuMSAATexture?.createView(msaaViewDescriptor);
2429
2432
  colorAttachments.push({
2430
2433
  view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,
2431
- resolveTarget: gpuMSAATexture ? colorTextureView : undefined,
2434
+ resolveTarget: gpuMSAATexture && !rtWrapper.disableAutomaticMSAAResolve ? colorTextureView : undefined,
2432
2435
  depthSlice: mrtTexture.is3D ? (rtWrapper.layerIndices?.[i] ?? 0) : undefined,
2433
2436
  clearValue: index !== 0 && mustClearColor ? (isRtInteger ? clearColorForIntegerRt : clearColor) : undefined,
2434
2437
  loadOp: index !== 0 && mustClearColor ? "clear" /* WebGPUConstants.LoadOp.Clear */ : "load" /* WebGPUConstants.LoadOp.Load */,
@@ -2456,7 +2459,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2456
2459
  const isRtInteger = internalTexture.type === 7 || internalTexture.type === 5;
2457
2460
  colorAttachments.push({
2458
2461
  view: colorMSAATextureView ? colorMSAATextureView : colorTextureView,
2459
- resolveTarget: gpuMSAATexture ? colorTextureView : undefined,
2462
+ resolveTarget: gpuMSAATexture && !rtWrapper.disableAutomaticMSAAResolve ? colorTextureView : undefined,
2460
2463
  depthSlice,
2461
2464
  clearValue: mustClearColor ? (isRtInteger ? clearColorForIntegerRt : clearColor) : undefined,
2462
2465
  loadOp: mustClearColor ? "clear" /* WebGPUConstants.LoadOp.Clear */ : "load" /* WebGPUConstants.LoadOp.Load */,
@@ -2607,6 +2610,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2607
2610
  this._setDepthTextureFormat(this._rttRenderPassWrapper);
2608
2611
  this._setColorFormat(this._rttRenderPassWrapper);
2609
2612
  this._rttRenderPassWrapper.colorAttachmentViewDescriptor = {
2613
+ label: texture.label ? texture.label + " - Color Attachment View" : "RTT - Color Attachment View",
2610
2614
  format: this._colorFormat,
2611
2615
  dimension: texture.is3D ? "3d" /* WebGPUConstants.TextureViewDimension.E3d */ : "2d" /* WebGPUConstants.TextureViewDimension.E2d */,
2612
2616
  mipLevelCount: 1,
@@ -2616,6 +2620,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2616
2620
  aspect: "all" /* WebGPUConstants.TextureAspect.All */,
2617
2621
  };
2618
2622
  this._rttRenderPassWrapper.depthAttachmentViewDescriptor = {
2623
+ label: texture.label ? texture.label + " - Depth Attachment View" : "RTT - Depth Attachment View",
2619
2624
  format: this._depthTextureFormat,
2620
2625
  dimension: depthStencilTexture && depthStencilTexture.is3D ? "3d" /* WebGPUConstants.TextureViewDimension.E3d */ : "2d" /* WebGPUConstants.TextureViewDimension.E2d */,
2621
2626
  mipLevelCount: 1,
@@ -2689,14 +2694,7 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2689
2694
  }
2690
2695
  this._currentRenderTarget = saveCrt;
2691
2696
  this._endCurrentRenderPass();
2692
- if (!disableGenerateMipMaps) {
2693
- if (texture.isMulti) {
2694
- this.generateMipMapsMultiFramebuffer(texture);
2695
- }
2696
- else {
2697
- this.generateMipMapsFramebuffer(texture);
2698
- }
2699
- }
2697
+ this._resolveAndGenerateMipMapsFramebuffer(texture, disableGenerateMipMaps);
2700
2698
  this._currentRenderTarget = null;
2701
2699
  if (this.dbgVerboseLogsForFirstFrames) {
2702
2700
  if (this._count === undefined) {
@@ -2710,6 +2708,21 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2710
2708
  this._cacheRenderPipeline.setMRT([]);
2711
2709
  this._cacheRenderPipeline.setMRTAttachments(this._mrtAttachments);
2712
2710
  }
2711
+ _resolveAndGenerateMipMapsFramebuffer(texture, disableGenerateMipMaps = false) {
2712
+ const webglRtWrapper = texture;
2713
+ if (!webglRtWrapper.disableAutomaticMSAAResolve) {
2714
+ // we pass false as the second parameter because the color resolve has already been done automatically when the render pass ended
2715
+ this.resolveFramebuffer(texture, false);
2716
+ }
2717
+ if (!disableGenerateMipMaps) {
2718
+ if (texture.isMulti) {
2719
+ this.generateMipMapsMultiFramebuffer(texture);
2720
+ }
2721
+ else {
2722
+ this.generateMipMapsFramebuffer(texture);
2723
+ }
2724
+ }
2725
+ }
2713
2726
  /**
2714
2727
  * Generates mipmaps for the texture of the (single) render target
2715
2728
  * @param texture The render target containing the texture to generate the mipmaps for
@@ -2720,12 +2733,28 @@ export class WebGPUEngine extends ThinWebGPUEngine {
2720
2733
  }
2721
2734
  }
2722
2735
  /**
2723
- * Resolves the MSAA texture of the (single) render target into its non-MSAA version.
2736
+ * Resolves the MSAA texture of the render target into its non-MSAA version.
2724
2737
  * Note that if "texture" is not a MSAA render target, no resolve is performed.
2725
- * @param _texture The render target texture containing the MSAA texture to resolve
2738
+ * @param texture The render target texture containing the MSAA texture to resolve
2739
+ * @param resolveColors If true, resolve the color textures (default: true) - still subject to texture.resolveMSAAColors
2726
2740
  */
2727
- resolveFramebuffer(_texture) {
2728
- throw new Error("resolveFramebuffer is not yet implemented in WebGPU!");
2741
+ resolveFramebuffer(texture, resolveColors = true) {
2742
+ if (texture.samples <= 1) {
2743
+ return;
2744
+ }
2745
+ if (texture.resolveMSAAColors && resolveColors) {
2746
+ const disableAutomaticMSAAResolve = texture.disableAutomaticMSAAResolve;
2747
+ texture.disableAutomaticMSAAResolve = false;
2748
+ // Simply bind and unbind the framebuffer to trigger the resolve
2749
+ this.bindFramebuffer(texture);
2750
+ this._startRenderTargetRenderPass(this._currentRenderTarget, false, null, false, false);
2751
+ this.unBindFramebuffer(texture);
2752
+ texture.disableAutomaticMSAAResolve = disableAutomaticMSAAResolve;
2753
+ }
2754
+ if (texture.resolveMSAADepth && texture._depthStencilTexture) {
2755
+ const gpuTextureWrapper = texture._depthStencilTexture._hardwareTexture;
2756
+ this._textureHelper.resolveMSAADepthTexture(gpuTextureWrapper.getMSAATexture(0), gpuTextureWrapper.underlyingResource, this._renderEncoder);
2757
+ }
2729
2758
  }
2730
2759
  /**
2731
2760
  * Unbind the current render target and bind the default framebuffer