• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 setTexture(const wgpu::TextureView &texture);
37     void reset();
38 
getTexture()39     wgpu::TextureView getTexture() { return mTexture; }
getImage()40     webgpu::ImageHelper *getImage() { return mImage; }
getLevelIndex()41     webgpu::LevelIndex getLevelIndex() const { return mLevelIndex; }
42 
43   private:
44     webgpu::ImageHelper *mImage;
45     // TODO(liza): move TextureView into ImageHelper.
46     wgpu::TextureView mTexture;
47     webgpu::LevelIndex mLevelIndex{0};
48     uint32_t mLayerIndex               = 0;
49     const wgpu::TextureFormat *mFormat = nullptr;
50 };
51 }  // namespace rx
52 
53 #endif  // LIBANGLE_RENDERER_WGPU_RENDERTARGETWGPU_H_
54