Skip to content

Commit

Permalink
Merge pull request #30 from JuliaGPU/try-ci
Browse files Browse the repository at this point in the history
Add basic Github Actions CI support
  • Loading branch information
Gnimuc committed Oct 4, 2020
2 parents 02ea572 + 97f66b6 commit c7a4e77
Show file tree
Hide file tree
Showing 10 changed files with 533 additions and 211 deletions.
34 changes: 0 additions & 34 deletions .appveyor.yml

This file was deleted.

88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Based on https://github.com/vsg-dev/VulkanSceneGraph/blob/master/.github/workflows/ci.yml
name: CI
on:
push:
pull_request:
env:
JuliaVersion: 1.5
VulkanSDKVersion: 1.2.148.1
JULIA_GITHUB_ACTIONS_CI: ON
jobs:
ubuntu-latest-x64:
runs-on: ubuntu-latest
env:
VULKAN_SDK: $GITHUB_WORKSPACE/../$VulkanSDKVersion/x86_64
steps:
- uses: actions/checkout@v2
- name: Download & Extract Vulkan SDK
run: |
wget --no-cookies -O ../vulkansdk-linux-x86_64-${{env.VulkanSDKVersion}}.tar.gz https://sdk.lunarg.com/sdk/download/${{env.VulkanSDKVersion}}/linux/vulkansdk-linux-x86_64-${{env.VulkanSDKVersion}}.tar.gz?u=
tar -zxf ../vulkansdk-linux-x86_64-${{env.VulkanSDKVersion}}.tar.gz -C ../
- name: Install xvfb for GLFW
run: sudo apt-get install xvfb && Xvfb :99 &
- uses: julia-actions/setup-julia@v1
with:
version: ${{env.JuliaVersion}}
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
DISPLAY: :99
- uses: julia-actions/julia-uploadcodecov@latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

windows-latest-x64:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set Environment variables
run: echo "::set-env name=VULKAN_SDK::C:\VulkanSDK\${{env.VulkanSDKVersion}}"
- name: Download & Install Vulkan SDK
run: |
Invoke-WebRequest -Uri https://sdk.lunarg.com/sdk/download/${{env.VulkanSDKVersion}}/windows/VulkanSDK-${{env.VulkanSDKVersion}}-Installer.exe?u= -OutFile ../vulkan-sdk-${{env.VulkanSDKVersion}}.exe
$installer = Start-Process -FilePath ../vulkan-sdk-${{env.VulkanSDKVersion}}.exe -Wait -PassThru -ArgumentList @("/S");
$installer.WaitForExit();
Invoke-WebRequest -Uri https://sdk.lunarg.com/sdk/download/latest/windows/vulkan-runtime.exe -OutFile ../vulkan-runtime.exe
$installer = Start-Process -FilePath ../vulkan-runtime.exe -Wait -PassThru -ArgumentList @("/S");
$installer.WaitForExit();
- uses: julia-actions/setup-julia@v1
with:
version: ${{env.JuliaVersion}}
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
DISPLAY: :99
- uses: julia-actions/julia-uploadcodecov@latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

macos-latest-x64:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Set Environment variables
run: |
VULKAN_SDK=$GITHUB_WORKSPACE/../vulkansdk-macos-${{env.VulkanSDKVersion}}/macOS
echo ::set-env name=VULKAN_SDK::$VULKAN_SDK
echo ::set-env name=JULIA_VULKAN_SDK_SEARCH_PATH::$VULKAN_SDK/lib
echo ::set-env name=VK_LAYER_PATH::$VULKAN_SDK/share/vulkan/explicit_layer.d
echo ::set-env name=VK_ICD_FILENAMES::$VULKAN_SDK/share/vulkan/icd.d/MoltenVK_icd.json
- name: Download & Extract Vulkan SDK
run: |
wget --no-cookies -O ../vulkansdk-macos-${{env.VulkanSDKVersion}}.dmg https://sdk.lunarg.com/sdk/download/${{env.VulkanSDKVersion}}/mac/vulkansdk-macos-${{env.VulkanSDKVersion}}.dmg?u=
hdiutil attach ../vulkansdk-macos-${{env.VulkanSDKVersion}}.dmg
cp -r /Volumes/vulkansdk-macos-${{env.VulkanSDKVersion}} ../
hdiutil detach /Volumes/vulkansdk-macos-${{env.VulkanSDKVersion}}
- uses: julia-actions/setup-julia@v1
with:
version: ${{env.JuliaVersion}}
arch: x64
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
env:
DISPLAY: :99
- uses: julia-actions/julia-uploadcodecov@latest
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# VulkanCore

[![Build Status](https://travis-ci.org/JuliaGPU/VulkanCore.jl.svg?branch=master)](https://travis-ci.org/JuliaGPU/VulkanCore.jl)
![CI](https://github.com/JuliaGPU/VulkanCore.jl/workflows/CI/badge.svg)
![TagBot](https://github.com/JuliaGPU/VulkanCore.jl/workflows/TagBot/badge.svg)

VulkanCore wraps Vulkan and exposes the library calls necessary to work with
Vulkan. It is targeted for developers wanting to directly work with Vulkan in
Expand All @@ -22,7 +23,7 @@ If these are present, just run `pkg> add VulkanCore` in Julia.
- [Vulkan Specification](https://www.khronos.org/registry/vulkan/#apispecs)

## Usage
The Vulkan wrapper is generated using [Clang.jl](https://github.com/JuliaInterop/Clang.jl)
The Vulkan wrapper is generated using [Clang.jl](https://github.com/JuliaInterop/Clang.jl)
with the [generator file](gen/generator.jl).

The API aims to replicate the Vulkan C-API and is thus very bare bones and hands-on.
Expand Down
5 changes: 4 additions & 1 deletion src/LibVulkan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ libvulkan_handle = C_NULL

function __init__()
libname = get(ENV, "JULIA_VULKAN_SDK_LIBNAME", "")
locations = get(ENV, "JULIA_VULKAN_SDK_SEARCH_PATH", "")
locations = [get(ENV, "JULIA_VULKAN_SDK_SEARCH_PATH", "")]
if isempty(libname)
libname = Libdl.find_library(["libvulkan", "vulkan", "vulkan-1", "libvulkan.so.1"], locations)
end
@assert libname != "" "cannot detect Vulkan SDK."
global libvulkan_handle = Libdl.dlopen(libname)
@assert libvulkan_handle != C_NULL "cannot dlopen libvulkan."
end

using CEnum
Expand Down Expand Up @@ -71,6 +72,8 @@ const VK_API_VERSION_1_2 = VK_MAKE_VERSION(1, 2, 0)
include(joinpath(@__DIR__, "..", "gen", "vk_common.jl"))
include(joinpath(@__DIR__, "..", "gen", "vk_api.jl"))

const VK_HEADER_VERSION_COMPLETE = VK_MAKE_VERSION(1, 2, VK_HEADER_VERSION)

# export everything
foreach(names(@__MODULE__, all=true)) do s
if startswith(string(s), "VK_") || startswith(string(s), "Vk") || startswith(string(s), "vk")
Expand Down
74 changes: 44 additions & 30 deletions test/glfw.jl
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
using GLFW
using VulkanCore
using VulkanCore.LibVulkan

@assert GLFW.VulkanSupported()

include("vkhelper.jl")

const WIDTH = 800
const HEIGHT = 600

# fill application info
sType = VK_STRUCTURE_TYPE_APPLICATION_INFO
pApplicationName = pointer(b"Vulkan Instance")
applicationVersion = convert_vk_back(UInt32, v"1.1")
pEngineName = pointer(b"Test")
engineVersion = convert_vk_back(UInt32, v"1.1")
apiVersion = convert_vk_back(UInt32, v"1.1")
appInfoRef = VkApplicationInfo(sType, C_NULL, pApplicationName, applicationVersion, pEngineName, engineVersion, apiVersion) |> Ref

# fill create info
sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO
flags = UInt32(0)
pApplicationInfo = Base.unsafe_convert(Ptr{VkApplicationInfo}, appInfoRef)
requiredExtensions = GLFW.GetRequiredInstanceExtensions()
@static if Sys.isapple()
@assert ("VK_MVK_macos_surface" in requiredExtensions) || ("VK_EXT_metal_surface" in requiredExtensions)
## init GLFW window
GLFW.WindowHint(GLFW.CLIENT_API, GLFW.NO_API) # not to create an OpenGL context
GLFW.WindowHint(GLFW.RESIZABLE, 0)
window = GLFW.CreateWindow(WIDTH, HEIGHT, "Vulkan")

## init Vulkan
## creating instance
appInfoRef = VkApplicationInfo(
"Application Name: Create Instance",
v"1.0.0",
"No Engine Name",
v"1.0.0",
VK_API_VERSION_1_2,
) |> Ref

extensions = GLFW.GetRequiredInstanceExtensions()
@test check_extensions(extensions)

layers = get(ENV, "JULIA_GITHUB_ACTIONS_CI", "OFF") == "ON" ? String[] : ["VK_LAYER_KHRONOS_validation"]
@test check_layers(layers)

createInfoRef = VkInstanceCreateInfo(appInfoRef, layers, extensions) |> Ref

instanceRef = Ref(VkInstance(C_NULL))
result = GC.@preserve appInfoRef layers extensions vkCreateInstance(createInfoRef, C_NULL, instanceRef)

@static if get(ENV, "JULIA_GITHUB_ACTIONS_CI", "OFF") == "ON"
@test_broken result == VK_SUCCESS
else
@test result == VK_SUCCESS
end

## cleaning up
if result == VK_SUCCESS
vkDestroyInstance(instanceRef[], C_NULL)
end
enabledExtensionCount = Ref{Cuint}(0)
ppEnabledExtensionNames = ccall((:glfwGetRequiredInstanceExtensions, GLFW.libglfw), Ptr{Cstring}, (Ref{Cuint},), enabledExtensionCount)
enabledExtensionCount = enabledExtensionCount[]
enabledLayerCount = Cuint(0)
ppEnabledLayerNames = C_NULL
createInfoRef = VkInstanceCreateInfo(sType, C_NULL, flags, pApplicationInfo, enabledLayerCount, ppEnabledLayerNames, enabledExtensionCount, ppEnabledExtensionNames) |> Ref

# create instance
instanceRef = Ref{VkInstance}(C_NULL)
result = vkCreateInstance(createInfoRef, C_NULL, instanceRef)
result != VK_SUCCESS && error("failed to create instance!")
instance = instanceRef[]
@show instance
vkDestroyInstance(instance, C_NULL)
GLFW.DestroyWindow(window)
121 changes: 121 additions & 0 deletions test/old_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
using VulkanCore
using VulkanCore.LibVulkan
using Test
using GLFW

const api = VulkanCore.vk

convert_vk_back(::Type{UInt32}, version::VersionNumber) = (version.major << 22) + (version.minor << 12) + version.patch
convert_vk(::Type{VersionNumber}, version::UInt32) = VersionNumber(UInt32(version) >> 22, (UInt32(version) >> 12) & 0x3ff, UInt32(version) & 0xfff)

err = VkResult(0)
count = Ref{Cuint}(0)
# Scan layers
err = api.vkEnumerateInstanceLayerProperties(count, C_NULL)
@assert err == api.VK_SUCCESS
global_layer_properties = Vector{api.VkLayerProperties}(undef, count[])
err = api.vkEnumerateInstanceLayerProperties(count, global_layer_properties)
@assert err == api.VK_SUCCESS

function Base.show(io::IO, lp::api.VkLayerProperties)
println(io, "Layer Properties: ")
println(io, " Layer Name: ", String(filter(x->x!=0, UInt8[lp.layerName...])))
println(io, " Spec Version: ", convert_vk(VersionNumber, lp.specVersion))
println(io, " Implementation Version: ", convert_vk(VersionNumber, lp.implementationVersion))
println(io, " description: ", String(filter(x->x!=0, UInt8[lp.description...])))
end
for elem in global_layer_properties
println(elem)
end

appname = b"vulkaninfo"

app_info = Ref(VkApplicationInfo(VK_STRUCTURE_TYPE_APPLICATION_INFO,
C_NULL,
pointer(appname),
1,
pointer(appname),
1,
convert_vk_back(UInt32, v"1.1")))

inst_info = Ref(VkInstanceCreateInfo(VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
C_NULL,
UInt32(0),
Base.unsafe_convert(Ptr{VkApplicationInfo}, app_info),
0,
C_NULL,
0,
C_NULL))

instance = Ref{VkInstance}(C_NULL)

err = vkCreateInstance(inst_info, C_NULL, instance)
@test err == VK_SUCCESS
println(instance)

gpu_count = Ref{Cuint}(0)
err = vkEnumeratePhysicalDevices(instance[], gpu_count, C_NULL)
@test err == VK_SUCCESS
devices = Array{VkPhysicalDevice}(undef, gpu_count[])

err = vkEnumeratePhysicalDevices(instance[], gpu_count, devices)
@test err == VK_SUCCESS

deviceprops = Ref{VkPhysicalDeviceProperties}()
vkGetPhysicalDeviceProperties(devices[], deviceprops)


function Base.show(io::IO, pdsp::VkPhysicalDeviceSparseProperties)
println(io, "Physical device Sparse Properties: ")
for name in fieldnames(typeof(pdsp))
println(io, " ", name, " ", getfield(pdsp, name) == 1)
end
end
function Base.show(io::IO, pdp::VkPhysicalDeviceProperties)
println(io, "Physical Device Properties: ")
println(io, " API Version: ", convert_vk(VersionNumber, pdp.apiVersion))
println(io, " Driver Version: ", convert_vk(VersionNumber, pdp.driverVersion))

println(io, " Vendor ID ", pdp.vendorID)
println(io, " Device ID: ", pdp.deviceID)
println(io, " Device Type: ", pdp.deviceType)
println(io, " Device Name: ", String(filter(x->x!=0, UInt8[pdp.deviceName...])))
println(io, " Pipeline Cache UUID: ", String(collect(pdp.pipelineCacheUUID)))
println(io, " Limits: ", pdp.limits)
println(io, " Sparse Properties: \n ", pdp.sparseProperties)
end

limitshow(x::Cuint) = Int(x)
limitshow(x::NTuple) = "<"*join(map(limitshow, x), " ")*">"
limitshow(x) = x

function Base.show(io::IO, pdl::VkPhysicalDeviceLimits)
println(io, "Physical Device Limits: ")
for name in fieldnames(typeof(pdl))
println(io, " ", name, " ", limitshow(getfield(pdl, name)))
end
end

println(deviceprops[])

queue_count = Ref{Cuint}(0)
vkGetPhysicalDeviceQueueFamilyProperties(devices[], queue_count, C_NULL)
queueprops = Array{VkQueueFamilyProperties}(undef, queue_count[])
println(queue_count[])
vkGetPhysicalDeviceQueueFamilyProperties(devices[], queue_count, queueprops)
println(queueprops)

memprops = Ref{VkPhysicalDeviceMemoryProperties}()
vkGetPhysicalDeviceMemoryProperties(devices[], memprops)

println(memprops[])
devicefeatures = Ref{VkPhysicalDeviceFeatures}()
vkGetPhysicalDeviceFeatures(devices[], devicefeatures)

function Base.show(io::IO, df::VkPhysicalDeviceFeatures)
println(io, "Physical device features: ")
for name in fieldnames(typeof(df))
println(io, " ", name, ": ", getfield(df, name) != 1 ? "un" : "", "supported")
end
end
println(devicefeatures[])
Loading

0 comments on commit c7a4e77

Please sign in to comment.