vulkan-go / vulkan

Vulkan API bindings for Go programming language
MIT License
744 stars 56 forks source link

Windows Compatibility #1

Closed ghost closed 7 years ago

ghost commented 7 years ago

Can you make it compatible with Windows? It doesn't compile as Windows needs its own dynamic loading (windows.h instead of dlfcn.h)

xlab commented 7 years ago

I'll do that when I have enough time. You still can contribute your solution, it's easy to do (I'm serious). I just need to unwrap my PC with gtx after moving, setup everything back etc.

xlab commented 7 years ago

Btw, getting bindings autogenerated for win32-specific code might be difficult as for now, I'm getting patches ready for MinGW support in cgogen.

ghost commented 7 years ago

I have an almost working patch based on dlfcn-win32 as a dependency byt i'm still bothering with some linker errors, maybe this will help you: https://github.com/dlfcn-win32/dlfcn-win32

ghost commented 7 years ago

Also, i had some other problems using the windows.h way, but i can not remember why

xlab commented 7 years ago

GLFW FTW.

xlab commented 7 years ago

@PWN1109 Implemented. Now works for Windows 32-bit or 64-bit. Window initialisation and pointer hooks are done via GLFW, see:

There is a demo already that does VulkanInfo:

To get it running you need to download GLFW 3.2+ precompiled binaries, and run go install command like this (in MSYS/Git shell):

$ CGO_CFLAGS="-IC:\dev\glfw-3.2.1\include" CGO_LDFLAGS="-LC:\dev\glfw-3.2.1\lib-mingw-w64" go install

I'll resolve this issue as soon as update the README.

ghost commented 7 years ago

Yeah, when I try to use your command, all I get is: http://hastebin.com/figoboyotu.tex . That's the same error I've been getting when I tried to port it myself.

ghost commented 7 years ago

Nevermind. Got it fixed with "-lpsapi" linker flag

xlab commented 7 years ago

Whoa, thanks. I wonder if I should include that linker flag too by default. Just for compatibility reasons. Could you provide some specifics about your environment?

ghost commented 7 years ago

What details would you like me to provide you?

xlab commented 7 years ago

@PWN1109 OS version, compiler details (gcc -v), alsogo env maybe. Thanks.

ghost commented 7 years ago

Here you go: http://hastebin.com/lacafaboju.sql

ghost commented 7 years ago

Moreover, i'm having some issues with ACCESS_VIOLATION, but i do not know yet if it's my fault or something in bindings

xlab commented 7 years ago

@PWN1109 I'm running my simple examples with no problem

Things to try:

1) Try to update and rebuild vulkan-go/vulkan; 2) Try to use github.com/vulkan-go/glfw/v3.3/glfw as in demos; 3) Check out https://github.com/vulkan-go/demos/tree/master/vulkandraw demo, how the main.go is organized; 4) Check if you're calling vk.InitInstance(instance) after creating an instance, this would re-set PFNs to instance-based ones.

Keep in mind that I heavily updated the source and demos on the weekend, while adding support for more platforms.

ghost commented 7 years ago

I've almost copied your vulkandraw and i'm getting ACCESS_VIOLATION on vk.InitInstance, are you available on some IRC or something? Issues are quite poor solution for conversations.

xlab commented 7 years ago

@PWN1109 email me

xlab commented 7 years ago

Ok, so just this part was missing in his code:

buffer, err = device.CreateBuffers()
orPanic(err)

I'm locking the thread, please feel free to open new issues. Thanks.