1 /*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "GraphicsDetector.h"
18
19 #include "GraphicsDetectorGl.h"
20 #include "GraphicsDetectorVk.h"
21 #include "GraphicsDetectorVkExternalMemoryHost.h"
22 #include "GraphicsDetectorVkPrecisionQualifiersOnYuvSamplers.h"
23 #include "Subprocess.h"
24
25 namespace gfxstream {
26
DetectGraphicsAvailability()27 ::gfxstream::proto::GraphicsAvailability DetectGraphicsAvailability() {
28 ::gfxstream::proto::GraphicsAvailability availability;
29
30 using GraphicsCheckFn = gfxstream::expected<Ok, std::string>(::gfxstream::proto::GraphicsAvailability*);
31 const std::vector<std::pair<std::string, GraphicsCheckFn*>> checks = {
32 {"PopulateEglAndGlesAvailability",
33 PopulateEglAndGlesAvailability},
34 {"PopulateVulkanAvailability",
35 PopulateVulkanAvailability},
36 {"PopulateVulkanExternalMemoryHostQuirk",
37 PopulateVulkanExternalMemoryHostQuirk},
38 {"PopulateVulkanPrecisionQualifiersOnYuvSamplersQuirk",
39 PopulateVulkanPrecisionQualifiersOnYuvSamplersQuirk},
40 };
41
42 for (const auto& check : checks) {
43 auto result = DoWithSubprocessCheck([&](){ return check.second(&availability); });
44 if (!result.ok()) {
45 availability.add_errors("Graphics check failure for " + check.first + ": " + result.error());
46 }
47 }
48
49 return availability;
50 }
51
52 } // namespace gfxstream
53