GPUOpen-Effects / TressFX

DirectX 12 and Vulkan libraries that provide convenient access to realistically rendered and simulated hair and fur
MIT License
789 stars 131 forks source link

Add a project for Vulkan port. #21

Open vlj opened 8 years ago

vlj commented 8 years ago

Here is the current state of my Vulkan port. It's based the master branch from may hence the conflicts. The classic TressFX algorithm is implemented as well as the Shortcut version (but not the deterministic variant). The skinned version is not implemented. It follows the DX11 interface as much as possible. SRV are replaced with ImageView and d3d context with command Buffer and extra parameters were added to switch between constant buffers (to avoid synchronisation). Since the command buffer creation is left to the user it's possible to run simulation and rendering on separate command buffers and submit them on different queue. Calling multiple time Asset load/processing is likely not safe since there is no lifetime tracking. I think the API should be extended to free some resources like Mesh or render target without having to release the TressFx object. I initially write the TressFX algorithm with a single renderpass but I finally use separate passes because I wasn't sure buffer were properly flushed without an explicit barrier. It didn't change performance as far as I can tell so I opted for the safest path.

Performance wise the rendering part is as fast as DX11 code on a HD 7750 and on a geforce card. The simulation is slower : it takes 3ms instead of 1ms on the hd 7750 and even more on the geforce, I will switch to storage buffer instead of image buffer in the compute shader to see if it solves the performance.

Compatibility wise the algorithm works as expected on radeon card. Congrats for the state of your vulkan implementation ! On geforce card using uniform buffer inside a compute shader is hanging the gpu so I had to use storage buffer to store constant data. It didn't change performance on radeon. There is also a small bug where some random pixels are not drawn, I wonder if it's not an issue with stencil op.

I wrote a very basic viewer using a custom framework here : https://github.com/vlj/YAGF it's the "TressFX.Vulkan" project.

I wrote a small script in python that replaces include and transform spv file into a single precompiled .h file. I still have to figure out how to integrate amd_tressfx_vulkan properly with premake.

vlj commented 8 years ago

I updated the PR. Now it's synced with master and uses premake build script.

I also fixed several bug from previous version : shortcut algorithm doesn't have random black point anymore, tangent computation is now split in a separate compute shader. Also performance are now even with the DX11 version. It's sub ms in both case.

The PR can be reviewed now I think.

jstewart-amd commented 8 years ago

Thanks, @vlj. We will review this shortly.

hey-o commented 8 years ago

Any updates?

Anteru commented 8 years ago

I haven't got around to review it yet. Hope is to do get some time next week.

Anteru commented 8 years ago

First of all: Thanks for the contribution! I've looked at the code (haven't actually run or profiled the thing yet) and found a couple of issues - could you please take a look at them?

vlj commented 7 years ago

Sorry for the delay, I updated the PR following some of your comments. I will break some functions into smaller part later but in the meantime you can have a look at the code.

By the way TressFX currently relies on DirectX11.h for some types, namely UINT and the XMMATRIX/XMVECTOR... however directxmath is available with an open source licence here : https://github.com/Microsoft/DirectXMath
It looks like it's portable which means that including directxmath instead of directx11.h would make tressFX more portable.

Broken1334 commented 7 years ago

Any progress?