Skip to content

Update dawn #244

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ set(SLANG_RHI_FETCH_OPTIX_URL "https://developer.download.nvidia.com/redist/opti

# Fetch Dawn options
option(SLANG_RHI_FETCH_DAWN "Fetch Dawn" ON)
set(SLANG_RHI_FETCH_DAWN_VERSION "131.0.6738.0" CACHE STRING "Dawn version to fetch")
set(SLANG_RHI_FETCH_DAWN_VERSION "135.0.7049.80" CACHE STRING "Dawn version to fetch")


if(SLANG_RHI_BUILD_SHARED)
Expand Down
85 changes: 17 additions & 68 deletions src/wgpu/wgpu-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,37 @@
// clang-format off

#define SLANG_RHI_WGPU_PROCS(x) \
/* TODO(374150686): Remove these Emscripten specific declarations from the */ \
/* header once they are fully deprecated. */ \
x(AdapterInfoFreeMembers) \
x(AdapterPropertiesMemoryHeapsFreeMembers) \
x(AdapterPropertiesSubgroupMatrixConfigsFreeMembers) \
x(CreateInstance) \
x(DrmFormatCapabilitiesFreeMembers) \
x(GetInstanceFeatures) \
x(DawnDrmFormatCapabilitiesFreeMembers) \
x(GetInstanceCapabilities) \
x(GetProcAddress) \
x(GetProcAddress2) \
x(SharedBufferMemoryEndAccessStateFreeMembers) \
x(SharedTextureMemoryEndAccessStateFreeMembers) \
x(SupportedWGSLLanguageFeaturesFreeMembers) \
x(SupportedFeaturesFreeMembers) \
x(SurfaceCapabilitiesFreeMembers) \
/* Procs of Adapter */ \
x(AdapterCreateDevice) \
x(AdapterEnumerateFeatures) \
x(AdapterGetFeatures) \
x(AdapterGetFormatCapabilities) \
x(AdapterGetInfo) \
x(AdapterGetInstance) \
x(AdapterGetLimits) \
x(AdapterHasFeature) \
x(AdapterRequestDevice) \
x(AdapterRequestDevice2) \
x(AdapterRequestDeviceF) \
x(AdapterAddRef) \
x(AdapterRelease) \
/* Procs of BindGroup */ \
x(BindGroupSetLabel) \
x(BindGroupSetLabel2) \
x(BindGroupAddRef) \
x(BindGroupRelease) \
/* Procs of BindGroupLayout */ \
x(BindGroupLayoutSetLabel) \
x(BindGroupLayoutSetLabel2) \
x(BindGroupLayoutAddRef) \
x(BindGroupLayoutRelease) \
/* Procs of Buffer */ \
Expand All @@ -51,16 +51,14 @@
x(BufferGetSize) \
x(BufferGetUsage) \
x(BufferMapAsync) \
x(BufferMapAsync2) \
x(BufferMapAsyncF) \
x(BufferReadMappedRange) \
x(BufferSetLabel) \
x(BufferSetLabel2) \
x(BufferUnmap) \
x(BufferWriteMappedRange) \
x(BufferAddRef) \
x(BufferRelease) \
/* Procs of CommandBuffer */ \
x(CommandBufferSetLabel) \
x(CommandBufferSetLabel2) \
x(CommandBufferAddRef) \
x(CommandBufferRelease) \
/* Procs of CommandEncoder */ \
Expand All @@ -73,15 +71,11 @@
x(CommandEncoderCopyTextureToTexture) \
x(CommandEncoderFinish) \
x(CommandEncoderInjectValidationError) \
x(CommandEncoderInjectValidationError2) \
x(CommandEncoderInsertDebugMarker) \
x(CommandEncoderInsertDebugMarker2) \
x(CommandEncoderPopDebugGroup) \
x(CommandEncoderPushDebugGroup) \
x(CommandEncoderPushDebugGroup2) \
x(CommandEncoderResolveQuerySet) \
x(CommandEncoderSetLabel) \
x(CommandEncoderSetLabel2) \
x(CommandEncoderWriteBuffer) \
x(CommandEncoderWriteTimestamp) \
x(CommandEncoderAddRef) \
Expand All @@ -91,21 +85,18 @@
x(ComputePassEncoderDispatchWorkgroupsIndirect) \
x(ComputePassEncoderEnd) \
x(ComputePassEncoderInsertDebugMarker) \
x(ComputePassEncoderInsertDebugMarker2) \
x(ComputePassEncoderPopDebugGroup) \
x(ComputePassEncoderPushDebugGroup) \
x(ComputePassEncoderPushDebugGroup2) \
x(ComputePassEncoderSetBindGroup) \
x(ComputePassEncoderSetImmediateData) \
x(ComputePassEncoderSetLabel) \
x(ComputePassEncoderSetLabel2) \
x(ComputePassEncoderSetPipeline) \
x(ComputePassEncoderWriteTimestamp) \
x(ComputePassEncoderAddRef) \
x(ComputePassEncoderRelease) \
/* Procs of ComputePipeline */ \
x(ComputePipelineGetBindGroupLayout) \
x(ComputePipelineSetLabel) \
x(ComputePipelineSetLabel2) \
x(ComputePipelineAddRef) \
x(ComputePipelineRelease) \
/* Procs of Device */ \
Expand All @@ -115,49 +106,37 @@
x(DeviceCreateCommandEncoder) \
x(DeviceCreateComputePipeline) \
x(DeviceCreateComputePipelineAsync) \
x(DeviceCreateComputePipelineAsync2) \
x(DeviceCreateComputePipelineAsyncF) \
x(DeviceCreateErrorBuffer) \
x(DeviceCreateErrorExternalTexture) \
x(DeviceCreateErrorShaderModule) \
x(DeviceCreateErrorShaderModule2) \
x(DeviceCreateErrorTexture) \
x(DeviceCreateExternalTexture) \
x(DeviceCreatePipelineLayout) \
x(DeviceCreateQuerySet) \
x(DeviceCreateRenderBundleEncoder) \
x(DeviceCreateRenderPipeline) \
x(DeviceCreateRenderPipelineAsync) \
x(DeviceCreateRenderPipelineAsync2) \
x(DeviceCreateRenderPipelineAsyncF) \
x(DeviceCreateSampler) \
x(DeviceCreateShaderModule) \
x(DeviceCreateSwapChain) \
x(DeviceCreateTexture) \
x(DeviceDestroy) \
x(DeviceEnumerateFeatures) \
x(DeviceForceLoss) \
x(DeviceForceLoss2) \
x(DeviceGetAHardwareBufferProperties) \
x(DeviceGetAdapter) \
x(DeviceGetAdapterInfo) \
x(DeviceGetFeatures) \
x(DeviceGetLimits) \
x(DeviceGetLostFuture) \
x(DeviceGetQueue) \
x(DeviceGetSupportedSurfaceUsage) \
x(DeviceHasFeature) \
x(DeviceImportSharedBufferMemory) \
x(DeviceImportSharedFence) \
x(DeviceImportSharedTextureMemory) \
x(DeviceInjectError) \
x(DeviceInjectError2) \
x(DevicePopErrorScope) \
x(DevicePopErrorScope2) \
x(DevicePopErrorScopeF) \
x(DevicePushErrorScope) \
x(DeviceSetDeviceLostCallback) \
x(DeviceSetLabel) \
x(DeviceSetLabel2) \
x(DeviceSetLoggingCallback) \
x(DeviceSetUncapturedErrorCallback) \
x(DeviceTick) \
x(DeviceValidateTextureDescriptor) \
x(DeviceAddRef) \
Expand All @@ -167,49 +146,40 @@
x(ExternalTextureExpire) \
x(ExternalTextureRefresh) \
x(ExternalTextureSetLabel) \
x(ExternalTextureSetLabel2) \
x(ExternalTextureAddRef) \
x(ExternalTextureRelease) \
/* Procs of Instance */ \
x(InstanceCreateSurface) \
x(InstanceEnumerateWGSLLanguageFeatures) \
x(InstanceGetWGSLLanguageFeatures) \
x(InstanceHasWGSLLanguageFeature) \
x(InstanceProcessEvents) \
x(InstanceRequestAdapter) \
x(InstanceRequestAdapter2) \
x(InstanceRequestAdapterF) \
x(InstanceWaitAny) \
x(InstanceAddRef) \
x(InstanceRelease) \
/* Procs of PipelineLayout */ \
x(PipelineLayoutSetLabel) \
x(PipelineLayoutSetLabel2) \
x(PipelineLayoutAddRef) \
x(PipelineLayoutRelease) \
/* Procs of QuerySet */ \
x(QuerySetDestroy) \
x(QuerySetGetCount) \
x(QuerySetGetType) \
x(QuerySetSetLabel) \
x(QuerySetSetLabel2) \
x(QuerySetAddRef) \
x(QuerySetRelease) \
/* Procs of Queue */ \
x(QueueCopyExternalTextureForBrowser) \
x(QueueCopyTextureForBrowser) \
x(QueueOnSubmittedWorkDone) \
x(QueueOnSubmittedWorkDone2) \
x(QueueOnSubmittedWorkDoneF) \
x(QueueSetLabel) \
x(QueueSetLabel2) \
x(QueueSubmit) \
x(QueueWriteBuffer) \
x(QueueWriteTexture) \
x(QueueAddRef) \
x(QueueRelease) \
/* Procs of RenderBundle */ \
x(RenderBundleSetLabel) \
x(RenderBundleSetLabel2) \
x(RenderBundleAddRef) \
x(RenderBundleRelease) \
/* Procs of RenderBundleEncoder */ \
Expand All @@ -219,14 +189,12 @@
x(RenderBundleEncoderDrawIndirect) \
x(RenderBundleEncoderFinish) \
x(RenderBundleEncoderInsertDebugMarker) \
x(RenderBundleEncoderInsertDebugMarker2) \
x(RenderBundleEncoderPopDebugGroup) \
x(RenderBundleEncoderPushDebugGroup) \
x(RenderBundleEncoderPushDebugGroup2) \
x(RenderBundleEncoderSetBindGroup) \
x(RenderBundleEncoderSetImmediateData) \
x(RenderBundleEncoderSetIndexBuffer) \
x(RenderBundleEncoderSetLabel) \
x(RenderBundleEncoderSetLabel2) \
x(RenderBundleEncoderSetPipeline) \
x(RenderBundleEncoderSetVertexBuffer) \
x(RenderBundleEncoderAddRef) \
Expand All @@ -241,18 +209,16 @@
x(RenderPassEncoderEndOcclusionQuery) \
x(RenderPassEncoderExecuteBundles) \
x(RenderPassEncoderInsertDebugMarker) \
x(RenderPassEncoderInsertDebugMarker2) \
x(RenderPassEncoderMultiDrawIndexedIndirect) \
x(RenderPassEncoderMultiDrawIndirect) \
x(RenderPassEncoderPixelLocalStorageBarrier) \
x(RenderPassEncoderPopDebugGroup) \
x(RenderPassEncoderPushDebugGroup) \
x(RenderPassEncoderPushDebugGroup2) \
x(RenderPassEncoderSetBindGroup) \
x(RenderPassEncoderSetBlendConstant) \
x(RenderPassEncoderSetImmediateData) \
x(RenderPassEncoderSetIndexBuffer) \
x(RenderPassEncoderSetLabel) \
x(RenderPassEncoderSetLabel2) \
x(RenderPassEncoderSetPipeline) \
x(RenderPassEncoderSetScissorRect) \
x(RenderPassEncoderSetStencilReference) \
Expand All @@ -264,20 +230,15 @@
/* Procs of RenderPipeline */ \
x(RenderPipelineGetBindGroupLayout) \
x(RenderPipelineSetLabel) \
x(RenderPipelineSetLabel2) \
x(RenderPipelineAddRef) \
x(RenderPipelineRelease) \
/* Procs of Sampler */ \
x(SamplerSetLabel) \
x(SamplerSetLabel2) \
x(SamplerAddRef) \
x(SamplerRelease) \
/* Procs of ShaderModule */ \
x(ShaderModuleGetCompilationInfo) \
x(ShaderModuleGetCompilationInfo2) \
x(ShaderModuleGetCompilationInfoF) \
x(ShaderModuleSetLabel) \
x(ShaderModuleSetLabel2) \
x(ShaderModuleAddRef) \
x(ShaderModuleRelease) \
/* Procs of SharedBufferMemory */ \
Expand All @@ -287,7 +248,6 @@
x(SharedBufferMemoryGetProperties) \
x(SharedBufferMemoryIsDeviceLost) \
x(SharedBufferMemorySetLabel) \
x(SharedBufferMemorySetLabel2) \
x(SharedBufferMemoryAddRef) \
x(SharedBufferMemoryRelease) \
/* Procs of SharedFence */ \
Expand All @@ -301,26 +261,17 @@
x(SharedTextureMemoryGetProperties) \
x(SharedTextureMemoryIsDeviceLost) \
x(SharedTextureMemorySetLabel) \
x(SharedTextureMemorySetLabel2) \
x(SharedTextureMemoryAddRef) \
x(SharedTextureMemoryRelease) \
/* Procs of Surface */ \
x(SurfaceConfigure) \
x(SurfaceGetCapabilities) \
x(SurfaceGetCurrentTexture) \
x(SurfaceGetPreferredFormat) \
x(SurfacePresent) \
x(SurfaceSetLabel) \
x(SurfaceSetLabel2) \
x(SurfaceUnconfigure) \
x(SurfaceAddRef) \
x(SurfaceRelease) \
/* Procs of SwapChain */ \
x(SwapChainGetCurrentTexture) \
x(SwapChainGetCurrentTextureView) \
x(SwapChainPresent) \
x(SwapChainAddRef) \
x(SwapChainRelease) \
/* Procs of Texture */ \
x(TextureCreateErrorView) \
x(TextureCreateView) \
Expand All @@ -334,12 +285,10 @@
x(TextureGetUsage) \
x(TextureGetWidth) \
x(TextureSetLabel) \
x(TextureSetLabel2) \
x(TextureAddRef) \
x(TextureRelease) \
/* Procs of TextureView */ \
x(TextureViewSetLabel) \
x(TextureViewSetLabel2) \
x(TextureViewAddRef) \
x(TextureViewRelease)

Expand Down
21 changes: 12 additions & 9 deletions src/wgpu/wgpu-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Result DeviceImpl::createBuffer(const BufferDesc& desc, const void* initData, IB
bufferDesc.usage |= WGPUBufferUsage_CopyDst;
}

bufferDesc.label = desc.label;
bufferDesc.label = translateString(desc.label);
buffer->m_buffer = m_ctx.api.wgpuDeviceCreateBuffer(m_ctx.device, &bufferDesc);
if (!buffer->m_buffer)
{
Expand All @@ -74,13 +74,13 @@ Result DeviceImpl::createBuffer(const BufferDesc& desc, const void* initData, IB

// Wait for the command buffer to finish executing
{
WGPUQueueWorkDoneStatus status = WGPUQueueWorkDoneStatus_Unknown;
WGPUQueueWorkDoneCallbackInfo2 callbackInfo = {};
WGPUQueueWorkDoneStatus status = WGPUQueueWorkDoneStatus(0);
WGPUQueueWorkDoneCallbackInfo callbackInfo = {};
callbackInfo.mode = WGPUCallbackMode_WaitAnyOnly;
callbackInfo.callback = [](WGPUQueueWorkDoneStatus status_, void* userdata1, void* userdata2)
{ *(WGPUQueueWorkDoneStatus*)userdata1 = status_; };
callbackInfo.userdata1 = &status;
WGPUFuture future = m_ctx.api.wgpuQueueOnSubmittedWorkDone2(queue, callbackInfo);
WGPUFuture future = m_ctx.api.wgpuQueueOnSubmittedWorkDone(queue, callbackInfo);
constexpr size_t futureCount = 1;
WGPUFutureWaitInfo futures[futureCount] = {{future}};
uint64_t timeoutNS = UINT64_MAX;
Expand Down Expand Up @@ -119,17 +119,20 @@ Result DeviceImpl::mapBuffer(IBuffer* buffer, CpuAccessMode mode, void** outData
size_t offset = 0;
size_t size = bufferImpl->m_desc.size;

WGPUMapAsyncStatus status = WGPUMapAsyncStatus_Unknown;
WGPUBufferMapCallbackInfo2 callbackInfo = {};
WGPUMapAsyncStatus status = WGPUMapAsyncStatus(0);
WGPUBufferMapCallbackInfo callbackInfo = {};
callbackInfo.mode = WGPUCallbackMode_WaitAnyOnly;
callbackInfo.callback = [](WGPUMapAsyncStatus status_, const char* message, void* userdata1, void* userdata2)
callbackInfo.callback = [](WGPUMapAsyncStatus status_, WGPUStringView message, void* userdata1, void* userdata2)
{
*(WGPUMapAsyncStatus*)userdata1 = status_;
if (status_ != WGPUMapAsyncStatus_Success)
fprintf(stderr, "MapAsync wait failed with message: %s\n", message);
{
static_cast<DeviceImpl*>(userdata2)->reportError("wgpuBufferMapAsync", message);
}
};
callbackInfo.userdata1 = &status;
WGPUFuture future = m_ctx.api.wgpuBufferMapAsync2(bufferImpl->m_buffer, mapMode, offset, size, callbackInfo);
callbackInfo.userdata2 = this;
WGPUFuture future = m_ctx.api.wgpuBufferMapAsync(bufferImpl->m_buffer, mapMode, offset, size, callbackInfo);
WGPUFutureWaitInfo futures[1] = {{future}};
uint64_t timeoutNS = UINT64_MAX;
WGPUWaitStatus waitStatus =
Expand Down
Loading
Loading