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