Skip to content

Commit

Permalink
Fix 160 (#161)
Browse files Browse the repository at this point in the history
* fix: enable filterable float32 feature in WebGPU #160

* chore: commit changeset
  • Loading branch information
xiaoiver authored Jan 19, 2024
1 parent 5c06618 commit 5c86bba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-ants-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@antv/g-device-api': patch
---

Enable filterable float32 feature in WebGPU.
1 change: 1 addition & 0 deletions src/api/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ export interface SamplerBinding {

export enum SamplerFormatKind {
Float,
UnfilterableFloat,
Uint,
Sint,
Depth,
Expand Down
1 change: 1 addition & 0 deletions src/webgpu/WebGPUDeviceContribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
7 changes: 7 additions & 0 deletions src/webgpu/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit 5c86bba

Please sign in to comment.