File tree Expand file tree Collapse file tree 2 files changed +53
-10
lines changed Expand file tree Collapse file tree 2 files changed +53
-10
lines changed Original file line number Diff line number Diff line change @@ -1732,20 +1732,18 @@ using namespace dx12_internal;
1732
1732
const uint64_t wrapped_offset_end = wrapped_offset + stats.descriptorCopyCount ;
1733
1733
1734
1734
// Check that gpu offset doesn't intersect with our newly allocated range, if it does, we need to wait until gpu finishes with it:
1735
+ // First check is with the cached completed value to avoid API call into fence object
1735
1736
uint64_t wrapped_gpu_offset = heap.cached_completedValue % wrap_effective_size;
1736
- int loop_cnt = 0 ; // safety
1737
- while (wrapped_offset < wrapped_gpu_offset && wrapped_gpu_offset <= wrapped_offset_end)
1737
+ if ((wrapped_offset < wrapped_gpu_offset) && (wrapped_gpu_offset < wrapped_offset_end))
1738
1738
{
1739
- wrapped_gpu_offset = device->descriptorheap_res .fence ->GetCompletedValue () % wrap_effective_size;
1740
-
1741
- // Check that the GPU has even a chance of freeing up the requested descriptors:
1742
- const uint64_t wrapped_signaled_offset = heap.fenceValue % wrap_effective_size;
1743
- if (wrapped_signaled_offset <= wrapped_offset_end || loop_cnt > 10 )
1739
+ // Second check is with current fence value with API call:
1740
+ wrapped_gpu_offset = heap.fence ->GetCompletedValue () % wrap_effective_size;
1741
+ if ((wrapped_offset < wrapped_gpu_offset) && (wrapped_gpu_offset < wrapped_offset_end))
1744
1742
{
1745
- assert (0 );
1746
- break ; // break out from waiting for GPU, because it might cause infinite loop
1743
+ // Third step is actual wait until GPU updates fence so that requested descriptors are free:
1744
+ HRESULT hr = heap.fence ->SetEventOnCompletion (heap.fenceValue , nullptr );
1745
+ assert (SUCCEEDED (hr));
1747
1746
}
1748
- loop_cnt++;
1749
1747
}
1750
1748
1751
1749
gpu_handle.ptr += (size_t )ringoffset;
Original file line number Diff line number Diff line change @@ -732,8 +732,53 @@ namespace wi::helper
732
732
733
733
bool FileExists (const std::string& fileName)
734
734
{
735
+ #ifndef PLATFORM_UWP
735
736
bool exists = std::filesystem::exists (fileName);
736
737
return exists;
738
+ #else
739
+ using namespace winrt ::Windows::Storage;
740
+ using namespace winrt ::Windows::Storage::Streams;
741
+ using namespace winrt ::Windows::Foundation;
742
+ std::wstring wstr;
743
+ std::filesystem::path filepath = fileName;
744
+ filepath = std::filesystem::absolute (filepath);
745
+ StringConvert (filepath.string (), wstr);
746
+ bool success = false ;
747
+
748
+ auto async_helper = [&]() -> IAsyncAction {
749
+ try
750
+ {
751
+ auto file = co_await StorageFile::GetFileFromPathAsync (wstr);
752
+ success = true ;
753
+ }
754
+ catch (winrt::hresult_error const & ex)
755
+ {
756
+ switch (ex.code ())
757
+ {
758
+ case E_ACCESSDENIED:
759
+ wi::backlog::post (" Opening file failed: " + fileName + " | Reason: Permission Denied!" );
760
+ break ;
761
+ default :
762
+ break ;
763
+ }
764
+ }
765
+
766
+ };
767
+
768
+ if (winrt::impl::is_sta_thread ())
769
+ {
770
+ std::thread ([&] { async_helper ().get (); }).join (); // can't block coroutine from ui thread
771
+ }
772
+ else
773
+ {
774
+ async_helper ().get ();
775
+ }
776
+
777
+ if (success)
778
+ {
779
+ return true ;
780
+ }
781
+ #endif // PLATFORM_UWP
737
782
}
738
783
739
784
std::string GetTempDirectoryPath ()
You can’t perform that action at this time.
0 commit comments