Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add vulkan demo #583

Merged
merged 3 commits into from
Nov 13, 2023
Merged

add vulkan demo #583

merged 3 commits into from
Nov 13, 2023

Conversation

m0ppers
Copy link
Contributor

@m0ppers m0ppers commented Oct 22, 2023

finally I found the time to create a PR.

This is mostly based on https://github.com/m0ppers/nuklear-glfw-vulkan but it now uses an independent pipeline to make it more compatible and not assume too much global state. The original reason I created this was this: https://www.youtube.com/watch?v=ySk0Vo70ox0 we were using nuklear to draw the UI :) not sure if there are other nuklear projects that are running on android?

this is quite a heavy PR due to the nature of vulkan unfortunately. I have tried to make it c89 compatible.

I am using lots of memsets. I am not sure if I should be using NK_MEMSET?

the demo application uses bools for errors. however the nuklear_glfw_vulkan.h does not as the other integrations also just use void. not sure if this is ok.

this is not super clean but it should work I think.

I am happy to change things based on feedback.

Copy link
Contributor

@RobLoach RobLoach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unable to test it on my machine, but this looks great. Thanks a lot. Happy to have more implementations available.

@m0ppers
Copy link
Contributor Author

m0ppers commented Nov 9, 2023

so what are the next steps? 🤔

@RobLoach
Copy link
Contributor

RobLoach commented Nov 9, 2023

I'm happy to merge, but it would be awesome to get another person to review. Let's leave it up for a bit to see if someone else can try it out.

@riri
Copy link
Contributor

riri commented Nov 12, 2023

I cloned the project, it compiles but I get an error at execution. I'm not familiar with vulkan so I don't know if it's a normal error or not, but would like to be able to see the render before I give my opinion:

Available vulkan layers:
  VK_LAYER_VALVE_steam_fossilize_32
  VK_LAYER_VALVE_steam_fossilize_64
  VK_LAYER_VALVE_steam_overlay_32
  VK_LAYER_VALVE_steam_overlay_64
  VK_LAYER_MANGOHUD_overlay_x86
  VK_LAYER_MANGOAPP_overlay
  VK_LAYER_MANGOHUD_overlay_x86_64
  VK_LAYER_MANGOAPP_overlay
  VK_LAYER_NV_optimus
Couldn't find validation layer VK_LAYER_KHRONOS_validation
failed to create vulkan demo!

@m0ppers
Copy link
Contributor Author

m0ppers commented Nov 13, 2023

@riri the vulkan validation layers are an integral part when doing vulkan development. they check api calls for validity and verify things against what the driver/GPU supports. for example when you try to allocate a large buffer and the buffer is larger than what the driver supports you will get a nice message that you did something wrong. more details here: https://github.com/KhronosGroup/Vulkan-ValidationLayers#introduction

In a release version you would disable them as they impose quite some overhead but they are absolutely crucial when doing development. As the demo is likely being used by people wanting to integrate nuklear into their project (so these are people having them installed anyway) I made them non-optional because they are "needed" for the development of the demo itself anyway.

It is of course possible to make them optional (note that this ONLY applies to the vulkan demo - the nuklear vulkan implementation does NOT depend on them). Should I do it? As we can see here it is not completely unlikely that people would start the demo without having them installed 😹 so maybe that is a good idea even if they are not really the target audience.

However they can easily be installed. for arch linux the package is "vulkan-validation-layers". for ubuntu: vulkan-validationlayers-dev. On windows you would have to install the vulkan sdk (https://vulkan.lunarg.com/). for mac there is an emulation layer on top of metal that allows mac to run vulkan applications however as far as I know the demo application needs some changes to make it work on mac (I don't have a mac test device). So the demo is currently win/linux only.

I think I answered my own question meanwhile. I will make them optional 😂

@riri
Copy link
Contributor

riri commented Nov 13, 2023

I think I answered my own question meanwhile. I will make them optional 😂

Yes you did lol

Thanks for the clear information. I think then it's better to make it optional either with a define or a boolean value. People knowing how to develop with vulkan will know what to do, and others (like me) just curious and reading a vulkan implementation wont be blocked.

I've added the arch package and it looks good to me.
Awaiting your little change to make it optional and I'll merge.

@m0ppers
Copy link
Contributor Author

m0ppers commented Nov 13, 2023

ok. this should now work with or without validation layers 🥳

@riri
Copy link
Contributor

riri commented Nov 13, 2023

Perfect, I merge

@riri riri merged commit a18175c into Immediate-Mode-UI:master Nov 13, 2023
@RobLoach
Copy link
Contributor

Thanks @m0ppers and @riri!

This was referenced Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants