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.cpp:
7 // Implements the class methods for RenderTargetWgpu.
8 //
9
10 #include "libANGLE/renderer/wgpu/RenderTargetWgpu.h"
11
12 namespace rx
13 {
RenderTargetWgpu()14 RenderTargetWgpu::RenderTargetWgpu() {}
15
~RenderTargetWgpu()16 RenderTargetWgpu::~RenderTargetWgpu()
17 {
18 reset();
19 }
20
RenderTargetWgpu(RenderTargetWgpu && other)21 RenderTargetWgpu::RenderTargetWgpu(RenderTargetWgpu &&other)
22 : mImage(other.mImage),
23 mTextureView(std::move(other.mTextureView)),
24 mLevelIndex(other.mLevelIndex),
25 mLayerIndex(other.mLayerIndex),
26 mFormat(other.mFormat)
27 {}
28
set(webgpu::ImageHelper * image,const wgpu::TextureView & texture,const webgpu::LevelIndex level,uint32_t layer,const wgpu::TextureFormat & format)29 void RenderTargetWgpu::set(webgpu::ImageHelper *image,
30 const wgpu::TextureView &texture,
31 const webgpu::LevelIndex level,
32 uint32_t layer,
33 const wgpu::TextureFormat &format)
34 {
35 mImage = image;
36 mTextureView = texture;
37 mLevelIndex = level;
38 mLayerIndex = layer;
39 mFormat = &format;
40 }
41
reset()42 void RenderTargetWgpu::reset()
43 {
44 mTextureView = nullptr;
45 mLevelIndex = webgpu::LevelIndex(0);
46 mLayerIndex = 0;
47 mFormat = nullptr;
48 }
49
flushImageStagedUpdates(ContextWgpu * contextWgpu,webgpu::ClearValuesArray * deferredClears,uint32_t deferredClearIndex)50 angle::Result RenderTargetWgpu::flushImageStagedUpdates(ContextWgpu *contextWgpu,
51 webgpu::ClearValuesArray *deferredClears,
52 uint32_t deferredClearIndex)
53 {
54 gl::LevelIndex targetLevel = mImage->toGlLevel(mLevelIndex);
55 ANGLE_TRY(mImage->flushSingleLevelUpdates(contextWgpu, targetLevel, deferredClears,
56 deferredClearIndex));
57 return angle::Result::Continue;
58 }
59 } // namespace rx
60