aboutsummaryrefslogtreecommitdiff
path: root/samples/amber.cc
diff options
context:
space:
mode:
authorMika Väinölä <33728696+mvainola@users.noreply.github.com>2019-10-28 19:40:06 +0200
committerdan sinclair <dsinclair@google.com>2019-10-28 13:40:06 -0400
commit34bb13d2747ec8c3ba1deca3d1c5c5f5f5dffa45 (patch)
tree2107e51975d2518edbe9b9cdb3ea4570d72c76e8 /samples/amber.cc
parent40fce113d6fec2ee35cf1c3574bcdb8e0129c373 (diff)
downloadamber-34bb13d2747ec8c3ba1deca3d1c5c5f5f5dffa45.tar.gz
Add Vulkan device selection support (#698)
Add the `-D` command line option for selecting a physical Vulkan device to run with. Only choose from enumerated physical devices in ChooseVulkanPhysicalDevice and move feature and extension checks to a new CheckVulkanPhysicalDeviceRequirements function. Issue #619
Diffstat (limited to 'samples/amber.cc')
-rw-r--r--samples/amber.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/samples/amber.cc b/samples/amber.cc
index cb085c6..6e7af87 100644
--- a/samples/amber.cc
+++ b/samples/amber.cc
@@ -49,6 +49,7 @@ struct Options {
uint32_t engine_major = 1;
uint32_t engine_minor = 0;
int32_t fence_timeout = -1;
+ int32_t selected_device = -1;
bool parse_only = false;
bool pipeline_create_only = false;
bool disable_validation_layer = false;
@@ -70,6 +71,7 @@ const char kUsage[] = R"(Usage: amber [options] SCRIPT [SCRIPTS...]
-ps -- Parse input files, create pipelines; Don't execute.
-q -- Disable summary output.
-d -- Disable validation layers.
+ -D <ID> -- ID of device to run with (Vulkan only).
-f <value> -- Sets the fence timeout value to |value|
-t <spirv_env> -- The target SPIR-V environment e.g., spv1.3, vulkan1.1.
If a SPIR-V environment, assume the lowest version of Vulkan that
@@ -146,6 +148,20 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) {
<< std::endl;
return false;
}
+ } else if (arg == "-D") {
+ ++i;
+ if (i >= args.size()) {
+ std::cerr << "Missing ID for -D argument." << std::endl;
+ return false;
+ }
+
+ int32_t val = std::stoi(std::string(args[i]));
+ if (val < 0) {
+ std::cerr << "Device ID must be non-negative" << std::endl;
+ return false;
+ }
+ opts->selected_device = val;
+
} else if (arg == "-f") {
++i;
if (i >= args.size()) {
@@ -405,6 +421,7 @@ int main(int argc, const char** argv) {
amber::Result r = config_helper.CreateConfig(
amber_options.engine, options.engine_major, options.engine_minor,
+ options.selected_device,
std::vector<std::string>(required_features.begin(),
required_features.end()),
std::vector<std::string>(required_instance_extensions.begin(),