renderTargetWrapper.d.ts 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. import type { InternalTexture } from "../Materials/Textures/internalTexture";
  2. import type { TextureSize } from "../Materials/Textures/textureCreationOptions";
  3. import type { Nullable } from "../types";
  4. import type { AbstractEngine } from "./abstractEngine";
  5. /**
  6. * An interface enforcing the renderTarget accessor to used by render target textures.
  7. */
  8. export interface IRenderTargetTexture {
  9. /**
  10. * Entry point to access the wrapper on a texture.
  11. */
  12. renderTarget: Nullable<RenderTargetWrapper>;
  13. }
  14. /**
  15. * Wrapper around a render target (either single or multi textures)
  16. */
  17. export declare class RenderTargetWrapper {
  18. protected _engine: AbstractEngine;
  19. private _size;
  20. private _isCube;
  21. private _isMulti;
  22. private _textures;
  23. private _faceIndices;
  24. private _layerIndices;
  25. private _depthStencilTextureLabel?;
  26. /** @internal */
  27. _samples: number;
  28. /** @internal */
  29. _attachments: Nullable<number[]>;
  30. /** @internal */
  31. _generateStencilBuffer: boolean;
  32. /** @internal */
  33. _generateDepthBuffer: boolean;
  34. /** @internal */
  35. _depthStencilTexture: Nullable<InternalTexture>;
  36. /** @internal */
  37. _depthStencilTextureWithStencil: boolean;
  38. /**
  39. * Gets or sets the label of the render target wrapper (optional, for debugging purpose)
  40. */
  41. label?: string;
  42. /**
  43. * Gets the depth/stencil texture (if created by a createDepthStencilTexture() call)
  44. */
  45. get depthStencilTexture(): Nullable<InternalTexture>;
  46. /**
  47. * Indicates if the depth/stencil texture has a stencil aspect
  48. */
  49. get depthStencilTextureWithStencil(): boolean;
  50. /**
  51. * Defines if the render target wrapper is for a cube texture or if false a 2d texture
  52. */
  53. get isCube(): boolean;
  54. /**
  55. * Defines if the render target wrapper is for a single or multi target render wrapper
  56. */
  57. get isMulti(): boolean;
  58. /**
  59. * Defines if the render target wrapper is for a single or an array of textures
  60. */
  61. get is2DArray(): boolean;
  62. /**
  63. * Defines if the render target wrapper is for a 3D texture
  64. */
  65. get is3D(): boolean;
  66. /**
  67. * Gets the size of the render target wrapper (used for cubes, as width=height in this case)
  68. */
  69. get size(): number;
  70. /**
  71. * Gets the width of the render target wrapper
  72. */
  73. get width(): number;
  74. /**
  75. * Gets the height of the render target wrapper
  76. */
  77. get height(): number;
  78. /**
  79. * Gets the number of layers of the render target wrapper (only used if is2DArray is true and wrapper is not a multi render target)
  80. */
  81. get layers(): number;
  82. /**
  83. * Gets the depth of the render target wrapper (only used if is3D is true and wrapper is not a multi render target)
  84. */
  85. get depth(): number;
  86. /**
  87. * Gets the render texture. If this is a multi render target, gets the first texture
  88. */
  89. get texture(): Nullable<InternalTexture>;
  90. /**
  91. * 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)
  92. */
  93. get textures(): Nullable<InternalTexture[]>;
  94. /**
  95. * 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
  96. */
  97. get faceIndices(): Nullable<number[]>;
  98. /**
  99. * 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
  100. */
  101. get layerIndices(): Nullable<number[]>;
  102. /**
  103. * Gets the sample count of the render target
  104. */
  105. get samples(): number;
  106. /**
  107. * Sets the sample count of the render target
  108. * @param value sample count
  109. * @param initializeBuffers If set to true, the engine will make an initializing call to drawBuffers (only used when isMulti=true).
  110. * @param force true to force calling the update sample count engine function even if the current sample count is equal to value
  111. * @returns the sample count that has been set
  112. */
  113. setSamples(value: number, initializeBuffers?: boolean, force?: boolean): number;
  114. /**
  115. * Initializes the render target wrapper
  116. * @param isMulti true if the wrapper is a multi render target
  117. * @param isCube true if the wrapper should render to a cube texture
  118. * @param size size of the render target (width/height/layers)
  119. * @param engine engine used to create the render target
  120. * @param label defines the label to use for the wrapper (for debugging purpose only)
  121. */
  122. constructor(isMulti: boolean, isCube: boolean, size: TextureSize, engine: AbstractEngine, label?: string);
  123. /**
  124. * Sets the render target texture(s)
  125. * @param textures texture(s) to set
  126. */
  127. setTextures(textures: Nullable<InternalTexture> | Nullable<InternalTexture[]>): void;
  128. /**
  129. * Set a texture in the textures array
  130. * @param texture The texture to set
  131. * @param index The index in the textures array to set
  132. * @param disposePrevious If this function should dispose the previous texture
  133. */
  134. setTexture(texture: InternalTexture, index?: number, disposePrevious?: boolean): void;
  135. /**
  136. * Sets the layer and face indices of every render target texture bound to each color attachment
  137. * @param layers The layers of each texture to be set
  138. * @param faces The faces of each texture to be set
  139. */
  140. setLayerAndFaceIndices(layers: number[], faces: number[]): void;
  141. /**
  142. * Sets the layer and face indices of a texture in the textures array that should be bound to each color attachment
  143. * @param index The index of the texture in the textures array to modify
  144. * @param layer The layer of the texture to be set
  145. * @param face The face of the texture to be set
  146. */
  147. setLayerAndFaceIndex(index?: number, layer?: number, face?: number): void;
  148. /**
  149. * Creates the depth/stencil texture
  150. * @param comparisonFunction Comparison function to use for the texture
  151. * @param bilinearFiltering true if bilinear filtering should be used when sampling the texture
  152. * @param generateStencil true if the stencil aspect should also be created
  153. * @param samples sample count to use when creating the texture
  154. * @param format format of the depth texture
  155. * @param label defines the label to use for the texture (for debugging purpose only)
  156. * @returns the depth/stencil created texture
  157. */
  158. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number, format?: number, label?: string): InternalTexture;
  159. /**
  160. * @deprecated Use shareDepth instead
  161. * @param renderTarget Destination renderTarget
  162. */
  163. _shareDepth(renderTarget: RenderTargetWrapper): void;
  164. /**
  165. * Shares the depth buffer of this render target with another render target.
  166. * @param renderTarget Destination renderTarget
  167. */
  168. shareDepth(renderTarget: RenderTargetWrapper): void;
  169. /**
  170. * @internal
  171. */
  172. _swapAndDie(target: InternalTexture): void;
  173. protected _cloneRenderTargetWrapper(): Nullable<RenderTargetWrapper>;
  174. protected _swapRenderTargetWrapper(target: RenderTargetWrapper): void;
  175. /** @internal */
  176. _rebuild(): void;
  177. /**
  178. * Releases the internal render textures
  179. */
  180. releaseTextures(): void;
  181. /**
  182. * Disposes the whole render target wrapper
  183. * @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
  184. */
  185. dispose(disposeOnlyFramebuffers?: boolean): void;
  186. }