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

Justin Holewinski justin.holewinski at gmail.com
Tue Mar 29 04:14:21 PDT 2011


On Mon, Mar 28, 2011 at 9:22 PM, Charles Davis <cdavis at mymail.mines.edu>wrote:

> 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.
>

Do you have any sources for this?  In my experience, fxc is able to do some
clever tricks such as replacing if-then-else conditions with predicated
instructions and swizzles.


>
> 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.
>

I'm a bit confused how Wine would take advantage of a Direct3D bytecode
compiler.  Would they not want to re-compile Direct3D bytecode (most often
shipped with games in binary form instead of HLSL source) to something an
OpenGL implementation on *nix could handle?


>
> 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.
>

Could you be a bit more specific on your goals?  A few quick questions that
come to mind are:

1. What shader models will you aim to support?
2. What types of shared will you aim to support?  e.g. vertex, pixel,
geometry, hull
3. How do you propose to handle vertex buffer semantics?  e.g. POSITION0,
TEXCOORD0, NORMAL, etc.

Perhaps a simple example would be nice, showing a very simple LLVM IR input
and the (proposed) bytecode output.


>
> 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
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110329/0a54e425/attachment.html>


More information about the llvm-dev mailing list