1*8975f5c5SAndroid Build Coastguard Worker //
2*8975f5c5SAndroid Build Coastguard Worker // Copyright 2024 The ANGLE Project Authors. All rights reserved.
3*8975f5c5SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
4*8975f5c5SAndroid Build Coastguard Worker // found in the LICENSE file.
5*8975f5c5SAndroid Build Coastguard Worker //
6*8975f5c5SAndroid Build Coastguard Worker // RenderTargetWgpu.cpp:
7*8975f5c5SAndroid Build Coastguard Worker // Implements the class methods for RenderTargetWgpu.
8*8975f5c5SAndroid Build Coastguard Worker //
9*8975f5c5SAndroid Build Coastguard Worker
10*8975f5c5SAndroid Build Coastguard Worker #include "libANGLE/renderer/wgpu/RenderTargetWgpu.h"
11*8975f5c5SAndroid Build Coastguard Worker
12*8975f5c5SAndroid Build Coastguard Worker namespace rx
13*8975f5c5SAndroid Build Coastguard Worker {
RenderTargetWgpu()14*8975f5c5SAndroid Build Coastguard Worker RenderTargetWgpu::RenderTargetWgpu() {}
15*8975f5c5SAndroid Build Coastguard Worker
~RenderTargetWgpu()16*8975f5c5SAndroid Build Coastguard Worker RenderTargetWgpu::~RenderTargetWgpu()
17*8975f5c5SAndroid Build Coastguard Worker {
18*8975f5c5SAndroid Build Coastguard Worker reset();
19*8975f5c5SAndroid Build Coastguard Worker }
20*8975f5c5SAndroid Build Coastguard Worker
RenderTargetWgpu(RenderTargetWgpu && other)21*8975f5c5SAndroid Build Coastguard Worker RenderTargetWgpu::RenderTargetWgpu(RenderTargetWgpu &&other)
22*8975f5c5SAndroid Build Coastguard Worker : mImage(other.mImage),
23*8975f5c5SAndroid Build Coastguard Worker mTextureView(std::move(other.mTextureView)),
24*8975f5c5SAndroid Build Coastguard Worker mLevelIndex(other.mLevelIndex),
25*8975f5c5SAndroid Build Coastguard Worker mLayerIndex(other.mLayerIndex),
26*8975f5c5SAndroid Build Coastguard Worker mFormat(other.mFormat)
27*8975f5c5SAndroid Build Coastguard Worker {}
28*8975f5c5SAndroid Build Coastguard Worker
set(webgpu::ImageHelper * image,const wgpu::TextureView & texture,const webgpu::LevelIndex level,uint32_t layer,const wgpu::TextureFormat & format)29*8975f5c5SAndroid Build Coastguard Worker void RenderTargetWgpu::set(webgpu::ImageHelper *image,
30*8975f5c5SAndroid Build Coastguard Worker const wgpu::TextureView &texture,
31*8975f5c5SAndroid Build Coastguard Worker const webgpu::LevelIndex level,
32*8975f5c5SAndroid Build Coastguard Worker uint32_t layer,
33*8975f5c5SAndroid Build Coastguard Worker const wgpu::TextureFormat &format)
34*8975f5c5SAndroid Build Coastguard Worker {
35*8975f5c5SAndroid Build Coastguard Worker mImage = image;
36*8975f5c5SAndroid Build Coastguard Worker mTextureView = texture;
37*8975f5c5SAndroid Build Coastguard Worker mLevelIndex = level;
38*8975f5c5SAndroid Build Coastguard Worker mLayerIndex = layer;
39*8975f5c5SAndroid Build Coastguard Worker mFormat = &format;
40*8975f5c5SAndroid Build Coastguard Worker }
41*8975f5c5SAndroid Build Coastguard Worker
reset()42*8975f5c5SAndroid Build Coastguard Worker void RenderTargetWgpu::reset()
43*8975f5c5SAndroid Build Coastguard Worker {
44*8975f5c5SAndroid Build Coastguard Worker mTextureView = nullptr;
45*8975f5c5SAndroid Build Coastguard Worker mLevelIndex = webgpu::LevelIndex(0);
46*8975f5c5SAndroid Build Coastguard Worker mLayerIndex = 0;
47*8975f5c5SAndroid Build Coastguard Worker mFormat = nullptr;
48*8975f5c5SAndroid Build Coastguard Worker }
49*8975f5c5SAndroid Build Coastguard Worker
flushImageStagedUpdates(ContextWgpu * contextWgpu,webgpu::ClearValuesArray * deferredClears,uint32_t deferredClearIndex)50*8975f5c5SAndroid Build Coastguard Worker angle::Result RenderTargetWgpu::flushImageStagedUpdates(ContextWgpu *contextWgpu,
51*8975f5c5SAndroid Build Coastguard Worker webgpu::ClearValuesArray *deferredClears,
52*8975f5c5SAndroid Build Coastguard Worker uint32_t deferredClearIndex)
53*8975f5c5SAndroid Build Coastguard Worker {
54*8975f5c5SAndroid Build Coastguard Worker gl::LevelIndex targetLevel = mImage->toGlLevel(mLevelIndex);
55*8975f5c5SAndroid Build Coastguard Worker ANGLE_TRY(mImage->flushSingleLevelUpdates(contextWgpu, targetLevel, deferredClears,
56*8975f5c5SAndroid Build Coastguard Worker deferredClearIndex));
57*8975f5c5SAndroid Build Coastguard Worker return angle::Result::Continue;
58*8975f5c5SAndroid Build Coastguard Worker }
59*8975f5c5SAndroid Build Coastguard Worker } // namespace rx
60