Skip to content

Commit

Permalink
Add windows build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kaizhangNV committed Feb 9, 2024
1 parent 2752124 commit 67d48e8
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/win64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: build-win64

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v3

- name: Setup Ninja
uses: ashutoshvarma/setup-ninja@master
with:
# ninja version to download. Default: 1.10.0
version: 1.10.0

- name: configure
run: cmake --preset windows-ninja-msvc
- name: make
run: cmake --build build/windows-ninja-msvc
28 changes: 25 additions & 3 deletions source/DeviceWrapper.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
#pragma once

#if defined(Linux)
#include <dlfcn.h>
#elif defined(_WIN32)
#include <windows.h>
#else
#error "No OS specified"
#endif

#include <slang-com-ptr.h>
#include <slang-gfx.h>
#include <memory>
#include "Types.h"
#include "Object.h"
#include "ProgramManager.h"
#include <vulkan/vulkan.h>
#include <dlfcn.h>
#include "CpuTimer.h"

class ProgramManager;
Expand Down Expand Up @@ -66,10 +73,17 @@ class PipelineCreationAPIDispatcher : public gfx::IPipelineCreationAPIDispatcher
void** outPipelineState
)
{
void* vulkanLibraryHandle = nullptr;
const char* dynamicLibraryName = "Unknown";

#if defined(Linux)
dynamicLibraryName = "libvulkan.so.1";
vulkanLibraryHandle = dlopen(dynamicLibraryName, RTLD_NOW);
void* vulkanLibraryHandle = dlopen(dynamicLibraryName, RTLD_NOW);
#elif defined(_WIN32)
dynamicLibraryName = "vulkan-1.dll";
HMODULE vulkanLibraryHandle = ::LoadLibraryA(dynamicLibraryName);
#else
#error "No OS specified"
#endif

gfx::IDevice::InteropHandles outHandles;
device->getNativeDeviceHandles(&outHandles);
Expand All @@ -81,7 +95,15 @@ class PipelineCreationAPIDispatcher : public gfx::IPipelineCreationAPIDispatcher
vkDevice = (VkDevice)outHandles.handles[2].handleValue;

PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = nullptr;

#if defined(Linux)
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dlsym(vulkanLibraryHandle, "vkGetInstanceProcAddr");
#elif defined(_WIN32)
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)::GetProcAddress(vulkanLibraryHandle, "vkGetInstanceProcAddr");
#else
#error "No OS specified"
#endif

if (!vkGetInstanceProcAddr)
{
assert(!"Fail to get instance proc address");
Expand Down

0 comments on commit 67d48e8

Please sign in to comment.