您的位置:首页 > 其它

HLSL Compiler

2015-11-05 19:16 204 查看
(See also DirectX-Shaders and DirectX-ToDo )

Many projects - Wine included - could use an open source HLSL compiler.

Wine in particular needs one that accepts the DirectX HLSL and outputs the DirectX shader bytecode. At the moment it's enough to target Direct3D 9 HLSL/bytecode, later Wine will also need to extend it to Direct3D 10 and
11.

There are several ways to approach building a compiler:
write an ad hoc compiler using lex and yacc, without much of an optimizer (like Mesa has for GLSL)
ditto, but use a well-known IR representation so a good optimizer could be borrowed later
write the compiler using an existing compiler toolkit (like LLVM or maybe Open64)

It's not clear yet what the best path is, they probably all merit some exploration.

Here are a few HLSL-compiler-like things that have been spotted in the wild:


Wine patches

http://repo.or.cz/w/wine/hlsl-compiler.git - Matijn Woudt and Matteo Bruni's
sandbox for their wine HLSL compiler work


Compilers that read HLSL (and their target languages)

http://sourceforge.net/projects/hlsl2glsl (GLSL) (2006)

http://code.google.com/p/hlsl2glslfork (GLSL) (2008)

http://icculus.org/mojoshader (GLSL, ARB_*_program) (HLSL parser just started in 2010)

http://marc.info/?l=wine-devel&m=127125529916136&w=2 (Stefan Doesinger's
HLSL compiler, 2006... need better link)


Parsers

http://developer.nvidia.com/object/cg_compiler_code.html (nvidia's
2002 opensourced CG parser)


Compiler Backends that output shader assembly

http://sourceforge.net/projects/llvmptxbackend/ (LLVM IR -> PTX) (GPL, so
not mergable into LLVM tree)


Glue to interface Mesa's ad-hoc GLSL compiler to LLVM IR

http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/gallivm (GLSL
-> X86 SSE specific LLVM IR?)


Related Pages

http://www.prog.uni-saarland.de/projects/anysl (home of llvmptxbackend)

http://llvm.org/docs/BitCodeFormat.html (LLVM IR file format)

http://aras-p.info/blog/2010/05/21/compiling-hlsl-into-glsl-in-2010/

http://graphics.stanford.edu/~danielrh/babelshader.html (converts
MS shader assembly to ARB shader assembly) (2003)


Not very related pages

http://en.wikipedia.org/wiki/OpenCL (OpenCL is an HLSL-like language, but targets computation
rather than graphics, and there aren't any open source implementations?)

http://en.wikipedia.org/wiki/CUDA (ditto)

http://www.tungstengraphics.com/wiki/files/tgsi.pdf (404, but archive.org
still has it, sha1sum df05ca5e4252026782179cdeaf65af63d1d82040 )


Discussion

http://www.radeonhd.org/?page=archive_display&c=radeon&m=4&y=2010&d=2010-4-01 "...
in Wine we want HLSL -> llvm -> d3d_asm and then d3d_asm -> GLSL (->llvm -> tgsi) ..."

CategoryCompilers CategoryGraphics
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: