Make the renderer APIs more verbose.

This commit is contained in:
Chinmay Garde
2021-11-03 11:16:58 -07:00
committed by Dan Field
parent 1c983cee42
commit 24f28685fe
10 changed files with 21 additions and 21 deletions

View File

@@ -82,7 +82,7 @@ bool LinearGradientContents::Render(const ContentRenderer& renderer,
FS::BindGradientInfo(
cmd, pass.GetTransientsBuffer().EmplaceUniform(gradient_info));
VS::BindFrameInfo(cmd, pass.GetTransientsBuffer().EmplaceUniform(frame_info));
return pass.RecordCommand(std::move(cmd));
return pass.AddCommand(std::move(cmd));
}
} // namespace impeller

View File

@@ -75,7 +75,7 @@ EntityRendererImpl::RenderResult EntityRendererImpl::RenderEntity(
cmd.primitive_type = PrimitiveType::kTriangle;
if (!pass.RecordCommand(std::move(cmd))) {
if (!pass.AddCommand(std::move(cmd))) {
return RenderResult::kFailure;
}
} else if (entity.GetContents()) {

View File

@@ -30,7 +30,7 @@ class CommandBufferMTL final : public CommandBuffer {
bool IsValid() const override;
// |CommandBuffer|
void Commit(CompletionCallback callback) override;
void SubmitCommands(CompletionCallback callback) override;
// |CommandBuffer|
std::shared_ptr<RenderPass> CreateRenderPass(

View File

@@ -34,7 +34,7 @@ static CommandBuffer::Status ToCommitResult(MTLCommandBufferStatus status) {
return CommandBufferMTL::Status::kError;
}
void CommandBufferMTL::Commit(CompletionCallback callback) {
void CommandBufferMTL::SubmitCommands(CompletionCallback callback) {
if (!callback) {
callback = [](auto) {};
}

View File

@@ -39,10 +39,10 @@ class RenderPassMTL final : public RenderPass {
HostBuffer& GetTransientsBuffer() override;
// |RenderPass|
bool RecordCommand(Command command) override;
bool AddCommand(Command command) override;
// |RenderPass|
bool Commit(Allocator& transients_allocator) const override;
bool EncodeCommands(Allocator& transients_allocator) const override;
bool EncodeCommands(Allocator& transients_allocator,
id<MTLRenderCommandEncoder> pass) const;

View File

@@ -118,7 +118,7 @@ void RenderPassMTL::SetLabel(std::string label) {
transients_buffer_->SetLabel(SPrintF("%s Transients", label_.c_str()));
}
bool RenderPassMTL::Commit(Allocator& transients_allocator) const {
bool RenderPassMTL::EncodeCommands(Allocator& transients_allocator) const {
if (!IsValid()) {
return false;
}
@@ -406,7 +406,7 @@ bool RenderPassMTL::EncodeCommands(Allocator& allocator,
return true;
}
bool RenderPassMTL::RecordCommand(Command command) {
bool RenderPassMTL::AddCommand(Command command) {
if (!command) {
return false;
}

View File

@@ -49,7 +49,7 @@ class CommandBuffer {
///
/// @param[in] callback The completion callback.
///
virtual void Commit(CompletionCallback callback) = 0;
virtual void SubmitCommands(CompletionCallback callback) = 0;
//----------------------------------------------------------------------------
/// @brief Create a render pass to record render commands into.

View File

@@ -24,7 +24,7 @@ class RenderPass {
virtual HostBuffer& GetTransientsBuffer() = 0;
//----------------------------------------------------------------------------
/// @brief Record a command for subsequent commit to the underlying
/// @brief Record a command for subsequent encoding to the underlying
/// command buffer. No work is encoded into the command buffer at
/// this time.
///
@@ -32,17 +32,17 @@ class RenderPass {
///
/// @return If the command was valid for subsequent commitment.
///
[[nodiscard]] virtual bool RecordCommand(Command command) = 0;
virtual bool AddCommand(Command command) = 0;
//----------------------------------------------------------------------------
/// @brief Commit the recorded commands to the underlying command buffer.
/// @brief Encode the recorded commands to the underlying command buffer.
///
/// @param transients_allocator The transients allocator.
///
/// @return If the commands were committed to the underlying command
/// @return If the commands were encoded to the underlying command
/// buffer.
///
[[nodiscard]] virtual bool Commit(Allocator& transients_allocator) const = 0;
virtual bool EncodeCommands(Allocator& transients_allocator) const = 0;
protected:
RenderPass();

View File

@@ -55,7 +55,7 @@ bool Renderer::Render(const Surface& surface,
return false;
}
if (!render_pass->Commit(*GetContext()->GetTransientsAllocator())) {
if (!render_pass->EncodeCommands(*GetContext()->GetTransientsAllocator())) {
return false;
}
@@ -63,7 +63,7 @@ bool Renderer::Render(const Surface& surface,
return false;
}
command_buffer->Commit(
command_buffer->SubmitCommands(
[sema = frames_in_flight_sema_](CommandBuffer::Status result) {
sema->Signal();
if (result != CommandBuffer::Status::kCompleted) {

View File

@@ -83,7 +83,7 @@ TEST_F(RendererTest, CanCreateBoxPrimitive) {
FS::BindContents2(cmd, bridge, sampler);
cmd.primitive_type = PrimitiveType::kTriangle;
if (!pass.RecordCommand(std::move(cmd))) {
if (!pass.AddCommand(std::move(cmd))) {
return false;
}
return true;
@@ -151,7 +151,7 @@ TEST_F(RendererTest, CanRenderMultiplePrimitives) {
Matrix::MakeTranslation({i * 50.0f, j * 50.0f, 0.0f});
VS::BindUniformBuffer(
cmd, pass.GetTransientsBuffer().EmplaceUniform(uniforms));
if (!pass.RecordCommand(cmd)) {
if (!pass.AddCommand(cmd)) {
return false;
}
}
@@ -249,8 +249,8 @@ TEST_F(RendererTest, CanRenderToTexture) {
Matrix::MakeTranslation({50.0f, 50.0f, 0.0f});
VS::BindUniformBuffer(
cmd, r2t_pass->GetTransientsBuffer().EmplaceUniform(uniforms));
ASSERT_TRUE(r2t_pass->RecordCommand(std::move(cmd)));
ASSERT_TRUE(r2t_pass->Commit(*context->GetTransientsAllocator()));
ASSERT_TRUE(r2t_pass->AddCommand(std::move(cmd)));
ASSERT_TRUE(r2t_pass->EncodeCommands(*context->GetTransientsAllocator()));
}
TEST_F(RendererTest, CanRenderPath) {
@@ -314,7 +314,7 @@ TEST_F(RendererTest, CanRenderPath) {
uniforms.mvp = Matrix::MakeOrthographic(surface.GetSize());
VS::BindUniformBuffer(cmd,
pass.GetTransientsBuffer().EmplaceUniform(uniforms));
if (!pass.RecordCommand(cmd)) {
if (!pass.AddCommand(cmd)) {
return false;
}