fix(wgpu): correct swapped maxComputeWorkGroupSize/Count capabilities (#327)

Co-authored-by: vanitynie <vanitynie@qq.com>
This commit is contained in:
Ming
2026-09-07 19:00:55 +08:00
committed by GitHub
parent a5090e5ae4
commit df98a99bb6
2 changed files with 21 additions and 5 deletions
+17 -1
View File
@@ -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;
@@ -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
}