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:
http://repo.or.cz/w/wine/hlsl-compiler.git - Matijn Woudt and Matteo Bruni's
sandbox for their wine HLSL compiler work
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)
http://developer.nvidia.com/object/cg_compiler_code.html (nvidia's
2002 opensourced CG parser)
http://sourceforge.net/projects/llvmptxbackend/ (LLVM IR -> PTX) (GPL, so
not mergable into LLVM tree)
http://cgit.freedesktop.org/mesa/mesa/tree/src/gallium/auxiliary/gallivm (GLSL
-> X86 SSE specific LLVM IR?)
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)
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 )
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
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'ssandbox 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's2002 opensourced CG parser)
Compiler Backends that output shader assembly
http://sourceforge.net/projects/llvmptxbackend/ (LLVM IR -> PTX) (GPL, sonot 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 computationrather 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
相关文章推荐
- Android ListView 使用及MVC关系概要
- java面向对象4
- PHP实现投镖求PI法,最笨但最有意思
- 多线程与网络A
- HLSL bytecode to GLSL编译器的第一步
- [C++11] 二叉树的实现
- Lesson16 Norm computations
- android中if判断引起的crash
- java面向对象3
- 如何在 GNOME 3 中显示桌面
- MySQL安全配置详解
- UVa 12700 - Banglawash
- opencv + numpy for python
- java面向对象2
- hdu5481
- 正式宣布DXBC2GLSL,HLSL字节码到GLSL的编译器
- java面向对象
- metasploit渗透测试笔记(内网渗透篇)
- daemon.c
- Jquery 中两个页面载入后执行的函数的分析区别