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 support #274

Closed
boberfly opened this issue Mar 3, 2015 · 61 comments
Closed

Add Vulkan support #274

boberfly opened this issue Mar 3, 2015 · 61 comments
Assignees

Comments

@boberfly
Copy link

boberfly commented Mar 3, 2015

The OpenGL successor:
https://www.khronos.org/vulkan

:)

@bkaradzic
Copy link
Owner

Hard part done https://github.com/bkaradzic/bgfx/blob/master/src/renderer_vk.cpp, now just Khronos to release specs, headers, docs, etc. and I can start filling up the blanks... :)

@dariomanesku
Copy link
Contributor

@bkaradzic 👍

@shakesoda
Copy link
Contributor

It's finally happening! 👍

https://www.khronos.org/registry/vulkan/specs/1.0/apispec.html

@fire
Copy link

fire commented Feb 24, 2016

Whooo, can't wait for this to be completed.

@bkaradzic
Copy link
Owner

It won't change bgfx API. It's just another rendering backend. Everything you write with bgfx will just work once it's in.

@vinjn
Copy link
Contributor

vinjn commented Mar 12, 2016

Do you have a roadmap for Vulkan support?
Or is someone already working on it!!

@bkaradzic
Copy link
Owner

I'm working on it. ETA, when it's done.

@bkaradzic
Copy link
Owner

ETA, when it's done is because, if you're using bgfx, you should not care what's behind it, nothing will change in bgfx API specifically for Vulkan, and even if there are changes it will be reflected for all other renderers. Once I release Vulkan backend renderer, your existing code will just work there.

If you're just curious to see how Vulkan implementation looks like, just look at D3D12 since it's closest to Vulkan.

@vinjn
Copy link
Contributor

vinjn commented Mar 13, 2016

Great thanks!

Sent from my iPhone

On Mar 13, 2016, at 1:53 AM, Branimir Karadžić [email protected] wrote:

ETA, when it's done is because, if you're using bgfx, you should not care what's behind it, nothing will change in bgfx API specifically for Vulkan, and even if there are changes it will be reflected for all other renderers. Once I release Vulkan backend renderer, your existing code will just work there.

If you're just curious to see how Vulkan implementation looks like, just look at D3D12 since it's closest to Vulkan.


Reply to this email directly or view it on GitHub.

@sp82
Copy link

sp82 commented Jan 27, 2017

What's the status of the implementation? I see a lot of code is already committed. Is it done?

@bkaradzic
Copy link
Owner

@sp82 it's work in progress, not usable yet. But also you should not care about it because from bgfx user point of view there is no difference between underlying APIs used.

@kalibannez
Copy link

Hi @bkaradzic !
What status of Vulkan renderer support is actual now?
What bugs still presented?

@kalibannez
Copy link

Hi @bkaradzic !
Is there still no news about Vulkan support?

@bkaradzic
Copy link
Owner

@kalibannez All platforms have support for at least one renderer. Once Vulkan is in you'll be able to switch, there is no platform that bgfx supports and requires only Vulkan.

Also once Vulkan is working I'll close this issue, and you'll get notification about it.

@pramanc
Copy link

pramanc commented Oct 9, 2018

Looking forward to the vulkan support !

@ovenxp
Copy link

ovenxp commented Oct 27, 2018

Hi, @bkaradzic
What's the time probably dose the vulkan be added to BGFX?

@bkaradzic
Copy link
Owner

the time probably dose

The time will be sometime in the future, and dose will be 1. :)

@raizam
Copy link
Contributor

raizam commented Oct 29, 2018

Hi, when will Vulkan be added to BGFX? :trollface:

@bkaradzic
Copy link
Owner

As soon as it becomes relevant for any commercially viable platform. ;)

@raizam
Copy link
Contributor

raizam commented Oct 29, 2018

Is Nintendo Switch a commercially viable platform? :)

@bkaradzic
Copy link
Owner

bkaradzic commented Oct 29, 2018

Switch uses native graphics API called NVN:

NVIDIA additionally created new gaming APIs to fully harness this performance. The newest API, NVN, was built specifically to bring lightweight, fast gaming to the masses.
https://blogs.nvidia.com/blog/2016/10/20/nintendo-switch/

@Paolo-Oliverio
Copy link

Paolo-Oliverio commented Jan 18, 2019

Switch uses native graphics API called NVN:

Do Unity and Unreal support NVN or Vulkan?
If you are not making any NVN support then Vulkan is still relevant both for Switch and Android.
I guess Vulkan will get relevant even for linux based game streaming.

@bkaradzic
Copy link
Owner

Do Unity and Unreal support NVN or Vulkan?
If you are not making any NVN support then Vulkan is still relevant both for Switch and Android.

What's your point here?!

@Paolo-Oliverio
Copy link

Paolo-Oliverio commented Jan 18, 2019

I asked about ue4 and unity as i didn't find the answer with a quick search.Not saying you should follow what others do.It was just curiousity.second the existence of nvn doesn't fight the relevancy of Vulkan even not counting Android.

@bkaradzic
Copy link
Owner

@Paolo-Oliverio Do you use bgfx?

@Paolo-Oliverio
Copy link

I'm making a native backend for my html5 only haxe engine and so I'm evaluating the library stack. for the render I'm planning to use bgfx or sokol's gfx.h. i'll probably go with bgfx as I just used bx and like it and bgfx not being one single file.

@cdannemiller
Copy link

The biggest advantage of Vulkan on platforms that support it is the
VK_KHR_display extension which allows rendering without a X11 server. AFAIK this isn't possible with the other backends.

@rinthel
Copy link
Contributor

rinthel commented Aug 10, 2019

@bkaradzic and some other examples that uses codes in common dir also should include recompiled embedded shader binaries. I will PR for this issue soon, including the metaballs example.

@bkaradzic
Copy link
Owner

@rinthel I thought you submitted embedded shaders with your PR.

@bkaradzic
Copy link
Owner

@rinthel Updated shaders and updated table...

@bkaradzic
Copy link
Owner

@rinthel Are there any special MoltenVK/OSX build instructions for bgfx?

@rinthel
Copy link
Contributor

rinthel commented Aug 11, 2019

@bkaradzic Nothing special in build, but some environment variables should be set for running examples. Let me explain what I know about that. Here is the link which I referred during setting in macOS.

  • In the directory that has example executable files, it also should have libvulkan.dylib files to load the vulkan's instance functions.
  • VK_ICD_FILENAMES=$VULKAN_SDK/etc/vulkan/icd.d/MoltenVK_icd.json should be set as an environment variable, in order to load libMoltenVK.dylib.
  • And when using layer extensions such as a standard validation layer, something like VK_LAYER_PATH=$VULKAN_SDK/etc/vulkan/explicit_layer.d also should be set to load layers.

Please let me know if you have any other question :)

@attilaz
Copy link
Contributor

attilaz commented Aug 11, 2019

@rinthel Thanks for the info. I have tried it but couldn't make it work. After that I have tried using the system path install './install_vulkan.py' . It seems to do the trick but I got validation errors:
https://gist.github.com/attilaz/28869f5cd80047b32fb1301daf82ec14

At the beginning there is 'bgfx platform data like window handle or backbuffer is not set, creating headless device.' Which is suspicious.

Any advice, what should I do to make it work?

@attilaz
Copy link
Contributor

attilaz commented Aug 11, 2019

@rinthel
Problem was that VK_FORMAT_D24_UNORM_S8_UINT is not a supported format I have changed to VK_FORMAT_D32_SFLOAT_S8_UINT and 00-helloworld works perfectly! 👍

https://github.com/bkaradzic/bgfx/blob/master/src/renderer_vk.cpp#L1547

I will check other examples, which ones are expected to work?

@rinthel
Copy link
Contributor

rinthel commented Aug 11, 2019

@attilaz good! An appropriate depth/stencil format choice step should be added in the initialization step, but I didn't write that yet.
Once you succeeded to run an basic example, any examples should be executable that @bkaradzic reports on windows, I think.

@attilaz
Copy link
Contributor

attilaz commented Aug 11, 2019

MacBook Air (13-inch, Early 2014) Intel HD Graphics 5000
MacOS Mojave 10.14.4

Results are similar to what @bkaradzic saw on windows/nvidia:

From 00 - 23 everything works except:

15 - incorrect depth sampling
16 - bgfx.cpp (4314): BGFX CHECK Texture format is not supported! Use bgfx::isTextureValid to check support for texture format before creating it. (layers 1, format D24S8)
17 crashes at https://github.com/bkaradzic/bgfx/blob/master/src/renderer_vk.cpp#L3626
19 crashes, validation fails at https://github.com/bkaradzic/bgfx/blob/master/src/renderer_vk.cpp#L3160
21 - shader not found

@bkaradzic
Copy link
Owner

Updated: #274 (comment)

@attilaz
Copy link
Contributor

attilaz commented Aug 11, 2019

Latest PR (2b5246f ) introduced new problems:
13 - Validation fails: Vertex shader consumes input at location 2 but not provided
14 - Validations fails: Vertex shader consumes input at location 3 but not provided

It fixed 19 with default options for me, but when I change options to 'mrt independent' I get validation error.

@rinthel
Copy link
Contributor

rinthel commented Aug 11, 2019

@attilaz OK, I’ll check it on my mac!

@rinthel
Copy link
Contributor

rinthel commented Aug 12, 2019

@attilaz I found what was wrong in my last PR, and create another PR (#1854) to fix it! BTW, the issue related to the example 19 seems to be another issue. I'll track it later!

@rinthel
Copy link
Contributor

rinthel commented Aug 13, 2019

@bkaradzic @attilaz Now I'm trying to support compute shaders on Vulkan. And I have the issue that should be discussed.
Currently, shader codes are precompiled with HLSL style and then feeded to SPIR-V compiler with HLSL input option. When using HLSL input, Buffer and RWBuffer uniforms are converted into separate_images and images, which are hard to treat with VertexBuffer objects in BGFX.
So I decide to modify shaderc compiler again in order to precompile shader code with GLSL-style and feed it to SPIR-V compiler.
Please let me know if you have any idea or notice that should be considered by me. I'll leave a comment or PR when I make any progress!

@bkaradzic
Copy link
Owner

When using HLSL input, Buffer and RWBuffer uniforms are converted into separate_images and images, which are hard to treat with VertexBuffer objects in BGFX.

But shouldn't SPIRV-Cross convert this back to something comparable?

I didn't use GLSL input because it added even more preprocessor hacks, and HLSL was cleaner path.

@rinthel
Copy link
Contributor

rinthel commented Aug 13, 2019

@bkaradzic good point that I missed! I’ll try that.

@rinthel
Copy link
Contributor

rinthel commented Aug 13, 2019

@bkaradzic It seems to be solved by modifying preprocessor in bgfx_compute.sh as below:

#if BGFX_SHADER_LANGUAGE_METAL || BGFX_SHADER_LANGUAGE_SPIRV // add SPIRV case!
#define BUFFER_RO(_name, _struct, _reg) StructuredBuffer<_struct>   _name : REGISTER(t, _reg)
#define BUFFER_RW(_name, _struct, _reg) RWStructuredBuffer <_struct> _name : REGISTER(u, _reg)
#define BUFFER_WR(_name, _struct, _reg) BUFFER_RW(_name, _struct, _reg)
#else
#define BUFFER_RO(_name, _struct, _reg) Buffer<_struct>   _name : REGISTER(t, _reg)
#define BUFFER_RW(_name, _struct, _reg) RWBuffer<_struct> _name : REGISTER(u, _reg)
#define BUFFER_WR(_name, _struct, _reg) BUFFER_RW(_name, _struct, _reg)
#endif

Thanks!

@bkaradzic
Copy link
Owner

bkaradzic commented Aug 14, 2019

Linux - Mesa 19.2.0-devel (git-4619535 2019-08-07 bionic-oibaf-ppa)

  • 00
  • 01
  • 02
  • 03
  • 04
  • 05
  • 06
  • 07
  • 08 - cube updated with compute doesn't work
  • 09
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15 - shadow sampler not supported
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22 - multiple swap chain is not implemented yet
  • 23
  • 24
  • 26 - occlusion query not supported
  • 27
  • 28
  • 29
  • 30 - readback not supported
  • 31 - readback not supported
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37 - draw indirect not supported
  • 38
  • 39 - texture2d array not supported
  • 40 - readback not supported
  • 41 - crash VK_ERROR_OUT_OF_DEVICE_MEMORY

@metora
Copy link

metora commented Aug 14, 2019

Windows 10 - Radeon Vega 8 Graphics (driver 19.7.1)

The depth stencil is failed with VK_FORMAT_D24_UNORM_S8_UINT.
It can with VK_FORMAT_D32_SFLOAT_S8_UINT only.

In addition, VkAllocationCallbacks is confusing s_renderVK->m_allocatorCb and s_allocationCb.
It will crash when it start to vkDestroy any objects.

@bkaradzic
Copy link
Owner

In addition, VkAllocationCallbacks is confusing s_renderVK->m_allocatorCb and s_allocationCb.
It will crash when it start to vkDestroy any objects.

Can you grab latest and test it again? cebb749

@bkaradzic
Copy link
Owner

@rinthel I fixed shaderc and now 21-deferred works. It crashes once I select "Show light scissor" and move away camera.

@rinthel
Copy link
Contributor

rinthel commented Aug 16, 2019

@bkaradzic Good! I checked it on my iMac and it seems to work but draw buggy scene, and some validation failure case were found. I'll fix it on the next PR.

@bkaradzic
Copy link
Owner

Updated #274 (comment)

@bkaradzic
Copy link
Owner

Added:
https://twitter.com/bkaradzic/status/1163446410215165952

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests