diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 92fe650ca60de..4d520632ee741 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -89,6 +89,11 @@ Layer::Inputs::~Inputs() = default;
 Layer::LayerTreeInputs::LayerTreeInputs() = default;
 Layer::LayerTreeInputs::~LayerTreeInputs() = default;
 
+int Layer::GetNextLayerId() {
+  // Layer IDs start from 1.
+  return g_next_layer_id.GetNext() + 1;
+}
+
 scoped_refptr<Layer> Layer::Create() {
   return base::WrapRefCounted(new Layer());
 }
@@ -96,8 +101,7 @@ scoped_refptr<Layer> Layer::Create() {
 Layer::Layer()
     : parent_(nullptr),
       layer_tree_host_(nullptr),
-      // Layer IDs start from 1.
-      layer_id_(g_next_layer_id.GetNext() + 1),
+      layer_id_(GetNextLayerId()),
       num_descendants_that_draw_content_(0),
       transform_tree_index_(kInvalidPropertyNodeId),
       effect_tree_index_(kInvalidPropertyNodeId),
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 34c6e2681da89..2354ffcff0b63 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -95,6 +95,9 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
     INVALID_ID = -1,
   };
 
+  // Get a unique layer id.
+  static int GetNextLayerId();
+
   // Factory to create a new Layer, with a unique id.
   static scoped_refptr<Layer> Create();
 
diff --git a/cc/layers/render_surface_impl.cc b/cc/layers/render_surface_impl.cc
index b7d915d802974..e2c30f75476b2 100644
--- a/cc/layers/render_surface_impl.cc
+++ b/cc/layers/render_surface_impl.cc
@@ -37,7 +37,8 @@ RenderSurfaceImpl::RenderSurfaceImpl(LayerTreeImpl* layer_tree_impl,
                                      ElementId id)
     : layer_tree_impl_(layer_tree_impl),
       id_(id),
-      effect_tree_index_(kInvalidPropertyNodeId) {
+      effect_tree_index_(kInvalidPropertyNodeId),
+      layer_id_(Layer::GetNextLayerId()) {
   DCHECK(id);
   damage_tracker_ = DamageTracker::Create();
 }
@@ -459,7 +460,7 @@ void RenderSurfaceImpl::AppendQuads(DrawMode draw_mode,
   shared_quad_state->SetAll(
       draw_transform(), content_rect(), content_rect(), mask_filter_info(),
       clip_rect, contents_opaque, draw_properties_.draw_opacity, BlendMode(),
-      sorting_context_id, /*layer_id=*/0u, is_fast_rounded_corner());
+      sorting_context_id, layer_id_, is_fast_rounded_corner());
 
   if (layer_tree_impl_->debug_state().show_debug_borders.test(
           DebugBorderType::RENDERPASS)) {
diff --git a/cc/layers/render_surface_impl.h b/cc/layers/render_surface_impl.h
index 7667f9869029d..3e2919dc65d96 100644
--- a/cc/layers/render_surface_impl.h
+++ b/cc/layers/render_surface_impl.h
@@ -273,6 +273,10 @@ class CC_EXPORT RenderSurfaceImpl {
   ElementId id_;
   int effect_tree_index_;
 
+  // A unique id in the same namespace as `Layer::layer_id_`, so viz can
+  // identify `RenderPassDrawQuads` across the frame, similarly to other quads.
+  uint32_t layer_id_ = 0;
+
   // Container for properties that render surfaces need to compute before they
   // can be drawn.
   struct DrawProperties {
diff --git a/cc/slim/layer.cc b/cc/slim/layer.cc
index fa2fcb62f1e88..c40bd35c10ee9 100644
--- a/cc/slim/layer.cc
+++ b/cc/slim/layer.cc
@@ -429,7 +429,8 @@ viz::SharedQuadState* Layer::CreateAndAppendSharedQuadState(
                      data.mask_filter_info_in_target, clip_opt,
                      contents_opaque(), opacity, SkBlendMode::kSrcOver,
                      /*sorting_context=*/0,
-                     /*layer_id=*/0u, /*fast_rounded_corner=*/false);
+                     /*layer_id=*/static_cast<uint32_t>(id()),
+                     /*fast_rounded_corner=*/false);
   quad_state->is_fast_rounded_corner = true;
   quad_state->offset_tag = data.offset_tag;
   return quad_state;
diff --git a/components/viz/common/quads/shared_quad_state.h b/components/viz/common/quads/shared_quad_state.h
index 67136d5679341..89dc1102022e5 100644
--- a/components/viz/common/quads/shared_quad_state.h
+++ b/components/viz/common/quads/shared_quad_state.h
@@ -74,10 +74,10 @@ class VIZ_COMMON_EXPORT SharedQuadState {
   float opacity = 1.0f;
   SkBlendMode blend_mode = SkBlendMode::kSrcOver;
   int sorting_context_id = 0;
-  // Optionally set by the client with a stable ID for the layer that produced
-  // the DrawQuad(s). This is used to help identify that DrawQuad(s) in one
-  // frame came from the same layer as DrawQuads() from a previous frame, even
-  // if they changed position or other attributes.
+  // Optionally set by the client as a performance hint for viz with a stable ID
+  // for the layer that produced the DrawQuad(s). This is used to help identify
+  // that DrawQuad(s) in one frame came from the same layer as DrawQuads() from
+  // a previous frame, even if they changed position or other attributes.
   uint32_t layer_id = 0;
   // Used by SurfaceAggregator to namespace layer_ids from different clients.
   uint32_t layer_namespace_id = 0;
diff --git a/components/viz/service/display/overlay_candidate_factory.cc b/components/viz/service/display/overlay_candidate_factory.cc
index b9e7c1f0f03c0..983b88c8e8618 100644
--- a/components/viz/service/display/overlay_candidate_factory.cc
+++ b/components/viz/service/display/overlay_candidate_factory.cc
@@ -173,15 +173,13 @@ OverlayCandidate::CandidateStatus OverlayCandidateFactory::FromDrawQuad(
   candidate.overlay_damage_index =
       sqs->overlay_damage_index.value_or(OverlayCandidate::kInvalidDamageIndex);
 
-  if (sqs->layer_id != 0) {
-    static_assert(
-        std::is_same<decltype(SharedQuadState::layer_id), uint32_t>::value);
-    static_assert(std::is_same<decltype(SharedQuadState::layer_namespace_id),
-                               uint32_t>::value);
-    candidate.aggregated_layer_id =
-        static_cast<uint64_t>(sqs->layer_id) |
-        (static_cast<uint64_t>(sqs->layer_namespace_id) << 32);
-  }
+  static_assert(
+      std::is_same<decltype(SharedQuadState::layer_id), uint32_t>::value);
+  static_assert(std::is_same<decltype(SharedQuadState::layer_namespace_id),
+                             uint32_t>::value);
+  candidate.aggregated_layer_id =
+      static_cast<uint64_t>(sqs->layer_id) |
+      (static_cast<uint64_t>(sqs->layer_namespace_id) << 32);
 
   auto status = CandidateStatus::kFailQuadNotSupported;
   switch (quad->material) {