simvx.graphics._native.basis_transcoder¶
Python wrapper around the compiled _simvx_basis_transcoder cffi extension.
Exposes a tiny Pythonic surface over the vendored basis_universal transcoder:
- func:
transcode_uastc_to_bc7/ :func:transcode_uastc_to_astc4x4/- func:
transcode_uastc_to_etc2turn one UASTC level’s packed 16-byte blocks into BC7 / ASTC-4x4 / ETC2-RGBA blocks (all 16 B/block). Used bysimvx.graphics.assets.ktx2_loaderto load single-source UASTC KTX2 textures on the desktop, withTextureManagerpicking the target per device caps.
Build the extension once after install:
uv run python -m simvx.graphics._native.basis_transcoder_build
If the .so is missing, this module still imports cleanly (the ImportError is
swallowed): callers check :func:is_available and fall through to a warn + -1
sentinel, never a crash. Mirrors simvx.core._native.miniaudio_engine.
Module Contents¶
Functions¶
True if the native extension was built, loaded, and ships the BC7 target. |
|
True if the extension shipped the UASTC->ASTC-4x4 target (BASISD_SUPPORT_ASTC). |
|
True if the extension shipped the UASTC->ETC2-RGBA target (BASISD_SUPPORT_ETC2_EAC_A8). |
|
Re-run the extension import, e.g. after a successful auto-build. |
|
Attempt a one-shot build of the extension if it is not already available. |
|
Transcode one UASTC level’s packed blocks to BC7 (16 B/block). |
|
Transcode one UASTC level’s packed blocks to ASTC LDR 4x4 (16 B/block). |
|
Transcode one UASTC level’s packed blocks to ETC2 RGBA (EAC_A8, 16 B/block). |
Data¶
API¶
- simvx.graphics._native.basis_transcoder.log¶
‘getLogger(…)’
- simvx.graphics._native.basis_transcoder.__all__¶
[‘BasisTranscoderUnavailable’, ‘is_available’, ‘astc_available’, ‘etc2_available’, ‘refresh’, ‘trans…
Bases:
RuntimeErrorThe compiled
_simvx_basis_transcoderextension was not found.Run
uv run python -m simvx.graphics._native.basis_transcoder_build(orsimvx build-textures) to compile it once, with a C++ compiler present.Initialization
Initialize self. See help(type(self)) for accurate signature.
- simvx.graphics._native.basis_transcoder.is_available() bool[source]¶
True if the native extension was built, loaded, and ships the BC7 target.
- simvx.graphics._native.basis_transcoder.astc_available() bool[source]¶
True if the extension shipped the UASTC->ASTC-4x4 target (BASISD_SUPPORT_ASTC).
A BC7-only build (the stale define-set) returns False here, so callers can verify the full-matrix .so actually shipped rather than silently skipping.
- simvx.graphics._native.basis_transcoder.etc2_available() bool[source]¶
True if the extension shipped the UASTC->ETC2-RGBA target (BASISD_SUPPORT_ETC2_EAC_A8).
- simvx.graphics._native.basis_transcoder.refresh() bool[source]¶
Re-run the extension import, e.g. after a successful auto-build.
- simvx.graphics._native.basis_transcoder.ensure_built() bool[source]¶
Attempt a one-shot build of the extension if it is not already available.
Honours
SIMVX_SKIP_TEXTURE_BUILD: when set, the build is skipped and the current availability is returned unchanged. Any build failure (no compiler, missing cffi/setuptools, etc.) is swallowed: the extension simply stays unavailable and the caller degrades gracefully. Returns the post-attempt availability.
- simvx.graphics._native.basis_transcoder.transcode_uastc_to_bc7(uastc_bytes: bytes, width: int, height: int) bytes[source]¶
Transcode one UASTC level’s packed blocks to BC7 (16 B/block).
uastc_bytesis the tightly-packed 16-byte UASTC blocks for a level ofwidthxheighttexels. Returnsnum_blocks * 16bytes of BC7.