From fb1ade89cc3b73c63c4295d3b2b6eddfd8972a6b Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 11 Dec 2018 15:11:15 -0500 Subject: Merge scripts and executors. (#170) This CL merges the vk and amber Script classes along with the vk and amber Executor classes. --- Android.mk | 6 +- src/CMakeLists.txt | 11 +- src/amber.cc | 11 +- src/amberscript/executor.cc | 36 -- src/amberscript/executor.h | 37 -- src/amberscript/parser.cc | 3 +- src/amberscript/parser.h | 7 +- src/amberscript/parser_test.cc | 59 +-- src/amberscript/pipeline.cc | 144 ------ src/amberscript/pipeline.h | 85 ---- src/amberscript/pipeline_test.cc | 333 ------------- src/amberscript/script.cc | 30 -- src/amberscript/script.h | 85 ---- src/amberscript/script_test.cc | 248 ---------- src/engine.h | 6 +- src/executor.cc | 134 ++++++ src/executor.h | 10 +- src/executor_test.cc | 992 +++++++++++++++++++++++++++++++++++++++ src/pipeline.cc | 142 ++++++ src/pipeline.h | 83 ++++ src/pipeline_test.cc | 331 +++++++++++++ src/script.cc | 2 +- src/script.h | 36 +- src/script_test.cc | 220 ++++++++- src/vkscript/executor.cc | 162 ------- src/vkscript/executor.h | 39 -- src/vkscript/executor_test.cc | 992 --------------------------------------- src/vkscript/parser.cc | 2 +- src/vkscript/parser.h | 8 +- src/vkscript/parser_test.cc | 2 +- src/vkscript/script.cc | 34 -- src/vkscript/script.h | 42 -- 32 files changed, 1969 insertions(+), 2363 deletions(-) delete mode 100644 src/amberscript/executor.cc delete mode 100644 src/amberscript/executor.h delete mode 100644 src/amberscript/pipeline.cc delete mode 100644 src/amberscript/pipeline.h delete mode 100644 src/amberscript/pipeline_test.cc delete mode 100644 src/amberscript/script.cc delete mode 100644 src/amberscript/script.h delete mode 100644 src/amberscript/script_test.cc create mode 100644 src/executor_test.cc create mode 100644 src/pipeline.cc create mode 100644 src/pipeline.h create mode 100644 src/pipeline_test.cc delete mode 100644 src/vkscript/executor.cc delete mode 100644 src/vkscript/executor.h delete mode 100644 src/vkscript/executor_test.cc delete mode 100644 src/vkscript/script.cc delete mode 100644 src/vkscript/script.h diff --git a/Android.mk b/Android.mk index 3c4dfb1..8b85179 100644 --- a/Android.mk +++ b/Android.mk @@ -5,10 +5,7 @@ LOCAL_MODULE:=amber LOCAL_CXXFLAGS:=-std=c++11 -fno-exceptions -fno-rtti LOCAL_SRC_FILES:= \ src/amber.cc \ - src/amberscript/executor.cc \ src/amberscript/parser.cc \ - src/amberscript/pipeline.cc \ - src/amberscript/script.cc \ src/buffer.cc \ src/command.cc \ src/command_data.cc \ @@ -17,6 +14,7 @@ LOCAL_SRC_FILES:= \ src/executor.cc \ src/format.cc \ src/parser.cc \ + src/pipeline.cc \ src/pipeline_data.cc \ src/recipe.cc \ src/result.cc \ @@ -28,10 +26,8 @@ LOCAL_SRC_FILES:= \ src/verifier.cc \ src/vkscript/command_parser.cc \ src/vkscript/datum_type_parser.cc \ - src/vkscript/executor.cc \ src/vkscript/format_parser.cc \ src/vkscript/parser.cc \ - src/vkscript/script.cc \ src/vkscript/section_parser.cc LOCAL_STATIC_LIBRARIES:=glslang SPIRV-Tools shaderc LOCAL_C_INCLUDES:=$(LOCAL_PATH)/include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 230c8db..67184d9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -14,10 +14,7 @@ set(AMBER_SOURCES amber.cc - amberscript/executor.cc amberscript/parser.cc - amberscript/pipeline.cc - amberscript/script.cc buffer.cc command.cc command_data.cc @@ -26,6 +23,7 @@ set(AMBER_SOURCES executor.cc format.cc parser.cc + pipeline.cc pipeline_data.cc recipe.cc result.cc @@ -38,10 +36,8 @@ set(AMBER_SOURCES verifier.cc vkscript/command_parser.cc vkscript/datum_type_parser.cc - vkscript/executor.cc vkscript/format_parser.cc vkscript/parser.cc - vkscript/script.cc vkscript/section_parser.cc ) @@ -78,10 +74,10 @@ endif() if (${AMBER_ENABLE_TESTS}) set(TEST_SRCS amberscript/parser_test.cc - amberscript/pipeline_test.cc - amberscript/script_test.cc buffer_test.cc command_data_test.cc + executor_test.cc + pipeline_test.cc result_test.cc script_test.cc shader_compiler_test.cc @@ -89,7 +85,6 @@ if (${AMBER_ENABLE_TESTS}) verifier_test.cc vkscript/command_parser_test.cc vkscript/datum_type_parser_test.cc - vkscript/executor_test.cc vkscript/format_parser_test.cc vkscript/parser_test.cc vkscript/section_parser_test.cc diff --git a/src/amber.cc b/src/amber.cc index 5cb3309..65ef22d 100644 --- a/src/amber.cc +++ b/src/amber.cc @@ -17,13 +17,11 @@ #include #include -#include "src/amberscript/executor.h" #include "src/amberscript/parser.h" #include "src/engine.h" #include "src/executor.h" #include "src/make_unique.h" #include "src/parser.h" -#include "src/vkscript/executor.h" #include "src/vkscript/parser.h" namespace amber { @@ -81,13 +79,8 @@ amber::Result Amber::ExecuteWithShaderData(const amber::Recipe* recipe, if (!r.IsSuccess()) return r; - std::unique_ptr executor; - if (script->IsVkScript()) - executor = MakeUnique(); - else - executor = MakeUnique(); - - r = executor->Execute(engine.get(), script, shader_data); + Executor executor; + r = executor.Execute(engine.get(), script, shader_data); if (!r.IsSuccess()) return r; diff --git a/src/amberscript/executor.cc b/src/amberscript/executor.cc deleted file mode 100644 index 1c9954b..0000000 --- a/src/amberscript/executor.cc +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 The Amber Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include "src/amberscript/executor.h" - -namespace amber { -namespace amberscript { - -Executor::Executor() : amber::Executor() {} - -Executor::~Executor() = default; - -Result Executor::Execute(Engine*, - const amber::Script* src_script, - const ShaderMap&) { - if (!src_script->IsAmberScript()) - return Result("AmberScript executor called with non-amber script source"); - - // const amberscript::Script* script = ToAmberScript(src_script); - - return {}; -} - -} // namespace amberscript -} // namespace amber diff --git a/src/amberscript/executor.h b/src/amberscript/executor.h deleted file mode 100644 index 71b6098..0000000 --- a/src/amberscript/executor.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2018 The Amber Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef SRC_AMBERSCRIPT_EXECUTOR_H_ -#define SRC_AMBERSCRIPT_EXECUTOR_H_ - -#include "amber/result.h" -#include "src/engine.h" -#include "src/executor.h" -#include "src/script.h" - -namespace amber { -namespace amberscript { - -class Executor : public amber::Executor { - public: - Executor(); - ~Executor() override; - - Result Execute(Engine*, const amber::Script*, const ShaderMap&) override; -}; - -} // namespace amberscript -} // namespace amber - -#endif // SRC_AMBERSCRIPT_EXECUTOR_H_ diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc index d45c52a..2e004cb 100644 --- a/src/amberscript/parser.cc +++ b/src/amberscript/parser.cc @@ -27,8 +27,7 @@ namespace amber { namespace amberscript { -Parser::Parser() - : amber::Parser(), script_(MakeUnique()) {} +Parser::Parser() : amber::Parser(), script_(MakeUnique