Vulkan-Samples icon indicating copy to clipboard operation
Vulkan-Samples copied to clipboard

CLI Samples launcher + Vulkan Hello Triangle

Open TomAtkinsonArm opened this issue 3 years ago • 0 comments

Description

Blocked by #485 #487 #488 #490

Large diff as this contains commits from several branches

Currently only works on Ubuntu with XLIB enabled as I have not added every window and surface type yet

loading sample configs
candidate: /build/linux/cmd/samples_launcher/samples.json
selected: /build/linux/cmd/samples_launcher/samples.json
looking for: libsample__hello_sample.so - not found
looking for: libsample__hello_triangle.so
candidate: ./build/linux/samples/hello_triangle/lib/Debug/x86_64/libsample__hello_triangle.so
selecting: ./build/linux/samples/hello_triangle/lib/Debug/x86_64/libsample__hello_triangle.so


Available Samples: (1/2)

id:             hello_triangle
name:           Hello Triangle
description:    Vulkan Hello Triangle
compile target: sample__hello_triangle

Hello Triangle!

samples.json is maintained by CMake automatically and contains metadata for all registered samples. Samples may be available or not, we cant easily track which have been built previously and which haven't. The Sample Launcher deduces available samples by searching the current working directory for platform specific runtime libraries for a given sample. Available samples are then displayed in a list.

The code sample shows the launcher being run with hello_triangle. The runtime library is found as stated in the lookup log. The launcher then loads this sample and runs its sample_main.

Screenshot from 2022-07-09 18-44-13

Screenshot from 2022-07-09 18-41-06

After a little bit more work I ported Hello Triangle

Screenshot from 2022-07-09 22-51-06

Solved Problems

Compilation

Single samples can be compiled by using the sample__<sample_name> target. All samples can be compiled with vkb__samples. samples_launcher is only compiled when one or more samples are selected for compilation. A user should never need to manually compile samples_launcher.

As the framework is now split into components a sample and the launcher will only compile the targets needed. For instance, compiling the current samples yields sub second compile times. There is also no link step so serialized link times in our current builds will not occur in this version of the framework.

Samples

Samples no longer need to follow strict patterns for creation. Requirements for a sample are:

  • A file defining sample_main
  • vkb__register_sample - sample build target
  • vkb__register_sample_descriptor - sample metadata

From here samples can come in any shape or size. The most appropriate execution flow can be used for each sample. We may want to define a component which acts as a base sample to reduce boilerplate, but these building blocks do not need to be the same for all samples.

TODO

  • [ ] - condense launcher code
  • [ ] - add a default samples build test which makes sure the launcher can find all samples when building with vkb__samples

TomAtkinsonArm avatar Jul 09 '22 15:07 TomAtkinsonArm