WebGPU fallback texture load failure

The code to reproduce the bug is very simple.

Here’s a reproduction: Babylon.js Playground (babylonjs.com)

new BABYLON.Texture("asdf", scene, {
    format: BABYLON.Constants.TEXTUREFORMAT_RGB,
    onError: (message, exception) => {
        console.log(message, exception);
    }
});

In fact, it’s a bit ambiguous to even call it a bug.

Let me explain.

  1. attempting to load a texture from the invalid texture url “asdf”.
  2. the texture load fails and attempts to load a fallback texture.
  3. TEXTUREFORMAT_RGB is a format not supported by WebGPU, try to load fallback texture using it.
  4. fallback texture loading fails.

You might think that this is not a bug and that this is the intended behavior. However, what actually happened is different from the logged text.

see:
image

I think it should force the texture format to be compatible when loading fallback textures, or at least log that the fallback texture is not being loaded.

@sebavan - we should probably provide RGBA-fallback texture?

I’m not sure…

It could be problematic if the user asks for RGB and gets a RGBA silently in return. I don’t think the fallback mechanism should alter the format of the texture. RGB is simply not supported in WebGPU, so the user should explicitely deal with it.

Sorry, just noticed the explicit request for the texture format. Got it - makes sense

Then I think the fallback texture shouldn’t be attempted either, as it is a guaranteed failure to load the fallback texture when the texture format is RGB.

We need a mechanism to handle cases where the fallback texture fails to load, or to pre-check if the fallback texture is in a condition that would cause it to fail to load.