msiglreith / rostkatze

C++ implementation of Vulkan sitting on D3D12 :cat2:
Apache License 2.0
82 stars 2 forks source link

Support for DXC/DXIL/SM6.x.. #8

Open oscarbg opened 6 years ago

oscarbg commented 6 years ago

Diff: dxc.zip

Notes: Code is a fast hack.. dxcompiler code may have leaks lacking releasing objects.. Confirmed working on AMD and Intel HD GPUs on Vulkan PBR GLTF demo.. *the use of DXC or D3DCompile it's selected by :#define USEDXC (will not work right now on D3DCompile because I replaced all profiles from 5_1 to 6_0 so for example "cs_6_0",etc.. you may fix it with some

ifdef USEDXC

define TARGET_COMPUTE "cs_6_0"

else

define TARGET_COMPUTE "cs_5_1"

endif

& use TARGET_COMPUTE on all compute shaders etc.. then using USEDXC will work on D3DCompiler and DXcompiler.. *Ok seems AMD drivers still not support SM6.x if not in experimental mode (needs D3D12EnableExperimentalFeatures and Win10 in developer mode)(optional via #ifdef EXPERIMENTAL) (both NV and Intel support SM6.x without experimental mode but NV can't be tested on your backend) without experimental mode shaders may compile fine but you get error on creategraphicpipeline or CreateComputePipelineState..

DXC compiler found some error on: dst[dispatch_thread_id + dst_offset] = src.SampleLevel(src_sampler, uvw, src_offset); changed to: 0,int3(0,0,0));//src_offset.x, src_offset.yz); without errors..

note I tested this could be avoided I think by using "-Vd" flag to new compiler but anyway using this I think also forces to use experimental mode which should not be needed on Intel and perhaps on AMD drivers soon enough..

Also see new :https://blogs.msdn.microsoft.com/marcelolr/2018/03/06/using-the-github-dxcompiler-dll/ for avoiding experimental mode you need put DXIL.dll from Win10 SDK.. dxcompiler.dll also in SDK.. I have hardcoded to a folder you should select from rostkatze dll folder along with DXIL.dll included so at least in Intel GPU it can run without D3D12EnableExperimentalFeatures mode and Win10 developer mode enabled i.e. on any user PC.. as said bad luck AMD are the only "bad" ones: https://github.com/Microsoft/DirectXShaderCompiler/blob/master/README.md#running-shaders

msiglreith commented 6 years ago

Thanks for the patch, I will integrate it in the next days. Nice to see that dxil compiler is already shipped with win10. Probably will change it a bit to check for feature support and use an env var to enable/disable using the new compiler in case of issues.