diff --git a/src/common/Platform.h b/src/common/Platform.h index 7e767f1322..3951362f44 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -23,6 +23,9 @@ #elif defined(__APPLE__) # define DAWN_PLATFORM_APPLE 1 # define DAWN_PLATFORM_POSIX 1 +#elif defined(__Fuchsia__) +# define DAWN_PLATFORM_FUCHSIA 1 +# define DAWN_PLATFORM_POSIX 1 #else # error "Unsupported platform." #endif diff --git a/src/common/vulkan_platform.h b/src/common/vulkan_platform.h index 81f0406bc5..881335300f 100644 --- a/src/common/vulkan_platform.h +++ b/src/common/vulkan_platform.h @@ -145,6 +145,20 @@ class alignas(kNativeVkHandleAlignment) VkNonDispatchableHandle { static_assert(sizeof(object) == sizeof(object##Native), ""); \ static_assert(alignof(object) == kNativeVkHandleAlignment, ""); +// Ensure platform-specific extensions are declared appropriately. +#if defined(DAWN_PLATFORM_LINUX) +# define VK_USE_PLATFORM_XLIB_KHR +# define VK_USE_PLATFORM_XCB_KHR +// NOTE: For now the line below is undefined to take care of systems that don't +// have the Wayland headers installed on the system. +// # define VK_USE_PLATFORM_WAYLAND_KHR +#elif defined(DAWN_PLATFORM_WINDOWS) +# define VK_USE_PLATFORM_WIN32_KHR +#elif defined(DAWN_PLATFORM_ANDROID) +# define VK_USE_PLATFORM_ANDROID_KHR +#elif defined(DAWN_PLATFORM_FUCHSIA) +# define VK_USE_PLATFORM_FUCHSIA +#endif # include // VK_NULL_HANDLE is defined to 0 but we don't want our handle type to compare to arbitrary @@ -156,5 +170,9 @@ class alignas(kNativeVkHandleAlignment) VkNonDispatchableHandle { #if defined(DAWN_PLATFORM_WINDOWS) # include "common/windows_with_undefs.h" #endif +// Remove X11/Xlib.h macros after vulkan_platform's include of it. +#if defined(DAWN_PLATFORM_LINUX) +# include "common/xlib_with_undefs.h" +#endif #endif // COMMON_VULKANPLATFORM_H_ diff --git a/src/common/xlib_with_undefs.h b/src/common/xlib_with_undefs.h new file mode 100644 index 0000000000..794ce0fb49 --- /dev/null +++ b/src/common/xlib_with_undefs.h @@ -0,0 +1,33 @@ +// Copyright 2019 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef COMMON_XLIB_WITH_UNDEFS_H_ +#define COMMON_XLIB_WITH_UNDEFS_H_ + +#include "common/Platform.h" + +#if !defined(DAWN_PLATFORM_LINUX) +# error "xlib_with_undefs.h included on non-Linux" +#endif + +// This header includes but removes all the extra defines that conflict with +// identifiers in internal code. It should never be included in something that is part of the public +// interface. +#include + +#undef Success +#undef None +#undef Always + +#endif // COMMON_XLIB_WITH_UNDEFS_H_