Skip to content

Commit

Permalink
fix: enable filterable float32 feature in WebGPU #160
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoiver committed Jan 19, 2024
1 parent 5c06618 commit fab40d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
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 fab40d0

Please sign in to comment.