Commit 5311495e authored by Maggie Chen's avatar Maggie Chen Committed by Commit Bot

Improve readability for the DX12/Vulkan info collection functions.

Bug: 850881,863086
Change-Id: I37ca7c191bb70d9571b3bea620df382496ae2498
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2265172Reviewed-by: default avatarZhenyao Mo <zmo@chromium.org>
Commit-Queue: Maggie Chen <magchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782102}
parent 651f00f8
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "components/viz/service/gl/info_collection_gpu_service_impl.h" #include "components/viz/service/gl/info_collection_gpu_service_impl.h"
#include <utility>
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/task_runner_util.h" #include "base/task_runner_util.h"
#include "gpu/config/dx_diag_node.h" #include "gpu/config/dx_diag_node.h"
...@@ -59,9 +60,8 @@ void InfoCollectionGpuServiceImpl:: ...@@ -59,9 +60,8 @@ void InfoCollectionGpuServiceImpl::
GetGpuSupportedDx12VersionAndDevicePerfInfoCallback callback) { GetGpuSupportedDx12VersionAndDevicePerfInfoCallback callback) {
DCHECK(main_runner_->BelongsToCurrentThread()); DCHECK(main_runner_->BelongsToCurrentThread());
uint32_t d3d12_feature_level; uint32_t d3d12_feature_level = gpu::GetGpuSupportedD3D12Version();
gpu::RecordGpuSupportedDx12VersionHistograms(gpu_device_, gpu::RecordGpuSupportedDx12VersionHistograms(d3d12_feature_level);
&d3d12_feature_level);
io_runner_->PostTask(FROM_HERE, io_runner_->PostTask(FROM_HERE,
base::BindOnce(std::move(callback), d3d12_feature_level, base::BindOnce(std::move(callback), d3d12_feature_level,
...@@ -83,9 +83,7 @@ void InfoCollectionGpuServiceImpl::GetGpuSupportedVulkanVersionInfoOnMain( ...@@ -83,9 +83,7 @@ void InfoCollectionGpuServiceImpl::GetGpuSupportedVulkanVersionInfoOnMain(
GetGpuSupportedVulkanVersionInfoCallback callback) { GetGpuSupportedVulkanVersionInfoCallback callback) {
DCHECK(main_runner_->BelongsToCurrentThread()); DCHECK(main_runner_->BelongsToCurrentThread());
uint32_t vulkan_version; uint32_t vulkan_version = gpu::GetGpuSupportedVulkanVersion(gpu_device_);
gpu::GetGpuSupportedVulkanVersion(gpu_device_, &vulkan_version);
io_runner_->PostTask(FROM_HERE, io_runner_->PostTask(FROM_HERE,
base::BindOnce(std::move(callback), vulkan_version)); base::BindOnce(std::move(callback), vulkan_version));
} }
......
...@@ -45,12 +45,11 @@ GPU_EXPORT bool CollectContextGraphicsInfo(GPUInfo* gpu_info); ...@@ -45,12 +45,11 @@ GPU_EXPORT bool CollectContextGraphicsInfo(GPUInfo* gpu_info);
#if defined(OS_WIN) #if defined(OS_WIN)
// Collect the DirectX Disagnostics information about the attached displays. // Collect the DirectX Disagnostics information about the attached displays.
GPU_EXPORT bool GetDxDiagnostics(DxDiagNode* output); GPU_EXPORT bool GetDxDiagnostics(DxDiagNode* output);
GPU_EXPORT uint32_t GetGpuSupportedD3D12Version();
GPU_EXPORT void RecordGpuSupportedDx12VersionHistograms( GPU_EXPORT void RecordGpuSupportedDx12VersionHistograms(
const gpu::GPUInfo::GPUDevice& gpu_device, uint32_t d3d12_feature_level);
uint32_t* d3d12_feature_level); GPU_EXPORT uint32_t
GPU_EXPORT void GetGpuSupportedVulkanVersion( GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device);
const gpu::GPUInfo::GPUDevice& gpu_device,
uint32_t* vulkan_version);
// Iterate through all adapters and create a hardware D3D11 device on each // Iterate through all adapters and create a hardware D3D11 device on each
// adapter. If succeeded, query the highest feature level it supports and // adapter. If succeeded, query the highest feature level it supports and
......
...@@ -236,14 +236,13 @@ bool CollectDriverInfoD3D(GPUInfo* gpu_info) { ...@@ -236,14 +236,13 @@ bool CollectDriverInfoD3D(GPUInfo* gpu_info) {
} }
// DirectX 12 are included with Windows 10 and Server 2016. // DirectX 12 are included with Windows 10 and Server 2016.
void GetGpuSupportedD3D12Version(uint32_t* d3d12_feature_level) { uint32_t GetGpuSupportedD3D12Version() {
TRACE_EVENT0("gpu", "GetGpuSupportedD3D12Version"); TRACE_EVENT0("gpu", "GetGpuSupportedD3D12Version");
*d3d12_feature_level = 0;
base::ScopedNativeLibrary d3d12_library( base::ScopedNativeLibrary d3d12_library(
base::FilePath(FILE_PATH_LITERAL("d3d12.dll"))); base::FilePath(FILE_PATH_LITERAL("d3d12.dll")));
if (!d3d12_library.is_valid()) if (!d3d12_library.is_valid())
return; return 0;
// The order of feature levels to attempt to create in D3D CreateDevice // The order of feature levels to attempt to create in D3D CreateDevice
const D3D_FEATURE_LEVEL feature_levels[] = { const D3D_FEATURE_LEVEL feature_levels[] = {
...@@ -260,11 +259,11 @@ void GetGpuSupportedD3D12Version(uint32_t* d3d12_feature_level) { ...@@ -260,11 +259,11 @@ void GetGpuSupportedD3D12Version(uint32_t* d3d12_feature_level) {
for (auto level : feature_levels) { for (auto level : feature_levels) {
if (SUCCEEDED(D3D12CreateDevice(nullptr, level, _uuidof(ID3D12Device), if (SUCCEEDED(D3D12CreateDevice(nullptr, level, _uuidof(ID3D12Device),
nullptr))) { nullptr))) {
*d3d12_feature_level = level; return level;
break;
} }
} }
} }
return 0;
} }
// The old graphics drivers are installed to the Windows system directory // The old graphics drivers are installed to the Windows system directory
...@@ -406,8 +405,8 @@ bool InitVulkanInstanceProc( ...@@ -406,8 +405,8 @@ bool InitVulkanInstanceProc(
return false; return false;
} }
void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device, uint32_t GetGpuSupportedVulkanVersion(
uint32_t* vulkan_version) { const gpu::GPUInfo::GPUDevice& gpu_device) {
TRACE_EVENT0("gpu", "GetGpuSupportedVulkanVersion"); TRACE_EVENT0("gpu", "GetGpuSupportedVulkanVersion");
base::NativeLibrary vulkan_library; base::NativeLibrary vulkan_library;
...@@ -417,26 +416,26 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device, ...@@ -417,26 +416,26 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device,
PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties; PFN_vkEnumerateDeviceExtensionProperties vkEnumerateDeviceExtensionProperties;
VkInstance vk_instance = VK_NULL_HANDLE; VkInstance vk_instance = VK_NULL_HANDLE;
uint32_t physical_device_count = 0; uint32_t physical_device_count = 0;
*vulkan_version = 0;
// Skip if the system has an older AMD Vulkan driver amdvlk64.dll or // Skip if the system has an older AMD Vulkan driver amdvlk64.dll or
// amdvlk32.dll which crashes when vkCreateInstance() is called. This bug has // amdvlk32.dll which crashes when vkCreateInstance() is called. This bug has
// been fixed in the latest AMD driver. // been fixed in the latest AMD driver.
// Detected by the file version of amdvlk64.dll. // Detected by the file version of amdvlk64.dll.
if (BadAMDVulkanDriverVersion()) { if (BadAMDVulkanDriverVersion()) {
return; return 0;
} }
// Don't collect any info if the graphics vulkan driver is blacklisted or // Don't collect any info if the graphics vulkan driver is blacklisted or
// doesn't support Vulkan 1.1 // doesn't support Vulkan 1.1
// Detected by the graphic driver version returned by DXGI // Detected by the graphic driver version returned by DXGI
if (BadGraphicsDriverVersions(gpu_device)) if (BadGraphicsDriverVersions(gpu_device))
return; return 0;
// Only supports a version >= 1.1.0. // Only supports a version >= 1.1.0.
uint32_t vulkan_version = 0;
if (!InitVulkan(&vulkan_library, &vkGetInstanceProcAddr, &vkCreateInstance, if (!InitVulkan(&vulkan_library, &vkGetInstanceProcAddr, &vkCreateInstance,
vulkan_version)) { &vulkan_version)) {
return; return 0;
} }
VkApplicationInfo app_info = {}; VkApplicationInfo app_info = {};
...@@ -452,7 +451,7 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device, ...@@ -452,7 +451,7 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device,
create_info.ppEnabledExtensionNames = enabled_instance_extensions.data(); create_info.ppEnabledExtensionNames = enabled_instance_extensions.data();
// Get the Vulkan API version supported in the GPU driver // Get the Vulkan API version supported in the GPU driver
int highest_minor_version = VK_VERSION_MINOR(*vulkan_version); int highest_minor_version = VK_VERSION_MINOR(vulkan_version);
for (int minor_version = highest_minor_version; minor_version >= 1; for (int minor_version = highest_minor_version; minor_version >= 1;
--minor_version) { --minor_version) {
app_info.apiVersion = VK_MAKE_VERSION(1, minor_version, 0); app_info.apiVersion = VK_MAKE_VERSION(1, minor_version, 0);
...@@ -464,8 +463,7 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device, ...@@ -464,8 +463,7 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device,
result = vkEnumeratePhysicalDevices(vk_instance, &physical_device_count, result = vkEnumeratePhysicalDevices(vk_instance, &physical_device_count,
nullptr); nullptr);
if (result == VK_SUCCESS && physical_device_count > 0) { if (result == VK_SUCCESS && physical_device_count > 0) {
*vulkan_version = app_info.apiVersion; return app_info.apiVersion;
break;
} else { } else {
// Skip destroy here. GPU process shutdown will unload all loaded DLLs. // Skip destroy here. GPU process shutdown will unload all loaded DLLs.
// vkDestroyInstance(vk_instance, nullptr); // vkDestroyInstance(vk_instance, nullptr);
...@@ -482,18 +480,16 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device, ...@@ -482,18 +480,16 @@ void GetGpuSupportedVulkanVersion(const gpu::GPUInfo::GPUDevice& gpu_device,
// vkDestroyInstance(vk_instance, nullptr); // vkDestroyInstance(vk_instance, nullptr);
// } // }
// base::UnloadNativeLibrary(vulkan_library); // base::UnloadNativeLibrary(vulkan_library);
return 0;
} }
void RecordGpuSupportedDx12VersionHistograms( void RecordGpuSupportedDx12VersionHistograms(uint32_t d3d12_feature_level) {
const gpu::GPUInfo::GPUDevice& gpu_device,
uint32_t* d3d12_feature_level) {
GetGpuSupportedD3D12Version(d3d12_feature_level);
bool supports_dx12 = bool supports_dx12 =
(*d3d12_feature_level >= D3D_FEATURE_LEVEL_12_0) ? true : false; (d3d12_feature_level >= D3D_FEATURE_LEVEL_12_0) ? true : false;
UMA_HISTOGRAM_BOOLEAN("GPU.SupportsDX12", supports_dx12); UMA_HISTOGRAM_BOOLEAN("GPU.SupportsDX12", supports_dx12);
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
"GPU.D3D12FeatureLevel", "GPU.D3D12FeatureLevel",
ConvertToHistogramFeatureLevel(*d3d12_feature_level)); ConvertToHistogramFeatureLevel(d3d12_feature_level));
} }
bool CollectD3D11FeatureInfo(D3D_FEATURE_LEVEL* d3d11_feature_level, bool CollectD3D11FeatureInfo(D3D_FEATURE_LEVEL* d3d11_feature_level,
......
...@@ -1034,21 +1034,4 @@ std::string VulkanVersionToString(uint32_t vulkan_version) { ...@@ -1034,21 +1034,4 @@ std::string VulkanVersionToString(uint32_t vulkan_version) {
} }
} }
#endif // OS_WIN #endif // OS_WIN
VulkanVersion ConvertToHistogramVulkanVersion(uint32_t vulkan_version) {
if (vulkan_version < VK_MAKE_VERSION(1, 0, 0))
return VulkanVersion::kVulkanVersionUnknown;
else if (vulkan_version < VK_MAKE_VERSION(1, 1, 0))
return VulkanVersion::kVulkanVersion_1_0_0;
else if (vulkan_version < VK_MAKE_VERSION(1, 2, 0))
return VulkanVersion::kVulkanVersion_1_1_0;
else if (vulkan_version < VK_MAKE_VERSION(1, 3, 0))
return VulkanVersion::kVulkanVersion_1_2_0;
else {
// Need to add 1.3.0+ to enum VulkanVersion.
NOTREACHED();
return VulkanVersion::kVulkanVersion_1_2_0;
}
}
} // namespace gpu } // namespace gpu
...@@ -97,20 +97,6 @@ GPU_EXPORT std::string D3DFeatureLevelToString(uint32_t d3d_feature_level); ...@@ -97,20 +97,6 @@ GPU_EXPORT std::string D3DFeatureLevelToString(uint32_t d3d_feature_level);
GPU_EXPORT std::string VulkanVersionToString(uint32_t vulkan_version); GPU_EXPORT std::string VulkanVersionToString(uint32_t vulkan_version);
#endif // OS_WIN #endif // OS_WIN
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// This should match enum VulkanVersion in \tools\metrics\histograms\enums.xml
enum class VulkanVersion {
kVulkanVersionUnknown = 0,
kVulkanVersion_1_0_0 = 1,
kVulkanVersion_1_1_0 = 2,
kVulkanVersion_1_2_0 = 3,
kMaxValue = kVulkanVersion_1_2_0,
};
GPU_EXPORT VulkanVersion
ConvertToHistogramVulkanVersion(uint32_t vulkan_version);
} // namespace gpu } // namespace gpu
#endif // GPU_CONFIG_GPU_UTIL_H_ #endif // GPU_CONFIG_GPU_UTIL_H_
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