Skip to content
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

Cannot read to / write from Depth16Unorm texture on WebGL backend #3537

Open
teh-cmc opened this issue Feb 28, 2023 · 2 comments
Open

Cannot read to / write from Depth16Unorm texture on WebGL backend #3537

teh-cmc opened this issue Feb 28, 2023 · 2 comments
Labels
api: gles Issues with GLES or WebGL type: bug Something isn't working

Comments

@teh-cmc
Copy link

teh-cmc commented Feb 28, 2023

Description

I have a program that creates and fills Depth16Unorm depth textures on the CPU, then reads that data (textureLoad) in a shader to render point clouds.

@group(1) @binding(1)
var depth_texture: texture_2d<f32>;

let norm_linear_depth = textureLoad(depth_texture, texcoords, 0).x;

On native, this works without issue, as the spec suggests.

When using the WebGL backend, on the other hand, my shader just... doesn't work. I cannot see any relevant logs in the browser console, and trying to enforce a fragment color output does nothing, so I assume the shader crashes right at the textureLoad.

Converting my u16 data to f32 on the CPU and then uploading that into a R32Float texture fixes the issue, no other changes required.

Repro steps

Using the WebGL backend:

  1. Create a Depth16Unorm texture
  2. Fill it with arbitrary data
  3. Read from it in a shader

Expected vs observed behavior

Writing to and reading from a Depth16Unorm should work on both native and web, as the spec suggests.

Platform

  • wgpu 0.15
  • Linux (Arch), also reproduced on macOS
  • Latest Firefox & Chromium
@teoxoy
Copy link
Member

teoxoy commented Feb 28, 2023

Looking at the spec (https://registry.khronos.org/webgl/specs/latest/2.0) it seems only those depth/stencil formats are supported:

  • Depth32Float
  • Depth32FloatStencil8
  • Depth24Plus
  • Depth24PlusStencil8

There are a few other open issues related to GLES texture format support.
The backend doesn't advertise support for DownlevelFlags::WEBGPU_TEXTURE_FORMAT_SUPPORT and as far as I know nobody researched what the gap is between the WebGPU spec, WebGL and GLES (since even between these 2 there seem to be differences).

@teoxoy teoxoy added type: bug Something isn't working api: gles Issues with GLES or WebGL labels Feb 28, 2023
@cwfitzgerald
Copy link
Member

We should have built up texture flag support independently of the spec building off the gles specs. When WEBGPU_TEXTURE_FORMAT_SUPPORT is disabled, we should defer to the backends texture flags for our checks, but that obviously isn't happening here for some reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: gles Issues with GLES or WebGL type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants