1 // 2 // Copyright 2024 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 // FramebufferWgpu.h: 7 // Defines the class interface for FramebufferWgpu, implementing FramebufferImpl. 8 // 9 10 #ifndef LIBANGLE_RENDERER_WGPU_FRAMEBUFFERWGPU_H_ 11 #define LIBANGLE_RENDERER_WGPU_FRAMEBUFFERWGPU_H_ 12 13 #include "libANGLE/renderer/FramebufferImpl.h" 14 #include "libANGLE/renderer/RenderTargetCache.h" 15 #include "libANGLE/renderer/wgpu/RenderTargetWgpu.h" 16 17 namespace rx 18 { 19 20 class FramebufferWgpu : public FramebufferImpl 21 { 22 public: 23 FramebufferWgpu(const gl::FramebufferState &state); 24 ~FramebufferWgpu() override; 25 26 angle::Result discard(const gl::Context *context, 27 size_t count, 28 const GLenum *attachments) override; 29 angle::Result invalidate(const gl::Context *context, 30 size_t count, 31 const GLenum *attachments) override; 32 angle::Result invalidateSub(const gl::Context *context, 33 size_t count, 34 const GLenum *attachments, 35 const gl::Rectangle &area) override; 36 37 angle::Result clear(const gl::Context *context, GLbitfield mask) override; 38 angle::Result clearBufferfv(const gl::Context *context, 39 GLenum buffer, 40 GLint drawbuffer, 41 const GLfloat *values) override; 42 angle::Result clearBufferuiv(const gl::Context *context, 43 GLenum buffer, 44 GLint drawbuffer, 45 const GLuint *values) override; 46 angle::Result clearBufferiv(const gl::Context *context, 47 GLenum buffer, 48 GLint drawbuffer, 49 const GLint *values) override; 50 angle::Result clearBufferfi(const gl::Context *context, 51 GLenum buffer, 52 GLint drawbuffer, 53 GLfloat depth, 54 GLint stencil) override; 55 56 angle::Result readPixels(const gl::Context *context, 57 const gl::Rectangle &area, 58 GLenum format, 59 GLenum type, 60 const gl::PixelPackState &pack, 61 gl::Buffer *packBuffer, 62 void *pixels) override; 63 64 angle::Result blit(const gl::Context *context, 65 const gl::Rectangle &sourceArea, 66 const gl::Rectangle &destArea, 67 GLbitfield mask, 68 GLenum filter) override; 69 70 gl::FramebufferStatus checkStatus(const gl::Context *context) const override; 71 72 angle::Result syncState(const gl::Context *context, 73 GLenum binding, 74 const gl::Framebuffer::DirtyBits &dirtyBits, 75 gl::Command command) override; 76 77 angle::Result getSamplePosition(const gl::Context *context, 78 size_t index, 79 GLfloat *xy) const override; 80 81 RenderTargetWgpu *getReadPixelsRenderTarget(const angle::Format &format) const; 82 83 void addNewColorAttachments(std::vector<wgpu::RenderPassColorAttachment> newColorAttachments); 84 85 angle::Result flushOneColorAttachmentUpdate(const gl::Context *context, 86 bool deferClears, 87 uint32_t colorIndexGL); 88 89 angle::Result flushColorAttachmentUpdates(const gl::Context *context, 90 gl::DrawBufferMask dirtyColorAttachments, 91 bool deferClears); 92 93 angle::Result flushDeferredClears(ContextWgpu *contextWgpu); 94 95 private: 96 RenderTargetCache<RenderTargetWgpu> mRenderTargetCache; 97 wgpu::RenderPassDescriptor mCurrentRenderPassDesc; 98 std::vector<wgpu::RenderPassColorAttachment> mCurrentColorAttachments; 99 // Secondary vector to track new clears that are added and should be run in a new render pass 100 // during flushColorAttachmentUpdates. 101 std::vector<wgpu::RenderPassColorAttachment> mNewColorAttachments; 102 103 webgpu::ClearValuesArray mDeferredClears; 104 }; 105 106 } // namespace rx 107 108 #endif // LIBANGLE_RENDERER_WGPU_FRAMEBUFFERWGPU_H_ 109