• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# -*- coding: utf-8 -*-
2
3#-------------------------------------------------------------------------
4# Vulkan CTS
5# ----------
6#
7# Copyright (c) 2022 Google LLC.
8#
9# Licensed under the Apache License, Version 2.0 (the "License");
10# you may not use this file except in compliance with the License.
11# You may obtain a copy of the License at
12#
13#      http://www.apache.org/licenses/LICENSE-2.0
14#
15# Unless required by applicable law or agreed to in writing, software
16# distributed under the License is distributed on an "AS IS" BASIS,
17# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18# See the License for the specific language governing permissions and
19# limitations under the License.
20#
21#-------------------------------------------------------------------------
22
23import os
24import sys
25import argparse
26import tempfile
27
28sys.path.append(os.path.join(os.path.dirname(__file__), "..", "..", "..", "scripts"))
29
30from ctsbuild.common import *
31from ctsbuild.config import *
32from ctsbuild.build import *
33
34class Module:
35	def __init__ (self, name, dirName, binName):
36		self.name		= name
37		self.dirName	= dirName
38		self.binName	= binName
39
40VULKAN_MODULE		= Module("dEQP-VK", "../external/vulkancts/modules/vulkan", "deqp-vk")
41DEFAULT_BUILD_DIR	= os.path.join(tempfile.gettempdir(), "amber-verify", "{targetName}-{buildType}")
42DEFAULT_TARGET		= "null"
43DEFAULT_DST_DIR		= os.path.join(DEQP_DIR, "external", "vulkancts", "data", "vulkan", "prebuilt")
44
45def getBuildConfig (buildPathPtrn, targetName, buildType):
46	buildPath = buildPathPtrn.format(
47		targetName	= targetName,
48		buildType	= buildType)
49
50	return BuildConfig(buildPath, buildType, [f"-DDEQP_TARGET={targetName}"])
51
52def execBuildPrograms (buildCfg, generator, module):
53	workDir		= os.path.join(buildCfg.getBuildDir(), "modules", module.dirName)
54
55	pushWorkingDir(workDir)
56
57	try:
58		binPath = generator.getBinaryPath(buildCfg.getBuildType(), os.path.join(".", "deqp-vk"))
59		execute([binPath, "--deqp-runmode=amber-verify"])
60	finally:
61		popWorkingDir()
62
63def parseArgs ():
64	parser = argparse.ArgumentParser(description = "Verify amber device requirements between CTS and .amber file",
65									 formatter_class=argparse.ArgumentDefaultsHelpFormatter)
66	parser.add_argument("-b",
67						"--build-dir",
68						dest="buildDir",
69						default=DEFAULT_BUILD_DIR,
70						help="Temporary build directory")
71	parser.add_argument("-t",
72						"--build-type",
73						dest="buildType",
74						default="Release",
75						help="Build type")
76	parser.add_argument("-c",
77						"--deqp-target",
78						dest="targetName",
79						default=DEFAULT_TARGET,
80						help="dEQP build target")
81	parser.add_argument("-d",
82						"--dst-path",
83						dest="dstPath",
84						default=DEFAULT_DST_DIR,
85						help="Destination path")
86	return parser.parse_args()
87
88if __name__ == "__main__":
89	args = parseArgs()
90
91	generator	= ANY_GENERATOR
92	buildCfg	= getBuildConfig(args.buildDir, args.targetName, args.buildType)
93	module		= VULKAN_MODULE
94
95	build(buildCfg, generator, ["deqp-vk"])
96
97	if not os.path.exists(args.dstPath):
98		os.makedirs(args.dstPath)
99
100	execBuildPrograms(buildCfg, generator, module)
101