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 GLenum getImplementationColorReadFormat(const gl::Context *context) const = 0;
67 virtual GLenum getImplementationColorReadType(const gl::Context *context) const = 0;
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 const gl::Framebuffer::DirtyBits &dirtyBits) = 0;
84
85 virtual angle::Result getSamplePosition(const gl::Context *context,
86 size_t index,
87 GLfloat *xy) const = 0;
88
89 // Special configuration option for checkStatus(). Some back-ends don't require a syncState
90 // before calling checkStatus. In practice the GL back-end is the only config that needs
91 // syncState because it depends on the behaviour of the driver. Allowing the Vulkan and
92 // D3D back-ends to skip syncState lets us do more work in the syncState call.
93 virtual bool shouldSyncStateBeforeCheckStatus() const;
94
getState()95 const gl::FramebufferState &getState() const { return mState; }
96
97 protected:
98 const gl::FramebufferState &mState;
99 };
100
shouldSyncStateBeforeCheckStatus()101 inline bool FramebufferImpl::shouldSyncStateBeforeCheckStatus() const
102 {
103 return false;
104 }
105
106 } // namespace rx
107
108 #endif // LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_
109