diff --git a/src/dawn/native/Toggles.cpp b/src/dawn/native/Toggles.cpp index 21427db473..8f22684f55 100644 --- a/src/dawn/native/Toggles.cpp +++ b/src/dawn/native/Toggles.cpp @@ -332,6 +332,12 @@ static constexpr ToggleEnumAndInfoList kToggleNameAndInfoList = {{ "This toggle is off by default. It is expected to turn on or get removed when WebGPU V1 " "ships and stays stable.", "https://crbug.com/dawn/1563"}}, + {Toggle::NoWorkaroundSampleMaskBecomesZeroForAllButLastColorTarget, + {"no_workaround_sample_mask_becomes_zero_for_all_but_last_color_target", + "MacOS 12.0+ Intel has a bug where the sample mask is only applied for the last color " + "target. If there are multiple color targets, all but the last one will use a sample mask " + "of zero.", + "https://crbug.com/dawn/1462"}} // Comment to separate the }} so it is clearer what to copy-paste to add a toggle. }}; } // anonymous namespace diff --git a/src/dawn/native/Toggles.h b/src/dawn/native/Toggles.h index 4f97b7138c..4774a6f625 100644 --- a/src/dawn/native/Toggles.h +++ b/src/dawn/native/Toggles.h @@ -84,6 +84,9 @@ enum class Toggle { D3D12Allocate2DTexturewithCopyDstAsCommittedResource, DisallowDeprecatedAPIs, + // Unresolved issues. + NoWorkaroundSampleMaskBecomesZeroForAllButLastColorTarget, + EnumCount, InvalidEnum = EnumCount, }; diff --git a/src/dawn/native/metal/DeviceMTL.mm b/src/dawn/native/metal/DeviceMTL.mm index 71d7d5405b..12dfda21c9 100644 --- a/src/dawn/native/metal/DeviceMTL.mm +++ b/src/dawn/native/metal/DeviceMTL.mm @@ -257,6 +257,15 @@ void Device::InitTogglesFromDriver() { if (@available(macos 11.0, iOS 14.0, *)) { SetToggle(Toggle::MetalUseMockBlitEncoderForWriteTimestamp, true); } + +#if DAWN_PLATFORM_IS(MACOS) + if (gpu_info::IsIntel(vendorId)) { + if ([NSProcessInfo.processInfo + isOperatingSystemAtLeastVersion:NSOperatingSystemVersion{12, 0, 0}]) { + ForceSetToggle(Toggle::NoWorkaroundSampleMaskBecomesZeroForAllButLastColorTarget, true); + } + } +#endif } ResultOrError> Device::CreateBindGroupImpl( diff --git a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp index 88bb571b8f..ea7a28def2 100644 --- a/src/dawn/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/dawn/tests/end2end/MultisampledRenderingTests.cpp @@ -643,9 +643,6 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithEmptyFinalSampleMask) // Test doing MSAA resolve into multiple resolve targets works correctly with a non-default sample // mask. TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithSampleMask) { - // TODO(crbug.com/dawn/1462): Re-enable on Mac Intel 12.4. - DAWN_SUPPRESS_TEST_IF(IsMetal() && IsIntel() && (IsMacOS(12, 4) || IsMacOS(12, 5))); - // TODO(dawn:1550) Fails on ARM-based Android devices. DAWN_SUPPRESS_TEST_IF(IsAndroid() && IsARM()); @@ -682,7 +679,13 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithSampleMas wgpu::CommandBuffer commandBuffer = commandEncoder.Finish(); queue.Submit(1, &commandBuffer); - VerifyResolveTarget(kRed, mResolveTexture, 0, 0, kMSAACoverage); + // TODO(crbug.com/dawn/1462): Work around that a sample mask of zero is used for all + // color targets except the last one. + VerifyResolveTarget( + HasToggleEnabled("no_workaround_sample_mask_becomes_zero_for_all_but_last_color_target") + ? wgpu::Color{} + : kRed, + mResolveTexture, 0, 0, kMSAACoverage); VerifyResolveTarget(kGreen, resolveTexture2, 0, 0, kMSAACoverage); } @@ -812,9 +815,6 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOut // supported on some platforms. DAWN_TEST_UNSUPPORTED_IF(HasToggleEnabled("disable_sample_variables")); - // TODO(crbug.com/dawn/1462): Re-enable on Mac Intel 12.4. - DAWN_SUPPRESS_TEST_IF(IsMetal() && IsIntel() && (IsMacOS(12, 4) || IsMacOS(12, 5))); - wgpu::TextureView multisampledColorView2 = CreateTextureForRenderAttachment(kColorFormat, kSampleCount).CreateView(); wgpu::Texture resolveTexture2 = CreateTextureForRenderAttachment(kColorFormat, 1); @@ -866,7 +866,13 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOut wgpu::CommandBuffer commandBuffer = commandEncoder.Finish(); queue.Submit(1, &commandBuffer); - VerifyResolveTarget(kRed, mResolveTexture, 0, 0, kMSAACoverage); + // TODO(crbug.com/dawn/1462): Work around that a sample mask of zero is used for all + // color targets except the last one. + VerifyResolveTarget( + HasToggleEnabled("no_workaround_sample_mask_becomes_zero_for_all_but_last_color_target") + ? wgpu::Color{} + : kRed, + mResolveTexture, 0, 0, kMSAACoverage); VerifyResolveTarget(kGreen, resolveTexture2, 0, 0, kMSAACoverage); }