From f02e9438fcd3d30cff68a0877dec207b3f3b4957 Mon Sep 17 00:00:00 2001 From: GengineJS <476393671@qq.com> Date: Thu, 13 Mar 2025 17:50:46 +0800 Subject: [PATCH] Fix the issue of inconsistent attachment sizes (#18455) * Fix the issue of inconsistent attachment sizes * Update --- cocos/gfx/webgpu/webgpu-command-buffer.ts | 3 ++- cocos/gfx/webgpu/webgpu-commands.ts | 2 +- cocos/gfx/webgpu/webgpu-descriptor-set.ts | 2 +- cocos/gfx/webgpu/webgpu-device.ts | 2 +- cocos/gfx/webgpu/webgpu-pipeline-state.ts | 6 +++--- cocos/gfx/webgpu/webgpu-render-pass.ts | 3 +-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cocos/gfx/webgpu/webgpu-command-buffer.ts b/cocos/gfx/webgpu/webgpu-command-buffer.ts index 8cbfddd9d0..20bdda35f0 100644 --- a/cocos/gfx/webgpu/webgpu-command-buffer.ts +++ b/cocos/gfx/webgpu/webgpu-command-buffer.ts @@ -39,6 +39,7 @@ import { Filter, TextureBlit, DescriptorSetInfo, + Format, } from '../base/define'; import { Framebuffer } from '../base/framebuffer'; import { InputAssembler } from '../base/input-assembler'; @@ -232,7 +233,7 @@ export class WebGPUCommandBuffer extends CommandBuffer { this._nativePassDesc.colorAttachments[i].clearValue = [clearColors[i].x, clearColors[i].y, clearColors[i].z, clearColors[i].w]; } - if (this._wgpuRenderPass.depthStencilAttachment) { + if (this._wgpuRenderPass.depthStencilAttachment?.format !== Format.UNKNOWN) { const tex = gpuFramebuffer.gpuDepthStencilTexture?.gpuTexture; const depthTex = tex ? tex.createView() : swapchain.gpuDepthStencilTextureView; const depthStencilAttachment = this._nativePassDesc.depthStencilAttachment!; diff --git a/cocos/gfx/webgpu/webgpu-commands.ts b/cocos/gfx/webgpu/webgpu-commands.ts index 12a0a7111b..8d9771599b 100644 --- a/cocos/gfx/webgpu/webgpu-commands.ts +++ b/cocos/gfx/webgpu/webgpu-commands.ts @@ -1406,7 +1406,7 @@ export function createBindGroupLayoutEntry (currBind: DescriptorSetLayoutBinding const device = WebGPUDeviceManager.instance; let entrySampler: GPUBindGroupLayoutEntry | null = null; let samplerType = GFXSampleTypeToGPUTextureSampleType[currBind.sampleType]; - if (samplerType === 'float' && !device.FloatFilterable) { samplerType = 'unfilterable-float'; } + if (samplerType === 'float' && !device.floatFilterable) { samplerType = 'unfilterable-float'; } const isTexUnFilter = samplerType === 'unfilterable-float'; const viewDimension = GFXViewDimensionToGPUViewDimension[currBind.viewDimension]; const type = currBind.descriptorType; diff --git a/cocos/gfx/webgpu/webgpu-descriptor-set.ts b/cocos/gfx/webgpu/webgpu-descriptor-set.ts index 9d3f644728..050a5ad5a0 100644 --- a/cocos/gfx/webgpu/webgpu-descriptor-set.ts +++ b/cocos/gfx/webgpu/webgpu-descriptor-set.ts @@ -131,7 +131,7 @@ export class WebGPUDescriptorSet extends DescriptorSet { const levelCount = currTexture.levelCount; const texFormat = currTexture.format; const isUnFilter = FormatToWGPUFormatType(texFormat) === 'unfilterable-float' - || (FormatToWGPUFormatType(texFormat) === 'float' && !device.FloatFilterable); + || (FormatToWGPUFormatType(texFormat) === 'float' && !device.floatFilterable); if (isUnFilter) { sampler.gpuSampler.minFilter = Filter.POINT; sampler.gpuSampler.magFilter = Filter.POINT; diff --git a/cocos/gfx/webgpu/webgpu-device.ts b/cocos/gfx/webgpu/webgpu-device.ts index 5dfada7981..de14429c95 100644 --- a/cocos/gfx/webgpu/webgpu-device.ts +++ b/cocos/gfx/webgpu/webgpu-device.ts @@ -477,7 +477,7 @@ export class WebGPUDevice extends Device { defaultResource.descSet.update(); } - get FloatFilterable (): boolean { + get floatFilterable (): boolean { return this._adapter!.features.has('float32-filterable'); } diff --git a/cocos/gfx/webgpu/webgpu-pipeline-state.ts b/cocos/gfx/webgpu/webgpu-pipeline-state.ts index 71625816d2..cdf489f88b 100644 --- a/cocos/gfx/webgpu/webgpu-pipeline-state.ts +++ b/cocos/gfx/webgpu/webgpu-pipeline-state.ts @@ -26,7 +26,7 @@ import { PipelineState, PipelineStateInfo } from '../base/pipeline-state'; import { IWebGPUGPUInputAssembler, IWebGPUGPUPipelineState } from './webgpu-gpu-objects'; import { WebGPURenderPass } from './webgpu-render-pass'; import { WebGPUShader } from './webgpu-shader'; -import { BlendOp, CullMode, DynamicStateFlagBit, FormatInfos, PrimitiveMode, ShaderStageFlagBit } from '../base/define'; +import { BlendOp, CullMode, DynamicStateFlagBit, Format, FormatInfos, PrimitiveMode, ShaderStageFlagBit } from '../base/define'; import { WebGPUPipelineLayout } from './webgpu-pipeline-layout'; import { GFXFormatToWGPUFormat, @@ -148,9 +148,9 @@ export class WebGPUPipelineState extends PipelineState { // depthstencil states let stencilRef = 0; - if (this._renderPass.depthStencilAttachment) { + if (this._renderPass.depthStencilAttachment?.format !== Format.UNKNOWN) { const dssDesc = {} as GPUDepthStencilState; - dssDesc.format = GFXFormatToWGPUFormat(this._renderPass.depthStencilAttachment.format); + dssDesc.format = GFXFormatToWGPUFormat(this._renderPass.depthStencilAttachment!.format); dssDesc.depthWriteEnabled = this._dss.depthWrite; dssDesc.depthCompare = this._dss.depthTest ? WebGPUCompereFunc[this._dss.depthFunc] : 'always'; let stencilReadMask = 0; diff --git a/cocos/gfx/webgpu/webgpu-render-pass.ts b/cocos/gfx/webgpu/webgpu-render-pass.ts index bdf7712474..a373dbe057 100644 --- a/cocos/gfx/webgpu/webgpu-render-pass.ts +++ b/cocos/gfx/webgpu/webgpu-render-pass.ts @@ -69,8 +69,7 @@ export class WebGPURenderPass extends RenderPass { colorAttachments: originalColorDesc, }; - if (info.depthStencilAttachment) { - if (info.depthStencilAttachment.format === Format.UNKNOWN) info.depthStencilAttachment.format = Format.DEPTH_STENCIL; + if (info.depthStencilAttachment.format !== Format.UNKNOWN) { const depthStencilDescriptor = this._generateDSAttachment(info.depthStencilAttachment); const originalDepthStencilDesc = this._generateDSAttachment(info.depthStencilAttachment); renderPassDesc.depthStencilAttachment = depthStencilDescriptor;