-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13284 from Popov72/ktx-new-decoders
KTXDecoder: Update and add new universal transcoders
- Loading branch information
Showing
21 changed files
with
250 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/tools/babylonServer/public/ktx2Transcoders/1/msc_basis_transcoder.js
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+445 KB
packages/tools/babylonServer/public/ktx2Transcoders/1/msc_basis_transcoder.wasm
Binary file not shown.
Binary file added
BIN
+11.9 KB
packages/tools/babylonServer/public/ktx2Transcoders/1/uastc_astc.wasm
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+13.8 KB
packages/tools/babylonServer/public/ktx2Transcoders/1/uastc_r8_unorm.wasm
Binary file not shown.
Binary file added
BIN
+17.2 KB
packages/tools/babylonServer/public/ktx2Transcoders/1/uastc_rg8_unorm.wasm
Binary file not shown.
Binary file added
BIN
+23.6 KB
packages/tools/babylonServer/public/ktx2Transcoders/1/uastc_rgba8_srgb_v2.wasm
Binary file not shown.
Binary file added
BIN
+29.4 KB
packages/tools/babylonServer/public/ktx2Transcoders/1/uastc_rgba8_unorm_v2.wasm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import * as KTX2Decoder from "@tools/ktx2decoder"; | ||
/* eslint-disable import/no-internal-modules */ | ||
import * as KTX2Decoder from "../../../ktx2Decoder/src/index"; | ||
|
||
const globalObject = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : undefined; | ||
if (typeof globalObject !== "undefined") { | ||
(<any>globalObject).KTX2DECODER = KTX2Decoder; | ||
} | ||
|
||
export * from "@tools/ktx2decoder"; | ||
export * from "../../../ktx2Decoder/src/index"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/tools/ktx2Decoder/src/Transcoders/liteTranscoder_UASTC_R8_UNORM.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { sourceTextureFormat, transcodeTarget } from "../transcoder"; | ||
import { LiteTranscoder } from "./liteTranscoder"; | ||
import type { KTX2FileReader, IKTX2_ImageDesc } from "../ktx2FileReader"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export class LiteTranscoder_UASTC_R8_UNORM extends LiteTranscoder { | ||
/** | ||
* URL to use when loading the wasm module for the transcoder (srgb) | ||
*/ | ||
public static WasmModuleURL = "https://preview.babylonjs.com/1/uastc_r8_unorm.wasm"; | ||
|
||
public static CanTranscode(src: sourceTextureFormat, dst: transcodeTarget, isInGammaSpace: boolean): boolean { | ||
return src === sourceTextureFormat.UASTC4x4 && dst === transcodeTarget.R8; | ||
} | ||
|
||
public static Name = "UniversalTranscoder_UASTC_R8_UNORM"; | ||
|
||
public getName(): string { | ||
return LiteTranscoder_UASTC_R8_UNORM.Name; | ||
} | ||
|
||
public initialize(): void { | ||
super.initialize(); | ||
this._transcodeInPlace = false; | ||
this.setModulePath(LiteTranscoder_UASTC_R8_UNORM.WasmModuleURL); | ||
} | ||
|
||
public transcode( | ||
src: sourceTextureFormat, | ||
dst: transcodeTarget, | ||
level: number, | ||
width: number, | ||
height: number, | ||
uncompressedByteLength: number, | ||
ktx2Reader: KTX2FileReader, | ||
imageDesc: IKTX2_ImageDesc | null, | ||
encodedData: Uint8Array | ||
): Promise<Uint8Array | null> { | ||
return this._loadModule().then((moduleWrapper: any) => { | ||
const transcoder: any = moduleWrapper.module; | ||
const [, uncompressedTextureView] = this._prepareTranscoding(width, height, uncompressedByteLength, encodedData, 1); | ||
|
||
return transcoder.decode(width, height) === 0 ? uncompressedTextureView!.slice() : null; | ||
}); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
packages/tools/ktx2Decoder/src/Transcoders/liteTranscoder_UASTC_RG8_UNORM.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { sourceTextureFormat, transcodeTarget } from "../transcoder"; | ||
import { LiteTranscoder } from "./liteTranscoder"; | ||
import type { KTX2FileReader, IKTX2_ImageDesc } from "../ktx2FileReader"; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
export class LiteTranscoder_UASTC_RG8_UNORM extends LiteTranscoder { | ||
/** | ||
* URL to use when loading the wasm module for the transcoder (srgb) | ||
*/ | ||
public static WasmModuleURL = "https://preview.babylonjs.com/ktx2Transcoders/1/uastc_rg8_unorm.wasm"; | ||
|
||
public static CanTranscode(src: sourceTextureFormat, dst: transcodeTarget, isInGammaSpace: boolean): boolean { | ||
return src === sourceTextureFormat.UASTC4x4 && dst === transcodeTarget.RG8; | ||
} | ||
|
||
public static Name = "UniversalTranscoder_UASTC_RG8_UNORM"; | ||
|
||
public getName(): string { | ||
return LiteTranscoder_UASTC_RG8_UNORM.Name; | ||
} | ||
|
||
public initialize(): void { | ||
super.initialize(); | ||
this._transcodeInPlace = false; | ||
this.setModulePath(LiteTranscoder_UASTC_RG8_UNORM.WasmModuleURL); | ||
} | ||
|
||
public transcode( | ||
src: sourceTextureFormat, | ||
dst: transcodeTarget, | ||
level: number, | ||
width: number, | ||
height: number, | ||
uncompressedByteLength: number, | ||
ktx2Reader: KTX2FileReader, | ||
imageDesc: IKTX2_ImageDesc | null, | ||
encodedData: Uint8Array | ||
): Promise<Uint8Array | null> { | ||
return this._loadModule().then((moduleWrapper: any) => { | ||
const transcoder: any = moduleWrapper.module; | ||
const [, uncompressedTextureView] = this._prepareTranscoding(width, height, uncompressedByteLength, encodedData, 2); | ||
|
||
return transcoder.decode(width, height) === 0 ? uncompressedTextureView!.slice() : null; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.