@@ -38,6 +38,15 @@ int main() {
3838 wgpu::AdapterInfo info{};require (surface.adapter ().GetInfo (&info)==wgpu::Status::Success," adapter identity unavailable" );
3939 hardware=info.adapterType ==wgpu::AdapterType::DiscreteGPU || info.adapterType ==wgpu::AdapterType::IntegratedGPU;
4040 require (info.backendType ==wgpu::BackendType::Vulkan," Linux test did not run Vulkan" );
41+ // GPU completion must retire an abandoned snapshot while application
42+ // frames are paused. No ProcessEvents or render timer drives this wait.
43+ {
44+ auto abandoned=paint (surface,1 ,0 ,0 );abandoned.reset ();
45+ const auto deadline=std::chrono::steady_clock::now ()+std::chrono::seconds (20 );
46+ while (surface.busy_images () && std::chrono::steady_clock::now ()<deadline)
47+ std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
48+ require (surface.busy_images ()==0 ," hidden GPU completion did not retire dropped snapshot" );
49+ }
4150 auto red=resolve (surface,paint (surface,1 ,0 ,0 ));
4251 auto green=resolve (surface,paint (surface,0 ,1 ,0 ));
4352 auto blue=resolve (surface,paint (surface,0 ,0 ,1 ));
@@ -52,7 +61,7 @@ int main() {
5261 require (resized->value .describe ().allocation_generation >generation," resize did not advance generation" );
5362 require (resized->value .describe ().width ==65 && resized->value .describe ().height ==7 ," resized metadata mismatch" );
5463 pixel (capture_offscreen_image (*resized),0 ,255 ,0 );
55- pixel (capture_offscreen_image (*red),255 ,0 ,0 ); // old front image remains immutable across resize
64+ pixel (capture_offscreen_image (*red),255 ,0 ,0 );
5665 require (surface.resident_bytes ()<=64 *1024 ," resident allocation budget exceeded" );
5766 bool wrong_thread=false ;
5867 std::thread foreign ([&]{try {surface.resize (2 ,2 );}catch (const std::logic_error&){wrong_thread=true ;}});foreign.join ();
@@ -69,13 +78,13 @@ int main() {
6978 require (budget_rejected," capture ignored byte budget" );
7079 captures=surface.capture_count ();allocations=surface.created_images ();surviving=std::move (red);
7180 }
72- pixel (capture_offscreen_image (*surviving),255 ,0 ,0 ); // retained lease owns device and provider
81+ pixel (capture_offscreen_image (*surviving),255 ,0 ,0 );
7382 surviving.reset ();
7483 for (int i=0 ;i<3 ;++i) {
7584 native_webgpu_surface surface (10 +i,13 ,5 );
7685 auto image=resolve (surface,paint (surface,0 ,1 ,0 ));pixel (capture_offscreen_image (*image),0 ,255 ,0 );
7786 }
7887 std::cout<<" {\" backend\" :\" Vulkan\" ,\" hardware\" :" <<(hardware?" true" :" false" )
7988 <<" ,\" readbacksBeforeCapture\" :0,\" explicitCaptures\" :" <<captures
80- <<" ,\" allocations\" :" <<allocations<<" ,\" pixelValidation\" :true,\" retainedResize\" :true,\" repeatedShutdown\" :true}\n " ;
89+ <<" ,\" allocations\" :" <<allocations<<" ,\" hiddenCompletion \" :true, \" pixelValidation\" :true,\" retainedResize\" :true,\" repeatedShutdown\" :true}\n " ;
8190}
0 commit comments