diff options
-rw-r--r-- | docs/amber_script.md | 22 | ||||
-rw-r--r-- | src/amberscript/parser.cc | 30 | ||||
-rw-r--r-- | src/amberscript/parser_test.cc | 146 | ||||
-rw-r--r-- | src/command.cc | 16 | ||||
-rw-r--r-- | src/command.h | 13 | ||||
-rw-r--r-- | src/dawn/engine_dawn.cc | 51 | ||||
-rw-r--r-- | src/dawn/engine_dawn.h | 1 | ||||
-rw-r--r-- | src/engine.h | 4 | ||||
-rw-r--r-- | src/executor.cc | 22 | ||||
-rw-r--r-- | src/executor_test.cc | 1 | ||||
-rw-r--r-- | src/verifier_test.cc | 144 | ||||
-rw-r--r-- | src/vkscript/command_parser.cc | 30 | ||||
-rw-r--r-- | src/vkscript/command_parser_test.cc | 83 | ||||
-rw-r--r-- | src/vulkan/compute_pipeline.cc | 8 | ||||
-rw-r--r-- | src/vulkan/engine_vulkan.cc | 4 | ||||
-rw-r--r-- | src/vulkan/engine_vulkan.h | 1 | ||||
-rw-r--r-- | src/vulkan/graphics_pipeline.cc | 35 | ||||
-rw-r--r-- | src/vulkan/graphics_pipeline.h | 1 | ||||
-rw-r--r-- | src/vulkan/pipeline.h | 2 | ||||
-rw-r--r-- | tests/cases/clear.amber | 2 |
20 files changed, 231 insertions, 385 deletions
diff --git a/docs/amber_script.md b/docs/amber_script.md index 60869a8..5c29110 100644 --- a/docs/amber_script.md +++ b/docs/amber_script.md @@ -315,24 +315,24 @@ CLEAR <pipeline> ``` # Checks that |buffer_name| at |x|, |y| has the given |value|s when compared # with the given |comparator|. -EXPECT <pipeline_name> BUFFER <buffer_name> IDX <x> <y> <comparator> <value>+ +EXPECT <buffer_name> IDX <x> <y> <comparator> <value>+ # Checks that |buffer_name| at |x|, |y| has values within |tolerance| of |value| # when compared with the given |comparator|. The |tolerance| can be specified # as 1-4 float values separated by spaces. -EXPECT <pipeline_name> BUFFER <buffer_name> IDX <x> <y> TOLERANCE \ +EXPECT <buffer_name> IDX <x> <y> TOLERANCE \ <tolerance>{1,4} <comparator> <value>+ # Checks that |buffer_name| at |x|, |y| for |width|x|height| pixels has the # given |r|, |g|, |b| values. Each r, g, b value is an integer from 0-255. -EXPECT <pipeline_name> BUFFER <buffer_name> IDX <x_in_pixels> <y_in_pixels> \ +EXPECT <buffer_name> IDX <x_in_pixels> <y_in_pixels> \ SIZE <width_in_pixels> <height_in_pixels> \ EQ_RGB <r (0 - 255)> <g (0 - 255)> <b (0 - 255)> # Checks that |buffer_name| at |x|, |y| for |width|x|height| pixels has the # given |r|, |g|, |b|, |a| values. Each r, g, b, a value is an integer # from 0-255. -EXPECT <pipeline_name> BUFFER <buffer_name> IDX <x_in_pixels> <y_in_pixels> \ +EXPECT <buffer_name> IDX <x_in_pixels> <y_in_pixels> \ SIZE <width_in_pixels> <height_in_pixels> \ EQ_RGBA <r (0 - 255)> <g (0 - 255)> <b (0 - 255)> <a (0 - 255)> ``` @@ -367,13 +367,13 @@ END # pipeline RUN kComputePipeline 256 256 1 # Four corners -EXPECT kComputePipeline BUFFER kComputeBuffer IDX 0 EQ 0 0 -EXPECT kComputePipeline BUFFER kComputeBuffer IDX 2040 EQ 255 0 -EXPECT kComputePipeline BUFFER kComputeBuffer IDX 522240 EQ 0 255 -EXPECT kComputePipeline BUFFER kComputeBuffer IDX 524280 EQ 255 255 +EXPECT kComputeBuffer IDX 0 EQ 0 0 +EXPECT kComputeBuffer IDX 2040 EQ 255 0 +EXPECT kComputeBuffer IDX 522240 EQ 0 255 +EXPECT kComputeBuffer IDX 524280 EQ 255 255 # Center -EXPECT kComputePipeline BUFFER kComputeBuffer IDX 263168 EQ 128 128 +EXPECT kComputeBuffer IDX 263168 EQ 128 128 ``` ### Entry Points @@ -448,8 +448,8 @@ END # pipeline RUN kRedPipeline DRAW_RECT POS 0 0 SIZE 256 256 RUN kGreenPipeline DRAW_RECT POS 128 128 SIZE 256 256 -EXPECT kGreenPipeline BUFFER kImgBuffer IDX 0 0 SIZE 127 127 EQ_RGB 255 0 0 -EXPECT kGreenPipeline BUFFER kImgBuffer IDX 128 128 SIZE 128 128 EQ_RGB 0 255 0 +EXPECT kImgBuffer IDX 0 0 SIZE 127 127 EQ_RGB 255 0 0 +EXPECT kImgBuffer IDX 128 128 SIZE 128 128 EQ_RGB 0 255 0 ``` ### Buffers diff --git a/src/amberscript/parser.cc b/src/amberscript/parser.cc index 9b99f91..dbd9e91 100644 --- a/src/amberscript/parser.cc +++ b/src/amberscript/parser.cc @@ -995,24 +995,6 @@ Result Parser::ParseClear() { Result Parser::ParseExpect() { auto token = tokenizer_->NextToken(); - if (token->IsEOS() || token->IsEOL()) - return Result("missing pipeline name in EXPECT command"); - if (!token->IsString()) - return Result("invalid pipeline name in EXPECT command"); - - auto* pipeline = script_->GetPipeline(token->AsString()); - if (!pipeline) - return Result("unknown pipeline name for EXPECT command"); - - token = tokenizer_->NextToken(); - if (token->IsEOS() || token->IsEOL()) - return Result("missing BUFFER in EXPECT command"); - if (!token->IsString() || token->AsString() != "BUFFER") { - return Result("expected BUFFER got '" + token->ToOriginalString() + - "' in " + "EXPECT command"); - } - - token = tokenizer_->NextToken(); if (!token->IsString()) return Result("invalid buffer name in EXPECT command"); @@ -1040,17 +1022,7 @@ Result Parser::ParseExpect() { token = tokenizer_->NextToken(); if (token->IsString() && token->AsString() == "SIZE") { - bool found = false; - for (const auto& info : pipeline->GetColorAttachments()) { - if (info.buffer == buffer) { - found = true; - break; - } - } - if (!found) - return Result("buffer not in pipeline for EXPECT command"); - - auto probe = MakeUnique<ProbeCommand>(pipeline, buffer); + auto probe = MakeUnique<ProbeCommand>(buffer); probe->SetX(x); probe->SetY(y); probe->SetProbeRect(); diff --git a/src/amberscript/parser_test.cc b/src/amberscript/parser_test.cc index d89c188..147fe59 100644 --- a/src/amberscript/parser_test.cc +++ b/src/amberscript/parser_test.cc @@ -3517,7 +3517,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 5 6 SIZE 250 150 EQ_RGB 2 128 255)"; +EXPECT my_fb IDX 5 6 SIZE 250 150 EQ_RGB 2 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3559,7 +3559,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 2 7 SIZE 20 88 EQ_RGBA 2 128 255 99)"; +EXPECT my_fb IDX 2 7 SIZE 20 88 EQ_RGBA 2 128 255 99)"; Parser parser; Result r = parser.Parse(in); @@ -3587,75 +3587,6 @@ EXPECT my_pipeline BUFFER my_fb IDX 2 7 SIZE 20 88 EQ_RGBA 2 128 255 99)"; EXPECT_EQ(99U, probe->GetA()); } -TEST_F(AmberScriptParserTest, ExpectMissingPipelineName) { - std::string in = R"( -SHADER vertex my_shader PASSTHROUGH -SHADER fragment my_fragment GLSL -# GLSL Shader -END -BUFFER my_fb FORMAT R32G32B32A32_SFLOAT - -PIPELINE graphics my_pipeline - ATTACH my_shader - ATTACH my_fragment - - BIND BUFFER my_fb AS color LOCATION 0 -END - -EXPECT BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; - - Parser parser; - Result r = parser.Parse(in); - ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("15: unknown pipeline name for EXPECT command", r.Error()); -} - -TEST_F(AmberScriptParserTest, ExpectInvalidPipelineName) { - std::string in = R"( -SHADER vertex my_shader PASSTHROUGH -SHADER fragment my_fragment GLSL -# GLSL Shader -END -BUFFER my_fb FORMAT R32G32B32A32_SFLOAT - -PIPELINE graphics my_pipeline - ATTACH my_shader - ATTACH my_fragment - - BIND BUFFER my_fb AS color LOCATION 0 -END - -EXPECT unknown_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; - - Parser parser; - Result r = parser.Parse(in); - ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("15: unknown pipeline name for EXPECT command", r.Error()); -} - -TEST_F(AmberScriptParserTest, ExpectMissingBuffer) { - std::string in = R"( -SHADER vertex my_shader PASSTHROUGH -SHADER fragment my_fragment GLSL -# GLSL Shader -END -BUFFER my_fb FORMAT R32G32B32A32_SFLOAT - -PIPELINE graphics my_pipeline - ATTACH my_shader - ATTACH my_fragment - - BIND BUFFER my_fb AS color LOCATION 0 -END - -EXPECT my_pipeline my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; - - Parser parser; - Result r = parser.Parse(in); - ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("15: expected BUFFER got 'my_fb' in EXPECT command", r.Error()); -} - TEST_F(AmberScriptParserTest, ExpectMissingBufferName) { std::string in = R"( SHADER vertex my_shader PASSTHROUGH @@ -3671,7 +3602,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; +EXPECT IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3694,7 +3625,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER unknown_buffer IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; +EXPECT unknown_buffer IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3702,27 +3633,6 @@ EXPECT my_pipeline BUFFER unknown_buffer IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)" EXPECT_EQ("15: unknown buffer name for EXPECT command", r.Error()); } -TEST_F(AmberScriptParserTest, ExpectBufferNotInPipeline) { - std::string in = R"( -SHADER vertex my_shader PASSTHROUGH -SHADER fragment my_fragment GLSL -# GLSL Shader -END -BUFFER other_fb FORMAT R32G32B32A32_SFLOAT - -PIPELINE graphics my_pipeline - ATTACH my_shader - ATTACH my_fragment -END - -EXPECT my_pipeline BUFFER other_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; - - Parser parser; - Result r = parser.Parse(in); - ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("13: buffer not in pipeline for EXPECT command", r.Error()); -} - TEST_F(AmberScriptParserTest, ExpectMissingIDX) { std::string in = R"( SHADER vertex my_shader PASSTHROUGH @@ -3738,7 +3648,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; +EXPECT my_fb 0 0 SIZE 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3761,7 +3671,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX SIZE 250 250 EQ_RGB 0 128 255)"; +EXPECT my_fb IDX SIZE 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3784,7 +3694,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 SIZE 250 250 EQ_RGB 0 128 255)"; +EXPECT my_fb IDX 0 SIZE 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3807,7 +3717,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX INVAILD 0 SIZE 250 250 EQ_RGB 0 128 255)"; +EXPECT my_fb IDX INVAILD 0 SIZE 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3830,7 +3740,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 INVALID SIZE 250 250 EQ_RGB 0 128 255)"; +EXPECT my_fb IDX 0 INVALID SIZE 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3853,7 +3763,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 250 250 EQ_RGB 0 128 255)"; +EXPECT my_fb IDX 0 0 250 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3876,7 +3786,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE EQ_RGB 0 128 255)"; +EXPECT my_fb IDX 0 0 SIZE EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3899,7 +3809,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 EQ_RGB 0 128 255)"; +EXPECT my_fb IDX 0 0 SIZE 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3922,7 +3832,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE INVALID 250 EQ_RGB 0 128 255)"; +EXPECT my_fb IDX 0 0 SIZE INVALID 250 EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3945,7 +3855,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 INVALID EQ_RGB 0 128 255)"; +EXPECT my_fb IDX 0 0 SIZE 250 INVALID EQ_RGB 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3968,7 +3878,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 INVALID 0 128 255)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 INVALID 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -3991,7 +3901,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGB)"; Parser parser; Result r = parser.Parse(in); @@ -4014,7 +3924,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128)"; Parser parser; Result r = parser.Parse(in); @@ -4037,7 +3947,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0)"; Parser parser; Result r = parser.Parse(in); @@ -4060,7 +3970,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGBA 0 128 255)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGBA 0 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -4083,7 +3993,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB INVALID 128 255)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGB INVALID 128 255)"; Parser parser; Result r = parser.Parse(in); @@ -4106,7 +4016,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 INVALID 255)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 INVALID 255)"; Parser parser; Result r = parser.Parse(in); @@ -4129,7 +4039,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 INVALID)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 INVALID)"; Parser parser; Result r = parser.Parse(in); @@ -4152,13 +4062,12 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 \ - EQ_RGBA 0 128 255 INVALID)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGBA 0 128 255 INVALID)"; Parser parser; Result r = parser.Parse(in); ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("16: invalid A value in EXPECT command", r.Error()); + EXPECT_EQ("15: invalid A value in EXPECT command", r.Error()); } TEST_F(AmberScriptParserTest, ExpectRGBExtraParam) { @@ -4176,7 +4085,7 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255 EXTRA)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGB 0 128 255 EXTRA)"; Parser parser; Result r = parser.Parse(in); @@ -4199,13 +4108,12 @@ PIPELINE graphics my_pipeline BIND BUFFER my_fb AS color LOCATION 0 END -EXPECT my_pipeline BUFFER my_fb IDX 0 0 SIZE 250 250 \ - EQ_RGBA 0 128 255 99 EXTRA)"; +EXPECT my_fb IDX 0 0 SIZE 250 250 EQ_RGBA 0 128 255 99 EXTRA)"; Parser parser; Result r = parser.Parse(in); ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("16: extra parameters after EXPECT command", r.Error()); + EXPECT_EQ("15: extra parameters after EXPECT command", r.Error()); } } // namespace amberscript diff --git a/src/command.cc b/src/command.cc index 9852383..d5a8429 100644 --- a/src/command.cc +++ b/src/command.cc @@ -86,25 +86,25 @@ ComputeCommand::ComputeCommand(Pipeline* pipeline) ComputeCommand::~ComputeCommand() = default; -Probe::Probe(Type type, Pipeline* pipeline) : Command(type, pipeline) {} +Probe::Probe(Type type, Buffer* buffer) + : Command(type, nullptr), buffer_(buffer) {} Probe::~Probe() = default; -ProbeCommand::ProbeCommand(Pipeline* pipeline, Buffer* buffer) - : Probe(Type::kProbe, pipeline), buffer_(buffer) {} +ProbeCommand::ProbeCommand(Buffer* buffer) : Probe(Type::kProbe, buffer) {} ProbeCommand::~ProbeCommand() = default; +ProbeSSBOCommand::ProbeSSBOCommand(Buffer* buffer) + : Probe(Type::kProbeSSBO, buffer) {} + +ProbeSSBOCommand::~ProbeSSBOCommand() = default; + BufferCommand::BufferCommand(BufferType type, Pipeline* pipeline) : Command(Type::kBuffer, pipeline), buffer_type_(type) {} BufferCommand::~BufferCommand() = default; -ProbeSSBOCommand::ProbeSSBOCommand(Pipeline* pipeline) - : Probe(Type::kProbeSSBO, pipeline) {} - -ProbeSSBOCommand::~ProbeSSBOCommand() = default; - ClearCommand::ClearCommand(Pipeline* pipeline) : Command(Type::kClear, pipeline) {} diff --git a/src/command.h b/src/command.h index 5a5f8b7..29b29a3 100644 --- a/src/command.h +++ b/src/command.h @@ -205,24 +205,25 @@ class Probe : public Command { ~Probe() override; + Buffer* GetBuffer() const { return buffer_; } + bool HasTolerances() const { return !tolerances_.empty(); } void SetTolerances(const std::vector<Tolerance>& t) { tolerances_ = t; } const std::vector<Tolerance>& GetTolerances() const { return tolerances_; } protected: - explicit Probe(Type type, Pipeline* pipeline); + explicit Probe(Type type, Buffer* buffer); private: + Buffer* buffer_; std::vector<Tolerance> tolerances_; }; class ProbeCommand : public Probe { public: - explicit ProbeCommand(Pipeline* pipeline, Buffer* buffer); + explicit ProbeCommand(Buffer* buffer); ~ProbeCommand() override; - Buffer* GetBuffer() const { return buffer_; } - void SetWholeWindow() { is_whole_window_ = true; } bool IsWholeWindow() const { return is_whole_window_; } @@ -265,8 +266,6 @@ class ProbeCommand : public Probe { kRGBA, }; - Buffer* buffer_; - bool is_whole_window_ = false; bool is_probe_rect_ = false; bool is_relative_ = false; @@ -295,7 +294,7 @@ class ProbeSSBOCommand : public Probe { kGreaterOrEqual }; - explicit ProbeSSBOCommand(Pipeline* pipeline); + explicit ProbeSSBOCommand(Buffer* buffer); ~ProbeSSBOCommand() override; void SetComparator(Comparator comp) { comparator_ = comp; } diff --git a/src/dawn/engine_dawn.cc b/src/dawn/engine_dawn.cc index 115e824..6cd5397 100644 --- a/src/dawn/engine_dawn.cc +++ b/src/dawn/engine_dawn.cc @@ -300,42 +300,14 @@ Result EngineDawn::DoClear(const ClearCommand*) { } Result EngineDawn::DoDrawRect(const DrawRectCommand*) { - return Result("Dawn:DoDrawRect not implemented"); -} - -Result EngineDawn::DoDrawArrays(const DrawArraysCommand*) { - return Result("Dawn:DoDrawArrays not implemented"); -} - -Result EngineDawn::DoCompute(const ComputeCommand*) { - return Result("Dawn:DoCompute not implemented"); -} - -Result EngineDawn::DoEntryPoint(const EntryPointCommand*) { - return Result("Dawn:DoEntryPoint not implemented"); -} - -Result EngineDawn::DoPatchParameterVertices( - const PatchParameterVerticesCommand*) { - return Result("Dawn:DoPatch not implemented"); -} - -Result EngineDawn::DoBuffer(const BufferCommand*) { - return Result("Dawn:DoBuffer not implemented"); -} - -Result EngineDawn::DoProcessCommands(Pipeline* pipeline) { Result result; - // TODO(dneto): How to distinguish the compute case: It won't have a - // framebuffer? - // Add one more command to the command buffer builder, which is to // copy the framebuffer texture to the framebuffer host-side buffer. ::dawn::Buffer& fb_buffer = render_pipeline_info_.fb_buffer; if (!fb_buffer) { return Result( - "Dawn::DoProcessCommands: Framebuffer was not created. Did you run " + "Dawn::DoDrawRect: Framebuffer was not created. Did you run " "any graphics pipeline commands?"); } @@ -387,6 +359,27 @@ Result EngineDawn::DoProcessCommands(Pipeline* pipeline) { return map.result; } +Result EngineDawn::DoDrawArrays(const DrawArraysCommand*) { + return Result("Dawn:DoDrawArrays not implemented"); +} + +Result EngineDawn::DoCompute(const ComputeCommand*) { + return Result("Dawn:DoCompute not implemented"); +} + +Result EngineDawn::DoEntryPoint(const EntryPointCommand*) { + return Result("Dawn:DoEntryPoint not implemented"); +} + +Result EngineDawn::DoPatchParameterVertices( + const PatchParameterVerticesCommand*) { + return Result("Dawn:DoPatch not implemented"); +} + +Result EngineDawn::DoBuffer(const BufferCommand*) { + return Result("Dawn:DoBuffer not implemented"); +} + Result EngineDawn::CreateCommandBufferBuilderIfNeeded() { if (command_buffer_builder_) return {}; diff --git a/src/dawn/engine_dawn.h b/src/dawn/engine_dawn.h index e03ccea..3fe8cab 100644 --- a/src/dawn/engine_dawn.h +++ b/src/dawn/engine_dawn.h @@ -60,7 +60,6 @@ class EngineDawn : public Engine { Result DoPatchParameterVertices( const PatchParameterVerticesCommand* cmd) override; Result DoBuffer(const BufferCommand* cmd) override; - Result DoProcessCommands(Pipeline*) override; Result GetFrameBuffer(Buffer*, std::vector<Value>* values) override; private: diff --git a/src/engine.h b/src/engine.h index cdd5af2..c46f505 100644 --- a/src/engine.h +++ b/src/engine.h @@ -93,10 +93,6 @@ class Engine { /// This covers both Vulkan buffers and images. virtual Result DoBuffer(const BufferCommand* cmd) = 0; - /// Run all queued commands and copy frame buffer data to the host - /// if graphics pipeline. - virtual Result DoProcessCommands(amber::Pipeline* pipeline) = 0; - /// Copy the content of the framebuffer into |values|, each value is a pixel /// in R8G8B8A8 format. virtual Result GetFrameBuffer(Buffer* buffer, std::vector<Value>* values) = 0; diff --git a/src/executor.cc b/src/executor.cc index a3ec347..b777cea 100644 --- a/src/executor.cc +++ b/src/executor.cc @@ -72,14 +72,11 @@ Result Executor::Execute(Engine* engine, // Process Commands for (const auto& cmd : script->GetCommands()) { if (cmd->IsProbe()) { - r = engine->DoProcessCommands(cmd->GetPipeline()); - if (!r.IsSuccess()) - return r; - assert(cmd->AsProbe()->GetBuffer()->IsFormatBuffer()); auto* buffer = cmd->AsProbe()->GetBuffer()->AsFormatBuffer(); - assert(buffer->GetMemPtr() != nullptr); + assert(buffer); + assert(buffer->GetMemPtr()); r = verifier_.Probe(cmd->AsProbe(), &buffer->GetFormat(), buffer->GetTexelStride(), buffer->GetRowStride(), @@ -88,18 +85,9 @@ Result Executor::Execute(Engine* engine, } else if (cmd->IsProbeSSBO()) { auto probe_ssbo = cmd->AsProbeSSBO(); - 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; + const auto* buffer = cmd->AsProbe()->GetBuffer(); + assert(buffer); + assert(buffer->GetMemPtr()); r = verifier_.ProbeSSBO(probe_ssbo, buffer->GetSize(), buffer->GetMemPtr()); diff --git a/src/executor_test.cc b/src/executor_test.cc index 7a93fd1..a0adea8 100644 --- a/src/executor_test.cc +++ b/src/executor_test.cc @@ -160,7 +160,6 @@ class EngineStub : public Engine { return {}; } - Result DoProcessCommands(Pipeline*) override { return {}; } Result GetFrameBuffer(Buffer*, std::vector<Value>*) override { return {}; } private: diff --git a/src/verifier_test.cc b/src/verifier_test.cc index 5b2629d..593488a 100644 --- a/src/verifier_test.cc +++ b/src/verifier_test.cc @@ -60,9 +60,8 @@ class VerifierTest : public testing::Test { TEST_F(VerifierTest, ProbeFrameBufferWholeWindow) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetWholeWindow(); probe.SetProbeRect(); probe.SetIsRGBA(); @@ -98,9 +97,8 @@ TEST_F(VerifierTest, ProbeFrameBufferWholeWindow) { TEST_F(VerifierTest, ProbeFrameBufferRelative) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetProbeRect(); probe.SetRelative(); probe.SetIsRGBA(); @@ -132,9 +130,8 @@ TEST_F(VerifierTest, ProbeFrameBufferRelative) { TEST_F(VerifierTest, ProbeFrameBufferRelativeSmallExpectFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetProbeRect(); probe.SetRelative(); probe.SetIsRGBA(); @@ -162,9 +159,8 @@ TEST_F(VerifierTest, ProbeFrameBufferRelativeSmallExpectFail) { TEST_F(VerifierTest, ProbeFrameBuffer) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetProbeRect(); probe.SetIsRGBA(); probe.SetX(1.0f); @@ -195,9 +191,8 @@ TEST_F(VerifierTest, ProbeFrameBuffer) { TEST_F(VerifierTest, ProbeFrameBufferUInt8) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -226,9 +221,8 @@ TEST_F(VerifierTest, ProbeFrameBufferUInt8) { TEST_F(VerifierTest, ProbeFrameBufferUInt16) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -257,9 +251,8 @@ TEST_F(VerifierTest, ProbeFrameBufferUInt16) { TEST_F(VerifierTest, ProbeFrameBufferUInt32) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -288,9 +281,8 @@ TEST_F(VerifierTest, ProbeFrameBufferUInt32) { TEST_F(VerifierTest, ProbeFrameBufferUInt64) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -319,9 +311,8 @@ TEST_F(VerifierTest, ProbeFrameBufferUInt64) { TEST_F(VerifierTest, ProbeFrameBufferSInt8) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -350,9 +341,8 @@ TEST_F(VerifierTest, ProbeFrameBufferSInt8) { TEST_F(VerifierTest, ProbeFrameBufferSInt16) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -381,9 +371,8 @@ TEST_F(VerifierTest, ProbeFrameBufferSInt16) { TEST_F(VerifierTest, ProbeFrameBufferSInt32) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -412,9 +401,8 @@ TEST_F(VerifierTest, ProbeFrameBufferSInt32) { TEST_F(VerifierTest, ProbeFrameBufferSInt64) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -443,9 +431,8 @@ TEST_F(VerifierTest, ProbeFrameBufferSInt64) { TEST_F(VerifierTest, ProbeFrameBufferFloat32) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -474,9 +461,8 @@ TEST_F(VerifierTest, ProbeFrameBufferFloat32) { TEST_F(VerifierTest, ProbeFrameBufferFloat64) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); @@ -505,9 +491,8 @@ TEST_F(VerifierTest, ProbeFrameBufferFloat64) { TEST_F(VerifierTest, HexFloatToFloatR16G11B10) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetX(0.0f); probe.SetY(0.0f); @@ -547,9 +532,8 @@ TEST_F(VerifierTest, HexFloatToFloatR16G11B10) { TEST_F(VerifierTest, HexFloatToFloatR11G16B10) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetX(0.0f); probe.SetY(0.0f); @@ -589,9 +573,8 @@ TEST_F(VerifierTest, HexFloatToFloatR11G16B10) { TEST_F(VerifierTest, HexFloatToFloatR10G11B16) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetX(0.0f); probe.SetY(0.0f); @@ -638,9 +621,8 @@ TEST_F(VerifierTest, ProbeFrameBufferNotRect) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(1.0f); probe.SetY(2.0f); @@ -658,9 +640,8 @@ TEST_F(VerifierTest, ProbeFrameBufferNotRect) { TEST_F(VerifierTest, ProbeFrameBufferRGB) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetWholeWindow(); probe.SetProbeRect(); probe.SetB(0.5f); @@ -694,9 +675,8 @@ TEST_F(VerifierTest, ProbeFrameBufferRGB) { TEST_F(VerifierTest, ProbeFrameBufferBadRowStride) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetWholeWindow(); probe.SetProbeRect(); @@ -715,9 +695,8 @@ TEST_F(VerifierTest, ProbeFrameBufferBadRowStride) { TEST_F(VerifierTest, ProbeSSBOUint8Single) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kUint8); @@ -741,9 +720,8 @@ TEST_F(VerifierTest, ProbeSSBOUint8Single) { TEST_F(VerifierTest, ProbeSSBOUint8Multiple) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kUint8); @@ -768,9 +746,8 @@ TEST_F(VerifierTest, ProbeSSBOUint8Multiple) { TEST_F(VerifierTest, ProbeSSBOUint8Many) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kUint8); @@ -800,9 +777,8 @@ TEST_F(VerifierTest, ProbeSSBOUint8Many) { TEST_F(VerifierTest, ProbeSSBOUint32Single) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kUint32); @@ -826,9 +802,8 @@ TEST_F(VerifierTest, ProbeSSBOUint32Single) { TEST_F(VerifierTest, ProbeSSBOUint32Multiple) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kUint32); @@ -854,9 +829,8 @@ TEST_F(VerifierTest, ProbeSSBOUint32Multiple) { TEST_F(VerifierTest, ProbeSSBOUint32Many) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kUint32); @@ -886,9 +860,8 @@ TEST_F(VerifierTest, ProbeSSBOUint32Many) { TEST_F(VerifierTest, ProbeSSBOFloatSingle) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kFloat); @@ -912,9 +885,8 @@ TEST_F(VerifierTest, ProbeSSBOFloatSingle) { TEST_F(VerifierTest, ProbeSSBOFloatMultiple) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kFloat); @@ -940,9 +912,8 @@ TEST_F(VerifierTest, ProbeSSBOFloatMultiple) { TEST_F(VerifierTest, ProbeSSBOFloatMany) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kFloat); @@ -972,9 +943,8 @@ TEST_F(VerifierTest, ProbeSSBOFloatMany) { TEST_F(VerifierTest, ProbeSSBODoubleSingle) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -998,9 +968,8 @@ TEST_F(VerifierTest, ProbeSSBODoubleSingle) { TEST_F(VerifierTest, ProbeSSBODoubleMultiple) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1026,9 +995,8 @@ TEST_F(VerifierTest, ProbeSSBODoubleMultiple) { TEST_F(VerifierTest, ProbeSSBODoubleMany) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1058,9 +1026,8 @@ TEST_F(VerifierTest, ProbeSSBODoubleMany) { TEST_F(VerifierTest, ProbeSSBOEqualFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1088,9 +1055,8 @@ TEST_F(VerifierTest, ProbeSSBOEqualFail) { TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithAbsoluteTolerance) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1125,9 +1091,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithAbsoluteTolerance) { TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithAbsoluteToleranceFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1159,9 +1124,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithAbsoluteToleranceFail) { TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithRelativeTolerance) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1196,9 +1160,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithRelativeTolerance) { TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithRelativeToleranceFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1230,9 +1193,8 @@ TEST_F(VerifierTest, ProbeSSBOFuzzyEqualWithRelativeToleranceFail) { TEST_F(VerifierTest, ProbeSSBONotEqual) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1258,9 +1220,8 @@ TEST_F(VerifierTest, ProbeSSBONotEqual) { TEST_F(VerifierTest, ProbeSSBONotEqualFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1288,9 +1249,8 @@ TEST_F(VerifierTest, ProbeSSBONotEqualFail) { TEST_F(VerifierTest, ProbeSSBOLess) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1316,9 +1276,8 @@ TEST_F(VerifierTest, ProbeSSBOLess) { TEST_F(VerifierTest, ProbeSSBOLessFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1346,9 +1305,8 @@ TEST_F(VerifierTest, ProbeSSBOLessFail) { TEST_F(VerifierTest, ProbeSSBOLessOrEqual) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1374,9 +1332,8 @@ TEST_F(VerifierTest, ProbeSSBOLessOrEqual) { TEST_F(VerifierTest, ProbeSSBOLessOrEqualFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1404,9 +1361,8 @@ TEST_F(VerifierTest, ProbeSSBOLessOrEqualFail) { TEST_F(VerifierTest, ProbeSSBOGreater) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1432,9 +1388,8 @@ TEST_F(VerifierTest, ProbeSSBOGreater) { TEST_F(VerifierTest, ProbeSSBOGreaterFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1462,9 +1417,8 @@ TEST_F(VerifierTest, ProbeSSBOGreaterFail) { TEST_F(VerifierTest, ProbeSSBOGreaterOrEqual) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1490,9 +1444,8 @@ TEST_F(VerifierTest, ProbeSSBOGreaterOrEqual) { TEST_F(VerifierTest, ProbeSSBOGreaterOrEqualFail) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeSSBOCommand probe_ssbo(&pipeline); + ProbeSSBOCommand probe_ssbo(color_buf.get()); DatumType datum_type; datum_type.SetType(DataType::kDouble); @@ -1520,9 +1473,8 @@ TEST_F(VerifierTest, ProbeSSBOGreaterOrEqualFail) { TEST_F(VerifierTest, CheckRGBAOrderForFailure) { Pipeline pipeline(PipelineType::kGraphics); auto color_buf = pipeline.GenerateDefaultColorAttachmentBuffer(); - pipeline.AddColorAttachment(color_buf.get(), 0); - ProbeCommand probe(&pipeline, color_buf.get()); + ProbeCommand probe(color_buf.get()); probe.SetIsRGBA(); probe.SetX(0.0f); probe.SetY(0.0f); diff --git a/src/vkscript/command_parser.cc b/src/vkscript/command_parser.cc index 97b9294..67ecdaa 100644 --- a/src/vkscript/command_parser.cc +++ b/src/vkscript/command_parser.cc @@ -878,7 +878,7 @@ Result CommandParser::ProcessProbe(bool relative) { if (!buffer) return Result("Pipeline missing color buffers, something went wrong."); - auto cmd = MakeUnique<ProbeCommand>(pipeline_, buffer); + auto cmd = MakeUnique<ProbeCommand>(buffer); cmd->SetLine(tokenizer_->GetCurrentLine()); cmd->SetTolerances(current_tolerances_); @@ -1978,9 +1978,7 @@ Result CommandParser::ParseComparator(const std::string& name, } Result CommandParser::ProcessProbeSSBO() { - auto cmd = MakeUnique<ProbeSSBOCommand>(pipeline_); - cmd->SetLine(tokenizer_->GetCurrentLine()); - cmd->SetTolerances(current_tolerances_); + size_t cur_line = tokenizer_->GetCurrentLine(); auto token = tokenizer_->NextToken(); if (token->IsEOL() || token->IsEOS()) @@ -1994,8 +1992,6 @@ Result CommandParser::ProcessProbeSSBO() { if (!r.IsSuccess()) return r; - cmd->SetDatumType(tp.GetType()); - token = tokenizer_->NextToken(); if (!token->IsInteger()) return Result("Invalid binding value for probe ssbo command: " + @@ -2003,11 +1999,13 @@ Result CommandParser::ProcessProbeSSBO() { uint32_t val = token->AsUint32(); + uint32_t set = 0; + uint32_t binding = 0; token = tokenizer_->NextToken(); if (token->IsString()) { auto& str = token->AsString(); if (str.size() >= 2 && str[0] == ':') { - cmd->SetDescriptorSet(val); + set = val; auto substr = str.substr(1, str.size()); uint64_t binding_val = strtoul(substr.c_str(), nullptr, 10); @@ -2015,7 +2013,7 @@ Result CommandParser::ProcessProbeSSBO() { return Result("binding value too large in probe ssbo command: " + token->ToOriginalString()); - cmd->SetBinding(static_cast<uint32_t>(binding_val)); + binding = static_cast<uint32_t>(binding_val); } else { return Result("Invalid value for probe ssbo command: " + token->ToOriginalString()); @@ -2023,9 +2021,23 @@ Result CommandParser::ProcessProbeSSBO() { token = tokenizer_->NextToken(); } else { - cmd->SetBinding(val); + binding = val; + } + + auto* buffer = pipeline_->GetBufferForBinding(set, binding); + if (!buffer) { + return Result("unable to find buffer at descriptor set " + + std::to_string(set) + " and binding " + + std::to_string(binding)); } + auto cmd = MakeUnique<ProbeSSBOCommand>(buffer); + cmd->SetLine(cur_line); + cmd->SetTolerances(current_tolerances_); + cmd->SetDatumType(tp.GetType()); + cmd->SetDescriptorSet(set); + cmd->SetBinding(binding); + if (!token->IsInteger()) return Result("Invalid offset for probe ssbo command: " + token->ToOriginalString()); diff --git a/src/vkscript/command_parser_test.cc b/src/vkscript/command_parser_test.cc index dd0838d..230dcbc 100644 --- a/src/vkscript/command_parser_test.cc +++ b/src/vkscript/command_parser_test.cc @@ -3831,6 +3831,7 @@ TEST_F(CommandParserTest, ToleranceWithCommas) { TEST_F(CommandParserTest, ProbeSSBOWithTolerance) { std::string data = R"( +ssbo 3:6 2 tolerance 2 3 4 5 probe ssbo vec3 3:6 2 >= 2.3 4.2 1.2)"; @@ -3841,10 +3842,10 @@ probe ssbo vec3 3:6 2 >= 2.3 4.2 1.2)"; ASSERT_TRUE(r.IsSuccess()) << r.Error(); auto& cmds = cp.Commands(); - ASSERT_EQ(1U, cmds.size()); - ASSERT_TRUE(cmds[0]->IsProbeSSBO()); + ASSERT_EQ(2U, cmds.size()); + ASSERT_TRUE(cmds[1]->IsProbeSSBO()); - auto* cmd = cmds[0]->AsProbeSSBO(); + auto* cmd = cmds[1]->AsProbeSSBO(); ASSERT_TRUE(cmd->HasTolerances()); auto& tolerances = cmd->GetTolerances(); @@ -3887,7 +3888,9 @@ probe all rgba 0.2 0.3 0.4 0.5)"; } TEST_F(CommandParserTest, ProbeSSBOWithDescriptorSet) { - std::string data = "probe ssbo vec3 3:6 2 >= 2.3 4.2 1.2"; + std::string data = R"( +ssbo 3:6 2 +probe ssbo vec3 3:6 2 >= 2.3 4.2 1.2)"; Pipeline pipeline(PipelineType::kGraphics); Script script; @@ -3896,10 +3899,10 @@ TEST_F(CommandParserTest, ProbeSSBOWithDescriptorSet) { ASSERT_TRUE(r.IsSuccess()) << r.Error(); auto& cmds = cp.Commands(); - ASSERT_EQ(1U, cmds.size()); - ASSERT_TRUE(cmds[0]->IsProbeSSBO()); + ASSERT_EQ(2U, cmds.size()); + ASSERT_TRUE(cmds[1]->IsProbeSSBO()); - auto* cmd = cmds[0]->AsProbeSSBO(); + auto* cmd = cmds[1]->AsProbeSSBO(); EXPECT_EQ(3U, cmd->GetDescriptorSet()); EXPECT_EQ(6U, cmd->GetBinding()); EXPECT_EQ(2U, cmd->GetOffset()); @@ -3920,7 +3923,9 @@ TEST_F(CommandParserTest, ProbeSSBOWithDescriptorSet) { } TEST_F(CommandParserTest, ProbeSSBOWithFloats) { - std::string data = "probe ssbo vec3 6 2 >= 2.3 4.2 1.2"; + std::string data = R"( +ssbo 6 2 +probe ssbo vec3 6 2 >= 2.3 4.2 1.2)"; Pipeline pipeline(PipelineType::kGraphics); Script script; @@ -3929,10 +3934,10 @@ TEST_F(CommandParserTest, ProbeSSBOWithFloats) { ASSERT_TRUE(r.IsSuccess()) << r.Error(); auto& cmds = cp.Commands(); - ASSERT_EQ(1U, cmds.size()); - ASSERT_TRUE(cmds[0]->IsProbeSSBO()); + ASSERT_EQ(2U, cmds.size()); + ASSERT_TRUE(cmds[1]->IsProbeSSBO()); - auto* cmd = cmds[0]->AsProbeSSBO(); + auto* cmd = cmds[1]->AsProbeSSBO(); EXPECT_EQ(static_cast<uint32_t>(0), cmd->GetDescriptorSet()); EXPECT_EQ(6U, cmd->GetBinding()); EXPECT_EQ(2U, cmd->GetOffset()); @@ -3953,8 +3958,10 @@ TEST_F(CommandParserTest, ProbeSSBOWithFloats) { } TEST_F(CommandParserTest, MultiProbeSSBOWithFloats) { - std::string data = - "probe ssbo vec3 6 2 >= 2.3 4.2 1.2\nprobe ssbo vec3 6 2 >= 2.3 4.2 1.2"; + std::string data = R"( +ssbo 6 2 +probe ssbo vec3 6 2 >= 2.3 4.2 1.2 +probe ssbo vec3 6 2 >= 2.3 4.2 1.2)"; Pipeline pipeline(PipelineType::kGraphics); Script script; @@ -3963,10 +3970,10 @@ TEST_F(CommandParserTest, MultiProbeSSBOWithFloats) { ASSERT_TRUE(r.IsSuccess()) << r.Error(); auto& cmds = cp.Commands(); - ASSERT_EQ(2U, cmds.size()); - ASSERT_TRUE(cmds[0]->IsProbeSSBO()); + ASSERT_EQ(3U, cmds.size()); + ASSERT_TRUE(cmds[1]->IsProbeSSBO()); - auto* cmd = cmds[0]->AsProbeSSBO(); + auto* cmd = cmds[1]->AsProbeSSBO(); EXPECT_EQ(6U, cmd->GetBinding()); EXPECT_EQ(2U, cmd->GetOffset()); EXPECT_EQ(ProbeSSBOCommand::Comparator::kGreaterOrEqual, @@ -3986,7 +3993,9 @@ TEST_F(CommandParserTest, MultiProbeSSBOWithFloats) { } TEST_F(CommandParserTest, ProbeSSBOWithInts) { - std::string data = "probe ssbo i16vec3 6 2 <= 2 4 1"; + std::string data = R"( +ssbo 6 2 +probe ssbo i16vec3 6 2 <= 2 4 1)"; Pipeline pipeline(PipelineType::kGraphics); Script script; @@ -3995,10 +4004,10 @@ TEST_F(CommandParserTest, ProbeSSBOWithInts) { ASSERT_TRUE(r.IsSuccess()) << r.Error(); auto& cmds = cp.Commands(); - ASSERT_EQ(1U, cmds.size()); - ASSERT_TRUE(cmds[0]->IsProbeSSBO()); + ASSERT_EQ(2U, cmds.size()); + ASSERT_TRUE(cmds[1]->IsProbeSSBO()); - auto* cmd = cmds[0]->AsProbeSSBO(); + auto* cmd = cmds[1]->AsProbeSSBO(); EXPECT_EQ(static_cast<uint32_t>(0), cmd->GetDescriptorSet()); EXPECT_EQ(6U, cmd->GetBinding()); EXPECT_EQ(2U, cmd->GetOffset()); @@ -4018,7 +4027,9 @@ TEST_F(CommandParserTest, ProbeSSBOWithInts) { } TEST_F(CommandParserTest, ProbeSSBOWithMultipleVectors) { - std::string data = "probe ssbo i16vec3 6 2 == 2 4 1 3 6 8"; + std::string data = R"( +ssbo 6 2 +probe ssbo i16vec3 6 2 == 2 4 1 3 6 8)"; Pipeline pipeline(PipelineType::kGraphics); Script script; @@ -4027,10 +4038,10 @@ TEST_F(CommandParserTest, ProbeSSBOWithMultipleVectors) { ASSERT_TRUE(r.IsSuccess()) << r.Error(); auto& cmds = cp.Commands(); - ASSERT_EQ(1U, cmds.size()); - ASSERT_TRUE(cmds[0]->IsProbeSSBO()); + ASSERT_EQ(2U, cmds.size()); + ASSERT_TRUE(cmds[1]->IsProbeSSBO()); - auto* cmd = cmds[0]->AsProbeSSBO(); + auto* cmd = cmds[1]->AsProbeSSBO(); EXPECT_EQ(static_cast<uint32_t>(0), cmd->GetDescriptorSet()); EXPECT_EQ(6U, cmd->GetBinding()); EXPECT_EQ(2U, cmd->GetOffset()); @@ -4084,14 +4095,16 @@ TEST_F(CommandParserTest, ProbeSSBOWithBadType) { } TEST_F(CommandParserTest, ProbeSSBOWithInvalidFloatOffset) { - std::string data = "probe ssbo vec2 0 2.0 == 3 2 4"; + std::string data = R"( +ssbo 0 2 +probe ssbo vec2 0 2.0 == 3 2 4)"; Pipeline pipeline(PipelineType::kGraphics); 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()); + EXPECT_EQ("3: Invalid offset for probe ssbo command: 2.0", r.Error()); } TEST_F(CommandParserTest, ProbeSSBOWithInvalidStringOffset) { @@ -4106,37 +4119,43 @@ TEST_F(CommandParserTest, ProbeSSBOWithInvalidStringOffset) { } TEST_F(CommandParserTest, ProbeSSBOWithInvalidComparator) { - std::string data = "probe ssbo vec2 6 2 INVALID 3 2 4"; + std::string data = R"( +ssbo 6 2 +probe ssbo vec2 6 2 INVALID 3 2 4)"; Pipeline pipeline(PipelineType::kGraphics); Script script; CommandParser cp(&script, &pipeline, 1, data); Result r = cp.Parse(); ASSERT_FALSE(r.IsSuccess()); - EXPECT_EQ("1: Invalid comparator: INVALID", r.Error()); + EXPECT_EQ("3: Invalid comparator: INVALID", r.Error()); } TEST_F(CommandParserTest, ProbeSSBOWithMissingData) { - std::string data = "probe ssbo i16vec3 6 2 == 2"; + std::string data = R"( +ssbo 6 2 +probe ssbo i16vec3 6 2 == 2)"; Pipeline pipeline(PipelineType::kGraphics); 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", + EXPECT_EQ("3: Incorrect number of values provided to probe ssbo command", r.Error()); } TEST_F(CommandParserTest, ProbeSSBOWithMissingAllData) { - std::string data = "probe ssbo i16vec3 6 2 =="; + std::string data = R"( +ssbo 6 2 +probe ssbo i16vec3 6 2 ==)"; Pipeline pipeline(PipelineType::kGraphics); 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", + EXPECT_EQ("3: Incorrect number of values provided to probe ssbo command", r.Error()); } diff --git a/src/vulkan/compute_pipeline.cc b/src/vulkan/compute_pipeline.cc index f03659e..849b900 100644 --- a/src/vulkan/compute_pipeline.cc +++ b/src/vulkan/compute_pipeline.cc @@ -116,6 +116,14 @@ Result ComputePipeline::Compute(uint32_t x, uint32_t y, uint32_t z) { command_->GetCommandBuffer(), VK_PIPELINE_BIND_POINT_COMPUTE, pipeline); device_->GetPtrs()->vkCmdDispatch(command_->GetCommandBuffer(), x, y, z); + r = command_->End(); + if (!r.IsSuccess()) + return r; + + r = command_->SubmitAndReset(GetFenceTimeout()); + if (!r.IsSuccess()) + return r; + r = ReadbackDescriptorsToHostDataQueue(); if (!r.IsSuccess()) return r; diff --git a/src/vulkan/engine_vulkan.cc b/src/vulkan/engine_vulkan.cc index bf6037d..f662c28 100644 --- a/src/vulkan/engine_vulkan.cc +++ b/src/vulkan/engine_vulkan.cc @@ -403,10 +403,6 @@ Result EngineVulkan::DoPatchParameterVertices( return {}; } -Result EngineVulkan::DoProcessCommands(amber::Pipeline* pipeline) { - return pipeline_map_[pipeline].vk_pipeline->ProcessCommands(); -} - Result EngineVulkan::GetFrameBuffer(Buffer* buffer, std::vector<Value>* values) { values->clear(); diff --git a/src/vulkan/engine_vulkan.h b/src/vulkan/engine_vulkan.h index f44c1d9..dd98600 100644 --- a/src/vulkan/engine_vulkan.h +++ b/src/vulkan/engine_vulkan.h @@ -58,7 +58,6 @@ class EngineVulkan : public Engine { Result DoPatchParameterVertices( const PatchParameterVerticesCommand* cmd) override; Result DoBuffer(const BufferCommand* cmd) override; - Result DoProcessCommands(amber::Pipeline* pipeline) override; Result GetFrameBuffer(Buffer* buffer, std::vector<Value>* values) override; private: diff --git a/src/vulkan/graphics_pipeline.cc b/src/vulkan/graphics_pipeline.cc index aaa4f9b..ff0c252 100644 --- a/src/vulkan/graphics_pipeline.cc +++ b/src/vulkan/graphics_pipeline.cc @@ -683,8 +683,6 @@ Result GraphicsPipeline::SendVertexBufferDataIfNeeded( if (!r.IsSuccess()) return r; - DeactivateRenderPassIfNeeded(); - return vertex_buffer->SendVertexData(command_.get(), memory_properties_); } @@ -701,8 +699,6 @@ Result GraphicsPipeline::SetIndexBuffer(const std::vector<Value>& values) { if (!r.IsSuccess()) return r; - DeactivateRenderPassIfNeeded(); - r = index_buffer_->SendIndexData(command_.get(), memory_properties_, values); if (!r.IsSuccess()) return r; @@ -819,7 +815,19 @@ Result GraphicsPipeline::ClearBuffer(const VkClearValue& clear_value, DeactivateRenderPassIfNeeded(); - return frame_->CopyColorImagesToHost(command_.get()); + r = frame_->CopyColorImagesToHost(command_.get()); + if (!r.IsSuccess()) + return r; + + r = command_->End(); + if (!r.IsSuccess()) + return r; + + r = command_->SubmitAndReset(GetFenceTimeout()); + if (!r.IsSuccess()) + return r; + + return {}; } Result GraphicsPipeline::Draw(const DrawArraysCommand* command, @@ -828,8 +836,6 @@ Result GraphicsPipeline::Draw(const DrawArraysCommand* command, if (!r.IsSuccess()) return r; - DeactivateRenderPassIfNeeded(); - r = SendDescriptorDataToDeviceIfNeeded(); if (!r.IsSuccess()) return r; @@ -919,6 +925,14 @@ Result GraphicsPipeline::Draw(const DrawArraysCommand* command, if (!r.IsSuccess()) return r; + r = command_->End(); + if (!r.IsSuccess()) + return r; + + r = command_->SubmitAndReset(GetFenceTimeout()); + if (!r.IsSuccess()) + return r; + r = ReadbackDescriptorsToHostDataQueue(); if (!r.IsSuccess()) return r; @@ -930,14 +944,7 @@ Result GraphicsPipeline::Draw(const DrawArraysCommand* command, return {}; } -Result GraphicsPipeline::ProcessCommands() { - DeactivateRenderPassIfNeeded(); - return Pipeline::ProcessCommands(); -} - void GraphicsPipeline::Shutdown() { - DeactivateRenderPassIfNeeded(); - index_buffer_ = nullptr; Pipeline::Shutdown(); frame_ = nullptr; diff --git a/src/vulkan/graphics_pipeline.h b/src/vulkan/graphics_pipeline.h index baeb897..447feb8 100644 --- a/src/vulkan/graphics_pipeline.h +++ b/src/vulkan/graphics_pipeline.h @@ -77,7 +77,6 @@ class GraphicsPipeline : public Pipeline { // Pipeline void Shutdown() override; - Result ProcessCommands() override; private: enum class RenderPassState : uint8_t { diff --git a/src/vulkan/pipeline.h b/src/vulkan/pipeline.h index 13b5e8c..abd91f6 100644 --- a/src/vulkan/pipeline.h +++ b/src/vulkan/pipeline.h @@ -65,7 +65,7 @@ class Pipeline { // End recording command buffer if it is in recording state. This // method also submits commands in the command buffer and reset // the command buffer. - virtual Result ProcessCommands(); + Result ProcessCommands(); virtual void Shutdown(); diff --git a/tests/cases/clear.amber b/tests/cases/clear.amber index 705b290..c3232ae 100644 --- a/tests/cases/clear.amber +++ b/tests/cases/clear.amber @@ -36,4 +36,4 @@ PIPELINE graphics my_pipeline END CLEAR my_pipeline -EXPECT my_pipeline BUFFER img_buf IDX 0 0 SIZE 256 256 EQ_RGBA 0 0 0 0 +EXPECT img_buf IDX 0 0 SIZE 256 256 EQ_RGBA 0 0 0 0 |