Make examples and utils use webgpu.h

BUG=dawn:22

Change-Id: I602d6a3422b493d199f3fded61ff1666bc2d9d7d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12702
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2019-10-25 11:36:47 +00:00
committed by Commit Bot service account
parent 9f90c8d3ca
commit 04863c42be
80 changed files with 451 additions and 454 deletions

View File

@@ -22,9 +22,9 @@
#include "dawn_native/DawnNative.h"
#include "dawn_wire/WireClient.h"
#include "dawn_wire/WireServer.h"
#include "utils/DawnHelpers.h"
#include "utils/SystemUtils.h"
#include "utils/TerribleCommandBuffer.h"
#include "utils/WGPUHelpers.h"
#include <algorithm>
#include <iomanip>

View File

@@ -14,7 +14,7 @@
#include "tests/DawnTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class BasicTests : public DawnTest {
};

View File

@@ -17,7 +17,7 @@
#include "common/Math.h"
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr static unsigned int kRTSize = 8;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ClipSpaceTest : public DawnTest {
protected:

View File

@@ -20,7 +20,7 @@
#include "common/Assert.h"
#include "common/Constants.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr static unsigned int kRTSize = 64;

View File

@@ -18,7 +18,7 @@
#include "common/Constants.h"
#include "common/Math.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
// The helper struct to configure the copies between buffers and textures.
struct CopyConfig {

View File

@@ -14,7 +14,7 @@
#include "tests/DawnTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <array>

View File

@@ -15,7 +15,7 @@
#include "dawn/dawncpp.h"
#include "tests/DawnTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <array>
#include <initializer_list>

View File

@@ -14,7 +14,7 @@
#include "tests/DawnTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <array>

View File

@@ -14,7 +14,7 @@
#include "tests/DawnTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ComputeStorageBufferBarrierTests : public DawnTest {
protected:

View File

@@ -17,7 +17,7 @@
#include <array>
#include "common/Constants.h"
#include "common/Math.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class CopyTests : public DawnTest {
protected:

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class CullingTest : public DawnTest {
protected:

View File

@@ -21,7 +21,7 @@
#include "dawn_native/D3D12Backend.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
using Microsoft::WRL::ComPtr;

View File

@@ -14,7 +14,7 @@
#include "tests/DawnTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class DebugMarkerTests : public DawnTest {};

View File

@@ -16,7 +16,7 @@
#include "common/Assert.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr static unsigned int kRTSize = 64;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 4;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 4;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 4;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 4;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 4;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 400;
constexpr uint32_t kBufferElementsCount = kMinDynamicBufferOffsetAlignment / sizeof(uint32_t) + 2;

View File

@@ -16,7 +16,7 @@
#include "dawn_native/MetalBackend.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <CoreFoundation/CoreFoundation.h>
#include <IOSurface/IOSurface.h>

View File

@@ -16,7 +16,7 @@
#include "common/Assert.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 400;

View File

@@ -16,7 +16,7 @@
#include "common/Assert.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class MultisampledRenderingTest : public DawnTest {
protected:

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class NonzeroTextureCreationTests : public DawnTest {
protected:

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ObjectCachingTest : public DawnTest {};

View File

@@ -16,7 +16,7 @@
#include "common/Assert.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class OpArrayLengthTest : public DawnTest {
protected:

View File

@@ -16,7 +16,7 @@
#include "common/Assert.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
// Primitive topology tests work by drawing the following vertices with all the different primitive topology states:
// -------------------------------------

View File

@@ -16,7 +16,7 @@
#include "utils/ComboRenderBundleEncoderDescriptor.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 4;
constexpr RGBA8 kColors[2] = {RGBA8(0, 255, 0, 255), RGBA8(0, 0, 255, 255)};

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <array>

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr uint32_t kRTSize = 16;
constexpr dawn::TextureFormat kFormat = dawn::TextureFormat::RGBA8Unorm;

View File

@@ -19,7 +19,7 @@
#include "common/Assert.h"
#include "common/Constants.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
constexpr static unsigned int kRTSize = 64;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ScissorTest: public DawnTest {
protected:

View File

@@ -17,7 +17,7 @@
#include "common/Assert.h"
#include "common/Math.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <type_traits>

View File

@@ -18,7 +18,7 @@
#include "common/Constants.h"
#include "common/Math.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <array>

View File

@@ -16,7 +16,7 @@
#include "common/Math.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class TextureZeroInitTest : public DawnTest {
protected:

View File

@@ -17,7 +17,7 @@
#include "common/Assert.h"
#include "common/Math.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
// Vertex format tests all work the same way: the test will render a triangle.
// Each test will set up a vertex buffer, and the vertex shader will check that

View File

@@ -16,7 +16,7 @@
#include "common/Assert.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
using dawn::InputStepMode;
using dawn::VertexFormat;

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ViewportOrientationTests : public DawnTest {};

View File

@@ -15,7 +15,7 @@
#include "tests/DawnTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ViewportTest : public DawnTest {
protected:

View File

@@ -15,7 +15,7 @@
#include "tests/perf_tests/DawnPerfTest.h"
#include "tests/ParamGenerator.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace {

View File

@@ -17,7 +17,7 @@
#include "common/Assert.h"
#include "common/Constants.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class BindGroupValidationTest : public ValidationTest {
public:

View File

@@ -14,7 +14,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class CommandBufferValidationTest : public ValidationTest {
};

View File

@@ -15,7 +15,7 @@
#include <initializer_list>
#include <limits>
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ComputeIndirectValidationTest : public ValidationTest {
protected:

View File

@@ -14,7 +14,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class ComputePassValidationTest : public ValidationTest {};

View File

@@ -16,7 +16,7 @@
#include "common/Constants.h"
#include "common/Math.h"
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class CopyCommandTest : public ValidationTest {
protected:

View File

@@ -14,7 +14,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class DebugMarkerValidationTest : public ValidationTest {};

View File

@@ -16,7 +16,7 @@
#include <limits>
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class DrawIndirectValidationTest : public ValidationTest {
protected:

View File

@@ -14,7 +14,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace {

View File

@@ -18,7 +18,7 @@
#include "utils/ComboRenderBundleEncoderDescriptor.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace {

View File

@@ -16,7 +16,7 @@
#include "common/Constants.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace {

View File

@@ -17,7 +17,7 @@
#include "common/Constants.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace {

View File

@@ -16,7 +16,7 @@
#include "common/Constants.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <sstream>

View File

@@ -14,7 +14,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <cmath>

View File

@@ -16,7 +16,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include <sstream>

View File

@@ -16,7 +16,7 @@
#include "common/Constants.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace {

View File

@@ -17,7 +17,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class VertexBufferValidationTest : public ValidationTest {
protected:

View File

@@ -15,7 +15,7 @@
#include "tests/unittests/validation/ValidationTest.h"
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
class VertexInputTest : public ValidationTest {
protected:

View File

@@ -22,8 +22,8 @@
#include "dawn_native/vulkan/FencedDeleter.h"
#include "dawn_native/vulkan/ResourceMemoryAllocatorVk.h"
#include "dawn_native/vulkan/TextureVk.h"
#include "utils/DawnHelpers.h"
#include "utils/SystemUtils.h"
#include "utils/WGPUHelpers.h"
// TODO(crbug.com/966500): Intel is disabled until upgrade is finished

View File

@@ -25,22 +25,22 @@
namespace utils {
#if defined(DAWN_ENABLE_BACKEND_D3D12)
BackendBinding* CreateD3D12Binding(GLFWwindow* window, DawnDevice device);
BackendBinding* CreateD3D12Binding(GLFWwindow* window, WGPUDevice device);
#endif
#if defined(DAWN_ENABLE_BACKEND_METAL)
BackendBinding* CreateMetalBinding(GLFWwindow* window, DawnDevice device);
BackendBinding* CreateMetalBinding(GLFWwindow* window, WGPUDevice device);
#endif
#if defined(DAWN_ENABLE_BACKEND_NULL)
BackendBinding* CreateNullBinding(GLFWwindow* window, DawnDevice device);
BackendBinding* CreateNullBinding(GLFWwindow* window, WGPUDevice device);
#endif
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, DawnDevice device);
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, WGPUDevice device);
#endif
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
BackendBinding* CreateVulkanBinding(GLFWwindow* window, DawnDevice device);
BackendBinding* CreateVulkanBinding(GLFWwindow* window, WGPUDevice device);
#endif
BackendBinding::BackendBinding(GLFWwindow* window, DawnDevice device)
BackendBinding::BackendBinding(GLFWwindow* window, WGPUDevice device)
: mWindow(window), mDevice(device) {
}
@@ -75,7 +75,7 @@ namespace utils {
BackendBinding* CreateBinding(dawn_native::BackendType type,
GLFWwindow* window,
DawnDevice device) {
WGPUDevice device) {
switch (type) {
#if defined(DAWN_ENABLE_BACKEND_D3D12)
case dawn_native::BackendType::D3D12:

View File

@@ -15,7 +15,7 @@
#ifndef UTILS_BACKENDBINDING_H_
#define UTILS_BACKENDBINDING_H_
#include "dawn/dawn.h"
#include "dawn/webgpu.h"
#include "dawn_native/DawnNative.h"
struct GLFWwindow;
@@ -27,13 +27,13 @@ namespace utils {
virtual ~BackendBinding() = default;
virtual uint64_t GetSwapChainImplementation() = 0;
virtual DawnTextureFormat GetPreferredSwapChainTextureFormat() = 0;
virtual WGPUTextureFormat GetPreferredSwapChainTextureFormat() = 0;
protected:
BackendBinding(GLFWwindow* window, DawnDevice device);
BackendBinding(GLFWwindow* window, WGPUDevice device);
GLFWwindow* mWindow = nullptr;
DawnDevice mDevice = nullptr;
WGPUDevice mDevice = nullptr;
};
void SetupGLFWWindowHintsForBackend(dawn_native::BackendType type);
@@ -42,7 +42,7 @@ namespace utils {
dawn_native::BackendType type);
BackendBinding* CreateBinding(dawn_native::BackendType type,
GLFWwindow* window,
DawnDevice device);
WGPUDevice device);
} // namespace utils

View File

@@ -14,12 +14,12 @@
#include "utils/ComboRenderBundleEncoderDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace utils {
ComboRenderBundleEncoderDescriptor::ComboRenderBundleEncoderDescriptor() {
dawn::RenderBundleEncoderDescriptor* descriptor = this;
wgpu::RenderBundleEncoderDescriptor* descriptor = this;
descriptor->colorFormatsCount = 0;
descriptor->colorFormats = &cColorFormats[0];

View File

@@ -15,7 +15,7 @@
#ifndef UTILS_COMBORENDERBUNDLEENCODERDESCRIPTOR_H_
#define UTILS_COMBORENDERBUNDLEENCODERDESCRIPTOR_H_
#include <dawn/dawncpp.h>
#include <dawn/webgpu_cpp.h>
#include "common/Constants.h"
@@ -23,11 +23,11 @@
namespace utils {
class ComboRenderBundleEncoderDescriptor : public dawn::RenderBundleEncoderDescriptor {
class ComboRenderBundleEncoderDescriptor : public wgpu::RenderBundleEncoderDescriptor {
public:
ComboRenderBundleEncoderDescriptor();
std::array<dawn::TextureFormat, kMaxColorAttachments> cColorFormats;
std::array<wgpu::TextureFormat, kMaxColorAttachments> cColorFormats;
};
} // namespace utils

View File

@@ -14,27 +14,27 @@
#include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
namespace utils {
ComboVertexInputDescriptor::ComboVertexInputDescriptor() {
dawn::VertexInputDescriptor* descriptor = this;
wgpu::VertexInputDescriptor* descriptor = this;
descriptor->indexFormat = dawn::IndexFormat::Uint32;
descriptor->indexFormat = wgpu::IndexFormat::Uint32;
descriptor->bufferCount = 0;
// Fill the default values for vertexBuffers and vertexAttributes in buffers.
dawn::VertexAttributeDescriptor vertexAttribute;
wgpu::VertexAttributeDescriptor vertexAttribute;
vertexAttribute.shaderLocation = 0;
vertexAttribute.offset = 0;
vertexAttribute.format = dawn::VertexFormat::Float;
vertexAttribute.format = wgpu::VertexFormat::Float;
for (uint32_t i = 0; i < kMaxVertexAttributes; ++i) {
cAttributes[i] = vertexAttribute;
}
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
cBuffers[i].stride = 0;
cBuffers[i].stepMode = dawn::InputStepMode::Vertex;
cBuffers[i].stepMode = wgpu::InputStepMode::Vertex;
cBuffers[i].attributeCount = 0;
cBuffers[i].attributes = nullptr;
}
@@ -46,10 +46,10 @@ namespace utils {
descriptor->buffers = &cBuffers[0];
}
ComboRenderPipelineDescriptor::ComboRenderPipelineDescriptor(const dawn::Device& device) {
dawn::RenderPipelineDescriptor* descriptor = this;
ComboRenderPipelineDescriptor::ComboRenderPipelineDescriptor(const wgpu::Device& device) {
wgpu::RenderPipelineDescriptor* descriptor = this;
descriptor->primitiveTopology = dawn::PrimitiveTopology::TriangleList;
descriptor->primitiveTopology = wgpu::PrimitiveTopology::TriangleList;
descriptor->sampleCount = 1;
// Set defaults for the vertex stage descriptor.
@@ -66,8 +66,8 @@ namespace utils {
// Set defaults for the rasterization state descriptor.
{
cRasterizationState.frontFace = dawn::FrontFace::CCW;
cRasterizationState.cullMode = dawn::CullMode::None;
cRasterizationState.frontFace = wgpu::FrontFace::CCW;
cRasterizationState.cullMode = wgpu::CullMode::None;
cRasterizationState.depthBias = 0;
cRasterizationState.depthBiasSlopeScale = 0.0;
@@ -80,15 +80,15 @@ namespace utils {
descriptor->colorStateCount = 1;
descriptor->colorStates = cColorStates.data();
dawn::BlendDescriptor blend;
blend.operation = dawn::BlendOperation::Add;
blend.srcFactor = dawn::BlendFactor::One;
blend.dstFactor = dawn::BlendFactor::Zero;
dawn::ColorStateDescriptor colorStateDescriptor;
colorStateDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
wgpu::BlendDescriptor blend;
blend.operation = wgpu::BlendOperation::Add;
blend.srcFactor = wgpu::BlendFactor::One;
blend.dstFactor = wgpu::BlendFactor::Zero;
wgpu::ColorStateDescriptor colorStateDescriptor;
colorStateDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
colorStateDescriptor.alphaBlend = blend;
colorStateDescriptor.colorBlend = blend;
colorStateDescriptor.writeMask = dawn::ColorWriteMask::All;
colorStateDescriptor.writeMask = wgpu::ColorWriteMask::All;
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
cColorStates[i] = colorStateDescriptor;
}
@@ -96,15 +96,15 @@ namespace utils {
// Set defaults for the depth stencil state descriptors.
{
dawn::StencilStateFaceDescriptor stencilFace;
stencilFace.compare = dawn::CompareFunction::Always;
stencilFace.failOp = dawn::StencilOperation::Keep;
stencilFace.depthFailOp = dawn::StencilOperation::Keep;
stencilFace.passOp = dawn::StencilOperation::Keep;
wgpu::StencilStateFaceDescriptor stencilFace;
stencilFace.compare = wgpu::CompareFunction::Always;
stencilFace.failOp = wgpu::StencilOperation::Keep;
stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
stencilFace.passOp = wgpu::StencilOperation::Keep;
cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
cDepthStencilState.depthWriteEnabled = false;
cDepthStencilState.depthCompare = dawn::CompareFunction::Always;
cDepthStencilState.depthCompare = wgpu::CompareFunction::Always;
cDepthStencilState.stencilBack = stencilFace;
cDepthStencilState.stencilFront = stencilFace;
cDepthStencilState.stencilReadMask = 0xff;

View File

@@ -15,7 +15,7 @@
#ifndef UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
#define UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
#include <dawn/dawncpp.h>
#include <dawn/webgpu_cpp.h>
#include "common/Constants.h"
@@ -23,29 +23,29 @@
namespace utils {
class ComboVertexInputDescriptor : public dawn::VertexInputDescriptor {
class ComboVertexInputDescriptor : public wgpu::VertexInputDescriptor {
public:
ComboVertexInputDescriptor();
std::array<dawn::VertexBufferDescriptor, kMaxVertexBuffers> cBuffers;
std::array<dawn::VertexAttributeDescriptor, kMaxVertexAttributes> cAttributes;
std::array<wgpu::VertexBufferDescriptor, kMaxVertexBuffers> cBuffers;
std::array<wgpu::VertexAttributeDescriptor, kMaxVertexAttributes> cAttributes;
};
class ComboRenderPipelineDescriptor : public dawn::RenderPipelineDescriptor {
class ComboRenderPipelineDescriptor : public wgpu::RenderPipelineDescriptor {
public:
ComboRenderPipelineDescriptor(const dawn::Device& device);
ComboRenderPipelineDescriptor(const wgpu::Device& device);
ComboRenderPipelineDescriptor(const ComboRenderPipelineDescriptor&) = delete;
ComboRenderPipelineDescriptor& operator=(const ComboRenderPipelineDescriptor&) = delete;
ComboRenderPipelineDescriptor(ComboRenderPipelineDescriptor&&) = delete;
ComboRenderPipelineDescriptor& operator=(ComboRenderPipelineDescriptor&&) = delete;
dawn::ProgrammableStageDescriptor cFragmentStage;
wgpu::ProgrammableStageDescriptor cFragmentStage;
ComboVertexInputDescriptor cVertexInput;
dawn::RasterizationStateDescriptor cRasterizationState;
std::array<dawn::ColorStateDescriptor, kMaxColorAttachments> cColorStates;
dawn::DepthStencilStateDescriptor cDepthStencilState;
wgpu::RasterizationStateDescriptor cRasterizationState;
std::array<wgpu::ColorStateDescriptor, kMaxColorAttachments> cColorStates;
wgpu::DepthStencilStateDescriptor cDepthStencilState;
};
} // namespace utils

View File

@@ -27,7 +27,7 @@ namespace utils {
class D3D12Binding : public BackendBinding {
public:
D3D12Binding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
D3D12Binding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
}
uint64_t GetSwapChainImplementation() override {
@@ -39,7 +39,7 @@ namespace utils {
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
}
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
ASSERT(mSwapchainImpl.userData != nullptr);
return dawn_native::d3d12::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
}
@@ -48,7 +48,7 @@ namespace utils {
DawnSwapChainImplementation mSwapchainImpl = {};
};
BackendBinding* CreateD3D12Binding(GLFWwindow* window, DawnDevice device) {
BackendBinding* CreateD3D12Binding(GLFWwindow* window, WGPUDevice device) {
return new D3D12Binding(window, device);
}

View File

@@ -42,11 +42,11 @@ namespace utils {
mCommandQueue = ctx->queue;
}
DawnSwapChainError Configure(DawnTextureFormat format,
DawnTextureUsage usage,
DawnSwapChainError Configure(WGPUTextureFormat format,
WGPUTextureUsage usage,
uint32_t width,
uint32_t height) {
if (format != DAWN_TEXTURE_FORMAT_BGRA8_UNORM) {
if (format != WGPUTextureFormat_BGRA8Unorm) {
return "unsupported format";
}
ASSERT(width > 0);
@@ -65,7 +65,7 @@ namespace utils {
[mLayer setDrawableSize:size];
constexpr uint32_t kFramebufferOnlyTextureUsages =
DAWN_TEXTURE_USAGE_OUTPUT_ATTACHMENT | DAWN_TEXTURE_USAGE_PRESENT;
WGPUTextureUsage_OutputAttachment | WGPUTextureUsage_Present;
bool hasOnlyFramebufferUsages = !(usage & (~kFramebufferOnlyTextureUsages));
if (hasOnlyFramebufferUsages) {
[mLayer setFramebufferOnly:YES];
@@ -110,7 +110,7 @@ namespace utils {
class MetalBinding : public BackendBinding {
public:
MetalBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
MetalBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
}
uint64_t GetSwapChainImplementation() override {
@@ -121,15 +121,15 @@ namespace utils {
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
}
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
return DAWN_TEXTURE_FORMAT_BGRA8_UNORM;
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
return WGPUTextureFormat_BGRA8Unorm;
}
private:
DawnSwapChainImplementation mSwapchainImpl = {};
};
BackendBinding* CreateMetalBinding(GLFWwindow* window, DawnDevice device) {
BackendBinding* CreateMetalBinding(GLFWwindow* window, WGPUDevice device) {
return new MetalBinding(window, device);
}
}

View File

@@ -23,7 +23,7 @@ namespace utils {
class NullBinding : public BackendBinding {
public:
NullBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
NullBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
}
uint64_t GetSwapChainImplementation() override {
@@ -32,15 +32,15 @@ namespace utils {
}
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
}
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
return DAWN_TEXTURE_FORMAT_RGBA8_UNORM;
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
return WGPUTextureFormat_RGBA8Unorm;
}
private:
DawnSwapChainImplementation mSwapchainImpl = {};
};
BackendBinding* CreateNullBinding(GLFWwindow* window, DawnDevice device) {
BackendBinding* CreateNullBinding(GLFWwindow* window, WGPUDevice device) {
return new NullBinding(window, device);
}

View File

@@ -27,7 +27,7 @@ namespace utils {
class OpenGLBinding : public BackendBinding {
public:
OpenGLBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
OpenGLBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
}
uint64_t GetSwapChainImplementation() override {
@@ -40,7 +40,7 @@ namespace utils {
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
}
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
return dawn_native::opengl::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
}
@@ -48,7 +48,7 @@ namespace utils {
DawnSwapChainImplementation mSwapchainImpl = {};
};
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, DawnDevice device) {
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, WGPUDevice device) {
return new OpenGLBinding(window, device);
}

View File

@@ -26,7 +26,7 @@ namespace utils {
class VulkanBinding : public BackendBinding {
public:
VulkanBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
VulkanBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
}
uint64_t GetSwapChainImplementation() override {
@@ -41,7 +41,7 @@ namespace utils {
}
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
}
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
ASSERT(mSwapchainImpl.userData != nullptr);
return dawn_native::vulkan::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
}
@@ -50,7 +50,7 @@ namespace utils {
DawnSwapChainImplementation mSwapchainImpl = {};
};
BackendBinding* CreateVulkanBinding(GLFWwindow* window, DawnDevice device) {
BackendBinding* CreateVulkanBinding(GLFWwindow* window, WGPUDevice device) {
return new VulkanBinding(window, device);
}

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "utils/DawnHelpers.h"
#include "utils/WGPUHelpers.h"
#include "common/Assert.h"
#include "common/Constants.h"
@@ -41,8 +41,8 @@ namespace utils {
}
}
dawn::ShaderModule CreateShaderModuleFromResult(
const dawn::Device& device,
wgpu::ShaderModule CreateShaderModuleFromResult(
const wgpu::Device& device,
const shaderc::SpvCompilationResult& result) {
// result.cend and result.cbegin return pointers to uint32_t.
const uint32_t* resultBegin = result.cbegin();
@@ -51,7 +51,7 @@ namespace utils {
ptrdiff_t resultSize = resultEnd - resultBegin;
// SetSource takes data as uint32_t*.
dawn::ShaderModuleDescriptor descriptor;
wgpu::ShaderModuleDescriptor descriptor;
descriptor.codeSize = static_cast<uint32_t>(resultSize);
descriptor.code = result.cbegin();
return device.CreateShaderModule(&descriptor);
@@ -59,7 +59,7 @@ namespace utils {
} // anonymous namespace
dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device,
SingleShaderStage stage,
const char* source) {
shaderc_shader_kind kind = ShadercShaderKind(stage);
@@ -102,7 +102,7 @@ namespace utils {
return CreateShaderModuleFromResult(device, result);
}
dawn::ShaderModule CreateShaderModuleFromASM(const dawn::Device& device, const char* source) {
wgpu::ShaderModule CreateShaderModuleFromASM(const wgpu::Device& device, const char* source) {
shaderc::Compiler compiler;
shaderc::SpvCompilationResult result = compiler.AssembleToSpv(source, strlen(source));
if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
@@ -113,38 +113,38 @@ namespace utils {
return CreateShaderModuleFromResult(device, result);
}
dawn::Buffer CreateBufferFromData(const dawn::Device& device,
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
const void* data,
uint64_t size,
dawn::BufferUsage usage) {
dawn::BufferDescriptor descriptor;
wgpu::BufferUsage usage) {
wgpu::BufferDescriptor descriptor;
descriptor.size = size;
descriptor.usage = usage | dawn::BufferUsage::CopyDst;
descriptor.usage = usage | wgpu::BufferUsage::CopyDst;
dawn::Buffer buffer = device.CreateBuffer(&descriptor);
wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
buffer.SetSubData(0, size, data);
return buffer;
}
ComboRenderPassDescriptor::ComboRenderPassDescriptor(
std::initializer_list<dawn::TextureView> colorAttachmentInfo,
dawn::TextureView depthStencil) {
std::initializer_list<wgpu::TextureView> colorAttachmentInfo,
wgpu::TextureView depthStencil) {
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
cColorAttachments[i].loadOp = dawn::LoadOp::Clear;
cColorAttachments[i].storeOp = dawn::StoreOp::Store;
cColorAttachments[i].loadOp = wgpu::LoadOp::Clear;
cColorAttachments[i].storeOp = wgpu::StoreOp::Store;
cColorAttachments[i].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
}
cDepthStencilAttachmentInfo.clearDepth = 1.0f;
cDepthStencilAttachmentInfo.clearStencil = 0;
cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Store;
cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Clear;
cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Store;
cDepthStencilAttachmentInfo.depthLoadOp = wgpu::LoadOp::Clear;
cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Store;
cDepthStencilAttachmentInfo.stencilLoadOp = wgpu::LoadOp::Clear;
cDepthStencilAttachmentInfo.stencilStoreOp = wgpu::StoreOp::Store;
colorAttachmentCount = static_cast<uint32_t>(colorAttachmentInfo.size());
uint32_t colorAttachmentIndex = 0;
for (const dawn::TextureView& colorAttachment : colorAttachmentInfo) {
for (const wgpu::TextureView& colorAttachment : colorAttachmentInfo) {
if (colorAttachment.Get() != nullptr) {
cColorAttachments[colorAttachmentIndex].attachment = colorAttachment;
}
@@ -182,14 +182,14 @@ namespace utils {
: width(0),
height(0),
color(nullptr),
colorFormat(dawn::TextureFormat::RGBA8Unorm),
colorFormat(wgpu::TextureFormat::RGBA8Unorm),
renderPassInfo({}) {
}
BasicRenderPass::BasicRenderPass(uint32_t texWidth,
uint32_t texHeight,
dawn::Texture colorAttachment,
dawn::TextureFormat textureFormat)
wgpu::Texture colorAttachment,
wgpu::TextureFormat textureFormat)
: width(texWidth),
height(texHeight),
color(colorAttachment),
@@ -197,13 +197,13 @@ namespace utils {
renderPassInfo({colorAttachment.CreateView()}) {
}
BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
BasicRenderPass CreateBasicRenderPass(const wgpu::Device& device,
uint32_t width,
uint32_t height) {
DAWN_ASSERT(width > 0 && height > 0);
dawn::TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D;
wgpu::TextureDescriptor descriptor;
descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size.width = width;
descriptor.size.height = height;
descriptor.size.depth = 1;
@@ -211,17 +211,17 @@ namespace utils {
descriptor.sampleCount = 1;
descriptor.format = BasicRenderPass::kDefaultColorFormat;
descriptor.mipLevelCount = 1;
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
dawn::Texture color = device.CreateTexture(&descriptor);
descriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
wgpu::Texture color = device.CreateTexture(&descriptor);
return BasicRenderPass(width, height, color);
}
dawn::BufferCopyView CreateBufferCopyView(dawn::Buffer buffer,
wgpu::BufferCopyView CreateBufferCopyView(wgpu::Buffer buffer,
uint64_t offset,
uint32_t rowPitch,
uint32_t imageHeight) {
dawn::BufferCopyView bufferCopyView;
wgpu::BufferCopyView bufferCopyView;
bufferCopyView.buffer = buffer;
bufferCopyView.offset = offset;
bufferCopyView.rowPitch = rowPitch;
@@ -230,11 +230,11 @@ namespace utils {
return bufferCopyView;
}
dawn::TextureCopyView CreateTextureCopyView(dawn::Texture texture,
wgpu::TextureCopyView CreateTextureCopyView(wgpu::Texture texture,
uint32_t mipLevel,
uint32_t arrayLayer,
dawn::Origin3D origin) {
dawn::TextureCopyView textureCopyView;
wgpu::Origin3D origin) {
wgpu::TextureCopyView textureCopyView;
textureCopyView.texture = texture;
textureCopyView.mipLevel = mipLevel;
textureCopyView.arrayLayer = arrayLayer;
@@ -243,25 +243,25 @@ namespace utils {
return textureCopyView;
}
dawn::SamplerDescriptor GetDefaultSamplerDescriptor() {
dawn::SamplerDescriptor desc;
wgpu::SamplerDescriptor GetDefaultSamplerDescriptor() {
wgpu::SamplerDescriptor desc;
desc.minFilter = dawn::FilterMode::Linear;
desc.magFilter = dawn::FilterMode::Linear;
desc.mipmapFilter = dawn::FilterMode::Linear;
desc.addressModeU = dawn::AddressMode::Repeat;
desc.addressModeV = dawn::AddressMode::Repeat;
desc.addressModeW = dawn::AddressMode::Repeat;
desc.minFilter = wgpu::FilterMode::Linear;
desc.magFilter = wgpu::FilterMode::Linear;
desc.mipmapFilter = wgpu::FilterMode::Linear;
desc.addressModeU = wgpu::AddressMode::Repeat;
desc.addressModeV = wgpu::AddressMode::Repeat;
desc.addressModeW = wgpu::AddressMode::Repeat;
desc.lodMinClamp = kLodMin;
desc.lodMaxClamp = kLodMax;
desc.compare = dawn::CompareFunction::Never;
desc.compare = wgpu::CompareFunction::Never;
return desc;
}
dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
const dawn::BindGroupLayout* bindGroupLayout) {
dawn::PipelineLayoutDescriptor descriptor;
wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device,
const wgpu::BindGroupLayout* bindGroupLayout) {
wgpu::PipelineLayoutDescriptor descriptor;
if (bindGroupLayout != nullptr) {
descriptor.bindGroupLayoutCount = 1;
descriptor.bindGroupLayouts = bindGroupLayout;
@@ -272,43 +272,43 @@ namespace utils {
return device.CreatePipelineLayout(&descriptor);
}
dawn::BindGroupLayout MakeBindGroupLayout(
const dawn::Device& device,
std::initializer_list<dawn::BindGroupLayoutBinding> bindingsInitializer) {
constexpr dawn::ShaderStage kNoStages{};
wgpu::BindGroupLayout MakeBindGroupLayout(
const wgpu::Device& device,
std::initializer_list<wgpu::BindGroupLayoutBinding> bindingsInitializer) {
constexpr wgpu::ShaderStage kNoStages{};
std::vector<dawn::BindGroupLayoutBinding> bindings;
for (const dawn::BindGroupLayoutBinding& binding : bindingsInitializer) {
std::vector<wgpu::BindGroupLayoutBinding> bindings;
for (const wgpu::BindGroupLayoutBinding& binding : bindingsInitializer) {
if (binding.visibility != kNoStages) {
bindings.push_back(binding);
}
}
dawn::BindGroupLayoutDescriptor descriptor;
wgpu::BindGroupLayoutDescriptor descriptor;
descriptor.bindingCount = static_cast<uint32_t>(bindings.size());
descriptor.bindings = bindings.data();
return device.CreateBindGroupLayout(&descriptor);
}
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
const dawn::Sampler& sampler)
const wgpu::Sampler& sampler)
: binding(binding), sampler(sampler) {
}
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
const dawn::TextureView& textureView)
const wgpu::TextureView& textureView)
: binding(binding), textureView(textureView) {
}
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
const dawn::Buffer& buffer,
const wgpu::Buffer& buffer,
uint64_t offset,
uint64_t size)
: binding(binding), buffer(buffer), offset(offset), size(size) {
}
dawn::BindGroupBinding BindingInitializationHelper::GetAsBinding() const {
dawn::BindGroupBinding result;
wgpu::BindGroupBinding BindingInitializationHelper::GetAsBinding() const {
wgpu::BindGroupBinding result;
result.binding = binding;
result.sampler = sampler;
@@ -320,16 +320,16 @@ namespace utils {
return result;
}
dawn::BindGroup MakeBindGroup(
const dawn::Device& device,
const dawn::BindGroupLayout& layout,
wgpu::BindGroup MakeBindGroup(
const wgpu::Device& device,
const wgpu::BindGroupLayout& layout,
std::initializer_list<BindingInitializationHelper> bindingsInitializer) {
std::vector<dawn::BindGroupBinding> bindings;
std::vector<wgpu::BindGroupBinding> bindings;
for (const BindingInitializationHelper& helper : bindingsInitializer) {
bindings.push_back(helper.GetAsBinding());
}
dawn::BindGroupDescriptor descriptor;
wgpu::BindGroupDescriptor descriptor;
descriptor.layout = layout;
descriptor.bindingCount = bindings.size();
descriptor.bindings = bindings.data();

View File

@@ -15,7 +15,7 @@
#ifndef UTILS_DAWNHELPERS_H_
#define UTILS_DAWNHELPERS_H_
#include <dawn/dawncpp.h>
#include <dawn/webgpu_cpp.h>
#include <array>
#include <initializer_list>
@@ -28,42 +28,42 @@ namespace utils {
enum class SingleShaderStage { Vertex, Fragment, Compute };
dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device,
SingleShaderStage stage,
const char* source);
dawn::ShaderModule CreateShaderModuleFromASM(const dawn::Device& device, const char* source);
wgpu::ShaderModule CreateShaderModuleFromASM(const wgpu::Device& device, const char* source);
dawn::Buffer CreateBufferFromData(const dawn::Device& device,
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
const void* data,
uint64_t size,
dawn::BufferUsage usage);
wgpu::BufferUsage usage);
template <typename T>
dawn::Buffer CreateBufferFromData(const dawn::Device& device,
dawn::BufferUsage usage,
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
wgpu::BufferUsage usage,
std::initializer_list<T> data) {
return CreateBufferFromData(device, data.begin(), uint32_t(sizeof(T) * data.size()), usage);
}
dawn::BufferCopyView CreateBufferCopyView(dawn::Buffer buffer,
wgpu::BufferCopyView CreateBufferCopyView(wgpu::Buffer buffer,
uint64_t offset,
uint32_t rowPitch,
uint32_t imageHeight);
dawn::TextureCopyView CreateTextureCopyView(dawn::Texture texture,
wgpu::TextureCopyView CreateTextureCopyView(wgpu::Texture texture,
uint32_t level,
uint32_t slice,
dawn::Origin3D origin);
wgpu::Origin3D origin);
struct ComboRenderPassDescriptor : public dawn::RenderPassDescriptor {
struct ComboRenderPassDescriptor : public wgpu::RenderPassDescriptor {
public:
ComboRenderPassDescriptor(std::initializer_list<dawn::TextureView> colorAttachmentInfo,
dawn::TextureView depthStencil = dawn::TextureView());
ComboRenderPassDescriptor(std::initializer_list<wgpu::TextureView> colorAttachmentInfo,
wgpu::TextureView depthStencil = wgpu::TextureView());
const ComboRenderPassDescriptor& operator=(
const ComboRenderPassDescriptor& otherRenderPass);
std::array<dawn::RenderPassColorAttachmentDescriptor, kMaxColorAttachments>
std::array<wgpu::RenderPassColorAttachmentDescriptor, kMaxColorAttachments>
cColorAttachments;
dawn::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
wgpu::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
};
struct BasicRenderPass {
@@ -71,27 +71,27 @@ namespace utils {
BasicRenderPass();
BasicRenderPass(uint32_t width,
uint32_t height,
dawn::Texture color,
dawn::TextureFormat texture = kDefaultColorFormat);
wgpu::Texture color,
wgpu::TextureFormat texture = kDefaultColorFormat);
static constexpr dawn::TextureFormat kDefaultColorFormat = dawn::TextureFormat::RGBA8Unorm;
static constexpr wgpu::TextureFormat kDefaultColorFormat = wgpu::TextureFormat::RGBA8Unorm;
uint32_t width;
uint32_t height;
dawn::Texture color;
dawn::TextureFormat colorFormat;
wgpu::Texture color;
wgpu::TextureFormat colorFormat;
utils::ComboRenderPassDescriptor renderPassInfo;
};
BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
BasicRenderPass CreateBasicRenderPass(const wgpu::Device& device,
uint32_t width,
uint32_t height);
dawn::SamplerDescriptor GetDefaultSamplerDescriptor();
dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
const dawn::BindGroupLayout* bindGroupLayout);
dawn::BindGroupLayout MakeBindGroupLayout(
const dawn::Device& device,
std::initializer_list<dawn::BindGroupLayoutBinding> bindingsInitializer);
wgpu::SamplerDescriptor GetDefaultSamplerDescriptor();
wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device,
const wgpu::BindGroupLayout* bindGroupLayout);
wgpu::BindGroupLayout MakeBindGroupLayout(
const wgpu::Device& device,
std::initializer_list<wgpu::BindGroupLayoutBinding> bindingsInitializer);
// Helpers to make creating bind groups look nicer:
//
@@ -104,26 +104,26 @@ namespace utils {
// Structure with one constructor per-type of bindings, so that the initializer_list accepts
// bindings with the right type and no extra information.
struct BindingInitializationHelper {
BindingInitializationHelper(uint32_t binding, const dawn::Sampler& sampler);
BindingInitializationHelper(uint32_t binding, const dawn::TextureView& textureView);
BindingInitializationHelper(uint32_t binding, const wgpu::Sampler& sampler);
BindingInitializationHelper(uint32_t binding, const wgpu::TextureView& textureView);
BindingInitializationHelper(uint32_t binding,
const dawn::Buffer& buffer,
const wgpu::Buffer& buffer,
uint64_t offset,
uint64_t size);
dawn::BindGroupBinding GetAsBinding() const;
wgpu::BindGroupBinding GetAsBinding() const;
uint32_t binding;
dawn::Sampler sampler;
dawn::TextureView textureView;
dawn::Buffer buffer;
wgpu::Sampler sampler;
wgpu::TextureView textureView;
wgpu::Buffer buffer;
uint64_t offset = 0;
uint64_t size = 0;
};
dawn::BindGroup MakeBindGroup(
const dawn::Device& device,
const dawn::BindGroupLayout& layout,
wgpu::BindGroup MakeBindGroup(
const wgpu::Device& device,
const wgpu::BindGroupLayout& layout,
std::initializer_list<BindingInitializationHelper> bindingsInitializer);
} // namespace utils