Re-enable -Wunguarded-availability in Dawn standalone builds
By bumping the min macOS SDK version for standalone Dawn builds we are able to re-introduce -Wunguarded-availability, which will help prevent usage of Metal APIs without correctly checking for their availability. BUG= Change-Id: Iebf2f64e9f68e2a7a90fc6f3f208967f952f3487 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11400 Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
e8e9d5daf5
commit
280b96ea8d
7
.gn
7
.gn
|
@ -16,6 +16,13 @@ buildconfig = "//build/config/BUILDCONFIG.gn"
|
|||
|
||||
default_args = {
|
||||
clang_use_chrome_plugins = false
|
||||
|
||||
# Override the mac version so standalone Dawn compiles with at least 10.11
|
||||
# which allows us to not skip the -Wunguarded-availability warning and get
|
||||
# proper warnings for use of APIs that are 10.12 and above (even if
|
||||
# Chromium is still on 10.10).
|
||||
mac_deployment_target = "10.11.0"
|
||||
mac_min_system_version = "10.11.0"
|
||||
}
|
||||
|
||||
check_targets = [
|
||||
|
|
14
BUILD.gn
14
BUILD.gn
|
@ -31,6 +31,11 @@ if (use_swiftshader) {
|
|||
import("${dawn_swiftshader_dir}/src/Vulkan/vulkan.gni")
|
||||
}
|
||||
|
||||
# Import mac_min_system_version
|
||||
if (is_mac) {
|
||||
import("//build/config/mac/mac_sdk.gni")
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
# dawn_platform
|
||||
###############################################################################
|
||||
|
@ -60,9 +65,14 @@ config("libdawn_native_internal") {
|
|||
# Suppress warnings that Metal isn't in the deployment target of Chrome:
|
||||
# initialization of the Metal backend is behind a IsMetalSupported check so
|
||||
# Dawn won't call Metal functions on macOS 10.10.
|
||||
# At the time this is written Chromium supports 10.10.0 and above, so if we
|
||||
# aren't on 10.11 it means we are on 10.11 and above, and Metal is available.
|
||||
# Skipping this check on 10.11 and above is important as it allows getting
|
||||
# proper compilation warning when using 10.12 and above feature for example.
|
||||
# TODO(cwallez@chromium.org): Consider using API_AVAILABLE annotations on all
|
||||
# metal code in dawn once crbug.com/1004024 is sorted out.
|
||||
if (is_mac) {
|
||||
# metal code in dawn once crbug.com/1004024 is sorted out if Chromium still
|
||||
# supports 10.10 then.
|
||||
if (is_mac && mac_min_system_version == "10.10.0") {
|
||||
cflags_objcc = [ "-Wno-unguarded-availability" ]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,8 @@ namespace dawn_native { namespace metal {
|
|||
//
|
||||
// [device registryID] is the ID for one of the IOGraphicsAccelerator2 and we can see that
|
||||
// their parent always is an IOPCIDevice that has properties for the device and vendor IDs.
|
||||
MaybeError GetDeviceIORegistryPCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
||||
MaybeError API_AVAILABLE(macos(10.13))
|
||||
GetDeviceIORegistryPCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
||||
// Get a matching dictionary for the IOGraphicsAccelerator2
|
||||
CFMutableDictionaryRef matchingDict = IORegistryEntryIDMatching([device registryID]);
|
||||
if (matchingDict == nullptr) {
|
||||
|
@ -143,7 +144,7 @@ namespace dawn_native { namespace metal {
|
|||
MaybeError GetDevicePCIInfo(id<MTLDevice> device, PCIIDs* ids) {
|
||||
// [device registryID] is introduced on macOS 10.13+, otherwise workaround to get vendor
|
||||
// id by vendor name on old macOS
|
||||
if ([NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:{10, 13, 0}]) {
|
||||
if (@available(macos 10.13, *)) {
|
||||
return GetDeviceIORegistryPCIInfo(device, ids);
|
||||
} else {
|
||||
return GetVendorIdFromVendors(device, ids);
|
||||
|
|
|
@ -48,6 +48,15 @@ namespace dawn_native { namespace metal {
|
|||
|
||||
namespace {
|
||||
|
||||
// Allows this file to use MTLStoreActionStoreAndMultismapleResolve because the logic is
|
||||
// first to compute what the "best" Metal render pass descriptor is, then fix it up if we
|
||||
// are not on macOS 10.12 (i.e. the EmulateStoreAndMSAAResolve toggle is on).
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
constexpr MTLStoreAction kMTLStoreActionStoreAndMultisampleResolve =
|
||||
MTLStoreActionStoreAndMultisampleResolve;
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
// Creates an autoreleased MTLRenderPassDescriptor matching desc
|
||||
MTLRenderPassDescriptor* CreateMTLRenderPassDescriptor(BeginRenderPassCmd* renderPass) {
|
||||
MTLRenderPassDescriptor* descriptor = [MTLRenderPassDescriptor renderPassDescriptor];
|
||||
|
@ -79,7 +88,7 @@ namespace dawn_native { namespace metal {
|
|||
descriptor.colorAttachments[i].resolveSlice =
|
||||
attachmentInfo.resolveTarget->GetBaseArrayLayer();
|
||||
descriptor.colorAttachments[i].storeAction =
|
||||
MTLStoreActionStoreAndMultisampleResolve;
|
||||
kMTLStoreActionStoreAndMultisampleResolve;
|
||||
} else {
|
||||
descriptor.colorAttachments[i].storeAction = MTLStoreActionStore;
|
||||
}
|
||||
|
@ -876,7 +885,7 @@ namespace dawn_native { namespace metal {
|
|||
std::array<id<MTLTexture>, kMaxColorAttachments> resolveTextures = {};
|
||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
||||
if (mtlRenderPass.colorAttachments[i].storeAction ==
|
||||
MTLStoreActionStoreAndMultisampleResolve) {
|
||||
kMTLStoreActionStoreAndMultisampleResolve) {
|
||||
hasStoreAndMSAAResolve = true;
|
||||
resolveTextures[i] = mtlRenderPass.colorAttachments[i].resolveTexture;
|
||||
|
||||
|
|
Loading…
Reference in New Issue