HLSL to GLSL language translator based on ATI's HLSL2GLSL. Used in Unity.
Перейти к файлу
Aras Pranckevicius dd3f8f52e2 docs: include bitsquid into authors 2012-09-26 19:25:47 +03:00
OGLCompilersDLL Added support to specify allocation functions for global allocation, instead of using default new/delete. 2012-03-30 20:01:38 +02:00
hlslang hand-merge from https://github.com/jims/hlsl2glslfork 2012-09-26 19:25:29 +03:00
hlslang.xcodeproj hand-merge from https://github.com/jims/hlsl2glslfork 2012-09-26 19:25:29 +03:00
include Fixed support to emit OS X 10.6 Snow Leopard compatible glsl 1.20 2012-09-11 11:59:56 +02:00
tests hand-merge from https://github.com/jims/hlsl2glslfork 2012-09-26 19:25:29 +03:00
tools initial hlsl2glsl from ATI 2010-02-23 14:26:22 +02:00
.gitignore Hide workspace-whiz project database files from git 2011-12-19 19:06:45 -05:00
CMakeLists.txt linux: cmake fixes 2011-08-16 16:36:32 +03:00
LICENSE.txt docs: include bitsquid into authors 2012-09-26 19:25:47 +03:00
README.md hand-merge from https://github.com/jims/hlsl2glslfork 2012-09-26 19:25:29 +03:00
hlslang.sln Added x64 build targets and disambiguated the build output directories for each. 2011-12-19 18:40:05 -05:00
hlslang.vcproj hand-merge from https://github.com/jims/hlsl2glslfork 2012-09-26 19:25:29 +03:00

README.md

HLSL to GLSL shader language translator

DX9 style HLSL in, GLSL / GLSL ES out.

A continued development from ATI's HLSL2GLSL. I'm changing it to make it work for Unity's use cases; might totally not work for yours!

For an opposite tool (GLSL ES to HLSL translator), look at Google's ANGLE.

Changes from original HLSL2GLSL 0.9

  • Made it build with VS2008 on Windows and XCode 3.2 on Mac. Build as static library.
  • Feature to produce OpenGL ES-like precision specifiers (fixed/half/float -> lowp/mediump/highp)
  • Fixes to ternary vector selection (float4 ? float4 : float4)
  • Fixes to bool->float promotion in arithmetic ops
  • Fixes to matrix constructors & indexing (GLSL is transposed in regards to HLSL)
  • Support clip()
  • Support Cg-like samplerRECT, texRECT, texRECTproj
  • Support VPOS and VFACE semantics
  • Fix various crashes & infinite loops, mostly on shaders with errors
  • Cleaner and more deterministic generated GLSL output
  • Unit testing suite
  • Simplified interface, code cleanup, unused code removal, merge copy-n-pasted code, simplify implementation etc.
  • Added support for emission of const initializers (including struct and array initializers using GLSL 1.20 array syntax).
  • Removed all constant folding functionality as it was completely broken.
  • A myriad of smaller bug fixes.
  • Support DX10 SV_VertexID, SV_PrimitiveID and SV_InstanceID semantics.
  • Support for shadow sampler types (samplerRECTShadow/sampler2DShadow etc.) which generate appropriate shadow2DRect/shadow2D etc. calls.
  • Fixed unaligned swizzled matrix access & assignments (view._m01_m02_m33 = value)

Notes

  • Only Direct3D 9 style HLSL is supported. No Direct3D 10/11 "template like" syntax, no geometry/tesselation/compute shaders, no abstract interfaces.
  • I bumped into some issues of HLSL2GLSL's preprocessor that I am not fixing. Most issues were with token pasting operator. So I preprocess source using mojoshader's preprocessor. Grab latest from mojoshader hg, it's awesome!
  • On Windows, the library is built with _HAS_ITERATOR_DEBUGGING=0,_SECURE_SCL=0 defines, which affect MSVC's STL behavior. If this does not match defines in your application, totally strange things can start to happen!
  • The library is not currently thread-safe.

Status

Used in Unity and bitsquid engine, and seems to work quite ok.

Support for DX11 features will probably not be added due to the bad condition the original code is in (very obscure and inefficient), instead maybe a new cross-compiler will be made.

No optimizations are performed on the generated GLSL, so it is expected that your platform will have a decent GLSL compiler. Or, use GLSL Optimizer, at Unity we use it to optimize shaders produced by HLSL2GLSL; gives a substantial performance boost on mobile platforms.