• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // RenderTargetMtl.h:
7 //    Defines the class interface for RenderTargetMtl.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_METAL_RENDERTARGETMTL_H_
11 #define LIBANGLE_RENDERER_METAL_RENDERTARGETMTL_H_
12 
13 #import <Metal/Metal.h>
14 
15 #include "libANGLE/FramebufferAttachment.h"
16 #include "libANGLE/renderer/metal/mtl_format_utils.h"
17 #include "libANGLE/renderer/metal/mtl_resources.h"
18 #include "libANGLE/renderer/metal/mtl_state_cache.h"
19 
20 namespace rx
21 {
22 
23 // This is a very light-weight class that does not own to the resources it points to.
24 // It's meant only to copy across some information from a FramebufferAttachment to the
25 // business rendering logic.
26 class RenderTargetMtl final : public FramebufferAttachmentRenderTarget
27 {
28   public:
29     RenderTargetMtl();
30     ~RenderTargetMtl() override;
31 
32     // Used in std::vector initialization.
33     RenderTargetMtl(RenderTargetMtl &&other);
34 
35     void set(const mtl::TextureRef &texture,
36              const mtl::MipmapNativeLevel &level,
37              uint32_t layer,
38              const mtl::Format &format);
39     void setWithImplicitMSTexture(const mtl::TextureRef &texture,
40                                   const mtl::TextureRef &implicitMSTexture,
41                                   const mtl::MipmapNativeLevel &level,
42                                   uint32_t layer,
43                                   const mtl::Format &format);
44     void setTexture(const mtl::TextureRef &texture);
45     void setImplicitMSTexture(const mtl::TextureRef &implicitMSTexture);
46     void duplicateFrom(const RenderTargetMtl &src);
47     void reset();
48 
getTexture()49     mtl::TextureRef getTexture() const { return mTexture.lock(); }
getImplicitMSTexture()50     mtl::TextureRef getImplicitMSTexture() const { return mImplicitMSTexture.lock(); }
getLevelIndex()51     const mtl::MipmapNativeLevel &getLevelIndex() const { return mLevelIndex; }
getLayerIndex()52     uint32_t getLayerIndex() const { return mLayerIndex; }
53     uint32_t getRenderSamples() const;
getFormat()54     const mtl::Format *getFormat() const { return mFormat; }
55 
56     void toRenderPassAttachmentDesc(mtl::RenderPassAttachmentDesc *rpaDescOut) const;
57 
58   private:
59     mtl::TextureWeakRef mTexture;
60     mtl::TextureWeakRef mImplicitMSTexture;
61     mtl::MipmapNativeLevel mLevelIndex = mtl::kZeroNativeMipLevel;
62     uint32_t mLayerIndex               = 0;
63     const mtl::Format *mFormat         = nullptr;
64 };
65 }  // namespace rx
66 
67 #endif /* LIBANGLE_RENDERER_METAL_RENDERTARGETMTL_H */
68