diff --git a/.changeset/gorgeous-ants-joke.md b/.changeset/gorgeous-ants-joke.md new file mode 100644 index 0000000..624aca7 --- /dev/null +++ b/.changeset/gorgeous-ants-joke.md @@ -0,0 +1,5 @@ +--- +'@antv/g-device-api': patch +--- + +Enable filterable float32 feature in WebGPU. diff --git a/src/api/interfaces.ts b/src/api/interfaces.ts index 406d74c..0069900 100644 --- a/src/api/interfaces.ts +++ b/src/api/interfaces.ts @@ -482,6 +482,7 @@ export interface SamplerBinding { export enum SamplerFormatKind { Float, + UnfilterableFloat, Uint, Sint, Depth, diff --git a/src/webgpu/WebGPUDeviceContribution.ts b/src/webgpu/WebGPUDeviceContribution.ts index b5a3d26..925045e 100644 --- a/src/webgpu/WebGPUDeviceContribution.ts +++ b/src/webgpu/WebGPUDeviceContribution.ts @@ -36,6 +36,7 @@ export class WebGPUDeviceContribution implements DeviceContribution { // 'depth24unorm-stencil8', 'depth32float-stencil8', 'texture-compression-bc', + 'float32-filterable', ]; const requiredFeatures = optionalFeatures.filter((feature) => adapter.features.has(feature), diff --git a/src/webgpu/utils.ts b/src/webgpu/utils.ts index 083bf24..ec09fcd 100644 --- a/src/webgpu/utils.ts +++ b/src/webgpu/utils.ts @@ -176,9 +176,16 @@ export function translateMipFilter( else throw new Error('whoops'); } +/** + * @see https://www.w3.org/TR/webgpu/#enumdef-gputexturesampletype + */ function translateSampleType(type: SamplerFormatKind): GPUTextureSampleType { if (type === SamplerFormatKind.Float) return 'float'; + else if (type === SamplerFormatKind.UnfilterableFloat) + return 'unfilterable-float'; else if (type === SamplerFormatKind.Depth) return 'depth'; + else if (type === SamplerFormatKind.Sint) return 'sint'; + else if (type === SamplerFormatKind.Uint) return 'uint'; else throw new Error('whoops'); }