Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f75aacfdbe |
No files matched your search
@@ -1198,6 +1198,14 @@ static uint32_t nominal_refresh_ns(void) {
|
||||
return (uint32_t)(1000000000000LL / (int64_t)mhz);
|
||||
}
|
||||
|
||||
static uint32_t feedback_refresh_ns(void) {
|
||||
const int limit = g_fps_limit;
|
||||
const uint32_t panel = nominal_refresh_ns();
|
||||
if (limit <= 0 || g_release_unpaced) return panel;
|
||||
const uint32_t paced = (uint32_t)(1000000000LL / limit);
|
||||
return paced > panel ? paced : panel;
|
||||
}
|
||||
|
||||
static int64_t presented_ns(int64_t render_ns) {
|
||||
int64_t tick = g_tick_vsync_ns;
|
||||
int64_t refresh = (int64_t)nominal_refresh_ns();
|
||||
@@ -1216,7 +1224,7 @@ static void feedback_present_all(struct wl_list *list, int64_t t) {
|
||||
uint32_t nsec = (uint32_t)(t % 1000000000LL);
|
||||
wl_resource_for_each_safe(fb, tmp, list) {
|
||||
wp_presentation_feedback_send_presented(fb, (uint32_t)(sec >> 32), (uint32_t)sec, nsec,
|
||||
nominal_refresh_ns(), 0, 0,
|
||||
feedback_refresh_ns(), 0, 0,
|
||||
WP_PRESENTATION_FEEDBACK_KIND_VSYNC);
|
||||
wl_resource_destroy(fb);
|
||||
g_pace.presented++;
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from test_output_refresh import SOURCE, extract_function
|
||||
|
||||
|
||||
PROBE = r'''
|
||||
#include <stdatomic.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static atomic_int g_output_refresh_mhz;
|
||||
static volatile int g_fps_limit;
|
||||
static volatile int g_release_unpaced;
|
||||
|
||||
%s
|
||||
%s
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
atomic_store(&g_output_refresh_mhz, atoi(argv[1]));
|
||||
g_fps_limit = atoi(argv[2]);
|
||||
g_release_unpaced = atoi(argv[3]);
|
||||
printf("%%u\n", feedback_refresh_ns());
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
@unittest.skipUnless(shutil.which('cc'), 'needs a C compiler')
|
||||
class FeedbackRefreshTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
source = SOURCE.read_text()
|
||||
cls.tmp = tempfile.TemporaryDirectory()
|
||||
probe = Path(cls.tmp.name) / 'probe.c'
|
||||
probe.write_text(PROBE % (extract_function(source, 'nominal_refresh_ns'),
|
||||
extract_function(source, 'feedback_refresh_ns')))
|
||||
cls.binary = Path(cls.tmp.name) / 'probe'
|
||||
subprocess.run(['cc', '-std=c11', '-Wall', '-Werror', str(probe), '-o', str(cls.binary)], check=True)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.tmp.cleanup()
|
||||
|
||||
def refresh(self, mhz, limit, unpaced=0):
|
||||
out = subprocess.run([str(self.binary), str(mhz), str(limit), str(unpaced)],
|
||||
check=True, capture_output=True, text=True).stdout
|
||||
return int(out)
|
||||
|
||||
def test_no_limit_reports_the_panel_refresh(self):
|
||||
self.assertEqual(self.refresh(120000, 0), 8333333)
|
||||
self.assertEqual(self.refresh(60000, 0), 16666666)
|
||||
|
||||
def test_limit_below_the_panel_reports_the_limit_interval(self):
|
||||
self.assertEqual(self.refresh(120000, 60), 16666666)
|
||||
self.assertEqual(self.refresh(120000, 30), 33333333)
|
||||
self.assertEqual(self.refresh(90000, 45), 22222222)
|
||||
|
||||
def test_limit_at_or_above_the_panel_keeps_the_panel_refresh(self):
|
||||
self.assertEqual(self.refresh(60000, 60), 16666666)
|
||||
self.assertEqual(self.refresh(60000, 144), 16666666)
|
||||
|
||||
def test_unpaced_sessions_keep_the_panel_refresh(self):
|
||||
self.assertEqual(self.refresh(120000, 60, unpaced=1), 8333333)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user