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 void set(const mtl::TextureRef &texture, 33 const mtl::MipmapNativeLevel &level, 34 uint32_t layer, 35 const mtl::Format &format); 36 void setWithImplicitMSTexture(const mtl::TextureRef &texture, 37 const mtl::TextureRef &implicitMSTexture, 38 const mtl::MipmapNativeLevel &level, 39 uint32_t layer, 40 const mtl::Format &format); 41 void setTexture(const mtl::TextureRef &texture); 42 void setImplicitMSTexture(const mtl::TextureRef &implicitMSTexture); 43 void duplicateFrom(const RenderTargetMtl &src); 44 void reset(); 45 getTexture()46 mtl::TextureRef getTexture() const { return mTexture.lock(); } getImplicitMSTexture()47 mtl::TextureRef getImplicitMSTexture() const { return mImplicitMSTexture.lock(); } getLevelIndex()48 const mtl::MipmapNativeLevel &getLevelIndex() const { return mLevelIndex; } getLayerIndex()49 uint32_t getLayerIndex() const { return mLayerIndex; } 50 uint32_t getRenderSamples() const; getFormat()51 const mtl::Format &getFormat() const { return mFormat; } 52 53 void toRenderPassAttachmentDesc(mtl::RenderPassAttachmentDesc *rpaDescOut) const; 54 55 private: 56 mtl::TextureWeakRef mTexture; 57 mtl::TextureWeakRef mImplicitMSTexture; 58 mtl::MipmapNativeLevel mLevelIndex = mtl::kZeroNativeMipLevel; 59 uint32_t mLayerIndex = 0; 60 mtl::Format mFormat; 61 }; 62 } // namespace rx 63 64 #endif /* LIBANGLE_RENDERER_METAL_RENDERTARGETMTL_H */ 65