1 // 2 // Copyright 2012 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 7 // RenderTarget11.h: Defines a DX11-specific wrapper for ID3D11View pointers 8 // retained by Renderbuffers. 9 10 #ifndef LIBANGLE_RENDERER_D3D_D3D11_RENDERTARGET11_H_ 11 #define LIBANGLE_RENDERER_D3D_D3D11_RENDERTARGET11_H_ 12 13 #include "libANGLE/renderer/d3d/RenderTargetD3D.h" 14 #include "libANGLE/renderer/d3d/d3d11/ResourceManager11.h" 15 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" 16 #include "libANGLE/renderer/d3d/d3d11/texture_format_table.h" 17 18 namespace rx 19 { 20 class SwapChain11; 21 class Renderer11; 22 23 class RenderTarget11 : public RenderTargetD3D 24 { 25 public: 26 RenderTarget11(const d3d11::Format &formatSet); 27 ~RenderTarget11() override; 28 29 virtual const TextureHelper11 &getTexture() const = 0; 30 virtual const d3d11::RenderTargetView &getRenderTargetView() const = 0; 31 virtual const d3d11::DepthStencilView &getDepthStencilView() const = 0; 32 virtual const d3d11::SharedSRV &getShaderResourceView(const gl::Context *context) const = 0; 33 virtual const d3d11::SharedSRV &getBlitShaderResourceView(const gl::Context *context) const = 0; 34 35 virtual unsigned int getSubresourceIndex() const = 0; 36 getFormatSet()37 const d3d11::Format &getFormatSet() const { return mFormatSet; } 38 39 protected: 40 const d3d11::Format &mFormatSet; 41 }; 42 43 class TextureRenderTarget11 : public RenderTarget11 44 { 45 public: 46 // TextureRenderTarget11 takes ownership of any D3D11 resources it is given and will AddRef them 47 TextureRenderTarget11(d3d11::RenderTargetView &&rtv, 48 const TextureHelper11 &resource, 49 const d3d11::SharedSRV &srv, 50 const d3d11::SharedSRV &blitSRV, 51 GLenum internalFormat, 52 const d3d11::Format &formatSet, 53 GLsizei width, 54 GLsizei height, 55 GLsizei depth, 56 GLsizei samples); 57 TextureRenderTarget11(d3d11::DepthStencilView &&dsv, 58 const TextureHelper11 &resource, 59 const d3d11::SharedSRV &srv, 60 GLenum internalFormat, 61 const d3d11::Format &formatSet, 62 GLsizei width, 63 GLsizei height, 64 GLsizei depth, 65 GLsizei samples); 66 ~TextureRenderTarget11() override; 67 68 GLsizei getWidth() const override; 69 GLsizei getHeight() const override; 70 GLsizei getDepth() const override; 71 GLenum getInternalFormat() const override; 72 GLsizei getSamples() const override; 73 74 const TextureHelper11 &getTexture() const override; 75 const d3d11::RenderTargetView &getRenderTargetView() const override; 76 const d3d11::DepthStencilView &getDepthStencilView() const override; 77 const d3d11::SharedSRV &getShaderResourceView(const gl::Context *context) const override; 78 const d3d11::SharedSRV &getBlitShaderResourceView(const gl::Context *context) const override; 79 80 unsigned int getSubresourceIndex() const override; 81 82 private: 83 GLsizei mWidth; 84 GLsizei mHeight; 85 GLsizei mDepth; 86 GLenum mInternalFormat; 87 GLsizei mSamples; 88 89 unsigned int mSubresourceIndex; 90 TextureHelper11 mTexture; 91 d3d11::RenderTargetView mRenderTarget; 92 d3d11::DepthStencilView mDepthStencil; 93 d3d11::SharedSRV mShaderResource; 94 95 // Shader resource view to use with internal blit shaders. Not set for depth/stencil render 96 // targets. 97 d3d11::SharedSRV mBlitShaderResource; 98 }; 99 100 class SurfaceRenderTarget11 : public RenderTarget11 101 { 102 public: 103 SurfaceRenderTarget11(SwapChain11 *swapChain, Renderer11 *renderer, bool depth); 104 ~SurfaceRenderTarget11() override; 105 106 GLsizei getWidth() const override; 107 GLsizei getHeight() const override; 108 GLsizei getDepth() const override; 109 GLenum getInternalFormat() const override; 110 GLsizei getSamples() const override; 111 112 const TextureHelper11 &getTexture() const override; 113 const d3d11::RenderTargetView &getRenderTargetView() const override; 114 const d3d11::DepthStencilView &getDepthStencilView() const override; 115 const d3d11::SharedSRV &getShaderResourceView(const gl::Context *context) const override; 116 const d3d11::SharedSRV &getBlitShaderResourceView(const gl::Context *context) const override; 117 118 unsigned int getSubresourceIndex() const override; 119 120 private: 121 SwapChain11 *mSwapChain; 122 bool mDepth; 123 }; 124 125 } // namespace rx 126 127 #endif // LIBANGLE_RENDERER_D3D_D3D11_RENDERTARGET11_H_ 128