Skip to content

Commit

Permalink
Merge pull request bfierz#131 from bfierz/feature/upgrade-dawn-chrom-…
Browse files Browse the repository at this point in the history
…4633

Update to dawn of chrome 4633
  • Loading branch information
bfierz authored Nov 1, 2021
2 parents 4c3747c + 0ed960f commit 7c61383
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 30 deletions.
10 changes: 5 additions & 5 deletions src/cmake/FetchDawn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ include(FetchContent)
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

if ((IS_MULTI_CONFIG AND "Debug" IN_LIST CMAKE_CONFIGURATION_TYPES) OR ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if ((IS_MULTI_CONFIG AND "Debug" IN_LIST CMAKE_CONFIGURATION_TYPES) OR "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
FetchContent_Declare(
webgpu_library_debug
URL https://github.com/bfierz/dawn-builds/releases/download/0.0.20210521-41c87d97/dawn_win_x64_debug.zip
URL https://github.com/bfierz/dawn-builds/releases/download/0.0.20210904-2e40f90e/dawn_win_x64_debug.zip
)
FetchContent_GetProperties(webgpu_library_debug)
if(NOT webgpu_library_debug_POPULATED)
FetchContent_Populate(webgpu_library_debug)
message(STATUS "Downloaded Google Dawn Debug to ${webgpu_library_debug_SOURCE_DIR}")
endif()
endif()
if (IS_MULTI_CONFIG OR NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if (IS_MULTI_CONFIG OR NOT "${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
FetchContent_Declare(
webgpu_library_release
URL https://github.com/bfierz/dawn-builds/releases/download/0.0.20210521-41c87d97/dawn_win_x64_release.zip
URL https://github.com/bfierz/dawn-builds/releases/download/0.0.20210904-2e40f90e/dawn_win_x64_release.zip
)
FetchContent_GetProperties(webgpu_library_release)
if(NOT webgpu_library_release_POPULATED)
Expand All @@ -51,7 +51,7 @@ if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux")
FetchContent_Declare(
webgpu_library_release
URL https://github.com/bfierz/dawn-builds/releases/download/0.0.20210521-41c87d97/dawn_linux_x64_release.zip
URL https://github.com/bfierz/dawn-builds/releases/download/0.0.20210904-2e40f90e/dawn_linux_x64_release.zip
)
FetchContent_GetProperties(webgpu_library_release)
if(NOT webgpu_library_release_POPULATED)
Expand Down
2 changes: 1 addition & 1 deletion src/examples/3rdparty/imgui
Submodule imgui updated 113 files
4 changes: 2 additions & 2 deletions src/examples/webgpu/common/imguiapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void ImGuiApplication::renderFrame(WGPUTextureView back_buffer)
{
wgpu::Device device{ _wgpuDevice };

auto color_attachments = wgpu::RenderPassColorAttachmentDescriptor{};
auto color_attachments = wgpu::RenderPassColorAttachment{};
color_attachments.loadOp = wgpu::LoadOp::Load;
color_attachments.storeOp = wgpu::StoreOp::Store;
color_attachments.clearColor = { 1.0f, 0.0f, 1.0f, 0.0f };
Expand All @@ -118,4 +118,4 @@ void ImGuiApplication::renderFrame(WGPUTextureView back_buffer)
auto cmd_buffer_desc = wgpu::CommandBufferDescriptor{};
auto cmd_buffer = encoder.Finish(&cmd_buffer_desc);
device.GetQueue().Submit(1, &cmd_buffer);
}
}
2 changes: 1 addition & 1 deletion src/examples/webgpu/drawquad/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class DrawQuadApplication final : public Application
const auto w = size.first / 2;
const auto h = size.second / 2;

std::array<WGPURenderPassColorAttachmentDescriptor, 1> color_attachments = {};
std::array<WGPURenderPassColorAttachment, 1> color_attachments = {};
color_attachments[0].loadOp = WGPULoadOp_Clear;
color_attachments[0].storeOp = WGPUStoreOp_Store;
color_attachments[0].clearColor = { 1.0f, 0.0f, 1.0f, 0.0f };
Expand Down
2 changes: 1 addition & 1 deletion src/examples/webgpu/imfiledialog/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class DemoImGuiApplication final : public ImGuiApplication
}
void renderFrame(WGPUTextureView back_buffer) override
{
std::array<WGPURenderPassColorAttachmentDescriptor, 1> color_attachments = {};
std::array<WGPURenderPassColorAttachment, 1> color_attachments = {};
color_attachments[0].loadOp = WGPULoadOp_Clear;
color_attachments[0].storeOp = WGPUStoreOp_Store;
color_attachments[0].clearColor = { clear_color.x, clear_color.y, clear_color.z, clear_color.w };
Expand Down
2 changes: 1 addition & 1 deletion src/examples/webgpu/imgui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class DemoImGuiApplication final : public ImGuiApplication
}
void renderFrame(WGPUTextureView back_buffer) override
{
std::array<WGPURenderPassColorAttachmentDescriptor, 1> color_attachments = {};
std::array<WGPURenderPassColorAttachment, 1> color_attachments = {};
color_attachments[0].loadOp = WGPULoadOp_Clear;
color_attachments[0].storeOp = WGPUStoreOp_Store;
color_attachments[0].clearColor = { clear_color.x, clear_color.y, clear_color.z, clear_color.w };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ namespace Vcl { namespace Graphics { namespace Runtime { namespace WebGPU {
switch (factor) {
case Blend::Zero : return WGPUBlendFactor_Zero;
case Blend::One : return WGPUBlendFactor_One;
case Blend::SrcColour : return WGPUBlendFactor_SrcColor;
case Blend::InvSrcColour : return WGPUBlendFactor_OneMinusSrcColor;
case Blend::SrcColour : return WGPUBlendFactor_Src;
case Blend::InvSrcColour : return WGPUBlendFactor_OneMinusSrc;
case Blend::SrcAlpha : return WGPUBlendFactor_SrcAlpha;
case Blend::InvSrcAlpha : return WGPUBlendFactor_OneMinusSrcAlpha;
case Blend::DestAlpha : return WGPUBlendFactor_DstAlpha;
case Blend::InvDestAlpha : return WGPUBlendFactor_OneMinusDstAlpha;
case Blend::DestColour : return WGPUBlendFactor_DstColor;
case Blend::InvDestColour : return WGPUBlendFactor_OneMinusDstColor;
case Blend::DestColour : return WGPUBlendFactor_Dst;
case Blend::InvDestColour : return WGPUBlendFactor_OneMinusDst;
case Blend::SrcAlphaSat : return WGPUBlendFactor_SrcAlphaSaturated;
case Blend::BlendFactor : return WGPUBlendFactor_BlendColor;
case Blend::InvBlendFactor: return WGPUBlendFactor_OneMinusBlendColor;
case Blend::BlendFactor : return WGPUBlendFactor_Constant;
case Blend::InvBlendFactor: return WGPUBlendFactor_OneMinusConstant;
case Blend::Src1Colour:
case Blend::InvSrc1Colour:
case Blend::Src1Alpha:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ namespace Vcl { namespace Graphics { namespace Runtime { namespace WebGPU {
return WGPUStencilOperation_Force32;
}

WGPUStencilStateFaceDescriptor toWebGPU(DepthStencilOperationDescription desc)
WGPUStencilFaceState toWebGPU(DepthStencilOperationDescription desc)
{
WGPUStencilStateFaceDescriptor webgpu_desc = {};
WGPUStencilFaceState webgpu_desc = {};
webgpu_desc.failOp = toWebGPU(desc.StencilFailOp);
webgpu_desc.depthFailOp = toWebGPU(desc.StencilDepthFailOp);
webgpu_desc.passOp = toWebGPU(desc.StencilPassOp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,27 @@ namespace Vcl { namespace Graphics { namespace Runtime { namespace WebGPU {
return WGPUVertexFormat_Force32;
}

std::pair<std::vector<WGPUVertexBufferLayoutDescriptor>, std::vector<WGPUVertexAttributeDescriptor>> toWebGPU(const InputLayoutDescription& desc)
std::pair<std::vector<WGPUVertexBufferLayout>, std::vector<WGPUVertexAttribute>> toWebGPU(const InputLayoutDescription& desc)
{
std::vector<WGPUVertexBufferLayoutDescriptor> webgpu_buffer_desc;
std::vector<WGPUVertexBufferLayout> webgpu_buffer_desc;
webgpu_buffer_desc.reserve(desc.attributes().size());
std::vector<WGPUVertexAttributeDescriptor> webgpu_attrib_desc;
std::vector<WGPUVertexAttribute> webgpu_attrib_desc;
webgpu_attrib_desc.reserve(desc.attributes().size());

int idx = 0;
for (const auto& elem : desc.attributes())
{
const auto& binding = desc.binding(elem.InputSlot);

WGPUVertexBufferLayoutDescriptor webgpu_elem;
WGPUVertexBufferLayout webgpu_elem;
webgpu_elem.arrayStride = binding.Stride;
webgpu_elem.stepMode = binding.InputRate == VertexDataClassification::VertexDataPerObject ? WGPUInputStepMode_Vertex : WGPUInputStepMode_Instance;
webgpu_elem.stepMode = binding.InputRate == VertexDataClassification::VertexDataPerObject ? WGPUVertexStepMode_Vertex : WGPUVertexStepMode_Instance;
webgpu_elem.attributeCount = elem.NumberLocations;
webgpu_buffer_desc.emplace_back(webgpu_elem);

for (int sub_loc = 0; sub_loc < std::max(1, (int)elem.NumberLocations); sub_loc++)
{
WGPUVertexAttributeDescriptor webgpu_attribute;
WGPUVertexAttribute webgpu_attribute;
webgpu_attribute.format = toWebGPU(elem.Format);
webgpu_attribute.offset = elem.Offset;
webgpu_attribute.shaderLocation = desc.location(idx) + sub_loc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
#include <vcl/graphics/runtime/state/inputlayout.h>

namespace Vcl { namespace Graphics { namespace Runtime { namespace WebGPU {
std::pair<std::vector<WGPUVertexBufferLayoutDescriptor>, std::vector<WGPUVertexAttributeDescriptor>> toWebGPU(const InputLayoutDescription& desc);
std::pair<std::vector<WGPUVertexBufferLayout>, std::vector<WGPUVertexAttribute>> toWebGPU(const InputLayoutDescription& desc);
}}}}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ namespace Vcl { namespace Graphics { namespace Runtime { namespace WebGPU {
VclRequire(implies(desc.ComputeShader, desc.ComputeShader->type() == ShaderType::ComputeShader), "Shader is compute shader");

WGPUComputePipelineDescriptor compute_pipeline_desc = {};
compute_pipeline_desc.computeStage = getProgammableStageDesc(desc.ComputeShader);
compute_pipeline_desc.compute = getProgammableStageDesc(desc.ComputeShader);

_pipeline = wgpuDeviceCreateComputePipeline(device, &compute_pipeline_desc);
}
Expand Down
4 changes: 2 additions & 2 deletions src/libs/vcl.graphics/vcl/graphics/webgpu/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ namespace Vcl { namespace Graphics { namespace WebGPU {
tex_desc.sampleCount = 1;
tex_desc.format = toWebGPUEnum(type);
tex_desc.mipLevelCount = 1;
tex_desc.usage = WGPUTextureUsage_CopyDst | WGPUTextureUsage_Sampled;
tex_desc.usage = WGPUTextureUsage_CopyDst | WGPUTextureUsage_TextureBinding;
std::get<0>(texture_data) = wgpuDeviceCreateTexture(device, &tex_desc);

WGPUTextureViewDescriptor tex_view_desc = {};
Expand All @@ -68,7 +68,7 @@ namespace Vcl { namespace Graphics { namespace WebGPU {
{
uint32_t pp_size = sizeInBytes(type);

WGPUTextureCopyView dst_view = {};
WGPUImageCopyTexture dst_view = {};
dst_view.texture = std::get<0>(texture_data);
dst_view.mipLevel = 0;
dst_view.origin = { 0, 0, 0 };
Expand Down
2 changes: 1 addition & 1 deletion src/libs/vcl.graphics/vcl/graphics/webgpu/swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace Vcl { namespace Graphics { namespace WebGPU {

#ifdef VCL_ARCH_WEBASM
WGPUSwapChainDescriptor wgpu_desc = {};
wgpu_desc.usage = WGPUTextureUsage_OutputAttachment;
wgpu_desc.usage = WGPUTextureUsage_RenderAttachment;
wgpu_desc.format = WGPUTextureFormat_RGBA8Unorm;
wgpu_desc.width = width;
wgpu_desc.height = height;
Expand Down

0 comments on commit 7c61383

Please sign in to comment.