Skip to content

Commit 37620d9

Browse files
committed
PR Feedback (temporary commit)
1 parent 3257e3a commit 37620d9

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

filament/backend/CMakeLists.txt

+14
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,16 @@ if (FILAMENT_SUPPORTS_WEBGPU)
255255
elseif (ANDROID)
256256
list(APPEND SRCS src/webgpu/platform/WebGPUPlatformAndroid.cpp)
257257
endif()
258+
259+
if (TNT_DEV)
260+
set(FILAMENT_WEBGPU_IMMEDIATE_ERROR_HANDLING_DEFAULT ON)
261+
else()
262+
set(FILAMENT_WEBGPU_IMMEDIATE_ERROR_HANDLING_DEFAULT OFF)
263+
endif()
264+
265+
option(FILAMENT_WEBGPU_IMMEDIATE_ERROR_HANDLING
266+
"Enable immediate_error_handling for the WebGPU backend Dawn implementation"
267+
${FILAMENT_WEBGPU_IMMEDIATE_ERROR_HANDLING_DEFAULT})
258268
endif()
259269

260270
if (ANDROID)
@@ -441,6 +451,10 @@ if (FILAMENT_SUPPORTS_METAL)
441451
target_compile_definitions(${TARGET} PRIVATE $<$<BOOL:${FILAMENT_METAL_PROFILING}>:FILAMENT_METAL_PROFILING>)
442452
endif()
443453

454+
if (FILAMENT_SUPPORTS_WEBGPU)
455+
target_compile_definitions(${TARGET} PRIVATE $<$<BOOL:${FILAMENT_WEBGPU_IMMEDIATE_ERROR_HANDLING}>:FILAMENT_WEBGPU_IMMEDIATE_ERROR_HANDLING>)
456+
endif()
457+
444458
target_link_libraries(${TARGET} PRIVATE
445459
${OSMESA_LINKER_FLAGS}
446460
$<$<AND:$<PLATFORM_ID:Linux>,$<CONFIG:Release>>:${LINUX_LINKER_OPTIMIZATION_FLAGS}>

filament/backend/include/backend/platforms/WebGPUPlatform.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class WebGPUPlatform final : public Platform {
5757
const Platform::DriverConfig& driverConfig) noexcept override;
5858

5959
private:
60-
wgpu::Instance mInstance;
60+
wgpu::Instance mInstance; // we may consider having the driver own this in the future
6161
};
6262

6363
}// namespace filament::backend

filament/backend/src/webgpu/WebGPUDriver.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ void WebGPUDriver::createSwapChainR(Handle<HwSwapChain> sch, void* nativeWindow,
461461
#endif
462462
mQueue = mDevice.GetQueue();
463463
// TODO configure the surface (maybe before or after creating the swapchain?
464-
// how do we get the
465-
// surface extent?)
464+
// how do we get the surface extent?)
466465
// TODO actually create the swapchain
467466
FWGPU_LOGW << "WebGPU support is still essentially a no-op at this point in development (only "
468467
"background components have been instantiated/selected, such as surface/screen, "

filament/backend/src/webgpu/platform/WebGPUPlatform.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,24 @@ namespace {
3333

3434
//either returns a valid instance or panics
3535
[[nodiscard]] wgpu::Instance createInstance() {
36+
wgpu::DawnTogglesDescriptor dawnTogglesDescriptor{};
37+
#if defined(FILAMENT_WEBGPU_IMMEDIATE_ERROR_HANDLING)
38+
#if FWGPU_ENABLED(FWGPU_PRINT_SYSTEM)
39+
FWGPU_LOGI << "setting on toggle enable_immediate_error_handling"
40+
<< utils::io::endl;
41+
#endif
3642
/**
3743
* Have the un-captured error callback invoked immediately when an error occurs, rather than
3844
* waiting for the next Tick. This enables using the stack trace in which the un-captured error
3945
* occurred when breaking into the un-captured error callback.
4046
* https://crbug.com/dawn/1789
4147
*/
4248
static const char* toggleName = "enable_immediate_error_handling";
43-
wgpu::DawnTogglesDescriptor dawnTogglesDescriptor{};
4449
dawnTogglesDescriptor.enabledToggleCount = 1;
4550
dawnTogglesDescriptor.enabledToggles = &toggleName;
46-
wgpu::InstanceDescriptor instanceDescriptor{ .nextInChain = &dawnTogglesDescriptor,
51+
#endif
52+
wgpu::InstanceDescriptor instanceDescriptor{
53+
.nextInChain = &dawnTogglesDescriptor,
4754
.capabilities = {
4855
.timedWaitAnyEnable = true// TODO consider using pure async instead
4956
} };
@@ -65,6 +72,7 @@ wgpu::Adapter WebGPUPlatform::requestAdapter(wgpu::Surface const& surface) {
6572
mInstance.RequestAdapter(&adaptorOptions, wgpu::CallbackMode::WaitAnyOnly,
6673
[&adapter](wgpu::RequestAdapterStatus const status,
6774
wgpu::Adapter const& readyAdapter, wgpu::StringView const message) {
75+
// TODO consider more robust error handling
6876
FILAMENT_CHECK_POSTCONDITION(status == wgpu::RequestAdapterStatus::Success)
6977
<< "Unable to request a WebGPU adapter. Status "
7078
<< static_cast<uint32_t>(status)

0 commit comments

Comments
 (0)