@babylonjs/core 8.48.0 → 8.48.2

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 (85) hide show
  1. package/Audio/analyser.js.map +1 -1
  2. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -1
  3. package/Buffers/buffer.align.js +3 -3
  4. package/Buffers/buffer.align.js.map +1 -1
  5. package/Buffers/bufferUtils.d.ts +7 -0
  6. package/Buffers/bufferUtils.js +31 -13
  7. package/Buffers/bufferUtils.js.map +1 -1
  8. package/Engines/Extensions/engine.dynamicBuffer.js +3 -3
  9. package/Engines/Extensions/engine.dynamicBuffer.js.map +1 -1
  10. package/Engines/Native/nativeDataStream.d.ts +1 -1
  11. package/Engines/Native/nativeDataStream.js.map +1 -1
  12. package/Engines/Native/nativeInterfaces.d.ts +4 -4
  13. package/Engines/Native/nativeInterfaces.js.map +1 -1
  14. package/Engines/WebGPU/Extensions/engine.rawTexture.d.ts +13 -1
  15. package/Engines/WebGPU/Extensions/engine.rawTexture.js +26 -8
  16. package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
  17. package/Engines/WebGPU/webgpuTextureManager.d.ts +2 -1
  18. package/Engines/WebGPU/webgpuTextureManager.js +19 -6
  19. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  20. package/Engines/abstractEngine.d.ts +4 -2
  21. package/Engines/abstractEngine.functions.d.ts +1 -1
  22. package/Engines/abstractEngine.functions.js +8 -8
  23. package/Engines/abstractEngine.functions.js.map +1 -1
  24. package/Engines/abstractEngine.js +6 -4
  25. package/Engines/abstractEngine.js.map +1 -1
  26. package/Engines/engine.d.ts +12 -0
  27. package/Engines/thinNativeEngine.js +1 -1
  28. package/Engines/thinNativeEngine.js.map +1 -1
  29. package/Engines/thinWebGPUEngine.js +3 -0
  30. package/Engines/thinWebGPUEngine.js.map +1 -1
  31. package/Engines/webgpuEngine.js +18 -18
  32. package/Engines/webgpuEngine.js.map +1 -1
  33. package/Lights/Clustered/clusteredLightContainer.js.map +1 -1
  34. package/Materials/Background/backgroundMaterial.d.ts +16 -8
  35. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +14 -1
  36. package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
  37. package/Materials/Node/Blocks/debugBlock.d.ts +2 -0
  38. package/Materials/Node/Blocks/debugBlock.js +6 -2
  39. package/Materials/Node/Blocks/debugBlock.js.map +1 -1
  40. package/Materials/Node/nodeMaterial.d.ts +16 -8
  41. package/Materials/Node/nodeMaterialBlock.js +2 -2
  42. package/Materials/Node/nodeMaterialBlock.js.map +1 -1
  43. package/Materials/PBR/openpbrMaterial.d.ts +16 -8
  44. package/Materials/PBR/pbrBaseMaterial.d.ts +16 -8
  45. package/Materials/Textures/Loaders/EXR/exrLoader.compression.rle.d.ts +1 -1
  46. package/Materials/Textures/Loaders/EXR/exrLoader.compression.rle.js.map +1 -1
  47. package/Materials/Textures/Loaders/EXR/exrLoader.core.d.ts +1 -1
  48. package/Materials/Textures/Loaders/EXR/exrLoader.core.js.map +1 -1
  49. package/Materials/Textures/internalTexture.d.ts +6 -0
  50. package/Materials/Textures/internalTexture.js +24 -2
  51. package/Materials/Textures/internalTexture.js.map +1 -1
  52. package/Materials/Textures/rawTexture.d.ts +8 -1
  53. package/Materials/Textures/rawTexture.js +12 -3
  54. package/Materials/Textures/rawTexture.js.map +1 -1
  55. package/Materials/Textures/rawTexture2DArray.d.ts +8 -1
  56. package/Materials/Textures/rawTexture2DArray.js +14 -3
  57. package/Materials/Textures/rawTexture2DArray.js.map +1 -1
  58. package/Materials/imageProcessing.d.ts +47 -8
  59. package/Materials/standardMaterial.d.ts +16 -8
  60. package/Meshes/Builders/shapeBuilder.d.ts +4 -0
  61. package/Meshes/Builders/shapeBuilder.js +12 -9
  62. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  63. package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +68 -4
  64. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +343 -26
  65. package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
  66. package/Misc/dds.js.map +1 -1
  67. package/Misc/environmentTextureTools.js +3 -1
  68. package/Misc/environmentTextureTools.js.map +1 -1
  69. package/Misc/fileTools.js +9 -1
  70. package/Misc/fileTools.js.map +1 -1
  71. package/Physics/v1/physicsImpostor.d.ts +2 -2
  72. package/Physics/v1/physicsImpostor.js.map +1 -1
  73. package/Shaders/ShadersInclude/gaussianSplatting.js +16 -3
  74. package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
  75. package/Shaders/gaussianSplatting.vertex.js +17 -4
  76. package/Shaders/gaussianSplatting.vertex.js.map +1 -1
  77. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +11 -1
  78. package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
  79. package/ShadersWGSL/gaussianSplatting.vertex.js +17 -4
  80. package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
  81. package/XR/native/nativeXRFrame.d.ts +1 -1
  82. package/XR/native/nativeXRFrame.js.map +1 -1
  83. package/package.json +1 -1
  84. package/types.d.ts +1 -1
  85. package/types.js.map +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"AAiaA,mFAAmF;AACnF,MAAM,CAAN,IAAkB,gBAGjB;AAHD,WAAkB,gBAAgB;IAC9B,uDAAQ,CAAA;IACR,qDAAO,CAAA;AACX,CAAC,EAHiB,gBAAgB,KAAhB,gBAAgB,QAGjC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage, IPath2D } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport type NativeFrameStats = {\r\n /** @internal */\r\n gpuTimeNs: number;\r\n};\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n setDeviceLostCallback(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(indexBuffer: NativeData, data: ArrayBuffer, dataByteOffset: number, dataByteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, dataBuffer: ArrayBuffer, dataByteOffset: number, dataByteLength: number, vertexByteOffset?: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n createProgramAsync(vertexShader: string, fragmentShader: string, onSuccess: () => void, onError: (error: Error) => void): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean, samples: number): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBuffer | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(\r\n texture: Nullable<NativeTexture>,\r\n width: number,\r\n height: number,\r\n generateStencilBuffer: boolean,\r\n generateDepthBuffer: boolean,\r\n samples: number\r\n ): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n\r\n populateFrameStats(stats: NativeFrameStats): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineInfo {\r\n version: string;\r\n nonFloatVertexBuffers: true;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (info: INativeEngineInfo): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_BC1: number;\r\n readonly TEXTURE_FORMAT_BC2: number;\r\n readonly TEXTURE_FORMAT_BC3: number;\r\n readonly TEXTURE_FORMAT_BC4: number;\r\n readonly TEXTURE_FORMAT_BC5: number;\r\n readonly TEXTURE_FORMAT_BC6H: number;\r\n readonly TEXTURE_FORMAT_BC7: number;\r\n readonly TEXTURE_FORMAT_ETC1: number;\r\n readonly TEXTURE_FORMAT_ETC2: number;\r\n readonly TEXTURE_FORMAT_ETC2A: number;\r\n readonly TEXTURE_FORMAT_ETC2A1: number;\r\n readonly TEXTURE_FORMAT_PTC12: number;\r\n readonly TEXTURE_FORMAT_PTC14: number;\r\n readonly TEXTURE_FORMAT_PTC12A: number;\r\n readonly TEXTURE_FORMAT_PTC14A: number;\r\n readonly TEXTURE_FORMAT_PTC22: number;\r\n readonly TEXTURE_FORMAT_PTC24: number;\r\n readonly TEXTURE_FORMAT_ATC: number;\r\n readonly TEXTURE_FORMAT_ATCE: number;\r\n readonly TEXTURE_FORMAT_ATCI: number;\r\n readonly TEXTURE_FORMAT_ASTC4x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x5: number;\r\n readonly TEXTURE_FORMAT_ASTC8x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x5: number;\r\n readonly TEXTURE_FORMAT_ASTC10x6: number;\r\n readonly TEXTURE_FORMAT_ASTC10x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x12: number;\r\n\r\n readonly TEXTURE_FORMAT_R1: number;\r\n readonly TEXTURE_FORMAT_A8: number;\r\n readonly TEXTURE_FORMAT_R8: number;\r\n readonly TEXTURE_FORMAT_R8I: number;\r\n readonly TEXTURE_FORMAT_R8U: number;\r\n readonly TEXTURE_FORMAT_R8S: number;\r\n readonly TEXTURE_FORMAT_R16: number;\r\n readonly TEXTURE_FORMAT_R16I: number;\r\n readonly TEXTURE_FORMAT_R16U: number;\r\n readonly TEXTURE_FORMAT_R16F: number;\r\n readonly TEXTURE_FORMAT_R16S: number;\r\n readonly TEXTURE_FORMAT_R32I: number;\r\n readonly TEXTURE_FORMAT_R32U: number;\r\n readonly TEXTURE_FORMAT_R32F: number;\r\n readonly TEXTURE_FORMAT_RG8: number;\r\n readonly TEXTURE_FORMAT_RG8I: number;\r\n readonly TEXTURE_FORMAT_RG8U: number;\r\n readonly TEXTURE_FORMAT_RG8S: number;\r\n readonly TEXTURE_FORMAT_RG16: number;\r\n readonly TEXTURE_FORMAT_RG16I: number;\r\n readonly TEXTURE_FORMAT_RG16U: number;\r\n readonly TEXTURE_FORMAT_RG16F: number;\r\n readonly TEXTURE_FORMAT_RG16S: number;\r\n readonly TEXTURE_FORMAT_RG32I: number;\r\n readonly TEXTURE_FORMAT_RG32U: number;\r\n readonly TEXTURE_FORMAT_RG32F: number;\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGB8I: number;\r\n readonly TEXTURE_FORMAT_RGB8U: number;\r\n readonly TEXTURE_FORMAT_RGB8S: number;\r\n readonly TEXTURE_FORMAT_RGB9E5F: number;\r\n readonly TEXTURE_FORMAT_BGRA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8I: number;\r\n readonly TEXTURE_FORMAT_RGBA8U: number;\r\n readonly TEXTURE_FORMAT_RGBA8S: number;\r\n readonly TEXTURE_FORMAT_RGBA16: number;\r\n readonly TEXTURE_FORMAT_RGBA16I: number;\r\n readonly TEXTURE_FORMAT_RGBA16U: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA16S: number;\r\n readonly TEXTURE_FORMAT_RGBA32I: number;\r\n readonly TEXTURE_FORMAT_RGBA32U: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n readonly TEXTURE_FORMAT_B5G6R5: number;\r\n readonly TEXTURE_FORMAT_R5G6B5: number;\r\n readonly TEXTURE_FORMAT_BGRA4: number;\r\n readonly TEXTURE_FORMAT_RGBA4: number;\r\n readonly TEXTURE_FORMAT_BGR5A1: number;\r\n readonly TEXTURE_FORMAT_RGB5A1: number;\r\n readonly TEXTURE_FORMAT_RGB10A2: number;\r\n readonly TEXTURE_FORMAT_RG11B10F: number;\r\n\r\n readonly TEXTURE_FORMAT_D16: number;\r\n readonly TEXTURE_FORMAT_D24: number;\r\n readonly TEXTURE_FORMAT_D24S8: number;\r\n readonly TEXTURE_FORMAT_D32: number;\r\n readonly TEXTURE_FORMAT_D16F: number;\r\n readonly TEXTURE_FORMAT_D24F: number;\r\n readonly TEXTURE_FORMAT_D32F: number;\r\n readonly TEXTURE_FORMAT_D0S8: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_UNSETTEXTURE: NativeData;\r\n readonly COMMAND_DISCARDALLTEXTURES: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAWINDEXEDINSTANCED: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_DRAWINSTANCED: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n readonly COMMAND_SETVIEWPORT: NativeData;\r\n readonly COMMAND_SETSCISSOR: NativeData;\r\n readonly COMMAND_COPYTEXTURE: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface INativePath2DConstructor {\r\n prototype: IPath2D;\r\n new (d?: string): IPath2D;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n// Note: These values need to match those in Babylon Native's NativeTracing plugin.\r\nexport const enum NativeTraceLevel {\r\n Mark = 1,\r\n Log = 2,\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n // NativeEngine plugin\r\n Engine: INativeEngineConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n\r\n // NativeCamera plugin\r\n Camera?: INativeCameraConstructor;\r\n\r\n // NativeCanvas plugin\r\n Canvas?: INativeCanvasConstructor;\r\n Image?: INativeImageConstructor;\r\n Path2D?: INativePath2DConstructor;\r\n\r\n // Native XMLHttpRequest polyfill\r\n XMLHttpRequest?: typeof XMLHttpRequest;\r\n\r\n // NativeInput plugin\r\n DeviceInputSystem?: IDeviceInputSystemConstructor;\r\n\r\n // NativeTracing plugin\r\n enablePerformanceLogging?(level?: NativeTraceLevel): void;\r\n disablePerformanceLogging?(): void;\r\n startPerformanceCounter?(counter: string): unknown;\r\n endPerformanceCounter?(counter: unknown): void;\r\n\r\n // GaussianSplatting\r\n sortSplats?(modelViewMatrix: Matrix, splatPositions: Float32Array, splatIndex: Float32Array, useRightHandedSystem: boolean): void;\r\n}\r\n"]}
1
+ {"version":3,"file":"nativeInterfaces.js","sourceRoot":"","sources":["../../../../../dev/core/src/Engines/Native/nativeInterfaces.ts"],"names":[],"mappings":"AAiaA,mFAAmF;AACnF,MAAM,CAAN,IAAkB,gBAGjB;AAHD,WAAkB,gBAAgB;IAC9B,uDAAQ,CAAA;IACR,qDAAO,CAAA;AACX,CAAC,EAHiB,gBAAgB,KAAhB,gBAAgB,QAGjC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { DeviceType } from \"../../DeviceInput/InputDevices/deviceEnums\";\r\nimport type { IDeviceInputSystem } from \"../../DeviceInput/inputInterfaces\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { ICanvas, IImage, IPath2D } from \"../ICanvas\";\r\nimport type { NativeData, NativeDataStream } from \"./nativeDataStream\";\r\nimport type { Matrix } from \"../../Maths/math.vector\";\r\n\r\nexport type NativeTexture = NativeData;\r\nexport type NativeFramebuffer = NativeData;\r\nexport type NativeVertexArrayObject = NativeData;\r\nexport type NativeProgram = NativeData;\r\nexport type NativeUniform = NativeData;\r\n\r\n/** @internal */\r\nexport type NativeFrameStats = {\r\n /** @internal */\r\n gpuTimeNs: number;\r\n};\r\n\r\n/** @internal */\r\nexport interface INativeEngine {\r\n dispose(): void;\r\n\r\n requestAnimationFrame(callback: () => void): void;\r\n setDeviceLostCallback(callback: () => void): void;\r\n\r\n createVertexArray(): NativeData;\r\n\r\n createIndexBuffer(dataBuffer: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, is32Bits: boolean, dynamic: boolean): NativeData;\r\n recordIndexBuffer(vertexArray: NativeData, indexBuffer: NativeData): void;\r\n updateDynamicIndexBuffer(indexBuffer: NativeData, data: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, startIndex: number): void;\r\n\r\n createVertexBuffer(dataBuffer: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, dynamic: boolean): NativeData;\r\n recordVertexBuffer(\r\n vertexArray: NativeData,\r\n vertexBuffer: NativeData,\r\n location: number,\r\n byteOffset: number,\r\n byteStride: number,\r\n numElements: number,\r\n type: number,\r\n normalized: boolean,\r\n instanceDivisor: number\r\n ): void;\r\n updateDynamicVertexBuffer(vertexBuffer: NativeData, dataBuffer: ArrayBufferLike, dataByteOffset: number, dataByteLength: number, vertexByteOffset?: number): void;\r\n\r\n createProgram(vertexShader: string, fragmentShader: string): NativeProgram;\r\n createProgramAsync(vertexShader: string, fragmentShader: string, onSuccess: () => void, onError: (error: Error) => void): NativeProgram;\r\n getUniforms(shaderProgram: NativeProgram, uniformsNames: string[]): WebGLUniformLocation[];\r\n getAttributes(shaderProgram: NativeProgram, attributeNames: string[]): number[];\r\n\r\n createTexture(): NativeTexture;\r\n initializeTexture(texture: NativeTexture, width: number, height: number, hasMips: boolean, format: number, renderTarget: boolean, srgb: boolean, samples: number): void;\r\n loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;\r\n loadRawTexture2DArray(\r\n texture: NativeTexture,\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean\r\n ): void;\r\n loadCubeTexture(texture: NativeTexture, data: Array<ArrayBufferView>, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;\r\n getTextureWidth(texture: NativeTexture): number;\r\n getTextureHeight(texture: NativeTexture): number;\r\n deleteTexture(texture: NativeTexture): void;\r\n readTexture(\r\n texture: NativeTexture,\r\n mipLevel: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n buffer: Nullable<ArrayBuffer>,\r\n bufferOffset: number,\r\n bufferLength: number\r\n ): Promise<ArrayBuffer>;\r\n\r\n createImageBitmap(data: ArrayBuffer | IImage): ImageBitmap;\r\n resizeImageBitmap(image: ImageBitmap, bufferWidth: number, bufferHeight: number): Uint8Array;\r\n\r\n createFrameBuffer(\r\n texture: Nullable<NativeTexture>,\r\n width: number,\r\n height: number,\r\n generateStencilBuffer: boolean,\r\n generateDepthBuffer: boolean,\r\n samples: number\r\n ): NativeFramebuffer;\r\n\r\n getRenderWidth(): number;\r\n getRenderHeight(): number;\r\n\r\n setHardwareScalingLevel(level: number): void;\r\n\r\n setViewPort(x: number, y: number, width: number, height: number): void;\r\n\r\n setCommandDataStream(dataStream: NativeDataStream): void;\r\n submitCommands(): void;\r\n\r\n populateFrameStats(stats: NativeFrameStats): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineInfo {\r\n version: string;\r\n nonFloatVertexBuffers: true;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeEngineConstructor {\r\n prototype: INativeEngine;\r\n new (info: INativeEngineInfo): INativeEngine;\r\n\r\n readonly PROTOCOL_VERSION: number;\r\n\r\n readonly CAPS_LIMITS_MAX_TEXTURE_SIZE: number;\r\n readonly CAPS_LIMITS_MAX_TEXTURE_LAYERS: number;\r\n\r\n readonly TEXTURE_NEAREST_NEAREST: number;\r\n readonly TEXTURE_LINEAR_LINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;\r\n readonly TEXTURE_NEAREST_LINEAR: number;\r\n readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;\r\n readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;\r\n readonly TEXTURE_LINEAR_NEAREST: number;\r\n\r\n readonly DEPTH_TEST_LESS: number;\r\n readonly DEPTH_TEST_LEQUAL: number;\r\n readonly DEPTH_TEST_EQUAL: number;\r\n readonly DEPTH_TEST_GEQUAL: number;\r\n readonly DEPTH_TEST_GREATER: number;\r\n readonly DEPTH_TEST_NOTEQUAL: number;\r\n readonly DEPTH_TEST_NEVER: number;\r\n readonly DEPTH_TEST_ALWAYS: number;\r\n\r\n readonly ADDRESS_MODE_WRAP: number;\r\n readonly ADDRESS_MODE_MIRROR: number;\r\n readonly ADDRESS_MODE_CLAMP: number;\r\n readonly ADDRESS_MODE_BORDER: number;\r\n readonly ADDRESS_MODE_MIRROR_ONCE: number;\r\n\r\n readonly TEXTURE_FORMAT_BC1: number;\r\n readonly TEXTURE_FORMAT_BC2: number;\r\n readonly TEXTURE_FORMAT_BC3: number;\r\n readonly TEXTURE_FORMAT_BC4: number;\r\n readonly TEXTURE_FORMAT_BC5: number;\r\n readonly TEXTURE_FORMAT_BC6H: number;\r\n readonly TEXTURE_FORMAT_BC7: number;\r\n readonly TEXTURE_FORMAT_ETC1: number;\r\n readonly TEXTURE_FORMAT_ETC2: number;\r\n readonly TEXTURE_FORMAT_ETC2A: number;\r\n readonly TEXTURE_FORMAT_ETC2A1: number;\r\n readonly TEXTURE_FORMAT_PTC12: number;\r\n readonly TEXTURE_FORMAT_PTC14: number;\r\n readonly TEXTURE_FORMAT_PTC12A: number;\r\n readonly TEXTURE_FORMAT_PTC14A: number;\r\n readonly TEXTURE_FORMAT_PTC22: number;\r\n readonly TEXTURE_FORMAT_PTC24: number;\r\n readonly TEXTURE_FORMAT_ATC: number;\r\n readonly TEXTURE_FORMAT_ATCE: number;\r\n readonly TEXTURE_FORMAT_ATCI: number;\r\n readonly TEXTURE_FORMAT_ASTC4x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x4: number;\r\n readonly TEXTURE_FORMAT_ASTC5x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x5: number;\r\n readonly TEXTURE_FORMAT_ASTC6x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x5: number;\r\n readonly TEXTURE_FORMAT_ASTC8x6: number;\r\n readonly TEXTURE_FORMAT_ASTC8x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x5: number;\r\n readonly TEXTURE_FORMAT_ASTC10x6: number;\r\n readonly TEXTURE_FORMAT_ASTC10x8: number;\r\n readonly TEXTURE_FORMAT_ASTC10x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x10: number;\r\n readonly TEXTURE_FORMAT_ASTC12x12: number;\r\n\r\n readonly TEXTURE_FORMAT_R1: number;\r\n readonly TEXTURE_FORMAT_A8: number;\r\n readonly TEXTURE_FORMAT_R8: number;\r\n readonly TEXTURE_FORMAT_R8I: number;\r\n readonly TEXTURE_FORMAT_R8U: number;\r\n readonly TEXTURE_FORMAT_R8S: number;\r\n readonly TEXTURE_FORMAT_R16: number;\r\n readonly TEXTURE_FORMAT_R16I: number;\r\n readonly TEXTURE_FORMAT_R16U: number;\r\n readonly TEXTURE_FORMAT_R16F: number;\r\n readonly TEXTURE_FORMAT_R16S: number;\r\n readonly TEXTURE_FORMAT_R32I: number;\r\n readonly TEXTURE_FORMAT_R32U: number;\r\n readonly TEXTURE_FORMAT_R32F: number;\r\n readonly TEXTURE_FORMAT_RG8: number;\r\n readonly TEXTURE_FORMAT_RG8I: number;\r\n readonly TEXTURE_FORMAT_RG8U: number;\r\n readonly TEXTURE_FORMAT_RG8S: number;\r\n readonly TEXTURE_FORMAT_RG16: number;\r\n readonly TEXTURE_FORMAT_RG16I: number;\r\n readonly TEXTURE_FORMAT_RG16U: number;\r\n readonly TEXTURE_FORMAT_RG16F: number;\r\n readonly TEXTURE_FORMAT_RG16S: number;\r\n readonly TEXTURE_FORMAT_RG32I: number;\r\n readonly TEXTURE_FORMAT_RG32U: number;\r\n readonly TEXTURE_FORMAT_RG32F: number;\r\n readonly TEXTURE_FORMAT_RGB8: number;\r\n readonly TEXTURE_FORMAT_RGB8I: number;\r\n readonly TEXTURE_FORMAT_RGB8U: number;\r\n readonly TEXTURE_FORMAT_RGB8S: number;\r\n readonly TEXTURE_FORMAT_RGB9E5F: number;\r\n readonly TEXTURE_FORMAT_BGRA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8: number;\r\n readonly TEXTURE_FORMAT_RGBA8I: number;\r\n readonly TEXTURE_FORMAT_RGBA8U: number;\r\n readonly TEXTURE_FORMAT_RGBA8S: number;\r\n readonly TEXTURE_FORMAT_RGBA16: number;\r\n readonly TEXTURE_FORMAT_RGBA16I: number;\r\n readonly TEXTURE_FORMAT_RGBA16U: number;\r\n readonly TEXTURE_FORMAT_RGBA16F: number;\r\n readonly TEXTURE_FORMAT_RGBA16S: number;\r\n readonly TEXTURE_FORMAT_RGBA32I: number;\r\n readonly TEXTURE_FORMAT_RGBA32U: number;\r\n readonly TEXTURE_FORMAT_RGBA32F: number;\r\n readonly TEXTURE_FORMAT_B5G6R5: number;\r\n readonly TEXTURE_FORMAT_R5G6B5: number;\r\n readonly TEXTURE_FORMAT_BGRA4: number;\r\n readonly TEXTURE_FORMAT_RGBA4: number;\r\n readonly TEXTURE_FORMAT_BGR5A1: number;\r\n readonly TEXTURE_FORMAT_RGB5A1: number;\r\n readonly TEXTURE_FORMAT_RGB10A2: number;\r\n readonly TEXTURE_FORMAT_RG11B10F: number;\r\n\r\n readonly TEXTURE_FORMAT_D16: number;\r\n readonly TEXTURE_FORMAT_D24: number;\r\n readonly TEXTURE_FORMAT_D24S8: number;\r\n readonly TEXTURE_FORMAT_D32: number;\r\n readonly TEXTURE_FORMAT_D16F: number;\r\n readonly TEXTURE_FORMAT_D24F: number;\r\n readonly TEXTURE_FORMAT_D32F: number;\r\n readonly TEXTURE_FORMAT_D0S8: number;\r\n\r\n readonly ATTRIB_TYPE_INT8: number;\r\n readonly ATTRIB_TYPE_UINT8: number;\r\n readonly ATTRIB_TYPE_INT16: number;\r\n readonly ATTRIB_TYPE_UINT16: number;\r\n readonly ATTRIB_TYPE_FLOAT: number;\r\n\r\n readonly ALPHA_DISABLE: number;\r\n readonly ALPHA_ADD: number;\r\n readonly ALPHA_COMBINE: number;\r\n readonly ALPHA_SUBTRACT: number;\r\n readonly ALPHA_MULTIPLY: number;\r\n readonly ALPHA_MAXIMIZED: number;\r\n readonly ALPHA_ONEONE: number;\r\n readonly ALPHA_PREMULTIPLIED: number;\r\n readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;\r\n readonly ALPHA_INTERPOLATE: number;\r\n readonly ALPHA_SCREENMODE: number;\r\n\r\n readonly STENCIL_TEST_LESS: number;\r\n readonly STENCIL_TEST_LEQUAL: number;\r\n readonly STENCIL_TEST_EQUAL: number;\r\n readonly STENCIL_TEST_GEQUAL: number;\r\n readonly STENCIL_TEST_GREATER: number;\r\n readonly STENCIL_TEST_NOTEQUAL: number;\r\n readonly STENCIL_TEST_NEVER: number;\r\n readonly STENCIL_TEST_ALWAYS: number;\r\n\r\n readonly STENCIL_OP_FAIL_S_ZERO: number;\r\n readonly STENCIL_OP_FAIL_S_KEEP: number;\r\n readonly STENCIL_OP_FAIL_S_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_S_INCR: number;\r\n readonly STENCIL_OP_FAIL_S_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_DECR: number;\r\n readonly STENCIL_OP_FAIL_S_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_S_INVERT: number;\r\n\r\n readonly STENCIL_OP_FAIL_Z_ZERO: number;\r\n readonly STENCIL_OP_FAIL_Z_KEEP: number;\r\n readonly STENCIL_OP_FAIL_Z_REPLACE: number;\r\n readonly STENCIL_OP_FAIL_Z_INCR: number;\r\n readonly STENCIL_OP_FAIL_Z_INCRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_DECR: number;\r\n readonly STENCIL_OP_FAIL_Z_DECRSAT: number;\r\n readonly STENCIL_OP_FAIL_Z_INVERT: number;\r\n\r\n readonly STENCIL_OP_PASS_Z_ZERO: number;\r\n readonly STENCIL_OP_PASS_Z_KEEP: number;\r\n readonly STENCIL_OP_PASS_Z_REPLACE: number;\r\n readonly STENCIL_OP_PASS_Z_INCR: number;\r\n readonly STENCIL_OP_PASS_Z_INCRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_DECR: number;\r\n readonly STENCIL_OP_PASS_Z_DECRSAT: number;\r\n readonly STENCIL_OP_PASS_Z_INVERT: number;\r\n\r\n readonly COMMAND_DELETEVERTEXARRAY: NativeData;\r\n readonly COMMAND_DELETEINDEXBUFFER: NativeData;\r\n readonly COMMAND_DELETEVERTEXBUFFER: NativeData;\r\n readonly COMMAND_SETPROGRAM: NativeData;\r\n readonly COMMAND_SETMATRIX: NativeData;\r\n readonly COMMAND_SETMATRIX3X3: NativeData;\r\n readonly COMMAND_SETMATRIX2X2: NativeData;\r\n readonly COMMAND_SETMATRICES: NativeData;\r\n readonly COMMAND_SETINT: NativeData;\r\n readonly COMMAND_SETINTARRAY: NativeData;\r\n readonly COMMAND_SETINTARRAY2: NativeData;\r\n readonly COMMAND_SETINTARRAY3: NativeData;\r\n readonly COMMAND_SETINTARRAY4: NativeData;\r\n readonly COMMAND_SETFLOATARRAY: NativeData;\r\n readonly COMMAND_SETFLOATARRAY2: NativeData;\r\n readonly COMMAND_SETFLOATARRAY3: NativeData;\r\n readonly COMMAND_SETFLOATARRAY4: NativeData;\r\n readonly COMMAND_SETTEXTURESAMPLING: NativeData;\r\n readonly COMMAND_SETTEXTUREWRAPMODE: NativeData;\r\n readonly COMMAND_SETTEXTUREANISOTROPICLEVEL: NativeData;\r\n readonly COMMAND_SETTEXTURE: NativeData;\r\n readonly COMMAND_UNSETTEXTURE: NativeData;\r\n readonly COMMAND_DISCARDALLTEXTURES: NativeData;\r\n readonly COMMAND_BINDVERTEXARRAY: NativeData;\r\n readonly COMMAND_SETSTATE: NativeData;\r\n readonly COMMAND_DELETEPROGRAM: NativeData;\r\n readonly COMMAND_SETZOFFSET: NativeData;\r\n readonly COMMAND_SETZOFFSETUNITS: NativeData;\r\n readonly COMMAND_SETDEPTHTEST: NativeData;\r\n readonly COMMAND_SETDEPTHWRITE: NativeData;\r\n readonly COMMAND_SETCOLORWRITE: NativeData;\r\n readonly COMMAND_SETBLENDMODE: NativeData;\r\n readonly COMMAND_SETFLOAT: NativeData;\r\n readonly COMMAND_SETFLOAT2: NativeData;\r\n readonly COMMAND_SETFLOAT3: NativeData;\r\n readonly COMMAND_SETFLOAT4: NativeData;\r\n readonly COMMAND_BINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_UNBINDFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DELETEFRAMEBUFFER: NativeData;\r\n readonly COMMAND_DRAWINDEXED: NativeData;\r\n readonly COMMAND_DRAWINDEXEDINSTANCED: NativeData;\r\n readonly COMMAND_DRAW: NativeData;\r\n readonly COMMAND_DRAWINSTANCED: NativeData;\r\n readonly COMMAND_CLEAR: NativeData;\r\n readonly COMMAND_SETSTENCIL: NativeData;\r\n readonly COMMAND_SETVIEWPORT: NativeData;\r\n readonly COMMAND_SETSCISSOR: NativeData;\r\n readonly COMMAND_COPYTEXTURE: NativeData;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeCamera {\r\n createVideo(constraints: MediaTrackConstraints): any;\r\n updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCameraConstructor {\r\n prototype: INativeCamera;\r\n new (): INativeCamera;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeCanvasConstructor {\r\n prototype: ICanvas;\r\n new (): ICanvas;\r\n\r\n loadTTFAsync(fontName: string, buffer: ArrayBuffer): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeImageConstructor {\r\n prototype: IImage;\r\n new (): IImage;\r\n}\r\n\r\n/** @internal */\r\ninterface INativePath2DConstructor {\r\n prototype: IPath2D;\r\n new (d?: string): IPath2D;\r\n}\r\n\r\n/** @internal */\r\ninterface IDeviceInputSystemConstructor {\r\n prototype: IDeviceInputSystem;\r\n new (\r\n onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void,\r\n onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, currentState: number) => void\r\n ): IDeviceInputSystem;\r\n}\r\n\r\n/** @internal */\r\nexport interface INativeDataStream {\r\n writeBuffer(buffer: ArrayBuffer, length: number): void;\r\n}\r\n\r\n/** @internal */\r\ninterface INativeDataStreamConstructor {\r\n prototype: INativeDataStream;\r\n new (requestFlushCallback: () => void): INativeDataStream;\r\n\r\n readonly VALIDATION_ENABLED: boolean;\r\n readonly VALIDATION_UINT_32: number;\r\n readonly VALIDATION_INT_32: number;\r\n readonly VALIDATION_FLOAT_32: number;\r\n readonly VALIDATION_UINT_32_ARRAY: number;\r\n readonly VALIDATION_INT_32_ARRAY: number;\r\n readonly VALIDATION_FLOAT_32_ARRAY: number;\r\n readonly VALIDATION_NATIVE_DATA: number;\r\n readonly VALIDATION_BOOLEAN: number;\r\n}\r\n\r\n// Note: These values need to match those in Babylon Native's NativeTracing plugin.\r\nexport const enum NativeTraceLevel {\r\n Mark = 1,\r\n Log = 2,\r\n}\r\n\r\n/** @internal */\r\nexport interface INative {\r\n // NativeEngine plugin\r\n Engine: INativeEngineConstructor;\r\n NativeDataStream: INativeDataStreamConstructor;\r\n\r\n // NativeCamera plugin\r\n Camera?: INativeCameraConstructor;\r\n\r\n // NativeCanvas plugin\r\n Canvas?: INativeCanvasConstructor;\r\n Image?: INativeImageConstructor;\r\n Path2D?: INativePath2DConstructor;\r\n\r\n // Native XMLHttpRequest polyfill\r\n XMLHttpRequest?: typeof XMLHttpRequest;\r\n\r\n // NativeInput plugin\r\n DeviceInputSystem?: IDeviceInputSystemConstructor;\r\n\r\n // NativeTracing plugin\r\n enablePerformanceLogging?(level?: NativeTraceLevel): void;\r\n disablePerformanceLogging?(): void;\r\n startPerformanceCounter?(counter: string): unknown;\r\n endPerformanceCounter?(counter: unknown): void;\r\n\r\n // GaussianSplatting\r\n sortSplats?(modelViewMatrix: Matrix, splatPositions: Float32Array, splatIndex: Float32Array, useRightHandedSystem: boolean): void;\r\n}\r\n"]}
@@ -20,8 +20,9 @@ declare module "../../abstractEngine.js" {
20
20
  * @param compression defines the compression used (null by default)
21
21
  * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)
22
22
  * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).
23
+ * @param mipLevel defines which mipLevel of the texture is going to be updated
23
24
  */
24
- updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number, useSRGBBuffer: boolean): void;
25
+ updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number, useSRGBBuffer: boolean, mipLevel?: number): void;
25
26
  /**
26
27
  * Creates a new raw cube texture
27
28
  * @param data defines the array of data to use to create each face
@@ -133,5 +134,16 @@ declare module "../../abstractEngine.js" {
133
134
  * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
134
135
  */
135
136
  updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
137
+ /**
138
+ * Update a raw 2D array texture
139
+ * @param texture defines the texture to update
140
+ * @param data defines the data to store
141
+ * @param format defines the data format
142
+ * @param invertY defines if data must be stored with Y axis inverted
143
+ * @param compression defines the used compression (can be null)
144
+ * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)
145
+ * @param mipLevel defines which mipLevel of the texture is going to be updated
146
+ */
147
+ updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number, mipLevel?: number): void;
136
148
  }
137
149
  }
@@ -2,7 +2,7 @@ import { InternalTexture } from "../../../Materials/Textures/internalTexture.js"
2
2
 
3
3
  import { Logger } from "../../../Misc/logger.js";
4
4
  import { ThinWebGPUEngine } from "../../thinWebGPUEngine.js";
5
- ThinWebGPUEngine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression = null, type = 0, creationFlags = 0, useSRGBBuffer = false) {
5
+ ThinWebGPUEngine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression = null, type = 0, creationFlags = 0, useSRGBBuffer = false, mipLevelCount) {
6
6
  const texture = new InternalTexture(this, 3 /* InternalTextureSource.Raw */);
7
7
  texture.baseWidth = width;
8
8
  texture.baseHeight = height;
@@ -19,12 +19,13 @@ ThinWebGPUEngine.prototype.createRawTexture = function (data, width, height, for
19
19
  if (!this._doNotHandleContextLost) {
20
20
  texture._bufferView = data;
21
21
  }
22
+ this._textureHelper.updateMipLevelCountForInternalTexture(texture, mipLevelCount);
22
23
  this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, undefined, creationFlags);
23
24
  this.updateRawTexture(texture, data, format, invertY, compression, type, useSRGBBuffer);
24
25
  this._internalTexturesCache.push(texture);
25
26
  return texture;
26
27
  };
27
- ThinWebGPUEngine.prototype.updateRawTexture = function (texture, bufferView, format, invertY, compression = null, type = 0, useSRGBBuffer = false) {
28
+ ThinWebGPUEngine.prototype.updateRawTexture = function (texture, bufferView, format, invertY, compression = null, type = 0, useSRGBBuffer = false, mipLevel) {
28
29
  if (!texture) {
29
30
  return;
30
31
  }
@@ -33,6 +34,12 @@ ThinWebGPUEngine.prototype.updateRawTexture = function (texture, bufferView, for
33
34
  texture.invertY = invertY;
34
35
  texture._compression = compression;
35
36
  texture._useSRGBBuffer = useSRGBBuffer;
37
+ if (mipLevel !== undefined && bufferView) {
38
+ if (!texture._bufferViewArray) {
39
+ texture._bufferViewArray = new Array(texture.mipLevelCount);
40
+ }
41
+ texture._bufferViewArray[mipLevel] = bufferView;
42
+ }
36
43
  }
37
44
  if (bufferView) {
38
45
  const gpuTextureWrapper = texture._hardwareTexture;
@@ -41,8 +48,10 @@ ThinWebGPUEngine.prototype.updateRawTexture = function (texture, bufferView, for
41
48
  bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, type);
42
49
  }
43
50
  const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);
44
- this._textureHelper.updateTexture(data, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);
45
- if (texture.generateMipMaps) {
51
+ const mipWidth = Math.max(1, texture.width >> (mipLevel ?? 0));
52
+ const mipHeight = Math.max(1, texture.height >> (mipLevel ?? 0));
53
+ this._textureHelper.updateTexture(data, texture, mipWidth, mipHeight, texture.depth, gpuTextureWrapper.format, 0, mipLevel ?? 0, invertY, false, 0, 0);
54
+ if (texture.generateMipMaps && !mipLevel) {
46
55
  this._generateMipmaps(texture, this._uploadEncoder);
47
56
  }
48
57
  }
@@ -213,7 +222,7 @@ ThinWebGPUEngine.prototype.updateRawTexture3D = function (texture, bufferView, f
213
222
  }
214
223
  texture.isReady = true;
215
224
  };
216
- ThinWebGPUEngine.prototype.createRawTexture2DArray = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression = null, textureType = 0, creationFlags = 0) {
225
+ ThinWebGPUEngine.prototype.createRawTexture2DArray = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression = null, textureType = 0, creationFlags = 0, mipLevelCount) {
217
226
  const source = 11 /* InternalTextureSource.Raw2DArray */;
218
227
  const texture = new InternalTexture(this, source);
219
228
  texture.baseWidth = width;
@@ -231,17 +240,24 @@ ThinWebGPUEngine.prototype.createRawTexture2DArray = function (data, width, heig
231
240
  if (!this._doNotHandleContextLost) {
232
241
  texture._bufferView = data;
233
242
  }
243
+ this._textureHelper.updateMipLevelCountForInternalTexture(texture, mipLevelCount);
234
244
  this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, depth, creationFlags);
235
245
  this.updateRawTexture2DArray(texture, data, format, invertY, compression, textureType);
236
246
  this._internalTexturesCache.push(texture);
237
247
  return texture;
238
248
  };
239
- ThinWebGPUEngine.prototype.updateRawTexture2DArray = function (texture, bufferView, format, invertY, compression = null, textureType = 0) {
249
+ ThinWebGPUEngine.prototype.updateRawTexture2DArray = function (texture, bufferView, format, invertY, compression = null, textureType = 0, mipLevel) {
240
250
  if (!this._doNotHandleContextLost) {
241
251
  texture._bufferView = bufferView;
242
252
  texture.format = format;
243
253
  texture.invertY = invertY;
244
254
  texture._compression = compression;
255
+ if (mipLevel !== undefined && bufferView) {
256
+ if (!texture._bufferViewArray) {
257
+ texture._bufferViewArray = new Array(texture.mipLevelCount);
258
+ }
259
+ texture._bufferViewArray[mipLevel] = bufferView;
260
+ }
245
261
  }
246
262
  if (bufferView) {
247
263
  const gpuTextureWrapper = texture._hardwareTexture;
@@ -250,8 +266,10 @@ ThinWebGPUEngine.prototype.updateRawTexture2DArray = function (texture, bufferVi
250
266
  bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, textureType);
251
267
  }
252
268
  const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);
253
- this._textureHelper.updateTexture(data, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);
254
- if (texture.generateMipMaps) {
269
+ const mipWidth = Math.max(1, texture.width >> (mipLevel ?? 0));
270
+ const mipHeight = Math.max(1, texture.height >> (mipLevel ?? 0));
271
+ this._textureHelper.updateTexture(data, texture, mipWidth, mipHeight, texture.depth, gpuTextureWrapper.format, 0, mipLevel ?? 0, invertY, false, 0, 0);
272
+ if (texture.generateMipMaps && !mipLevel) {
255
273
  this._generateMipmaps(texture, this._uploadEncoder);
256
274
  }
257
275
  }
@@ -1 +1 @@
1
- {"version":3,"file":"engine.rawTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.rawTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAyB,MAAM,6CAA6C,CAAC;AAGrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,M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ture\";\r\nimport type { IWebRequest } from \"../../../Misc/interfaces/iWebRequest\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\n\r\nimport type { Scene } from \"../../../scene\";\r\nimport { ThinWebGPUEngine } from \"core/Engines/thinWebGPUEngine\";\r\n\r\ndeclare module \"../../abstractEngine\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface AbstractEngine {\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n */\r\n updateRawTexture(\r\n texture: Nullable<InternalTexture>,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n type: number,\r\n useSRGBBuffer: boolean\r\n ): void;\r\n\r\n /**\r\n * Creates a new raw cube texture\r\n * @param data defines the array of data to use to create each face\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compression used (null by default)\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTexture(\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param level defines which level of the texture to update\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[] | Promise<ArrayBufferView[]>>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[] | Promise<ArrayBufferView[]>>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>,\r\n samplingMode: number,\r\n invertY: boolean\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture2DArray(\r\n texture: InternalTexture,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n textureType: number\r\n ): void;\r\n }\r\n}\r\n\r\nThinWebGPUEngine.prototype.createRawTexture = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false\r\n): InternalTexture {\r\n const texture = new InternalTexture(this, InternalTextureSource.Raw);\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.format = format;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture.type = type;\r\n texture._creationFlags = creationFlags;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, undefined, creationFlags);\r\n\r\n this.updateRawTexture(texture, data, format, invertY, compression, type, useSRGBBuffer);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawTexture = function (\r\n texture: Nullable<InternalTexture>,\r\n bufferView: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n useSRGBBuffer: boolean = false\r\n): void {\r\n if (!texture) {\r\n return;\r\n }\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = bufferView;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n }\r\n\r\n if (bufferView) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (needConversion) {\r\n bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, type);\r\n }\r\n\r\n const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);\r\n\r\n this._textureHelper.updateTexture(data, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);\r\n if (texture.generateMipMaps) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawCubeTexture = function (\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null\r\n): InternalTexture {\r\n const texture = new InternalTexture(this, InternalTextureSource.CubeRaw);\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatRender) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to float textures is not supported. Mipmap generation forced to false.\");\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.colorBufferFloat) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to half float textures is not supported. Mipmap generation forced to false.\");\r\n }\r\n\r\n texture.isCube = true;\r\n texture._originalFormat = format;\r\n texture.format = format === Constants.TEXTUREFORMAT_RGB ? Constants.TEXTUREFORMAT_RGBA : format;\r\n texture.type = type;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.width = size;\r\n texture.height = size;\r\n texture.samplingMode = samplingMode;\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferViewArray = data;\r\n }\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n\r\n if (format === Constants.TEXTUREFORMAT_RGB) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n gpuTextureWrapper._originalFormatIsRGB = true;\r\n }\r\n\r\n if (data) {\r\n this.updateRawCubeTexture(texture, data, format, type, invertY, compression);\r\n }\r\n\r\n texture.isReady = true;\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawCubeTexture = function (\r\n texture: InternalTexture,\r\n bufferView: ArrayBufferView[],\r\n _format: number,\r\n type: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null\r\n): void {\r\n texture._bufferViewArray = bufferView;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = gpuTextureWrapper._originalFormatIsRGB;\r\n\r\n const faces = [0, 2, 4, 1, 3, 5];\r\n\r\n const data = [];\r\n for (let i = 0; i < bufferView.length; ++i) {\r\n let faceData = bufferView[faces[i]];\r\n if (needConversion) {\r\n faceData = ConvertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);\r\n }\r\n data.push(new Uint8Array(faceData.buffer, faceData.byteOffset, faceData.byteLength));\r\n }\r\n\r\n this._textureHelper.updateCubeTextures(data, gpuTextureWrapper.underlyingResource!, texture.width, texture.height, gpuTextureWrapper.format, invertY, false, 0, 0);\r\n if (texture.generateMipMaps) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawCubeTextureFromUrl = function (\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[] | Promise<ArrayBufferView[]>>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n invertY: boolean = false\r\n): InternalTexture {\r\n const texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode, null);\r\n scene?.addPendingData(texture);\r\n texture.url = url;\r\n texture.isReady = false;\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n const onerror = (request?: IWebRequest, exception?: any) => {\r\n scene?.removePendingData(texture);\r\n if (onError && request) {\r\n onError(request.status + \" \" + request.statusText, exception);\r\n }\r\n };\r\n\r\n const internalCallbackAsync = async (data: any) => {\r\n const faceDataArraysResult = callback(data);\r\n if (!faceDataArraysResult) {\r\n return;\r\n }\r\n\r\n const faceDataArrays: any = faceDataArraysResult instanceof Promise ? await faceDataArraysResult : faceDataArraysResult;\r\n const width = texture.width;\r\n\r\n if (mipmapGenerator) {\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n const mipData = mipmapGenerator(faceDataArrays);\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const faces = [0, 1, 2, 3, 4, 5];\r\n for (let level = 0; level < mipData.length; level++) {\r\n const mipSize = width >> level;\r\n const allFaces = [];\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n let mipFaceData = mipData[level][faces[faceIndex]];\r\n if (needConversion) {\r\n mipFaceData = ConvertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);\r\n }\r\n allFaces.push(new Uint8Array(mipFaceData.buffer, mipFaceData.byteOffset, mipFaceData.byteLength));\r\n }\r\n this._textureHelper.updateCubeTextures(allFaces, gpuTextureWrapper.underlyingResource!, mipSize, mipSize, gpuTextureWrapper.format, invertY, false, 0, 0);\r\n }\r\n } else {\r\n this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);\r\n }\r\n\r\n texture.isReady = true;\r\n scene?.removePendingData(texture);\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n this._loadFile(\r\n url,\r\n (data) => {\r\n // eslint-disable-next-line github/no-then\r\n internalCallbackAsync(data).catch((err) => {\r\n onerror(undefined, err);\r\n });\r\n },\r\n undefined,\r\n scene?.offlineProvider,\r\n true,\r\n onerror\r\n );\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawTexture3D = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0\r\n): InternalTexture {\r\n const source = InternalTextureSource.Raw3D;\r\n const texture = new InternalTexture(this, source);\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.baseDepth = depth;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.depth = depth;\r\n texture.format = format;\r\n texture.type = textureType;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.is3D = true;\r\n texture._creationFlags = creationFlags;\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, undefined, creationFlags);\r\n\r\n this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawTexture3D = function (\r\n texture: InternalTexture,\r\n bufferView: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n): void {\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = bufferView;\r\n texture.format = format;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n }\r\n\r\n if (bufferView) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (needConversion) {\r\n bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, textureType);\r\n }\r\n\r\n const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);\r\n\r\n this._textureHelper.updateTexture(data, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);\r\n if (texture.generateMipMaps) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawTexture2DArray = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0\r\n): InternalTexture {\r\n const source = InternalTextureSource.Raw2DArray;\r\n const texture = new InternalTexture(this, source);\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.baseDepth = depth;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.depth = depth;\r\n texture.format = format;\r\n texture.type = textureType;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.is2DArray = true;\r\n texture._creationFlags = creationFlags;\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, depth, creationFlags);\r\n\r\n this.updateRawTexture2DArray(texture, data, format, invertY, compression, textureType);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawTexture2DArray = function (\r\n texture: InternalTexture,\r\n bufferView: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n): void {\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = bufferView;\r\n texture.format = format;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n }\r\n\r\n if (bufferView) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (needConversion) {\r\n bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, textureType);\r\n }\r\n\r\n const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);\r\n\r\n this._textureHelper.updateTexture(data, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);\r\n if (texture.generateMipMaps) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction ConvertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView {\r\n // Create new RGBA data container.\r\n let rgbaData: any;\r\n let val1 = 1;\r\n if (textureType === Constants.TEXTURETYPE_FLOAT) {\r\n rgbaData = new Float32Array(width * height * 4);\r\n } else if (textureType === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n rgbaData = new Uint16Array(width * height * 4);\r\n val1 = 15360; // 15360 is the encoding of 1 in half float\r\n } else if (textureType === Constants.TEXTURETYPE_UNSIGNED_INTEGER) {\r\n rgbaData = new Uint32Array(width * height * 4);\r\n } else {\r\n rgbaData = new Uint8Array(width * height * 4);\r\n }\r\n\r\n // Convert each pixel.\r\n for (let x = 0; x < width; x++) {\r\n for (let y = 0; y < height; y++) {\r\n const index = (y * width + x) * 3;\r\n const newIndex = (y * width + x) * 4;\r\n\r\n // Map Old Value to new value.\r\n rgbaData[newIndex + 0] = rgbData[index + 0];\r\n rgbaData[newIndex + 1] = rgbData[index + 1];\r\n rgbaData[newIndex + 2] = rgbData[index + 2];\r\n\r\n // Add fully opaque alpha channel.\r\n rgbaData[newIndex + 3] = val1;\r\n }\r\n }\r\n\r\n return rgbaData;\r\n}\r\n"]}
1
+ {"version":3,"file":"engine.rawTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Engines/WebGPU/Extensions/engine.rawTexture.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAyB,MAAM,6CAA6C,CAAC;AAGrG,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,kCAAsC;AA2NjE,gBAAgB,CAAC,SAAS,CAAC,gBAAgB,GAAG,UAC1C,IAA+B,EAC/B,KAAa,EACb,MAAc,EACd,MAAc,EACd,eAAwB,EACxB,OAAgB,EAChB,YAAoB,EACpB,cAAgC,IAAI,EACpC,OAAe,SAAS,CAAC,yBAAyB,EAClD,gBAAwB,CAAC,EACzB,gBAAyB,KAAK,EAC9B,aAAsB;IAEtB,MAAM,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,oCAA4B,CAAC;IACrE,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;IAC1B,OAAO,CAAC,UAAU,GAAG,MAAM,CAAC;IAC5B,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IACtB,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,eAAe,GAAG,eAAe,CAAC;IAC1C,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IACpC,OAAO,CA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GAAG,CAAC,CAAC;YAClC,MAAM,QAAQ,GAAG,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;YAErC,8BAA8B;YAC9B,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAC5C,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAC5C,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;YAE5C,kCAAkC;YAClC,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;QAClC,CAAC;IACL,CAAC;IAED,OAAO,QAAQ,CAAC;AACpB,CAAC","sourcesContent":["import { InternalTexture, InternalTextureSource } from \"../../../Materials/Textures/internalTexture\";\r\nimport type { IWebRequest } from \"../../../Misc/interfaces/iWebRequest\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Constants } from \"../../constants\";\r\nimport type { WebGPUHardwareTexture } from \"../webgpuHardwareTexture\";\r\nimport { Logger } from \"../../../Misc/logger\";\r\n\r\nimport type { Scene } from \"../../../scene\";\r\nimport { ThinWebGPUEngine } from \"core/Engines/thinWebGPUEngine\";\r\n\r\ndeclare module \"../../abstractEngine\" {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n export interface AbstractEngine {\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store in the texture\r\n * @param format defines the format of the data\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param useSRGBBuffer defines if the texture must be loaded in a sRGB GPU buffer (if supported by the GPU).\r\n * @param mipLevel defines which mipLevel of the texture is going to be updated\r\n */\r\n updateRawTexture(\r\n texture: Nullable<InternalTexture>,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n type: number,\r\n useSRGBBuffer: boolean,\r\n mipLevel?: number\r\n ): void;\r\n\r\n /**\r\n * Creates a new raw cube texture\r\n * @param data defines the array of data to use to create each face\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)\r\n * @param generateMipMaps defines if the engine should generate the mip levels\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param compression defines the compression used (null by default)\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTexture(\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;\r\n\r\n /**\r\n * Update a raw cube texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_BYTE by default)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the compression used (null by default)\r\n * @param level defines which level of the texture to update\r\n */\r\n updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[] | Promise<ArrayBufferView[]>>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>\r\n ): InternalTexture;\r\n\r\n /**\r\n * Creates a new raw cube texture from a specified url\r\n * @param url defines the url where the data is located\r\n * @param scene defines the current scene\r\n * @param size defines the size of the textures\r\n * @param format defines the format of the data\r\n * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_BYTE)\r\n * @param noMipmap defines if the engine should avoid generating the mip levels\r\n * @param callback defines a callback used to extract texture data from loaded data\r\n * @param mipmapGenerator defines to provide an optional tool to generate mip levels\r\n * @param onLoad defines a callback called when texture is loaded\r\n * @param onError defines a callback called if there is an error\r\n * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @returns the cube texture as an InternalTexture\r\n */\r\n createRawCubeTextureFromUrl(\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[] | Promise<ArrayBufferView[]>>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>,\r\n samplingMode: number,\r\n invertY: boolean\r\n ): InternalTexture;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 3D texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n */\r\n updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)\r\n */\r\n updateRawTexture2DArray(\r\n texture: InternalTexture,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n textureType: number\r\n ): void;\r\n\r\n /**\r\n * Update a raw 2D array texture\r\n * @param texture defines the texture to update\r\n * @param data defines the data to store\r\n * @param format defines the data format\r\n * @param invertY defines if data must be stored with Y axis inverted\r\n * @param compression defines the used compression (can be null)\r\n * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_BYTE, Engine.TEXTURETYPE_FLOAT...)\r\n * @param mipLevel defines which mipLevel of the texture is going to be updated\r\n */\r\n updateRawTexture2DArray(\r\n texture: InternalTexture,\r\n data: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string>,\r\n textureType: number,\r\n mipLevel?: number\r\n ): void;\r\n }\r\n}\r\n\r\nThinWebGPUEngine.prototype.createRawTexture = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0,\r\n useSRGBBuffer: boolean = false,\r\n mipLevelCount?: number\r\n): InternalTexture {\r\n const texture = new InternalTexture(this, InternalTextureSource.Raw);\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.format = format;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture.type = type;\r\n texture._creationFlags = creationFlags;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this._textureHelper.updateMipLevelCountForInternalTexture(texture, mipLevelCount);\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, undefined, creationFlags);\r\n\r\n this.updateRawTexture(texture, data, format, invertY, compression, type, useSRGBBuffer);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawTexture = function (\r\n texture: Nullable<InternalTexture>,\r\n bufferView: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n type: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n useSRGBBuffer: boolean = false,\r\n mipLevel?: number\r\n): void {\r\n if (!texture) {\r\n return;\r\n }\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = bufferView;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture._useSRGBBuffer = useSRGBBuffer;\r\n if (mipLevel !== undefined && bufferView) {\r\n if (!texture._bufferViewArray) {\r\n texture._bufferViewArray = new Array(texture.mipLevelCount);\r\n }\r\n texture._bufferViewArray[mipLevel] = bufferView;\r\n }\r\n }\r\n\r\n if (bufferView) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (needConversion) {\r\n bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, type);\r\n }\r\n\r\n const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);\r\n\r\n const mipWidth = Math.max(1, texture.width >> (mipLevel ?? 0));\r\n const mipHeight = Math.max(1, texture.height >> (mipLevel ?? 0));\r\n this._textureHelper.updateTexture(data, texture, mipWidth, mipHeight, texture.depth, gpuTextureWrapper.format, 0, mipLevel ?? 0, invertY, false, 0, 0);\r\n if (texture.generateMipMaps && !mipLevel) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawCubeTexture = function (\r\n data: Nullable<ArrayBufferView[]>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null\r\n): InternalTexture {\r\n const texture = new InternalTexture(this, InternalTextureSource.CubeRaw);\r\n\r\n if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {\r\n generateMipMaps = false;\r\n samplingMode = Constants.TEXTURE_NEAREST_SAMPLINGMODE;\r\n Logger.Warn(\"Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.\");\r\n } else if (type === Constants.TEXTURETYPE_FLOAT && !this._caps.textureFloatRender) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to float textures is not supported. Mipmap generation forced to false.\");\r\n } else if (type === Constants.TEXTURETYPE_HALF_FLOAT && !this._caps.colorBufferFloat) {\r\n generateMipMaps = false;\r\n Logger.Warn(\"Render to half float textures is not supported. Mipmap generation forced to false.\");\r\n }\r\n\r\n texture.isCube = true;\r\n texture._originalFormat = format;\r\n texture.format = format === Constants.TEXTUREFORMAT_RGB ? Constants.TEXTUREFORMAT_RGBA : format;\r\n texture.type = type;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.width = size;\r\n texture.height = size;\r\n texture.samplingMode = samplingMode;\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferViewArray = data;\r\n }\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n texture._cachedWrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n texture._cachedWrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture);\r\n\r\n if (format === Constants.TEXTUREFORMAT_RGB) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n gpuTextureWrapper._originalFormatIsRGB = true;\r\n }\r\n\r\n if (data) {\r\n this.updateRawCubeTexture(texture, data, format, type, invertY, compression);\r\n }\r\n\r\n texture.isReady = true;\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawCubeTexture = function (\r\n texture: InternalTexture,\r\n bufferView: ArrayBufferView[],\r\n _format: number,\r\n type: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null\r\n): void {\r\n texture._bufferViewArray = bufferView;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = gpuTextureWrapper._originalFormatIsRGB;\r\n\r\n const faces = [0, 2, 4, 1, 3, 5];\r\n\r\n const data = [];\r\n for (let i = 0; i < bufferView.length; ++i) {\r\n let faceData = bufferView[faces[i]];\r\n if (needConversion) {\r\n faceData = ConvertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);\r\n }\r\n data.push(new Uint8Array(faceData.buffer, faceData.byteOffset, faceData.byteLength));\r\n }\r\n\r\n this._textureHelper.updateCubeTextures(data, gpuTextureWrapper.underlyingResource!, texture.width, texture.height, gpuTextureWrapper.format, invertY, false, 0, 0);\r\n if (texture.generateMipMaps) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawCubeTextureFromUrl = function (\r\n url: string,\r\n scene: Nullable<Scene>,\r\n size: number,\r\n format: number,\r\n type: number,\r\n noMipmap: boolean,\r\n callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[] | Promise<ArrayBufferView[]>>,\r\n mipmapGenerator: Nullable<(faces: ArrayBufferView[]) => ArrayBufferView[][]>,\r\n onLoad: Nullable<() => void> = null,\r\n onError: Nullable<(message?: string, exception?: any) => void> = null,\r\n samplingMode: number = Constants.TEXTURE_TRILINEAR_SAMPLINGMODE,\r\n invertY: boolean = false\r\n): InternalTexture {\r\n const texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode, null);\r\n scene?.addPendingData(texture);\r\n texture.url = url;\r\n texture.isReady = false;\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n const onerror = (request?: IWebRequest, exception?: any) => {\r\n scene?.removePendingData(texture);\r\n if (onError && request) {\r\n onError(request.status + \" \" + request.statusText, exception);\r\n }\r\n };\r\n\r\n const internalCallbackAsync = async (data: any) => {\r\n const faceDataArraysResult = callback(data);\r\n if (!faceDataArraysResult) {\r\n return;\r\n }\r\n\r\n const faceDataArrays: any = faceDataArraysResult instanceof Promise ? await faceDataArraysResult : faceDataArraysResult;\r\n const width = texture.width;\r\n\r\n if (mipmapGenerator) {\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n const mipData = mipmapGenerator(faceDataArrays);\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const faces = [0, 1, 2, 3, 4, 5];\r\n for (let level = 0; level < mipData.length; level++) {\r\n const mipSize = width >> level;\r\n const allFaces = [];\r\n for (let faceIndex = 0; faceIndex < 6; faceIndex++) {\r\n let mipFaceData = mipData[level][faces[faceIndex]];\r\n if (needConversion) {\r\n mipFaceData = ConvertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);\r\n }\r\n allFaces.push(new Uint8Array(mipFaceData.buffer, mipFaceData.byteOffset, mipFaceData.byteLength));\r\n }\r\n this._textureHelper.updateCubeTextures(allFaces, gpuTextureWrapper.underlyingResource!, mipSize, mipSize, gpuTextureWrapper.format, invertY, false, 0, 0);\r\n }\r\n } else {\r\n this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);\r\n }\r\n\r\n texture.isReady = true;\r\n scene?.removePendingData(texture);\r\n\r\n if (onLoad) {\r\n onLoad();\r\n }\r\n };\r\n\r\n this._loadFile(\r\n url,\r\n (data) => {\r\n // eslint-disable-next-line github/no-then\r\n internalCallbackAsync(data).catch((err) => {\r\n onerror(undefined, err);\r\n });\r\n },\r\n undefined,\r\n scene?.offlineProvider,\r\n true,\r\n onerror\r\n );\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawTexture3D = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0\r\n): InternalTexture {\r\n const source = InternalTextureSource.Raw3D;\r\n const texture = new InternalTexture(this, source);\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.baseDepth = depth;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.depth = depth;\r\n texture.format = format;\r\n texture.type = textureType;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.is3D = true;\r\n texture._creationFlags = creationFlags;\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, undefined, creationFlags);\r\n\r\n this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawTexture3D = function (\r\n texture: InternalTexture,\r\n bufferView: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n): void {\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = bufferView;\r\n texture.format = format;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n }\r\n\r\n if (bufferView) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (needConversion) {\r\n bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, textureType);\r\n }\r\n\r\n const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);\r\n\r\n this._textureHelper.updateTexture(data, texture, texture.width, texture.height, texture.depth, gpuTextureWrapper.format, 0, 0, invertY, false, 0, 0);\r\n if (texture.generateMipMaps) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\nThinWebGPUEngine.prototype.createRawTexture2DArray = function (\r\n data: Nullable<ArrayBufferView>,\r\n width: number,\r\n height: number,\r\n depth: number,\r\n format: number,\r\n generateMipMaps: boolean,\r\n invertY: boolean,\r\n samplingMode: number,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n creationFlags: number = 0,\r\n mipLevelCount?: number\r\n): InternalTexture {\r\n const source = InternalTextureSource.Raw2DArray;\r\n const texture = new InternalTexture(this, source);\r\n\r\n texture.baseWidth = width;\r\n texture.baseHeight = height;\r\n texture.baseDepth = depth;\r\n texture.width = width;\r\n texture.height = height;\r\n texture.depth = depth;\r\n texture.format = format;\r\n texture.type = textureType;\r\n texture.generateMipMaps = generateMipMaps;\r\n texture.samplingMode = samplingMode;\r\n texture.is2DArray = true;\r\n texture._creationFlags = creationFlags;\r\n\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = data;\r\n }\r\n\r\n this._textureHelper.updateMipLevelCountForInternalTexture(texture, mipLevelCount);\r\n this._textureHelper.createGPUTextureForInternalTexture(texture, width, height, depth, creationFlags);\r\n\r\n this.updateRawTexture2DArray(texture, data, format, invertY, compression, textureType);\r\n\r\n this._internalTexturesCache.push(texture);\r\n\r\n return texture;\r\n};\r\n\r\nThinWebGPUEngine.prototype.updateRawTexture2DArray = function (\r\n texture: InternalTexture,\r\n bufferView: Nullable<ArrayBufferView>,\r\n format: number,\r\n invertY: boolean,\r\n compression: Nullable<string> = null,\r\n textureType: number = Constants.TEXTURETYPE_UNSIGNED_BYTE,\r\n mipLevel?: number\r\n): void {\r\n if (!this._doNotHandleContextLost) {\r\n texture._bufferView = bufferView;\r\n texture.format = format;\r\n texture.invertY = invertY;\r\n texture._compression = compression;\r\n if (mipLevel !== undefined && bufferView) {\r\n if (!texture._bufferViewArray) {\r\n texture._bufferViewArray = new Array(texture.mipLevelCount);\r\n }\r\n texture._bufferViewArray[mipLevel] = bufferView;\r\n }\r\n }\r\n\r\n if (bufferView) {\r\n const gpuTextureWrapper = texture._hardwareTexture as WebGPUHardwareTexture;\r\n const needConversion = format === Constants.TEXTUREFORMAT_RGB;\r\n\r\n if (needConversion) {\r\n bufferView = ConvertRGBtoRGBATextureData(bufferView, texture.width, texture.height, textureType);\r\n }\r\n\r\n const data = new Uint8Array(bufferView.buffer, bufferView.byteOffset, bufferView.byteLength);\r\n\r\n const mipWidth = Math.max(1, texture.width >> (mipLevel ?? 0));\r\n const mipHeight = Math.max(1, texture.height >> (mipLevel ?? 0));\r\n this._textureHelper.updateTexture(data, texture, mipWidth, mipHeight, texture.depth, gpuTextureWrapper.format, 0, mipLevel ?? 0, invertY, false, 0, 0);\r\n if (texture.generateMipMaps && !mipLevel) {\r\n this._generateMipmaps(texture, this._uploadEncoder);\r\n }\r\n }\r\n\r\n texture.isReady = true;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction ConvertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView {\r\n // Create new RGBA data container.\r\n let rgbaData: any;\r\n let val1 = 1;\r\n if (textureType === Constants.TEXTURETYPE_FLOAT) {\r\n rgbaData = new Float32Array(width * height * 4);\r\n } else if (textureType === Constants.TEXTURETYPE_HALF_FLOAT) {\r\n rgbaData = new Uint16Array(width * height * 4);\r\n val1 = 15360; // 15360 is the encoding of 1 in half float\r\n } else if (textureType === Constants.TEXTURETYPE_UNSIGNED_INTEGER) {\r\n rgbaData = new Uint32Array(width * height * 4);\r\n } else {\r\n rgbaData = new Uint8Array(width * height * 4);\r\n }\r\n\r\n // Convert each pixel.\r\n for (let x = 0; x < width; x++) {\r\n for (let y = 0; y < height; y++) {\r\n const index = (y * width + x) * 3;\r\n const newIndex = (y * width + x) * 4;\r\n\r\n // Map Old Value to new value.\r\n rgbaData[newIndex + 0] = rgbData[index + 0];\r\n rgbaData[newIndex + 1] = rgbData[index + 1];\r\n rgbaData[newIndex + 2] = rgbData[index + 2];\r\n\r\n // Add fully opaque alpha channel.\r\n rgbaData[newIndex + 3] = val1;\r\n }\r\n }\r\n\r\n return rgbaData;\r\n}\r\n"]}
@@ -35,7 +35,7 @@ export declare class WebGPUTextureManager {
35
35
  width: number;
36
36
  height: number;
37
37
  layers: number;
38
- }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number, additionalUsages?: number, label?: string): GPUTexture;
38
+ }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number, additionalUsages?: number, label?: string, mipLevelCount?: number): GPUTexture;
39
39
  createCubeTexture(imageBitmaps: ImageBitmap[] | {
40
40
  width: number;
41
41
  height: number;
@@ -48,6 +48,7 @@ export declare class WebGPUTextureManager {
48
48
  resolveMSAADepthTexture(msaaTexture: GPUTexture, outputTexture: GPUTexture, commandEncoder?: GPUCommandEncoder): void;
49
49
  updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number): void;
50
50
  updateTexture(imageBitmap: ImageBitmap | Uint8Array | ImageData | HTMLImageElement | HTMLVideoElement | VideoFrame | HTMLCanvasElement | OffscreenCanvas, texture: GPUTexture | InternalTexture, width: number, height: number, layers: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, allowGPUOptimization?: boolean): void;
51
+ updateMipLevelCountForInternalTexture(texture: InternalTexture, mipLevelCount?: number): void;
51
52
  readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>, noDataConversion?: boolean): Promise<ArrayBufferView>;
52
53
  releaseTexture(texture: InternalTexture | GPUTexture): void;
53
54
  destroyDeferredTextures(): void;
@@ -207,7 +207,7 @@ const resolveDepthFragmentSource = `
207
207
  for (var i = 0u; i < numSamples; i = i + 1u) {
208
208
  depth = min(depth, textureLoad(msaaDepthTexture, vec2u(input.position.xy), i));
209
209
  }
210
-
210
+
211
211
  fragmentOutputs.color = vec4f(depth);
212
212
  #else
213
213
  fragmentOutputs.color = vec4f(textureLoad(msaaDepthTexture, vec2u(input.position.xy), 0)); // do like WebGL, take the first sample
@@ -625,7 +625,7 @@ export class WebGPUTextureManager {
625
625
  //------------------------------------------------------------------------------
626
626
  // Creation
627
627
  //------------------------------------------------------------------------------
628
- createTexture(imageBitmap, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, is3D = false, format = "rgba8unorm" /* WebGPUConstants.TextureFormat.RGBA8Unorm */, sampleCount = 1, commandEncoder, usage = -1, additionalUsages = 0, label) {
628
+ createTexture(imageBitmap, hasMipmaps = false, generateMipmaps = false, invertY = false, premultiplyAlpha = false, is3D = false, format = "rgba8unorm" /* WebGPUConstants.TextureFormat.RGBA8Unorm */, sampleCount = 1, commandEncoder, usage = -1, additionalUsages = 0, label, mipLevelCount) {
629
629
  sampleCount = WebGPUTextureHelper.GetSample(sampleCount);
630
630
  const layerCount = imageBitmap.layers || 1;
631
631
  const textureSize = {
@@ -635,7 +635,8 @@ export class WebGPUTextureManager {
635
635
  };
636
636
  const renderAttachmentFlag = renderableTextureFormatToIndex[format] ? 16 /* WebGPUConstants.TextureUsage.RenderAttachment */ : 0;
637
637
  const isCompressedFormat = WebGPUTextureHelper.IsCompressedFormat(format);
638
- const mipLevelCount = hasMipmaps ? WebGPUTextureHelper.ComputeNumMipmapLevels(imageBitmap.width, imageBitmap.height) : 1;
638
+ const maxNumMipLevels = WebGPUTextureHelper.ComputeNumMipmapLevels(imageBitmap.width, imageBitmap.height);
639
+ const effectiveMipLevelCount = hasMipmaps ? Math.min(mipLevelCount ?? maxNumMipLevels, maxNumMipLevels) : 1;
639
640
  const usages = usage >= 0 ? usage : 1 /* WebGPUConstants.TextureUsage.CopySrc */ | 2 /* WebGPUConstants.TextureUsage.CopyDst */ | 4 /* WebGPUConstants.TextureUsage.TextureBinding */;
640
641
  additionalUsages |= hasMipmaps && !isCompressedFormat ? 1 /* WebGPUConstants.TextureUsage.CopySrc */ | renderAttachmentFlag : 0;
641
642
  if (!isCompressedFormat && !is3D) {
@@ -649,12 +650,12 @@ export class WebGPUTextureManager {
649
650
  format,
650
651
  usage: usages | additionalUsages,
651
652
  sampleCount,
652
- mipLevelCount,
653
+ mipLevelCount: effectiveMipLevelCount,
653
654
  });
654
655
  if (WebGPUTextureHelper.IsImageBitmap(imageBitmap)) {
655
656
  this.updateTexture(imageBitmap, gpuTexture, imageBitmap.width, imageBitmap.height, layerCount, format, 0, 0, invertY, premultiplyAlpha, 0, 0);
656
657
  if (hasMipmaps && generateMipmaps) {
657
- this.generateMipmaps(gpuTexture, mipLevelCount, 0, commandEncoder);
658
+ this.generateMipmaps(gpuTexture, effectiveMipLevelCount, 0, commandEncoder);
658
659
  }
659
660
  }
660
661
  return gpuTexture;
@@ -860,7 +861,7 @@ export class WebGPUTextureManager {
860
861
  }, isStorageTexture);
861
862
  }
862
863
  else {
863
- const gpuTexture = this.createTexture({ width, height, layers: layerCount }, texture.generateMipMaps, texture.generateMipMaps, texture.invertY, false, texture.is3D, gpuTextureWrapper.format, 1, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label);
864
+ const gpuTexture = this.createTexture({ width, height, layers: layerCount }, hasMipMaps, texture.generateMipMaps, texture.invertY, false, texture.is3D, gpuTextureWrapper.format, 1, this._commandEncoderForCreation, gpuTextureWrapper.textureUsages, gpuTextureWrapper.textureAdditionalUsages, texture.label);
864
865
  gpuTextureWrapper.set(gpuTexture);
865
866
  const arrayLayerCount = texture.is3D ? 1 : layerCount;
866
867
  const format = WebGPUTextureHelper.GetDepthFormatOnly(gpuTextureWrapper.format);
@@ -1006,6 +1007,18 @@ export class WebGPUTextureManager {
1006
1007
  this._device.queue.copyExternalImageToTexture({ source: imageBitmap, flipY: invertY }, textureCopyView, textureExtent);
1007
1008
  }
1008
1009
  }
1010
+ updateMipLevelCountForInternalTexture(texture, mipLevelCount) {
1011
+ const maxNumMipLevels = WebGPUTextureHelper.ComputeNumMipmapLevels(texture.width, texture.height);
1012
+ if (mipLevelCount !== undefined) {
1013
+ texture.mipLevelCount = Math.min(Math.max(1, mipLevelCount), maxNumMipLevels);
1014
+ }
1015
+ else if (texture.generateMipMaps) {
1016
+ texture.mipLevelCount = maxNumMipLevels;
1017
+ }
1018
+ else {
1019
+ texture.mipLevelCount = 1;
1020
+ }
1021
+ }
1009
1022
  // eslint-disable-next-line @typescript-eslint/promise-function-async
1010
1023
  readPixels(texture, x, y, width, height, format, faceIndex = 0, mipLevel = 0, buffer = null, noDataConversion = false) {
1011
1024
  const blockInformation = WebGPUTextureHelper.GetBlockInformationFromFormat(format);