blob: c31adc421ae94c26d0648c882b845e6017b21651 [file] [log] [blame]
// Copyright 2018 The Fuchsia 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 "src/ui/lib/escher/vk/impl/pipeline_layout_cache.h"
#include "src/ui/lib/escher/util/hasher.h"
#include "src/ui/lib/escher/util/trace_macros.h"
namespace escher {
namespace impl {
PipelineLayoutCache::PipelineLayoutCache(ResourceRecycler* recycler) : recycler_(recycler) {}
PipelineLayoutCache::~PipelineLayoutCache() = default;
const PipelineLayoutPtr& PipelineLayoutCache::ObtainPipelineLayout(const PipelineLayoutSpec& spec) {
auto pair = layouts_.Obtain(spec.hash());
if (!pair.second) {
FX_DCHECK(!pair.first->layout);
pair.first->layout = fxl::MakeRefCounted<PipelineLayout>(recycler_, spec);
}
FX_DCHECK(pair.first->layout);
return pair.first->layout;
}
void PipelineLayoutCache::BeginFrame() {
TRACE_DURATION("gfx", "escher::impl::PipelineLayoutCache::BeginFrame");
layouts_.BeginFrame();
}
} // namespace impl
} // namespace escher