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
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)
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?)
http://www.prog.uni-saarland.de/projects/anysl (home of llvmptxbackend)
http://llvm.org/docs/BitCodeFormat.html (LLVM IR file format)
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://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) ..."