Desktop (Vulkan) Target

Desktop (Vulkan) is a second way to build a Windows program. Instead of the DirectX 12 runtime, it uses the Vulkan runtime that the Linux editions of BambooBasic use, built for Windows. A game built this way behaves the same on Windows and on Linux, and its shaders are the same GLSL files on both.

Desktop (DX12) stays the main Windows target. Use Vulkan when you want your Windows and Linux builds to match.

This target is new. Everything the Linux runtime has works: graphics, text, fonts, images, shaders, meshes, tilemaps, IGI, BGI and canvases, movies, sound, input, files and network.



Building

Start the program with

Import "BBRuntimeVulkan.decls"

and choose Target > Desktop (Vulkan). Build and Build and Run then work as they do for Desktop (DX12). A Vulkan program won't build with the Target menu on Desktop (DX12), and a DX12 program won't build on Desktop (Vulkan). If they don't match, the IDE offers to switch the menu for you.

As on Desktop (DX12), the window's close button ends the program. A program that calls sysQuitRequested gets the close as a request instead, so it can save and quit in its own time. Either way the runtime is shut down properly when the program ends, even without b2dEnd.

One file can build for both desktop targets with conditional compiling. On this target the names DESKTOP_VK and DESKTOP are set:

#If DESKTOP_VK
Import "BBRuntimeVulkan.decls"
#Else
Import "BBRuntime64.decls"
#EndIf


Shipping a Game

The build puts two files beside your program, and they go with it:

Players need a graphics driver with Vulkan 1.3, which current NVIDIA, AMD and Intel drivers all have. A notice for shaderc_shared.dll is in the userlibs folder (shaderc-NOTICE.txt): ship it with your game too.



Shaders

Image, text and screen shaders are GLSL (.glsl) files, the same files as on Linux, instead of the HLSL (.hlsl) files that Desktop (DX12) uses. The functions are the same: b2dLoadImageShader, b2dSetImageShaderFloat and the others, with parameters numbered "0" to "63".

The runtime puts these declarations before your file, so a shader is only its main():

// Brighter.glsl - an image a little brighter
void main()
{
    vec4 colour = texture(imageTexture, texCoord);
    colour.rgb *= param0;
    colour.a *= alpha;
    fragColour = colour;
}

The examples in examples\BambooRuntime\9 - Shaders have GLSL versions of several shaders beside the HLSL ones.

Note: The Web (WebGL2) target also uses GLSL, but declares things differently (param(0), color, pixelPos()), so a Vulkan shader needs small changes to run there.



BGI and Movies

BGI is the same set of Win32 gizmos as on Desktop (DX12), the HTML view included. A canvas has its own Vulkan swapchain, so drawing into it costs little more than drawing to the main window. Movies are decoded with Windows' Media Foundation, as on Desktop (DX12): any file Windows itself can play.



Back to Index