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