Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 58 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ jobs:
compiler: dmd-latest
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@main
- uses: egor-tensin/vs-shell@v2
if: runner.os == 'Windows'
with:
arch: x64
- uses: dlang-community/setup-dlang@v2
Expand Down Expand Up @@ -69,7 +70,7 @@ jobs:
runs-on: [ubuntu-24.04-arm, ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@main
- uses: dlang-community/setup-dlang@v2
with:
compiler: ldc-master
Expand Down Expand Up @@ -105,7 +106,7 @@ jobs:
runs-on: [ubuntu-24.04-arm, ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@main
- uses: dlang-community/setup-dlang@v2
with:
compiler: ldc-master
Expand Down Expand Up @@ -144,7 +145,7 @@ jobs:
run:
shell: bash
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@main
- name: prepare-linux
run: |
pacman -Syu --noconfirm
Expand All @@ -171,3 +172,56 @@ jobs:
dub build :texcube
dub build :userdata
dub build :vertexpull

build-vulkan:
strategy:
fail-fast: false
matrix:
runs-on: [ubuntu-24.04-arm, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.runs-on }}
steps:
- uses: actions/checkout@main
- uses: egor-tensin/vs-shell@v2
if: runner.os == 'Windows'
with:
arch: x64
- uses: humbletim/setup-vulkan-sdk@main
if: runner.os == 'Windows'
with:
vulkan-query-version: 1.4.335.0
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true
- uses: dlang-community/setup-dlang@v2
with:
compiler: ldc-master
- name: prepare-linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install libgl1-mesa-dev libegl1-mesa-dev mesa-common-dev xorg-dev libasound-dev libvulkan-dev
- name: (dub) Running shdc
run: dub build -c genshaders-vk
- name: (dub) Build sokol examples
working-directory: examples
run: |
dub build :blend -c vulkan
dub build :bufferoffsets -c vulkan
dub build :clear -c vulkan
dub build :cube -c vulkan
dub build :debugtext -c vulkan
dub build :droptest -c vulkan
dub build :imgui -c vulkan
dub build :instancing -c vulkan
dub build :instancingcompute -c vulkan
dub build :mrt -c vulkan
dub build :noninterleaved -c vulkan
dub build :nuklear -c vulkan
dub build :offscreen -c vulkan
dub build :quad -c vulkan
dub build :shapes -c vulkan
dub build :saudio -c vulkan
dub build :sglcontext -c vulkan
dub build :sglpoints -c vulkan
dub build :triangle -c vulkan
dub build :texcube -c vulkan
dub build :vertexpull -c vulkan
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ dub :triangle
By default, the backend 3D API will be selected based on the target platform:

- macOS: Metal
- Windows: D3D11
- Linux: GL/Wayland
- Windows: D3D11/Vulkan
- Linux: GL/Wayland/Vulkan
- Wasm (LDC2 required) - WebGL2/WebGPU support

#### Usage - template project
Expand All @@ -52,6 +52,7 @@ dub init -t sokol-d <project-name>
- imgui
- instancing
- instancingcompute
- nuklear
- saudio
- sglcontext
- sglpoints
Expand All @@ -68,17 +69,21 @@ Available configurations:
sokol-shared # Shared/dynamic library build
sokol-wayland-static # Wayland static build for Linux
sokol-wayland-shared # Wayland shared build for Linux
sokol-vulkan # Sokol + Vulkan Static library build
imgui-static # Sokol + Dear ImGui static build
imgui-shared # Sokol + Dear ImGui shared build
imgui-vulkan # Sokol + Dear ImGui + Vulkan static build
imgui-wgles3 # Sokol + Dear ImGui WebGL ES3 build
imgui-wgpu # Sokol + Dear ImGui WebGPU build
sokol-wgles3 # WebGL ES3 build
sokol-wgpu # WebGPU build
nuklear-static # Sokol + Nuklear static build
nuklear-shared # Sokol + Nuklear shared build
nuklear-vulkan # Sokol + Nuklear + Vulkan static build
nuklear-wgles3 # Sokol + Nuklear WebGL ES3 build
nuklear-wgpu # Sokol + Nuklear WebGPU build
genshaders # [re]Generate shader code
genshaders-vk # [re]Generate vk-shader code
```

## Additional Build Options
Expand Down
12 changes: 7 additions & 5 deletions build.d
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void main(string[] args) @safe

// Execute build steps
if (opts.downloadShdc)
buildShaders(vendorPath);
buildShaders(vendorPath, opts.backend);
else if (opts.linkExample)
{
EmLinkOptions linkOpts = {
Expand Down Expand Up @@ -218,7 +218,7 @@ void getNuklear(string vendor) @safe
}
}

void buildShaders(string vendor) @safe
void buildShaders(string vendor, ref SokolBackend opts) @safe
{
immutable shdcPath = getSHDC(vendor);
immutable shadersDir = "examples/shaders";
Expand All @@ -233,7 +233,7 @@ void buildShaders(string vendor) @safe
else
enum glsl = "glsl430";

immutable slangTemplate = glsl ~ ":metal_macos:hlsl5:%s:wgsl";
immutable slangTemplate = opts == SokolBackend.vulkan ? glsl ~ ":metal_macos:hlsl5:%s:wgsl:spirv_vk" : glsl ~ ":metal_macos:hlsl5:%s:wgsl";

version (Posix)
executeOrFail(["chmod", "+x", shdcPath], "Failed to set shader permissions", true);
Expand Down Expand Up @@ -278,7 +278,8 @@ enum SokolBackend
metal,
glcore,
gles3,
wgpu
wgpu,
vulkan
}

struct LibSokolOptions
Expand Down Expand Up @@ -347,7 +348,8 @@ void buildLibSokol(LibSokolOptions opts) @safe
lflags ~= opts.use_wayland ? [
"-lwayland-client", "-lwayland-egl", "-lwayland-cursor", "-lxkbcommon"
] : [];
lflags ~= ["-lX11", "-lGL", "-lXi", "-lXcursor", "-lasound"];
lflags ~= opts.backend == SokolBackend.vulkan ? ["-lvulkan"] : ["-lGL"];
lflags ~= ["-lX11", "-lXi", "-lXcursor", "-lasound"];
break;
case "windows":
cflags ~= ["/DNDEBUG", "/DIMPL", "/wd4190", "/O2"];
Expand Down
Loading