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
12 changes: 6 additions & 6 deletions .github/workflows/generate-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ env:
V3_COMMIT: f59b886d2564e37d8626d715236fdfa928e13dda
V3_VC_COMMIT: 4598bc7e4894c154b27391e4442005fff2fbbd68
V3_TCC_COMMIT: d6e7ac1b1bcc98aed734a6ecbfa8509f24606c74
VULKAN_REF: v2.0.0
GLFW_COMMIT: 3d7c1ddacb7215a7bbeb5fef0d7a68c90ba392ed
VULKAN_REF: v3.2.0
GLFW_REF: v2.0.0

jobs:
generate-and-test:
Expand Down Expand Up @@ -50,7 +50,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
repository: antono2/glfw
ref: ${{ env.GLFW_COMMIT }}
ref: ${{ env.GLFW_REF }}
path: .ci-modules/glfw
- uses: prantlf/setup-v-action@92f20bea50d2c9931a28c96bb4997a3c7357baf0 # v4
with:
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
run: |
sudo apt-get install --yes libvulkan-dev libvulkan-volk-dev libglfw3-dev mesa-vulkan-drivers vulkan-validationlayers xauth xvfb
test "$(git -C .ci-modules/vulkan describe --tags --exact-match)" = "$VULKAN_REF"
test "$(git -C .ci-modules/glfw rev-parse HEAD)" = "$GLFW_COMMIT"
test "$(git -C .ci-modules/glfw describe --tags --exact-match)" = "$GLFW_REF"
install -d "$HOME/.vmodules/antono2/vulkan" "$HOME/.vmodules/antono2/glfw"
cp -a .ci-modules/vulkan/. "$HOME/.vmodules/antono2/vulkan/"
cp -a .ci-modules/glfw/. "$HOME/.vmodules/antono2/glfw/"
Expand Down Expand Up @@ -247,7 +247,7 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
repository: antono2/glfw
ref: ${{ env.GLFW_COMMIT }}
ref: ${{ env.GLFW_REF }}
path: .ci-modules/glfw
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
Expand Down Expand Up @@ -360,7 +360,7 @@ jobs:
cp src/opencl.v src/convenience.v src/ownership.v src/program.v src/event.v src/image.v src/svm.v src/capabilities.v src/external_interop.v v.mod "$HOME/.vmodules/antono2/opencl/"
mkdir -p "$HOME/.vmodules/antono2/opencl/include/CL"
cp include/CL/opencl.h "$HOME/.vmodules/antono2/opencl/include/CL/"
v -cc gcc -d vulkan_fd_i32 -o "$RUNNER_TEMP/vulkan-particles" examples/vulkan_particles
v -cc gcc -o "$RUNNER_TEMP/vulkan-particles" examples/vulkan_particles

required-checks:
name: required-checks
Expand Down
8 changes: 4 additions & 4 deletions examples/vulkan_particles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ checked-in SPIR-V after editing GLSL with `./compile_shaders.sh`.
Install the example-only V modules and Linux development packages before building from source:

```sh
v install antono2.opencl@v1.0.0
v install antono2.vulkan@v2.0.0
v install antono2.glfw
v install antono2.opencl@v1.0.1
v install antono2.vulkan@v3.2.0
v install antono2.glfw@v2.0.0
sudo apt install ocl-icd-opencl-dev libvulkan-dev libglfw3-dev
```

Expand All @@ -52,7 +52,7 @@ v -cc gcc run examples/vulkan_particles --particles=4096
v -cc tcc run examples/vulkan_particles --particles=4096
```

TinyCC requires `antono2.vulkan` v2.0.0 for its deep-bound Volk loader.
The pinned Vulkan release provides the deep-bound Volk loader used by TinyCC.

## Tested hardware

Expand Down
17 changes: 4 additions & 13 deletions examples/vulkan_particles/fd_abi.v
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,12 @@ module main

import antono2.vulkan as vk

// Vulkan registry revisions have described POSIX file descriptors as both
// C int and int32_t. These pointer types have the same ABI but distinct V
// types. Select the matching raw declaration in the dependency-master lane.
// Vulkan v3.2.0 exposes POSIX file descriptors as i32. C int has the same
// ABI here but is a distinct V type, so cast the pointer at this boundary.
fn export_vk_memory_fd(device vk.Device, info &vk.MemoryGetFdInfoKHR, fd &int) vk.Result {
$if vulkan_fd_i32 ? {
return vk.get_memory_fd_khr(device, info, unsafe { &i32(fd) })
} $else {
return vk.get_memory_fd_khr(device, info, fd)
}
return vk.get_memory_fd_khr(device, info, unsafe { &i32(fd) })
}

fn export_vk_semaphore_fd(device vk.Device, info &vk.SemaphoreGetFdInfoKHR, fd &int) vk.Result {
$if vulkan_fd_i32 ? {
return vk.get_semaphore_fd_khr(device, info, unsafe { &i32(fd) })
} $else {
return vk.get_semaphore_fd_khr(device, info, fd)
}
return vk.get_semaphore_fd_khr(device, info, unsafe { &i32(fd) })
}
8 changes: 3 additions & 5 deletions examples/vulkan_particles/swapchain.v
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,10 @@ fn choose_extent(capabilities vk.SurfaceCapabilitiesKHR, window &glfw.Window) vk
if capabilities.currentExtent.width != max_u32 {
return capabilities.currentExtent
}
mut width := i32(0)
mut height := i32(0)
glfw.get_framebuffer_size(window, &width, &height)
framebuffer := glfw.framebuffer_size(window)
return vk.Extent2D{
width: clamp_u32(u32(width), capabilities.minImageExtent.width, capabilities.maxImageExtent.width)
height: clamp_u32(u32(height), capabilities.minImageExtent.height, capabilities.maxImageExtent.height)
width: clamp_u32(u32(framebuffer.width), capabilities.minImageExtent.width, capabilities.maxImageExtent.width)
height: clamp_u32(u32(framebuffer.height), capabilities.minImageExtent.height, capabilities.maxImageExtent.height)
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/vulkan_particles/v.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Module {
description: 'OpenCL particle simulation with a Vulkan renderer'
version: '0.1.0'
license: 'MIT'
dependencies: ['antono2.opencl@v1.0.1', 'antono2.vulkan@v2.0.0', 'antono2.glfw']
dependencies: ['antono2.opencl@v1.0.1', 'antono2.vulkan@v3.2.0', 'antono2.glfw@v2.0.0']
}
17 changes: 6 additions & 11 deletions examples/vulkan_particles/window_smoke.v
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,7 @@ fn window_device_loop(compute &Compute, particle_count usize, use_zero_copy bool
return error('GLFW cannot find a Vulkan loader')
}
glfw.window_hint(glfw.client_api, glfw.no_api)
window := glfw.create_window(960, 640, 'Vulkan + OpenCL particles', unsafe { nil },
unsafe { nil })
if isnil(window) {
return error('GLFW window creation failed')
}
window := glfw.create_windowed(960, 640, 'Vulkan + OpenCL particles')!
defer { glfw.destroy_window(window) }

if vk.initialize_loader() != vk.Result.success {
Expand Down Expand Up @@ -231,14 +227,13 @@ fn window_device_loop(compute &Compute, particle_count usize, use_zero_copy bool
pipeline.destroy(device)
frames.destroy(device)
swapchain.destroy(device)
mut width := i32(0)
mut height := i32(0)
for width == 0 || height == 0 {
glfw.get_framebuffer_size(window, &width, &height)
if width == 0 || height == 0 {
for {
framebuffer := glfw.framebuffer_size(window)
if framebuffer.width > 0 && framebuffer.height > 0 {
break
}
glfw.poll_events()
time.sleep(16 * time.millisecond)
}
}
swapchain = create_swapchain(physical, device, surface, window)!
frames = create_frame_resources(device, queue_family, &swapchain)!
Expand Down
Loading