Files
RetroArch/samples/gfx/vulkan_validation/Makefile
LibretroAdmin 28d304414e Vulkan: rebuild the swapchain once on a suboptimal present
A suboptimal present is the WSI asking for a new swapchain. On Wayland
the compositor's dma-buf feedback has changed under it: a window gone
fullscreen is offered the scanout tranche, and images allocated before
that for compositing - on NVIDIA, compressed block-linear - are not in
it, so the window is never put on the display plane. Only a rebuild
lets the WSI allocate from the new tranche (#19841, the modifier the
primary plane rejects).

One rebuild per answer: the swapchain built in its place is kept while
it keeps presenting suboptimal (Android without prerotate), and an
optimal present arms the rebuild again. context.flags widens to 16
bits for the new bit, placed before swap_interval to keep the struct
sorted by alignment.

The vulkan_validation lane drives a suboptimal present through the
real present path and checks the rebuild, the hold and the re-arm,
with the tracker confirming nothing the present still needed was
destroyed. Its Makefile takes the tree's Vulkan headers ahead of the
system's, which vulkan_video_caps.h already requires.
2026-10-16 01:29:43 +02:00

74 lines
2.5 KiB
Makefile

include ../../sample_objdir.mk
TARGET := vulkan_validation_test
# Path back to the repo root from this sample dir. Like the
# display_servers samples, this one links the real code rather than
# mirroring it -- the point is to run RetroArch's own Vulkan setup
# under the validation layer, so a copy would prove nothing.
REPO_ROOT := ../../..
LIBRETRO_COMM_DIR := $(REPO_ROOT)/libretro-common
# VULKAN_DEBUG is the flag RetroArch already uses to enable
# VK_LAYER_KHRONOS_validation and VK_EXT_debug_utils and to install
# vulkan_debug_cb(). That callback reports through RARCH_LOG, which
# stubs_retroarch.c supplies and scores, so the test needs no debug
# messenger of its own.
SOURCES := vulkan_validation_test.c \
stubs_retroarch.c \
$(REPO_ROOT)/gfx/common/vulkan_common.c \
$(LIBRETRO_COMM_DIR)/vulkan/vulkan_symbol_wrapper.c \
$(LIBRETRO_COMM_DIR)/rthreads/rthreads.c \
$(LIBRETRO_COMM_DIR)/rthreads/retro_eventcount.c \
$(LIBRETRO_COMM_DIR)/features/features_cpu.c \
$(LIBRETRO_COMM_DIR)/lists/string_list.c \
$(LIBRETRO_COMM_DIR)/dynamic/dylib.c \
$(LIBRETRO_COMM_DIR)/compat/compat_strl.c \
$(LIBRETRO_COMM_DIR)/string/stdstring.c \
$(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c
CFLAGS += -Wall -std=gnu99 -g1 -O0 \
-DHAVE_VULKAN -DVULKAN_DEBUG -DHAVE_THREADS -DHAVE_DYLIB \
-DHAVE_XLIB \
-I$(REPO_ROOT) \
-I$(REPO_ROOT)/gfx/include \
-I$(LIBRETRO_COMM_DIR)/include
LDFLAGS += -lvulkan -lpthread -ldl -lX11
OBJS := $(call sample_objs,$(SOURCES:.c=.o))
ifneq ($(SANITIZER),)
CFLAGS := -fsanitize=$(SANITIZER) -fno-omit-frame-pointer $(CFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
endif
all: $(TARGET)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
$(SAMPLE_OBJDIR)/%.o: $$(call sample_src,$$*).c
@mkdir -p $(@D)
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
# Needs an X display, a Vulkan device and the validation layer. Xvfb
# plus lavapipe is enough, and both are packaged:
# apt-get install xvfb mesa-vulkan-drivers vulkan-validationlayers
# Xvfb :99 -screen 0 1280x720x24 &
# With no display or no device the test exits 77 (skipped) rather than
# failing, so it is safe to run unconditionally.
VK_DRIVER_FILES ?= /usr/share/vulkan/icd.d/lvp_icd.json
run: $(TARGET)
VK_DRIVER_FILES=$(VK_DRIVER_FILES) ./$(TARGET)
clean:
rm -rf $(SAMPLE_OBJDIR)
rm -f $(TARGET) $(OBJS)
.PHONY: all run clean