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

Native translation to FXC binaries #4300

Closed
kvark opened this issue Jul 24, 2017 · 8 comments
Closed

Native translation to FXC binaries #4300

kvark opened this issue Jul 24, 2017 · 8 comments
Labels
area: naga back-end Outputs of naga shader conversion help required We need community help to make this happen. naga Shader Translator type: enhancement New feature or request

Comments

@kvark
Copy link
Member

kvark commented Jul 24, 2017

The FXC is not publicly specified, but there is some information about its structure:
http://timjones.io/blog/archive/2015/09/02/parsing-direct3d-shader-bytecode

It would be very nice to be able to generate it natively from SPIR-V. This would greatly improve the performance of (uncached) pipeline creation when working with API abstraction libraries that take SPIR-V input (gfx-rs/gfx#1374). This in turn could give us an edge comparing to NXT and MoltenVK.

The downsides are:

  • difficult to debug
  • working without clear specification
@jrmuizel
Copy link
Contributor

Wine and https://github.com/GPUOpen-Tools/common-src-ShaderUtils/tree/master/DX10 should give you enough information to fully understand DXBC

@antiagainst
Copy link

Contributions to add such functionalities into rspirv is definitely welcome! :-)

Just curious about DXBC vs. DXIL:

I'm more familiar with Vulkan/SPIR-V and its tooling than DirectX/DXBC. But I do have some experience with DXIL. (We are developing a SPIR-V codegen in DirectXShaderCompiler: microsoft/DirectXShaderCompiler#216.) AFAICT, DXIL is at a lower level than SPIR-V (DXIL has no requirement for structured control flows; DXIL scalarized all vectors; etc.) So translating from SPIR-V to DXIL should be feasible; although I would expect certain semantic differences will cause problems. I'm not quite clear about the level of abstraction of DXBC though.

Compared to translating SPIR-V to DXIL, I think the main advantage of converting to DXBC is that DXBC is widely accepted in drivers right now? Microsoft does have plan to shift to dxc and DXIL gradually from here.

@Skepfyr
Copy link

Skepfyr commented Oct 7, 2019

This seems out of scope for rspirv but in scope for javelin, it might make sense to raise this there.

@kvark
Copy link
Member Author

kvark commented Oct 8, 2019

Interestingly, this issue was filed before Javelin existed :) Moving now

@kvark kvark transferred this issue from gfx-rs/rspirv Oct 8, 2019
@kvark kvark added the help required We need community help to make this happen. label Mar 6, 2020
@kvark
Copy link
Member Author

kvark commented Dec 9, 2020

@Kangz pointed out that DXBC binaries need to be signed, and there isn't really a good way today to avoid going through HLSL when targeting DX11. Let's find out if it's necessary.

@magcius
Copy link
Contributor

magcius commented Jan 12, 2022

FYI, DXBC is not signed, it is just checksummed, and the algorithm can be found here:

https://github.com/GPUOpen-Archive/common-src-ShaderUtils/blob/master/DX10/DXBCChecksum.cpp
https://github.com/bkaradzic/bgfx/blob/a2ad0667397d82b921907870de45ca47d3e2526d/src/shader_dxbc.cpp#L726

@cwfitzgerald
Copy link
Member

This is the same for dxil, just that dxil.dll also validates, not just checksum (iirc the algorithm is the same)

@cwfitzgerald cwfitzgerald added kind: feature area: naga back-end Outputs of naga shader conversion labels Oct 25, 2023
@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/naga Oct 25, 2023
@cwfitzgerald cwfitzgerald added the naga Shader Translator label Oct 25, 2023
@teoxoy teoxoy added type: enhancement New feature or request and removed kind: feature labels Jul 3, 2024
@teoxoy
Copy link
Member

teoxoy commented Dec 11, 2024

I think this is out of scope at this point in time, unless someone makes a really good case for it.

@teoxoy teoxoy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: naga back-end Outputs of naga shader conversion help required We need community help to make this happen. naga Shader Translator type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants