Flutter Impeller
swapchain_transients_mtl.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
9 
10 namespace impeller {
11 
13  const std::shared_ptr<Allocator>& allocator)
14  : allocator_(allocator) {}
15 
17 
19  if (size != size_ || format != format_) {
20  resolve_tex_ = nullptr;
21  msaa_tex_ = nullptr;
22  depth_stencil_tex_ = nullptr;
23  }
24  size_ = size;
25  format_ = format;
26 }
27 
28 std::shared_ptr<Texture> SwapchainTransientsMTL::GetResolveTexture() {
29  if (!resolve_tex_) {
30  TextureDescriptor desc;
31  desc.size = size_;
33  desc.format = format_;
38 
39  resolve_tex_ = allocator_->CreateTexture(desc);
40  if (!resolve_tex_) {
41  VALIDATION_LOG << "Failed to allocate resolve texture.";
42  return nullptr;
43  }
44  resolve_tex_->SetLabel("ImpellerOnscreenResolve");
45  }
46 
47  return resolve_tex_;
48 }
49 
50 std::shared_ptr<Texture> SwapchainTransientsMTL::GetMSAATexture() {
51  if (!msaa_tex_) {
52  TextureDescriptor desc;
53  desc.size = size_;
55  desc.format = format_;
59 
60  msaa_tex_ = allocator_->CreateTexture(desc);
61  if (!msaa_tex_) {
62  VALIDATION_LOG << "Failed to allocate MSAA texture.";
63  return nullptr;
64  }
65  msaa_tex_->SetLabel("ImpellerOnscreenMSAA");
66  }
67 
68  return msaa_tex_;
69 }
70 
72  if (!depth_stencil_tex_) {
73  TextureDescriptor desc;
74  desc.size = size_;
80 
81  depth_stencil_tex_ = allocator_->CreateTexture(desc);
82  if (!depth_stencil_tex_) {
83  VALIDATION_LOG << "Failed to allocate depth-stencil texture.";
84  return nullptr;
85  }
86  depth_stencil_tex_->SetLabel("ImpellerOnscreenDepth+Stencil");
87  }
88 
89  return depth_stencil_tex_;
90 }
91 
92 } // namespace impeller
SwapchainTransientsMTL(const std::shared_ptr< Allocator > &allocator)
std::shared_ptr< Texture > GetResolveTexture()
Retrieve the resolve texture, creating one if needed.
void SetSizeAndFormat(ISize size, PixelFormat format)
Update the size and pixel format of the onscreens.
std::shared_ptr< Texture > GetMSAATexture()
Retrieve the MSAA texture, creating one if needed.
std::shared_ptr< Texture > GetDepthStencilTexture()
Retrieve the depth+stencil texture, creating one if needed.
PixelFormat
The Pixel formats supported by Impeller. The naming convention denotes the usage of the component,...
Definition: formats.h:99
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
#define VALIDATION_LOG
Definition: validation.h:91