Skip to content

Commit 45a8dab

Browse files
amaioranoDawn LUCI CQ
authored andcommitted
dawn: add dawn::Platform hook for querying feature flags
And use it to query "WebGPUUseDXC". This is important because the moment the feature flag is queried in Chrome is when the user is made part of the study. Since we normally want only users using WebGPU to be in the study, we need this query to happen from within Dawn. Bug: chromium:1474897 Change-Id: I2adad2b3a256fad5c51080b80b348c0ffd5a914d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/153181 Kokoro: Kokoro <[email protected]> Commit-Queue: Antonio Maiorano <[email protected]> Reviewed-by: Corentin Wallez <[email protected]>
1 parent dc5ac88 commit 45a8dab

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

include/dawn/platform/DawnPlatform.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class DAWN_PLATFORM_EXPORT WorkerTaskPool {
7373
void* userdata) = 0;
7474
};
7575

76+
// These features map to similarly named ones in src/chromium/src/gpu/config/gpu_finch_features.h
77+
// in `namespace features`.
78+
enum class Features {
79+
kWebGPUUseDXC,
80+
};
81+
7682
class DAWN_PLATFORM_EXPORT Platform {
7783
public:
7884
Platform();
@@ -123,6 +129,9 @@ class DAWN_PLATFORM_EXPORT Platform {
123129

124130
virtual std::unique_ptr<WorkerTaskPool> CreateWorkerTaskPool();
125131

132+
// Hook for querying if a Finch feature is enabled.
133+
virtual bool IsFeatureEnabled(Features feature);
134+
126135
private:
127136
Platform(const Platform&) = delete;
128137
Platform& operator=(const Platform&) = delete;

src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "dawn/native/d3d12/DeviceD3D12.h"
2727
#include "dawn/native/d3d12/PlatformFunctionsD3D12.h"
2828
#include "dawn/native/d3d12/UtilsD3D12.h"
29+
#include "dawn/platform/DawnPlatform.h"
2930

3031
namespace dawn::native::d3d12 {
3132

@@ -489,7 +490,10 @@ void PhysicalDevice::SetupBackendAdapterToggles(TogglesState* adapterToggles) co
489490
if (GetDeviceInfo().shaderModel <= 60) {
490491
adapterToggles->ForceSet(Toggle::UseDXC, false);
491492
}
492-
adapterToggles->Default(Toggle::UseDXC, true);
493+
494+
bool useDxc =
495+
GetInstance()->GetPlatform()->IsFeatureEnabled(dawn::platform::Features::kWebGPUUseDXC);
496+
adapterToggles->Default(Toggle::UseDXC, useDxc);
493497
#else
494498
// Default to using FXC
495499
if (!GetBackend()->IsDXCAvailable()) {

src/dawn/platform/DawnPlatform.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,16 @@ std::unique_ptr<dawn::platform::WorkerTaskPool> Platform::CreateWorkerTaskPool()
7979
return std::make_unique<AsyncWorkerThreadPool>();
8080
}
8181

82+
bool Platform::IsFeatureEnabled(Features feature) {
83+
switch (feature) {
84+
case Features::kWebGPUUseDXC:
85+
#ifdef DAWN_USE_BUILT_DXC
86+
return true;
87+
#else
88+
return false;
89+
#endif
90+
}
91+
return false;
92+
}
93+
8294
} // namespace dawn::platform

0 commit comments

Comments
 (0)