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:
parent
9f90c8d3ca
commit
04863c42be
4
BUILD.gn
4
BUILD.gn
|
@ -658,13 +658,13 @@ static_library("dawn_utils") {
|
||||||
"src/utils/ComboRenderBundleEncoderDescriptor.h",
|
"src/utils/ComboRenderBundleEncoderDescriptor.h",
|
||||||
"src/utils/ComboRenderPipelineDescriptor.cpp",
|
"src/utils/ComboRenderPipelineDescriptor.cpp",
|
||||||
"src/utils/ComboRenderPipelineDescriptor.h",
|
"src/utils/ComboRenderPipelineDescriptor.h",
|
||||||
"src/utils/DawnHelpers.cpp",
|
|
||||||
"src/utils/DawnHelpers.h",
|
|
||||||
"src/utils/SystemUtils.cpp",
|
"src/utils/SystemUtils.cpp",
|
||||||
"src/utils/SystemUtils.h",
|
"src/utils/SystemUtils.h",
|
||||||
"src/utils/TerribleCommandBuffer.cpp",
|
"src/utils/TerribleCommandBuffer.cpp",
|
||||||
"src/utils/TerribleCommandBuffer.h",
|
"src/utils/TerribleCommandBuffer.h",
|
||||||
"src/utils/Timer.h",
|
"src/utils/Timer.h",
|
||||||
|
"src/utils/WGPUHelpers.cpp",
|
||||||
|
"src/utils/WGPUHelpers.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (is_win) {
|
if (is_win) {
|
||||||
|
|
|
@ -15,19 +15,19 @@
|
||||||
#include "SampleUtils.h"
|
#include "SampleUtils.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
dawn::Device device;
|
wgpu::Device device;
|
||||||
dawn::Queue queue;
|
wgpu::Queue queue;
|
||||||
dawn::SwapChain swapchain;
|
wgpu::SwapChain swapchain;
|
||||||
dawn::RenderPipeline pipeline;
|
wgpu::RenderPipeline pipeline;
|
||||||
dawn::BindGroup bindGroup;
|
wgpu::BindGroup bindGroup;
|
||||||
dawn::Buffer ubo;
|
wgpu::Buffer ubo;
|
||||||
|
|
||||||
float RandomFloat(float min, float max) {
|
float RandomFloat(float min, float max) {
|
||||||
float zeroOne = rand() / float(RAND_MAX);
|
float zeroOne = rand() / float(RAND_MAX);
|
||||||
|
@ -52,10 +52,10 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), wgpu::TextureUsage::OutputAttachment,
|
||||||
640, 480);
|
640, 480);
|
||||||
|
|
||||||
dawn::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void init() {
|
||||||
gl_Position = vec4(xpos, ypos, 0.0, 1.0);
|
gl_Position = vec4(xpos, ypos, 0.0, 1.0);
|
||||||
})");
|
})");
|
||||||
|
|
||||||
dawn::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
@ -112,8 +112,8 @@ void init() {
|
||||||
fragColor = v_color;
|
fragColor = v_color;
|
||||||
})");
|
})");
|
||||||
|
|
||||||
dawn::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||||
device, {{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer, true}});
|
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer, true}});
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
@ -133,9 +133,9 @@ void init() {
|
||||||
data.scalarOffset = RandomFloat(0.0f, 10.0f);
|
data.scalarOffset = RandomFloat(0.0f, 10.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BufferDescriptor bufferDesc;
|
wgpu::BufferDescriptor bufferDesc;
|
||||||
bufferDesc.size = kNumTriangles * sizeof(ShaderData);
|
bufferDesc.size = kNumTriangles * sizeof(ShaderData);
|
||||||
bufferDesc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::Uniform;
|
bufferDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
||||||
ubo = device.CreateBuffer(&bufferDesc);
|
ubo = device.CreateBuffer(&bufferDesc);
|
||||||
|
|
||||||
bindGroup =
|
bindGroup =
|
||||||
|
@ -143,7 +143,7 @@ void init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame() {
|
void frame() {
|
||||||
dawn::Texture backbuffer = swapchain.GetNextTexture();
|
wgpu::Texture backbuffer = swapchain.GetNextTexture();
|
||||||
|
|
||||||
static int f = 0;
|
static int f = 0;
|
||||||
f++;
|
f++;
|
||||||
|
@ -153,9 +153,9 @@ void frame() {
|
||||||
ubo.SetSubData(0, kNumTriangles * sizeof(ShaderData), shaderData.data());
|
ubo.SetSubData(0, kNumTriangles * sizeof(ShaderData), shaderData.data());
|
||||||
|
|
||||||
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()});
|
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()});
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
{
|
{
|
||||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||||
pass.SetPipeline(pipeline);
|
pass.SetPipeline(pipeline);
|
||||||
|
|
||||||
for (size_t i = 0; i < kNumTriangles; i++) {
|
for (size_t i = 0; i < kNumTriangles; i++) {
|
||||||
|
@ -167,7 +167,7 @@ void frame() {
|
||||||
pass.EndPass();
|
pass.EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
wgpu::CommandBuffer commands = encoder.Finish();
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
swapchain.Present(backbuffer);
|
swapchain.Present(backbuffer);
|
||||||
DoFlush();
|
DoFlush();
|
||||||
|
|
|
@ -14,30 +14,29 @@
|
||||||
|
|
||||||
#include "SampleUtils.h"
|
#include "SampleUtils.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
DawnDevice device;
|
WGPUDevice device;
|
||||||
DawnQueue queue;
|
WGPUQueue queue;
|
||||||
DawnSwapChain swapchain;
|
WGPUSwapChain swapchain;
|
||||||
DawnRenderPipeline pipeline;
|
WGPURenderPipeline pipeline;
|
||||||
|
|
||||||
DawnTextureFormat swapChainFormat;
|
WGPUTextureFormat swapChainFormat;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
device = CreateCppDawnDevice().Release();
|
device = CreateCppDawnDevice().Release();
|
||||||
queue = dawnDeviceCreateQueue(device);
|
queue = wgpuDeviceCreateQueue(device);
|
||||||
|
|
||||||
{
|
{
|
||||||
DawnSwapChainDescriptor descriptor;
|
WGPUSwapChainDescriptor descriptor;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
descriptor.label = nullptr;
|
descriptor.label = nullptr;
|
||||||
descriptor.implementation = GetSwapChainImplementation();
|
descriptor.implementation = GetSwapChainImplementation();
|
||||||
swapchain = dawnDeviceCreateSwapChain(device, &descriptor);
|
swapchain = wgpuDeviceCreateSwapChain(device, &descriptor);
|
||||||
}
|
}
|
||||||
swapChainFormat = static_cast<DawnTextureFormat>(GetPreferredSwapChainTextureFormat());
|
swapChainFormat = static_cast<WGPUTextureFormat>(GetPreferredSwapChainTextureFormat());
|
||||||
dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_OUTPUT_ATTACHMENT, 640,
|
wgpuSwapChainConfigure(swapchain, swapChainFormat, WGPUTextureUsage_OutputAttachment, 640, 480);
|
||||||
480);
|
|
||||||
|
|
||||||
const char* vs =
|
const char* vs =
|
||||||
"#version 450\n"
|
"#version 450\n"
|
||||||
|
@ -45,8 +44,8 @@ void init() {
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n"
|
" gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
DawnShaderModule vsModule =
|
WGPUShaderModule vsModule =
|
||||||
utils::CreateShaderModule(dawn::Device(device), utils::SingleShaderStage::Vertex, vs)
|
utils::CreateShaderModule(wgpu::Device(device), utils::SingleShaderStage::Vertex, vs)
|
||||||
.Release();
|
.Release();
|
||||||
|
|
||||||
const char* fs =
|
const char* fs =
|
||||||
|
@ -55,11 +54,11 @@ void init() {
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
" fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
DawnShaderModule fsModule =
|
WGPUShaderModule fsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs).Release();
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs).Release();
|
||||||
|
|
||||||
{
|
{
|
||||||
DawnRenderPipelineDescriptor descriptor;
|
WGPURenderPipelineDescriptor descriptor;
|
||||||
descriptor.label = nullptr;
|
descriptor.label = nullptr;
|
||||||
descriptor.nextInChain = nullptr;
|
descriptor.nextInChain = nullptr;
|
||||||
|
|
||||||
|
@ -67,7 +66,7 @@ void init() {
|
||||||
descriptor.vertexStage.module = vsModule;
|
descriptor.vertexStage.module = vsModule;
|
||||||
descriptor.vertexStage.entryPoint = "main";
|
descriptor.vertexStage.entryPoint = "main";
|
||||||
|
|
||||||
DawnProgrammableStageDescriptor fragmentStage;
|
WGPUProgrammableStageDescriptor fragmentStage;
|
||||||
fragmentStage.nextInChain = nullptr;
|
fragmentStage.nextInChain = nullptr;
|
||||||
fragmentStage.module = fsModule;
|
fragmentStage.module = fsModule;
|
||||||
fragmentStage.entryPoint = "main";
|
fragmentStage.entryPoint = "main";
|
||||||
|
@ -75,91 +74,91 @@ void init() {
|
||||||
|
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
|
|
||||||
DawnBlendDescriptor blendDescriptor;
|
WGPUBlendDescriptor blendDescriptor;
|
||||||
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD;
|
blendDescriptor.operation = WGPUBlendOperation_Add;
|
||||||
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE;
|
blendDescriptor.srcFactor = WGPUBlendFactor_One;
|
||||||
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
|
blendDescriptor.dstFactor = WGPUBlendFactor_One;
|
||||||
DawnColorStateDescriptor colorStateDescriptor;
|
WGPUColorStateDescriptor colorStateDescriptor;
|
||||||
colorStateDescriptor.nextInChain = nullptr;
|
colorStateDescriptor.nextInChain = nullptr;
|
||||||
colorStateDescriptor.format = swapChainFormat;
|
colorStateDescriptor.format = swapChainFormat;
|
||||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
colorStateDescriptor.alphaBlend = blendDescriptor;
|
||||||
colorStateDescriptor.colorBlend = blendDescriptor;
|
colorStateDescriptor.colorBlend = blendDescriptor;
|
||||||
colorStateDescriptor.writeMask = DAWN_COLOR_WRITE_MASK_ALL;
|
colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
|
||||||
|
|
||||||
descriptor.colorStateCount = 1;
|
descriptor.colorStateCount = 1;
|
||||||
descriptor.colorStates = &colorStateDescriptor;
|
descriptor.colorStates = &colorStateDescriptor;
|
||||||
|
|
||||||
DawnPipelineLayoutDescriptor pl;
|
WGPUPipelineLayoutDescriptor pl;
|
||||||
pl.nextInChain = nullptr;
|
pl.nextInChain = nullptr;
|
||||||
pl.label = nullptr;
|
pl.label = nullptr;
|
||||||
pl.bindGroupLayoutCount = 0;
|
pl.bindGroupLayoutCount = 0;
|
||||||
pl.bindGroupLayouts = nullptr;
|
pl.bindGroupLayouts = nullptr;
|
||||||
descriptor.layout = dawnDeviceCreatePipelineLayout(device, &pl);
|
descriptor.layout = wgpuDeviceCreatePipelineLayout(device, &pl);
|
||||||
|
|
||||||
DawnVertexInputDescriptor vertexInput;
|
WGPUVertexInputDescriptor vertexInput;
|
||||||
vertexInput.nextInChain = nullptr;
|
vertexInput.nextInChain = nullptr;
|
||||||
vertexInput.indexFormat = DAWN_INDEX_FORMAT_UINT32;
|
vertexInput.indexFormat = WGPUIndexFormat_Uint32;
|
||||||
vertexInput.bufferCount = 0;
|
vertexInput.bufferCount = 0;
|
||||||
vertexInput.buffers = nullptr;
|
vertexInput.buffers = nullptr;
|
||||||
descriptor.vertexInput = &vertexInput;
|
descriptor.vertexInput = &vertexInput;
|
||||||
|
|
||||||
DawnRasterizationStateDescriptor rasterizationState;
|
WGPURasterizationStateDescriptor rasterizationState;
|
||||||
rasterizationState.nextInChain = nullptr;
|
rasterizationState.nextInChain = nullptr;
|
||||||
rasterizationState.frontFace = DAWN_FRONT_FACE_CCW;
|
rasterizationState.frontFace = WGPUFrontFace_CCW;
|
||||||
rasterizationState.cullMode = DAWN_CULL_MODE_NONE;
|
rasterizationState.cullMode = WGPUCullMode_None;
|
||||||
rasterizationState.depthBias = 0;
|
rasterizationState.depthBias = 0;
|
||||||
rasterizationState.depthBiasSlopeScale = 0.0;
|
rasterizationState.depthBiasSlopeScale = 0.0;
|
||||||
rasterizationState.depthBiasClamp = 0.0;
|
rasterizationState.depthBiasClamp = 0.0;
|
||||||
descriptor.rasterizationState = &rasterizationState;
|
descriptor.rasterizationState = &rasterizationState;
|
||||||
|
|
||||||
descriptor.primitiveTopology = DAWN_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
descriptor.primitiveTopology = WGPUPrimitiveTopology_TriangleList;
|
||||||
descriptor.sampleMask = 0xFFFFFFFF;
|
descriptor.sampleMask = 0xFFFFFFFF;
|
||||||
descriptor.alphaToCoverageEnabled = false;
|
descriptor.alphaToCoverageEnabled = false;
|
||||||
|
|
||||||
descriptor.depthStencilState = nullptr;
|
descriptor.depthStencilState = nullptr;
|
||||||
|
|
||||||
pipeline = dawnDeviceCreateRenderPipeline(device, &descriptor);
|
pipeline = wgpuDeviceCreateRenderPipeline(device, &descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnShaderModuleRelease(vsModule);
|
wgpuShaderModuleRelease(vsModule);
|
||||||
dawnShaderModuleRelease(fsModule);
|
wgpuShaderModuleRelease(fsModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame() {
|
void frame() {
|
||||||
DawnTexture backbuffer = dawnSwapChainGetNextTexture(swapchain);
|
WGPUTexture backbuffer = wgpuSwapChainGetNextTexture(swapchain);
|
||||||
DawnTextureView backbufferView = dawnTextureCreateView(backbuffer, nullptr);
|
WGPUTextureView backbufferView = wgpuTextureCreateView(backbuffer, nullptr);
|
||||||
DawnRenderPassDescriptor renderpassInfo;
|
WGPURenderPassDescriptor renderpassInfo;
|
||||||
renderpassInfo.nextInChain = nullptr;
|
renderpassInfo.nextInChain = nullptr;
|
||||||
renderpassInfo.label = nullptr;
|
renderpassInfo.label = nullptr;
|
||||||
DawnRenderPassColorAttachmentDescriptor colorAttachment;
|
WGPURenderPassColorAttachmentDescriptor colorAttachment;
|
||||||
{
|
{
|
||||||
colorAttachment.attachment = backbufferView;
|
colorAttachment.attachment = backbufferView;
|
||||||
colorAttachment.resolveTarget = nullptr;
|
colorAttachment.resolveTarget = nullptr;
|
||||||
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
colorAttachment.clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
colorAttachment.loadOp = DAWN_LOAD_OP_CLEAR;
|
colorAttachment.loadOp = WGPULoadOp_Clear;
|
||||||
colorAttachment.storeOp = DAWN_STORE_OP_STORE;
|
colorAttachment.storeOp = WGPUStoreOp_Store;
|
||||||
renderpassInfo.colorAttachmentCount = 1;
|
renderpassInfo.colorAttachmentCount = 1;
|
||||||
renderpassInfo.colorAttachments = &colorAttachment;
|
renderpassInfo.colorAttachments = &colorAttachment;
|
||||||
renderpassInfo.depthStencilAttachment = nullptr;
|
renderpassInfo.depthStencilAttachment = nullptr;
|
||||||
}
|
}
|
||||||
DawnCommandBuffer commands;
|
WGPUCommandBuffer commands;
|
||||||
{
|
{
|
||||||
DawnCommandEncoder encoder = dawnDeviceCreateCommandEncoder(device, nullptr);
|
WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr);
|
||||||
|
|
||||||
DawnRenderPassEncoder pass = dawnCommandEncoderBeginRenderPass(encoder, &renderpassInfo);
|
WGPURenderPassEncoder pass = wgpuCommandEncoderBeginRenderPass(encoder, &renderpassInfo);
|
||||||
dawnRenderPassEncoderSetPipeline(pass, pipeline);
|
wgpuRenderPassEncoderSetPipeline(pass, pipeline);
|
||||||
dawnRenderPassEncoderDraw(pass, 3, 1, 0, 0);
|
wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0);
|
||||||
dawnRenderPassEncoderEndPass(pass);
|
wgpuRenderPassEncoderEndPass(pass);
|
||||||
dawnRenderPassEncoderRelease(pass);
|
wgpuRenderPassEncoderRelease(pass);
|
||||||
|
|
||||||
commands = dawnCommandEncoderFinish(encoder, nullptr);
|
commands = wgpuCommandEncoderFinish(encoder, nullptr);
|
||||||
dawnCommandEncoderRelease(encoder);
|
wgpuCommandEncoderRelease(encoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawnQueueSubmit(queue, 1, &commands);
|
wgpuQueueSubmit(queue, 1, &commands);
|
||||||
dawnCommandBufferRelease(commands);
|
wgpuCommandBufferRelease(commands);
|
||||||
dawnSwapChainPresent(swapchain, backbuffer);
|
wgpuSwapChainPresent(swapchain, backbuffer);
|
||||||
dawnTextureViewRelease(backbufferView);
|
wgpuTextureViewRelease(backbufferView);
|
||||||
|
|
||||||
DoFlush();
|
DoFlush();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
#include "SampleUtils.h"
|
#include "SampleUtils.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -24,19 +24,19 @@
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
dawn::Device device;
|
wgpu::Device device;
|
||||||
dawn::Queue queue;
|
wgpu::Queue queue;
|
||||||
dawn::SwapChain swapchain;
|
wgpu::SwapChain swapchain;
|
||||||
dawn::TextureView depthStencilView;
|
wgpu::TextureView depthStencilView;
|
||||||
|
|
||||||
dawn::Buffer modelBuffer;
|
wgpu::Buffer modelBuffer;
|
||||||
std::array<dawn::Buffer, 2> particleBuffers;
|
std::array<wgpu::Buffer, 2> particleBuffers;
|
||||||
|
|
||||||
dawn::RenderPipeline renderPipeline;
|
wgpu::RenderPipeline renderPipeline;
|
||||||
|
|
||||||
dawn::Buffer updateParams;
|
wgpu::Buffer updateParams;
|
||||||
dawn::ComputePipeline updatePipeline;
|
wgpu::ComputePipeline updatePipeline;
|
||||||
std::array<dawn::BindGroup, 2> updateBGs;
|
std::array<wgpu::BindGroup, 2> updateBGs;
|
||||||
|
|
||||||
size_t pingpong = 0;
|
size_t pingpong = 0;
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ void initBuffers() {
|
||||||
{0.00, 0.02},
|
{0.00, 0.02},
|
||||||
};
|
};
|
||||||
modelBuffer =
|
modelBuffer =
|
||||||
utils::CreateBufferFromData(device, model, sizeof(model), dawn::BufferUsage::Vertex);
|
utils::CreateBufferFromData(device, model, sizeof(model), wgpu::BufferUsage::Vertex);
|
||||||
|
|
||||||
SimParams params = { 0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles };
|
SimParams params = { 0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles };
|
||||||
updateParams =
|
updateParams =
|
||||||
utils::CreateBufferFromData(device, ¶ms, sizeof(params), dawn::BufferUsage::Uniform);
|
utils::CreateBufferFromData(device, ¶ms, sizeof(params), wgpu::BufferUsage::Uniform);
|
||||||
|
|
||||||
std::vector<Particle> initialParticles(kNumParticles);
|
std::vector<Particle> initialParticles(kNumParticles);
|
||||||
{
|
{
|
||||||
|
@ -83,10 +83,10 @@ void initBuffers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < 2; i++) {
|
for (size_t i = 0; i < 2; i++) {
|
||||||
dawn::BufferDescriptor descriptor;
|
wgpu::BufferDescriptor descriptor;
|
||||||
descriptor.size = sizeof(Particle) * kNumParticles;
|
descriptor.size = sizeof(Particle) * kNumParticles;
|
||||||
descriptor.usage =
|
descriptor.usage =
|
||||||
dawn::BufferUsage::CopyDst | dawn::BufferUsage::Vertex | dawn::BufferUsage::Storage;
|
wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Storage;
|
||||||
particleBuffers[i] = device.CreateBuffer(&descriptor);
|
particleBuffers[i] = device.CreateBuffer(&descriptor);
|
||||||
|
|
||||||
particleBuffers[i].SetSubData(0,
|
particleBuffers[i].SetSubData(0,
|
||||||
|
@ -96,7 +96,7 @@ void initBuffers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initRender() {
|
void initRender() {
|
||||||
dawn::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(location = 0) in vec2 a_particlePos;
|
layout(location = 0) in vec2 a_particlePos;
|
||||||
|
@ -110,7 +110,7 @@ void initRender() {
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
|
|
||||||
dawn::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(location = 0) out vec4 fragColor;
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
@ -127,27 +127,27 @@ void initRender() {
|
||||||
|
|
||||||
descriptor.cVertexInput.bufferCount = 2;
|
descriptor.cVertexInput.bufferCount = 2;
|
||||||
descriptor.cVertexInput.cBuffers[0].stride = sizeof(Particle);
|
descriptor.cVertexInput.cBuffers[0].stride = sizeof(Particle);
|
||||||
descriptor.cVertexInput.cBuffers[0].stepMode = dawn::InputStepMode::Instance;
|
descriptor.cVertexInput.cBuffers[0].stepMode = wgpu::InputStepMode::Instance;
|
||||||
descriptor.cVertexInput.cBuffers[0].attributeCount = 2;
|
descriptor.cVertexInput.cBuffers[0].attributeCount = 2;
|
||||||
descriptor.cVertexInput.cAttributes[0].offset = offsetof(Particle, pos);
|
descriptor.cVertexInput.cAttributes[0].offset = offsetof(Particle, pos);
|
||||||
descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float2;
|
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float2;
|
||||||
descriptor.cVertexInput.cAttributes[1].shaderLocation = 1;
|
descriptor.cVertexInput.cAttributes[1].shaderLocation = 1;
|
||||||
descriptor.cVertexInput.cAttributes[1].offset = offsetof(Particle, vel);
|
descriptor.cVertexInput.cAttributes[1].offset = offsetof(Particle, vel);
|
||||||
descriptor.cVertexInput.cAttributes[1].format = dawn::VertexFormat::Float2;
|
descriptor.cVertexInput.cAttributes[1].format = wgpu::VertexFormat::Float2;
|
||||||
descriptor.cVertexInput.cBuffers[1].stride = sizeof(glm::vec2);
|
descriptor.cVertexInput.cBuffers[1].stride = sizeof(glm::vec2);
|
||||||
descriptor.cVertexInput.cBuffers[1].attributeCount = 1;
|
descriptor.cVertexInput.cBuffers[1].attributeCount = 1;
|
||||||
descriptor.cVertexInput.cBuffers[1].attributes = &descriptor.cVertexInput.cAttributes[2];
|
descriptor.cVertexInput.cBuffers[1].attributes = &descriptor.cVertexInput.cAttributes[2];
|
||||||
descriptor.cVertexInput.cAttributes[2].shaderLocation = 2;
|
descriptor.cVertexInput.cAttributes[2].shaderLocation = 2;
|
||||||
descriptor.cVertexInput.cAttributes[2].format = dawn::VertexFormat::Float2;
|
descriptor.cVertexInput.cAttributes[2].format = wgpu::VertexFormat::Float2;
|
||||||
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
||||||
descriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
|
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
|
|
||||||
renderPipeline = device.CreateRenderPipeline(&descriptor);
|
renderPipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSim() {
|
void initSim() {
|
||||||
dawn::ShaderModule module =
|
wgpu::ShaderModule module =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
||||||
#version 450
|
#version 450
|
||||||
|
|
||||||
|
@ -239,14 +239,14 @@ void initSim() {
|
||||||
|
|
||||||
auto bgl = utils::MakeBindGroupLayout(
|
auto bgl = utils::MakeBindGroupLayout(
|
||||||
device, {
|
device, {
|
||||||
{0, dawn::ShaderStage::Compute, dawn::BindingType::UniformBuffer},
|
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer},
|
||||||
{1, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer},
|
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer},
|
||||||
{2, dawn::ShaderStage::Compute, dawn::BindingType::StorageBuffer},
|
{2, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer},
|
||||||
});
|
});
|
||||||
|
|
||||||
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
|
||||||
dawn::ComputePipelineDescriptor csDesc;
|
wgpu::ComputePipelineDescriptor csDesc;
|
||||||
csDesc.layout = pl;
|
csDesc.layout = pl;
|
||||||
csDesc.computeStage.module = module;
|
csDesc.computeStage.module = module;
|
||||||
csDesc.computeStage.entryPoint = "main";
|
csDesc.computeStage.entryPoint = "main";
|
||||||
|
@ -261,12 +261,12 @@ void initSim() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CommandBuffer createCommandBuffer(const dawn::Texture backbuffer, size_t i) {
|
wgpu::CommandBuffer createCommandBuffer(const wgpu::Texture backbuffer, size_t i) {
|
||||||
auto& bufferDst = particleBuffers[(i + 1) % 2];
|
auto& bufferDst = particleBuffers[(i + 1) % 2];
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
|
|
||||||
{
|
{
|
||||||
dawn::ComputePassEncoder pass = encoder.BeginComputePass();
|
wgpu::ComputePassEncoder pass = encoder.BeginComputePass();
|
||||||
pass.SetPipeline(updatePipeline);
|
pass.SetPipeline(updatePipeline);
|
||||||
pass.SetBindGroup(0, updateBGs[i]);
|
pass.SetBindGroup(0, updateBGs[i]);
|
||||||
pass.Dispatch(kNumParticles, 1, 1);
|
pass.Dispatch(kNumParticles, 1, 1);
|
||||||
|
@ -275,7 +275,7 @@ dawn::CommandBuffer createCommandBuffer(const dawn::Texture backbuffer, size_t i
|
||||||
|
|
||||||
{
|
{
|
||||||
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
||||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||||
pass.SetPipeline(renderPipeline);
|
pass.SetPipeline(renderPipeline);
|
||||||
pass.SetVertexBuffer(0, bufferDst);
|
pass.SetVertexBuffer(0, bufferDst);
|
||||||
pass.SetVertexBuffer(1, modelBuffer);
|
pass.SetVertexBuffer(1, modelBuffer);
|
||||||
|
@ -291,7 +291,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), wgpu::TextureUsage::OutputAttachment,
|
||||||
640, 480);
|
640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
|
@ -300,9 +300,9 @@ void init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void frame() {
|
void frame() {
|
||||||
dawn::Texture backbuffer = swapchain.GetNextTexture();
|
wgpu::Texture backbuffer = swapchain.GetNextTexture();
|
||||||
|
|
||||||
dawn::CommandBuffer commandBuffer = createCommandBuffer(backbuffer, pingpong);
|
wgpu::CommandBuffer commandBuffer = createCommandBuffer(backbuffer, pingpong);
|
||||||
queue.Submit(1, &commandBuffer);
|
queue.Submit(1, &commandBuffer);
|
||||||
swapchain.Present(backbuffer);
|
swapchain.Present(backbuffer);
|
||||||
DoFlush();
|
DoFlush();
|
||||||
|
|
|
@ -15,31 +15,31 @@
|
||||||
#include "SampleUtils.h"
|
#include "SampleUtils.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
dawn::Device device;
|
wgpu::Device device;
|
||||||
|
|
||||||
dawn::Buffer indexBuffer;
|
wgpu::Buffer indexBuffer;
|
||||||
dawn::Buffer vertexBuffer;
|
wgpu::Buffer vertexBuffer;
|
||||||
|
|
||||||
dawn::Texture texture;
|
wgpu::Texture texture;
|
||||||
dawn::Sampler sampler;
|
wgpu::Sampler sampler;
|
||||||
|
|
||||||
dawn::Queue queue;
|
wgpu::Queue queue;
|
||||||
dawn::SwapChain swapchain;
|
wgpu::SwapChain swapchain;
|
||||||
dawn::TextureView depthStencilView;
|
wgpu::TextureView depthStencilView;
|
||||||
dawn::RenderPipeline pipeline;
|
wgpu::RenderPipeline pipeline;
|
||||||
dawn::BindGroup bindGroup;
|
wgpu::BindGroup bindGroup;
|
||||||
|
|
||||||
void initBuffers() {
|
void initBuffers() {
|
||||||
static const uint32_t indexData[3] = {
|
static const uint32_t indexData[3] = {
|
||||||
0, 1, 2,
|
0, 1, 2,
|
||||||
};
|
};
|
||||||
indexBuffer =
|
indexBuffer =
|
||||||
utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsage::Index);
|
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
|
||||||
|
|
||||||
static const float vertexData[12] = {
|
static const float vertexData[12] = {
|
||||||
0.0f, 0.5f, 0.0f, 1.0f,
|
0.0f, 0.5f, 0.0f, 1.0f,
|
||||||
|
@ -47,23 +47,23 @@ void initBuffers() {
|
||||||
0.5f, -0.5f, 0.0f, 1.0f,
|
0.5f, -0.5f, 0.0f, 1.0f,
|
||||||
};
|
};
|
||||||
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
||||||
dawn::BufferUsage::Vertex);
|
wgpu::BufferUsage::Vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initTextures() {
|
void initTextures() {
|
||||||
dawn::TextureDescriptor descriptor;
|
wgpu::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||||
descriptor.size.width = 1024;
|
descriptor.size.width = 1024;
|
||||||
descriptor.size.height = 1024;
|
descriptor.size.height = 1024;
|
||||||
descriptor.size.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsage::CopyDst | dawn::TextureUsage::Sampled;
|
descriptor.usage = wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Sampled;
|
||||||
texture = device.CreateTexture(&descriptor);
|
texture = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
wgpu::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
|
||||||
sampler = device.CreateSampler(&samplerDesc);
|
sampler = device.CreateSampler(&samplerDesc);
|
||||||
|
|
||||||
// Initialize the texture with arbitrary data until we can load images
|
// Initialize the texture with arbitrary data until we can load images
|
||||||
|
@ -72,16 +72,16 @@ void initTextures() {
|
||||||
data[i] = static_cast<uint8_t>(i % 253);
|
data[i] = static_cast<uint8_t>(i % 253);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::Buffer stagingBuffer = utils::CreateBufferFromData(
|
wgpu::Buffer stagingBuffer = utils::CreateBufferFromData(
|
||||||
device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsage::CopySrc);
|
device, data.data(), static_cast<uint32_t>(data.size()), wgpu::BufferUsage::CopySrc);
|
||||||
dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
wgpu::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
|
||||||
dawn::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0});
|
||||||
dawn::Extent3D copySize = {1024, 1024, 1};
|
wgpu::Extent3D copySize = {1024, 1024, 1};
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
encoder.CopyBufferToTexture(&bufferCopyView, &textureCopyView, ©Size);
|
||||||
|
|
||||||
dawn::CommandBuffer copy = encoder.Finish();
|
wgpu::CommandBuffer copy = encoder.Finish();
|
||||||
queue.Submit(1, ©);
|
queue.Submit(1, ©);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), wgpu::TextureUsage::OutputAttachment,
|
||||||
640, 480);
|
640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
initTextures();
|
initTextures();
|
||||||
|
|
||||||
dawn::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(location = 0) in vec4 pos;
|
layout(location = 0) in vec4 pos;
|
||||||
|
@ -104,7 +104,7 @@ void init() {
|
||||||
gl_Position = pos;
|
gl_Position = pos;
|
||||||
})");
|
})");
|
||||||
|
|
||||||
dawn::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(set = 0, binding = 0) uniform sampler mySampler;
|
layout(set = 0, binding = 0) uniform sampler mySampler;
|
||||||
|
@ -117,11 +117,11 @@ void init() {
|
||||||
|
|
||||||
auto bgl = utils::MakeBindGroupLayout(
|
auto bgl = utils::MakeBindGroupLayout(
|
||||||
device, {
|
device, {
|
||||||
{0, dawn::ShaderStage::Fragment, dawn::BindingType::Sampler},
|
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler},
|
||||||
{1, dawn::ShaderStage::Fragment, dawn::BindingType::SampledTexture},
|
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture},
|
||||||
});
|
});
|
||||||
|
|
||||||
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
|
||||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||||
|
|
||||||
|
@ -132,14 +132,14 @@ void init() {
|
||||||
descriptor.cVertexInput.bufferCount = 1;
|
descriptor.cVertexInput.bufferCount = 1;
|
||||||
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
|
descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float);
|
||||||
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
|
descriptor.cVertexInput.cBuffers[0].attributeCount = 1;
|
||||||
descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4;
|
descriptor.cVertexInput.cAttributes[0].format = wgpu::VertexFormat::Float4;
|
||||||
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
||||||
descriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
|
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
|
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
dawn::TextureView view = texture.CreateView();
|
wgpu::TextureView view = texture.CreateView();
|
||||||
|
|
||||||
bindGroup = utils::MakeBindGroup(device, bgl, {
|
bindGroup = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, sampler},
|
{0, sampler},
|
||||||
|
@ -153,12 +153,12 @@ void frame() {
|
||||||
s.b += 0.02f;
|
s.b += 0.02f;
|
||||||
if (s.b >= 1.0f) {s.b = 0.0f;}
|
if (s.b >= 1.0f) {s.b = 0.0f;}
|
||||||
|
|
||||||
dawn::Texture backbuffer = swapchain.GetNextTexture();
|
wgpu::Texture backbuffer = swapchain.GetNextTexture();
|
||||||
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
{
|
{
|
||||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||||
pass.SetPipeline(pipeline);
|
pass.SetPipeline(pipeline);
|
||||||
pass.SetBindGroup(0, bindGroup);
|
pass.SetBindGroup(0, bindGroup);
|
||||||
pass.SetVertexBuffer(0, vertexBuffer);
|
pass.SetVertexBuffer(0, vertexBuffer);
|
||||||
|
@ -167,7 +167,7 @@ void frame() {
|
||||||
pass.EndPass();
|
pass.EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
wgpu::CommandBuffer commands = encoder.Finish();
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
swapchain.Present(backbuffer);
|
swapchain.Present(backbuffer);
|
||||||
DoFlush();
|
DoFlush();
|
||||||
|
|
|
@ -15,32 +15,32 @@
|
||||||
#include "SampleUtils.h"
|
#include "SampleUtils.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include <glm/gtc/type_ptr.hpp>
|
#include <glm/gtc/type_ptr.hpp>
|
||||||
|
|
||||||
dawn::Device device;
|
wgpu::Device device;
|
||||||
|
|
||||||
dawn::Buffer indexBuffer;
|
wgpu::Buffer indexBuffer;
|
||||||
dawn::Buffer vertexBuffer;
|
wgpu::Buffer vertexBuffer;
|
||||||
dawn::Buffer planeBuffer;
|
wgpu::Buffer planeBuffer;
|
||||||
dawn::Buffer cameraBuffer;
|
wgpu::Buffer cameraBuffer;
|
||||||
dawn::Buffer transformBuffer[2];
|
wgpu::Buffer transformBuffer[2];
|
||||||
|
|
||||||
dawn::BindGroup cameraBindGroup;
|
wgpu::BindGroup cameraBindGroup;
|
||||||
dawn::BindGroup bindGroup[2];
|
wgpu::BindGroup bindGroup[2];
|
||||||
dawn::BindGroup cubeTransformBindGroup[2];
|
wgpu::BindGroup cubeTransformBindGroup[2];
|
||||||
|
|
||||||
dawn::Queue queue;
|
wgpu::Queue queue;
|
||||||
dawn::SwapChain swapchain;
|
wgpu::SwapChain swapchain;
|
||||||
dawn::TextureView depthStencilView;
|
wgpu::TextureView depthStencilView;
|
||||||
dawn::RenderPipeline pipeline;
|
wgpu::RenderPipeline pipeline;
|
||||||
dawn::RenderPipeline planePipeline;
|
wgpu::RenderPipeline planePipeline;
|
||||||
dawn::RenderPipeline reflectionPipeline;
|
wgpu::RenderPipeline reflectionPipeline;
|
||||||
|
|
||||||
void initBuffers() {
|
void initBuffers() {
|
||||||
static const uint32_t indexData[6*6] = {
|
static const uint32_t indexData[6*6] = {
|
||||||
|
@ -63,7 +63,7 @@ void initBuffers() {
|
||||||
20, 22, 23
|
20, 22, 23
|
||||||
};
|
};
|
||||||
indexBuffer =
|
indexBuffer =
|
||||||
utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsage::Index);
|
utils::CreateBufferFromData(device, indexData, sizeof(indexData), wgpu::BufferUsage::Index);
|
||||||
|
|
||||||
static const float vertexData[6 * 4 * 6] = {
|
static const float vertexData[6 * 4 * 6] = {
|
||||||
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
|
-1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
|
||||||
|
@ -97,7 +97,7 @@ void initBuffers() {
|
||||||
-1.0, 1.0, -1.0, 1.0, 1.0, 1.0
|
-1.0, 1.0, -1.0, 1.0, 1.0, 1.0
|
||||||
};
|
};
|
||||||
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData),
|
||||||
dawn::BufferUsage::Vertex);
|
wgpu::BufferUsage::Vertex);
|
||||||
|
|
||||||
static const float planeData[6 * 4] = {
|
static const float planeData[6 * 4] = {
|
||||||
-2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
|
-2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
|
||||||
|
@ -106,7 +106,7 @@ void initBuffers() {
|
||||||
-2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
-2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
|
||||||
};
|
};
|
||||||
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData),
|
planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData),
|
||||||
dawn::BufferUsage::Vertex);
|
wgpu::BufferUsage::Vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct CameraData {
|
struct CameraData {
|
||||||
|
@ -119,12 +119,12 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueue();
|
queue = device.CreateQueue();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(GetPreferredSwapChainTextureFormat(), dawn::TextureUsage::OutputAttachment,
|
swapchain.Configure(GetPreferredSwapChainTextureFormat(), wgpu::TextureUsage::OutputAttachment,
|
||||||
640, 480);
|
640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
|
|
||||||
dawn::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(set = 0, binding = 0) uniform cameraData {
|
layout(set = 0, binding = 0) uniform cameraData {
|
||||||
|
@ -142,7 +142,7 @@ void init() {
|
||||||
gl_Position = camera.proj * camera.view * modelMatrix * vec4(pos, 1.0);
|
gl_Position = camera.proj * camera.view * modelMatrix * vec4(pos, 1.0);
|
||||||
})");
|
})");
|
||||||
|
|
||||||
dawn::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(location = 2) in vec3 f_col;
|
layout(location = 2) in vec3 f_col;
|
||||||
|
@ -151,7 +151,7 @@ void init() {
|
||||||
fragColor = vec4(f_col, 1.0);
|
fragColor = vec4(f_col, 1.0);
|
||||||
})");
|
})");
|
||||||
|
|
||||||
dawn::ShaderModule fsReflectionModule =
|
wgpu::ShaderModule fsReflectionModule =
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
||||||
#version 450
|
#version 450
|
||||||
layout(location = 2) in vec3 f_col;
|
layout(location = 2) in vec3 f_col;
|
||||||
|
@ -162,34 +162,34 @@ void init() {
|
||||||
|
|
||||||
utils::ComboVertexInputDescriptor vertexInput;
|
utils::ComboVertexInputDescriptor vertexInput;
|
||||||
vertexInput.cBuffers[0].attributeCount = 2;
|
vertexInput.cBuffers[0].attributeCount = 2;
|
||||||
vertexInput.cAttributes[0].format = dawn::VertexFormat::Float3;
|
vertexInput.cAttributes[0].format = wgpu::VertexFormat::Float3;
|
||||||
vertexInput.cAttributes[1].shaderLocation = 1;
|
vertexInput.cAttributes[1].shaderLocation = 1;
|
||||||
vertexInput.cAttributes[1].offset = 3 * sizeof(float);
|
vertexInput.cAttributes[1].offset = 3 * sizeof(float);
|
||||||
vertexInput.cAttributes[1].format = dawn::VertexFormat::Float3;
|
vertexInput.cAttributes[1].format = wgpu::VertexFormat::Float3;
|
||||||
|
|
||||||
vertexInput.bufferCount = 1;
|
vertexInput.bufferCount = 1;
|
||||||
vertexInput.cBuffers[0].stride = 6 * sizeof(float);
|
vertexInput.cBuffers[0].stride = 6 * sizeof(float);
|
||||||
|
|
||||||
auto bgl = utils::MakeBindGroupLayout(
|
auto bgl = utils::MakeBindGroupLayout(
|
||||||
device, {
|
device, {
|
||||||
{0, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer},
|
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
|
||||||
{1, dawn::ShaderStage::Vertex, dawn::BindingType::UniformBuffer},
|
{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
|
||||||
});
|
});
|
||||||
|
|
||||||
dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
|
||||||
dawn::BufferDescriptor cameraBufDesc;
|
wgpu::BufferDescriptor cameraBufDesc;
|
||||||
cameraBufDesc.size = sizeof(CameraData);
|
cameraBufDesc.size = sizeof(CameraData);
|
||||||
cameraBufDesc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::Uniform;
|
cameraBufDesc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Uniform;
|
||||||
cameraBuffer = device.CreateBuffer(&cameraBufDesc);
|
cameraBuffer = device.CreateBuffer(&cameraBufDesc);
|
||||||
|
|
||||||
glm::mat4 transform(1.0);
|
glm::mat4 transform(1.0);
|
||||||
transformBuffer[0] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
transformBuffer[0] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
||||||
dawn::BufferUsage::Uniform);
|
wgpu::BufferUsage::Uniform);
|
||||||
|
|
||||||
transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
|
transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
|
||||||
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4),
|
||||||
dawn::BufferUsage::Uniform);
|
wgpu::BufferUsage::Uniform);
|
||||||
|
|
||||||
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
bindGroup[0] = utils::MakeBindGroup(device, bgl, {
|
||||||
{0, cameraBuffer, 0, sizeof(CameraData)},
|
{0, cameraBuffer, 0, sizeof(CameraData)},
|
||||||
|
@ -209,10 +209,10 @@ void init() {
|
||||||
descriptor.cFragmentStage.module = fsModule;
|
descriptor.cFragmentStage.module = fsModule;
|
||||||
descriptor.vertexInput = &vertexInput;
|
descriptor.vertexInput = &vertexInput;
|
||||||
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
||||||
descriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
|
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
descriptor.cDepthStencilState.depthWriteEnabled = true;
|
descriptor.cDepthStencilState.depthWriteEnabled = true;
|
||||||
descriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less;
|
descriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
||||||
|
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline(&descriptor);
|
||||||
|
|
||||||
|
@ -222,11 +222,11 @@ void init() {
|
||||||
pDescriptor.cFragmentStage.module = fsModule;
|
pDescriptor.cFragmentStage.module = fsModule;
|
||||||
pDescriptor.vertexInput = &vertexInput;
|
pDescriptor.vertexInput = &vertexInput;
|
||||||
pDescriptor.depthStencilState = &pDescriptor.cDepthStencilState;
|
pDescriptor.depthStencilState = &pDescriptor.cDepthStencilState;
|
||||||
pDescriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
|
pDescriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
pDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
pDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
pDescriptor.cDepthStencilState.stencilFront.passOp = dawn::StencilOperation::Replace;
|
pDescriptor.cDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Replace;
|
||||||
pDescriptor.cDepthStencilState.stencilBack.passOp = dawn::StencilOperation::Replace;
|
pDescriptor.cDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Replace;
|
||||||
pDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less;
|
pDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
||||||
|
|
||||||
planePipeline = device.CreateRenderPipeline(&pDescriptor);
|
planePipeline = device.CreateRenderPipeline(&pDescriptor);
|
||||||
|
|
||||||
|
@ -236,14 +236,14 @@ void init() {
|
||||||
rfDescriptor.cFragmentStage.module = fsReflectionModule;
|
rfDescriptor.cFragmentStage.module = fsReflectionModule;
|
||||||
rfDescriptor.vertexInput = &vertexInput;
|
rfDescriptor.vertexInput = &vertexInput;
|
||||||
rfDescriptor.depthStencilState = &rfDescriptor.cDepthStencilState;
|
rfDescriptor.depthStencilState = &rfDescriptor.cDepthStencilState;
|
||||||
rfDescriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
|
rfDescriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
rfDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
rfDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
rfDescriptor.cDepthStencilState.stencilFront.compare = dawn::CompareFunction::Equal;
|
rfDescriptor.cDepthStencilState.stencilFront.compare = wgpu::CompareFunction::Equal;
|
||||||
rfDescriptor.cDepthStencilState.stencilBack.compare = dawn::CompareFunction::Equal;
|
rfDescriptor.cDepthStencilState.stencilBack.compare = wgpu::CompareFunction::Equal;
|
||||||
rfDescriptor.cDepthStencilState.stencilFront.passOp = dawn::StencilOperation::Replace;
|
rfDescriptor.cDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Replace;
|
||||||
rfDescriptor.cDepthStencilState.stencilBack.passOp = dawn::StencilOperation::Replace;
|
rfDescriptor.cDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Replace;
|
||||||
rfDescriptor.cDepthStencilState.depthWriteEnabled = true;
|
rfDescriptor.cDepthStencilState.depthWriteEnabled = true;
|
||||||
rfDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less;
|
rfDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
||||||
|
|
||||||
reflectionPipeline = device.CreateRenderPipeline(&rfDescriptor);
|
reflectionPipeline = device.CreateRenderPipeline(&rfDescriptor);
|
||||||
|
|
||||||
|
@ -264,12 +264,12 @@ void frame() {
|
||||||
|
|
||||||
cameraBuffer.SetSubData(0, sizeof(CameraData), &cameraData);
|
cameraBuffer.SetSubData(0, sizeof(CameraData), &cameraData);
|
||||||
|
|
||||||
dawn::Texture backbuffer = swapchain.GetNextTexture();
|
wgpu::Texture backbuffer = swapchain.GetNextTexture();
|
||||||
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
utils::ComboRenderPassDescriptor renderPass({backbuffer.CreateView()}, depthStencilView);
|
||||||
|
|
||||||
dawn::CommandEncoder encoder = device.CreateCommandEncoder();
|
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||||
{
|
{
|
||||||
dawn::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass);
|
||||||
pass.SetPipeline(pipeline);
|
pass.SetPipeline(pipeline);
|
||||||
pass.SetBindGroup(0, bindGroup[0]);
|
pass.SetBindGroup(0, bindGroup[0]);
|
||||||
pass.SetVertexBuffer(0, vertexBuffer);
|
pass.SetVertexBuffer(0, vertexBuffer);
|
||||||
|
@ -290,7 +290,7 @@ void frame() {
|
||||||
pass.EndPass();
|
pass.EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::CommandBuffer commands = encoder.Finish();
|
wgpu::CommandBuffer commands = encoder.Finish();
|
||||||
queue.Submit(1, &commands);
|
queue.Submit(1, &commands);
|
||||||
swapchain.Present(backbuffer);
|
swapchain.Present(backbuffer);
|
||||||
DoFlush();
|
DoFlush();
|
||||||
|
|
|
@ -19,10 +19,8 @@
|
||||||
#include "utils/BackendBinding.h"
|
#include "utils/BackendBinding.h"
|
||||||
#include "utils/TerribleCommandBuffer.h"
|
#include "utils/TerribleCommandBuffer.h"
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
|
||||||
#include <dawn/dawn_proc.h>
|
#include <dawn/dawn_proc.h>
|
||||||
#include <dawn/dawn_wsi.h>
|
#include <dawn/dawn_wsi.h>
|
||||||
#include <dawn/dawncpp.h>
|
|
||||||
#include <dawn_native/DawnNative.h>
|
#include <dawn_native/DawnNative.h>
|
||||||
#include <dawn_wire/WireClient.h>
|
#include <dawn_wire/WireClient.h>
|
||||||
#include <dawn_wire/WireServer.h>
|
#include <dawn_wire/WireServer.h>
|
||||||
|
@ -32,18 +30,18 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void PrintDeviceError(DawnErrorType errorType, const char* message, void*) {
|
void PrintDeviceError(WGPUErrorType errorType, const char* message, void*) {
|
||||||
switch (errorType) {
|
switch (errorType) {
|
||||||
case DAWN_ERROR_TYPE_VALIDATION:
|
case WGPUErrorType_Validation:
|
||||||
std::cout << "Validation ";
|
std::cout << "Validation ";
|
||||||
break;
|
break;
|
||||||
case DAWN_ERROR_TYPE_OUT_OF_MEMORY:
|
case WGPUErrorType_OutOfMemory:
|
||||||
std::cout << "Out of memory ";
|
std::cout << "Out of memory ";
|
||||||
break;
|
break;
|
||||||
case DAWN_ERROR_TYPE_UNKNOWN:
|
case WGPUErrorType_Unknown:
|
||||||
std::cout << "Unknown ";
|
std::cout << "Unknown ";
|
||||||
break;
|
break;
|
||||||
case DAWN_ERROR_TYPE_DEVICE_LOST:
|
case WGPUErrorType_DeviceLost:
|
||||||
std::cout << "Device lost ";
|
std::cout << "Device lost ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -88,17 +86,17 @@ static dawn_wire::WireClient* wireClient = nullptr;
|
||||||
static utils::TerribleCommandBuffer* c2sBuf = nullptr;
|
static utils::TerribleCommandBuffer* c2sBuf = nullptr;
|
||||||
static utils::TerribleCommandBuffer* s2cBuf = nullptr;
|
static utils::TerribleCommandBuffer* s2cBuf = nullptr;
|
||||||
|
|
||||||
dawn::Device CreateCppDawnDevice() {
|
wgpu::Device CreateCppDawnDevice() {
|
||||||
glfwSetErrorCallback(PrintGLFWError);
|
glfwSetErrorCallback(PrintGLFWError);
|
||||||
if (!glfwInit()) {
|
if (!glfwInit()) {
|
||||||
return dawn::Device();
|
return wgpu::Device();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the test window and discover adapters using it (esp. for OpenGL)
|
// Create the test window and discover adapters using it (esp. for OpenGL)
|
||||||
utils::SetupGLFWWindowHintsForBackend(backendType);
|
utils::SetupGLFWWindowHintsForBackend(backendType);
|
||||||
window = glfwCreateWindow(640, 480, "Dawn window", nullptr, nullptr);
|
window = glfwCreateWindow(640, 480, "Dawn window", nullptr, nullptr);
|
||||||
if (!window) {
|
if (!window) {
|
||||||
return dawn::Device();
|
return wgpu::Device();
|
||||||
}
|
}
|
||||||
|
|
||||||
instance = std::make_unique<dawn_native::Instance>();
|
instance = std::make_unique<dawn_native::Instance>();
|
||||||
|
@ -116,16 +114,16 @@ dawn::Device CreateCppDawnDevice() {
|
||||||
backendAdapter = *adapterIt;
|
backendAdapter = *adapterIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnDevice backendDevice = backendAdapter.CreateDevice();
|
WGPUDevice backendDevice = backendAdapter.CreateDevice();
|
||||||
DawnProcTable backendProcs = dawn_native::GetProcs();
|
DawnProcTable backendProcs = dawn_native::GetProcs();
|
||||||
|
|
||||||
binding = utils::CreateBinding(backendType, window, backendDevice);
|
binding = utils::CreateBinding(backendType, window, backendDevice);
|
||||||
if (binding == nullptr) {
|
if (binding == nullptr) {
|
||||||
return dawn::Device();
|
return wgpu::Device();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
// Choose whether to use the backend procs and devices directly, or set up the wire.
|
||||||
DawnDevice cDevice = nullptr;
|
WGPUDevice cDevice = nullptr;
|
||||||
DawnProcTable procs;
|
DawnProcTable procs;
|
||||||
|
|
||||||
switch (cmdBufType) {
|
switch (cmdBufType) {
|
||||||
|
@ -151,7 +149,7 @@ dawn::Device CreateCppDawnDevice() {
|
||||||
clientDesc.serializer = c2sBuf;
|
clientDesc.serializer = c2sBuf;
|
||||||
|
|
||||||
wireClient = new dawn_wire::WireClient(clientDesc);
|
wireClient = new dawn_wire::WireClient(clientDesc);
|
||||||
DawnDevice clientDevice = wireClient->GetDevice();
|
WGPUDevice clientDevice = wireClient->GetDevice();
|
||||||
DawnProcTable clientProcs = wireClient->GetProcs();
|
DawnProcTable clientProcs = wireClient->GetProcs();
|
||||||
s2cBuf->SetHandler(wireClient);
|
s2cBuf->SetHandler(wireClient);
|
||||||
|
|
||||||
|
@ -163,35 +161,35 @@ dawn::Device CreateCppDawnDevice() {
|
||||||
|
|
||||||
dawnProcSetProcs(&procs);
|
dawnProcSetProcs(&procs);
|
||||||
procs.deviceSetUncapturedErrorCallback(cDevice, PrintDeviceError, nullptr);
|
procs.deviceSetUncapturedErrorCallback(cDevice, PrintDeviceError, nullptr);
|
||||||
return dawn::Device::Acquire(cDevice);
|
return wgpu::Device::Acquire(cDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetSwapChainImplementation() {
|
uint64_t GetSwapChainImplementation() {
|
||||||
return binding->GetSwapChainImplementation();
|
return binding->GetSwapChainImplementation();
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::TextureFormat GetPreferredSwapChainTextureFormat() {
|
wgpu::TextureFormat GetPreferredSwapChainTextureFormat() {
|
||||||
DoFlush();
|
DoFlush();
|
||||||
return static_cast<dawn::TextureFormat>(binding->GetPreferredSwapChainTextureFormat());
|
return static_cast<wgpu::TextureFormat>(binding->GetPreferredSwapChainTextureFormat());
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::SwapChain GetSwapChain(const dawn::Device &device) {
|
wgpu::SwapChain GetSwapChain(const wgpu::Device& device) {
|
||||||
dawn::SwapChainDescriptor swapChainDesc;
|
wgpu::SwapChainDescriptor swapChainDesc;
|
||||||
swapChainDesc.implementation = GetSwapChainImplementation();
|
swapChainDesc.implementation = GetSwapChainImplementation();
|
||||||
return device.CreateSwapChain(&swapChainDesc);
|
return device.CreateSwapChain(&swapChainDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
|
wgpu::TextureView CreateDefaultDepthStencilView(const wgpu::Device& device) {
|
||||||
dawn::TextureDescriptor descriptor;
|
wgpu::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||||
descriptor.size.width = 640;
|
descriptor.size.width = 640;
|
||||||
descriptor.size.height = 480;
|
descriptor.size.height = 480;
|
||||||
descriptor.size.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = dawn::TextureFormat::Depth24PlusStencil8;
|
descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsage::OutputAttachment;
|
descriptor.usage = wgpu::TextureUsage::OutputAttachment;
|
||||||
auto depthStencilTexture = device.CreateTexture(&descriptor);
|
auto depthStencilTexture = device.CreateTexture(&descriptor);
|
||||||
return depthStencilTexture.CreateView();
|
return depthStencilTexture.CreateView();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include <dawn/dawncpp.h>
|
|
||||||
#include <dawn/dawn_wsi.h>
|
#include <dawn/dawn_wsi.h>
|
||||||
|
#include <dawn/webgpu_cpp.h>
|
||||||
|
|
||||||
bool InitSample(int argc, const char** argv);
|
bool InitSample(int argc, const char** argv);
|
||||||
void DoFlush();
|
void DoFlush();
|
||||||
|
@ -22,8 +22,8 @@ bool ShouldQuit();
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
struct GLFWwindow* GetGLFWWindow();
|
struct GLFWwindow* GetGLFWWindow();
|
||||||
|
|
||||||
dawn::Device CreateCppDawnDevice();
|
wgpu::Device CreateCppDawnDevice();
|
||||||
uint64_t GetSwapChainImplementation();
|
uint64_t GetSwapChainImplementation();
|
||||||
dawn::TextureFormat GetPreferredSwapChainTextureFormat();
|
wgpu::TextureFormat GetPreferredSwapChainTextureFormat();
|
||||||
dawn::SwapChain GetSwapChain(const dawn::Device& device);
|
wgpu::SwapChain GetSwapChain(const wgpu::Device& device);
|
||||||
dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device);
|
wgpu::TextureView CreateDefaultDepthStencilView(const wgpu::Device& device);
|
||||||
|
|
|
@ -22,9 +22,9 @@
|
||||||
#include "dawn_native/DawnNative.h"
|
#include "dawn_native/DawnNative.h"
|
||||||
#include "dawn_wire/WireClient.h"
|
#include "dawn_wire/WireClient.h"
|
||||||
#include "dawn_wire/WireServer.h"
|
#include "dawn_wire/WireServer.h"
|
||||||
#include "utils/DawnHelpers.h"
|
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
#include "utils/TerribleCommandBuffer.h"
|
#include "utils/TerribleCommandBuffer.h"
|
||||||
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class BasicTests : public DawnTest {
|
class BasicTests : public DawnTest {
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr static unsigned int kRTSize = 8;
|
constexpr static unsigned int kRTSize = 8;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ClipSpaceTest : public DawnTest {
|
class ClipSpaceTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr static unsigned int kRTSize = 64;
|
constexpr static unsigned int kRTSize = 64;
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
// The helper struct to configure the copies between buffers and textures.
|
// The helper struct to configure the copies between buffers and textures.
|
||||||
struct CopyConfig {
|
struct CopyConfig {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "dawn/dawncpp.h"
|
#include "dawn/dawncpp.h"
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ComputeStorageBufferBarrierTests : public DawnTest {
|
class ComputeStorageBufferBarrierTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <array>
|
#include <array>
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class CopyTests : public DawnTest {
|
class CopyTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class CullingTest : public DawnTest {
|
class CullingTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include "dawn_native/D3D12Backend.h"
|
#include "dawn_native/D3D12Backend.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class DebugMarkerTests : public DawnTest {};
|
class DebugMarkerTests : public DawnTest {};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr static unsigned int kRTSize = 64;
|
constexpr static unsigned int kRTSize = 64;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 4;
|
constexpr uint32_t kRTSize = 4;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 4;
|
constexpr uint32_t kRTSize = 4;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 4;
|
constexpr uint32_t kRTSize = 4;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 4;
|
constexpr uint32_t kRTSize = 4;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 4;
|
constexpr uint32_t kRTSize = 4;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 400;
|
constexpr uint32_t kRTSize = 400;
|
||||||
constexpr uint32_t kBufferElementsCount = kMinDynamicBufferOffsetAlignment / sizeof(uint32_t) + 2;
|
constexpr uint32_t kBufferElementsCount = kMinDynamicBufferOffsetAlignment / sizeof(uint32_t) + 2;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "dawn_native/MetalBackend.h"
|
#include "dawn_native/MetalBackend.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <IOSurface/IOSurface.h>
|
#include <IOSurface/IOSurface.h>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 400;
|
constexpr uint32_t kRTSize = 400;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class MultisampledRenderingTest : public DawnTest {
|
class MultisampledRenderingTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class NonzeroTextureCreationTests : public DawnTest {
|
class NonzeroTextureCreationTests : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ObjectCachingTest : public DawnTest {};
|
class ObjectCachingTest : public DawnTest {};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class OpArrayLengthTest : public DawnTest {
|
class OpArrayLengthTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.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:
|
// Primitive topology tests work by drawing the following vertices with all the different primitive topology states:
|
||||||
// -------------------------------------
|
// -------------------------------------
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 4;
|
constexpr uint32_t kRTSize = 4;
|
||||||
constexpr RGBA8 kColors[2] = {RGBA8(0, 255, 0, 255), RGBA8(0, 0, 255, 255)};
|
constexpr RGBA8 kColors[2] = {RGBA8(0, 255, 0, 255), RGBA8(0, 0, 255, 255)};
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr uint32_t kRTSize = 16;
|
constexpr uint32_t kRTSize = 16;
|
||||||
constexpr dawn::TextureFormat kFormat = dawn::TextureFormat::RGBA8Unorm;
|
constexpr dawn::TextureFormat kFormat = dawn::TextureFormat::RGBA8Unorm;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
constexpr static unsigned int kRTSize = 64;
|
constexpr static unsigned int kRTSize = 64;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ScissorTest: public DawnTest {
|
class ScissorTest: public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class TextureZeroInitTest : public DawnTest {
|
class TextureZeroInitTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.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.
|
// 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
|
// Each test will set up a vertex buffer, and the vertex shader will check that
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
using dawn::InputStepMode;
|
using dawn::InputStepMode;
|
||||||
using dawn::VertexFormat;
|
using dawn::VertexFormat;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ViewportOrientationTests : public DawnTest {};
|
class ViewportOrientationTests : public DawnTest {};
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/DawnTest.h"
|
#include "tests/DawnTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ViewportTest : public DawnTest {
|
class ViewportTest : public DawnTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/perf_tests/DawnPerfTest.h"
|
#include "tests/perf_tests/DawnPerfTest.h"
|
||||||
|
|
||||||
#include "tests/ParamGenerator.h"
|
#include "tests/ParamGenerator.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class BindGroupValidationTest : public ValidationTest {
|
class BindGroupValidationTest : public ValidationTest {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class CommandBufferValidationTest : public ValidationTest {
|
class CommandBufferValidationTest : public ValidationTest {
|
||||||
};
|
};
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ComputeIndirectValidationTest : public ValidationTest {
|
class ComputeIndirectValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class ComputePassValidationTest : public ValidationTest {};
|
class ComputePassValidationTest : public ValidationTest {};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "common/Math.h"
|
#include "common/Math.h"
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class CopyCommandTest : public ValidationTest {
|
class CopyCommandTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class DebugMarkerValidationTest : public ValidationTest {};
|
class DebugMarkerValidationTest : public ValidationTest {};
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class DrawIndirectValidationTest : public ValidationTest {
|
class DrawIndirectValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class VertexBufferValidationTest : public ValidationTest {
|
class VertexBufferValidationTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "tests/unittests/validation/ValidationTest.h"
|
#include "tests/unittests/validation/ValidationTest.h"
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
class VertexInputTest : public ValidationTest {
|
class VertexInputTest : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include "dawn_native/vulkan/FencedDeleter.h"
|
#include "dawn_native/vulkan/FencedDeleter.h"
|
||||||
#include "dawn_native/vulkan/ResourceMemoryAllocatorVk.h"
|
#include "dawn_native/vulkan/ResourceMemoryAllocatorVk.h"
|
||||||
#include "dawn_native/vulkan/TextureVk.h"
|
#include "dawn_native/vulkan/TextureVk.h"
|
||||||
#include "utils/DawnHelpers.h"
|
|
||||||
#include "utils/SystemUtils.h"
|
#include "utils/SystemUtils.h"
|
||||||
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
// TODO(crbug.com/966500): Intel is disabled until upgrade is finished
|
// TODO(crbug.com/966500): Intel is disabled until upgrade is finished
|
||||||
|
|
||||||
|
|
|
@ -25,22 +25,22 @@
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
BackendBinding* CreateD3D12Binding(GLFWwindow* window, DawnDevice device);
|
BackendBinding* CreateD3D12Binding(GLFWwindow* window, WGPUDevice device);
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
#if defined(DAWN_ENABLE_BACKEND_METAL)
|
||||||
BackendBinding* CreateMetalBinding(GLFWwindow* window, DawnDevice device);
|
BackendBinding* CreateMetalBinding(GLFWwindow* window, WGPUDevice device);
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
#if defined(DAWN_ENABLE_BACKEND_NULL)
|
||||||
BackendBinding* CreateNullBinding(GLFWwindow* window, DawnDevice device);
|
BackendBinding* CreateNullBinding(GLFWwindow* window, WGPUDevice device);
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
#if defined(DAWN_ENABLE_BACKEND_OPENGL)
|
||||||
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, DawnDevice device);
|
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, WGPUDevice device);
|
||||||
#endif
|
#endif
|
||||||
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
#if defined(DAWN_ENABLE_BACKEND_VULKAN)
|
||||||
BackendBinding* CreateVulkanBinding(GLFWwindow* window, DawnDevice device);
|
BackendBinding* CreateVulkanBinding(GLFWwindow* window, WGPUDevice device);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BackendBinding::BackendBinding(GLFWwindow* window, DawnDevice device)
|
BackendBinding::BackendBinding(GLFWwindow* window, WGPUDevice device)
|
||||||
: mWindow(window), mDevice(device) {
|
: mWindow(window), mDevice(device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ namespace utils {
|
||||||
|
|
||||||
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
||||||
GLFWwindow* window,
|
GLFWwindow* window,
|
||||||
DawnDevice device) {
|
WGPUDevice device) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||||
case dawn_native::BackendType::D3D12:
|
case dawn_native::BackendType::D3D12:
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef UTILS_BACKENDBINDING_H_
|
#ifndef UTILS_BACKENDBINDING_H_
|
||||||
#define UTILS_BACKENDBINDING_H_
|
#define UTILS_BACKENDBINDING_H_
|
||||||
|
|
||||||
#include "dawn/dawn.h"
|
#include "dawn/webgpu.h"
|
||||||
#include "dawn_native/DawnNative.h"
|
#include "dawn_native/DawnNative.h"
|
||||||
|
|
||||||
struct GLFWwindow;
|
struct GLFWwindow;
|
||||||
|
@ -27,13 +27,13 @@ namespace utils {
|
||||||
virtual ~BackendBinding() = default;
|
virtual ~BackendBinding() = default;
|
||||||
|
|
||||||
virtual uint64_t GetSwapChainImplementation() = 0;
|
virtual uint64_t GetSwapChainImplementation() = 0;
|
||||||
virtual DawnTextureFormat GetPreferredSwapChainTextureFormat() = 0;
|
virtual WGPUTextureFormat GetPreferredSwapChainTextureFormat() = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BackendBinding(GLFWwindow* window, DawnDevice device);
|
BackendBinding(GLFWwindow* window, WGPUDevice device);
|
||||||
|
|
||||||
GLFWwindow* mWindow = nullptr;
|
GLFWwindow* mWindow = nullptr;
|
||||||
DawnDevice mDevice = nullptr;
|
WGPUDevice mDevice = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetupGLFWWindowHintsForBackend(dawn_native::BackendType type);
|
void SetupGLFWWindowHintsForBackend(dawn_native::BackendType type);
|
||||||
|
@ -42,7 +42,7 @@ namespace utils {
|
||||||
dawn_native::BackendType type);
|
dawn_native::BackendType type);
|
||||||
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
BackendBinding* CreateBinding(dawn_native::BackendType type,
|
||||||
GLFWwindow* window,
|
GLFWwindow* window,
|
||||||
DawnDevice device);
|
WGPUDevice device);
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,12 @@
|
||||||
|
|
||||||
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
#include "utils/ComboRenderBundleEncoderDescriptor.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
ComboRenderBundleEncoderDescriptor::ComboRenderBundleEncoderDescriptor() {
|
ComboRenderBundleEncoderDescriptor::ComboRenderBundleEncoderDescriptor() {
|
||||||
dawn::RenderBundleEncoderDescriptor* descriptor = this;
|
wgpu::RenderBundleEncoderDescriptor* descriptor = this;
|
||||||
|
|
||||||
descriptor->colorFormatsCount = 0;
|
descriptor->colorFormatsCount = 0;
|
||||||
descriptor->colorFormats = &cColorFormats[0];
|
descriptor->colorFormats = &cColorFormats[0];
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef UTILS_COMBORENDERBUNDLEENCODERDESCRIPTOR_H_
|
#ifndef UTILS_COMBORENDERBUNDLEENCODERDESCRIPTOR_H_
|
||||||
#define UTILS_COMBORENDERBUNDLEENCODERDESCRIPTOR_H_
|
#define UTILS_COMBORENDERBUNDLEENCODERDESCRIPTOR_H_
|
||||||
|
|
||||||
#include <dawn/dawncpp.h>
|
#include <dawn/webgpu_cpp.h>
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
|
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
class ComboRenderBundleEncoderDescriptor : public dawn::RenderBundleEncoderDescriptor {
|
class ComboRenderBundleEncoderDescriptor : public wgpu::RenderBundleEncoderDescriptor {
|
||||||
public:
|
public:
|
||||||
ComboRenderBundleEncoderDescriptor();
|
ComboRenderBundleEncoderDescriptor();
|
||||||
|
|
||||||
std::array<dawn::TextureFormat, kMaxColorAttachments> cColorFormats;
|
std::array<wgpu::TextureFormat, kMaxColorAttachments> cColorFormats;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
|
@ -14,27 +14,27 @@
|
||||||
|
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
ComboVertexInputDescriptor::ComboVertexInputDescriptor() {
|
ComboVertexInputDescriptor::ComboVertexInputDescriptor() {
|
||||||
dawn::VertexInputDescriptor* descriptor = this;
|
wgpu::VertexInputDescriptor* descriptor = this;
|
||||||
|
|
||||||
descriptor->indexFormat = dawn::IndexFormat::Uint32;
|
descriptor->indexFormat = wgpu::IndexFormat::Uint32;
|
||||||
descriptor->bufferCount = 0;
|
descriptor->bufferCount = 0;
|
||||||
|
|
||||||
// Fill the default values for vertexBuffers and vertexAttributes in buffers.
|
// Fill the default values for vertexBuffers and vertexAttributes in buffers.
|
||||||
dawn::VertexAttributeDescriptor vertexAttribute;
|
wgpu::VertexAttributeDescriptor vertexAttribute;
|
||||||
vertexAttribute.shaderLocation = 0;
|
vertexAttribute.shaderLocation = 0;
|
||||||
vertexAttribute.offset = 0;
|
vertexAttribute.offset = 0;
|
||||||
vertexAttribute.format = dawn::VertexFormat::Float;
|
vertexAttribute.format = wgpu::VertexFormat::Float;
|
||||||
for (uint32_t i = 0; i < kMaxVertexAttributes; ++i) {
|
for (uint32_t i = 0; i < kMaxVertexAttributes; ++i) {
|
||||||
cAttributes[i] = vertexAttribute;
|
cAttributes[i] = vertexAttribute;
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
|
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
|
||||||
cBuffers[i].stride = 0;
|
cBuffers[i].stride = 0;
|
||||||
cBuffers[i].stepMode = dawn::InputStepMode::Vertex;
|
cBuffers[i].stepMode = wgpu::InputStepMode::Vertex;
|
||||||
cBuffers[i].attributeCount = 0;
|
cBuffers[i].attributeCount = 0;
|
||||||
cBuffers[i].attributes = nullptr;
|
cBuffers[i].attributes = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,10 @@ namespace utils {
|
||||||
descriptor->buffers = &cBuffers[0];
|
descriptor->buffers = &cBuffers[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboRenderPipelineDescriptor::ComboRenderPipelineDescriptor(const dawn::Device& device) {
|
ComboRenderPipelineDescriptor::ComboRenderPipelineDescriptor(const wgpu::Device& device) {
|
||||||
dawn::RenderPipelineDescriptor* descriptor = this;
|
wgpu::RenderPipelineDescriptor* descriptor = this;
|
||||||
|
|
||||||
descriptor->primitiveTopology = dawn::PrimitiveTopology::TriangleList;
|
descriptor->primitiveTopology = wgpu::PrimitiveTopology::TriangleList;
|
||||||
descriptor->sampleCount = 1;
|
descriptor->sampleCount = 1;
|
||||||
|
|
||||||
// Set defaults for the vertex stage descriptor.
|
// Set defaults for the vertex stage descriptor.
|
||||||
|
@ -66,8 +66,8 @@ namespace utils {
|
||||||
|
|
||||||
// Set defaults for the rasterization state descriptor.
|
// Set defaults for the rasterization state descriptor.
|
||||||
{
|
{
|
||||||
cRasterizationState.frontFace = dawn::FrontFace::CCW;
|
cRasterizationState.frontFace = wgpu::FrontFace::CCW;
|
||||||
cRasterizationState.cullMode = dawn::CullMode::None;
|
cRasterizationState.cullMode = wgpu::CullMode::None;
|
||||||
|
|
||||||
cRasterizationState.depthBias = 0;
|
cRasterizationState.depthBias = 0;
|
||||||
cRasterizationState.depthBiasSlopeScale = 0.0;
|
cRasterizationState.depthBiasSlopeScale = 0.0;
|
||||||
|
@ -80,15 +80,15 @@ namespace utils {
|
||||||
descriptor->colorStateCount = 1;
|
descriptor->colorStateCount = 1;
|
||||||
descriptor->colorStates = cColorStates.data();
|
descriptor->colorStates = cColorStates.data();
|
||||||
|
|
||||||
dawn::BlendDescriptor blend;
|
wgpu::BlendDescriptor blend;
|
||||||
blend.operation = dawn::BlendOperation::Add;
|
blend.operation = wgpu::BlendOperation::Add;
|
||||||
blend.srcFactor = dawn::BlendFactor::One;
|
blend.srcFactor = wgpu::BlendFactor::One;
|
||||||
blend.dstFactor = dawn::BlendFactor::Zero;
|
blend.dstFactor = wgpu::BlendFactor::Zero;
|
||||||
dawn::ColorStateDescriptor colorStateDescriptor;
|
wgpu::ColorStateDescriptor colorStateDescriptor;
|
||||||
colorStateDescriptor.format = dawn::TextureFormat::RGBA8Unorm;
|
colorStateDescriptor.format = wgpu::TextureFormat::RGBA8Unorm;
|
||||||
colorStateDescriptor.alphaBlend = blend;
|
colorStateDescriptor.alphaBlend = blend;
|
||||||
colorStateDescriptor.colorBlend = blend;
|
colorStateDescriptor.colorBlend = blend;
|
||||||
colorStateDescriptor.writeMask = dawn::ColorWriteMask::All;
|
colorStateDescriptor.writeMask = wgpu::ColorWriteMask::All;
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
||||||
cColorStates[i] = colorStateDescriptor;
|
cColorStates[i] = colorStateDescriptor;
|
||||||
}
|
}
|
||||||
|
@ -96,15 +96,15 @@ namespace utils {
|
||||||
|
|
||||||
// Set defaults for the depth stencil state descriptors.
|
// Set defaults for the depth stencil state descriptors.
|
||||||
{
|
{
|
||||||
dawn::StencilStateFaceDescriptor stencilFace;
|
wgpu::StencilStateFaceDescriptor stencilFace;
|
||||||
stencilFace.compare = dawn::CompareFunction::Always;
|
stencilFace.compare = wgpu::CompareFunction::Always;
|
||||||
stencilFace.failOp = dawn::StencilOperation::Keep;
|
stencilFace.failOp = wgpu::StencilOperation::Keep;
|
||||||
stencilFace.depthFailOp = dawn::StencilOperation::Keep;
|
stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
|
||||||
stencilFace.passOp = dawn::StencilOperation::Keep;
|
stencilFace.passOp = wgpu::StencilOperation::Keep;
|
||||||
|
|
||||||
cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
|
cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
||||||
cDepthStencilState.depthWriteEnabled = false;
|
cDepthStencilState.depthWriteEnabled = false;
|
||||||
cDepthStencilState.depthCompare = dawn::CompareFunction::Always;
|
cDepthStencilState.depthCompare = wgpu::CompareFunction::Always;
|
||||||
cDepthStencilState.stencilBack = stencilFace;
|
cDepthStencilState.stencilBack = stencilFace;
|
||||||
cDepthStencilState.stencilFront = stencilFace;
|
cDepthStencilState.stencilFront = stencilFace;
|
||||||
cDepthStencilState.stencilReadMask = 0xff;
|
cDepthStencilState.stencilReadMask = 0xff;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
|
#ifndef UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
|
||||||
#define UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
|
#define UTILS_COMBORENDERPIPELINEDESCRIPTOR_H_
|
||||||
|
|
||||||
#include <dawn/dawncpp.h>
|
#include <dawn/webgpu_cpp.h>
|
||||||
|
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
|
|
||||||
|
@ -23,29 +23,29 @@
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
class ComboVertexInputDescriptor : public dawn::VertexInputDescriptor {
|
class ComboVertexInputDescriptor : public wgpu::VertexInputDescriptor {
|
||||||
public:
|
public:
|
||||||
ComboVertexInputDescriptor();
|
ComboVertexInputDescriptor();
|
||||||
|
|
||||||
std::array<dawn::VertexBufferDescriptor, kMaxVertexBuffers> cBuffers;
|
std::array<wgpu::VertexBufferDescriptor, kMaxVertexBuffers> cBuffers;
|
||||||
std::array<dawn::VertexAttributeDescriptor, kMaxVertexAttributes> cAttributes;
|
std::array<wgpu::VertexAttributeDescriptor, kMaxVertexAttributes> cAttributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ComboRenderPipelineDescriptor : public dawn::RenderPipelineDescriptor {
|
class ComboRenderPipelineDescriptor : public wgpu::RenderPipelineDescriptor {
|
||||||
public:
|
public:
|
||||||
ComboRenderPipelineDescriptor(const dawn::Device& device);
|
ComboRenderPipelineDescriptor(const wgpu::Device& device);
|
||||||
|
|
||||||
ComboRenderPipelineDescriptor(const ComboRenderPipelineDescriptor&) = delete;
|
ComboRenderPipelineDescriptor(const ComboRenderPipelineDescriptor&) = delete;
|
||||||
ComboRenderPipelineDescriptor& operator=(const ComboRenderPipelineDescriptor&) = delete;
|
ComboRenderPipelineDescriptor& operator=(const ComboRenderPipelineDescriptor&) = delete;
|
||||||
ComboRenderPipelineDescriptor(ComboRenderPipelineDescriptor&&) = delete;
|
ComboRenderPipelineDescriptor(ComboRenderPipelineDescriptor&&) = delete;
|
||||||
ComboRenderPipelineDescriptor& operator=(ComboRenderPipelineDescriptor&&) = delete;
|
ComboRenderPipelineDescriptor& operator=(ComboRenderPipelineDescriptor&&) = delete;
|
||||||
|
|
||||||
dawn::ProgrammableStageDescriptor cFragmentStage;
|
wgpu::ProgrammableStageDescriptor cFragmentStage;
|
||||||
|
|
||||||
ComboVertexInputDescriptor cVertexInput;
|
ComboVertexInputDescriptor cVertexInput;
|
||||||
dawn::RasterizationStateDescriptor cRasterizationState;
|
wgpu::RasterizationStateDescriptor cRasterizationState;
|
||||||
std::array<dawn::ColorStateDescriptor, kMaxColorAttachments> cColorStates;
|
std::array<wgpu::ColorStateDescriptor, kMaxColorAttachments> cColorStates;
|
||||||
dawn::DepthStencilStateDescriptor cDepthStencilState;
|
wgpu::DepthStencilStateDescriptor cDepthStencilState;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace utils {
|
||||||
|
|
||||||
class D3D12Binding : public BackendBinding {
|
class D3D12Binding : public BackendBinding {
|
||||||
public:
|
public:
|
||||||
D3D12Binding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
D3D12Binding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetSwapChainImplementation() override {
|
uint64_t GetSwapChainImplementation() override {
|
||||||
|
@ -39,7 +39,7 @@ namespace utils {
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
ASSERT(mSwapchainImpl.userData != nullptr);
|
ASSERT(mSwapchainImpl.userData != nullptr);
|
||||||
return dawn_native::d3d12::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
return dawn_native::d3d12::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ namespace utils {
|
||||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateD3D12Binding(GLFWwindow* window, DawnDevice device) {
|
BackendBinding* CreateD3D12Binding(GLFWwindow* window, WGPUDevice device) {
|
||||||
return new D3D12Binding(window, device);
|
return new D3D12Binding(window, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,11 @@ namespace utils {
|
||||||
mCommandQueue = ctx->queue;
|
mCommandQueue = ctx->queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnSwapChainError Configure(DawnTextureFormat format,
|
DawnSwapChainError Configure(WGPUTextureFormat format,
|
||||||
DawnTextureUsage usage,
|
WGPUTextureUsage usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (format != DAWN_TEXTURE_FORMAT_BGRA8_UNORM) {
|
if (format != WGPUTextureFormat_BGRA8Unorm) {
|
||||||
return "unsupported format";
|
return "unsupported format";
|
||||||
}
|
}
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
|
@ -65,7 +65,7 @@ namespace utils {
|
||||||
[mLayer setDrawableSize:size];
|
[mLayer setDrawableSize:size];
|
||||||
|
|
||||||
constexpr uint32_t kFramebufferOnlyTextureUsages =
|
constexpr uint32_t kFramebufferOnlyTextureUsages =
|
||||||
DAWN_TEXTURE_USAGE_OUTPUT_ATTACHMENT | DAWN_TEXTURE_USAGE_PRESENT;
|
WGPUTextureUsage_OutputAttachment | WGPUTextureUsage_Present;
|
||||||
bool hasOnlyFramebufferUsages = !(usage & (~kFramebufferOnlyTextureUsages));
|
bool hasOnlyFramebufferUsages = !(usage & (~kFramebufferOnlyTextureUsages));
|
||||||
if (hasOnlyFramebufferUsages) {
|
if (hasOnlyFramebufferUsages) {
|
||||||
[mLayer setFramebufferOnly:YES];
|
[mLayer setFramebufferOnly:YES];
|
||||||
|
@ -110,7 +110,7 @@ namespace utils {
|
||||||
|
|
||||||
class MetalBinding : public BackendBinding {
|
class MetalBinding : public BackendBinding {
|
||||||
public:
|
public:
|
||||||
MetalBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
MetalBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetSwapChainImplementation() override {
|
uint64_t GetSwapChainImplementation() override {
|
||||||
|
@ -121,15 +121,15 @@ namespace utils {
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
return DAWN_TEXTURE_FORMAT_BGRA8_UNORM;
|
return WGPUTextureFormat_BGRA8Unorm;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateMetalBinding(GLFWwindow* window, DawnDevice device) {
|
BackendBinding* CreateMetalBinding(GLFWwindow* window, WGPUDevice device) {
|
||||||
return new MetalBinding(window, device);
|
return new MetalBinding(window, device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace utils {
|
||||||
|
|
||||||
class NullBinding : public BackendBinding {
|
class NullBinding : public BackendBinding {
|
||||||
public:
|
public:
|
||||||
NullBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
NullBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetSwapChainImplementation() override {
|
uint64_t GetSwapChainImplementation() override {
|
||||||
|
@ -32,15 +32,15 @@ namespace utils {
|
||||||
}
|
}
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
return DAWN_TEXTURE_FORMAT_RGBA8_UNORM;
|
return WGPUTextureFormat_RGBA8Unorm;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateNullBinding(GLFWwindow* window, DawnDevice device) {
|
BackendBinding* CreateNullBinding(GLFWwindow* window, WGPUDevice device) {
|
||||||
return new NullBinding(window, device);
|
return new NullBinding(window, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace utils {
|
||||||
|
|
||||||
class OpenGLBinding : public BackendBinding {
|
class OpenGLBinding : public BackendBinding {
|
||||||
public:
|
public:
|
||||||
OpenGLBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
OpenGLBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetSwapChainImplementation() override {
|
uint64_t GetSwapChainImplementation() override {
|
||||||
|
@ -40,7 +40,7 @@ namespace utils {
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
return dawn_native::opengl::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
return dawn_native::opengl::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ namespace utils {
|
||||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, DawnDevice device) {
|
BackendBinding* CreateOpenGLBinding(GLFWwindow* window, WGPUDevice device) {
|
||||||
return new OpenGLBinding(window, device);
|
return new OpenGLBinding(window, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace utils {
|
||||||
|
|
||||||
class VulkanBinding : public BackendBinding {
|
class VulkanBinding : public BackendBinding {
|
||||||
public:
|
public:
|
||||||
VulkanBinding(GLFWwindow* window, DawnDevice device) : BackendBinding(window, device) {
|
VulkanBinding(GLFWwindow* window, WGPUDevice device) : BackendBinding(window, device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t GetSwapChainImplementation() override {
|
uint64_t GetSwapChainImplementation() override {
|
||||||
|
@ -41,7 +41,7 @@ namespace utils {
|
||||||
}
|
}
|
||||||
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
return reinterpret_cast<uint64_t>(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
DawnTextureFormat GetPreferredSwapChainTextureFormat() override {
|
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||||
ASSERT(mSwapchainImpl.userData != nullptr);
|
ASSERT(mSwapchainImpl.userData != nullptr);
|
||||||
return dawn_native::vulkan::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
return dawn_native::vulkan::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace utils {
|
||||||
DawnSwapChainImplementation mSwapchainImpl = {};
|
DawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateVulkanBinding(GLFWwindow* window, DawnDevice device) {
|
BackendBinding* CreateVulkanBinding(GLFWwindow* window, WGPUDevice device) {
|
||||||
return new VulkanBinding(window, device);
|
return new VulkanBinding(window, device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "utils/DawnHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
#include "common/Assert.h"
|
#include "common/Assert.h"
|
||||||
#include "common/Constants.h"
|
#include "common/Constants.h"
|
||||||
|
@ -41,8 +41,8 @@ namespace utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::ShaderModule CreateShaderModuleFromResult(
|
wgpu::ShaderModule CreateShaderModuleFromResult(
|
||||||
const dawn::Device& device,
|
const wgpu::Device& device,
|
||||||
const shaderc::SpvCompilationResult& result) {
|
const shaderc::SpvCompilationResult& result) {
|
||||||
// result.cend and result.cbegin return pointers to uint32_t.
|
// result.cend and result.cbegin return pointers to uint32_t.
|
||||||
const uint32_t* resultBegin = result.cbegin();
|
const uint32_t* resultBegin = result.cbegin();
|
||||||
|
@ -51,7 +51,7 @@ namespace utils {
|
||||||
ptrdiff_t resultSize = resultEnd - resultBegin;
|
ptrdiff_t resultSize = resultEnd - resultBegin;
|
||||||
// SetSource takes data as uint32_t*.
|
// SetSource takes data as uint32_t*.
|
||||||
|
|
||||||
dawn::ShaderModuleDescriptor descriptor;
|
wgpu::ShaderModuleDescriptor descriptor;
|
||||||
descriptor.codeSize = static_cast<uint32_t>(resultSize);
|
descriptor.codeSize = static_cast<uint32_t>(resultSize);
|
||||||
descriptor.code = result.cbegin();
|
descriptor.code = result.cbegin();
|
||||||
return device.CreateShaderModule(&descriptor);
|
return device.CreateShaderModule(&descriptor);
|
||||||
|
@ -59,7 +59,7 @@ namespace utils {
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
|
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device,
|
||||||
SingleShaderStage stage,
|
SingleShaderStage stage,
|
||||||
const char* source) {
|
const char* source) {
|
||||||
shaderc_shader_kind kind = ShadercShaderKind(stage);
|
shaderc_shader_kind kind = ShadercShaderKind(stage);
|
||||||
|
@ -102,7 +102,7 @@ namespace utils {
|
||||||
return CreateShaderModuleFromResult(device, result);
|
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::Compiler compiler;
|
||||||
shaderc::SpvCompilationResult result = compiler.AssembleToSpv(source, strlen(source));
|
shaderc::SpvCompilationResult result = compiler.AssembleToSpv(source, strlen(source));
|
||||||
if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
|
if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
|
||||||
|
@ -113,38 +113,38 @@ namespace utils {
|
||||||
return CreateShaderModuleFromResult(device, result);
|
return CreateShaderModuleFromResult(device, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::Buffer CreateBufferFromData(const dawn::Device& device,
|
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
|
||||||
const void* data,
|
const void* data,
|
||||||
uint64_t size,
|
uint64_t size,
|
||||||
dawn::BufferUsage usage) {
|
wgpu::BufferUsage usage) {
|
||||||
dawn::BufferDescriptor descriptor;
|
wgpu::BufferDescriptor descriptor;
|
||||||
descriptor.size = size;
|
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);
|
buffer.SetSubData(0, size, data);
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboRenderPassDescriptor::ComboRenderPassDescriptor(
|
ComboRenderPassDescriptor::ComboRenderPassDescriptor(
|
||||||
std::initializer_list<dawn::TextureView> colorAttachmentInfo,
|
std::initializer_list<wgpu::TextureView> colorAttachmentInfo,
|
||||||
dawn::TextureView depthStencil) {
|
wgpu::TextureView depthStencil) {
|
||||||
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
for (uint32_t i = 0; i < kMaxColorAttachments; ++i) {
|
||||||
cColorAttachments[i].loadOp = dawn::LoadOp::Clear;
|
cColorAttachments[i].loadOp = wgpu::LoadOp::Clear;
|
||||||
cColorAttachments[i].storeOp = dawn::StoreOp::Store;
|
cColorAttachments[i].storeOp = wgpu::StoreOp::Store;
|
||||||
cColorAttachments[i].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
cColorAttachments[i].clearColor = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
cDepthStencilAttachmentInfo.clearDepth = 1.0f;
|
cDepthStencilAttachmentInfo.clearDepth = 1.0f;
|
||||||
cDepthStencilAttachmentInfo.clearStencil = 0;
|
cDepthStencilAttachmentInfo.clearStencil = 0;
|
||||||
cDepthStencilAttachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
|
cDepthStencilAttachmentInfo.depthLoadOp = wgpu::LoadOp::Clear;
|
||||||
cDepthStencilAttachmentInfo.depthStoreOp = dawn::StoreOp::Store;
|
cDepthStencilAttachmentInfo.depthStoreOp = wgpu::StoreOp::Store;
|
||||||
cDepthStencilAttachmentInfo.stencilLoadOp = dawn::LoadOp::Clear;
|
cDepthStencilAttachmentInfo.stencilLoadOp = wgpu::LoadOp::Clear;
|
||||||
cDepthStencilAttachmentInfo.stencilStoreOp = dawn::StoreOp::Store;
|
cDepthStencilAttachmentInfo.stencilStoreOp = wgpu::StoreOp::Store;
|
||||||
|
|
||||||
colorAttachmentCount = static_cast<uint32_t>(colorAttachmentInfo.size());
|
colorAttachmentCount = static_cast<uint32_t>(colorAttachmentInfo.size());
|
||||||
uint32_t colorAttachmentIndex = 0;
|
uint32_t colorAttachmentIndex = 0;
|
||||||
for (const dawn::TextureView& colorAttachment : colorAttachmentInfo) {
|
for (const wgpu::TextureView& colorAttachment : colorAttachmentInfo) {
|
||||||
if (colorAttachment.Get() != nullptr) {
|
if (colorAttachment.Get() != nullptr) {
|
||||||
cColorAttachments[colorAttachmentIndex].attachment = colorAttachment;
|
cColorAttachments[colorAttachmentIndex].attachment = colorAttachment;
|
||||||
}
|
}
|
||||||
|
@ -182,14 +182,14 @@ namespace utils {
|
||||||
: width(0),
|
: width(0),
|
||||||
height(0),
|
height(0),
|
||||||
color(nullptr),
|
color(nullptr),
|
||||||
colorFormat(dawn::TextureFormat::RGBA8Unorm),
|
colorFormat(wgpu::TextureFormat::RGBA8Unorm),
|
||||||
renderPassInfo({}) {
|
renderPassInfo({}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicRenderPass::BasicRenderPass(uint32_t texWidth,
|
BasicRenderPass::BasicRenderPass(uint32_t texWidth,
|
||||||
uint32_t texHeight,
|
uint32_t texHeight,
|
||||||
dawn::Texture colorAttachment,
|
wgpu::Texture colorAttachment,
|
||||||
dawn::TextureFormat textureFormat)
|
wgpu::TextureFormat textureFormat)
|
||||||
: width(texWidth),
|
: width(texWidth),
|
||||||
height(texHeight),
|
height(texHeight),
|
||||||
color(colorAttachment),
|
color(colorAttachment),
|
||||||
|
@ -197,13 +197,13 @@ namespace utils {
|
||||||
renderPassInfo({colorAttachment.CreateView()}) {
|
renderPassInfo({colorAttachment.CreateView()}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
|
BasicRenderPass CreateBasicRenderPass(const wgpu::Device& device,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
DAWN_ASSERT(width > 0 && height > 0);
|
DAWN_ASSERT(width > 0 && height > 0);
|
||||||
|
|
||||||
dawn::TextureDescriptor descriptor;
|
wgpu::TextureDescriptor descriptor;
|
||||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||||
descriptor.size.width = width;
|
descriptor.size.width = width;
|
||||||
descriptor.size.height = height;
|
descriptor.size.height = height;
|
||||||
descriptor.size.depth = 1;
|
descriptor.size.depth = 1;
|
||||||
|
@ -211,17 +211,17 @@ namespace utils {
|
||||||
descriptor.sampleCount = 1;
|
descriptor.sampleCount = 1;
|
||||||
descriptor.format = BasicRenderPass::kDefaultColorFormat;
|
descriptor.format = BasicRenderPass::kDefaultColorFormat;
|
||||||
descriptor.mipLevelCount = 1;
|
descriptor.mipLevelCount = 1;
|
||||||
descriptor.usage = dawn::TextureUsage::OutputAttachment | dawn::TextureUsage::CopySrc;
|
descriptor.usage = wgpu::TextureUsage::OutputAttachment | wgpu::TextureUsage::CopySrc;
|
||||||
dawn::Texture color = device.CreateTexture(&descriptor);
|
wgpu::Texture color = device.CreateTexture(&descriptor);
|
||||||
|
|
||||||
return BasicRenderPass(width, height, color);
|
return BasicRenderPass(width, height, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BufferCopyView CreateBufferCopyView(dawn::Buffer buffer,
|
wgpu::BufferCopyView CreateBufferCopyView(wgpu::Buffer buffer,
|
||||||
uint64_t offset,
|
uint64_t offset,
|
||||||
uint32_t rowPitch,
|
uint32_t rowPitch,
|
||||||
uint32_t imageHeight) {
|
uint32_t imageHeight) {
|
||||||
dawn::BufferCopyView bufferCopyView;
|
wgpu::BufferCopyView bufferCopyView;
|
||||||
bufferCopyView.buffer = buffer;
|
bufferCopyView.buffer = buffer;
|
||||||
bufferCopyView.offset = offset;
|
bufferCopyView.offset = offset;
|
||||||
bufferCopyView.rowPitch = rowPitch;
|
bufferCopyView.rowPitch = rowPitch;
|
||||||
|
@ -230,11 +230,11 @@ namespace utils {
|
||||||
return bufferCopyView;
|
return bufferCopyView;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::TextureCopyView CreateTextureCopyView(dawn::Texture texture,
|
wgpu::TextureCopyView CreateTextureCopyView(wgpu::Texture texture,
|
||||||
uint32_t mipLevel,
|
uint32_t mipLevel,
|
||||||
uint32_t arrayLayer,
|
uint32_t arrayLayer,
|
||||||
dawn::Origin3D origin) {
|
wgpu::Origin3D origin) {
|
||||||
dawn::TextureCopyView textureCopyView;
|
wgpu::TextureCopyView textureCopyView;
|
||||||
textureCopyView.texture = texture;
|
textureCopyView.texture = texture;
|
||||||
textureCopyView.mipLevel = mipLevel;
|
textureCopyView.mipLevel = mipLevel;
|
||||||
textureCopyView.arrayLayer = arrayLayer;
|
textureCopyView.arrayLayer = arrayLayer;
|
||||||
|
@ -243,25 +243,25 @@ namespace utils {
|
||||||
return textureCopyView;
|
return textureCopyView;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::SamplerDescriptor GetDefaultSamplerDescriptor() {
|
wgpu::SamplerDescriptor GetDefaultSamplerDescriptor() {
|
||||||
dawn::SamplerDescriptor desc;
|
wgpu::SamplerDescriptor desc;
|
||||||
|
|
||||||
desc.minFilter = dawn::FilterMode::Linear;
|
desc.minFilter = wgpu::FilterMode::Linear;
|
||||||
desc.magFilter = dawn::FilterMode::Linear;
|
desc.magFilter = wgpu::FilterMode::Linear;
|
||||||
desc.mipmapFilter = dawn::FilterMode::Linear;
|
desc.mipmapFilter = wgpu::FilterMode::Linear;
|
||||||
desc.addressModeU = dawn::AddressMode::Repeat;
|
desc.addressModeU = wgpu::AddressMode::Repeat;
|
||||||
desc.addressModeV = dawn::AddressMode::Repeat;
|
desc.addressModeV = wgpu::AddressMode::Repeat;
|
||||||
desc.addressModeW = dawn::AddressMode::Repeat;
|
desc.addressModeW = wgpu::AddressMode::Repeat;
|
||||||
desc.lodMinClamp = kLodMin;
|
desc.lodMinClamp = kLodMin;
|
||||||
desc.lodMaxClamp = kLodMax;
|
desc.lodMaxClamp = kLodMax;
|
||||||
desc.compare = dawn::CompareFunction::Never;
|
desc.compare = wgpu::CompareFunction::Never;
|
||||||
|
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
|
wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device,
|
||||||
const dawn::BindGroupLayout* bindGroupLayout) {
|
const wgpu::BindGroupLayout* bindGroupLayout) {
|
||||||
dawn::PipelineLayoutDescriptor descriptor;
|
wgpu::PipelineLayoutDescriptor descriptor;
|
||||||
if (bindGroupLayout != nullptr) {
|
if (bindGroupLayout != nullptr) {
|
||||||
descriptor.bindGroupLayoutCount = 1;
|
descriptor.bindGroupLayoutCount = 1;
|
||||||
descriptor.bindGroupLayouts = bindGroupLayout;
|
descriptor.bindGroupLayouts = bindGroupLayout;
|
||||||
|
@ -272,43 +272,43 @@ namespace utils {
|
||||||
return device.CreatePipelineLayout(&descriptor);
|
return device.CreatePipelineLayout(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BindGroupLayout MakeBindGroupLayout(
|
wgpu::BindGroupLayout MakeBindGroupLayout(
|
||||||
const dawn::Device& device,
|
const wgpu::Device& device,
|
||||||
std::initializer_list<dawn::BindGroupLayoutBinding> bindingsInitializer) {
|
std::initializer_list<wgpu::BindGroupLayoutBinding> bindingsInitializer) {
|
||||||
constexpr dawn::ShaderStage kNoStages{};
|
constexpr wgpu::ShaderStage kNoStages{};
|
||||||
|
|
||||||
std::vector<dawn::BindGroupLayoutBinding> bindings;
|
std::vector<wgpu::BindGroupLayoutBinding> bindings;
|
||||||
for (const dawn::BindGroupLayoutBinding& binding : bindingsInitializer) {
|
for (const wgpu::BindGroupLayoutBinding& binding : bindingsInitializer) {
|
||||||
if (binding.visibility != kNoStages) {
|
if (binding.visibility != kNoStages) {
|
||||||
bindings.push_back(binding);
|
bindings.push_back(binding);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BindGroupLayoutDescriptor descriptor;
|
wgpu::BindGroupLayoutDescriptor descriptor;
|
||||||
descriptor.bindingCount = static_cast<uint32_t>(bindings.size());
|
descriptor.bindingCount = static_cast<uint32_t>(bindings.size());
|
||||||
descriptor.bindings = bindings.data();
|
descriptor.bindings = bindings.data();
|
||||||
return device.CreateBindGroupLayout(&descriptor);
|
return device.CreateBindGroupLayout(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
||||||
const dawn::Sampler& sampler)
|
const wgpu::Sampler& sampler)
|
||||||
: binding(binding), sampler(sampler) {
|
: binding(binding), sampler(sampler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
||||||
const dawn::TextureView& textureView)
|
const wgpu::TextureView& textureView)
|
||||||
: binding(binding), textureView(textureView) {
|
: binding(binding), textureView(textureView) {
|
||||||
}
|
}
|
||||||
|
|
||||||
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
BindingInitializationHelper::BindingInitializationHelper(uint32_t binding,
|
||||||
const dawn::Buffer& buffer,
|
const wgpu::Buffer& buffer,
|
||||||
uint64_t offset,
|
uint64_t offset,
|
||||||
uint64_t size)
|
uint64_t size)
|
||||||
: binding(binding), buffer(buffer), offset(offset), size(size) {
|
: binding(binding), buffer(buffer), offset(offset), size(size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BindGroupBinding BindingInitializationHelper::GetAsBinding() const {
|
wgpu::BindGroupBinding BindingInitializationHelper::GetAsBinding() const {
|
||||||
dawn::BindGroupBinding result;
|
wgpu::BindGroupBinding result;
|
||||||
|
|
||||||
result.binding = binding;
|
result.binding = binding;
|
||||||
result.sampler = sampler;
|
result.sampler = sampler;
|
||||||
|
@ -320,16 +320,16 @@ namespace utils {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BindGroup MakeBindGroup(
|
wgpu::BindGroup MakeBindGroup(
|
||||||
const dawn::Device& device,
|
const wgpu::Device& device,
|
||||||
const dawn::BindGroupLayout& layout,
|
const wgpu::BindGroupLayout& layout,
|
||||||
std::initializer_list<BindingInitializationHelper> bindingsInitializer) {
|
std::initializer_list<BindingInitializationHelper> bindingsInitializer) {
|
||||||
std::vector<dawn::BindGroupBinding> bindings;
|
std::vector<wgpu::BindGroupBinding> bindings;
|
||||||
for (const BindingInitializationHelper& helper : bindingsInitializer) {
|
for (const BindingInitializationHelper& helper : bindingsInitializer) {
|
||||||
bindings.push_back(helper.GetAsBinding());
|
bindings.push_back(helper.GetAsBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::BindGroupDescriptor descriptor;
|
wgpu::BindGroupDescriptor descriptor;
|
||||||
descriptor.layout = layout;
|
descriptor.layout = layout;
|
||||||
descriptor.bindingCount = bindings.size();
|
descriptor.bindingCount = bindings.size();
|
||||||
descriptor.bindings = bindings.data();
|
descriptor.bindings = bindings.data();
|
|
@ -15,7 +15,7 @@
|
||||||
#ifndef UTILS_DAWNHELPERS_H_
|
#ifndef UTILS_DAWNHELPERS_H_
|
||||||
#define UTILS_DAWNHELPERS_H_
|
#define UTILS_DAWNHELPERS_H_
|
||||||
|
|
||||||
#include <dawn/dawncpp.h>
|
#include <dawn/webgpu_cpp.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
|
@ -28,42 +28,42 @@ namespace utils {
|
||||||
|
|
||||||
enum class SingleShaderStage { Vertex, Fragment, Compute };
|
enum class SingleShaderStage { Vertex, Fragment, Compute };
|
||||||
|
|
||||||
dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
|
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device,
|
||||||
SingleShaderStage stage,
|
SingleShaderStage stage,
|
||||||
const char* source);
|
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,
|
const void* data,
|
||||||
uint64_t size,
|
uint64_t size,
|
||||||
dawn::BufferUsage usage);
|
wgpu::BufferUsage usage);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
dawn::Buffer CreateBufferFromData(const dawn::Device& device,
|
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
|
||||||
dawn::BufferUsage usage,
|
wgpu::BufferUsage usage,
|
||||||
std::initializer_list<T> data) {
|
std::initializer_list<T> data) {
|
||||||
return CreateBufferFromData(device, data.begin(), uint32_t(sizeof(T) * data.size()), usage);
|
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,
|
uint64_t offset,
|
||||||
uint32_t rowPitch,
|
uint32_t rowPitch,
|
||||||
uint32_t imageHeight);
|
uint32_t imageHeight);
|
||||||
dawn::TextureCopyView CreateTextureCopyView(dawn::Texture texture,
|
wgpu::TextureCopyView CreateTextureCopyView(wgpu::Texture texture,
|
||||||
uint32_t level,
|
uint32_t level,
|
||||||
uint32_t slice,
|
uint32_t slice,
|
||||||
dawn::Origin3D origin);
|
wgpu::Origin3D origin);
|
||||||
|
|
||||||
struct ComboRenderPassDescriptor : public dawn::RenderPassDescriptor {
|
struct ComboRenderPassDescriptor : public wgpu::RenderPassDescriptor {
|
||||||
public:
|
public:
|
||||||
ComboRenderPassDescriptor(std::initializer_list<dawn::TextureView> colorAttachmentInfo,
|
ComboRenderPassDescriptor(std::initializer_list<wgpu::TextureView> colorAttachmentInfo,
|
||||||
dawn::TextureView depthStencil = dawn::TextureView());
|
wgpu::TextureView depthStencil = wgpu::TextureView());
|
||||||
const ComboRenderPassDescriptor& operator=(
|
const ComboRenderPassDescriptor& operator=(
|
||||||
const ComboRenderPassDescriptor& otherRenderPass);
|
const ComboRenderPassDescriptor& otherRenderPass);
|
||||||
|
|
||||||
std::array<dawn::RenderPassColorAttachmentDescriptor, kMaxColorAttachments>
|
std::array<wgpu::RenderPassColorAttachmentDescriptor, kMaxColorAttachments>
|
||||||
cColorAttachments;
|
cColorAttachments;
|
||||||
dawn::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
|
wgpu::RenderPassDepthStencilAttachmentDescriptor cDepthStencilAttachmentInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BasicRenderPass {
|
struct BasicRenderPass {
|
||||||
|
@ -71,27 +71,27 @@ namespace utils {
|
||||||
BasicRenderPass();
|
BasicRenderPass();
|
||||||
BasicRenderPass(uint32_t width,
|
BasicRenderPass(uint32_t width,
|
||||||
uint32_t height,
|
uint32_t height,
|
||||||
dawn::Texture color,
|
wgpu::Texture color,
|
||||||
dawn::TextureFormat texture = kDefaultColorFormat);
|
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 width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
dawn::Texture color;
|
wgpu::Texture color;
|
||||||
dawn::TextureFormat colorFormat;
|
wgpu::TextureFormat colorFormat;
|
||||||
utils::ComboRenderPassDescriptor renderPassInfo;
|
utils::ComboRenderPassDescriptor renderPassInfo;
|
||||||
};
|
};
|
||||||
BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
|
BasicRenderPass CreateBasicRenderPass(const wgpu::Device& device,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
|
|
||||||
dawn::SamplerDescriptor GetDefaultSamplerDescriptor();
|
wgpu::SamplerDescriptor GetDefaultSamplerDescriptor();
|
||||||
dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
|
wgpu::PipelineLayout MakeBasicPipelineLayout(const wgpu::Device& device,
|
||||||
const dawn::BindGroupLayout* bindGroupLayout);
|
const wgpu::BindGroupLayout* bindGroupLayout);
|
||||||
dawn::BindGroupLayout MakeBindGroupLayout(
|
wgpu::BindGroupLayout MakeBindGroupLayout(
|
||||||
const dawn::Device& device,
|
const wgpu::Device& device,
|
||||||
std::initializer_list<dawn::BindGroupLayoutBinding> bindingsInitializer);
|
std::initializer_list<wgpu::BindGroupLayoutBinding> bindingsInitializer);
|
||||||
|
|
||||||
// Helpers to make creating bind groups look nicer:
|
// 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
|
// Structure with one constructor per-type of bindings, so that the initializer_list accepts
|
||||||
// bindings with the right type and no extra information.
|
// bindings with the right type and no extra information.
|
||||||
struct BindingInitializationHelper {
|
struct BindingInitializationHelper {
|
||||||
BindingInitializationHelper(uint32_t binding, const dawn::Sampler& sampler);
|
BindingInitializationHelper(uint32_t binding, const wgpu::Sampler& sampler);
|
||||||
BindingInitializationHelper(uint32_t binding, const dawn::TextureView& textureView);
|
BindingInitializationHelper(uint32_t binding, const wgpu::TextureView& textureView);
|
||||||
BindingInitializationHelper(uint32_t binding,
|
BindingInitializationHelper(uint32_t binding,
|
||||||
const dawn::Buffer& buffer,
|
const wgpu::Buffer& buffer,
|
||||||
uint64_t offset,
|
uint64_t offset,
|
||||||
uint64_t size);
|
uint64_t size);
|
||||||
|
|
||||||
dawn::BindGroupBinding GetAsBinding() const;
|
wgpu::BindGroupBinding GetAsBinding() const;
|
||||||
|
|
||||||
uint32_t binding;
|
uint32_t binding;
|
||||||
dawn::Sampler sampler;
|
wgpu::Sampler sampler;
|
||||||
dawn::TextureView textureView;
|
wgpu::TextureView textureView;
|
||||||
dawn::Buffer buffer;
|
wgpu::Buffer buffer;
|
||||||
uint64_t offset = 0;
|
uint64_t offset = 0;
|
||||||
uint64_t size = 0;
|
uint64_t size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
dawn::BindGroup MakeBindGroup(
|
wgpu::BindGroup MakeBindGroup(
|
||||||
const dawn::Device& device,
|
const wgpu::Device& device,
|
||||||
const dawn::BindGroupLayout& layout,
|
const wgpu::BindGroupLayout& layout,
|
||||||
std::initializer_list<BindingInitializationHelper> bindingsInitializer);
|
std::initializer_list<BindingInitializationHelper> bindingsInitializer);
|
||||||
|
|
||||||
} // namespace utils
|
} // namespace utils
|
Loading…
Reference in New Issue