From df98a99bb6b45322dfd8d838a73281ca5a9f29d0 Mon Sep 17 00:00:00 2001 From: Ming <55941109+VanityNie@users.noreply.github.com> Date: Mon, 7 Sep 2026 19:00:55 +0800 Subject: [PATCH] fix(wgpu): correct swapped maxComputeWorkGroupSize/Count capabilities (#327) Co-authored-by: vanitynie --- cocos/gfx/webgpu/webgpu-device.ts | 18 +++++++++++++++++- native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp | 8 ++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/cocos/gfx/webgpu/webgpu-device.ts b/cocos/gfx/webgpu/webgpu-device.ts index 032778d656..b2b6cf68ec 100644 --- a/cocos/gfx/webgpu/webgpu-device.ts +++ b/cocos/gfx/webgpu/webgpu-device.ts @@ -53,7 +53,7 @@ import { WebGPUTexture } from './webgpu-texture'; import { DefaultResources, hashCombineNum, hashCombineStr, webGPU, WebGPUDeviceManager } from './define'; import { Filter, Format, - QueueType, Feature, BufferTextureCopy, Rect, DescriptorSetInfo, + QueueType, Feature, BufferTextureCopy, Rect, Size, DescriptorSetInfo, BufferInfo, BufferViewInfo, CommandBufferInfo, DeviceInfo, FramebufferInfo, InputAssemblerInfo, QueueInfo, RenderPassInfo, SamplerInfo, ShaderInfo, PipelineLayoutInfo, DescriptorSetLayoutInfo, TextureInfo, TextureViewInfo, GeneralBarrierInfo, TextureBarrierInfo, @@ -552,6 +552,22 @@ export class WebGPUDevice extends Device { this._caps.max3DTextureSize = limits.maxTextureDimension3D; this._caps.uboOffsetAlignment = limits.minUniformBufferOffsetAlignment; + // Compute limits are read from the device (not the adapter): no elevated + // compute limits are requested, so these are the values validation enforces. + const deviceLimits = device.limits; + this._caps.maxComputeSharedMemorySize = deviceLimits.maxComputeWorkgroupStorageSize; + this._caps.maxComputeWorkGroupInvocations = deviceLimits.maxComputeInvocationsPerWorkgroup; + this._caps.maxComputeWorkGroupSize = new Size( + deviceLimits.maxComputeWorkgroupSizeX, + deviceLimits.maxComputeWorkgroupSizeY, + deviceLimits.maxComputeWorkgroupSizeZ, + ); + this._caps.maxComputeWorkGroupCount = new Size( + deviceLimits.maxComputeWorkgroupsPerDimension, + deviceLimits.maxComputeWorkgroupsPerDimension, + deviceLimits.maxComputeWorkgroupsPerDimension, + ); + const features = this._adapter!.features; // FIXME: require by query this._multiDrawIndirect = false; diff --git a/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp b/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp index 314cbb349c..fb140d7dc2 100644 --- a/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp +++ b/native/cocos/renderer/gfx-wgpu/WGPUDevice.cpp @@ -99,8 +99,8 @@ CCWGPUDevice::CCWGPUDevice() : Device() { _caps.maxComputeSharedMemorySize = 32768; _caps.maxComputeWorkGroupInvocations = 256; - _caps.maxComputeWorkGroupSize = {65535, 65535, 65535}; - _caps.maxComputeWorkGroupCount = {256, 256, 64}; + _caps.maxComputeWorkGroupSize = {256, 256, 64}; + _caps.maxComputeWorkGroupCount = {65535, 65535, 65535}; instance = this; } @@ -582,8 +582,8 @@ void CCWGPUDevice::initLimits() { _caps.maxComputeSharedMemorySize = limits.maxComputeWorkgroupStorageSize; _caps.maxComputeWorkGroupInvocations = limits.maxComputeInvocationsPerWorkgroup; - _caps.maxComputeWorkGroupSize = {limits.maxComputeWorkgroupsPerDimension, limits.maxComputeWorkgroupsPerDimension, limits.maxComputeWorkgroupsPerDimension}; - _caps.maxComputeWorkGroupCount = {limits.maxComputeWorkgroupSizeX, limits.maxComputeWorkgroupSizeY, limits.maxComputeWorkgroupSizeZ}; + _caps.maxComputeWorkGroupSize = {limits.maxComputeWorkgroupSizeX, limits.maxComputeWorkgroupSizeY, limits.maxComputeWorkgroupSizeZ}; + _caps.maxComputeWorkGroupCount = {limits.maxComputeWorkgroupsPerDimension, limits.maxComputeWorkgroupsPerDimension, limits.maxComputeWorkgroupsPerDimension}; #endif }