Add Toggle to disable sampler compare function on Metal.

This Toggle is set if MTLFeatureSet_iOS_GPUFamily3_v1 is not supported.

Bug: dawn:342
Change-Id: Ia5f43e87fdd2c13eaffe9557cb0ce9a06dec3b29
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16180
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Austin Eng 2020-02-26 08:06:00 +00:00 committed by Commit Bot service account
parent 227568451b
commit 2f0f850da8
4 changed files with 15 additions and 7 deletions

View File

@ -102,6 +102,10 @@ namespace dawn_native {
"backend will use D32S8 (toggle to on) but setting the toggle to off will make it"
"use the D24S8 format when possible.",
"https://crbug.com/dawn/286"}},
{Toggle::MetalDisableSamplerCompare,
{"metal_disable_sampler_compare",
"Disables the use of sampler compare on Metal. This is unsupported before A9 "
"processors."}},
}};
} // anonymous namespace

View File

@ -36,6 +36,7 @@ namespace dawn_native {
UseSpvc,
UseSpvcParser,
VulkanUseD32S8,
MetalDisableSamplerCompare,
EnumCount,
InvalidEnum = EnumCount,

View File

@ -69,6 +69,13 @@ namespace dawn_native { namespace metal {
#endif
// On tvOS, we would need MTLFeatureSet_tvOS_GPUFamily2_v1.
SetToggle(Toggle::EmulateStoreAndMSAAResolve, !haveStoreAndMSAAResolve);
bool haveSamplerCompare = true;
#if defined(DAWN_PLATFORM_IOS)
haveSamplerCompare = [mMtlDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1];
#endif
// TODO(crbug.com/dawn/342): Investigate emulation -- possibly expensive.
SetToggle(Toggle::MetalDisableSamplerCompare, !haveSamplerCompare);
}
// TODO(jiawei.shao@intel.com): tighten this workaround when the driver bug is fixed.

View File

@ -52,15 +52,11 @@ namespace dawn_native { namespace metal {
// static
ResultOrError<Sampler*> Sampler::Create(Device* device, const SamplerDescriptor* descriptor) {
#if defined(DAWN_PLATFORM_IOS)
if (descriptor->compare != wgpu::CompareFunction::Never &&
![device->GetMTLDevice() supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily3_v1]) {
// Unsupported before A9.
// TODO(b/149025333): Investigate emulation -- possibly expensive.
return DAWN_VALIDATION_ERROR(
"Sampler compare function requires at least iOS GPU family 3, version 1");
device->IsToggleEnabled(Toggle::MetalDisableSamplerCompare)) {
return DAWN_VALIDATION_ERROR("Sampler compare function not supported.");
}
#endif
return new Sampler(device, descriptor);
}