Commit a0928b94 by Corentin Wallez

Port gpu_test_expectations to Mac

BUG=angleproject:891 Change-Id: I06ad3b25914bc9ec4541b38a9b160983b7dcb720 Reviewed-on: https://chromium-review.googlesource.com/299850Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent fdaad25e
...@@ -1501,6 +1501,20 @@ ...@@ -1501,6 +1501,20 @@
'<!@(pkg-config --libs-only-l libpci)', '<!@(pkg-config --libs-only-l libpci)',
], ],
}], }],
['OS=="mac"',
{
'sources':
[
'third_party/gpu_test_expectations/gpu_test_config_mac.mm',
],
'link_settings':
{
'libraries':
[
'$(SDKROOT)/System/Library/Frameworks/IOKit.framework',
],
},
}],
], ],
}, },
......
...@@ -7,7 +7,7 @@ In order to make a change to this directory, do the following: ...@@ -7,7 +7,7 @@ In order to make a change to this directory, do the following:
* copy the directory somewhere like in ```gpu_test_expectations_reverted``` * copy the directory somewhere like in ```gpu_test_expectations_reverted```
* in ```gpu_test_expectations_reverted``` run ```patch -p 1 -R < angle-mods.patch``` * in ```gpu_test_expectations_reverted``` run ```patch -p 1 -R < angle-mods.patch```
* do your changes in ```gpu_test_expectations``` * do your changes in ```gpu_test_expectations```
* delete angle-mods.path in both directories * delete angle-mods.patch in both directories
* run ```diff -rupN gpu_test_expectations_reverted gpu_test_expectations > angle-mods.patch``` * run ```diff -rupN gpu_test_expectations_reverted gpu_test_expectations > angle-mods.patch```
* copy ```angle-mods.patch``` in ```gpu_test_expectations``` * copy ```angle-mods.patch``` in ```gpu_test_expectations```
......
...@@ -48,6 +48,8 @@ namespace base ...@@ -48,6 +48,8 @@ namespace base
# define OS_WIN # define OS_WIN
#elif defined(__linux__) #elif defined(__linux__)
# define OS_LINUX # define OS_LINUX
#elif defined(__APPLE__)
# define OS_MACOSX
#else #else
# error "Unsupported platform" # error "Unsupported platform"
#endif #endif
......
...@@ -13,6 +13,10 @@ extern "C" { ...@@ -13,6 +13,10 @@ extern "C" {
} }
#endif #endif
#if defined(OS_MACOSX)
#include "gpu_test_config_mac.h"
#endif
using namespace gpu; using namespace gpu;
#if defined(OS_WIN) #if defined(OS_WIN)
...@@ -168,8 +172,25 @@ CollectInfoResult CollectGpuID(uint32* vendor_id, uint32* device_id) { ...@@ -168,8 +172,25 @@ CollectInfoResult CollectGpuID(uint32* vendor_id, uint32* device_id) {
} }
return result; return result;
} }
#endif // defined(OS_LINUX) #endif // defined(OS_LINUX)
#if defined(OS_MACOSX)
CollectInfoResult CollectGpuID(uint32* vendor_id, uint32* device_id) {
DCHECK(vendor_id && device_id);
GPUInfo::GPUDevice gpu = GetActiveGPU();
*vendor_id = gpu.vendor_id;
*device_id = gpu.device_id;
if (*vendor_id != 0 && *device_id != 0)
return kCollectInfoSuccess;
return kCollectInfoNonFatalFailure;
}
#endif
namespace gpu { namespace gpu {
namespace { namespace {
......
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// gpu_test_config_mac.h:
// Helper functions for gpu_test_config that have to be compiled in ObjectiveC++
//
#ifndef GPU_TEST_EXPECTATIONS_GPU_TEST_CONFIG_MAC_H_
#define GPU_TEST_EXPECTATIONS_GPU_TEST_CONFIG_MAC_H_
#include "gpu_info.h"
namespace base {
class SysInfo
{
public:
static void OperatingSystemVersionNumbers(
int32 *major_version, int32 *minor_version, int32 *bugfix_version);
};
} // namespace base
gpu::GPUInfo::GPUDevice GetActiveGPU();
#endif // GPU_TEST_EXPECTATIONS_GPU_TEST_CONFIG_MAC_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// gpu_test_config_mac.mm:
// Helper functions for gpu_test_config that have to be compiled in ObjectiveC++
#include "gpu_test_config_mac.h"
#import <Cocoa/Cocoa.h>
namespace base {
void SysInfo::OperatingSystemVersionNumbers(
int32 *major_version, int32 *minor_version, int32 *bugfix_version)
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
Gestalt(gestaltSystemVersionMajor, reinterpret_cast<SInt32*>(major_version));
Gestalt(gestaltSystemVersionMinor, reinterpret_cast<SInt32*>(minor_version));
Gestalt(gestaltSystemVersionBugFix, reinterpret_cast<SInt32*>(bugfix_version));
#else
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
*major_version = version.majorVersion;
*minor_version = version.minorVersion;
*bugfix_version = version.patchVersion;
#endif
}
} // namespace base
UInt32 GetEntryProperty(io_registry_entry_t entry, CFStringRef property_name) {
CFTypeRef type = IORegistryEntrySearchCFProperty(entry,
kIOServicePlane,
property_name,
kCFAllocatorDefault,
kIORegistryIterateRecursively | kIORegistryIterateParents);
CFDataRef data = reinterpret_cast<CFDataRef>(type);
if (!data) {
CFRelease(data);
return 0;
}
UInt32 value = 0;
const uint32_t* valuePointer = reinterpret_cast<const uint32_t*>(CFDataGetBytePtr(data));
if (valuePointer != NULL) {
value = *valuePointer;
}
CFRelease(data);
return value;
}
gpu::GPUInfo::GPUDevice GetActiveGPU() {
gpu::GPUInfo::GPUDevice gpu;
// Ignore the fact that CGDisplayIOServicePort is deprecated as Apple
// did not provide a good replacement for it as of 10.10.
// TODO(cwallez) revisit with later systems
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
io_registry_entry_t dsp_port = CGDisplayIOServicePort(kCGDirectMainDisplay);
#pragma clang diagnostic pop
gpu.vendor_id = GetEntryProperty(dsp_port, CFSTR("vendor-id"));
gpu.device_id = GetEntryProperty(dsp_port, CFSTR("device-id"));
return gpu;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment