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