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
11 changes: 11 additions & 0 deletions packages/dev/core/src/Engines/Native/nativeInterfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ export interface INativeEngine {
): void;
loadTexture(texture: NativeTexture, data: ArrayBufferView, generateMips: boolean, invertY: boolean, srgb: boolean, onSuccess: () => void, onError: () => void): void;
loadRawTexture(texture: NativeTexture, data: ArrayBufferView, width: number, height: number, format: number, generateMips: boolean, invertY: boolean): void;
updateTextureData?(
texture: NativeTexture,
data: ArrayBufferView,
xOffset: number,
yOffset: number,
width: number,
height: number,
faceIndex: number,
lod: number,
invertY: boolean
): void;
loadRawTexture2DArray(
texture: NativeTexture,
data: Nullable<ArrayBufferView>,
Expand Down
18 changes: 17 additions & 1 deletion packages/dev/core/src/Engines/thinNativeEngine.pure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,10 @@ export class ThinNativeEngine extends ThinEngine {
this._webGLVersion = 2;
this.disableUniformBuffers = true;
this._shaderPlatformName = "NATIVE";
// Babylon Native is not WebGL and has no _gl context. Report a distinct engine name (like
// WebGPU reports "WebGPU") so application/feature code that branches on engine.name === "WebGL"
// to touch the WebGL-only _gl context skips the native engine instead of dereferencing null.
this._name = "Native";

// TODO: Initialize this more correctly based on the hardware capabilities.
// Init caps
Expand Down Expand Up @@ -2821,7 +2825,19 @@ export class ThinNativeEngine extends ThinEngine {
lod: number = 0,
generateMipMaps = false
): void {
throw new Error("updateTextureData not implemented.");
if (!texture._hardwareTexture) {
return;
}
Comment thread
bkaradzic-microsoft marked this conversation as resolved.

if (!this._engine.updateTextureData) {
throw new Error("updateTextureData not implemented.");
}

// bgfx updates the requested sub-rectangle of the existing texture (faceIndex selects the cube
// face / array layer, lod selects the mip level). invertY is forwarded so the native side can match
// the vertical orientation the base texture upload uses. Mip regeneration after a partial update is
// not supported on Native, so generateMipMaps is ignored (consistent with the other raw-texture paths).
this._engine.updateTextureData(texture._hardwareTexture.underlyingResource, imageData, xOffset, yOffset, width, height, faceIndex, lod, texture.invertY);
Comment thread
bkaradzic-microsoft marked this conversation as resolved.
}

/**
Expand Down