File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
filament/backend/src/webgpu Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 5353#include < sstream>
5454#include < utility>
5555
56+ using namespace std ::chrono_literals;
57+
5658namespace filament ::backend {
5759
5860Driver* WebGPUDriver::create (WebGPUPlatform& platform, const Platform::DriverConfig& driverConfig) noexcept {
@@ -923,6 +925,22 @@ void WebGPUDriver::commit(Handle<HwSwapChain> sch) {
923925 assert_invariant (mCommandBuffer );
924926 mCommandEncoder = nullptr ;
925927 mQueue .Submit (1 , &mCommandBuffer );
928+
929+ static bool firstRender = true ;
930+ // For the first frame rendered, we need to make sure the work is done before presenting or we
931+ // get a purple flash
932+ if (firstRender) {
933+ auto f = mQueue .OnSubmittedWorkDone (wgpu::CallbackMode::WaitAnyOnly,
934+ [=](wgpu::QueueWorkDoneStatus) {});
935+ const wgpu::Instance instance = mAdapter .GetInstance ();
936+ auto wStatus = instance.WaitAny (f,
937+ std::chrono::duration_cast<std::chrono::nanoseconds>(1s).count ());
938+ if (wStatus != wgpu::WaitStatus::Success) {
939+ FWGPU_LOGW << " Waiting for first frame work to finish resulted in an error"
940+ << static_cast <uint32_t >(wStatus);
941+ }
942+ firstRender = false ;
943+ }
926944 mCommandBuffer = nullptr ;
927945 mTextureView = nullptr ;
928946 assert_invariant (mSwapChain );
You can’t perform that action at this time.
0 commit comments