• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // FramebufferD3D.h: Defines the DefaultAttachmentD3D and FramebufferD3D classes.
8 
9 #ifndef LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_
10 #define LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_
11 
12 #include <cstdint>
13 #include <vector>
14 
15 #include "common/Color.h"
16 #include "common/Optional.h"
17 #include "libANGLE/angletypes.h"
18 #include "libANGLE/renderer/FramebufferImpl.h"
19 
20 namespace gl
21 {
22 class FramebufferAttachment;
23 struct PixelPackState;
24 
25 typedef std::vector<const FramebufferAttachment *> AttachmentList;
26 }  // namespace gl
27 
28 namespace rx
29 {
30 class RendererD3D;
31 class RenderTargetD3D;
32 
33 struct ClearParameters
34 {
35     ClearParameters();
36     ClearParameters(const ClearParameters &other);
37 
38     gl::DrawBufferMask clearColor;
39     gl::ColorF colorF;
40     gl::ColorI colorI;
41     gl::ColorUI colorUI;
42     GLenum colorType;
43     gl::BlendStateExt::ColorMaskStorage::Type colorMask;
44 
45     bool clearDepth;
46     float depthValue;
47 
48     bool clearStencil;
49     GLint stencilValue;
50     GLuint stencilWriteMask;
51 
52     bool scissorEnabled;
53     gl::Rectangle scissor;
54 };
55 
56 class FramebufferD3D : public FramebufferImpl
57 {
58   public:
59     FramebufferD3D(const gl::FramebufferState &data, RendererD3D *renderer);
60     ~FramebufferD3D() override;
61 
62     angle::Result clear(const gl::Context *context, GLbitfield mask) override;
63     angle::Result clearBufferfv(const gl::Context *context,
64                                 GLenum buffer,
65                                 GLint drawbuffer,
66                                 const GLfloat *values) override;
67     angle::Result clearBufferuiv(const gl::Context *context,
68                                  GLenum buffer,
69                                  GLint drawbuffer,
70                                  const GLuint *values) override;
71     angle::Result clearBufferiv(const gl::Context *context,
72                                 GLenum buffer,
73                                 GLint drawbuffer,
74                                 const GLint *values) override;
75     angle::Result clearBufferfi(const gl::Context *context,
76                                 GLenum buffer,
77                                 GLint drawbuffer,
78                                 GLfloat depth,
79                                 GLint stencil) override;
80 
81     angle::Result readPixels(const gl::Context *context,
82                              const gl::Rectangle &area,
83                              GLenum format,
84                              GLenum type,
85                              void *pixels) override;
86 
87     angle::Result blit(const gl::Context *context,
88                        const gl::Rectangle &sourceArea,
89                        const gl::Rectangle &destArea,
90                        GLbitfield mask,
91                        GLenum filter) override;
92 
93     bool checkStatus(const gl::Context *context) const override;
94 
95     angle::Result syncState(const gl::Context *context,
96                             GLenum binding,
97                             const gl::Framebuffer::DirtyBits &dirtyBits) override;
98 
99     const gl::AttachmentList &getColorAttachmentsForRender(const gl::Context *context);
100 
getLastColorAttachmentsForRenderMask()101     const gl::DrawBufferMask getLastColorAttachmentsForRenderMask() const
102     {
103         return mColorAttachmentsForRenderMask;
104     }
105 
106     void destroy(const gl::Context *context) override;
107 
108   private:
109     virtual angle::Result clearImpl(const gl::Context *context,
110                                     const ClearParameters &clearParams) = 0;
111 
112     virtual angle::Result readPixelsImpl(const gl::Context *context,
113                                          const gl::Rectangle &area,
114                                          GLenum format,
115                                          GLenum type,
116                                          size_t outputPitch,
117                                          const gl::PixelPackState &pack,
118                                          uint8_t *pixels) = 0;
119 
120     virtual angle::Result blitImpl(const gl::Context *context,
121                                    const gl::Rectangle &sourceArea,
122                                    const gl::Rectangle &destArea,
123                                    const gl::Rectangle *scissor,
124                                    bool blitRenderTarget,
125                                    bool blitDepth,
126                                    bool blitStencil,
127                                    GLenum filter,
128                                    const gl::Framebuffer *sourceFramebuffer) = 0;
129 
130     RendererD3D *mRenderer;
131     Optional<gl::AttachmentList> mColorAttachmentsForRender;
132     gl::DrawBufferMask mCurrentActiveProgramOutputs;
133     gl::DrawBufferMask mColorAttachmentsForRenderMask;
134 
135     gl::FramebufferAttachment mDummyAttachment;
136 };
137 }  // namespace rx
138 
139 #endif  // LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_
140