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
9 changes: 8 additions & 1 deletion .github/workflows/generated-bindings-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
module_root="$RUNNER_TEMP/vmodules/antono2/vulkan"
mkdir -p "$module_root/c" "$module_root/ergonomic"
cp vulkan.v vulkan_video.v loader.v v.mod VERSION REGISTRY_COMMIT VOLK_COMMIT "$module_root/"
cp c/loader_bridge.h c/volk.c.v c/volk_impl.h "$module_root/c/"
cp c/loader_bridge.h c/volk.c.v c/volk_impl.h c/vulkan_core_prelude.h "$module_root/c/"
cp -R c/vendor "$module_root/c/"
cp ergonomic/*.v "$module_root/ergonomic/"
echo "VMODULES=$RUNNER_TEMP/vmodules" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -282,6 +282,7 @@ jobs:
v "${v_flags[@]}" run generator/test
fi
v "${v_flags[@]}" -o "$RUNNER_TEMP/bundled-header-smoke" ci/bundled_header_smoke
v "${v_flags[@]}" run ci/header_order_smoke
v "${v_flags[@]}" test ergonomic
python3 scripts/check_docs.py
v "${v_flags[@]}" -o "$RUNNER_TEMP/vulkan-first-use" examples/getting_started
Expand All @@ -299,6 +300,12 @@ jobs:
v -cc tcc test ergonomic
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
v -cc tcc run examples/ergonomic_lifecycle
- name: Exercise current V3 device discovery and lifecycle
if: runner.os == 'Linux' && matrix.v-channel == 'master'
shell: bash
run: |
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation \
v -new-compiler -cc gcc run examples/ergonomic_lifecycle
- name: Check out presentation example dependency
if: runner.os == 'Linux' && matrix.v-channel == 'stable'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
Expand Down
2 changes: 2 additions & 0 deletions c/volk.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ module c
#flag -I@VMODROOT/c/vendor/include
#flag -I@VMODROOT/c/vendor/volk
#flag linux -Wl,-Bsymbolic
// Establish the pinned core before GLFW or another consumer includes Vulkan.
#preinclude "@VMODROOT/c/vulkan_core_prelude.h"
#include "@VMODROOT/c/volk_impl.h"
8 changes: 8 additions & 0 deletions c/vulkan_core_prelude.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

// Consumers such as GLFW must see the pinned core without function prototypes.
// Keep the Volk implementation and its CRT headers in the normal include phase.
#ifndef VK_NO_PROTOTYPES
#define VK_NO_PROTOTYPES
#endif
#include "vendor/include/vulkan/vulkan_core.h"
6 changes: 6 additions & 0 deletions ci/header_order_smoke/consumer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef VK_HEADER_VERSION
#error "Pinned Vulkan headers must precede consumer includes"
#endif
static uint32_t v_vulkan_consumer_header_version(void) {
return VK_HEADER_VERSION;
}
9 changes: 9 additions & 0 deletions ci/header_order_smoke/consumer/consumer.c.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module consumer

#include "@VMODROOT/ci/header_order_smoke/consumer.h"

fn C.v_vulkan_consumer_header_version() u32

pub fn header_version() u32 {
return C.v_vulkan_consumer_header_version()
}
8 changes: 8 additions & 0 deletions ci/header_order_smoke/main.c.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module main

import ci.header_order_smoke.consumer
import antono2.vulkan as vk

fn main() {
assert consumer.header_version() == u32(vk.header_version)
}
14 changes: 7 additions & 7 deletions ergonomic/discovery.v
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn extension_infos(properties []vk.ExtensionProperties) []ExtensionInfo {
mut result := []ExtensionInfo{cap: properties.len}
for property in properties {
result << ExtensionInfo{
name: unsafe { cstring_to_vstring(&property.extensionName[0]) }.clone()
name: unsafe { cstring_to_vstring(&property.extensionName[0]) }.clone()
spec_version: property.specVersion
}
}
Expand All @@ -35,9 +35,9 @@ fn layer_infos(properties []vk.LayerProperties) []LayerInfo {
mut result := []LayerInfo{cap: properties.len}
for property in properties {
result << LayerInfo{
name: unsafe { cstring_to_vstring(&property.layerName[0]) }.clone()
description: unsafe { cstring_to_vstring(&property.description[0]) }.clone()
spec_version: property.specVersion
name: unsafe { cstring_to_vstring(&property.layerName[0]) }.clone()
description: unsafe { cstring_to_vstring(&property.description[0]) }.clone()
spec_version: property.specVersion
implementation_version: property.implementationVersion
}
}
Expand All @@ -50,7 +50,7 @@ pub fn instance_extensions() ![]ExtensionInfo {
require_success(vk.initialize_loader(), 'volkInitialize')!
for {
mut count := u32(0)
mut no_properties := unsafe { nil }
mut no_properties := unsafe { &vk.ExtensionProperties(nil) }
require_success(vk.enumerate_instance_extension_properties(unsafe { nil }, &count, mut no_properties), 'vkEnumerateInstanceExtensionProperties(count)')!
if count == 0 {
return []ExtensionInfo{}
Expand All @@ -72,7 +72,7 @@ pub fn instance_layers() ![]LayerInfo {
require_success(vk.initialize_loader(), 'volkInitialize')!
for {
mut count := u32(0)
mut no_properties := unsafe { nil }
mut no_properties := unsafe { &vk.LayerProperties(nil) }
require_success(vk.enumerate_instance_layer_properties(&count, mut no_properties), 'vkEnumerateInstanceLayerProperties(count)')!
if count == 0 {
return []LayerInfo{}
Expand All @@ -92,7 +92,7 @@ pub fn instance_layers() ![]LayerInfo {
pub fn (device PhysicalDevice) extensions() ![]ExtensionInfo {
for {
mut count := u32(0)
mut no_properties := unsafe { nil }
mut no_properties := unsafe { &vk.ExtensionProperties(nil) }
require_success(vk.enumerate_device_extension_properties(device.handle, unsafe { nil }, &count, mut no_properties), 'vkEnumerateDeviceExtensionProperties(count)')!
if count == 0 {
return []ExtensionInfo{}
Expand Down
2 changes: 1 addition & 1 deletion ergonomic/ergonomic.v
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub fn select_queue_family(families []QueueFamily, required_flags vk.QueueFlags)
// family properties.
pub fn (device PhysicalDevice) queue_families() []QueueFamily {
mut count := u32(0)
mut no_properties := unsafe { nil }
mut no_properties := unsafe { &vk.QueueFamilyProperties(nil) }
vk.get_physical_device_queue_family_properties(device.handle, &count, mut no_properties)
if count == 0 {
return []QueueFamily{}
Expand Down
8 changes: 4 additions & 4 deletions ergonomic/presentation.v
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn (device PhysicalDevice) surface_formats(surface vk.SurfaceKHR) ![]vk.Surf
}
for {
mut count := u32(0)
mut no_formats := unsafe { nil }
mut no_formats := unsafe { &vk.SurfaceFormatKHR(nil) }
result := vk.get_physical_device_surface_formats_khr(device.handle, surface, &count, mut no_formats)
if result == .incomplete {
continue
Expand Down Expand Up @@ -82,8 +82,8 @@ pub fn (device PhysicalDevice) surface_present_modes(surface vk.SurfaceKHR) ![]v
// to configure or recreate a swapchain.
pub fn (device PhysicalDevice) surface_support(surface vk.SurfaceKHR) !SurfaceSupport {
return SurfaceSupport{
capabilities: device.surface_capabilities(surface)!
formats: device.surface_formats(surface)!
capabilities: device.surface_capabilities(surface)!
formats: device.surface_formats(surface)!
present_modes: device.surface_present_modes(surface)!
}
}
Expand Down Expand Up @@ -135,7 +135,7 @@ pub fn select_surface_extent(capabilities vk.SurfaceCapabilitiesKHR,
return capabilities.currentExtent
}
return vk.Extent2D{
width: clamp_u32(requested.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width)
width: clamp_u32(requested.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width)
height: clamp_u32(requested.height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height)
}
}
Expand Down
Loading