xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/wgpu/RenderTargetWgpu.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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 // RenderTargetWgpu.h:
7 //    Defines the class interface for RenderTargetWgpu.
8 //
9 
10 #ifndef LIBANGLE_RENDERER_WGPU_RENDERTARGETWGPU_H_
11 #define LIBANGLE_RENDERER_WGPU_RENDERTARGETWGPU_H_
12 
13 #include <dawn/webgpu_cpp.h>
14 #include <stdint.h>
15 
16 #include "libANGLE/FramebufferAttachment.h"
17 #include "libANGLE/renderer/wgpu/wgpu_helpers.h"
18 #include "libANGLE/renderer/wgpu/wgpu_utils.h"
19 
20 namespace rx
21 {
22 class RenderTargetWgpu final : public FramebufferAttachmentRenderTarget
23 {
24   public:
25     RenderTargetWgpu();
26     ~RenderTargetWgpu() override;
27 
28     // Used in std::vector initialization.
29     RenderTargetWgpu(RenderTargetWgpu &&other);
30 
31     void set(webgpu::ImageHelper *image,
32              const wgpu::TextureView &texture,
33              const webgpu::LevelIndex level,
34              uint32_t layer,
35              const wgpu::TextureFormat &format);
36     void reset();
37 
38     angle::Result flushImageStagedUpdates(ContextWgpu *contextWgpu,
39                                           webgpu::ClearValuesArray *deferredClears,
40                                           uint32_t deferredClearIndex);
41 
getTextureView()42     wgpu::TextureView getTextureView() { return mTextureView; }
getImage()43     webgpu::ImageHelper *getImage() { return mImage; }
getLevelIndex()44     webgpu::LevelIndex getLevelIndex() const { return mLevelIndex; }
45 
46   private:
47     webgpu::ImageHelper *mImage = nullptr;
48     // TODO(liza): move TextureView into ImageHelper.
49     wgpu::TextureView mTextureView;
50     webgpu::LevelIndex mLevelIndex{0};
51     uint32_t mLayerIndex               = 0;
52     const wgpu::TextureFormat *mFormat = nullptr;
53 };
54 }  // namespace rx
55 
56 #endif  // LIBANGLE_RENDERER_WGPU_RENDERTARGETWGPU_H_
57