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, size_t level, size_t layer, const mtl::Format &format); 36 void set(const mtl::TextureRef &texture); 37 void reset(); 38 getTexture()39 const mtl::TextureRef &getTexture() const { return mTexture; } getLevelIndex()40 size_t getLevelIndex() const { return mLevelIndex; } getLayerIndex()41 size_t getLayerIndex() const { return mLayerIndex; } getFormat()42 const mtl::Format *getFormat() const { return mFormat; } 43 44 void toRenderPassAttachmentDesc(mtl::RenderPassAttachmentDesc *rpaDescOut) const; 45 46 private: 47 mtl::TextureRef mTexture; 48 size_t mLevelIndex = 0; 49 size_t mLayerIndex = 0; 50 const mtl::Format *mFormat = nullptr; 51 }; 52 } // namespace rx 53 54 #endif /* LIBANGLE_RENDERER_METAL_RENDERTARGETMTL_H */ 55