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

Comments

@boberfly
Copy link

commented Mar 3, 2015

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

:)

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Mar 6, 2015

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

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2015

@bkaradzic 👍

@shakesoda

This comment has been minimized.

Copy link
Contributor

commented Feb 16, 2016

@fire

This comment has been minimized.

Copy link

commented Feb 24, 2016

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Feb 24, 2016

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

This comment has been minimized.

Copy link
Contributor

commented Mar 12, 2016

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Mar 12, 2016

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Mar 12, 2016

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

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2016

Great thanks!

Sent from my iPhone

On Mar 13, 2016, at 1:53 AM, Branimir Karadžić notifications@github.com 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

This comment has been minimized.

Copy link

commented Jan 27, 2017

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Jan 27, 2017

@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

This comment has been minimized.

Copy link

commented Nov 1, 2017

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

@kalibannez

This comment has been minimized.

Copy link

commented Jan 29, 2018

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Jan 29, 2018

@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

This comment has been minimized.

Copy link

commented Oct 9, 2018

Looking forward to the vulkan support !

@ovenxp

This comment has been minimized.

Copy link

commented Oct 27, 2018

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Oct 27, 2018

the time probably dose

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

@raizam

This comment has been minimized.

Copy link
Contributor

commented Oct 29, 2018

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Oct 29, 2018

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

@raizam

This comment has been minimized.

Copy link
Contributor

commented Oct 29, 2018

Is Nintendo Switch a commercially viable platform? :)

@bkaradzic

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner

commented Jan 18, 2019

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner

commented Jan 18, 2019

@Paolo-Oliverio Do you use bgfx?

@Paolo-Oliverio

This comment has been minimized.

Copy link

commented Jan 18, 2019

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

This comment has been minimized.

Copy link

commented Apr 21, 2019

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Owner

commented Aug 10, 2019

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

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Aug 10, 2019

@rinthel Updated shaders and updated table...

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Aug 11, 2019

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

@rinthel

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Owner

commented Aug 11, 2019

Updated: #274 (comment)

@attilaz

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Aug 11, 2019

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

@rinthel

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Owner

commented Aug 13, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

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

@rinthel

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Owner

commented Aug 14, 2019

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

This comment has been minimized.

Copy link
Owner

commented Aug 16, 2019

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

@rinthel

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Owner

commented Aug 17, 2019

Updated #274 (comment)

@bkaradzic

This comment has been minimized.

Copy link
Owner

commented Aug 20, 2019

@bkaradzic bkaradzic closed this Aug 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.