Skip to content

Commit

Permalink
dawn/node: Add support for dual source blending feature
Browse files Browse the repository at this point in the history
Bug: 341973423
Change-Id: I4c4204f12f23911b8f32346df16767930eb9bb9d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/203515
Reviewed-by: Corentin Wallez <[email protected]>
Commit-Queue: Fr <[email protected]>
  • Loading branch information
beaufortfrancois authored and Dawn LUCI CQ committed Aug 23, 2024
1 parent 704ba48 commit 5d1dde5
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions src/dawn/node/binding/Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ bool Converter::Convert(wgpu::BlendComponent& out, const interop::GPUBlendCompon

bool Converter::Convert(wgpu::BlendFactor& out, const interop::GPUBlendFactor& in) {
out = wgpu::BlendFactor::Zero;
wgpu::FeatureName requiredFeature = wgpu::FeatureName(0u);
switch (in) {
case interop::GPUBlendFactor::kZero:
out = wgpu::BlendFactor::Zero;
Expand Down Expand Up @@ -841,10 +842,37 @@ bool Converter::Convert(wgpu::BlendFactor& out, const interop::GPUBlendFactor& i
case interop::GPUBlendFactor::kOneMinusConstant:
out = wgpu::BlendFactor::OneMinusConstant;
return true;
default:
case interop::GPUBlendFactor::kSrc1:
out = wgpu::BlendFactor::Src1;
requiredFeature = wgpu::FeatureName::DualSourceBlending;
return true;
case interop::GPUBlendFactor::kOneMinusSrc1:
out = wgpu::BlendFactor::OneMinusSrc1;
requiredFeature = wgpu::FeatureName::DualSourceBlending;
return true;
case interop::GPUBlendFactor::kSrc1Alpha:
out = wgpu::BlendFactor::Src1Alpha;
requiredFeature = wgpu::FeatureName::DualSourceBlending;
return true;
case interop::GPUBlendFactor::kOneMinusSrc1Alpha:
out = wgpu::BlendFactor::OneMinusSrc1Alpha;
requiredFeature = wgpu::FeatureName::DualSourceBlending;
break;

default:
std::stringstream err;
err << "unknown GPUBlendFactor(" << static_cast<int>(in) << ")";
return Throw(err.str());
}
return Throw("invalid value for GPUBlendFactor");

assert(requiredFeature != wgpu::FeatureName(0u));
if (!HasFeature(requiredFeature)) {
std::stringstream err;
err << "" << out << " requires feature '" << requiredFeature << "'";
return Throw(Napi::TypeError::New(env, err.str()));
}

return true;
}

bool Converter::Convert(wgpu::BlendOperation& out, const interop::GPUBlendOperation& in) {
Expand Down Expand Up @@ -1462,6 +1490,9 @@ bool Converter::Convert(wgpu::FeatureName& out, interop::GPUFeatureName in) {
case interop::GPUFeatureName::kMultiDrawIndirect:
out = wgpu::FeatureName::MultiDrawIndirect;
return true;
case interop::GPUFeatureName::kDualSourceBlending:
out = wgpu::FeatureName::DualSourceBlending;
return true;
case interop::GPUFeatureName::kChromiumExperimentalSubgroups:
out = wgpu::FeatureName::ChromiumExperimentalSubgroups;
return true;
Expand All @@ -1470,7 +1501,6 @@ bool Converter::Convert(wgpu::FeatureName& out, interop::GPUFeatureName in) {
return true;
case interop::GPUFeatureName::kTextureCompressionBcSliced3D:
case interop::GPUFeatureName::kClipDistances:
case interop::GPUFeatureName::kDualSourceBlending:
return false;
}
return false;
Expand Down Expand Up @@ -1500,6 +1530,7 @@ bool Converter::Convert(interop::GPUFeatureName& out, wgpu::FeatureName in) {
CASE(Subgroups, kSubgroups);
CASE(SubgroupsF16, kSubgroupsF16);
CASE(MultiDrawIndirect, kMultiDrawIndirect);
CASE(DualSourceBlending, kDualSourceBlending);

#undef CASE

Expand All @@ -1514,7 +1545,6 @@ bool Converter::Convert(interop::GPUFeatureName& out, wgpu::FeatureName in) {
case wgpu::FeatureName::DawnMultiPlanarFormats:
case wgpu::FeatureName::DawnNative:
case wgpu::FeatureName::DrmFormatCapabilities:
case wgpu::FeatureName::DualSourceBlending:
case wgpu::FeatureName::FormatCapabilities:
case wgpu::FeatureName::FramebufferFetch:
case wgpu::FeatureName::HostMappedPointer:
Expand Down

0 comments on commit 5d1dde5

Please sign in to comment.