diff options
author | dan sinclair <dsinclair@chromium.org> | 2019-09-04 09:53:32 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-04 09:53:32 -0400 |
commit | 6e16cab40484dd0cf488ae63fc41f882068712e9 (patch) | |
tree | 9dc17ca482a3ceae2a03d666f4cb944847c0efe1 | |
parent | 64b636272a989e48b691e1d66dc52286922272de (diff) | |
download | amber-6e16cab40484dd0cf488ae63fc41f882068712e9.tar.gz |
Allow recipe to change fence timeout. (#624)
This CL adds an API to the recipe class to set the fence timeout for a
given script.
The default fence timeout is also bumped from 100ms to 1000ms.
-rw-r--r-- | include/amber/recipe.h | 6 | ||||
-rw-r--r-- | samples/amber.cc | 19 | ||||
-rw-r--r-- | src/engine.h | 2 | ||||
-rw-r--r-- | src/executor_test.cc | 6 | ||||
-rw-r--r-- | src/recipe.cc | 5 | ||||
-rw-r--r-- | src/script.h | 5 |
6 files changed, 36 insertions, 7 deletions
diff --git a/include/amber/recipe.h b/include/amber/recipe.h index 7e6d797..310a86a 100644 --- a/include/amber/recipe.h +++ b/include/amber/recipe.h @@ -40,6 +40,9 @@ class RecipeImpl { /// Returns required instance extensions in the given recipe. virtual std::vector<std::string> GetRequiredInstanceExtensions() const = 0; + /// Sets the fence timeout value to |timeout_ms|. + virtual void SetFenceTimeout(uint32_t timeout_ms) = 0; + protected: RecipeImpl(); }; @@ -66,6 +69,9 @@ class Recipe { /// Returns required instance extensions in the given recipe. std::vector<std::string> GetRequiredInstanceExtensions() const; + /// Sets the timeout value for fences to |timeout_ms|. + void SetFenceTimeout(uint32_t timeout_ms); + private: RecipeImpl* impl_; }; diff --git a/samples/amber.cc b/samples/amber.cc index b327bab..cefc58f 100644 --- a/samples/amber.cc +++ b/samples/amber.cc @@ -47,6 +47,7 @@ struct Options { std::vector<amber::BufferInfo> buffer_to_dump; uint32_t engine_major = 1; uint32_t engine_minor = 0; + int32_t fence_timeout = -1; bool parse_only = false; bool pipeline_create_only = false; bool disable_validation_layer = false; @@ -68,6 +69,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. + -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 requires support of that version of SPIR-V. @@ -143,6 +145,20 @@ bool ParseArgs(const std::vector<std::string>& args, Options* opts) { << std::endl; return false; } + } else if (arg == "-f") { + ++i; + if (i >= args.size()) { + std::cerr << "Missing value for -f argument." << std::endl; + return false; + } + + int32_t val = std::stoi(std::string(args[i])); + if (val < 0) { + std::cerr << "Fence timeout must be non-negative" << std::endl; + return false; + } + opts->fence_timeout = val; + } else if (arg == "-t") { ++i; if (i >= args.size()) { @@ -337,6 +353,9 @@ int main(int argc, const char** argv) { continue; } + if (options.fence_timeout > -1) + recipe->SetFenceTimeout(static_cast<uint32_t>(options.fence_timeout)); + recipe_data.emplace_back(); recipe_data.back().file = file; recipe_data.back().recipe = std::move(recipe); diff --git a/src/engine.h b/src/engine.h index 4eecb0c..7b1f10e 100644 --- a/src/engine.h +++ b/src/engine.h @@ -31,7 +31,7 @@ namespace amber { /// EngineData stores information used during engine execution. struct EngineData { /// The timeout to use for fences, in milliseconds. - uint32_t fence_timeout_ms = 100; + uint32_t fence_timeout_ms = 1000; }; /// Abstract class which describes a backing engine for Amber. diff --git a/src/executor_test.cc b/src/executor_test.cc index 499ef5c..c0558b5 100644 --- a/src/executor_test.cc +++ b/src/executor_test.cc @@ -238,8 +238,6 @@ logicOp)"; const auto& extensions = ToStub(engine.get())->GetDeviceExtensions(); ASSERT_EQ(static_cast<size_t>(0U), extensions.size()); - - EXPECT_EQ(100U, ToStub(engine.get())->GetFenceTimeoutMs()); } TEST_F(VkScriptExecutorTest, ExecutesRequiredExtensions) { @@ -269,8 +267,6 @@ VK_KHR_variable_pointers)"; ASSERT_EQ(2U, extensions.size()); EXPECT_EQ("VK_KHR_storage_buffer_storage_class", extensions[0]); EXPECT_EQ("VK_KHR_variable_pointers", extensions[1]); - - EXPECT_EQ(100U, ToStub(engine.get())->GetFenceTimeoutMs()); } TEST_F(VkScriptExecutorTest, ExecutesRequiredFrameBuffers) { @@ -298,8 +294,6 @@ depthstencil D24_UNORM_S8_UINT)"; const auto& extensions = ToStub(engine.get())->GetDeviceExtensions(); ASSERT_EQ(static_cast<size_t>(0U), extensions.size()); - - EXPECT_EQ(100U, ToStub(engine.get())->GetFenceTimeoutMs()); } TEST_F(VkScriptExecutorTest, ExecutesRequiredFenceTimeout) { diff --git a/src/recipe.cc b/src/recipe.cc index bf7182a..f7507b9 100644 --- a/src/recipe.cc +++ b/src/recipe.cc @@ -45,4 +45,9 @@ std::vector<std::string> Recipe::GetRequiredInstanceExtensions() const { : std::vector<std::string>(); } +void Recipe::SetFenceTimeout(uint32_t timeout_ms) { + if (impl_) + impl_->SetFenceTimeout(timeout_ms); +} + } // namespace amber diff --git a/src/script.h b/src/script.h index e57f990..3e0dc3c 100644 --- a/src/script.h +++ b/src/script.h @@ -58,6 +58,11 @@ class Script : public RecipeImpl { return engine_info_.required_instance_extensions; } + /// Sets the fence timeout to |timeout_ms|. + void SetFenceTimeout(uint32_t timeout_ms) override { + engine_data_.fence_timeout_ms = timeout_ms; + } + /// Adds |pipeline| to the list of known pipelines. The |pipeline| must have /// a unique name over all pipelines in the script. Result AddPipeline(std::unique_ptr<Pipeline> pipeline) { |