Skip to content

Commit

Permalink
[Impeller] Include the new primitive type in the pipeline hash (#37546)
Browse files Browse the repository at this point in the history
* Include the new primitive type in the pipeline hash

* Add test
  • Loading branch information
bdero authored and zanderso committed Nov 14, 2022
1 parent af741d9 commit cbb46c3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
1 change: 1 addition & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,7 @@ FILE: ../../../flutter/impeller/renderer/pipeline_builder.cc
FILE: ../../../flutter/impeller/renderer/pipeline_builder.h
FILE: ../../../flutter/impeller/renderer/pipeline_descriptor.cc
FILE: ../../../flutter/impeller/renderer/pipeline_descriptor.h
FILE: ../../../flutter/impeller/renderer/pipeline_descriptor_unittests.cc
FILE: ../../../flutter/impeller/renderer/pipeline_library.cc
FILE: ../../../flutter/impeller/renderer/pipeline_library.h
FILE: ../../../flutter/impeller/renderer/platform.cc
Expand Down
1 change: 1 addition & 0 deletions impeller/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ impeller_component("renderer_unittests") {
sources = [
"device_buffer_unittests.cc",
"host_buffer_unittests.cc",
"pipeline_descriptor_unittests.cc",
"renderer_unittests.cc",
]

Expand Down
4 changes: 3 additions & 1 deletion impeller/renderer/pipeline_descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ std::size_t PipelineDescriptor::GetHash() const {
fml::HashCombineSeed(seed, back_stencil_attachment_descriptor_);
fml::HashCombineSeed(seed, winding_order_);
fml::HashCombineSeed(seed, cull_mode_);
fml::HashCombineSeed(seed, primitive_type_);
return seed;
}

Expand All @@ -57,7 +58,8 @@ bool PipelineDescriptor::IsEqual(const PipelineDescriptor& other) const {
back_stencil_attachment_descriptor_ ==
other.back_stencil_attachment_descriptor_ &&
winding_order_ == other.winding_order_ &&
cull_mode_ == other.cull_mode_;
cull_mode_ == other.cull_mode_ &&
primitive_type_ == other.primitive_type_;
}

PipelineDescriptor& PipelineDescriptor::SetLabel(std::string label) {
Expand Down
27 changes: 27 additions & 0 deletions impeller/renderer/pipeline_descriptor_unittests.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <unordered_set>

#include "flutter/testing/testing.h"
#include "impeller/renderer/pipeline_descriptor.h"

namespace impeller {
namespace testing {

TEST(PipelineDescriptorTest, PrimitiveTypeHashEquality) {
PipelineDescriptor descA;
PipelineDescriptor descB;

ASSERT_TRUE(descA.IsEqual(descB));
ASSERT_EQ(descA.GetHash(), descB.GetHash());

descA.SetPrimitiveType(PrimitiveType::kTriangleStrip);

ASSERT_FALSE(descA.IsEqual(descB));
ASSERT_NE(descA.GetHash(), descB.GetHash());
}

} // namespace testing
} // namespace impeller

0 comments on commit cbb46c3

Please sign in to comment.