Implementing BGFX as a driver...

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
AReichl
Posts: 268
Joined: Wed Jul 13, 2011 2:34 pm

Re: Implementing BGFX as a driver...

Post by AReichl »

I have problem accessing the repository.
There is only
https://gitlab.com/JFT/Irrlicht_extended.git
but that's for Irrlicht itself.
For Irrlicht-bgfx i tried
https://gitlab.com/JFT/Irrlicht_extended.git/tree/bgfx
but with no success.
JFT90
Posts: 22
Joined: Sun Jan 03, 2016 6:53 pm

Re: Implementing BGFX as a driver...

Post by JFT90 »

To pull the bgfx branch you just do:

Code: Select all

 
git clone https://gitlab.com/JFT/Irrlicht_extended.git
git checkout bgfx
 
maybe you need to use one more

Code: Select all

 
git pull
 
after switching to the bgfx branch - normally its not necessary if you have a freshly cloned version.
If we use a shader inside this version of Irrlicht inside a BGFX, will it be working, or miss some details? Have you made an example to launch the BGFX portion of this modified Irrlicht?
For first tests just try to build and launch the HelloWorld-Example. I didn't adapt the makefile for it yet, so expect some linker errors. Should be easily fixed by adding -lbgfxRelease to the ldflags.
For shaders have a look at 'source/Irrlicht/bgfx_shader'. Shaderfiles for bgfx are written in shaderc - it's very similar to glsl.
By using the shaderc tool from bgfx (will be compiled with the bgfx library) you can compile your shaderc (we named them *.sc) files to a binary glsl/hlsl/metal shader header.
Also have a look here: https://bkaradzic.github.io/bgfx/tools.html

For Windows builds try the Codeblocks or VisualStudio14 Project - for Mingw you maybe need to build bgfx yourself first by running

Code: Select all

make mingw-gcc-release32
inside the bgfx folder.
I will add compiled bgfxlibraries for mingw to the lib folder when I am back home later.
If you add CEGUI to the project will it be accessible by others?
CEGUI is used in a project I am working on at the moment. This project is also the reason we decided to add bgfx to irrlicht, since we wanted support for newer versions of DirectX/OpenGL and the drawcall sorting of bgfx is also quite attractive.
We are not planning to add CEGUI directly to the Irrlicht_extended project. But using CEGUI is quite simple with Irrlicht (once you succesfully compiled it^^): http://static.cegui.org.uk/docs/0.8.7/r ... orial.html
Irrlicht with bgfx-Driver https://gitlab.com/JFT/Irrlicht_extended (forked from Irrlicht trunk)
AReichl
Posts: 268
Joined: Wed Jul 13, 2011 2:34 pm

Re: Implementing BGFX as a driver...

Post by AReichl »

Still does not work.
"git checkout bgfx" says not a valid repository.
JFT90
Posts: 22
Joined: Sun Jan 03, 2016 6:53 pm

Re: Implementing BGFX as a driver...

Post by JFT90 »

You need to run 'git checkout bgfx' inside the Irrlicht_extended folder you created with 'git clone...'

I forgot the cd command in my post before - so the full command sequence would be:

Code: Select all

 
git clone https://gitlab.com/JFT/Irrlicht_extended.git
cd Irrlicht_extended
git checkout bgfx
 
Irrlicht with bgfx-Driver https://gitlab.com/JFT/Irrlicht_extended (forked from Irrlicht trunk)
JFT90
Posts: 22
Joined: Sun Jan 03, 2016 6:53 pm

Re: Implementing BGFX as a driver...

Post by JFT90 »

We have added support for compute shaders and instancing.
Also we decided to give users the ability to access some bgfx features more or less directly.
Checkout the files in the include/ directory:
IBgfxBuffer.h
IBgfxManipulator.h
IComputeShader.h

We know thats not really nice as other drivers won't be able to use it, but Bgfx offers OpenGl, DirectX, Metal and (hopefully) soon Vulkan anyway...

As there is never enough time and other projects to work on as well, adding new features plus fixing problems will probably take some time.
So if anyone is interested in adding more features of bgfx to Irrlicht or in helping bugs (we expect there are many) we would appreciate it ;)
Irrlicht with bgfx-Driver https://gitlab.com/JFT/Irrlicht_extended (forked from Irrlicht trunk)
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Implementing BGFX as a driver...

Post by robmar »

Hi, just wanted to ask if this can work with 1.7.3 without too much work?

Does this driver support the current shaders, for transparency, metal effect, etc?
JFT90
Posts: 22
Joined: Sun Jan 03, 2016 6:53 pm

Re: Implementing BGFX as a driver...

Post by JFT90 »

Hmmm... It should be possible to add the bgfx-driver to 1.7.3 without too much work
You would need all the files containing *Bgfx* from source and probably should run a diff between the two versions
to see the changes made to all Driver related parts.

The driver supports anything as long as you write the shaders yourself - we didn't implement all the standard effects available in other drivers,
because we didn't need them (yet) and usually we need more customized shaders for our projects anyway.
Irrlicht with bgfx-Driver https://gitlab.com/JFT/Irrlicht_extended (forked from Irrlicht trunk)
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Implementing BGFX as a driver...

Post by robmar »

Okay thanks, and how is the efficiency of the Bgfx driver, is there any extra overhead compared to the inbuilt DX9?
JFT90
Posts: 22
Joined: Sun Jan 03, 2016 6:53 pm

Re: Implementing BGFX as a driver...

Post by JFT90 »

I can't test the inbuilt DX9 vs Bgfx DX9 at the moment - Only have a Linux Laptop were I am right now.
The author of Bgfx says there is no big overhead: https://github.com/bkaradzic/bgfx/issues/631

In our cross-platform project we noticed significant fps improvements (40%) using bgfx instead of the inbuilt OpenGL driver.

If you want to run a benchmark - I can try to help you.
Irrlicht with bgfx-Driver https://gitlab.com/JFT/Irrlicht_extended (forked from Irrlicht trunk)
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Implementing BGFX as a driver...

Post by robmar »

Okay, any idea of the improvement of Bgfx compared to DX9?

I'd love to tun a benchmark, so any help would be appreciated
JFT90
Posts: 22
Joined: Sun Jan 03, 2016 6:53 pm

Re: Implementing BGFX as a driver...

Post by JFT90 »

I have no Idea how good bgfx performs with dx9.

Do you have an example you'd like to run the benchmark on?
Irrlicht with bgfx-Driver https://gitlab.com/JFT/Irrlicht_extended (forked from Irrlicht trunk)
ikam
Posts: 46
Joined: Sun Jun 24, 2007 4:46 pm
Location: France

Re: Implementing BGFX as a driver...

Post by ikam »

Nice job JFT90.
I'll use your implementation
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Implementing BGFX as a driver...

Post by robmar »

I have your code running, Irrlicht + BGFX, but there are problems with the first and some other shaders, probably because I'm using a different GPU to those tested on. Sometimes NVidia code runs the shaders, and AMD fails, or the other way around.

As the shaders are coded into the code files, its not easy to test and fix them.

Could original files for the shaders be provided?

Rather than coding the shader text into the source code, its better to load them from a standard text file, makes testing and fixing so much easier.
JFT90
Posts: 22
Joined: Sun Jan 03, 2016 6:53 pm

Re: Implementing BGFX as a driver...

Post by JFT90 »

Hey,

original shader files are written in shaderc: https://bkaradzic.github.io/bgfx/tools.html

you can find them in

Code: Select all

source/Irrlicht/bgfx_shader/
the *.sc files are the ones you can edit.
To compile them (i assume you have a git-bash shell on windows) just run the shellscript

Code: Select all

shaders.sh
In our project that uses irrlicht+bgfx I changed the compilation process to produce *.bin files that are loaded on runtime.
You are correct, testing is a lot faster that way. I will change the irrlicht code to load shader *.bin files at runtime as well as soon as I have some time.
Also: If you create an issue at our gitlab page https://gitlab.com/JFT/Irrlicht_extended, we will notice sooner, that something needs to be changed.

PS: Can you give me the error message you get when irrlicht/bgfx fails? In Debug there should be a lot of output.
Irrlicht with bgfx-Driver https://gitlab.com/JFT/Irrlicht_extended (forked from Irrlicht trunk)
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: Implementing BGFX as a driver...

Post by robmar »

The calls to load the shaders (2 or 3 of them), failed, I thought it was the AMD shader compiler not happy with the syntax. I've seen this many times where shader code compiles on the NVidia but not on the AMD, usually the code needs minor adjustment.
I´ll take a look at it again soon and try to fix it. Will post on your page.
Post Reply