supportsTextureFormat method

  1. @override
bool supportsTextureFormat(
  1. TextureFormat format
)

Whether WebGPU has a name for format and this device was granted the feature it needs.

Two questions, and the second is asked of the device rather than of a table. A spelling is not permission: bc7-rgba-unorm is a name the specification defines and a device that did not request texture-compression-bc refuses it at allocation and at sampling alike. create asks the adapter which of the three families it carries and requests exactly those, so what came back is what this reads — gpuDevice.features, not the list of wants. A device may be granted less than it asked for, and a capability answering from a wish is how a loader is told to upload a texture the browser will not take.

Three formats stay false whatever any adapter carries — TextureFormat.a8UNormInt and the two HDR ASTC layouts — because WebGPU has no spelling for them at all. See gpuTextureFormat, which is where that is written down.

Implementation

@override
bool supportsTextureFormat(TextureFormat format) {
  if (gpuTextureFormat(format) == null) return false;
  final feature = gpuTextureFormatFeature(format);
  return feature == null || gpuDevice.features.has(feature);
}