[Mesa-dev] Mesa (d3d1x): d3d1x: add new Direct3D 10/11 COM state tracker for Gallium

Keith Whitwell keith.whitwell at gmail.com
Mon Sep 20 15:45:12 PDT 2010


Luca,

This is an amazing achievement -- not least because even excluding
this you've been incredibly productive recently.  I hope you haven't
got any more monster projects about to uncloak...

A couple of questions - it looks like this is a drop-in for the
d3d10/11 runtime, rather than an implementation of the DDI.  I think
that makes sense, but it could also be possible to split it into two
pieces implementing either side of the d3d10 DDI interface.  Any
thoughts on whether that's interesting to you?

Just trying to wrap my head around this, and how D3D10 works on
linux...  Right now, the test applications must be some sort of hybrid
between a regular posix/linux app and a win32/com/etc application,
right?  So you've essentially taken d3d10 plus a minimal amount of
dxgi, com, etc, sufficient to support the graphics apis, and
implemented that on linux+gallium?

I can see this being a useful tool for people porting win32 games to
linux, but at the same time there will probably be ongoing confusion
about which bits of win32 are a part of this platform -- I guess
that's where wine comes in.

Will this codebase work on windows, ie as a drop-in replacement for
the d3d10 runtime?  Or would it, with a bit of work?

Keith

On Mon, Sep 20, 2010 at 8:58 PM, Luca Barbieri
<lb at kemper.freedesktop.org> wrote:
> Module: Mesa
> Branch: d3d1x
> Commit: e80d59faaa410bfc78af64204bc4055b837c7fad
> URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e80d59faaa410bfc78af64204bc4055b837c7fad
>
> Author: Luca Barbieri <luca at luca-barbieri.com>
> Date:   Sun Sep 12 02:49:36 2010 +0200
>
> d3d1x: add new Direct3D 10/11 COM state tracker for Gallium
>
> This is a new implementation of the Direct3D 11 COM API for Gallium.
>
> Direct3D 10 and 10.1 implementations are also provided, which are
> automatically generated with s/D3D11/D3D10/g plus a bunch of #ifs.
>
> While this in an initial version, most of the code is there (limited
> to what Gallium can express), and tri, gears and texturing demos
> are working.
>
> The primary goal is to realize Gallium's promise of multiple API
> support, and provide an API that can be easily implemented with just
> a very thin wrapper over Gallium, instead of the enormous amount of
> complex code needed for OpenGL.
>
> The secondary goal is to run Windows Direct3D 10/11 games on Linux
> using Wine.
> Wine dlls are currently not provided, but adding them should be
> quite easy.
>
> Fglrx and nvidia drivers can also be supported by writing a Gallium
> driver that talks to them using OpenGL, which is a relatively easy
> task.
> Thanks to the great design of Direct3D 10/11 and closeness to Gallium,
> this approach should not result in detectable overhead, and is the
> most maintainable way to do it, providing a path to switch to the
> open Gallium drivers once they are on par with the proprietary ones.
>
> Currently Wine has a very limited Direct3D 10 implementation, and
> completely lacks a Direct3D 11 implementation.
>
> Note that Direct3D 10/11 are completely different from Direct3D 9
> and earlier, and thus warrant a fully separate implementation.
>
> The third goal is to provide a superior alternative to OpenGL for
> graphics programming on non-Windows systems, particularly Linux
> and other free and open systems.
>
> Thanks to a very clean and well-though design done from scratch,
> the Direct3D 10/11 APIs are vastly better than OpenGL and can be
> supported with orders of magnitude less code and development time,
> as you can see by comparing the lines of code of this commit and
> those in the existing Mesa OpenGL implementation.
>
> This would have been true for the Longs Peak proposal as well, but
> unfortunately it was abandoned by Khronos, leaving the OpenGL
> ecosystem without a graphics API with a modern design.
>
> A binding of Direct3D 10/11 to EGL would solve this issue in the
> most economical way possible, and this would be great to provide
> in Mesa, since DXGI, the API used to bind Direct3D 10/11 to Windows,
> is a bit suboptimal, especially on non-Windows platforms.
>
> Finally, a mature Direct3D 10/11 implementation is intrinsically going
> to be faster and more reliable than an OpenGL implementation, thanks
> to the dramatically smaller API and the segregation of all nontrivial
> work to object creation that the application must perform ahead of
> time.
>
> Currently, this commit contains:
> - Independently created headers for Direct3D 10, 10.1, 11 and DXGI 1.1,
>  partially based on the existing Wine headers for D3D10 and DXGI 1.0
> - A parser for Direct3D 10/11 DXBC and TokenizedProgramFormat (TPF)
> - A shader translator from TokenizedProgramFormat to TGSI
> - Implementation of the Direct3D 11 core interfaces
> - Automatically generated implementation of Direct3D 10 and 10.1
> - Implementation of DXGI using the "native" framework of the EGL st
> - Demos, usable either on Windows or on this implementation
>  - d3d11tri, a clone of tri
>  - d3d11tex, a (multi)texturing demo
>  - d3d11gears, an improved version of glxgears
>  - d3d11spikysphere, a D3D11 tessellation demo (currently Windows-only)
> - A downloader for the Microsoft HLSL compiler, needed to recompile
>  the shaders (compiled shader bytecode is also included)
>
> To compile this, configure at least with these options:
> --with-state-trackers=egl,d3d1x --with-egl-platforms=x11
> plus some gallium drivers (such as softpipe with --enable-gallium-swrast)
>
> The Wine headers (usually from a wine-dev or wine-devel package) must
> be installed.
> Only x86-32 has been tested.
>
> You may need to run "make" in the subdirectories of src/gallium/winsys/sw
> and you may need to manually run "sudo make install" in
> src/gallium/targets/egl
>
> To test it, run the demos in the "progs" directory.
> Windows binaries are included to find out how demos should work, and to
> test Wine integration when it will be done.
>
> Enjoy, and let me know if you manage to compile and run this, or
> which issues you are facing if not.
>
> Using softpipe is recommended for now, and your mileage with hardware
> drivers may vary.
> However, getting this to work on hardware drivers is also obviously very
> important.
>
> Note that currently llvmpipe is buggy and causes all 3 gears to be
> drawn with the same color.
> Use export GALLIUM_DRIVER=softpipe to avoid this.
>
> Thanks to all the Gallium contributors and especially the VMware
> team, whose work made it possible to implement Direct3D 10/11 much
> more easily than it would have been otherwise.
>
> ---
>
>  src/gallium/state_trackers/d3d1x/Makefile          |   11 +
>  src/gallium/state_trackers/d3d1x/Makefile.inc      |   19 +
>  .../state_trackers/d3d1x/d3d1xshader/Makefile      |    7 +
>  .../d3d1x/d3d1xshader/include/dxbc.h               |  101 +
>  .../d3d1x/d3d1xshader/include/le32.h               |   45 +
>  .../state_trackers/d3d1x/d3d1xshader/include/tpf.h |  808 +++++++
>  .../d3d1x/d3d1xshader/src/dxbc_dump.cpp            |   43 +
>  .../d3d1x/d3d1xshader/src/dxbc_parse.cpp           |   93 +
>  .../d3d1x/d3d1xshader/src/tpf_analyze.cpp          |  186 ++
>  .../d3d1x/d3d1xshader/src/tpf_dump.cpp             |  222 ++
>  .../d3d1x/d3d1xshader/src/tpf_parse.cpp            |  424 ++++
>  .../d3d1x/d3d1xshader/src/tpf_text.cpp             |  385 +++
>  .../state_trackers/d3d1x/d3d1xshader/src/utils.h   |   45 +
>  .../d3d1x/d3d1xshader/tools/fxdis.cpp              |   75 +
>  .../state_trackers/d3d1x/d3d1xstutil/Makefile      |    5 +
>  .../d3d1x/d3d1xstutil/include/d3d1xstutil.h        | 1038 ++++++++
>  .../d3d1x/d3d1xstutil/src/dxgi_enums.cpp           |  147 ++
>  src/gallium/state_trackers/d3d1x/d3dapi/Makefile   |    4 +
>  src/gallium/state_trackers/d3d1x/d3dapi/d3d10.idl  | 1554 ++++++++++++
>  .../state_trackers/d3d1x/d3dapi/d3d10_1.idl        |  191 ++
>  .../state_trackers/d3d1x/d3dapi/d3d10misc.h        |   47 +
>  .../state_trackers/d3d1x/d3dapi/d3d10shader.idl    |  269 +++
>  src/gallium/state_trackers/d3d1x/d3dapi/d3d11.idl  | 2492 ++++++++++++++++++++
>  .../state_trackers/d3d1x/d3dapi/d3d11shader.idl    |  287 +++
>  .../state_trackers/d3d1x/d3dapi/d3dcommon.idl      |  700 ++++++
>  src/gallium/state_trackers/d3d1x/d3dapi/dxgi.idl   |  470 ++++
>  .../state_trackers/d3d1x/d3dapi/dxgiformat.idl     |  129 +
>  .../state_trackers/d3d1x/d3dapi/dxgitype.idl       |   84 +
>  .../state_trackers/d3d1x/d3dapi/specstrings.h      |   25 +
>  src/gallium/state_trackers/d3d1x/docs/Makefile     |    4 +
>  .../state_trackers/d3d1x/docs/coding_style.txt     |   85 +
>  .../d3d1x/docs/module_dependencies.dot             |   25 +
>  .../state_trackers/d3d1x/docs/source_layout.txt    |   17 +
>  src/gallium/state_trackers/d3d1x/dxgi/Makefile     |   17 +
>  .../state_trackers/d3d1x/dxgi/src/dxgi_loader.cpp  |  206 ++
>  .../state_trackers/d3d1x/dxgi/src/dxgi_native.cpp  | 1314 +++++++++++
>  .../state_trackers/d3d1x/dxgi/src/dxgi_private.h   |   50 +
>  .../state_trackers/d3d1x/dxgid3d10/Makefile        |    4 +
>  .../state_trackers/d3d1x/dxgid3d10/dxgid3d10.cpp   |  149 ++
>  .../state_trackers/d3d1x/dxgid3d11/Makefile        |    4 +
>  .../state_trackers/d3d1x/dxgid3d11/dxgid3d11.cpp   |  135 ++
>  src/gallium/state_trackers/d3d1x/gd3d10/Makefile   |   19 +
>  src/gallium/state_trackers/d3d1x/gd3d10/d3d10.pl   |   12 +
>  src/gallium/state_trackers/d3d1x/gd3d11/Makefile   |    6 +
>  src/gallium/state_trackers/d3d1x/gd3d11/d3d11.cpp  |  236 ++
>  .../state_trackers/d3d1x/gd3d11/d3d11_context.h    | 2033 ++++++++++++++++
>  .../state_trackers/d3d1x/gd3d11/d3d11_objects.h    |  715 ++++++
>  .../state_trackers/d3d1x/gd3d11/d3d11_screen.h     | 1447 ++++++++++++
>  src/gallium/state_trackers/d3d1x/gd3d1x/Makefile   |    6 +
>  .../state_trackers/d3d1x/gd3d1x/d3d1x_private.h    |  101 +
>  .../state_trackers/d3d1x/gd3d1x/d3d_enums.cpp      |  147 ++
>  .../d3d1x/gd3d1x/tools/dxbc2tgsi.cpp               |   82 +
>  .../state_trackers/d3d1x/gd3d1x/tpf_to_tgsi.cpp    |  832 +++++++
>  .../state_trackers/d3d1x/gd3d1x/tpf_to_tgsi.h      |   34 +
>  src/gallium/state_trackers/d3d1x/gd3dapi/Makefile  |    4 +
>  .../state_trackers/d3d1x/gd3dapi/galliumcom.idl    |   76 +
>  .../d3d1x/gd3dapi/galliumd3d10_1.idl               |   30 +
>  .../state_trackers/d3d1x/gd3dapi/galliumd3d11.idl  |   31 +
>  .../state_trackers/d3d1x/gd3dapi/galliumdxgi.idl   |   77 +
>  .../state_trackers/d3d1x/mstools/download-mstools  |   73 +
>  src/gallium/state_trackers/d3d1x/progs/Makefile    |   32 +
>  .../state_trackers/d3d1x/progs/bin/d3d10tri.exe    |  Bin 0 -> 11776 bytes
>  .../state_trackers/d3d1x/progs/bin/d3d11gears.exe  |  Bin 0 -> 27136 bytes
>  .../d3d1x/progs/bin/d3d11spikysphere.exe           |  Bin 0 -> 17408 bytes
>  .../state_trackers/d3d1x/progs/bin/d3d11tex.exe    |  Bin 0 -> 22016 bytes
>  .../state_trackers/d3d1x/progs/bin/d3d11tri.exe    |  Bin 0 -> 11776 bytes
>  .../state_trackers/d3d1x/progs/d3d10app/d3d10app.h |   51 +
>  .../d3d1x/progs/d3d10app/d3d10winmain.cpp          |  188 ++
>  .../d3d1x/progs/d3d10app/d3d10x11main.cpp          |  164 ++
>  .../d3d1x/progs/d3d10tri/d3d10tri.cpp              |  118 +
>  .../d3d1x/progs/d3d10tri/d3d10tri.hlsl             |   50 +
>  .../d3d1x/progs/d3d10tri/d3d10tri.hlsl.ps.h        |  112 +
>  .../d3d1x/progs/d3d10tri/d3d10tri.hlsl.vs.h        |  128 +
>  .../d3d1x/progs/d3d10tri/d3d10tri.vcxproj          |   98 +
>  .../state_trackers/d3d1x/progs/d3d11app/d3d11app.h |   51 +
>  .../d3d1x/progs/d3d11app/d3d11blit.hlsl            |   53 +
>  .../d3d1x/progs/d3d11app/d3d11blit.hlsl.ps.h       |  142 ++
>  .../d3d1x/progs/d3d11app/d3d11blit.hlsl.vs.h       |  130 +
>  .../state_trackers/d3d1x/progs/d3d11app/d3d11u.h   |  424 ++++
>  .../d3d1x/progs/d3d11app/d3d11winmain.cpp          |  172 ++
>  .../d3d1x/progs/d3d11app/d3d11x11main.cpp          |  124 +
>  .../d3d1x/progs/d3d11gears/d3d11gears.cpp          |  573 +++++
>  .../d3d1x/progs/d3d11gears/d3d11gears.hlsl         |   75 +
>  .../d3d1x/progs/d3d11gears/d3d11gears.hlsl.ps.h    |  309 +++
>  .../d3d1x/progs/d3d11gears/d3d11gears.hlsl.vs.h    |  308 +++
>  .../d3d1x/progs/d3d11gears/d3d11gears.vcxproj      |  100 +
>  .../progs/d3d11spikysphere/d3d11spikysphere.cpp    |  227 ++
>  .../progs/d3d11spikysphere/d3d11spikysphere.hlsl   |  193 ++
>  .../d3d11spikysphere/d3d11spikysphere.hlsl.ds.h    |  623 +++++
>  .../d3d11spikysphere/d3d11spikysphere.hlsl.hs.h    |  297 +++
>  .../d3d11spikysphere/d3d11spikysphere.hlsl.ps.h    |  211 ++
>  .../d3d11spikysphere/d3d11spikysphere.hlsl.vs.h    |  105 +
>  .../d3d11spikysphere/d3d11spikysphere.vcxproj      |  102 +
>  .../d3d1x/progs/d3d11tex/d3d11tex.cpp              |  116 +
>  .../d3d1x/progs/d3d11tex/d3d11tex.hlsl             |   66 +
>  .../d3d1x/progs/d3d11tex/d3d11tex.hlsl.ps.h        |  234 ++
>  .../d3d1x/progs/d3d11tex/d3d11tex.hlsl.vs.h        |  153 ++
>  .../d3d1x/progs/d3d11tex/d3d11tex.vcxproj          |   98 +
>  .../d3d1x/progs/d3d11tri/d3d11tri.cpp              |  120 +
>  .../d3d1x/progs/d3d11tri/d3d11tri.hlsl             |   50 +
>  .../d3d1x/progs/d3d11tri/d3d11tri.hlsl.ps.h        |  112 +
>  .../d3d1x/progs/d3d11tri/d3d11tri.hlsl.vs.h        |  128 +
>  .../d3d1x/progs/d3d11tri/d3d11tri.vcxproj          |   99 +
>  .../d3d1x/progs/data/cornell_box_image.h           | 1028 ++++++++
>  .../state_trackers/d3d1x/progs/data/tux_image.h    | 1028 ++++++++
>  src/gallium/state_trackers/d3d1x/progs/progs.sln   |   49 +
>  src/gallium/state_trackers/d3d1x/tools/fxc         |   16 +
>  src/gallium/state_trackers/d3d1x/w32api            |    1 +
>  108 files changed, 26335 insertions(+), 0 deletions(-)
>
> Diff:   http://cgit.freedesktop.org/mesa/mesa/diff/?id=e80d59faaa410bfc78af64204bc4055b837c7fad
> _______________________________________________
> mesa-commit mailing list
> mesa-commit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-commit
>


More information about the mesa-dev mailing list