https://github.com/glfw/glfw/blob/master/tests/triangle-vulk...
(yes it's over 2kloc for a triangle - that's Vulkan for you ;) but at least it's all in one file readable from top to bottom instead of being spread over a dozen obscure "helper classes")
If you can compile that code, then you necessarily have the compiler at hand. You can't make a simple single code file example though. The build system has to get involved somehow.
FWIW, I think this is a good thing. Any non-trivial 3D project is going to involve some kind of asset baking sooner or later, which makes the barrier of entry to that negligible. At the same time, driver-driven compilation is just too convenient and sticky. That's a bad combination.
Vulkan doesn't come with any tools to generate that bytecode though. Foreign shader language (like HLSL, GLSL, etc) to SPIR-V compilers exist, and various graphics toolchains can generate SPIR-V. https://github.com/KhronosGroup/SPIRV-Tools does have tools to validate and optimize bytecode.
edit: i lied apparently - the SPIRV-Tools does have an assembler that translates text such as the "Corresponding SPIR-V" at https://registry.khronos.org/SPIR-V/specs/unified1/SPIRV.htm... to bytecode. However, that's not something you'd want to write manually, especially if you're used to something like GLSL.
My understanding is that VK_EXT_shader_object should make such examples simpler? https://www.khronos.org/blog/you-can-use-vulkan-without-pipe...
.components =
{
.r = VK_COMPONENT_SWIZZLE_R,
.g = VK_COMPONENT_SWIZZLE_G,
.b = VK_COMPONENT_SWIZZLE_B,
.a = VK_COMPONENT_SWIZZLE_A,
},Most things in Vulkan have reasonable defaults, fortunately. Still, it's best to code with the spec open on another monitor.
Try reading the above implementation. It’s a Hello, Triangle with SDL. Should compile out of the box on Windows.