Hash :
6eaaad7c
Author :
Date :
2024-02-27T21:24:59
Create ImageHelper. This CL adds a helper class ImageHelper, which acts as a wrapper on webgpu textures that will be used by TextureWgpu. Bug: angleproject:8547 Change-Id: Ia796534c9d3ff0dd24797cc483677cfcbedb1f8c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5317864 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Liza Burakova <liza@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
//
// Copyright 2024 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#ifndef LIBANGLE_RENDERER_WGPU_WGPU_HELPERS_H_
#define LIBANGLE_RENDERER_WGPU_WGPU_HELPERS_H_
#include <dawn/webgpu_cpp.h>
#include <stdint.h>
#include "libANGLE/Error.h"
#include "libANGLE/angletypes.h"
namespace webgpu
{
// WebGPU image level index.
using LevelIndex = gl::LevelIndexWrapper<uint32_t>;
struct QueuedDataUpload
{
wgpu::ImageCopyBuffer copyBuffer;
gl::LevelIndex targetLevel;
};
class ImageHelper
{
public:
ImageHelper();
~ImageHelper();
angle::Result initImage(wgpu::TextureUsage usage,
wgpu::TextureDimension dimension,
wgpu::Extent3D size,
wgpu::TextureFormat format,
std::uint32_t mipLevelCount,
std::uint32_t sampleCount,
std::size_t ViewFormatCount);
void flushStagedUpdates(wgpu::Device device);
LevelIndex toWgpuLevel(gl::LevelIndex levelIndexGl) const;
gl::LevelIndex toGlLevel(LevelIndex levelIndexWgpu) const;
private:
wgpu::Texture mTexture;
wgpu::TextureUsage mUsage;
wgpu::TextureDimension mDimension;
wgpu::Extent3D mSize;
wgpu::TextureFormat mFormat;
std::uint32_t mMipLevelCount;
std::uint32_t mSampleCount;
std::size_t mViewFormatCount;
gl::LevelIndex mFirstAllocatedLevel;
std::vector<QueuedDataUpload> mBufferQueue;
};
} // namespace webgpu
namespace wgpu_gl
{
gl::LevelIndex getLevelIndex(webgpu::LevelIndex levelWgpu, gl::LevelIndex baseLevel);
} // namespace wgpu_gl
namespace gl_wgpu
{
webgpu::LevelIndex getLevelIndex(gl::LevelIndex levelGl, gl::LevelIndex baseLevel);
} // namespace gl_wgpu
#endif // LIBANGLE_RENDERER_WGPU_WGPU_HELPERS_H_