diff options
32 files changed, 703 insertions, 578 deletions
diff --git a/src/amber.cc b/src/amber.cc index 255e6dd..c6cbe5f 100644 --- a/src/amber.cc +++ b/src/amber.cc @@ -151,16 +151,15 @@ amber::Result Amber::ExecuteWithShaderData(const amber::Recipe* recipe, if (!r.IsSuccess()) break; - ResourceInfo info = ResourceInfo(); - r = engine->GetDescriptorInfo( - pipeline, desc_set_and_binding_parser.GetDescriptorSet(), - desc_set_and_binding_parser.GetBinding(), &info); - if (!r.IsSuccess()) + const auto* buffer = pipeline->GetBufferForBinding( + desc_set_and_binding_parser.GetDescriptorSet(), + desc_set_and_binding_parser.GetBinding()); + if (!buffer) break; - const uint8_t* ptr = static_cast<const uint8_t*>(info.cpu_memory); + const uint8_t* ptr = static_cast<const uint8_t*>(buffer->GetMemPtr()); auto& values = buffer_info.values; - for (size_t i = 0; i < info.size_in_bytes; ++i) { + for (size_t i = 0; i < buffer->GetSize(); ++i) { values.emplace_back(); values.back().SetIntValue(*ptr); ++ptr; diff --git a/src/buffer.h b/src/buffer.h index 652a792..8833202 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -35,6 +35,9 @@ class FormatBuffer; /// maybe created as needed. A buffer must have a unique name. class Buffer { public: + /// Create a buffer of |type_|. + explicit Buffer(BufferType type); + virtual ~Buffer(); /// Returns |true| if this is a buffer described by a |DatumType|. @@ -75,7 +78,7 @@ class Buffer { void SetHeight(uint32_t height) { height_ = height; } /// Returns the number of bytes needed for the data in the buffer. - virtual uint32_t GetSizeInBytes() const = 0; + virtual uint32_t GetSizeInBytes() const { return size_; } /// Sets the data into the buffer. The size will also be updated to be the /// size of the data provided. @@ -84,13 +87,24 @@ class Buffer { const std::vector<Value>& GetData() const { return data_; } void SetMemPtr(void* ptr) { mem_ptr_ = ptr; } - void* GetMemPtr() const { return mem_ptr_; } + + const void* GetMemPtr() const { + if (mem_ptr_ == nullptr && !values_.empty()) + return values_.data(); + return mem_ptr_; + } + + void* GetMemPtr() { + if (mem_ptr_ == nullptr && !values_.empty()) + return values_.data(); + return mem_ptr_; + } + + std::vector<uint8_t>* ValuePtr() { return &values_; } protected: /// Create an un-typed buffer. Buffer(); - /// Create a buffer of |type_|. - explicit Buffer(BufferType type); private: BufferType buffer_type_ = BufferType::kUnknown; @@ -101,6 +115,7 @@ class Buffer { uint32_t height_ = 0; uint8_t location_ = 0; void* mem_ptr_ = nullptr; + std::vector<uint8_t> values_; }; /// A buffer class where the data is described by a |DatumType| object. diff --git a/src/command.h b/src/command.h index 0500b34..5a5f8b7 100644 --- a/src/command.h +++ b/src/command.h @@ -367,7 +367,11 @@ class BufferCommand : public Command { } const std::vector<Value>& GetValues() const { return values_; } + void SetBuffer(Buffer* buffer) { buffer_ = buffer; } + Buffer* GetBuffer() const { return buffer_; } + private: + Buffer* buffer_ = nullptr; BufferType buffer_type_; bool is_subdata_ = false; uint32_t descriptor_set_ = 0; diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index f045bf6..115e824 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -453,12 +453,5 @@ Result EngineDawn::GetFrameBuffer(Buffer*, std::vector<Value>*) { return Result("Dawn::GetFrameBuffer not implemented"); } -Result EngineDawn::GetDescriptorInfo(Pipeline*, - const uint32_t, - const uint32_t, - ResourceInfo*) { - return Result("Dawn:GetDescriptorInfo not implemented"); -} - } // namespace dawn } // namespace amber diff --git a/src/dawn/engine_dawn.h b/src/dawn/engine_dawn.h index 9bf81de..e03ccea 100644 --- a/src/dawn/engine_dawn.h +++ b/src/dawn/engine_dawn.h @@ -62,10 +62,6 @@ class EngineDawn : public Engine { Result DoBuffer(const BufferCommand* cmd) override; Result DoProcessCommands(Pipeline*) override; Result GetFrameBuffer(Buffer*, std::vector<Value>* values) override; - Result GetDescriptorInfo(Pipeline*, - const uint32_t descriptor_set, - const uint32_t binding, - ResourceInfo* info) override; private: // Creates a command buffer builder if it doesn't already exist. diff --git a/src/engine.h b/src/engine.h index 0a0bdaf..cdd5af2 100644 --- a/src/engine.h +++ b/src/engine.h @@ -34,20 +34,6 @@ struct EngineData { uint32_t fence_timeout_ms = 100; }; -/// Contains information relating to a backing resource from the engine. -struct ResourceInfo { - /// The size in bytes of Vulkan memory pointed by |cpu_memory|. - /// For the case when it is an image resource, |size_in_bytes| must - /// be |image_info.row_stride * image_info.height * image_info.depth|. - size_t size_in_bytes = 0; - - /// If the primitive type of resource is the same with the type - /// of actual data, the alignment must be properly determined by - /// Vulkan's internal memory allocation. In these cases, script - /// writers can assume that there is no alignment issues. - const void* cpu_memory = nullptr; -}; - /// Abstract class which describes a backing engine for Amber. class Engine { public: @@ -115,15 +101,6 @@ class Engine { /// in R8G8B8A8 format. virtual Result GetFrameBuffer(Buffer* buffer, std::vector<Value>* values) = 0; - /// Copy the contents of the resource bound to the given descriptor - /// and get the resource information e.g., size for buffer, width, - /// height, depth for image of descriptor given as |descriptor_set| - /// and |binding|. - virtual Result GetDescriptorInfo(Pipeline* pipeline, - const uint32_t descriptor_set, - const uint32_t binding, - ResourceInfo* info) = 0; - /// Sets the engine data to use. void SetEngineData(const EngineData& data) { engine_data_ = data; } diff --git a/src/executor.cc b/src/executor.cc index 50341f3..a3ec347 100644 --- a/src/executor.cc +++ b/src/executor.cc @@ -19,6 +19,7 @@ #include <vector> #include "src/engine.h" +#include "src/make_unique.h" #include "src/script.h" #include "src/shader_compiler.h" @@ -86,18 +87,22 @@ Result Executor::Execute(Engine* engine, buffer->GetMemPtr()); } else if (cmd->IsProbeSSBO()) { auto probe_ssbo = cmd->AsProbeSSBO(); - ResourceInfo info; - r = engine->GetDescriptorInfo(cmd->GetPipeline(), - probe_ssbo->GetDescriptorSet(), - probe_ssbo->GetBinding(), &info); - if (!r.IsSuccess()) - return r; + + const auto* buffer = cmd->GetPipeline()->GetBufferForBinding( + probe_ssbo->GetDescriptorSet(), probe_ssbo->GetBinding()); + if (!buffer) { + return Result("unable to find buffer at descriptor set " + + std::to_string(probe_ssbo->GetDescriptorSet()) + + " and binding " + + std::to_string(probe_ssbo->GetBinding())); + } r = engine->DoProcessCommands(cmd->GetPipeline()); if (!r.IsSuccess()) return r; - r = verifier_.ProbeSSBO(probe_ssbo, info.size_in_bytes, info.cpu_memory); + r = verifier_.ProbeSSBO(probe_ssbo, buffer->GetSize(), + buffer->GetMemPtr()); } else if (cmd->IsClear()) { r = engine->DoClear(cmd->AsClear()); } else if (cmd->IsClearColor()) { diff --git a/src/executor_test.cc b/src/executor_test.cc index 0537f4e..7a93fd1 100644 --- a/src/executor_test.cc +++ b/src/executor_test.cc @@ -162,12 +162,6 @@ class EngineStub : public Engine { Result DoProcessCommands(Pipeline*) override { return {}; } Result GetFrameBuffer(Buffer*, std::vector<Value>*) override { return {}; } - Result GetDescriptorInfo(Pipeline*, - const uint32_t, - const uint32_t, - ResourceInfo*) override { - return {}; - } private: bool fail_clear_command_ = false; diff --git a/src/pipeline.cc b/src/pipeline.cc index ddfdf21..b7e2780 100644 --- a/src/pipeline.cc +++ b/src/pipeline.cc @@ -214,6 +214,17 @@ Result Pipeline::AddColorAttachment(Buffer* buf, uint32_t location) { return {}; } +Result Pipeline::GetLocationForColorAttachment(Buffer* buf, + uint32_t* loc) const { + for (const auto& info : color_attachments_) { + if (info.buffer == buf) { + *loc = info.location; + return {}; + } + } + return Result("Unable to find requested buffer"); +} + Result Pipeline::SetDepthBuffer(Buffer* buf) { if (depth_buffer_.buffer != nullptr) return Result("can only bind one depth buffer in a PIPELINE"); @@ -268,4 +279,13 @@ std::unique_ptr<Buffer> Pipeline::GenerateDefaultDepthAttachmentBuffer() const { return buf; } +Buffer* Pipeline::GetBufferForBinding(uint32_t descriptor_set, + uint32_t binding) const { + for (const auto& info : buffers_) { + if (info.descriptor_set == descriptor_set && info.binding == binding) + return info.buffer; + } + return nullptr; +} + } // namespace amber diff --git a/src/pipeline.h b/src/pipeline.h index 645e882..903c2c3 100644 --- a/src/pipeline.h +++ b/src/pipeline.h @@ -112,6 +112,7 @@ class Pipeline { return color_attachments_; } Result AddColorAttachment(Buffer* buf, uint32_t location); + Result GetLocationForColorAttachment(Buffer* buf, uint32_t* loc) const; Result SetDepthBuffer(Buffer* buf); const BufferInfo& GetDepthBuffer() const { return depth_buffer_; } @@ -137,6 +138,8 @@ class Pipeline { } const std::vector<BufferInfo>& GetBuffers() const { return buffers_; } + Buffer* GetBufferForBinding(uint32_t descriptor_set, uint32_t binding) const; + // Validates that the pipeline has been created correctly. Result Validate() const; diff --git a/src/verifier.cc b/src/verifier.cc index d0bbd0a..ac0f80d 100644 --- a/src/verifier.cc +++ b/src/verifier.cc @@ -656,7 +656,6 @@ Result Verifier::ProbeSSBO(const ProbeSSBOCommand* command, size_t bytes_per_elem = datum_type.SizeInBytes() / datum_type.RowCount() / datum_type.ColumnCount(); size_t offset = static_cast<size_t>(command->GetOffset()); - if (values.size() * bytes_per_elem + offset > size_in_bytes) { return Result( "Line " + std::to_string(command->GetLine()) + diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index fd75b08..97b9294 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -47,10 +47,13 @@ ShaderType ShaderNameToType(const std::string& name) { } // namespace -CommandParser::CommandParser(Pipeline* pipeline, +CommandParser::CommandParser(Script* script, + Pipeline* pipeline, size_t current_line, const std::string& data) - : pipeline_(pipeline), tokenizer_(MakeUnique<Tokenizer>(data)) { + : script_(script), + pipeline_(pipeline), + tokenizer_(MakeUnique<Tokenizer>(data)) { tokenizer_->SetCurrentLine(current_line); } @@ -581,6 +584,22 @@ Result CommandParser::ProcessSSBO() { cmd->SetBinding(val); } + { + // Generate an internal buffer for this binding if needed. + auto set = cmd->GetDescriptorSet(); + auto binding = cmd->GetBinding(); + + auto* buffer = pipeline_->GetBufferForBinding(set, binding); + if (!buffer) { + auto b = MakeUnique<Buffer>(BufferType::kStorage); + b->SetName("AutoBuf-" + std::to_string(script_->GetBuffers().size())); + buffer = b.get(); + script_->AddBuffer(std::move(b)); + pipeline_->AddBuffer(buffer, set, binding, 0); + } + cmd->SetBuffer(buffer); + } + if (token->IsString() && token->AsString() == "subdata") { cmd->SetIsSubdata(); @@ -686,6 +705,22 @@ Result CommandParser::ProcessUniform() { cmd->SetBinding(val); } + { + // Generate an internal buffer for this binding if needed. + auto set = cmd->GetDescriptorSet(); + auto binding = cmd->GetBinding(); + + auto* buffer = pipeline_->GetBufferForBinding(set, binding); + if (!buffer) { + auto b = MakeUnique<Buffer>(BufferType::kUniform); + b->SetName("AutoBuf-" + std::to_string(script_->GetBuffers().size())); + buffer = b.get(); + script_->AddBuffer(std::move(b)); + pipeline_->AddBuffer(buffer, set, binding, 0); + } + cmd->SetBuffer(buffer); + } + use_std430_layout = true; } else { cmd = MakeUnique<BufferCommand>(BufferCommand::BufferType::kPushConstant, diff --git a/src/vkscript/command_parser.h b/src/vkscript/command_parser.h index 6bd7e6f..5f1b23e 100644 --- a/src/vkscript/command_parser.h +++ b/src/vkscript/command_parser.h @@ -25,6 +25,7 @@ #include "src/datum_type.h" #include "src/pipeline.h" #include "src/pipeline_data.h" +#include "src/script.h" namespace amber { @@ -35,7 +36,8 @@ namespace vkscript { class CommandParser { public: - CommandParser(Pipeline* pipeline, + CommandParser(Script* script, + Pipeline* pipeline, size_t current_line, const std::string& data); ~CommandParser(); @@ -158,6 +160,7 @@ class CommandParser { Result ParseComparator(const std::string& name, ProbeSSBOCommand::Comparator* op); + Script* script_; Pipeline* pipeline_; PipelineData pipeline_data_; std::unique_ptr<Tokenizer> tokenizer_; diff --git a/src/vkscript/command_parser_test.cc b/src/vkscript/command_parser_test.cc index 13f1196..dd0838d 100644 --- a/src/vkscript/command_parser_test.cc +++ b/src/vkscript/command_parser_test.cc @@ -31,7 +31,8 @@ clear # done)"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -68,7 +69,8 @@ TEST_F(CommandParserTest, DrawRect) { std::string data = "draw rect 1.2 2.3 200 400.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -89,7 +91,8 @@ TEST_F(CommandParserTest, DrawRectWithOrth) { std::string data = "draw rect ortho 1.2 2.3 200 400.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -110,7 +113,8 @@ TEST_F(CommandParserTest, DrawRectWithPatch) { std::string data = "draw rect patch 1.2 2.3 200 400.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -131,7 +135,8 @@ TEST_F(CommandParserTest, DrawRectWithOrthAndPatch) { std::string data = "draw rect ortho patch 1.2 2.3 200 400.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -152,7 +157,8 @@ TEST_F(CommandParserTest, DrawRectTooShort) { std::string data = "draw rect 1.2 2.3 400.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -162,7 +168,8 @@ TEST_F(CommandParserTest, DrawRectExtraParameters) { std::string data = "draw rect ortho patch 1.2 2.3 200 400.2 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to draw rect command: EXTRA", r.Error()); @@ -172,7 +179,8 @@ TEST_F(CommandParserTest, DrawArrays) { std::string data = "draw arrays GL_LINES 2 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -193,7 +201,8 @@ TEST_F(CommandParserTest, DrawArraysIndexed) { std::string data = "draw arrays indexed TRIANGLE_FAN 2 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -214,7 +223,8 @@ TEST_F(CommandParserTest, DrawArraysExtraParams) { std::string data = "draw arrays indexed TRIANGLE_FAN 2 4 EXTRA_PARAM"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to draw arrays command: EXTRA_PARAM", @@ -225,7 +235,8 @@ TEST_F(CommandParserTest, DrawArraysInstanced) { std::string data = "draw arrays instanced LINE_LIST_WITH_ADJACENCY 2 9"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -247,7 +258,8 @@ TEST_F(CommandParserTest, DrawArraysInstancedExtraParams) { "draw arrays instanced LINE_LIST_WITH_ADJACENCY 2 9 4 EXTRA_COMMAND"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to draw arrays command: EXTRA_COMMAND", @@ -259,7 +271,8 @@ TEST_F(CommandParserTest, DrawArraysIndexedAndInstanced) { "draw arrays indexed instanced LINE_LIST_WITH_ADJACENCY 3 9"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -280,7 +293,8 @@ TEST_F(CommandParserTest, DrawArraysInstancedWithCount) { std::string data = "draw arrays instanced LINE_LIST_WITH_ADJACENCY 3 9 12"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -301,7 +315,8 @@ TEST_F(CommandParserTest, DrawArraysBadTopology) { std::string data = "draw arrays UNKNOWN_TOPO 1 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Unknown parameter to draw arrays: UNKNOWN_TOPO", r.Error()); @@ -311,7 +326,8 @@ TEST_F(CommandParserTest, DrawArraysTooShort) { std::string data = "draw arrays PATCH_LIST 1"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing integer vertex count value for draw arrays: ", @@ -322,7 +338,8 @@ TEST_F(CommandParserTest, DrawArraysInstanceCountWithoutInstanced) { std::string data = "draw arrays PATCH_LIST 1 2 3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to draw arrays command: 3", r.Error()); @@ -332,7 +349,8 @@ TEST_F(CommandParserTest, DrawArraysMissingTopology) { std::string data = "draw arrays 1 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing draw arrays topology", r.Error()); @@ -342,7 +360,8 @@ TEST_F(CommandParserTest, Compute) { std::string data = "compute 1 2 3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -360,7 +379,8 @@ TEST_F(CommandParserTest, ComputeTooShort) { std::string data = "compute 1 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing integer value for compute Z entry: ", r.Error()); @@ -370,7 +390,8 @@ TEST_F(CommandParserTest, ComputeInvalidX) { std::string data = "compute 1.2 2 3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing integer value for compute X entry: 1.2", r.Error()); @@ -380,7 +401,8 @@ TEST_F(CommandParserTest, ComputeInvalidY) { std::string data = "compute 1 a 3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing integer value for compute Y entry: a", r.Error()); @@ -390,7 +412,8 @@ TEST_F(CommandParserTest, ComputeInvalidZ) { std::string data = "compute 1 2 1.5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing integer value for compute Z entry: 1.5", r.Error()); @@ -400,7 +423,8 @@ TEST_F(CommandParserTest, ComputeExtraCommands) { std::string data = "compute 1 2 3 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to compute command: EXTRA", r.Error()); @@ -410,7 +434,8 @@ TEST_F(CommandParserTest, Clear) { std::string data = "clear"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -423,7 +448,8 @@ TEST_F(CommandParserTest, ClearExtraParams) { std::string data = "clear EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to clear command: EXTRA", r.Error()); @@ -433,7 +459,8 @@ TEST_F(CommandParserTest, ClearDepth) { std::string data = "clear depth 0.8"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -449,7 +476,8 @@ TEST_F(CommandParserTest, ClearDepthMissingValue) { std::string data = "clear depth"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -459,7 +487,8 @@ TEST_F(CommandParserTest, ClearDepthExtraParameters) { std::string data = "clear depth 0.2 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to clear depth command: EXTRA", r.Error()); @@ -469,7 +498,8 @@ TEST_F(CommandParserTest, ClearStencil) { std::string data = "clear stencil 8"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -485,7 +515,8 @@ TEST_F(CommandParserTest, ClearStencilMissingValue) { std::string data = "clear stencil"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing stencil value for clear stencil command: ", r.Error()); @@ -495,7 +526,8 @@ TEST_F(CommandParserTest, ClearStencilExtraParameters) { std::string data = "clear stencil 2 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to clear stencil command: EXTRA", r.Error()); @@ -505,7 +537,8 @@ TEST_F(CommandParserTest, ClearStencilNotInteger) { std::string data = "clear stencil 2.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid stencil value for clear stencil command: 2.3", @@ -516,7 +549,8 @@ TEST_F(CommandParserTest, ClearColor) { std::string data = "clear color 0.8 0.4 0.2 1.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -535,7 +569,8 @@ TEST_F(CommandParserTest, ClearColorMissingParams) { std::string data = "clear color 0.8 0.4 0.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -545,7 +580,8 @@ TEST_F(CommandParserTest, ClearColorExtraParams) { std::string data = "clear color 0.8 0.4 0.2 1.3 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter to clear color command: EXTRA", r.Error()); @@ -555,7 +591,8 @@ TEST_F(CommandParserTest, ClearColorBadR) { std::string data = "clear color a 0.4 0.2 0.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -565,7 +602,8 @@ TEST_F(CommandParserTest, ClearColorBadG) { std::string data = "clear color 0.2 a 0.2 0.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -575,7 +613,8 @@ TEST_F(CommandParserTest, ClearColorBadB) { std::string data = "clear color 0.2 0.4 a 0.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -585,7 +624,8 @@ TEST_F(CommandParserTest, ClearColorBadA) { std::string data = "clear color 0.2 0.4 0.2 a"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -595,7 +635,8 @@ TEST_F(CommandParserTest, PatchParameterVertices) { std::string data = "patch parameter vertices 9"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -611,7 +652,8 @@ TEST_F(CommandParserTest, PatchParameterVerticesMissingParameter) { std::string data = "patch vertices 5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing parameter flag to patch command: vertices", r.Error()); @@ -621,7 +663,8 @@ TEST_F(CommandParserTest, PatchParameterVerticesMissingVertices) { std::string data = "patch parameter 5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing vertices flag to patch command: 5", r.Error()); @@ -631,7 +674,8 @@ TEST_F(CommandParserTest, PatchParameterVerticesMissingParam) { std::string data = "patch parameter vertices"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid count parameter for patch parameter vertices: ", @@ -642,7 +686,8 @@ TEST_F(CommandParserTest, PatchParameterVerticesInvalidParam) { std::string data = "patch parameter vertices invalid"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid count parameter for patch parameter vertices: invalid", @@ -653,7 +698,8 @@ TEST_F(CommandParserTest, PatchParameterVerticesExtraParam) { std::string data = "patch parameter vertices 3 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter for patch parameter vertices command: EXTRA", @@ -678,7 +724,8 @@ TEST_F(CommandParserTest, EntryPoint) { std::string data = std::string(ep.name) + " entrypoint main"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -697,7 +744,8 @@ TEST_F(CommandParserTest, EntryPointNameMissing) { std::string data = std::string(ep.name) + " entrypoint"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing entrypoint name", r.Error()); @@ -713,7 +761,8 @@ TEST_F(CommandParserTest, EntryPointEntryPointMissing) { std::string data = std::string(ep.name) + " main"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Unknown command: " + std::string(ep.name), r.Error()); @@ -725,7 +774,8 @@ TEST_F(CommandParserTest, EntryPointExtraParam) { std::string data = std::string(ep.name) + " entrypoint main EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter for entrypoint command: EXTRA", r.Error()); @@ -737,7 +787,8 @@ TEST_F(CommandParserTest, EntryPointInvalidValue) { std::string data = std::string(ep.name) + " entrypoint 123"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Entrypoint name must be a string: 123", r.Error()); @@ -748,7 +799,8 @@ TEST_F(CommandParserTest, TessellationEntryPointRequiresASuffix) { std::string data = "tessellation entrypoint main"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -761,7 +813,8 @@ TEST_F(CommandParserTest, TessellationEntryPointRequiresAKnownSuffix) { std::string data = "tessellation unknown entrypoint main"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -774,7 +827,8 @@ TEST_F(CommandParserTest, InvalidEntryPoint) { std::string data = "unknown entrypoint main"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Unknown command: unknown", r.Error()); @@ -792,7 +846,8 @@ TEST_P(CommandParserProbeTest, ProbeRgb) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << data << std::endl << r.Error(); @@ -826,7 +881,8 @@ TEST_P(CommandParserProbeTest, ProbeRgba) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << data << std::endl << r.Error(); @@ -861,7 +917,8 @@ TEST_P(CommandParserProbeTest, ProbeRect) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << data << std::endl << r.Error(); @@ -896,7 +953,8 @@ TEST_P(CommandParserProbeTest, ProbeNotRect) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << data << std::endl << r.Error(); @@ -933,7 +991,8 @@ TEST_F(CommandParserTest, ProbeAllRGB) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -959,7 +1018,8 @@ TEST_F(CommandParserTest, ProbeAllRGBA) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -986,7 +1046,8 @@ TEST_F(CommandParserTest, ProbeCommandRectBrackets) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -1017,7 +1078,8 @@ TEST_F(CommandParserTest, ProbeCommandNotRectBrackets) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -1048,7 +1110,8 @@ TEST_F(CommandParserTest, ProbeCommandColorBrackets) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -1079,7 +1142,8 @@ TEST_F(CommandParserTest, ProbeCommandColorOptionalCommas) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -1212,7 +1276,8 @@ TEST_F(CommandParserTest, ProbeErrors) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, probe.str); + Script script; + CommandParser cp(&script, &pipeline, 1, probe.str); Result r = cp.Parse(); EXPECT_FALSE(r.IsSuccess()) << probe.str; EXPECT_EQ(std::string("1: ") + probe.err, r.Error()) << probe.str; @@ -1223,7 +1288,8 @@ TEST_F(CommandParserTest, RelativeWithoutProbe) { std::string data = "relative unknown"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: relative must be used with probe: unknown", r.Error()); @@ -1236,7 +1302,8 @@ TEST_F(CommandParserTest, ProbeWithInvalidRGBA) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid token in probe command: 1", r.Error()); @@ -1249,7 +1316,8 @@ TEST_F(CommandParserTest, ProbeWithRectAndInvalidRGB) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid token in probe command: 1", r.Error()); @@ -1262,7 +1330,8 @@ TEST_F(CommandParserTest, ProbeWithRectMissingFormat) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid format specified to probe command: unknown", r.Error()); @@ -1275,7 +1344,8 @@ TEST_F(CommandParserTest, ProbeAllMissingFormat) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid format specified to probe command: unknown", r.Error()); @@ -1288,7 +1358,8 @@ TEST_F(CommandParserTest, ProbeAlWithInvalidRGB) { auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid format specified to probe command: unknown", r.Error()); @@ -1307,7 +1378,8 @@ TEST_P(CommandDataPipelineTopologyParser, Topology) { std::string data = "topology " + std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(test_data.value, cp.PipelineDataForTesting()->GetTopology()); @@ -1355,7 +1427,8 @@ TEST_P(CommandDataPipelineDataInvalidParser, InvalidPipelineParamValue) { std::string data = std::string(test_data.name) + " 123"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -1369,7 +1442,8 @@ TEST_P(CommandDataPipelineDataInvalidParser, MissingTopologyValue) { std::string data = test_data.name; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Missing value for ") + test_data.name + " command", @@ -1382,7 +1456,8 @@ TEST_P(CommandDataPipelineDataInvalidParser, UnknownPipelineParamValue) { std::string data = std::string(test_data.name) + " UNKNOWN"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Unknown value for ") + test_data.name + @@ -1401,7 +1476,8 @@ TEST_P(CommandDataPipelineDataInvalidParser, ExtraPipelineParamValue) { std::string(test_data.name) + " " + test_data.arg + " EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -1427,7 +1503,8 @@ TEST_F(CommandParserTest, BooleanTrue) { for (const auto& d : data) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); bool value = false; Result r = cp.ParseBooleanForTesting(d.name, &value); @@ -1443,7 +1520,8 @@ TEST_F(CommandParserTest, BooleanFalse) { for (const auto& d : data) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); bool value = true; Result r = cp.ParseBooleanForTesting(d.name, &value); @@ -1459,7 +1537,8 @@ TEST_F(CommandParserTest, BooleanInvalid) { for (const auto& d : data) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); bool value = true; Result r = cp.ParseBooleanForTesting(d.name, &value); @@ -1474,7 +1553,8 @@ TEST_F(CommandParserTest, PrimitiveRestartEnable) { std::string data = "primitiveRestartEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnablePrimitiveRestart()); @@ -1484,7 +1564,8 @@ TEST_F(CommandParserTest, PrimitiveRestartDisable) { std::string data = "primitiveRestartEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnablePrimitiveRestart()); @@ -1494,7 +1575,8 @@ TEST_F(CommandParserTest, DepthClampEnable) { std::string data = "depthClampEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableDepthClamp()); @@ -1504,7 +1586,8 @@ TEST_F(CommandParserTest, DepthClampDisable) { std::string data = "depthClampEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableDepthClamp()); @@ -1514,7 +1597,8 @@ TEST_F(CommandParserTest, RasterizerDiscardEnable) { std::string data = "rasterizerDiscardEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableRasterizerDiscard()); @@ -1524,7 +1608,8 @@ TEST_F(CommandParserTest, RasterizerDiscardDisable) { std::string data = "rasterizerDiscardEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableRasterizerDiscard()); @@ -1534,7 +1619,8 @@ TEST_F(CommandParserTest, DepthBiasEnable) { std::string data = "depthBiasEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableDepthBias()); @@ -1544,7 +1630,8 @@ TEST_F(CommandParserTest, DepthBiasDisable) { std::string data = "depthBiasEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableDepthBias()); @@ -1554,7 +1641,8 @@ TEST_F(CommandParserTest, LogicOpEnable) { std::string data = "logicOpEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableLogicOp()); @@ -1564,7 +1652,8 @@ TEST_F(CommandParserTest, LogicOpDisable) { std::string data = "logicOpEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableLogicOp()); @@ -1574,7 +1663,8 @@ TEST_F(CommandParserTest, BlendEnable) { std::string data = "blendEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableBlend()); @@ -1584,7 +1674,8 @@ TEST_F(CommandParserTest, BlendDisable) { std::string data = "blendEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableBlend()); @@ -1594,7 +1685,8 @@ TEST_F(CommandParserTest, DepthTestEnable) { std::string data = "depthTestEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableDepthTest()); @@ -1604,7 +1696,8 @@ TEST_F(CommandParserTest, DepthTestDisable) { std::string data = "depthTestEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableDepthTest()); @@ -1614,7 +1707,8 @@ TEST_F(CommandParserTest, DepthWriteEnable) { std::string data = "depthWriteEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableDepthWrite()); @@ -1624,7 +1718,8 @@ TEST_F(CommandParserTest, DepthWriteDisable) { std::string data = "depthWriteEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableDepthWrite()); @@ -1634,7 +1729,8 @@ TEST_F(CommandParserTest, DepthBoundsTestEnable) { std::string data = "depthBoundsTestEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableDepthBoundsTest()); @@ -1644,7 +1740,8 @@ TEST_F(CommandParserTest, DepthBoundsTestDisable) { std::string data = "depthBoundsTestEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableDepthBoundsTest()); @@ -1654,7 +1751,8 @@ TEST_F(CommandParserTest, StencilTestEnable) { std::string data = "stencilTestEnable true"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_TRUE(cp.PipelineDataForTesting()->GetEnableStencilTest()); @@ -1664,7 +1762,8 @@ TEST_F(CommandParserTest, StencilTestDisable) { std::string data = "stencilTestEnable false"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FALSE(cp.PipelineDataForTesting()->GetEnableStencilTest()); @@ -1681,7 +1780,8 @@ TEST_P(CommandParserBooleanTests, MissingParam) { std::string data = std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Missing value for ") + test_data.name + " command", @@ -1694,7 +1794,8 @@ TEST_P(CommandParserBooleanTests, IllegalParam) { std::string data = std::string(test_data.name) + " 123"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -1708,7 +1809,8 @@ TEST_P(CommandParserBooleanTests, ExtraParam) { std::string data = std::string(test_data.name) + " true EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -1744,7 +1846,8 @@ TEST_P(CommandDataPipelinePolygonModeParser, PolygonMode) { std::string data = "polygonMode " + std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(test_data.value, cp.PipelineDataForTesting()->GetPolygonMode()); @@ -1773,7 +1876,8 @@ TEST_P(CommandDataPipelineCullModeParser, CullMode) { std::string data = "cullMode " + std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(test_data.value, cp.PipelineDataForTesting()->GetCullMode()); @@ -1807,7 +1911,8 @@ TEST_P(CommandDataPipelineFrontFaceParser, FrontFace) { std::string data = "frontFace " + std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(test_data.value, cp.PipelineDataForTesting()->GetFrontFace()); @@ -1836,7 +1941,8 @@ TEST_P(CommandDataPipelineLogicOpParser, LogicOp) { std::string data = "logicOp " + std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(test_data.value, cp.PipelineDataForTesting()->GetLogicOp()); @@ -1868,7 +1974,8 @@ TEST_F(CommandParserTest, DepthBiasConstantFactor) { std::string data = "depthBiasConstantFactor 3.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FLOAT_EQ(3.4f, @@ -1879,7 +1986,8 @@ TEST_F(CommandParserTest, DepthBiasClamp) { std::string data = "depthBiasClamp 3.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FLOAT_EQ(3.4f, cp.PipelineDataForTesting()->GetDepthBiasClamp()); @@ -1889,7 +1997,8 @@ TEST_F(CommandParserTest, DepthBiasSlopeFactor) { std::string data = "depthBiasSlopeFactor 3.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FLOAT_EQ(3.4f, cp.PipelineDataForTesting()->GetDepthBiasSlopeFactor()); @@ -1899,7 +2008,8 @@ TEST_F(CommandParserTest, LineWidth) { std::string data = "lineWidth 3.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FLOAT_EQ(3.4f, cp.PipelineDataForTesting()->GetLineWidth()); @@ -1909,7 +2019,8 @@ TEST_F(CommandParserTest, MinDepthBounds) { std::string data = "minDepthBounds 3.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FLOAT_EQ(3.4f, cp.PipelineDataForTesting()->GetMinDepthBounds()); @@ -1919,7 +2030,8 @@ TEST_F(CommandParserTest, MaxDepthBounds) { std::string data = "maxDepthBounds 3.4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_FLOAT_EQ(3.4f, cp.PipelineDataForTesting()->GetMaxDepthBounds()); @@ -1936,7 +2048,8 @@ TEST_P(CommandParserFloatTests, MissingParam) { std::string data = std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Missing value for ") + test_data.name + " command", @@ -1949,7 +2062,8 @@ TEST_P(CommandParserFloatTests, IllegalParam) { std::string data = std::string(test_data.name) + " INVALID"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid conversion to double", r.Error()); @@ -1961,7 +2075,8 @@ TEST_P(CommandParserFloatTests, ExtraParam) { std::string data = std::string(test_data.name) + " 3.2 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -1984,7 +2099,8 @@ TEST_F(CommandParserTest, SrcColorBlendFactor) { std::string data = "srcColorBlendFactor VK_BLEND_FACTOR_DST_COLOR"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(BlendFactor::kDstColor, @@ -1995,7 +2111,8 @@ TEST_F(CommandParserTest, DstColorBlendFactor) { std::string data = "dstColorBlendFactor VK_BLEND_FACTOR_DST_COLOR"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(BlendFactor::kDstColor, @@ -2006,7 +2123,8 @@ TEST_F(CommandParserTest, SrcAlphaBlendFactor) { std::string data = "srcAlphaBlendFactor VK_BLEND_FACTOR_DST_COLOR"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(BlendFactor::kDstColor, @@ -2017,7 +2135,8 @@ TEST_F(CommandParserTest, DstAlphaBlendFactor) { std::string data = "dstAlphaBlendFactor VK_BLEND_FACTOR_DST_COLOR"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(BlendFactor::kDstColor, @@ -2034,7 +2153,8 @@ TEST_P(CommandParserBlendFactorParsing, Parse) { const auto& test_data = GetParam(); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); BlendFactor factor = BlendFactor::kZero; Result r = cp.ParseBlendFactorNameForTesting(test_data.name, &factor); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2079,7 +2199,8 @@ INSTANTIATE_TEST_CASE_P( TEST_F(CommandParserTest, BlendFactorParsingInvalid) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); BlendFactor factor = BlendFactor::kZero; Result r = cp.ParseBlendFactorNameForTesting("INVALID", &factor); ASSERT_FALSE(r.IsSuccess()); @@ -2097,7 +2218,8 @@ TEST_P(CommandParserBlendFactorTests, MissingParam) { std::string data = std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -2111,7 +2233,8 @@ TEST_P(CommandParserBlendFactorTests, IllegalParam) { std::string data = std::string(test_data.name) + " 1.23"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Invalid parameter for ") + test_data.name + @@ -2125,7 +2248,8 @@ TEST_P(CommandParserBlendFactorTests, ExtraParam) { std::string data = std::string(test_data.name) + " VK_BLEND_FACTOR_ONE EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -2147,7 +2271,8 @@ TEST_F(CommandParserTest, ColorBlendOp) { std::string data = "colorBlendOp VK_BLEND_OP_XOR_EXT"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(BlendOp::kXor, cp.PipelineDataForTesting()->GetColorBlendOp()); @@ -2157,7 +2282,8 @@ TEST_F(CommandParserTest, AlphaBlendOp) { std::string data = "alphaBlendOp VK_BLEND_OP_XOR_EXT"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(BlendOp::kXor, cp.PipelineDataForTesting()->GetAlphaBlendOp()); @@ -2173,7 +2299,8 @@ TEST_P(CommandParserBlendOpParsing, Parse) { const auto& test_data = GetParam(); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); BlendOp op = BlendOp::kAdd; Result r = cp.ParseBlendOpNameForTesting(test_data.name, &op); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2246,7 +2373,8 @@ INSTANTIATE_TEST_CASE_P( TEST_F(CommandParserTest, BlendOpParsingInvalid) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); BlendOp op = BlendOp::kAdd; Result r = cp.ParseBlendOpNameForTesting("INVALID", &op); ASSERT_FALSE(r.IsSuccess()); @@ -2264,7 +2392,8 @@ TEST_P(CommandParserBlendOpTests, MissingParam) { std::string data = std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -2278,7 +2407,8 @@ TEST_P(CommandParserBlendOpTests, IllegalParam) { std::string data = std::string(test_data.name) + " 1.23"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Invalid parameter for ") + test_data.name + @@ -2292,7 +2422,8 @@ TEST_P(CommandParserBlendOpTests, ExtraParam) { std::string data = std::string(test_data.name) + " VK_BLEND_OP_MAX EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -2311,7 +2442,8 @@ TEST_F(CommandParserTest, DepthCompareOp) { std::string data = "depthCompareOp VK_COMPARE_OP_EQUAL"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(CompareOp::kEqual, @@ -2322,7 +2454,8 @@ TEST_F(CommandParserTest, FrontCompareOp) { std::string data = "front.compareOp VK_COMPARE_OP_EQUAL"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(CompareOp::kEqual, @@ -2333,7 +2466,8 @@ TEST_F(CommandParserTest, BackCompareOp) { std::string data = "back.compareOp VK_COMPARE_OP_EQUAL"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(CompareOp::kEqual, cp.PipelineDataForTesting()->GetBackCompareOp()); @@ -2349,7 +2483,8 @@ TEST_P(CommandParserCompareOpParsing, Parse) { const auto& test_data = GetParam(); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); CompareOp op = CompareOp::kNever; Result r = cp.ParseCompareOpNameForTesting(test_data.name, &op); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2373,7 +2508,8 @@ INSTANTIATE_TEST_CASE_P( TEST_F(CommandParserTest, CompareOpParsingInvalid) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); CompareOp op = CompareOp::kNever; Result r = cp.ParseCompareOpNameForTesting("INVALID", &op); ASSERT_FALSE(r.IsSuccess()); @@ -2391,7 +2527,8 @@ TEST_P(CommandParserCompareOpTests, MissingParam) { std::string data = std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -2405,7 +2542,8 @@ TEST_P(CommandParserCompareOpTests, IllegalParam) { std::string data = std::string(test_data.name) + " 1.23"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Invalid parameter for ") + test_data.name + @@ -2420,7 +2558,8 @@ TEST_P(CommandParserCompareOpTests, ExtraParam) { std::string(test_data.name) + " VK_COMPARE_OP_ALWAYS EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -2440,7 +2579,8 @@ TEST_F(CommandParserTest, FrontFailOp) { std::string data = "front.failOp VK_STENCIL_OP_REPLACE"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(StencilOp::kReplace, cp.PipelineDataForTesting()->GetFrontFailOp()); @@ -2450,7 +2590,8 @@ TEST_F(CommandParserTest, FrontPassOp) { std::string data = "front.passOp VK_STENCIL_OP_REPLACE"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(StencilOp::kReplace, cp.PipelineDataForTesting()->GetFrontPassOp()); @@ -2460,7 +2601,8 @@ TEST_F(CommandParserTest, FrontDepthFailOp) { std::string data = "front.depthFailOp VK_STENCIL_OP_REPLACE"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(StencilOp::kReplace, @@ -2471,7 +2613,8 @@ TEST_F(CommandParserTest, BackFailOp) { std::string data = "back.failOp VK_STENCIL_OP_REPLACE"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(StencilOp::kReplace, cp.PipelineDataForTesting()->GetBackFailOp()); @@ -2481,7 +2624,8 @@ TEST_F(CommandParserTest, BackPassOp) { std::string data = "back.passOp VK_STENCIL_OP_REPLACE"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(StencilOp::kReplace, cp.PipelineDataForTesting()->GetBackPassOp()); @@ -2491,7 +2635,8 @@ TEST_F(CommandParserTest, BackDepthFailOp) { std::string data = "back.depthFailOp VK_STENCIL_OP_REPLACE"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(StencilOp::kReplace, @@ -2508,7 +2653,8 @@ TEST_P(CommandParserStencilOpParsing, Parse) { const auto& test_data = GetParam(); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); StencilOp op = StencilOp::kKeep; Result r = cp.ParseStencilOpNameForTesting(test_data.name, &op); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2535,7 +2681,8 @@ INSTANTIATE_TEST_CASE_P( TEST_F(CommandParserTest, StencilOpParsingInvalid) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); StencilOp op = StencilOp::kKeep; Result r = cp.ParseStencilOpNameForTesting("INVALID", &op); ASSERT_FALSE(r.IsSuccess()); @@ -2553,7 +2700,8 @@ TEST_P(CommandParserStencilOpTests, MissingParam) { std::string data = std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -2567,7 +2715,8 @@ TEST_P(CommandParserStencilOpTests, IllegalParam) { std::string data = std::string(test_data.name) + " 1.23"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Invalid parameter for ") + test_data.name + @@ -2582,7 +2731,8 @@ TEST_P(CommandParserStencilOpTests, ExtraParam) { std::string(test_data.name) + " VK_STENCIL_OP_REPLACE EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -2605,7 +2755,8 @@ TEST_F(CommandParserTest, FrontCompareMask) { std::string data = "front.compareMask 123"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: front.compareMask not implemented", r.Error()); @@ -2615,7 +2766,8 @@ TEST_F(CommandParserTest, FrontWriteMask) { std::string data = "front.writeMask 123"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: front.writeMask not implemented", r.Error()); @@ -2625,7 +2777,8 @@ TEST_F(CommandParserTest, BackCompareMask) { std::string data = "back.compareMask 123"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: back.compareMask not implemented", r.Error()); @@ -2635,7 +2788,8 @@ TEST_F(CommandParserTest, BackWriteMask) { std::string data = "back.writeMask 123"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: back.writeMask not implemented", r.Error()); @@ -2645,7 +2799,8 @@ TEST_F(CommandParserTest, FrontReference) { std::string data = "front.reference 10"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(10U, cp.PipelineDataForTesting()->GetFrontReference()); @@ -2655,7 +2810,8 @@ TEST_F(CommandParserTest, BackReference) { std::string data = "back.reference 10"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(10U, cp.PipelineDataForTesting()->GetBackReference()); @@ -2672,7 +2828,8 @@ TEST_P(CommandParserReferenceTests, FrontReferenceMissingValue) { std::string data = std::string(test_data.name); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ( @@ -2685,7 +2842,8 @@ TEST_P(CommandParserReferenceTests, FrontReferenceExtraParameters) { std::string data = std::string(test_data.name) + " 10 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Extra parameter for ") + test_data.name + @@ -2698,7 +2856,8 @@ TEST_P(CommandParserReferenceTests, FrontReferenceInvalidParameters) { std::string data = std::string(test_data.name) + " INVALID"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ(std::string("1: Invalid parameter for ") + test_data.name + @@ -2724,7 +2883,8 @@ TEST_P(CommandParserColorMaskTests, ColorWriteMask) { std::string data = "colorWriteMask " + std::string(test_data.input); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); EXPECT_EQ(test_data.result, cp.PipelineDataForTesting()->GetColorWriteMask()); @@ -2750,7 +2910,8 @@ TEST_F(CommandParserTest, ColorWriteMaskInvalid) { std::string data = "colorWriteMask INVALID"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Unknown parameter for colorWriteMask command: INVALID", @@ -2761,7 +2922,8 @@ TEST_F(CommandParserTest, ColorWriteMaskInvalidAfterValid) { std::string data = "colorWriteMask VK_COLOR_COMPONENT_G_BIT | INVALID"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Unknown parameter for colorWriteMask command: INVALID", @@ -2772,7 +2934,8 @@ TEST_F(CommandParserTest, ColorWriteMaskMissingParam) { std::string data = "colorWriteMask"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing parameter for colorWriteMask command", r.Error()); @@ -2784,7 +2947,8 @@ TEST_F(CommandParserTest, ColorWriteMaskExtraParam) { "EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Unknown parameter for colorWriteMask command: EXTRA", @@ -2795,7 +2959,8 @@ TEST_F(CommandParserTest, SSBO) { std::string data = "ssbo 5 40"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2814,7 +2979,8 @@ TEST_F(CommandParserTest, SSBOWithDescriptorSet) { std::string data = "ssbo 9:5 40"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2833,7 +2999,8 @@ TEST_F(CommandParserTest, SSBOExtraParameter) { std::string data = "ssbo 5 40 EXTRA"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter for ssbo command: EXTRA", r.Error()); @@ -2843,7 +3010,8 @@ TEST_F(CommandParserTest, SSBOInvalidFloatBinding) { std::string data = "ssbo 5.0 40"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid binding value for ssbo command", r.Error()); @@ -2853,7 +3021,8 @@ TEST_F(CommandParserTest, SSBOInvalidBinding) { std::string data = "ssbo abc 40"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid binding value for ssbo command", r.Error()); @@ -2863,7 +3032,8 @@ TEST_F(CommandParserTest, SSBOInvalidFloatSize) { std::string data = "ssbo 5 40.0"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid size value for ssbo command: 40.0", r.Error()); @@ -2873,7 +3043,8 @@ TEST_F(CommandParserTest, SSBOInvalidSize) { std::string data = "ssbo 5 abc"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for ssbo command: abc", r.Error()); @@ -2883,7 +3054,8 @@ TEST_F(CommandParserTest, SSBOMissingSize) { std::string data = "ssbo 5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing size value for ssbo command: ", r.Error()); @@ -2893,7 +3065,8 @@ TEST_F(CommandParserTest, SSBOMissingBinding) { std::string data = "ssbo"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing binding and size values for ssbo command", r.Error()); @@ -2903,7 +3076,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithFloat) { std::string data = "ssbo 6 subdata vec3 2 2.3 4.2 1.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2936,7 +3110,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithNegativeOffset) { std::string data = "ssbo 6 subdata vec3 -2 -4 -5 -6"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: offset for SSBO must be positive, got: -2", r.Error()); @@ -2946,7 +3121,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithDescriptorSet) { std::string data = "ssbo 5:6 subdata vec3 2 2.3 4.2 1.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -2979,7 +3155,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithInts) { std::string data = "ssbo 6 subdata i16vec3 2 2 4 1"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3012,7 +3189,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithMultipleVectors) { std::string data = "ssbo 6 subdata i16vec3 2 2 4 1 3 6 8"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3045,7 +3223,8 @@ TEST_F(CommandParserTest, SSBOSubdataMissingBinding) { std::string data = "ssbo subdata i16vec3 2 2 3 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid binding value for ssbo command", r.Error()); @@ -3055,7 +3234,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithInvalidBinding) { std::string data = "ssbo INVALID subdata i16vec3 2 2 3 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid binding value for ssbo command", r.Error()); @@ -3065,7 +3245,8 @@ TEST_F(CommandParserTest, SSBOSubdataMissingSubdataCommand) { std::string data = "ssbo 6 INVALID i16vec3 2 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for ssbo command: INVALID", r.Error()); @@ -3075,7 +3256,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithBadType) { std::string data = "ssbo 0 subdata INVALID 2 2 3 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid type provided: INVALID", r.Error()); @@ -3085,7 +3267,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithInvalidFloatOffset) { std::string data = "ssbo 0 subdata vec2 2.0 3 2 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid offset for ssbo command: 2.0", r.Error()); @@ -3095,7 +3278,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithInvalidStringOffset) { std::string data = "ssbo 0 subdata vec2 asdf 3 2 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid offset for ssbo command: asdf", r.Error()); @@ -3105,7 +3289,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithMissingData) { std::string data = "ssbo 6 subdata i16vec3 2 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Incorrect number of values provided to ssbo command", @@ -3116,7 +3301,8 @@ TEST_F(CommandParserTest, SSBOSubdataWithMissingAllData) { std::string data = "ssbo 6 subdata i16vec3 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Incorrect number of values provided to ssbo command", @@ -3127,7 +3313,8 @@ TEST_F(CommandParserTest, Uniform) { std::string data = "uniform vec3 2 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3157,7 +3344,8 @@ TEST_F(CommandParserTest, UniformOffsetMustBePositive) { std::string data = "uniform vec3 -2 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: offset for uniform must be positive, got: -2", r.Error()); @@ -3167,7 +3355,8 @@ TEST_F(CommandParserTest, UniformWithContinuation) { std::string data = "uniform vec3 2 2.1 3.2 4.3 \\\n5.4 6.7 8.9"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3197,7 +3386,8 @@ TEST_F(CommandParserTest, UniformInvalidType) { std::string data = "uniform INVALID 0 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid type provided: INVALID", r.Error()); @@ -3207,7 +3397,8 @@ TEST_F(CommandParserTest, UniformInvalidFloatOffset) { std::string data = "uniform vec3 5.5 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid offset value for uniform command: 5.5", r.Error()); @@ -3217,7 +3408,8 @@ TEST_F(CommandParserTest, UniformInvalidStringOffset) { std::string data = "uniform vec3 INVALID 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid offset value for uniform command: INVALID", r.Error()); @@ -3227,7 +3419,8 @@ TEST_F(CommandParserTest, UniformMissingValues) { std::string data = "uniform vec3 2 2.1 3.2 4.3 5.5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Incorrect number of values provided to uniform command", @@ -3238,7 +3431,8 @@ TEST_F(CommandParserTest, UniformUBO) { std::string data = "uniform ubo 2 vec3 1 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3270,7 +3464,8 @@ TEST_F(CommandParserTest, UniformUBOOffsetMustBePositive) { std::string data = "uniform ubo 2 vec3 -1 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: offset for uniform must be positive, got: -1", r.Error()); @@ -3280,7 +3475,8 @@ TEST_F(CommandParserTest, UniformUBOWithDescriptorSet) { std::string data = "uniform ubo 3:2 vec3 1 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3312,7 +3508,8 @@ TEST_F(CommandParserTest, UniformUBOInvalidFloatBinding) { std::string data = "uniform ubo 0.0 vec3 0 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid binding value for uniform ubo command: 0.0", r.Error()); @@ -3322,7 +3519,8 @@ TEST_F(CommandParserTest, UniformUBOInvalidStringBinding) { std::string data = "uniform ubo INVALID vec3 0 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid binding value for uniform ubo command: INVALID", @@ -3333,7 +3531,8 @@ TEST_F(CommandParserTest, UniformUBOInvalidType) { std::string data = "uniform ubo 0 INVALID 0 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid type provided: INVALID", r.Error()); @@ -3343,7 +3542,8 @@ TEST_F(CommandParserTest, UniformUBOInvalidFloatOffset) { std::string data = "uniform ubo 0 vec3 5.5 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid offset value for uniform command: 5.5", r.Error()); @@ -3353,7 +3553,8 @@ TEST_F(CommandParserTest, UniformUBOInvalidStringOffset) { std::string data = "uniform ubo 0 vec3 INVALID 2.1 3.2 4.3"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid offset value for uniform command: INVALID", r.Error()); @@ -3363,7 +3564,8 @@ TEST_F(CommandParserTest, UniformUBOMissingValues) { std::string data = "uniform ubo 0 vec3 2 2.1 3.2 4.3 5.5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Incorrect number of values provided to uniform command", @@ -3374,7 +3576,8 @@ TEST_F(CommandParserTest, ToleranceSingleFloatValue) { std::string data = "tolerance 0.5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3388,7 +3591,8 @@ TEST_F(CommandParserTest, ToleranceSingleFloatPercent) { std::string data = "tolerance 0.5%"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3402,7 +3606,8 @@ TEST_F(CommandParserTest, ToleranceSingleIntValue) { std::string data = "tolerance 5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3416,7 +3621,8 @@ TEST_F(CommandParserTest, ToleranceSingleIntPercent) { std::string data = "tolerance 5%"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3430,7 +3636,8 @@ TEST_F(CommandParserTest, ToleranceMultiFloatValue) { std::string data = "tolerance 0.5 2.4 3.9 99.7"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3447,7 +3654,8 @@ TEST_F(CommandParserTest, ToleranceMultiFloatValueWithPercent) { std::string data = "tolerance 0.5% 2.4 3.9% 99.7"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3468,7 +3676,8 @@ TEST_F(CommandParserTest, ToleranceMultiIntValue) { std::string data = "tolerance 5 4 3 99"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3485,7 +3694,8 @@ TEST_F(CommandParserTest, ToleranceMultiIntValueWithPercent) { std::string data = "tolerance 5% 4 3% 99"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3506,7 +3716,8 @@ TEST_F(CommandParserTest, ToleranceInvalidValue1) { std::string data = "tolerance INVALID"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for tolerance command: INVALID", r.Error()); @@ -3516,7 +3727,8 @@ TEST_F(CommandParserTest, ToleranceInvalidJustPercent) { std::string data = "tolerance %"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for tolerance command: %", r.Error()); @@ -3526,7 +3738,8 @@ TEST_F(CommandParserTest, ToleranceInvalidValue2) { std::string data = "tolerance 1 INVALID 3 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for tolerance command: INVALID", r.Error()); @@ -3536,7 +3749,8 @@ TEST_F(CommandParserTest, ToleranceInvalidValue3) { std::string data = "tolerance 1 2 INVALID 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for tolerance command: INVALID", r.Error()); @@ -3546,7 +3760,8 @@ TEST_F(CommandParserTest, ToleranceInvalidValue4) { std::string data = "tolerance 1 2 3 INVALID"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for tolerance command: INVALID", r.Error()); @@ -3556,7 +3771,8 @@ TEST_F(CommandParserTest, ToleranceMissingValues) { std::string data = "tolerance"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Missing value for tolerance command", r.Error()); @@ -3566,7 +3782,8 @@ TEST_F(CommandParserTest, ToleranceTooManyValues) { std::string data = "tolerance 1 2 3 4 5"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Extra parameter for tolerance command: 5", r.Error()); @@ -3576,7 +3793,8 @@ TEST_F(CommandParserTest, ToleranceInvalidWithNumber) { std::string data = "tolerance 1INVALID"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for tolerance command: INVALID", r.Error()); @@ -3586,7 +3804,8 @@ TEST_F(CommandParserTest, ToleranceInvalidWithMissingValue) { std::string data = "tolerance 1, , 3, 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid number of tolerance parameters provided", r.Error()); @@ -3596,7 +3815,8 @@ TEST_F(CommandParserTest, ToleranceWithCommas) { std::string data = "tolerance 1,2, 3 ,4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3615,7 +3835,8 @@ tolerance 2 3 4 5 probe ssbo vec3 3:6 2 >= 2.3 4.2 1.2)"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3644,7 +3865,8 @@ probe all rgba 0.2 0.3 0.4 0.5)"; auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); pipeline.AddColorAttachment(color_buf.get(), 0); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3668,7 +3890,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithDescriptorSet) { std::string data = "probe ssbo vec3 3:6 2 >= 2.3 4.2 1.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3700,7 +3923,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithFloats) { std::string data = "probe ssbo vec3 6 2 >= 2.3 4.2 1.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3733,7 +3957,8 @@ TEST_F(CommandParserTest, MultiProbeSSBOWithFloats) { "probe ssbo vec3 6 2 >= 2.3 4.2 1.2\nprobe ssbo vec3 6 2 >= 2.3 4.2 1.2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3764,7 +3989,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithInts) { std::string data = "probe ssbo i16vec3 6 2 <= 2 4 1"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3795,7 +4021,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithMultipleVectors) { std::string data = "probe ssbo i16vec3 6 2 == 2 4 1 3 6 8"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3826,7 +4053,8 @@ TEST_F(CommandParserTest, ProbeSSBOMissingBinding) { std::string data = "probe ssbo i16vec3 2 == 2 3 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for probe ssbo command: ==", r.Error()); @@ -3836,7 +4064,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithInvalidBinding) { std::string data = "probe ssbo i16vec3 INVALID 2 == 2 3 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid binding value for probe ssbo command: INVALID", @@ -3847,7 +4076,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithBadType) { std::string data = "probe ssbo INVALID 0 2 == 2 3 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid type provided: INVALID", r.Error()); @@ -3857,7 +4087,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithInvalidFloatOffset) { std::string data = "probe ssbo vec2 0 2.0 == 3 2 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid offset for probe ssbo command: 2.0", r.Error()); @@ -3867,7 +4098,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithInvalidStringOffset) { std::string data = "probe ssbo vec2 0 INVALID == 3 2 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid value for probe ssbo command: INVALID", r.Error()); @@ -3877,7 +4109,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithInvalidComparator) { std::string data = "probe ssbo vec2 6 2 INVALID 3 2 4"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Invalid comparator: INVALID", r.Error()); @@ -3887,7 +4120,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithMissingData) { std::string data = "probe ssbo i16vec3 6 2 == 2"; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Incorrect number of values provided to probe ssbo command", @@ -3898,7 +4132,8 @@ TEST_F(CommandParserTest, ProbeSSBOWithMissingAllData) { std::string data = "probe ssbo i16vec3 6 2 =="; Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, data); + Script script; + CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); EXPECT_EQ("1: Incorrect number of values provided to probe ssbo command", @@ -3915,7 +4150,8 @@ TEST_P(CommandParserComparatorTests, Comparator) { const auto& test_data = GetParam(); Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); ProbeSSBOCommand::Comparator result; Result r = cp.ParseComparatorForTesting(test_data.name, &result); ASSERT_TRUE(r.IsSuccess()) << r.Error(); @@ -3938,7 +4174,8 @@ INSTANTIATE_TEST_CASE_P( TEST_F(CommandParserTest, ComparatorInvalid) { Pipeline pipeline(PipelineType::kGraphics); - CommandParser cp(&pipeline, 1, "unused"); + Script script; + CommandParser cp(&script, &pipeline, 1, "unused"); ProbeSSBOCommand::Comparator result; Result r = cp.ParseComparatorForTesting("INVALID", &result); ASSERT_FALSE(r.IsSuccess()); diff --git a/src/vkscript/parser.cc b/src/vkscript/parser.cc index 03c97db..4b4d908 100644 --- a/src/vkscript/parser.cc +++ b/src/vkscript/parser.cc @@ -469,7 +469,7 @@ Result Parser::ProcessVertexDataBlock(const SectionParser::Section& section) { Result Parser::ProcessTestBlock(const SectionParser::Section& section) { auto* pipeline = script_->GetPipeline(kDefaultPipelineName); - CommandParser cp(pipeline, section.starting_line_number + 1, + CommandParser cp(script_.get(), pipeline, section.starting_line_number + 1, section.contents); Result r = cp.Parse(); if (!r.IsSuccess()) diff --git a/src/vulkan/buffer.cc b/src/vulkan/buffer.cc index 43dc870..525fcd7 100644 --- a/src/vulkan/buffer.cc +++ b/src/vulkan/buffer.cc @@ -38,7 +38,7 @@ bool IsMemoryHostCoherent(const VkPhysicalDeviceMemoryProperties& props, } // namespace Buffer::Buffer(Device* device, - size_t size_in_bytes, + uint32_t size_in_bytes, const VkPhysicalDeviceMemoryProperties& properties) : Resource(device, size_in_bytes, properties) {} diff --git a/src/vulkan/buffer.h b/src/vulkan/buffer.h index d5e4c69..2f6596a 100644 --- a/src/vulkan/buffer.h +++ b/src/vulkan/buffer.h @@ -32,7 +32,7 @@ class Device; class Buffer : public Resource { public: Buffer(Device* device, - size_t size_in_bytes, + uint32_t size_in_bytes, const VkPhysicalDeviceMemoryProperties& properties); ~Buffer() override; diff --git a/src/vulkan/buffer_descriptor.cc b/src/vulkan/buffer_descriptor.cc index 71112af..1ae6b12 100644 --- a/src/vulkan/buffer_descriptor.cc +++ b/src/vulkan/buffer_descriptor.cc @@ -26,32 +26,13 @@ namespace amber { namespace vulkan { -namespace { - -// Return the size in bytes for a buffer that has enough capacity to -// copy all data in |buffer_input_queue|. -size_t GetBufferSizeInBytesForQueue( - const std::vector<BufferInput>& buffer_input_queue) { - if (buffer_input_queue.empty()) - return 0; - - auto buffer_data_with_last_offset = std::max_element( - buffer_input_queue.begin(), buffer_input_queue.end(), - [](const BufferInput& a, const BufferInput& b) { - return static_cast<size_t>(a.offset) + a.size_in_bytes < - static_cast<size_t>(b.offset) + b.size_in_bytes; - }); - return static_cast<size_t>(buffer_data_with_last_offset->offset) + - buffer_data_with_last_offset->size_in_bytes; -} - -} // namespace -BufferDescriptor::BufferDescriptor(DescriptorType type, +BufferDescriptor::BufferDescriptor(amber::Buffer* buffer, + DescriptorType type, Device* device, uint32_t desc_set, uint32_t binding) - : Descriptor(type, device, desc_set, binding) { + : Descriptor(type, device, desc_set, binding), amber_buffer_(buffer) { assert(type == DescriptorType::kStorageBuffer || type == DescriptorType::kUniformBuffer); } @@ -60,30 +41,23 @@ BufferDescriptor::~BufferDescriptor() = default; Result BufferDescriptor::CreateResourceIfNeeded( const VkPhysicalDeviceMemoryProperties& properties) { - // Amber copies back contents of |buffer_| to host and put it into - // |buffer_input_queue_| right after draw or compute. Therefore, - // when calling this method, |buffer_| must be always empty. - if (buffer_) { + if (vk_buffer_) { return Result( "Vulkan: BufferDescriptor::CreateResourceIfNeeded() must be called " - "only when |buffer_| is empty"); + "only when |vk_buffer| is empty"); } - const auto& buffer_input_queue = GetBufferInputQueue(); - const auto& buffer_output = GetBufferOutput(); - - if (buffer_input_queue.empty() && buffer_output.empty()) + if (amber_buffer_ && amber_buffer_->ValuePtr()->empty()) return {}; - size_t size_in_bytes = GetBufferSizeInBytesForQueue(buffer_input_queue); - if (buffer_output.size() > size_in_bytes) - size_in_bytes = buffer_output.size(); - - buffer_ = MakeUnique<Buffer>(device_, size_in_bytes, properties); + uint32_t size_in_bytes = + amber_buffer_ ? static_cast<uint32_t>(amber_buffer_->ValuePtr()->size()) + : 0; + vk_buffer_ = MakeUnique<Buffer>(device_, size_in_bytes, properties); - Result r = buffer_->Initialize(GetVkBufferUsage() | - VK_BUFFER_USAGE_TRANSFER_SRC_BIT | - VK_BUFFER_USAGE_TRANSFER_DST_BIT); + Result r = vk_buffer_->Initialize(GetVkBufferUsage() | + VK_BUFFER_USAGE_TRANSFER_SRC_BIT | + VK_BUFFER_USAGE_TRANSFER_DST_BIT); if (!r.IsSuccess()) return r; @@ -93,64 +67,57 @@ Result BufferDescriptor::CreateResourceIfNeeded( Result BufferDescriptor::RecordCopyDataToResourceIfNeeded( CommandBuffer* command) { - auto& buffer_output = GetBufferOutput(); - if (!buffer_output.empty()) { - buffer_->UpdateMemoryWithRawData(buffer_output); - buffer_output.clear(); - } - - const auto& buffer_input_queue = GetBufferInputQueue(); - if (buffer_input_queue.empty()) - return {}; - - for (const auto& input : buffer_input_queue) { - Result r = buffer_->UpdateMemoryWithInput(input); - if (!r.IsSuccess()) - return r; + if (amber_buffer_ && !amber_buffer_->ValuePtr()->empty()) { + vk_buffer_->UpdateMemoryWithRawData(*amber_buffer_->ValuePtr()); + amber_buffer_->ValuePtr()->clear(); } - ClearBufferInputQueue(); - - buffer_->CopyToDevice(command); + vk_buffer_->CopyToDevice(command); return {}; } Result BufferDescriptor::RecordCopyDataToHost(CommandBuffer* command) { - if (!buffer_) { + if (!vk_buffer_) { return Result( - "Vulkan: BufferDescriptor::RecordCopyDataToHost() |buffer_| is empty"); + "Vulkan: BufferDescriptor::RecordCopyDataToHost() |vk_buffer| is " + "empty"); } - return buffer_->CopyToHost(command); + return vk_buffer_->CopyToHost(command); } Result BufferDescriptor::MoveResourceToBufferOutput() { - if (!buffer_) { + if (!vk_buffer_) { return Result( - "Vulkan: BufferDescriptor::MoveResourceToBufferOutput() |buffer_| " + "Vulkan: BufferDescriptor::MoveResourceToBufferOutput() |vk_buffer| " "is empty"); } - void* resource_memory_ptr = buffer_->HostAccessibleMemoryPtr(); - if (!resource_memory_ptr) { - return Result( - "Vulkan: BufferDescriptor::MoveResourceToBufferOutput() |buffer_| " - "has nullptr host accessible memory"); + // Only need to copy the buffer back if we have an attached amber buffer to + // write too. + if (amber_buffer_) { + void* resource_memory_ptr = vk_buffer_->HostAccessibleMemoryPtr(); + if (!resource_memory_ptr) { + return Result( + "Vulkan: BufferDescriptor::MoveResourceToBufferOutput() |vk_buffer| " + "has nullptr host accessible memory"); + } + + if (!amber_buffer_->ValuePtr()->empty()) { + return Result( + "Vulkan: BufferDescriptor::MoveResourceToBufferOutput() " + "output buffer is not empty"); + } + + auto size_in_bytes = vk_buffer_->GetSizeInBytes(); + amber_buffer_->SetSize(size_in_bytes); + amber_buffer_->ValuePtr()->resize(size_in_bytes); + std::memcpy(amber_buffer_->ValuePtr()->data(), resource_memory_ptr, + size_in_bytes); } - auto& buffer_output = GetBufferOutput(); - if (!buffer_output.empty()) { - return Result( - "Vulkan: BufferDescriptor::MoveResourceToBufferOutput() " - "|buffer_output_| is not empty"); - } - - auto size_in_bytes = buffer_->GetSizeInBytes(); - buffer_output.resize(size_in_bytes); - std::memcpy(buffer_output.data(), resource_memory_ptr, size_in_bytes); - - buffer_->Shutdown(); - buffer_ = nullptr; + vk_buffer_->Shutdown(); + vk_buffer_ = nullptr; return {}; } @@ -160,7 +127,7 @@ Result BufferDescriptor::UpdateDescriptorSetIfNeeded( return {}; VkDescriptorBufferInfo buffer_info = VkDescriptorBufferInfo(); - buffer_info.buffer = buffer_->GetVkBuffer(); + buffer_info.buffer = vk_buffer_->GetVkBuffer(); buffer_info.offset = 0; buffer_info.range = VK_WHOLE_SIZE; @@ -168,51 +135,27 @@ Result BufferDescriptor::UpdateDescriptorSetIfNeeded( descriptor_set, GetVkDescriptorType(), buffer_info); } -ResourceInfo BufferDescriptor::GetResourceInfo() { - auto& buffer_input_queue = GetBufferInputQueue(); - auto& buffer_output = GetBufferOutput(); - - ResourceInfo info = ResourceInfo(); - if (buffer_) { - assert(buffer_input_queue.empty() && buffer_output.empty()); - - info.size_in_bytes = buffer_->GetSizeInBytes(); - info.cpu_memory = buffer_->HostAccessibleMemoryPtr(); - return info; - } - - if (buffer_input_queue.empty()) { - info.size_in_bytes = buffer_output.size(); - info.cpu_memory = buffer_output.data(); - return info; - } +void BufferDescriptor::Shutdown() { + if (vk_buffer_) + vk_buffer_->Shutdown(); +} - // Squash elements of |buffer_input_queue_| into |buffer_output_|. - size_t size_in_bytes = GetBufferSizeInBytesForQueue(buffer_input_queue); - std::vector<uint8_t> new_buffer_output = buffer_output; - if (size_in_bytes > new_buffer_output.size()) - new_buffer_output.resize(size_in_bytes); +Result BufferDescriptor::AddToBuffer(DataType type, + uint32_t offset, + uint32_t size_in_bytes, + const std::vector<Value>& values) { + if (!amber_buffer_) + return Result("missing amber_buffer for AddToBuffer call"); - for (const auto& input : buffer_input_queue) { - input.UpdateBufferWithValues(new_buffer_output.data()); + if (amber_buffer_->ValuePtr()->size() < offset + size_in_bytes) { + amber_buffer_->ValuePtr()->resize(offset + size_in_bytes); + amber_buffer_->SetSize(offset + size_in_bytes); } - buffer_input_queue.clear(); - buffer_output = new_buffer_output; + BufferInput in{offset, size_in_bytes, type, values}; + in.UpdateBufferWithValues(amber_buffer_->GetMemPtr()); - info.size_in_bytes = buffer_output.size(); - info.cpu_memory = buffer_output.data(); - return info; -} - -void BufferDescriptor::Shutdown() { - if (buffer_) - buffer_->Shutdown(); - - for (auto& buffer : not_destroyed_buffers_) { - if (buffer) - buffer->Shutdown(); - } + return {}; } } // namespace vulkan diff --git a/src/vulkan/buffer_descriptor.h b/src/vulkan/buffer_descriptor.h index cc01f53..9cac494 100644 --- a/src/vulkan/buffer_descriptor.h +++ b/src/vulkan/buffer_descriptor.h @@ -21,6 +21,7 @@ #include "amber/result.h" #include "amber/value.h" #include "amber/vulkan_header.h" +#include "src/buffer.h" #include "src/datum_type.h" #include "src/engine.h" #include "src/vulkan/buffer.h" @@ -36,7 +37,8 @@ class Device; // a.k.a. SSBO and Uniform Buffer a.k.a. UBO. class BufferDescriptor : public Descriptor { public: - BufferDescriptor(DescriptorType type, + BufferDescriptor(amber::Buffer* buffer, + DescriptorType type, Device* device, uint32_t desc_set, uint32_t binding); @@ -49,9 +51,13 @@ class BufferDescriptor : public Descriptor { Result RecordCopyDataToHost(CommandBuffer* command) override; Result MoveResourceToBufferOutput() override; Result UpdateDescriptorSetIfNeeded(VkDescriptorSet descriptor_set) override; - ResourceInfo GetResourceInfo() override; void Shutdown() override; + Result AddToBuffer(DataType type, + uint32_t offset, + uint32_t size_in_bytes, + const std::vector<Value>& values); + private: VkBufferUsageFlagBits GetVkBufferUsage() const { return GetType() == DescriptorType::kStorageBuffer @@ -65,8 +71,8 @@ class BufferDescriptor : public Descriptor { : VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; } - std::unique_ptr<Buffer> buffer_; - std::vector<std::unique_ptr<Buffer>> not_destroyed_buffers_; + amber::Buffer* amber_buffer_ = nullptr; + std::unique_ptr<Buffer> vk_buffer_; }; } // namespace vulkan diff --git a/src/vulkan/descriptor.cc b/src/vulkan/descriptor.cc index 572ab59..5f2380b 100644 --- a/src/vulkan/descriptor.cc +++ b/src/vulkan/descriptor.cc @@ -148,12 +148,5 @@ void Descriptor::UpdateVkDescriptorSet(const VkWriteDescriptorSet& write) { is_descriptor_set_update_needed_ = false; } -void Descriptor::AddToBufferInputQueue(DataType type, - uint32_t offset, - size_t size_in_bytes, - const std::vector<Value>& values) { - buffer_input_queue_.push_back({offset, size_in_bytes, type, values}); -} - } // namespace vulkan } // namespace amber diff --git a/src/vulkan/descriptor.h b/src/vulkan/descriptor.h index bf86d2c..cada88e 100644 --- a/src/vulkan/descriptor.h +++ b/src/vulkan/descriptor.h @@ -85,34 +85,21 @@ class Descriptor { return type_ == DescriptorType::kDynamicStorageBuffer; } - bool HasDataNotSent() { return !buffer_input_queue_.empty(); } - - // Add the information to |buffer_input_queue_| that "we will fill - // resource of this descriptor with |values| at |offset| of the - // resource". |type| indicates the primitive type of |values| and - // |size_in_bytes| denotes the total size in bytes of |values|. - void AddToBufferInputQueue(DataType type, - uint32_t offset, - size_t size_in_bytes, - const std::vector<Value>& values); - // Call vkUpdateDescriptorSets() to update the backing resource // for this descriptor only when the backing resource was newly // created or changed. virtual Result UpdateDescriptorSetIfNeeded(VkDescriptorSet) = 0; // Create vulkan resource e.g., buffer or image used for this - // descriptor if |buffer_input_queue_| is not empty. This method - // assumes that the resource is empty when it is called that means - // the resource must be created only when it is actually needed - // i.e., compute or draw command and destroyed right after those - // commands. + // descriptor if needed. This method assumes that the resource is empty when + // it is called that means the resource must be created only when it is + // actually needed i.e., compute or draw command and destroyed right after + // those commands. virtual Result CreateResourceIfNeeded( const VkPhysicalDeviceMemoryProperties& properties) = 0; - // Record a command for copying |buffer_output_| and - // |buffer_input_queue_| to the resource in device. After the copy - // it clears |buffer_output_| and |buffer_input_queue_|. Note that + // Record a command for copying buffer data to the resource in device. After + // the copy it clears the internal buffer data. Note that // it only records the command and the actual submission must be // done later. virtual Result RecordCopyDataToResourceIfNeeded(CommandBuffer* command) = 0; @@ -122,21 +109,12 @@ class Descriptor { // must be done later. virtual Result RecordCopyDataToHost(CommandBuffer* command) = 0; - // Copy contents of resource e.g., VkBuffer to host buffer - // |buffer_output_|. This method assumes that we already copy - // the resource data to the host accessible memory by calling - // RecordCopyDataToHost() method and submitting the command buffer. - // After copying the contents, it destroys |buffer_|. + // Copy contents of resource e.g., VkBuffer to host buffer. + // This method assumes that we already copy the resource data to the host + // accessible memory by calling RecordCopyDataToHost() method and submitting + // the command buffer. After copying the contents, it destroys |buffer_|. virtual Result MoveResourceToBufferOutput() = 0; - // If the resource is empty and |buffer_input_queue_| has a single - // BufferInput, the BufferInput is the data copied from the resource - // before. In that case, this methods returns information for the - // BufferInput. If the resource is not empty, it returns - // |size_in_bytes_| and host accessible memory of the resource. - // Otherwise, it returns nullptr for |cpu_memory| of ResourceInfo. - virtual ResourceInfo GetResourceInfo() = 0; - virtual void Shutdown() = 0; protected: @@ -151,14 +129,6 @@ class Descriptor { VkDescriptorType descriptor_type, const VkBufferView& texel_view); - std::vector<BufferInput>& GetBufferInputQueue() { - return buffer_input_queue_; - } - std::vector<uint8_t>& GetBufferOutput() { return buffer_output_; } - - void ClearBufferInputQueue() { buffer_input_queue_.clear(); } - void ClearBufferOutput() { buffer_output_.clear(); } - void SetUpdateDescriptorSetNeeded() { is_descriptor_set_update_needed_ = true; } @@ -178,16 +148,6 @@ class Descriptor { DescriptorType type_ = DescriptorType::kSampledImage; - // Each element of this queue contains information of what parts - // of buffer must be updates with what values. This queue will be - // consumed and cleared by CopyDataToResourceIfNeeded(). - // CopyDataToResourceIfNeeded() updates the actual buffer in device - // using this queued information. - std::vector<BufferInput> buffer_input_queue_; - - // Vector to keep data from GPU memory i.e., read back from VkBuffer. - std::vector<uint8_t> buffer_output_; - bool is_descriptor_set_update_needed_ = false; }; diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc index 0e5e61a..b64d398 100644 --- a/src/vulkan/engine_vulkan.cc +++ b/src/vulkan/engine_vulkan.cc @@ -414,9 +414,6 @@ Result EngineVulkan::GetFrameBuffer(amber::Buffer* buffer, std::vector<Value>* values) { values->resize(0); - if (!buffer->GetMemPtr()) - return Result("Vulkan::GetFrameBuffer buffer missing memory pointer"); - // TODO(jaebaek): Support other formats if (buffer->AsFormatBuffer()->GetFormat().GetFormatType() != kDefaultFramebufferFormat) @@ -439,28 +436,18 @@ Result EngineVulkan::GetFrameBuffer(amber::Buffer* buffer, return {}; } -Result EngineVulkan::GetDescriptorInfo(amber::Pipeline* pipeline, - const uint32_t descriptor_set, - const uint32_t binding, - ResourceInfo* resource_info) { - auto& info = pipeline_map_[pipeline]; - return info.vk_pipeline->GetDescriptorInfo(descriptor_set, binding, - resource_info); -} - -Result EngineVulkan::DoBuffer(const BufferCommand* command) { - auto& info = pipeline_map_[command->GetPipeline()]; - if (command->IsPushConstant()) - return info.vk_pipeline->AddPushConstant(command); +Result EngineVulkan::DoBuffer(const BufferCommand* cmd) { + auto& info = pipeline_map_[cmd->GetPipeline()]; + if (cmd->IsPushConstant()) + return info.vk_pipeline->AddPushConstant(cmd); if (!IsDescriptorSetInBounds(device_->GetPhysicalDevice(), - command->GetDescriptorSet())) { + cmd->GetDescriptorSet())) { return Result( "Vulkan::DoBuffer exceed maxBoundDescriptorSets limit of physical " "device"); } - - return info.vk_pipeline->AddDescriptor(command); + return info.vk_pipeline->AddDescriptor(cmd); } bool EngineVulkan::IsFormatSupportedByPhysicalDevice( diff --git a/src/vulkan/engine_vulkan.h b/src/vulkan/engine_vulkan.h index 8cd0ce3..f41d809 100644 --- a/src/vulkan/engine_vulkan.h +++ b/src/vulkan/engine_vulkan.h @@ -61,10 +61,6 @@ class EngineVulkan : public Engine { Result DoProcessCommands(amber::Pipeline* pipeline) override; Result GetFrameBuffer(amber::Buffer* buffer, std::vector<Value>* values) override; - Result GetDescriptorInfo(amber::Pipeline* pipeline, - const uint32_t descriptor_set, - const uint32_t binding, - ResourceInfo* info) override; private: struct PipelineInfo { diff --git a/src/vulkan/index_buffer.cc b/src/vulkan/index_buffer.cc index c826c42..38cb063 100644 --- a/src/vulkan/index_buffer.cc +++ b/src/vulkan/index_buffer.cc @@ -46,8 +46,9 @@ Result IndexBuffer::SendIndexData( if (values.empty()) return Result("IndexBuffer::SendIndexData |values| is empty"); - buffer_ = - MakeUnique<Buffer>(device_, sizeof(uint32_t) * values.size(), properties); + buffer_ = MakeUnique<Buffer>( + device_, static_cast<uint32_t>(sizeof(uint32_t) * values.size()), + properties); Result r = buffer_->Initialize(VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT); if (!r.IsSuccess()) diff --git a/src/vulkan/pipeline.cc b/src/vulkan/pipeline.cc index 24283df..a75d8da 100644 --- a/src/vulkan/pipeline.cc +++ b/src/vulkan/pipeline.cc @@ -262,14 +262,14 @@ Result Pipeline::AddPushConstant(const BufferCommand* command) { return push_constant_->AddBufferData(command); } -Result Pipeline::AddDescriptor(const BufferCommand* buffer_command) { - if (buffer_command == nullptr) +Result Pipeline::AddDescriptor(const BufferCommand* cmd) { + if (cmd == nullptr) return Result("Pipeline::AddDescriptor BufferCommand is nullptr"); - if (!buffer_command->IsSSBO() && !buffer_command->IsUniform()) + if (!cmd->IsSSBO() && !cmd->IsUniform()) return Result("Pipeline::AddDescriptor not supported buffer type"); - const uint32_t desc_set = buffer_command->GetDescriptorSet(); + const uint32_t desc_set = cmd->GetDescriptorSet(); if (desc_set >= descriptor_set_info_.size()) { for (size_t i = descriptor_set_info_.size(); i <= static_cast<size_t>(desc_set); ++i) { @@ -291,57 +291,44 @@ Result Pipeline::AddDescriptor(const BufferCommand* buffer_command) { auto& descriptors = descriptor_set_info_[desc_set].descriptors_; Descriptor* desc = nullptr; for (auto& descriptor : descriptors) { - if (descriptor->GetBinding() == buffer_command->GetBinding()) + if (descriptor->GetBinding() == cmd->GetBinding()) desc = descriptor.get(); } if (desc == nullptr) { - auto desc_type = buffer_command->IsSSBO() ? DescriptorType::kStorageBuffer - : DescriptorType::kUniformBuffer; + auto desc_type = cmd->IsSSBO() ? DescriptorType::kStorageBuffer + : DescriptorType::kUniformBuffer; auto buffer_desc = MakeUnique<BufferDescriptor>( - desc_type, device_, buffer_command->GetDescriptorSet(), - buffer_command->GetBinding()); + cmd->GetBuffer(), desc_type, device_, cmd->GetDescriptorSet(), + cmd->GetBinding()); descriptors.push_back(std::move(buffer_desc)); desc = descriptors.back().get(); } - if (buffer_command->IsSSBO() && !desc->IsStorageBuffer()) { + if (cmd->IsSSBO() && !desc->IsStorageBuffer()) { return Result( "Vulkan::AddDescriptor BufferCommand for SSBO uses wrong descriptor " "set and binding"); } - if (buffer_command->IsUniform() && !desc->IsUniformBuffer()) { + if (cmd->IsUniform() && !desc->IsUniformBuffer()) { return Result( "Vulkan::AddDescriptor BufferCommand for UBO uses wrong descriptor set " "and binding"); } - desc->AddToBufferInputQueue( - buffer_command->GetDatumType().GetType(), buffer_command->GetOffset(), - buffer_command->GetSize(), buffer_command->GetValues()); + auto* buf_desc = static_cast<BufferDescriptor*>(desc); + Result r = + buf_desc->AddToBuffer(cmd->GetDatumType().GetType(), cmd->GetOffset(), + cmd->GetSize(), cmd->GetValues()); + if (!r.IsSuccess()) + return r; return {}; } Result Pipeline::SendDescriptorDataToDeviceIfNeeded() { - bool data_send_needed = false; - for (auto& info : descriptor_set_info_) { - for (auto& desc : info.descriptors_) { - if (desc->HasDataNotSent()) { - data_send_needed = true; - break; - } - } - - if (data_send_needed) - break; - } - - if (!data_send_needed) - return {}; - Result r = command_->BeginIfNotInRecording(); if (!r.IsSuccess()) return r; @@ -429,30 +416,6 @@ Result Pipeline::ReadbackDescriptorsToHostDataQueue() { return {}; } -Result Pipeline::GetDescriptorInfo(const uint32_t descriptor_set, - const uint32_t binding, - ResourceInfo* info) { - assert(info); - - if (descriptor_set_info_.size() <= descriptor_set) { - return Result( - "Pipeline::GetDescriptorInfo no Descriptor class has given descriptor " - "set: " + - std::to_string(descriptor_set)); - } - - for (auto& desc : descriptor_set_info_[descriptor_set].descriptors_) { - if (desc->GetBinding() == binding) { - *info = desc->GetResourceInfo(); - return {}; - } - } - - return Result("Vulkan::Pipeline descriptor with descriptor set: " + - std::to_string(descriptor_set) + - ", binding: " + std::to_string(binding) + " does not exist"); -} - const char* Pipeline::GetEntryPointName(VkShaderStageFlagBits stage) const { auto it = entry_points_.find(stage); if (it != entry_points_.end()) diff --git a/src/vulkan/pipeline.h b/src/vulkan/pipeline.h index 1f69961..13b5e8c 100644 --- a/src/vulkan/pipeline.h +++ b/src/vulkan/pipeline.h @@ -57,11 +57,6 @@ class Pipeline { // Add information of how and what to do with push constant. Result AddPushConstant(const BufferCommand* command); - // Get the information of the resource bound to the given descriptor. - Result GetDescriptorInfo(const uint32_t descriptor_set, - const uint32_t binding, - ResourceInfo* info); - void SetEntryPointName(VkShaderStageFlagBits stage, const std::string& entry) { entry_points_[stage] = entry; diff --git a/src/vulkan/resource.cc b/src/vulkan/resource.cc index 08c6329..a847396 100644 --- a/src/vulkan/resource.cc +++ b/src/vulkan/resource.cc @@ -97,7 +97,7 @@ void BufferInput::UpdateBufferWithValues(void* buffer) const { } Resource::Resource(Device* device, - size_t size_in_bytes, + uint32_t size_in_bytes, const VkPhysicalDeviceMemoryProperties& properties) : device_(device), size_in_bytes_(size_in_bytes), diff --git a/src/vulkan/resource.h b/src/vulkan/resource.h index 6d937c0..1f1a8bd 100644 --- a/src/vulkan/resource.h +++ b/src/vulkan/resource.h @@ -36,7 +36,7 @@ struct BufferInput { void UpdateBufferWithValues(void* buffer) const; uint32_t offset; - size_t size_in_bytes; + uint32_t size_in_bytes; DataType type; // Type of |values|. std::vector<Value> values; // Data whose type is |type|. }; @@ -64,11 +64,11 @@ class Resource { virtual void* HostAccessibleMemoryPtr() const { return memory_ptr_; } - size_t GetSizeInBytes() const { return size_in_bytes_; } + uint32_t GetSizeInBytes() const { return size_in_bytes_; } protected: Resource(Device* device, - size_t size, + uint32_t size, const VkPhysicalDeviceMemoryProperties& properties); Result Initialize(); Result CreateVkBuffer(VkBuffer* buffer, VkBufferUsageFlags usage); @@ -110,7 +110,7 @@ class Resource { const VkMemoryRequirements GetVkBufferMemoryRequirements( VkBuffer buffer) const; - size_t size_in_bytes_ = 0; + uint32_t size_in_bytes_ = 0; VkPhysicalDeviceMemoryProperties physical_memory_properties_; VkBuffer host_accessible_buffer_ = VK_NULL_HANDLE; diff --git a/src/vulkan/vertex_buffer.cc b/src/vulkan/vertex_buffer.cc index c0333f0..60faa87 100644 --- a/src/vulkan/vertex_buffer.cc +++ b/src/vulkan/vertex_buffer.cc @@ -280,11 +280,11 @@ Result VertexBuffer::SendVertexData( if (!is_vertex_data_pending_) return Result("Vulkan::Vertices data was already sent"); - const size_t n_vertices = GetVertexCount(); + const uint32_t n_vertices = GetVertexCount(); if (n_vertices == 0) return Result("Vulkan::Data for VertexBuffer is empty"); - size_t bytes = static_cast<size_t>(Get4BytesAlignedStride()) * n_vertices; + uint32_t bytes = Get4BytesAlignedStride() * n_vertices; if (!buffer_) { buffer_ = MakeUnique<Buffer>(device_, bytes, properties); diff --git a/src/vulkan/vertex_buffer.h b/src/vulkan/vertex_buffer.h index cdf6e63..213df77 100644 --- a/src/vulkan/vertex_buffer.h +++ b/src/vulkan/vertex_buffer.h @@ -59,11 +59,12 @@ class VertexBuffer { return vertex_binding_desc; } - size_t GetVertexCount() const { + uint32_t GetVertexCount() const { if (data_.empty()) return 0; - return data_[0].size() / formats_[0].GetComponents().size(); + return static_cast<uint32_t>(data_[0].size() / + formats_[0].GetComponents().size()); } void BindToCommandBuffer(CommandBuffer* command); diff --git a/src/vulkan/vertex_buffer_test.cc b/src/vulkan/vertex_buffer_test.cc index e575535..bd3b6ae 100644 --- a/src/vulkan/vertex_buffer_test.cc +++ b/src/vulkan/vertex_buffer_test.cc @@ -32,7 +32,7 @@ const VkPhysicalDeviceMemoryProperties kMemoryProperties = class BufferForTest : public Buffer { public: BufferForTest(Device* device, - size_t size_in_bytes, + uint32_t size_in_bytes, const VkPhysicalDeviceMemoryProperties& properties) : Buffer(device, size_in_bytes, properties) { memory_.resize(4096); diff --git a/tests/cases/probe_no_compute_with_ssbo.vkscript b/tests/cases/probe_no_compute_with_ssbo.vkscript index ccd3593..a4a94a6 100644 --- a/tests/cases/probe_no_compute_with_ssbo.vkscript +++ b/tests/cases/probe_no_compute_with_ssbo.vkscript @@ -24,7 +24,7 @@ void main() { [test] ssbo 1:2 subdata vec4 0 0.1 0.2 0.3 0.4 -probe ssbo float 1:2 0 ~= 0.1 0.2 0.3 0.4 +probe ssbo float 1:2 0 ~= 0.1 0.2 0.3 0.4 ssbo 1:2 subdata float 0 0.57 0.56 0.55 0.54 \ |