Skip to content

Fix volume rendering texture 3d sample #506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2025

Conversation

greggman
Copy link
Collaborator

@greggman greggman commented Apr 19, 2025

The files were changed from .bin-gz to .bin.gz and then left
to the browser to decompress. But, that only happened to work
because the local dev server served .gz files with
content-encoding: gzip headers. Github doesn't do this.

Revert to using .bin-gz and manually decompressing with
DecompressionStream. .bin-gz seems better then .gz because
many servers are configured to treat files that end in .gz specially.

@mehmetoguzderin
Copy link
Contributor

Just for background, when initially contributing the sample, I went with gz to also demonstrate how compression formats interact with archival compression such as gzip or brotli, and also out of concern for git repo size (hence use of bin-gz as extension to explicitly control when things decompress). However either way should be fine

Copy link
Collaborator

@beaufortfrancois beaufortfrancois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The public/assets/img/volume/t1_icbm_normal_1mm_pn0_rf0.py file would also be need to be updated right as it generates a gzip file. See gzip_filename in af6432c

@greggman greggman force-pushed the fix-volume-sample branch from a20b507 to a7fbc25 Compare April 19, 2025 05:35
@greggman
Copy link
Collaborator Author

updated

The files were changed from `.bin-gz` to `.gz` and then left
to the browser to decompress. But that only happened to work
because the local dev server served `.gz` files with
`content-encoding: gzip` headers. Github didn't do this.

Revert to using `.bin-gz` and manually decompressing with
`DecompressionStream`
@greggman greggman force-pushed the fix-volume-sample branch from a7fbc25 to 99fdbe4 Compare April 19, 2025 05:41
@@ -158,11 +158,20 @@ async function createVolumeTexture(format: GPUTextureFormat) {
});

const response = await fetch(dataPath);
const buffer = await response.arrayBuffer();

const compressedBlob = await response.blob();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why blob?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because theoretically it uses less memory? The browser can stream the blob through the decompressor. It can't stream the arrayBuffer as it's required to have loaded the entire thing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha! Thanks!

@beaufortfrancois beaufortfrancois merged commit 719ac60 into webgpu:main Apr 19, 2025
1 check passed
@greggman greggman deleted the fix-volume-sample branch April 19, 2025 06:13
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.

3 participants