1 //
2 // Copyright 2014 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 // Framebuffer11.h: Defines the Framebuffer11 class.
8 
9 #ifndef LIBANGLE_RENDERER_D3D_D3D11_FRAMBUFFER11_H_
10 #define LIBANGLE_RENDERER_D3D_D3D11_FRAMBUFFER11_H_
11 
12 #include "libANGLE/renderer/d3d/FramebufferD3D.h"
13 #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
14 #include "libANGLE/signal_utils.h"
15 
16 namespace rx
17 {
18 class Renderer11;
19 
20 class Framebuffer11 : public FramebufferD3D, public angle::SignalReceiver
21 {
22   public:
23     Framebuffer11(const gl::FramebufferState &data, Renderer11 *renderer);
24     virtual ~Framebuffer11();
25 
26     gl::Error discard(size_t count, const GLenum *attachments) override;
27     gl::Error invalidate(size_t count, const GLenum *attachments) override;
28     gl::Error invalidateSub(size_t count, const GLenum *attachments, const gl::Rectangle &area) override;
29 
30     // Invalidate the cached swizzles of all bound texture attachments.
31     gl::Error markAttachmentsDirty() const;
32 
33     void syncState(const gl::Framebuffer::DirtyBits &dirtyBits) override;
34 
getCachedColorRenderTargets()35     const RenderTargetArray &getCachedColorRenderTargets() const
36     {
37         return mCachedColorRenderTargets;
38     }
getCachedDepthStencilRenderTarget()39     const RenderTarget11 *getCachedDepthStencilRenderTarget() const
40     {
41         return mCachedDepthStencilRenderTarget;
42     }
43 
44     bool hasAnyInternalDirtyBit() const;
45     void syncInternalState();
46 
47     void signal(angle::SignalToken token) override;
48 
49   private:
50     gl::Error clearImpl(ContextImpl *context, const ClearParameters &clearParams) override;
51 
52     gl::Error readPixelsImpl(const gl::Rectangle &area,
53                              GLenum format,
54                              GLenum type,
55                              size_t outputPitch,
56                              const gl::PixelPackState &pack,
57                              uint8_t *pixels) const override;
58 
59     gl::Error blitImpl(const gl::Rectangle &sourceArea,
60                        const gl::Rectangle &destArea,
61                        const gl::Rectangle *scissor,
62                        bool blitRenderTarget,
63                        bool blitDepth,
64                        bool blitStencil,
65                        GLenum filter,
66                        const gl::Framebuffer *sourceFramebuffer) override;
67 
68     gl::Error invalidateBase(size_t count, const GLenum *attachments, bool useEXTBehavior) const;
69     gl::Error invalidateAttachment(const gl::FramebufferAttachment *attachment) const;
70 
71     GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const override;
72 
73     void updateColorRenderTarget(size_t colorIndex);
74     void updateDepthStencilRenderTarget();
75 
76     Renderer11 *const mRenderer;
77     RenderTargetArray mCachedColorRenderTargets;
78     RenderTarget11 *mCachedDepthStencilRenderTarget;
79 
80     std::vector<angle::ChannelBinding> mColorRenderTargetsDirty;
81     angle::ChannelBinding mDepthStencilRenderTargetDirty;
82 
83     gl::Framebuffer::DirtyBits mInternalDirtyBits;
84 };
85 
86 }
87 
88 #endif // LIBANGLE_RENDERER_D3D_D3D11_FRAMBUFFER11_H_
89