FramebufferImpl.h (5197B)
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 // FramebufferImpl.h: Defines the abstract rx::FramebufferImpl class. 8 9 #ifndef LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_ 10 #define LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_ 11 12 #include "angle_gl.h" 13 #include "common/angleutils.h" 14 #include "libANGLE/Error.h" 15 #include "libANGLE/Framebuffer.h" 16 #include "libANGLE/State.h" 17 #include "libANGLE/angletypes.h" 18 19 namespace gl 20 { 21 class Buffer; 22 class Framebuffer; 23 class FramebufferAttachment; 24 struct PixelPackState; 25 } // namespace gl 26 27 namespace rx 28 { 29 class DisplayImpl; 30 31 class FramebufferImpl : angle::NonCopyable 32 { 33 public: 34 explicit FramebufferImpl(const gl::FramebufferState &state) : mState(state) {} 35 virtual ~FramebufferImpl() {} 36 virtual void destroy(const gl::Context *context) {} 37 38 virtual angle::Result discard(const gl::Context *context, 39 size_t count, 40 const GLenum *attachments) = 0; 41 virtual angle::Result invalidate(const gl::Context *context, 42 size_t count, 43 const GLenum *attachments) = 0; 44 virtual angle::Result invalidateSub(const gl::Context *context, 45 size_t count, 46 const GLenum *attachments, 47 const gl::Rectangle &area) = 0; 48 49 virtual angle::Result clear(const gl::Context *context, GLbitfield mask) = 0; 50 virtual angle::Result clearBufferfv(const gl::Context *context, 51 GLenum buffer, 52 GLint drawbuffer, 53 const GLfloat *values) = 0; 54 virtual angle::Result clearBufferuiv(const gl::Context *context, 55 GLenum buffer, 56 GLint drawbuffer, 57 const GLuint *values) = 0; 58 virtual angle::Result clearBufferiv(const gl::Context *context, 59 GLenum buffer, 60 GLint drawbuffer, 61 const GLint *values) = 0; 62 virtual angle::Result clearBufferfi(const gl::Context *context, 63 GLenum buffer, 64 GLint drawbuffer, 65 GLfloat depth, 66 GLint stencil) = 0; 67 68 virtual const gl::InternalFormat &getImplementationColorReadFormat( 69 const gl::Context *context) const; 70 virtual angle::Result readPixels(const gl::Context *context, 71 const gl::Rectangle &area, 72 GLenum format, 73 GLenum type, 74 const gl::PixelPackState &pack, 75 gl::Buffer *packBuffer, 76 void *pixels) = 0; 77 78 virtual angle::Result blit(const gl::Context *context, 79 const gl::Rectangle &sourceArea, 80 const gl::Rectangle &destArea, 81 GLbitfield mask, 82 GLenum filter) = 0; 83 84 virtual gl::FramebufferStatus checkStatus(const gl::Context *context) const = 0; 85 86 virtual angle::Result syncState(const gl::Context *context, 87 GLenum binding, 88 const gl::Framebuffer::DirtyBits &dirtyBits, 89 gl::Command command) = 0; 90 91 virtual angle::Result getSamplePosition(const gl::Context *context, 92 size_t index, 93 GLfloat *xy) const = 0; 94 95 // Special configuration option for checkStatus(). Some back-ends don't require a syncState 96 // before calling checkStatus. In practice the GL back-end is the only config that needs 97 // syncState because it depends on the behaviour of the driver. Allowing the Vulkan and 98 // D3D back-ends to skip syncState lets us do more work in the syncState call. 99 virtual bool shouldSyncStateBeforeCheckStatus() const; 100 101 virtual angle::Result onLabelUpdate(const gl::Context *context); 102 103 const gl::FramebufferState &getState() const { return mState; } 104 105 protected: 106 const gl::FramebufferState &mState; 107 }; 108 109 inline bool FramebufferImpl::shouldSyncStateBeforeCheckStatus() const 110 { 111 return false; 112 } 113 114 // Default implementation returns the format specified in the attachment. 115 inline const gl::InternalFormat &FramebufferImpl::getImplementationColorReadFormat( 116 const gl::Context *context) const 117 { 118 const gl::FramebufferAttachment *readAttachment = mState.getReadAttachment(); 119 return *readAttachment->getFormat().info; 120 } 121 } // namespace rx 122 123 #endif // LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_