mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-23 00:36:42 -10:00
The core's input_state callback was chosen once, when the core loaded: the late-polling one, whose first query of the frame polls, or a plain one. The poll mode can change afterwards - Poll Type Behavior in the menu calls core_set_poll_type(), and a core can set an override - and nothing chose again. So a core loaded with normal or early polling and switched to late kept the plain callback. input_poll does nothing under late polling, the early poll no longer ran, and the only poll left was the fallback after retro_run(). The core then read input sampled before the previous frame's pacing wait: up to a frame older than late polling is there to give, and older than either mode it was switched from. It lasted until the content was reloaded. Give the core one callback and read the mode at the call. The frame's first query polls if late polling is in force and the frame has not polled yet. RETRO_CORE_FLAG_INPUT_POLLED now means that in every mode: set by the early poll before retro_run(), by input_poll under normal polling, or by the first query under late; cleared at the start of each frame that does not poll early. Past the frame's poll a query costs one test of that flag, as it did under late polling; the flag is no longer written on every query. Netplay and run-ahead are unaffected: both wrap the same callback, and netplay forces normal polling as before. samples/runloop/frontend_overhead gains a lane that counts where the frontend polls. The joypad driver's poll is counted between four points of the harness core's retro_run() and the two ends of the iterate, and each mode must poll once a frame in its own place and nowhere else: early before retro_run(), normal in input_poll, late in the first input_state. The check target now runs the harness three times, loading the core with late, normal and early polling (HARNESS_LOAD_POLL), since which mode the core is loaded with is what decided the callback. Before this change the lane fails for a core loaded with normal or with early polling and switched to late: 300 polls in 300 frames, all after retro_run(). The opposite switch, late to normal or early, was already correct. Cost, from the harness on the release build: input_state stays at 60 to 70 ns a query in every mode and the frame at 2.9 us, before and after.
45 lines
1.6 KiB
Makefile
45 lines
1.6 KiB
Makefile
# See build.sh: this harness links the shipping RetroArch objects with
|
|
# only main() replaced, so it needs the project's own build first.
|
|
#
|
|
# SAN= selects which tree build to link:
|
|
# SAN=none (default) -> plain release build; the heap lane needs
|
|
# this, an allocator sanitizer replaces
|
|
# malloc and would be counted
|
|
# SAN=address -> make SANITIZER=address,undefined DEBUG=1
|
|
# SAN=thread -> make SANITIZER=thread DEBUG=1
|
|
TARGET := frontend_overhead_test
|
|
SAN ?= none
|
|
|
|
ifeq ($(SAN),address)
|
|
MAKE_ARGS := SANITIZER=address,undefined DEBUG=1
|
|
else ifeq ($(SAN),thread)
|
|
MAKE_ARGS := SANITIZER=thread DEBUG=1
|
|
else
|
|
MAKE_ARGS :=
|
|
endif
|
|
|
|
all:
|
|
@MAKE_ARGS="$(MAKE_ARGS)" ./build.sh
|
|
|
|
# The default run loads the core with late polling and runs every lane.
|
|
# The two after it load it with normal and with early polling and run
|
|
# the poll-site lane alone: which state callback the core is given used
|
|
# to be decided at load.
|
|
check: all
|
|
@for load in "" normal early; do \
|
|
HARNESS_LOAD_POLL=$$load; \
|
|
if [ -n "$$load" ]; then export HARNESS_LOAD_POLL; else unset HARNESS_LOAD_POLL; fi; \
|
|
ASAN_OPTIONS=detect_leaks=0:abort_on_error=1 \
|
|
UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 \
|
|
TSAN_OPTIONS=halt_on_error=1:second_deadlock_stack=1 \
|
|
./$(TARGET) > check.log 2>&1; rc=$$?; \
|
|
grep -vE '^\[(INFO|DEBUG|WARN|ERROR)\]' check.log; rm -f check.log; \
|
|
[ $$rc -eq 0 ] || exit $$rc; \
|
|
done
|
|
|
|
clean:
|
|
rm -f $(TARGET) check.log harness_core.so retroarch_nomain.o retroarch_nomain.d \
|
|
harness_main.o harness_main.d
|
|
|
|
.PHONY: all check clean
|