-
Notifications
You must be signed in to change notification settings - Fork 345
Description
Originally raised in #4746 (comment)
Should specifying a viewFormat that has no compatible usage defined on the texture trigger a validation error at texture creation time?
Example:
const t = device.createTexture({
size: { width: 64, height: 64 },
format: 'rgba8unorm',
viewFormats: [ 'rgba8unorm-srgb' ],
usage: GPUTextureUsage.STORAGE,
});If we implemented this validation, the above would trigger an error because rgba8unorm-srgb cannot be used with STORAGE usage, which in turn means that you can't create a valid view with that format from this texture. If the texture was instead created with STORAGE | RENDER_ATTACHMENT usage it would not fail validation at texture creation time because even though STORAGE is still invalid to use with rgba8unorm-srgb you could still create a valid view with just the RENDER_ATTACHMENT usage.
It is worth noting that the validation proposed in #4426 and added in #4746 already ensures that views must be created with compatible formats and usages, so even without this validation there's no way to create invalid texture views. This instead would be an earlier error to help developers identify potential problems or performance pitfalls in their code.
Alternatively, browsers could be encouraged to surface warnings in this situation rather than surfacing it as an error, since the createTexture() call itself can succeed in this case and it's only later potential createView() calls using the viewFormat that would fail.