Skip to content

Conversation

@Ne0nWinds
Copy link
Contributor

@Ne0nWinds Ne0nWinds commented Nov 21, 2025

Closes #30663

Description

GLSL in WebGL2 supports the following functions for packing floating-point values:

uint packUnorm2x16(vec2 v);
uint packSnorm2x16(vec2 v);
uint packHalf2x16(vec2 v);

vec2 unpackUnorm2x16(uint v);
vec2 unpackSnorm2x16(uint v);
vec2 unpackHalf2x16(uint v);

WGSL has the equivalent set of float-packing functions:

fn pack2x16snorm(e: vec2<f32>) -> u32
fn pack2x16unorm(e: vec2<f32>) -> u32
fn pack2x16float(e: vec2<f32>) -> u32

fn unpack2x16snorm(e: u32) -> vec2<f32>
fn unpack2x16unorm(e: u32) -> vec2<f32>
fn unpack2x16float(e: u32) -> vec2<f32>

This PR adds the GLSL-style functions to TSL

Additional Notes
WGSL supports additional packing functions beyond the ones mentioned in this PR. However, WebGL2 doesn't support them. This PR only adds the TSL functions that can be directly turned into an intrinsic in both.

@github-actions
Copy link

github-actions bot commented Nov 21, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 356.88
86.59
356.88
86.59
+0 B
+0 B
WebGPU 618.77
173.73
620.5
174.16
+1.73 kB
+431 B
WebGPU Nodes 617.38
173.48
619.11
173.91
+1.73 kB
+427 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 488.61
121.38
488.61
121.38
+0 B
+0 B
WebGPU 690.82
189.58
691.58
189.81
+762 B
+229 B
WebGPU Nodes 632.26
172.76
633.02
172.99
+762 B
+231 B

@sunag sunag added this to the r182 milestone Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TSL Support for data packing / unpacking functions

2 participants