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::ObserverInterface 21 { 22 public: 23 Framebuffer11(const gl::FramebufferState &data, Renderer11 *renderer); 24 ~Framebuffer11() override; 25 26 gl::Error discard(const gl::Context *context, size_t count, const GLenum *attachments) override; 27 gl::Error invalidate(const gl::Context *context, 28 size_t count, 29 const GLenum *attachments) override; 30 gl::Error invalidateSub(const gl::Context *context, 31 size_t count, 32 const GLenum *attachments, 33 const gl::Rectangle &area) override; 34 35 // Invalidate the cached swizzles of all bound texture attachments. 36 gl::Error markAttachmentsDirty(const gl::Context *context) const; 37 38 void syncState(const gl::Context *context, 39 const gl::Framebuffer::DirtyBits &dirtyBits) override; 40 getCachedColorRenderTargets()41 const RenderTargetArray &getCachedColorRenderTargets() const 42 { 43 return mCachedColorRenderTargets; 44 } getCachedDepthStencilRenderTarget()45 const RenderTarget11 *getCachedDepthStencilRenderTarget() const 46 { 47 return mCachedDepthStencilRenderTarget; 48 } 49 50 RenderTarget11 *getFirstRenderTarget() const; 51 52 bool hasAnyInternalDirtyBit() const; 53 void syncInternalState(const gl::Context *context); 54 55 // Observer implementation. 56 void onSubjectStateChange(const gl::Context *context, 57 angle::SubjectIndex index, 58 angle::SubjectMessage message) override; 59 60 gl::Error getSamplePosition(size_t index, GLfloat *xy) const override; 61 62 private: 63 gl::Error clearImpl(const gl::Context *context, const ClearParameters &clearParams) override; 64 65 gl::Error readPixelsImpl(const gl::Context *context, 66 const gl::Rectangle &area, 67 GLenum format, 68 GLenum type, 69 size_t outputPitch, 70 const gl::PixelPackState &pack, 71 uint8_t *pixels) override; 72 73 gl::Error blitImpl(const gl::Context *context, 74 const gl::Rectangle &sourceArea, 75 const gl::Rectangle &destArea, 76 const gl::Rectangle *scissor, 77 bool blitRenderTarget, 78 bool blitDepth, 79 bool blitStencil, 80 GLenum filter, 81 const gl::Framebuffer *sourceFramebuffer) override; 82 83 gl::Error invalidateBase(const gl::Context *context, 84 size_t count, 85 const GLenum *attachments, 86 bool useEXTBehavior) const; 87 gl::Error invalidateAttachment(const gl::Context *context, 88 const gl::FramebufferAttachment *attachment) const; 89 90 GLenum getRenderTargetImplementationFormat(RenderTargetD3D *renderTarget) const override; 91 92 void updateColorRenderTarget(const gl::Context *context, size_t colorIndex); 93 void updateDepthStencilRenderTarget(const gl::Context *context); 94 95 Renderer11 *const mRenderer; 96 RenderTargetArray mCachedColorRenderTargets; 97 RenderTarget11 *mCachedDepthStencilRenderTarget; 98 99 std::vector<angle::ObserverBinding> mColorRenderTargetsDirty; 100 angle::ObserverBinding mDepthStencilRenderTargetDirty; 101 102 gl::Framebuffer::DirtyBits mInternalDirtyBits; 103 }; 104 105 } 106 107 #endif // LIBANGLE_RENDERER_D3D_D3D11_FRAMBUFFER11_H_ 108