Skip to content

Commit

Permalink
If float filtering is not supported, then it falls back to using unfi…
Browse files Browse the repository at this point in the history
…lterable settings. (#18411)
  • Loading branch information
GengineJS authored Mar 5, 2025
1 parent dcdf54d commit 72a8216
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cocos/gfx/webgpu/webgpu-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import {
IWebGPUGPUShaderStage,
} from './webgpu-gpu-objects';
import { error, log, warn } from '../../core';
import { WebGPUDeviceManager } from './define';

const WebGPUAdressMode: GPUAddressMode[] = [
'repeat', // WRAP,
Expand Down Expand Up @@ -1402,8 +1403,10 @@ export function createBindGroupLayoutEntry (currBind: DescriptorSetLayoutBinding
visibility: gpuVisibility,
};
entrys.push(entry);
const device = WebGPUDeviceManager.instance;
let entrySampler: GPUBindGroupLayoutEntry | null = null;
const samplerType = GFXSampleTypeToGPUTextureSampleType[currBind.sampleType];
let samplerType = GFXSampleTypeToGPUTextureSampleType[currBind.sampleType];
if (samplerType === 'float' && !device.FloatFilterable) { samplerType = 'unfilterable-float'; }
const isTexUnFilter = samplerType === 'unfilterable-float';
const viewDimension = GFXViewDimensionToGPUViewDimension[currBind.viewDimension];
const type = currBind.descriptorType;
Expand Down
3 changes: 2 additions & 1 deletion cocos/gfx/webgpu/webgpu-descriptor-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export class WebGPUDescriptorSet extends DescriptorSet {
const currTexture = (this._textures[bind.binding] || device.defaultResource.texture) as WebGPUTexture;
const levelCount = currTexture.levelCount;
const texFormat = currTexture.format;
const isUnFilter = FormatToWGPUFormatType(texFormat) === 'unfilterable-float';
const isUnFilter = FormatToWGPUFormatType(texFormat) === 'unfilterable-float'
|| (FormatToWGPUFormatType(texFormat) === 'float' && !device.FloatFilterable);
if (isUnFilter) {
sampler.gpuSampler.minFilter = Filter.POINT;
sampler.gpuSampler.magFilter = Filter.POINT;
Expand Down
4 changes: 4 additions & 0 deletions cocos/gfx/webgpu/webgpu-device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ export class WebGPUDevice extends Device {
defaultResource.descSet.update();
}

get FloatFilterable (): boolean {
return this._adapter!.features.has('float32-filterable');
}

private async initDevice (info: Readonly<DeviceInfo>): Promise<boolean> {
const gpu = navigator.gpu;
this._adapter = await gpu?.requestAdapter();
Expand Down

0 comments on commit 72a8216

Please sign in to comment.