Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/dev/core/src/Engines/Native/nativeInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export interface INativeEngine {
loadCubeTextureWithMips(texture: NativeTexture, data: Array<Array<ArrayBufferView>>, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;
getTextureWidth(texture: NativeTexture): number;
getTextureHeight(texture: NativeTexture): number;
getTextureLayerCount?(texture: NativeTexture): number;
deleteTexture(texture: NativeTexture): void;
readTexture(
texture: NativeTexture,
Expand Down
14 changes: 14 additions & 0 deletions packages/dev/core/src/Engines/thinNativeEngine.pure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2035,6 +2035,13 @@ export class ThinNativeEngine extends ThinEngine {
internalTexture.baseHeight = this._engine.getTextureHeight(texture);
internalTexture.width = internalTexture.baseWidth;
internalTexture.height = internalTexture.baseHeight;
if (this._engine.getTextureLayerCount) {
const layerCount = this._engine.getTextureLayerCount(texture);
if (layerCount > 1) {
internalTexture.is2DArray = true;
internalTexture.baseDepth = internalTexture.depth = layerCount;
}
}
internalTexture.isReady = true;
internalTexture.useMipMaps = hasMipMaps;
this.updateTextureSamplingMode(samplingMode, internalTexture);
Expand Down Expand Up @@ -2073,6 +2080,13 @@ export class ThinNativeEngine extends ThinEngine {
`updateWrappedNativeTexture: new handle dimensions (${newWidth}x${newHeight}) must match the wrapped texture's dimensions (${internalTexture.baseWidth}x${internalTexture.baseHeight}).`
);
}
if (this._engine.getTextureLayerCount) {
const newLayerCount = this._engine.getTextureLayerCount(texture);
const oldLayerCount = internalTexture.is2DArray ? internalTexture.depth : 1;
if (newLayerCount !== oldLayerCount) {
throw new Error(`updateWrappedNativeTexture: new handle layer count (${newLayerCount}) must match the wrapped texture's layer count (${oldLayerCount}).`);
}
}

// Pre-validate before mutating any state so a thrown precondition leaves the InternalTexture untouched.
// Note: rtWrapper.texture only returns _textures[0]; walk every attachment to catch the multi-RT case where
Expand Down
Loading