mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	tearing: avoid permanent disable due to rejected commits (#2295)
Currently, the cursor plane does not allow async page flips which causes tearing page flips to be rejected if the cursor was moved. However, in games where no cursor image is present, the async page flips can still work as expected. Instead of permanently disabling tearing after too many failures, test the output state first before each frame to see if we can commit with tearing_page_flip set to true.
This commit is contained in:
		
							parent
							
								
									c29d8a2174
								
							
						
					
					
						commit
						8f940358e4
					
				
					 3 changed files with 22 additions and 38 deletions
				
			
		
							
								
								
									
										30
									
								
								src/output.c
									
										
									
									
									
								
							
							
						
						
									
										30
									
								
								src/output.c
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -32,14 +32,6 @@
 | 
			
		|||
#include "view.h"
 | 
			
		||||
#include "xwayland.h"
 | 
			
		||||
 | 
			
		||||
static unsigned int
 | 
			
		||||
get_tearing_retry_count(struct output *output)
 | 
			
		||||
{
 | 
			
		||||
	/* Two seconds worth of frames, guessing 60Hz if refresh is invalid */
 | 
			
		||||
	int refresh = output->wlr_output->refresh;
 | 
			
		||||
	return refresh > 0 ? refresh / 500 : 120;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool
 | 
			
		||||
output_get_tearing_allowance(struct output *output)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			@ -57,11 +49,6 @@ output_get_tearing_allowance(struct output *output)
 | 
			
		|||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* tearing should not have failed too many times */
 | 
			
		||||
	if (output->nr_tearing_failures >= get_tearing_retry_count(output)) {
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* allow tearing for any window when requested or forced */
 | 
			
		||||
	if (rc.allow_tearing == LAB_TEARING_ENABLED) {
 | 
			
		||||
		if (view->force_tearing == LAB_STATE_UNSPECIFIED) {
 | 
			
		||||
| 
						 | 
				
			
			@ -154,22 +141,7 @@ output_frame_notify(struct wl_listener *listener, void *data)
 | 
			
		|||
 | 
			
		||||
		pending->tearing_page_flip = output_get_tearing_allowance(output);
 | 
			
		||||
 | 
			
		||||
		bool committed =
 | 
			
		||||
			lab_wlr_scene_output_commit(scene_output, pending);
 | 
			
		||||
 | 
			
		||||
		if (pending->tearing_page_flip) {
 | 
			
		||||
			if (committed) {
 | 
			
		||||
				output->nr_tearing_failures = 0;
 | 
			
		||||
			} else {
 | 
			
		||||
				if (++output->nr_tearing_failures >=
 | 
			
		||||
						get_tearing_retry_count(output)) {
 | 
			
		||||
					wlr_log(WLR_INFO, "setting tearing allowance failed "
 | 
			
		||||
						"for two consecutive seconds, disabling");
 | 
			
		||||
				}
 | 
			
		||||
				pending->tearing_page_flip = false;
 | 
			
		||||
				lab_wlr_scene_output_commit(scene_output, pending);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		lab_wlr_scene_output_commit(scene_output, pending);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	struct timespec now = { 0 };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue