Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native dawn dev package for development #338

Merged
merged 31 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions 3rdparty/include/webgpu/include/dawn/EnumClassBitmasks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// Copyright 2017 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef DAWN_ENUM_CLASS_BITMASKS_H_
#define DAWN_ENUM_CLASS_BITMASKS_H_

#include <type_traits>

namespace wgpu {

template <typename T>
struct IsDawnBitmask {
static constexpr bool enable = false;
};

template <typename T, typename Enable = void>
struct LowerBitmask {
static constexpr bool enable = false;
};

template <typename T>
struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
static constexpr bool enable = true;
using type = T;
constexpr static T Lower(T t) {
return t;
}
};

template <typename T>
struct BoolConvertible {
using Integral = typename std::underlying_type<T>::type;

constexpr BoolConvertible(Integral value) : value(value) {
}
constexpr operator bool() const {
return value != 0;
}
constexpr operator T() const {
return static_cast<T>(value);
}

Integral value;
};

template <typename T>
struct LowerBitmask<BoolConvertible<T>> {
static constexpr bool enable = true;
using type = T;
static constexpr type Lower(BoolConvertible<T> t) {
return t;
}
};

template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}

template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}

template <typename T1,
typename T2,
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
}

template <typename T1>
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
using T = typename LowerBitmask<T1>::type;
using Integral = typename std::underlying_type<T>::type;
return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
}

template <typename T,
typename T2,
typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr T& operator&=(T& l, T2 right) {
T r = LowerBitmask<T2>::Lower(right);
l = l & r;
return l;
}

template <typename T,
typename T2,
typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr T& operator|=(T& l, T2 right) {
T r = LowerBitmask<T2>::Lower(right);
l = l | r;
return l;
}

template <typename T,
typename T2,
typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
LowerBitmask<T2>::enable>::type>
constexpr T& operator^=(T& l, T2 right) {
T r = LowerBitmask<T2>::Lower(right);
l = l ^ r;
return l;
}

template <typename T>
constexpr bool HasZeroOrOneBits(T value) {
using Integral = typename std::underlying_type<T>::type;
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
}

} // namespace wgpu

#endif // DAWN_ENUM_CLASS_BITMASKS_H_
36 changes: 36 additions & 0 deletions 3rdparty/include/webgpu/include/dawn/dawn_proc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright 2019 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef DAWN_DAWN_PROC_H_
#define DAWN_DAWN_PROC_H_

#include "dawn/dawn_proc_table.h"
#include "dawn/webgpu.h"

#ifdef __cplusplus
extern "C" {
#endif

// Sets the static proctable used by libdawn_proc to implement the Dawn entrypoints. Passing NULL
// for `procs` sets up the null proctable that contains only null function pointers. It is the
// default value of the proctable. Setting the proctable back to null is good practice when you
// are done using libdawn_proc since further usage will cause a segfault instead of calling an
// unexpected function.
WGPU_EXPORT void dawnProcSetProcs(const DawnProcTable* procs);

#ifdef __cplusplus
} // extern "C"
#endif

#endif // DAWN_DAWN_PROC_H_
165 changes: 165 additions & 0 deletions 3rdparty/include/webgpu/include/dawn/dawn_proc_table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@

#ifndef DAWN_DAWN_PROC_TABLE_H_
#define DAWN_DAWN_PROC_TABLE_H_

#include "dawn/webgpu.h"

typedef struct DawnProcTable {
WGPUProcGetProcAddress getProcAddress;
WGPUProcCreateInstance createInstance;

WGPUProcBindGroupReference bindGroupReference;
WGPUProcBindGroupRelease bindGroupRelease;

WGPUProcBindGroupLayoutReference bindGroupLayoutReference;
WGPUProcBindGroupLayoutRelease bindGroupLayoutRelease;

WGPUProcBufferDestroy bufferDestroy;
WGPUProcBufferMapReadAsync bufferMapReadAsync;
WGPUProcBufferMapWriteAsync bufferMapWriteAsync;
WGPUProcBufferSetSubData bufferSetSubData;
WGPUProcBufferUnmap bufferUnmap;
WGPUProcBufferReference bufferReference;
WGPUProcBufferRelease bufferRelease;

WGPUProcCommandBufferReference commandBufferReference;
WGPUProcCommandBufferRelease commandBufferRelease;

WGPUProcCommandEncoderBeginComputePass commandEncoderBeginComputePass;
WGPUProcCommandEncoderBeginRenderPass commandEncoderBeginRenderPass;
WGPUProcCommandEncoderCopyBufferToBuffer commandEncoderCopyBufferToBuffer;
WGPUProcCommandEncoderCopyBufferToTexture commandEncoderCopyBufferToTexture;
WGPUProcCommandEncoderCopyTextureToBuffer commandEncoderCopyTextureToBuffer;
WGPUProcCommandEncoderCopyTextureToTexture commandEncoderCopyTextureToTexture;
WGPUProcCommandEncoderFinish commandEncoderFinish;
WGPUProcCommandEncoderInsertDebugMarker commandEncoderInsertDebugMarker;
WGPUProcCommandEncoderPopDebugGroup commandEncoderPopDebugGroup;
WGPUProcCommandEncoderPushDebugGroup commandEncoderPushDebugGroup;
WGPUProcCommandEncoderReference commandEncoderReference;
WGPUProcCommandEncoderRelease commandEncoderRelease;

WGPUProcComputePassEncoderDispatch computePassEncoderDispatch;
WGPUProcComputePassEncoderDispatchIndirect computePassEncoderDispatchIndirect;
WGPUProcComputePassEncoderEndPass computePassEncoderEndPass;
WGPUProcComputePassEncoderInsertDebugMarker computePassEncoderInsertDebugMarker;
WGPUProcComputePassEncoderPopDebugGroup computePassEncoderPopDebugGroup;
WGPUProcComputePassEncoderPushDebugGroup computePassEncoderPushDebugGroup;
WGPUProcComputePassEncoderSetBindGroup computePassEncoderSetBindGroup;
WGPUProcComputePassEncoderSetPipeline computePassEncoderSetPipeline;
WGPUProcComputePassEncoderReference computePassEncoderReference;
WGPUProcComputePassEncoderRelease computePassEncoderRelease;

WGPUProcComputePipelineGetBindGroupLayout computePipelineGetBindGroupLayout;
WGPUProcComputePipelineReference computePipelineReference;
WGPUProcComputePipelineRelease computePipelineRelease;

WGPUProcDeviceCreateBindGroup deviceCreateBindGroup;
WGPUProcDeviceCreateBindGroupLayout deviceCreateBindGroupLayout;
WGPUProcDeviceCreateBuffer deviceCreateBuffer;
WGPUProcDeviceCreateBufferMapped deviceCreateBufferMapped;
WGPUProcDeviceCreateCommandEncoder deviceCreateCommandEncoder;
WGPUProcDeviceCreateComputePipeline deviceCreateComputePipeline;
WGPUProcDeviceCreatePipelineLayout deviceCreatePipelineLayout;
WGPUProcDeviceCreateRenderBundleEncoder deviceCreateRenderBundleEncoder;
WGPUProcDeviceCreateRenderPipeline deviceCreateRenderPipeline;
WGPUProcDeviceCreateSampler deviceCreateSampler;
WGPUProcDeviceCreateShaderModule deviceCreateShaderModule;
WGPUProcDeviceCreateSwapChain deviceCreateSwapChain;
WGPUProcDeviceCreateTexture deviceCreateTexture;
WGPUProcDeviceGetDefaultQueue deviceGetDefaultQueue;
WGPUProcDeviceInjectError deviceInjectError;
WGPUProcDeviceLoseForTesting deviceLoseForTesting;
WGPUProcDevicePopErrorScope devicePopErrorScope;
WGPUProcDevicePushErrorScope devicePushErrorScope;
WGPUProcDeviceSetDeviceLostCallback deviceSetDeviceLostCallback;
WGPUProcDeviceSetUncapturedErrorCallback deviceSetUncapturedErrorCallback;
WGPUProcDeviceTick deviceTick;
WGPUProcDeviceReference deviceReference;
WGPUProcDeviceRelease deviceRelease;

WGPUProcFenceGetCompletedValue fenceGetCompletedValue;
WGPUProcFenceOnCompletion fenceOnCompletion;
WGPUProcFenceReference fenceReference;
WGPUProcFenceRelease fenceRelease;

WGPUProcInstanceCreateSurface instanceCreateSurface;
WGPUProcInstanceReference instanceReference;
WGPUProcInstanceRelease instanceRelease;

WGPUProcPipelineLayoutReference pipelineLayoutReference;
WGPUProcPipelineLayoutRelease pipelineLayoutRelease;

WGPUProcQueueCreateFence queueCreateFence;
WGPUProcQueueSignal queueSignal;
WGPUProcQueueSubmit queueSubmit;
WGPUProcQueueReference queueReference;
WGPUProcQueueRelease queueRelease;

WGPUProcRenderBundleReference renderBundleReference;
WGPUProcRenderBundleRelease renderBundleRelease;

WGPUProcRenderBundleEncoderDraw renderBundleEncoderDraw;
WGPUProcRenderBundleEncoderDrawIndexed renderBundleEncoderDrawIndexed;
WGPUProcRenderBundleEncoderDrawIndexedIndirect renderBundleEncoderDrawIndexedIndirect;
WGPUProcRenderBundleEncoderDrawIndirect renderBundleEncoderDrawIndirect;
WGPUProcRenderBundleEncoderFinish renderBundleEncoderFinish;
WGPUProcRenderBundleEncoderInsertDebugMarker renderBundleEncoderInsertDebugMarker;
WGPUProcRenderBundleEncoderPopDebugGroup renderBundleEncoderPopDebugGroup;
WGPUProcRenderBundleEncoderPushDebugGroup renderBundleEncoderPushDebugGroup;
WGPUProcRenderBundleEncoderSetBindGroup renderBundleEncoderSetBindGroup;
WGPUProcRenderBundleEncoderSetIndexBuffer renderBundleEncoderSetIndexBuffer;
WGPUProcRenderBundleEncoderSetPipeline renderBundleEncoderSetPipeline;
WGPUProcRenderBundleEncoderSetVertexBuffer renderBundleEncoderSetVertexBuffer;
WGPUProcRenderBundleEncoderReference renderBundleEncoderReference;
WGPUProcRenderBundleEncoderRelease renderBundleEncoderRelease;

WGPUProcRenderPassEncoderDraw renderPassEncoderDraw;
WGPUProcRenderPassEncoderDrawIndexed renderPassEncoderDrawIndexed;
WGPUProcRenderPassEncoderDrawIndexedIndirect renderPassEncoderDrawIndexedIndirect;
WGPUProcRenderPassEncoderDrawIndirect renderPassEncoderDrawIndirect;
WGPUProcRenderPassEncoderEndPass renderPassEncoderEndPass;
WGPUProcRenderPassEncoderExecuteBundles renderPassEncoderExecuteBundles;
WGPUProcRenderPassEncoderInsertDebugMarker renderPassEncoderInsertDebugMarker;
WGPUProcRenderPassEncoderPopDebugGroup renderPassEncoderPopDebugGroup;
WGPUProcRenderPassEncoderPushDebugGroup renderPassEncoderPushDebugGroup;
WGPUProcRenderPassEncoderSetBindGroup renderPassEncoderSetBindGroup;
WGPUProcRenderPassEncoderSetBlendColor renderPassEncoderSetBlendColor;
WGPUProcRenderPassEncoderSetIndexBuffer renderPassEncoderSetIndexBuffer;
WGPUProcRenderPassEncoderSetPipeline renderPassEncoderSetPipeline;
WGPUProcRenderPassEncoderSetScissorRect renderPassEncoderSetScissorRect;
WGPUProcRenderPassEncoderSetStencilReference renderPassEncoderSetStencilReference;
WGPUProcRenderPassEncoderSetVertexBuffer renderPassEncoderSetVertexBuffer;
WGPUProcRenderPassEncoderSetViewport renderPassEncoderSetViewport;
WGPUProcRenderPassEncoderReference renderPassEncoderReference;
WGPUProcRenderPassEncoderRelease renderPassEncoderRelease;

WGPUProcRenderPipelineGetBindGroupLayout renderPipelineGetBindGroupLayout;
WGPUProcRenderPipelineReference renderPipelineReference;
WGPUProcRenderPipelineRelease renderPipelineRelease;

WGPUProcSamplerReference samplerReference;
WGPUProcSamplerRelease samplerRelease;

WGPUProcShaderModuleReference shaderModuleReference;
WGPUProcShaderModuleRelease shaderModuleRelease;

WGPUProcSurfaceReference surfaceReference;
WGPUProcSurfaceRelease surfaceRelease;

WGPUProcSwapChainConfigure swapChainConfigure;
WGPUProcSwapChainGetCurrentTextureView swapChainGetCurrentTextureView;
WGPUProcSwapChainPresent swapChainPresent;
WGPUProcSwapChainReference swapChainReference;
WGPUProcSwapChainRelease swapChainRelease;

WGPUProcTextureCreateView textureCreateView;
WGPUProcTextureDestroy textureDestroy;
WGPUProcTextureReference textureReference;
WGPUProcTextureRelease textureRelease;

WGPUProcTextureViewReference textureViewReference;
WGPUProcTextureViewRelease textureViewRelease;

} DawnProcTable;

#endif // DAWN_DAWN_PROC_TABLE_H_
Loading