Skip to content

Commit

Permalink
[node] populate subgroup sizes for device.adapterInfo
Browse files Browse the repository at this point in the history
Also, always populate subgroup sizes in adapter info.
Rely on backends always supplying a value.

Bug: 354751907
Change-Id: I628a87aea57982ed5a903e4b9697c74493cedcc8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218294
Auto-Submit: David Neto <[email protected]>
Reviewed-by: Alan Baker <[email protected]>
Commit-Queue: Alan Baker <[email protected]>
  • Loading branch information
dneto0 authored and Dawn LUCI CQ committed Dec 5, 2024
1 parent 38268c8 commit cf0329c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
6 changes: 1 addition & 5 deletions src/dawn/node/binding/GPUAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ interop::Interface<interop::GPUSupportedLimits> GPUAdapter::getLimits(Napi::Env
interop::Interface<interop::GPUAdapterInfo> GPUAdapter::getInfo(Napi::Env env) {
wgpu::AdapterInfo info = {};
wgpu::AdapterPropertiesSubgroups subgroupProperties = {};

wgpu::Adapter wgpuAdapter = adapter_.Get();
if (wgpuAdapter.HasFeature(FeatureName::Subgroups)) {
info.nextInChain = &subgroupProperties;
}
info.nextInChain = &subgroupProperties;

adapter_.GetInfo(&info);

Expand Down
12 changes: 3 additions & 9 deletions src/dawn/node/binding/GPUAdapterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GPUAdapterInfo::GPUAdapterInfo(const wgpu::AdapterInfo& info)
if (chain->sType == wgpu::SType::AdapterPropertiesSubgroups) {
subgroup_properties_ = *static_cast<wgpu::AdapterPropertiesSubgroups*>(chain);
// Clear to prevent using invalid pointer.
subgroup_properties_->nextInChain = nullptr;
subgroup_properties_.nextInChain = nullptr;
break;
}
}
Expand All @@ -68,17 +68,11 @@ std::string GPUAdapterInfo::getDescription(Napi::Env) {
}

std::variant<uint32_t, interop::UndefinedType> GPUAdapterInfo::getSubgroupMinSize(Napi::Env) {
if (subgroup_properties_.has_value()) {
return subgroup_properties_->subgroupMinSize;
}
return interop::Undefined;
return subgroup_properties_.subgroupMinSize;
}

std::variant<uint32_t, interop::UndefinedType> GPUAdapterInfo::getSubgroupMaxSize(Napi::Env) {
if (subgroup_properties_.has_value()) {
return subgroup_properties_->subgroupMaxSize;
}
return interop::Undefined;
return subgroup_properties_.subgroupMaxSize;
}

} // namespace wgpu::binding
2 changes: 1 addition & 1 deletion src/dawn/node/binding/GPUAdapterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class GPUAdapterInfo final : public interop::GPUAdapterInfo {
std::string architecture_;
std::string device_;
std::string description_;
std::optional<wgpu::AdapterPropertiesSubgroups> subgroup_properties_;
wgpu::AdapterPropertiesSubgroups subgroup_properties_;
};

} // namespace wgpu::binding
Expand Down
2 changes: 2 additions & 0 deletions src/dawn/node/binding/GPUDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ interop::Interface<interop::GPUSupportedLimits> GPUDevice::getLimits(Napi::Env e

interop::Interface<interop::GPUAdapterInfo> GPUDevice::getAdapterInfo(Napi::Env env) {
wgpu::AdapterInfo adapterInfo = {};
wgpu::AdapterPropertiesSubgroups subgroupsProperties = {};
adapterInfo.nextInChain = &subgroupsProperties;
device_.GetAdapterInfo(&adapterInfo);

return interop::GPUAdapterInfo::Create<GPUAdapterInfo>(env, adapterInfo);
Expand Down

0 comments on commit cf0329c

Please sign in to comment.