Fix bug about requiring unexpected files when compiling on Android

In MemoryService implementation, Dawn uses DAWN_PLATFORM_IS() to choose
required header files for different OS platform.

On Android platform, both DAWN_PLATFORM_IS(LINUX) and DAWN_PLATFORM_IS(ANDROID) are true. This caused some linux platform header files and implementations has been included unexpected when compiling on Android platform.

This CL strict the macro condition to ensure Android platform include AHardwareBuffer related files only.

Bug:dawn:1593
Change-Id: If64567edf99cd25a3783d8c456a1fc3f6a7dccf2
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/126323
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
This commit is contained in:
Yan,Shaobo 2023-04-04 08:57:46 +00:00 committed by Dawn LUCI CQ
parent 3fcf96dd8c
commit 2c4847e59a
2 changed files with 17 additions and 13 deletions

View File

@ -51,9 +51,10 @@
#define DAWN_PLATFORM_IS_POSIX 1
#if defined(__ANDROID__)
#define DAWN_PLATFORM_IS_ANDROID 1
#endif
#if defined(DAWN_OS_CHROMEOS)
#elif defined(DAWN_OS_CHROMEOS)
#define DAWN_PLATFORM_IS_CHROMEOS 1
#else
#define DAWN_PLATFORM_IS_LINUX_DESKTOP 1
#endif
#elif defined(__APPLE__)
@ -197,6 +198,9 @@ static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
#if !defined(DAWN_PLATFORM_IS_CHROMEOS)
#define DAWN_PLATFORM_IS_CHROMEOS 0
#endif
#if !defined(DAWN_PLATFORM_IS_LINUX_DESKTOP)
#define DAWN_PLATFORM_IS_LINUX_DESKTOP 0
#endif
#if !defined(DAWN_PLATFORM_IS_APPLE)
#define DAWN_PLATFORM_IS_APPLE 0

View File

@ -17,10 +17,10 @@
#include "dawn/native/vulkan/DeviceVk.h"
#include "dawn/native/vulkan/external_memory/MemoryService.h"
#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(CHROMEOS)
#if DAWN_PLATFORM_IS(LINUX_DESKTOP) || DAWN_PLATFORM_IS(CHROMEOS)
#include "dawn/native/vulkan/external_memory/MemoryServiceImplementationDmaBuf.h"
#include "dawn/native/vulkan/external_memory/MemoryServiceImplementationOpaqueFD.h"
#endif // DAWN_PLATFORM_IS(LINUX)
#endif // DAWN_PLATFORM_IS(LINUX_DESKTOP) || DAWN_PLATFORM_IS(CHROMEOS)
#if DAWN_PLATFORM_IS(ANDROID)
#include "dawn/native/vulkan/external_memory/MemoryServiceImplementationAHardwareBuffer.h"
@ -37,7 +37,7 @@ bool Service::CheckSupport(const VulkanDeviceInfo& deviceInfo) {
return CheckAHardwareBufferSupport(deviceInfo);
#elif DAWN_PLATFORM_IS(FUCHSIA)
return CheckZirconHandleSupport(deviceInfo);
#elif DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(CHROMEOS)
#elif DAWN_PLATFORM_IS(LINUX_DESKTOP) || DAWN_PLATFORM_IS(CHROMEOS)
return CheckOpaqueFDSupport(deviceInfo) || CheckDmaBufSupport(deviceInfo);
#else
return false;
@ -51,7 +51,13 @@ Service::Service(Device* device) {
}
#endif // DAWN_PLATFORM_IS(FUCHSIA)
#if DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(CHROMEOS)
#if DAWN_PLATFORM_IS(ANDROID)
if (CheckAHardwareBufferSupport(device->GetDeviceInfo())) {
mServiceImpls[ExternalImageType::AHardwareBuffer] = CreateAHardwareBufferService(device);
}
#endif // DAWN_PLATFORM_IS(ANDROID)
#if DAWN_PLATFORM_IS(LINUX_DESKTOP) || DAWN_PLATFORM_IS(CHROMEOS)
if (CheckOpaqueFDSupport(device->GetDeviceInfo())) {
mServiceImpls[ExternalImageType::OpaqueFD] = CreateOpaqueFDService(device);
}
@ -59,13 +65,7 @@ Service::Service(Device* device) {
if (CheckDmaBufSupport(device->GetDeviceInfo())) {
mServiceImpls[ExternalImageType::DmaBuf] = CreateDmaBufService(device);
}
#endif // DAWN_PLATFORM_IS(LINUX) || DAWN_PLATFORM_IS(CHROMEOS)
#if DAWN_PLATFORM_IS(ANDROID)
if (CheckAHardwareBufferSupport(device->GetDeviceInfo())) {
mServiceImpls[ExternalImageType::AHardwareBuffer] = CreateAHardwareBufferService(device);
}
#endif // DAWN_PLATFORM_IS(ANDROID)
#endif // DAWN_PLATFORM_IS(LINUX_DESKTOP) || DAWN_PLATFORM_IS(CHROMEOS)
}
Service::~Service() = default;