@babylonjs/core 9.12.1 → 9.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/runtimeAnimation.js +11 -0
- package/Animations/runtimeAnimation.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSound.d.ts +2 -1
- package/AudioV2/abstractAudio/abstractSound.js +3 -2
- package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundInstance.d.ts +1 -1
- package/AudioV2/abstractAudio/abstractSoundInstance.js.map +1 -1
- package/AudioV2/abstractAudio/staticSound.d.ts +6 -0
- package/AudioV2/abstractAudio/staticSound.js +9 -1
- package/AudioV2/abstractAudio/staticSound.js.map +1 -1
- package/AudioV2/abstractAudio/streamingSound.d.ts +6 -0
- package/AudioV2/abstractAudio/streamingSound.js +9 -1
- package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.d.ts +1 -1
- package/AudioV2/webAudio/webAudioStaticSound.js +6 -3
- package/AudioV2/webAudio/webAudioStaticSound.js.map +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.d.ts +1 -1
- package/AudioV2/webAudio/webAudioStreamingSound.js +7 -4
- package/AudioV2/webAudio/webAudioStreamingSound.js.map +1 -1
- package/Cameras/arcRotateCamera.pure.js +9 -3
- package/Cameras/arcRotateCamera.pure.js.map +1 -1
- package/Cameras/targetCamera.pure.js +18 -18
- package/Cameras/targetCamera.pure.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +111 -4
- package/Collisions/gpuPicker.js +696 -119
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +4 -2
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +3 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +24 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js +16 -3
- package/Engines/WebGPU/Extensions/engine.videoTexture.pure.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +8 -1
- package/Engines/abstractEngine.pure.js +4 -3
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/engine.d.ts +113 -0
- package/Engines/nullEngine.pure.js +5 -1
- package/Engines/nullEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +5 -0
- package/Engines/thinNativeEngine.pure.js +158 -13
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/FlowGraph/flowGraph.js +9 -0
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.pure.d.ts +14 -0
- package/FlowGraph/flowGraphDataConnection.pure.js +38 -1
- package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
- package/FlowGraph/serialization.d.ts +11 -0
- package/FlowGraph/serialization.js +11 -1
- package/FlowGraph/serialization.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.d.ts +2 -2
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js +43 -51
- package/FrameGraph/Tasks/Rendering/iblShadows/iblShadowsAccumulationTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.d.ts +0 -1
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js +63 -35
- package/FrameGraph/Tasks/Rendering/iblShadowsRendererTask.pure.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.d.ts +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.js +2 -2
- package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
- package/Lights/areaLight.pure.js +5 -0
- package/Lights/areaLight.pure.js.map +1 -1
- package/Lights/light.d.ts +4 -2
- package/Lights/light.js +10 -4
- package/Lights/light.js.map +1 -1
- package/Lights/rectAreaLight.pure.d.ts +17 -0
- package/Lights/rectAreaLight.pure.js +67 -0
- package/Lights/rectAreaLight.pure.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.pure.js +1 -1
- package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
- package/Loading/sceneLoader.d.ts +5 -1
- package/Loading/sceneLoader.js +298 -401
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.d.ts +15 -0
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +34 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.d.ts +9 -0
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +26 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +3 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +43 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +64 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -0
- package/Materials/Textures/HTML/htmlInteractionManager.d.ts +69 -0
- package/Materials/Textures/HTML/htmlInteractionManager.js +130 -0
- package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -0
- package/Materials/Textures/HTML/htmlRaycastInteractionManager.d.ts +84 -0
- package/Materials/Textures/HTML/htmlRaycastInteractionManager.js +246 -0
- package/Materials/Textures/HTML/htmlRaycastInteractionManager.js.map +1 -0
- package/Materials/Textures/HTML/htmlTexture.d.ts +148 -0
- package/Materials/Textures/HTML/htmlTexture.js +455 -0
- package/Materials/Textures/HTML/htmlTexture.js.map +1 -0
- package/Materials/Textures/HTML/index.d.ts +4 -0
- package/Materials/Textures/HTML/index.js +5 -0
- package/Materials/Textures/HTML/index.js.map +1 -0
- package/Materials/Textures/HTML/pure.d.ts +5 -0
- package/Materials/Textures/HTML/pure.js +6 -0
- package/Materials/Textures/HTML/pure.js.map +1 -0
- package/Materials/Textures/index.d.ts +1 -0
- package/Materials/Textures/index.js +1 -1
- package/Materials/Textures/index.js.map +1 -1
- package/Materials/Textures/pure.d.ts +1 -0
- package/Materials/Textures/pure.js +1 -0
- package/Materials/Textures/pure.js.map +1 -1
- package/Materials/Textures/videoTexture.pure.d.ts +3 -0
- package/Materials/Textures/videoTexture.pure.js +30 -0
- package/Materials/Textures/videoTexture.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +36 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +56 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.d.ts +3 -1
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js +210 -48
- package/Meshes/GaussianSplatting/gaussianSplattingSortWorker.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +1 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +34 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +1 -0
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/gaussianSplatting.fragment.js +17 -1
- package/Shaders/gaussianSplatting.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +1 -1
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/Shaders/picking.fragment.js +39 -3
- package/Shaders/picking.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +3 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js +4 -3
- package/ShadersWGSL/ShadersInclude/openpbrIblFunctions.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js +14 -1
- package/ShadersWGSL/gaussianSplatting.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/picking.fragment.js +22 -1
- package/ShadersWGSL/picking.fragment.js.map +1 -1
- package/package.json +1 -1
|
@@ -148,7 +148,8 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
148
148
|
this._frameStats = { gpuTimeNs: Number.NaN };
|
|
149
149
|
this._boundBuffersVertexArray = null;
|
|
150
150
|
this._currentDepthTest = _native.Engine.DEPTH_TEST_LEQUAL;
|
|
151
|
-
this.
|
|
151
|
+
this._depthTestEnabled = true;
|
|
152
|
+
this._stencilTest = false;
|
|
152
153
|
this._stencilMask = 255;
|
|
153
154
|
this._stencilFunc = 519;
|
|
154
155
|
this._stencilFuncRef = 0;
|
|
@@ -182,6 +183,10 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
182
183
|
this._webGLVersion = 2;
|
|
183
184
|
this.disableUniformBuffers = true;
|
|
184
185
|
this._shaderPlatformName = "NATIVE";
|
|
186
|
+
// Babylon Native is not WebGL and has no _gl context. Report a distinct engine name (like
|
|
187
|
+
// WebGPU reports "WebGPU") so application/feature code that branches on engine.name === "WebGL"
|
|
188
|
+
// to touch the WebGL-only _gl context skips the native engine instead of dereferencing null.
|
|
189
|
+
this._name = "Native";
|
|
185
190
|
// TODO: Initialize this more correctly based on the hardware capabilities.
|
|
186
191
|
// Init caps
|
|
187
192
|
this._caps = {
|
|
@@ -545,6 +550,7 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
545
550
|
return;
|
|
546
551
|
}
|
|
547
552
|
// Apply states
|
|
553
|
+
this._flushDepthTestState();
|
|
548
554
|
this._drawCalls.addCount(1, false);
|
|
549
555
|
if (instancesCount) {
|
|
550
556
|
this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXEDINSTANCED);
|
|
@@ -573,6 +579,7 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
573
579
|
return;
|
|
574
580
|
}
|
|
575
581
|
// Apply states
|
|
582
|
+
this._flushDepthTestState();
|
|
576
583
|
this._drawCalls.addCount(1, false);
|
|
577
584
|
if (instancesCount) {
|
|
578
585
|
this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINSTANCED);
|
|
@@ -823,10 +830,28 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
823
830
|
* @param enable defines the state to set
|
|
824
831
|
*/
|
|
825
832
|
setDepthBuffer(enable) {
|
|
833
|
+
// Keep the shared depth-culling state in sync so that code paths which toggle
|
|
834
|
+
// depth testing through engine.depthCullingState.depthTest (for example
|
|
835
|
+
// EffectRenderer.applyEffectWrapper) are also honored on the native side. The
|
|
836
|
+
// native draw path does not go through the WebGL applyStates() flush, so the
|
|
837
|
+
// value is reconciled in _flushDepthTestState() right before each draw.
|
|
838
|
+
this._depthCullingState.depthTest = enable;
|
|
839
|
+
this._encodeDepthTest(enable);
|
|
840
|
+
}
|
|
841
|
+
_encodeDepthTest(enable) {
|
|
842
|
+
this._depthTestEnabled = enable;
|
|
826
843
|
this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETDEPTHTEST);
|
|
827
844
|
this._commandBufferEncoder.encodeCommandArgAsUInt32(enable ? this._currentDepthTest : _native.Engine.DEPTH_TEST_ALWAYS);
|
|
828
845
|
this._commandBufferEncoder.finishEncodingCommand();
|
|
829
846
|
}
|
|
847
|
+
_flushDepthTestState() {
|
|
848
|
+
// Unlike the WebGL engine, the native engine does not call applyStates() before
|
|
849
|
+
// a draw, so depth-test toggles made directly on engine.depthCullingState are
|
|
850
|
+
// flushed here to match the cross-engine contract.
|
|
851
|
+
if (this._depthCullingState.depthTest !== this._depthTestEnabled) {
|
|
852
|
+
this._encodeDepthTest(this._depthCullingState.depthTest);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
830
855
|
/**
|
|
831
856
|
* Gets a boolean indicating if depth writing is enabled
|
|
832
857
|
* @returns the current depth writing state
|
|
@@ -884,9 +909,13 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
884
909
|
break;
|
|
885
910
|
}
|
|
886
911
|
this._currentDepthTest = nativeDepthFunc;
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
912
|
+
// Route through _encodeDepthTest so the tracked _depthTestEnabled state stays in
|
|
913
|
+
// sync with the encoded command. Because COMMAND_SETDEPTHTEST conflates the
|
|
914
|
+
// compare function and the enable bit (DEPTH_TEST_ALWAYS == disabled), encoding
|
|
915
|
+
// the new function directly here would silently re-enable depth testing while
|
|
916
|
+
// depth testing is logically disabled; _encodeDepthTest honors the current
|
|
917
|
+
// depthCullingState.depthTest and only emits the new function when enabled.
|
|
918
|
+
this._encodeDepthTest(this._depthCullingState.depthTest);
|
|
890
919
|
}
|
|
891
920
|
/**
|
|
892
921
|
* Enable or disable depth writing
|
|
@@ -1562,6 +1591,13 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
1562
1591
|
internalTexture.baseHeight = this._engine.getTextureHeight(texture);
|
|
1563
1592
|
internalTexture.width = internalTexture.baseWidth;
|
|
1564
1593
|
internalTexture.height = internalTexture.baseHeight;
|
|
1594
|
+
if (this._engine.getTextureLayerCount) {
|
|
1595
|
+
const layerCount = this._engine.getTextureLayerCount(texture);
|
|
1596
|
+
if (layerCount > 1) {
|
|
1597
|
+
internalTexture.is2DArray = true;
|
|
1598
|
+
internalTexture.baseDepth = internalTexture.depth = layerCount;
|
|
1599
|
+
}
|
|
1600
|
+
}
|
|
1565
1601
|
internalTexture.isReady = true;
|
|
1566
1602
|
internalTexture.useMipMaps = hasMipMaps;
|
|
1567
1603
|
this.updateTextureSamplingMode(samplingMode, internalTexture);
|
|
@@ -1596,6 +1632,13 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
1596
1632
|
if (newWidth !== internalTexture.baseWidth || newHeight !== internalTexture.baseHeight) {
|
|
1597
1633
|
throw new Error(`updateWrappedNativeTexture: new handle dimensions (${newWidth}x${newHeight}) must match the wrapped texture's dimensions (${internalTexture.baseWidth}x${internalTexture.baseHeight}).`);
|
|
1598
1634
|
}
|
|
1635
|
+
if (this._engine.getTextureLayerCount) {
|
|
1636
|
+
const newLayerCount = this._engine.getTextureLayerCount(texture);
|
|
1637
|
+
const oldLayerCount = internalTexture.is2DArray ? internalTexture.depth : 1;
|
|
1638
|
+
if (newLayerCount !== oldLayerCount) {
|
|
1639
|
+
throw new Error(`updateWrappedNativeTexture: new handle layer count (${newLayerCount}) must match the wrapped texture's layer count (${oldLayerCount}).`);
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1599
1642
|
// Pre-validate before mutating any state so a thrown precondition leaves the InternalTexture untouched.
|
|
1600
1643
|
// Note: rtWrapper.texture only returns _textures[0]; walk every attachment to catch the multi-RT case where
|
|
1601
1644
|
// the wrapped texture is at index > 0.
|
|
@@ -1815,6 +1858,80 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
1815
1858
|
rtWrapper.setTextures(texture);
|
|
1816
1859
|
return rtWrapper;
|
|
1817
1860
|
}
|
|
1861
|
+
createRenderTargetCubeTexture(size, options) {
|
|
1862
|
+
const rtWrapper = this._createHardwareRenderTargetWrapper(false, true, size);
|
|
1863
|
+
let generateDepthBuffer = true;
|
|
1864
|
+
let generateStencilBuffer = false;
|
|
1865
|
+
let generateMipMaps = false;
|
|
1866
|
+
let type = 0;
|
|
1867
|
+
let samplingMode = 3;
|
|
1868
|
+
let format = 5;
|
|
1869
|
+
let samples = 1;
|
|
1870
|
+
let label;
|
|
1871
|
+
if (options !== undefined && typeof options === "object") {
|
|
1872
|
+
generateDepthBuffer = options.generateDepthBuffer ?? true;
|
|
1873
|
+
generateStencilBuffer = !!options.generateStencilBuffer;
|
|
1874
|
+
generateMipMaps = !!options.generateMipMaps;
|
|
1875
|
+
type = options.type ?? 0;
|
|
1876
|
+
samplingMode = options.samplingMode ?? 3;
|
|
1877
|
+
format = options.format ?? 5;
|
|
1878
|
+
samples = options.samples ?? 1;
|
|
1879
|
+
label = options.label;
|
|
1880
|
+
}
|
|
1881
|
+
// Match _createInternalTexture: float/half-float RTTs that the platform can't linearly filter fall
|
|
1882
|
+
// back to NEAREST so the cube RTT never carries an unsupported sampling mode.
|
|
1883
|
+
if (type === 1 && !this._caps.textureFloatLinearFiltering) {
|
|
1884
|
+
samplingMode = 1;
|
|
1885
|
+
}
|
|
1886
|
+
else if (type === 2 && !this._caps.textureHalfFloatLinearFiltering) {
|
|
1887
|
+
samplingMode = 1;
|
|
1888
|
+
}
|
|
1889
|
+
if (type === 1 && !this._caps.textureFloat) {
|
|
1890
|
+
type = 0;
|
|
1891
|
+
Logger.Warn("Float textures are not supported. Type forced to TEXTURETYPE_UNSIGNED_BYTE");
|
|
1892
|
+
}
|
|
1893
|
+
const texture = new InternalTexture(this, 5 /* InternalTextureSource.RenderTarget */);
|
|
1894
|
+
texture.isCube = true;
|
|
1895
|
+
texture.baseWidth = size;
|
|
1896
|
+
texture.baseHeight = size;
|
|
1897
|
+
texture.width = size;
|
|
1898
|
+
texture.height = size;
|
|
1899
|
+
texture.isReady = true;
|
|
1900
|
+
texture.samples = samples;
|
|
1901
|
+
texture.generateMipMaps = generateMipMaps;
|
|
1902
|
+
texture.samplingMode = samplingMode;
|
|
1903
|
+
texture.type = type;
|
|
1904
|
+
texture.format = format;
|
|
1905
|
+
texture.label = label;
|
|
1906
|
+
const nativeTexture = texture._hardwareTexture.underlyingResource;
|
|
1907
|
+
const nativeTextureFormat = getNativeTextureFormat(format, type);
|
|
1908
|
+
// See the createRenderTargetTexture MSAA/mips note: avoid the mips + samples combo on bgfx.
|
|
1909
|
+
const hasMips = samples > 1 ? false : generateMipMaps;
|
|
1910
|
+
this._engine.initializeTexture(nativeTexture, size, size, hasMips, nativeTextureFormat, /*renderTarget*/ true, /*srgb*/ false, samples, /*isCube*/ true);
|
|
1911
|
+
this._setTextureSampling(nativeTexture, getNativeSamplingMode(samplingMode));
|
|
1912
|
+
// The native engine cannot render to all six faces through one framebuffer, so create one
|
|
1913
|
+
// framebuffer per face (the C++ side binds the matching cube layer); bindFramebuffer(faceIndex)
|
|
1914
|
+
// then selects the right one.
|
|
1915
|
+
const framebuffers = [];
|
|
1916
|
+
for (let face = 0; face < 6; face++) {
|
|
1917
|
+
framebuffers.push(this._engine.createFrameBuffer(nativeTexture, size, size, generateStencilBuffer, generateDepthBuffer, samples, face));
|
|
1918
|
+
}
|
|
1919
|
+
rtWrapper._framebuffers = framebuffers;
|
|
1920
|
+
rtWrapper._generateDepthBuffer = generateDepthBuffer;
|
|
1921
|
+
rtWrapper._generateStencilBuffer = generateStencilBuffer;
|
|
1922
|
+
rtWrapper._samples = samples;
|
|
1923
|
+
rtWrapper.setTextures(texture);
|
|
1924
|
+
// Track the hand-built cube RTT texture the same way _createInternalTexture tracks 2D textures so it
|
|
1925
|
+
// participates in engine-wide lifecycle management (dispose iteration, context rebuild, stats).
|
|
1926
|
+
this._internalTexturesCache.push(texture);
|
|
1927
|
+
return rtWrapper;
|
|
1928
|
+
}
|
|
1929
|
+
generateMipMapsForCubemap(_texture, _unbind = true) {
|
|
1930
|
+
// The WebGL path rebinds gl.TEXTURE_CUBE_MAP and calls gl.generateMipmap; both deref _gl, which is
|
|
1931
|
+
// null on Native. bgfx auto-generates the mip chain when a render target texture created with mips is
|
|
1932
|
+
// resolved (the same way 2D RTTs get their mips here -- unBindFramebuffer issues no explicit mipgen),
|
|
1933
|
+
// so this is a no-op on Native.
|
|
1934
|
+
}
|
|
1818
1935
|
updateRenderTargetTextureSampleCount(rtWrapper, samples) {
|
|
1819
1936
|
if (rtWrapper.samples === samples) {
|
|
1820
1937
|
return samples;
|
|
@@ -1854,10 +1971,24 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
1854
1971
|
// underlying bgfx resource has 1 mip level. Remove this guard once a fixed bgfx is in stable BN npm.
|
|
1855
1972
|
const hasMips = samples > 1 ? false : texture.generateMipMaps;
|
|
1856
1973
|
const nativeTextureFormat = getNativeTextureFormat(texture.format, texture.type);
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1974
|
+
const isCube = texture.isCube;
|
|
1975
|
+
this._engine.initializeTexture(nativeTexture, texture.baseWidth, texture.baseHeight, hasMips, nativeTextureFormat,
|
|
1976
|
+
/*renderTarget*/ true, texture._useSRGBBuffer, samples, isCube);
|
|
1977
|
+
if (isCube) {
|
|
1978
|
+
// Cube RTTs render through one framebuffer per face (see createRenderTargetCubeTexture). The
|
|
1979
|
+
// underlying bgfx handle was just rotated, so recreate all six attachments; the _framebuffers
|
|
1980
|
+
// setter releases the stale ones and keeps _framebuffer aliased to face 0 for single-target paths.
|
|
1981
|
+
const framebuffers = [];
|
|
1982
|
+
for (let face = 0; face < 6; face++) {
|
|
1983
|
+
framebuffers.push(this._engine.createFrameBuffer(nativeTexture, texture.baseWidth, texture.baseHeight, rtWrapper._generateStencilBuffer, rtWrapper._generateDepthBuffer, samples, face));
|
|
1984
|
+
}
|
|
1985
|
+
nativeRTWrapper._framebuffers = framebuffers;
|
|
1986
|
+
}
|
|
1987
|
+
else {
|
|
1988
|
+
// NativeRenderTargetWrapper._framebuffer setter releases the old framebuffer before assigning,
|
|
1989
|
+
// so no manual _releaseFramebufferObjects call is needed (and would double-delete the handle).
|
|
1990
|
+
nativeRTWrapper._framebuffer = this._engine.createFrameBuffer(nativeTexture, texture.baseWidth, texture.baseHeight, rtWrapper._generateStencilBuffer, rtWrapper._generateDepthBuffer, samples);
|
|
1991
|
+
}
|
|
1861
1992
|
rtWrapper._samples = samples;
|
|
1862
1993
|
texture.samples = samples;
|
|
1863
1994
|
return samples;
|
|
@@ -1875,13 +2006,17 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
1875
2006
|
this.unBindFramebuffer(this._currentRenderTarget);
|
|
1876
2007
|
}
|
|
1877
2008
|
this._currentRenderTarget = texture;
|
|
1878
|
-
if (faceIndex) {
|
|
1879
|
-
throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
|
|
1880
|
-
}
|
|
1881
2009
|
if (requiredWidth || requiredHeight) {
|
|
1882
2010
|
throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");
|
|
1883
2011
|
}
|
|
1884
|
-
if (nativeRTWrapper.
|
|
2012
|
+
if (nativeRTWrapper._framebuffers) {
|
|
2013
|
+
// Cube render target: bind the framebuffer for the requested face.
|
|
2014
|
+
this._bindUnboundFramebuffer(nativeRTWrapper._framebuffers[faceIndex ?? 0]);
|
|
2015
|
+
}
|
|
2016
|
+
else if (faceIndex) {
|
|
2017
|
+
throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");
|
|
2018
|
+
}
|
|
2019
|
+
else if (nativeRTWrapper._framebufferDepthStencil) {
|
|
1885
2020
|
this._bindUnboundFramebuffer(nativeRTWrapper._framebufferDepthStencil);
|
|
1886
2021
|
}
|
|
1887
2022
|
else {
|
|
@@ -2098,7 +2233,17 @@ export class ThinNativeEngine extends ThinEngine {
|
|
|
2098
2233
|
* @param generateMipMaps defines whether to generate mipmaps or not
|
|
2099
2234
|
*/
|
|
2100
2235
|
updateTextureData(texture, imageData, xOffset, yOffset, width, height, faceIndex = 0, lod = 0, generateMipMaps = false) {
|
|
2101
|
-
|
|
2236
|
+
if (!texture._hardwareTexture) {
|
|
2237
|
+
return;
|
|
2238
|
+
}
|
|
2239
|
+
if (!this._engine.updateTextureData) {
|
|
2240
|
+
throw new Error("updateTextureData not implemented.");
|
|
2241
|
+
}
|
|
2242
|
+
// bgfx updates the requested sub-rectangle of the existing texture (faceIndex selects the cube
|
|
2243
|
+
// face / array layer, lod selects the mip level). invertY is forwarded so the native side can match
|
|
2244
|
+
// the vertical orientation the base texture upload uses. Mip regeneration after a partial update is
|
|
2245
|
+
// not supported on Native, so generateMipMaps is ignored (consistent with the other raw-texture paths).
|
|
2246
|
+
this._engine.updateTextureData(texture._hardwareTexture.underlyingResource, imageData, xOffset, yOffset, width, height, faceIndex, lod, texture.invertY);
|
|
2102
2247
|
}
|
|
2103
2248
|
/**
|
|
2104
2249
|
* @internal
|