#ifndef SRC_DAWN_UTILS_WGPUHELPERS_H_
#define SRC_DAWN_UTILS_WGPUHELPERS_H_
#include <webgpu/webgpu_cpp.h>
#include <array>
#include <initializer_list>
#include <string>
#include <vector>
#include "dawn/common/Constants.h"
#include "dawn/utils/TextureUtils.h"
namespace dawn::utils {
enum Expectation { … };
#if TINT_BUILD_SPV_READER
wgpu::ShaderModule CreateShaderModuleFromASM(
const wgpu::Device& device,
const char* source,
wgpu::DawnShaderModuleSPIRVOptionsDescriptor* spirv_options = nullptr);
#endif
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device, const char* source);
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device, const std::string& source);
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
const void* data,
uint64_t size,
wgpu::BufferUsage usage);
template <typename T>
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
wgpu::BufferUsage usage,
std::initializer_list<T> data) { … }
wgpu::ImageCopyBuffer CreateImageCopyBuffer(wgpu::Buffer buffer,
uint64_t offset = 0,
uint32_t bytesPerRow = wgpu::kCopyStrideUndefined,
uint32_t rowsPerImage = wgpu::kCopyStrideUndefined);
wgpu::ImageCopyTexture CreateImageCopyTexture(
wgpu::Texture texture,
uint32_t level = 0,
wgpu::Origin3D origin = { … };
wgpu::TextureDataLayout CreateTextureDataLayout(uint64_t offset,
uint32_t bytesPerRow,
uint32_t rowsPerImage = wgpu::kCopyStrideUndefined);
struct ComboRenderPassDescriptor : public wgpu::RenderPassDescriptor { … };
struct BasicRenderPass { … };
BasicRenderPass CreateBasicRenderPass(
const wgpu::Device& device,
uint32_t width,
uint32_t height,
wgpu::TextureFormat format = BasicRenderPass::kDefaultColorFormat);
wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device,
const wgpu::BindGroupLayout* bindGroupLayout);
wgpu::PipelineLayout MakePipelineLayout(const wgpu::Device& device,
std::vector<wgpu::BindGroupLayout> bgls);
#ifndef __EMSCRIPTEN__
extern wgpu::ExternalTextureBindingLayout kExternalTextureBindingLayout;
#endif
struct BindingLayoutEntryInitializationHelper : wgpu::BindGroupLayoutEntry { … };
wgpu::BindGroupLayout MakeBindGroupLayout(
const wgpu::Device& device,
std::initializer_list<BindingLayoutEntryInitializationHelper> entriesInitializer);
struct BindingInitializationHelper { … };
wgpu::BindGroup MakeBindGroup(
const wgpu::Device& device,
const wgpu::BindGroupLayout& layout,
std::initializer_list<BindingInitializationHelper> entriesInitializer);
struct ColorSpaceConversionInfo { … };
ColorSpaceConversionInfo GetYUVBT709ToRGBSRGBColorSpaceConversionInfo();
ColorSpaceConversionInfo GetNoopRGBColorSpaceConversionInfo();
bool BackendRequiresCompat(wgpu::BackendType backend);
}
#endif