Skip to content

Commit e9b74a8

Browse files
authored
Merge pull request #38 from brendan-duncan/dawn-updates
Dawn updates
2 parents d86d7eb + 0aff990 commit e9b74a8

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

lib/lib_webgpu.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,12 @@ EM_BOOL wgpu_is_device(WGpuObjectBase object);
432432

433433
WGpuQueue wgpu_device_get_queue(WGpuDevice device);
434434

435+
#ifdef __EMSCRIPTEN__
436+
void wgpu_device_tick(WGpuDevice device) __attribute__((deprecated("The function wgpu_device_tick() is not available when targeting the web. Presentation always occurs when yielding out from browser event loop.")));
437+
#else
438+
void wgpu_device_tick(WGpuDevice device);
439+
#endif
440+
435441
WGpuBuffer wgpu_device_create_buffer(WGpuDevice device, const WGpuBufferDescriptor *bufferDesc NOTNULL);
436442
WGpuTexture wgpu_device_create_texture(WGpuDevice device, const WGpuTextureDescriptor *textureDesc NOTNULL);
437443
WGpuSampler wgpu_device_create_sampler(WGpuDevice device, const WGpuSamplerDescriptor *samplerDesc NOTNULL);

lib/lib_webgpu_cpp11.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const WGpuSamplerBindingLayout WGPU_SAMPLER_BINDING_LAYOUT_DEFAULT_INITIALIZER =
7070
const WGpuTextureBindingLayout WGPU_TEXTURE_BINDING_LAYOUT_DEFAULT_INITIALIZER = {
7171
WGPU_TEXTURE_SAMPLE_TYPE_FLOAT, /* sampleType */
7272
WGPU_TEXTURE_VIEW_DIMENSION_2D, /* viewDimension */
73+
false, /* multisampled */
7374
};
7475

7576
const WGpuBindGroupEntry WGPU_BIND_GROUP_ENTRY_DEFAULT_INITIALIZER = {

lib/lib_webgpu_dawn.cpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,13 @@ const WGPUFilterMode WGPU_FILTER_MODE_to_Dawn[] = {
399399
WGPUFilterMode_Linear
400400
};
401401
#define wgpu_filter_mode_to_dawn(mode) WGPU_FILTER_MODE_to_Dawn[mode]
402+
403+
const WGPUMipmapFilterMode WGPU_MIPMAP_FILTER_MODE_to_Dawn[] = {
404+
WGPUMipmapFilterMode_Force32,
405+
WGPUMipmapFilterMode_Nearest,
406+
WGPUMipmapFilterMode_Linear
407+
};
408+
#define wgpu_mipmap_filter_mode_to_dawn(mode) WGPU_MIPMAP_FILTER_MODE_to_Dawn[mode]
402409

403410
const WGPUCompareFunction WGPU_COMPARE_FUNCTION_to_Dawn[] = {
404411
WGPUCompareFunction_Undefined,
@@ -1113,6 +1120,12 @@ WGpuQueue wgpu_device_get_queue(WGpuDevice device) {
11131120
return _wgpu_store_and_set_parent(kWebGPUQueue, queue, device);
11141121
}
11151122

1123+
void wgpu_device_tick(WGpuDevice device) {
1124+
assert(wgpu_is_device(device));
1125+
WGPUDevice _device = _wgpu_get_dawn<WGPUDevice>(device);
1126+
wgpuDeviceTick(_device);
1127+
}
1128+
11161129
WGpuBuffer wgpu_device_create_buffer(WGpuDevice device, const WGpuBufferDescriptor* bufferDesc) {
11171130
assert(wgpu_is_device(device));
11181131
assert(bufferDesc);
@@ -1165,7 +1178,7 @@ WGpuSampler wgpu_device_create_sampler(WGpuDevice device, const WGpuSamplerDescr
11651178
_desc.addressModeW = wgpu_address_mode_to_dawn(samplerDesc->addressModeW);
11661179
_desc.magFilter = wgpu_filter_mode_to_dawn(samplerDesc->magFilter);
11671180
_desc.minFilter = wgpu_filter_mode_to_dawn(samplerDesc->minFilter);
1168-
_desc.mipmapFilter = wgpu_filter_mode_to_dawn(samplerDesc->mipmapFilter);
1181+
_desc.mipmapFilter = wgpu_mipmap_filter_mode_to_dawn(samplerDesc->mipmapFilter);
11691182
_desc.lodMinClamp = samplerDesc->lodMinClamp;
11701183
_desc.lodMaxClamp = samplerDesc->lodMaxClamp;
11711184
_desc.compare = wgpu_compare_function_to_dawn(samplerDesc->compare);
@@ -1963,7 +1976,6 @@ static WGPURenderPassColorAttachment getColorAttachInfo(const WGpuRenderPassColo
19631976
_attachment.resolveTarget = _wgpu_get_dawn<WGPUTextureView>(colorAttachment.resolveTarget);
19641977
_attachment.loadOp = wgpu_load_op_to_dawn(colorAttachment.loadOp);
19651978
_attachment.storeOp = wgpu_store_op_to_dawn(colorAttachment.storeOp);
1966-
_attachment.clearColor = WGPUColor{ colorAttachment.clearValue.r, colorAttachment.clearValue.g, colorAttachment.clearValue.b, colorAttachment.clearValue.a };
19671979
_attachment.clearValue = WGPUColor{ colorAttachment.clearValue.r, colorAttachment.clearValue.g, colorAttachment.clearValue.b, colorAttachment.clearValue.a };
19681980
return _attachment;
19691981
}
@@ -1990,11 +2002,10 @@ WGpuRenderPassEncoder wgpu_command_encoder_begin_render_pass(WGpuCommandEncoder
19902002
depthStencil.depthLoadOp = wgpu_load_op_to_dawn(_depthStencil.depthLoadOp);
19912003
depthStencil.depthStoreOp = wgpu_store_op_to_dawn(_depthStencil.depthStoreOp);
19922004
depthStencil.depthReadOnly = _depthStencil.depthReadOnly;
1993-
depthStencil.clearDepth = _depthStencil.depthClearValue;
19942005
depthStencil.depthClearValue = _depthStencil.depthClearValue;
19952006
depthStencil.stencilLoadOp = wgpu_load_op_to_dawn(_depthStencil.stencilLoadOp);
19962007
depthStencil.stencilStoreOp = wgpu_store_op_to_dawn(_depthStencil.stencilStoreOp);
1997-
depthStencil.clearStencil = _depthStencil.stencilClearValue;
2008+
depthStencil.stencilClearValue = _depthStencil.stencilClearValue;
19982009
depthStencil.stencilReadOnly = _depthStencil.stencilReadOnly;
19992010
_desc.depthStencilAttachment = &depthStencil;
20002011
}
@@ -2011,8 +2022,8 @@ WGpuRenderPassEncoder wgpu_command_encoder_begin_render_pass(WGpuCommandEncoder
20112022
}
20122023
_desc.timestampWrites = timestampWrites.data();
20132024

2025+
WGPURenderPassDescriptorMaxDrawCount chainedDesc;
20142026
if (renderPassDesc->maxDrawCount > 0) {
2015-
WGPURenderPassDescriptorMaxDrawCount chainedDesc;
20162027
chainedDesc.maxDrawCount = renderPassDesc->maxDrawCount;
20172028
chainedDesc.chain = { nullptr, WGPUSType_RenderPassDescriptorMaxDrawCount };
20182029
_desc.nextInChain = reinterpret_cast<WGPUChainedStruct*>(&chainedDesc);
@@ -2527,7 +2538,6 @@ void wgpu_canvas_context_configure(WGpuCanvasContext canvasContext, const WGpuCa
25272538
swapDesc.usage = (WGPUTextureUsageFlags)config->usage;
25282539
swapDesc.nextInChain = nullptr;
25292540
swapDesc.label = nullptr;
2530-
swapDesc.implementation = 0;
25312541
context->swapChain = wgpuDeviceCreateSwapChain(_wgpu_get_dawn<WGPUDevice>(config->device), context->surface, &swapDesc);
25322542
}
25332543

@@ -2569,6 +2579,10 @@ void wgpu_device_set_lost_callback(WGpuDevice device, WGpuDeviceLostCallback cal
25692579
assert(wgpu_is_device(device));
25702580
assert(callback);
25712581
WGPUDevice _device = _wgpu_get_dawn<WGPUDevice>(device);
2582+
if (callback == nullptr) {
2583+
wgpuDeviceSetDeviceLostCallback(_device, nullptr, nullptr);
2584+
return;
2585+
}
25722586
struct _Data {
25732587
WGpuDevice device;
25742588
WGpuDeviceLostCallback callback;

0 commit comments

Comments
 (0)