[LLVMdev] [GSoC] "Microsoft Direct3D shader bytecode backend" proposal

Charles Davis cdavis at mymail.mines.edu
Mon Mar 28 18:22:41 PDT 2011


Here's the other of my proposals for this year's Google Summer of Code.
(The first is on cfe-dev.) It was suggested to me by Dan Kegel (from the
Wine project, they really want this).

Title: Microsoft Direct3D shader bytecode backend

Abstract:

There is a distinct lack of open-source frameworks for compiling HLSL,
the shader language used by Direct3D, into bytecode that D3D can
understand. Currently, the only such framework is Ryan Gordon's
MojoShader, whose HLSL compiler component is still under heavy
development. By utilizing LLVM, it may be possible to generate
high-performance shader code from HLSL, just as Apple is known to do for
GLSL. The first step is a backend to generate D3D bytecode from LLVM IR.

Content:

1. Proposal

Currently, there are very few open-source frameworks for compiling
High-Level Shader Language (HLSL) into shader bytecode that can be
understood by Direct3D, a popular interface to 3D hardware in games.
This is because Microsoft provides its own interface in its D3DX (and
underlying D3DCompiler) DLLs. Most games therefore end up using D3DX to
compile their Direct3D shaders.

Microsoft seems to have paid no attention to optimization of the
resulting shader code, though. With LLVM, we can do better.

By using LLVM's optimizers, programs can potentially generate
high-performance shader code that works well on the platform on which
they are running. In addition, an open-source implementation would allow
the compiler to be embedded in many different applications--not the
least of which is Wine, which is in desperate need of a working shader
compiler.

The first step to this HLSL compiler is an LLVM backend for generating
D3D shader bytecode from LLVM IR. Therefore, I intend to implement such
a backend. Because implementing a full backend is a daunting task, I
intend to implement just enough to get simple examples working with
Wine's Direct3D implementation.

2. Interest

Over the past few years, I've become interested in graphics programming.
I'm also interested in learning how to design backends for LLVM.

3. Usefulness to LLVM

This should increase adoption of LLVM, particularly by games and other
3D graphical applications that use Direct3D.

4. Prior knowledge in compilers and LLVM in particular

I have been working with LLVM since the fall of 2009. I have a little
experience working with the x86 backend, but no experience writing my
own backend. I have, however, read the documents on building a new
backend, and I am very familiar with the TableGen syntax.

5. Academic, industry, etc. experience

I am a student at the Colorado School of Mines studying in Computer
Science. I am a Senior by year and credits, and I am set to graduate in
December of 2011. In addition, I have contributed to several open-source
projects, including Wine and LLVM.

6. Contact information

 - E-mail: cdavis at mymail.mines.edu
 - IRC nick: cdavis5x

Chip



More information about the llvm-dev mailing list